Re: [PATCH v2 04/10] gpio: aggregator: add read-write 'name' attribute

From: Geert Uytterhoeven
Date: Wed Feb 12 2025 - 09:28:35 EST


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.

> /* GPIO chip label or line name */
> char *key;

Actually this can be const, too.

> /* 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()

> +}
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