From: Axel Lin Date: Tue, 1 Nov 2011 00:12:12 +0000 (-0700) Subject: drivers/leds/leds-lp5521.c: avoid writing uninitialized value to LP5521_REG_OP_MODE... X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=fa0ea0e16f748e36d65931227188ccf07f2b77c7;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git 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 Cc: Samu Onkalo Cc: Richard Purdie Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- 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) mode = LP5521_CMD_DIRECT; ret = lp5521_read(client, LP5521_REG_OP_MODE, &engine_state); + if (ret < 0) + return ret; /* set mode only for this engine */ engine_state &= ~(engine->engine_mask); mode &= engine->engine_mask; engine_state |= mode; - ret |= lp5521_write(client, LP5521_REG_OP_MODE, engine_state); - - return ret; + return lp5521_write(client, LP5521_REG_OP_MODE, engine_state); } static int lp5521_load_program(struct lp5521_engine *eng, const u8 *pattern)