iio: adc: Correct conditional logic for store mode
Subsystems (4)
PATCH 1/1 iio: adc: Correct conditional logic for store mode
The mode setting logic in ad7816_store_mode was reversed due to incorrect handling of the strcmp return value. strcmp returns 0 on match, so the if (strcmp(buf, "full")) block executed when the input was not "full".
This resulted in "full" setting the mode to AD7816_PD (power-down) and other inputs setting it to AD7816_FULL.
Fix this by checking it against 0 to correctly check for "full" and "power-down", mapping them to AD7816_FULL and AD7816_PD respectively.
--- drivers/staging/iio/adc/ad7816.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/iio/adc/ad7816.c +1 -1
@@ -136,7 +136,7 @@ static ssize_t ad7816_store_mode(struct device *dev,struct iio_dev *indio_dev =dev_to_iio_dev (dev);struct ad7816_chip_info *chip =iio_priv (indio_dev); -if (strcmp (buf,"full" )) { +if (sysfs_streq (buf,"full" )) {gpiod_set_value (chip->rdwr_pin,1 ); chip->mode =AD7816_FULL ; }else {
Signature · 1 line
2.43.0
David Lechner
reviewerQuoted 11 lines · Gabriel Shahrouzi
The mode setting logic in
ad7816_store_modewas reversed due to incorrect handling of the strcmp return value. strcmp returns 0 on match, so theif (strcmp(buf, "full"))block executed when the input was not "full".This resulted in "full" setting the mode to
AD7816_PD(power-down) and other inputs setting it toAD7816_FULL.Fix this by checking it against 0 to correctly check for "full" and "power-down", mapping them to
AD7816_FULLandAD7816_PDrespectively.
Sounds like we need a Fixes: tag here that reference the commit that introduced the bug.
Quoted 2 lines
Signed-off-by Gabriel Shahrouzi <[email protected]>---
David Lechner
reviewerQuoted 9 lines · David Lechner
Quoted 8 lines · Gabriel Shahrouzi
The mode setting logic in
ad7816_store_modewas reversed due to incorrect handling of the strcmp return value. strcmp returns 0 on match, so theif (strcmp(buf, "full"))block executed when the input was not "full".This resulted in "full" setting the mode to
AD7816_PD(power-down) and other inputs setting it toAD7816_FULL.
Quoted 9 lines
Quoted 3 lines
Fix this by checking it against 0 to correctly check for "full" and "power-down", mapping them to
AD7816_FULLandAD7816_PDrespectively.Sounds like we need a Fixes: tag here that reference the commit that introduced the bug.
Quoted 2 lines
Signed-off-by Gabriel Shahrouzi <[email protected]>---
There is also a typo in your email address in the cc: [email protected]
Quoted 11 lines · David Lechner
Quoted 9 lines · David Lechner
Quoted 8 lines · Gabriel Shahrouzi
The mode setting logic in
ad7816_store_modewas reversed due to incorrect handling of the strcmp return value. strcmp returns 0 on match, so theif (strcmp(buf, "full"))block executed when the input was not "full".This resulted in "full" setting the mode to
AD7816_PD(power-down) and other inputs setting it toAD7816_FULL.
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Fix this by checking it against 0 to correctly check for "full" and "power-down", mapping them to
AD7816_FULLandAD7816_PDrespectively.Sounds like we need a Fixes: tag here that reference the commit that introduced the bug.
Sounds good. Included the fixes tag and CC'd [email protected].
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
Signed-off-by Gabriel Shahrouzi <[email protected]>---
There is also a typo in your email address in the cc: [email protected]
Whoops - I'll update that.
I just realized I didn't update the version for the second patch correctly so I'll send in a new one.