public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC/PATCH] remoteproc/keystone: switch to using gpiod API
@ 2022-09-06 21:08 Dmitry Torokhov
  2022-09-07 21:48 ` Linus Walleij
  2022-09-08 21:57 ` Mathieu Poirier
  0 siblings, 2 replies; 4+ messages in thread
From: Dmitry Torokhov @ 2022-09-06 21:08 UTC (permalink / raw)
  To: Bjorn Andersson, Mathieu Poirier
  Cc: Suman Anna, Linus Walleij, linux-remoteproc, linux-kernel

This patch switches the driver away from legacy gpio/of_gpio API to
gpiod API, and removes use of of_get_named_gpio_flags() which I want to
make private to gpiolib.

Note that there is a behavior change in the driver: previously the
driver did not actually request GPIO, it simply parsed GPIO number out
of device tree and poked at it.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/remoteproc/keystone_remoteproc.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/remoteproc/keystone_remoteproc.c b/drivers/remoteproc/keystone_remoteproc.c
index 594a9b43b7ae..95b39741925d 100644
--- a/drivers/remoteproc/keystone_remoteproc.c
+++ b/drivers/remoteproc/keystone_remoteproc.c
@@ -14,7 +14,7 @@
 #include <linux/workqueue.h>
 #include <linux/of_address.h>
 #include <linux/of_reserved_mem.h>
-#include <linux/of_gpio.h>
+#include <linux/gpio/consumer.h>
 #include <linux/regmap.h>
 #include <linux/mfd/syscon.h>
 #include <linux/remoteproc.h>
@@ -59,10 +59,10 @@ struct keystone_rproc {
 	int num_mems;
 	struct regmap *dev_ctrl;
 	struct reset_control *reset;
+	struct gpio_desc *kick_gpio;
 	u32 boot_offset;
 	int irq_ring;
 	int irq_fault;
-	int kick_gpio;
 	struct work_struct workqueue;
 };
 
@@ -232,10 +232,10 @@ static void keystone_rproc_kick(struct rproc *rproc, int vqid)
 {
 	struct keystone_rproc *ksproc = rproc->priv;
 
-	if (WARN_ON(ksproc->kick_gpio < 0))
+	if (!ksproc->kick_gpio)
 		return;
 
-	gpio_set_value(ksproc->kick_gpio, 1);
+	gpiod_set_value(ksproc->kick_gpio, 1);
 }
 
 /*
@@ -432,9 +432,9 @@ static int keystone_rproc_probe(struct platform_device *pdev)
 		goto disable_clk;
 	}
 
-	ksproc->kick_gpio = of_get_named_gpio_flags(np, "kick-gpios", 0, NULL);
-	if (ksproc->kick_gpio < 0) {
-		ret = ksproc->kick_gpio;
+	ksproc->kick_gpio = gpiod_get(dev, "kick", GPIOD_ASIS);
+	ret = PTR_ERR_OR_ZERO(ksproc->kick_gpio);
+	if (ret) {
 		dev_err(dev, "failed to get gpio for virtio kicks, status = %d\n",
 			ret);
 		goto disable_clk;
@@ -466,6 +466,7 @@ static int keystone_rproc_probe(struct platform_device *pdev)
 
 release_mem:
 	of_reserved_mem_device_release(dev);
+	gpiod_put(ksproc->kick_gpio);
 disable_clk:
 	pm_runtime_put_sync(dev);
 disable_rpm:
@@ -480,6 +481,7 @@ static int keystone_rproc_remove(struct platform_device *pdev)
 	struct keystone_rproc *ksproc = platform_get_drvdata(pdev);
 
 	rproc_del(ksproc->rproc);
+	gpiod_put(ksproc->kick_gpio);
 	pm_runtime_put_sync(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 	rproc_free(ksproc->rproc);
-- 
2.37.2.789.g6183377224-goog


-- 
Dmitry

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

* Re: [RFC/PATCH] remoteproc/keystone: switch to using gpiod API
  2022-09-06 21:08 [RFC/PATCH] remoteproc/keystone: switch to using gpiod API Dmitry Torokhov
@ 2022-09-07 21:48 ` Linus Walleij
  2022-09-08 21:57 ` Mathieu Poirier
  1 sibling, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2022-09-07 21:48 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Bjorn Andersson, Mathieu Poirier, Suman Anna, linux-remoteproc,
	linux-kernel

On Tue, Sep 6, 2022 at 11:08 PM Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:

> This patch switches the driver away from legacy gpio/of_gpio API to
> gpiod API, and removes use of of_get_named_gpio_flags() which I want to
> make private to gpiolib.
>
> Note that there is a behavior change in the driver: previously the
> driver did not actually request GPIO, it simply parsed GPIO number out
> of device tree and poked at it.
>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* Re: [RFC/PATCH] remoteproc/keystone: switch to using gpiod API
  2022-09-06 21:08 [RFC/PATCH] remoteproc/keystone: switch to using gpiod API Dmitry Torokhov
  2022-09-07 21:48 ` Linus Walleij
@ 2022-09-08 21:57 ` Mathieu Poirier
  2022-09-19 20:09   ` Mathieu Poirier
  1 sibling, 1 reply; 4+ messages in thread
From: Mathieu Poirier @ 2022-09-08 21:57 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Bjorn Andersson, Suman Anna, Linus Walleij, linux-remoteproc,
	linux-kernel, kishon, danishanwar, nm, vigneshr,
	grygorii.strashko

On Tue, Sep 06, 2022 at 02:08:33PM -0700, Dmitry Torokhov wrote:
> This patch switches the driver away from legacy gpio/of_gpio API to
> gpiod API, and removes use of of_get_named_gpio_flags() which I want to
> make private to gpiolib.
> 
> Note that there is a behavior change in the driver: previously the
> driver did not actually request GPIO, it simply parsed GPIO number out
> of device tree and poked at it.
> 
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
>  drivers/remoteproc/keystone_remoteproc.c | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)

This change looks good to me but I would like someone from the TI brigade test
this before applying it.

Thanks,
Mathieu

> 
> diff --git a/drivers/remoteproc/keystone_remoteproc.c b/drivers/remoteproc/keystone_remoteproc.c
> index 594a9b43b7ae..95b39741925d 100644
> --- a/drivers/remoteproc/keystone_remoteproc.c
> +++ b/drivers/remoteproc/keystone_remoteproc.c
> @@ -14,7 +14,7 @@
>  #include <linux/workqueue.h>
>  #include <linux/of_address.h>
>  #include <linux/of_reserved_mem.h>
> -#include <linux/of_gpio.h>
> +#include <linux/gpio/consumer.h>
>  #include <linux/regmap.h>
>  #include <linux/mfd/syscon.h>
>  #include <linux/remoteproc.h>
> @@ -59,10 +59,10 @@ struct keystone_rproc {
>  	int num_mems;
>  	struct regmap *dev_ctrl;
>  	struct reset_control *reset;
> +	struct gpio_desc *kick_gpio;
>  	u32 boot_offset;
>  	int irq_ring;
>  	int irq_fault;
> -	int kick_gpio;
>  	struct work_struct workqueue;
>  };
>  
> @@ -232,10 +232,10 @@ static void keystone_rproc_kick(struct rproc *rproc, int vqid)
>  {
>  	struct keystone_rproc *ksproc = rproc->priv;
>  
> -	if (WARN_ON(ksproc->kick_gpio < 0))
> +	if (!ksproc->kick_gpio)
>  		return;
>  
> -	gpio_set_value(ksproc->kick_gpio, 1);
> +	gpiod_set_value(ksproc->kick_gpio, 1);
>  }
>  
>  /*
> @@ -432,9 +432,9 @@ static int keystone_rproc_probe(struct platform_device *pdev)
>  		goto disable_clk;
>  	}
>  
> -	ksproc->kick_gpio = of_get_named_gpio_flags(np, "kick-gpios", 0, NULL);
> -	if (ksproc->kick_gpio < 0) {
> -		ret = ksproc->kick_gpio;
> +	ksproc->kick_gpio = gpiod_get(dev, "kick", GPIOD_ASIS);
> +	ret = PTR_ERR_OR_ZERO(ksproc->kick_gpio);
> +	if (ret) {
>  		dev_err(dev, "failed to get gpio for virtio kicks, status = %d\n",
>  			ret);
>  		goto disable_clk;
> @@ -466,6 +466,7 @@ static int keystone_rproc_probe(struct platform_device *pdev)
>  
>  release_mem:
>  	of_reserved_mem_device_release(dev);
> +	gpiod_put(ksproc->kick_gpio);
>  disable_clk:
>  	pm_runtime_put_sync(dev);
>  disable_rpm:
> @@ -480,6 +481,7 @@ static int keystone_rproc_remove(struct platform_device *pdev)
>  	struct keystone_rproc *ksproc = platform_get_drvdata(pdev);
>  
>  	rproc_del(ksproc->rproc);
> +	gpiod_put(ksproc->kick_gpio);
>  	pm_runtime_put_sync(&pdev->dev);
>  	pm_runtime_disable(&pdev->dev);
>  	rproc_free(ksproc->rproc);
> -- 
> 2.37.2.789.g6183377224-goog
> 
> 
> -- 
> Dmitry

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

* Re: [RFC/PATCH] remoteproc/keystone: switch to using gpiod API
  2022-09-08 21:57 ` Mathieu Poirier
@ 2022-09-19 20:09   ` Mathieu Poirier
  0 siblings, 0 replies; 4+ messages in thread
From: Mathieu Poirier @ 2022-09-19 20:09 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Bjorn Andersson, Suman Anna, Linus Walleij, linux-remoteproc,
	linux-kernel, kishon, danishanwar, nm, vigneshr,
	grygorii.strashko

On Thu, Sep 08, 2022 at 03:57:47PM -0600, Mathieu Poirier wrote:
> On Tue, Sep 06, 2022 at 02:08:33PM -0700, Dmitry Torokhov wrote:
> > This patch switches the driver away from legacy gpio/of_gpio API to
> > gpiod API, and removes use of of_get_named_gpio_flags() which I want to
> > make private to gpiolib.
> > 
> > Note that there is a behavior change in the driver: previously the
> > driver did not actually request GPIO, it simply parsed GPIO number out
> > of device tree and poked at it.
> > 
> > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > ---
> >  drivers/remoteproc/keystone_remoteproc.c | 16 +++++++++-------
> >  1 file changed, 9 insertions(+), 7 deletions(-)
> 
> This change looks good to me but I would like someone from the TI brigade test
> this before applying it.
>

Applied.

> Thanks,
> Mathieu
> 
> > 
> > diff --git a/drivers/remoteproc/keystone_remoteproc.c b/drivers/remoteproc/keystone_remoteproc.c
> > index 594a9b43b7ae..95b39741925d 100644
> > --- a/drivers/remoteproc/keystone_remoteproc.c
> > +++ b/drivers/remoteproc/keystone_remoteproc.c
> > @@ -14,7 +14,7 @@
> >  #include <linux/workqueue.h>
> >  #include <linux/of_address.h>
> >  #include <linux/of_reserved_mem.h>
> > -#include <linux/of_gpio.h>
> > +#include <linux/gpio/consumer.h>
> >  #include <linux/regmap.h>
> >  #include <linux/mfd/syscon.h>
> >  #include <linux/remoteproc.h>
> > @@ -59,10 +59,10 @@ struct keystone_rproc {
> >  	int num_mems;
> >  	struct regmap *dev_ctrl;
> >  	struct reset_control *reset;
> > +	struct gpio_desc *kick_gpio;
> >  	u32 boot_offset;
> >  	int irq_ring;
> >  	int irq_fault;
> > -	int kick_gpio;
> >  	struct work_struct workqueue;
> >  };
> >  
> > @@ -232,10 +232,10 @@ static void keystone_rproc_kick(struct rproc *rproc, int vqid)
> >  {
> >  	struct keystone_rproc *ksproc = rproc->priv;
> >  
> > -	if (WARN_ON(ksproc->kick_gpio < 0))
> > +	if (!ksproc->kick_gpio)
> >  		return;
> >  
> > -	gpio_set_value(ksproc->kick_gpio, 1);
> > +	gpiod_set_value(ksproc->kick_gpio, 1);
> >  }
> >  
> >  /*
> > @@ -432,9 +432,9 @@ static int keystone_rproc_probe(struct platform_device *pdev)
> >  		goto disable_clk;
> >  	}
> >  
> > -	ksproc->kick_gpio = of_get_named_gpio_flags(np, "kick-gpios", 0, NULL);
> > -	if (ksproc->kick_gpio < 0) {
> > -		ret = ksproc->kick_gpio;
> > +	ksproc->kick_gpio = gpiod_get(dev, "kick", GPIOD_ASIS);
> > +	ret = PTR_ERR_OR_ZERO(ksproc->kick_gpio);
> > +	if (ret) {
> >  		dev_err(dev, "failed to get gpio for virtio kicks, status = %d\n",
> >  			ret);
> >  		goto disable_clk;
> > @@ -466,6 +466,7 @@ static int keystone_rproc_probe(struct platform_device *pdev)
> >  
> >  release_mem:
> >  	of_reserved_mem_device_release(dev);
> > +	gpiod_put(ksproc->kick_gpio);
> >  disable_clk:
> >  	pm_runtime_put_sync(dev);
> >  disable_rpm:
> > @@ -480,6 +481,7 @@ static int keystone_rproc_remove(struct platform_device *pdev)
> >  	struct keystone_rproc *ksproc = platform_get_drvdata(pdev);
> >  
> >  	rproc_del(ksproc->rproc);
> > +	gpiod_put(ksproc->kick_gpio);
> >  	pm_runtime_put_sync(&pdev->dev);
> >  	pm_runtime_disable(&pdev->dev);
> >  	rproc_free(ksproc->rproc);
> > -- 
> > 2.37.2.789.g6183377224-goog
> > 
> > 
> > -- 
> > Dmitry

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

end of thread, other threads:[~2022-09-19 20:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-06 21:08 [RFC/PATCH] remoteproc/keystone: switch to using gpiod API Dmitry Torokhov
2022-09-07 21:48 ` Linus Walleij
2022-09-08 21:57 ` Mathieu Poirier
2022-09-19 20:09   ` Mathieu Poirier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox