diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2012-12-02 12:29:30 -0500 |
---|---|---|
committer | Bryan Wu <cooloney@gmail.com> | 2012-12-03 14:16:58 -0500 |
commit | 2f05e1d4458f9cb68d4d36fb47e6830fec03c80e (patch) | |
tree | 1cecb89a8b55797d0a90f465fd0c593605673d56 /drivers/leds/leds-lp5521.c | |
parent | 5c6f844cee2139182b3a778f2a883a77e5bb8f7d (diff) |
leds: leds-lp5521: return an error code on error in probe()
If "buf" wasn't equal to LP5521_REG_R_CURR_DEFAULT the probe fails but
we still return zero. I've changed it to print an error message and
return -EINVAL.
Reported-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
Diffstat (limited to 'drivers/leds/leds-lp5521.c')
-rw-r--r-- | drivers/leds/leds-lp5521.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c index 8505afe4b52e..ddc431529157 100644 --- a/drivers/leds/leds-lp5521.c +++ b/drivers/leds/leds-lp5521.c | |||
@@ -788,10 +788,17 @@ static int __devinit lp5521_probe(struct i2c_client *client, | |||
788 | * LP5521_REG_ENABLE register will not have any effect - strange! | 788 | * LP5521_REG_ENABLE register will not have any effect - strange! |
789 | */ | 789 | */ |
790 | ret = lp5521_read(client, LP5521_REG_R_CURRENT, &buf); | 790 | ret = lp5521_read(client, LP5521_REG_R_CURRENT, &buf); |
791 | if (ret || buf != LP5521_REG_R_CURR_DEFAULT) { | 791 | if (ret) { |
792 | dev_err(&client->dev, "error in resetting chip\n"); | 792 | dev_err(&client->dev, "error in resetting chip\n"); |
793 | goto fail2; | 793 | goto fail2; |
794 | } | 794 | } |
795 | if (buf != LP5521_REG_R_CURR_DEFAULT) { | ||
796 | dev_err(&client->dev, | ||
797 | "unexpected data in register (expected 0x%x got 0x%x)\n", | ||
798 | LP5521_REG_R_CURR_DEFAULT, buf); | ||
799 | ret = -EINVAL; | ||
800 | goto fail2; | ||
801 | } | ||
795 | usleep_range(10000, 20000); | 802 | usleep_range(10000, 20000); |
796 | 803 | ||
797 | ret = lp5521_detect(client); | 804 | ret = lp5521_detect(client); |