linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* RE: [PATCH 4/4] leds-lp5521: redefinition of register bits
@ 2012-01-27  2:23 Kim, Milo
  0 siblings, 0 replies; 3+ messages in thread
From: Kim, Milo @ 2012-01-27  2:23 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arun MURTHY, srinidhi kasagar, Linus Walleij, Andrew Morton, rpurdie

Add Arun, Srinidhi, Linus and Andrew on CC

> -----Original Message-----
> From: Kim, Milo
> Sent: Sunday, January 22, 2012 3:10 AM
> To: 'linux-kernel@vger.kernel.org'; 'rpurdie@rpsys.net'
> Subject: [PATCH 4/4] leds-lp5521: redefinition of register bits
> 
> For better readability, values of LP5521_REG_ENABLE register were
> redefined.
> Additional definitions: LP5521_ENABLE_DEFAULT and
> LP5521_ENABLE_RUN_PROGRAM.
> 
> Use definition rather than hard code value.
> : 0x3F -> 'LP5521_CMD_DIRECT'
> 
> Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
> ---
>  drivers/leds/leds-lp5521.c |   21 ++++++++++-----------
>  1 files changed, 10 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c
> index 471cef1..8368ce4 100644
> --- a/drivers/leds/leds-lp5521.c
> +++ b/drivers/leds/leds-lp5521.c
> @@ -81,6 +81,10 @@
>  #define LP5521_MASTER_ENABLE		0x40	/* Chip master enable */
>  #define LP5521_LOGARITHMIC_PWM		0x80	/* Logarithmic PWM
> adjustment */
>  #define LP5521_EXEC_RUN			0x2A
> +#define LP5521_ENABLE_DEFAULT	\
> +	(LP5521_MASTER_ENABLE | LP5521_LOGARITHMIC_PWM)
> +#define LP5521_ENABLE_RUN_PROGRAM	\
> +	(LP5521_ENABLE_DEFAULT | LP5521_EXEC_RUN)
> 
>  /* Status */
>  #define LP5521_EXT_CLK_USED		0x08
> @@ -234,7 +238,7 @@ static int lp5521_configure(struct i2c_client
> *client)
>  	lp5521_init_engine(chip);
> 
>  	/* Set all PWMs to direct control mode */
> -	ret = lp5521_write(client, LP5521_REG_OP_MODE, 0x3F);
> +	ret = lp5521_write(client, LP5521_REG_OP_MODE, LP5521_CMD_DIRECT);
> 
>  	cfg = chip->pdata->update_config ?
>  		: (LP5521_PWRSAVE_EN | LP5521_CP_MODE_AUTO |
> LP5521_R_TO_BATT);
> @@ -247,8 +251,7 @@ static int lp5521_configure(struct i2c_client
> *client)
> 
>  	/* Set engines are set to run state when OP_MODE enables engines
> */
>  	ret |= lp5521_write(client, LP5521_REG_ENABLE,
> -			LP5521_MASTER_ENABLE | LP5521_LOGARITHMIC_PWM |
> -			LP5521_EXEC_RUN);
> +			LP5521_ENABLE_RUN_PROGRAM);
>  	/* enable takes 500us. 1 - 2 ms leaves some margin */
>  	usleep_range(1000, 2000);
> 
> @@ -299,8 +302,7 @@ static int lp5521_detect(struct i2c_client *client)
>  	int ret;
>  	u8 buf;
> 
> -	ret = lp5521_write(client, LP5521_REG_ENABLE,
> -			LP5521_MASTER_ENABLE | LP5521_LOGARITHMIC_PWM);
> +	ret = lp5521_write(client, LP5521_REG_ENABLE,
> LP5521_ENABLE_DEFAULT);
>  	if (ret)
>  		return ret;
>  	/* enable takes 500us. 1 - 2 ms leaves some margin */
> @@ -308,7 +310,7 @@ static int lp5521_detect(struct i2c_client *client)
>  	ret = lp5521_read(client, LP5521_REG_ENABLE, &buf);
>  	if (ret)
>  		return ret;
> -	if (buf != (LP5521_MASTER_ENABLE | LP5521_LOGARITHMIC_PWM))
> +	if (buf != LP5521_ENABLE_DEFAULT)
>  		return -ENODEV;
> 
>  	return 0;
> @@ -573,8 +575,7 @@ static void lp5521_run_led_pattern(int mode, struct
> lp5521_chip *chip)
>  		return;
> 
>  	if (mode == PATTERN_OFF) {
> -		lp5521_write(cl, LP5521_REG_ENABLE,
> -			LP5521_MASTER_ENABLE | LP5521_LOGARITHMIC_PWM);
> +		lp5521_write(cl, LP5521_REG_ENABLE, LP5521_ENABLE_DEFAULT);
>  		usleep_range(1000, 2000);
>  		lp5521_write(cl, LP5521_REG_OP_MODE, LP5521_CMD_DIRECT);
>  	} else {
> @@ -596,9 +597,7 @@ static void lp5521_run_led_pattern(int mode, struct
> lp5521_chip *chip)
> 
>  		lp5521_write(cl, LP5521_REG_OP_MODE, LP5521_CMD_RUN);
>  		usleep_range(1000, 2000);
> -		lp5521_write(cl, LP5521_REG_ENABLE,
> -			LP5521_MASTER_ENABLE | LP5521_LOGARITHMIC_PWM |
> -			LP5521_EXEC_RUN);
> +		lp5521_write(cl, LP5521_REG_ENABLE,
> LP5521_ENABLE_RUN_PROGRAM);
>  	}
>  }
> 
> --
> 1.7.4.1
> 
> 
> Best Regards,
> Milo (Woogyom) Kim
> Texas Instruments Incorporated



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

* Re: [PATCH 4/4] leds-lp5521: redefinition of register bits
  2012-01-21 18:09 ` Kim, Milo
@ 2012-01-27 14:08   ` Linus Walleij
  0 siblings, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2012-01-27 14:08 UTC (permalink / raw)
  To: Kim, Milo; +Cc: linux-kernel, rpurdie

On Sat, Jan 21, 2012 at 7:09 PM, Kim, Milo <Milo.Kim@ti.com> wrote:

> For better readability, values of LP5521_REG_ENABLE register were redefined.
> Additional definitions: LP5521_ENABLE_DEFAULT and LP5521_ENABLE_RUN_PROGRAM.
>
> Use definition rather than hard code value.
> : 0x3F -> 'LP5521_CMD_DIRECT'
>
> Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>

Looks like a good idea.

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* [PATCH 4/4] leds-lp5521: redefinition of register bits
@ 2012-01-21 18:09 ` Kim, Milo
  2012-01-27 14:08   ` Linus Walleij
  0 siblings, 1 reply; 3+ messages in thread
From: Kim, Milo @ 2012-01-21 18:09 UTC (permalink / raw)
  To: linux-kernel, rpurdie

For better readability, values of LP5521_REG_ENABLE register were redefined.
Additional definitions: LP5521_ENABLE_DEFAULT and LP5521_ENABLE_RUN_PROGRAM.

Use definition rather than hard code value.
: 0x3F -> 'LP5521_CMD_DIRECT'

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
---
 drivers/leds/leds-lp5521.c |   21 ++++++++++-----------
 1 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c
index 471cef1..8368ce4 100644
--- a/drivers/leds/leds-lp5521.c
+++ b/drivers/leds/leds-lp5521.c
@@ -81,6 +81,10 @@
 #define LP5521_MASTER_ENABLE		0x40	/* Chip master enable */
 #define LP5521_LOGARITHMIC_PWM		0x80	/* Logarithmic PWM adjustment */
 #define LP5521_EXEC_RUN			0x2A
+#define LP5521_ENABLE_DEFAULT	\
+	(LP5521_MASTER_ENABLE | LP5521_LOGARITHMIC_PWM)
+#define LP5521_ENABLE_RUN_PROGRAM	\
+	(LP5521_ENABLE_DEFAULT | LP5521_EXEC_RUN)
 
 /* Status */
 #define LP5521_EXT_CLK_USED		0x08
@@ -234,7 +238,7 @@ static int lp5521_configure(struct i2c_client *client)
 	lp5521_init_engine(chip);
 
 	/* Set all PWMs to direct control mode */
-	ret = lp5521_write(client, LP5521_REG_OP_MODE, 0x3F);
+	ret = lp5521_write(client, LP5521_REG_OP_MODE, LP5521_CMD_DIRECT);
 
 	cfg = chip->pdata->update_config ?
 		: (LP5521_PWRSAVE_EN | LP5521_CP_MODE_AUTO | LP5521_R_TO_BATT);
@@ -247,8 +251,7 @@ static int lp5521_configure(struct i2c_client *client)
 
 	/* Set engines are set to run state when OP_MODE enables engines */
 	ret |= lp5521_write(client, LP5521_REG_ENABLE,
-			LP5521_MASTER_ENABLE | LP5521_LOGARITHMIC_PWM |
-			LP5521_EXEC_RUN);
+			LP5521_ENABLE_RUN_PROGRAM);
 	/* enable takes 500us. 1 - 2 ms leaves some margin */
 	usleep_range(1000, 2000);
 
@@ -299,8 +302,7 @@ static int lp5521_detect(struct i2c_client *client)
 	int ret;
 	u8 buf;
 
-	ret = lp5521_write(client, LP5521_REG_ENABLE,
-			LP5521_MASTER_ENABLE | LP5521_LOGARITHMIC_PWM);
+	ret = lp5521_write(client, LP5521_REG_ENABLE, LP5521_ENABLE_DEFAULT);
 	if (ret)
 		return ret;
 	/* enable takes 500us. 1 - 2 ms leaves some margin */
@@ -308,7 +310,7 @@ static int lp5521_detect(struct i2c_client *client)
 	ret = lp5521_read(client, LP5521_REG_ENABLE, &buf);
 	if (ret)
 		return ret;
-	if (buf != (LP5521_MASTER_ENABLE | LP5521_LOGARITHMIC_PWM))
+	if (buf != LP5521_ENABLE_DEFAULT)
 		return -ENODEV;
 
 	return 0;
@@ -573,8 +575,7 @@ static void lp5521_run_led_pattern(int mode, struct lp5521_chip *chip)
 		return;
 
 	if (mode == PATTERN_OFF) {
-		lp5521_write(cl, LP5521_REG_ENABLE,
-			LP5521_MASTER_ENABLE | LP5521_LOGARITHMIC_PWM);
+		lp5521_write(cl, LP5521_REG_ENABLE, LP5521_ENABLE_DEFAULT);
 		usleep_range(1000, 2000);
 		lp5521_write(cl, LP5521_REG_OP_MODE, LP5521_CMD_DIRECT);
 	} else {
@@ -596,9 +597,7 @@ static void lp5521_run_led_pattern(int mode, struct lp5521_chip *chip)
 
 		lp5521_write(cl, LP5521_REG_OP_MODE, LP5521_CMD_RUN);
 		usleep_range(1000, 2000);
-		lp5521_write(cl, LP5521_REG_ENABLE,
-			LP5521_MASTER_ENABLE | LP5521_LOGARITHMIC_PWM |
-			LP5521_EXEC_RUN);
+		lp5521_write(cl, LP5521_REG_ENABLE, LP5521_ENABLE_RUN_PROGRAM);
 	}
 }
 
-- 
1.7.4.1


Best Regards,
Milo (Woogyom) Kim
Texas Instruments Incorporated



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

end of thread, other threads:[~2012-01-27 14:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-27  2:23 [PATCH 4/4] leds-lp5521: redefinition of register bits Kim, Milo
     [not found] <AczYZ9hWemTkved3RqKuOuMCSoz1+Q==>
2012-01-21 18:09 ` Kim, Milo
2012-01-27 14:08   ` Linus Walleij

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