Skip to contentSkip to conversation

iio: adc: tsc2046: fix a warning message in tsc2046_adc_update_scan_mode()

PATCH Applied Dan Carpenter 2 participants 2 messages May 15, 2021 – May 16, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: adc: tsc2046: fix a warning message in tsc2046_adc_update_scan_mode()

These variables are unsigned so the condition can't be less than zero and the warning message will never be printed.

Fixes 5fec3541aa88 ("iio: adc: add ADC driver for the TI TSC2046 controller")
---
 drivers/iio/adc/ti-tsc2046.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/ti-tsc2046.c +1 -1
index 89a818b653b4..cf5373d5cdd7 100644
@@ -398,7 +398,7 @@ static int tsc2046_adc_update_scan_mode(struct iio_dev *indio_dev,
 	priv->xfer.len = size;
 	priv->time_per_scan_us = size * 8 * priv->time_per_bit_ns / NSEC_PER_USEC;
 
-	if ((priv->scan_interval_us - priv->time_per_scan_us) < 0)
+	if (priv->scan_interval_us > priv->time_per_scan_us)
 		dev_warn(&priv->spi->dev, "The scan interval (%d) is less then calculated scan time (%d)\n",
 			 priv->scan_interval_us, priv->time_per_scan_us);
 
Signature · 1 line
2.30.2
maintainer Applied
#1 lore raw
Quoted 5 lines · On Sat, 15 May 2021 12:51:52 +0300 Dan Carpenter <[email protected]>…

These variables are unsigned so the condition can't be less than zero and the warning message will never be printed.

Fixes 5fec3541aa88 ("iio: adc: add ADC driver for the TI TSC2046 controller")

Applied. Thanks.

Chances are I'm going to rebase togreg shortly to unwind a merge conflict with fixes-togreg so hopefully I'll manage to remember to update that fixes tag.

Thanks,

Jonathan

Quoted 17 lines
---
 drivers/iio/adc/ti-tsc2046.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/ti-tsc2046.c +1 -1
index 89a818b653b4..cf5373d5cdd7 100644
@@ -398,7 +398,7 @@ static int tsc2046_adc_update_scan_mode(struct iio_dev *indio_dev,
 	priv->xfer.len = size;
 	priv->time_per_scan_us = size * 8 * priv->time_per_bit_ns / NSEC_PER_USEC;
 
-	if ((priv->scan_interval_us - priv->time_per_scan_us) < 0)
+	if (priv->scan_interval_us > priv->time_per_scan_us)
 		dev_warn(&priv->spi->dev, "The scan interval (%d) is less then calculated scan time (%d)\n",
 			 priv->scan_interval_us, priv->time_per_scan_us);