Hello,
this series converts all platform drivers below drivers/mfd to use
.remove_new(). Compared to the traditional .remove() callback
.remove_new() returns no value. This is a good thing because the driver
core doesn't (and cannot) cope for errors during remove. The only effect
of a non-zero return value in .remove() is that the driver core emits a
warning. The device is removed anyhow and an early return from .remove()
usually yields resource leaks and/or use-after-free bugs.
See commit 5c5a7680e67b ("platform: Provide a remove callback that
returns no value") for an extended explanation and the eventual goal.
All drivers converted here already returned zero unconditionally in
.remove(), so they are converted here trivially.
Compared to the (implicit) v1[1] I added two review tags and rebased to
today's next/master. Also I failed to Cc: all patches of v1 to lkml.
Best regards
Uwe
[1] https://lore.kernel.org/all/[email protected]
Uwe Kleine-König (18):
mfd: ab8500-sysctrl: Convert to platform remove callback returning
void
mfd: cros_ec_dev: Convert to platform remove callback returning void
mfd: exynos-lpass: Convert to platform remove callback returning void
mfd: fsl-imx25-tsadc: Convert to platform remove callback returning
void
mfd: hi655x-pmic: Convert to platform remove callback returning void
mfd: intel-lpss-acpi: Convert to platform remove callback returning
void
mfd: kempld-core: Convert to platform remove callback returning void
mfd: mcp-sa11x0: Convert to platform remove callback returning void
mfd: mxs-lradc: Convert to platform remove callback returning void
mfd: omap-usb-host: Convert to platform remove callback returning void
mfd: omap-usb-tll: Convert to platform remove callback returning void
mfd: pcf50633-adc: Convert to platform remove callback returning void
mfd: qcom-pm8xxx: Convert to platform remove callback returning void
mfd: sm501: Convert to platform remove callback returning void
mfd: stm32-timers: Convert to platform remove callback returning void
mfd: ti_am335x_tscadc: Convert to platform remove callback returning
void
mfd: tps65911-comparator: Convert to platform remove callback
returning void
mfd: twl4030-audio: Convert to platform remove callback returning void
drivers/mfd/ab8500-sysctrl.c | 6 ++----
drivers/mfd/cros_ec_dev.c | 5 ++---
drivers/mfd/exynos-lpass.c | 6 ++----
drivers/mfd/fsl-imx25-tsadc.c | 6 ++----
drivers/mfd/hi655x-pmic.c | 5 ++---
drivers/mfd/intel-lpss-acpi.c | 6 ++----
drivers/mfd/kempld-core.c | 6 ++----
drivers/mfd/mcp-sa11x0.c | 6 ++----
drivers/mfd/mxs-lradc.c | 6 ++----
drivers/mfd/omap-usb-host.c | 5 ++---
drivers/mfd/omap-usb-tll.c | 5 ++---
drivers/mfd/pcf50633-adc.c | 6 ++----
drivers/mfd/qcom-pm8xxx.c | 6 ++----
drivers/mfd/sm501.c | 6 ++----
drivers/mfd/stm32-timers.c | 6 ++----
drivers/mfd/ti_am335x_tscadc.c | 6 ++----
drivers/mfd/tps65911-comparator.c | 6 ++----
drivers/mfd/twl4030-audio.c | 6 ++----
18 files changed, 36 insertions(+), 68 deletions(-)
base-commit: 4e87148f80d198ba5febcbcc969c6b9471099a09
--
2.42.0
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() will be renamed to .remove().
Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.
Signed-off-by: Uwe Kleine-König <[email protected]>
---
drivers/mfd/omap-usb-host.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 78f1bb55dbc0..ebc62033db16 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -816,13 +816,12 @@ static int usbhs_omap_remove_child(struct device *dev, void *data)
*
* Reverses the effect of usbhs_omap_probe().
*/
-static int usbhs_omap_remove(struct platform_device *pdev)
+static void usbhs_omap_remove(struct platform_device *pdev)
{
pm_runtime_disable(&pdev->dev);
/* remove children */
device_for_each_child(&pdev->dev, NULL, usbhs_omap_remove_child);
- return 0;
}
static const struct dev_pm_ops usbhsomap_dev_pm_ops = {
@@ -845,7 +844,7 @@ static struct platform_driver usbhs_omap_driver = {
.of_match_table = usbhs_omap_dt_ids,
},
.probe = usbhs_omap_probe,
- .remove = usbhs_omap_remove,
+ .remove_new = usbhs_omap_remove,
};
MODULE_AUTHOR("Keshava Munegowda <[email protected]>");
--
2.42.0
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() will be renamed to .remove().
Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.
Signed-off-by: Uwe Kleine-König <[email protected]>
---
drivers/mfd/cros_ec_dev.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c
index 79d393b602bf..603b1cd52785 100644
--- a/drivers/mfd/cros_ec_dev.c
+++ b/drivers/mfd/cros_ec_dev.c
@@ -288,13 +288,12 @@ static int ec_device_probe(struct platform_device *pdev)
return retval;
}
-static int ec_device_remove(struct platform_device *pdev)
+static void ec_device_remove(struct platform_device *pdev)
{
struct cros_ec_dev *ec = dev_get_drvdata(&pdev->dev);
mfd_remove_devices(ec->dev);
device_unregister(&ec->class_dev);
- return 0;
}
static const struct platform_device_id cros_ec_id[] = {
@@ -309,7 +308,7 @@ static struct platform_driver cros_ec_dev_driver = {
},
.id_table = cros_ec_id,
.probe = ec_device_probe,
- .remove = ec_device_remove,
+ .remove_new = ec_device_remove,
};
static int __init cros_ec_dev_init(void)
--
2.42.0
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() will be renamed to .remove().
Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.
Reviewed-by: Konrad Dybcio <[email protected]>
Signed-off-by: Uwe Kleine-König <[email protected]>
---
drivers/mfd/qcom-pm8xxx.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/mfd/qcom-pm8xxx.c b/drivers/mfd/qcom-pm8xxx.c
index 07c531bd1236..8b6285f687da 100644
--- a/drivers/mfd/qcom-pm8xxx.c
+++ b/drivers/mfd/qcom-pm8xxx.c
@@ -585,19 +585,17 @@ static int pm8xxx_remove_child(struct device *dev, void *unused)
return 0;
}
-static int pm8xxx_remove(struct platform_device *pdev)
+static void pm8xxx_remove(struct platform_device *pdev)
{
struct pm_irq_chip *chip = platform_get_drvdata(pdev);
device_for_each_child(&pdev->dev, NULL, pm8xxx_remove_child);
irq_domain_remove(chip->irqdomain);
-
- return 0;
}
static struct platform_driver pm8xxx_driver = {
.probe = pm8xxx_probe,
- .remove = pm8xxx_remove,
+ .remove_new = pm8xxx_remove,
.driver = {
.name = "pm8xxx-core",
.of_match_table = pm8xxx_id_table,
--
2.42.0
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() will be renamed to .remove().
Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.
Signed-off-by: Uwe Kleine-König <[email protected]>
---
drivers/mfd/sm501.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c
index 28027982cf69..b3592982a83b 100644
--- a/drivers/mfd/sm501.c
+++ b/drivers/mfd/sm501.c
@@ -1667,7 +1667,7 @@ static void sm501_pci_remove(struct pci_dev *dev)
pci_disable_device(dev);
}
-static int sm501_plat_remove(struct platform_device *dev)
+static void sm501_plat_remove(struct platform_device *dev)
{
struct sm501_devdata *sm = platform_get_drvdata(dev);
@@ -1675,8 +1675,6 @@ static int sm501_plat_remove(struct platform_device *dev)
iounmap(sm->regs);
release_mem_region(sm->io_res->start, 0x100);
-
- return 0;
}
static const struct pci_device_id sm501_pci_tbl[] = {
@@ -1707,7 +1705,7 @@ static struct platform_driver sm501_plat_driver = {
.of_match_table = of_sm501_match_tbl,
},
.probe = sm501_plat_probe,
- .remove = sm501_plat_remove,
+ .remove_new = sm501_plat_remove,
.suspend = pm_sleep_ptr(sm501_plat_suspend),
.resume = pm_sleep_ptr(sm501_plat_resume),
};
--
2.42.0
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() will be renamed to .remove().
Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.
Signed-off-by: Uwe Kleine-König <[email protected]>
---
drivers/mfd/twl4030-audio.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/mfd/twl4030-audio.c b/drivers/mfd/twl4030-audio.c
index 88002f8941e5..d436ddf661da 100644
--- a/drivers/mfd/twl4030-audio.c
+++ b/drivers/mfd/twl4030-audio.c
@@ -258,12 +258,10 @@ static int twl4030_audio_probe(struct platform_device *pdev)
return ret;
}
-static int twl4030_audio_remove(struct platform_device *pdev)
+static void twl4030_audio_remove(struct platform_device *pdev)
{
mfd_remove_devices(&pdev->dev);
twl4030_audio_dev = NULL;
-
- return 0;
}
static const struct of_device_id twl4030_audio_of_match[] = {
@@ -278,7 +276,7 @@ static struct platform_driver twl4030_audio_driver = {
.of_match_table = twl4030_audio_of_match,
},
.probe = twl4030_audio_probe,
- .remove = twl4030_audio_remove,
+ .remove_new = twl4030_audio_remove,
};
module_platform_driver(twl4030_audio_driver);
--
2.42.0
On Thu, 23 Nov 2023 17:56:28 +0100, Uwe Kleine-König wrote:
> this series converts all platform drivers below drivers/mfd to use
> .remove_new(). Compared to the traditional .remove() callback
> .remove_new() returns no value. This is a good thing because the driver
> core doesn't (and cannot) cope for errors during remove. The only effect
> of a non-zero return value in .remove() is that the driver core emits a
> warning. The device is removed anyhow and an early return from .remove()
> usually yields resource leaks and/or use-after-free bugs.
>
> [...]
Applied, thanks!
[01/18] mfd: ab8500-sysctrl: Convert to platform remove callback returning void
commit: 05ce16c1303acaf2094f55ea248fd0d14119ed8f
[02/18] mfd: cros_ec_dev: Convert to platform remove callback returning void
commit: c86e0818174f506e77dcb7ca0251f18269d79219
[03/18] mfd: exynos-lpass: Convert to platform remove callback returning void
commit: e3468e03a63e8c24a8b2f9f84ed8443268dcccf4
[04/18] mfd: fsl-imx25-tsadc: Convert to platform remove callback returning void
commit: 05d78da532ededbc11889ca5a22b302aaa8b9e1e
[05/18] mfd: hi655x-pmic: Convert to platform remove callback returning void
commit: 30441c456171723d4d40ea86fdc7675a630cb5f8
[06/18] mfd: intel-lpss-acpi: Convert to platform remove callback returning void
commit: 8b7ffe18eb0bf86b21d558c739279a9cb349b78d
[07/18] mfd: kempld-core: Convert to platform remove callback returning void
commit: 5c9d52223920a70becbbdf67cce192917f997319
[08/18] mfd: mcp-sa11x0: Convert to platform remove callback returning void
commit: 0082e145163801002a257c2cbaf2982192ab761e
[09/18] mfd: mxs-lradc: Convert to platform remove callback returning void
commit: f9714ad21b8c01e6964e0638858d37f941dc19ba
[10/18] mfd: omap-usb-host: Convert to platform remove callback returning void
commit: 7e5e828e1fef60673c20b47573054eaa036d1980
[11/18] mfd: omap-usb-tll: Convert to platform remove callback returning void
commit: 6ee0e1844c917fb4e5f314aec2b780f1641375f0
[12/18] mfd: pcf50633-adc: Convert to platform remove callback returning void
commit: 3e6eccaca6923e8d1ac4a0913b3367b5ab94f95c
[13/18] mfd: qcom-pm8xxx: Convert to platform remove callback returning void
commit: 31b895f2528bda4db526dee1942f915f8f34091b
[14/18] mfd: sm501: Convert to platform remove callback returning void
commit: 69fbad222c5caad34f777da33271ccdad3d9504c
[15/18] mfd: stm32-timers: Convert to platform remove callback returning void
commit: 59569bc36fcec1cd62bd2f639784126c87c6fd1e
[16/18] mfd: ti_am335x_tscadc: Convert to platform remove callback returning void
commit: 1dbe13baca338502bf741bbe3b199c07c7d1c5bc
[17/18] mfd: tps65911-comparator: Convert to platform remove callback returning void
commit: 4aa72c8515734c2edf4c6c264aee4925efd97366
[18/18] mfd: twl4030-audio: Convert to platform remove callback returning void
commit: db1e0b072da189db99f905b758676a81bb796a1a
--
Lee Jones [李琼斯]