linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: magnetometer: ak8974: remove redundant zero timeout check
@ 2017-01-11 17:49 Colin King
  2017-01-11 23:11 ` Linus Walleij
  0 siblings, 1 reply; 3+ messages in thread
From: Colin King @ 2017-01-11 17:49 UTC (permalink / raw)
  To: Linus Walleij, Jonathan Cameron, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio
  Cc: linux-kernel

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] iio: magnetometer: ak8974: remove redundant zero timeout check
  2017-01-11 17:49 [PATCH] iio: magnetometer: ak8974: remove redundant zero timeout check Colin King
@ 2017-01-11 23:11 ` Linus Walleij
  2017-01-14 13:10   ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Linus Walleij @ 2017-01-11 23:11 UTC (permalink / raw)
  To: Colin King
  Cc: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, linux-iio, linux-kernel

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] iio: magnetometer: ak8974: remove redundant zero timeout check
  2017-01-11 23:11 ` Linus Walleij
@ 2017-01-14 13:10   ` Jonathan Cameron
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2017-01-14 13:10 UTC (permalink / raw)
  To: Linus Walleij, Colin King
  Cc: Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler,
	linux-iio, linux-kernel

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
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-01-14 13:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-11 17:49 [PATCH] iio: magnetometer: ak8974: remove redundant zero timeout check Colin King
2017-01-11 23:11 ` Linus Walleij
2017-01-14 13:10   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).