linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Heiner Kallweit <hkallweit1@gmail.com>
To: Jacek Anaszewski <j.anaszewski@samsung.com>
Cc: "linux-leds@vger.kernel.org" <linux-leds@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [PATCH v2 2/7] leds: gpio: fix an unhandled error case in create_gpio_led
Date: Wed, 14 Sep 2016 20:54:31 +0200	[thread overview]
Message-ID: <77a5dc84-38a7-e030-b367-ed8b7430805f@gmail.com> (raw)
In-Reply-To: <5432fb03-ea18-a949-ce53-10fedc15f5d9@gmail.com>

gpiod_get_value_cansleep returns 0, 1, or an error code.
So far errors are not handled and treated the same as 1.
Change this to bail out if an error code is returned and
remove the double negation.

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 | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index 3599b2e..10c851e 100644
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -118,10 +118,13 @@ static int create_gpio_led(const struct gpio_led *template,
 		led_dat->platform_gpio_blink_set = blink_set;
 		led_dat->cdev.blink_set = gpio_blink_set;
 	}
-	if (template->default_state == LEDS_GPIO_DEFSTATE_KEEP)
-		state = !!gpiod_get_value_cansleep(led_dat->gpiod);
-	else
+	if (template->default_state == LEDS_GPIO_DEFSTATE_KEEP) {
+		state = gpiod_get_value_cansleep(led_dat->gpiod);
+		if (state < 0)
+			return state;
+	} else {
 		state = (template->default_state == LEDS_GPIO_DEFSTATE_ON);
+	}
 	led_dat->cdev.brightness = state ? LED_FULL : LED_OFF;
 	if (!template->retain_state_suspended)
 		led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
-- 
2.9.2

  parent reply	other threads:[~2016-09-14 18:56 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <5432fb03-ea18-a949-ce53-10fedc15f5d9@gmail.com>
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 ` Heiner Kallweit [this message]
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=77a5dc84-38a7-e030-b367-ed8b7430805f@gmail.com \
    --to=hkallweit1@gmail.com \
    --cc=j.anaszewski@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --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).