diff options
author | Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com> | 2021-03-23 15:57:56 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-03-23 15:22:40 +0100 |
commit | 6d0c5de2fd84a0ad07f0cecea24def3987675192 (patch) | |
tree | 6f2cda876c2d01ed851d5a6a8fdc9149fc4ba42b /drivers/power/supply/bq24735-charger.c | |
parent | b82a7b018b93d282d0f1a41a854ca3d071e02759 (diff) | |
download | lwn-6d0c5de2fd84a0ad07f0cecea24def3987675192.tar.gz lwn-6d0c5de2fd84a0ad07f0cecea24def3987675192.zip |
power: supply: Clean-up few drivers by using managed work init
Few drivers implement remove call-back only for ensuring a delayed
work gets cancelled prior driver removal. Clean-up these by switching
to use devm_delayed_work_autocancel() instead.
This change is compile-tested only. All testing is appreciated.
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Link: https://lore.kernel.org/r/e5b1b0380cdd1aa066c9ac6d7a8b1a86ba1ddbbe.1616506559.git.matti.vaittinen@fi.rohmeurope.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/power/supply/bq24735-charger.c')
-rw-r--r-- | drivers/power/supply/bq24735-charger.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/drivers/power/supply/bq24735-charger.c b/drivers/power/supply/bq24735-charger.c index ab2f4bf8f603..b5d619db79f6 100644 --- a/drivers/power/supply/bq24735-charger.c +++ b/drivers/power/supply/bq24735-charger.c @@ -17,6 +17,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include <linux/devm-helpers.h> #include <linux/err.h> #include <linux/i2c.h> #include <linux/init.h> @@ -473,7 +474,11 @@ static int bq24735_charger_probe(struct i2c_client *client, if (!charger->poll_interval) return 0; - INIT_DELAYED_WORK(&charger->poll, bq24735_poll); + ret = devm_delayed_work_autocancel(&client->dev, &charger->poll, + bq24735_poll); + if (ret) + return ret; + schedule_delayed_work(&charger->poll, msecs_to_jiffies(charger->poll_interval)); } @@ -481,16 +486,6 @@ static int bq24735_charger_probe(struct i2c_client *client, return 0; } -static int bq24735_charger_remove(struct i2c_client *client) -{ - struct bq24735 *charger = i2c_get_clientdata(client); - - if (charger->poll_interval) - cancel_delayed_work_sync(&charger->poll); - - return 0; -} - static const struct i2c_device_id bq24735_charger_id[] = { { "bq24735-charger", 0 }, {} @@ -509,7 +504,6 @@ static struct i2c_driver bq24735_charger_driver = { .of_match_table = bq24735_match_ids, }, .probe = bq24735_charger_probe, - .remove = bq24735_charger_remove, .id_table = bq24735_charger_id, }; |