Skip to content

Commit

Permalink
[SPARC]: Add of_n_{addr,size}_cells().
Browse files Browse the repository at this point in the history
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
davem330 authored and David S. Miller committed Jun 29, 2006
1 parent 286bbe8 commit 3ae9a34
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 0 deletions.
30 changes: 30 additions & 0 deletions arch/sparc/kernel/prom.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,36 @@ int of_getintprop_default(struct device_node *np, const char *name, int def)
}
EXPORT_SYMBOL(of_getintprop_default);

int of_n_addr_cells(struct device_node *np)
{
int* ip;
do {
if (np->parent)
np = np->parent;
ip = of_get_property(np, "#address-cells", NULL);
if (ip != NULL)
return *ip;
} while (np->parent);
/* No #address-cells property for the root node, default to 2 */
return 2;
}
EXPORT_SYMBOL(of_n_addr_cells);

int of_n_size_cells(struct device_node *np)
{
int* ip;
do {
if (np->parent)
np = np->parent;
ip = of_get_property(np, "#size-cells", NULL);
if (ip != NULL)
return *ip;
} while (np->parent);
/* No #size-cells property for the root node, default to 1 */
return 1;
}
EXPORT_SYMBOL(of_n_size_cells);

int of_set_property(struct device_node *dp, const char *name, void *val, int len)
{
struct property **prevp;
Expand Down
30 changes: 30 additions & 0 deletions arch/sparc64/kernel/prom.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,36 @@ int of_getintprop_default(struct device_node *np, const char *name, int def)
}
EXPORT_SYMBOL(of_getintprop_default);

int of_n_addr_cells(struct device_node *np)
{
int* ip;
do {
if (np->parent)
np = np->parent;
ip = of_get_property(np, "#address-cells", NULL);
if (ip != NULL)
return *ip;
} while (np->parent);
/* No #address-cells property for the root node, default to 2 */
return 2;
}
EXPORT_SYMBOL(of_n_addr_cells);

int of_n_size_cells(struct device_node *np)
{
int* ip;
do {
if (np->parent)
np = np->parent;
ip = of_get_property(np, "#size-cells", NULL);
if (ip != NULL)
return *ip;
} while (np->parent);
/* No #size-cells property for the root node, default to 1 */
return 1;
}
EXPORT_SYMBOL(of_n_size_cells);

int of_set_property(struct device_node *dp, const char *name, void *val, int len)
{
struct property **prevp;
Expand Down
2 changes: 2 additions & 0 deletions include/asm-sparc/prom.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ extern int of_set_property(struct device_node *node, const char *name, void *val
extern int of_getintprop_default(struct device_node *np,
const char *name,
int def);
extern int of_n_addr_cells(struct device_node *np);
extern int of_n_size_cells(struct device_node *np);

extern void prom_build_devicetree(void);

Expand Down
2 changes: 2 additions & 0 deletions include/asm-sparc64/prom.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ extern int of_set_property(struct device_node *node, const char *name, void *val
extern int of_getintprop_default(struct device_node *np,
const char *name,
int def);
extern int of_n_addr_cells(struct device_node *np);
extern int of_n_size_cells(struct device_node *np);

extern void prom_build_devicetree(void);

Expand Down

0 comments on commit 3ae9a34

Please sign in to comment.