Skip to contentSkip to conversation

drivers: iio: max1027: Fix sparse warning: "dubious: x | !y"

PATCH Superseded Sandhya Bankar 2 participants 3 messages Sep 23, 2016 IIO

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers: iio: max1027: Fix sparse warning: "dubious: x | !y"

Fixing below warning:
drivers/iio/adc/max1027.c:241:34: warning: dubious: x | !y .

---
 drivers/iio/adc/max1027.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iio/adc/max1027.c +3 -1
index 712fbd2..b1fee47 100644
@@ -238,7 +238,9 @@ static int max1027_read_single_value(struct iio_dev *indio_dev,
 
 	/* Configure conversion register with the requested chan */
 	st->reg = MAX1027_CONV_REG | MAX1027_CHAN(chan->channel) |
-		  MAX1027_NOSCAN | !!(chan->type == IIO_TEMP);
+		  MAX1027_NOSCAN;
+	if (chan->type == IIO_TEMP)
+		st->reg |= 1;
 	ret = spi_write(st->spi, &st->reg, 1);
 	if (ret < 0) {
 		dev_err(&indio_dev->dev,
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 4 lines · Sandhya Bankar

Fixing below warning:
drivers/iio/adc/max1027.c:241:34: warning: dubious: x | !y .

Hi,

Thanks for the patch. Looks good in general, just one minor detail

Quoted 9 lines
---
 drivers/iio/adc/max1027.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iio/adc/max1027.c +0 -0
index 712fbd2..b1fee47 100644

drivers/iio/adc/max1027.c static int max1027_read_single_value(struct iio_dev *indio_dev, · line 243

Quoted 7 lines
drivers/iio/adc/max1027.c +3 -1
@@ -238,7 +238,9 @@ static int max1027_read_single_value(struct iio_dev *indio_dev,
 
 	/* Configure conversion register with the requested chan */
 	st->reg = MAX1027_CONV_REG | MAX1027_CHAN(chan->channel) |
-		  MAX1027_NOSCAN | !!(chan->type == IIO_TEMP);
+		  MAX1027_NOSCAN;
+	if (chan->type == IIO_TEMP)
+		st->reg |= 1;

The driver has a symbolic constant defined for this 'MAX1027_TEMP'. Using this instead of the number makes it clear what the semantic meaning of the value is.

#2 lore raw
Quoted 11 lines · Lars-Peter Clausen
Quoted 4 lines · Sandhya Bankar

Fixing below warning:
drivers/iio/adc/max1027.c:241:34: warning: dubious: x | !y .

Hi,

Thanks for the patch. Looks good in general, just one minor detail

Thanks for review !

I will incorporate your suggestion and send new patch.

Thanks,
Sandhya

Quoted 23 lines

drivers/iio/adc/max1027.c static int max1027_read_single_value(struct iio_dev

Quoted 9 lines
---
 drivers/iio/adc/max1027.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iio/adc/max1027.c +0 -0
index 712fbd2..b1fee47 100644
@@ -238,7 +238,9 @@ static int max1027_read_single_value(struct iio_dev

*indio_dev,

drivers/iio/adc/max1027.c static int max1027_read_single_value(struct iio_dev *indio_dev, · line 243

Quoted 7 lines
drivers/iio/adc/max1027.c +3 -1
      /* Configure conversion register with the requested chan */
      st->reg = MAX1027_CONV_REG | MAX1027_CHAN(chan->channel) |
-               MAX1027_NOSCAN | !!(chan->type == IIO_TEMP);
+               MAX1027_NOSCAN;
+     if (chan->type == IIO_TEMP)
+             st->reg |= 1;

The driver has a symbolic constant defined for this 'MAX1027_TEMP'. Using this instead of the number makes it clear what the semantic meaning of the value is.