[openwrt/openwrt] mediatek: leds-smartrg: use devm_mutex_init

LEDE Commits lede-commits at lists.infradead.org
Sat Oct 19 10:21:00 PDT 2024


hauke pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/0dfe1e876a0704216215312ae4be6875d2378170

commit 0dfe1e876a0704216215312ae4be6875d2378170
Author: Rosen Penev <rosenp at gmail.com>
AuthorDate: Tue Oct 8 16:37:08 2024 -0700

    mediatek: leds-smartrg: use devm_mutex_init
    
    No longer need normal _remove function. Replaced with _disable.
    
    Signed-off-by: Rosen Penev <rosenp at gmail.com>
    Link: https://github.com/openwrt/openwrt/pull/16651
    Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
 .../mediatek/files/drivers/leds/leds-smartrg-system.c    | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/target/linux/mediatek/files/drivers/leds/leds-smartrg-system.c b/target/linux/mediatek/files/drivers/leds/leds-smartrg-system.c
index 5e1e3a3542..385f85d6da 100644
--- a/target/linux/mediatek/files/drivers/leds/leds-smartrg-system.c
+++ b/target/linux/mediatek/files/drivers/leds/leds-smartrg-system.c
@@ -163,6 +163,7 @@ srg_led_probe(struct i2c_client *client)
 {
 	struct device_node *np = client->dev.of_node, *child;
 	struct srg_led_ctrl *sysled_ctrl;
+	int err;
 
 	sysled_ctrl = devm_kzalloc(&client->dev, sizeof(*sysled_ctrl), GFP_KERNEL);
 	if (!sysled_ctrl)
@@ -170,7 +171,9 @@ srg_led_probe(struct i2c_client *client)
 
 	sysled_ctrl->client = client;
 
-	mutex_init(&sysled_ctrl->lock);
+	err = devm_mutex_init(&client->dev, &sysled_ctrl->lock);
+	if (err)
+		return err;
 
 	i2c_set_clientdata(client, sysled_ctrl);
 
@@ -193,15 +196,6 @@ static void srg_led_disable(struct i2c_client *client)
 		srg_led_i2c_write(sysled_ctrl, i, 0);
 }
 
-static void
-srg_led_remove(struct i2c_client *client)
-{
-	struct srg_led_ctrl *sysled_ctrl = i2c_get_clientdata(client);
-
-	srg_led_disable(client);
-	mutex_destroy(&sysled_ctrl->lock);
-}
-
 static const struct i2c_device_id srg_led_id[] = {
 	{ "srg-sysled", 0 },
 	{ }
@@ -220,7 +214,7 @@ static struct i2c_driver srg_sysled_driver = {
 		.of_match_table = of_srg_led_match,
 	},
 	.probe		= srg_led_probe,
-	.remove		= srg_led_remove,
+	.remove		= srg_led_disable,
 	.id_table	= srg_led_id,
 };
 module_i2c_driver(srg_sysled_driver);




More information about the lede-commits mailing list