Commit 1e716a15 authored by Devendra Naga's avatar Devendra Naga Committed by Jonathan Cameron

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: default avatarDevendra Naga <devendra.aaru@gmail.com>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent abe4e26b
......@@ -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 @@ static int ade7759_set_irq(struct device *dev, bool enable)
/* 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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment