提交 5bc9ad77 编写于 作者: D Dan Carpenter 提交者: Linus Torvalds

drivers/leds/leds-lp5521.c: fix lp5521_read() error handling

Gcc 4.6.2 complains that:

  drivers/leds/leds-lp5521.c: In function `lp5521_load_program':
  drivers/leds/leds-lp5521.c:214:21: warning: `mode' may be used uninitialized in this function [-Wuninitialized]
  drivers/leds/leds-lp5521.c: In function `lp5521_probe':
  drivers/leds/leds-lp5521.c:788:5: warning: `buf' may be used uninitialized in this function [-Wuninitialized]
  drivers/leds/leds-lp5521.c:740:6: warning: `ret' may be used uninitialized in this function [-Wuninitialized]

These are real problems if lp5521_read() returns an error.  When that
happens we should handle it, instead of ignoring it or doing a bitwise
OR with all the other error codes and continuing.
Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
Cc: Milo <Milo.Kim@ti.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Cc: Bryan Wu <bryan.wu@canonical.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 c8515294
...@@ -193,9 +193,14 @@ static int lp5521_load_program(struct lp5521_engine *eng, const u8 *pattern) ...@@ -193,9 +193,14 @@ static int lp5521_load_program(struct lp5521_engine *eng, const u8 *pattern)
/* move current engine to direct mode and remember the state */ /* move current engine to direct mode and remember the state */
ret = lp5521_set_engine_mode(eng, LP5521_CMD_DIRECT); ret = lp5521_set_engine_mode(eng, LP5521_CMD_DIRECT);
if (ret)
return ret;
/* Mode change requires min 500 us delay. 1 - 2 ms with margin */ /* Mode change requires min 500 us delay. 1 - 2 ms with margin */
usleep_range(1000, 2000); usleep_range(1000, 2000);
ret |= lp5521_read(client, LP5521_REG_OP_MODE, &mode); ret = lp5521_read(client, LP5521_REG_OP_MODE, &mode);
if (ret)
return ret;
/* For loading, all the engines to load mode */ /* For loading, all the engines to load mode */
lp5521_write(client, LP5521_REG_OP_MODE, LP5521_CMD_DIRECT); lp5521_write(client, LP5521_REG_OP_MODE, LP5521_CMD_DIRECT);
...@@ -211,8 +216,7 @@ static int lp5521_load_program(struct lp5521_engine *eng, const u8 *pattern) ...@@ -211,8 +216,7 @@ static int lp5521_load_program(struct lp5521_engine *eng, const u8 *pattern)
LP5521_PROG_MEM_SIZE, LP5521_PROG_MEM_SIZE,
pattern); pattern);
ret |= lp5521_write(client, LP5521_REG_OP_MODE, mode); return lp5521_write(client, LP5521_REG_OP_MODE, mode);
return ret;
} }
static int lp5521_set_led_current(struct lp5521_chip *chip, int led, u8 curr) static int lp5521_set_led_current(struct lp5521_chip *chip, int led, u8 curr)
...@@ -785,7 +789,7 @@ static int __devinit lp5521_probe(struct i2c_client *client, ...@@ -785,7 +789,7 @@ static int __devinit lp5521_probe(struct i2c_client *client,
* LP5521_REG_ENABLE register will not have any effect - strange! * LP5521_REG_ENABLE register will not have any effect - strange!
*/ */
ret = lp5521_read(client, LP5521_REG_R_CURRENT, &buf); ret = lp5521_read(client, LP5521_REG_R_CURRENT, &buf);
if (buf != LP5521_REG_R_CURR_DEFAULT) { if (ret || buf != LP5521_REG_R_CURR_DEFAULT) {
dev_err(&client->dev, "error in resetting chip\n"); dev_err(&client->dev, "error in resetting chip\n");
goto fail2; goto fail2;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册