net: fec: Convert to platform remove callback returning void
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Mon, 10 Jul 2023 07:19:41 +0000 (09:19 +0200)
committerJakub Kicinski <kuba@kernel.org>
Wed, 12 Jul 2023 03:24:33 +0000 (20:24 -0700)
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 (mostly) ignored
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.

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Reviewed-by: Michal Kubiak <michal.kubiak@intel.com>
Reviewed-by: Wei Fang <wei.fang@nxp.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20230710071946.3470249-4-u.kleine-koenig@pengutronix.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/freescale/fec_main.c
drivers/net/ethernet/freescale/fec_mpc52xx.c
drivers/net/ethernet/freescale/fec_mpc52xx_phy.c

index 8fbe47703d4755a9c31bbd96ce059c7efa8863ea..1280da699fa3bb08253c464e88909ee811a98158 100644 (file)
@@ -4458,7 +4458,7 @@ failed_ioremap:
        return ret;
 }
 
-static int
+static void
 fec_drv_remove(struct platform_device *pdev)
 {
        struct net_device *ndev = platform_get_drvdata(pdev);
@@ -4494,7 +4494,6 @@ fec_drv_remove(struct platform_device *pdev)
        pm_runtime_disable(&pdev->dev);
 
        free_netdev(ndev);
-       return 0;
 }
 
 static int __maybe_unused fec_suspend(struct device *dev)
@@ -4650,7 +4649,7 @@ static struct platform_driver fec_driver = {
        },
        .id_table = fec_devtype,
        .probe  = fec_probe,
-       .remove = fec_drv_remove,
+       .remove_new = fec_drv_remove,
 };
 
 module_platform_driver(fec_driver);
index b88816b71ddff3dca52753d24d90817014d9924b..984ece5cd64f6dd25ab484593f0cda8a598f895a 100644 (file)
@@ -974,7 +974,7 @@ err_netdev:
        return rv;
 }
 
-static int
+static void
 mpc52xx_fec_remove(struct platform_device *op)
 {
        struct net_device *ndev;
@@ -998,8 +998,6 @@ mpc52xx_fec_remove(struct platform_device *op)
        release_mem_region(ndev->base_addr, sizeof(struct mpc52xx_fec));
 
        free_netdev(ndev);
-
-       return 0;
 }
 
 #ifdef CONFIG_PM
@@ -1042,7 +1040,7 @@ static struct platform_driver mpc52xx_fec_driver = {
                .of_match_table = mpc52xx_fec_match,
        },
        .probe          = mpc52xx_fec_probe,
-       .remove         = mpc52xx_fec_remove,
+       .remove_new     = mpc52xx_fec_remove,
 #ifdef CONFIG_PM
        .suspend        = mpc52xx_fec_of_suspend,
        .resume         = mpc52xx_fec_of_resume,
index 95f778cce98cbabda9fcb6c950149c84e44f9c1f..61d3776d6750921dd7464b43b05ff71dbab61f1a 100644 (file)
@@ -117,7 +117,7 @@ static int mpc52xx_fec_mdio_probe(struct platform_device *of)
        return err;
 }
 
-static int mpc52xx_fec_mdio_remove(struct platform_device *of)
+static void mpc52xx_fec_mdio_remove(struct platform_device *of)
 {
        struct mii_bus *bus = platform_get_drvdata(of);
        struct mpc52xx_fec_mdio_priv *priv = bus->priv;
@@ -126,8 +126,6 @@ static int mpc52xx_fec_mdio_remove(struct platform_device *of)
        iounmap(priv->regs);
        kfree(priv);
        mdiobus_free(bus);
-
-       return 0;
 }
 
 static const struct of_device_id mpc52xx_fec_mdio_match[] = {
@@ -145,7 +143,7 @@ struct platform_driver mpc52xx_fec_mdio_driver = {
                .of_match_table = mpc52xx_fec_mdio_match,
        },
        .probe = mpc52xx_fec_mdio_probe,
-       .remove = mpc52xx_fec_mdio_remove,
+       .remove_new = mpc52xx_fec_mdio_remove,
 };
 
 /* let fec driver call it, since this has to be registered before it */