Commit a59d8824 authored by George Stark's avatar George Stark Committed by Lee Jones

leds: aw200xx: Use devm API to cleanup module's resources

In this driver LEDs are registered using devm_led_classdev_register()
so they are automatically unregistered after module's remove() is done.
led_classdev_unregister() calls module's led_set_brightness() to turn off
the LEDs and that callback uses resources which were destroyed already
in module's remove() so use devm API instead of remove().
Signed-off-by: default avatarGeorge Stark <gnstark@salutedevices.com>
Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20240411161032.609544-4-gnstark@salutedevices.comSigned-off-by: default avatarLee Jones <lee@kernel.org>
parent fb74e4fa
...@@ -530,6 +530,16 @@ static const struct regmap_config aw200xx_regmap_config = { ...@@ -530,6 +530,16 @@ static const struct regmap_config aw200xx_regmap_config = {
.disable_locking = true, .disable_locking = true,
}; };
static void aw200xx_chip_reset_action(void *data)
{
aw200xx_chip_reset(data);
}
static void aw200xx_disable_action(void *data)
{
aw200xx_disable(data);
}
static int aw200xx_probe(struct i2c_client *client) static int aw200xx_probe(struct i2c_client *client)
{ {
const struct aw200xx_chipdef *cdef; const struct aw200xx_chipdef *cdef;
...@@ -568,11 +578,17 @@ static int aw200xx_probe(struct i2c_client *client) ...@@ -568,11 +578,17 @@ static int aw200xx_probe(struct i2c_client *client)
aw200xx_enable(chip); aw200xx_enable(chip);
ret = devm_add_action(&client->dev, aw200xx_disable_action, chip);
if (ret)
return ret;
ret = aw200xx_chip_check(chip); ret = aw200xx_chip_check(chip);
if (ret) if (ret)
return ret; return ret;
mutex_init(&chip->mutex); ret = devm_mutex_init(&client->dev, &chip->mutex);
if (ret)
return ret;
/* Need a lock now since after call aw200xx_probe_fw, sysfs nodes created */ /* Need a lock now since after call aw200xx_probe_fw, sysfs nodes created */
mutex_lock(&chip->mutex); mutex_lock(&chip->mutex);
...@@ -581,6 +597,10 @@ static int aw200xx_probe(struct i2c_client *client) ...@@ -581,6 +597,10 @@ static int aw200xx_probe(struct i2c_client *client)
if (ret) if (ret)
goto out_unlock; goto out_unlock;
ret = devm_add_action(&client->dev, aw200xx_chip_reset_action, chip);
if (ret)
goto out_unlock;
ret = aw200xx_probe_fw(&client->dev, chip); ret = aw200xx_probe_fw(&client->dev, chip);
if (ret) if (ret)
goto out_unlock; goto out_unlock;
...@@ -595,15 +615,6 @@ static int aw200xx_probe(struct i2c_client *client) ...@@ -595,15 +615,6 @@ static int aw200xx_probe(struct i2c_client *client)
return ret; return ret;
} }
static void aw200xx_remove(struct i2c_client *client)
{
struct aw200xx *chip = i2c_get_clientdata(client);
aw200xx_chip_reset(chip);
aw200xx_disable(chip);
mutex_destroy(&chip->mutex);
}
static const struct aw200xx_chipdef aw20036_cdef = { static const struct aw200xx_chipdef aw20036_cdef = {
.channels = 36, .channels = 36,
.display_size_rows_max = 3, .display_size_rows_max = 3,
...@@ -652,7 +663,6 @@ static struct i2c_driver aw200xx_driver = { ...@@ -652,7 +663,6 @@ static struct i2c_driver aw200xx_driver = {
.of_match_table = aw200xx_match_table, .of_match_table = aw200xx_match_table,
}, },
.probe = aw200xx_probe, .probe = aw200xx_probe,
.remove = aw200xx_remove,
.id_table = aw200xx_id, .id_table = aw200xx_id,
}; };
module_i2c_driver(aw200xx_driver); module_i2c_driver(aw200xx_driver);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment