Commit abe4e26b authored by Devendra Naga's avatar Devendra Naga Committed by Jonathan Cameron

iio: meter: ade7754: add error handling in _reset and _stop_device

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: default avatarDevendra Naga <devendra.aaru@gmail.com>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 178cf7de
...@@ -216,9 +216,13 @@ static ssize_t ade7754_write_16bit(struct device *dev, ...@@ -216,9 +216,13 @@ static ssize_t ade7754_write_16bit(struct device *dev,
static int ade7754_reset(struct device *dev) static int ade7754_reset(struct device *dev)
{ {
int ret;
u8 val; 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 */ val |= 1 << 6; /* Software Chip Reset */
return ade7754_spi_write_reg_8(dev, ADE7754_OPMODE, val); return ade7754_spi_write_reg_8(dev, ADE7754_OPMODE, val);
} }
...@@ -362,9 +366,16 @@ static int ade7754_set_irq(struct device *dev, bool enable) ...@@ -362,9 +366,16 @@ static int ade7754_set_irq(struct device *dev, bool enable)
/* Power down the device */ /* Power down the device */
static int ade7754_stop_device(struct device *dev) static int ade7754_stop_device(struct device *dev)
{ {
int ret;
u8 val; 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 */ val |= 7 << 3; /* ADE7754 powered down */
return ade7754_spi_write_reg_8(dev, ADE7754_OPMODE, val); return ade7754_spi_write_reg_8(dev, ADE7754_OPMODE, 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