serial: sh-sci: Convert to platform remove callback returning void
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Fri, 10 Nov 2023 15:30:06 +0000 (16:30 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 23 Nov 2023 19:12:34 +0000 (19:12 +0000)
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>
Link: https://lore.kernel.org/r/20231110152927.70601-39-u.kleine-koenig@pengutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/sh-sci.c

index 84ab434c94baf92ab1c404e7ab8ad78c67599f6f..745023001510ab2bde0a70f2c76a91920229a6bc 100644 (file)
@@ -3190,7 +3190,7 @@ static struct uart_driver sci_uart_driver = {
        .cons           = SCI_CONSOLE,
 };
 
-static int sci_remove(struct platform_device *dev)
+static void sci_remove(struct platform_device *dev)
 {
        struct sci_port *port = platform_get_drvdata(dev);
        unsigned int type = port->port.type;    /* uart_remove_... clears it */
@@ -3204,8 +3204,6 @@ static int sci_remove(struct platform_device *dev)
                device_remove_file(&dev->dev, &dev_attr_rx_fifo_trigger);
        if (type == PORT_SCIFA || type == PORT_SCIFB || type == PORT_HSCIF)
                device_remove_file(&dev->dev, &dev_attr_rx_fifo_timeout);
-
-       return 0;
 }
 
 
@@ -3470,7 +3468,7 @@ static SIMPLE_DEV_PM_OPS(sci_dev_pm_ops, sci_suspend, sci_resume);
 
 static struct platform_driver sci_driver = {
        .probe          = sci_probe,
-       .remove         = sci_remove,
+       .remove_new     = sci_remove,
        .driver         = {
                .name   = "sh-sci",
                .pm     = &sci_dev_pm_ops,