aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2012-05-29 18:07:26 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-05-29 19:22:31 -0400
commit5bc9ad774c063f6b41965e7314f2c26aa5e465a0 (patch)
tree838363a1ead69a031fce1eccdc9f732f34275b92 /drivers/leds
parentc8515294a31ec63536eb1a2ba7a38797435dda4f (diff)
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: Dan 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: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/leds')
-rw-r--r--drivers/leds/leds-lp5521.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c
index 410a723b8691..23815624f35e 100644
--- a/drivers/leds/leds-lp5521.c
+++ b/drivers/leds/leds-lp5521.c
@@ -193,9 +193,14 @@ static int lp5521_load_program(struct lp5521_engine *eng, const u8 *pattern)
193 193
194 /* move current engine to direct mode and remember the state */ 194 /* move current engine to direct mode and remember the state */
195 ret = lp5521_set_engine_mode(eng, LP5521_CMD_DIRECT); 195 ret = lp5521_set_engine_mode(eng, LP5521_CMD_DIRECT);
196 if (ret)
197 return ret;
198
196 /* Mode change requires min 500 us delay. 1 - 2 ms with margin */ 199 /* Mode change requires min 500 us delay. 1 - 2 ms with margin */
197 usleep_range(1000, 2000); 200 usleep_range(1000, 2000);
198 ret |= lp5521_read(client, LP5521_REG_OP_MODE, &mode); 201 ret = lp5521_read(client, LP5521_REG_OP_MODE, &mode);
202 if (ret)
203 return ret;
199 204
200 /* For loading, all the engines to load mode */ 205 /* For loading, all the engines to load mode */
201 lp5521_write(client, LP5521_REG_OP_MODE, LP5521_CMD_DIRECT); 206 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 LP5521_PROG_MEM_SIZE, 216 LP5521_PROG_MEM_SIZE,
212 pattern); 217 pattern);
213 218
214 ret |= lp5521_write(client, LP5521_REG_OP_MODE, mode); 219 return lp5521_write(client, LP5521_REG_OP_MODE, mode);
215 return ret;
216} 220}
217 221
218static int lp5521_set_led_current(struct lp5521_chip *chip, int led, u8 curr) 222static 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 * LP5521_REG_ENABLE register will not have any effect - strange! 789 * LP5521_REG_ENABLE register will not have any effect - strange!
786 */ 790 */
787 ret = lp5521_read(client, LP5521_REG_R_CURRENT, &buf); 791 ret = lp5521_read(client, LP5521_REG_R_CURRENT, &buf);
788 if (buf != LP5521_REG_R_CURR_DEFAULT) { 792 if (ret || buf != LP5521_REG_R_CURR_DEFAULT) {
789 dev_err(&client->dev, "error in resetting chip\n"); 793 dev_err(&client->dev, "error in resetting chip\n");
790 goto fail2; 794 goto fail2;
791 } 795 }