tty: amiserial: Convert to platform remove callback returning void
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Sun, 18 Feb 2024 08:53:54 +0000 (09:53 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 19 Feb 2024 08:40:50 +0000 (09:40 +0100)
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>
Link: https://lore.kernel.org/r/f2ad92c97086c42dab23cdb165d9f978bbf3d3b5.1708246007.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/amiserial.c

index 7716ce0d35bc219608bd67b762aac0d4544bd9b9..e27360652d9b6b6e09976b5fda3ff495ed3f9838 100644 (file)
@@ -1566,7 +1566,7 @@ fail_tty_driver_kref_put:
        return error;
 }
 
-static int __exit amiga_serial_remove(struct platform_device *pdev)
+static void __exit amiga_serial_remove(struct platform_device *pdev)
 {
        struct serial_state *state = platform_get_drvdata(pdev);
 
@@ -1576,12 +1576,10 @@ static int __exit amiga_serial_remove(struct platform_device *pdev)
 
        free_irq(IRQ_AMIGA_TBE, state);
        free_irq(IRQ_AMIGA_RBF, state);
-
-       return 0;
 }
 
 static struct platform_driver amiga_serial_driver = {
-       .remove = __exit_p(amiga_serial_remove),
+       .remove_new = __exit_p(amiga_serial_remove),
        .driver   = {
                .name   = "amiga-serial",
        },