mbox series

[00/13] backlight: Convert to platform remove callback returning void

Message ID 20230308073945.2336302-1-u.kleine-koenig@pengutronix.de
Headers show
Series backlight: Convert to platform remove callback returning void | expand

Message

Uwe Kleine-König March 8, 2023, 7:39 a.m. UTC
Hello,

this patch series adapts the platform drivers below drivers/video/backlight 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 drivers/video/backlight returned zero unconditionally in their
remove callback, so they could all be converted trivially to .remove_new().

Note that this series depends on commit 5c5a7680e67b ("platform: Provide
a remove callback that returns no value") which is included in v6.3-rc1.

Best regards
Uwe

Uwe Kleine-König (13):
  backlight: aat2870_bl: Convert to platform remove callback returning
    void
  backlight: adp5520_bl: Convert to platform remove callback returning
    void
  backlight: cr_bllcd: Convert to platform remove callback returning
    void
  backlight: da9052_bl: Convert to platform remove callback returning
    void
  backlight: hp680_bl: Convert to platform remove callback returning
    void
  backlight: led_bl: Convert to platform remove callback returning void
  backlight: lm3533_bl: Convert to platform remove callback returning
    void
  backlight: lp8788_bl: Convert to platform remove callback returning
    void
  backlight: mt6370-backlight: Convert to platform remove callback
    returning void
  backlight: pwm_bl: Convert to platform remove callback returning void
  backlight: qcom-wled: Convert to platform remove callback returning
    void
  backlight: rt4831-backlight: Convert to platform remove callback
    returning void
  backlight: sky81452-backlight: Convert to platform remove callback
    returning void

 drivers/video/backlight/aat2870_bl.c         | 6 ++----
 drivers/video/backlight/adp5520_bl.c         | 6 ++----
 drivers/video/backlight/cr_bllcd.c           | 6 ++----
 drivers/video/backlight/da9052_bl.c          | 6 ++----
 drivers/video/backlight/hp680_bl.c           | 6 ++----
 drivers/video/backlight/led_bl.c             | 6 ++----
 drivers/video/backlight/lm3533_bl.c          | 6 ++----
 drivers/video/backlight/lp8788_bl.c          | 6 ++----
 drivers/video/backlight/mt6370-backlight.c   | 6 ++----
 drivers/video/backlight/pwm_bl.c             | 6 ++----
 drivers/video/backlight/qcom-wled.c          | 6 ++----
 drivers/video/backlight/rt4831-backlight.c   | 6 ++----
 drivers/video/backlight/sky81452-backlight.c | 6 ++----
 13 files changed, 26 insertions(+), 52 deletions(-)

base-commit: fe15c26ee26efa11741a7b632e9f23b01aca4cc6

Comments

Lee Jones March 16, 2023, 1:48 p.m. UTC | #1
On Wed, 08 Mar 2023, 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/video/backlight/cr_bllcd.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)

Applied, thanks

--
Lee Jones [李琼斯]
Lee Jones March 16, 2023, 1:49 p.m. UTC | #2
On Wed, 08 Mar 2023, 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/video/backlight/hp680_bl.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)

Applied, thanks

--
Lee Jones [李琼斯]
Lee Jones March 16, 2023, 1:50 p.m. UTC | #3
On Wed, 08 Mar 2023, 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/video/backlight/lm3533_bl.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)

Applied, thanks

--
Lee Jones [李琼斯]
Lee Jones March 16, 2023, 1:50 p.m. UTC | #4
On Wed, 08 Mar 2023, 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/video/backlight/lp8788_bl.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)

Applied, thanks

--
Lee Jones [李琼斯]
Lee Jones March 16, 2023, 1:51 p.m. UTC | #5
On Wed, 08 Mar 2023, 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/video/backlight/pwm_bl.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)

Applied, thanks

--
Lee Jones [李琼斯]
Lee Jones March 16, 2023, 1:51 p.m. UTC | #6
On Wed, 08 Mar 2023, 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/video/backlight/qcom-wled.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)

Applied, thanks

--
Lee Jones [李琼斯]
Lee Jones March 16, 2023, 1:51 p.m. UTC | #7
On Wed, 08 Mar 2023, 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/video/backlight/rt4831-backlight.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)

Applied, thanks

--
Lee Jones [李琼斯]