Skip to contentSkip to conversation

gpio: mockup: Drop duplicate NULL check in gpio_mockup_unregister_pdevs()

PATCH Applied Andy Shevchenko 2 participants 2 messages Mar 15, 2021 – Mar 16, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpio: mockup: Drop duplicate NULL check in gpio_mockup_unregister_pdevs()

Since platform_device_unregister() is NULL-aware, we don't need to duplicate this check. Remove it and fold the rest of the code.

---
 drivers/gpio/gpio-mockup.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/gpio/gpio-mockup.c +2 -7
index 28b757d34046..d7e73876a3b9 100644
@@ -479,15 +479,10 @@ static struct platform_device *gpio_mockup_pdevs[GPIO_MOCKUP_MAX_GC];
 
 static void gpio_mockup_unregister_pdevs(void)
 {
-	struct platform_device *pdev;
 	int i;
 
-	for (i = 0; i < GPIO_MOCKUP_MAX_GC; i++) {
-		pdev = gpio_mockup_pdevs[i];
-
-		if (pdev)
-			platform_device_unregister(pdev);
-	}
+	for (i = 0; i < GPIO_MOCKUP_MAX_GC; i++)
+		platform_device_unregister(gpio_mockup_pdevs[i]);
 }
 
 static __init char **gpio_mockup_make_line_names(const char *label,
Signature · 1 line
2.30.2
#1 lore raw
Quoted 32 lines · Andy Shevchenko

Since platform_device_unregister() is NULL-aware, we don't need to duplicate this check. Remove it and fold the rest of the code.

---
 drivers/gpio/gpio-mockup.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/gpio/gpio-mockup.c +2 -8
index 28b757d34046..d7e73876a3b9 100644
@@ -479,15 +479,10 @@ static struct platform_device *gpio_mockup_pdevs[GPIO_MOCKUP_MAX_GC];
 
 static void gpio_mockup_unregister_pdevs(void)
 {
-       struct platform_device *pdev;
        int i;
 
-       for (i = 0; i < GPIO_MOCKUP_MAX_GC; i++) {
-               pdev = gpio_mockup_pdevs[i];
-
-               if (pdev)
-                       platform_device_unregister(pdev);
-       }
+       for (i = 0; i < GPIO_MOCKUP_MAX_GC; i++)
+               platform_device_unregister(gpio_mockup_pdevs[i]);
 }
 
 static __init char **gpio_mockup_make_line_names(const char *label,
--
Quoted 2 lines

2.30.2

Applied, thanks!

Bartosz