serial: 8250: Convert to platform remove callback returning void
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Fri, 10 Nov 2023 15:29:31 +0000 (16:29 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 23 Nov 2023 19:12:30 +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>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com> # 8250_bcm*
Link: https://lore.kernel.org/r/20231110152927.70601-4-u.kleine-koenig@pengutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
16 files changed:
drivers/tty/serial/8250/8250_aspeed_vuart.c
drivers/tty/serial/8250/8250_bcm2835aux.c
drivers/tty/serial/8250/8250_bcm7271.c
drivers/tty/serial/8250/8250_core.c
drivers/tty/serial/8250/8250_dw.c
drivers/tty/serial/8250/8250_em.c
drivers/tty/serial/8250/8250_fsl.c
drivers/tty/serial/8250/8250_ingenic.c
drivers/tty/serial/8250/8250_ioc3.c
drivers/tty/serial/8250/8250_lpc18xx.c
drivers/tty/serial/8250/8250_mtk.c
drivers/tty/serial/8250/8250_of.c
drivers/tty/serial/8250/8250_omap.c
drivers/tty/serial/8250/8250_pxa.c
drivers/tty/serial/8250/8250_tegra.c
drivers/tty/serial/8250/8250_uniphier.c

index d7482ae33a1caea283ab6b568173a0782f446db3..8c2aaf7af7b75c23587f847f8bc9be9330ddadc2 100644 (file)
@@ -566,7 +566,7 @@ err_sysfs_remove:
        return rc;
 }
 
-static int aspeed_vuart_remove(struct platform_device *pdev)
+static void aspeed_vuart_remove(struct platform_device *pdev)
 {
        struct aspeed_vuart *vuart = platform_get_drvdata(pdev);
 
@@ -574,8 +574,6 @@ static int aspeed_vuart_remove(struct platform_device *pdev)
        aspeed_vuart_set_enabled(vuart, false);
        serial8250_unregister_port(vuart->line);
        sysfs_remove_group(&vuart->dev->kobj, &aspeed_vuart_attr_group);
-
-       return 0;
 }
 
 static const struct of_device_id aspeed_vuart_table[] = {
@@ -590,7 +588,7 @@ static struct platform_driver aspeed_vuart_driver = {
                .of_match_table = aspeed_vuart_table,
        },
        .probe = aspeed_vuart_probe,
-       .remove = aspeed_vuart_remove,
+       .remove_new = aspeed_vuart_remove,
 };
 
 module_platform_driver(aspeed_vuart_driver);
index 15a2387a5b258f60420d86b4ac170630cf0c7446..b5760f914a8cf79e14c8db41557819417ce916ee 100644 (file)
@@ -195,14 +195,12 @@ dis_clk:
        return ret;
 }
 
-static int bcm2835aux_serial_remove(struct platform_device *pdev)
+static void bcm2835aux_serial_remove(struct platform_device *pdev)
 {
        struct bcm2835aux_data *data = platform_get_drvdata(pdev);
 
        serial8250_unregister_port(data->line);
        clk_disable_unprepare(data->clk);
-
-       return 0;
 }
 
 static const struct bcm2835_aux_serial_driver_data bcm2835_acpi_data = {
@@ -228,7 +226,7 @@ static struct platform_driver bcm2835aux_serial_driver = {
                .acpi_match_table = bcm2835aux_serial_acpi_match,
        },
        .probe  = bcm2835aux_serial_probe,
-       .remove = bcm2835aux_serial_remove,
+       .remove_new = bcm2835aux_serial_remove,
 };
 module_platform_driver(bcm2835aux_serial_driver);
 
index 55dea2539c47956878f0336d02d9697cf6e43a35..504c4c02085776c610e8a6d9010f6982046c674a 100644 (file)
@@ -1121,7 +1121,7 @@ release_dma:
        return ret;
 }
 
-static int brcmuart_remove(struct platform_device *pdev)
+static void brcmuart_remove(struct platform_device *pdev)
 {
        struct brcmuart_priv *priv = platform_get_drvdata(pdev);
 
@@ -1131,7 +1131,6 @@ static int brcmuart_remove(struct platform_device *pdev)
        brcmuart_free_bufs(&pdev->dev, priv);
        if (priv->dma_enabled)
                brcmuart_arbitration(priv, 0);
-       return 0;
 }
 
 static int __maybe_unused brcmuart_suspend(struct device *dev)
@@ -1207,7 +1206,7 @@ static struct platform_driver brcmuart_platform_driver = {
                .of_match_table = brcmuart_dt_ids,
        },
        .probe          = brcmuart_probe,
-       .remove         = brcmuart_remove,
+       .remove_new     = brcmuart_remove,
 };
 
 static int __init brcmuart_init(void)
index 912733151858760bdab550be2bd261db296f68d3..b62ad9006780ce4b7266ffb0df6066ebecd60ecd 100644 (file)
@@ -883,7 +883,7 @@ static int serial8250_probe(struct platform_device *dev)
 /*
  * Remove serial ports registered against a platform device.
  */
-static int serial8250_remove(struct platform_device *dev)
+static void serial8250_remove(struct platform_device *dev)
 {
        int i;
 
@@ -893,7 +893,6 @@ static int serial8250_remove(struct platform_device *dev)
                if (up->port.dev == &dev->dev)
                        serial8250_unregister_port(i);
        }
-       return 0;
 }
 
 static int serial8250_suspend(struct platform_device *dev, pm_message_t state)
@@ -926,7 +925,7 @@ static int serial8250_resume(struct platform_device *dev)
 
 static struct platform_driver serial8250_isa_driver = {
        .probe          = serial8250_probe,
-       .remove         = serial8250_remove,
+       .remove_new     = serial8250_remove,
        .suspend        = serial8250_suspend,
        .resume         = serial8250_resume,
        .driver         = {
index b94f567647cb653b7332d25d06fa0674de0a21c1..63b14ce9c009cde689330b631d2fd7fb8d88a26e 100644 (file)
@@ -663,7 +663,7 @@ static int dw8250_probe(struct platform_device *pdev)
        return 0;
 }
 
-static int dw8250_remove(struct platform_device *pdev)
+static void dw8250_remove(struct platform_device *pdev)
 {
        struct dw8250_data *data = platform_get_drvdata(pdev);
        struct device *dev = &pdev->dev;
@@ -680,8 +680,6 @@ static int dw8250_remove(struct platform_device *pdev)
 
        pm_runtime_disable(dev);
        pm_runtime_put_noidle(dev);
-
-       return 0;
 }
 
 static int dw8250_suspend(struct device *dev)
@@ -789,7 +787,7 @@ static struct platform_driver dw8250_platform_driver = {
                .acpi_match_table = dw8250_acpi_match,
        },
        .probe                  = dw8250_probe,
-       .remove                 = dw8250_remove,
+       .remove_new             = dw8250_remove,
 };
 
 module_platform_driver(dw8250_platform_driver);
index ef5019e944eaa82cbaf85b98ef7a6de3f0d5c4c3..a754755100ffe1f11ca7ebfdb90d915e6c3a2187 100644 (file)
@@ -200,12 +200,11 @@ static int serial8250_em_probe(struct platform_device *pdev)
        return 0;
 }
 
-static int serial8250_em_remove(struct platform_device *pdev)
+static void serial8250_em_remove(struct platform_device *pdev)
 {
        struct serial8250_em_priv *priv = platform_get_drvdata(pdev);
 
        serial8250_unregister_port(priv->line);
-       return 0;
 }
 
 static const struct of_device_id serial8250_em_dt_ids[] = {
@@ -220,7 +219,7 @@ static struct platform_driver serial8250_em_platform_driver = {
                .of_match_table = serial8250_em_dt_ids,
        },
        .probe                  = serial8250_em_probe,
-       .remove                 = serial8250_em_remove,
+       .remove_new             = serial8250_em_remove,
 };
 
 module_platform_driver(serial8250_em_platform_driver);
index f522eb5026c979f03fabfa08cc97bc2be9fed99c..5cf675eadefe11bf616c3d3ed2b530b53cae9147 100644 (file)
@@ -159,12 +159,11 @@ static int fsl8250_acpi_probe(struct platform_device *pdev)
        return 0;
 }
 
-static int fsl8250_acpi_remove(struct platform_device *pdev)
+static void fsl8250_acpi_remove(struct platform_device *pdev)
 {
        struct fsl8250_data *data = platform_get_drvdata(pdev);
 
        serial8250_unregister_port(data->line);
-       return 0;
 }
 
 static const struct acpi_device_id fsl_8250_acpi_id[] = {
@@ -179,7 +178,7 @@ static struct platform_driver fsl8250_platform_driver = {
                .acpi_match_table       = ACPI_PTR(fsl_8250_acpi_id),
        },
        .probe                  = fsl8250_acpi_probe,
-       .remove                 = fsl8250_acpi_remove,
+       .remove_new             = fsl8250_acpi_remove,
 };
 
 module_platform_driver(fsl8250_platform_driver);
index 4c4c4da73ad09c3c2bd03114e1f66b7949f5e266..a12f737924c0b79c5d85d13e413f412bb7ed6dd6 100644 (file)
@@ -320,14 +320,13 @@ out:
        return err;
 }
 
-static int ingenic_uart_remove(struct platform_device *pdev)
+static void ingenic_uart_remove(struct platform_device *pdev)
 {
        struct ingenic_uart_data *data = platform_get_drvdata(pdev);
 
        serial8250_unregister_port(data->line);
        clk_disable_unprepare(data->clk_module);
        clk_disable_unprepare(data->clk_baud);
-       return 0;
 }
 
 static const struct ingenic_uart_config jz4740_uart_config = {
@@ -368,7 +367,7 @@ static struct platform_driver ingenic_uart_platform_driver = {
                .of_match_table = of_match,
        },
        .probe                  = ingenic_uart_probe,
-       .remove                 = ingenic_uart_remove,
+       .remove_new             = ingenic_uart_remove,
 };
 
 module_platform_driver(ingenic_uart_platform_driver);
index d5a39e105a76f5bfbd9e3718c91d52ca5a79fbff..50c77c3dacf2c809dd1785e54a363c5381d605b9 100644 (file)
@@ -75,17 +75,16 @@ static int serial8250_ioc3_probe(struct platform_device *pdev)
        return 0;
 }
 
-static int serial8250_ioc3_remove(struct platform_device *pdev)
+static void serial8250_ioc3_remove(struct platform_device *pdev)
 {
        struct ioc3_8250_data *data = platform_get_drvdata(pdev);
 
        serial8250_unregister_port(data->line);
-       return 0;
 }
 
 static struct platform_driver serial8250_ioc3_driver = {
        .probe  = serial8250_ioc3_probe,
-       .remove = serial8250_ioc3_remove,
+       .remove_new = serial8250_ioc3_remove,
        .driver = {
                .name = "ioc3-serial8250",
        }
index 6dc85aaba5d0b9c27df3048e13ce7d783f0b289d..8d728a6a5991412b23298368aa914971ea4b4261 100644 (file)
@@ -182,15 +182,13 @@ dis_clk_reg:
        return ret;
 }
 
-static int lpc18xx_serial_remove(struct platform_device *pdev)
+static void lpc18xx_serial_remove(struct platform_device *pdev)
 {
        struct lpc18xx_uart_data *data = platform_get_drvdata(pdev);
 
        serial8250_unregister_port(data->line);
        clk_disable_unprepare(data->clk_uart);
        clk_disable_unprepare(data->clk_reg);
-
-       return 0;
 }
 
 static const struct of_device_id lpc18xx_serial_match[] = {
@@ -201,7 +199,7 @@ MODULE_DEVICE_TABLE(of, lpc18xx_serial_match);
 
 static struct platform_driver lpc18xx_serial_driver = {
        .probe  = lpc18xx_serial_probe,
-       .remove = lpc18xx_serial_remove,
+       .remove_new = lpc18xx_serial_remove,
        .driver = {
                .name = "lpc18xx-uart",
                .of_match_table = lpc18xx_serial_match,
index 23457daae8a148c6237e0262079cd401a72a7ea2..9ff6bbe9c0863e4c5891f862ea5425b08d813c6b 100644 (file)
@@ -581,7 +581,7 @@ static int mtk8250_probe(struct platform_device *pdev)
        return 0;
 }
 
-static int mtk8250_remove(struct platform_device *pdev)
+static void mtk8250_remove(struct platform_device *pdev)
 {
        struct mtk8250_data *data = platform_get_drvdata(pdev);
 
@@ -591,8 +591,6 @@ static int mtk8250_remove(struct platform_device *pdev)
 
        pm_runtime_disable(&pdev->dev);
        pm_runtime_put_noidle(&pdev->dev);
-
-       return 0;
 }
 
 static int __maybe_unused mtk8250_suspend(struct device *dev)
@@ -652,7 +650,7 @@ static struct platform_driver mtk8250_platform_driver = {
                .of_match_table = mtk8250_of_match,
        },
        .probe                  = mtk8250_probe,
-       .remove                 = mtk8250_remove,
+       .remove_new             = mtk8250_remove,
 };
 module_platform_driver(mtk8250_platform_driver);
 
index ef3e745bd09cbf17b6d3c22fa123212375f8cc6c..34f17a9785e79e1d26b6fbbbea3441a89f523e44 100644 (file)
@@ -251,7 +251,7 @@ err_free:
 /*
  * Release a line
  */
-static int of_platform_serial_remove(struct platform_device *ofdev)
+static void of_platform_serial_remove(struct platform_device *ofdev)
 {
        struct of_serial_info *info = platform_get_drvdata(ofdev);
 
@@ -261,7 +261,6 @@ static int of_platform_serial_remove(struct platform_device *ofdev)
        pm_runtime_put_sync(&ofdev->dev);
        pm_runtime_disable(&ofdev->dev);
        kfree(info);
-       return 0;
 }
 
 #ifdef CONFIG_PM_SLEEP
@@ -337,7 +336,7 @@ static struct platform_driver of_platform_serial_driver = {
                .pm = &of_serial_pm_ops,
        },
        .probe = of_platform_serial_probe,
-       .remove = of_platform_serial_remove,
+       .remove_new = of_platform_serial_remove,
 };
 
 module_platform_driver(of_platform_serial_driver);
index 661a83dbc11b0ec4727d051ccd51fc88a0dc272c..5a89a8cd7f717649f3bce42b378205647af2180c 100644 (file)
@@ -1584,7 +1584,7 @@ err:
        return ret;
 }
 
-static int omap8250_remove(struct platform_device *pdev)
+static void omap8250_remove(struct platform_device *pdev)
 {
        struct omap8250_priv *priv = platform_get_drvdata(pdev);
        struct uart_8250_port *up;
@@ -1604,7 +1604,6 @@ static int omap8250_remove(struct platform_device *pdev)
        pm_runtime_disable(&pdev->dev);
        cpu_latency_qos_remove_request(&priv->pm_qos_request);
        device_init_wakeup(&pdev->dev, false);
-       return 0;
 }
 
 static int omap8250_prepare(struct device *dev)
@@ -1863,7 +1862,7 @@ static struct platform_driver omap8250_platform_driver = {
                .of_match_table = omap8250_dt_ids,
        },
        .probe                  = omap8250_probe,
-       .remove                 = omap8250_remove,
+       .remove_new             = omap8250_remove,
 };
 module_platform_driver(omap8250_platform_driver);
 
index a5b3ea27fc90207650884231c5b76a6d624761a2..77686da42ce8e93ca42d9c00ffde2d4e8bb9c234 100644 (file)
@@ -146,20 +146,18 @@ static int serial_pxa_probe(struct platform_device *pdev)
        return ret;
 }
 
-static int serial_pxa_remove(struct platform_device *pdev)
+static void serial_pxa_remove(struct platform_device *pdev)
 {
        struct pxa8250_data *data = platform_get_drvdata(pdev);
 
        serial8250_unregister_port(data->line);
 
        clk_unprepare(data->clk);
-
-       return 0;
 }
 
 static struct platform_driver serial_pxa_driver = {
        .probe          = serial_pxa_probe,
-       .remove         = serial_pxa_remove,
+       .remove_new     = serial_pxa_remove,
 
        .driver         = {
                .name   = "pxa2xx-uart",
index 89956bbf34d9e4d4ad6b921db7a13b039629741a..ba352262df75a7b32c9fa6401abd012e5ccf0ec8 100644 (file)
@@ -128,15 +128,13 @@ err_clkdisable:
        return ret;
 }
 
-static int tegra_uart_remove(struct platform_device *pdev)
+static void tegra_uart_remove(struct platform_device *pdev)
 {
        struct tegra_uart *uart = platform_get_drvdata(pdev);
 
        serial8250_unregister_port(uart->line);
        reset_control_assert(uart->rst);
        clk_disable_unprepare(uart->clk);
-
-       return 0;
 }
 
 #ifdef CONFIG_PM_SLEEP
@@ -192,7 +190,7 @@ static struct platform_driver tegra_uart_driver = {
                .acpi_match_table = ACPI_PTR(tegra_uart_acpi_match),
        },
        .probe = tegra_uart_probe,
-       .remove = tegra_uart_remove,
+       .remove_new = tegra_uart_remove,
 };
 
 module_platform_driver(tegra_uart_driver);
index a405155264b1721a2f731ec051a93942d6f90441..6399a38ecce2ada62168872b33b13ae7c7273b49 100644 (file)
@@ -241,14 +241,12 @@ static int uniphier_uart_probe(struct platform_device *pdev)
        return 0;
 }
 
-static int uniphier_uart_remove(struct platform_device *pdev)
+static void uniphier_uart_remove(struct platform_device *pdev)
 {
        struct uniphier8250_priv *priv = platform_get_drvdata(pdev);
 
        serial8250_unregister_port(priv->line);
        clk_disable_unprepare(priv->clk);
-
-       return 0;
 }
 
 static int __maybe_unused uniphier_uart_suspend(struct device *dev)
@@ -293,7 +291,7 @@ MODULE_DEVICE_TABLE(of, uniphier_uart_match);
 
 static struct platform_driver uniphier_uart_platform_driver = {
        .probe          = uniphier_uart_probe,
-       .remove         = uniphier_uart_remove,
+       .remove_new     = uniphier_uart_remove,
        .driver = {
                .name   = "uniphier-uart",
                .of_match_table = uniphier_uart_match,