Thread (25 messages) 25 messages, 6 authors, 2021-07-12

Re: [PATCH 3/4] iio: rn5t618: Add devicetree support

From: Jonathan Cameron <jic23@kernel.org>
Date: 2021-07-03 16:09:45
Also in: linux-devicetree, linux-iio, lkml

On Sat,  3 Jul 2021 10:42:23 +0200
Andreas Kemnade [off-list ref] wrote:
quoted hunk ↗ jump to hunk
Add devicetree support to be able to easily get the channels
from another device.

Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
---
 drivers/iio/adc/rn5t618-adc.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/adc/rn5t618-adc.c b/drivers/iio/adc/rn5t618-adc.c
index 7010c4276947..feba19f91574 100644
--- a/drivers/iio/adc/rn5t618-adc.c
+++ b/drivers/iio/adc/rn5t618-adc.c
@@ -12,6 +12,7 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/mfd/rn5t618.h>
+#include <linux/of_device.h>
Why?

mod_devicetable.h probably the one you want.
quoted hunk ↗ jump to hunk
 #include <linux/platform_device.h>
 #include <linux/completion.h>
 #include <linux/regmap.h>
@@ -218,6 +219,7 @@ static int rn5t618_adc_probe(struct platform_device *pdev)
 	init_completion(&adc->conv_completion);
 
 	iio_dev->name = dev_name(&pdev->dev);
+	iio_dev->dev.of_node = pdev->dev.of_node;
That should (now) be set by the IIO core for you via the devm_iio_device_register()
call below if it's not already set.
quoted hunk ↗ jump to hunk
 	iio_dev->info = &rn5t618_adc_iio_info;
 	iio_dev->modes = INDIO_DIRECT_MODE;
 	iio_dev->channels = rn5t618_adc_iio_channels;
@@ -242,9 +244,19 @@ static int rn5t618_adc_probe(struct platform_device *pdev)
 	return devm_iio_device_register(adc->dev, iio_dev);
 }
 
+#ifdef CONFIG_OF
+static const struct of_device_id rn5t618_adc_of_match[] = {
+	{ .compatible = "ricoh,rc5t619-adc", },
+	{ .compatible = "ricoh,rn5t618-adc", },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, rn5t618_adc_of_match);
+#endif
+
 static struct platform_driver rn5t618_adc_driver = {
 	.driver = {
-		.name   = "rn5t618-adc",
+		.name = "rn5t618-adc",
+		.of_match_table = of_match_ptr(rn5t618_adc_of_match),
Given cost of that table is totally trivial (and I'm trying to get rid
of this pattern in IIO as it's noisy and adds little :) drop the
of_match_ptr protection and the ifdefs above.
 	},
 	.probe = rn5t618_adc_probe,
 };
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help