Merge branch 'net-ethernet-convert-to-platform-remove-callback-returning-void'
Uwe Kleine-König says: ==================== net: ethernet: Convert to platform remove callback returning void in (implicit) v1 of this series (https://lore.kernel.org/netdev/20231117091655.872426-1-u.kleine-koenig@pengutronix.de) I tried to address the resource leaks in the three cpsw drivers. However this is hard to get right without being able to test the changes. So here comes a series that just converts all drivers below drivers/net/ethernet to use .remove_new() and adds a comment about the potential leaks for someone else to fix the problem. See commit 5c5a7680e67b ("platform: Provide a remove callback that returns no value") for an extended explanation and the eventual goal. The TL;DR; is to prevent bugs like the three noticed here. Note this series results in no change of behaviour apart from improving the error message for the three cpsw drivers from remove callback returned a non-zero value. This will be ignored. to Failed to resume device (-ESOMETHING) ==================== Link: https://lore.kernel.org/r/20231128173823.867512-1-u.kleine-koenig@pengutronix.de Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
commit
7e02226863
@ -633,7 +633,7 @@ out_netdev:
|
||||
return err;
|
||||
}
|
||||
|
||||
static s32 nps_enet_remove(struct platform_device *pdev)
|
||||
static void nps_enet_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct net_device *ndev = platform_get_drvdata(pdev);
|
||||
struct nps_enet_priv *priv = netdev_priv(ndev);
|
||||
@ -641,8 +641,6 @@ static s32 nps_enet_remove(struct platform_device *pdev)
|
||||
unregister_netdev(ndev);
|
||||
netif_napi_del(&priv->napi);
|
||||
free_netdev(ndev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct of_device_id nps_enet_dt_ids[] = {
|
||||
@ -653,7 +651,7 @@ MODULE_DEVICE_TABLE(of, nps_enet_dt_ids);
|
||||
|
||||
static struct platform_driver nps_enet_driver = {
|
||||
.probe = nps_enet_probe,
|
||||
.remove = nps_enet_remove,
|
||||
.remove_new = nps_enet_remove,
|
||||
.driver = {
|
||||
.name = DRV_NAME,
|
||||
.of_match_table = nps_enet_dt_ids,
|
||||
|
@ -3028,7 +3028,7 @@ err_pm_clear:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int am65_cpsw_nuss_remove(struct platform_device *pdev)
|
||||
static void am65_cpsw_nuss_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
struct am65_cpsw_common *common;
|
||||
@ -3037,8 +3037,14 @@ static int am65_cpsw_nuss_remove(struct platform_device *pdev)
|
||||
common = dev_get_drvdata(dev);
|
||||
|
||||
ret = pm_runtime_resume_and_get(&pdev->dev);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
if (ret < 0) {
|
||||
/* Note, if this error path is taken, we're leaking some
|
||||
* resources.
|
||||
*/
|
||||
dev_err(&pdev->dev, "Failed to resume device (%pe)\n",
|
||||
ERR_PTR(ret));
|
||||
return;
|
||||
}
|
||||
|
||||
am65_cpsw_unregister_devlink(common);
|
||||
am65_cpsw_unregister_notifiers(common);
|
||||
@ -3056,7 +3062,6 @@ static int am65_cpsw_nuss_remove(struct platform_device *pdev)
|
||||
|
||||
pm_runtime_put_sync(&pdev->dev);
|
||||
pm_runtime_disable(&pdev->dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int am65_cpsw_nuss_suspend(struct device *dev)
|
||||
@ -3156,7 +3161,7 @@ static struct platform_driver am65_cpsw_nuss_driver = {
|
||||
.pm = &am65_cpsw_nuss_dev_pm_ops,
|
||||
},
|
||||
.probe = am65_cpsw_nuss_probe,
|
||||
.remove = am65_cpsw_nuss_remove,
|
||||
.remove_new = am65_cpsw_nuss_remove,
|
||||
};
|
||||
|
||||
module_platform_driver(am65_cpsw_nuss_driver);
|
||||
|
@ -1722,14 +1722,20 @@ clean_runtime_disable_ret:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int cpsw_remove(struct platform_device *pdev)
|
||||
static void cpsw_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct cpsw_common *cpsw = platform_get_drvdata(pdev);
|
||||
int i, ret;
|
||||
|
||||
ret = pm_runtime_resume_and_get(&pdev->dev);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
if (ret < 0) {
|
||||
/* Note, if this error path is taken, we're leaking some
|
||||
* resources.
|
||||
*/
|
||||
dev_err(&pdev->dev, "Failed to resume device (%pe)\n",
|
||||
ERR_PTR(ret));
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < cpsw->data.slaves; i++)
|
||||
if (cpsw->slaves[i].ndev)
|
||||
@ -1740,7 +1746,6 @@ static int cpsw_remove(struct platform_device *pdev)
|
||||
cpsw_remove_dt(pdev);
|
||||
pm_runtime_put_sync(&pdev->dev);
|
||||
pm_runtime_disable(&pdev->dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
@ -1795,7 +1800,7 @@ static struct platform_driver cpsw_driver = {
|
||||
.of_match_table = cpsw_of_mtable,
|
||||
},
|
||||
.probe = cpsw_probe,
|
||||
.remove = cpsw_remove,
|
||||
.remove_new = cpsw_remove,
|
||||
};
|
||||
|
||||
module_platform_driver(cpsw_driver);
|
||||
|
@ -2037,14 +2037,20 @@ clean_dt_ret:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int cpsw_remove(struct platform_device *pdev)
|
||||
static void cpsw_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct cpsw_common *cpsw = platform_get_drvdata(pdev);
|
||||
int ret;
|
||||
|
||||
ret = pm_runtime_resume_and_get(&pdev->dev);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
if (ret < 0) {
|
||||
/* Note, if this error path is taken, we're leaking some
|
||||
* resources.
|
||||
*/
|
||||
dev_err(&pdev->dev, "Failed to resume device (%pe)\n",
|
||||
ERR_PTR(ret));
|
||||
return;
|
||||
}
|
||||
|
||||
cpsw_unregister_notifiers(cpsw);
|
||||
cpsw_unregister_devlink(cpsw);
|
||||
@ -2055,7 +2061,6 @@ static int cpsw_remove(struct platform_device *pdev)
|
||||
cpsw_remove_dt(cpsw);
|
||||
pm_runtime_put_sync(&pdev->dev);
|
||||
pm_runtime_disable(&pdev->dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __maybe_unused cpsw_suspend(struct device *dev)
|
||||
@ -2116,7 +2121,7 @@ static struct platform_driver cpsw_driver = {
|
||||
.of_match_table = cpsw_of_mtable,
|
||||
},
|
||||
.probe = cpsw_probe,
|
||||
.remove = cpsw_remove,
|
||||
.remove_new = cpsw_remove,
|
||||
};
|
||||
|
||||
module_platform_driver(cpsw_driver);
|
||||
|
Loading…
x
Reference in New Issue
Block a user