Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: adc: ad7476: Use correct channel for bit info

The ad7476 supports ADCs which use separate GPIO for starting the
conversion. For such devices, the driver uses different channel
information if the GPIO is found. The bit information is still always
used from the original (non 'convstart') channels.

This has not been causing problems because the bit information for the
'convstart' -channel and the 'normal' -channel is identical. It,
however, will cause issues if an IC has different characteristics for an
'convstart' -channel and regular channel. Furthermore, this will cause
problems if a device always requires the convstart GPIO and thus only
defines the convstart channel.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Link: https://patch.msgid.link/70619e39023bc497ef68cc1eff11943ab68cbdf8.1754901948.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Matti Vaittinen and committed by
Jonathan Cameron
5e6847a0 1003d539

+3 -3
+3 -3
drivers/iio/adc/ad7476.c
··· 121 121 122 122 if (ret < 0) 123 123 return ret; 124 - *val = (ret >> st->chip_info->channel[0].scan_type.shift) & 125 - GENMASK(st->chip_info->channel[0].scan_type.realbits - 1, 0); 124 + *val = (ret >> chan->scan_type.shift) & 125 + GENMASK(chan->scan_type.realbits - 1, 0); 126 126 return IIO_VAL_INT; 127 127 case IIO_CHAN_INFO_SCALE: 128 128 *val = st->scale_mv; ··· 345 345 /* Setup default message */ 346 346 347 347 st->xfer.rx_buf = &st->data; 348 - st->xfer.len = st->chip_info->channel[0].scan_type.storagebits / 8; 348 + st->xfer.len = indio_dev->channels[0].scan_type.storagebits / 8; 349 349 350 350 spi_message_init(&st->msg); 351 351 spi_message_add_tail(&st->xfer, &st->msg);