summaryrefslogtreecommitdiff
path: root/drivers/iio
diff options
context:
space:
mode:
authorArtur Rojek <contact@artur-rojek.eu>2020-07-19 22:53:04 +0200
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2020-07-20 10:25:32 +0100
commit155e41efe70bcd5f254e43d38c19f74b1378cd78 (patch)
tree8c9388accc334db683355b0a246f285c1c0b7e58 /drivers/iio
parent1a99dc467943c02e08ee59fe4a3f2093a1ba28cb (diff)
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: Artur Rojek <contact@artur-rojek.eu> Tested-by: Paul Cercueil <paul@crapouillou.net> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio')
-rw-r--r--drivers/iio/adc/ingenic-adc.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/iio/adc/ingenic-adc.c b/drivers/iio/adc/ingenic-adc.c
index 059c2573e4a9..a742724fa7e6 100644
--- a/drivers/iio/adc/ingenic-adc.c
+++ b/drivers/iio/adc/ingenic-adc.c
@@ -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[] = {