Message ID | 20231102165640.3307820-34-u.kleine-koenig@pengutronix.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | drm: Convert to platform remove callback returning void | expand |
On 02/11/2023 18:56, Uwe Kleine-König wrote: > 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. > > There is one error path in tilcdc_pdev_remove() that potentially could > yield a non-zero return code. In this case an error message describing > the failure is emitted now instead of > > remove callback returned a non-zero value. This will be ignored. > > before. Otherwise there is no difference. Also note that currently > tilcdc_get_external_components() doesn't return negative values. > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> > --- > drivers/gpu/drm/tilcdc/tilcdc_drv.c | 9 ++++----- > 1 file changed, 4 insertions(+), 5 deletions(-) > > diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c > index 8ebd7134ee21..137cd9f62e9f 100644 > --- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c > +++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c > @@ -570,19 +570,18 @@ static int tilcdc_pdev_probe(struct platform_device *pdev) > match); > } > > -static int tilcdc_pdev_remove(struct platform_device *pdev) > +static void tilcdc_pdev_remove(struct platform_device *pdev) > { > int ret; > > ret = tilcdc_get_external_components(&pdev->dev, NULL); > if (ret < 0) > - return ret; > + dev_err(&pdev->dev, "tilcdc_get_external_components() failed (%pe)\n", > + ERR_PTR(ret)); > else if (ret == 0) > tilcdc_fini(platform_get_drvdata(pdev)); > else > component_master_del(&pdev->dev, &tilcdc_comp_ops); > - > - return 0; > } > > static void tilcdc_pdev_shutdown(struct platform_device *pdev) > @@ -599,7 +598,7 @@ MODULE_DEVICE_TABLE(of, tilcdc_of_match); > > static struct platform_driver tilcdc_platform_driver = { > .probe = tilcdc_pdev_probe, > - .remove = tilcdc_pdev_remove, > + .remove_new = tilcdc_pdev_remove, > .shutdown = tilcdc_pdev_shutdown, > .driver = { > .name = "tilcdc", Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Tomi
On Fri, Nov 03, 2023 at 09:58:07AM +0200, Tomi Valkeinen wrote: > On 02/11/2023 18:56, Uwe Kleine-König wrote: > > 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. > > [...] > > Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> This patch didn't make it into next yet. Who is responsible to pick this up? Best regards Uwe
November 28, 2023 at 6:49 PM, "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de mailto:u.kleine-koenig@pengutronix.de?to=%22Uwe%20Kleine-K%C3%B6nig%22%20%3Cu.kleine-koenig%40pengutronix.de%3E > wrote: > > On Fri, Nov 03, 2023 at 09:58:07AM +0200, Tomi Valkeinen wrote: > > > > > On 02/11/2023 18:56, Uwe Kleine-König wrote: > > 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. > > [...] > > > > Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> > > > > This patch didn't make it into next yet. Who is responsible to pick this > up? > I expected the whole series had been applied at once. But yes, I can apply this patch. Best regards, Jyri > Best regards > Uwe > > -- > Pengutronix e.K. | Uwe Kleine-König | > Industrial Linux Solutions | https://www.pengutronix.de/| >
On Tue, Nov 28, 2023 at 07:54:31PM +0000, sarha@kapsi.fi wrote: > November 28, 2023 at 6:49 PM, "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de mailto:u.kleine-koenig@pengutronix.de?to=%22Uwe%20Kleine-K%C3%B6nig%22%20%3Cu.kleine-koenig%40pengutronix.de%3E > wrote: > > > > > On Fri, Nov 03, 2023 at 09:58:07AM +0200, Tomi Valkeinen wrote: > > > > > > > > On 02/11/2023 18:56, Uwe Kleine-König wrote: > > > 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. > > > [...] > > > > > > Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> > > > > > > > This patch didn't make it into next yet. Who is responsible to pick this > > up? > > > > I expected the whole series had been applied at once. But yes, I can apply this patch. Thanks. Thomas wrote in https://lore.kernel.org/dri-devel/250b5d51-93f8-4d8c-8507-0c47adbf7237@suse.de: Except for patches 8 and 16, I've pushed this patchset into drm-misc-next. . I understand he skipped patch 8, but for patch 16 I guess that's just an oversight. Best regards Uwe
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c index 8ebd7134ee21..137cd9f62e9f 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c +++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c @@ -570,19 +570,18 @@ static int tilcdc_pdev_probe(struct platform_device *pdev) match); } -static int tilcdc_pdev_remove(struct platform_device *pdev) +static void tilcdc_pdev_remove(struct platform_device *pdev) { int ret; ret = tilcdc_get_external_components(&pdev->dev, NULL); if (ret < 0) - return ret; + dev_err(&pdev->dev, "tilcdc_get_external_components() failed (%pe)\n", + ERR_PTR(ret)); else if (ret == 0) tilcdc_fini(platform_get_drvdata(pdev)); else component_master_del(&pdev->dev, &tilcdc_comp_ops); - - return 0; } static void tilcdc_pdev_shutdown(struct platform_device *pdev) @@ -599,7 +598,7 @@ MODULE_DEVICE_TABLE(of, tilcdc_of_match); static struct platform_driver tilcdc_platform_driver = { .probe = tilcdc_pdev_probe, - .remove = tilcdc_pdev_remove, + .remove_new = tilcdc_pdev_remove, .shutdown = tilcdc_pdev_shutdown, .driver = { .name = "tilcdc",
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. There is one error path in tilcdc_pdev_remove() that potentially could yield a non-zero return code. In this case an error message describing the failure is emitted now instead of remove callback returned a non-zero value. This will be ignored. before. Otherwise there is no difference. Also note that currently tilcdc_get_external_components() doesn't return negative values. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> --- drivers/gpu/drm/tilcdc/tilcdc_drv.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)