public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Jean-François Dagenais" <jeff.dagenais@gmail.com>
To: grant.likely@secretlab.ca, dtor@mail.ru,
	dmitry.torokhov@gmail.com, linus.walleij@stericsson.com,
	linux-kernel@vger.kernel.org
Cc: linux-input@vger.kernel.org, michael.hennerich@analog.com,
	"Jean-François Dagenais" <jeff.dagenais@gmail.com>
Subject: [PATCH 2/2] gpio: adp5588 - get value from data out when dir out
Date: Fri, 20 Apr 2012 11:32:01 -0400	[thread overview]
Message-ID: <1334935921-13016-2-git-send-email-jeff.dagenais@gmail.com> (raw)
In-Reply-To: <1334935921-13016-1-git-send-email-jeff.dagenais@gmail.com>

As discussed here: http://ez.analog.com/message/35852,
the 5587 revC and 5588 revB spec sheets contain a mistake
in the GPIO_DAT_STATx register description.

According to R.Shnell at ADI, as well as my own
observations, it should read:
"GPIO data status (shows GPIO state when read for inputs)".

This commit changes the get value function accordingly.

Follows a similar patch for adp5588-keys.

Signed-off-by: Jean-François Dagenais <jeff.dagenais@gmail.com>
Acked-by: Michael Hennerich <michael.hennerich@analog.com>
---
 drivers/gpio/gpio-adp5588.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/drivers/gpio/gpio-adp5588.c b/drivers/gpio/gpio-adp5588.c
index 3122713..293ddb6 100644
--- a/drivers/gpio/gpio-adp5588.c
+++ b/drivers/gpio/gpio-adp5588.c
@@ -65,11 +65,23 @@ static int adp5588_gpio_write(struct i2c_client *client, u8 reg, u8 val)
 
 static int adp5588_gpio_get_value(struct gpio_chip *chip, unsigned off)
 {
+	unsigned bank, bit;
 	struct adp5588_gpio *dev =
 	    container_of(chip, struct adp5588_gpio, gpio_chip);
 
+	bank = ADP5588_BANK(off);
+	bit = ADP5588_BIT(off);
+
+	mutex_lock(&dev->lock);
+	if (dev->dir[bank] & bit) {
+		int result = !!(dev->dat_out[bank] & bit);
+		mutex_unlock(&dev->lock);
+		return result;
+	}
+	mutex_unlock(&dev->lock);
+
 	return !!(adp5588_gpio_read(dev->client,
-		  GPIO_DAT_STAT1 + ADP5588_BANK(off)) & ADP5588_BIT(off));
+		  GPIO_DAT_STAT1 + bank) & bit);
 }
 
 static void adp5588_gpio_set_value(struct gpio_chip *chip,
-- 
1.7.9


  reply	other threads:[~2012-04-20 15:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-20 15:32 [PATCH 1/2] input: adp5588-keys - get value from data out when dir out Jean-François Dagenais
2012-04-20 15:32 ` Jean-François Dagenais [this message]
2012-04-21  6:47 ` Dmitry Torokhov
2012-04-24 13:33   ` Jean-Francois Dagenais
  -- strict thread matches above, loose matches on Subject: below --
2012-01-09 15:05 Jean-François Dagenais
2012-01-09 15:05 ` [PATCH 2/2] gpio: adp5588 " Jean-François Dagenais

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=1334935921-13016-2-git-send-email-jeff.dagenais@gmail.com \
    --to=jeff.dagenais@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=dtor@mail.ru \
    --cc=grant.likely@secretlab.ca \
    --cc=linus.walleij@stericsson.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.hennerich@analog.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