[PATCH] [POWERPC] of: add alias helper functions.
Stephen Rothwell
sfr at canb.auug.org.au
Tue Feb 5 15:21:29 EST 2008
Hi Grant,
On Mon, 04 Feb 2008 09:16:08 -0700 Grant Likely <grant.likely at secretlab.ca> wrote:
>
> From: Grant Likely <grant.likely at secretlab.ca>
>
> Add helper functions for translating back and forth between alias
> properties and device tree nodes.
Do you have a use for this yet (I assume you do - it would be nice to
have a reason in the changelog)?
Overall looks ok, just a few comments?
Dave (Miller) is this useful for Sparc?
> +struct device_node *of_find_node_by_alias(const char *alias)
> +{
> + struct device_node *np, *alias_np;
> + const char *path;
> +
> + np = NULL;
struct device_node *np = NULL;
struct device_node *alias_np;
> +const char *of_node_alias(struct device_node *np, const char *prefix)
> + /* Loop over the aliases looking for a match */
> + alias = NULL;
> + for (pp = alias_np->properties; pp != 0; pp = pp->next) {
^
Use NULL for pointers (or just test "pp").
> + if (test_np == np)
> + alias = pp->name + prefix_len;
> + of_node_put(test_np);
> + if (alias)
> + break;
This could be:
of_node_put(test_np);
if (test_np == np) {
alias = pp->name + prefix_len;
break;
}
As you can still test for pointer equality after dropping the ref count.
--
Cheers,
Stephen Rothwell sfr at canb.auug.org.au
http://www.canb.auug.org.au/~sfr/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/linuxppc-dev/attachments/20080205/2224dacc/attachment.pgp>
More information about the Linuxppc-dev
mailing list