Re: [PATCH] [v2] leds: gpio: make legacy gpiolib interface optional
From: Arnd Bergmann
Date: Tue May 05 2026 - 10:21:48 EST
On Tue, May 5, 2026, at 15:25, Andy Shevchenko wrote:
> On Tue, May 05, 2026 at 04:19:36PM +0300, Andy Shevchenko wrote:
>> On Tue, May 05, 2026 at 03:10:28PM +0200, Arnd Bergmann wrote:
>> > On Mon, May 4, 2026, at 09:31, Andy Shevchenko wrote:
>> > struct gpio_desc *gpiod;
>> >
>> > gpiod = devm_gpiod_get_index_optional(dev, NULL, idx, GPIOD_OUT_LOW);
>>
>> > if (gpiod && !IS_ERR(gpiod));
>>
>> And this is not needed. The below is NULL-aware.
>
> To be clear
>
> struct gpio_desc *gpiod;
>
> gpiod = devm_gpiod_get_index_optional(dev, NULL, idx, GPIOD_OUT_LOW);
> if (!IS_ERR(gpiod))
> gpiod_set_consumer_name(gpiod, template->name);
>
> return gpiod;
>
> But looking at the original code, I would leave another return, so
Right, I actually had this at first, but decided to keep the NULL
check because that was used in the driver already.
I've dropped it again now.
>> > gpiod = devm_gpiod_get_index_optional(dev, template->name, i, GPIOD_OUT_LOW);
>> >
>> > Did I get that right? If so, I'll fold that in as another
>
> Nope, the con_id != consumer name. Can't be done this way.
I see. I had tried to find an existing interface that sets
the consumer name and saw that gpiod_get_index() internally
uses con_id as the label if set, but I missed that this would
break the actual lookup in gpio_desc_table_match() because the
13 lookup tables are of course all defined by index rather than
by name.
Arnd