gpio: aggregator: move GPIO forwarder allocation in a dedicated function
Move the GPIO forwarder allocation and static initialization in a dedicated function. Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Thomas Richard <thomas.richard@bootlin.com> Link: https://lore.kernel.org/r/20250811-aaeon-up-board-pinctrl-support-v9-2-29f0cbbdfb30@bootlin.com Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
This commit is contained in:
committed by
Bartosz Golaszewski
parent
181fe022ec
commit
871c7cd548
@@ -475,6 +475,35 @@ static int gpiochip_fwd_setup_delay_line(struct device *dev, struct gpio_chip *c
|
||||
}
|
||||
#endif /* !CONFIG_OF_GPIO */
|
||||
|
||||
static struct gpiochip_fwd *
|
||||
devm_gpiochip_fwd_alloc(struct device *dev, unsigned int ngpios)
|
||||
{
|
||||
struct gpiochip_fwd *fwd;
|
||||
struct gpio_chip *chip;
|
||||
|
||||
fwd = devm_kzalloc(dev, struct_size(fwd, tmp, fwd_tmp_size(ngpios)), GFP_KERNEL);
|
||||
if (!fwd)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
chip = &fwd->chip;
|
||||
|
||||
chip->label = dev_name(dev);
|
||||
chip->parent = dev;
|
||||
chip->owner = THIS_MODULE;
|
||||
chip->get_direction = gpio_fwd_get_direction;
|
||||
chip->direction_input = gpio_fwd_direction_input;
|
||||
chip->direction_output = gpio_fwd_direction_output;
|
||||
chip->get = gpio_fwd_get;
|
||||
chip->get_multiple = gpio_fwd_get_multiple_locked;
|
||||
chip->set = gpio_fwd_set;
|
||||
chip->set_multiple = gpio_fwd_set_multiple_locked;
|
||||
chip->to_irq = gpio_fwd_to_irq;
|
||||
chip->base = -1;
|
||||
chip->ngpio = ngpios;
|
||||
|
||||
return fwd;
|
||||
}
|
||||
|
||||
/**
|
||||
* gpiochip_fwd_create() - Create a new GPIO forwarder
|
||||
* @dev: Parent device pointer
|
||||
@@ -495,16 +524,14 @@ static struct gpiochip_fwd *gpiochip_fwd_create(struct device *dev,
|
||||
struct gpio_desc *descs[],
|
||||
unsigned long features)
|
||||
{
|
||||
const char *label = dev_name(dev);
|
||||
struct gpiochip_fwd *fwd;
|
||||
struct gpio_chip *chip;
|
||||
unsigned int i;
|
||||
int error;
|
||||
|
||||
fwd = devm_kzalloc(dev, struct_size(fwd, tmp, fwd_tmp_size(ngpios)),
|
||||
GFP_KERNEL);
|
||||
if (!fwd)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
fwd = devm_gpiochip_fwd_alloc(dev, ngpios);
|
||||
if (IS_ERR(fwd))
|
||||
return fwd;
|
||||
|
||||
chip = &fwd->chip;
|
||||
|
||||
@@ -526,19 +553,6 @@ static struct gpiochip_fwd *gpiochip_fwd_create(struct device *dev,
|
||||
chip->set_config = gpio_fwd_set_config;
|
||||
}
|
||||
|
||||
chip->label = label;
|
||||
chip->parent = dev;
|
||||
chip->owner = THIS_MODULE;
|
||||
chip->get_direction = gpio_fwd_get_direction;
|
||||
chip->direction_input = gpio_fwd_direction_input;
|
||||
chip->direction_output = gpio_fwd_direction_output;
|
||||
chip->get = gpio_fwd_get;
|
||||
chip->get_multiple = gpio_fwd_get_multiple_locked;
|
||||
chip->set = gpio_fwd_set;
|
||||
chip->set_multiple = gpio_fwd_set_multiple_locked;
|
||||
chip->to_irq = gpio_fwd_to_irq;
|
||||
chip->base = -1;
|
||||
chip->ngpio = ngpios;
|
||||
fwd->descs = descs;
|
||||
|
||||
if (chip->can_sleep)
|
||||
|
||||
Reference in New Issue
Block a user