diff options
author | Devendra Naga <devendra.aaru@gmail.com> | 2015-01-02 04:02:55 -0500 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2015-02-03 21:03:20 +0000 |
commit | 1e716a15ce5e5840cac0fb4cd6ca79d70d3568a9 (patch) | |
tree | 1fde8ea601297ff91663e0683b139d10b2b494d4 | |
parent | abe4e26bb7edb7b36ef99e2e78e86de79b18f922 (diff) | |
download | op-kernel-dev-1e716a15ce5e5840cac0fb4cd6ca79d70d3568a9.zip op-kernel-dev-1e716a15ce5e5840cac0fb4cd6ca79d70d3568a9.tar.gz |
iio: meter: ade7759: add error handling in _reset and _stop_device
This patch adds the error handling for the value returned from
ade7759_spi_read_reg_16. With this patch, the following randconfig
warnings get fixed automatically.
drivers/staging/iio/meter/ade7759.c:224:6: warning: ‘val’ may be
used uninitialized in this function [-Wmaybe-uninitialized]
drivers/staging/iio/meter/ade7759.c:309: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>
-rw-r--r-- | drivers/staging/iio/meter/ade7759.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/drivers/staging/iio/meter/ade7759.c b/drivers/staging/iio/meter/ade7759.c index b0c7dbc..9afdb1e 100644 --- a/drivers/staging/iio/meter/ade7759.c +++ b/drivers/staging/iio/meter/ade7759.c @@ -218,9 +218,12 @@ static int ade7759_reset(struct device *dev) int ret; u16 val; - ade7759_spi_read_reg_16(dev, + ret = ade7759_spi_read_reg_16(dev, ADE7759_MODE, &val); + if (ret < 0) + return ret; + val |= 1 << 6; /* Software Chip Reset */ ret = ade7759_spi_write_reg_16(dev, ADE7759_MODE, @@ -301,11 +304,18 @@ error_ret: /* Power down the device */ static int ade7759_stop_device(struct device *dev) { + int ret; u16 val; - ade7759_spi_read_reg_16(dev, + ret = ade7759_spi_read_reg_16(dev, ADE7759_MODE, &val); + if (ret < 0) { + dev_err(dev, "unable to power down the device, error: %d\n", + ret); + return ret; + } + val |= 1 << 4; /* AD converters can be turned off */ return ade7759_spi_write_reg_16(dev, ADE7759_MODE, val); |