leds: leds-lp5521: return an error code on error in probe()
authorDan Carpenter <dan.carpenter@oracle.com>
Sun, 2 Dec 2012 17:29:30 +0000 (09:29 -0800)
committerBryan Wu <cooloney@gmail.com>
Mon, 3 Dec 2012 19:16:58 +0000 (11:16 -0800)
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>
drivers/leds/leds-lp5521.c

index 8505afe4b52e1b4a1d2f13885496b05a28f5e278..ddc431529157db635e34f0f095b4a6b91d23f06e 100644 (file)
@@ -788,10 +788,17 @@ static int __devinit lp5521_probe(struct i2c_client *client,
         * LP5521_REG_ENABLE register will not have any effect - strange!
         */
        ret = lp5521_read(client, LP5521_REG_R_CURRENT, &buf);
-       if (ret || buf != LP5521_REG_R_CURR_DEFAULT) {
+       if (ret) {
                dev_err(&client->dev, "error in resetting chip\n");
                goto fail2;
        }
+       if (buf != LP5521_REG_R_CURR_DEFAULT) {
+               dev_err(&client->dev,
+                       "unexpected data in register (expected 0x%x got 0x%x)\n",
+                       LP5521_REG_R_CURR_DEFAULT, buf);
+               ret = -EINVAL;
+               goto fail2;
+       }
        usleep_range(10000, 20000);
 
        ret = lp5521_detect(client);