Skip to content

Commit b98362b

Browse files
Uwe Kleine-KönigTzung-Bi Shih
authored andcommitted
platform/chrome: cros_usbpd_notify: Convert to platform remove callback returning void
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new(), which already returns void. Eventually after all drivers are converted, .remove_new() will be renamed to .remove(). Trivially convert this driver from always returning zero in the remove callback to the void returning variant. Signed-off-by: Uwe Kleine-König <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Tzung-Bi Shih <[email protected]>
1 parent b6c1fea commit b98362b

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

drivers/platform/chrome/cros_usbpd_notify.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,13 @@ static int cros_usbpd_notify_probe_acpi(struct platform_device *pdev)
134134
return 0;
135135
}
136136

137-
static int cros_usbpd_notify_remove_acpi(struct platform_device *pdev)
137+
static void cros_usbpd_notify_remove_acpi(struct platform_device *pdev)
138138
{
139139
struct device *dev = &pdev->dev;
140140
struct acpi_device *adev = ACPI_COMPANION(dev);
141141

142142
acpi_remove_notify_handler(adev->handle, ACPI_ALL_NOTIFY,
143143
cros_usbpd_notify_acpi);
144-
145-
return 0;
146144
}
147145

148146
static const struct acpi_device_id cros_usbpd_notify_acpi_device_ids[] = {
@@ -157,7 +155,7 @@ static struct platform_driver cros_usbpd_notify_acpi_driver = {
157155
.acpi_match_table = cros_usbpd_notify_acpi_device_ids,
158156
},
159157
.probe = cros_usbpd_notify_probe_acpi,
160-
.remove = cros_usbpd_notify_remove_acpi,
158+
.remove_new = cros_usbpd_notify_remove_acpi,
161159
};
162160

163161
#endif /* CONFIG_ACPI */
@@ -209,7 +207,7 @@ static int cros_usbpd_notify_probe_plat(struct platform_device *pdev)
209207
return 0;
210208
}
211209

212-
static int cros_usbpd_notify_remove_plat(struct platform_device *pdev)
210+
static void cros_usbpd_notify_remove_plat(struct platform_device *pdev)
213211
{
214212
struct device *dev = &pdev->dev;
215213
struct cros_ec_dev *ecdev = dev_get_drvdata(dev->parent);
@@ -218,16 +216,14 @@ static int cros_usbpd_notify_remove_plat(struct platform_device *pdev)
218216

219217
blocking_notifier_chain_unregister(&ecdev->ec_dev->event_notifier,
220218
&pdnotify->nb);
221-
222-
return 0;
223219
}
224220

225221
static struct platform_driver cros_usbpd_notify_plat_driver = {
226222
.driver = {
227223
.name = DRV_NAME,
228224
},
229225
.probe = cros_usbpd_notify_probe_plat,
230-
.remove = cros_usbpd_notify_remove_plat,
226+
.remove_new = cros_usbpd_notify_remove_plat,
231227
};
232228

233229
static int __init cros_usbpd_notify_init(void)

0 commit comments

Comments
 (0)