[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200517194904.34758-3-contact@artur-rojek.eu>
Date: Sun, 17 May 2020 21:49:00 +0200
From: Artur Rojek <contact@...ur-rojek.eu>
To: Dmitry Torokhov <dmitry.torokhov@...il.com>,
Rob Herring <robh+dt@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Jonathan Cameron <jic23@...nel.org>,
Paul Cercueil <paul@...pouillou.net>,
Andy Shevchenko <andy.shevchenko@...il.com>
Cc: Heiko Stuebner <heiko@...ech.de>,
Ezequiel Garcia <ezequiel@...guardiasur.com.ar>,
linux-input@...r.kernel.org, devicetree@...r.kernel.org,
linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org,
Artur Rojek <contact@...ur-rojek.eu>
Subject: [PATCH v7 3/7] 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@...ur-rojek.eu>
Tested-by: Paul Cercueil <paul@...pouillou.net>
---
Changes:
v2-v7: no change
drivers/iio/adc/ingenic-adc.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/drivers/iio/adc/ingenic-adc.c b/drivers/iio/adc/ingenic-adc.c
index 6c3bbba7c44b..0eee4b4fb96c 100644
--- a/drivers/iio/adc/ingenic-adc.c
+++ b/drivers/iio/adc/ingenic-adc.c
@@ -400,6 +400,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);
@@ -409,6 +424,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[] = {
--
2.26.2
Powered by blists - more mailing lists