Skip to content

Commit 6016a36

Browse files
committed
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: Grant Likely <[email protected]> Acked-by: David S. Miller <[email protected]> Tested-by: Wolfram Sang <[email protected]> Acked-by: Benjamin Herrenschmidt <[email protected]>
1 parent 923f7e3 commit 6016a36

File tree

16 files changed

+29
-33
lines changed

16 files changed

+29
-33
lines changed

arch/microblaze/kernel/of_platform.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ EXPORT_SYMBOL(of_find_device_by_node);
185185
static int of_dev_phandle_match(struct device *dev, void *data)
186186
{
187187
phandle *ph = data;
188-
return to_of_device(dev)->node->linux_phandle == *ph;
188+
return to_of_device(dev)->node->phandle == *ph;
189189
}
190190

191191
struct of_device *of_find_device_by_phandle(phandle ph)

arch/microblaze/kernel/prom.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ struct device_node *of_find_node_by_phandle(phandle handle)
342342

343343
read_lock(&devtree_lock);
344344
for (np = allnodes; np != NULL; np = np->allnext)
345-
if (np->linux_phandle == handle)
345+
if (np->phandle == handle)
346346
break;
347347
of_node_get(np);
348348
read_unlock(&devtree_lock);

arch/powerpc/kernel/of_platform.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ EXPORT_SYMBOL(of_find_device_by_node);
214214
static int of_dev_phandle_match(struct device *dev, void *data)
215215
{
216216
phandle *ph = data;
217-
return to_of_device(dev)->node->linux_phandle == *ph;
217+
return to_of_device(dev)->node->phandle == *ph;
218218
}
219219

220220
struct of_device *of_find_device_by_phandle(phandle ph)

arch/powerpc/kernel/prom.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ struct device_node *of_find_node_by_phandle(phandle handle)
778778

779779
read_lock(&devtree_lock);
780780
for (np = allnodes; np != 0; np = np->allnext)
781-
if (np->linux_phandle == handle)
781+
if (np->phandle == handle)
782782
break;
783783
of_node_get(np);
784784
read_unlock(&devtree_lock);
@@ -907,9 +907,9 @@ static int of_finish_dynamic_node(struct device_node *node)
907907
if (machine_is(powermac))
908908
return -ENODEV;
909909

910-
/* fix up new node's linux_phandle field */
910+
/* fix up new node's phandle field */
911911
if ((ibm_phandle = of_get_property(node, "ibm,phandle", NULL)))
912-
node->linux_phandle = *ibm_phandle;
912+
node->phandle = *ibm_phandle;
913913

914914
out:
915915
of_node_put(parent);

arch/powerpc/platforms/cell/spu_manage.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ neighbour_spu(int cbe, struct device_node *target, struct device_node *avoid)
457457
continue;
458458
vic_handles = of_get_property(spu_dn, "vicinity", &lenp);
459459
for (i=0; i < (lenp / sizeof(phandle)); i++) {
460-
if (vic_handles[i] == target->linux_phandle)
460+
if (vic_handles[i] == target->phandle)
461461
return spu;
462462
}
463463
}
@@ -499,7 +499,7 @@ static void init_affinity_node(int cbe)
499499

500500
if (strcmp(name, "spe") == 0) {
501501
spu = devnode_spu(cbe, vic_dn);
502-
avoid_ph = last_spu_dn->linux_phandle;
502+
avoid_ph = last_spu_dn->phandle;
503503
} else {
504504
/*
505505
* "mic-tm" and "bif0" nodes do not have
@@ -514,7 +514,7 @@ static void init_affinity_node(int cbe)
514514
last_spu->has_mem_affinity = 1;
515515
spu->has_mem_affinity = 1;
516516
}
517-
avoid_ph = vic_dn->linux_phandle;
517+
avoid_ph = vic_dn->phandle;
518518
}
519519

520520
list_add_tail(&spu->aff_list, &last_spu->aff_list);

arch/powerpc/platforms/powermac/pfunc_core.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,7 @@ struct pmf_function *__pmf_find_function(struct device_node *target,
842842
list_for_each_entry(func, &dev->functions, link) {
843843
if (name && strcmp(name, func->name))
844844
continue;
845-
if (func->phandle && target->node != func->phandle)
845+
if (func->phandle && target->phandle != func->phandle)
846846
continue;
847847
if ((func->flags & flags) == 0)
848848
continue;

arch/sparc/kernel/devices.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static int __cpu_find_by(int (*compare)(int, int, void *), void *compare_arg,
5959

6060
cur_inst = 0;
6161
for_each_node_by_type(dp, "cpu") {
62-
int err = check_cpu_node(dp->node, &cur_inst,
62+
int err = check_cpu_node(dp->phandle, &cur_inst,
6363
compare, compare_arg,
6464
prom_node, mid);
6565
if (!err) {

arch/sparc/kernel/of_device_32.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ static struct of_device * __init scan_one_device(struct device_node *dp,
433433
if (!parent)
434434
dev_set_name(&op->dev, "root");
435435
else
436-
dev_set_name(&op->dev, "%08x", dp->node);
436+
dev_set_name(&op->dev, "%08x", dp->phandle);
437437

438438
if (of_device_register(op)) {
439439
printk("%s: Could not register of device.\n",

arch/sparc/kernel/of_device_64.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ static struct of_device * __init scan_one_device(struct device_node *dp,
666666
if (!parent)
667667
dev_set_name(&op->dev, "root");
668668
else
669-
dev_set_name(&op->dev, "%08x", dp->node);
669+
dev_set_name(&op->dev, "%08x", dp->phandle);
670670

671671
if (of_device_register(op)) {
672672
printk("%s: Could not register of device.\n",

arch/sparc/kernel/prom_common.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ struct device_node *of_find_node_by_phandle(phandle handle)
4242
struct device_node *np;
4343

4444
for (np = allnodes; np; np = np->allnext)
45-
if (np->node == handle)
45+
if (np->phandle == handle)
4646
break;
4747

4848
return np;
@@ -89,7 +89,7 @@ int of_set_property(struct device_node *dp, const char *name, void *val, int len
8989
void *old_val = prop->value;
9090
int ret;
9191

92-
ret = prom_setprop(dp->node, name, val, len);
92+
ret = prom_setprop(dp->phandle, name, val, len);
9393

9494
err = -EINVAL;
9595
if (ret >= 0) {
@@ -236,7 +236,7 @@ static struct device_node * __init prom_create_node(phandle node,
236236

237237
dp->name = get_one_property(node, "name");
238238
dp->type = get_one_property(node, "device_type");
239-
dp->node = node;
239+
dp->phandle = node;
240240

241241
dp->properties = build_prop_list(node);
242242

@@ -313,7 +313,7 @@ void __init prom_build_devicetree(void)
313313

314314
nextp = &allnodes->allnext;
315315
allnodes->child = prom_build_tree(allnodes,
316-
prom_getchild(allnodes->node),
316+
prom_getchild(allnodes->phandle),
317317
&nextp);
318318
of_console_init();
319319

arch/sparc/kernel/smp_64.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ static int __cpuinit smp_boot_one_cpu(unsigned int cpu)
370370
} else {
371371
struct device_node *dp = of_find_node_by_cpuid(cpu);
372372

373-
prom_startcpu(dp->node, entry, cookie);
373+
prom_startcpu(dp->phandle, entry, cookie);
374374
}
375375

376376
for (timeout = 0; timeout < 50000; timeout++) {

drivers/of/fdt.c

+3-4
Original file line numberDiff line numberDiff line change
@@ -310,12 +310,11 @@ unsigned long __init unflatten_dt_node(unsigned long mem,
310310
__alignof__(struct property));
311311
if (allnextpp) {
312312
if (strcmp(pname, "linux,phandle") == 0) {
313-
np->node = *((u32 *)*p);
314-
if (np->linux_phandle == 0)
315-
np->linux_phandle = np->node;
313+
if (np->phandle == 0)
314+
np->phandle = *((u32 *)*p);
316315
}
317316
if (strcmp(pname, "ibm,phandle") == 0)
318-
np->linux_phandle = *((u32 *)*p);
317+
np->phandle = *((u32 *)*p);
319318
pp->name = pname;
320319
pp->length = sz;
321320
pp->value = (void *)*p;

drivers/sbus/char/openprom.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ static int opromnext(void __user *argp, unsigned int cmd, struct device_node *dp
233233

234234
ph = 0;
235235
if (dp)
236-
ph = dp->node;
236+
ph = dp->phandle;
237237

238238
data->current_node = dp;
239239
*((int *) op->oprom_array) = ph;
@@ -256,7 +256,7 @@ static int oprompci2node(void __user *argp, struct device_node *dp, struct openp
256256

257257
dp = pci_device_to_OF_node(pdev);
258258
data->current_node = dp;
259-
*((int *)op->oprom_array) = dp->node;
259+
*((int *)op->oprom_array) = dp->phandle;
260260
op->oprom_size = sizeof(int);
261261
err = copyout(argp, op, bufsize + sizeof(int));
262262

@@ -273,7 +273,7 @@ static int oprompath2node(void __user *argp, struct device_node *dp, struct open
273273

274274
dp = of_find_node_by_path(op->oprom_array);
275275
if (dp)
276-
ph = dp->node;
276+
ph = dp->phandle;
277277
data->current_node = dp;
278278
*((int *)op->oprom_array) = ph;
279279
op->oprom_size = sizeof(int);
@@ -540,7 +540,7 @@ static int opiocgetnext(unsigned int cmd, void __user *argp)
540540
}
541541
}
542542
if (dp)
543-
nd = dp->node;
543+
nd = dp->phandle;
544544
if (copy_to_user(argp, &nd, sizeof(phandle)))
545545
return -EFAULT;
546546

@@ -570,7 +570,7 @@ static int openprom_bsd_ioctl(struct inode * inode, struct file * file,
570570
case OPIOCGETOPTNODE:
571571
BUILD_BUG_ON(sizeof(phandle) != sizeof(int));
572572

573-
if (copy_to_user(argp, &options_node->node, sizeof(phandle)))
573+
if (copy_to_user(argp, &options_node->phandle, sizeof(phandle)))
574574
return -EFAULT;
575575

576576
return 0;

drivers/video/aty/atyfb_base.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3104,7 +3104,7 @@ static int __devinit atyfb_setup_sparc(struct pci_dev *pdev,
31043104
}
31053105

31063106
dp = pci_device_to_OF_node(pdev);
3107-
if (node == dp->node) {
3107+
if (node == dp->phandle) {
31083108
struct fb_var_screeninfo *var = &default_var;
31093109
unsigned int N, P, Q, M, T, R;
31103110
u32 v_total, h_total;

include/linux/of.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,7 @@ struct of_irq_controller;
3939
struct device_node {
4040
const char *name;
4141
const char *type;
42-
phandle node;
43-
#if !defined(CONFIG_SPARC)
44-
phandle linux_phandle;
45-
#endif
42+
phandle phandle;
4643
char *full_name;
4744

4845
struct property *properties;

sound/aoa/fabrics/layout.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ static int check_codec(struct aoa_codec *codec,
768768
"required property %s not present\n", propname);
769769
return -ENODEV;
770770
}
771-
if (*ref != codec->node->linux_phandle) {
771+
if (*ref != codec->node->phandle) {
772772
printk(KERN_INFO "snd-aoa-fabric-layout: "
773773
"%s doesn't match!\n", propname);
774774
return -ENODEV;

0 commit comments

Comments
 (0)