Re: [PATCH v2 2/2] leds: class: Reinitialise list after dropping from lookup table
From: Andy Shevchenko
Date: Thu Apr 09 2026 - 12:01:08 EST
On Thu, Apr 09, 2026 at 04:52:32PM +0100, Lee Jones wrote:
> On Tue, 31 Mar 2026, Andy Shevchenko wrote:
>
> > Currently the lookup table just removes the list entry and leaves
> > the stale pointers in it. If the lookup is embedded in some data
> > structure, the pointer to the lookup entry can't be NULL (always
> > valid), but calling led_remove_lookup() on it twice will lead to
> > the wrong behaviour. To avoid that the user has to track the state
> > itself. With this change in place, the user may drop that approach
> > and use something like
> >
> > probe:
> > INIT_LIST_HEAD(&lookup.list);
> > if (LED lookup is required)
> > led_add_lookup(&lookup);
> >
> > remove:
> > led_remove_lookup(&lookup);
>
> How do we feel about a devm_led_add_lookup()?
No strong opinion. If we have that already, great! This patch won't be needed.
If not yet, we may add one, but briefly looking at the kernel I have not found
any other framework doing that.
In any case the user that would need this patch has been already modified the
way that lookup is always there, effectively means we may postpone or even drop
this patch for now.
> > without any additional tracking kept over the device lifetime.
--
With Best Regards,
Andy Shevchenko