diff options
author | Kim, Milo <Milo.Kim@ti.com> | 2012-08-21 05:04:02 -0400 |
---|---|---|
committer | Bryan Wu <bryan.wu@canonical.com> | 2012-09-11 06:32:41 -0400 |
commit | 469eba023087d8fa3974827e6bedf874a620d0e7 (patch) | |
tree | bf9ba0ac2ef5acb2e8be0d3f8dbc5b2245ce6d7d | |
parent | 6f6365fbac2d6bcf6867c633d3ec33af08b5b219 (diff) |
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>
-rw-r--r-- | drivers/leds/leds-lp5523.c | 15 |
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) | |||
177 | int ret; | 177 | int ret; |
178 | u8 buf; | 178 | u8 buf; |
179 | 179 | ||
180 | ret = lp5523_write(client, LP5523_REG_ENABLE, 0x40); | 180 | ret = lp5523_write(client, LP5523_REG_ENABLE, LP5523_ENABLE); |
181 | if (ret) | 181 | if (ret) |
182 | return ret; | 182 | return ret; |
183 | ret = lp5523_read(client, LP5523_REG_ENABLE, &buf); | 183 | 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) | |||
338 | { | 338 | { |
339 | int i; | 339 | int i; |
340 | u16 tmp_mux = 0; | 340 | u16 tmp_mux = 0; |
341 | len = len < LP5523_LEDS ? len : LP5523_LEDS; | 341 | |
342 | len = min_t(int, len, LP5523_LEDS); | ||
342 | for (i = 0; i < len; i++) { | 343 | for (i = 0; i < len; i++) { |
343 | switch (buf[i]) { | 344 | switch (buf[i]) { |
344 | case '1': | 345 | case '1': |
@@ -546,6 +547,9 @@ static int lp5523_do_store_load(struct lp5523_engine *engine, | |||
546 | unsigned cmd; | 547 | unsigned cmd; |
547 | u8 pattern[LP5523_PROGRAM_LENGTH] = {0}; | 548 | u8 pattern[LP5523_PROGRAM_LENGTH] = {0}; |
548 | 549 | ||
550 | if (engine->mode != LP5523_CMD_LOAD) | ||
551 | return -EINVAL; | ||
552 | |||
549 | while ((offset < len - 1) && (i < LP5523_PROGRAM_LENGTH)) { | 553 | while ((offset < len - 1) && (i < LP5523_PROGRAM_LENGTH)) { |
550 | /* separate sscanfs because length is working only for %s */ | 554 | /* separate sscanfs because length is working only for %s */ |
551 | ret = sscanf(buf + offset, "%2s%n ", c, &nrchars); | 555 | ret = sscanf(buf + offset, "%2s%n ", c, &nrchars); |
@@ -563,12 +567,7 @@ static int lp5523_do_store_load(struct lp5523_engine *engine, | |||
563 | goto fail; | 567 | goto fail; |
564 | 568 | ||
565 | mutex_lock(&chip->lock); | 569 | mutex_lock(&chip->lock); |
566 | 570 | ret = lp5523_load_program(engine, pattern); | |
567 | if (engine->mode == LP5523_CMD_LOAD) | ||
568 | ret = lp5523_load_program(engine, pattern); | ||
569 | else | ||
570 | ret = -EINVAL; | ||
571 | |||
572 | mutex_unlock(&chip->lock); | 571 | mutex_unlock(&chip->lock); |
573 | 572 | ||
574 | if (ret) { | 573 | if (ret) { |