iio: meter: ade7754: fix build warnings with make randconfig
Subsystems (4)
PATCH 1/2 iio: meter: ade7754: fix build warnings with make randconfig
fixes
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]
the fix here is to check the return value of ade7754_spi_read_reg_8.
---
hapens on next-20141215 with make randconfig. compile tested only on x86_64.
drivers/staging/iio/meter/ade7754.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/staging/iio/meter/ade7754.c +10 -2
@@ -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,13 @@ 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 ) +return ret; + val |=7 <<3 ;/* ADE7754 powered down */ return ade7754_spi_write_reg_8 (dev,ADE7754_OPMODE , val); }
Signature · 1 line
2.1.0
PATCH 2/2 iio: meter: ade7759: fix build warnings with make randconfig
fixes
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]
the fix is to check the return value of ade7759_spi_read_reg_16.
---
hapens on next-20141215 with make randconfig. compile tested only on x86_64.
drivers/staging/iio/meter/ade7759.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/staging/iio/meter/ade7759.c +9 -2
@@ -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,15 @@ 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 ) +return ret; + val |=1 <<4 ;/* AD converters can be turned off */ return ade7759_spi_write_reg_16 (dev,ADE7759_MODE , val);
Signature · 1 line
2.1.0
Devendra Naga schrieb am 15.12.2014 um 12:46:
Quoted 8 lines
fixes
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]the fix here is to check the return value of
ade7754_spi_read_reg_8.
Hi,
I would recommend to use a different topic name, which represents a bit better what your patch actually does (something like add error handling in _reset and _stop_device).
Your attempt is basically right, but in _stop_device I would at least recommend to add an error message, given that it is only called from _remove, which does no error handling. So, at least it becomes clear that something went wrong and the device didn't get powered down. Since your second patch is very similar to this one, the same applies there, too.
Thanks,
Hartmut
Quoted 44 lines
Signed-off-by Devendra Naga <[email protected]>---
hapens on next-20141215 with make randconfig. compile tested only on
x86_64.drivers/staging/iio/meter/ade7754.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)drivers/staging/iio/meter/ade7754.c +10
-2@@ -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,13 @@ 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 ) +return ret; + val |=7 <<3 ;/* ADE7754 powered down */ return ade7754_spi_write_reg_8 (dev,ADE7754_OPMODE , val); }
Hello,
Sorry for sending the email in the holidays...
Quoted 8 lines · Hartmut Knaack
Devendra Naga schrieb am 15.12.2014 um 12:46:
Quoted 7 lines
fixes
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]
Quoted 5 lines
Quoted 1 line
the fix here is to check the return value of
ade7754_spi_read_reg_8.Hi,
I would recommend to use a different topic name, which represents a bit better what your patch actually does (something like add error handling in_resetand_stop_device).
Okay. Got you.
Quoted 1 line
Your attempt is basically right, but in _stop_device I would at least
Quoted 8 lines
recommend to add an error message, given that it is only called from
_remove, which does no error handling. So, at least it becomes clear that something went wrong and the device didn't get powered down. Since your second patch is very similar to this one, the same applies there, too.
Thanks,
Okay. Will add the error message in _stop_device.
I will update both of the patches with your comments.
-- Devendra