mfd: twl6040: Check for error when reading revision register
authorFlorian Vaussard <florian.vaussard@epfl.ch>
Tue, 25 Feb 2014 13:28:19 +0000 (14:28 +0100)
committerLee Jones <lee.jones@linaro.org>
Wed, 19 Mar 2014 08:58:27 +0000 (08:58 +0000)
We may have an error when reading the revision register, so check for
the returned value.

Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Florian Vaussard <florian.vaussard@epfl.ch>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
drivers/mfd/twl6040.c

index f15114f8c2582cc6eb91f44f8289af2fd60202ee..6e88f25832fb23a13198a1b2f5ca8170b9e04772 100644 (file)
@@ -661,6 +661,11 @@ static int twl6040_probe(struct i2c_client *client,
        init_completion(&twl6040->ready);
 
        twl6040->rev = twl6040_reg_read(twl6040, TWL6040_REG_ASICREV);
+       if (twl6040->rev < 0) {
+               dev_err(&client->dev, "Failed to read revision register: %d\n",
+                       twl6040->rev);
+               goto gpio_err;
+       }
 
        /* ERRATA: Automatic power-up is not possible in ES1.0 */
        if (twl6040_get_revid(twl6040) > TWL6040_REV_ES1_0)