Commit 09f4eb40 authored by Jonathan Cameron's avatar Jonathan Cameron Committed by Greg Kroah-Hartman

staging:iio:dac Add IIO_CHAN_INFO_RAW entries to all drivers.

Precursor to making value read / write attribute optional.
No processed versions in DACs.
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
Acked-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b11f98ff
...@@ -235,7 +235,7 @@ static int ad5064_read_raw(struct iio_dev *indio_dev, ...@@ -235,7 +235,7 @@ static int ad5064_read_raw(struct iio_dev *indio_dev,
int scale_uv; int scale_uv;
switch (m) { switch (m) {
case 0: case IIO_CHAN_INFO_RAW:
*val = st->dac_cache[chan->channel]; *val = st->dac_cache[chan->channel];
return IIO_VAL_INT; return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE: case IIO_CHAN_INFO_SCALE:
...@@ -260,7 +260,7 @@ static int ad5064_write_raw(struct iio_dev *indio_dev, ...@@ -260,7 +260,7 @@ static int ad5064_write_raw(struct iio_dev *indio_dev,
int ret; int ret;
switch (mask) { switch (mask) {
case 0: case IIO_CHAN_INFO_RAW:
if (val > (1 << chan->scan_type.realbits) || val < 0) if (val > (1 << chan->scan_type.realbits) || val < 0)
return -EINVAL; return -EINVAL;
...@@ -308,7 +308,8 @@ static struct iio_chan_spec_ext_info ad5064_ext_info[] = { ...@@ -308,7 +308,8 @@ static struct iio_chan_spec_ext_info ad5064_ext_info[] = {
.indexed = 1, \ .indexed = 1, \
.output = 1, \ .output = 1, \
.channel = (chan), \ .channel = (chan), \
.info_mask = IIO_CHAN_INFO_SCALE_SEPARATE_BIT, \ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
IIO_CHAN_INFO_SCALE_SEPARATE_BIT, \
.address = AD5064_ADDR_DAC(chan), \ .address = AD5064_ADDR_DAC(chan), \
.scan_type = IIO_ST('u', (bits), 16, 20 - (bits)), \ .scan_type = IIO_ST('u', (bits), 16, 20 - (bits)), \
.ext_info = ad5064_ext_info, \ .ext_info = ad5064_ext_info, \
......
...@@ -103,7 +103,8 @@ enum ad5360_type { ...@@ -103,7 +103,8 @@ enum ad5360_type {
.type = IIO_VOLTAGE, \ .type = IIO_VOLTAGE, \
.indexed = 1, \ .indexed = 1, \
.output = 1, \ .output = 1, \
.info_mask = IIO_CHAN_INFO_SCALE_SEPARATE_BIT | \ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
IIO_CHAN_INFO_SCALE_SEPARATE_BIT | \
IIO_CHAN_INFO_OFFSET_SEPARATE_BIT | \ IIO_CHAN_INFO_OFFSET_SEPARATE_BIT | \
IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT | \ IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT | \
IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT, \ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT, \
...@@ -319,7 +320,7 @@ static int ad5360_write_raw(struct iio_dev *indio_dev, ...@@ -319,7 +320,7 @@ static int ad5360_write_raw(struct iio_dev *indio_dev,
unsigned int ofs_index; unsigned int ofs_index;
switch (mask) { switch (mask) {
case 0: case IIO_CHAN_INFO_RAW:
if (val >= max_val || val < 0) if (val >= max_val || val < 0)
return -EINVAL; return -EINVAL;
...@@ -376,7 +377,7 @@ static int ad5360_read_raw(struct iio_dev *indio_dev, ...@@ -376,7 +377,7 @@ static int ad5360_read_raw(struct iio_dev *indio_dev,
int ret; int ret;
switch (m) { switch (m) {
case 0: case IIO_CHAN_INFO_RAW:
ret = ad5360_read(indio_dev, AD5360_READBACK_X1A, ret = ad5360_read(indio_dev, AD5360_READBACK_X1A,
chan->address); chan->address);
if (ret < 0) if (ret < 0)
......
...@@ -85,7 +85,8 @@ enum ad5380_type { ...@@ -85,7 +85,8 @@ enum ad5380_type {
.type = IIO_VOLTAGE, \ .type = IIO_VOLTAGE, \
.indexed = 1, \ .indexed = 1, \
.output = 1, \ .output = 1, \
.info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT | \ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
IIO_CHAN_INFO_SCALE_SHARED_BIT | \
IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT | \ IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT | \
IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT, \ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT, \
.scan_type = IIO_ST('u', (_bits), 16, 14 - (_bits)) \ .scan_type = IIO_ST('u', (_bits), 16, 14 - (_bits)) \
...@@ -292,7 +293,7 @@ static int ad5380_write_raw(struct iio_dev *indio_dev, ...@@ -292,7 +293,7 @@ static int ad5380_write_raw(struct iio_dev *indio_dev,
struct ad5380_state *st = iio_priv(indio_dev); struct ad5380_state *st = iio_priv(indio_dev);
switch (info) { switch (info) {
case 0: case IIO_CHAN_INFO_RAW:
case IIO_CHAN_INFO_CALIBSCALE: case IIO_CHAN_INFO_CALIBSCALE:
if (val >= max_val || val < 0) if (val >= max_val || val < 0)
return -EINVAL; return -EINVAL;
...@@ -322,7 +323,7 @@ static int ad5380_read_raw(struct iio_dev *indio_dev, ...@@ -322,7 +323,7 @@ static int ad5380_read_raw(struct iio_dev *indio_dev,
int ret; int ret;
switch (info) { switch (info) {
case 0: case IIO_CHAN_INFO_RAW:
case IIO_CHAN_INFO_CALIBSCALE: case IIO_CHAN_INFO_CALIBSCALE:
ret = regmap_read(st->regmap, ad5380_info_to_reg(chan, info), ret = regmap_read(st->regmap, ad5380_info_to_reg(chan, info),
val); val);
......
...@@ -87,7 +87,8 @@ static const struct iio_chan_spec ad5421_channels[] = { ...@@ -87,7 +87,8 @@ static const struct iio_chan_spec ad5421_channels[] = {
.indexed = 1, .indexed = 1,
.output = 1, .output = 1,
.channel = 0, .channel = 0,
.info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT | .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_OFFSET_SHARED_BIT | IIO_CHAN_INFO_OFFSET_SHARED_BIT |
IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT | IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT |
IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT, IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT,
...@@ -304,7 +305,7 @@ static int ad5421_read_raw(struct iio_dev *indio_dev, ...@@ -304,7 +305,7 @@ static int ad5421_read_raw(struct iio_dev *indio_dev,
return -EINVAL; return -EINVAL;
switch (m) { switch (m) {
case 0: case IIO_CHAN_INFO_RAW:
ret = ad5421_read(indio_dev, AD5421_REG_DAC_DATA); ret = ad5421_read(indio_dev, AD5421_REG_DAC_DATA);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -340,7 +341,7 @@ static int ad5421_write_raw(struct iio_dev *indio_dev, ...@@ -340,7 +341,7 @@ static int ad5421_write_raw(struct iio_dev *indio_dev,
const unsigned int max_val = 1 << 16; const unsigned int max_val = 1 << 16;
switch (mask) { switch (mask) {
case 0: case IIO_CHAN_INFO_RAW:
if (val >= max_val || val < 0) if (val >= max_val || val < 0)
return -EINVAL; return -EINVAL;
......
...@@ -158,7 +158,8 @@ static const struct attribute_group ad5446_attribute_group = { ...@@ -158,7 +158,8 @@ static const struct attribute_group ad5446_attribute_group = {
.indexed = 1, \ .indexed = 1, \
.output = 1, \ .output = 1, \
.channel = 0, \ .channel = 0, \
.info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT, \ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
IIO_CHAN_INFO_SCALE_SHARED_BIT, \
.scan_type = IIO_ST('u', (bits), (storage), (shift)) \ .scan_type = IIO_ST('u', (bits), (storage), (shift)) \
} }
...@@ -274,7 +275,7 @@ static int ad5446_write_raw(struct iio_dev *indio_dev, ...@@ -274,7 +275,7 @@ static int ad5446_write_raw(struct iio_dev *indio_dev,
int ret; int ret;
switch (mask) { switch (mask) {
case 0: case IIO_CHAN_INFO_RAW:
if (val >= (1 << chan->scan_type.realbits) || val < 0) if (val >= (1 << chan->scan_type.realbits) || val < 0)
return -EINVAL; return -EINVAL;
......
...@@ -27,7 +27,8 @@ ...@@ -27,7 +27,8 @@
.indexed = 1, \ .indexed = 1, \
.output = 1, \ .output = 1, \
.channel = (_chan), \ .channel = (_chan), \
.info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT, \ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
IIO_CHAN_INFO_SCALE_SHARED_BIT, \
.address = AD5504_ADDR_DAC(_chan), \ .address = AD5504_ADDR_DAC(_chan), \
.scan_type = IIO_ST('u', 12, 16, 0), \ .scan_type = IIO_ST('u', 12, 16, 0), \
} }
...@@ -81,7 +82,7 @@ static int ad5504_read_raw(struct iio_dev *indio_dev, ...@@ -81,7 +82,7 @@ static int ad5504_read_raw(struct iio_dev *indio_dev,
int ret; int ret;
switch (m) { switch (m) {
case 0: case IIO_CHAN_INFO_RAW:
ret = ad5504_spi_read(st->spi, chan->address); ret = ad5504_spi_read(st->spi, chan->address);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -109,7 +110,7 @@ static int ad5504_write_raw(struct iio_dev *indio_dev, ...@@ -109,7 +110,7 @@ static int ad5504_write_raw(struct iio_dev *indio_dev,
int ret; int ret;
switch (mask) { switch (mask) {
case 0: case IIO_CHAN_INFO_RAW:
if (val >= (1 << chan->scan_type.realbits) || val < 0) if (val >= (1 << chan->scan_type.realbits) || val < 0)
return -EINVAL; return -EINVAL;
......
...@@ -26,7 +26,8 @@ ...@@ -26,7 +26,8 @@
.indexed = 1, \ .indexed = 1, \
.output = 1, \ .output = 1, \
.channel = (_chan), \ .channel = (_chan), \
.info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT, \ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
IIO_CHAN_INFO_SCALE_SHARED_BIT, \
.address = (_chan), \ .address = (_chan), \
.scan_type = IIO_ST('u', (_bits), 16, 16 - (_bits)), \ .scan_type = IIO_ST('u', (_bits), 16, 16 - (_bits)), \
} }
...@@ -122,7 +123,7 @@ static int ad5624r_write_raw(struct iio_dev *indio_dev, ...@@ -122,7 +123,7 @@ static int ad5624r_write_raw(struct iio_dev *indio_dev,
int ret; int ret;
switch (mask) { switch (mask) {
case 0: case IIO_CHAN_INFO_RAW:
if (val >= (1 << chan->scan_type.realbits) || val < 0) if (val >= (1 << chan->scan_type.realbits) || val < 0)
return -EINVAL; return -EINVAL;
......
...@@ -98,7 +98,8 @@ enum ad5686_supported_device_ids { ...@@ -98,7 +98,8 @@ enum ad5686_supported_device_ids {
.indexed = 1, \ .indexed = 1, \
.output = 1, \ .output = 1, \
.channel = chan, \ .channel = chan, \
.info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT, \ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
IIO_CHAN_INFO_SCALE_SHARED_BIT, \
.address = AD5686_ADDR_DAC(chan), \ .address = AD5686_ADDR_DAC(chan), \
.scan_type = IIO_ST('u', bits, 16, shift) \ .scan_type = IIO_ST('u', bits, 16, shift) \
} }
...@@ -296,7 +297,7 @@ static int ad5686_read_raw(struct iio_dev *indio_dev, ...@@ -296,7 +297,7 @@ static int ad5686_read_raw(struct iio_dev *indio_dev,
int ret; int ret;
switch (m) { switch (m) {
case 0: case IIO_CHAN_INFO_RAW:
mutex_lock(&indio_dev->mlock); mutex_lock(&indio_dev->mlock);
ret = ad5686_spi_read(st, chan->address); ret = ad5686_spi_read(st, chan->address);
mutex_unlock(&indio_dev->mlock); mutex_unlock(&indio_dev->mlock);
...@@ -326,7 +327,7 @@ static int ad5686_write_raw(struct iio_dev *indio_dev, ...@@ -326,7 +327,7 @@ static int ad5686_write_raw(struct iio_dev *indio_dev,
int ret; int ret;
switch (mask) { switch (mask) {
case 0: case IIO_CHAN_INFO_RAW:
if (val > (1 << chan->scan_type.realbits) || val < 0) if (val > (1 << chan->scan_type.realbits) || val < 0)
return -EINVAL; return -EINVAL;
......
...@@ -79,7 +79,8 @@ enum ad5764_type { ...@@ -79,7 +79,8 @@ enum ad5764_type {
.output = 1, \ .output = 1, \
.channel = (_chan), \ .channel = (_chan), \
.address = (_chan), \ .address = (_chan), \
.info_mask = IIO_CHAN_INFO_OFFSET_SHARED_BIT | \ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
IIO_CHAN_INFO_OFFSET_SHARED_BIT | \
IIO_CHAN_INFO_SCALE_SEPARATE_BIT | \ IIO_CHAN_INFO_SCALE_SEPARATE_BIT | \
IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT | \ IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT | \
IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT, \ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT, \
...@@ -188,7 +189,7 @@ static int ad5764_write_raw(struct iio_dev *indio_dev, ...@@ -188,7 +189,7 @@ static int ad5764_write_raw(struct iio_dev *indio_dev,
unsigned int reg; unsigned int reg;
switch (info) { switch (info) {
case 0: case IIO_CHAN_INFO_RAW:
if (val >= max_val || val < 0) if (val >= max_val || val < 0)
return -EINVAL; return -EINVAL;
val <<= chan->scan_type.shift; val <<= chan->scan_type.shift;
...@@ -228,7 +229,7 @@ static int ad5764_read_raw(struct iio_dev *indio_dev, ...@@ -228,7 +229,7 @@ static int ad5764_read_raw(struct iio_dev *indio_dev,
int ret; int ret;
switch (info) { switch (info) {
case 0: case IIO_CHAN_INFO_RAW:
reg = AD5764_REG_DATA(chan->address); reg = AD5764_REG_DATA(chan->address);
ret = ad5764_read(indio_dev, reg, val); ret = ad5764_read(indio_dev, reg, val);
if (ret < 0) if (ret < 0)
......
...@@ -78,7 +78,8 @@ static int ad5791_spi_read(struct spi_device *spi, u8 addr, u32 *val) ...@@ -78,7 +78,8 @@ static int ad5791_spi_read(struct spi_device *spi, u8 addr, u32 *val)
.indexed = 1, \ .indexed = 1, \
.address = AD5791_ADDR_DAC0, \ .address = AD5791_ADDR_DAC0, \
.channel = 0, \ .channel = 0, \
.info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT | \ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
IIO_CHAN_INFO_SCALE_SHARED_BIT | \
IIO_CHAN_INFO_OFFSET_SHARED_BIT, \ IIO_CHAN_INFO_OFFSET_SHARED_BIT, \
.scan_type = IIO_ST('u', bits, 24, shift) \ .scan_type = IIO_ST('u', bits, 24, shift) \
} }
...@@ -231,7 +232,7 @@ static int ad5791_read_raw(struct iio_dev *indio_dev, ...@@ -231,7 +232,7 @@ static int ad5791_read_raw(struct iio_dev *indio_dev,
int ret; int ret;
switch (m) { switch (m) {
case 0: case IIO_CHAN_INFO_RAW:
ret = ad5791_spi_read(st->spi, chan->address, val); ret = ad5791_spi_read(st->spi, chan->address, val);
if (ret) if (ret)
return ret; return ret;
...@@ -263,7 +264,7 @@ static int ad5791_write_raw(struct iio_dev *indio_dev, ...@@ -263,7 +264,7 @@ static int ad5791_write_raw(struct iio_dev *indio_dev,
struct ad5791_state *st = iio_priv(indio_dev); struct ad5791_state *st = iio_priv(indio_dev);
switch (mask) { switch (mask) {
case 0: case IIO_CHAN_INFO_RAW:
val &= AD5791_RES_MASK(chan->scan_type.realbits); val &= AD5791_RES_MASK(chan->scan_type.realbits);
val <<= chan->scan_type.shift; val <<= chan->scan_type.shift;
......
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