Skip to content

Commit e190a0c

Browse files
Uwe Kleine-Königwsakernel
authored andcommitted
i2c: 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. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Acked-by: Alain Volmat <alain.volmat@foss.st.com> Acked-by: Ard Biesheuvel <ardb@kernel.org> Acked-by: Baruch Siach <baruch@tkos.co.il> Acked-by: Florian Fainelli <f.fainelli@gmail.com> Acked-by: Heiko Stuebner <heiko@sntech.de> Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com> Acked-by: Jochen Friedrich <jochen@scram.de> Acked-by: Peter Rosin <peda@axentia.se> Acked-by: Vadim Pasternak <vadimp@nvidia.com> Reviewed-by: Asmaa Mnebhi <asnaa@nvidia.com> Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz> Reviewed-by: Chris Pringle <chris.pringle@phabrix.com> Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com> Reviewed-by: Conor Dooley <conor.dooley@microchip.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Jean Delvare <jdelvare@suse.de> Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com> Reviewed-by: Tali Perry <tali.perry@nuvoton.com> Reviewed-by: Vignesh Raghavendra <vigneshr@ti.com> Signed-off-by: Wolfram Sang <wsa@kernel.org>
1 parent 9561de3 commit e190a0c

88 files changed

Lines changed: 180 additions & 343 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

drivers/i2c/busses/i2c-altera.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -465,14 +465,12 @@ static int altr_i2c_probe(struct platform_device *pdev)
465465
return 0;
466466
}
467467

468-
static int altr_i2c_remove(struct platform_device *pdev)
468+
static void altr_i2c_remove(struct platform_device *pdev)
469469
{
470470
struct altr_i2c_dev *idev = platform_get_drvdata(pdev);
471471

472472
clk_disable_unprepare(idev->i2c_clk);
473473
i2c_del_adapter(&idev->adapter);
474-
475-
return 0;
476474
}
477475

478476
/* Match table for of_platform binding */
@@ -484,7 +482,7 @@ MODULE_DEVICE_TABLE(of, altr_i2c_of_match);
484482

485483
static struct platform_driver altr_i2c_driver = {
486484
.probe = altr_i2c_probe,
487-
.remove = altr_i2c_remove,
485+
.remove_new = altr_i2c_remove,
488486
.driver = {
489487
.name = "altera-i2c",
490488
.of_match_table = altr_i2c_of_match,

drivers/i2c/busses/i2c-amd-mp2-plat.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ static int i2c_amd_probe(struct platform_device *pdev)
322322
return ret;
323323
}
324324

325-
static int i2c_amd_remove(struct platform_device *pdev)
325+
static void i2c_amd_remove(struct platform_device *pdev)
326326
{
327327
struct amd_i2c_dev *i2c_dev = platform_get_drvdata(pdev);
328328
struct amd_i2c_common *i2c_common = &i2c_dev->common;
@@ -336,7 +336,6 @@ static int i2c_amd_remove(struct platform_device *pdev)
336336
i2c_unlock_bus(&i2c_dev->adap, I2C_LOCK_ROOT_ADAPTER);
337337

338338
i2c_del_adapter(&i2c_dev->adap);
339-
return 0;
340339
}
341340

342341
static const struct acpi_device_id i2c_amd_acpi_match[] = {
@@ -347,7 +346,7 @@ MODULE_DEVICE_TABLE(acpi, i2c_amd_acpi_match);
347346

348347
static struct platform_driver i2c_amd_plat_driver = {
349348
.probe = i2c_amd_probe,
350-
.remove = i2c_amd_remove,
349+
.remove_new = i2c_amd_remove,
351350
.driver = {
352351
.name = "i2c_amd_mp2",
353352
.acpi_match_table = ACPI_PTR(i2c_amd_acpi_match),

drivers/i2c/busses/i2c-aspeed.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ static int aspeed_i2c_probe_bus(struct platform_device *pdev)
10611061
return 0;
10621062
}
10631063

1064-
static int aspeed_i2c_remove_bus(struct platform_device *pdev)
1064+
static void aspeed_i2c_remove_bus(struct platform_device *pdev)
10651065
{
10661066
struct aspeed_i2c_bus *bus = platform_get_drvdata(pdev);
10671067
unsigned long flags;
@@ -1077,13 +1077,11 @@ static int aspeed_i2c_remove_bus(struct platform_device *pdev)
10771077
reset_control_assert(bus->rst);
10781078

10791079
i2c_del_adapter(&bus->adap);
1080-
1081-
return 0;
10821080
}
10831081

10841082
static struct platform_driver aspeed_i2c_bus_driver = {
10851083
.probe = aspeed_i2c_probe_bus,
1086-
.remove = aspeed_i2c_remove_bus,
1084+
.remove_new = aspeed_i2c_remove_bus,
10871085
.driver = {
10881086
.name = "aspeed-i2c-bus",
10891087
.of_match_table = aspeed_i2c_bus_of_table,

drivers/i2c/busses/i2c-at91-core.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ static int at91_twi_probe(struct platform_device *pdev)
273273
return 0;
274274
}
275275

276-
static int at91_twi_remove(struct platform_device *pdev)
276+
static void at91_twi_remove(struct platform_device *pdev)
277277
{
278278
struct at91_twi_dev *dev = platform_get_drvdata(pdev);
279279

@@ -282,8 +282,6 @@ static int at91_twi_remove(struct platform_device *pdev)
282282

283283
pm_runtime_disable(dev->dev);
284284
pm_runtime_set_suspended(dev->dev);
285-
286-
return 0;
287285
}
288286

289287
static int __maybe_unused at91_twi_runtime_suspend(struct device *dev)
@@ -342,7 +340,7 @@ static const struct dev_pm_ops __maybe_unused at91_twi_pm = {
342340

343341
static struct platform_driver at91_twi_driver = {
344342
.probe = at91_twi_probe,
345-
.remove = at91_twi_remove,
343+
.remove_new = at91_twi_remove,
346344
.id_table = at91_twi_devtypes,
347345
.driver = {
348346
.name = "at91_i2c",

drivers/i2c/busses/i2c-au1550.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,13 +334,12 @@ i2c_au1550_probe(struct platform_device *pdev)
334334
return 0;
335335
}
336336

337-
static int i2c_au1550_remove(struct platform_device *pdev)
337+
static void i2c_au1550_remove(struct platform_device *pdev)
338338
{
339339
struct i2c_au1550_data *priv = platform_get_drvdata(pdev);
340340

341341
i2c_del_adapter(&priv->adap);
342342
i2c_au1550_disable(priv);
343-
return 0;
344343
}
345344

346345
#ifdef CONFIG_PM
@@ -379,7 +378,7 @@ static struct platform_driver au1xpsc_smbus_driver = {
379378
.pm = AU1XPSC_SMBUS_PMOPS,
380379
},
381380
.probe = i2c_au1550_probe,
382-
.remove = i2c_au1550_remove,
381+
.remove_new = i2c_au1550_remove,
383382
};
384383

385384
module_platform_driver(au1xpsc_smbus_driver);

drivers/i2c/busses/i2c-axxia.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -804,14 +804,12 @@ static int axxia_i2c_probe(struct platform_device *pdev)
804804
return ret;
805805
}
806806

807-
static int axxia_i2c_remove(struct platform_device *pdev)
807+
static void axxia_i2c_remove(struct platform_device *pdev)
808808
{
809809
struct axxia_i2c_dev *idev = platform_get_drvdata(pdev);
810810

811811
clk_disable_unprepare(idev->i2c_clk);
812812
i2c_del_adapter(&idev->adapter);
813-
814-
return 0;
815813
}
816814

817815
/* Match table for of_platform binding */
@@ -824,7 +822,7 @@ MODULE_DEVICE_TABLE(of, axxia_i2c_of_match);
824822

825823
static struct platform_driver axxia_i2c_driver = {
826824
.probe = axxia_i2c_probe,
827-
.remove = axxia_i2c_remove,
825+
.remove_new = axxia_i2c_remove,
828826
.driver = {
829827
.name = "axxia-i2c",
830828
.of_match_table = axxia_i2c_of_match,

drivers/i2c/busses/i2c-bcm-iproc.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,7 +1107,7 @@ static int bcm_iproc_i2c_probe(struct platform_device *pdev)
11071107
return i2c_add_adapter(adap);
11081108
}
11091109

1110-
static int bcm_iproc_i2c_remove(struct platform_device *pdev)
1110+
static void bcm_iproc_i2c_remove(struct platform_device *pdev)
11111111
{
11121112
struct bcm_iproc_i2c_dev *iproc_i2c = platform_get_drvdata(pdev);
11131113

@@ -1123,8 +1123,6 @@ static int bcm_iproc_i2c_remove(struct platform_device *pdev)
11231123

11241124
i2c_del_adapter(&iproc_i2c->adapter);
11251125
bcm_iproc_i2c_enable_disable(iproc_i2c, false);
1126-
1127-
return 0;
11281126
}
11291127

11301128
#ifdef CONFIG_PM_SLEEP
@@ -1260,7 +1258,7 @@ static struct platform_driver bcm_iproc_i2c_driver = {
12601258
.pm = BCM_IPROC_I2C_PM_OPS,
12611259
},
12621260
.probe = bcm_iproc_i2c_probe,
1263-
.remove = bcm_iproc_i2c_remove,
1261+
.remove_new = bcm_iproc_i2c_remove,
12641262
};
12651263
module_platform_driver(bcm_iproc_i2c_driver);
12661264

drivers/i2c/busses/i2c-bcm-kona.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -859,13 +859,11 @@ static int bcm_kona_i2c_probe(struct platform_device *pdev)
859859
return rc;
860860
}
861861

862-
static int bcm_kona_i2c_remove(struct platform_device *pdev)
862+
static void bcm_kona_i2c_remove(struct platform_device *pdev)
863863
{
864864
struct bcm_kona_i2c_dev *dev = platform_get_drvdata(pdev);
865865

866866
i2c_del_adapter(&dev->adapter);
867-
868-
return 0;
869867
}
870868

871869
static const struct of_device_id bcm_kona_i2c_of_match[] = {
@@ -880,7 +878,7 @@ static struct platform_driver bcm_kona_i2c_driver = {
880878
.of_match_table = bcm_kona_i2c_of_match,
881879
},
882880
.probe = bcm_kona_i2c_probe,
883-
.remove = bcm_kona_i2c_remove,
881+
.remove_new = bcm_kona_i2c_remove,
884882
};
885883
module_platform_driver(bcm_kona_i2c_driver);
886884

drivers/i2c/busses/i2c-bcm2835.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ static int bcm2835_i2c_probe(struct platform_device *pdev)
503503
return ret;
504504
}
505505

506-
static int bcm2835_i2c_remove(struct platform_device *pdev)
506+
static void bcm2835_i2c_remove(struct platform_device *pdev)
507507
{
508508
struct bcm2835_i2c_dev *i2c_dev = platform_get_drvdata(pdev);
509509

@@ -512,8 +512,6 @@ static int bcm2835_i2c_remove(struct platform_device *pdev)
512512

513513
free_irq(i2c_dev->irq, i2c_dev);
514514
i2c_del_adapter(&i2c_dev->adapter);
515-
516-
return 0;
517515
}
518516

519517
static const struct of_device_id bcm2835_i2c_of_match[] = {
@@ -525,7 +523,7 @@ MODULE_DEVICE_TABLE(of, bcm2835_i2c_of_match);
525523

526524
static struct platform_driver bcm2835_i2c_driver = {
527525
.probe = bcm2835_i2c_probe,
528-
.remove = bcm2835_i2c_remove,
526+
.remove_new = bcm2835_i2c_remove,
529527
.driver = {
530528
.name = "i2c-bcm2835",
531529
.of_match_table = bcm2835_i2c_of_match,

drivers/i2c/busses/i2c-brcmstb.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -690,12 +690,11 @@ static int brcmstb_i2c_probe(struct platform_device *pdev)
690690
return rc;
691691
}
692692

693-
static int brcmstb_i2c_remove(struct platform_device *pdev)
693+
static void brcmstb_i2c_remove(struct platform_device *pdev)
694694
{
695695
struct brcmstb_i2c_dev *dev = platform_get_drvdata(pdev);
696696

697697
i2c_del_adapter(&dev->adapter);
698-
return 0;
699698
}
700699

701700
#ifdef CONFIG_PM_SLEEP
@@ -736,7 +735,7 @@ static struct platform_driver brcmstb_i2c_driver = {
736735
.pm = &brcmstb_i2c_pm,
737736
},
738737
.probe = brcmstb_i2c_probe,
739-
.remove = brcmstb_i2c_remove,
738+
.remove_new = brcmstb_i2c_remove,
740739
};
741740
module_platform_driver(brcmstb_i2c_driver);
742741

0 commit comments

Comments
 (0)