linux-leds.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: pavel@ucw.cz, mallikarjunax.reddy@linux.intel.com
Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org,
	Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Subject: [PATCH 1/2] leds: lgm: Propagate error codes to the caller
Date: Sun, 11 Apr 2021 09:45:30 +0200	[thread overview]
Message-ID: <22e1f8245251f0ec297881942abfa2b00eff48d2.1618126878.git.christophe.jaillet@wanadoo.fr> (raw)

Do not always return -EINVAL in case of error in '__sso_led_dt_parse()'.
Propagate the error code instead.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/leds/blink/leds-lgm-sso.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/leds/blink/leds-lgm-sso.c b/drivers/leds/blink/leds-lgm-sso.c
index 7d5c9ca007d6..3da242d4ce7d 100644
--- a/drivers/leds/blink/leds-lgm-sso.c
+++ b/drivers/leds/blink/leds-lgm-sso.c
@@ -643,6 +643,7 @@ __sso_led_dt_parse(struct sso_led_priv *priv, struct fwnode_handle *fw_ssoled)
 							      GPIOD_ASIS, NULL);
 		if (IS_ERR(led->gpiod)) {
 			dev_err(dev, "led: get gpio fail!\n");
+			ret = PTR_ERR(led->gpiod);
 			goto __dt_err;
 		}
 
@@ -664,6 +665,7 @@ __sso_led_dt_parse(struct sso_led_priv *priv, struct fwnode_handle *fw_ssoled)
 		ret = fwnode_property_read_u32(fwnode_child, "reg", &prop);
 		if (ret != 0 || prop >= SSO_LED_MAX_NUM) {
 			dev_err(dev, "invalid LED pin:%u\n", prop);
+			ret = ret ? ret : -EINVAL;
 			goto __dt_err;
 		}
 		desc->pin = prop;
@@ -699,8 +701,10 @@ __sso_led_dt_parse(struct sso_led_priv *priv, struct fwnode_handle *fw_ssoled)
 				desc->brightness = LED_FULL;
 		}
 
-		if (sso_create_led(priv, led, fwnode_child))
+		if (sso_create_led(priv, led, fwnode_child)) {
+			ret = -EINVAL;
 			goto __dt_err;
+		}
 	}
 	fwnode_handle_put(fw_ssoled);
 
@@ -713,7 +717,7 @@ __sso_led_dt_parse(struct sso_led_priv *priv, struct fwnode_handle *fw_ssoled)
 		sso_led_shutdown(led);
 	}
 
-	return -EINVAL;
+	return ret;
 }
 
 static int sso_led_dt_parse(struct sso_led_priv *priv)
-- 
2.27.0


             reply	other threads:[~2021-04-11  7:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-11  7:45 Christophe JAILLET [this message]
2021-04-11  7:45 ` [PATCH 2/2] leds: lgm: Fix an error handling path in '__sso_led_dt_parse()' Christophe JAILLET

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=22e1f8245251f0ec297881942abfa2b00eff48d2.1618126878.git.christophe.jaillet@wanadoo.fr \
    --to=christophe.jaillet@wanadoo.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=mallikarjunax.reddy@linux.intel.com \
    --cc=pavel@ucw.cz \
    /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).