Skip to content

Commit 74a5b94

Browse files
Uwe Kleine-Königarndb
authored andcommitted
ARM: 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 (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: Arnd Bergmann <arnd@arndb.de> Acked-by: Shawn Guo <shawnguo@kernel.org> # for imx/mmdc Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.kernel.org/r/20230314103225.2787101-1-u.kleine-koenig@pengutronix.de Signed-off-by: Arnd Bergmann <arnd@arndb.de>
1 parent eeac8ed commit 74a5b94

8 files changed

Lines changed: 16 additions & 30 deletions

File tree

arch/arm/common/locomo.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -494,16 +494,14 @@ static int locomo_probe(struct platform_device *dev)
494494
return __locomo_probe(&dev->dev, mem, irq);
495495
}
496496

497-
static int locomo_remove(struct platform_device *dev)
497+
static void locomo_remove(struct platform_device *dev)
498498
{
499499
struct locomo *lchip = platform_get_drvdata(dev);
500500

501501
if (lchip) {
502502
__locomo_remove(lchip);
503503
platform_set_drvdata(dev, NULL);
504504
}
505-
506-
return 0;
507505
}
508506

509507
/*
@@ -514,7 +512,7 @@ static int locomo_remove(struct platform_device *dev)
514512
*/
515513
static struct platform_driver locomo_device_driver = {
516514
.probe = locomo_probe,
517-
.remove = locomo_remove,
515+
.remove_new = locomo_remove,
518516
#ifdef CONFIG_PM
519517
.suspend = locomo_suspend,
520518
.resume = locomo_resume,

arch/arm/common/sa1111.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,7 @@ static int sa1111_probe(struct platform_device *pdev)
11231123
return __sa1111_probe(&pdev->dev, mem, irq);
11241124
}
11251125

1126-
static int sa1111_remove(struct platform_device *pdev)
1126+
static void sa1111_remove(struct platform_device *pdev)
11271127
{
11281128
struct sa1111 *sachip = platform_get_drvdata(pdev);
11291129

@@ -1135,8 +1135,6 @@ static int sa1111_remove(struct platform_device *pdev)
11351135
__sa1111_remove(sachip);
11361136
platform_set_drvdata(pdev, NULL);
11371137
}
1138-
1139-
return 0;
11401138
}
11411139

11421140
static struct dev_pm_ops sa1111_pm_ops = {
@@ -1155,7 +1153,7 @@ static struct dev_pm_ops sa1111_pm_ops = {
11551153
*/
11561154
static struct platform_driver sa1111_device_driver = {
11571155
.probe = sa1111_probe,
1158-
.remove = sa1111_remove,
1156+
.remove_new = sa1111_remove,
11591157
.driver = {
11601158
.name = "sa1111",
11611159
.pm = &sa1111_pm_ops,

arch/arm/common/scoop.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ static int scoop_probe(struct platform_device *pdev)
236236
return ret;
237237
}
238238

239-
static int scoop_remove(struct platform_device *pdev)
239+
static void scoop_remove(struct platform_device *pdev)
240240
{
241241
struct scoop_dev *sdev = platform_get_drvdata(pdev);
242242

@@ -246,13 +246,11 @@ static int scoop_remove(struct platform_device *pdev)
246246
platform_set_drvdata(pdev, NULL);
247247
iounmap(sdev->base);
248248
kfree(sdev);
249-
250-
return 0;
251249
}
252250

253251
static struct platform_driver scoop_driver = {
254252
.probe = scoop_probe,
255-
.remove = scoop_remove,
253+
.remove_new = scoop_remove,
256254
.suspend = scoop_suspend,
257255
.resume = scoop_resume,
258256
.driver = {

arch/arm/mach-imx/mmdc.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ static int mmdc_pmu_init(struct mmdc_pmu *pmu_mmdc,
456456
return pmu_mmdc->id;
457457
}
458458

459-
static int imx_mmdc_remove(struct platform_device *pdev)
459+
static void imx_mmdc_remove(struct platform_device *pdev)
460460
{
461461
struct mmdc_pmu *pmu_mmdc = platform_get_drvdata(pdev);
462462

@@ -466,7 +466,6 @@ static int imx_mmdc_remove(struct platform_device *pdev)
466466
iounmap(pmu_mmdc->mmdc_base);
467467
clk_disable_unprepare(pmu_mmdc->mmdc_ipg_clk);
468468
kfree(pmu_mmdc);
469-
return 0;
470469
}
471470

472471
static int imx_mmdc_perf_init(struct platform_device *pdev, void __iomem *mmdc_base,
@@ -592,7 +591,7 @@ static struct platform_driver imx_mmdc_driver = {
592591
.of_match_table = imx_mmdc_dt_ids,
593592
},
594593
.probe = imx_mmdc_probe,
595-
.remove = imx_mmdc_remove,
594+
.remove_new = imx_mmdc_remove,
596595
};
597596

598597
static int __init imx_mmdc_init(void)

arch/arm/mach-omap1/omap-dma.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -833,21 +833,19 @@ static int omap_system_dma_probe(struct platform_device *pdev)
833833
return ret;
834834
}
835835

836-
static int omap_system_dma_remove(struct platform_device *pdev)
836+
static void omap_system_dma_remove(struct platform_device *pdev)
837837
{
838838
int dma_irq, irq_rel = 0;
839839

840840
for ( ; irq_rel < dma_chan_count; irq_rel++) {
841841
dma_irq = platform_get_irq(pdev, irq_rel);
842842
free_irq(dma_irq, (void *)(irq_rel + 1));
843843
}
844-
845-
return 0;
846844
}
847845

848846
static struct platform_driver omap_system_dma_driver = {
849847
.probe = omap_system_dma_probe,
850-
.remove = omap_system_dma_remove,
848+
.remove_new = omap_system_dma_remove,
851849
.driver = {
852850
.name = "omap_dma_system"
853851
},

arch/arm/mach-pxa/sharpsl_pm.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,7 @@ static int sharpsl_pm_probe(struct platform_device *pdev)
890890
return 0;
891891
}
892892

893-
static int sharpsl_pm_remove(struct platform_device *pdev)
893+
static void sharpsl_pm_remove(struct platform_device *pdev)
894894
{
895895
suspend_set_ops(NULL);
896896

@@ -917,13 +917,11 @@ static int sharpsl_pm_remove(struct platform_device *pdev)
917917

918918
del_timer_sync(&sharpsl_pm.chrg_full_timer);
919919
del_timer_sync(&sharpsl_pm.ac_timer);
920-
921-
return 0;
922920
}
923921

924922
static struct platform_driver sharpsl_pm_driver = {
925923
.probe = sharpsl_pm_probe,
926-
.remove = sharpsl_pm_remove,
924+
.remove_new = sharpsl_pm_remove,
927925
.suspend = sharpsl_pm_suspend,
928926
.resume = sharpsl_pm_resume,
929927
.driver = {

arch/arm/mach-sa1100/jornada720_ssp.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,18 +175,17 @@ static int jornada_ssp_probe(struct platform_device *dev)
175175
return 0;
176176
};
177177

178-
static int jornada_ssp_remove(struct platform_device *dev)
178+
static void jornada_ssp_remove(struct platform_device *dev)
179179
{
180180
/* Note that this doesn't actually remove the driver, since theres nothing to remove
181181
* It just makes sure everything is turned off */
182182
GPSR = GPIO_GPIO25;
183183
ssp_exit();
184-
return 0;
185184
};
186185

187186
struct platform_driver jornadassp_driver = {
188187
.probe = jornada_ssp_probe,
189-
.remove = jornada_ssp_remove,
188+
.remove_new = jornada_ssp_remove,
190189
.driver = {
191190
.name = "jornada_ssp",
192191
},

arch/arm/mach-sa1100/neponset.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ static int neponset_probe(struct platform_device *dev)
376376
return ret;
377377
}
378378

379-
static int neponset_remove(struct platform_device *dev)
379+
static void neponset_remove(struct platform_device *dev)
380380
{
381381
struct neponset_drvdata *d = platform_get_drvdata(dev);
382382
int irq = platform_get_irq(dev, 0);
@@ -395,8 +395,6 @@ static int neponset_remove(struct platform_device *dev)
395395
nep = NULL;
396396
iounmap(d->base);
397397
kfree(d);
398-
399-
return 0;
400398
}
401399

402400
#ifdef CONFIG_PM_SLEEP
@@ -425,7 +423,7 @@ static const struct dev_pm_ops neponset_pm_ops = {
425423

426424
static struct platform_driver neponset_device_driver = {
427425
.probe = neponset_probe,
428-
.remove = neponset_remove,
426+
.remove_new = neponset_remove,
429427
.driver = {
430428
.name = "neponset",
431429
.pm = PM_OPS,

0 commit comments

Comments
 (0)