aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/prom_parse.c
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2006-07-12 01:35:54 -0400
committerPaul Mackerras <paulus@samba.org>2006-07-31 01:55:04 -0400
commita7f67bdf2c9f24509b8e81e0f35573b611987c80 (patch)
tree201662dd6504418ef3c84cfe1f280153a4d8cb29 /arch/powerpc/kernel/prom_parse.c
parent4288b92b9644fdb4c6168273873fe08f32090d7a (diff)
[POWERPC] Constify & voidify get_property()
Now that get_property() returns a void *, there's no need to cast its return value. Also, treat the return value as const, so we can constify get_property later. powerpc core changes. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/kernel/prom_parse.c')
-rw-r--r--arch/powerpc/kernel/prom_parse.c68
1 files changed, 35 insertions, 33 deletions
diff --git a/arch/powerpc/kernel/prom_parse.c b/arch/powerpc/kernel/prom_parse.c
index e9960170667b..cdcd5d665468 100644
--- a/arch/powerpc/kernel/prom_parse.c
+++ b/arch/powerpc/kernel/prom_parse.c
@@ -270,7 +270,7 @@ static int of_translate_one(struct device_node *parent, struct of_bus *bus,
270 struct of_bus *pbus, u32 *addr, 270 struct of_bus *pbus, u32 *addr,
271 int na, int ns, int pna) 271 int na, int ns, int pna)
272{ 272{
273 u32 *ranges; 273 const u32 *ranges;
274 unsigned int rlen; 274 unsigned int rlen;
275 int rone; 275 int rone;
276 u64 offset = OF_BAD_ADDR; 276 u64 offset = OF_BAD_ADDR;
@@ -287,7 +287,7 @@ static int of_translate_one(struct device_node *parent, struct of_bus *bus,
287 * to translate addresses that aren't supposed to be translated in 287 * to translate addresses that aren't supposed to be translated in
288 * the first place. --BenH. 288 * the first place. --BenH.
289 */ 289 */
290 ranges = (u32 *)get_property(parent, "ranges", &rlen); 290 ranges = get_property(parent, "ranges", &rlen);
291 if (ranges == NULL || rlen == 0) { 291 if (ranges == NULL || rlen == 0) {
292 offset = of_read_number(addr, na); 292 offset = of_read_number(addr, na);
293 memset(addr, 0, pna * 4); 293 memset(addr, 0, pna * 4);
@@ -330,7 +330,7 @@ static int of_translate_one(struct device_node *parent, struct of_bus *bus,
330 * that can be mapped to a cpu physical address). This is not really specified 330 * that can be mapped to a cpu physical address). This is not really specified
331 * that way, but this is traditionally the way IBM at least do things 331 * that way, but this is traditionally the way IBM at least do things
332 */ 332 */
333u64 of_translate_address(struct device_node *dev, u32 *in_addr) 333u64 of_translate_address(struct device_node *dev, const u32 *in_addr)
334{ 334{
335 struct device_node *parent = NULL; 335 struct device_node *parent = NULL;
336 struct of_bus *bus, *pbus; 336 struct of_bus *bus, *pbus;
@@ -407,10 +407,10 @@ u64 of_translate_address(struct device_node *dev, u32 *in_addr)
407} 407}
408EXPORT_SYMBOL(of_translate_address); 408EXPORT_SYMBOL(of_translate_address);
409 409
410u32 *of_get_address(struct device_node *dev, int index, u64 *size, 410const u32 *of_get_address(struct device_node *dev, int index, u64 *size,
411 unsigned int *flags) 411 unsigned int *flags)
412{ 412{
413 u32 *prop; 413 const u32 *prop;
414 unsigned int psize; 414 unsigned int psize;
415 struct device_node *parent; 415 struct device_node *parent;
416 struct of_bus *bus; 416 struct of_bus *bus;
@@ -427,7 +427,7 @@ u32 *of_get_address(struct device_node *dev, int index, u64 *size,
427 return NULL; 427 return NULL;
428 428
429 /* Get "reg" or "assigned-addresses" property */ 429 /* Get "reg" or "assigned-addresses" property */
430 prop = (u32 *)get_property(dev, bus->addresses, &psize); 430 prop = get_property(dev, bus->addresses, &psize);
431 if (prop == NULL) 431 if (prop == NULL)
432 return NULL; 432 return NULL;
433 psize /= 4; 433 psize /= 4;
@@ -445,10 +445,10 @@ u32 *of_get_address(struct device_node *dev, int index, u64 *size,
445} 445}
446EXPORT_SYMBOL(of_get_address); 446EXPORT_SYMBOL(of_get_address);
447 447
448u32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size, 448const u32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size,
449 unsigned int *flags) 449 unsigned int *flags)
450{ 450{
451 u32 *prop; 451 const u32 *prop;
452 unsigned int psize; 452 unsigned int psize;
453 struct device_node *parent; 453 struct device_node *parent;
454 struct of_bus *bus; 454 struct of_bus *bus;
@@ -469,7 +469,7 @@ u32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size,
469 return NULL; 469 return NULL;
470 470
471 /* Get "reg" or "assigned-addresses" property */ 471 /* Get "reg" or "assigned-addresses" property */
472 prop = (u32 *)get_property(dev, bus->addresses, &psize); 472 prop = get_property(dev, bus->addresses, &psize);
473 if (prop == NULL) 473 if (prop == NULL)
474 return NULL; 474 return NULL;
475 psize /= 4; 475 psize /= 4;
@@ -487,7 +487,7 @@ u32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size,
487} 487}
488EXPORT_SYMBOL(of_get_pci_address); 488EXPORT_SYMBOL(of_get_pci_address);
489 489
490static int __of_address_to_resource(struct device_node *dev, u32 *addrp, 490static int __of_address_to_resource(struct device_node *dev, const u32 *addrp,
491 u64 size, unsigned int flags, 491 u64 size, unsigned int flags,
492 struct resource *r) 492 struct resource *r)
493{ 493{
@@ -518,7 +518,7 @@ static int __of_address_to_resource(struct device_node *dev, u32 *addrp,
518int of_address_to_resource(struct device_node *dev, int index, 518int of_address_to_resource(struct device_node *dev, int index,
519 struct resource *r) 519 struct resource *r)
520{ 520{
521 u32 *addrp; 521 const u32 *addrp;
522 u64 size; 522 u64 size;
523 unsigned int flags; 523 unsigned int flags;
524 524
@@ -532,7 +532,7 @@ EXPORT_SYMBOL_GPL(of_address_to_resource);
532int of_pci_address_to_resource(struct device_node *dev, int bar, 532int of_pci_address_to_resource(struct device_node *dev, int bar,
533 struct resource *r) 533 struct resource *r)
534{ 534{
535 u32 *addrp; 535 const u32 *addrp;
536 u64 size; 536 u64 size;
537 unsigned int flags; 537 unsigned int flags;
538 538
@@ -543,13 +543,14 @@ int of_pci_address_to_resource(struct device_node *dev, int bar,
543} 543}
544EXPORT_SYMBOL_GPL(of_pci_address_to_resource); 544EXPORT_SYMBOL_GPL(of_pci_address_to_resource);
545 545
546void of_parse_dma_window(struct device_node *dn, unsigned char *dma_window_prop, 546void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop,
547 unsigned long *busno, unsigned long *phys, unsigned long *size) 547 unsigned long *busno, unsigned long *phys, unsigned long *size)
548{ 548{
549 u32 *dma_window, cells; 549 const u32 *dma_window;
550 unsigned char *prop; 550 u32 cells;
551 const unsigned char *prop;
551 552
552 dma_window = (u32 *)dma_window_prop; 553 dma_window = dma_window_prop;
553 554
554 /* busno is always one cell */ 555 /* busno is always one cell */
555 *busno = *(dma_window++); 556 *busno = *(dma_window++);
@@ -578,13 +579,13 @@ static struct device_node *of_irq_dflt_pic;
578static struct device_node *of_irq_find_parent(struct device_node *child) 579static struct device_node *of_irq_find_parent(struct device_node *child)
579{ 580{
580 struct device_node *p; 581 struct device_node *p;
581 phandle *parp; 582 const phandle *parp;
582 583
583 if (!of_node_get(child)) 584 if (!of_node_get(child))
584 return NULL; 585 return NULL;
585 586
586 do { 587 do {
587 parp = (phandle *)get_property(child, "interrupt-parent", NULL); 588 parp = get_property(child, "interrupt-parent", NULL);
588 if (parp == NULL) 589 if (parp == NULL)
589 p = of_get_parent(child); 590 p = of_get_parent(child);
590 else { 591 else {
@@ -646,11 +647,11 @@ void of_irq_map_init(unsigned int flags)
646 647
647} 648}
648 649
649int of_irq_map_raw(struct device_node *parent, u32 *intspec, u32 *addr, 650int of_irq_map_raw(struct device_node *parent, const u32 *intspec,
650 struct of_irq *out_irq) 651 const u32 *addr, struct of_irq *out_irq)
651{ 652{
652 struct device_node *ipar, *tnode, *old = NULL, *newpar = NULL; 653 struct device_node *ipar, *tnode, *old = NULL, *newpar = NULL;
653 u32 *tmp, *imap, *imask; 654 const u32 *tmp, *imap, *imask;
654 u32 intsize = 1, addrsize, newintsize = 0, newaddrsize = 0; 655 u32 intsize = 1, addrsize, newintsize = 0, newaddrsize = 0;
655 int imaplen, match, i; 656 int imaplen, match, i;
656 657
@@ -661,7 +662,7 @@ int of_irq_map_raw(struct device_node *parent, u32 *intspec, u32 *addr,
661 * is none, we are nice and just walk up the tree 662 * is none, we are nice and just walk up the tree
662 */ 663 */
663 do { 664 do {
664 tmp = (u32 *)get_property(ipar, "#interrupt-cells", NULL); 665 tmp = get_property(ipar, "#interrupt-cells", NULL);
665 if (tmp != NULL) { 666 if (tmp != NULL) {
666 intsize = *tmp; 667 intsize = *tmp;
667 break; 668 break;
@@ -682,7 +683,7 @@ int of_irq_map_raw(struct device_node *parent, u32 *intspec, u32 *addr,
682 */ 683 */
683 old = of_node_get(ipar); 684 old = of_node_get(ipar);
684 do { 685 do {
685 tmp = (u32 *)get_property(old, "#address-cells", NULL); 686 tmp = get_property(old, "#address-cells", NULL);
686 tnode = of_get_parent(old); 687 tnode = of_get_parent(old);
687 of_node_put(old); 688 of_node_put(old);
688 old = tnode; 689 old = tnode;
@@ -709,7 +710,7 @@ int of_irq_map_raw(struct device_node *parent, u32 *intspec, u32 *addr,
709 } 710 }
710 711
711 /* Now look for an interrupt-map */ 712 /* Now look for an interrupt-map */
712 imap = (u32 *)get_property(ipar, "interrupt-map", &imaplen); 713 imap = get_property(ipar, "interrupt-map", &imaplen);
713 /* No interrupt map, check for an interrupt parent */ 714 /* No interrupt map, check for an interrupt parent */
714 if (imap == NULL) { 715 if (imap == NULL) {
715 DBG(" -> no map, getting parent\n"); 716 DBG(" -> no map, getting parent\n");
@@ -719,7 +720,7 @@ int of_irq_map_raw(struct device_node *parent, u32 *intspec, u32 *addr,
719 imaplen /= sizeof(u32); 720 imaplen /= sizeof(u32);
720 721
721 /* Look for a mask */ 722 /* Look for a mask */
722 imask = (u32 *)get_property(ipar, "interrupt-map-mask", NULL); 723 imask = get_property(ipar, "interrupt-map-mask", NULL);
723 724
724 /* If we were passed no "reg" property and we attempt to parse 725 /* If we were passed no "reg" property and we attempt to parse
725 * an interrupt-map, then #address-cells must be 0. 726 * an interrupt-map, then #address-cells must be 0.
@@ -766,14 +767,14 @@ int of_irq_map_raw(struct device_node *parent, u32 *intspec, u32 *addr,
766 /* Get #interrupt-cells and #address-cells of new 767 /* Get #interrupt-cells and #address-cells of new
767 * parent 768 * parent
768 */ 769 */
769 tmp = (u32 *)get_property(newpar, "#interrupt-cells", 770 tmp = get_property(newpar, "#interrupt-cells",
770 NULL); 771 NULL);
771 if (tmp == NULL) { 772 if (tmp == NULL) {
772 DBG(" -> parent lacks #interrupt-cells !\n"); 773 DBG(" -> parent lacks #interrupt-cells !\n");
773 goto fail; 774 goto fail;
774 } 775 }
775 newintsize = *tmp; 776 newintsize = *tmp;
776 tmp = (u32 *)get_property(newpar, "#address-cells", 777 tmp = get_property(newpar, "#address-cells",
777 NULL); 778 NULL);
778 newaddrsize = (tmp == NULL) ? 0 : *tmp; 779 newaddrsize = (tmp == NULL) ? 0 : *tmp;
779 780
@@ -819,14 +820,14 @@ EXPORT_SYMBOL_GPL(of_irq_map_raw);
819static int of_irq_map_oldworld(struct device_node *device, int index, 820static int of_irq_map_oldworld(struct device_node *device, int index,
820 struct of_irq *out_irq) 821 struct of_irq *out_irq)
821{ 822{
822 u32 *ints; 823 const u32 *ints;
823 int intlen; 824 int intlen;
824 825
825 /* 826 /*
826 * Old machines just have a list of interrupt numbers 827 * Old machines just have a list of interrupt numbers
827 * and no interrupt-controller nodes. 828 * and no interrupt-controller nodes.
828 */ 829 */
829 ints = (u32 *) get_property(device, "AAPL,interrupts", &intlen); 830 ints = get_property(device, "AAPL,interrupts", &intlen);
830 if (ints == NULL) 831 if (ints == NULL)
831 return -EINVAL; 832 return -EINVAL;
832 intlen /= sizeof(u32); 833 intlen /= sizeof(u32);
@@ -851,7 +852,8 @@ static int of_irq_map_oldworld(struct device_node *device, int index,
851int of_irq_map_one(struct device_node *device, int index, struct of_irq *out_irq) 852int of_irq_map_one(struct device_node *device, int index, struct of_irq *out_irq)
852{ 853{
853 struct device_node *p; 854 struct device_node *p;
854 u32 *intspec, *tmp, intsize, intlen, *addr; 855 const u32 *intspec, *tmp, *addr;
856 u32 intsize, intlen;
855 int res; 857 int res;
856 858
857 DBG("of_irq_map_one: dev=%s, index=%d\n", device->full_name, index); 859 DBG("of_irq_map_one: dev=%s, index=%d\n", device->full_name, index);
@@ -861,13 +863,13 @@ int of_irq_map_one(struct device_node *device, int index, struct of_irq *out_irq
861 return of_irq_map_oldworld(device, index, out_irq); 863 return of_irq_map_oldworld(device, index, out_irq);
862 864
863 /* Get the interrupts property */ 865 /* Get the interrupts property */
864 intspec = (u32 *)get_property(device, "interrupts", &intlen); 866 intspec = get_property(device, "interrupts", &intlen);
865 if (intspec == NULL) 867 if (intspec == NULL)
866 return -EINVAL; 868 return -EINVAL;
867 intlen /= sizeof(u32); 869 intlen /= sizeof(u32);
868 870
869 /* Get the reg property (if any) */ 871 /* Get the reg property (if any) */
870 addr = (u32 *)get_property(device, "reg", NULL); 872 addr = get_property(device, "reg", NULL);
871 873
872 /* Look for the interrupt parent. */ 874 /* Look for the interrupt parent. */
873 p = of_irq_find_parent(device); 875 p = of_irq_find_parent(device);
@@ -875,7 +877,7 @@ int of_irq_map_one(struct device_node *device, int index, struct of_irq *out_irq
875 return -EINVAL; 877 return -EINVAL;
876 878
877 /* Get size of interrupt specifier */ 879 /* Get size of interrupt specifier */
878 tmp = (u32 *)get_property(p, "#interrupt-cells", NULL); 880 tmp = get_property(p, "#interrupt-cells", NULL);
879 if (tmp == NULL) { 881 if (tmp == NULL) {
880 of_node_put(p); 882 of_node_put(p);
881 return -EINVAL; 883 return -EINVAL;