* [PATCH] iio: adc: ad7768-1: Remove logically dead code
@ 2025-08-16 13:37 Chandra Mohan Sundar
2025-08-17 14:32 ` Jonathan Cameron
0 siblings, 1 reply; 3+ messages in thread
From: Chandra Mohan Sundar @ 2025-08-16 13:37 UTC (permalink / raw)
To: lars, Michael.Hennerich, jic23, dlechner, nuno.sa, andy,
linux-iio, shuah
Cc: Chandra Mohan Sundar, linux-kernel-mentees
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")
Signed-off-by: Chandra Mohan Sundar <chandramohan.explore@gmail.com>
---
drivers/iio/adc/ad7768-1.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/iio/adc/ad7768-1.c b/drivers/iio/adc/ad7768-1.c
index ca8fa91796ca..a27591bbf7df 100644
--- a/drivers/iio/adc/ad7768-1.c
+++ b/drivers/iio/adc/ad7768-1.c
@@ -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.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] iio: adc: ad7768-1: Remove logically dead code
2025-08-16 13:37 [PATCH] iio: adc: ad7768-1: Remove logically dead code Chandra Mohan Sundar
@ 2025-08-17 14:32 ` Jonathan Cameron
2025-08-17 16:25 ` Chandra Mohan Sundar
0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Cameron @ 2025-08-17 14:32 UTC (permalink / raw)
To: Chandra Mohan Sundar
Cc: lars, Michael.Hennerich, dlechner, nuno.sa, andy, linux-iio,
shuah, linux-kernel-mentees
On Sat, 16 Aug 2025 19:07:55 +0530
Chandra Mohan Sundar <chandramohan.explore@gmail.com> wrote:
> 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")
Applied but dropped the fixes tag. No need to encourage people to backport
this.
Jonathan
> Signed-off-by: Chandra Mohan Sundar <chandramohan.explore@gmail.com>
> ---
> drivers/iio/adc/ad7768-1.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/drivers/iio/adc/ad7768-1.c b/drivers/iio/adc/ad7768-1.c
> index ca8fa91796ca..a27591bbf7df 100644
> --- a/drivers/iio/adc/ad7768-1.c
> +++ b/drivers/iio/adc/ad7768-1.c
> @@ -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 */
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] iio: adc: ad7768-1: Remove logically dead code
2025-08-17 14:32 ` Jonathan Cameron
@ 2025-08-17 16:25 ` Chandra Mohan Sundar
0 siblings, 0 replies; 3+ messages in thread
From: Chandra Mohan Sundar @ 2025-08-17 16:25 UTC (permalink / raw)
To: Jonathan Cameron
Cc: lars, Michael.Hennerich, dlechner, nuno.sa, andy, linux-iio,
shuah, linux-kernel-mentees
On Sun, Aug 17, 2025 at 8:02 PM Jonathan Cameron <jic23@kernel.org> wrote:
> > 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-08-17 16:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-16 13:37 [PATCH] iio: adc: ad7768-1: Remove logically dead code Chandra Mohan Sundar
2025-08-17 14:32 ` Jonathan Cameron
2025-08-17 16:25 ` Chandra Mohan Sundar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox