linux-pwm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] gpio: syscon: order includes alphabetically
@ 2024-09-30 10:31 Bartosz Golaszewski
  2024-09-30 10:31 ` [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
  0 siblings, 2 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2024-09-30 10:31 UTC (permalink / raw)
  To: Linus Walleij; +Cc: linux-gpio, linux-kernel, linux-pwm, Bartosz Golaszewski

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

Put includes in alphabetical order in gpio-syscon.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 drivers/gpio/gpio-syscon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-syscon.c b/drivers/gpio/gpio-syscon.c
index 5ab394ec81e6..638095d5f459 100644
--- a/drivers/gpio/gpio-syscon.c
+++ b/drivers/gpio/gpio-syscon.c
@@ -7,11 +7,11 @@
 
 #include <linux/err.h>
 #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>
-#include <linux/mfd/syscon.h>
 
 #define GPIO_SYSCON_FEAT_IN	BIT(0)
 #define GPIO_SYSCON_FEAT_OUT	BIT(1)
-- 
2.43.0


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

* [PATCH 2/3] gpio: syscon: use generic device properties
  2024-09-30 10:31 [PATCH 1/3] gpio: syscon: order includes alphabetically Bartosz Golaszewski
@ 2024-09-30 10:31 ` Bartosz Golaszewski
  2024-09-30 11:28   ` Bartosz Golaszewski
  2024-09-30 10:31 ` [PATCH 3/3] gpio: syscon: drop dependency on CONFIG_OF Bartosz Golaszewski
  1 sibling, 1 reply; 4+ messages in thread
From: Bartosz Golaszewski @ 2024-09-30 10:31 UTC (permalink / raw)
  To: Linus Walleij; +Cc: linux-gpio, linux-kernel, linux-pwm, Bartosz Golaszewski

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


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

* [PATCH 3/3] gpio: syscon: drop dependency on CONFIG_OF
  2024-09-30 10:31 [PATCH 1/3] gpio: syscon: order includes alphabetically Bartosz Golaszewski
  2024-09-30 10:31 ` [PATCH 2/3] gpio: syscon: use generic device properties Bartosz Golaszewski
@ 2024-09-30 10:31 ` Bartosz Golaszewski
  1 sibling, 0 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2024-09-30 10:31 UTC (permalink / raw)
  To: Linus Walleij; +Cc: linux-gpio, linux-kernel, linux-pwm, Bartosz Golaszewski

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

MFD_SYSCON does not depend on OF and we now removed OF symbols from
gpio-syscon. Drop the Kconfig dependency.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 drivers/gpio/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 98722e814e81..643747da4475 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -681,7 +681,7 @@ config GPIO_STP_XWAY
 
 config GPIO_SYSCON
 	tristate "GPIO based on SYSCON"
-	depends on MFD_SYSCON && OF
+	depends on MFD_SYSCON
 	help
 	  Say yes here to support GPIO functionality though SYSCON driver.
 
-- 
2.43.0


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

* Re: [PATCH 2/3] gpio: syscon: use generic device properties
  2024-09-30 10:31 ` [PATCH 2/3] gpio: syscon: use generic device properties Bartosz Golaszewski
@ 2024-09-30 11:28   ` Bartosz Golaszewski
  0 siblings, 0 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2024-09-30 11:28 UTC (permalink / raw)
  To: Linus Walleij; +Cc: linux-gpio, linux-kernel, linux-pwm, Bartosz Golaszewski

On Mon, Sep 30, 2024 at 12:32 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
>
> 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)

Sorry, this is wrong, it doesn't return the prop count unless val is NULL.

I'll send a better version.

Bart

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

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

end of thread, other threads:[~2024-09-30 11:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-30 10:31 [PATCH 1/3] gpio: syscon: order includes alphabetically Bartosz Golaszewski
2024-09-30 10:31 ` [PATCH 2/3] gpio: syscon: use generic device properties Bartosz Golaszewski
2024-09-30 11:28   ` Bartosz Golaszewski
2024-09-30 10:31 ` [PATCH 3/3] gpio: syscon: drop dependency on CONFIG_OF Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).