aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds/leds-lp5523.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/leds/leds-lp5523.c')
-rw-r--r--drivers/leds/leds-lp5523.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c
index 7e304b7ff779..7f5be8948cde 100644
--- a/drivers/leds/leds-lp5523.c
+++ b/drivers/leds/leds-lp5523.c
@@ -171,7 +171,7 @@ static int lp5523_read(struct i2c_client *client, u8 reg, u8 *buf)
171 s32 ret = i2c_smbus_read_byte_data(client, reg); 171 s32 ret = i2c_smbus_read_byte_data(client, reg);
172 172
173 if (ret < 0) 173 if (ret < 0)
174 return -EIO; 174 return ret;
175 175
176 *buf = ret; 176 *buf = ret;
177 return 0; 177 return 0;
@@ -248,7 +248,10 @@ static int lp5523_configure(struct i2c_client *client)
248 248
249 /* Let the programs run for couple of ms and check the engine status */ 249 /* Let the programs run for couple of ms and check the engine status */
250 usleep_range(3000, 6000); 250 usleep_range(3000, 6000);
251 lp5523_read(client, LP5523_REG_STATUS, &status); 251 ret = lp5523_read(client, LP5523_REG_STATUS, &status);
252 if (ret < 0)
253 return ret;
254
252 status &= LP5523_ENG_STATUS_MASK; 255 status &= LP5523_ENG_STATUS_MASK;
253 256
254 if (status == LP5523_ENG_STATUS_MASK) { 257 if (status == LP5523_ENG_STATUS_MASK) {
@@ -464,10 +467,16 @@ static ssize_t lp5523_selftest(struct device *dev,
464 LP5523_EN_LEDTEST | 16); 467 LP5523_EN_LEDTEST | 16);
465 usleep_range(3000, 6000); /* ADC conversion time is typically 2.7 ms */ 468 usleep_range(3000, 6000); /* ADC conversion time is typically 2.7 ms */
466 ret = lp5523_read(chip->client, LP5523_REG_STATUS, &status); 469 ret = lp5523_read(chip->client, LP5523_REG_STATUS, &status);
470 if (ret < 0)
471 goto fail;
472
467 if (!(status & LP5523_LEDTEST_DONE)) 473 if (!(status & LP5523_LEDTEST_DONE))
468 usleep_range(3000, 6000); /* Was not ready. Wait little bit */ 474 usleep_range(3000, 6000); /* Was not ready. Wait little bit */
469 475
470 ret |= lp5523_read(chip->client, LP5523_REG_LED_TEST_ADC, &vdd); 476 ret = lp5523_read(chip->client, LP5523_REG_LED_TEST_ADC, &vdd);
477 if (ret < 0)
478 goto fail;
479
471 vdd--; /* There may be some fluctuation in measurement */ 480 vdd--; /* There may be some fluctuation in measurement */
472 481
473 for (i = 0; i < LP5523_LEDS; i++) { 482 for (i = 0; i < LP5523_LEDS; i++) {
@@ -489,9 +498,14 @@ static ssize_t lp5523_selftest(struct device *dev,
489 /* ADC conversion time is 2.7 ms typically */ 498 /* ADC conversion time is 2.7 ms typically */
490 usleep_range(3000, 6000); 499 usleep_range(3000, 6000);
491 ret = lp5523_read(chip->client, LP5523_REG_STATUS, &status); 500 ret = lp5523_read(chip->client, LP5523_REG_STATUS, &status);
501 if (ret < 0)
502 goto fail;
503
492 if (!(status & LP5523_LEDTEST_DONE)) 504 if (!(status & LP5523_LEDTEST_DONE))
493 usleep_range(3000, 6000);/* Was not ready. Wait. */ 505 usleep_range(3000, 6000);/* Was not ready. Wait. */
494 ret |= lp5523_read(chip->client, LP5523_REG_LED_TEST_ADC, &adc); 506 ret = lp5523_read(chip->client, LP5523_REG_LED_TEST_ADC, &adc);
507 if (ret < 0)
508 goto fail;
495 509
496 if (adc >= vdd || adc < LP5523_ADC_SHORTCIRC_LIM) 510 if (adc >= vdd || adc < LP5523_ADC_SHORTCIRC_LIM)
497 pos += sprintf(buf + pos, "LED %d FAIL\n", i); 511 pos += sprintf(buf + pos, "LED %d FAIL\n", i);
@@ -696,7 +710,7 @@ static ssize_t store_current(struct device *dev,
696 ssize_t ret; 710 ssize_t ret;
697 unsigned long curr; 711 unsigned long curr;
698 712
699 if (strict_strtoul(buf, 0, &curr)) 713 if (kstrtoul(buf, 0, &curr))
700 return -EINVAL; 714 return -EINVAL;
701 715
702 if (curr > led->max_current) 716 if (curr > led->max_current)