Hi Grant,
On Mon, 04 Feb 2008 09:16:08 -0700 Grant Likely [off-list ref] wrote:
From: Grant Likely <redacted>
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@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/