diff options
author | Axel Lin <axel.lin@ingics.com> | 2012-11-16 04:17:50 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-11-16 07:53:08 -0500 |
commit | 644a9d3b66e6983c2c1f3b24c3006d49b184c871 (patch) | |
tree | b4861582f20654cdb0b76989295bdf55bf842db6 /drivers/misc | |
parent | ebf1b764aa5cb3b4bfe2e96674f1b559f7c37e64 (diff) |
misc: apds9802als: Fix the logic checking timeout in als_wait_for_data_ready()
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc')
-rw-r--r-- | drivers/misc/apds9802als.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/misc/apds9802als.c b/drivers/misc/apds9802als.c index 0314773f6db3..94923d259910 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) | |||
68 | ret = i2c_smbus_read_byte_data(client, 0x86); | 68 | ret = i2c_smbus_read_byte_data(client, 0x86); |
69 | } while (!(ret & 0x80) && retry--); | 69 | } while (!(ret & 0x80) && retry--); |
70 | 70 | ||
71 | if (!retry) { | 71 | if (retry < 0) { |
72 | dev_warn(dev, "timeout waiting for data ready\n"); | 72 | dev_warn(dev, "timeout waiting for data ready\n"); |
73 | return -ETIMEDOUT; | 73 | return -ETIMEDOUT; |
74 | } | 74 | } |