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

hwmon: raspberry-pi: 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: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Link: https://lore.kernel.org/r/4830f52d46278ea1c92ad7252f6050540346d8b7.1616506559.git.matti.vaittinen@fi.rohmeurope.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Matti Vaittinen and committed by
Greg Kroah-Hartman
96dc2b31 f94a5bec

+6 -11
+6 -11
drivers/hwmon/raspberrypi-hwmon.c
··· 7 7 * Copyright (C) 2018 Stefan Wahren <stefan.wahren@i2se.com> 8 8 */ 9 9 #include <linux/device.h> 10 + #include <linux/devm-helpers.h> 10 11 #include <linux/err.h> 11 12 #include <linux/hwmon.h> 12 13 #include <linux/module.h> ··· 107 106 { 108 107 struct device *dev = &pdev->dev; 109 108 struct rpi_hwmon_data *data; 109 + int ret; 110 110 111 111 data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); 112 112 if (!data) ··· 121 119 &rpi_chip_info, 122 120 NULL); 123 121 124 - INIT_DELAYED_WORK(&data->get_values_poll_work, get_values_poll); 122 + ret = devm_delayed_work_autocancel(dev, &data->get_values_poll_work, 123 + get_values_poll); 124 + if (ret) 125 + return ret; 125 126 platform_set_drvdata(pdev, data); 126 127 127 128 if (!PTR_ERR_OR_ZERO(data->hwmon_dev)) ··· 133 128 return PTR_ERR_OR_ZERO(data->hwmon_dev); 134 129 } 135 130 136 - static int rpi_hwmon_remove(struct platform_device *pdev) 137 - { 138 - struct rpi_hwmon_data *data = platform_get_drvdata(pdev); 139 - 140 - cancel_delayed_work_sync(&data->get_values_poll_work); 141 - 142 - return 0; 143 - } 144 - 145 131 static struct platform_driver rpi_hwmon_driver = { 146 132 .probe = rpi_hwmon_probe, 147 - .remove = rpi_hwmon_remove, 148 133 .driver = { 149 134 .name = "raspberrypi-hwmon", 150 135 },