public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Anton Vorontsov <cbouatmailru@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: David Brownell <david-b@pacbell.net>,
	Samuel Ortiz <sameo@linux.intel.com>,
	Mark Brown <broonie@opensource.wolfsonmicro.com>,
	David Brownell <dbrownell@users.sourceforge.net>,
	Alan Cox <alan@lxorguk.ukuu.org.uk>,
	linux-kernel@vger.kernel.org
Subject: [PATCH v7-fix] gpio: Add driver for basic memory-mapped GPIO controllers (fix)
Date: Tue, 28 Sep 2010 16:40:41 +0400	[thread overview]
Message-ID: <20100928124041.GA27783@oksana.dev.rtsoft.ru> (raw)
In-Reply-To: <20100924144535.3714beab.akpm@linux-foundation.org>

On Fri, Sep 24, 2010 at 02:45:35PM -0700, Andrew Morton wrote:
> It would be good to document `bits' and `big_endian_bits', and to
> describe what `lock' locks.

Done.

> > +static int bgpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
> > +{
> > +	return 0;
> > +}
> 
> hm, what does this mean.  The hardware cannot set pin directions to
> "in"?

Nope, 0 is the success. The hardware cannot set pin directions
at all (well, some hw can, but we don't support these yet).

> > +	return gpiochip_add(&bgc->gc);
> > +}
> 
> If this function returns -EINVAL then much head-scratching will ensue. 
> It might make your life easier to emit a diagnostic just before the
> failure so you can work out why it failed.

OK.

Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
---

Thanks!

 drivers/gpio/basic_mmio_gpio.c |   22 +++++++++++++++++++---
 1 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/basic_mmio_gpio.c b/drivers/gpio/basic_mmio_gpio.c
index c2c11e7..3addea6 100644
--- a/drivers/gpio/basic_mmio_gpio.c
+++ b/drivers/gpio/basic_mmio_gpio.c
@@ -66,12 +66,23 @@ struct bgpio_chip {
 	void __iomem *reg_dat;
 	void __iomem *reg_set;
 	void __iomem *reg_clr;
-	spinlock_t lock;
 
+	/* Number of bits (GPIOs): <register width> * 8. */
 	int bits;
+
+	/*
+	 * Some GPIO controllers work with the big-endian bits notation,
+	 * e.g. in a 8-bits register, GPIO7 is the least significant bit.
+	 */
 	int big_endian_bits;
 
-	/* shadowed data register to clear/set bits safely */
+	/*
+	 * Used to lock bgpio_chip->data. Also, this is needed to keep
+	 * shadowed and real data registers writes together.
+	 */
+	spinlock_t lock;
+
+	/* Shadowed data register to clear/set bits safely. */
 	unsigned long data;
 };
 
@@ -181,6 +192,7 @@ static int __devinit bgpio_probe(struct platform_device *pdev)
 	struct resource *res_clr;
 	resource_size_t dat_sz;
 	int bits;
+	int ret;
 
 	res_dat = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dat");
 	if (!res_dat)
@@ -238,7 +250,11 @@ static int __devinit bgpio_probe(struct platform_device *pdev)
 
 	dev_set_drvdata(dev, bgc);
 
-	return gpiochip_add(&bgc->gc);
+	ret = gpiochip_add(&bgc->gc);
+	if (ret)
+		dev_err(dev, "gpiochip_add() failed: %d\n", ret);
+
+	return ret;
 }
 
 static int __devexit bgpio_remove(struct platform_device *pdev)
-- 
1.7.0.5


  reply	other threads:[~2010-09-28 12:40 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-25 19:42 [PATCH] gpio: Add generic driver for simple memory mapped controllers Anton Vorontsov
     [not found] ` <921098.64431.qm@web180306.mail.gq1.yahoo.com>
2010-08-26  5:17   ` Anton Vorontsov
2010-08-26 16:22     ` David Brownell
2010-08-26 16:48       ` Alan Cox
2010-08-26 17:34         ` David Brownell
2010-08-26 18:36           ` Mark Brown
2010-08-26 21:07           ` Alan Cox
2010-08-26 22:58             ` David Brownell
2010-08-27  0:15               ` Alan Cox
2010-08-26 17:26       ` [PATCH v2] gpio: Add driver for Anton GPIO controllers Anton Vorontsov
2010-08-26 17:57         ` David Brownell
2010-08-26 21:20           ` Anton Vorontsov
2010-08-26 22:48             ` David Brownell
2010-08-27 15:57               ` [PATCH v3] gpio: Add driver for basic memory-mapped " Anton Vorontsov
2010-08-28 19:08                 ` David Brownell
2010-08-29 21:28                   ` [PATCH v4] " Anton Vorontsov
2010-08-30 20:23                     ` David Brownell
2010-08-31 17:58                       ` [PATCH v5] " Anton Vorontsov
2010-08-31 18:21                         ` Mark Brown
2010-08-31 20:32                         ` David Brownell
2010-09-01 19:52                           ` [PATCH v6] " Anton Vorontsov
2010-09-07 14:01                           ` [PATCH v7] " Anton Vorontsov
2010-09-21 22:23                             ` Anton Vorontsov
2010-09-24 21:45                             ` Andrew Morton
2010-09-28 12:40                               ` Anton Vorontsov [this message]
2010-08-26 18:38 ` [PATCH] gpio: Add generic driver for simple memory mapped controllers Mark Brown

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=20100928124041.GA27783@oksana.dev.rtsoft.ru \
    --to=cbouatmailru@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=david-b@pacbell.net \
    --cc=dbrownell@users.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --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