Commit aecac191 authored by Michael Hennerich's avatar Michael Hennerich Committed by Greg Kroah-Hartman

staging: iio: adc: ad799x: Address iio list feedback

Address feedback from Shubhrajyoti Datta:
	Cast return value
Michael Hennerich:
	Use i2c_smbus_read_byte_data()
	Fix return value check
Signed-off-by: default avatarMichael Hennerich <michael.hennerich@analog.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent e1517c00
...@@ -65,13 +65,13 @@ static int ad799x_i2c_read8(struct ad799x_state *st, u8 reg, u8 *data) ...@@ -65,13 +65,13 @@ static int ad799x_i2c_read8(struct ad799x_state *st, u8 reg, u8 *data)
struct i2c_client *client = st->client; struct i2c_client *client = st->client;
int ret = 0; int ret = 0;
ret = i2c_smbus_read_word_data(client, reg); ret = i2c_smbus_read_byte_data(client, reg);
if (ret < 0) { if (ret < 0) {
dev_err(&client->dev, "I2C read error\n"); dev_err(&client->dev, "I2C read error\n");
return ret; return ret;
} }
*data = ret; *data = (u8)ret;
return 0; return 0;
} }
...@@ -182,11 +182,10 @@ static ssize_t ad799x_read_single_channel(struct device *dev, ...@@ -182,11 +182,10 @@ static ssize_t ad799x_read_single_channel(struct device *dev,
mask = 1 << this_attr->address; mask = 1 << this_attr->address;
/* If ring buffer capture is occuring, query the buffer */ /* If ring buffer capture is occuring, query the buffer */
if (iio_ring_enabled(dev_info)) { if (iio_ring_enabled(dev_info)) {
data = ad799x_single_channel_from_ring(st, mask); data = ret = ad799x_single_channel_from_ring(st, mask);
if (data < 0) { if (ret < 0)
ret = data;
goto error_ret; goto error_ret;
} ret = 0;
} else { } else {
switch (st->id) { switch (st->id) {
case ad7991: case ad7991:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment