From: Jonathan Cameron <jic23@kernel.org>
To: Colin King <colin.king@canonical.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
Lee Jones <lee.jones@linaro.org>,
Laxman Dewangan <ldewangan@nvidia.com>,
Pradeep Goudagunta <pgoudagunta@nvidia.com>,
Marek Belisko <marek@goldelico.com>,
linux-iio@vger.kernel.org, kernel-janitors@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: adc: Fix incorrect exit of for-loop
Date: Sat, 31 Jul 2021 14:47:32 +0100 [thread overview]
Message-ID: <20210731144732.57777e20@jic23-huawei> (raw)
In-Reply-To: <20210730071651.17394-1-colin.king@canonical.com>
On Fri, 30 Jul 2021 08:16:51 +0100
Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently the for-loop that scans for the optimial adc_period iterates
> through all the possible adc_period levels because the exit logic in
> the loop is inverted. I believe the comparison should be swapped and
> the continue replaced with a break to exit the loop at the correct
> point.
>
> Addresses-Coverity: ("Continue has no effect")
> Fixes: e08e19c331fb ("iio:adc: add iio driver for Palmas (twl6035/7) gpadc")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
ouch.
Applied to the fixes togreg branch of iio.git and marked for stable.
Thanks,
Jonathan
> ---
> drivers/iio/adc/palmas_gpadc.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/adc/palmas_gpadc.c b/drivers/iio/adc/palmas_gpadc.c
> index 6ef09609be9f..f9c8385c72d3 100644
> --- a/drivers/iio/adc/palmas_gpadc.c
> +++ b/drivers/iio/adc/palmas_gpadc.c
> @@ -664,8 +664,8 @@ static int palmas_adc_wakeup_configure(struct palmas_gpadc *adc)
>
> adc_period = adc->auto_conversion_period;
> for (i = 0; i < 16; ++i) {
> - if (((1000 * (1 << i)) / 32) < adc_period)
> - continue;
> + if (((1000 * (1 << i)) / 32) >= adc_period)
> + break;
> }
> if (i > 0)
> i--;
prev parent reply other threads:[~2021-07-31 13:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-30 7:16 [PATCH] iio: adc: Fix incorrect exit of for-loop Colin King
2021-07-31 13:47 ` Jonathan Cameron [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210731144732.57777e20@jic23-huawei \
--to=jic23@kernel.org \
--cc=colin.king@canonical.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=lars@metafoo.de \
--cc=ldewangan@nvidia.com \
--cc=lee.jones@linaro.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marek@goldelico.com \
--cc=pgoudagunta@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox