Re: [PATCH v2 04/10] gpio: aggregator: add read-write 'name' attribute
From: Koichiro Den
Date: Thu Feb 13 2025 - 09:18:30 EST
On Wed, Feb 12, 2025 at 03:27:50PM GMT, Geert Uytterhoeven wrote:
> Hi Den,
>
> On Mon, 3 Feb 2025 at 04:12, Koichiro Den <koichiro.den@xxxxxxxxxxxxx> wrote:
> > Previously, there is no way to assign names to GPIO lines exported
> > through an aggregator.
> >
> > Allow users to set custom line names via a 'name' attribute.
> >
> > Signed-off-by: Koichiro Den <koichiro.den@xxxxxxxxxxxxx>
>
> Thanks for your patch!
>
> > --- a/drivers/gpio/gpio-aggregator.c
> > +++ b/drivers/gpio/gpio-aggregator.c
> > @@ -63,6 +63,8 @@ struct gpio_aggregator_line {
> > /* Line index within the aggregator device */
> > int idx;
> >
> > + /* Custom name for the virtual line */
> > + char *name;
>
> This can be const.
Will fix in v3.
>
> > /* GPIO chip label or line name */
> > char *key;
>
> Actually this can be const, too.
Will fix in v3.
>
> > /* Can be negative to indicate lookup by line name */
> > @@ -678,6 +680,44 @@ gpio_aggr_line_key_store(struct config_item *item, const char *page,
> >
> > CONFIGFS_ATTR(gpio_aggr_line_, key);
> >
> > +static ssize_t
> > +gpio_aggr_line_name_show(struct config_item *item, char *page)
> > +{
> > + struct gpio_aggregator_line *line = to_gpio_aggregator_line(item);
> > + struct gpio_aggregator *aggr = line->parent;
> > +
> > + guard(mutex)(&aggr->lock);
> > +
> > + return sprintf(page, "%s\n", line->name ?: "");
>
> sysfs_emit()
Will fix in v3.
Thanks!
Koichiro
>
> > +}
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
> -- Linus Torvalds