iio: adc: ad7266: Don't set error code to st->vref_uv
authorAxel Lin <axel.lin@ingics.com>
Fri, 14 Dec 2012 07:47:00 +0000 (07:47 +0000)
committerJonathan Cameron <jic23@kernel.org>
Thu, 27 Dec 2012 10:59:56 +0000 (10:59 +0000)
regulator_get_voltage() may return negative error code.
Add error checking to avoid setting error code to st->vref_uv.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/adc/ad7266.c

index a6f4fc5f8201a414f653d86db92b7ef03a9c1705..e36107dc30b9a96942f6acc16d70fb62a4083fcc 100644 (file)
@@ -411,7 +411,11 @@ static int __devinit ad7266_probe(struct spi_device *spi)
                if (ret)
                        goto error_put_reg;
 
-               st->vref_uv = regulator_get_voltage(st->reg);
+               ret = regulator_get_voltage(st->reg);
+               if (ret < 0)
+                       goto error_disable_reg;
+
+               st->vref_uv = ret;
        } else {
                /* Use internal reference */
                st->vref_uv = 2500000;