aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-01-08 20:59:04 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-01-08 20:59:04 -0500
commit8ecb55b849b74dff026681b41266970072b207dd (patch)
tree0304ed3e252374adf0f5b3ec5eb0de0700a9e130 /drivers/iio
parentb7392d2247cfe6771f95d256374f1a8e6a6f48d6 (diff)
parent65de7654d39c70c2b942f801cea01590cf7e3458 (diff)
Merge tag 'iio-fixes-for-3.19a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-linus
Jonathan writes: First round of IIO fixes for the 3.19 cycle. * ad799x fix ad7991/ad7995/ad7999 setup as they do not have a configuration register to write to. It is written during the convesion sequence. As such we don't want to write to it at other times. * Fix iio_channel_read utility function to return to ensure it is apparent if the relevant element is not there. This avoids using a wrong value if some channels have the element and others do not.
Diffstat (limited to 'drivers/iio')
-rw-r--r--drivers/iio/adc/ad799x.c15
-rw-r--r--drivers/iio/inkern.c3
2 files changed, 16 insertions, 2 deletions
diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c
index e37412da15f5..b99de00e57b8 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)
143 case ad7998: 143 case ad7998:
144 return i2c_smbus_write_word_swapped(st->client, AD7998_CONF_REG, 144 return i2c_smbus_write_word_swapped(st->client, AD7998_CONF_REG,
145 val); 145 val);
146 default: 146 case ad7992:
147 case ad7993:
148 case ad7994:
147 return i2c_smbus_write_byte_data(st->client, AD7998_CONF_REG, 149 return i2c_smbus_write_byte_data(st->client, AD7998_CONF_REG,
148 val); 150 val);
151 default:
152 /* Will be written when doing a conversion */
153 st->config = val;
154 return 0;
149 } 155 }
150} 156}
151 157
@@ -155,8 +161,13 @@ static int ad799x_read_config(struct ad799x_state *st)
155 case ad7997: 161 case ad7997:
156 case ad7998: 162 case ad7998:
157 return i2c_smbus_read_word_swapped(st->client, AD7998_CONF_REG); 163 return i2c_smbus_read_word_swapped(st->client, AD7998_CONF_REG);
158 default: 164 case ad7992:
165 case ad7993:
166 case ad7994:
159 return i2c_smbus_read_byte_data(st->client, AD7998_CONF_REG); 167 return i2c_smbus_read_byte_data(st->client, AD7998_CONF_REG);
168 default:
169 /* No readback support */
170 return st->config;
160 } 171 }
161} 172}
162 173
diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index 866fe904cba2..90c8cb727cc7 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -449,6 +449,9 @@ static int iio_channel_read(struct iio_channel *chan, int *val, int *val2,
449 if (val2 == NULL) 449 if (val2 == NULL)
450 val2 = &unused; 450 val2 = &unused;
451 451
452 if(!iio_channel_has_info(chan->channel, info))
453 return -EINVAL;
454
452 if (chan->indio_dev->info->read_raw_multi) { 455 if (chan->indio_dev->info->read_raw_multi) {
453 ret = chan->indio_dev->info->read_raw_multi(chan->indio_dev, 456 ret = chan->indio_dev->info->read_raw_multi(chan->indio_dev,
454 chan->channel, INDIO_MAX_RAW_ELEMENTS, 457 chan->channel, INDIO_MAX_RAW_ELEMENTS,