Message ID | 20230326143224.572654-39-u.kleine-koenig@pengutronix.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | media: Convert to platform remove callback returning void | expand |
On 3/26/23 16:31, 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. > > 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/media/platform/nxp/dw100/dw100.c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/drivers/media/platform/nxp/dw100/dw100.c b/drivers/media/platform/nxp/dw100/dw100.c > index 189d60cd5ed1..6eed4bde9611 100644 > --- a/drivers/media/platform/nxp/dw100/dw100.c > +++ b/drivers/media/platform/nxp/dw100/dw100.c > @@ -1633,7 +1633,7 @@ static int dw100_probe(struct platform_device *pdev) > return ret; > } > > -static int dw100_remove(struct platform_device *pdev) > +static void dw100_remove(struct platform_device *pdev) > { > struct dw100_device *dw_dev = platform_get_drvdata(pdev); > > @@ -1649,8 +1649,6 @@ static int dw100_remove(struct platform_device *pdev) > mutex_destroy(dw_dev->vfd.lock); > v4l2_m2m_release(dw_dev->m2m_dev); > v4l2_device_unregister(&dw_dev->v4l2_dev); > - > - return 0; > } > > static int __maybe_unused dw100_runtime_suspend(struct device *dev) > @@ -1692,7 +1690,7 @@ MODULE_DEVICE_TABLE(of, dw100_dt_ids); > > static struct platform_driver dw100_driver = { > .probe = dw100_probe, > - .remove = dw100_remove, > + .remove_new = dw100_remove, > .driver = { > .name = DRV_NAME, > .pm = &dw100_pm, Reviewed-by: Xavier Roumegue <xavier.roumegue@oss.nxp.com>
diff --git a/drivers/media/platform/nxp/dw100/dw100.c b/drivers/media/platform/nxp/dw100/dw100.c index 189d60cd5ed1..6eed4bde9611 100644 --- a/drivers/media/platform/nxp/dw100/dw100.c +++ b/drivers/media/platform/nxp/dw100/dw100.c @@ -1633,7 +1633,7 @@ static int dw100_probe(struct platform_device *pdev) return ret; } -static int dw100_remove(struct platform_device *pdev) +static void dw100_remove(struct platform_device *pdev) { struct dw100_device *dw_dev = platform_get_drvdata(pdev); @@ -1649,8 +1649,6 @@ static int dw100_remove(struct platform_device *pdev) mutex_destroy(dw_dev->vfd.lock); v4l2_m2m_release(dw_dev->m2m_dev); v4l2_device_unregister(&dw_dev->v4l2_dev); - - return 0; } static int __maybe_unused dw100_runtime_suspend(struct device *dev) @@ -1692,7 +1690,7 @@ MODULE_DEVICE_TABLE(of, dw100_dt_ids); static struct platform_driver dw100_driver = { .probe = dw100_probe, - .remove = dw100_remove, + .remove_new = dw100_remove, .driver = { .name = DRV_NAME, .pm = &dw100_pm,
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/media/platform/nxp/dw100/dw100.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)