diff options
author | Grant Likely <grant.likely@secretlab.ca> | 2010-07-23 03:48:25 -0400 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2010-07-24 18:51:52 -0400 |
commit | 9a6b2e588c7809e86161236da3d29581bf5f8402 (patch) | |
tree | 0aebb8e868615a2354042a376405cd73d80ef19e /drivers/of | |
parent | 883c2cfc8bcc0fd00c5d9f596fb8870f481b5bda (diff) |
of: Fix phandle endian issues
The flat tree code wasn't fixing the endianness on phandle values when
unflattening the tree, and the code in drivers/of wasn't always doing a
be32_to_cpu before trying to dereference the phandle values. This patch
fixes them.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/of')
-rw-r--r-- | drivers/of/base.c | 12 | ||||
-rw-r--r-- | drivers/of/fdt.c | 4 | ||||
-rw-r--r-- | drivers/of/irq.c | 6 |
3 files changed, 11 insertions, 11 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c index e3f7af882e45..aa805250de76 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c | |||
@@ -605,14 +605,14 @@ EXPORT_SYMBOL(of_find_node_by_phandle); | |||
605 | struct device_node * | 605 | struct device_node * |
606 | of_parse_phandle(struct device_node *np, const char *phandle_name, int index) | 606 | of_parse_phandle(struct device_node *np, const char *phandle_name, int index) |
607 | { | 607 | { |
608 | const phandle *phandle; | 608 | const __be32 *phandle; |
609 | int size; | 609 | int size; |
610 | 610 | ||
611 | phandle = of_get_property(np, phandle_name, &size); | 611 | phandle = of_get_property(np, phandle_name, &size); |
612 | if ((!phandle) || (size < sizeof(*phandle) * (index + 1))) | 612 | if ((!phandle) || (size < sizeof(*phandle) * (index + 1))) |
613 | return NULL; | 613 | return NULL; |
614 | 614 | ||
615 | return of_find_node_by_phandle(phandle[index]); | 615 | return of_find_node_by_phandle(be32_to_cpup(phandle + index)); |
616 | } | 616 | } |
617 | EXPORT_SYMBOL(of_parse_phandle); | 617 | EXPORT_SYMBOL(of_parse_phandle); |
618 | 618 | ||
@@ -668,16 +668,16 @@ int of_parse_phandles_with_args(struct device_node *np, const char *list_name, | |||
668 | 668 | ||
669 | while (list < list_end) { | 669 | while (list < list_end) { |
670 | const __be32 *cells; | 670 | const __be32 *cells; |
671 | const phandle *phandle; | 671 | phandle phandle; |
672 | 672 | ||
673 | phandle = list++; | 673 | phandle = be32_to_cpup(list++); |
674 | args = list; | 674 | args = list; |
675 | 675 | ||
676 | /* one cell hole in the list = <>; */ | 676 | /* one cell hole in the list = <>; */ |
677 | if (!*phandle) | 677 | if (!phandle) |
678 | goto next; | 678 | goto next; |
679 | 679 | ||
680 | node = of_find_node_by_phandle(*phandle); | 680 | node = of_find_node_by_phandle(phandle); |
681 | if (!node) { | 681 | if (!node) { |
682 | pr_debug("%s: could not find phandle\n", | 682 | pr_debug("%s: could not find phandle\n", |
683 | np->full_name); | 683 | np->full_name); |
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index dc876cbbd9dd..65da5aec7552 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c | |||
@@ -320,13 +320,13 @@ unsigned long __init unflatten_dt_node(unsigned long mem, | |||
320 | if ((strcmp(pname, "phandle") == 0) || | 320 | if ((strcmp(pname, "phandle") == 0) || |
321 | (strcmp(pname, "linux,phandle") == 0)) { | 321 | (strcmp(pname, "linux,phandle") == 0)) { |
322 | if (np->phandle == 0) | 322 | if (np->phandle == 0) |
323 | np->phandle = *((u32 *)*p); | 323 | np->phandle = be32_to_cpup((__be32*)*p); |
324 | } | 324 | } |
325 | /* And we process the "ibm,phandle" property | 325 | /* And we process the "ibm,phandle" property |
326 | * used in pSeries dynamic device tree | 326 | * used in pSeries dynamic device tree |
327 | * stuff */ | 327 | * stuff */ |
328 | if (strcmp(pname, "ibm,phandle") == 0) | 328 | if (strcmp(pname, "ibm,phandle") == 0) |
329 | np->phandle = *((u32 *)*p); | 329 | np->phandle = be32_to_cpup((__be32 *)*p); |
330 | pp->name = pname; | 330 | pp->name = pname; |
331 | pp->length = sz; | 331 | pp->length = sz; |
332 | pp->value = (void *)*p; | 332 | pp->value = (void *)*p; |
diff --git a/drivers/of/irq.c b/drivers/of/irq.c index 6cfb307204c3..65cfae1bd670 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c | |||
@@ -54,7 +54,7 @@ EXPORT_SYMBOL_GPL(irq_of_parse_and_map); | |||
54 | static struct device_node *of_irq_find_parent(struct device_node *child) | 54 | static struct device_node *of_irq_find_parent(struct device_node *child) |
55 | { | 55 | { |
56 | struct device_node *p; | 56 | struct device_node *p; |
57 | const phandle *parp; | 57 | const __be32 *parp; |
58 | 58 | ||
59 | if (!of_node_get(child)) | 59 | if (!of_node_get(child)) |
60 | return NULL; | 60 | return NULL; |
@@ -67,7 +67,7 @@ static struct device_node *of_irq_find_parent(struct device_node *child) | |||
67 | if (of_irq_workarounds & OF_IMAP_NO_PHANDLE) | 67 | if (of_irq_workarounds & OF_IMAP_NO_PHANDLE) |
68 | p = of_node_get(of_irq_dflt_pic); | 68 | p = of_node_get(of_irq_dflt_pic); |
69 | else | 69 | else |
70 | p = of_find_node_by_phandle(*parp); | 70 | p = of_find_node_by_phandle(be32_to_cpup(parp)); |
71 | } | 71 | } |
72 | of_node_put(child); | 72 | of_node_put(child); |
73 | child = p; | 73 | child = p; |
@@ -206,7 +206,7 @@ int of_irq_map_raw(struct device_node *parent, const u32 *intspec, u32 ointsize, | |||
206 | if (of_irq_workarounds & OF_IMAP_NO_PHANDLE) | 206 | if (of_irq_workarounds & OF_IMAP_NO_PHANDLE) |
207 | newpar = of_node_get(of_irq_dflt_pic); | 207 | newpar = of_node_get(of_irq_dflt_pic); |
208 | else | 208 | else |
209 | newpar = of_find_node_by_phandle((phandle)*imap); | 209 | newpar = of_find_node_by_phandle(be32_to_cpup(imap)); |
210 | imap++; | 210 | imap++; |
211 | --imaplen; | 211 | --imaplen; |
212 | 212 | ||