提交 32a2f747 编写于 作者: K Kim, Milo 提交者: Linus Torvalds

drivers/leds/leds-lp5521.c: 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: NMilo(Woogyom) Kim <milo.kim@ti.com>
Acked-by: NLinus Walleij <linus.walleij@linaro.org>
Cc: Arun MURTHY <arun.murthy@stericsson.com>
Cc: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 011af7bc
...@@ -81,6 +81,10 @@ ...@@ -81,6 +81,10 @@
#define LP5521_MASTER_ENABLE 0x40 /* Chip master enable */ #define LP5521_MASTER_ENABLE 0x40 /* Chip master enable */
#define LP5521_LOGARITHMIC_PWM 0x80 /* Logarithmic PWM adjustment */ #define LP5521_LOGARITHMIC_PWM 0x80 /* Logarithmic PWM adjustment */
#define LP5521_EXEC_RUN 0x2A #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 */ /* Status */
#define LP5521_EXT_CLK_USED 0x08 #define LP5521_EXT_CLK_USED 0x08
...@@ -237,7 +241,7 @@ static int lp5521_configure(struct i2c_client *client) ...@@ -237,7 +241,7 @@ static int lp5521_configure(struct i2c_client *client)
lp5521_init_engine(chip); lp5521_init_engine(chip);
/* Set all PWMs to direct control mode */ /* 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 ? cfg = chip->pdata->update_config ?
: (LP5521_PWRSAVE_EN | LP5521_CP_MODE_AUTO | LP5521_R_TO_BATT); : (LP5521_PWRSAVE_EN | LP5521_CP_MODE_AUTO | LP5521_R_TO_BATT);
...@@ -250,8 +254,7 @@ static int lp5521_configure(struct i2c_client *client) ...@@ -250,8 +254,7 @@ static int lp5521_configure(struct i2c_client *client)
/* Set engines are set to run state when OP_MODE enables engines */ /* Set engines are set to run state when OP_MODE enables engines */
ret |= lp5521_write(client, LP5521_REG_ENABLE, ret |= lp5521_write(client, LP5521_REG_ENABLE,
LP5521_MASTER_ENABLE | LP5521_LOGARITHMIC_PWM | LP5521_ENABLE_RUN_PROGRAM);
LP5521_EXEC_RUN);
/* enable takes 500us. 1 - 2 ms leaves some margin */ /* enable takes 500us. 1 - 2 ms leaves some margin */
usleep_range(1000, 2000); usleep_range(1000, 2000);
...@@ -302,8 +305,7 @@ static int lp5521_detect(struct i2c_client *client) ...@@ -302,8 +305,7 @@ static int lp5521_detect(struct i2c_client *client)
int ret; int ret;
u8 buf; u8 buf;
ret = lp5521_write(client, LP5521_REG_ENABLE, ret = lp5521_write(client, LP5521_REG_ENABLE, LP5521_ENABLE_DEFAULT);
LP5521_MASTER_ENABLE | LP5521_LOGARITHMIC_PWM);
if (ret) if (ret)
return ret; return ret;
/* enable takes 500us. 1 - 2 ms leaves some margin */ /* enable takes 500us. 1 - 2 ms leaves some margin */
...@@ -311,7 +313,7 @@ static int lp5521_detect(struct i2c_client *client) ...@@ -311,7 +313,7 @@ static int lp5521_detect(struct i2c_client *client)
ret = lp5521_read(client, LP5521_REG_ENABLE, &buf); ret = lp5521_read(client, LP5521_REG_ENABLE, &buf);
if (ret) if (ret)
return ret; return ret;
if (buf != (LP5521_MASTER_ENABLE | LP5521_LOGARITHMIC_PWM)) if (buf != LP5521_ENABLE_DEFAULT)
return -ENODEV; return -ENODEV;
return 0; return 0;
...@@ -576,8 +578,7 @@ static void lp5521_run_led_pattern(int mode, struct lp5521_chip *chip) ...@@ -576,8 +578,7 @@ static void lp5521_run_led_pattern(int mode, struct lp5521_chip *chip)
return; return;
if (mode == PATTERN_OFF) { if (mode == PATTERN_OFF) {
lp5521_write(cl, LP5521_REG_ENABLE, lp5521_write(cl, LP5521_REG_ENABLE, LP5521_ENABLE_DEFAULT);
LP5521_MASTER_ENABLE | LP5521_LOGARITHMIC_PWM);
usleep_range(1000, 2000); usleep_range(1000, 2000);
lp5521_write(cl, LP5521_REG_OP_MODE, LP5521_CMD_DIRECT); lp5521_write(cl, LP5521_REG_OP_MODE, LP5521_CMD_DIRECT);
} else { } else {
...@@ -599,9 +600,7 @@ static void lp5521_run_led_pattern(int mode, struct lp5521_chip *chip) ...@@ -599,9 +600,7 @@ static void lp5521_run_led_pattern(int mode, struct lp5521_chip *chip)
lp5521_write(cl, LP5521_REG_OP_MODE, LP5521_CMD_RUN); lp5521_write(cl, LP5521_REG_OP_MODE, LP5521_CMD_RUN);
usleep_range(1000, 2000); usleep_range(1000, 2000);
lp5521_write(cl, LP5521_REG_ENABLE, lp5521_write(cl, LP5521_REG_ENABLE, LP5521_ENABLE_RUN_PROGRAM);
LP5521_MASTER_ENABLE | LP5521_LOGARITHMIC_PWM |
LP5521_EXEC_RUN);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册