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

Skip to content
Commit 6ba5dee9 authored by Brian Masney's avatar Brian Masney Committed by Jonathan Cameron
Browse files

staging: iio: tsl2583: i2c_smbus_write_byte() / i2c_smbus_read_byte() migration



There were several places where the driver would first call
i2c_smbus_write_byte() to select the register on the device, and then
call i2c_smbus_read_byte() to get the contents of that register. The
code would look roughly like:

/* Select register */
i2c_smbus_write_byte(client, REGISTER);

/* Read the the last register that was written to */
int data = i2c_smbus_read_byte(client);

Rewrite this to use i2c_smbus_read_byte_data() to combine the two
calls into one:

int data = i2c_smbus_read_byte_data(chip->client, REGISTER);

Verified that the driver still functions correctly using a TSL2581
hooked up to a Raspberry Pi 2.

This fixes the following warnings that were found by the
kbuild test robot that were introduced by commit 8ba355cce3c6 ("staging:
iio: tsl2583: check for error code from i2c_smbus_read_byte()").

drivers/staging/iio/light/tsl2583.c:365:5-12: WARNING: Unsigned
expression compared with zero: reg_val < 0

drivers/staging/iio/light/tsl2583.c:388:5-12: WARNING: Unsigned
expression compared with zero: reg_val < 0

This also removes the need for the taos_i2c_read() function since all
callers were only calling the function with a length of 1.

Signed-off-by: default avatarBrian Masney <masneyb@onstation.org>
Cc: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 25acb398
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment