Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1556782 > unrolled thread

[PATCH] iio: magnetometer: ak8974: remove redundant zero timeout check

Started byColin King <colin.king@canonical.com>
First post2017-01-11 19:00 +0100
Last post2017-01-14 14:20 +0100
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] iio: magnetometer: ak8974: remove redundant zero timeout check Colin King <colin.king@canonical.com> - 2017-01-11 19:00 +0100
    Re: [PATCH] iio: magnetometer: ak8974: remove redundant zero timeout check Linus Walleij <linus.walleij@linaro.org> - 2017-01-12 00:20 +0100
      Re: [PATCH] iio: magnetometer: ak8974: remove redundant zero timeout  check Jonathan Cameron <jic23@kernel.org> - 2017-01-14 14:20 +0100

#1556782 — [PATCH] iio: magnetometer: ak8974: remove redundant zero timeout check

FromColin King <colin.king@canonical.com>
Date2017-01-11 19:00 +0100
Subject[PATCH] iio: magnetometer: ak8974: remove redundant zero timeout check
Message-ID<sYvlL-1rB-33@gated-at.bofh.it>
From: Colin Ian King <colin.king@canonical.com>

At the end of the delay loop timeout will always be zero
and hence the check for !timeout will always be true. Remove
the redundant check and the redundant return 0 at the end of
the function.

Fixes CoverityScan CID#1357168 ("Logically dead code")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/iio/magnetometer/ak8974.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/magnetometer/ak8974.c b/drivers/iio/magnetometer/ak8974.c
index ce09d77..6dd8cbd 100644
--- a/drivers/iio/magnetometer/ak8974.c
+++ b/drivers/iio/magnetometer/ak8974.c
@@ -278,13 +278,9 @@ static int ak8974_await_drdy(struct ak8974 *ak8974)
 		if (val & AK8974_STATUS_DRDY)
 			return 0;
 	} while (--timeout);
-	if (!timeout) {
-		dev_err(&ak8974->i2c->dev,
-			"timeout waiting for DRDY\n");
-		return -ETIMEDOUT;
-	}
 
-	return 0;
+	dev_err(&ak8974->i2c->dev, "timeout waiting for DRDY\n");
+	return -ETIMEDOUT;
 }
 
 static int ak8974_getresult(struct ak8974 *ak8974, __le16 *result)
-- 
2.10.2

[toc] | [next] | [standalone]


#1557004

FromLinus Walleij <linus.walleij@linaro.org>
Date2017-01-12 00:20 +0100
Message-ID<sYAlr-4Mp-15@gated-at.bofh.it>
In reply to#1556782
On Wed, Jan 11, 2017 at 6:49 PM, Colin King <colin.king@canonical.com> wrote:

> From: Colin Ian King <colin.king@canonical.com>
>
> At the end of the delay loop timeout will always be zero
> and hence the check for !timeout will always be true. Remove
> the redundant check and the redundant return 0 at the end of
> the function.
>
> Fixes CoverityScan CID#1357168 ("Logically dead code")
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Clever Coverity scan.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

[toc] | [prev] | [next] | [standalone]


#1559001 — Re: [PATCH] iio: magnetometer: ak8974: remove redundant zero timeout check

FromJonathan Cameron <jic23@kernel.org>
Date2017-01-14 14:20 +0100
SubjectRe: [PATCH] iio: magnetometer: ak8974: remove redundant zero timeout check
Message-ID<sZwpt-6pM-33@gated-at.bofh.it>
In reply to#1557004
On 11/01/17 23:11, Linus Walleij wrote:
> On Wed, Jan 11, 2017 at 6:49 PM, Colin King <colin.king@canonical.com> wrote:
> 
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> At the end of the delay loop timeout will always be zero
>> and hence the check for !timeout will always be true. Remove
>> the redundant check and the redundant return 0 at the end of
>> the function.
>>
>> Fixes CoverityScan CID#1357168 ("Logically dead code")
>>
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> 
> Clever Coverity scan.
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
> 
Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to play with it.

Thanks,

Jonathan
> Yours,
> Linus Walleij
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web