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

platform/x86: gpd pocket fan: Clean-up 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.

Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Link: https://lore.kernel.org/r/aa25a6781ba016772b045cd6e630da8c559a665d.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
b82a7b01 96dc2b31

+6 -11
+6 -11
drivers/platform/x86/gpd-pocket-fan.c
··· 6 6 */ 7 7 8 8 #include <linux/acpi.h> 9 + #include <linux/devm-helpers.h> 9 10 #include <linux/gpio/consumer.h> 10 11 #include <linux/module.h> 11 12 #include <linux/moduleparam.h> ··· 125 124 static int gpd_pocket_fan_probe(struct platform_device *pdev) 126 125 { 127 126 struct gpd_pocket_fan_data *fan; 128 - int i; 127 + int i, ret; 129 128 130 129 for (i = 0; i < ARRAY_SIZE(temp_limits); i++) { 131 130 if (temp_limits[i] < 20000 || temp_limits[i] > 90000) { ··· 153 152 return -ENOMEM; 154 153 155 154 fan->dev = &pdev->dev; 156 - INIT_DELAYED_WORK(&fan->work, gpd_pocket_fan_worker); 155 + ret = devm_delayed_work_autocancel(&pdev->dev, &fan->work, 156 + gpd_pocket_fan_worker); 157 + if (ret) 158 + return ret; 157 159 158 160 /* Note this returns a "weak" reference which we don't need to free */ 159 161 fan->dts0 = thermal_zone_get_zone_by_name("soc_dts0"); ··· 178 174 gpd_pocket_fan_force_update(fan); 179 175 180 176 platform_set_drvdata(pdev, fan); 181 - return 0; 182 - } 183 - 184 - static int gpd_pocket_fan_remove(struct platform_device *pdev) 185 - { 186 - struct gpd_pocket_fan_data *fan = platform_get_drvdata(pdev); 187 - 188 - cancel_delayed_work_sync(&fan->work); 189 177 return 0; 190 178 } 191 179 ··· 211 215 212 216 static struct platform_driver gpd_pocket_fan_driver = { 213 217 .probe = gpd_pocket_fan_probe, 214 - .remove = gpd_pocket_fan_remove, 215 218 .driver = { 216 219 .name = "gpd_pocket_fan", 217 220 .acpi_match_table = gpd_pocket_fan_acpi_match,