]> git.karo-electronics.de Git - linux-beck.git/commitdiff
iio: meter: ade7754: add error handling in _reset and _stop_device
authorDevendra Naga <devendra.aaru@gmail.com>
Fri, 2 Jan 2015 09:02:54 +0000 (04:02 -0500)
committerJonathan Cameron <jic23@kernel.org>
Tue, 3 Feb 2015 21:03:20 +0000 (21:03 +0000)
This patch adds the error handling for the value returned from
ade7754_spi_read_reg_8. With this patch, the following randconfig
warnings get fixed automatically.

drivers/staging/iio/meter/ade7754.c:222:6: warning: ‘val’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
drivers/staging/iio/meter/ade7754.c:368:6: warning: ‘val’ may be used
uninitialized in this function [-Wmaybe-uninitialized]

Signed-off-by: Devendra Naga <devendra.aaru@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/staging/iio/meter/ade7754.c

index 81f67318974ad77322c3f66138f25d3385463af9..746b18894ebf6009cfe379cb3e7b69eaf26b57c9 100644 (file)
@@ -216,9 +216,13 @@ error_ret:
 
 static int ade7754_reset(struct device *dev)
 {
+       int ret;
        u8 val;
 
-       ade7754_spi_read_reg_8(dev, ADE7754_OPMODE, &val);
+       ret = ade7754_spi_read_reg_8(dev, ADE7754_OPMODE, &val);
+       if (ret < 0)
+               return ret;
+
        val |= 1 << 6; /* Software Chip Reset */
        return ade7754_spi_write_reg_8(dev, ADE7754_OPMODE, val);
 }
@@ -362,9 +366,16 @@ error_ret:
 /* Power down the device */
 static int ade7754_stop_device(struct device *dev)
 {
+       int ret;
        u8 val;
 
-       ade7754_spi_read_reg_8(dev, ADE7754_OPMODE, &val);
+       ret = ade7754_spi_read_reg_8(dev, ADE7754_OPMODE, &val);
+       if (ret < 0) {
+               dev_err(dev, "unable to power down the device, error: %d",
+                       ret);
+               return ret;
+       }
+
        val |= 7 << 3;  /* ADE7754 powered down */
        return ade7754_spi_write_reg_8(dev, ADE7754_OPMODE, val);
 }