// 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>
.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)
{
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);