mediatek: leds-smartrg: use devm_mutex_init
authorRosen Penev <rosenp@gmail.com>
Tue, 8 Oct 2024 23:37:08 +0000 (16:37 -0700)
committerHauke Mehrtens <hauke@hauke-m.de>
Sat, 19 Oct 2024 17:19:38 +0000 (19:19 +0200)
No longer need normal _remove function. Replaced with _disable.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/16651
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
target/linux/mediatek/files/drivers/leds/leds-smartrg-system.c

index 5e1e3a3542463792f6c533870456110e319e5c50..385f85d6da0ee04a4c55a84b2b4edc8cd34317b6 100644 (file)
@@ -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);