static struct property * __init of_pdt_build_one_prop(phandle node, char *prev, char *special_name, void *special_val, int special_len) { static struct property *tmp = NULL; struct property *p; int err; if (tmp) { p = tmp; memset(p, 0, sizeof(*p) + 32); tmp = NULL; } else { p = prom_early_alloc(sizeof(struct property) + 32); of_pdt_incr_unique_id(p); } p->name = (char *) (p + 1); if (special_name) { strcpy(p->name, special_name); p->length = special_len; p->value = prom_early_alloc(special_len); memcpy(p->value, special_val, special_len); } else { err = of_pdt_prom_ops->nextprop(node, prev, p->name); if (err) { tmp = p; return NULL; } p->length = of_pdt_prom_ops->getproplen(node, p->name); if (p->length <= 0) { p->length = 0; } else { int len; p->value = prom_early_alloc(p->length + 1); len = of_pdt_prom_ops->getproperty(node, p->name, p->value, p->length); if (len <= 0) p->length = 0; ((unsigned char *)p->value)[p->length] = '\0'; } } return p; }
static struct device_node * __init of_pdt_create_node(phandle node, struct device_node *parent) { struct device_node *dp; if (!node) return NULL; dp = prom_early_alloc(sizeof(*dp)); of_node_init(dp); of_pdt_incr_unique_id(dp); dp->parent = parent; dp->name = of_pdt_get_one_property(node, "name"); dp->type = of_pdt_get_one_property(node, "device_type"); dp->phandle = node; dp->properties = of_pdt_build_prop_list(node); irq_trans_init(dp); return dp; }