Re: [PATCH RFC v2 2/6] gpio: aggregator: refactor the forwarder part.
From: Andy Shevchenko
Date: Mon Mar 17 2025 - 13:06:46 EST
On Mon, Mar 17, 2025 at 04:38:00PM +0100, Thomas Richard wrote:
> Prepare the code to create a gpio-fwd library. This library will allow to
> create and register a gpiochip forwarder.
...
> struct gpiochip_fwd {
> + struct device *dev;
> struct gpio_chip chip;
Have you checked the code generation?
Also, is this new pointer the same as chip.parent?
> struct gpio_desc **descs;
> union {
> };
...
> +static struct gpiochip_fwd *devm_gpiochip_fwd_alloc(struct device *dev,
> + unsigned int ngpios)
I would rather split as
static struct gpiochip_fwd *
devm_gpiochip_fwd_alloc(struct device *dev, unsigned int ngpios)
...
> + fwd->descs = devm_kcalloc(dev, ngpios, sizeof(*fwd->descs),
> + GFP_KERNEL);
One line.
...
> +static int gpiochip_fwd_register(struct gpiochip_fwd *fwd)
> +{
> + struct gpio_chip *chip = &fwd->chip;
> + struct device *dev = fwd->dev;
> + int error;
>
> if (chip->can_sleep)
> mutex_init(&fwd->mlock);
> else
> spin_lock_init(&fwd->slock);
>
> + error = devm_gpiochip_add_data(dev, chip, fwd);
> +
> + return error;
return devm_...
> +}
...
Overall it looks and feels like this can be split to more simpler logically
isolated changes. At least I see that folding function parameters can be a
separate patch.
--
With Best Regards,
Andy Shevchenko