sh: push-switch: Convert to platform remove callback returning void
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Wed, 6 Mar 2024 21:19:47 +0000 (22:19 +0100)
committerJohn Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Thu, 2 May 2024 10:02:22 +0000 (12:02 +0200)
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 <u.kleine-koenig@pengutronix.de>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Link: https://lore.kernel.org/r/20240306211947.97103-2-u.kleine-koenig@pengutronix.de
Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
arch/sh/drivers/push-switch.c

index 6ecba5f521eb6c276a34961e8b10b3bcc5f14bfe..362e4860bf52e4f96d6dcc9b5f4a8cfc885ee0d9 100644 (file)
@@ -91,7 +91,7 @@ err:
        return ret;
 }
 
-static int switch_drv_remove(struct platform_device *pdev)
+static void switch_drv_remove(struct platform_device *pdev)
 {
        struct push_switch *psw = platform_get_drvdata(pdev);
        struct push_switch_platform_info *psw_info = pdev->dev.platform_data;
@@ -106,13 +106,11 @@ static int switch_drv_remove(struct platform_device *pdev)
        free_irq(irq, pdev);
 
        kfree(psw);
-
-       return 0;
 }
 
 static struct platform_driver switch_driver = {
        .probe          = switch_drv_probe,
-       .remove         = switch_drv_remove,
+       .remove_new     = switch_drv_remove,
        .driver         = {
                .name   = DRV_NAME,
        },