public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Grant Likely <grant.likely@secretlab.ca>
Cc: linux-kernel@vger.kernel.org, sodaville@linutronix.de
Subject: [PATCH 1/2 v2] gpio/gpio-generic: read correct set register for caching if available
Date: Wed, 20 Jul 2011 09:24:32 +0200	[thread overview]
Message-ID: <20110720072432.GA20042@linutronix.de> (raw)
In-Reply-To: <20110704154447.GG29977@ponder.secretlab.ca>

The ->data is a shadow copy which is used during the ->set callback in
order to avoid a read of the register before write.
If ->reg_set is set then we write to this location therefore we should
cache that value.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
* Grant Likely | 2011-07-04 09:44:47 [-0600]:

>On most of the gpio controllers that I've seen, the 'set' register
>isn't something that you can actually read.  I don't think this is
>something that can be done for all gpio controllers.

I have reworked the part to only read the set register only if not
set/clear mode. Is this okay or are they any controller where this does
not work?

 drivers/gpio/gpio-generic.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/gpio/gpio-generic.c b/drivers/gpio/gpio-generic.c
index 231714d..5234b20 100644
--- a/drivers/gpio/gpio-generic.c
+++ b/drivers/gpio/gpio-generic.c
@@ -398,7 +398,10 @@ int __devinit bgpio_init(struct bgpio_chip *bgc,
 	if (ret)
 		return ret;
 
-	bgc->data = bgc->read_reg(bgc->reg_dat);
+	if (bgc->reg_set == bgpio_set_set)
+		bgc->data = bgc->read_reg(bgc->reg_set);
+	else if (bgc->reg_set == bgpio_set)
+		bgc->data = bgc->read_reg(bgc->reg_dat);
 
 	return ret;
 }
-- 
1.7.4.4


      parent reply	other threads:[~2011-07-20  7:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-27  7:26 [PATCH 1/2] gpio/gpio-generic: read set register for caching if available Sebastian Andrzej Siewior
2011-06-27  7:26 ` [PATCH v2 2/2] gpio: Add a driver for Sodaville GPIO controller Sebastian Andrzej Siewior
2011-06-27  9:33   ` Alan Cox
2011-06-27 10:34     ` Sebastian Andrzej Siewior
2011-07-04  7:26   ` [sodaville] " Sebastian Andrzej Siewior
2011-07-04 16:19   ` Grant Likely
2011-07-04 16:29     ` Sebastian Andrzej Siewior
2011-07-04 16:33       ` Grant Likely
2011-07-04 16:35         ` Grant Likely
2011-08-01 16:44           ` [sodaville] " Sebastian Andrzej Siewior
2011-07-04 15:44 ` [PATCH 1/2] gpio/gpio-generic: read set register for caching if available Grant Likely
2011-07-04 15:57   ` Sebastian Andrzej Siewior
2011-07-20  7:24   ` Sebastian Andrzej Siewior [this message]

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=20110720072432.GA20042@linutronix.de \
    --to=bigeasy@linutronix.de \
    --cc=grant.likely@secretlab.ca \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sodaville@linutronix.de \
    /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