All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 1/5] IIO: Ingenic JZ47xx: Add xlate cb to retrieve correct channel idx
@ 2020-03-07 21:14 Artur Rojek
  2020-03-07 21:14 ` [PATCH v4 2/5] dt-bindings: iio/adc: Add touchscreen idx for JZ47xx SoC ADC Artur Rojek
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Artur Rojek @ 2020-03-07 21:14 UTC (permalink / raw)
  To: Dmitry Torokhov, Rob Herring, Mark Rutland, Jonathan Cameron,
	Paul Cercueil
  Cc: Heiko Stuebner, linux-input, devicetree, linux-kernel, linux-iio,
	Artur Rojek

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>
---

 Changes:

 v2-v4: 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 39c0a609fc94..7a24bc1dabe1 100644
--- a/drivers/iio/adc/ingenic-adc.c
+++ b/drivers/iio/adc/ingenic-adc.c
@@ -383,6 +383,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);
@@ -392,6 +407,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.25.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-03-20  0:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-07 21:14 [PATCH v4 1/5] IIO: Ingenic JZ47xx: Add xlate cb to retrieve correct channel idx Artur Rojek
2020-03-07 21:14 ` [PATCH v4 2/5] dt-bindings: iio/adc: Add touchscreen idx for JZ47xx SoC ADC Artur Rojek
2020-03-07 21:14 ` [PATCH v4 3/5] IIO: Ingenic JZ47xx: Add touchscreen mode Artur Rojek
2020-03-07 21:14 ` [PATCH v4 4/5] dt-bindings: input: Add docs for ADC driven joystick Artur Rojek
2020-03-09 20:38   ` Rob Herring
2020-03-09 21:41     ` Artur Rojek
2020-03-15  9:28       ` Jonathan Cameron
2020-03-20  0:15   ` Rob Herring
2020-03-07 21:14 ` [PATCH v4 5/5] input: joystick: Add ADC attached joystick driver Artur Rojek

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.