gpio: aggregator: refactor the forwarder registration part
Add a new function gpiochip_fwd_register(), which finalizes the initialization of the forwarder and registers the corresponding gpiochip. Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> 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-4-29f0cbbdfb30@bootlin.com Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
This commit is contained in:
committed by
Bartosz Golaszewski
parent
c44ce91b8a
commit
10d022efe2
@@ -538,6 +538,18 @@ static int gpiochip_fwd_desc_add(struct gpiochip_fwd *fwd,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gpiochip_fwd_register(struct gpiochip_fwd *fwd)
|
||||
{
|
||||
struct gpio_chip *chip = &fwd->chip;
|
||||
|
||||
if (chip->can_sleep)
|
||||
mutex_init(&fwd->mlock);
|
||||
else
|
||||
spin_lock_init(&fwd->slock);
|
||||
|
||||
return devm_gpiochip_add_data(chip->parent, chip, fwd);
|
||||
}
|
||||
|
||||
/**
|
||||
* gpiochip_fwd_create() - Create a new GPIO forwarder
|
||||
* @dev: Parent device pointer
|
||||
@@ -575,18 +587,13 @@ static struct gpiochip_fwd *gpiochip_fwd_create(struct device *dev,
|
||||
return ERR_PTR(error);
|
||||
}
|
||||
|
||||
if (chip->can_sleep)
|
||||
mutex_init(&fwd->mlock);
|
||||
else
|
||||
spin_lock_init(&fwd->slock);
|
||||
|
||||
if (features & FWD_FEATURE_DELAY) {
|
||||
error = gpiochip_fwd_setup_delay_line(dev, chip, fwd);
|
||||
if (error)
|
||||
return ERR_PTR(error);
|
||||
}
|
||||
|
||||
error = devm_gpiochip_add_data(dev, chip, fwd);
|
||||
error = gpiochip_fwd_register(fwd);
|
||||
if (error)
|
||||
return ERR_PTR(error);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user