leds: gpio: fix and simplify reading property "label"
authorHeiner Kallweit <hkallweit1@gmail.com>
Wed, 14 Sep 2016 18:55:18 +0000 (20:55 +0200)
committerJacek Anaszewski <j.anaszewski@samsung.com>
Thu, 15 Sep 2016 14:49:42 +0000 (16:49 +0200)
Checking for the presence of the property first isn't strictly needed
as we can react on the return code of fwnode_property_read_string.
Also, even if the presence of a property "label" was checked,
reading a string value for it theoretically still can fail and
this case isn't handled.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
drivers/leds/leds-gpio.c

index 171ba2f..00a24e3 100644 (file)
@@ -181,16 +181,14 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev)
                        goto err;
                }
 
-               if (fwnode_property_present(child, "label")) {
-                       fwnode_property_read_string(child, "label", &led.name);
-               } else {
-                       if (IS_ENABLED(CONFIG_OF) && !led.name && np)
-                               led.name = np->name;
-                       if (!led.name) {
-                               ret = -EINVAL;
-                               goto err;
-                       }
+               ret = fwnode_property_read_string(child, "label", &led.name);
+               if (ret && IS_ENABLED(CONFIG_OF) && np)
+                       led.name = np->name;
+               if (!led.name) {
+                       ret = -EINVAL;
+                       goto err;
                }
+
                fwnode_property_read_string(child, "linux,default-trigger",
                                            &led.default_trigger);