leds: simatic-ipc-leds-gpio: Convert to platform remove callback returning void
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Sat, 16 Sep 2023 16:45:16 +0000 (18:45 +0200)
committerLee Jones <lee@kernel.org>
Wed, 1 Nov 2023 11:28:33 +0000 (11:28 +0000)
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 three remove callbacks that use
this function were trivial to convert to return void, too.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20230916164516.1063380-1-u.kleine-koenig@pengutronix.de
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/leds/simple/simatic-ipc-leds-gpio-apollolake.c
drivers/leds/simple/simatic-ipc-leds-gpio-core.c
drivers/leds/simple/simatic-ipc-leds-gpio-elkhartlake.c
drivers/leds/simple/simatic-ipc-leds-gpio-f7188x.c
drivers/leds/simple/simatic-ipc-leds-gpio.h

index e1c712729dcf7ed344be5c2c942cca4c0adfe2ac..4183ee71fcce67524f73ebc9e642656edc745be4 100644 (file)
@@ -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,
        },
index c552ea73ed9df62d345174cb0b7033a1d03ec6f0..667ba1bc3a30fe4116fd239e0eee3e62efc4f886 100644 (file)
@@ -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);
 
index 6ba21dbb3ba0a6027c318426ea1d6babbeac7901..4a53d4dbf52fdfa93584876ceca70c13d3144731 100644 (file)
@@ -36,15 +36,14 @@ static int simatic_ipc_leds_gpio_elkhartlake_probe(struct platform_device *pdev)
                                           NULL);
 }
 
-static int simatic_ipc_leds_gpio_elkhartlake_remove(struct platform_device *pdev)
+static void simatic_ipc_leds_gpio_elkhartlake_remove(struct platform_device *pdev)
 {
-       return simatic_ipc_leds_gpio_remove(pdev, &simatic_ipc_led_gpio_table,
-                                           NULL);
+       simatic_ipc_leds_gpio_remove(pdev, &simatic_ipc_led_gpio_table, NULL);
 }
 
 static struct platform_driver simatic_ipc_led_gpio_elkhartlake_driver = {
        .probe = simatic_ipc_leds_gpio_elkhartlake_probe,
-       .remove = simatic_ipc_leds_gpio_elkhartlake_remove,
+       .remove_new = simatic_ipc_leds_gpio_elkhartlake_remove,
        .driver = {
                .name = KBUILD_MODNAME,
        },
index 583a6b6c7c2226f17cbf308fd8e8a2d795ee33a9..c7c3a1f986e61d21f91d2e1c6290a6211a554f0c 100644 (file)
@@ -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,
        },
index 3d4877aa4e0cb4a27aa2e7808bcbfc85cd8bc89d..6b2519809cee8c7a66247d95faa934b437f583c7 100644 (file)
@@ -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 */