linux-leds.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] leds: lm3692x: Simplify with dev_err_probe()
@ 2020-08-26 14:50 Krzysztof Kozlowski
  2020-08-26 14:50 ` [PATCH 2/4] leds: pwm: " Krzysztof Kozlowski
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Krzysztof Kozlowski @ 2020-08-26 14:50 UTC (permalink / raw)
  To: Pavel Machek, Dan Murphy, linux-leds, linux-kernel; +Cc: Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
 drivers/leds/leds-lm3692x.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/leds/leds-lm3692x.c b/drivers/leds/leds-lm3692x.c
index e1e2d2b64a56..1d7ea1b76a12 100644
--- a/drivers/leds/leds-lm3692x.c
+++ b/drivers/leds/leds-lm3692x.c
@@ -394,13 +394,10 @@ static int lm3692x_probe_dt(struct lm3692x_led *led)
 	led->regulator = devm_regulator_get_optional(&led->client->dev, "vled");
 	if (IS_ERR(led->regulator)) {
 		ret = PTR_ERR(led->regulator);
-		if (ret != -ENODEV) {
-			if (ret != -EPROBE_DEFER)
-				dev_err(&led->client->dev,
-					"Failed to get vled regulator: %d\n",
-					ret);
-			return ret;
-		}
+		if (ret != -ENODEV)
+			return dev_err_probe(&led->client->dev, ret,
+					     "Failed to get vled regulator\n");
+
 		led->regulator = NULL;
 	}
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/4] leds: pwm: Simplify with dev_err_probe()
  2020-08-26 14:50 [PATCH 1/4] leds: lm3692x: Simplify with dev_err_probe() Krzysztof Kozlowski
@ 2020-08-26 14:50 ` Krzysztof Kozlowski
  2020-08-26 14:50 ` [PATCH 3/4] leds: sgm3140: " Krzysztof Kozlowski
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Krzysztof Kozlowski @ 2020-08-26 14:50 UTC (permalink / raw)
  To: Pavel Machek, Dan Murphy, linux-leds, linux-kernel; +Cc: Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
 drivers/leds/leds-pwm.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
index ef7b91bd2064..e35a97c1d828 100644
--- a/drivers/leds/leds-pwm.c
+++ b/drivers/leds/leds-pwm.c
@@ -78,13 +78,10 @@ static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv,
 		led_data->pwm = devm_fwnode_pwm_get(dev, fwnode, NULL);
 	else
 		led_data->pwm = devm_pwm_get(dev, led->name);
-	if (IS_ERR(led_data->pwm)) {
-		ret = PTR_ERR(led_data->pwm);
-		if (ret != -EPROBE_DEFER)
-			dev_err(dev, "unable to request PWM for %s: %d\n",
-				led->name, ret);
-		return ret;
-	}
+	if (IS_ERR(led_data->pwm))
+		return dev_err_probe(dev, PTR_ERR(led_data->pwm),
+				     "unable to request PWM for %s\n",
+				     led->name);
 
 	led_data->cdev.brightness_set_blocking = led_pwm_set;
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/4] leds: sgm3140: Simplify with dev_err_probe()
  2020-08-26 14:50 [PATCH 1/4] leds: lm3692x: Simplify with dev_err_probe() Krzysztof Kozlowski
  2020-08-26 14:50 ` [PATCH 2/4] leds: pwm: " Krzysztof Kozlowski
@ 2020-08-26 14:50 ` Krzysztof Kozlowski
  2020-08-26 14:50 ` [PATCH 4/4] leds: tlc591xx: " Krzysztof Kozlowski
  2020-09-09  9:20 ` [PATCH 1/4] leds: lm3692x: " Pavel Machek
  3 siblings, 0 replies; 5+ messages in thread
From: Krzysztof Kozlowski @ 2020-08-26 14:50 UTC (permalink / raw)
  To: Pavel Machek, Dan Murphy, linux-leds, linux-kernel; +Cc: Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
 drivers/leds/leds-sgm3140.c | 27 +++++++++------------------
 1 file changed, 9 insertions(+), 18 deletions(-)

diff --git a/drivers/leds/leds-sgm3140.c b/drivers/leds/leds-sgm3140.c
index 28c8b31fa952..f4f831570f11 100644
--- a/drivers/leds/leds-sgm3140.c
+++ b/drivers/leds/leds-sgm3140.c
@@ -195,30 +195,21 @@ static int sgm3140_probe(struct platform_device *pdev)
 
 	priv->flash_gpio = devm_gpiod_get(&pdev->dev, "flash", GPIOD_OUT_LOW);
 	ret = PTR_ERR_OR_ZERO(priv->flash_gpio);
-	if (ret) {
-		if (ret != -EPROBE_DEFER)
-			dev_err(&pdev->dev,
-				"Failed to request flash gpio: %d\n", ret);
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(&pdev->dev, ret,
+				     "Failed to request flash gpio\n");
 
 	priv->enable_gpio = devm_gpiod_get(&pdev->dev, "enable", GPIOD_OUT_LOW);
 	ret = PTR_ERR_OR_ZERO(priv->enable_gpio);
-	if (ret) {
-		if (ret != -EPROBE_DEFER)
-			dev_err(&pdev->dev,
-				"Failed to request enable gpio: %d\n", ret);
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(&pdev->dev, ret,
+				     "Failed to request enable gpio\n");
 
 	priv->vin_regulator = devm_regulator_get(&pdev->dev, "vin");
 	ret = PTR_ERR_OR_ZERO(priv->vin_regulator);
-	if (ret) {
-		if (ret != -EPROBE_DEFER)
-			dev_err(&pdev->dev,
-				"Failed to request regulator: %d\n", ret);
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(&pdev->dev, ret,
+				     "Failed to request regulator\n");
 
 	child_node = fwnode_get_next_available_child_node(pdev->dev.fwnode,
 							  NULL);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 4/4] leds: tlc591xx: Simplify with dev_err_probe()
  2020-08-26 14:50 [PATCH 1/4] leds: lm3692x: Simplify with dev_err_probe() Krzysztof Kozlowski
  2020-08-26 14:50 ` [PATCH 2/4] leds: pwm: " Krzysztof Kozlowski
  2020-08-26 14:50 ` [PATCH 3/4] leds: sgm3140: " Krzysztof Kozlowski
@ 2020-08-26 14:50 ` Krzysztof Kozlowski
  2020-09-09  9:20 ` [PATCH 1/4] leds: lm3692x: " Pavel Machek
  3 siblings, 0 replies; 5+ messages in thread
From: Krzysztof Kozlowski @ 2020-08-26 14:50 UTC (permalink / raw)
  To: Pavel Machek, Dan Murphy, linux-leds, linux-kernel; +Cc: Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
 drivers/leds/leds-tlc591xx.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/leds/leds-tlc591xx.c b/drivers/leds/leds-tlc591xx.c
index 0929f1275814..1dc14051639c 100644
--- a/drivers/leds/leds-tlc591xx.c
+++ b/drivers/leds/leds-tlc591xx.c
@@ -213,12 +213,10 @@ tlc591xx_probe(struct i2c_client *client,
 		led->ldev.max_brightness = TLC591XX_MAX_BRIGHTNESS;
 		err = devm_led_classdev_register_ext(dev, &led->ldev,
 						     &init_data);
-		if (err < 0) {
-			if (err != -EPROBE_DEFER)
-				dev_err(dev, "couldn't register LED %s\n",
-					led->ldev.name);
-			return err;
-		}
+		if (err < 0)
+			return dev_err_probe(dev, err,
+					     "couldn't register LED %s\n",
+					     led->ldev.name);
 	}
 	return 0;
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/4] leds: lm3692x: Simplify with dev_err_probe()
  2020-08-26 14:50 [PATCH 1/4] leds: lm3692x: Simplify with dev_err_probe() Krzysztof Kozlowski
                   ` (2 preceding siblings ...)
  2020-08-26 14:50 ` [PATCH 4/4] leds: tlc591xx: " Krzysztof Kozlowski
@ 2020-09-09  9:20 ` Pavel Machek
  3 siblings, 0 replies; 5+ messages in thread
From: Pavel Machek @ 2020-09-09  9:20 UTC (permalink / raw)
  To: Krzysztof Kozlowski; +Cc: Dan Murphy, linux-leds, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 435 bytes --]

On Wed 2020-08-26 16:50:10, Krzysztof Kozlowski wrote:
> Common pattern of handling deferred probe can be simplified with
> dev_err_probe().  Less code and also it prints the error value.
> 
> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>

Thanks, applied.
								Pavel
								
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-09-09  9:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-26 14:50 [PATCH 1/4] leds: lm3692x: Simplify with dev_err_probe() Krzysztof Kozlowski
2020-08-26 14:50 ` [PATCH 2/4] leds: pwm: " Krzysztof Kozlowski
2020-08-26 14:50 ` [PATCH 3/4] leds: sgm3140: " Krzysztof Kozlowski
2020-08-26 14:50 ` [PATCH 4/4] leds: tlc591xx: " Krzysztof Kozlowski
2020-09-09  9:20 ` [PATCH 1/4] leds: lm3692x: " Pavel Machek

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).