Skip to content

Commit 68ace16

Browse files
Uwe Kleine-Königdavem330
authored andcommitted
net: dsa: ocelot: 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: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 9764bba commit 68ace16

2 files changed

Lines changed: 6 additions & 10 deletions

File tree

drivers/net/dsa/ocelot/ocelot_ext.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,19 +115,17 @@ static int ocelot_ext_probe(struct platform_device *pdev)
115115
return err;
116116
}
117117

118-
static int ocelot_ext_remove(struct platform_device *pdev)
118+
static void ocelot_ext_remove(struct platform_device *pdev)
119119
{
120120
struct felix *felix = dev_get_drvdata(&pdev->dev);
121121

122122
if (!felix)
123-
return 0;
123+
return;
124124

125125
dsa_unregister_switch(felix->ds);
126126

127127
kfree(felix->ds);
128128
kfree(felix);
129-
130-
return 0;
131129
}
132130

133131
static void ocelot_ext_shutdown(struct platform_device *pdev)
@@ -154,7 +152,7 @@ static struct platform_driver ocelot_ext_switch_driver = {
154152
.of_match_table = ocelot_ext_switch_of_match,
155153
},
156154
.probe = ocelot_ext_probe,
157-
.remove = ocelot_ext_remove,
155+
.remove_new = ocelot_ext_remove,
158156
.shutdown = ocelot_ext_shutdown,
159157
};
160158
module_platform_driver(ocelot_ext_switch_driver);

drivers/net/dsa/ocelot/seville_vsc9953.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,19 +1029,17 @@ static int seville_probe(struct platform_device *pdev)
10291029
return err;
10301030
}
10311031

1032-
static int seville_remove(struct platform_device *pdev)
1032+
static void seville_remove(struct platform_device *pdev)
10331033
{
10341034
struct felix *felix = platform_get_drvdata(pdev);
10351035

10361036
if (!felix)
1037-
return 0;
1037+
return;
10381038

10391039
dsa_unregister_switch(felix->ds);
10401040

10411041
kfree(felix->ds);
10421042
kfree(felix);
1043-
1044-
return 0;
10451043
}
10461044

10471045
static void seville_shutdown(struct platform_device *pdev)
@@ -1064,7 +1062,7 @@ MODULE_DEVICE_TABLE(of, seville_of_match);
10641062

10651063
static struct platform_driver seville_vsc9953_driver = {
10661064
.probe = seville_probe,
1067-
.remove = seville_remove,
1065+
.remove_new = seville_remove,
10681066
.shutdown = seville_shutdown,
10691067
.driver = {
10701068
.name = "mscc_seville",

0 commit comments

Comments
 (0)