netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Robert Dolca <robert.dolca@intel.com>
Cc: linux-nfc@ml01.01.org,
	Lauro Ramos Venancio <lauro.venancio@openbossa.org>,
	Aloisio Almeida Jr <aloisio.almeida@openbossa.org>,
	Samuel Ortiz <sameo@linux.intel.com>,
	linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org,
	netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
	Berg Johannes <johannes.berg@intel.com>,
	Clement Perrochaud <clement.perrochaud@nxp.com>
Subject: Re: [PATCH v2 2/2] NFC: Add ACPI support for NXP PN544
Date: Thu, 12 Feb 2015 09:14:59 +0100	[thread overview]
Message-ID: <20150212081459.GA28954@pengutronix.de> (raw)
In-Reply-To: <1422270817-10950-3-git-send-email-robert.dolca@intel.com>

Hello,

On Mon, Jan 26, 2015 at 01:13:37PM +0200, Robert Dolca wrote:
> +	/* Get EN GPIO from ACPI */
> +	gpiod_en = devm_gpiod_get_index(dev, PN544_GPIO_NAME_EN, 1);
Actually devm_gpiod_get_index takes 4 arguments. In your case you should
also pass GPIOD_OUT_LOW, then you can skip the gpiod_direction_output
part below.

> +	if (IS_ERR(gpiod_en)) {
> +		nfc_err(dev,
> +			"Unable to get EN GPIO\n");
> +		return -ENODEV;
> +	}
> +
> +	phy->gpio_en  = desc_to_gpio(gpiod_en);
Why don't you save a reference to the gpiod instead? Mixing usage of raw
and gpiod might result in surprising results. For example

	gpiod_direction_output(gpiod_en, 0);

might actually have the same result as

	gpio_direction_output(gpio_en, 1);

if the matching gpio is marked as active low.

> +
> +	/* Configuration EN GPIO */
> +	ret = gpiod_direction_output(gpiod_en, 0);
> +	if (ret) {
> +		nfc_err(dev, "Fail EN pin direction\n");
> +		return ret;
> +	}
> +
> +	/* Get FW GPIO from ACPI */
> +	gpiod_fw = devm_gpiod_get_index(dev, PN544_GPIO_NAME_FW, 2);
> +	if (IS_ERR(gpiod_fw)) {
> +		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;
> +	}
The same comments apply here.

> +
> +	/* Get IRQ GPIO */
> +	gpiod_irq = devm_gpiod_get_index(dev, PN544_GPIO_NAME_IRQ, 0);
> +	if (IS_ERR(gpiod_irq)) {
> +		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) {
> +		nfc_err(dev, "Fail pin IRQ mapping\n");
> +		return ret;
> +	}
and here.

Best regards
Uwe

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

  parent reply	other threads:[~2015-02-12  8:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-26 11:13 [PATCH v2 0/2] Add ACPI support for NXP PN544 Robert Dolca
2015-01-26 11:13 ` [PATCH v2 1/2] NFC: PN544: GPIO access that may sleep Robert Dolca
2015-01-26 11:13 ` [PATCH v2 2/2] NFC: Add ACPI support for NXP PN544 Robert Dolca
2015-01-27 23:28   ` Samuel Ortiz
2015-02-12  8:14   ` Uwe Kleine-König [this message]
2015-02-12 17:48     ` Robert Dolca
2015-02-12 19:26       ` Uwe Kleine-König
2015-01-27 23:29 ` [PATCH v2 0/2] " Samuel Ortiz

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=20150212081459.GA28954@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=aloisio.almeida@openbossa.org \
    --cc=clement.perrochaud@nxp.com \
    --cc=davem@davemloft.net \
    --cc=johannes.berg@intel.com \
    --cc=lauro.venancio@openbossa.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfc@ml01.01.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=robert.dolca@intel.com \
    --cc=sameo@linux.intel.com \
    /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;
as well as URLs for NNTP newsgroup(s).