lkml.org 
[lkml]   [2009]   [Jun]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v4] gpio: driver for PrimeCell PL061 GPIO controller
On Wed, Jun 10, 2009 at 12:44:47AM -0700, 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?

I don't think so. This is just a warning. We do use this GPIO here, so I guess
we should keep it requested.

> Should the gpio core provide a primitive to check that a gpio has been
> properly requested rathe rthan open-coding it here?

Probably. The author (maintainer?) of gpiolib, David Brownell, is not
responsive at the moment. (I have an SPI master driver waiting for his
review/ack).

> > > > static void pl061_irq_handler(unsigned irq, struct irq_desc *desc)
> > > > {
> > > > + struct list_head *chip_list = get_irq_chip_data(irq);
> > > > + struct list_head *ptr;
> > > > + struct pl061_gpio *chip;
> > > > +
> > > > desc->chip->ack(irq);
> > > > - while (1) {
> > > > + list_for_each(ptr, chip_list) {
> > >
> > > What locking protects the newly-added list?
> >
> > Do we need locking even though we list_add() only at probe time?
>
> Nope. I guess. It depends on the driver. hotplug/hot-remove needs to
> beconsidered often.
>
> > (Compiling as
> > a module is not supported, so this only happens at boot time).
>
> The probe handler is probably serialised against everything else even if
> the driver _is_ a module.

baruch

--
~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- baruch@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -


\
 
 \ /
  Last update: 2009-06-10 09:59    [W:0.047 / U:3.808 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site