linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] leds-lm3530: set the value of max_brightness to 127
@ 2012-01-20 17:34 Kim, Milo
  2012-01-20 18:38 ` Lars-Peter Clausen
  0 siblings, 1 reply; 3+ messages in thread
From: Kim, Milo @ 2012-01-20 17:34 UTC (permalink / raw)
  To: Linus Walleij, shreshthakumar.sahu, Lars-Peter Clausen
  Cc: linux-kernel, rpurdie

Only 7 bits are used for the brightness. (register address : A0h)
So the max_brightness property of lm3530 should be set to 127.

On initializing registers, maximum initial brightness is limited to 'max_brightness'.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/leds/leds-lm3530.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/drivers/leds/leds-lm3530.c b/drivers/leds/leds-lm3530.c
index 4d7ce76..dce6c2a 100644
--- a/drivers/leds/leds-lm3530.c
+++ b/drivers/leds/leds-lm3530.c
@@ -80,6 +80,9 @@
 #define LM3530_DEF_ZT_3			(0x66)
 #define LM3530_DEF_ZT_4			(0x7F)
 
+/* 7 bits are used for the brightness : LM3530_BRT_CTRL_REG */
+#define MAX_BRIGHTNESS			(127)
+
 struct lm3530_mode_map {
 	const char *mode;
 	enum lm3530_mode mode_val;
@@ -184,6 +187,9 @@ static int lm3530_init_registers(struct lm3530_data *drvdata)
 	else
 		brightness = drvdata->brightness = pltfm->brt_val;
 
+	if (brightness > drvdata->led_dev.max_brightness)
+		brightness = drvdata->led_dev.max_brightness;
+
 	reg_val[0] = gen_config;	/* LM3530_GEN_CONFIG */
 	reg_val[1] = als_config;	/* LM3530_ALS_CONFIG */
 	reg_val[2] = brt_ramp;		/* LM3530_BRT_RAMP_RATE */
@@ -340,6 +346,7 @@ static int __devinit lm3530_probe(struct i2c_client *client,
 	drvdata->enable = false;
 	drvdata->led_dev.name = LM3530_LED_DEV;
 	drvdata->led_dev.brightness_set = lm3530_brightness_set;
+	drvdata->led_dev.max_brightness = MAX_BRIGHTNESS;
 
 	i2c_set_clientdata(client, drvdata);
 
-- 
1.7.4.1


Best Regards,
Milo (Woogyom) Kim
Texas Instruments Incorporated


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

* Re: [PATCH] leds-lm3530: set the value of max_brightness to 127
  2012-01-20 17:34 [PATCH] leds-lm3530: set the value of max_brightness to 127 Kim, Milo
@ 2012-01-20 18:38 ` Lars-Peter Clausen
  2012-01-25  1:53   ` Kim, Milo
  0 siblings, 1 reply; 3+ messages in thread
From: Lars-Peter Clausen @ 2012-01-20 18:38 UTC (permalink / raw)
  To: Kim, Milo; +Cc: Linus Walleij, shreshthakumar.sahu, linux-kernel, rpurdie

On 01/20/2012 06:34 PM, Kim, Milo wrote:
> Only 7 bits are used for the brightness. (register address : A0h)
> So the max_brightness property of lm3530 should be set to 127.
> 
> On initializing registers, maximum initial brightness is limited to 'max_brightness'.
> 
> Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
> Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>

Uhm, I might have suggested this, but I've definitely not yet reviewed this
patch. Please don't add tags for other people unless they have explicitly given
you that tag.

> ---
>  drivers/leds/leds-lm3530.c |    7 +++++++
>  1 files changed, 7 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/leds/leds-lm3530.c b/drivers/leds/leds-lm3530.c
> index 4d7ce76..dce6c2a 100644
> --- a/drivers/leds/leds-lm3530.c
> +++ b/drivers/leds/leds-lm3530.c
> @@ -80,6 +80,9 @@
>  #define LM3530_DEF_ZT_3			(0x66)
>  #define LM3530_DEF_ZT_4			(0x7F)
>  
> +/* 7 bits are used for the brightness : LM3530_BRT_CTRL_REG */
> +#define MAX_BRIGHTNESS			(127)
> +
>  struct lm3530_mode_map {
>  	const char *mode;
>  	enum lm3530_mode mode_val;
> @@ -184,6 +187,9 @@ static int lm3530_init_registers(struct lm3530_data *drvdata)
>  	else
>  		brightness = drvdata->brightness = pltfm->brt_val;
>  
> +	if (brightness > drvdata->led_dev.max_brightness)
> +		brightness = drvdata->led_dev.max_brightness;
> +
>  	reg_val[0] = gen_config;	/* LM3530_GEN_CONFIG */
>  	reg_val[1] = als_config;	/* LM3530_ALS_CONFIG */
>  	reg_val[2] = brt_ramp;		/* LM3530_BRT_RAMP_RATE */
> @@ -340,6 +346,7 @@ static int __devinit lm3530_probe(struct i2c_client *client,
>  	drvdata->enable = false;
>  	drvdata->led_dev.name = LM3530_LED_DEV;
>  	drvdata->led_dev.brightness_set = lm3530_brightness_set;
> +	drvdata->led_dev.max_brightness = MAX_BRIGHTNESS;
>  
>  	i2c_set_clientdata(client, drvdata);
>

You should also remove the division by two. max_brightness is supposed to be
the maximum value which the brightness value can be set to.

- Lars


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

* RE: [PATCH] leds-lm3530: set the value of max_brightness to 127
  2012-01-20 18:38 ` Lars-Peter Clausen
@ 2012-01-25  1:53   ` Kim, Milo
  0 siblings, 0 replies; 3+ messages in thread
From: Kim, Milo @ 2012-01-25  1:53 UTC (permalink / raw)
  To: Lars-Peter Clausen
  Cc: Linus Walleij, shreshthakumar.sahu, linux-kernel, rpurdie

Updated patch has been sent.

Title : [PATCH v2 1/2] leds-lm3530: set the value of max_brightness to 127

Thanks & BR
Milo -

-----Original Message-----
From: Lars-Peter Clausen [mailto:lars@metafoo.de] 
Sent: Saturday, January 21, 2012 3:39 AM
To: Kim, Milo
Cc: Linus Walleij; shreshthakumar.sahu@stericsson.com; linux-kernel@vger.kernel.org; rpurdie@rpsys.net
Subject: Re: [PATCH] leds-lm3530: set the value of max_brightness to 127

On 01/20/2012 06:34 PM, Kim, Milo wrote:
> Only 7 bits are used for the brightness. (register address : A0h)
> So the max_brightness property of lm3530 should be set to 127.
> 
> On initializing registers, maximum initial brightness is limited to 'max_brightness'.
> 
> Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
> Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>

Uhm, I might have suggested this, but I've definitely not yet reviewed this
patch. Please don't add tags for other people unless they have explicitly given
you that tag.

> ---
>  drivers/leds/leds-lm3530.c |    7 +++++++
>  1 files changed, 7 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/leds/leds-lm3530.c b/drivers/leds/leds-lm3530.c
> index 4d7ce76..dce6c2a 100644
> --- a/drivers/leds/leds-lm3530.c
> +++ b/drivers/leds/leds-lm3530.c
> @@ -80,6 +80,9 @@
>  #define LM3530_DEF_ZT_3			(0x66)
>  #define LM3530_DEF_ZT_4			(0x7F)
>  
> +/* 7 bits are used for the brightness : LM3530_BRT_CTRL_REG */
> +#define MAX_BRIGHTNESS			(127)
> +
>  struct lm3530_mode_map {
>  	const char *mode;
>  	enum lm3530_mode mode_val;
> @@ -184,6 +187,9 @@ static int lm3530_init_registers(struct lm3530_data *drvdata)
>  	else
>  		brightness = drvdata->brightness = pltfm->brt_val;
>  
> +	if (brightness > drvdata->led_dev.max_brightness)
> +		brightness = drvdata->led_dev.max_brightness;
> +
>  	reg_val[0] = gen_config;	/* LM3530_GEN_CONFIG */
>  	reg_val[1] = als_config;	/* LM3530_ALS_CONFIG */
>  	reg_val[2] = brt_ramp;		/* LM3530_BRT_RAMP_RATE */
> @@ -340,6 +346,7 @@ static int __devinit lm3530_probe(struct i2c_client *client,
>  	drvdata->enable = false;
>  	drvdata->led_dev.name = LM3530_LED_DEV;
>  	drvdata->led_dev.brightness_set = lm3530_brightness_set;
> +	drvdata->led_dev.max_brightness = MAX_BRIGHTNESS;
>  
>  	i2c_set_clientdata(client, drvdata);
>

You should also remove the division by two. max_brightness is supposed to be
the maximum value which the brightness value can be set to.

- Lars



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

end of thread, other threads:[~2012-01-25  1:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-20 17:34 [PATCH] leds-lm3530: set the value of max_brightness to 127 Kim, Milo
2012-01-20 18:38 ` Lars-Peter Clausen
2012-01-25  1:53   ` Kim, Milo

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