power: supply: sbs-charger: Don't cancel work that is not initialized

This driver can use an interrupt or polling in order get the charger's
status.

When using polling, a delayed work is used.

However, the remove() function unconditionally call
cancel_delayed_work_sync(), even if the delayed work is not used and is not
initialized.

In order to fix it, use devm_delayed_work_autocancel() and remove the now
useless remove() function.

Fixes: feb583e37f ("power: supply: add sbs-charger driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
This commit is contained in:
Christophe JAILLET 2022-02-13 18:07:03 +01:00 committed by Sebastian Reichel
parent 1ff8cc2ca8
commit de85193cff

View file

@ -18,6 +18,7 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/devm-helpers.h>
#define SBS_CHARGER_REG_SPEC_INFO 0x11 #define SBS_CHARGER_REG_SPEC_INFO 0x11
#define SBS_CHARGER_REG_STATUS 0x13 #define SBS_CHARGER_REG_STATUS 0x13
@ -209,7 +210,12 @@ static int sbs_probe(struct i2c_client *client,
if (ret) if (ret)
return dev_err_probe(&client->dev, ret, "Failed to request irq\n"); return dev_err_probe(&client->dev, ret, "Failed to request irq\n");
} else { } else {
INIT_DELAYED_WORK(&chip->work, sbs_delayed_work); ret = devm_delayed_work_autocancel(&client->dev, &chip->work,
sbs_delayed_work);
if (ret)
return dev_err_probe(&client->dev, ret,
"Failed to init work for polling\n");
schedule_delayed_work(&chip->work, schedule_delayed_work(&chip->work,
msecs_to_jiffies(SBS_CHARGER_POLL_TIME)); msecs_to_jiffies(SBS_CHARGER_POLL_TIME));
} }
@ -220,15 +226,6 @@ static int sbs_probe(struct i2c_client *client,
return 0; return 0;
} }
static int sbs_remove(struct i2c_client *client)
{
struct sbs_info *chip = i2c_get_clientdata(client);
cancel_delayed_work_sync(&chip->work);
return 0;
}
#ifdef CONFIG_OF #ifdef CONFIG_OF
static const struct of_device_id sbs_dt_ids[] = { static const struct of_device_id sbs_dt_ids[] = {
{ .compatible = "sbs,sbs-charger" }, { .compatible = "sbs,sbs-charger" },
@ -245,7 +242,6 @@ MODULE_DEVICE_TABLE(i2c, sbs_id);
static struct i2c_driver sbs_driver = { static struct i2c_driver sbs_driver = {
.probe = sbs_probe, .probe = sbs_probe,
.remove = sbs_remove,
.id_table = sbs_id, .id_table = sbs_id,
.driver = { .driver = {
.name = "sbs-charger", .name = "sbs-charger",