Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 644a9d3b authored by Axel Lin's avatar Axel Lin Committed by Greg Kroah-Hartman
Browse files

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: default avatarAxel Lin <axel.lin@ingics.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent ebf1b764
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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;
	}