[PATCH 4/5] [POWERPC] QE: implement support for the GPIO LIB API

Anton Vorontsov avorontsov at ru.mvista.com
Tue Apr 22 00:49:38 EST 2008


On Mon, Apr 21, 2008 at 06:33:13PM +0400, Anton Vorontsov wrote:
[...]
> > >  +static int __init qe_add_gpiochips(void)
> > >  +{
> > >  +       int ret;
> > >  +       struct device_node *np;
> > >  +
> > >  +       for_each_compatible_node(np, NULL, "fsl,qe-pario-bank") {
> > >  +               struct qe_gpio_chip *qe_gc;
> > >  +               struct of_mm_gpio_chip *mm_gc;
> > >  +               struct of_gpio_chip *of_gc;
> > >  +               struct gpio_chip *gc;
> > >  +
> > >  +               qe_gc = kzalloc(sizeof(*qe_gc), GFP_KERNEL);
> > >  +               if (!qe_gc) {
> > >  +                       ret = -ENOMEM;
> > >  +                       goto err;
> > >  +               }
> > >  +
> > >  +               spin_lock_init(&qe_gc->lock);
> > >  +
> > >  +               mm_gc = &qe_gc->mm_gc;
> > >  +               of_gc = &mm_gc->of_gc;
> > >  +               gc = &of_gc->gc;
> > >  +
> > >  +               mm_gc->save_regs = qe_gpio_save_regs;
> > >  +               of_gc->gpio_cells = 2;
> > >  +               gc->ngpio = QE_PIO_PINS;
> > >  +               gc->direction_input = qe_gpio_dir_in;
> > >  +               gc->direction_output = qe_gpio_dir_out;
> > >  +               gc->get = qe_gpio_get;
> > >  +               gc->set = qe_gpio_set;
> > >  +
> > >  +               ret = of_mm_gpiochip_add(np, mm_gc);
> > >  +               if (ret)
> > >  +                       goto err;
> > >  +       }
> > >  +
> > >  +       return 0;
> > >  +err:
> > >  +       pr_err("%s: registration failed with status %d\n", np->full_name, ret);
> > >  +       of_node_put(np);
> > >  +       return ret;
> > >  +}
> > >  +arch_initcall(qe_add_gpiochips);
> > 
> > Should this really be a arch_initcall()?  Would it be better for
> > platforms needing it to call it explicitly from one of the platform's
> > machine_arch_initcall()?  Otherwise it gets called for all platforms
> > in a multiplatform kernel.
> 
> Ok, I'll place it into qe_reset().

Ugh, no, I can't. qe_reset() is called too early. And I don't like
having every QE board file to call this through machine_arch_initcall...
Hmm, what to do.. well, is this thaat bad to call this for every
platform?..

-- 
Anton Vorontsov
email: cbouatmailru at gmail.com
irc://irc.freenode.net/bd2



More information about the Linuxppc-dev mailing list