diff options
author | Christophe JAILLET <christophe.jaillet@wanadoo.fr> | 2022-02-18 18:37:37 +0100 |
---|---|---|
committer | Sebastian Reichel <sebastian.reichel@collabora.com> | 2022-02-24 12:00:14 +0100 |
commit | e5372503d82b780ebc3fea3b893f04ca6f52fe42 (patch) | |
tree | ff5ca2e3ef92556570dd096e7d94006a2314991e | |
parent | power: supply: Use an rbtree rather than flat register cache (diff) | |
download | linux-e5372503d82b780ebc3fea3b893f04ca6f52fe42.tar.xz linux-e5372503d82b780ebc3fea3b893f04ca6f52fe42.zip |
power: supply: max17042_battery: Use devm_work_autocancel()
Use devm_work_autocancel() instead of hand-writing it.
This saves a few lines of code.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
-rw-r--r-- | drivers/power/supply/max17042_battery.c | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c index 87128cf0d577..ab031bbfbe78 100644 --- a/drivers/power/supply/max17042_battery.c +++ b/drivers/power/supply/max17042_battery.c @@ -9,6 +9,7 @@ // This driver is based on max17040_battery.c #include <linux/acpi.h> +#include <linux/devm-helpers.h> #include <linux/init.h> #include <linux/module.h> #include <linux/slab.h> @@ -1030,13 +1031,6 @@ static const struct power_supply_desc max17042_no_current_sense_psy_desc = { .num_properties = ARRAY_SIZE(max17042_battery_props) - 2, }; -static void max17042_stop_work(void *data) -{ - struct max17042_chip *chip = data; - - cancel_work_sync(&chip->work); -} - static int max17042_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -1142,8 +1136,8 @@ static int max17042_probe(struct i2c_client *client, regmap_read(chip->regmap, MAX17042_STATUS, &val); if (val & STATUS_POR_BIT) { - INIT_WORK(&chip->work, max17042_init_worker); - ret = devm_add_action(&client->dev, max17042_stop_work, chip); + ret = devm_work_autocancel(&client->dev, &chip->work, + max17042_init_worker); if (ret) return ret; schedule_work(&chip->work); |