aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds/leds-lp5523.c
diff options
context:
space:
mode:
authorMilo Kim <milo.kim@ti.com>2013-08-08 01:09:24 -0400
committerBryan Wu <cooloney@gmail.com>2013-08-26 20:22:13 -0400
commit2f733cad3699c6fd1cc3350ab43c9f684b976e73 (patch)
tree6a0302f9062e1c079a44d15be5576c8981f0a9b6 /drivers/leds/leds-lp5523.c
parent45e611bfbe18d854498c65d60703841e4a4c3c3a (diff)
leds: lp5523: 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-lp5523.c')
-rw-r--r--drivers/leds/leds-lp5523.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c
index 9b8be6f6c595..fe3bcbb5747f 100644
--- a/drivers/leds/leds-lp5523.c
+++ b/drivers/leds/leds-lp5523.c
@@ -312,17 +312,11 @@ static int lp5523_update_program_memory(struct lp55xx_chip *chip,
312 u8 pattern[LP5523_PROGRAM_LENGTH] = {0}; 312 u8 pattern[LP5523_PROGRAM_LENGTH] = {0};
313 unsigned cmd; 313 unsigned cmd;
314 char c[3]; 314 char c[3];
315 int update_size;
316 int nrchars; 315 int nrchars;
317 int offset = 0;
318 int ret; 316 int ret;
319 int i; 317 int offset = 0;
320 318 int i = 0;
321 /* clear program memory before updating */
322 for (i = 0; i < LP5523_PROGRAM_LENGTH; i++)
323 lp55xx_write(chip, LP5523_REG_PROG_MEM + i, 0);
324 319
325 i = 0;
326 while ((offset < size - 1) && (i < LP5523_PROGRAM_LENGTH)) { 320 while ((offset < size - 1) && (i < LP5523_PROGRAM_LENGTH)) {
327 /* separate sscanfs because length is working only for %s */ 321 /* separate sscanfs because length is working only for %s */
328 ret = sscanf(data + offset, "%2s%n ", c, &nrchars); 322 ret = sscanf(data + offset, "%2s%n ", c, &nrchars);
@@ -342,11 +336,9 @@ static int lp5523_update_program_memory(struct lp55xx_chip *chip,
342 if (i % 2) 336 if (i % 2)
343 goto err; 337 goto err;
344 338
345 update_size = i;
346
347 mutex_lock(&chip->lock); 339 mutex_lock(&chip->lock);
348 340
349 for (i = 0; i < update_size; i++) { 341 for (i = 0; i < LP5523_PROGRAM_LENGTH; i++) {
350 ret = lp55xx_write(chip, LP5523_REG_PROG_MEM + i, pattern[i]); 342 ret = lp55xx_write(chip, LP5523_REG_PROG_MEM + i, pattern[i]);
351 if (ret) { 343 if (ret) {
352 mutex_unlock(&chip->lock); 344 mutex_unlock(&chip->lock);