From: Heiner Kallweit <hkallweit1@gmail.com>
To: Jacek Anaszewski <j.anaszewski@samsung.com>,
"linux-leds@vger.kernel.org" <linux-leds@vger.kernel.org>
Subject: [PATCH 6/8] leds: gpio: fix and simplify reading property "label"
Date: Tue, 13 Sep 2016 08:03:34 +0200 [thread overview]
Message-ID: <9f7cac79-f3e6-0300-cf95-b06d3560ed73@gmail.com> (raw)
In-Reply-To: <5432fb03-ea18-a949-ce53-10fedc15f5d9@gmail.com>
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>
---
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 8e2ffc9..deea159 100644
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -176,16 +176,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
next prev parent reply other threads:[~2016-09-13 6:04 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <5432fb03-ea18-a949-ce53-10fedc15f5d9@gmail.com>
2016-09-13 6:03 ` [PATCH 2/8] leds: gpio: set max_brightness to 1 Heiner Kallweit
2016-09-13 13:35 ` Jacek Anaszewski
2016-09-13 18:42 ` Heiner Kallweit
2016-09-13 6:03 ` [PATCH 3/8] leds: gpio: fix an unhandled error case in create_gpio_led Heiner Kallweit
2016-09-13 6:03 ` [PATCH 4/8] leds: gpio: add helper cdev_to_gpio_led_data Heiner Kallweit
2016-09-13 6:03 ` [PATCH 5/8] leds: gpio: simplify gpio_leds_create Heiner Kallweit
2016-09-13 6:03 ` Heiner Kallweit [this message]
2016-09-13 6:03 ` [PATCH 7/8] leds: gpio: switch to managed version of led_classdev_register Heiner Kallweit
2016-09-13 6:03 ` [PATCH 8/8] leds: gpio: fix and simplify error handling in gpio_leds_create Heiner Kallweit
2016-09-13 18:53 ` [PATCH 1/6] leds: gpio: fix an unhandled error case in create_gpio_led Heiner Kallweit
2016-09-14 7:13 ` Jacek Anaszewski
2016-09-15 11:48 ` Jacek Anaszewski
2016-09-13 18:54 ` [PATCH 2/6] leds: gpio: add helper cdev_to_gpio_led_data Heiner Kallweit
2016-09-13 18:55 ` [PATCH 3/6] leds: gpio: simplify gpio_leds_create Heiner Kallweit
2016-09-13 18:56 ` [PATCH 4/6] leds: gpio: fix and simplify reading property "label" Heiner Kallweit
2016-09-13 18:57 ` [PATCH 5/6] leds: gpio: switch to managed version of led_classdev_register Heiner Kallweit
2016-09-13 18:57 ` [PATCH 6/6] leds: gpio: fix and simplify error handling in gpio_leds_create Heiner Kallweit
2016-09-14 18:54 ` [PATCH v2 2/7] leds: gpio: fix an unhandled error case in create_gpio_led Heiner Kallweit
2016-09-14 18:55 ` [PATCH v2 3/7] leds: gpio: add helper cdev_to_gpio_led_data Heiner Kallweit
2016-09-14 18:55 ` [PATCH v2 4/7] leds: gpio: simplify gpio_leds_create Heiner Kallweit
2016-09-14 18:55 ` [PATCH v2 5/7] leds: gpio: fix and simplify reading property "label" Heiner Kallweit
2016-09-14 18:55 ` [PATCH v2 6/7] leds: gpio: switch to managed version of led_classdev_register Heiner Kallweit
2016-09-14 18:55 ` [PATCH v2 7/7] leds: gpio: fix and simplify error handling in gpio_leds_create Heiner Kallweit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9f7cac79-f3e6-0300-cf95-b06d3560ed73@gmail.com \
--to=hkallweit1@gmail.com \
--cc=j.anaszewski@samsung.com \
--cc=linux-leds@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).