public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Felipe Balbi <felipe.balbi@nokia.com>
To: ext Andrew Morton <akpm@linux-foundation.org>
Cc: Baruch Siach <baruch@tkos.co.il>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"dbrownell@users.sourceforge.net"
	<dbrownell@users.sourceforge.net>,
	"linux-arm-kernel@lists.arm.linux.org.uk" 
	<linux-arm-kernel@lists.arm.linux.org.uk>,
	"linux@arm.linux.org.uk" <linux@arm.linux.org.uk>
Subject: Re: [PATCH v4] gpio: driver for PrimeCell PL061 GPIO controller
Date: Wed, 10 Jun 2009 10:48:39 +0300	[thread overview]
Message-ID: <20090610074839.GB27385@nokia.com> (raw)
In-Reply-To: <20090610004447.78b84cd5.akpm@linux-foundation.org>

Hi,

On Wed, Jun 10, 2009 at 09:44:47AM +0200, ext Andrew Morton wrote:
> On Wed, 10 Jun 2009 10:22:31 +0300 Baruch Siach <baruch@tkos.co.il> wrote:
> 
> > Hi Andrew,
> > 
> > > >  static unsigned int pl061_irq_startup(unsigned irq)
> > > >  {
> > > > -	int ret;
> > > > -
> > > > -	ret = gpio_request(irq_to_gpio(irq), "IRQ");
> > > > -	if (ret < 0) {
> > > > -		pr_warning("%s: warning: gpio_request(%d) returned %d\n",
> > > > -				__func__, irq_to_gpio(irq), ret);
> > > > -		return 0;
> > > > -	}
> > > > +	if (gpio_request(irq_to_gpio(irq), "IRQ") == 0)
> > > > +		pr_warning("%s: warning: GPIO%d has not been requested\n",
> > > > +				__func__, irq_to_gpio(irq));
> > > 
> > > This is wrong, isn't it?  gpio_request() returns 0 on success.
> > 
> > Russell said that gpio configuration is the responsibility of the platform 
> > code. Here I just warn when the gpio has not been requested, and thus 
> > gpio_request() succeeds. I'll add a comment.
> 
> OK.
> 
> If the gpio_request() accidentally succeeded, should we gpio_free() the
> result here?
> 
> Should the gpio core provide a primitive to check that a gpio has been
> properly requested rathe rthan open-coding it here?

how about passing a setup() and cleanup() pointers via platform_data to the driver ?

Then, during probe(), the driver calls setup() which would
gpio_request() and during remove() it calls cleanup() to gpio_free();

would that be ok ?

-- 
balbi

  reply	other threads:[~2009-06-10  7:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-07 18:38 [PATCH v4] gpio: driver for PrimeCell PL061 GPIO controller Baruch Siach
2009-06-07 21:33 ` Linus Walleij
2009-06-07 21:45   ` Russell King - ARM Linux
2009-06-07 22:25     ` Linus Walleij
2009-06-07 22:32   ` Linus Walleij
2009-06-09 21:02 ` Andrew Morton
2009-06-10  7:22   ` Baruch Siach
2009-06-10  7:44     ` Andrew Morton
2009-06-10  7:48       ` Felipe Balbi [this message]
2009-06-10  7:56       ` Baruch Siach
2009-06-15 23:33         ` David Brownell

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=20090610074839.GB27385@nokia.com \
    --to=felipe.balbi@nokia.com \
    --cc=akpm@linux-foundation.org \
    --cc=baruch@tkos.co.il \
    --cc=dbrownell@users.sourceforge.net \
    --cc=linux-arm-kernel@lists.arm.linux.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    /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