summaryrefslogtreecommitdiff
path: root/drivers/leds/leds-lp5521.c
diff options
context:
space:
mode:
authorMilo Kim <milo.kim@ti.com>2013-08-08 13:45:45 +0900
committerBryan Wu <cooloney@gmail.com>2013-08-26 17:22:12 -0700
commit1eca0b3ab8d04e2b1749b28cbcafbba6f6e74225 (patch)
tree9b5bbac0f71bb731e5014f30159d8b98ec6a2968 /drivers/leds/leds-lp5521.c
parentc0e5e9b542d134eb43ea4ebc83446e6f2f63089a (diff)
leds: lp5521: remove unnecessary writing commands
This patch reduces the number of programming commands. (Count of sending commands) Old code: 32 + program size (32 counts for clearing program memory) New code: 32 Pattern buffer is initialized to 0 in this function. Just update new program data and remaining buffers are filled with 0. So it's needless to clear whole area. Signed-off-by: Milo Kim <milo.kim@ti.com> Signed-off-by: Bryan Wu <cooloney@gmail.com>
Diffstat (limited to 'drivers/leds/leds-lp5521.c')
-rw-r--r--drivers/leds/leds-lp5521.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c
index c00f922163b3..05188351711d 100644
--- a/drivers/leds/leds-lp5521.c
+++ b/drivers/leds/leds-lp5521.c
@@ -220,17 +220,11 @@ static int lp5521_update_program_memory(struct lp55xx_chip *chip,
};
unsigned cmd;
char c[3];
- int program_size;
int nrchars;
- int offset = 0;
int ret;
- int i;
-
- /* clear program memory before updating */
- for (i = 0; i < LP5521_PROGRAM_LENGTH; i++)
- lp55xx_write(chip, addr[idx] + i, 0);
+ int offset = 0;
+ int i = 0;
- i = 0;
while ((offset < size - 1) && (i < LP5521_PROGRAM_LENGTH)) {
/* separate sscanfs because length is working only for %s */
ret = sscanf(data + offset, "%2s%n ", c, &nrchars);
@@ -250,11 +244,9 @@ static int lp5521_update_program_memory(struct lp55xx_chip *chip,
if (i % 2)
goto err;
- program_size = i;
-
mutex_lock(&chip->lock);
- for (i = 0; i < program_size; i++) {
+ for (i = 0; i < LP5521_PROGRAM_LENGTH; i++) {
ret = lp55xx_write(chip, addr[idx] + i, pattern[i]);
if (ret) {
mutex_unlock(&chip->lock);