20 #include <linux/ctype.h>
21 #include <linux/module.h>
24 #include <linux/slab.h>
71 return OF_ROOT_NODE_ADDR_CELLS_DEFAULT;
87 return OF_ROOT_NODE_SIZE_CELLS_DEFAULT;
91 #if defined(CONFIG_OF_DYNAMIC)
102 kref_get(&node->
kref);
119 static void of_node_release(
struct kref *
kref)
121 struct device_node *node = kref_to_device_node(kref);
125 if (!of_node_check_flag(node, OF_DETACHED)) {
128 kref_init(&node->
kref);
132 if (!of_node_check_flag(node, OF_DYNAMIC))
161 kref_put(&node->
kref, of_node_release);
177 if (of_prop_cmp(pp->
name, name) == 0) {
238 if (of_compat_cmp(cp, compat,
strlen(compat)) == 0)
311 np = of_node_get(node->
parent);
336 parent = of_node_get(node->
parent);
358 if (of_node_get(next))
384 if (of_node_get(next))
410 if (child->
name && (of_node_cmp(child->
name, name) == 0))
457 if (np->
name && (of_node_cmp(np->
name, name) == 0)
486 if (np->
type && (of_node_cmp(np->
type, type) == 0)
518 && !(np->
type && (of_node_cmp(np->
type, type) == 0)))
542 const char *prop_name)
551 if (of_prop_cmp(pp->
name, prop_name) == 0) {
579 if (matches->
name[0])
582 if (matches->
type[0])
644 if (!compatible ||
strlen(compatible) > cplen)
646 p =
strchr(compatible,
',');
647 strlcpy(modalias, p ? p + 1 : compatible, len);
664 for (np = allnodes; np; np = np->
allnext)
689 const char *propname,
u32 *out_values,
699 if ((sz *
sizeof(*out_values)) > prop->
length)
731 if (
sizeof(*out_value) > prop->
length)
733 *out_value = of_read_number(prop->
value, 2);
754 const char **out_string)
763 *out_string = prop->
value;
787 int index,
const char **output)
791 size_t l = 0, total = 0;
803 for (i = 0; total < prop->
length; total +=
l, p +=
l) {
839 for (i = 0; p <
end; i++, p +=
l) {
843 pr_debug(
"comparing %s with %s\n",
string, p);
844 if (
strcmp(
string, p) == 0)
867 size_t l = 0, total = 0;
879 for (i = 0; total < prop->
length; total +=
l, p +=
l, i++)
903 if ((!phandle) || (size <
sizeof(*phandle) * (index + 1)))
943 const char *cells_name,
int index,
947 int size, cur_index = 0;
956 list_end = list + size /
sizeof(*list);
959 while (list < list_end) {
974 pr_err(
"%s: could not find phandle\n",
978 if (of_property_read_u32(node, cells_name, &count)) {
979 pr_err(
"%s: could not get %s for %s\n",
989 if (list + count > list_end) {
990 pr_err(
"%s: arguments longer than property\n",
1002 if (cur_index == index) {
1012 for (i = 0; i <
count; i++)
1037 unsigned long flags;
1043 if (
strcmp(prop->
name, (*next)->name) == 0) {
1048 next = &(*next)->
next;
1053 #ifdef CONFIG_PROC_DEVICETREE
1073 unsigned long flags;
1079 if (*next == prop) {
1087 next = &(*next)->
next;
1094 #ifdef CONFIG_PROC_DEVICETREE
1116 unsigned long flags;
1129 if (*next == oldprop) {
1138 next = &(*next)->
next;
1145 #ifdef CONFIG_PROC_DEVICETREE
1154 #if defined(CONFIG_OF_DYNAMIC)
1168 unsigned long flags;
1187 unsigned long flags;
1199 for (prev = allnodes;
1206 if (parent->
child == np)
1210 for (prevsib = np->
parent->child;
1217 of_node_set_flag(np, OF_DETACHED);
1225 int id,
const char *stem,
int stem_len)
1230 ap->
stem[stem_len] = 0;
1232 pr_debug(
"adding DT alias:%s: stem=%s id=%i node=%s\n",
1233 ap->
alias, ap->
stem, ap->
id, of_node_full_name(np));
1251 if (of_chosen ==
NULL)
1257 for_each_property_of_node(of_aliases, pp) {
1259 const char *
end = start +
strlen(start);
1276 while (
isdigit(*(end-1)) && end > start)
1284 ap = dt_alloc(
sizeof(*ap) + len + 1, 4);
1288 of_alias_add(ap, np,
id, start, len);
1310 if (np == app->
np) {
1324 const void *curv =
cur;
1334 curv +=
sizeof(*cur);
1346 const void *curv =
cur;