[RFC/PATCH 4/4] Add support for MSI on Axon-based Cell systems

Michael Ellerman michael at ellerman.id.au
Tue Jun 12 12:32:14 EST 2007


On Fri, 2007-06-08 at 22:16 +0200, Segher Boessenkool wrote:
> > If you do
> >
> > for_each_compatible_node(node, NULL, "foo") {
> > 	do_something(node);
> > }
> >
> > then the reference count is held just as long as the do_something()
> > function is run,
> 
> Yeah.  so (like we discussed on irc) the of_node_get() in
> the code under discussion should really be done inside the
> axon_msi_setup_one() function.

Yep.

> > and if you do
> >
> > for_each_compatible_node(node, NULL, "foo")
> > 	if (conditional_func(node))
> > 		break;
> >
> > then the node variable will have the reference count.
> 
> Yes.  This is bad form though, "for_each" means for
> _each_, open coding the loop would be clearer IMHO.

No. That just means more places people can get the refcounting wrong.

If in doubt, just do:

for_each_compatible_node(node, NULL, "foo") {
   ..
}

...

of_node_put(node);

And then you're free to do whatever inside the loop, including breaking
out.

cheers

-- 
Michael Ellerman
OzLabs, IBM Australia Development Lab

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://lists.ozlabs.org/pipermail/linuxppc-dev/attachments/20070612/5fcde99b/attachment.pgp>


More information about the Linuxppc-dev mailing list