Skip to content

Commit bcfa1e2

Browse files
gclementjic23
authored andcommitted
iio: adc: ti-ads8344: Fix channel selection
During initial submission the selection of the channel was done using the scan_index member of the iio_chan_spec structure. It was an abuse because this member is supposed to be used with a buffer so it was removed. However there was still the need to be able to known how to select a channel, the correct member to store this information is address. Thanks to this it is possible to select any other channel than the channel 0. Fixes: 8dd2d7c ("iio: adc: Add driver for the TI ADS8344 A/DC chips") Signed-off-by: Gregory CLEMENT <[email protected]> Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 5e4f99a commit bcfa1e2

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

drivers/iio/adc/ti-ads8344.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,17 @@ struct ads8344 {
3232
u8 rx_buf[3];
3333
};
3434

35-
#define ADS8344_VOLTAGE_CHANNEL(chan, si) \
35+
#define ADS8344_VOLTAGE_CHANNEL(chan, addr) \
3636
{ \
3737
.type = IIO_VOLTAGE, \
3838
.indexed = 1, \
3939
.channel = chan, \
4040
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
4141
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
42+
.address = addr, \
4243
}
4344

44-
#define ADS8344_VOLTAGE_CHANNEL_DIFF(chan1, chan2, si) \
45+
#define ADS8344_VOLTAGE_CHANNEL_DIFF(chan1, chan2, addr) \
4546
{ \
4647
.type = IIO_VOLTAGE, \
4748
.indexed = 1, \
@@ -50,6 +51,7 @@ struct ads8344 {
5051
.differential = 1, \
5152
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
5253
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
54+
.address = addr, \
5355
}
5456

5557
static const struct iio_chan_spec ads8344_channels[] = {
@@ -105,7 +107,7 @@ static int ads8344_read_raw(struct iio_dev *iio,
105107
switch (mask) {
106108
case IIO_CHAN_INFO_RAW:
107109
mutex_lock(&adc->lock);
108-
*value = ads8344_adc_conversion(adc, channel->scan_index,
110+
*value = ads8344_adc_conversion(adc, channel->address,
109111
channel->differential);
110112
mutex_unlock(&adc->lock);
111113
if (*value < 0)

0 commit comments

Comments
 (0)