iio: adc: at91-sama5d2_adc: fix channel configuration for differential channels
authorEugen Hristev <eugen.hristev@microchip.com>
Tue, 10 Apr 2018 08:57:47 +0000 (11:57 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 5 Jun 2018 09:46:12 +0000 (11:46 +0200)
commitca327245cbe2e6a090cddcc0309c7f95e84e70a6
tree8a49b2d665e6c5de9ba42f890d2607dc01988a10
parentdd4dbf413fd7a22c236ba112c1d3ac99fb04c240
iio: adc: at91-sama5d2_adc: fix channel configuration for differential channels

commit f0c8d1f6dc8eac5a1fbf441c8e080721a7b6c0ff upstream.

When iterating through the channels, the index in the array is not the
scan index. Added an xlate function to translate to the proper index.
The result of the bug is that the channel array is indexed with a wrong index,
thus instead of the proper channel, we access invalid memory, which may
lead to invalid results and/or corruption.
This will be used also for devicetree channel xlate.

Fixes: 5e1a1da0f ("iio: adc: at91-sama5d2_adc: add hw trigger and buffer support")
Fixes: 073c66201 ("iio: adc: at91-sama5d2_adc: add support for DMA")
Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/iio/adc/at91-sama5d2_adc.c