Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 233801
b: refs/heads/master
c: a74ea43
h: refs/heads/master
i:
  233799: e74da18
v: v3
  • Loading branch information
Andres Salomon authored and Grant Likely committed Mar 2, 2011
1 parent 11e95e1 commit b93d57d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 71 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 60cba5a57b8affe98ea9f2bac147be0fb253d5f4
refs/heads/master: a74ea43df1afc68f265c0ac2cb64031d855ae97b
112 changes: 42 additions & 70 deletions trunk/drivers/of/pdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,55 @@ unsigned int of_pdt_unique_id __initdata;
(p)->unique_id = of_pdt_unique_id++; \
} while (0)

static inline const char *of_pdt_node_name(struct device_node *dp)
static char * __init of_pdt_build_full_name(struct device_node *dp)
{
return dp->path_component_name;
int len, ourlen, plen;
char *n;

dp->path_component_name = build_path_component(dp);

plen = strlen(dp->parent->full_name);
ourlen = strlen(dp->path_component_name);
len = ourlen + plen + 2;

n = prom_early_alloc(len);
strcpy(n, dp->parent->full_name);
if (!of_node_is_root(dp->parent)) {
strcpy(n + plen, "/");
plen++;
}
strcpy(n + plen, dp->path_component_name);

return n;
}

#else
#else /* CONFIG_SPARC */

static inline void of_pdt_incr_unique_id(void *p) { }
static inline void irq_trans_init(struct device_node *dp) { }

static inline const char *of_pdt_node_name(struct device_node *dp)
static char * __init of_pdt_build_full_name(struct device_node *dp)
{
return dp->name;
static int failsafe_id = 0; /* for generating unique names on failure */
char *buf;
int len;

if (of_pdt_prom_ops->pkg2path(dp->phandle, NULL, 0, &len))
goto failsafe;

buf = prom_early_alloc(len + 1);
if (of_pdt_prom_ops->pkg2path(dp->phandle, buf, len, &len))
goto failsafe;
return buf;

failsafe:
buf = prom_early_alloc(strlen(dp->parent->full_name) +
strlen(dp->name) + 16);
sprintf(buf, "%s/%s@unknown%i",
of_node_is_root(dp->parent) ? "" : dp->parent->full_name,
dp->name, failsafe_id++);
pr_err("%s: pkg2path failed; assigning %s\n", __func__, buf);
return buf;
}

#endif /* !CONFIG_SPARC */
Expand Down Expand Up @@ -132,47 +168,6 @@ static char * __init of_pdt_get_one_property(phandle node, const char *name)
return buf;
}

static char * __init of_pdt_try_pkg2path(phandle node)
{
char *res, *buf = NULL;
int len;

if (!of_pdt_prom_ops->pkg2path)
return NULL;

if (of_pdt_prom_ops->pkg2path(node, buf, 0, &len))
return NULL;
buf = prom_early_alloc(len + 1);
if (of_pdt_prom_ops->pkg2path(node, buf, len, &len)) {
pr_err("%s: package-to-path failed\n", __func__);
return NULL;
}

res = strrchr(buf, '/');
if (!res) {
pr_err("%s: couldn't find / in %s\n", __func__, buf);
return NULL;
}
return res+1;
}

/*
* When fetching the node's name, first try using package-to-path; if
* that fails (either because the arch hasn't supplied a PROM callback,
* or some other random failure), fall back to just looking at the node's
* 'name' property.
*/
static char * __init of_pdt_build_name(phandle node)
{
char *buf;

buf = of_pdt_try_pkg2path(node);
if (!buf)
buf = of_pdt_get_one_property(node, "name");

return buf;
}

static struct device_node * __init of_pdt_create_node(phandle node,
struct device_node *parent)
{
Expand All @@ -187,7 +182,7 @@ static struct device_node * __init of_pdt_create_node(phandle node,

kref_init(&dp->kref);

dp->name = of_pdt_build_name(node);
dp->name = of_pdt_get_one_property(node, "name");
dp->type = of_pdt_get_one_property(node, "device_type");
dp->phandle = node;

Expand All @@ -198,26 +193,6 @@ static struct device_node * __init of_pdt_create_node(phandle node,
return dp;
}

static char * __init of_pdt_build_full_name(struct device_node *dp)
{
int len, ourlen, plen;
char *n;

plen = strlen(dp->parent->full_name);
ourlen = strlen(of_pdt_node_name(dp));
len = ourlen + plen + 2;

n = prom_early_alloc(len);
strcpy(n, dp->parent->full_name);
if (!of_node_is_root(dp->parent)) {
strcpy(n + plen, "/");
plen++;
}
strcpy(n + plen, of_pdt_node_name(dp));

return n;
}

static struct device_node * __init of_pdt_build_tree(struct device_node *parent,
phandle node,
struct device_node ***nextp)
Expand All @@ -240,9 +215,6 @@ static struct device_node * __init of_pdt_build_tree(struct device_node *parent,
*(*nextp) = dp;
*nextp = &dp->allnext;

#if defined(CONFIG_SPARC)
dp->path_component_name = build_path_component(dp);
#endif
dp->full_name = of_pdt_build_full_name(dp);

dp->child = of_pdt_build_tree(dp,
Expand Down

0 comments on commit b93d57d

Please sign in to comment.