[openwrt/openwrt] kernel: ws2812b: use devm for mutex_init
LEDE Commits
lede-commits at lists.infradead.org
Sun Oct 6 03:21:58 PDT 2024
robimarko pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/5ee75b6bb2fbdf2438aa94d9df92b7d76650e633
commit 5ee75b6bb2fbdf2438aa94d9df92b7d76650e633
Author: Rosen Penev <rosenp at gmail.com>
AuthorDate: Thu Oct 3 13:20:30 2024 -0700
kernel: ws2812b: use devm for mutex_init
Allows removal of _remove function.
Signed-off-by: Rosen Penev <rosenp at gmail.com>
Link: https://github.com/openwrt/openwrt/pull/16587
Signed-off-by: Robert Marko <robimarko at gmail.com>
---
package/kernel/leds-ws2812b/src/leds-ws2812b.c | 23 +++++++----------------
1 file changed, 7 insertions(+), 16 deletions(-)
diff --git a/package/kernel/leds-ws2812b/src/leds-ws2812b.c b/package/kernel/leds-ws2812b/src/leds-ws2812b.c
index d061ee9dce..3f26664913 100644
--- a/package/kernel/leds-ws2812b/src/leds-ws2812b.c
+++ b/package/kernel/leds-ws2812b/src/leds-ws2812b.c
@@ -124,7 +124,10 @@ static int ws2812b_probe(struct spi_device *spi)
for (i = 0; i < num_leds * WS2812B_NUM_COLORS; i++)
ws2812b_set_byte(priv, i, 0);
- mutex_init(&priv->mutex);
+ ret = devm_mutex_init(dev, &priv->mutex);
+ if (ret)
+ return ret;
+
priv->num_leds = num_leds;
priv->spi = spi;
@@ -144,13 +147,12 @@ static int ws2812b_probe(struct spi_device *spi)
if (ret) {
dev_err(dev, "failed to obtain numerical LED index for %s",
fwnode_get_name(led_node));
- goto ERR_UNREG_LEDS;
+ return ret;
}
if (cascade >= num_leds) {
dev_err(dev, "LED index of %s is larger than the number of LEDs.",
fwnode_get_name(led_node));
- ret = -EINVAL;
- goto ERR_UNREG_LEDS;
+ return -EINVAL;
}
cnt = fwnode_property_count_u32(led_node, "color-index");
@@ -176,7 +178,7 @@ static int ws2812b_probe(struct spi_device *spi)
if (ret) {
dev_err(dev, "registration of %s failed.",
fwnode_get_name(led_node));
- goto ERR_UNREG_LEDS;
+ return ret;
}
cur_led++;
}
@@ -184,16 +186,6 @@ static int ws2812b_probe(struct spi_device *spi)
spi_set_drvdata(spi, priv);
return 0;
-ERR_UNREG_LEDS:
- mutex_destroy(&priv->mutex);
- return ret;
-}
-
-static void ws2812b_remove(struct spi_device *spi)
-{
- struct ws2812b_priv *priv = spi_get_drvdata(spi);
-
- mutex_destroy(&priv->mutex);
}
static const struct spi_device_id ws2812b_spi_ids[] = {
@@ -210,7 +202,6 @@ MODULE_DEVICE_TABLE(of, ws2812b_dt_ids);
static struct spi_driver ws2812b_driver = {
.probe = ws2812b_probe,
- .remove = ws2812b_remove,
.id_table = ws2812b_spi_ids,
.driver = {
.name = KBUILD_MODNAME,
More information about the lede-commits
mailing list