Re: [PATCH v3] leds: lp5860: Fix LED teardown ordering using devm_add_action_or_reset()

From: Lee Jones

Date: Thu Aug 27 2026 - 12:22:01 EST


On Wed, 12 Aug 2026, kr494167@xxxxxxxxx wrote:

> From: Surendra Singh Chouhan <kr494167@xxxxxxxxx>
>
> The driver previously disabled the chip in its remove callback before
> devres unregistered the LEDs. LED unregistration turns the LEDs off
> through the driver brightness callback, which accessed disabled hardware.
>
> Fix this by registering a devm action via devm_add_action_or_reset()
> immediately after enabling the chip in lp5860_device_init(). Due to devm
> LIFO (Last-In, First-Out) teardown ordering, devm will automatically
> unregister all multicolor LEDs before the devm action disables the chip.
>
> In addition, use scoped_guard(mutex, &lp->lock) to restrict the initial
> mode setting lock scope, avoiding holding the mutex across
> lp5860_init_dt(), which would cause a self-deadlock when registering
> subleds.
>
> Finally, convert mutex_init() to devm_mutex_init() and declare the local
> variable ret in lp5860_probe(), allowing lp5860_device_remove() and
> lp5860_remove() to be removed completely.
>
> Fixes: f0a66563aa2d ("leds: Add support for TI LP5860 LED driver chip")
> Signed-off-by: Surendra Singh Chouhan <kr494167@xxxxxxxxx>
> ---
> v3:
> - Use scoped_guard(mutex, &lp->lock) in lp5860_device_init() so the lock is released before calling lp5860_init_dt(), preventing a self-deadlock during subled registration.
> - Declare missing local variable 'ret' in lp5860_probe().
> - Capitalize patch title per LED subsystem guidelines.
>
> v2:
> - Use full name "Surendra Singh Chouhan" in From header and Signed-off-by.
> - Convert chip disable sequence to devm_add_action_or_reset() as suggested by Lee Jones.
> - Use devm_mutex_init() for lock initialization.
>
> drivers/leds/rgb/leds-lp5860-core.c | 42 +++++++++++++----------------
> drivers/leds/rgb/leds-lp5860-spi.c | 15 +++--------
> drivers/leds/rgb/leds-lp5860.h | 1 -
> 3 files changed, 22 insertions(+), 36 deletions(-)

This no longer applies.

Please rebase onto -next or my LEDs tree and resubmit with my:

Acked-by: Lee Jones <lee@xxxxxxxxxx>

--
Lee Jones