aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds/leds-lp5523.c
diff options
context:
space:
mode:
authorKim, Milo <Milo.Kim@ti.com>2012-08-21 17:04:02 +0800
committerBryan Wu <bryan.wu@canonical.com>2012-09-11 18:32:41 +0800
commit469eba023087d8fa3974827e6bedf874a620d0e7 (patch)
treebf9ba0ac2ef5acb2e8be0d3f8dbc5b2245ce6d7d /drivers/leds/leds-lp5523.c
parentleds-lp5523: change the return type of lp5523_set_mode() (diff)
downloadlinux-dev-469eba023087d8fa3974827e6bedf874a620d0e7.tar.xz
linux-dev-469eba023087d8fa3974827e6bedf874a620d0e7.zip
leds-lp5523: minor code style fixes
(a) use LP5523_ENABLE rather than magic number 0x40 (b) use min_t() in lp5523_mux_parse() (c) skip while loop and just return if invalid command Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com> Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
Diffstat (limited to 'drivers/leds/leds-lp5523.c')
-rw-r--r--drivers/leds/leds-lp5523.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c
index a14495402cc5..80d37929044f 100644
--- a/drivers/leds/leds-lp5523.c
+++ b/drivers/leds/leds-lp5523.c
@@ -177,7 +177,7 @@ static int lp5523_detect(struct i2c_client *client)
int ret;
u8 buf;
- ret = lp5523_write(client, LP5523_REG_ENABLE, 0x40);
+ ret = lp5523_write(client, LP5523_REG_ENABLE, LP5523_ENABLE);
if (ret)
return ret;
ret = lp5523_read(client, LP5523_REG_ENABLE, &buf);
@@ -338,7 +338,8 @@ static int lp5523_mux_parse(const char *buf, u16 *mux, size_t len)
{
int i;
u16 tmp_mux = 0;
- len = len < LP5523_LEDS ? len : LP5523_LEDS;
+
+ len = min_t(int, len, LP5523_LEDS);
for (i = 0; i < len; i++) {
switch (buf[i]) {
case '1':
@@ -546,6 +547,9 @@ static int lp5523_do_store_load(struct lp5523_engine *engine,
unsigned cmd;
u8 pattern[LP5523_PROGRAM_LENGTH] = {0};
+ if (engine->mode != LP5523_CMD_LOAD)
+ return -EINVAL;
+
while ((offset < len - 1) && (i < LP5523_PROGRAM_LENGTH)) {
/* separate sscanfs because length is working only for %s */
ret = sscanf(buf + offset, "%2s%n ", c, &nrchars);
@@ -563,12 +567,7 @@ static int lp5523_do_store_load(struct lp5523_engine *engine,
goto fail;
mutex_lock(&chip->lock);
-
- if (engine->mode == LP5523_CMD_LOAD)
- ret = lp5523_load_program(engine, pattern);
- else
- ret = -EINVAL;
-
+ ret = lp5523_load_program(engine, pattern);
mutex_unlock(&chip->lock);
if (ret) {