Commit 155e41ef authored by Artur Rojek's avatar Artur Rojek Committed by Jonathan Cameron

IIO: Ingenic JZ47xx: Add xlate cb to retrieve correct channel idx

Provide an of_xlate callback in order to retrieve the correct channel
specifier index from the IIO channels array.
Signed-off-by: default avatarArtur Rojek <contact@artur-rojek.eu>
Tested-by: default avatarPaul Cercueil <paul@crapouillou.net>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 1a99dc46
......@@ -401,6 +401,21 @@ static int ingenic_adc_read_raw(struct iio_dev *iio_dev,
}
}
static int ingenic_adc_of_xlate(struct iio_dev *iio_dev,
const struct of_phandle_args *iiospec)
{
int i;
if (!iiospec->args_count)
return -EINVAL;
for (i = 0; i < iio_dev->num_channels; ++i)
if (iio_dev->channels[i].channel == iiospec->args[0])
return i;
return -EINVAL;
}
static void ingenic_adc_clk_cleanup(void *data)
{
clk_unprepare(data);
......@@ -410,6 +425,7 @@ static const struct iio_info ingenic_adc_info = {
.write_raw = ingenic_adc_write_raw,
.read_raw = ingenic_adc_read_raw,
.read_avail = ingenic_adc_read_avail,
.of_xlate = ingenic_adc_of_xlate,
};
static const struct iio_chan_spec ingenic_channels[] = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment