Skip to content

Commit ce34a89

Browse files
committed
iio: dac: ad5686: fix triggered buffer support
Sample for the first channel was repeated over all the channels. Endianness conversion is already taken care inside the write function implementation. Also, IIO_TRIGGERED_BUFFER dependency is missing in Kconfig. Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
1 parent bf41747 commit ce34a89

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

drivers/iio/dac/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ config LTC2688
224224

225225
config AD5686
226226
tristate
227+
select IIO_BUFFER
228+
select IIO_TRIGGERED_BUFFER
227229

228230
config AD5686_SPI
229231
tristate "Analog Devices AD5686 and similar multi-channel DACs (SPI)"

drivers/iio/dac/ad5686.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -511,22 +511,18 @@ static irqreturn_t ad5686_trigger_handler(int irq, void *p)
511511
const struct iio_chan_spec *chan;
512512
struct iio_buffer *buffer = indio_dev->buffer;
513513
struct ad5686_state *st = iio_priv(indio_dev);
514-
u8 sample[2];
515-
unsigned int i;
516-
u16 val;
517-
int ret;
514+
u16 val[AD5686_MAX_CHANNELS];
515+
int ret, ch, i = 0;
518516

519-
ret = iio_pop_from_buffer(buffer, sample);
517+
ret = iio_pop_from_buffer(buffer, val);
520518
if (ret < 0)
521519
goto out;
522520

523521
mutex_lock(&st->lock);
524-
iio_for_each_active_channel(indio_dev, i) {
525-
val = (sample[1] << 8) + sample[0];
526-
527-
chan = &indio_dev->channels[i];
522+
iio_for_each_active_channel(indio_dev, ch) {
523+
chan = &indio_dev->channels[ch];
528524
ret = st->write(st, AD5686_CMD_WRITE_INPUT_N_UPDATE_N,
529-
chan->address, val << chan->scan_type.shift);
525+
chan->address, val[i++] << chan->scan_type.shift);
530526
}
531527
mutex_unlock(&st->lock);
532528

drivers/iio/dac/ad5686.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#define AD5686_ADDR_DAC(chan) (0x1 << (chan))
2727
#define AD5686_ADDR_ALL_DAC 0xF
28+
#define AD5686_MAX_CHANNELS 16
2829

2930
#define AD5686_CMD_NOOP 0x0
3031
#define AD5686_CMD_WRITE_INPUT_N 0x1

0 commit comments

Comments
 (0)