[PATCH v5 4/8] iio: adc: at91_adc: convert to device_property_*() APIs

Abdelnasser Hussein abdelnasserhussein11 at gmail.com
Sun Nov 22 23:00:57 PST 2026


Use the firmware-agnostic device_property_*() helpers instead of the
OF-specific property readers, so the driver does not depend on a device
node being available in probe.

Update at91_adc_probe_dt_ts() to take a struct device and read its
properties through device_property_read_u32() as well.  Since the helper
no longer uses DT-specific APIs, rename it from at91_adc_probe_dt_ts() to
at91_adc_probe_ts().  This removes the need for a struct device_node
pointer in at91_adc_probe(); as a result, at91_adc_probe_ts() now logs
against dev (&pdev->dev) instead of &idev->dev.

Drop the " in the DT" suffix from the missing property messages to match
the firmware-agnostic property APIs.

With no OF APIs or struct device_node left in the file, drop the
<linux/of.h> include and add <linux/mod_devicetable.h> for struct
of_device_id.

Signed-off-by: Abdelnasser Hussein <abdelnasserhussein11 at gmail.com>
---
 drivers/iio/adc/at91_adc.c | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index 2a378540837d..b6e6fa77c782 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -15,8 +15,8 @@
 #include <linux/interrupt.h>
 #include <linux/jiffies.h>
 #include <linux/kernel.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
-#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/property.h>
 #include <linux/sched.h>
@@ -790,13 +790,12 @@ static u32 calc_startup_ticks_9x5(u32 startup_time, u32 adc_clk_khz)
 	return ticks;
 }
 
-static int at91_adc_probe_dt_ts(struct device_node *node,
-	struct at91_adc_state *st, struct device *dev)
+static int at91_adc_probe_ts(struct device *dev, struct at91_adc_state *st)
 {
 	int ret;
 	u32 prop;
 
-	ret = of_property_read_u32(node, "atmel,adc-ts-wires", &prop);
+	ret = device_property_read_u32(dev, "atmel,adc-ts-wires", &prop);
 	if (ret) {
 		dev_info(dev, "ADC Touch screen is disabled.\n");
 		return 0;
@@ -815,7 +814,7 @@ static int at91_adc_probe_dt_ts(struct device_node *node,
 	if (!st->caps->has_tsmr)
 		return 0;
 	prop = 0;
-	of_property_read_u32(node, "atmel,adc-ts-pressure-threshold", &prop);
+	device_property_read_u32(dev, "atmel,adc-ts-pressure-threshold", &prop);
 	st->ts_pressure_threshold = prop;
 	if (st->ts_pressure_threshold) {
 		return 0;
@@ -990,7 +989,6 @@ static void at91_ts_unregister(struct at91_adc_state *st)
 static int at91_adc_probe(struct platform_device *pdev)
 {
 	unsigned int prsc, mstrclk, ticks, adc_clk, adc_clk_khz, shtim;
-	struct device_node *node = pdev->dev.of_node;
 	int ret;
 	struct iio_dev *idev;
 	struct at91_adc_state *st;
@@ -1007,32 +1005,34 @@ static int at91_adc_probe(struct platform_device *pdev)
 	if (!st->caps)
 		return -ENODEV;
 
-	st->use_external = of_property_read_bool(node, "atmel,adc-use-external-triggers");
+	st->use_external = device_property_read_bool(&pdev->dev,
+						     "atmel,adc-use-external-triggers");
 
-	if (of_property_read_u32(node, "atmel,adc-channels-used", &prop))
+	if (device_property_read_u32(&pdev->dev, "atmel,adc-channels-used", &prop))
 		return dev_err_probe(&idev->dev, -EINVAL,
-				     "Missing adc-channels-used property in the DT.\n");
+				     "Missing adc-channels-used property.\n");
 	st->channels_mask = prop;
 
-	st->sleep_mode = of_property_read_bool(node, "atmel,adc-sleep-mode");
+	st->sleep_mode = device_property_read_bool(&pdev->dev,
+						   "atmel,adc-sleep-mode");
 
-	if (of_property_read_u32(node, "atmel,adc-startup-time", &prop))
+	if (device_property_read_u32(&pdev->dev, "atmel,adc-startup-time", &prop))
 		return dev_err_probe(&idev->dev, -EINVAL,
-				     "Missing adc-startup-time property in the DT.\n");
+				     "Missing adc-startup-time property.\n");
 	st->startup_time = prop;
 
 	prop = 0;
-	of_property_read_u32(node, "atmel,adc-sample-hold-time", &prop);
+	device_property_read_u32(&pdev->dev, "atmel,adc-sample-hold-time", &prop);
 	st->sample_hold_time = prop;
 
-	if (of_property_read_u32(node, "atmel,adc-vref", &prop))
+	if (device_property_read_u32(&pdev->dev, "atmel,adc-vref", &prop))
 		return dev_err_probe(&idev->dev, -EINVAL,
-				     "Missing adc-vref property in the DT.\n");
+				     "Missing adc-vref property.\n");
 	st->vref_mv = prop;
 
 	st->res = st->caps->high_res_bits;
 	if (st->caps->low_res_bits &&
-	    !of_property_read_string(node, "atmel,adc-use-res", &s)
+	    !device_property_read_string(&pdev->dev, "atmel,adc-use-res", &s)
 	    && !strcmp(s, "lowres"))
 		st->res = st->caps->low_res_bits;
 
@@ -1043,7 +1043,7 @@ static int at91_adc_probe(struct platform_device *pdev)
 
 	/* Check if touchscreen is supported. */
 	if (st->caps->has_ts) {
-		ret = at91_adc_probe_dt_ts(node, st, &idev->dev);
+		ret = at91_adc_probe_ts(&pdev->dev, st);
 		if (ret)
 			return ret;
 	}
-- 
2.56.0




More information about the linux-arm-kernel mailing list