[PATCH 3/4] [POWERPC] CPM2: implement GPIO API

Anton Vorontsov cbouatmailru at gmail.com
Sat Dec 22 10:58:02 EST 2007


On Fri, Dec 21, 2007 at 10:16:32PM +0100, Arnd Bergmann wrote:
> On Friday 21 December 2007, Anton Vorontsov wrote:
> >  
> > +static spinlock_t cpm2_port_lock = __SPIN_LOCK_UNLOCKED(cpm2_port_lock);
> 
> This needs to be
> 
> static DEFINE_SPINLOCK(cpm2_port_lock);

These are equivalents.

#define DEFINE_SPINLOCK(x)      spinlock_t x = __SPIN_LOCK_UNLOCKED(x)

> I think at least lockdep doesn't work the way you do it here.

Is it anyhow special regarding what exact macro is used?..

spinlocks.txt says:

SPIN_LOCK_UNLOCKED and RW_LOCK_UNLOCKED defeat lockdep state tracking and
are hence deprecated.

Please use DEFINE_SPINLOCK()/DEFINE_RWLOCK() or
__SPIN_LOCK_UNLOCKED()/__RW_LOCK_UNLOCKED() as appropriate for static
initialization.
-

..should be equivalent, though I prefer open-coded version, until
it fits 80 column width. ;-)

> > +int cpm2_init_par_io(void)
> > +{
> > +	struct device_node *np;
> > +	const u32 *num_ports;
> > +
> > +	np = of_find_compatible_node(NULL, NULL, "fsl,cpm2-pario");
> > +	if (!np)
> > +		return -ENOENT;
> > +
> > +	num_ports = of_get_property(np, "num-ports", NULL);
> > +	if (!num_ports) {
> > +		of_node_put(np);
> > +		return -ENOENT;
> > +	}
> > +	cpm2_num_ports = *num_ports;
> > +
> > +	np->data = &of_gpio_chip;
> > +
> > +	return 0;
> > +}
> 
> This function should also do the call to of_iomap, so you don't
> need to pull the address out of the cpm2_immr, which I believe
> we're trying to get rid of.

Yup, thanks!

-- 
Anton Vorontsov
email: cbou at mail.ru
backup email: ya-cbou at yandex.ru
irc://irc.freenode.net/bd2



More information about the Linuxppc-dev mailing list