Re: [PATCH] gpio: sysfs: use const APIs for legacy sysfs attributes

From: Thomas Weißschuh

Date: Wed Oct 21 2026 - 08:31:49 EST


On Wed, Oct 21, 2026 at 01:17:54PM +0200, Thomas Weißschuh wrote:
> On Wed, Oct 21, 2026 at 12:47:25PM +0200, Bartosz Golaszewski wrote:
> > Replace the deprecated non-const sysfs attribute APIs with modern const
> > variants where applicable. This leaves out the attributes embedded in
> > struct gpiod_data as this structure contains fields that are modified at
> > run-time.
>
> Leaving the dynamically allocated attributes with non-const signatures will
> make it harder to remove the non-const APIs later on.
> Would it be possible to switch those to const signatures, too and cast away
> the constness in the store handlers?
> I see that this is a legacy interface anyways, which might be gone by the
> time we want to remove the non-const APIs. But that applies to the
> currently proposed changes, too.

If I understand correctly, the dynamically allocated attributes are only
necessary to retreive 'struct gpiod_data' in the attribute registered on the
*parent*. Those registered on the gpio device itself can just use dev_get_drvdata().
Instead of registering the 'direction' and 'value' attributes on the parent,
you could use symlinks pointing to the child attributes instead.
This would make the code a whole lot simpler.

Currently it is not possible to create symlinks to sysfs attributes, but I have
simple patch for that locally. Let me know if you are interested.


Thomas

(...)