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>
This commit is contained in:
Heiner Kallweit 2016-09-14 20:55:18 +02:00 committed by Jacek Anaszewski
parent 8ca03da5e0
commit bec69de89b
1 changed files with 7 additions and 9 deletions

View File

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