leds: lp5860-spi: Fix an error handling path

If lp5860_device_init() fails, a missing mutex_destroy() should be called.

Use devm_mutex_init() instead of mutex_init() to fix it.
This also simplifies the remove function.

Fixes: f0a66563aa ("leds: Add support for TI LP5860 LED driver chip")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://patch.msgid.link/311792e767ab803d4744bc26155e6dac253d9b45.1781970783.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Lee Jones <lee@kernel.org>
This commit is contained in:
Christophe JAILLET 2026-06-20 17:53:22 +02:00 committed by Lee Jones
parent 10a5a70c02
commit f647a22662

View File

@ -38,6 +38,7 @@ static int lp5860_probe(struct spi_device *spi)
struct device *dev = &spi->dev;
struct lp5860 *lp5860;
unsigned int multi_leds;
int ret;
multi_leds = device_get_child_node_count(dev);
if (!multi_leds) {
@ -61,7 +62,10 @@ static int lp5860_probe(struct spi_device *spi)
"Failed to initialise Regmap.\n");
lp5860->dev = dev;
mutex_init(&lp5860->lock);
ret = devm_mutex_init(dev, &lp5860->lock);
if (ret)
return ret;
spi_set_drvdata(spi, lp5860);
@ -70,10 +74,6 @@ static int lp5860_probe(struct spi_device *spi)
static void lp5860_remove(struct spi_device *spi)
{
struct lp5860 *lp5860 = spi_get_drvdata(spi);
mutex_destroy(&lp5860->lock);
lp5860_device_remove(&spi->dev);
}