Commit 6016a363 authored by Grant Likely's avatar Grant Likely

of: unify phandle name in struct device_node

In struct device_node, the phandle is named 'linux_phandle' for PowerPC
and MicroBlaze, and 'node' for SPARC.  There is no good reason for the
difference, it is just an artifact of the code diverging over a couple
of years.  This patch renames both to simply .phandle.

Note: the .node also existed in PowerPC/MicroBlaze, but the only user
seems to be arch/powerpc/platforms/powermac/pfunc_core.c.  It doesn't
look like the assignment between .linux_phandle and .node is
significantly different enough to warrant the separate code paths
unless ibm,phandle properties actually appear in Apple device trees.

I think it is safe to eliminate the old .node property and use
phandle everywhere.
Signed-off-by: default avatarGrant Likely <grant.likely@secretlab.ca>
Acked-by: default avatarDavid S. Miller <davem@davemloft.net>
Tested-by: default avatarWolfram Sang <w.sang@pengutronix.de>
Acked-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent 923f7e30
...@@ -185,7 +185,7 @@ EXPORT_SYMBOL(of_find_device_by_node); ...@@ -185,7 +185,7 @@ EXPORT_SYMBOL(of_find_device_by_node);
static int of_dev_phandle_match(struct device *dev, void *data) static int of_dev_phandle_match(struct device *dev, void *data)
{ {
phandle *ph = data; phandle *ph = data;
return to_of_device(dev)->node->linux_phandle == *ph; return to_of_device(dev)->node->phandle == *ph;
} }
struct of_device *of_find_device_by_phandle(phandle ph) struct of_device *of_find_device_by_phandle(phandle ph)
......
...@@ -342,7 +342,7 @@ struct device_node *of_find_node_by_phandle(phandle handle) ...@@ -342,7 +342,7 @@ struct device_node *of_find_node_by_phandle(phandle handle)
read_lock(&devtree_lock); read_lock(&devtree_lock);
for (np = allnodes; np != NULL; np = np->allnext) for (np = allnodes; np != NULL; np = np->allnext)
if (np->linux_phandle == handle) if (np->phandle == handle)
break; break;
of_node_get(np); of_node_get(np);
read_unlock(&devtree_lock); read_unlock(&devtree_lock);
......
...@@ -214,7 +214,7 @@ EXPORT_SYMBOL(of_find_device_by_node); ...@@ -214,7 +214,7 @@ EXPORT_SYMBOL(of_find_device_by_node);
static int of_dev_phandle_match(struct device *dev, void *data) static int of_dev_phandle_match(struct device *dev, void *data)
{ {
phandle *ph = data; phandle *ph = data;
return to_of_device(dev)->node->linux_phandle == *ph; return to_of_device(dev)->node->phandle == *ph;
} }
struct of_device *of_find_device_by_phandle(phandle ph) struct of_device *of_find_device_by_phandle(phandle ph)
......
...@@ -778,7 +778,7 @@ struct device_node *of_find_node_by_phandle(phandle handle) ...@@ -778,7 +778,7 @@ struct device_node *of_find_node_by_phandle(phandle handle)
read_lock(&devtree_lock); read_lock(&devtree_lock);
for (np = allnodes; np != 0; np = np->allnext) for (np = allnodes; np != 0; np = np->allnext)
if (np->linux_phandle == handle) if (np->phandle == handle)
break; break;
of_node_get(np); of_node_get(np);
read_unlock(&devtree_lock); read_unlock(&devtree_lock);
...@@ -907,9 +907,9 @@ static int of_finish_dynamic_node(struct device_node *node) ...@@ -907,9 +907,9 @@ static int of_finish_dynamic_node(struct device_node *node)
if (machine_is(powermac)) if (machine_is(powermac))
return -ENODEV; return -ENODEV;
/* fix up new node's linux_phandle field */ /* fix up new node's phandle field */
if ((ibm_phandle = of_get_property(node, "ibm,phandle", NULL))) if ((ibm_phandle = of_get_property(node, "ibm,phandle", NULL)))
node->linux_phandle = *ibm_phandle; node->phandle = *ibm_phandle;
out: out:
of_node_put(parent); of_node_put(parent);
......
...@@ -457,7 +457,7 @@ neighbour_spu(int cbe, struct device_node *target, struct device_node *avoid) ...@@ -457,7 +457,7 @@ neighbour_spu(int cbe, struct device_node *target, struct device_node *avoid)
continue; continue;
vic_handles = of_get_property(spu_dn, "vicinity", &lenp); vic_handles = of_get_property(spu_dn, "vicinity", &lenp);
for (i=0; i < (lenp / sizeof(phandle)); i++) { for (i=0; i < (lenp / sizeof(phandle)); i++) {
if (vic_handles[i] == target->linux_phandle) if (vic_handles[i] == target->phandle)
return spu; return spu;
} }
} }
...@@ -499,7 +499,7 @@ static void init_affinity_node(int cbe) ...@@ -499,7 +499,7 @@ static void init_affinity_node(int cbe)
if (strcmp(name, "spe") == 0) { if (strcmp(name, "spe") == 0) {
spu = devnode_spu(cbe, vic_dn); spu = devnode_spu(cbe, vic_dn);
avoid_ph = last_spu_dn->linux_phandle; avoid_ph = last_spu_dn->phandle;
} else { } else {
/* /*
* "mic-tm" and "bif0" nodes do not have * "mic-tm" and "bif0" nodes do not have
...@@ -514,7 +514,7 @@ static void init_affinity_node(int cbe) ...@@ -514,7 +514,7 @@ static void init_affinity_node(int cbe)
last_spu->has_mem_affinity = 1; last_spu->has_mem_affinity = 1;
spu->has_mem_affinity = 1; spu->has_mem_affinity = 1;
} }
avoid_ph = vic_dn->linux_phandle; avoid_ph = vic_dn->phandle;
} }
list_add_tail(&spu->aff_list, &last_spu->aff_list); list_add_tail(&spu->aff_list, &last_spu->aff_list);
......
...@@ -842,7 +842,7 @@ struct pmf_function *__pmf_find_function(struct device_node *target, ...@@ -842,7 +842,7 @@ struct pmf_function *__pmf_find_function(struct device_node *target,
list_for_each_entry(func, &dev->functions, link) { list_for_each_entry(func, &dev->functions, link) {
if (name && strcmp(name, func->name)) if (name && strcmp(name, func->name))
continue; continue;
if (func->phandle && target->node != func->phandle) if (func->phandle && target->phandle != func->phandle)
continue; continue;
if ((func->flags & flags) == 0) if ((func->flags & flags) == 0)
continue; continue;
......
...@@ -59,7 +59,7 @@ static int __cpu_find_by(int (*compare)(int, int, void *), void *compare_arg, ...@@ -59,7 +59,7 @@ static int __cpu_find_by(int (*compare)(int, int, void *), void *compare_arg,
cur_inst = 0; cur_inst = 0;
for_each_node_by_type(dp, "cpu") { for_each_node_by_type(dp, "cpu") {
int err = check_cpu_node(dp->node, &cur_inst, int err = check_cpu_node(dp->phandle, &cur_inst,
compare, compare_arg, compare, compare_arg,
prom_node, mid); prom_node, mid);
if (!err) { if (!err) {
......
...@@ -433,7 +433,7 @@ static struct of_device * __init scan_one_device(struct device_node *dp, ...@@ -433,7 +433,7 @@ static struct of_device * __init scan_one_device(struct device_node *dp,
if (!parent) if (!parent)
dev_set_name(&op->dev, "root"); dev_set_name(&op->dev, "root");
else else
dev_set_name(&op->dev, "%08x", dp->node); dev_set_name(&op->dev, "%08x", dp->phandle);
if (of_device_register(op)) { if (of_device_register(op)) {
printk("%s: Could not register of device.\n", printk("%s: Could not register of device.\n",
......
...@@ -666,7 +666,7 @@ static struct of_device * __init scan_one_device(struct device_node *dp, ...@@ -666,7 +666,7 @@ static struct of_device * __init scan_one_device(struct device_node *dp,
if (!parent) if (!parent)
dev_set_name(&op->dev, "root"); dev_set_name(&op->dev, "root");
else else
dev_set_name(&op->dev, "%08x", dp->node); dev_set_name(&op->dev, "%08x", dp->phandle);
if (of_device_register(op)) { if (of_device_register(op)) {
printk("%s: Could not register of device.\n", printk("%s: Could not register of device.\n",
......
...@@ -42,7 +42,7 @@ struct device_node *of_find_node_by_phandle(phandle handle) ...@@ -42,7 +42,7 @@ struct device_node *of_find_node_by_phandle(phandle handle)
struct device_node *np; struct device_node *np;
for (np = allnodes; np; np = np->allnext) for (np = allnodes; np; np = np->allnext)
if (np->node == handle) if (np->phandle == handle)
break; break;
return np; return np;
...@@ -89,7 +89,7 @@ int of_set_property(struct device_node *dp, const char *name, void *val, int len ...@@ -89,7 +89,7 @@ int of_set_property(struct device_node *dp, const char *name, void *val, int len
void *old_val = prop->value; void *old_val = prop->value;
int ret; int ret;
ret = prom_setprop(dp->node, name, val, len); ret = prom_setprop(dp->phandle, name, val, len);
err = -EINVAL; err = -EINVAL;
if (ret >= 0) { if (ret >= 0) {
...@@ -236,7 +236,7 @@ static struct device_node * __init prom_create_node(phandle node, ...@@ -236,7 +236,7 @@ static struct device_node * __init prom_create_node(phandle node,
dp->name = get_one_property(node, "name"); dp->name = get_one_property(node, "name");
dp->type = get_one_property(node, "device_type"); dp->type = get_one_property(node, "device_type");
dp->node = node; dp->phandle = node;
dp->properties = build_prop_list(node); dp->properties = build_prop_list(node);
...@@ -313,7 +313,7 @@ void __init prom_build_devicetree(void) ...@@ -313,7 +313,7 @@ void __init prom_build_devicetree(void)
nextp = &allnodes->allnext; nextp = &allnodes->allnext;
allnodes->child = prom_build_tree(allnodes, allnodes->child = prom_build_tree(allnodes,
prom_getchild(allnodes->node), prom_getchild(allnodes->phandle),
&nextp); &nextp);
of_console_init(); of_console_init();
......
...@@ -370,7 +370,7 @@ static int __cpuinit smp_boot_one_cpu(unsigned int cpu) ...@@ -370,7 +370,7 @@ static int __cpuinit smp_boot_one_cpu(unsigned int cpu)
} else { } else {
struct device_node *dp = of_find_node_by_cpuid(cpu); struct device_node *dp = of_find_node_by_cpuid(cpu);
prom_startcpu(dp->node, entry, cookie); prom_startcpu(dp->phandle, entry, cookie);
} }
for (timeout = 0; timeout < 50000; timeout++) { for (timeout = 0; timeout < 50000; timeout++) {
......
...@@ -310,12 +310,11 @@ unsigned long __init unflatten_dt_node(unsigned long mem, ...@@ -310,12 +310,11 @@ unsigned long __init unflatten_dt_node(unsigned long mem,
__alignof__(struct property)); __alignof__(struct property));
if (allnextpp) { if (allnextpp) {
if (strcmp(pname, "linux,phandle") == 0) { if (strcmp(pname, "linux,phandle") == 0) {
np->node = *((u32 *)*p); if (np->phandle == 0)
if (np->linux_phandle == 0) np->phandle = *((u32 *)*p);
np->linux_phandle = np->node;
} }
if (strcmp(pname, "ibm,phandle") == 0) if (strcmp(pname, "ibm,phandle") == 0)
np->linux_phandle = *((u32 *)*p); np->phandle = *((u32 *)*p);
pp->name = pname; pp->name = pname;
pp->length = sz; pp->length = sz;
pp->value = (void *)*p; pp->value = (void *)*p;
......
...@@ -233,7 +233,7 @@ static int opromnext(void __user *argp, unsigned int cmd, struct device_node *dp ...@@ -233,7 +233,7 @@ static int opromnext(void __user *argp, unsigned int cmd, struct device_node *dp
ph = 0; ph = 0;
if (dp) if (dp)
ph = dp->node; ph = dp->phandle;
data->current_node = dp; data->current_node = dp;
*((int *) op->oprom_array) = ph; *((int *) op->oprom_array) = ph;
...@@ -256,7 +256,7 @@ static int oprompci2node(void __user *argp, struct device_node *dp, struct openp ...@@ -256,7 +256,7 @@ static int oprompci2node(void __user *argp, struct device_node *dp, struct openp
dp = pci_device_to_OF_node(pdev); dp = pci_device_to_OF_node(pdev);
data->current_node = dp; data->current_node = dp;
*((int *)op->oprom_array) = dp->node; *((int *)op->oprom_array) = dp->phandle;
op->oprom_size = sizeof(int); op->oprom_size = sizeof(int);
err = copyout(argp, op, bufsize + sizeof(int)); err = copyout(argp, op, bufsize + sizeof(int));
...@@ -273,7 +273,7 @@ static int oprompath2node(void __user *argp, struct device_node *dp, struct open ...@@ -273,7 +273,7 @@ static int oprompath2node(void __user *argp, struct device_node *dp, struct open
dp = of_find_node_by_path(op->oprom_array); dp = of_find_node_by_path(op->oprom_array);
if (dp) if (dp)
ph = dp->node; ph = dp->phandle;
data->current_node = dp; data->current_node = dp;
*((int *)op->oprom_array) = ph; *((int *)op->oprom_array) = ph;
op->oprom_size = sizeof(int); op->oprom_size = sizeof(int);
...@@ -540,7 +540,7 @@ static int opiocgetnext(unsigned int cmd, void __user *argp) ...@@ -540,7 +540,7 @@ static int opiocgetnext(unsigned int cmd, void __user *argp)
} }
} }
if (dp) if (dp)
nd = dp->node; nd = dp->phandle;
if (copy_to_user(argp, &nd, sizeof(phandle))) if (copy_to_user(argp, &nd, sizeof(phandle)))
return -EFAULT; return -EFAULT;
...@@ -570,7 +570,7 @@ static int openprom_bsd_ioctl(struct inode * inode, struct file * file, ...@@ -570,7 +570,7 @@ static int openprom_bsd_ioctl(struct inode * inode, struct file * file,
case OPIOCGETOPTNODE: case OPIOCGETOPTNODE:
BUILD_BUG_ON(sizeof(phandle) != sizeof(int)); BUILD_BUG_ON(sizeof(phandle) != sizeof(int));
if (copy_to_user(argp, &options_node->node, sizeof(phandle))) if (copy_to_user(argp, &options_node->phandle, sizeof(phandle)))
return -EFAULT; return -EFAULT;
return 0; return 0;
......
...@@ -3104,7 +3104,7 @@ static int __devinit atyfb_setup_sparc(struct pci_dev *pdev, ...@@ -3104,7 +3104,7 @@ static int __devinit atyfb_setup_sparc(struct pci_dev *pdev,
} }
dp = pci_device_to_OF_node(pdev); dp = pci_device_to_OF_node(pdev);
if (node == dp->node) { if (node == dp->phandle) {
struct fb_var_screeninfo *var = &default_var; struct fb_var_screeninfo *var = &default_var;
unsigned int N, P, Q, M, T, R; unsigned int N, P, Q, M, T, R;
u32 v_total, h_total; u32 v_total, h_total;
......
...@@ -39,10 +39,7 @@ struct of_irq_controller; ...@@ -39,10 +39,7 @@ struct of_irq_controller;
struct device_node { struct device_node {
const char *name; const char *name;
const char *type; const char *type;
phandle node; phandle phandle;
#if !defined(CONFIG_SPARC)
phandle linux_phandle;
#endif
char *full_name; char *full_name;
struct property *properties; struct property *properties;
......
...@@ -768,7 +768,7 @@ static int check_codec(struct aoa_codec *codec, ...@@ -768,7 +768,7 @@ static int check_codec(struct aoa_codec *codec,
"required property %s not present\n", propname); "required property %s not present\n", propname);
return -ENODEV; return -ENODEV;
} }
if (*ref != codec->node->linux_phandle) { if (*ref != codec->node->phandle) {
printk(KERN_INFO "snd-aoa-fabric-layout: " printk(KERN_INFO "snd-aoa-fabric-layout: "
"%s doesn't match!\n", propname); "%s doesn't match!\n", propname);
return -ENODEV; return -ENODEV;
......
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