From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760141AbcIMS6j (ORCPT ); Tue, 13 Sep 2016 14:58:39 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:35069 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759969AbcIMS6d (ORCPT ); Tue, 13 Sep 2016 14:58:33 -0400 From: Heiner Kallweit Subject: [PATCH 4/6] leds: gpio: fix and simplify reading property "label" To: Jacek Anaszewski References: <5432fb03-ea18-a949-ce53-10fedc15f5d9@gmail.com> Cc: "linux-leds@vger.kernel.org" , Linux Kernel Mailing List Message-ID: <60a7f96e-631d-1f2f-f359-901584361406@gmail.com> Date: Tue, 13 Sep 2016 20:56:26 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <5432fb03-ea18-a949-ce53-10fedc15f5d9@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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