Commit bb31f9eb authored by Rob Herring's avatar Rob Herring Committed by David S. Miller

sparc: prom: use property "name" directly to construct node names

In preparation to remove direct accesses to the device_node.name
pointer, retrieve the node name from the "name" property instead. This
is slightly less optimal as we have to walk the kernel's DT property
list to find the "name" property.

Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Signed-off-by: default avatarRob Herring <robh@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0c5eaa77
...@@ -60,6 +60,7 @@ void * __init prom_early_alloc(unsigned long size) ...@@ -60,6 +60,7 @@ void * __init prom_early_alloc(unsigned long size)
*/ */
static void __init sparc32_path_component(struct device_node *dp, char *tmp_buf) static void __init sparc32_path_component(struct device_node *dp, char *tmp_buf)
{ {
const char *name = of_get_property(dp, "name", NULL);
struct linux_prom_registers *regs; struct linux_prom_registers *regs;
struct property *rprop; struct property *rprop;
...@@ -69,13 +70,14 @@ static void __init sparc32_path_component(struct device_node *dp, char *tmp_buf) ...@@ -69,13 +70,14 @@ static void __init sparc32_path_component(struct device_node *dp, char *tmp_buf)
regs = rprop->value; regs = rprop->value;
sprintf(tmp_buf, "%s@%x,%x", sprintf(tmp_buf, "%s@%x,%x",
dp->name, name,
regs->which_io, regs->phys_addr); regs->which_io, regs->phys_addr);
} }
/* "name@slot,offset" */ /* "name@slot,offset" */
static void __init sbus_path_component(struct device_node *dp, char *tmp_buf) static void __init sbus_path_component(struct device_node *dp, char *tmp_buf)
{ {
const char *name = of_get_property(dp, "name", NULL);
struct linux_prom_registers *regs; struct linux_prom_registers *regs;
struct property *prop; struct property *prop;
...@@ -85,7 +87,7 @@ static void __init sbus_path_component(struct device_node *dp, char *tmp_buf) ...@@ -85,7 +87,7 @@ static void __init sbus_path_component(struct device_node *dp, char *tmp_buf)
regs = prop->value; regs = prop->value;
sprintf(tmp_buf, "%s@%x,%x", sprintf(tmp_buf, "%s@%x,%x",
dp->name, name,
regs->which_io, regs->which_io,
regs->phys_addr); regs->phys_addr);
} }
...@@ -93,6 +95,7 @@ static void __init sbus_path_component(struct device_node *dp, char *tmp_buf) ...@@ -93,6 +95,7 @@ static void __init sbus_path_component(struct device_node *dp, char *tmp_buf)
/* "name@devnum[,func]" */ /* "name@devnum[,func]" */
static void __init pci_path_component(struct device_node *dp, char *tmp_buf) static void __init pci_path_component(struct device_node *dp, char *tmp_buf)
{ {
const char *name = of_get_property(dp, "name", NULL);
struct linux_prom_pci_registers *regs; struct linux_prom_pci_registers *regs;
struct property *prop; struct property *prop;
unsigned int devfn; unsigned int devfn;
...@@ -105,12 +108,12 @@ static void __init pci_path_component(struct device_node *dp, char *tmp_buf) ...@@ -105,12 +108,12 @@ static void __init pci_path_component(struct device_node *dp, char *tmp_buf)
devfn = (regs->phys_hi >> 8) & 0xff; devfn = (regs->phys_hi >> 8) & 0xff;
if (devfn & 0x07) { if (devfn & 0x07) {
sprintf(tmp_buf, "%s@%x,%x", sprintf(tmp_buf, "%s@%x,%x",
dp->name, name,
devfn >> 3, devfn >> 3,
devfn & 0x07); devfn & 0x07);
} else { } else {
sprintf(tmp_buf, "%s@%x", sprintf(tmp_buf, "%s@%x",
dp->name, name,
devfn >> 3); devfn >> 3);
} }
} }
...@@ -118,6 +121,7 @@ static void __init pci_path_component(struct device_node *dp, char *tmp_buf) ...@@ -118,6 +121,7 @@ static void __init pci_path_component(struct device_node *dp, char *tmp_buf)
/* "name@addrhi,addrlo" */ /* "name@addrhi,addrlo" */
static void __init ebus_path_component(struct device_node *dp, char *tmp_buf) static void __init ebus_path_component(struct device_node *dp, char *tmp_buf)
{ {
const char *name = of_get_property(dp, "name", NULL);
struct linux_prom_registers *regs; struct linux_prom_registers *regs;
struct property *prop; struct property *prop;
...@@ -128,13 +132,14 @@ static void __init ebus_path_component(struct device_node *dp, char *tmp_buf) ...@@ -128,13 +132,14 @@ static void __init ebus_path_component(struct device_node *dp, char *tmp_buf)
regs = prop->value; regs = prop->value;
sprintf(tmp_buf, "%s@%x,%x", sprintf(tmp_buf, "%s@%x,%x",
dp->name, name,
regs->which_io, regs->phys_addr); regs->which_io, regs->phys_addr);
} }
/* "name:vendor:device@irq,addrlo" */ /* "name:vendor:device@irq,addrlo" */
static void __init ambapp_path_component(struct device_node *dp, char *tmp_buf) static void __init ambapp_path_component(struct device_node *dp, char *tmp_buf)
{ {
const char *name = of_get_property(dp, "name", NULL);
struct amba_prom_registers *regs; struct amba_prom_registers *regs;
unsigned int *intr, *device, *vendor, reg0; unsigned int *intr, *device, *vendor, reg0;
struct property *prop; struct property *prop;
...@@ -168,7 +173,7 @@ static void __init ambapp_path_component(struct device_node *dp, char *tmp_buf) ...@@ -168,7 +173,7 @@ static void __init ambapp_path_component(struct device_node *dp, char *tmp_buf)
device = prop->value; device = prop->value;
sprintf(tmp_buf, "%s:%d:%d@%x,%x", sprintf(tmp_buf, "%s:%d:%d@%x,%x",
dp->name, *vendor, *device, name, *vendor, *device,
*intr, reg0); *intr, reg0);
} }
...@@ -196,12 +201,13 @@ static void __init __build_path_component(struct device_node *dp, char *tmp_buf) ...@@ -196,12 +201,13 @@ static void __init __build_path_component(struct device_node *dp, char *tmp_buf)
char * __init build_path_component(struct device_node *dp) char * __init build_path_component(struct device_node *dp)
{ {
const char *name = of_get_property(dp, "name", NULL);
char tmp_buf[64], *n; char tmp_buf[64], *n;
tmp_buf[0] = '\0'; tmp_buf[0] = '\0';
__build_path_component(dp, tmp_buf); __build_path_component(dp, tmp_buf);
if (tmp_buf[0] == '\0') if (tmp_buf[0] == '\0')
strcpy(tmp_buf, dp->name); strcpy(tmp_buf, name);
n = prom_early_alloc(strlen(tmp_buf) + 1); n = prom_early_alloc(strlen(tmp_buf) + 1);
strcpy(n, tmp_buf); strcpy(n, tmp_buf);
......
...@@ -72,6 +72,7 @@ void * __init prom_early_alloc(unsigned long size) ...@@ -72,6 +72,7 @@ void * __init prom_early_alloc(unsigned long size)
*/ */
static void __init sun4v_path_component(struct device_node *dp, char *tmp_buf) static void __init sun4v_path_component(struct device_node *dp, char *tmp_buf)
{ {
const char *name = of_get_property(dp, "name", NULL);
struct linux_prom64_registers *regs; struct linux_prom64_registers *regs;
struct property *rprop; struct property *rprop;
u32 high_bits, low_bits, type; u32 high_bits, low_bits, type;
...@@ -83,7 +84,7 @@ static void __init sun4v_path_component(struct device_node *dp, char *tmp_buf) ...@@ -83,7 +84,7 @@ static void __init sun4v_path_component(struct device_node *dp, char *tmp_buf)
regs = rprop->value; regs = rprop->value;
if (!of_node_is_root(dp->parent)) { if (!of_node_is_root(dp->parent)) {
sprintf(tmp_buf, "%s@%x,%x", sprintf(tmp_buf, "%s@%x,%x",
dp->name, name,
(unsigned int) (regs->phys_addr >> 32UL), (unsigned int) (regs->phys_addr >> 32UL),
(unsigned int) (regs->phys_addr & 0xffffffffUL)); (unsigned int) (regs->phys_addr & 0xffffffffUL));
return; return;
...@@ -98,21 +99,22 @@ static void __init sun4v_path_component(struct device_node *dp, char *tmp_buf) ...@@ -98,21 +99,22 @@ static void __init sun4v_path_component(struct device_node *dp, char *tmp_buf)
if (low_bits) if (low_bits)
sprintf(tmp_buf, "%s@%s%x,%x", sprintf(tmp_buf, "%s@%s%x,%x",
dp->name, prefix, name, prefix,
high_bits, low_bits); high_bits, low_bits);
else else
sprintf(tmp_buf, "%s@%s%x", sprintf(tmp_buf, "%s@%s%x",
dp->name, name,
prefix, prefix,
high_bits); high_bits);
} else if (type == 12) { } else if (type == 12) {
sprintf(tmp_buf, "%s@%x", sprintf(tmp_buf, "%s@%x",
dp->name, high_bits); name, high_bits);
} }
} }
static void __init sun4u_path_component(struct device_node *dp, char *tmp_buf) static void __init sun4u_path_component(struct device_node *dp, char *tmp_buf)
{ {
const char *name = of_get_property(dp, "name", NULL);
struct linux_prom64_registers *regs; struct linux_prom64_registers *regs;
struct property *prop; struct property *prop;
...@@ -123,7 +125,7 @@ static void __init sun4u_path_component(struct device_node *dp, char *tmp_buf) ...@@ -123,7 +125,7 @@ static void __init sun4u_path_component(struct device_node *dp, char *tmp_buf)
regs = prop->value; regs = prop->value;
if (!of_node_is_root(dp->parent)) { if (!of_node_is_root(dp->parent)) {
sprintf(tmp_buf, "%s@%x,%x", sprintf(tmp_buf, "%s@%x,%x",
dp->name, name,
(unsigned int) (regs->phys_addr >> 32UL), (unsigned int) (regs->phys_addr >> 32UL),
(unsigned int) (regs->phys_addr & 0xffffffffUL)); (unsigned int) (regs->phys_addr & 0xffffffffUL));
return; return;
...@@ -139,7 +141,7 @@ static void __init sun4u_path_component(struct device_node *dp, char *tmp_buf) ...@@ -139,7 +141,7 @@ static void __init sun4u_path_component(struct device_node *dp, char *tmp_buf)
mask = 0x7fffff; mask = 0x7fffff;
sprintf(tmp_buf, "%s@%x,%x", sprintf(tmp_buf, "%s@%x,%x",
dp->name, name,
*(u32 *)prop->value, *(u32 *)prop->value,
(unsigned int) (regs->phys_addr & mask)); (unsigned int) (regs->phys_addr & mask));
} }
...@@ -148,6 +150,7 @@ static void __init sun4u_path_component(struct device_node *dp, char *tmp_buf) ...@@ -148,6 +150,7 @@ static void __init sun4u_path_component(struct device_node *dp, char *tmp_buf)
/* "name@slot,offset" */ /* "name@slot,offset" */
static void __init sbus_path_component(struct device_node *dp, char *tmp_buf) static void __init sbus_path_component(struct device_node *dp, char *tmp_buf)
{ {
const char *name = of_get_property(dp, "name", NULL);
struct linux_prom_registers *regs; struct linux_prom_registers *regs;
struct property *prop; struct property *prop;
...@@ -157,7 +160,7 @@ static void __init sbus_path_component(struct device_node *dp, char *tmp_buf) ...@@ -157,7 +160,7 @@ static void __init sbus_path_component(struct device_node *dp, char *tmp_buf)
regs = prop->value; regs = prop->value;
sprintf(tmp_buf, "%s@%x,%x", sprintf(tmp_buf, "%s@%x,%x",
dp->name, name,
regs->which_io, regs->which_io,
regs->phys_addr); regs->phys_addr);
} }
...@@ -165,6 +168,7 @@ static void __init sbus_path_component(struct device_node *dp, char *tmp_buf) ...@@ -165,6 +168,7 @@ static void __init sbus_path_component(struct device_node *dp, char *tmp_buf)
/* "name@devnum[,func]" */ /* "name@devnum[,func]" */
static void __init pci_path_component(struct device_node *dp, char *tmp_buf) static void __init pci_path_component(struct device_node *dp, char *tmp_buf)
{ {
const char *name = of_get_property(dp, "name", NULL);
struct linux_prom_pci_registers *regs; struct linux_prom_pci_registers *regs;
struct property *prop; struct property *prop;
unsigned int devfn; unsigned int devfn;
...@@ -177,12 +181,12 @@ static void __init pci_path_component(struct device_node *dp, char *tmp_buf) ...@@ -177,12 +181,12 @@ static void __init pci_path_component(struct device_node *dp, char *tmp_buf)
devfn = (regs->phys_hi >> 8) & 0xff; devfn = (regs->phys_hi >> 8) & 0xff;
if (devfn & 0x07) { if (devfn & 0x07) {
sprintf(tmp_buf, "%s@%x,%x", sprintf(tmp_buf, "%s@%x,%x",
dp->name, name,
devfn >> 3, devfn >> 3,
devfn & 0x07); devfn & 0x07);
} else { } else {
sprintf(tmp_buf, "%s@%x", sprintf(tmp_buf, "%s@%x",
dp->name, name,
devfn >> 3); devfn >> 3);
} }
} }
...@@ -190,6 +194,7 @@ static void __init pci_path_component(struct device_node *dp, char *tmp_buf) ...@@ -190,6 +194,7 @@ static void __init pci_path_component(struct device_node *dp, char *tmp_buf)
/* "name@UPA_PORTID,offset" */ /* "name@UPA_PORTID,offset" */
static void __init upa_path_component(struct device_node *dp, char *tmp_buf) static void __init upa_path_component(struct device_node *dp, char *tmp_buf)
{ {
const char *name = of_get_property(dp, "name", NULL);
struct linux_prom64_registers *regs; struct linux_prom64_registers *regs;
struct property *prop; struct property *prop;
...@@ -204,7 +209,7 @@ static void __init upa_path_component(struct device_node *dp, char *tmp_buf) ...@@ -204,7 +209,7 @@ static void __init upa_path_component(struct device_node *dp, char *tmp_buf)
return; return;
sprintf(tmp_buf, "%s@%x,%x", sprintf(tmp_buf, "%s@%x,%x",
dp->name, name,
*(u32 *) prop->value, *(u32 *) prop->value,
(unsigned int) (regs->phys_addr & 0xffffffffUL)); (unsigned int) (regs->phys_addr & 0xffffffffUL));
} }
...@@ -212,6 +217,7 @@ static void __init upa_path_component(struct device_node *dp, char *tmp_buf) ...@@ -212,6 +217,7 @@ static void __init upa_path_component(struct device_node *dp, char *tmp_buf)
/* "name@reg" */ /* "name@reg" */
static void __init vdev_path_component(struct device_node *dp, char *tmp_buf) static void __init vdev_path_component(struct device_node *dp, char *tmp_buf)
{ {
const char *name = of_get_property(dp, "name", NULL);
struct property *prop; struct property *prop;
u32 *regs; u32 *regs;
...@@ -221,12 +227,13 @@ static void __init vdev_path_component(struct device_node *dp, char *tmp_buf) ...@@ -221,12 +227,13 @@ static void __init vdev_path_component(struct device_node *dp, char *tmp_buf)
regs = prop->value; regs = prop->value;
sprintf(tmp_buf, "%s@%x", dp->name, *regs); sprintf(tmp_buf, "%s@%x", name, *regs);
} }
/* "name@addrhi,addrlo" */ /* "name@addrhi,addrlo" */
static void __init ebus_path_component(struct device_node *dp, char *tmp_buf) static void __init ebus_path_component(struct device_node *dp, char *tmp_buf)
{ {
const char *name = of_get_property(dp, "name", NULL);
struct linux_prom64_registers *regs; struct linux_prom64_registers *regs;
struct property *prop; struct property *prop;
...@@ -237,7 +244,7 @@ static void __init ebus_path_component(struct device_node *dp, char *tmp_buf) ...@@ -237,7 +244,7 @@ static void __init ebus_path_component(struct device_node *dp, char *tmp_buf)
regs = prop->value; regs = prop->value;
sprintf(tmp_buf, "%s@%x,%x", sprintf(tmp_buf, "%s@%x,%x",
dp->name, name,
(unsigned int) (regs->phys_addr >> 32UL), (unsigned int) (regs->phys_addr >> 32UL),
(unsigned int) (regs->phys_addr & 0xffffffffUL)); (unsigned int) (regs->phys_addr & 0xffffffffUL));
} }
...@@ -245,6 +252,7 @@ static void __init ebus_path_component(struct device_node *dp, char *tmp_buf) ...@@ -245,6 +252,7 @@ static void __init ebus_path_component(struct device_node *dp, char *tmp_buf)
/* "name@bus,addr" */ /* "name@bus,addr" */
static void __init i2c_path_component(struct device_node *dp, char *tmp_buf) static void __init i2c_path_component(struct device_node *dp, char *tmp_buf)
{ {
const char *name = of_get_property(dp, "name", NULL);
struct property *prop; struct property *prop;
u32 *regs; u32 *regs;
...@@ -258,12 +266,13 @@ static void __init i2c_path_component(struct device_node *dp, char *tmp_buf) ...@@ -258,12 +266,13 @@ static void __init i2c_path_component(struct device_node *dp, char *tmp_buf)
* property of the i2c bus node etc. etc. * property of the i2c bus node etc. etc.
*/ */
sprintf(tmp_buf, "%s@%x,%x", sprintf(tmp_buf, "%s@%x,%x",
dp->name, regs[0], regs[1]); name, regs[0], regs[1]);
} }
/* "name@reg0[,reg1]" */ /* "name@reg0[,reg1]" */
static void __init usb_path_component(struct device_node *dp, char *tmp_buf) static void __init usb_path_component(struct device_node *dp, char *tmp_buf)
{ {
const char *name = of_get_property(dp, "name", NULL);
struct property *prop; struct property *prop;
u32 *regs; u32 *regs;
...@@ -275,16 +284,17 @@ static void __init usb_path_component(struct device_node *dp, char *tmp_buf) ...@@ -275,16 +284,17 @@ static void __init usb_path_component(struct device_node *dp, char *tmp_buf)
if (prop->length == sizeof(u32) || regs[1] == 1) { if (prop->length == sizeof(u32) || regs[1] == 1) {
sprintf(tmp_buf, "%s@%x", sprintf(tmp_buf, "%s@%x",
dp->name, regs[0]); name, regs[0]);
} else { } else {
sprintf(tmp_buf, "%s@%x,%x", sprintf(tmp_buf, "%s@%x,%x",
dp->name, regs[0], regs[1]); name, regs[0], regs[1]);
} }
} }
/* "name@reg0reg1[,reg2reg3]" */ /* "name@reg0reg1[,reg2reg3]" */
static void __init ieee1394_path_component(struct device_node *dp, char *tmp_buf) static void __init ieee1394_path_component(struct device_node *dp, char *tmp_buf)
{ {
const char *name = of_get_property(dp, "name", NULL);
struct property *prop; struct property *prop;
u32 *regs; u32 *regs;
...@@ -296,10 +306,10 @@ static void __init ieee1394_path_component(struct device_node *dp, char *tmp_buf ...@@ -296,10 +306,10 @@ static void __init ieee1394_path_component(struct device_node *dp, char *tmp_buf
if (regs[2] || regs[3]) { if (regs[2] || regs[3]) {
sprintf(tmp_buf, "%s@%08x%08x,%04x%08x", sprintf(tmp_buf, "%s@%08x%08x,%04x%08x",
dp->name, regs[0], regs[1], regs[2], regs[3]); name, regs[0], regs[1], regs[2], regs[3]);
} else { } else {
sprintf(tmp_buf, "%s@%08x%08x", sprintf(tmp_buf, "%s@%08x%08x",
dp->name, regs[0], regs[1]); name, regs[0], regs[1]);
} }
} }
...@@ -356,12 +366,13 @@ static void __init __build_path_component(struct device_node *dp, char *tmp_buf) ...@@ -356,12 +366,13 @@ static void __init __build_path_component(struct device_node *dp, char *tmp_buf)
char * __init build_path_component(struct device_node *dp) char * __init build_path_component(struct device_node *dp)
{ {
const char *name = of_get_property(dp, "name", NULL);
char tmp_buf[64], *n; char tmp_buf[64], *n;
tmp_buf[0] = '\0'; tmp_buf[0] = '\0';
__build_path_component(dp, tmp_buf); __build_path_component(dp, tmp_buf);
if (tmp_buf[0] == '\0') if (tmp_buf[0] == '\0')
strcpy(tmp_buf, dp->name); strcpy(tmp_buf, name);
n = prom_early_alloc(strlen(tmp_buf) + 1); n = prom_early_alloc(strlen(tmp_buf) + 1);
strcpy(n, tmp_buf); strcpy(n, tmp_buf);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment