net: ethernet: smsc: Convert to platform remove callback returning void
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Mon, 18 Sep 2023 20:42:17 +0000 (22:42 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 20 Sep 2023 08:06:40 +0000 (09:06 +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() is renamed to .remove().

Trivially convert these drivers 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>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/smsc/smc91x.c
drivers/net/ethernet/smsc/smsc911x.c

index 032eccf8eb428ee5fe1198f7c45b5e1b1fb79cc7..758347616535aa1d0f03a2fa88ece40287f54aed 100644 (file)
@@ -2411,7 +2411,7 @@ static int smc_drv_probe(struct platform_device *pdev)
        return ret;
 }
 
-static int smc_drv_remove(struct platform_device *pdev)
+static void smc_drv_remove(struct platform_device *pdev)
 {
        struct net_device *ndev = platform_get_drvdata(pdev);
        struct smc_local *lp = netdev_priv(ndev);
@@ -2436,8 +2436,6 @@ static int smc_drv_remove(struct platform_device *pdev)
        release_mem_region(res->start, SMC_IO_EXTENT);
 
        free_netdev(ndev);
-
-       return 0;
 }
 
 static int smc_drv_suspend(struct device *dev)
@@ -2480,7 +2478,7 @@ static const struct dev_pm_ops smc_drv_pm_ops = {
 
 static struct platform_driver smc_driver = {
        .probe          = smc_drv_probe,
-       .remove         = smc_drv_remove,
+       .remove_new     = smc_drv_remove,
        .driver         = {
                .name   = CARDNAME,
                .pm     = &smc_drv_pm_ops,
index cb590db625e8371df6aade4dd5d54bd8811d383a..31cb7d0166f030846e9d76da09d80947352a1707 100644 (file)
@@ -2314,7 +2314,7 @@ static int smsc911x_init(struct net_device *dev)
        return 0;
 }
 
-static int smsc911x_drv_remove(struct platform_device *pdev)
+static void smsc911x_drv_remove(struct platform_device *pdev)
 {
        struct net_device *dev;
        struct smsc911x_data *pdata;
@@ -2348,8 +2348,6 @@ static int smsc911x_drv_remove(struct platform_device *pdev)
        free_netdev(dev);
 
        pm_runtime_disable(&pdev->dev);
-
-       return 0;
 }
 
 /* standard register acces */
@@ -2668,7 +2666,7 @@ MODULE_DEVICE_TABLE(acpi, smsc911x_acpi_match);
 
 static struct platform_driver smsc911x_driver = {
        .probe = smsc911x_drv_probe,
-       .remove = smsc911x_drv_remove,
+       .remove_new = smsc911x_drv_remove,
        .driver = {
                .name   = SMSC_CHIPNAME,
                .pm     = SMSC911X_PM_OPS,