Skip to content

Commit 231ea97

Browse files
Uwe Kleine-Königdavem330
authored andcommitted
net: ethernet: ti: Convert to platform remove callback returning void
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> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> # cpmac Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent ede778e commit 231ea97

4 files changed

Lines changed: 8 additions & 15 deletions

File tree

drivers/net/ethernet/ti/cpmac.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,22 +1151,20 @@ static int cpmac_probe(struct platform_device *pdev)
11511151
return rc;
11521152
}
11531153

1154-
static int cpmac_remove(struct platform_device *pdev)
1154+
static void cpmac_remove(struct platform_device *pdev)
11551155
{
11561156
struct net_device *dev = platform_get_drvdata(pdev);
11571157

11581158
unregister_netdev(dev);
11591159
free_netdev(dev);
1160-
1161-
return 0;
11621160
}
11631161

11641162
static struct platform_driver cpmac_driver = {
11651163
.driver = {
11661164
.name = "cpmac",
11671165
},
11681166
.probe = cpmac_probe,
1169-
.remove = cpmac_remove,
1167+
.remove_new = cpmac_remove,
11701168
};
11711169

11721170
int __init cpmac_init(void)

drivers/net/ethernet/ti/davinci_emac.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2002,7 +2002,7 @@ static int davinci_emac_probe(struct platform_device *pdev)
20022002
* Called when removing the device driver. We disable clock usage and release
20032003
* the resources taken up by the driver and unregister network device
20042004
*/
2005-
static int davinci_emac_remove(struct platform_device *pdev)
2005+
static void davinci_emac_remove(struct platform_device *pdev)
20062006
{
20072007
struct net_device *ndev = platform_get_drvdata(pdev);
20082008
struct emac_priv *priv = netdev_priv(ndev);
@@ -2022,8 +2022,6 @@ static int davinci_emac_remove(struct platform_device *pdev)
20222022
if (of_phy_is_fixed_link(np))
20232023
of_phy_deregister_fixed_link(np);
20242024
free_netdev(ndev);
2025-
2026-
return 0;
20272025
}
20282026

20292027
static int davinci_emac_suspend(struct device *dev)
@@ -2076,7 +2074,7 @@ static struct platform_driver davinci_emac_driver = {
20762074
.of_match_table = davinci_emac_of_match,
20772075
},
20782076
.probe = davinci_emac_probe,
2079-
.remove = davinci_emac_remove,
2077+
.remove_new = davinci_emac_remove,
20802078
};
20812079

20822080
/**

drivers/net/ethernet/ti/davinci_mdio.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ static int davinci_mdio_probe(struct platform_device *pdev)
673673
return ret;
674674
}
675675

676-
static int davinci_mdio_remove(struct platform_device *pdev)
676+
static void davinci_mdio_remove(struct platform_device *pdev)
677677
{
678678
struct davinci_mdio_data *data = platform_get_drvdata(pdev);
679679

@@ -686,8 +686,6 @@ static int davinci_mdio_remove(struct platform_device *pdev)
686686

687687
pm_runtime_dont_use_autosuspend(&pdev->dev);
688688
pm_runtime_disable(&pdev->dev);
689-
690-
return 0;
691689
}
692690

693691
#ifdef CONFIG_PM
@@ -766,7 +764,7 @@ static struct platform_driver davinci_mdio_driver = {
766764
.of_match_table = of_match_ptr(davinci_mdio_of_mtable),
767765
},
768766
.probe = davinci_mdio_probe,
769-
.remove = davinci_mdio_remove,
767+
.remove_new = davinci_mdio_remove,
770768
};
771769

772770
static int __init davinci_mdio_init(void)

drivers/net/ethernet/ti/netcp_core.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2228,7 +2228,7 @@ static int netcp_probe(struct platform_device *pdev)
22282228
return ret;
22292229
}
22302230

2231-
static int netcp_remove(struct platform_device *pdev)
2231+
static void netcp_remove(struct platform_device *pdev)
22322232
{
22332233
struct netcp_device *netcp_device = platform_get_drvdata(pdev);
22342234
struct netcp_intf *netcp_intf, *netcp_tmp;
@@ -2256,7 +2256,6 @@ static int netcp_remove(struct platform_device *pdev)
22562256
pm_runtime_put_sync(&pdev->dev);
22572257
pm_runtime_disable(&pdev->dev);
22582258
platform_set_drvdata(pdev, NULL);
2259-
return 0;
22602259
}
22612260

22622261
static const struct of_device_id of_match[] = {
@@ -2271,7 +2270,7 @@ static struct platform_driver netcp_driver = {
22712270
.of_match_table = of_match,
22722271
},
22732272
.probe = netcp_probe,
2274-
.remove = netcp_remove,
2273+
.remove_new = netcp_remove,
22752274
};
22762275
module_platform_driver(netcp_driver);
22772276

0 commit comments

Comments
 (0)