Linux-LEDs Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 0/5] leds: lm3692x: Probing and flag fixes
@ 2019-09-18  2:19 Guido Günther
  2019-09-18  2:19 ` [PATCH 1/5] leds: lm3692x: Print error value on dev_err Guido Günther
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: Guido Günther @ 2019-09-18  2:19 UTC (permalink / raw)
  To: Jacek Anaszewski, Pavel Machek, Dan Murphy, linux-leds, linux-kernel

The driver currently returns success on init although probing fails and
register setup uses flag values from other registers which is confusing
when reading the driver. This series cleans this up.

Guido Günther (5):
  leds: lm3692x: Print error value on dev_err
  leds: lm3692x: Don't overwrite return value in error path
  leds: lm3692x: Handle failure to probe the regulator
  leds: lm3692x: Use flags from LM3692X_BOOST_CTRL
  leds: lm3692x: Use flags from LM3692X_BRT_CTRL

 drivers/leds/leds-lm3692x.c | 45 ++++++++++++++++++++-----------------
 1 file changed, 25 insertions(+), 20 deletions(-)

-- 
2.23.0.rc1


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

* [PATCH 1/5] leds: lm3692x: Print error value on dev_err
  2019-09-18  2:19 [PATCH 0/5] leds: lm3692x: Probing and flag fixes Guido Günther
@ 2019-09-18  2:19 ` Guido Günther
  2019-09-18 18:23   ` Dan Murphy
  2019-09-18  2:19 ` [PATCH 2/5] leds: lm3692x: Don't overwrite return value in error path Guido Günther
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Guido Günther @ 2019-09-18  2:19 UTC (permalink / raw)
  To: Jacek Anaszewski, Pavel Machek, Dan Murphy, linux-leds, linux-kernel

This gives a way better idea what is going on.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
---
 drivers/leds/leds-lm3692x.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/leds/leds-lm3692x.c b/drivers/leds/leds-lm3692x.c
index 3d381f2f73d0..487228c2bed2 100644
--- a/drivers/leds/leds-lm3692x.c
+++ b/drivers/leds/leds-lm3692x.c
@@ -174,19 +174,20 @@ static int lm3692x_brightness_set(struct led_classdev *led_cdev,
 
 	ret = lm3692x_fault_check(led);
 	if (ret) {
-		dev_err(&led->client->dev, "Cannot read/clear faults\n");
+		dev_err(&led->client->dev, "Cannot read/clear faults: %d\n",
+			ret);
 		goto out;
 	}
 
 	ret = regmap_write(led->regmap, LM3692X_BRT_MSB, brt_val);
 	if (ret) {
-		dev_err(&led->client->dev, "Cannot write MSB\n");
+		dev_err(&led->client->dev, "Cannot write MSB: %d\n", ret);
 		goto out;
 	}
 
 	ret = regmap_write(led->regmap, LM3692X_BRT_LSB, led_brightness_lsb);
 	if (ret) {
-		dev_err(&led->client->dev, "Cannot write LSB\n");
+		dev_err(&led->client->dev, "Cannot write LSB: %d\n", ret);
 		goto out;
 	}
 out:
@@ -203,7 +204,7 @@ static int lm3692x_init(struct lm3692x_led *led)
 		ret = regulator_enable(led->regulator);
 		if (ret) {
 			dev_err(&led->client->dev,
-				"Failed to enable regulator\n");
+				"Failed to enable regulator: %d\n", ret);
 			return ret;
 		}
 	}
@@ -213,7 +214,8 @@ static int lm3692x_init(struct lm3692x_led *led)
 
 	ret = lm3692x_fault_check(led);
 	if (ret) {
-		dev_err(&led->client->dev, "Cannot read/clear faults\n");
+		dev_err(&led->client->dev, "Cannot read/clear faults: %d\n",
+			ret);
 		goto out;
 	}
 
@@ -409,7 +411,8 @@ static int lm3692x_remove(struct i2c_client *client)
 
 	ret = regmap_update_bits(led->regmap, LM3692X_EN, LM3692X_DEVICE_EN, 0);
 	if (ret) {
-		dev_err(&led->client->dev, "Failed to disable regulator\n");
+		dev_err(&led->client->dev, "Failed to disable regulator: %d\n",
+			ret);
 		return ret;
 	}
 
@@ -420,7 +423,7 @@ static int lm3692x_remove(struct i2c_client *client)
 		ret = regulator_disable(led->regulator);
 		if (ret)
 			dev_err(&led->client->dev,
-				"Failed to disable regulator\n");
+				"Failed to disable regulator: %d\n", ret);
 	}
 
 	mutex_destroy(&led->lock);
-- 
2.23.0.rc1


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

* [PATCH 2/5] leds: lm3692x: Don't overwrite return value in error path
  2019-09-18  2:19 [PATCH 0/5] leds: lm3692x: Probing and flag fixes Guido Günther
  2019-09-18  2:19 ` [PATCH 1/5] leds: lm3692x: Print error value on dev_err Guido Günther
@ 2019-09-18  2:19 ` Guido Günther
  2019-09-18 18:33   ` Dan Murphy
  2019-09-19 10:57   ` Pavel Machek
  2019-09-18  2:19 ` [PATCH 3/5] leds: lm3692x: Handle failure to probe the regulator Guido Günther
                   ` (3 subsequent siblings)
  5 siblings, 2 replies; 13+ messages in thread
From: Guido Günther @ 2019-09-18  2:19 UTC (permalink / raw)
  To: Jacek Anaszewski, Pavel Machek, Dan Murphy, linux-leds, linux-kernel

The driver currently reports successful initialization on every failure
as long as it's able to power off the regulator. Don't check the return
value of regulator_disable to avoid that.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
---
 drivers/leds/leds-lm3692x.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/leds/leds-lm3692x.c b/drivers/leds/leds-lm3692x.c
index 487228c2bed2..f394669ad8f2 100644
--- a/drivers/leds/leds-lm3692x.c
+++ b/drivers/leds/leds-lm3692x.c
@@ -312,15 +312,12 @@ static int lm3692x_init(struct lm3692x_led *led)
 	if (led->enable_gpio)
 		gpiod_direction_output(led->enable_gpio, 0);
 
-	if (led->regulator) {
-		ret = regulator_disable(led->regulator);
-		if (ret)
-			dev_err(&led->client->dev,
-				"Failed to disable regulator\n");
-	}
+	if (led->regulator)
+		regulator_disable(led->regulator);
 
 	return ret;
 }
+
 static int lm3692x_probe_dt(struct lm3692x_led *led)
 {
 	struct fwnode_handle *child = NULL;
-- 
2.23.0.rc1


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

* [PATCH 3/5] leds: lm3692x: Handle failure to probe the regulator
  2019-09-18  2:19 [PATCH 0/5] leds: lm3692x: Probing and flag fixes Guido Günther
  2019-09-18  2:19 ` [PATCH 1/5] leds: lm3692x: Print error value on dev_err Guido Günther
  2019-09-18  2:19 ` [PATCH 2/5] leds: lm3692x: Don't overwrite return value in error path Guido Günther
@ 2019-09-18  2:19 ` Guido Günther
  2019-09-18 18:41   ` Dan Murphy
  2019-09-18  2:19 ` [PATCH 4/5] leds: lm3692x: Use flags from LM3692X_BOOST_CTRL Guido Günther
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Guido Günther @ 2019-09-18  2:19 UTC (permalink / raw)
  To: Jacek Anaszewski, Pavel Machek, Dan Murphy, linux-leds, linux-kernel

Instead use devm_regulator_get_optional since the regulator
is optional and check for errors.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
---
 drivers/leds/leds-lm3692x.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/leds/leds-lm3692x.c b/drivers/leds/leds-lm3692x.c
index f394669ad8f2..9972c932d51e 100644
--- a/drivers/leds/leds-lm3692x.c
+++ b/drivers/leds/leds-lm3692x.c
@@ -333,9 +333,14 @@ static int lm3692x_probe_dt(struct lm3692x_led *led)
 		return ret;
 	}
 
-	led->regulator = devm_regulator_get(&led->client->dev, "vled");
-	if (IS_ERR(led->regulator))
-		led->regulator = NULL;
+	led->regulator = devm_regulator_get_optional(&led->client->dev, "vled");
+	if (IS_ERR(led->regulator)) {
+		ret = PTR_ERR(led->regulator);
+		if (ret != -EPROBE_DEFER)
+			dev_err(&led->client->dev,
+				"Failed to get vled regulator: %d\n", ret);
+		return ret;
+	}
 
 	child = device_get_next_child_node(&led->client->dev, child);
 	if (!child) {
-- 
2.23.0.rc1


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

* [PATCH 4/5] leds: lm3692x: Use flags from LM3692X_BOOST_CTRL
  2019-09-18  2:19 [PATCH 0/5] leds: lm3692x: Probing and flag fixes Guido Günther
                   ` (2 preceding siblings ...)
  2019-09-18  2:19 ` [PATCH 3/5] leds: lm3692x: Handle failure to probe the regulator Guido Günther
@ 2019-09-18  2:19 ` Guido Günther
  2019-09-18 18:46   ` Dan Murphy
  2019-09-18  2:19 ` [PATCH 5/5] leds: lm3692x: Use flags from LM3692X_BRT_CTRL Guido Günther
  2019-09-19  9:54 ` [PATCH 0/5] leds: lm3692x: Probing and flag fixes Pavel Machek
  5 siblings, 1 reply; 13+ messages in thread
From: Guido Günther @ 2019-09-18  2:19 UTC (permalink / raw)
  To: Jacek Anaszewski, Pavel Machek, Dan Murphy, linux-leds, linux-kernel

The current setup of LM3692X_BOOST_CTRL uses flags from LM3692X_BRT_CTRL.
Use flags from LM3692X_BOOST_CTRL but leave the resulting register value
unchanged.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
---
 drivers/leds/leds-lm3692x.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/leds/leds-lm3692x.c b/drivers/leds/leds-lm3692x.c
index 9972c932d51e..d673f706385e 100644
--- a/drivers/leds/leds-lm3692x.c
+++ b/drivers/leds/leds-lm3692x.c
@@ -250,9 +250,9 @@ static int lm3692x_init(struct lm3692x_led *led)
 		goto out;
 
 	ret = regmap_write(led->regmap, LM3692X_BOOST_CTRL,
-			LM3692X_BRHT_MODE_RAMP_MULTI |
-			LM3692X_BL_ADJ_POL |
-			LM3692X_RAMP_RATE_250us);
+			LM3692X_BOOST_SW_1MHZ |
+			LM3692X_BOOST_SW_NO_SHIFT |
+			LM3692X_OCP_PROT_1_5A);
 	if (ret)
 		goto out;
 
-- 
2.23.0.rc1


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

* [PATCH 5/5] leds: lm3692x: Use flags from LM3692X_BRT_CTRL
  2019-09-18  2:19 [PATCH 0/5] leds: lm3692x: Probing and flag fixes Guido Günther
                   ` (3 preceding siblings ...)
  2019-09-18  2:19 ` [PATCH 4/5] leds: lm3692x: Use flags from LM3692X_BOOST_CTRL Guido Günther
@ 2019-09-18  2:19 ` Guido Günther
  2019-09-18 18:48   ` Dan Murphy
  2019-09-19  9:54 ` [PATCH 0/5] leds: lm3692x: Probing and flag fixes Pavel Machek
  5 siblings, 1 reply; 13+ messages in thread
From: Guido Günther @ 2019-09-18  2:19 UTC (permalink / raw)
  To: Jacek Anaszewski, Pavel Machek, Dan Murphy, linux-leds, linux-kernel

Use LM3692X_RAMP_EN instead of LM3692X_PWM_HYSTER_4LSB
since the later is a flag for the PWM register. The
actual register value remains unchanged.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
---
 drivers/leds/leds-lm3692x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/leds/leds-lm3692x.c b/drivers/leds/leds-lm3692x.c
index d673f706385e..ecac586ca89c 100644
--- a/drivers/leds/leds-lm3692x.c
+++ b/drivers/leds/leds-lm3692x.c
@@ -269,7 +269,7 @@ static int lm3692x_init(struct lm3692x_led *led)
 		goto out;
 
 	ret = regmap_write(led->regmap, LM3692X_BRT_CTRL,
-			LM3692X_BL_ADJ_POL | LM3692X_PWM_HYSTER_4LSB);
+			LM3692X_BL_ADJ_POL | LM3692X_RAMP_EN);
 	if (ret)
 		goto out;
 
-- 
2.23.0.rc1


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

* Re: [PATCH 1/5] leds: lm3692x: Print error value on dev_err
  2019-09-18  2:19 ` [PATCH 1/5] leds: lm3692x: Print error value on dev_err Guido Günther
@ 2019-09-18 18:23   ` Dan Murphy
  0 siblings, 0 replies; 13+ messages in thread
From: Dan Murphy @ 2019-09-18 18:23 UTC (permalink / raw)
  To: Guido Günther, Jacek Anaszewski, Pavel Machek, linux-leds,
	linux-kernel

Guido

On 9/17/19 9:19 PM, Guido Günther wrote:
> This gives a way better idea what is going on.
>
> Signed-off-by: Guido Günther <agx@sigxcpu.org>

Reviewed-by: Dan Murphy <dmurphy@ti.com>


> ---
>   drivers/leds/leds-lm3692x.c | 17 ++++++++++-------
>   1 file changed, 10 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/leds/leds-lm3692x.c b/drivers/leds/leds-lm3692x.c
> index 3d381f2f73d0..487228c2bed2 100644
> --- a/drivers/leds/leds-lm3692x.c
> +++ b/drivers/leds/leds-lm3692x.c
> @@ -174,19 +174,20 @@ static int lm3692x_brightness_set(struct led_classdev *led_cdev,
>   
>   	ret = lm3692x_fault_check(led);
>   	if (ret) {
> -		dev_err(&led->client->dev, "Cannot read/clear faults\n");
> +		dev_err(&led->client->dev, "Cannot read/clear faults: %d\n",
> +			ret);
>   		goto out;
>   	}
>   
>   	ret = regmap_write(led->regmap, LM3692X_BRT_MSB, brt_val);
>   	if (ret) {
> -		dev_err(&led->client->dev, "Cannot write MSB\n");
> +		dev_err(&led->client->dev, "Cannot write MSB: %d\n", ret);
>   		goto out;
>   	}
>   
>   	ret = regmap_write(led->regmap, LM3692X_BRT_LSB, led_brightness_lsb);
>   	if (ret) {
> -		dev_err(&led->client->dev, "Cannot write LSB\n");
> +		dev_err(&led->client->dev, "Cannot write LSB: %d\n", ret);
>   		goto out;
>   	}
>   out:
> @@ -203,7 +204,7 @@ static int lm3692x_init(struct lm3692x_led *led)
>   		ret = regulator_enable(led->regulator);
>   		if (ret) {
>   			dev_err(&led->client->dev,
> -				"Failed to enable regulator\n");
> +				"Failed to enable regulator: %d\n", ret);
>   			return ret;
>   		}
>   	}
> @@ -213,7 +214,8 @@ static int lm3692x_init(struct lm3692x_led *led)
>   
>   	ret = lm3692x_fault_check(led);
>   	if (ret) {
> -		dev_err(&led->client->dev, "Cannot read/clear faults\n");
> +		dev_err(&led->client->dev, "Cannot read/clear faults: %d\n",
> +			ret);
>   		goto out;
>   	}
>   
> @@ -409,7 +411,8 @@ static int lm3692x_remove(struct i2c_client *client)
>   
>   	ret = regmap_update_bits(led->regmap, LM3692X_EN, LM3692X_DEVICE_EN, 0);
>   	if (ret) {
> -		dev_err(&led->client->dev, "Failed to disable regulator\n");
> +		dev_err(&led->client->dev, "Failed to disable regulator: %d\n",
> +			ret);
>   		return ret;
>   	}
>   
> @@ -420,7 +423,7 @@ static int lm3692x_remove(struct i2c_client *client)
>   		ret = regulator_disable(led->regulator);
>   		if (ret)
>   			dev_err(&led->client->dev,
> -				"Failed to disable regulator\n");
> +				"Failed to disable regulator: %d\n", ret);
>   	}
>   
>   	mutex_destroy(&led->lock);

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

* Re: [PATCH 2/5] leds: lm3692x: Don't overwrite return value in error path
  2019-09-18  2:19 ` [PATCH 2/5] leds: lm3692x: Don't overwrite return value in error path Guido Günther
@ 2019-09-18 18:33   ` Dan Murphy
  2019-09-19 10:57   ` Pavel Machek
  1 sibling, 0 replies; 13+ messages in thread
From: Dan Murphy @ 2019-09-18 18:33 UTC (permalink / raw)
  To: Guido Günther, Jacek Anaszewski, Pavel Machek, linux-leds,
	linux-kernel

Guido

On 9/17/19 9:19 PM, Guido Günther wrote:
> The driver currently reports successful initialization on every failure
> as long as it's able to power off the regulator. Don't check the return
> value of regulator_disable to avoid that.
>
> Signed-off-by: Guido Günther <agx@sigxcpu.org>
> ---
>   drivers/leds/leds-lm3692x.c | 9 +++------
>   1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/leds/leds-lm3692x.c b/drivers/leds/leds-lm3692x.c
> index 487228c2bed2..f394669ad8f2 100644
> --- a/drivers/leds/leds-lm3692x.c
> +++ b/drivers/leds/leds-lm3692x.c
> @@ -312,15 +312,12 @@ static int lm3692x_init(struct lm3692x_led *led)
>   	if (led->enable_gpio)
>   		gpiod_direction_output(led->enable_gpio, 0);
>   
> -	if (led->regulator) {
> -		ret = regulator_disable(led->regulator);
> -		if (ret)
> -			dev_err(&led->client->dev,
> -				"Failed to disable regulator\n");
> -	}
> +	if (led->regulator)
> +		regulator_disable(led->regulator);

The change is ok and makes sense but I believe that if the regulator was 
not properly disabled there needs to be some error message t0o.

If the code got here then there is either a fault or an I/O issue not a 
regulator issue.

The regulator failing to disable should be logged.

Dan


>   
>   	return ret;
>   }
> +
>   static int lm3692x_probe_dt(struct lm3692x_led *led)
>   {
>   	struct fwnode_handle *child = NULL;

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

* Re: [PATCH 3/5] leds: lm3692x: Handle failure to probe the regulator
  2019-09-18  2:19 ` [PATCH 3/5] leds: lm3692x: Handle failure to probe the regulator Guido Günther
@ 2019-09-18 18:41   ` Dan Murphy
  0 siblings, 0 replies; 13+ messages in thread
From: Dan Murphy @ 2019-09-18 18:41 UTC (permalink / raw)
  To: Guido Günther, Jacek Anaszewski, Pavel Machek, linux-leds,
	linux-kernel

Guido

On 9/17/19 9:19 PM, Guido Günther wrote:
> Instead use devm_regulator_get_optional since the regulator
> is optional and check for errors.
>
> Signed-off-by: Guido Günther <agx@sigxcpu.org>
> ---
>   drivers/leds/leds-lm3692x.c | 11 ++++++++---
>   1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/leds/leds-lm3692x.c b/drivers/leds/leds-lm3692x.c
> index f394669ad8f2..9972c932d51e 100644
> --- a/drivers/leds/leds-lm3692x.c
> +++ b/drivers/leds/leds-lm3692x.c
> @@ -333,9 +333,14 @@ static int lm3692x_probe_dt(struct lm3692x_led *led)
>   		return ret;
>   	}
>   
> -	led->regulator = devm_regulator_get(&led->client->dev, "vled");
> -	if (IS_ERR(led->regulator))
> -		led->regulator = NULL;
> +	led->regulator = devm_regulator_get_optional(&led->client->dev, "vled");
> +	if (IS_ERR(led->regulator)) {
> +		ret = PTR_ERR(led->regulator);
> +		if (ret != -EPROBE_DEFER)
> +			dev_err(&led->client->dev,
> +				"Failed to get vled regulator: %d\n", ret);
nitpick. Add a new line for readability
> +		return ret;
> +	}

If the regulator is not set then led->regulator should be set to NULL.

Dan


>   
>   	child = device_get_next_child_node(&led->client->dev, child);
>   	if (!child) {

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

* Re: [PATCH 4/5] leds: lm3692x: Use flags from LM3692X_BOOST_CTRL
  2019-09-18  2:19 ` [PATCH 4/5] leds: lm3692x: Use flags from LM3692X_BOOST_CTRL Guido Günther
@ 2019-09-18 18:46   ` Dan Murphy
  0 siblings, 0 replies; 13+ messages in thread
From: Dan Murphy @ 2019-09-18 18:46 UTC (permalink / raw)
  To: Guido Günther, Jacek Anaszewski, Pavel Machek, linux-leds,
	linux-kernel

Guido

On 9/17/19 9:19 PM, Guido Günther wrote:
> The current setup of LM3692X_BOOST_CTRL uses flags from LM3692X_BRT_CTRL.
> Use flags from LM3692X_BOOST_CTRL but leave the resulting register value
> unchanged.
>
> Signed-off-by: Guido Günther <agx@sigxcpu.org>
Reviewed-by: Dan Murphy <dmurphy@ti.com>
> ---
>   drivers/leds/leds-lm3692x.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/leds/leds-lm3692x.c b/drivers/leds/leds-lm3692x.c
> index 9972c932d51e..d673f706385e 100644
> --- a/drivers/leds/leds-lm3692x.c
> +++ b/drivers/leds/leds-lm3692x.c
> @@ -250,9 +250,9 @@ static int lm3692x_init(struct lm3692x_led *led)
>   		goto out;
>   
>   	ret = regmap_write(led->regmap, LM3692X_BOOST_CTRL,
> -			LM3692X_BRHT_MODE_RAMP_MULTI |
> -			LM3692X_BL_ADJ_POL |
> -			LM3692X_RAMP_RATE_250us);
> +			LM3692X_BOOST_SW_1MHZ |
> +			LM3692X_BOOST_SW_NO_SHIFT |
> +			LM3692X_OCP_PROT_1_5A);
>   	if (ret)
>   		goto out;
>   

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

* Re: [PATCH 5/5] leds: lm3692x: Use flags from LM3692X_BRT_CTRL
  2019-09-18  2:19 ` [PATCH 5/5] leds: lm3692x: Use flags from LM3692X_BRT_CTRL Guido Günther
@ 2019-09-18 18:48   ` Dan Murphy
  0 siblings, 0 replies; 13+ messages in thread
From: Dan Murphy @ 2019-09-18 18:48 UTC (permalink / raw)
  To: Guido Günther, Jacek Anaszewski, Pavel Machek, linux-leds,
	linux-kernel

Guido

On 9/17/19 9:19 PM, Guido Günther wrote:
> Use LM3692X_RAMP_EN instead of LM3692X_PWM_HYSTER_4LSB
> since the later is a flag for the PWM register. The
> actual register value remains unchanged.
>
> Signed-off-by: Guido Günther <agx@sigxcpu.org>
Reviewed-by: Dan Murphy <dmurphy@ti.com>
> ---
>   drivers/leds/leds-lm3692x.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/leds/leds-lm3692x.c b/drivers/leds/leds-lm3692x.c
> index d673f706385e..ecac586ca89c 100644
> --- a/drivers/leds/leds-lm3692x.c
> +++ b/drivers/leds/leds-lm3692x.c
> @@ -269,7 +269,7 @@ static int lm3692x_init(struct lm3692x_led *led)
>   		goto out;
>   
>   	ret = regmap_write(led->regmap, LM3692X_BRT_CTRL,
> -			LM3692X_BL_ADJ_POL | LM3692X_PWM_HYSTER_4LSB);
> +			LM3692X_BL_ADJ_POL | LM3692X_RAMP_EN);
>   	if (ret)
>   		goto out;
>   

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

* Re: [PATCH 0/5] leds: lm3692x: Probing and flag fixes
  2019-09-18  2:19 [PATCH 0/5] leds: lm3692x: Probing and flag fixes Guido Günther
                   ` (4 preceding siblings ...)
  2019-09-18  2:19 ` [PATCH 5/5] leds: lm3692x: Use flags from LM3692X_BRT_CTRL Guido Günther
@ 2019-09-19  9:54 ` Pavel Machek
  5 siblings, 0 replies; 13+ messages in thread
From: Pavel Machek @ 2019-09-19  9:54 UTC (permalink / raw)
  To: Guido Günther; +Cc: Jacek Anaszewski, Dan Murphy, linux-leds, linux-kernel


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

On Tue 2019-09-17 19:19:53, Guido Günther wrote:
> The driver currently returns success on init although probing fails and
> register setup uses flag values from other registers which is confusing
> when reading the driver. This series cleans this up.

1,3,4,5: Acked-by: Pavel Machek <pavel@ucw.cz>

-- 
(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] 13+ messages in thread

* Re: [PATCH 2/5] leds: lm3692x: Don't overwrite return value in error path
  2019-09-18  2:19 ` [PATCH 2/5] leds: lm3692x: Don't overwrite return value in error path Guido Günther
  2019-09-18 18:33   ` Dan Murphy
@ 2019-09-19 10:57   ` Pavel Machek
  1 sibling, 0 replies; 13+ messages in thread
From: Pavel Machek @ 2019-09-19 10:57 UTC (permalink / raw)
  To: Guido Günther; +Cc: Jacek Anaszewski, Dan Murphy, linux-leds, linux-kernel


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

On Tue 2019-09-17 19:19:55, Guido Günther wrote:
> The driver currently reports successful initialization on every failure
> as long as it's able to power off the regulator. Don't check the return
> value of regulator_disable to avoid that.
> 
> Signed-off-by: Guido Günther <agx@sigxcpu.org>
> ---
>  drivers/leds/leds-lm3692x.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/leds/leds-lm3692x.c b/drivers/leds/leds-lm3692x.c
> index 487228c2bed2..f394669ad8f2 100644
> --- a/drivers/leds/leds-lm3692x.c
> +++ b/drivers/leds/leds-lm3692x.c
> @@ -312,15 +312,12 @@ static int lm3692x_init(struct lm3692x_led *led)
>  	if (led->enable_gpio)
>  		gpiod_direction_output(led->enable_gpio, 0);
>  
> -	if (led->regulator) {
> -		ret = regulator_disable(led->regulator);
> -		if (ret)
> -			dev_err(&led->client->dev,
> -				"Failed to disable regulator\n");
> -	}
> +	if (led->regulator)
> +		regulator_disable(led->regulator);
>  
>  	return ret;

Overwriting return value is bad, but we should still print some kind
of error message.

Best regards,
									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] 13+ messages in thread

end of thread, back to index

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-18  2:19 [PATCH 0/5] leds: lm3692x: Probing and flag fixes Guido Günther
2019-09-18  2:19 ` [PATCH 1/5] leds: lm3692x: Print error value on dev_err Guido Günther
2019-09-18 18:23   ` Dan Murphy
2019-09-18  2:19 ` [PATCH 2/5] leds: lm3692x: Don't overwrite return value in error path Guido Günther
2019-09-18 18:33   ` Dan Murphy
2019-09-19 10:57   ` Pavel Machek
2019-09-18  2:19 ` [PATCH 3/5] leds: lm3692x: Handle failure to probe the regulator Guido Günther
2019-09-18 18:41   ` Dan Murphy
2019-09-18  2:19 ` [PATCH 4/5] leds: lm3692x: Use flags from LM3692X_BOOST_CTRL Guido Günther
2019-09-18 18:46   ` Dan Murphy
2019-09-18  2:19 ` [PATCH 5/5] leds: lm3692x: Use flags from LM3692X_BRT_CTRL Guido Günther
2019-09-18 18:48   ` Dan Murphy
2019-09-19  9:54 ` [PATCH 0/5] leds: lm3692x: Probing and flag fixes Pavel Machek

Linux-LEDs Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-leds/0 linux-leds/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-leds linux-leds/ https://lore.kernel.org/linux-leds \
		linux-leds@vger.kernel.org
	public-inbox-index linux-leds

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-leds


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git