diff mbox series

leds: simatic-ipc-leds-gpio: Convert to platform remove callback returning void

Message ID 20230724054743.310750-1-u.kleine-koenig@pengutronix.de
State New
Headers show
Series leds: simatic-ipc-leds-gpio: Convert to platform remove callback returning void | expand

Commit Message

Uwe Kleine-König July 24, 2023, 5:47 a.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.

Make simatic_ipc_leds_gpio_remove() return void instead of returning
zero unconditionally. After that the two remove callbacks were trivial
to convert to return void, too.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/leds/simple/simatic-ipc-leds-gpio-apollolake.c | 8 ++++----
 drivers/leds/simple/simatic-ipc-leds-gpio-core.c       | 4 +---
 drivers/leds/simple/simatic-ipc-leds-gpio-f7188x.c     | 8 ++++----
 drivers/leds/simple/simatic-ipc-leds-gpio.h            | 6 +++---
 4 files changed, 12 insertions(+), 14 deletions(-)


base-commit: 06c2afb862f9da8dc5efa4b6076a0e48c3fbaaa5

Comments

Henning Schild July 24, 2023, 6:11 a.m. UTC | #1
Am Mon, 24 Jul 2023 07:47:43 +0200
schrieb Uwe Kleine-König <u.kleine-koenig@pengutronix.de>:

> 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.
> 
> Make simatic_ipc_leds_gpio_remove() return void instead of returning
> zero unconditionally. After that the two remove callbacks were trivial
> to convert to return void, too.

Thanks for taking care of that. There are currently two+ patch qs in
flight that would conflict with that, or rather need that done as well.

1.
is the introduction of a CMOS battery monitoring driver which can
be found in (using the same pattern but in pdx86)

git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git
tags/ib-pdx86-simatic-v6.6

and was sent as "platform/x86: add CMOS battery monitoring for simatic
IPCs"

in fact plus "[PATCH v2 0/3] platform/x86: move simatic drivers into
subdir"

2.
And the other one is the introduction of a new board in the GPIO LEDs,
sent as "[PATCH v2 2/2] leds: simatic-ipc-leds-gpio: add Elkhart Lake
version".

If you just want to deal with LEDs you should rebase on the latter. But
since that is based on the first, might as well do both.

Or we wait until all those are merged, you try that conversion later or
Tobias will take it.

regards,
Henning

> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
>  drivers/leds/simple/simatic-ipc-leds-gpio-apollolake.c | 8 ++++----
>  drivers/leds/simple/simatic-ipc-leds-gpio-core.c       | 4 +---
>  drivers/leds/simple/simatic-ipc-leds-gpio-f7188x.c     | 8 ++++----
>  drivers/leds/simple/simatic-ipc-leds-gpio.h            | 6 +++---
>  4 files changed, 12 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/leds/simple/simatic-ipc-leds-gpio-apollolake.c
> b/drivers/leds/simple/simatic-ipc-leds-gpio-apollolake.c index
> e1c712729dcf..4183ee71fcce 100644 ---
> a/drivers/leds/simple/simatic-ipc-leds-gpio-apollolake.c +++
> b/drivers/leds/simple/simatic-ipc-leds-gpio-apollolake.c @@ -45,15
> +45,15 @@ static int simatic_ipc_leds_gpio_apollolake_probe(struct
> platform_device *pdev) &simatic_ipc_led_gpio_table_extra); }
>  
> -static int simatic_ipc_leds_gpio_apollolake_remove(struct
> platform_device *pdev) +static void
> simatic_ipc_leds_gpio_apollolake_remove(struct platform_device *pdev)
> {
> -	return simatic_ipc_leds_gpio_remove(pdev,
> &simatic_ipc_led_gpio_table,
> -
> &simatic_ipc_led_gpio_table_extra);
> +	simatic_ipc_leds_gpio_remove(pdev,
> &simatic_ipc_led_gpio_table,
> +
> &simatic_ipc_led_gpio_table_extra); }
>  
>  static struct platform_driver simatic_ipc_led_gpio_apollolake_driver
> = { .probe = simatic_ipc_leds_gpio_apollolake_probe,
> -	.remove = simatic_ipc_leds_gpio_apollolake_remove,
> +	.remove_new = simatic_ipc_leds_gpio_apollolake_remove,
>  	.driver = {
>  		.name = KBUILD_MODNAME,
>  	},
> diff --git a/drivers/leds/simple/simatic-ipc-leds-gpio-core.c
> b/drivers/leds/simple/simatic-ipc-leds-gpio-core.c index
> 2a21b663df87..32a753e5c7b6 100644 ---
> a/drivers/leds/simple/simatic-ipc-leds-gpio-core.c +++
> b/drivers/leds/simple/simatic-ipc-leds-gpio-core.c @@ -33,15 +33,13
> @@ static const struct gpio_led_platform_data
> simatic_ipc_gpio_leds_pdata = { .leds		=
> simatic_ipc_gpio_leds, }; 
> -int simatic_ipc_leds_gpio_remove(struct platform_device *pdev,
> +void simatic_ipc_leds_gpio_remove(struct platform_device *pdev,
>  				 struct gpiod_lookup_table *table,
>  				 struct gpiod_lookup_table
> *table_extra) {
>  	gpiod_remove_lookup_table(table);
>  	gpiod_remove_lookup_table(table_extra);
>  	platform_device_unregister(simatic_leds_pdev);
> -
> -	return 0;
>  }
>  EXPORT_SYMBOL_GPL(simatic_ipc_leds_gpio_remove);
>  
> diff --git a/drivers/leds/simple/simatic-ipc-leds-gpio-f7188x.c
> b/drivers/leds/simple/simatic-ipc-leds-gpio-f7188x.c index
> 583a6b6c7c22..c7c3a1f986e6 100644 ---
> a/drivers/leds/simple/simatic-ipc-leds-gpio-f7188x.c +++
> b/drivers/leds/simple/simatic-ipc-leds-gpio-f7188x.c @@ -45,15 +45,15
> @@ static int simatic_ipc_leds_gpio_f7188x_probe(struct
> platform_device *pdev) &simatic_ipc_led_gpio_table_extra); }
>  
> -static int simatic_ipc_leds_gpio_f7188x_remove(struct
> platform_device *pdev) +static void
> simatic_ipc_leds_gpio_f7188x_remove(struct platform_device *pdev) {
> -	return simatic_ipc_leds_gpio_remove(pdev,
> &simatic_ipc_led_gpio_table,
> -
> &simatic_ipc_led_gpio_table_extra);
> +	simatic_ipc_leds_gpio_remove(pdev,
> &simatic_ipc_led_gpio_table,
> +
> &simatic_ipc_led_gpio_table_extra); }
>  
>  static struct platform_driver simatic_ipc_led_gpio_driver = {
>  	.probe = simatic_ipc_leds_gpio_f7188x_probe,
> -	.remove = simatic_ipc_leds_gpio_f7188x_remove,
> +	.remove_new = simatic_ipc_leds_gpio_f7188x_remove,
>  	.driver = {
>  		.name = KBUILD_MODNAME,
>  	},
> diff --git a/drivers/leds/simple/simatic-ipc-leds-gpio.h
> b/drivers/leds/simple/simatic-ipc-leds-gpio.h index
> bf258c32f83d..af7384c37e67 100644 ---
> a/drivers/leds/simple/simatic-ipc-leds-gpio.h +++
> b/drivers/leds/simple/simatic-ipc-leds-gpio.h @@ -15,8 +15,8 @@ int
> simatic_ipc_leds_gpio_probe(struct platform_device *pdev, struct
> gpiod_lookup_table *table, struct gpiod_lookup_table *table_extra);
>  
> -int simatic_ipc_leds_gpio_remove(struct platform_device *pdev,
> -				 struct gpiod_lookup_table *table,
> -				 struct gpiod_lookup_table
> *table_extra); +void simatic_ipc_leds_gpio_remove(struct
> platform_device *pdev,
> +				  struct gpiod_lookup_table *table,
> +				  struct gpiod_lookup_table
> *table_extra); 
>  #endif /* _SIMATIC_IPC_LEDS_GPIO_H */
> 
> base-commit: 06c2afb862f9da8dc5efa4b6076a0e48c3fbaaa5
diff mbox series

Patch

diff --git a/drivers/leds/simple/simatic-ipc-leds-gpio-apollolake.c b/drivers/leds/simple/simatic-ipc-leds-gpio-apollolake.c
index e1c712729dcf..4183ee71fcce 100644
--- a/drivers/leds/simple/simatic-ipc-leds-gpio-apollolake.c
+++ b/drivers/leds/simple/simatic-ipc-leds-gpio-apollolake.c
@@ -45,15 +45,15 @@  static int simatic_ipc_leds_gpio_apollolake_probe(struct platform_device *pdev)
 					   &simatic_ipc_led_gpio_table_extra);
 }
 
-static int simatic_ipc_leds_gpio_apollolake_remove(struct platform_device *pdev)
+static void simatic_ipc_leds_gpio_apollolake_remove(struct platform_device *pdev)
 {
-	return simatic_ipc_leds_gpio_remove(pdev, &simatic_ipc_led_gpio_table,
-					    &simatic_ipc_led_gpio_table_extra);
+	simatic_ipc_leds_gpio_remove(pdev, &simatic_ipc_led_gpio_table,
+				     &simatic_ipc_led_gpio_table_extra);
 }
 
 static struct platform_driver simatic_ipc_led_gpio_apollolake_driver = {
 	.probe = simatic_ipc_leds_gpio_apollolake_probe,
-	.remove = simatic_ipc_leds_gpio_apollolake_remove,
+	.remove_new = simatic_ipc_leds_gpio_apollolake_remove,
 	.driver = {
 		.name = KBUILD_MODNAME,
 	},
diff --git a/drivers/leds/simple/simatic-ipc-leds-gpio-core.c b/drivers/leds/simple/simatic-ipc-leds-gpio-core.c
index 2a21b663df87..32a753e5c7b6 100644
--- a/drivers/leds/simple/simatic-ipc-leds-gpio-core.c
+++ b/drivers/leds/simple/simatic-ipc-leds-gpio-core.c
@@ -33,15 +33,13 @@  static const struct gpio_led_platform_data simatic_ipc_gpio_leds_pdata = {
 	.leds		= simatic_ipc_gpio_leds,
 };
 
-int simatic_ipc_leds_gpio_remove(struct platform_device *pdev,
+void simatic_ipc_leds_gpio_remove(struct platform_device *pdev,
 				 struct gpiod_lookup_table *table,
 				 struct gpiod_lookup_table *table_extra)
 {
 	gpiod_remove_lookup_table(table);
 	gpiod_remove_lookup_table(table_extra);
 	platform_device_unregister(simatic_leds_pdev);
-
-	return 0;
 }
 EXPORT_SYMBOL_GPL(simatic_ipc_leds_gpio_remove);
 
diff --git a/drivers/leds/simple/simatic-ipc-leds-gpio-f7188x.c b/drivers/leds/simple/simatic-ipc-leds-gpio-f7188x.c
index 583a6b6c7c22..c7c3a1f986e6 100644
--- a/drivers/leds/simple/simatic-ipc-leds-gpio-f7188x.c
+++ b/drivers/leds/simple/simatic-ipc-leds-gpio-f7188x.c
@@ -45,15 +45,15 @@  static int simatic_ipc_leds_gpio_f7188x_probe(struct platform_device *pdev)
 					   &simatic_ipc_led_gpio_table_extra);
 }
 
-static int simatic_ipc_leds_gpio_f7188x_remove(struct platform_device *pdev)
+static void simatic_ipc_leds_gpio_f7188x_remove(struct platform_device *pdev)
 {
-	return simatic_ipc_leds_gpio_remove(pdev, &simatic_ipc_led_gpio_table,
-					    &simatic_ipc_led_gpio_table_extra);
+	simatic_ipc_leds_gpio_remove(pdev, &simatic_ipc_led_gpio_table,
+				     &simatic_ipc_led_gpio_table_extra);
 }
 
 static struct platform_driver simatic_ipc_led_gpio_driver = {
 	.probe = simatic_ipc_leds_gpio_f7188x_probe,
-	.remove = simatic_ipc_leds_gpio_f7188x_remove,
+	.remove_new = simatic_ipc_leds_gpio_f7188x_remove,
 	.driver = {
 		.name = KBUILD_MODNAME,
 	},
diff --git a/drivers/leds/simple/simatic-ipc-leds-gpio.h b/drivers/leds/simple/simatic-ipc-leds-gpio.h
index bf258c32f83d..af7384c37e67 100644
--- a/drivers/leds/simple/simatic-ipc-leds-gpio.h
+++ b/drivers/leds/simple/simatic-ipc-leds-gpio.h
@@ -15,8 +15,8 @@  int simatic_ipc_leds_gpio_probe(struct platform_device *pdev,
 				struct gpiod_lookup_table *table,
 				struct gpiod_lookup_table *table_extra);
 
-int simatic_ipc_leds_gpio_remove(struct platform_device *pdev,
-				 struct gpiod_lookup_table *table,
-				 struct gpiod_lookup_table *table_extra);
+void simatic_ipc_leds_gpio_remove(struct platform_device *pdev,
+				  struct gpiod_lookup_table *table,
+				  struct gpiod_lookup_table *table_extra);
 
 #endif /* _SIMATIC_IPC_LEDS_GPIO_H */