aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHeiner Kallweit <hkallweit1@gmail.com>2016-09-14 14:55:18 -0400
committerJacek Anaszewski <j.anaszewski@samsung.com>2016-09-15 10:49:42 -0400
commitbec69de89bab29c739ab84ceb04ae63d6811babf (patch)
treeef7f54092b35d682c5d3ff0dcf264507aa42df10
parent8ca03da5e0f70a413986221da4c88459bb6f6878 (diff)
leds: gpio: fix and simplify reading property "label"
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>
-rw-r--r--drivers/leds/leds-gpio.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index 171ba2fbb59a..00a24e32c6c6 100644
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -181,16 +181,14 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev)
181 goto err; 181 goto err;
182 } 182 }
183 183
184 if (fwnode_property_present(child, "label")) { 184 ret = fwnode_property_read_string(child, "label", &led.name);
185 fwnode_property_read_string(child, "label", &led.name); 185 if (ret && IS_ENABLED(CONFIG_OF) && np)
186 } else { 186 led.name = np->name;
187 if (IS_ENABLED(CONFIG_OF) && !led.name && np) 187 if (!led.name) {
188 led.name = np->name; 188 ret = -EINVAL;
189 if (!led.name) { 189 goto err;
190 ret = -EINVAL;
191 goto err;
192 }
193 } 190 }
191
194 fwnode_property_read_string(child, "linux,default-trigger", 192 fwnode_property_read_string(child, "linux,default-trigger",
195 &led.default_trigger); 193 &led.default_trigger);
196 194