All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] misc: apds9802als: Fix checking timeout in als_wait_for_data_ready()
@ 2012-11-09  7:31 Axel Lin
  0 siblings, 0 replies; only message in thread
From: Axel Lin @ 2012-11-09  7:31 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Anantha Narayanan, Alan Cox, Arnd Bergmann, linux-kernel

In the case of timeout waiting for data ready, the retry variable is -1.
This also fixes a bug: current code returns -ETIMEDOUT if latest retry success
( which means retry is 0 when exiting the while loop ).

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/misc/apds9802als.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/apds9802als.c b/drivers/misc/apds9802als.c
index 0314773..94923d2 100644
--- a/drivers/misc/apds9802als.c
+++ b/drivers/misc/apds9802als.c
@@ -68,7 +68,7 @@ static int als_wait_for_data_ready(struct device *dev)
 		ret = i2c_smbus_read_byte_data(client, 0x86);
 	} while (!(ret & 0x80) && retry--);
 
-	if (!retry) {
+	if (retry < 0) {
 		dev_warn(dev, "timeout waiting for data ready\n");
 		return -ETIMEDOUT;
 	}
-- 
1.7.9.5




^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2012-11-09  7:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-09  7:31 [PATCH] misc: apds9802als: Fix checking timeout in als_wait_for_data_ready() Axel Lin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.