2019-12-25 11:17:41

by Guido Günther

[permalink] [raw]
Subject: [PATCH 0/3] leds: lm3692x: Disable chip on brightness 0

Otherwise there's a hardly noticeable glow even with brightness 0. Also turning
off the regulator can save additional power.

This is on top of the "leds: lm3692x: Allow to set ovp and brigthness mode".
Without that applied there's a minor merge conflict since this introduces a new
variable in struct lm3692x_led as well. I did not want to lump it in there as
well since it's not related to any DT properties at all.

Guido Günther (3):
leds: lm3692x: Move lm3692x_init and rename to lm3692x_leds_enable
leds: lm3692x: Split out lm3692x_leds_disable
leds: lm3692x: Disable chip on brightness 0

drivers/leds/leds-lm3692x.c | 128 ++++++++++++++++++++++--------------
1 file changed, 77 insertions(+), 51 deletions(-)

--
2.23.0


2019-12-25 11:17:46

by Guido Günther

[permalink] [raw]
Subject: [PATCH 2/3] leds: lm3692x: Split out lm3692x_leds_disable

Move the relevant parts out of lm3692x_remove() and
call it from there. No functional change.

Signed-off-by: Guido Günther <[email protected]>
---
drivers/leds/leds-lm3692x.c | 42 +++++++++++++++++++++++--------------
1 file changed, 26 insertions(+), 16 deletions(-)

diff --git a/drivers/leds/leds-lm3692x.c b/drivers/leds/leds-lm3692x.c
index 7bf97ee6aa92..d1bd9ae4e7ab 100644
--- a/drivers/leds/leds-lm3692x.c
+++ b/drivers/leds/leds-lm3692x.c
@@ -288,6 +288,30 @@ static int lm3692x_leds_enable(struct lm3692x_led *led)
return ret;
}

+static int lm3692x_leds_disable(struct lm3692x_led *led)
+{
+ int ret;
+
+ ret = regmap_update_bits(led->regmap, LM3692X_EN, LM3692X_DEVICE_EN, 0);
+ if (ret) {
+ dev_err(&led->client->dev, "Failed to disable regulator: %d\n",
+ ret);
+ return ret;
+ }
+
+ 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: %d\n", ret);
+ }
+
+ return ret;
+}
+
static int lm3692x_brightness_set(struct led_classdev *led_cdev,
enum led_brightness brt_val)
{
@@ -474,23 +498,9 @@ static int lm3692x_remove(struct i2c_client *client)
struct lm3692x_led *led = i2c_get_clientdata(client);
int ret;

- ret = regmap_update_bits(led->regmap, LM3692X_EN, LM3692X_DEVICE_EN, 0);
- if (ret) {
- dev_err(&led->client->dev, "Failed to disable regulator: %d\n",
- ret);
+ ret = lm3692x_leds_disable(led);
+ if (ret)
return ret;
- }
-
- 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: %d\n", ret);
- }
-
mutex_destroy(&led->lock);

return 0;
--
2.23.0

2019-12-26 10:15:16

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH 0/3] leds: lm3692x: Disable chip on brightness 0

On Wed 2019-12-25 12:16:36, Guido G?nther wrote:
> Otherwise there's a hardly noticeable glow even with brightness 0. Also turning
> off the regulator can save additional power.

I guess it is of too low intensity to be used, for example in
completely dark room?

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


Attachments:
(No filename) (441.00 B)
signature.asc (188.00 B)
Digital signature
Download all attachments

2019-12-26 10:17:11

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH 2/3] leds: lm3692x: Split out lm3692x_leds_disable

On Wed 2019-12-25 12:16:38, Guido G?nther wrote:
> Move the relevant parts out of lm3692x_remove() and
> call it from there. No functional change.
>
> Signed-off-by: Guido G?nther <[email protected]>

Acked-by: Pavel Machek <[email protected]>

Pavel

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


Attachments:
(No filename) (411.00 B)
signature.asc (188.00 B)
Digital signature
Download all attachments