extcon: usb-gpio: Convert to platform remove callback returning void
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Sun, 25 Feb 2024 15:54:55 +0000 (16:54 +0100)
committerChanwoo Choi <cw00.choi@samsung.com>
Wed, 8 May 2024 16:03:38 +0000 (01:03 +0900)
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.

Link: https://lore.kernel.org/lkml/8914cd71b32e1f6298e65b84fb84370c73b4fe37.1708876186.git.u.kleine-koenig@pengutronix.de/
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
drivers/extcon/extcon-usb-gpio.c

index 40d967a11e87b118fa1f70d0344eb9e65c4a2ed7..9b61eb99b7dc950086ab5967ff911c26e552d4e0 100644 (file)
@@ -193,14 +193,12 @@ static int usb_extcon_probe(struct platform_device *pdev)
        return 0;
 }
 
-static int usb_extcon_remove(struct platform_device *pdev)
+static void usb_extcon_remove(struct platform_device *pdev)
 {
        struct usb_extcon_info *info = platform_get_drvdata(pdev);
 
        cancel_delayed_work_sync(&info->wq_detcable);
        device_init_wakeup(&pdev->dev, false);
-
-       return 0;
 }
 
 #ifdef CONFIG_PM_SLEEP
@@ -281,7 +279,7 @@ MODULE_DEVICE_TABLE(platform, usb_extcon_platform_ids);
 
 static struct platform_driver usb_extcon_driver = {
        .probe          = usb_extcon_probe,
-       .remove         = usb_extcon_remove,
+       .remove_new     = usb_extcon_remove,
        .driver         = {
                .name   = "extcon-usb-gpio",
                .pm     = &usb_extcon_pm_ops,