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


Groups > linux.kernel > #1556782

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

From Colin King <colin.king@canonical.com>
Newsgroups linux.kernel
Subject [PATCH] iio: magnetometer: ak8974: remove redundant zero timeout check
Date 2017-01-11 19:00 +0100
Message-ID <sYvlL-1rB-33@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

[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

csiph-web