Linux GPIO subsystem development
 help / color / mirror / Atom feed
From: Bartosz Golaszewski <brgl@bgdev.pl>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-pwm@vger.kernel.org,
	Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: [PATCH 2/3] gpio: syscon: use generic device properties
Date: Mon, 30 Sep 2024 12:31:56 +0200	[thread overview]
Message-ID: <20240930103157.49259-2-brgl@bgdev.pl> (raw)
In-Reply-To: <20240930103157.49259-1-brgl@bgdev.pl>

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

OF-specific routines should not be used unless necessary. Generic device
properties are preferred so switch to using them in the driver code.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 drivers/gpio/gpio-syscon.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/drivers/gpio/gpio-syscon.c b/drivers/gpio/gpio-syscon.c
index 638095d5f459..06c07085feb8 100644
--- a/drivers/gpio/gpio-syscon.c
+++ b/drivers/gpio/gpio-syscon.c
@@ -9,7 +9,6 @@
 #include <linux/gpio/driver.h>
 #include <linux/mfd/syscon.h>
 #include <linux/module.h>
-#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
 
@@ -208,12 +207,13 @@ static int syscon_gpio_probe(struct platform_device *pdev)
 	struct device_node *np = dev->of_node;
 	int ret;
 	bool use_parent_regmap = false;
+	unsigned int props[] = { 0, 0 };
 
 	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
 		return -ENOMEM;
 
-	priv->data = of_device_get_match_data(dev);
+	priv->data = device_get_match_data(dev);
 
 	priv->syscon = syscon_regmap_lookup_by_phandle(np, "gpio,syscon-dev");
 	if (IS_ERR(priv->syscon) && np->parent) {
@@ -224,19 +224,15 @@ static int syscon_gpio_probe(struct platform_device *pdev)
 		return PTR_ERR(priv->syscon);
 
 	if (!use_parent_regmap) {
-		ret = of_property_read_u32_index(np, "gpio,syscon-dev", 1,
-						 &priv->dreg_offset);
-		if (ret)
+		ret = device_property_read_u32_array(dev, "gpio,syscon-dev",
+						     props, 2);
+		if (ret < 0)
 			dev_err(dev, "can't read the data register offset!\n");
-
-		priv->dreg_offset <<= 3;
-
-		ret = of_property_read_u32_index(np, "gpio,syscon-dev", 2,
-						 &priv->dir_reg_offset);
-		if (ret)
+		if (ret != 2)
 			dev_dbg(dev, "can't read the dir register offset!\n");
 
-		priv->dir_reg_offset <<= 3;
+		priv->dreg_offset = props[0] << 3;
+		priv->dir_reg_offset = props[1] << 3;
 	}
 
 	priv->chip.parent = dev;
-- 
2.43.0


  reply	other threads:[~2024-09-30 10:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-30 10:31 [PATCH 1/3] gpio: syscon: order includes alphabetically Bartosz Golaszewski
2024-09-30 10:31 ` Bartosz Golaszewski [this message]
2024-09-30 11:28   ` [PATCH 2/3] gpio: syscon: use generic device properties Bartosz Golaszewski
2024-09-30 10:31 ` [PATCH 3/3] gpio: syscon: drop dependency on CONFIG_OF Bartosz Golaszewski

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=20240930103157.49259-2-brgl@bgdev.pl \
    --to=brgl@bgdev.pl \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    /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