diff mbox series

[2/2] gpio: mvebu: use generic device properties

Message ID 20240930091111.32010-2-brgl@bgdev.pl
State New
Headers show
Series [1/2] gpio: mvebu: allow building the module with COMPILE_TEST=y | expand

Commit Message

Bartosz Golaszewski Sept. 30, 2024, 9:11 a.m. UTC
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-mvebu.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Uwe Kleine-König Oct. 1, 2024, 7:33 a.m. UTC | #1
Hello Bart,

On Mon, Sep 30, 2024 at 11:11:11AM +0200, Bartosz Golaszewski wrote:
> diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
> index 8cfd3a89c018..5ffb332e9849 100644
> --- a/drivers/gpio/gpio-mvebu.c
> +++ b/drivers/gpio/gpio-mvebu.c
> @@ -794,8 +794,8 @@ static int mvebu_pwm_probe(struct platform_device *pdev,
>  	u32 set;
>  
>  	if (mvchip->soc_variant == MVEBU_GPIO_SOC_VARIANT_A8K) {
> -		int ret = of_property_read_u32(dev->of_node,
> -					       "marvell,pwm-offset", &offset);
> +		int ret = device_property_read_u32(dev, "marvell,pwm-offset",
> +						   &offset);
>  		if (ret < 0)
>  			return 0;
>  	} else {
> @@ -1106,7 +1106,7 @@ static int mvebu_gpio_probe_syscon(struct platform_device *pdev,
>  	if (IS_ERR(mvchip->regs))
>  		return PTR_ERR(mvchip->regs);
>  
> -	if (of_property_read_u32(pdev->dev.of_node, "offset", &mvchip->offset))
> +	if (device_property_read_u32(&pdev->dev, "offset", &mvchip->offset))
>  		return -EINVAL;
>  
>  	return 0;
> @@ -1147,7 +1147,7 @@ static int mvebu_gpio_probe(struct platform_device *pdev)
>  
>  	platform_set_drvdata(pdev, mvchip);
>  
> -	if (of_property_read_u32(pdev->dev.of_node, "ngpios", &ngpios)) {
> +	if (device_property_read_u32(&pdev->dev, "ngpios", &ngpios)) {
>  		dev_err(&pdev->dev, "Missing ngpios OF property\n");
>  		return -ENODEV;
>  	}

I didn't look closely, but I wonder if GPIO_MVEBU depending on OF_GPIO
can be softened with this change?!

Best regards
Uwe
Bartosz Golaszewski Oct. 1, 2024, 8:42 a.m. UTC | #2
On Tue, Oct 1, 2024 at 9:34 AM Uwe Kleine-König
<u.kleine-koenig@baylibre.com> wrote:
>
> I didn't look closely, but I wonder if GPIO_MVEBU depending on OF_GPIO
> can be softened with this change?!
>

Yes, this can be done in a follow-up patch.

Bart
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
index 8cfd3a89c018..5ffb332e9849 100644
--- a/drivers/gpio/gpio-mvebu.c
+++ b/drivers/gpio/gpio-mvebu.c
@@ -794,8 +794,8 @@  static int mvebu_pwm_probe(struct platform_device *pdev,
 	u32 set;
 
 	if (mvchip->soc_variant == MVEBU_GPIO_SOC_VARIANT_A8K) {
-		int ret = of_property_read_u32(dev->of_node,
-					       "marvell,pwm-offset", &offset);
+		int ret = device_property_read_u32(dev, "marvell,pwm-offset",
+						   &offset);
 		if (ret < 0)
 			return 0;
 	} else {
@@ -1106,7 +1106,7 @@  static int mvebu_gpio_probe_syscon(struct platform_device *pdev,
 	if (IS_ERR(mvchip->regs))
 		return PTR_ERR(mvchip->regs);
 
-	if (of_property_read_u32(pdev->dev.of_node, "offset", &mvchip->offset))
+	if (device_property_read_u32(&pdev->dev, "offset", &mvchip->offset))
 		return -EINVAL;
 
 	return 0;
@@ -1147,7 +1147,7 @@  static int mvebu_gpio_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, mvchip);
 
-	if (of_property_read_u32(pdev->dev.of_node, "ngpios", &ngpios)) {
+	if (device_property_read_u32(&pdev->dev, "ngpios", &ngpios)) {
 		dev_err(&pdev->dev, "Missing ngpios OF property\n");
 		return -ENODEV;
 	}