Skip to content

Commit 2a3e163

Browse files
Merge patch series "can: Convert to platform remove callback returning void"
Uwe Kleine-König <u.kleine-koenig@pengutronix.de> says: this series converts the drivers below drivers/net/can to the .remove_new() callback of struct platform_driver(). The motivation is to make the remove callback less prone for errors and wrong assumptions. See commit 5c5a768 ("platform: Provide a remove callback that returns no value") for a more detailed rationale. All drivers already returned zero unconditionally in their .remove() callback, so converting them to .remove_new() is trivial. Link: https://lore.kernel.org/r/20230512212725.143824-1-u.kleine-koenig@pengutronix.de Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2 parents 6882011 + 0816e1d commit 2a3e163

File tree

20 files changed

+40
-77
lines changed

20 files changed

+40
-77
lines changed

drivers/net/can/at91_can.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,7 +1346,7 @@ static int at91_can_probe(struct platform_device *pdev)
13461346
return err;
13471347
}
13481348

1349-
static int at91_can_remove(struct platform_device *pdev)
1349+
static void at91_can_remove(struct platform_device *pdev)
13501350
{
13511351
struct net_device *dev = platform_get_drvdata(pdev);
13521352
struct at91_priv *priv = netdev_priv(dev);
@@ -1362,8 +1362,6 @@ static int at91_can_remove(struct platform_device *pdev)
13621362
clk_put(priv->clk);
13631363

13641364
free_candev(dev);
1365-
1366-
return 0;
13671365
}
13681366

13691367
static const struct platform_device_id at91_can_id_table[] = {
@@ -1381,7 +1379,7 @@ MODULE_DEVICE_TABLE(platform, at91_can_id_table);
13811379

13821380
static struct platform_driver at91_can_driver = {
13831381
.probe = at91_can_probe,
1384-
.remove = at91_can_remove,
1382+
.remove_new = at91_can_remove,
13851383
.driver = {
13861384
.name = KBUILD_MODNAME,
13871385
.of_match_table = of_match_ptr(at91_can_dt_ids),

drivers/net/can/bxcan.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ static int bxcan_probe(struct platform_device *pdev)
10211021
return err;
10221022
}
10231023

1024-
static int bxcan_remove(struct platform_device *pdev)
1024+
static void bxcan_remove(struct platform_device *pdev)
10251025
{
10261026
struct net_device *ndev = platform_get_drvdata(pdev);
10271027
struct bxcan_priv *priv = netdev_priv(ndev);
@@ -1030,7 +1030,6 @@ static int bxcan_remove(struct platform_device *pdev)
10301030
clk_disable_unprepare(priv->clk);
10311031
can_rx_offload_del(&priv->offload);
10321032
free_candev(ndev);
1033-
return 0;
10341033
}
10351034

10361035
static int __maybe_unused bxcan_suspend(struct device *dev)
@@ -1082,7 +1081,7 @@ static struct platform_driver bxcan_driver = {
10821081
.of_match_table = bxcan_of_match,
10831082
},
10841083
.probe = bxcan_probe,
1085-
.remove = bxcan_remove,
1084+
.remove_new = bxcan_remove,
10861085
};
10871086

10881087
module_platform_driver(bxcan_driver);

drivers/net/can/c_can/c_can_platform.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -410,16 +410,14 @@ static int c_can_plat_probe(struct platform_device *pdev)
410410
return ret;
411411
}
412412

413-
static int c_can_plat_remove(struct platform_device *pdev)
413+
static void c_can_plat_remove(struct platform_device *pdev)
414414
{
415415
struct net_device *dev = platform_get_drvdata(pdev);
416416
struct c_can_priv *priv = netdev_priv(dev);
417417

418418
unregister_c_can_dev(dev);
419419
pm_runtime_disable(priv->device);
420420
free_c_can_dev(dev);
421-
422-
return 0;
423421
}
424422

425423
#ifdef CONFIG_PM
@@ -487,7 +485,7 @@ static struct platform_driver c_can_plat_driver = {
487485
.of_match_table = c_can_of_table,
488486
},
489487
.probe = c_can_plat_probe,
490-
.remove = c_can_plat_remove,
488+
.remove_new = c_can_plat_remove,
491489
.suspend = c_can_suspend,
492490
.resume = c_can_resume,
493491
.id_table = c_can_id_table,

drivers/net/can/cc770/cc770_isa.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ static int cc770_isa_probe(struct platform_device *pdev)
285285
return err;
286286
}
287287

288-
static int cc770_isa_remove(struct platform_device *pdev)
288+
static void cc770_isa_remove(struct platform_device *pdev)
289289
{
290290
struct net_device *dev = platform_get_drvdata(pdev);
291291
struct cc770_priv *priv = netdev_priv(dev);
@@ -303,13 +303,11 @@ static int cc770_isa_remove(struct platform_device *pdev)
303303
release_region(port[idx], CC770_IOSIZE);
304304
}
305305
free_cc770dev(dev);
306-
307-
return 0;
308306
}
309307

310308
static struct platform_driver cc770_isa_driver = {
311309
.probe = cc770_isa_probe,
312-
.remove = cc770_isa_remove,
310+
.remove_new = cc770_isa_remove,
313311
.driver = {
314312
.name = KBUILD_MODNAME,
315313
},

drivers/net/can/cc770/cc770_platform.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ static int cc770_platform_probe(struct platform_device *pdev)
230230
return err;
231231
}
232232

233-
static int cc770_platform_remove(struct platform_device *pdev)
233+
static void cc770_platform_remove(struct platform_device *pdev)
234234
{
235235
struct net_device *dev = platform_get_drvdata(pdev);
236236
struct cc770_priv *priv = netdev_priv(dev);
@@ -242,8 +242,6 @@ static int cc770_platform_remove(struct platform_device *pdev)
242242

243243
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
244244
release_mem_region(mem->start, resource_size(mem));
245-
246-
return 0;
247245
}
248246

249247
static const struct of_device_id cc770_platform_table[] = {
@@ -259,7 +257,7 @@ static struct platform_driver cc770_platform_driver = {
259257
.of_match_table = cc770_platform_table,
260258
},
261259
.probe = cc770_platform_probe,
262-
.remove = cc770_platform_remove,
260+
.remove_new = cc770_platform_remove,
263261
};
264262

265263
module_platform_driver(cc770_platform_driver);

drivers/net/can/ctucanfd/ctucanfd_platform.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ static int ctucan_platform_probe(struct platform_device *pdev)
8686
* This function frees all the resources allocated to the device.
8787
* Return: 0 always
8888
*/
89-
static int ctucan_platform_remove(struct platform_device *pdev)
89+
static void ctucan_platform_remove(struct platform_device *pdev)
9090
{
9191
struct net_device *ndev = platform_get_drvdata(pdev);
9292
struct ctucan_priv *priv = netdev_priv(ndev);
@@ -97,8 +97,6 @@ static int ctucan_platform_remove(struct platform_device *pdev)
9797
pm_runtime_disable(&pdev->dev);
9898
netif_napi_del(&priv->napi);
9999
free_candev(ndev);
100-
101-
return 0;
102100
}
103101

104102
static SIMPLE_DEV_PM_OPS(ctucan_platform_pm_ops, ctucan_suspend, ctucan_resume);
@@ -113,7 +111,7 @@ MODULE_DEVICE_TABLE(of, ctucan_of_match);
113111

114112
static struct platform_driver ctucanfd_driver = {
115113
.probe = ctucan_platform_probe,
116-
.remove = ctucan_platform_remove,
114+
.remove_new = ctucan_platform_remove,
117115
.driver = {
118116
.name = DRV_NAME,
119117
.pm = &ctucan_platform_pm_ops,

drivers/net/can/flexcan/flexcan-core.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2218,7 +2218,7 @@ static int flexcan_probe(struct platform_device *pdev)
22182218
return err;
22192219
}
22202220

2221-
static int flexcan_remove(struct platform_device *pdev)
2221+
static void flexcan_remove(struct platform_device *pdev)
22222222
{
22232223
struct net_device *dev = platform_get_drvdata(pdev);
22242224

@@ -2227,8 +2227,6 @@ static int flexcan_remove(struct platform_device *pdev)
22272227
unregister_flexcandev(dev);
22282228
pm_runtime_disable(&pdev->dev);
22292229
free_candev(dev);
2230-
2231-
return 0;
22322230
}
22332231

22342232
static int __maybe_unused flexcan_suspend(struct device *device)
@@ -2379,7 +2377,7 @@ static struct platform_driver flexcan_driver = {
23792377
.of_match_table = flexcan_of_match,
23802378
},
23812379
.probe = flexcan_probe,
2382-
.remove = flexcan_remove,
2380+
.remove_new = flexcan_remove,
23832381
.id_table = flexcan_id_table,
23842382
};
23852383

drivers/net/can/grcan.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,7 +1696,7 @@ static int grcan_probe(struct platform_device *ofdev)
16961696
return err;
16971697
}
16981698

1699-
static int grcan_remove(struct platform_device *ofdev)
1699+
static void grcan_remove(struct platform_device *ofdev)
17001700
{
17011701
struct net_device *dev = platform_get_drvdata(ofdev);
17021702
struct grcan_priv *priv = netdev_priv(dev);
@@ -1706,8 +1706,6 @@ static int grcan_remove(struct platform_device *ofdev)
17061706
irq_dispose_mapping(dev->irq);
17071707
netif_napi_del(&priv->napi);
17081708
free_candev(dev);
1709-
1710-
return 0;
17111709
}
17121710

17131711
static const struct of_device_id grcan_match[] = {
@@ -1726,7 +1724,7 @@ static struct platform_driver grcan_driver = {
17261724
.of_match_table = grcan_match,
17271725
},
17281726
.probe = grcan_probe,
1729-
.remove = grcan_remove,
1727+
.remove_new = grcan_remove,
17301728
};
17311729

17321730
module_platform_driver(grcan_driver);

drivers/net/can/ifi_canfd/ifi_canfd.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,15 +1013,13 @@ static int ifi_canfd_plat_probe(struct platform_device *pdev)
10131013
return ret;
10141014
}
10151015

1016-
static int ifi_canfd_plat_remove(struct platform_device *pdev)
1016+
static void ifi_canfd_plat_remove(struct platform_device *pdev)
10171017
{
10181018
struct net_device *ndev = platform_get_drvdata(pdev);
10191019

10201020
unregister_candev(ndev);
10211021
platform_set_drvdata(pdev, NULL);
10221022
free_candev(ndev);
1023-
1024-
return 0;
10251023
}
10261024

10271025
static const struct of_device_id ifi_canfd_of_table[] = {
@@ -1036,7 +1034,7 @@ static struct platform_driver ifi_canfd_plat_driver = {
10361034
.of_match_table = ifi_canfd_of_table,
10371035
},
10381036
.probe = ifi_canfd_plat_probe,
1039-
.remove = ifi_canfd_plat_remove,
1037+
.remove_new = ifi_canfd_plat_remove,
10401038
};
10411039

10421040
module_platform_driver(ifi_canfd_plat_driver);

drivers/net/can/janz-ican3.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2023,7 +2023,7 @@ static int ican3_probe(struct platform_device *pdev)
20232023
return ret;
20242024
}
20252025

2026-
static int ican3_remove(struct platform_device *pdev)
2026+
static void ican3_remove(struct platform_device *pdev)
20272027
{
20282028
struct net_device *ndev = platform_get_drvdata(pdev);
20292029
struct ican3_dev *mod = netdev_priv(ndev);
@@ -2042,16 +2042,14 @@ static int ican3_remove(struct platform_device *pdev)
20422042
iounmap(mod->dpm);
20432043

20442044
free_candev(ndev);
2045-
2046-
return 0;
20472045
}
20482046

20492047
static struct platform_driver ican3_driver = {
20502048
.driver = {
20512049
.name = DRV_NAME,
20522050
},
20532051
.probe = ican3_probe,
2054-
.remove = ican3_remove,
2052+
.remove_new = ican3_remove,
20552053
};
20562054

20572055
module_platform_driver(ican3_driver);

0 commit comments

Comments
 (0)