diff mbox series

[09/30] pwm: cros-ec: Convert to platform remove callback returning void

Message ID 20230303185445.2112695-10-u.kleine-koenig@pengutronix.de (mailing list archive)
State Accepted
Commit 159a61a7b5b01dc158cbe718a181f1943ab6dcac
Headers show
Series pwm: Convert to platform remove callback returning void | expand

Commit Message

Uwe Kleine-König March 3, 2023, 6:54 p.m. UTC
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/pwm/pwm-cros-ec.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Guenter Roeck March 3, 2023, 7:14 p.m. UTC | #1
On Fri, Mar 3, 2023 at 10:55 AM Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> 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>

Reviewed-by: Guenter Roeck <groeck@chromium.org>

> ---
>  drivers/pwm/pwm-cros-ec.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/pwm/pwm-cros-ec.c b/drivers/pwm/pwm-cros-ec.c
> index 86df6702cb83..90afce212fb0 100644
> --- a/drivers/pwm/pwm-cros-ec.c
> +++ b/drivers/pwm/pwm-cros-ec.c
> @@ -328,14 +328,12 @@ static int cros_ec_pwm_probe(struct platform_device *pdev)
>         return ret;
>  }
>
> -static int cros_ec_pwm_remove(struct platform_device *dev)
> +static void cros_ec_pwm_remove(struct platform_device *dev)
>  {
>         struct cros_ec_pwm_device *ec_pwm = platform_get_drvdata(dev);
>         struct pwm_chip *chip = &ec_pwm->chip;
>
>         pwmchip_remove(chip);
> -
> -       return 0;
>  }
>
>  #ifdef CONFIG_OF
> @@ -349,7 +347,7 @@ MODULE_DEVICE_TABLE(of, cros_ec_pwm_of_match);
>
>  static struct platform_driver cros_ec_pwm_driver = {
>         .probe = cros_ec_pwm_probe,
> -       .remove = cros_ec_pwm_remove,
> +       .remove_new = cros_ec_pwm_remove,
>         .driver = {
>                 .name = "cros-ec-pwm",
>                 .of_match_table = of_match_ptr(cros_ec_pwm_of_match),
> --
> 2.39.1
>
diff mbox series

Patch

diff --git a/drivers/pwm/pwm-cros-ec.c b/drivers/pwm/pwm-cros-ec.c
index 86df6702cb83..90afce212fb0 100644
--- a/drivers/pwm/pwm-cros-ec.c
+++ b/drivers/pwm/pwm-cros-ec.c
@@ -328,14 +328,12 @@  static int cros_ec_pwm_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int cros_ec_pwm_remove(struct platform_device *dev)
+static void cros_ec_pwm_remove(struct platform_device *dev)
 {
 	struct cros_ec_pwm_device *ec_pwm = platform_get_drvdata(dev);
 	struct pwm_chip *chip = &ec_pwm->chip;
 
 	pwmchip_remove(chip);
-
-	return 0;
 }
 
 #ifdef CONFIG_OF
@@ -349,7 +347,7 @@  MODULE_DEVICE_TABLE(of, cros_ec_pwm_of_match);
 
 static struct platform_driver cros_ec_pwm_driver = {
 	.probe = cros_ec_pwm_probe,
-	.remove = cros_ec_pwm_remove,
+	.remove_new = cros_ec_pwm_remove,
 	.driver = {
 		.name = "cros-ec-pwm",
 		.of_match_table = of_match_ptr(cros_ec_pwm_of_match),