Commit 924f8a21 authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Greg Kroah-Hartman

staging:iio: Do not use bitmasks for channel info addresses

Currently the iio framework uses bitmasks for the address field of channel info
attributes. This is for historical reasons and no longer required since it will
only ever query a single info attribute at once. This patch changes the code to
use the non-shifted iio_chan_info_enum values for the info attribute address.
Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: default avatarJonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 3014cd97
...@@ -322,8 +322,8 @@ static int adis16201_read_raw(struct iio_dev *indio_dev, ...@@ -322,8 +322,8 @@ static int adis16201_read_raw(struct iio_dev *indio_dev,
*val = val16; *val = val16;
mutex_unlock(&indio_dev->mlock); mutex_unlock(&indio_dev->mlock);
return IIO_VAL_INT; return IIO_VAL_INT;
case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): case IIO_CHAN_INFO_SCALE_SEPARATE:
case (1 << IIO_CHAN_INFO_SCALE_SHARED): case IIO_CHAN_INFO_SCALE_SHARED:
switch (chan->type) { switch (chan->type) {
case IIO_VOLTAGE: case IIO_VOLTAGE:
*val = 0; *val = 0;
...@@ -348,10 +348,10 @@ static int adis16201_read_raw(struct iio_dev *indio_dev, ...@@ -348,10 +348,10 @@ static int adis16201_read_raw(struct iio_dev *indio_dev,
return -EINVAL; return -EINVAL;
} }
break; break;
case (1 << IIO_CHAN_INFO_OFFSET_SEPARATE): case IIO_CHAN_INFO_OFFSET_SEPARATE:
*val = 25; *val = 25;
return IIO_VAL_INT; return IIO_VAL_INT;
case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE): case IIO_CHAN_INFO_CALIBBIAS_SEPARATE:
switch (chan->type) { switch (chan->type) {
case IIO_ACCEL: case IIO_ACCEL:
bits = 12; bits = 12;
...@@ -388,7 +388,7 @@ static int adis16201_write_raw(struct iio_dev *indio_dev, ...@@ -388,7 +388,7 @@ static int adis16201_write_raw(struct iio_dev *indio_dev,
s16 val16; s16 val16;
u8 addr; u8 addr;
switch (mask) { switch (mask) {
case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE): case IIO_CHAN_INFO_CALIBBIAS_SEPARATE:
switch (chan->type) { switch (chan->type) {
case IIO_ACCEL: case IIO_ACCEL:
bits = 12; bits = 12;
......
...@@ -329,8 +329,8 @@ static int adis16203_read_raw(struct iio_dev *indio_dev, ...@@ -329,8 +329,8 @@ static int adis16203_read_raw(struct iio_dev *indio_dev,
*val = val16; *val = val16;
mutex_unlock(&indio_dev->mlock); mutex_unlock(&indio_dev->mlock);
return IIO_VAL_INT; return IIO_VAL_INT;
case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): case IIO_CHAN_INFO_SCALE_SEPARATE:
case (1 << IIO_CHAN_INFO_SCALE_SHARED): case IIO_CHAN_INFO_SCALE_SHARED:
switch (chan->type) { switch (chan->type) {
case IIO_VOLTAGE: case IIO_VOLTAGE:
*val = 0; *val = 0;
...@@ -350,10 +350,10 @@ static int adis16203_read_raw(struct iio_dev *indio_dev, ...@@ -350,10 +350,10 @@ static int adis16203_read_raw(struct iio_dev *indio_dev,
default: default:
return -EINVAL; return -EINVAL;
} }
case (1 << IIO_CHAN_INFO_OFFSET_SEPARATE): case IIO_CHAN_INFO_OFFSET_SEPARATE:
*val = 25; *val = 25;
return IIO_VAL_INT; return IIO_VAL_INT;
case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE): case IIO_CHAN_INFO_CALIBBIAS_SEPARATE:
bits = 14; bits = 14;
mutex_lock(&indio_dev->mlock); mutex_lock(&indio_dev->mlock);
addr = adis16203_addresses[chan->address][1]; addr = adis16203_addresses[chan->address][1];
......
...@@ -366,7 +366,7 @@ static int adis16204_read_raw(struct iio_dev *indio_dev, ...@@ -366,7 +366,7 @@ static int adis16204_read_raw(struct iio_dev *indio_dev,
*val = val16; *val = val16;
mutex_unlock(&indio_dev->mlock); mutex_unlock(&indio_dev->mlock);
return IIO_VAL_INT; return IIO_VAL_INT;
case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): case IIO_CHAN_INFO_SCALE_SEPARATE:
switch (chan->type) { switch (chan->type) {
case IIO_VOLTAGE: case IIO_VOLTAGE:
*val = 0; *val = 0;
...@@ -390,12 +390,12 @@ static int adis16204_read_raw(struct iio_dev *indio_dev, ...@@ -390,12 +390,12 @@ static int adis16204_read_raw(struct iio_dev *indio_dev,
return -EINVAL; return -EINVAL;
} }
break; break;
case (1 << IIO_CHAN_INFO_OFFSET_SEPARATE): case IIO_CHAN_INFO_OFFSET_SEPARATE:
*val = 25; *val = 25;
return IIO_VAL_INT; return IIO_VAL_INT;
case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE): case IIO_CHAN_INFO_CALIBBIAS_SEPARATE:
case (1 << IIO_CHAN_INFO_PEAK_SEPARATE): case IIO_CHAN_INFO_PEAK_SEPARATE:
if (mask == (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE)) { if (mask == IIO_CHAN_INFO_CALIBBIAS_SEPARATE) {
bits = 12; bits = 12;
addrind = 1; addrind = 1;
} else { /* PEAK_SEPARATE */ } else { /* PEAK_SEPARATE */
...@@ -428,7 +428,7 @@ static int adis16204_write_raw(struct iio_dev *indio_dev, ...@@ -428,7 +428,7 @@ static int adis16204_write_raw(struct iio_dev *indio_dev,
s16 val16; s16 val16;
u8 addr; u8 addr;
switch (mask) { switch (mask) {
case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE): case IIO_CHAN_INFO_CALIBBIAS_SEPARATE:
switch (chan->type) { switch (chan->type) {
case IIO_ACCEL: case IIO_ACCEL:
bits = 12; bits = 12;
......
...@@ -304,7 +304,7 @@ static int adis16209_write_raw(struct iio_dev *indio_dev, ...@@ -304,7 +304,7 @@ static int adis16209_write_raw(struct iio_dev *indio_dev,
s16 val16; s16 val16;
u8 addr; u8 addr;
switch (mask) { switch (mask) {
case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE): case IIO_CHAN_INFO_CALIBBIAS_SEPARATE:
switch (chan->type) { switch (chan->type) {
case IIO_ACCEL: case IIO_ACCEL:
case IIO_INCLI: case IIO_INCLI:
...@@ -355,8 +355,8 @@ static int adis16209_read_raw(struct iio_dev *indio_dev, ...@@ -355,8 +355,8 @@ static int adis16209_read_raw(struct iio_dev *indio_dev,
*val = val16; *val = val16;
mutex_unlock(&indio_dev->mlock); mutex_unlock(&indio_dev->mlock);
return IIO_VAL_INT; return IIO_VAL_INT;
case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): case IIO_CHAN_INFO_SCALE_SEPARATE:
case (1 << IIO_CHAN_INFO_SCALE_SHARED): case IIO_CHAN_INFO_SCALE_SHARED:
switch (chan->type) { switch (chan->type) {
case IIO_VOLTAGE: case IIO_VOLTAGE:
*val = 0; *val = 0;
...@@ -381,10 +381,10 @@ static int adis16209_read_raw(struct iio_dev *indio_dev, ...@@ -381,10 +381,10 @@ static int adis16209_read_raw(struct iio_dev *indio_dev,
return -EINVAL; return -EINVAL;
} }
break; break;
case (1 << IIO_CHAN_INFO_OFFSET_SEPARATE): case IIO_CHAN_INFO_OFFSET_SEPARATE:
*val = 25; *val = 25;
return IIO_VAL_INT; return IIO_VAL_INT;
case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE): case IIO_CHAN_INFO_CALIBBIAS_SEPARATE:
switch (chan->type) { switch (chan->type) {
case IIO_ACCEL: case IIO_ACCEL:
bits = 14; bits = 14;
......
...@@ -510,17 +510,17 @@ static int adis16220_read_raw(struct iio_dev *indio_dev, ...@@ -510,17 +510,17 @@ static int adis16220_read_raw(struct iio_dev *indio_dev,
case 0: case 0:
addrind = 0; addrind = 0;
break; break;
case (1 << IIO_CHAN_INFO_OFFSET_SEPARATE): case IIO_CHAN_INFO_OFFSET_SEPARATE:
if (chan->type == IIO_TEMP) { if (chan->type == IIO_TEMP) {
*val = 25; *val = 25;
return IIO_VAL_INT; return IIO_VAL_INT;
} }
addrind = 1; addrind = 1;
break; break;
case (1 << IIO_CHAN_INFO_PEAK_SEPARATE): case IIO_CHAN_INFO_PEAK_SEPARATE:
addrind = 2; addrind = 2;
break; break;
case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): case IIO_CHAN_INFO_SCALE_SEPARATE:
*val = 0; *val = 0;
switch (chan->type) { switch (chan->type) {
case IIO_TEMP: case IIO_TEMP:
......
...@@ -389,8 +389,8 @@ static int adis16240_read_raw(struct iio_dev *indio_dev, ...@@ -389,8 +389,8 @@ static int adis16240_read_raw(struct iio_dev *indio_dev,
*val = val16; *val = val16;
mutex_unlock(&indio_dev->mlock); mutex_unlock(&indio_dev->mlock);
return IIO_VAL_INT; return IIO_VAL_INT;
case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): case IIO_CHAN_INFO_SCALE_SEPARATE:
case (1 << IIO_CHAN_INFO_SCALE_SHARED): case IIO_CHAN_INFO_SCALE_SHARED:
switch (chan->type) { switch (chan->type) {
case IIO_VOLTAGE: case IIO_VOLTAGE:
*val = 0; *val = 0;
...@@ -411,14 +411,14 @@ static int adis16240_read_raw(struct iio_dev *indio_dev, ...@@ -411,14 +411,14 @@ static int adis16240_read_raw(struct iio_dev *indio_dev,
return -EINVAL; return -EINVAL;
} }
break; break;
case (1 << IIO_CHAN_INFO_PEAK_SCALE_SHARED): case IIO_CHAN_INFO_PEAK_SCALE_SHARED:
*val = 6; *val = 6;
*val2 = 629295; *val2 = 629295;
return IIO_VAL_INT_PLUS_MICRO; return IIO_VAL_INT_PLUS_MICRO;
case (1 << IIO_CHAN_INFO_OFFSET_SEPARATE): case IIO_CHAN_INFO_OFFSET_SEPARATE:
*val = 25; *val = 25;
return IIO_VAL_INT; return IIO_VAL_INT;
case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE): case IIO_CHAN_INFO_CALIBBIAS_SEPARATE:
bits = 10; bits = 10;
mutex_lock(&indio_dev->mlock); mutex_lock(&indio_dev->mlock);
addr = adis16240_addresses[chan->address][1]; addr = adis16240_addresses[chan->address][1];
...@@ -432,7 +432,7 @@ static int adis16240_read_raw(struct iio_dev *indio_dev, ...@@ -432,7 +432,7 @@ static int adis16240_read_raw(struct iio_dev *indio_dev,
*val = val16; *val = val16;
mutex_unlock(&indio_dev->mlock); mutex_unlock(&indio_dev->mlock);
return IIO_VAL_INT; return IIO_VAL_INT;
case (1 << IIO_CHAN_INFO_PEAK_SEPARATE): case IIO_CHAN_INFO_PEAK_SEPARATE:
bits = 10; bits = 10;
mutex_lock(&indio_dev->mlock); mutex_lock(&indio_dev->mlock);
addr = adis16240_addresses[chan->address][2]; addr = adis16240_addresses[chan->address][2];
...@@ -460,7 +460,7 @@ static int adis16240_write_raw(struct iio_dev *indio_dev, ...@@ -460,7 +460,7 @@ static int adis16240_write_raw(struct iio_dev *indio_dev,
s16 val16; s16 val16;
u8 addr; u8 addr;
switch (mask) { switch (mask) {
case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE): case IIO_CHAN_INFO_CALIBBIAS_SEPARATE:
val16 = val & ((1 << bits) - 1); val16 = val & ((1 << bits) - 1);
addr = adis16240_addresses[chan->address][1]; addr = adis16240_addresses[chan->address][1];
return adis16240_spi_write_reg_16(indio_dev, addr, val16); return adis16240_spi_write_reg_16(indio_dev, addr, val16);
......
...@@ -140,7 +140,7 @@ static int kxsd9_write_raw(struct iio_dev *indio_dev, ...@@ -140,7 +140,7 @@ static int kxsd9_write_raw(struct iio_dev *indio_dev,
{ {
int ret = -EINVAL; int ret = -EINVAL;
if (mask == (1 << IIO_CHAN_INFO_SCALE_SHARED)) { if (mask == IIO_CHAN_INFO_SCALE_SHARED) {
/* Check no integer component */ /* Check no integer component */
if (val) if (val)
return -EINVAL; return -EINVAL;
...@@ -164,7 +164,7 @@ static int kxsd9_read_raw(struct iio_dev *indio_dev, ...@@ -164,7 +164,7 @@ static int kxsd9_read_raw(struct iio_dev *indio_dev,
goto error_ret; goto error_ret;
*val = ret; *val = ret;
break; break;
case (1 << IIO_CHAN_INFO_SCALE_SHARED): case IIO_CHAN_INFO_SCALE_SHARED:
ret = spi_w8r8(st->us, KXSD9_READ(KXSD9_REG_CTRL_C)); ret = spi_w8r8(st->us, KXSD9_READ(KXSD9_REG_CTRL_C));
if (ret) if (ret)
goto error_ret; goto error_ret;
......
...@@ -227,14 +227,14 @@ static int lis3l02dq_write_raw(struct iio_dev *indio_dev, ...@@ -227,14 +227,14 @@ static int lis3l02dq_write_raw(struct iio_dev *indio_dev,
u8 uval; u8 uval;
s8 sval; s8 sval;
switch (mask) { switch (mask) {
case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE): case IIO_CHAN_INFO_CALIBBIAS_SEPARATE:
if (val > 255 || val < -256) if (val > 255 || val < -256)
return -EINVAL; return -EINVAL;
sval = val; sval = val;
reg = lis3l02dq_axis_map[LIS3L02DQ_BIAS][chan->address]; reg = lis3l02dq_axis_map[LIS3L02DQ_BIAS][chan->address];
ret = lis3l02dq_spi_write_reg_8(indio_dev, reg, sval); ret = lis3l02dq_spi_write_reg_8(indio_dev, reg, sval);
break; break;
case (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE): case IIO_CHAN_INFO_CALIBSCALE_SEPARATE:
if (val & ~0xFF) if (val & ~0xFF)
return -EINVAL; return -EINVAL;
uval = val; uval = val;
...@@ -272,11 +272,11 @@ static int lis3l02dq_read_raw(struct iio_dev *indio_dev, ...@@ -272,11 +272,11 @@ static int lis3l02dq_read_raw(struct iio_dev *indio_dev,
} }
mutex_unlock(&indio_dev->mlock); mutex_unlock(&indio_dev->mlock);
return IIO_VAL_INT; return IIO_VAL_INT;
case (1 << IIO_CHAN_INFO_SCALE_SHARED): case IIO_CHAN_INFO_SCALE_SHARED:
*val = 0; *val = 0;
*val2 = 9580; *val2 = 9580;
return IIO_VAL_INT_PLUS_MICRO; return IIO_VAL_INT_PLUS_MICRO;
case (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE): case IIO_CHAN_INFO_CALIBSCALE_SEPARATE:
reg = lis3l02dq_axis_map[LIS3L02DQ_GAIN][chan->address]; reg = lis3l02dq_axis_map[LIS3L02DQ_GAIN][chan->address];
ret = lis3l02dq_spi_read_reg_8(indio_dev, reg, &utemp); ret = lis3l02dq_spi_read_reg_8(indio_dev, reg, &utemp);
if (ret) if (ret)
...@@ -285,7 +285,7 @@ static int lis3l02dq_read_raw(struct iio_dev *indio_dev, ...@@ -285,7 +285,7 @@ static int lis3l02dq_read_raw(struct iio_dev *indio_dev,
*val = utemp; *val = utemp;
return IIO_VAL_INT; return IIO_VAL_INT;
case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE): case IIO_CHAN_INFO_CALIBBIAS_SEPARATE:
reg = lis3l02dq_axis_map[LIS3L02DQ_BIAS][chan->address]; reg = lis3l02dq_axis_map[LIS3L02DQ_BIAS][chan->address];
ret = lis3l02dq_spi_read_reg_8(indio_dev, reg, (u8 *)&stemp); ret = lis3l02dq_spi_read_reg_8(indio_dev, reg, (u8 *)&stemp);
/* to match with what previous code does */ /* to match with what previous code does */
......
...@@ -475,7 +475,7 @@ static int sca3000_read_raw(struct iio_dev *indio_dev, ...@@ -475,7 +475,7 @@ static int sca3000_read_raw(struct iio_dev *indio_dev,
(sizeof(*val)*8 - 13); (sizeof(*val)*8 - 13);
mutex_unlock(&st->lock); mutex_unlock(&st->lock);
return IIO_VAL_INT; return IIO_VAL_INT;
case (1 << IIO_CHAN_INFO_SCALE_SHARED): case IIO_CHAN_INFO_SCALE_SHARED:
*val = 0; *val = 0;
if (chan->type == IIO_ACCEL) if (chan->type == IIO_ACCEL)
*val2 = st->info->scale; *val2 = st->info->scale;
......
...@@ -901,7 +901,7 @@ static int ad7192_read_raw(struct iio_dev *indio_dev, ...@@ -901,7 +901,7 @@ static int ad7192_read_raw(struct iio_dev *indio_dev,
} }
return IIO_VAL_INT; return IIO_VAL_INT;
case (1 << IIO_CHAN_INFO_SCALE_SHARED): case IIO_CHAN_INFO_SCALE_SHARED:
mutex_lock(&indio_dev->mlock); mutex_lock(&indio_dev->mlock);
*val = st->scale_avail[AD7192_CONF_GAIN(st->conf)][0]; *val = st->scale_avail[AD7192_CONF_GAIN(st->conf)][0];
*val2 = st->scale_avail[AD7192_CONF_GAIN(st->conf)][1]; *val2 = st->scale_avail[AD7192_CONF_GAIN(st->conf)][1];
...@@ -909,7 +909,7 @@ static int ad7192_read_raw(struct iio_dev *indio_dev, ...@@ -909,7 +909,7 @@ static int ad7192_read_raw(struct iio_dev *indio_dev,
return IIO_VAL_INT_PLUS_NANO; return IIO_VAL_INT_PLUS_NANO;
case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): case IIO_CHAN_INFO_SCALE_SEPARATE:
*val = 1000; *val = 1000;
return IIO_VAL_INT; return IIO_VAL_INT;
...@@ -935,7 +935,7 @@ static int ad7192_write_raw(struct iio_dev *indio_dev, ...@@ -935,7 +935,7 @@ static int ad7192_write_raw(struct iio_dev *indio_dev,
} }
switch (mask) { switch (mask) {
case (1 << IIO_CHAN_INFO_SCALE_SHARED): case IIO_CHAN_INFO_SCALE_SHARED:
ret = -EINVAL; ret = -EINVAL;
for (i = 0; i < ARRAY_SIZE(st->scale_avail); i++) for (i = 0; i < ARRAY_SIZE(st->scale_avail); i++)
if (val2 == st->scale_avail[i][1]) { if (val2 == st->scale_avail[i][1]) {
......
...@@ -803,7 +803,7 @@ static int ad7280_read_raw(struct iio_dev *indio_dev, ...@@ -803,7 +803,7 @@ static int ad7280_read_raw(struct iio_dev *indio_dev,
*val = ret; *val = ret;
return IIO_VAL_INT; return IIO_VAL_INT;
case (1 << IIO_CHAN_INFO_SCALE_SHARED): case IIO_CHAN_INFO_SCALE_SHARED:
if ((chan->address & 0xFF) <= AD7280A_CELL_VOLTAGE_6) if ((chan->address & 0xFF) <= AD7280A_CELL_VOLTAGE_6)
scale_uv = (4000 * 1000) >> AD7280A_BITS; scale_uv = (4000 * 1000) >> AD7280A_BITS;
else else
......
...@@ -501,7 +501,7 @@ static int ad7291_read_raw(struct iio_dev *indio_dev, ...@@ -501,7 +501,7 @@ static int ad7291_read_raw(struct iio_dev *indio_dev,
default: default:
return -EINVAL; return -EINVAL;
} }
case (1 << IIO_CHAN_INFO_AVERAGE_RAW_SEPARATE): case IIO_CHAN_INFO_AVERAGE_RAW_SEPARATE:
ret = i2c_smbus_read_word_data(chip->client, ret = i2c_smbus_read_word_data(chip->client,
AD7291_T_AVERAGE); AD7291_T_AVERAGE);
if (ret < 0) if (ret < 0)
...@@ -510,12 +510,12 @@ static int ad7291_read_raw(struct iio_dev *indio_dev, ...@@ -510,12 +510,12 @@ static int ad7291_read_raw(struct iio_dev *indio_dev,
AD7291_VALUE_MASK) << 4) >> 4; AD7291_VALUE_MASK) << 4) >> 4;
*val = signval; *val = signval;
return IIO_VAL_INT; return IIO_VAL_INT;
case (1 << IIO_CHAN_INFO_SCALE_SHARED): case IIO_CHAN_INFO_SCALE_SHARED:
scale_uv = (chip->int_vref_mv * 1000) >> AD7291_BITS; scale_uv = (chip->int_vref_mv * 1000) >> AD7291_BITS;
*val = scale_uv / 1000; *val = scale_uv / 1000;
*val2 = (scale_uv % 1000) * 1000; *val2 = (scale_uv % 1000) * 1000;
return IIO_VAL_INT_PLUS_MICRO; return IIO_VAL_INT_PLUS_MICRO;
case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): case IIO_CHAN_INFO_SCALE_SEPARATE:
/* /*
* One LSB of the ADC corresponds to 0.25 deg C. * One LSB of the ADC corresponds to 0.25 deg C.
* The temperature reading is in 12-bit twos complement format * The temperature reading is in 12-bit twos complement format
......
...@@ -143,12 +143,12 @@ static int ad7298_read_raw(struct iio_dev *indio_dev, ...@@ -143,12 +143,12 @@ static int ad7298_read_raw(struct iio_dev *indio_dev,
*val = ret & RES_MASK(AD7298_BITS); *val = ret & RES_MASK(AD7298_BITS);
return IIO_VAL_INT; return IIO_VAL_INT;
case (1 << IIO_CHAN_INFO_SCALE_SHARED): case IIO_CHAN_INFO_SCALE_SHARED:
scale_uv = (st->int_vref_mv * 1000) >> AD7298_BITS; scale_uv = (st->int_vref_mv * 1000) >> AD7298_BITS;
*val = scale_uv / 1000; *val = scale_uv / 1000;
*val2 = (scale_uv % 1000) * 1000; *val2 = (scale_uv % 1000) * 1000;
return IIO_VAL_INT_PLUS_MICRO; return IIO_VAL_INT_PLUS_MICRO;
case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): case IIO_CHAN_INFO_SCALE_SEPARATE:
*val = 1; *val = 1;
*val2 = 0; *val2 = 0;
return IIO_VAL_INT_PLUS_MICRO; return IIO_VAL_INT_PLUS_MICRO;
......
...@@ -56,7 +56,7 @@ static int ad7476_read_raw(struct iio_dev *indio_dev, ...@@ -56,7 +56,7 @@ static int ad7476_read_raw(struct iio_dev *indio_dev,
*val = (ret >> st->chip_info->channel[0].scan_type.shift) & *val = (ret >> st->chip_info->channel[0].scan_type.shift) &
RES_MASK(st->chip_info->channel[0].scan_type.realbits); RES_MASK(st->chip_info->channel[0].scan_type.realbits);
return IIO_VAL_INT; return IIO_VAL_INT;
case (1 << IIO_CHAN_INFO_SCALE_SHARED): case IIO_CHAN_INFO_SCALE_SHARED:
scale_uv = (st->int_vref_mv * 1000) scale_uv = (st->int_vref_mv * 1000)
>> st->chip_info->channel[0].scan_type.realbits; >> st->chip_info->channel[0].scan_type.realbits;
*val = scale_uv/1000; *val = scale_uv/1000;
......
...@@ -100,7 +100,7 @@ static int ad7606_read_raw(struct iio_dev *indio_dev, ...@@ -100,7 +100,7 @@ static int ad7606_read_raw(struct iio_dev *indio_dev,
return ret; return ret;
*val = (short) ret; *val = (short) ret;
return IIO_VAL_INT; return IIO_VAL_INT;
case (1 << IIO_CHAN_INFO_SCALE_SHARED): case IIO_CHAN_INFO_SCALE_SHARED:
scale_uv = (st->range * 1000 * 2) scale_uv = (st->range * 1000 * 2)
>> st->chip_info->channels[0].scan_type.realbits; >> st->chip_info->channels[0].scan_type.realbits;
*val = scale_uv / 1000; *val = scale_uv / 1000;
......
...@@ -114,7 +114,7 @@ static int ad7780_read_raw(struct iio_dev *indio_dev, ...@@ -114,7 +114,7 @@ static int ad7780_read_raw(struct iio_dev *indio_dev,
*val *= 128; *val *= 128;
return IIO_VAL_INT; return IIO_VAL_INT;
case (1 << IIO_CHAN_INFO_SCALE_SHARED): case IIO_CHAN_INFO_SCALE_SHARED:
scale_uv = (st->int_vref_mv * 100000) scale_uv = (st->int_vref_mv * 100000)
>> (channel.scan_type.realbits - 1); >> (channel.scan_type.realbits - 1);
*val = scale_uv / 100000; *val = scale_uv / 100000;
......
...@@ -667,13 +667,13 @@ static int ad7793_read_raw(struct iio_dev *indio_dev, ...@@ -667,13 +667,13 @@ static int ad7793_read_raw(struct iio_dev *indio_dev,
return IIO_VAL_INT; return IIO_VAL_INT;
case (1 << IIO_CHAN_INFO_SCALE_SHARED): case IIO_CHAN_INFO_SCALE_SHARED:
*val = st->scale_avail[(st->conf >> 8) & 0x7][0]; *val = st->scale_avail[(st->conf >> 8) & 0x7][0];
*val2 = st->scale_avail[(st->conf >> 8) & 0x7][1]; *val2 = st->scale_avail[(st->conf >> 8) & 0x7][1];
return IIO_VAL_INT_PLUS_NANO; return IIO_VAL_INT_PLUS_NANO;
case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): case IIO_CHAN_INFO_SCALE_SEPARATE:
switch (chan->type) { switch (chan->type) {
case IIO_VOLTAGE: case IIO_VOLTAGE:
/* 1170mV / 2^23 * 6 */ /* 1170mV / 2^23 * 6 */
...@@ -716,7 +716,7 @@ static int ad7793_write_raw(struct iio_dev *indio_dev, ...@@ -716,7 +716,7 @@ static int ad7793_write_raw(struct iio_dev *indio_dev,
} }
switch (mask) { switch (mask) {
case (1 << IIO_CHAN_INFO_SCALE_SHARED): case IIO_CHAN_INFO_SCALE_SHARED:
ret = -EINVAL; ret = -EINVAL;
for (i = 0; i < ARRAY_SIZE(st->scale_avail); i++) for (i = 0; i < ARRAY_SIZE(st->scale_avail); i++)
if (val2 == st->scale_avail[i][1]) { if (val2 == st->scale_avail[i][1]) {
......
...@@ -55,7 +55,7 @@ static int ad7887_read_raw(struct iio_dev *indio_dev, ...@@ -55,7 +55,7 @@ static int ad7887_read_raw(struct iio_dev *indio_dev,
*val = (ret >> st->chip_info->channel[0].scan_type.shift) & *val = (ret >> st->chip_info->channel[0].scan_type.shift) &
RES_MASK(st->chip_info->channel[0].scan_type.realbits); RES_MASK(st->chip_info->channel[0].scan_type.realbits);
return IIO_VAL_INT; return IIO_VAL_INT;
case (1 << IIO_CHAN_INFO_SCALE_SHARED): case IIO_CHAN_INFO_SCALE_SHARED:
scale_uv = (st->int_vref_mv * 1000) scale_uv = (st->int_vref_mv * 1000)
>> st->chip_info->channel[0].scan_type.realbits; >> st->chip_info->channel[0].scan_type.realbits;
*val = scale_uv/1000; *val = scale_uv/1000;
......
...@@ -162,7 +162,7 @@ static int ad799x_read_raw(struct iio_dev *indio_dev, ...@@ -162,7 +162,7 @@ static int ad799x_read_raw(struct iio_dev *indio_dev,
*val = (ret >> chan->scan_type.shift) & *val = (ret >> chan->scan_type.shift) &
RES_MASK(chan->scan_type.realbits); RES_MASK(chan->scan_type.realbits);
return IIO_VAL_INT; return IIO_VAL_INT;
case (1 << IIO_CHAN_INFO_SCALE_SHARED): case IIO_CHAN_INFO_SCALE_SHARED:
scale_uv = (st->int_vref_mv * 1000) >> chan->scan_type.realbits; scale_uv = (st->int_vref_mv * 1000) >> chan->scan_type.realbits;
*val = scale_uv / 1000; *val = scale_uv / 1000;
*val2 = (scale_uv % 1000) * 1000; *val2 = (scale_uv % 1000) * 1000;
......
...@@ -261,7 +261,7 @@ static int max1363_read_raw(struct iio_dev *indio_dev, ...@@ -261,7 +261,7 @@ static int max1363_read_raw(struct iio_dev *indio_dev,
if (ret < 0) if (ret < 0)
return ret; return ret;
return IIO_VAL_INT; return IIO_VAL_INT;
case (1 << IIO_CHAN_INFO_SCALE_SHARED): case IIO_CHAN_INFO_SCALE_SHARED:
if ((1 << (st->chip_info->bits + 1)) > if ((1 << (st->chip_info->bits + 1)) >
st->chip_info->int_vref_mv) { st->chip_info->int_vref_mv) {
*val = 0; *val = 0;
......
...@@ -111,7 +111,7 @@ static int ad7150_read_raw(struct iio_dev *indio_dev, ...@@ -111,7 +111,7 @@ static int ad7150_read_raw(struct iio_dev *indio_dev,
return ret; return ret;
*val = swab16(ret); *val = swab16(ret);
return IIO_VAL_INT; return IIO_VAL_INT;
case (1 << IIO_CHAN_INFO_AVERAGE_RAW_SEPARATE): case IIO_CHAN_INFO_AVERAGE_RAW_SEPARATE:
ret = i2c_smbus_read_word_data(chip->client, ret = i2c_smbus_read_word_data(chip->client,
ad7150_addresses[chan->channel][1]); ad7150_addresses[chan->channel][1]);
if (ret < 0) if (ret < 0)
......
...@@ -259,7 +259,7 @@ static int ad7152_write_raw(struct iio_dev *indio_dev, ...@@ -259,7 +259,7 @@ static int ad7152_write_raw(struct iio_dev *indio_dev,
mutex_lock(&indio_dev->mlock); mutex_lock(&indio_dev->mlock);
switch (mask) { switch (mask) {
case (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE): case IIO_CHAN_INFO_CALIBSCALE_SEPARATE:
if (val != 1) { if (val != 1) {
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
...@@ -276,7 +276,7 @@ static int ad7152_write_raw(struct iio_dev *indio_dev, ...@@ -276,7 +276,7 @@ static int ad7152_write_raw(struct iio_dev *indio_dev,
ret = 0; ret = 0;
break; break;
case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE): case IIO_CHAN_INFO_CALIBBIAS_SEPARATE:
if ((val < 0) | (val > 0xFFFF)) { if ((val < 0) | (val > 0xFFFF)) {
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
...@@ -289,7 +289,7 @@ static int ad7152_write_raw(struct iio_dev *indio_dev, ...@@ -289,7 +289,7 @@ static int ad7152_write_raw(struct iio_dev *indio_dev,
ret = 0; ret = 0;
break; break;
case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): case IIO_CHAN_INFO_SCALE_SEPARATE:
if (val != 0) { if (val != 0) {
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
...@@ -372,7 +372,7 @@ static int ad7152_read_raw(struct iio_dev *indio_dev, ...@@ -372,7 +372,7 @@ static int ad7152_read_raw(struct iio_dev *indio_dev,
ret = IIO_VAL_INT; ret = IIO_VAL_INT;
break; break;
case (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE): case IIO_CHAN_INFO_CALIBSCALE_SEPARATE:
ret = i2c_smbus_read_word_data(chip->client, ret = i2c_smbus_read_word_data(chip->client,
ad7152_addresses[chan->channel][AD7152_GAIN]); ad7152_addresses[chan->channel][AD7152_GAIN]);
...@@ -384,7 +384,7 @@ static int ad7152_read_raw(struct iio_dev *indio_dev, ...@@ -384,7 +384,7 @@ static int ad7152_read_raw(struct iio_dev *indio_dev,
ret = IIO_VAL_INT_PLUS_MICRO; ret = IIO_VAL_INT_PLUS_MICRO;
break; break;
case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE): case IIO_CHAN_INFO_CALIBBIAS_SEPARATE:
ret = i2c_smbus_read_word_data(chip->client, ret = i2c_smbus_read_word_data(chip->client,
ad7152_addresses[chan->channel][AD7152_OFFS]); ad7152_addresses[chan->channel][AD7152_OFFS]);
if (ret < 0) if (ret < 0)
...@@ -393,7 +393,7 @@ static int ad7152_read_raw(struct iio_dev *indio_dev, ...@@ -393,7 +393,7 @@ static int ad7152_read_raw(struct iio_dev *indio_dev,
ret = IIO_VAL_INT; ret = IIO_VAL_INT;
break; break;
case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): case IIO_CHAN_INFO_SCALE_SEPARATE:
ret = i2c_smbus_read_byte_data(chip->client, ret = i2c_smbus_read_byte_data(chip->client,
ad7152_addresses[chan->channel][AD7152_SETUP]); ad7152_addresses[chan->channel][AD7152_SETUP]);
if (ret < 0) if (ret < 0)
...@@ -416,7 +416,7 @@ static int ad7152_write_raw_get_fmt(struct iio_dev *indio_dev, ...@@ -416,7 +416,7 @@ static int ad7152_write_raw_get_fmt(struct iio_dev *indio_dev,
long mask) long mask)
{ {
switch (mask) { switch (mask) {
case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): case IIO_CHAN_INFO_SCALE_SEPARATE:
return IIO_VAL_INT_PLUS_NANO; return IIO_VAL_INT_PLUS_NANO;
default: default:
return IIO_VAL_INT_PLUS_MICRO; return IIO_VAL_INT_PLUS_MICRO;
......
...@@ -477,7 +477,7 @@ static int ad7746_write_raw(struct iio_dev *indio_dev, ...@@ -477,7 +477,7 @@ static int ad7746_write_raw(struct iio_dev *indio_dev,
mutex_lock(&indio_dev->mlock); mutex_lock(&indio_dev->mlock);
switch (mask) { switch (mask) {
case (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE): case IIO_CHAN_INFO_CALIBSCALE_SEPARATE:
if (val != 1) { if (val != 1) {
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
...@@ -503,7 +503,7 @@ static int ad7746_write_raw(struct iio_dev *indio_dev, ...@@ -503,7 +503,7 @@ static int ad7746_write_raw(struct iio_dev *indio_dev,
ret = 0; ret = 0;
break; break;
case (1 << IIO_CHAN_INFO_CALIBBIAS_SHARED): case IIO_CHAN_INFO_CALIBBIAS_SHARED:
if ((val < 0) | (val > 0xFFFF)) { if ((val < 0) | (val > 0xFFFF)) {
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
...@@ -515,7 +515,7 @@ static int ad7746_write_raw(struct iio_dev *indio_dev, ...@@ -515,7 +515,7 @@ static int ad7746_write_raw(struct iio_dev *indio_dev,
ret = 0; ret = 0;
break; break;
case (1 << IIO_CHAN_INFO_OFFSET_SEPARATE): case IIO_CHAN_INFO_OFFSET_SEPARATE:
if ((val < 0) | (val > 43008000)) { /* 21pF */ if ((val < 0) | (val > 43008000)) { /* 21pF */
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
...@@ -612,7 +612,7 @@ static int ad7746_read_raw(struct iio_dev *indio_dev, ...@@ -612,7 +612,7 @@ static int ad7746_read_raw(struct iio_dev *indio_dev,
ret = IIO_VAL_INT; ret = IIO_VAL_INT;
break; break;
case (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE): case IIO_CHAN_INFO_CALIBSCALE_SEPARATE:
switch (chan->type) { switch (chan->type) {
case IIO_CAPACITANCE: case IIO_CAPACITANCE:
reg = AD7746_REG_CAP_GAINH; reg = AD7746_REG_CAP_GAINH;
...@@ -634,7 +634,7 @@ static int ad7746_read_raw(struct iio_dev *indio_dev, ...@@ -634,7 +634,7 @@ static int ad7746_read_raw(struct iio_dev *indio_dev,
ret = IIO_VAL_INT_PLUS_MICRO; ret = IIO_VAL_INT_PLUS_MICRO;
break; break;
case (1 << IIO_CHAN_INFO_CALIBBIAS_SHARED): case IIO_CHAN_INFO_CALIBBIAS_SHARED:
ret = i2c_smbus_read_word_data(chip->client, ret = i2c_smbus_read_word_data(chip->client,
AD7746_REG_CAP_OFFH); AD7746_REG_CAP_OFFH);
if (ret < 0) if (ret < 0)
...@@ -643,13 +643,13 @@ static int ad7746_read_raw(struct iio_dev *indio_dev, ...@@ -643,13 +643,13 @@ static int ad7746_read_raw(struct iio_dev *indio_dev,
ret = IIO_VAL_INT; ret = IIO_VAL_INT;
break; break;
case (1 << IIO_CHAN_INFO_OFFSET_SEPARATE): case IIO_CHAN_INFO_OFFSET_SEPARATE:
*val = AD7746_CAPDAC_DACP(chip->capdac[chan->channel] *val = AD7746_CAPDAC_DACP(chip->capdac[chan->channel]
[chan->differential]) * 338646; [chan->differential]) * 338646;
ret = IIO_VAL_INT; ret = IIO_VAL_INT;
break; break;
case (1 << IIO_CHAN_INFO_SCALE_SHARED): case IIO_CHAN_INFO_SCALE_SHARED:
switch (chan->type) { switch (chan->type) {
case IIO_CAPACITANCE: case IIO_CAPACITANCE:
/* 8.192pf / 2^24 */ /* 8.192pf / 2^24 */
......
...@@ -287,7 +287,7 @@ static int ad5064_read_raw(struct iio_dev *indio_dev, ...@@ -287,7 +287,7 @@ static int ad5064_read_raw(struct iio_dev *indio_dev,
case 0: case 0:
*val = st->dac_cache[chan->channel]; *val = st->dac_cache[chan->channel];
return IIO_VAL_INT; return IIO_VAL_INT;
case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): case IIO_CHAN_INFO_SCALE_SEPARATE:
vref = st->chip_info->shared_vref ? 0 : chan->channel; vref = st->chip_info->shared_vref ? 0 : chan->channel;
scale_uv = regulator_get_voltage(st->vref_reg[vref].consumer); scale_uv = regulator_get_voltage(st->vref_reg[vref].consumer);
if (scale_uv < 0) if (scale_uv < 0)
......
...@@ -326,21 +326,21 @@ static int ad5360_write_raw(struct iio_dev *indio_dev, ...@@ -326,21 +326,21 @@ static int ad5360_write_raw(struct iio_dev *indio_dev,
return ad5360_write(indio_dev, AD5360_CMD_WRITE_DATA, return ad5360_write(indio_dev, AD5360_CMD_WRITE_DATA,
chan->address, val, chan->scan_type.shift); chan->address, val, chan->scan_type.shift);
case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE): case IIO_CHAN_INFO_CALIBBIAS_SEPARATE:
if (val >= max_val || val < 0) if (val >= max_val || val < 0)
return -EINVAL; return -EINVAL;
return ad5360_write(indio_dev, AD5360_CMD_WRITE_OFFSET, return ad5360_write(indio_dev, AD5360_CMD_WRITE_OFFSET,
chan->address, val, chan->scan_type.shift); chan->address, val, chan->scan_type.shift);
case (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE): case IIO_CHAN_INFO_CALIBSCALE_SEPARATE:
if (val >= max_val || val < 0) if (val >= max_val || val < 0)
return -EINVAL; return -EINVAL;
return ad5360_write(indio_dev, AD5360_CMD_WRITE_GAIN, return ad5360_write(indio_dev, AD5360_CMD_WRITE_GAIN,
chan->address, val, chan->scan_type.shift); chan->address, val, chan->scan_type.shift);
case (1 << IIO_CHAN_INFO_OFFSET_SEPARATE): case IIO_CHAN_INFO_OFFSET_SEPARATE:
if (val <= -max_val || val > 0) if (val <= -max_val || val > 0)
return -EINVAL; return -EINVAL;
...@@ -383,7 +383,7 @@ static int ad5360_read_raw(struct iio_dev *indio_dev, ...@@ -383,7 +383,7 @@ static int ad5360_read_raw(struct iio_dev *indio_dev,
return ret; return ret;
*val = ret >> chan->scan_type.shift; *val = ret >> chan->scan_type.shift;
return IIO_VAL_INT; return IIO_VAL_INT;
case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): case IIO_CHAN_INFO_SCALE_SEPARATE:
/* vout = 4 * vref * dac_code */ /* vout = 4 * vref * dac_code */
scale_uv = ad5360_get_channel_vref(st, chan->channel) * 4 * 100; scale_uv = ad5360_get_channel_vref(st, chan->channel) * 4 * 100;
if (scale_uv < 0) if (scale_uv < 0)
...@@ -393,21 +393,21 @@ static int ad5360_read_raw(struct iio_dev *indio_dev, ...@@ -393,21 +393,21 @@ static int ad5360_read_raw(struct iio_dev *indio_dev,
*val = scale_uv / 100000; *val = scale_uv / 100000;
*val2 = (scale_uv % 100000) * 10; *val2 = (scale_uv % 100000) * 10;
return IIO_VAL_INT_PLUS_MICRO; return IIO_VAL_INT_PLUS_MICRO;
case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE): case IIO_CHAN_INFO_CALIBBIAS_SEPARATE:
ret = ad5360_read(indio_dev, AD5360_READBACK_OFFSET, ret = ad5360_read(indio_dev, AD5360_READBACK_OFFSET,
chan->address); chan->address);
if (ret < 0) if (ret < 0)
return ret; return ret;
*val = ret; *val = ret;
return IIO_VAL_INT; return IIO_VAL_INT;
case (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE): case IIO_CHAN_INFO_CALIBSCALE_SEPARATE:
ret = ad5360_read(indio_dev, AD5360_READBACK_GAIN, ret = ad5360_read(indio_dev, AD5360_READBACK_GAIN,
chan->address); chan->address);
if (ret < 0) if (ret < 0)
return ret; return ret;
*val = ret; *val = ret;
return IIO_VAL_INT; return IIO_VAL_INT;
case (1 << IIO_CHAN_INFO_OFFSET_SEPARATE): case IIO_CHAN_INFO_OFFSET_SEPARATE:
ofs_index = ad5360_get_channel_vref_index(st, chan->channel); ofs_index = ad5360_get_channel_vref_index(st, chan->channel);
ret = ad5360_read(indio_dev, AD5360_READBACK_SF, ret = ad5360_read(indio_dev, AD5360_READBACK_SF,
AD5360_REG_SF_OFS(ofs_index)); AD5360_REG_SF_OFS(ofs_index));
......
...@@ -306,7 +306,7 @@ static int ad5686_read_raw(struct iio_dev *indio_dev, ...@@ -306,7 +306,7 @@ static int ad5686_read_raw(struct iio_dev *indio_dev,
*val = ret; *val = ret;
return IIO_VAL_INT; return IIO_VAL_INT;
break; break;
case (1 << IIO_CHAN_INFO_SCALE_SHARED): case IIO_CHAN_INFO_SCALE_SHARED:
scale_uv = (st->vref_mv * 100000) scale_uv = (st->vref_mv * 100000)
>> (chan->scan_type.realbits); >> (chan->scan_type.realbits);
*val = scale_uv / 100000; *val = scale_uv / 100000;
......
...@@ -237,11 +237,11 @@ static int ad5791_read_raw(struct iio_dev *indio_dev, ...@@ -237,11 +237,11 @@ static int ad5791_read_raw(struct iio_dev *indio_dev,
*val &= AD5791_DAC_MASK; *val &= AD5791_DAC_MASK;
*val >>= chan->scan_type.shift; *val >>= chan->scan_type.shift;
return IIO_VAL_INT; return IIO_VAL_INT;
case (1 << IIO_CHAN_INFO_SCALE_SHARED): case IIO_CHAN_INFO_SCALE_SHARED:
*val = 0; *val = 0;
*val2 = (((u64)st->vref_mv) * 1000000ULL) >> chan->scan_type.realbits; *val2 = (((u64)st->vref_mv) * 1000000ULL) >> chan->scan_type.realbits;
return IIO_VAL_INT_PLUS_MICRO; return IIO_VAL_INT_PLUS_MICRO;
case (1 << IIO_CHAN_INFO_OFFSET_SHARED): case IIO_CHAN_INFO_OFFSET_SHARED:
val64 = (((u64)st->vref_neg_mv) << chan->scan_type.realbits); val64 = (((u64)st->vref_neg_mv) << chan->scan_type.realbits);
do_div(val64, st->vref_mv); do_div(val64, st->vref_mv);
*val = -val64; *val = -val64;
......
...@@ -98,11 +98,11 @@ static int adis16060_read_raw(struct iio_dev *indio_dev, ...@@ -98,11 +98,11 @@ static int adis16060_read_raw(struct iio_dev *indio_dev,
mutex_unlock(&indio_dev->mlock); mutex_unlock(&indio_dev->mlock);
*val = tval; *val = tval;
return IIO_VAL_INT; return IIO_VAL_INT;
case (1 << IIO_CHAN_INFO_OFFSET_SEPARATE): case IIO_CHAN_INFO_OFFSET_SEPARATE:
*val = -7; *val = -7;
*val2 = 461117; *val2 = 461117;
return IIO_VAL_INT_PLUS_MICRO; return IIO_VAL_INT_PLUS_MICRO;
case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): case IIO_CHAN_INFO_SCALE_SEPARATE:
*val = 0; *val = 0;
*val2 = 34000; *val2 = 34000;
return IIO_VAL_INT_PLUS_MICRO; return IIO_VAL_INT_PLUS_MICRO;
......
...@@ -464,8 +464,8 @@ static int adis16260_read_raw(struct iio_dev *indio_dev, ...@@ -464,8 +464,8 @@ static int adis16260_read_raw(struct iio_dev *indio_dev,
*val = val16; *val = val16;
mutex_unlock(&indio_dev->mlock); mutex_unlock(&indio_dev->mlock);
return IIO_VAL_INT; return IIO_VAL_INT;
case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): case IIO_CHAN_INFO_SCALE_SEPARATE:
case (1 << IIO_CHAN_INFO_SCALE_SHARED): case IIO_CHAN_INFO_SCALE_SHARED:
switch (chan->type) { switch (chan->type) {
case IIO_ANGL_VEL: case IIO_ANGL_VEL:
*val = 0; *val = 0;
...@@ -489,10 +489,10 @@ static int adis16260_read_raw(struct iio_dev *indio_dev, ...@@ -489,10 +489,10 @@ static int adis16260_read_raw(struct iio_dev *indio_dev,
return -EINVAL; return -EINVAL;
} }
break; break;
case (1 << IIO_CHAN_INFO_OFFSET_SEPARATE): case IIO_CHAN_INFO_OFFSET_SEPARATE:
*val = 25; *val = 25;
return IIO_VAL_INT; return IIO_VAL_INT;
case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE): case IIO_CHAN_INFO_CALIBBIAS_SEPARATE:
switch (chan->type) { switch (chan->type) {
case IIO_ANGL_VEL: case IIO_ANGL_VEL:
bits = 12; bits = 12;
...@@ -512,7 +512,7 @@ static int adis16260_read_raw(struct iio_dev *indio_dev, ...@@ -512,7 +512,7 @@ static int adis16260_read_raw(struct iio_dev *indio_dev,
*val = val16; *val = val16;
mutex_unlock(&indio_dev->mlock); mutex_unlock(&indio_dev->mlock);
return IIO_VAL_INT; return IIO_VAL_INT;
case (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE): case IIO_CHAN_INFO_CALIBSCALE_SEPARATE:
switch (chan->type) { switch (chan->type) {
case IIO_ANGL_VEL: case IIO_ANGL_VEL:
bits = 12; bits = 12;
...@@ -544,11 +544,11 @@ static int adis16260_write_raw(struct iio_dev *indio_dev, ...@@ -544,11 +544,11 @@ static int adis16260_write_raw(struct iio_dev *indio_dev,
s16 val16; s16 val16;
u8 addr; u8 addr;
switch (mask) { switch (mask) {
case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE): case IIO_CHAN_INFO_CALIBBIAS_SEPARATE:
val16 = val & ((1 << bits) - 1); val16 = val & ((1 << bits) - 1);
addr = adis16260_addresses[chan->address][1]; addr = adis16260_addresses[chan->address][1];
return adis16260_spi_write_reg_16(indio_dev, addr, val16); return adis16260_spi_write_reg_16(indio_dev, addr, val16);
case (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE): case IIO_CHAN_INFO_CALIBSCALE_SEPARATE:
val16 = val & ((1 << bits) - 1); val16 = val & ((1 << bits) - 1);
addr = adis16260_addresses[chan->address][2]; addr = adis16260_addresses[chan->address][2];
return adis16260_spi_write_reg_16(indio_dev, addr, val16); return adis16260_spi_write_reg_16(indio_dev, addr, val16);
......
...@@ -243,7 +243,7 @@ static int adxrs450_write_raw(struct iio_dev *indio_dev, ...@@ -243,7 +243,7 @@ static int adxrs450_write_raw(struct iio_dev *indio_dev,
{ {
int ret; int ret;
switch (mask) { switch (mask) {
case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE): case IIO_CHAN_INFO_CALIBBIAS_SEPARATE:
ret = adxrs450_spi_write_reg_16(indio_dev, ret = adxrs450_spi_write_reg_16(indio_dev,
ADXRS450_DNC1, ADXRS450_DNC1,
val & 0x3FF); val & 0x3FF);
...@@ -287,7 +287,7 @@ static int adxrs450_read_raw(struct iio_dev *indio_dev, ...@@ -287,7 +287,7 @@ static int adxrs450_read_raw(struct iio_dev *indio_dev,
break; break;
} }
break; break;
case (1 << IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SEPARATE): case IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SEPARATE:
ret = adxrs450_spi_read_reg_16(indio_dev, ADXRS450_QUAD1, &t); ret = adxrs450_spi_read_reg_16(indio_dev, ADXRS450_QUAD1, &t);
if (ret) if (ret)
break; break;
......
...@@ -26,7 +26,8 @@ enum iio_data_type { ...@@ -26,7 +26,8 @@ enum iio_data_type {
/* Could add the raw attributes as well - allowing buffer only devices */ /* Could add the raw attributes as well - allowing buffer only devices */
enum iio_chan_info_enum { enum iio_chan_info_enum {
IIO_CHAN_INFO_SCALE_SHARED, /* 0 is reserverd for raw attributes */
IIO_CHAN_INFO_SCALE_SHARED = 2,
IIO_CHAN_INFO_SCALE_SEPARATE, IIO_CHAN_INFO_SCALE_SEPARATE,
IIO_CHAN_INFO_OFFSET_SHARED, IIO_CHAN_INFO_OFFSET_SHARED,
IIO_CHAN_INFO_OFFSET_SEPARATE, IIO_CHAN_INFO_OFFSET_SEPARATE,
......
...@@ -229,29 +229,29 @@ static int iio_dummy_read_raw(struct iio_dev *indio_dev, ...@@ -229,29 +229,29 @@ static int iio_dummy_read_raw(struct iio_dev *indio_dev,
break; break;
} }
break; break;
case (1 << IIO_CHAN_INFO_OFFSET_SEPARATE): case IIO_CHAN_INFO_OFFSET_SEPARATE:
/* only single ended adc -> 7 */ /* only single ended adc -> 7 */
*val = 7; *val = 7;
ret = IIO_VAL_INT; ret = IIO_VAL_INT;
break; break;
case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): case IIO_CHAN_INFO_SCALE_SEPARATE:
/* only single ended adc -> 0.001333 */ /* only single ended adc -> 0.001333 */
*val = 0; *val = 0;
*val2 = 1333; *val2 = 1333;
ret = IIO_VAL_INT_PLUS_MICRO; ret = IIO_VAL_INT_PLUS_MICRO;
break; break;
case (1 << IIO_CHAN_INFO_SCALE_SHARED): case IIO_CHAN_INFO_SCALE_SHARED:
/* all differential adc channels -> 0.000001344 */ /* all differential adc channels -> 0.000001344 */
*val = 0; *val = 0;
*val2 = 1344; *val2 = 1344;
ret = IIO_VAL_INT_PLUS_NANO; ret = IIO_VAL_INT_PLUS_NANO;
break; break;
case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE): case IIO_CHAN_INFO_CALIBBIAS_SEPARATE:
/* only the acceleration axis - read from cache */ /* only the acceleration axis - read from cache */
*val = st->accel_calibbias; *val = st->accel_calibbias;
ret = IIO_VAL_INT; ret = IIO_VAL_INT;
break; break;
case (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE): case IIO_CHAN_INFO_CALIBSCALE_SEPARATE:
*val = st->accel_calibscale->val; *val = st->accel_calibscale->val;
*val2 = st->accel_calibscale->val2; *val2 = st->accel_calibscale->val2;
ret = IIO_VAL_INT_PLUS_MICRO; ret = IIO_VAL_INT_PLUS_MICRO;
...@@ -296,7 +296,7 @@ static int iio_dummy_write_raw(struct iio_dev *indio_dev, ...@@ -296,7 +296,7 @@ static int iio_dummy_write_raw(struct iio_dev *indio_dev,
st->dac_val = val; st->dac_val = val;
mutex_unlock(&st->lock); mutex_unlock(&st->lock);
return 0; return 0;
case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE): case IIO_CHAN_INFO_CALIBBIAS_SEPARATE:
mutex_lock(&st->lock); mutex_lock(&st->lock);
/* Compare against table - hard matching here */ /* Compare against table - hard matching here */
for (i = 0; i < ARRAY_SIZE(dummy_scales); i++) for (i = 0; i < ARRAY_SIZE(dummy_scales); i++)
......
...@@ -464,7 +464,7 @@ static int adis16400_write_raw(struct iio_dev *indio_dev, ...@@ -464,7 +464,7 @@ static int adis16400_write_raw(struct iio_dev *indio_dev,
int ret; int ret;
switch (mask) { switch (mask) {
case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE): case IIO_CHAN_INFO_CALIBBIAS_SEPARATE:
mutex_lock(&indio_dev->mlock); mutex_lock(&indio_dev->mlock);
ret = adis16400_spi_write_reg_16(indio_dev, ret = adis16400_spi_write_reg_16(indio_dev,
adis16400_addresses[chan->address][1], adis16400_addresses[chan->address][1],
...@@ -504,8 +504,8 @@ static int adis16400_read_raw(struct iio_dev *indio_dev, ...@@ -504,8 +504,8 @@ static int adis16400_read_raw(struct iio_dev *indio_dev,
*val = val16; *val = val16;
mutex_unlock(&indio_dev->mlock); mutex_unlock(&indio_dev->mlock);
return IIO_VAL_INT; return IIO_VAL_INT;
case (1 << IIO_CHAN_INFO_SCALE_SHARED): case IIO_CHAN_INFO_SCALE_SHARED:
case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): case IIO_CHAN_INFO_SCALE_SEPARATE:
switch (chan->type) { switch (chan->type) {
case IIO_ANGL_VEL: case IIO_ANGL_VEL:
*val = 0; *val = 0;
...@@ -533,7 +533,7 @@ static int adis16400_read_raw(struct iio_dev *indio_dev, ...@@ -533,7 +533,7 @@ static int adis16400_read_raw(struct iio_dev *indio_dev,
default: default:
return -EINVAL; return -EINVAL;
} }
case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE): case IIO_CHAN_INFO_CALIBBIAS_SEPARATE:
mutex_lock(&indio_dev->mlock); mutex_lock(&indio_dev->mlock);
ret = adis16400_spi_read_reg_16(indio_dev, ret = adis16400_spi_read_reg_16(indio_dev,
adis16400_addresses[chan->address][1], adis16400_addresses[chan->address][1],
...@@ -544,7 +544,7 @@ static int adis16400_read_raw(struct iio_dev *indio_dev, ...@@ -544,7 +544,7 @@ static int adis16400_read_raw(struct iio_dev *indio_dev,
val16 = ((val16 & 0xFFF) << 4) >> 4; val16 = ((val16 & 0xFFF) << 4) >> 4;
*val = val16; *val = val16;
return IIO_VAL_INT; return IIO_VAL_INT;
case (1 << IIO_CHAN_INFO_OFFSET_SEPARATE): case IIO_CHAN_INFO_OFFSET_SEPARATE:
/* currently only temperature */ /* currently only temperature */
*val = 198; *val = 198;
*val2 = 160000; *val2 = 160000;
......
...@@ -603,7 +603,7 @@ static int iio_device_add_channel_sysfs(struct iio_dev *indio_dev, ...@@ -603,7 +603,7 @@ static int iio_device_add_channel_sysfs(struct iio_dev *indio_dev,
chan, chan,
&iio_read_channel_info, &iio_read_channel_info,
&iio_write_channel_info, &iio_write_channel_info,
(1 << i), i,
!(i%2), !(i%2),
&indio_dev->dev, &indio_dev->dev,
&indio_dev->channel_attr_list); &indio_dev->channel_attr_list);
......
...@@ -362,7 +362,7 @@ static int isl29018_write_raw(struct iio_dev *indio_dev, ...@@ -362,7 +362,7 @@ static int isl29018_write_raw(struct iio_dev *indio_dev,
int ret = -EINVAL; int ret = -EINVAL;
mutex_lock(&chip->lock); mutex_lock(&chip->lock);
if (mask == (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE) && if (mask == IIO_CHAN_INFO_CALIBSCALE_SEPARATE &&
chan->type == IIO_LIGHT) { chan->type == IIO_LIGHT) {
chip->lux_scale = val; chip->lux_scale = val;
ret = 0; ret = 0;
...@@ -402,7 +402,7 @@ static int isl29018_read_raw(struct iio_dev *indio_dev, ...@@ -402,7 +402,7 @@ static int isl29018_read_raw(struct iio_dev *indio_dev,
if (!ret) if (!ret)
ret = IIO_VAL_INT; ret = IIO_VAL_INT;
break; break;
case (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE): case IIO_CHAN_INFO_CALIBSCALE_SEPARATE:
if (chan->type == IIO_LIGHT) { if (chan->type == IIO_LIGHT) {
*val = chip->lux_scale; *val = chip->lux_scale;
ret = IIO_VAL_INT; ret = IIO_VAL_INT;
......
...@@ -513,7 +513,7 @@ static int tsl2563_read_raw(struct iio_dev *indio_dev, ...@@ -513,7 +513,7 @@ static int tsl2563_read_raw(struct iio_dev *indio_dev,
} }
break; break;
case (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE): case IIO_CHAN_INFO_CALIBSCALE_SEPARATE:
if (chan->channel == 0) if (chan->channel == 0)
*val = calib_to_sysfs(chip->calib0); *val = calib_to_sysfs(chip->calib0);
else else
......
...@@ -431,7 +431,7 @@ static int ak8975_read_raw(struct iio_dev *indio_dev, ...@@ -431,7 +431,7 @@ static int ak8975_read_raw(struct iio_dev *indio_dev,
switch (mask) { switch (mask) {
case 0: case 0:
return ak8975_read_axis(indio_dev, chan->address, val); return ak8975_read_axis(indio_dev, chan->address, val);
case (1 << IIO_CHAN_INFO_SCALE_SEPARATE): case IIO_CHAN_INFO_SCALE_SEPARATE:
*val = data->raw_to_gauss[chan->address]; *val = data->raw_to_gauss[chan->address];
return IIO_VAL_INT; return IIO_VAL_INT;
} }
......
...@@ -463,7 +463,7 @@ static int hmc5843_read_raw(struct iio_dev *indio_dev, ...@@ -463,7 +463,7 @@ static int hmc5843_read_raw(struct iio_dev *indio_dev,
return hmc5843_read_measurement(indio_dev, return hmc5843_read_measurement(indio_dev,
chan->address, chan->address,
val); val);
case (1 << IIO_CHAN_INFO_SCALE_SHARED): case IIO_CHAN_INFO_SCALE_SHARED:
*val = 0; *val = 0;
*val2 = hmc5843_regval_to_nanoscale[data->range]; *val2 = hmc5843_regval_to_nanoscale[data->range];
return IIO_VAL_INT_PLUS_NANO; return IIO_VAL_INT_PLUS_NANO;
......
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