2 * Procedures for creating, accessing and interpreting the device tree.
4 * Paul Mackerras August 1996.
5 * Copyright (C) 1996-2005 Paul Mackerras.
7 * Adapted for 64bit PowerPC by Dave Engebretsen and Peter Bergner.
8 * {engebret|bergner}@us.ibm.com
10 * Adapted for sparc and sparc64 by David S. Miller davem@davemloft.net
12 * Reconsolidated from arch/x/kernel/prom.c by Stephen Rothwell.
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version
17 * 2 of the License, or (at your option) any later version.
19 #include <linux/module.h>
22 int of_n_addr_cells(struct device_node *np)
29 ip = of_get_property(np, "#address-cells", NULL);
33 /* No #address-cells property for the root node */
34 return OF_ROOT_NODE_ADDR_CELLS_DEFAULT;
36 EXPORT_SYMBOL(of_n_addr_cells);
38 int of_n_size_cells(struct device_node *np)
45 ip = of_get_property(np, "#size-cells", NULL);
49 /* No #size-cells property for the root node */
50 return OF_ROOT_NODE_SIZE_CELLS_DEFAULT;
52 EXPORT_SYMBOL(of_n_size_cells);
55 * Find a property with a given name for a given node
56 * and return the value.
58 const void *of_get_property(const struct device_node *np, const char *name,
61 struct property *pp = of_find_property(np, name, lenp);
63 return pp ? pp->value : NULL;
65 EXPORT_SYMBOL(of_get_property);
67 /** Checks if the given "compat" string matches one of the strings in
68 * the device's "compatible" property
70 int of_device_is_compatible(const struct device_node *device,
76 cp = of_get_property(device, "compatible", &cplen);
80 if (of_compat_cmp(cp, compat, strlen(compat)) == 0)
89 EXPORT_SYMBOL(of_device_is_compatible);