Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Christophe JAILLET and committed by
Sebastian Reichel
e5372503 4c678b7a

+3 -9
+3 -9
drivers/power/supply/max17042_battery.c
··· 9 9 // This driver is based on max17040_battery.c 10 10 11 11 #include <linux/acpi.h> 12 + #include <linux/devm-helpers.h> 12 13 #include <linux/init.h> 13 14 #include <linux/module.h> 14 15 #include <linux/slab.h> ··· 1031 1030 .num_properties = ARRAY_SIZE(max17042_battery_props) - 2, 1032 1031 }; 1033 1032 1034 - static void max17042_stop_work(void *data) 1035 - { 1036 - struct max17042_chip *chip = data; 1037 - 1038 - cancel_work_sync(&chip->work); 1039 - } 1040 - 1041 1033 static int max17042_probe(struct i2c_client *client, 1042 1034 const struct i2c_device_id *id) 1043 1035 { ··· 1136 1142 1137 1143 regmap_read(chip->regmap, MAX17042_STATUS, &val); 1138 1144 if (val & STATUS_POR_BIT) { 1139 - INIT_WORK(&chip->work, max17042_init_worker); 1140 - ret = devm_add_action(&client->dev, max17042_stop_work, chip); 1145 + ret = devm_work_autocancel(&client->dev, &chip->work, 1146 + max17042_init_worker); 1141 1147 if (ret) 1142 1148 return ret; 1143 1149 schedule_work(&chip->work);