All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] NFC: PN544: use flags argument of devm_gpiod_get to set direction
@ 2015-05-19  7:22 Uwe Kleine-König
  2015-05-19 14:55 ` Linus Walleij
  2015-06-08 21:39 ` Samuel Ortiz
  0 siblings, 2 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2015-05-19  7:22 UTC (permalink / raw)
  To: Samuel Ortiz, Lauro Ramos Venancio, Aloisio Almeida Jr
  Cc: Robert Dolca, linux-wireless, kernel, Linus Walleij, Alexandre Courbot

Since 39b2bbe3d715 (gpio: add flags argument to gpiod_get*() functions)
which appeared in v3.17-rc1, the gpiod_get* functions take an additional
parameter that allows to specify direction and initial value for output.

Use this to simplify the driver. Furthermore this is one caller less
that stops us making the flags argument to gpiod_get*() mandatory.

While touching this also do some minor coding style fixes.

Fixes: 0a5942c8e148 ("NFC: Add ACPI support for NXP PN544")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/nfc/pn544/i2c.c | 43 +++++++++++--------------------------------
 1 file changed, 11 insertions(+), 32 deletions(-)

diff --git a/drivers/nfc/pn544/i2c.c b/drivers/nfc/pn544/i2c.c
index 6fd986f5ac3e..fa75c53f3fa5 100644
--- a/drivers/nfc/pn544/i2c.c
+++ b/drivers/nfc/pn544/i2c.c
@@ -895,56 +895,35 @@ static int pn544_hci_i2c_acpi_request_resources(struct i2c_client *client)
 		return -ENODEV;
 
 	/* Get EN GPIO from ACPI */
-	gpiod_en = devm_gpiod_get_index(dev, PN544_GPIO_NAME_EN, 1);
+	gpiod_en = devm_gpiod_get_index(dev, PN544_GPIO_NAME_EN, 1,
+					GPIOD_OUT_LOW);
 	if (IS_ERR(gpiod_en)) {
-		nfc_err(dev,
-			"Unable to get EN GPIO\n");
+		nfc_err(dev, "Unable to get EN GPIO\n");
 		return -ENODEV;
 	}
 
-	phy->gpio_en  = desc_to_gpio(gpiod_en);
-
-	/* Configuration EN GPIO */
-	ret = gpiod_direction_output(gpiod_en, 0);
-	if (ret) {
-		nfc_err(dev, "Fail EN pin direction\n");
-		return ret;
-	}
+	phy->gpio_en = desc_to_gpio(gpiod_en);
 
 	/* Get FW GPIO from ACPI */
-	gpiod_fw = devm_gpiod_get_index(dev, PN544_GPIO_NAME_FW, 2);
+	gpiod_fw = devm_gpiod_get_index(dev, PN544_GPIO_NAME_FW, 2,
+					GPIOD_OUT_LOW);
 	if (IS_ERR(gpiod_fw)) {
-		nfc_err(dev,
-			"Unable to get FW GPIO\n");
+		nfc_err(dev, "Unable to get FW GPIO\n");
 		return -ENODEV;
 	}
 
-	phy->gpio_fw  = desc_to_gpio(gpiod_fw);
-
-	/* Configuration FW GPIO */
-	ret = gpiod_direction_output(gpiod_fw, 0);
-	if (ret) {
-		nfc_err(dev, "Fail FW pin direction\n");
-		return ret;
-	}
+	phy->gpio_fw = desc_to_gpio(gpiod_fw);
 
 	/* Get IRQ GPIO */
-	gpiod_irq = devm_gpiod_get_index(dev, PN544_GPIO_NAME_IRQ, 0);
+	gpiod_irq = devm_gpiod_get_index(dev, PN544_GPIO_NAME_IRQ, 0,
+					 GPIOD_IN);
 	if (IS_ERR(gpiod_irq)) {
-		nfc_err(dev,
-			"Unable to get IRQ GPIO\n");
+		nfc_err(dev, "Unable to get IRQ GPIO\n");
 		return -ENODEV;
 	}
 
 	phy->gpio_irq = desc_to_gpio(gpiod_irq);
 
-	/* Configure IRQ GPIO */
-	ret = gpiod_direction_input(gpiod_irq);
-	if (ret) {
-		nfc_err(dev, "Fail IRQ pin direction\n");
-		return ret;
-	}
-
 	/* Map the pin to an IRQ */
 	ret = gpiod_to_irq(gpiod_irq);
 	if (ret < 0) {
-- 
2.1.4


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

* Re: [PATCH] NFC: PN544: use flags argument of devm_gpiod_get to set direction
  2015-05-19  7:22 [PATCH] NFC: PN544: use flags argument of devm_gpiod_get to set direction Uwe Kleine-König
@ 2015-05-19 14:55 ` Linus Walleij
  2015-06-08 21:39 ` Samuel Ortiz
  1 sibling, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2015-05-19 14:55 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Samuel Ortiz, Lauro Ramos Venancio, Aloisio Almeida Jr,
	Robert Dolca, linux-wireless, Sascha Hauer, Alexandre Courbot

On Tue, May 19, 2015 at 9:22 AM, Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:

> Since 39b2bbe3d715 (gpio: add flags argument to gpiod_get*() functions)
> which appeared in v3.17-rc1, the gpiod_get* functions take an additional
> parameter that allows to specify direction and initial value for output.
>
> Use this to simplify the driver. Furthermore this is one caller less
> that stops us making the flags argument to gpiod_get*() mandatory.
>
> While touching this also do some minor coding style fixes.
>
> Fixes: 0a5942c8e148 ("NFC: Add ACPI support for NXP PN544")

As noted on earlier patches: maybe this Fixes: is a bit aggressive.

> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

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

Yours,
Linus Walleij

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

* Re: [PATCH] NFC: PN544: use flags argument of devm_gpiod_get to set direction
  2015-05-19  7:22 [PATCH] NFC: PN544: use flags argument of devm_gpiod_get to set direction Uwe Kleine-König
  2015-05-19 14:55 ` Linus Walleij
@ 2015-06-08 21:39 ` Samuel Ortiz
  2015-06-15 20:54   ` Uwe Kleine-König
  1 sibling, 1 reply; 4+ messages in thread
From: Samuel Ortiz @ 2015-06-08 21:39 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Lauro Ramos Venancio, Aloisio Almeida Jr, Robert Dolca,
	linux-wireless, kernel, Linus Walleij, Alexandre Courbot

Hi Uwe,

On Tue, May 19, 2015 at 09:22:56AM +0200, Uwe Kleine-König wrote:
> Since 39b2bbe3d715 (gpio: add flags argument to gpiod_get*() functions)
> which appeared in v3.17-rc1, the gpiod_get* functions take an additional
> parameter that allows to specify direction and initial value for output.
> 
> Use this to simplify the driver. Furthermore this is one caller less
> that stops us making the flags argument to gpiod_get*() mandatory.
> 
> While touching this also do some minor coding style fixes.
> 
> Fixes: 0a5942c8e148 ("NFC: Add ACPI support for NXP PN544")
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
>  drivers/nfc/pn544/i2c.c | 43 +++++++++++--------------------------------
>  1 file changed, 11 insertions(+), 32 deletions(-)
Applied to nfc-next, thanks.

Cheers,
Samuel.

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

* Re: [PATCH] NFC: PN544: use flags argument of devm_gpiod_get to set direction
  2015-06-08 21:39 ` Samuel Ortiz
@ 2015-06-15 20:54   ` Uwe Kleine-König
  0 siblings, 0 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2015-06-15 20:54 UTC (permalink / raw)
  To: Samuel Ortiz
  Cc: Lauro Ramos Venancio, Aloisio Almeida Jr, Robert Dolca,
	linux-wireless, kernel, Linus Walleij, Alexandre Courbot

Hello Samuel,

On Mon, Jun 08, 2015 at 11:39:11PM +0200, Samuel Ortiz wrote:
> On Tue, May 19, 2015 at 09:22:56AM +0200, Uwe Kleine-König wrote:
> > Since 39b2bbe3d715 (gpio: add flags argument to gpiod_get*() functions)
> > which appeared in v3.17-rc1, the gpiod_get* functions take an additional
> > parameter that allows to specify direction and initial value for output.
> > 
> > Use this to simplify the driver. Furthermore this is one caller less
> > that stops us making the flags argument to gpiod_get*() mandatory.
> > 
> > While touching this also do some minor coding style fixes.
> > 
> > Fixes: 0a5942c8e148 ("NFC: Add ACPI support for NXP PN544")
> > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> > ---
> >  drivers/nfc/pn544/i2c.c | 43 +++++++++++--------------------------------
> >  1 file changed, 11 insertions(+), 32 deletions(-)
> Applied to nfc-next, thanks.
I wonder why nfs isn't included in next. At least this commit doesn't
show up there.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

end of thread, other threads:[~2015-06-15 20:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-19  7:22 [PATCH] NFC: PN544: use flags argument of devm_gpiod_get to set direction Uwe Kleine-König
2015-05-19 14:55 ` Linus Walleij
2015-06-08 21:39 ` Samuel Ortiz
2015-06-15 20:54   ` Uwe Kleine-König

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.