mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Abdelnasser Hussein <abdelnasserhussein11@gmail.com>
To: "Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Nicolas Ferre" <nicolas.ferre@microchip.com>,
	"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
	"Claudiu Beznea" <claudiu.beznea@tuxon.dev>,
	"Maxime Ripard" <mripard@kernel.org>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	u.kleine-koenig@baylibre.com
Cc: linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	 linux-kernel@vger.kernel.org,
	 Abdelnasser Hussein <abdelnasserhussein11@gmail.com>
Subject: [PATCH v6 4/8] iio: adc: at91_adc: convert to device_property_*() APIs
Date: Thu, 03 Dec 2026 19:30:08 +0200	[thread overview]
Message-ID: <20261203-at91-adc-v6-v6-4-bfa754299f54@gmail.com> (raw)
In-Reply-To: <20261203-at91-adc-v6-v6-0-bfa754299f54@gmail.com>

Read the atmel,adc-* properties through device_property_*() in
at91_adc_probe() and at91_adc_probe_ts(), dropping the local
device_node.

Use a local struct device pointer and a propname variable, return the
actual property-read error with the property name in the message, and
replace the atmel,adc-use-res string comparison with
device_property_match_string().

With the of_* helpers gone, drop <linux/of.h> (<linux/platform_device.h>
already provides struct of_device_id).

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

diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index 9439eef7b564..cbaad9473239 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -16,7 +16,6 @@
 #include <linux/jiffies.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/property.h>
 #include <linux/sched.h>
@@ -798,13 +797,14 @@ 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)
 {
+	const char *propname;
 	int ret;
 	u32 prop;
 
-	ret = of_property_read_u32(node, "atmel,adc-ts-wires", &prop);
+	propname = "atmel,adc-ts-wires";
+	ret = device_property_read_u32(dev, propname, &prop);
 	if (ret) {
 		dev_info(dev, "ADC Touch screen is disabled.\n");
 		return 0;
@@ -822,15 +822,20 @@ 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);
+	propname = "atmel,adc-ts-pressure-threshold";
+	ret = device_property_read_u32(dev, propname, &prop);
+	if (ret)
+		return dev_err_probe(dev, ret, "Missing %s property.\n", propname);
+
 	st->ts_pressure_threshold = prop;
-	if (st->ts_pressure_threshold) {
-		return 0;
-	} else {
+	if (!st->ts_pressure_threshold) {
 		dev_err(dev, "Invalid pressure threshold for the touchscreen\n");
 		return -EINVAL;
 	}
+
+	return 0;
 }
 
 static const struct iio_info at91_adc_info = {
@@ -998,12 +1003,12 @@ 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;
+	struct device *dev = &pdev->dev;
+	const char *propname;
 	int ret;
 	struct iio_dev *idev;
 	struct at91_adc_state *st;
 	u32 reg, prop;
-	const char *s;
 
 	idev = devm_iio_device_alloc(&pdev->dev, sizeof(struct at91_adc_state));
 	if (!idev)
@@ -1015,33 +1020,38 @@ static int at91_adc_probe(struct platform_device *pdev)
 	if (!st->caps)
 		return -ENODATA;
 
-	st->use_external = of_property_read_bool(node, "atmel,adc-use-external-triggers");
+	propname = "atmel,adc-use-external-triggers";
+	st->use_external = device_property_read_bool(dev, propname);
 
-	if (of_property_read_u32(node, "atmel,adc-channels-used", &prop))
-		return dev_err_probe(&idev->dev, -EINVAL,
-				     "Missing adc-channels-used property in the DT.\n");
+	propname = "atmel,adc-channels-used";
+	ret = device_property_read_u32(dev, propname, &prop);
+	if (ret)
+		return dev_err_probe(dev, ret, "Missing %s property.\n", propname);
 	st->channels_mask = prop;
 
-	st->sleep_mode = of_property_read_bool(node, "atmel,adc-sleep-mode");
+	propname = "atmel,adc-sleep-mode";
+	st->sleep_mode = device_property_read_bool(dev, propname);
 
-	if (of_property_read_u32(node, "atmel,adc-startup-time", &prop))
-		return dev_err_probe(&idev->dev, -EINVAL,
-				     "Missing adc-startup-time property in the DT.\n");
+	propname = "atmel,adc-startup-time";
+	ret = device_property_read_u32(dev, propname, &prop);
+	if (ret)
+		return dev_err_probe(dev, ret, "Missing %s property.\n", propname);
 	st->startup_time = prop;
 
 	prop = 0;
-	of_property_read_u32(node, "atmel,adc-sample-hold-time", &prop);
+	propname = "atmel,adc-sample-hold-time";
+	device_property_read_u32(dev, propname, &prop);
 	st->sample_hold_time = prop;
 
-	if (of_property_read_u32(node, "atmel,adc-vref", &prop))
-		return dev_err_probe(&idev->dev, -EINVAL,
-				     "Missing adc-vref property in the DT.\n");
+	propname = "atmel,adc-vref";
+	ret = device_property_read_u32(dev, propname, &prop);
+	if (ret)
+		return dev_err_probe(dev, ret, "Missing %s property.\n", propname);
 	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)
-	    && !strcmp(s, "lowres"))
+	    device_property_match_string(dev, "atmel,adc-use-res", "lowres") >= 0)
 		st->res = st->caps->low_res_bits;
 
 	dev_info(&idev->dev, "Resolution used: %u bits\n", st->res);
@@ -1051,7 +1061,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(dev, st);
 		if (ret)
 			return ret;
 	}

-- 
2.56.0


  parent reply	other threads:[~2026-12-03 17:33 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 17:30 [PATCH v6 0/8] iio: adc: at91_adc: fix NULL trigger dereference and convert to devm Abdelnasser Hussein
2026-12-03 17:30 ` [PATCH v6 1/8] iio: adc: at91_adc: skip unpopulated triggers on teardown Abdelnasser Hussein
2026-12-03 17:53   ` Andy Shevchenko
2026-12-03 17:30 ` [PATCH v6 2/8] iio: adc: at91_adc: drop duplicate IRQ allocation error message Abdelnasser Hussein
2026-12-03 17:30 ` [PATCH v6 3/8] iio: adc: at91_adc: switch to device_get_match_data() Abdelnasser Hussein
2026-12-03 17:55   ` Andy Shevchenko
2026-12-03 17:30 ` Abdelnasser Hussein [this message]
2026-12-03 17:57   ` [PATCH v6 4/8] iio: adc: at91_adc: convert to device_property_*() APIs Andy Shevchenko
2026-12-03 17:30 ` [PATCH v6 5/8] iio: adc: at91_adc: use local struct device pointer in probe Abdelnasser Hussein
2026-12-03 17:30 ` [PATCH v6 6/8] iio: adc: at91_adc: pass struct device to at91_ts_register() Abdelnasser Hussein
2026-12-03 17:30 ` [PATCH v6 7/8] iio: adc: at91_adc: use HZ_PER_KHZ instead of raw 1000 Abdelnasser Hussein
2026-12-03 17:30 ` [PATCH v6 8/8] iio: adc: at91_adc: convert to device-managed resources Abdelnasser Hussein

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261203-at91-adc-v6-v6-4-bfa754299f54@gmail.com \
    --to=abdelnasserhussein11@gmail.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=andy@kernel.org \
    --cc=claudiu.beznea@tuxon.dev \
    --cc=dlechner@baylibre.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jic23@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mripard@kernel.org \
    --cc=nicolas.ferre@microchip.com \
    --cc=nuno.sa@analog.com \
    --cc=u.kleine-koenig@baylibre.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®