Commit 038696f8 authored by Miquel Raynal's avatar Miquel Raynal Committed by Jonathan Cameron

iio: adc: max1027: Add debugfs register read support

Until now, only write operations were supported. Force two bytes read
operation when reading, which should fit most of the development
purposes. Of course, extended operations like buffered reads on
multiple channels or even temperature + voltage reads will not be read
entirely. Usually, just starting a new operation will work but in any
case a software reset (done through the debufs interface too) will
return the device in a usable state.
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 35654354
...@@ -309,8 +309,11 @@ static int max1027_debugfs_reg_access(struct iio_dev *indio_dev, ...@@ -309,8 +309,11 @@ static int max1027_debugfs_reg_access(struct iio_dev *indio_dev,
struct max1027_state *st = iio_priv(indio_dev); struct max1027_state *st = iio_priv(indio_dev);
u8 *val = (u8 *)st->buffer; u8 *val = (u8 *)st->buffer;
if (readval != NULL) if (readval) {
return -EINVAL; int ret = spi_read(st->spi, val, 2);
*readval = be16_to_cpu(st->buffer[0]);
return ret;
}
*val = (u8)writeval; *val = (u8)writeval;
return spi_write(st->spi, val, 1); return spi_write(st->spi, val, 1);
......
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