iio: adc: ad7768-1: Remove logically dead code
Subsystems (3)
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.
--- drivers/iio/adc/ad7768-1.c | 2 -- 1 file changed, 2 deletions(-)
drivers/iio/adc/ad7768-1.c +0 -2
@@ -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
Jonathan Cameron
maintainerQuoted 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 fromclamp()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
Signed-off-by Chandra Mohan Sundar <[email protected]>--- drivers/iio/adc/ad7768-1.c | 2 -- 1 file changed, 2 deletions(-)drivers/iio/adc/ad7768-1.c +0
-2@@ -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 */
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