Skip to content

Commit

Permalink
misc: apds9802als: Fix the logic checking timeout in als_wait_for_dat…
Browse files Browse the repository at this point in the history
…a_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>
  • Loading branch information
Axel Lin authored and Greg Kroah-Hartman committed Nov 16, 2012
1 parent ebf1b76 commit 644a9d3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/misc/apds9802als.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 644a9d3

Please sign in to comment.