[openwrt/openwrt] kernel: ubnt-ledbar: use devm_mutex_init
LEDE Commits
lede-commits at lists.infradead.org
Tue Oct 8 10:21:47 PDT 2024
robimarko pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/3483f63c563298186b351111d6b8ec06b935ba4d
commit 3483f63c563298186b351111d6b8ec06b935ba4d
Author: Rosen Penev <rosenp at gmail.com>
AuthorDate: Fri Oct 4 13:27:26 2024 -0700
kernel: ubnt-ledbar: use devm_mutex_init
Allows remove the _remove function as devm calls mutex_destroy
automatically.
Signed-off-by: Rosen Penev <rosenp at gmail.com>
Link: https://github.com/openwrt/openwrt/pull/16615
Signed-off-by: Robert Marko <robimarko at gmail.com>
---
package/kernel/ubnt-ledbar/src/leds-ubnt-ledbar.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/package/kernel/ubnt-ledbar/src/leds-ubnt-ledbar.c b/package/kernel/ubnt-ledbar/src/leds-ubnt-ledbar.c
index 52b33ef43d..9fb52b4b3a 100644
--- a/package/kernel/ubnt-ledbar/src/leds-ubnt-ledbar.c
+++ b/package/kernel/ubnt-ledbar/src/leds-ubnt-ledbar.c
@@ -164,6 +164,7 @@ static int ubnt_ledbar_probe(struct i2c_client *client)
{
struct device_node *np = client->dev.of_node;
struct ubnt_ledbar *ledbar;
+ int err;
ledbar = devm_kzalloc(&client->dev, sizeof(*ledbar), GFP_KERNEL);
if (!ledbar)
@@ -184,7 +185,9 @@ static int ubnt_ledbar_probe(struct i2c_client *client)
ledbar->client = client;
- mutex_init(&ledbar->lock);
+ err = devm_mutex_init(&ofdev->dev, &ledbar->lock);
+ if (err)
+ return err;
i2c_set_clientdata(client, ledbar);
@@ -203,13 +206,6 @@ static int ubnt_ledbar_probe(struct i2c_client *client)
return ubnt_ledbar_apply_state(ledbar);
}
-static void ubnt_ledbar_remove(struct i2c_client *client)
-{
- struct ubnt_ledbar *ledbar = i2c_get_clientdata(client);
-
- mutex_destroy(&ledbar->lock);
-}
-
static const struct i2c_device_id ubnt_ledbar_id[] = {
{ "ubnt-ledbar", 0 },
{ }
@@ -228,7 +224,6 @@ static struct i2c_driver ubnt_ledbar_driver = {
.of_match_table = of_ubnt_ledbar_match,
},
.probe = ubnt_ledbar_probe,
- .remove = ubnt_ledbar_remove,
.id_table = ubnt_ledbar_id,
};
module_i2c_driver(ubnt_ledbar_driver);
More information about the lede-commits
mailing list