From 2eacc608b3bf3519fc353c558454873f4589146d Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 26 Nov 2014 11:35:35 +0100 Subject: iio: ad799x: Fix ad7991/ad7995/ad7999 config setup The ad7991/ad7995/ad7999 does not have a configuration register like the other devices that can be written and read. The configuration is written as part of the conversion sequence. Fixes: 0f7ddcc1bff1 ("iio:adc:ad799x: Write default config on probe and reset alert status on probe") Signed-off-by: Lars-Peter Clausen Tested-by: Mike Looijmans Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ad799x.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'drivers/iio') diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c index e37412d..b99de00 100644 --- a/drivers/iio/adc/ad799x.c +++ b/drivers/iio/adc/ad799x.c @@ -143,9 +143,15 @@ static int ad799x_write_config(struct ad799x_state *st, u16 val) case ad7998: return i2c_smbus_write_word_swapped(st->client, AD7998_CONF_REG, val); - default: + case ad7992: + case ad7993: + case ad7994: return i2c_smbus_write_byte_data(st->client, AD7998_CONF_REG, val); + default: + /* Will be written when doing a conversion */ + st->config = val; + return 0; } } @@ -155,8 +161,13 @@ static int ad799x_read_config(struct ad799x_state *st) case ad7997: case ad7998: return i2c_smbus_read_word_swapped(st->client, AD7998_CONF_REG); - default: + case ad7992: + case ad7993: + case ad7994: return i2c_smbus_read_byte_data(st->client, AD7998_CONF_REG); + default: + /* No readback support */ + return st->config; } } -- cgit v1.1 From 65de7654d39c70c2b942f801cea01590cf7e3458 Mon Sep 17 00:00:00 2001 From: Fabien Proriol Date: Thu, 1 Jan 2015 12:46:48 +0000 Subject: iio: iio: Fix iio_channel_read return if channel havn't info When xilinx-xadc is used with hwmon driver to read voltage, offset used for temperature is always applied whatever the channel. iio_channel_read must return an error to avoid offset for channel without IIO_CHAN_INFO_OFFSET property. Signed-off-by: Fabien Proriol Signed-off-by: Jonathan Cameron --- drivers/iio/inkern.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/iio') diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c index f084610..d33590e 100644 --- a/drivers/iio/inkern.c +++ b/drivers/iio/inkern.c @@ -426,6 +426,9 @@ static int iio_channel_read(struct iio_channel *chan, int *val, int *val2, if (val2 == NULL) val2 = &unused; + if(!iio_channel_has_info(chan->channel, info)) + return -EINVAL; + if (chan->indio_dev->info->read_raw_multi) { ret = chan->indio_dev->info->read_raw_multi(chan->indio_dev, chan->channel, INDIO_MAX_RAW_ELEMENTS, -- cgit v1.1