Re: [PATCH v3 07/10] gpio: aggregator: export symbols of the GPIO forwarder library

Andy Shevchenko
2025-04-17T17:34:48Z

On Wed, Apr 16, 2025 at 04:08:15PM +0200, Thomas Richard wrote:
> Export all symbols and create header file for the GPIO forwarder library.

...

> -struct gpiochip_fwd_timing {
> - u32 ramp_up_us;
> - u32 ramp_down_us;
> -};
> -
> -struct gpiochip_fwd {
> - struct gpio_chip chip;
> - struct gpio_desc **descs;
> - union {
> - struct mutex mlock; /* protects tmp[] if can_sleep */
> - spinlock_t slock; /* protects tmp[] if !can_sleep */
> - };
> - struct gpiochip_fwd_timing *delay_timings;
> - unsigned long tmp[]; /* values and descs for multiple ops */
> -};

I don't like this piece at all. It will repeat one of the biggest mistake done
with many (old) subsystems and core.

Looking at the last patch ahead, I can tell that this is not needed. Instead
add a couple of APIs:
- getter for the gpiochip
- getter for the specific private data

and use the error code filtering for the existed GPIO descriptor, I actually
don't understand why for the existed descriptor you return there 0 and not an
error.

TL;DR: Follow OOP and make this an opaque pointer, no need to move it to the
header. The rest looks okay on the first glance.

--
With Best Regards,
Andy Shevchenko