mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: <patrice.chotard.st@gmail.com>
To: <linux-kernel@vger.kernel.org>, Linus Walleij <linus.walleij@linaro.org>
Cc: Olivier Clergeaud <olivier.clergeaud@st.com>,
	Lee Jones <lee.jones@linaro.org>,
	Fabio Baltieri <fabio.baltieri@linaro.org>,
	Patrice Chotard <patrice.chotard@st.com>
Subject: [PATCH 2/2] pinctrl: abx500: fix abx500_gpio_get()
Date: Thu, 20 Jun 2013 09:24:44 +0200	[thread overview]
Message-ID: <1371713084-19098-3-git-send-email-patrice.chotard.st@gmail.com> (raw)
In-Reply-To: <1371713084-19098-1-git-send-email-patrice.chotard.st@gmail.com>

From: Patrice Chotard <patrice.chotard@st.com>

_ allow to get output GPIO value.
_ as there is no GPIO0 on ABX500, use correct offset with 
  abx500_gpio_get_bit().

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
---
 drivers/pinctrl/pinctrl-abx500.c |   16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-abx500.c b/drivers/pinctrl/pinctrl-abx500.c
index 4307b0f..070442d 100644
--- a/drivers/pinctrl/pinctrl-abx500.c
+++ b/drivers/pinctrl/pinctrl-abx500.c
@@ -162,10 +162,22 @@ static int abx500_gpio_get(struct gpio_chip *chip, unsigned offset)
 {
 	struct abx500_pinctrl *pct = to_abx500_pinctrl(chip);
 	bool bit;
+	bool is_out;
+	u8 gpio_offset = offset - 1;
 	int ret;
 
-	ret = abx500_gpio_get_bit(chip, AB8500_GPIO_IN1_REG,
-				  offset, &bit);
+	ret = abx500_gpio_get_bit(chip, AB8500_GPIO_DIR1_REG, gpio_offset, &is_out);
+	if (ret < 0) {
+		dev_err(pct->dev, "%s failed\n", __func__);
+		return ret;
+	}
+
+	if (is_out)
+		ret = abx500_gpio_get_bit(chip, AB8500_GPIO_OUT1_REG,
+				gpio_offset, &bit);
+	else
+		ret = abx500_gpio_get_bit(chip, AB8500_GPIO_IN1_REG,
+				gpio_offset, &bit);
 	if (ret < 0) {
 		dev_err(pct->dev, "%s failed\n", __func__);
 		return ret;
-- 
1.7.10


  parent reply	other threads:[~2013-06-20  7:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-20  7:24 [PATCH 0/2] pinctrl: ABX500: fix patrice.chotard.st
2013-06-20  7:24 ` [PATCH 1/2] pinctrl: abx500: suppress hardcoded value patrice.chotard.st
2013-06-20  7:24 ` patrice.chotard.st [this message]
2013-06-20  9:00   ` [PATCH 2/2] pinctrl: abx500: fix abx500_gpio_get() Fabio Baltieri
2013-06-20 11:26     ` Patrice Chotard

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=1371713084-19098-3-git-send-email-patrice.chotard.st@gmail.com \
    --to=patrice.chotard.st@gmail.com \
    --cc=fabio.baltieri@linaro.org \
    --cc=lee.jones@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=olivier.clergeaud@st.com \
    --cc=patrice.chotard@st.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

all inboxes | Powered by JetHome®