Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1483546 > unrolled thread
| Started by | Heiner Kallweit <hkallweit1@gmail.com> |
|---|---|
| First post | 2016-09-14 21:00 +0200 |
| Last post | 2016-09-14 21:00 +0200 |
| Articles | 1 — 1 participant |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH v2 5/7] leds: gpio: fix and simplify reading property "label" Heiner Kallweit <hkallweit1@gmail.com> - 2016-09-14 21:00 +0200
| From | Heiner Kallweit <hkallweit1@gmail.com> |
|---|---|
| Date | 2016-09-14 21:00 +0200 |
| Subject | [PATCH v2 5/7] leds: gpio: fix and simplify reading property "label" |
| Message-ID | <shnzA-4sf-19@gated-at.bofh.it> |
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>
---
v2:
- rebased due to removal of patch 2 of the original series
---
drivers/leds/leds-gpio.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index 171ba2f..00a24e3 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)
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);
--
2.9.2
Back to top | Article view | linux.kernel
csiph-web