aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2011-10-31 20:12:12 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-10-31 20:30:55 -0400
commitfa0ea0e16f748e36d65931227188ccf07f2b77c7 (patch)
treeaa6f67424045340e8a71f4700905e40eaebbf780
parent2b67c95b74f17c13c7b3a990540c9dd9b4a8480d (diff)
drivers/leds/leds-lp5521.c: avoid writing uninitialized value to LP5521_REG_OP_MODE register
If lp5521_read fails, engine_state variable is not initialized. If lp5521_read fails, we should return error. This patch fixes below warning. CC drivers/leds/leds-lp5521.o drivers/leds/leds-lp5521.c: In function 'lp5521_set_engine_mode': drivers/leds/leds-lp5521.c:168: warning: 'engine_state' may be used uninitialized in this function [akpm@linux-foundation.org: remove unneeded "ret |="] Signed-off-by: Axel Lin <axel.lin@gmail.com> Cc: Samu Onkalo <samu.p.onkalo@nokia.com> Cc: Richard Purdie <rpurdie@rpsys.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/leds/leds-lp5521.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c
index 9fc122c81f06..16f281b8c2d0 100644
--- a/drivers/leds/leds-lp5521.c
+++ b/drivers/leds/leds-lp5521.c
@@ -175,14 +175,14 @@ static int lp5521_set_engine_mode(struct lp5521_engine *engine, u8 mode)
175 mode = LP5521_CMD_DIRECT; 175 mode = LP5521_CMD_DIRECT;
176 176
177 ret = lp5521_read(client, LP5521_REG_OP_MODE, &engine_state); 177 ret = lp5521_read(client, LP5521_REG_OP_MODE, &engine_state);
178 if (ret < 0)
179 return ret;
178 180
179 /* set mode only for this engine */ 181 /* set mode only for this engine */
180 engine_state &= ~(engine->engine_mask); 182 engine_state &= ~(engine->engine_mask);
181 mode &= engine->engine_mask; 183 mode &= engine->engine_mask;
182 engine_state |= mode; 184 engine_state |= mode;
183 ret |= lp5521_write(client, LP5521_REG_OP_MODE, engine_state); 185 return lp5521_write(client, LP5521_REG_OP_MODE, engine_state);
184
185 return ret;
186} 186}
187 187
188static int lp5521_load_program(struct lp5521_engine *eng, const u8 *pattern) 188static int lp5521_load_program(struct lp5521_engine *eng, const u8 *pattern)