Hello,
this series adapts the platform drivers below drivers/staging to use the .remove_new() callback. 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 a resource leak.
By changing the remove callback to return void driver authors cannot reasonably assume any more that there is some kind of cleanup later.
All drivers in staging already return zero in their remove callback, so they can be trivially converted.
The changes to the individual drivers are all orthogonal. If I need to resend some patches because of some review feedback, I'd like to only send the patches that actually needed changes, so please pick up the remaining patches that don't need changing to reduce the amount of mail.
Best regards Uwe
Uwe Kleine-König (24): staging: axis-fifo: Convert to platform remove callback returning void staging: emxx_udc: Convert to platform remove callback returning void staging: fieldbus: arcx-anybus: Convert to platform remove callback returning void staging: greybus: arche-apb-ctrl: Convert to platform remove callback returning void staging: greybus: arche: Convert to platform remove callback returning void staging: media: atmel-sama5d2-isc: Convert to platform remove callback returning void staging: media: atmel-sama7g5-isc: Convert to platform remove callback returning void staging: media: imx-media-csi: Convert to platform remove callback returning void staging: media: imx-media-dev: Convert to platform remove callback returning void staging: media: imx6-mipi-csi2: Convert to platform remove callback returning void staging: media: imx8mq-mipi-csi2: Convert to platform remove callback returning void staging: media: meson: vdec: Convert to platform remove callback returning void staging: media: omap4iss: Convert to platform remove callback returning void staging: media: rkvdec: Convert to platform remove callback returning void staging: media: sunxi: cedrus: Convert to platform remove callback returning void staging: media: sun6i-isp: Convert to platform remove callback returning void staging: most: dim2: Convert to platform remove callback returning void staging: nvec: Convert to platform remove callback returning void staging: nvec: nvec_kbd: Convert to platform remove callback returning void staging: nvec_power: Convert to platform remove callback returning void staging: nvec_ps2: Convert to platform remove callback returning void staging: octeon: ethernet: Convert to platform remove callback returning void staging: vc04_services: bcm2835-camera: Convert to platform remove callback returning void staging: vc04_services: vchiq_arm: Convert to platform remove callback returning void
drivers/staging/axis-fifo/axis-fifo.c | 6 ++---- drivers/staging/emxx_udc/emxx_udc.c | 6 ++---- drivers/staging/fieldbus/anybuss/arcx-anybus.c | 5 ++--- drivers/staging/greybus/arche-apb-ctrl.c | 6 ++---- drivers/staging/greybus/arche-platform.c | 6 ++---- drivers/staging/media/deprecated/atmel/atmel-sama5d2-isc.c | 6 ++---- drivers/staging/media/deprecated/atmel/atmel-sama7g5-isc.c | 6 ++---- drivers/staging/media/imx/imx-media-csi.c | 6 ++---- drivers/staging/media/imx/imx-media-dev.c | 6 ++---- drivers/staging/media/imx/imx6-mipi-csi2.c | 6 ++---- drivers/staging/media/imx/imx8mq-mipi-csi2.c | 6 ++---- drivers/staging/media/meson/vdec/vdec.c | 6 ++---- drivers/staging/media/omap4iss/iss.c | 6 ++---- drivers/staging/media/rkvdec/rkvdec.c | 5 ++--- drivers/staging/media/sunxi/cedrus/cedrus.c | 6 ++---- drivers/staging/media/sunxi/sun6i-isp/sun6i_isp.c | 6 ++---- drivers/staging/most/dim2/dim2.c | 6 ++---- drivers/staging/nvec/nvec.c | 6 ++---- drivers/staging/nvec/nvec_kbd.c | 6 ++---- drivers/staging/nvec/nvec_power.c | 6 ++---- drivers/staging/nvec/nvec_ps2.c | 6 ++---- drivers/staging/octeon/ethernet.c | 5 ++--- .../staging/vc04_services/bcm2835-camera/bcm2835-camera.c | 6 ++---- .../staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 6 ++---- 24 files changed, 48 insertions(+), 93 deletions(-)
base-commit: fe15c26ee26efa11741a7b632e9f23b01aca4cc6
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.
Signed-off-by: Uwe Kleine-König u.kleine-koenig@pengutronix.de --- drivers/staging/greybus/arche-apb-ctrl.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/greybus/arche-apb-ctrl.c b/drivers/staging/greybus/arche-apb-ctrl.c index 45afa208d004..8541995008da 100644 --- a/drivers/staging/greybus/arche-apb-ctrl.c +++ b/drivers/staging/greybus/arche-apb-ctrl.c @@ -419,13 +419,11 @@ static int arche_apb_ctrl_probe(struct platform_device *pdev) return 0; }
-static int arche_apb_ctrl_remove(struct platform_device *pdev) +static void arche_apb_ctrl_remove(struct platform_device *pdev) { device_remove_file(&pdev->dev, &dev_attr_state); poweroff_seq(pdev); platform_set_drvdata(pdev, NULL); - - return 0; }
static int __maybe_unused arche_apb_ctrl_suspend(struct device *dev) @@ -471,7 +469,7 @@ static const struct of_device_id arche_apb_ctrl_of_match[] = {
static struct platform_driver arche_apb_ctrl_device_driver = { .probe = arche_apb_ctrl_probe, - .remove = arche_apb_ctrl_remove, + .remove_new = arche_apb_ctrl_remove, .shutdown = arche_apb_ctrl_shutdown, .driver = { .name = "arche-apb-ctrl",
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.
Signed-off-by: Uwe Kleine-König u.kleine-koenig@pengutronix.de --- drivers/staging/greybus/arche-platform.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/greybus/arche-platform.c b/drivers/staging/greybus/arche-platform.c index fcbd5f71eff2..ebe835f25d13 100644 --- a/drivers/staging/greybus/arche-platform.c +++ b/drivers/staging/greybus/arche-platform.c @@ -559,7 +559,7 @@ static int arche_remove_child(struct device *dev, void *unused) return 0; }
-static int arche_platform_remove(struct platform_device *pdev) +static void arche_platform_remove(struct platform_device *pdev) { struct arche_platform_drvdata *arche_pdata = platform_get_drvdata(pdev);
@@ -570,8 +570,6 @@ static int arche_platform_remove(struct platform_device *pdev)
if (usb3613_hub_mode_ctrl(false)) dev_warn(arche_pdata->dev, "failed to control hub device\n"); - /* TODO: Should we do anything more here ?? */ - return 0; }
static __maybe_unused int arche_platform_suspend(struct device *dev) @@ -631,7 +629,7 @@ MODULE_DEVICE_TABLE(of, arche_combined_id);
static struct platform_driver arche_platform_device_driver = { .probe = arche_platform_probe, - .remove = arche_platform_remove, + .remove_new = arche_platform_remove, .shutdown = arche_platform_shutdown, .driver = { .name = "arche-platform-ctrl",
On Mon, Apr 03, 2023 at 05:39:50PM +0200, Uwe Kleine-König wrote:
Hello,
this series adapts the platform drivers below drivers/staging to use the .remove_new() callback. 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 a resource leak.
By changing the remove callback to return void driver authors cannot reasonably assume any more that there is some kind of cleanup later.
All drivers in staging already return zero in their remove callback, so they can be trivially converted.
The changes to the individual drivers are all orthogonal. If I need to resend some patches because of some review feedback, I'd like to only send the patches that actually needed changes, so please pick up the remaining patches that don't need changing to reduce the amount of mail.
Note, I can't take drivers/staging/media/ patches, those go through the v4l maintainer's tree. So I've taken the non-media patches from this series now.
thanks,
greg k-h