mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-23 20:24:12 +08:00
iio: adc: ad7606: fix oversampling gpio array
[ Upstream commit8dc4594b54
] gpiod_set_array_value was misused here: the implementation relied on the assumption that an unsigned long was required for each gpio, while the function expects a bit array stored in "as much unsigned long as needed for storing one bit per GPIO", i.e it is using a bit field. This leaded to incorrect parameter passed to gpiod_set_array_value, that would set 1 value instead of 3. It also prevents to select the software mode correctly for the AD7606B. Fixes:d2a415c86c
("iio: adc: ad7606: Add support for AD7606B ADC") Fixes:41f71e5e7d
("staging: iio: adc: ad7606: Use find_closest() macro") Signed-off-by: Guillaume Stols <gstols@baylibre.com> Reviewed-by: Nuno Sa <nuno.sa@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
30b9bf4b41
commit
4861770740
@ -215,9 +215,9 @@ static int ad7606_write_os_hw(struct iio_dev *indio_dev, int val)
|
||||
struct ad7606_state *st = iio_priv(indio_dev);
|
||||
DECLARE_BITMAP(values, 3);
|
||||
|
||||
values[0] = val;
|
||||
values[0] = val & GENMASK(2, 0);
|
||||
|
||||
gpiod_set_array_value(ARRAY_SIZE(values), st->gpio_os->desc,
|
||||
gpiod_set_array_value(st->gpio_os->ndescs, st->gpio_os->desc,
|
||||
st->gpio_os->info, values);
|
||||
|
||||
/* AD7616 requires a reset to update value */
|
||||
|
@ -249,8 +249,9 @@ static int ad7616_sw_mode_config(struct iio_dev *indio_dev)
|
||||
static int ad7606B_sw_mode_config(struct iio_dev *indio_dev)
|
||||
{
|
||||
struct ad7606_state *st = iio_priv(indio_dev);
|
||||
unsigned long os[3] = {1};
|
||||
DECLARE_BITMAP(os, 3);
|
||||
|
||||
bitmap_fill(os, 3);
|
||||
/*
|
||||
* Software mode is enabled when all three oversampling
|
||||
* pins are set to high. If oversampling gpios are defined
|
||||
@ -258,7 +259,7 @@ static int ad7606B_sw_mode_config(struct iio_dev *indio_dev)
|
||||
* otherwise, they must be hardwired to VDD
|
||||
*/
|
||||
if (st->gpio_os) {
|
||||
gpiod_set_array_value(ARRAY_SIZE(os),
|
||||
gpiod_set_array_value(st->gpio_os->ndescs,
|
||||
st->gpio_os->desc, st->gpio_os->info, os);
|
||||
}
|
||||
/* OS of 128 and 256 are available only in software mode */
|
||||
|
Loading…
Reference in New Issue
Block a user