]> git.karo-electronics.de Git - linux-beck.git/commit
staging: iio: tsl2583: i2c_smbus_write_byte() / i2c_smbus_read_byte() migration
authorBrian Masney <masneyb@onstation.org>
Thu, 3 Nov 2016 12:56:12 +0000 (08:56 -0400)
committerJonathan Cameron <jic23@kernel.org>
Sun, 6 Nov 2016 11:33:11 +0000 (11:33 +0000)
commit6ba5dee90b2483f8a78081376f56e6b65c10ea92
tree1a96ab417c99b1e30d464ce80317f2de3767d1cb
parent25acb3986f3e14210f37eb5503beba8e35126a3e
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: Brian Masney <masneyb@onstation.org>
Cc: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/staging/iio/light/tsl2583.c