Skip to contentSkip to conversation

iio: adc: ad7768-1: Remove logically dead code

PATCH In review Chandra Mohan Sundar 2 participants 3 messages Aug 16, 2025 – Aug 17, 2025

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

PATCH 1/1 iio: adc: ad7768-1: Remove logically dead code

The clamp macro returns a value within the specified range.

In ad7768_set_freq(), the value returned from clamp() is checked against zero, which is not possible since the value would always be between 50 and 1024000.

Removed the 'if' check.

This issue was reported by static coverity analyser as logically dead code.

Fixes fb1d3b24ebf5c ("iio: adc: ad7768-1: add filter type and oversampling ratio attributes")
---
 drivers/iio/adc/ad7768-1.c | 2 --
 1 file changed, 2 deletions(-)
drivers/iio/adc/ad7768-1.c +0 -2
index ca8fa91796ca..a27591bbf7df 100644
@@ -687,8 +687,6 @@ static int ad7768_set_freq(struct ad7768_state *st,
 	int ret;
 
 	freq = clamp(freq, 50, 1024000);
-	if (freq == 0)
-		return -EINVAL;
 
 	mclk_div = DIV_ROUND_CLOSEST(st->mclk_freq, freq * st->oversampling_ratio);
 	/* Find the closest match for the desired sampling frequency */
Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 6 lines · On Sat, 16 Aug 2025 19:07:55 +0530 Chandra Mohan Sundar…

The clamp macro returns a value within the specified range.

In ad7768_set_freq(), the value returned from clamp() is checked against zero, which is not possible since the value would always be between 50 and 1024000.

Quoted 6 lines

Removed the 'if' check.

This issue was reported by static coverity analyser as logically dead code.

Fixes fb1d3b24ebf5c ("iio: adc: ad7768-1: add filter type and oversampling ratio attributes")

Applied but dropped the fixes tag. No need to encourage people to backport this.

Jonathan

Quoted 18 lines
---
 drivers/iio/adc/ad7768-1.c | 2 --
 1 file changed, 2 deletions(-)
drivers/iio/adc/ad7768-1.c +0 -2
index ca8fa91796ca..a27591bbf7df 100644
@@ -687,8 +687,6 @@ static int ad7768_set_freq(struct ad7768_state *st,
 	int ret;
 
 	freq = clamp(freq, 50, 1024000);
-	if (freq == 0)
-		return -EINVAL;
 
 	mclk_div = DIV_ROUND_CLOSEST(st->mclk_freq, freq * st->oversampling_ratio);
 	/* Find the closest match for the desired sampling frequency */
#2 lore raw
Quoted 3 lines · Jonathan Cameron
Quoted 1 line
Fixes fb1d3b24ebf5c ("iio: adc: ad7768-1: add filter type and oversampling ratio attributes")

Applied but dropped the fixes tag. No need to encourage people to backport this.

Thanks Jonathan.

Regards,
Chandra Mohan Sundar