mirror of
https://github.com/FEX-Emu/linux.git
synced 2024-12-26 19:36:41 +00:00
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: Jonathan Cameron <jic23@kernel.org> Acked-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
b11f98ff8c
commit
09f4eb4046
@ -235,7 +235,7 @@ static int ad5064_read_raw(struct iio_dev *indio_dev,
|
||||
int scale_uv;
|
||||
|
||||
switch (m) {
|
||||
case 0:
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
*val = st->dac_cache[chan->channel];
|
||||
return IIO_VAL_INT;
|
||||
case IIO_CHAN_INFO_SCALE:
|
||||
@ -260,7 +260,7 @@ static int ad5064_write_raw(struct iio_dev *indio_dev,
|
||||
int ret;
|
||||
|
||||
switch (mask) {
|
||||
case 0:
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
if (val > (1 << chan->scan_type.realbits) || val < 0)
|
||||
return -EINVAL;
|
||||
|
||||
@ -308,7 +308,8 @@ static struct iio_chan_spec_ext_info ad5064_ext_info[] = {
|
||||
.indexed = 1, \
|
||||
.output = 1, \
|
||||
.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), \
|
||||
.scan_type = IIO_ST('u', (bits), 16, 20 - (bits)), \
|
||||
.ext_info = ad5064_ext_info, \
|
||||
|
@ -103,7 +103,8 @@ enum ad5360_type {
|
||||
.type = IIO_VOLTAGE, \
|
||||
.indexed = 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_CALIBSCALE_SEPARATE_BIT | \
|
||||
IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT, \
|
||||
@ -319,7 +320,7 @@ static int ad5360_write_raw(struct iio_dev *indio_dev,
|
||||
unsigned int ofs_index;
|
||||
|
||||
switch (mask) {
|
||||
case 0:
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
if (val >= max_val || val < 0)
|
||||
return -EINVAL;
|
||||
|
||||
@ -376,7 +377,7 @@ static int ad5360_read_raw(struct iio_dev *indio_dev,
|
||||
int ret;
|
||||
|
||||
switch (m) {
|
||||
case 0:
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
ret = ad5360_read(indio_dev, AD5360_READBACK_X1A,
|
||||
chan->address);
|
||||
if (ret < 0)
|
||||
|
@ -85,7 +85,8 @@ enum ad5380_type {
|
||||
.type = IIO_VOLTAGE, \
|
||||
.indexed = 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_CALIBBIAS_SEPARATE_BIT, \
|
||||
.scan_type = IIO_ST('u', (_bits), 16, 14 - (_bits)) \
|
||||
@ -292,7 +293,7 @@ static int ad5380_write_raw(struct iio_dev *indio_dev,
|
||||
struct ad5380_state *st = iio_priv(indio_dev);
|
||||
|
||||
switch (info) {
|
||||
case 0:
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
case IIO_CHAN_INFO_CALIBSCALE:
|
||||
if (val >= max_val || val < 0)
|
||||
return -EINVAL;
|
||||
@ -322,7 +323,7 @@ static int ad5380_read_raw(struct iio_dev *indio_dev,
|
||||
int ret;
|
||||
|
||||
switch (info) {
|
||||
case 0:
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
case IIO_CHAN_INFO_CALIBSCALE:
|
||||
ret = regmap_read(st->regmap, ad5380_info_to_reg(chan, info),
|
||||
val);
|
||||
|
@ -87,7 +87,8 @@ static const struct iio_chan_spec ad5421_channels[] = {
|
||||
.indexed = 1,
|
||||
.output = 1,
|
||||
.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_CALIBSCALE_SEPARATE_BIT |
|
||||
IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT,
|
||||
@ -304,7 +305,7 @@ static int ad5421_read_raw(struct iio_dev *indio_dev,
|
||||
return -EINVAL;
|
||||
|
||||
switch (m) {
|
||||
case 0:
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
ret = ad5421_read(indio_dev, AD5421_REG_DAC_DATA);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
@ -340,7 +341,7 @@ static int ad5421_write_raw(struct iio_dev *indio_dev,
|
||||
const unsigned int max_val = 1 << 16;
|
||||
|
||||
switch (mask) {
|
||||
case 0:
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
if (val >= max_val || val < 0)
|
||||
return -EINVAL;
|
||||
|
||||
|
@ -158,7 +158,8 @@ static const struct attribute_group ad5446_attribute_group = {
|
||||
.indexed = 1, \
|
||||
.output = 1, \
|
||||
.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)) \
|
||||
}
|
||||
|
||||
@ -274,7 +275,7 @@ static int ad5446_write_raw(struct iio_dev *indio_dev,
|
||||
int ret;
|
||||
|
||||
switch (mask) {
|
||||
case 0:
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
if (val >= (1 << chan->scan_type.realbits) || val < 0)
|
||||
return -EINVAL;
|
||||
|
||||
|
@ -27,7 +27,8 @@
|
||||
.indexed = 1, \
|
||||
.output = 1, \
|
||||
.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), \
|
||||
.scan_type = IIO_ST('u', 12, 16, 0), \
|
||||
}
|
||||
@ -81,7 +82,7 @@ static int ad5504_read_raw(struct iio_dev *indio_dev,
|
||||
int ret;
|
||||
|
||||
switch (m) {
|
||||
case 0:
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
ret = ad5504_spi_read(st->spi, chan->address);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
@ -109,7 +110,7 @@ static int ad5504_write_raw(struct iio_dev *indio_dev,
|
||||
int ret;
|
||||
|
||||
switch (mask) {
|
||||
case 0:
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
if (val >= (1 << chan->scan_type.realbits) || val < 0)
|
||||
return -EINVAL;
|
||||
|
||||
|
@ -26,7 +26,8 @@
|
||||
.indexed = 1, \
|
||||
.output = 1, \
|
||||
.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), \
|
||||
.scan_type = IIO_ST('u', (_bits), 16, 16 - (_bits)), \
|
||||
}
|
||||
@ -122,7 +123,7 @@ static int ad5624r_write_raw(struct iio_dev *indio_dev,
|
||||
int ret;
|
||||
|
||||
switch (mask) {
|
||||
case 0:
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
if (val >= (1 << chan->scan_type.realbits) || val < 0)
|
||||
return -EINVAL;
|
||||
|
||||
|
@ -98,7 +98,8 @@ enum ad5686_supported_device_ids {
|
||||
.indexed = 1, \
|
||||
.output = 1, \
|
||||
.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), \
|
||||
.scan_type = IIO_ST('u', bits, 16, shift) \
|
||||
}
|
||||
@ -296,7 +297,7 @@ static int ad5686_read_raw(struct iio_dev *indio_dev,
|
||||
int ret;
|
||||
|
||||
switch (m) {
|
||||
case 0:
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
mutex_lock(&indio_dev->mlock);
|
||||
ret = ad5686_spi_read(st, chan->address);
|
||||
mutex_unlock(&indio_dev->mlock);
|
||||
@ -326,7 +327,7 @@ static int ad5686_write_raw(struct iio_dev *indio_dev,
|
||||
int ret;
|
||||
|
||||
switch (mask) {
|
||||
case 0:
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
if (val > (1 << chan->scan_type.realbits) || val < 0)
|
||||
return -EINVAL;
|
||||
|
||||
|
@ -79,7 +79,8 @@ enum ad5764_type {
|
||||
.output = 1, \
|
||||
.channel = (_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_CALIBSCALE_SEPARATE_BIT | \
|
||||
IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT, \
|
||||
@ -188,7 +189,7 @@ static int ad5764_write_raw(struct iio_dev *indio_dev,
|
||||
unsigned int reg;
|
||||
|
||||
switch (info) {
|
||||
case 0:
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
if (val >= max_val || val < 0)
|
||||
return -EINVAL;
|
||||
val <<= chan->scan_type.shift;
|
||||
@ -228,7 +229,7 @@ static int ad5764_read_raw(struct iio_dev *indio_dev,
|
||||
int ret;
|
||||
|
||||
switch (info) {
|
||||
case 0:
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
reg = AD5764_REG_DATA(chan->address);
|
||||
ret = ad5764_read(indio_dev, reg, val);
|
||||
if (ret < 0)
|
||||
|
@ -78,7 +78,8 @@ static int ad5791_spi_read(struct spi_device *spi, u8 addr, u32 *val)
|
||||
.indexed = 1, \
|
||||
.address = AD5791_ADDR_DAC0, \
|
||||
.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, \
|
||||
.scan_type = IIO_ST('u', bits, 24, shift) \
|
||||
}
|
||||
@ -231,7 +232,7 @@ static int ad5791_read_raw(struct iio_dev *indio_dev,
|
||||
int ret;
|
||||
|
||||
switch (m) {
|
||||
case 0:
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
ret = ad5791_spi_read(st->spi, chan->address, val);
|
||||
if (ret)
|
||||
return ret;
|
||||
@ -263,7 +264,7 @@ static int ad5791_write_raw(struct iio_dev *indio_dev,
|
||||
struct ad5791_state *st = iio_priv(indio_dev);
|
||||
|
||||
switch (mask) {
|
||||
case 0:
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
val &= AD5791_RES_MASK(chan->scan_type.realbits);
|
||||
val <<= chan->scan_type.shift;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user