public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org,
	Pavel Machek <pavel@kernel.org>
Subject: Re: [PATCH v2 2/2] leds: class: Reinitialise list after dropping from lookup table
Date: Thu, 9 Apr 2026 16:52:32 +0100	[thread overview]
Message-ID: <20260409155232.GA3439476@google.com> (raw)
In-Reply-To: <20260331183055.1209526-3-andriy.shevchenko@linux.intel.com>

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()?

> without any additional tracking kept over the device lifetime.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/leds/led-class.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
> index b53ebe3a0faa..424c07e0ecce 100644
> --- a/drivers/leds/led-class.c
> +++ b/drivers/leds/led-class.c
> @@ -425,7 +425,7 @@ void led_remove_lookup(struct led_lookup_data *led_lookup)
>  		return;
>  
>  	mutex_lock(&leds_lookup_lock);
> -	list_del(&led_lookup->list);
> +	list_del_init(&led_lookup->list);
>  	mutex_unlock(&leds_lookup_lock);
>  }
>  EXPORT_SYMBOL_GPL(led_remove_lookup);
> -- 
> 2.50.1
> 

-- 
Lee Jones [李琼斯]

  reply	other threads:[~2026-04-09 15:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-31 18:28 [PATCH v2 0/2] leds: class: improve led_remove_lookup() Andy Shevchenko
2026-03-31 18:28 ` [PATCH v2 1/2] leds: class: Make led_remove_lookup() NULL-aware Andy Shevchenko
2026-03-31 18:28 ` [PATCH v2 2/2] leds: class: Reinitialise list after dropping from lookup table Andy Shevchenko
2026-04-09 15:52   ` Lee Jones [this message]
2026-04-09 16:00     ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260409155232.GA3439476@google.com \
    --to=lee@kernel.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=pavel@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox