Re: [PATCH v3] leds: lp5860: Fix LED teardown ordering using devm_add_action_or_reset()
| Newsgroups | org.kernel.vger.linux-leds |
|---|---|
| Message-ID | <[email protected]> |
> From: Surendra Singh Chouhan <[email protected]> > > 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 <[email protected]> Sashiko has reviewed this patch and found no issues. It looks great! -- Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1