This code is problematic because we're supposed to be writing an int but
we instead write to only the high 16 bits. This doesn't work on big
endian systems, and there is a potential that the bottom 16 bits are
used without being initialized.
Fixes: 23ec2774f1cc ("iio: adc: at91-sama5d2_adc: add support for position and pressure channels")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Tested-by: Eugen Hristev <eugen.hristev@microchip.com>
Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
{
struct at91_adc_state *st = iio_priv(indio_dev);
u32 cor = 0;
+ u16 tmp_val;
int ret;
/*
mutex_lock(&st->lock);
ret = at91_adc_read_position(st, chan->channel,
- (u16 *)val);
+ &tmp_val);
+ *val = tmp_val;
mutex_unlock(&st->lock);
iio_device_release_direct_mode(indio_dev);
mutex_lock(&st->lock);
ret = at91_adc_read_pressure(st, chan->channel,
- (u16 *)val);
+ &tmp_val);
+ *val = tmp_val;
mutex_unlock(&st->lock);
iio_device_release_direct_mode(indio_dev);