Skip to content

Commit f132271

Browse files
author
Al Stone
committed
power: supply: sbs-charger: Don't cancel work that is not initialized
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2071846 Tested: This is one of a series of patch sets to enable Arm SystemReady IR support in the kernel for NXP i.MX8 platforms. This set updates the power subsystem. This set has been tested via simple boot tests and the CI loop. commit de85193 Author: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Date: Sun Feb 13 18:07:03 2022 +0100 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: feb583e ("power: supply: add sbs-charger driver") Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com> (cherry picked from commit de85193) Signed-off-by: Al Stone <ahs3@redhat.com>
1 parent ff87f0c commit f132271

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

drivers/power/supply/sbs-charger.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/interrupt.h>
1919
#include <linux/regmap.h>
2020
#include <linux/bitops.h>
21+
#include <linux/devm-helpers.h>
2122

2223
#define SBS_CHARGER_REG_SPEC_INFO 0x11
2324
#define SBS_CHARGER_REG_STATUS 0x13
@@ -209,7 +210,12 @@ static int sbs_probe(struct i2c_client *client,
209210
if (ret)
210211
return dev_err_probe(&client->dev, ret, "Failed to request irq\n");
211212
} else {
212-
INIT_DELAYED_WORK(&chip->work, sbs_delayed_work);
213+
ret = devm_delayed_work_autocancel(&client->dev, &chip->work,
214+
sbs_delayed_work);
215+
if (ret)
216+
return dev_err_probe(&client->dev, ret,
217+
"Failed to init work for polling\n");
218+
213219
schedule_delayed_work(&chip->work,
214220
msecs_to_jiffies(SBS_CHARGER_POLL_TIME));
215221
}
@@ -220,15 +226,6 @@ static int sbs_probe(struct i2c_client *client,
220226
return 0;
221227
}
222228

223-
static int sbs_remove(struct i2c_client *client)
224-
{
225-
struct sbs_info *chip = i2c_get_clientdata(client);
226-
227-
cancel_delayed_work_sync(&chip->work);
228-
229-
return 0;
230-
}
231-
232229
#ifdef CONFIG_OF
233230
static const struct of_device_id sbs_dt_ids[] = {
234231
{ .compatible = "sbs,sbs-charger" },
@@ -245,7 +242,6 @@ MODULE_DEVICE_TABLE(i2c, sbs_id);
245242

246243
static struct i2c_driver sbs_driver = {
247244
.probe = sbs_probe,
248-
.remove = sbs_remove,
249245
.id_table = sbs_id,
250246
.driver = {
251247
.name = "sbs-charger",

0 commit comments

Comments
 (0)