Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'next-devicetree' of git://git.secretlab.ca/git/linux-2.6

* 'next-devicetree' of git://git.secretlab.ca/git/linux-2.6:
mtd/m25p80: add support to parse the partitions by OF node
of/irq: of_irq.c needs to include linux/irq.h
of/mips: Cleanup some include directives/files.
of/mips: Add device tree support to MIPS
of/flattree: Eliminate need to provide early_init_dt_scan_chosen_arch
of/device: Rework to use common platform_device_alloc() for allocating devices
of/xsysace: Fix OF probing on little-endian systems
of: use __be32 types for big-endian device tree data
of/irq: remove references to NO_IRQ in drivers/of/platform.c
of/promtree: add package-to-path support to pdt
of/promtree: add of_pdt namespace to pdt code
of/promtree: no longer call prom_ functions directly; use an ops structure
of/promtree: make drivers/of/pdt.c no longer sparc-only
sparc: break out some PROM device-tree building code out into drivers/of
of/sparc: convert various prom_* functions to use phandle
sparc: stop exporting openprom.h header
powerpc, of_serial: Endianness issues setting up the serial ports
of: MTD: Fix OF probing on little-endian systems
of: GPIO: Fix OF probing on little-endian systems

+805 -422
-5
arch/microblaze/kernel/prom.c
··· 42 42 #include <asm/sections.h> 43 43 #include <asm/pci-bridge.h> 44 44 45 - void __init early_init_dt_scan_chosen_arch(unsigned long node) 46 - { 47 - /* No Microblaze specific code here */ 48 - } 49 - 50 45 void __init early_init_dt_add_memory_arch(u64 base, u64 size) 51 46 { 52 47 memblock_add(base, size);
+7
arch/mips/Kconfig
··· 2128 2128 2129 2129 If unsure, say Y. Only embedded should say N here. 2130 2130 2131 + config USE_OF 2132 + bool "Flattened Device Tree support" 2133 + select OF 2134 + select OF_FLATTREE 2135 + help 2136 + Include support for flattened device tree machine descriptions. 2137 + 2131 2138 endmenu 2132 2139 2133 2140 config LOCKDEP_SUPPORT
+5
arch/mips/include/asm/irq.h
··· 16 16 17 17 #include <irq.h> 18 18 19 + static inline void irq_dispose_mapping(unsigned int virq) 20 + { 21 + return; 22 + } 23 + 19 24 #ifdef CONFIG_I8259 20 25 static inline int irq_canonicalize(int irq) 21 26 {
+31
arch/mips/include/asm/prom.h
··· 1 + /* 2 + * arch/mips/include/asm/prom.h 3 + * 4 + * Copyright (C) 2010 Cisco Systems Inc. <dediao@cisco.com> 5 + * 6 + * This program is free software; you can redistribute it and/or modify 7 + * it under the terms of the GNU General Public License version 2 as 8 + * published by the Free Software Foundation. 9 + * 10 + */ 11 + #ifndef __ASM_MIPS_PROM_H 12 + #define __ASM_MIPS_PROM_H 13 + 14 + #ifdef CONFIG_OF 15 + #include <asm/bootinfo.h> 16 + 17 + /* which is compatible with the flattened device tree (FDT) */ 18 + #define cmd_line arcs_cmdline 19 + 20 + extern int early_init_dt_scan_memory_arch(unsigned long node, 21 + const char *uname, int depth, void *data); 22 + 23 + extern int reserve_mem_mach(unsigned long addr, unsigned long size); 24 + extern void free_mem_mach(unsigned long addr, unsigned long size); 25 + 26 + extern void device_tree_init(void); 27 + #else /* CONFIG_OF */ 28 + static inline void device_tree_init(void) { } 29 + #endif /* CONFIG_OF */ 30 + 31 + #endif /* _ASM_MIPS_PROM_H */
+2
arch/mips/kernel/Makefile
··· 96 96 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o 97 97 obj-$(CONFIG_SPINLOCK_TEST) += spinlock_test.o 98 98 99 + obj-$(CONFIG_OF) += prom.o 100 + 99 101 CFLAGS_cpu-bugs64.o = $(shell if $(CC) $(KBUILD_CFLAGS) -Wa,-mdaddi -c -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-DHAVE_AS_SET_DADDI"; fi) 100 102 101 103 obj-$(CONFIG_HAVE_STD_PC_SERIAL_PORT) += 8250-platform.o
+112
arch/mips/kernel/prom.c
··· 1 + /* 2 + * MIPS support for CONFIG_OF device tree support 3 + * 4 + * Copyright (C) 2010 Cisco Systems Inc. <dediao@cisco.com> 5 + * 6 + * This program is free software; you can redistribute it and/or modify 7 + * it under the terms of the GNU General Public License version 2 as 8 + * published by the Free Software Foundation. 9 + */ 10 + 11 + #include <linux/init.h> 12 + #include <linux/module.h> 13 + #include <linux/errno.h> 14 + #include <linux/types.h> 15 + #include <linux/bootmem.h> 16 + #include <linux/initrd.h> 17 + #include <linux/debugfs.h> 18 + #include <linux/of.h> 19 + #include <linux/of_fdt.h> 20 + #include <linux/of_irq.h> 21 + #include <linux/of_platform.h> 22 + 23 + #include <asm/page.h> 24 + #include <asm/prom.h> 25 + 26 + int __init early_init_dt_scan_memory_arch(unsigned long node, 27 + const char *uname, int depth, 28 + void *data) 29 + { 30 + return early_init_dt_scan_memory(node, uname, depth, data); 31 + } 32 + 33 + void __init early_init_dt_add_memory_arch(u64 base, u64 size) 34 + { 35 + return add_memory_region(base, size, BOOT_MEM_RAM); 36 + } 37 + 38 + int __init reserve_mem_mach(unsigned long addr, unsigned long size) 39 + { 40 + return reserve_bootmem(addr, size, BOOTMEM_DEFAULT); 41 + } 42 + 43 + void __init free_mem_mach(unsigned long addr, unsigned long size) 44 + { 45 + return free_bootmem(addr, size); 46 + } 47 + 48 + u64 __init early_init_dt_alloc_memory_arch(u64 size, u64 align) 49 + { 50 + return virt_to_phys( 51 + __alloc_bootmem(size, align, __pa(MAX_DMA_ADDRESS)) 52 + ); 53 + } 54 + 55 + #ifdef CONFIG_BLK_DEV_INITRD 56 + void __init early_init_dt_setup_initrd_arch(unsigned long start, 57 + unsigned long end) 58 + { 59 + initrd_start = (unsigned long)__va(start); 60 + initrd_end = (unsigned long)__va(end); 61 + initrd_below_start_ok = 1; 62 + } 63 + #endif 64 + 65 + /* 66 + * irq_create_of_mapping - Hook to resolve OF irq specifier into a Linux irq# 67 + * 68 + * Currently the mapping mechanism is trivial; simple flat hwirq numbers are 69 + * mapped 1:1 onto Linux irq numbers. Cascaded irq controllers are not 70 + * supported. 71 + */ 72 + unsigned int irq_create_of_mapping(struct device_node *controller, 73 + const u32 *intspec, unsigned int intsize) 74 + { 75 + return intspec[0]; 76 + } 77 + EXPORT_SYMBOL_GPL(irq_create_of_mapping); 78 + 79 + void __init early_init_devtree(void *params) 80 + { 81 + /* Setup flat device-tree pointer */ 82 + initial_boot_params = params; 83 + 84 + /* Retrieve various informations from the /chosen node of the 85 + * device-tree, including the platform type, initrd location and 86 + * size, and more ... 87 + */ 88 + of_scan_flat_dt(early_init_dt_scan_chosen, NULL); 89 + 90 + /* Scan memory nodes */ 91 + of_scan_flat_dt(early_init_dt_scan_root, NULL); 92 + of_scan_flat_dt(early_init_dt_scan_memory_arch, NULL); 93 + } 94 + 95 + void __init device_tree_init(void) 96 + { 97 + unsigned long base, size; 98 + 99 + if (!initial_boot_params) 100 + return; 101 + 102 + base = virt_to_phys((void *)initial_boot_params); 103 + size = initial_boot_params->totalsize; 104 + 105 + /* Before we do anything, lets reserve the dt blob */ 106 + reserve_mem_mach(base, size); 107 + 108 + unflatten_device_tree(); 109 + 110 + /* free the space reserved for the dt blob */ 111 + free_mem_mach(base, size); 112 + }
+2
arch/mips/kernel/setup.c
··· 31 31 #include <asm/setup.h> 32 32 #include <asm/smp-ops.h> 33 33 #include <asm/system.h> 34 + #include <asm/prom.h> 34 35 35 36 struct cpuinfo_mips cpu_data[NR_CPUS] __read_mostly; 36 37 ··· 488 487 } 489 488 490 489 bootmem_init(); 490 + device_tree_init(); 491 491 sparse_init(); 492 492 paging_init(); 493 493 }
+4 -7
arch/powerpc/kernel/ibmebus.c
··· 162 162 dev->dev.bus = &ibmebus_bus_type; 163 163 dev->dev.archdata.dma_ops = &ibmebus_dma_ops; 164 164 165 - ret = of_device_register(dev); 166 - if (ret) { 167 - of_device_free(dev); 168 - return ret; 169 - } 170 - 171 - return 0; 165 + ret = of_device_add(dev); 166 + if (ret) 167 + platform_device_put(dev); 168 + return ret; 172 169 } 173 170 174 171 static int ibmebus_create_devices(const struct of_device_id *matches)
+11 -11
arch/powerpc/kernel/legacy_serial.c
··· 52 52 phys_addr_t taddr, unsigned long irq, 53 53 upf_t flags, int irq_check_parent) 54 54 { 55 - const u32 *clk, *spd; 55 + const __be32 *clk, *spd; 56 56 u32 clock = BASE_BAUD * 16; 57 57 int index; 58 58 59 59 /* get clock freq. if present */ 60 60 clk = of_get_property(np, "clock-frequency", NULL); 61 61 if (clk && *clk) 62 - clock = *clk; 62 + clock = be32_to_cpup(clk); 63 63 64 64 /* get default speed if present */ 65 65 spd = of_get_property(np, "current-speed", NULL); ··· 109 109 legacy_serial_infos[index].taddr = taddr; 110 110 legacy_serial_infos[index].np = of_node_get(np); 111 111 legacy_serial_infos[index].clock = clock; 112 - legacy_serial_infos[index].speed = spd ? *spd : 0; 112 + legacy_serial_infos[index].speed = spd ? be32_to_cpup(spd) : 0; 113 113 legacy_serial_infos[index].irq_check_parent = irq_check_parent; 114 114 115 115 printk(KERN_DEBUG "Found legacy serial port %d for %s\n", ··· 168 168 static int __init add_legacy_isa_port(struct device_node *np, 169 169 struct device_node *isa_brg) 170 170 { 171 - const u32 *reg; 171 + const __be32 *reg; 172 172 const char *typep; 173 173 int index = -1; 174 174 u64 taddr; ··· 181 181 return -1; 182 182 183 183 /* Verify it's an IO port, we don't support anything else */ 184 - if (!(reg[0] & 0x00000001)) 184 + if (!(be32_to_cpu(reg[0]) & 0x00000001)) 185 185 return -1; 186 186 187 187 /* Now look for an "ibm,aix-loc" property that gives us ordering ··· 202 202 taddr = 0; 203 203 204 204 /* Add port, irq will be dealt with later */ 205 - return add_legacy_port(np, index, UPIO_PORT, reg[1], taddr, 205 + return add_legacy_port(np, index, UPIO_PORT, be32_to_cpu(reg[1]), taddr, 206 206 NO_IRQ, UPF_BOOT_AUTOCONF, 0); 207 207 208 208 } ··· 251 251 * we get to their "reg" property 252 252 */ 253 253 if (np != pci_dev) { 254 - const u32 *reg = of_get_property(np, "reg", NULL); 255 - if (reg && (*reg < 4)) 256 - index = lindex = *reg; 254 + const __be32 *reg = of_get_property(np, "reg", NULL); 255 + if (reg && (be32_to_cpup(reg) < 4)) 256 + index = lindex = be32_to_cpup(reg); 257 257 } 258 258 259 259 /* Local index means it's the Nth port in the PCI chip. Unfortunately ··· 507 507 struct device_node *prom_stdout = NULL; 508 508 int i, speed = 0, offset = 0; 509 509 const char *name; 510 - const u32 *spd; 510 + const __be32 *spd; 511 511 512 512 DBG(" -> check_legacy_serial_console()\n"); 513 513 ··· 547 547 } 548 548 spd = of_get_property(prom_stdout, "current-speed", NULL); 549 549 if (spd) 550 - speed = *spd; 550 + speed = be32_to_cpup(spd); 551 551 552 552 if (strcmp(name, "serial") != 0) 553 553 goto not_found;
+10 -2
arch/powerpc/kernel/prom.c
··· 364 364 return 0; 365 365 } 366 366 367 - void __init early_init_dt_scan_chosen_arch(unsigned long node) 367 + int __init early_init_dt_scan_chosen_ppc(unsigned long node, const char *uname, 368 + int depth, void *data) 368 369 { 369 370 unsigned long *lprop; 371 + 372 + /* Use common scan routine to determine if this is the chosen node */ 373 + if (early_init_dt_scan_chosen(node, uname, depth, data) == 0) 374 + return 0; 370 375 371 376 #ifdef CONFIG_PPC64 372 377 /* check if iommu is forced on or off */ ··· 404 399 if (lprop) 405 400 crashk_res.end = crashk_res.start + *lprop - 1; 406 401 #endif 402 + 403 + /* break now */ 404 + return 1; 407 405 } 408 406 409 407 #ifdef CONFIG_PPC_PSERIES ··· 691 683 * device-tree, including the platform type, initrd location and 692 684 * size, TCE reserve, and more ... 693 685 */ 694 - of_scan_flat_dt(early_init_dt_scan_chosen, NULL); 686 + of_scan_flat_dt(early_init_dt_scan_chosen_ppc, NULL); 695 687 696 688 /* Scan memory nodes and rebuild MEMBLOCKs */ 697 689 memblock_init();
+1
arch/sparc/Kconfig
··· 19 19 bool 20 20 default y 21 21 select OF 22 + select OF_PROMTREE 22 23 select HAVE_IDE 23 24 select HAVE_OPROFILE 24 25 select HAVE_ARCH_KGDB if !SMP || SPARC64
-1
arch/sparc/include/asm/Kbuild
··· 7 7 header-y += envctrl.h 8 8 header-y += fbio.h 9 9 header-y += jsflash.h 10 - header-y += openprom.h 11 10 header-y += openpromio.h 12 11 header-y += perfctr.h 13 12 header-y += psrcompat.h
+2 -1
arch/sparc/include/asm/floppy_32.h
··· 304 304 static int sun_floppy_init(void) 305 305 { 306 306 char state[128]; 307 - int tnode, fd_node, num_regs; 307 + phandle tnode, fd_node; 308 + int num_regs; 308 309 struct resource r; 309 310 310 311 use_virtual_dma = 1;
+9 -7
arch/sparc/include/asm/openprom.h
··· 11 11 #define LINUX_OPPROM_MAGIC 0x10010407 12 12 13 13 #ifndef __ASSEMBLY__ 14 + #include <linux/of.h> 15 + 14 16 /* V0 prom device operations. */ 15 17 struct linux_dev_v0_funcs { 16 18 int (*v0_devopen)(char *device_str); ··· 28 26 29 27 /* V2 and later prom device operations. */ 30 28 struct linux_dev_v2_funcs { 31 - int (*v2_inst2pkg)(int d); /* Convert ihandle to phandle */ 29 + phandle (*v2_inst2pkg)(int d); /* Convert ihandle to phandle */ 32 30 char * (*v2_dumb_mem_alloc)(char *va, unsigned sz); 33 31 void (*v2_dumb_mem_free)(char *va, unsigned sz); 34 32 ··· 170 168 171 169 /* Routines for traversing the prom device tree. */ 172 170 struct linux_nodeops { 173 - int (*no_nextnode)(int node); 174 - int (*no_child)(int node); 175 - int (*no_proplen)(int node, const char *name); 176 - int (*no_getprop)(int node, const char *name, char *val); 177 - int (*no_setprop)(int node, const char *name, char *val, int len); 178 - char * (*no_nextprop)(int node, char *name); 171 + phandle (*no_nextnode)(phandle node); 172 + phandle (*no_child)(phandle node); 173 + int (*no_proplen)(phandle node, const char *name); 174 + int (*no_getprop)(phandle node, const char *name, char *val); 175 + int (*no_setprop)(phandle node, const char *name, char *val, int len); 176 + char * (*no_nextprop)(phandle node, char *name); 179 177 }; 180 178 181 179 /* More fun PROM structures for device probing. */
+22 -22
arch/sparc/include/asm/oplib_32.h
··· 30 30 /* Root node of the prom device tree, this stays constant after 31 31 * initialization is complete. 32 32 */ 33 - extern int prom_root_node; 33 + extern phandle prom_root_node; 34 34 35 35 /* Pointer to prom structure containing the device tree traversal 36 36 * and usage utility functions. Only prom-lib should use these, ··· 178 178 /* PROM device tree traversal functions... */ 179 179 180 180 /* Get the child node of the given node, or zero if no child exists. */ 181 - extern int prom_getchild(int parent_node); 181 + extern phandle prom_getchild(phandle parent_node); 182 182 183 183 /* Get the next sibling node of the given node, or zero if no further 184 184 * siblings exist. 185 185 */ 186 - extern int prom_getsibling(int node); 186 + extern phandle prom_getsibling(phandle node); 187 187 188 188 /* Get the length, at the passed node, of the given property type. 189 189 * Returns -1 on error (ie. no such property at this node). 190 190 */ 191 - extern int prom_getproplen(int thisnode, const char *property); 191 + extern int prom_getproplen(phandle thisnode, const char *property); 192 192 193 193 /* Fetch the requested property using the given buffer. Returns 194 194 * the number of bytes the prom put into your buffer or -1 on error. 195 195 */ 196 - extern int __must_check prom_getproperty(int thisnode, const char *property, 196 + extern int __must_check prom_getproperty(phandle thisnode, const char *property, 197 197 char *prop_buffer, int propbuf_size); 198 198 199 199 /* Acquire an integer property. */ 200 - extern int prom_getint(int node, char *property); 200 + extern int prom_getint(phandle node, char *property); 201 201 202 202 /* Acquire an integer property, with a default value. */ 203 - extern int prom_getintdefault(int node, char *property, int defval); 203 + extern int prom_getintdefault(phandle node, char *property, int defval); 204 204 205 205 /* Acquire a boolean property, 0=FALSE 1=TRUE. */ 206 - extern int prom_getbool(int node, char *prop); 206 + extern int prom_getbool(phandle node, char *prop); 207 207 208 208 /* Acquire a string property, null string on error. */ 209 - extern void prom_getstring(int node, char *prop, char *buf, int bufsize); 209 + extern void prom_getstring(phandle node, char *prop, char *buf, int bufsize); 210 210 211 211 /* Does the passed node have the given "name"? YES=1 NO=0 */ 212 - extern int prom_nodematch(int thisnode, char *name); 212 + extern int prom_nodematch(phandle thisnode, char *name); 213 213 214 214 /* Search all siblings starting at the passed node for "name" matching 215 215 * the given string. Returns the node on success, zero on failure. 216 216 */ 217 - extern int prom_searchsiblings(int node_start, char *name); 217 + extern phandle prom_searchsiblings(phandle node_start, char *name); 218 218 219 219 /* Return the first property type, as a string, for the given node. 220 220 * Returns a null string on error. 221 221 */ 222 - extern char *prom_firstprop(int node, char *buffer); 222 + extern char *prom_firstprop(phandle node, char *buffer); 223 223 224 224 /* Returns the next property after the passed property for the given 225 225 * node. Returns null string on failure. 226 226 */ 227 - extern char *prom_nextprop(int node, char *prev_property, char *buffer); 227 + extern char *prom_nextprop(phandle node, char *prev_property, char *buffer); 228 228 229 229 /* Returns phandle of the path specified */ 230 - extern int prom_finddevice(char *name); 230 + extern phandle prom_finddevice(char *name); 231 231 232 232 /* Returns 1 if the specified node has given property. */ 233 - extern int prom_node_has_property(int node, char *property); 233 + extern int prom_node_has_property(phandle node, char *property); 234 234 235 235 /* Set the indicated property at the given node with the passed value. 236 236 * Returns the number of bytes of your value that the prom took. 237 237 */ 238 - extern int prom_setprop(int node, const char *prop_name, char *prop_value, 238 + extern int prom_setprop(phandle node, const char *prop_name, char *prop_value, 239 239 int value_size); 240 240 241 - extern int prom_pathtoinode(char *path); 242 - extern int prom_inst2pkg(int); 241 + extern phandle prom_pathtoinode(char *path); 242 + extern phandle prom_inst2pkg(int); 243 243 244 244 /* Dorking with Bus ranges... */ 245 245 ··· 247 247 extern void prom_apply_obio_ranges(struct linux_prom_registers *obioregs, int nregs); 248 248 249 249 /* Apply ranges of any prom node (and optionally parent node as well) to registers. */ 250 - extern void prom_apply_generic_ranges(int node, int parent, 250 + extern void prom_apply_generic_ranges(phandle node, phandle parent, 251 251 struct linux_prom_registers *sbusregs, int nregs); 252 252 253 253 /* CPU probing helpers. */ 254 - int cpu_find_by_instance(int instance, int *prom_node, int *mid); 255 - int cpu_find_by_mid(int mid, int *prom_node); 256 - int cpu_get_hwmid(int prom_node); 254 + int cpu_find_by_instance(int instance, phandle *prom_node, int *mid); 255 + int cpu_find_by_mid(int mid, phandle *prom_node); 256 + int cpu_get_hwmid(phandle prom_node); 257 257 258 258 extern spinlock_t prom_lock; 259 259
+20 -19
arch/sparc/include/asm/oplib_64.h
··· 16 16 /* Root node of the prom device tree, this stays constant after 17 17 * initialization is complete. 18 18 */ 19 - extern int prom_root_node; 19 + extern phandle prom_root_node; 20 20 21 21 /* PROM stdin and stdout */ 22 22 extern int prom_stdin, prom_stdout; ··· 24 24 /* /chosen node of the prom device tree, this stays constant after 25 25 * initialization is complete. 26 26 */ 27 - extern int prom_chosen_node; 27 + extern phandle prom_chosen_node; 28 28 29 29 /* Helper values and strings in arch/sparc64/kernel/head.S */ 30 30 extern const char prom_peer_name[]; ··· 218 218 /* PROM device tree traversal functions... */ 219 219 220 220 /* Get the child node of the given node, or zero if no child exists. */ 221 - extern int prom_getchild(int parent_node); 221 + extern phandle prom_getchild(phandle parent_node); 222 222 223 223 /* Get the next sibling node of the given node, or zero if no further 224 224 * siblings exist. 225 225 */ 226 - extern int prom_getsibling(int node); 226 + extern phandle prom_getsibling(phandle node); 227 227 228 228 /* Get the length, at the passed node, of the given property type. 229 229 * Returns -1 on error (ie. no such property at this node). 230 230 */ 231 - extern int prom_getproplen(int thisnode, const char *property); 231 + extern int prom_getproplen(phandle thisnode, const char *property); 232 232 233 233 /* Fetch the requested property using the given buffer. Returns 234 234 * the number of bytes the prom put into your buffer or -1 on error. 235 235 */ 236 - extern int prom_getproperty(int thisnode, const char *property, 236 + extern int prom_getproperty(phandle thisnode, const char *property, 237 237 char *prop_buffer, int propbuf_size); 238 238 239 239 /* Acquire an integer property. */ 240 - extern int prom_getint(int node, const char *property); 240 + extern int prom_getint(phandle node, const char *property); 241 241 242 242 /* Acquire an integer property, with a default value. */ 243 - extern int prom_getintdefault(int node, const char *property, int defval); 243 + extern int prom_getintdefault(phandle node, const char *property, int defval); 244 244 245 245 /* Acquire a boolean property, 0=FALSE 1=TRUE. */ 246 - extern int prom_getbool(int node, const char *prop); 246 + extern int prom_getbool(phandle node, const char *prop); 247 247 248 248 /* Acquire a string property, null string on error. */ 249 - extern void prom_getstring(int node, const char *prop, char *buf, int bufsize); 249 + extern void prom_getstring(phandle node, const char *prop, char *buf, 250 + int bufsize); 250 251 251 252 /* Does the passed node have the given "name"? YES=1 NO=0 */ 252 - extern int prom_nodematch(int thisnode, const char *name); 253 + extern int prom_nodematch(phandle thisnode, const char *name); 253 254 254 255 /* Search all siblings starting at the passed node for "name" matching 255 256 * the given string. Returns the node on success, zero on failure. 256 257 */ 257 - extern int prom_searchsiblings(int node_start, const char *name); 258 + extern phandle prom_searchsiblings(phandle node_start, const char *name); 258 259 259 260 /* Return the first property type, as a string, for the given node. 260 261 * Returns a null string on error. Buffer should be at least 32B long. 261 262 */ 262 - extern char *prom_firstprop(int node, char *buffer); 263 + extern char *prom_firstprop(phandle node, char *buffer); 263 264 264 265 /* Returns the next property after the passed property for the given 265 266 * node. Returns null string on failure. Buffer should be at least 32B long. 266 267 */ 267 - extern char *prom_nextprop(int node, const char *prev_property, char *buffer); 268 + extern char *prom_nextprop(phandle node, const char *prev_property, char *buf); 268 269 269 270 /* Returns 1 if the specified node has given property. */ 270 - extern int prom_node_has_property(int node, const char *property); 271 + extern int prom_node_has_property(phandle node, const char *property); 271 272 272 273 /* Returns phandle of the path specified */ 273 - extern int prom_finddevice(const char *name); 274 + extern phandle prom_finddevice(const char *name); 274 275 275 276 /* Set the indicated property at the given node with the passed value. 276 277 * Returns the number of bytes of your value that the prom took. 277 278 */ 278 - extern int prom_setprop(int node, const char *prop_name, char *prop_value, 279 + extern int prom_setprop(phandle node, const char *prop_name, char *prop_value, 279 280 int value_size); 280 281 281 - extern int prom_pathtoinode(const char *path); 282 - extern int prom_inst2pkg(int); 282 + extern phandle prom_pathtoinode(const char *path); 283 + extern phandle prom_inst2pkg(int); 283 284 extern int prom_service_exists(const char *service_name); 284 285 extern void prom_sun4v_guest_soft_state(void); 285 286
+3 -2
arch/sparc/include/asm/prom.h
··· 18 18 * 2 of the License, or (at your option) any later version. 19 19 */ 20 20 #include <linux/types.h> 21 + #include <linux/of_pdt.h> 21 22 #include <linux/proc_fs.h> 22 23 #include <linux/mutex.h> 23 24 #include <asm/atomic.h> ··· 68 67 extern char *of_console_path; 69 68 extern char *of_console_options; 70 69 71 - extern void (*prom_build_more)(struct device_node *dp, struct device_node ***nextp); 72 - extern char *build_full_name(struct device_node *dp); 70 + extern void irq_trans_init(struct device_node *dp); 71 + extern char *build_path_component(struct device_node *dp); 73 72 74 73 #endif /* __KERNEL__ */ 75 74 #endif /* _SPARC_PROM_H */
+2 -2
arch/sparc/kernel/auxio_32.c
··· 23 23 24 24 void __init auxio_probe(void) 25 25 { 26 - int node, auxio_nd; 26 + phandle node, auxio_nd; 27 27 struct linux_prom_registers auxregs[1]; 28 28 struct resource r; 29 29 ··· 113 113 void __init auxio_power_probe(void) 114 114 { 115 115 struct linux_prom_registers regs; 116 - int node; 116 + phandle node; 117 117 struct resource r; 118 118 119 119 /* Attempt to find the sun4m power control node. */
+2 -2
arch/sparc/kernel/btext.c
··· 40 40 41 41 static unsigned char vga_font[cmapsz]; 42 42 43 - static int __init btext_initialize(unsigned int node) 43 + static int __init btext_initialize(phandle node) 44 44 { 45 45 unsigned int width, height, depth, pitch; 46 46 unsigned long address = 0; ··· 309 309 310 310 int __init btext_find_display(void) 311 311 { 312 - unsigned int node; 312 + phandle node; 313 313 char type[32]; 314 314 int ret; 315 315
+12 -11
arch/sparc/kernel/devices.c
··· 31 31 return "mid"; 32 32 } 33 33 34 - static int check_cpu_node(int nd, int *cur_inst, 35 - int (*compare)(int, int, void *), void *compare_arg, 36 - int *prom_node, int *mid) 34 + static int check_cpu_node(phandle nd, int *cur_inst, 35 + int (*compare)(phandle, int, void *), void *compare_arg, 36 + phandle *prom_node, int *mid) 37 37 { 38 38 if (!compare(nd, *cur_inst, compare_arg)) { 39 39 if (prom_node) ··· 51 51 return -ENODEV; 52 52 } 53 53 54 - static int __cpu_find_by(int (*compare)(int, int, void *), void *compare_arg, 55 - int *prom_node, int *mid) 54 + static int __cpu_find_by(int (*compare)(phandle, int, void *), 55 + void *compare_arg, phandle *prom_node, int *mid) 56 56 { 57 57 struct device_node *dp; 58 58 int cur_inst; ··· 71 71 return -ENODEV; 72 72 } 73 73 74 - static int cpu_instance_compare(int nd, int instance, void *_arg) 74 + static int cpu_instance_compare(phandle nd, int instance, void *_arg) 75 75 { 76 76 int desired_instance = (int) _arg; 77 77 ··· 80 80 return -ENODEV; 81 81 } 82 82 83 - int cpu_find_by_instance(int instance, int *prom_node, int *mid) 83 + int cpu_find_by_instance(int instance, phandle *prom_node, int *mid) 84 84 { 85 85 return __cpu_find_by(cpu_instance_compare, (void *)instance, 86 86 prom_node, mid); 87 87 } 88 88 89 - static int cpu_mid_compare(int nd, int instance, void *_arg) 89 + static int cpu_mid_compare(phandle nd, int instance, void *_arg) 90 90 { 91 91 int desired_mid = (int) _arg; 92 92 int this_mid; ··· 98 98 return -ENODEV; 99 99 } 100 100 101 - int cpu_find_by_mid(int mid, int *prom_node) 101 + int cpu_find_by_mid(int mid, phandle *prom_node) 102 102 { 103 103 return __cpu_find_by(cpu_mid_compare, (void *)mid, 104 104 prom_node, NULL); ··· 108 108 * address (0-3). This gives us the true hardware mid, which might have 109 109 * some other bits set. On 4d hardware and software mids are the same. 110 110 */ 111 - int cpu_get_hwmid(int prom_node) 111 + int cpu_get_hwmid(phandle prom_node) 112 112 { 113 113 return prom_getintdefault(prom_node, cpu_mid_prop(), -ENODEV); 114 114 } ··· 119 119 120 120 #ifndef CONFIG_SMP 121 121 { 122 - int err, cpu_node; 122 + phandle cpu_node; 123 + int err; 123 124 err = cpu_find_by_instance(0, &cpu_node, NULL); 124 125 if (err) { 125 126 /* Probably a sun4e, Sun is trying to trick us ;-) */
+1 -1
arch/sparc/kernel/leon_kernel.c
··· 282 282 283 283 void __init leon_init(void) 284 284 { 285 - prom_build_more = &leon_node_init; 285 + of_pdt_build_more = &leon_node_init; 286 286 }
+2 -2
arch/sparc/kernel/pcic.c
··· 284 284 struct linux_prom_registers regs[PROMREG_MAX]; 285 285 struct linux_pbm_info* pbm; 286 286 char namebuf[64]; 287 - int node; 287 + phandle node; 288 288 int err; 289 289 290 290 if (pcic0_up) { ··· 440 440 { 441 441 struct linux_prom_pci_registers regs[PROMREG_MAX]; 442 442 int err; 443 - int node = prom_getchild(pbm->prom_node); 443 + phandle node = prom_getchild(pbm->prom_node); 444 444 445 445 while(node) { 446 446 err = prom_getproperty(node, "reg",
-6
arch/sparc/kernel/prom.h
··· 4 4 #include <linux/spinlock.h> 5 5 #include <asm/prom.h> 6 6 7 - extern void * prom_early_alloc(unsigned long size); 8 - extern void irq_trans_init(struct device_node *dp); 9 - 10 - extern unsigned int prom_unique_id; 11 - 12 - extern char *build_path_component(struct device_node *dp); 13 7 extern void of_console_init(void); 14 8 15 9 extern unsigned int prom_early_allocated;
+33 -179
arch/sparc/kernel/prom_common.c
··· 20 20 #include <linux/mutex.h> 21 21 #include <linux/slab.h> 22 22 #include <linux/of.h> 23 + #include <linux/of_pdt.h> 23 24 #include <asm/prom.h> 24 25 #include <asm/oplib.h> 25 26 #include <asm/leon.h> 26 27 27 28 #include "prom.h" 28 - 29 - void (*prom_build_more)(struct device_node *dp, struct device_node ***nextp); 30 29 31 30 struct device_node *of_console_device; 32 31 EXPORT_SYMBOL(of_console_device); ··· 118 119 } 119 120 EXPORT_SYMBOL(of_find_in_proplist); 120 121 121 - unsigned int prom_unique_id; 122 - 123 - static struct property * __init build_one_prop(phandle node, char *prev, 124 - char *special_name, 125 - void *special_val, 126 - int special_len) 122 + /* 123 + * SPARC32 and SPARC64's prom_nextprop() do things differently 124 + * here, despite sharing the same interface. SPARC32 doesn't fill in 'buf', 125 + * returning NULL on an error. SPARC64 fills in 'buf', but sets it to an 126 + * empty string upon error. 127 + */ 128 + static int __init handle_nextprop_quirks(char *buf, const char *name) 127 129 { 128 - static struct property *tmp = NULL; 129 - struct property *p; 130 + if (!name || strlen(name) == 0) 131 + return -1; 132 + 133 + #ifdef CONFIG_SPARC32 134 + strcpy(buf, name); 135 + #endif 136 + return 0; 137 + } 138 + 139 + static int __init prom_common_nextprop(phandle node, char *prev, char *buf) 140 + { 130 141 const char *name; 131 142 132 - if (tmp) { 133 - p = tmp; 134 - memset(p, 0, sizeof(*p) + 32); 135 - tmp = NULL; 136 - } else { 137 - p = prom_early_alloc(sizeof(struct property) + 32); 138 - p->unique_id = prom_unique_id++; 139 - } 140 - 141 - p->name = (char *) (p + 1); 142 - if (special_name) { 143 - strcpy(p->name, special_name); 144 - p->length = special_len; 145 - p->value = prom_early_alloc(special_len); 146 - memcpy(p->value, special_val, special_len); 147 - } else { 148 - if (prev == NULL) { 149 - name = prom_firstprop(node, p->name); 150 - } else { 151 - name = prom_nextprop(node, prev, p->name); 152 - } 153 - 154 - if (!name || strlen(name) == 0) { 155 - tmp = p; 156 - return NULL; 157 - } 158 - #ifdef CONFIG_SPARC32 159 - strcpy(p->name, name); 160 - #endif 161 - p->length = prom_getproplen(node, p->name); 162 - if (p->length <= 0) { 163 - p->length = 0; 164 - } else { 165 - int len; 166 - 167 - p->value = prom_early_alloc(p->length + 1); 168 - len = prom_getproperty(node, p->name, p->value, 169 - p->length); 170 - if (len <= 0) 171 - p->length = 0; 172 - ((unsigned char *)p->value)[p->length] = '\0'; 173 - } 174 - } 175 - return p; 176 - } 177 - 178 - static struct property * __init build_prop_list(phandle node) 179 - { 180 - struct property *head, *tail; 181 - 182 - head = tail = build_one_prop(node, NULL, 183 - ".node", &node, sizeof(node)); 184 - 185 - tail->next = build_one_prop(node, NULL, NULL, NULL, 0); 186 - tail = tail->next; 187 - while(tail) { 188 - tail->next = build_one_prop(node, tail->name, 189 - NULL, NULL, 0); 190 - tail = tail->next; 191 - } 192 - 193 - return head; 194 - } 195 - 196 - static char * __init get_one_property(phandle node, const char *name) 197 - { 198 - char *buf = "<NULL>"; 199 - int len; 200 - 201 - len = prom_getproplen(node, name); 202 - if (len > 0) { 203 - buf = prom_early_alloc(len); 204 - len = prom_getproperty(node, name, buf, len); 205 - } 206 - 207 - return buf; 208 - } 209 - 210 - static struct device_node * __init prom_create_node(phandle node, 211 - struct device_node *parent) 212 - { 213 - struct device_node *dp; 214 - 215 - if (!node) 216 - return NULL; 217 - 218 - dp = prom_early_alloc(sizeof(*dp)); 219 - dp->unique_id = prom_unique_id++; 220 - dp->parent = parent; 221 - 222 - kref_init(&dp->kref); 223 - 224 - dp->name = get_one_property(node, "name"); 225 - dp->type = get_one_property(node, "device_type"); 226 - dp->phandle = node; 227 - 228 - dp->properties = build_prop_list(node); 229 - 230 - irq_trans_init(dp); 231 - 232 - return dp; 233 - } 234 - 235 - char * __init build_full_name(struct device_node *dp) 236 - { 237 - int len, ourlen, plen; 238 - char *n; 239 - 240 - plen = strlen(dp->parent->full_name); 241 - ourlen = strlen(dp->path_component_name); 242 - len = ourlen + plen + 2; 243 - 244 - n = prom_early_alloc(len); 245 - strcpy(n, dp->parent->full_name); 246 - if (!of_node_is_root(dp->parent)) { 247 - strcpy(n + plen, "/"); 248 - plen++; 249 - } 250 - strcpy(n + plen, dp->path_component_name); 251 - 252 - return n; 253 - } 254 - 255 - static struct device_node * __init prom_build_tree(struct device_node *parent, 256 - phandle node, 257 - struct device_node ***nextp) 258 - { 259 - struct device_node *ret = NULL, *prev_sibling = NULL; 260 - struct device_node *dp; 261 - 262 - while (1) { 263 - dp = prom_create_node(node, parent); 264 - if (!dp) 265 - break; 266 - 267 - if (prev_sibling) 268 - prev_sibling->sibling = dp; 269 - 270 - if (!ret) 271 - ret = dp; 272 - prev_sibling = dp; 273 - 274 - *(*nextp) = dp; 275 - *nextp = &dp->allnext; 276 - 277 - dp->path_component_name = build_path_component(dp); 278 - dp->full_name = build_full_name(dp); 279 - 280 - dp->child = prom_build_tree(dp, prom_getchild(node), nextp); 281 - 282 - if (prom_build_more) 283 - prom_build_more(dp, nextp); 284 - 285 - node = prom_getsibling(node); 286 - } 287 - 288 - return ret; 143 + buf[0] = '\0'; 144 + name = prom_nextprop(node, prev, buf); 145 + return handle_nextprop_quirks(buf, name); 289 146 } 290 147 291 148 unsigned int prom_early_allocated __initdata; 292 149 150 + static struct of_pdt_ops prom_sparc_ops __initdata = { 151 + .nextprop = prom_common_nextprop, 152 + .getproplen = prom_getproplen, 153 + .getproperty = prom_getproperty, 154 + .getchild = prom_getchild, 155 + .getsibling = prom_getsibling, 156 + }; 157 + 293 158 void __init prom_build_devicetree(void) 294 159 { 295 - struct device_node **nextp; 296 - 297 - allnodes = prom_create_node(prom_root_node, NULL); 298 - allnodes->path_component_name = ""; 299 - allnodes->full_name = "/"; 300 - 301 - nextp = &allnodes->allnext; 302 - allnodes->child = prom_build_tree(allnodes, 303 - prom_getchild(allnodes->phandle), 304 - &nextp); 160 + of_pdt_build_devicetree(prom_root_node, &prom_sparc_ops); 305 161 of_console_init(); 306 162 307 - printk("PROM: Built device tree with %u bytes of memory.\n", 308 - prom_early_allocated); 163 + pr_info("PROM: Built device tree with %u bytes of memory.\n", 164 + prom_early_allocated); 309 165 }
+1 -1
arch/sparc/kernel/setup_64.c
··· 315 315 316 316 #ifdef CONFIG_IP_PNP 317 317 if (!ic_set_manually) { 318 - int chosen = prom_finddevice ("/chosen"); 318 + phandle chosen = prom_finddevice("/chosen"); 319 319 u32 cl, sv, gw; 320 320 321 321 cl = prom_getintdefault (chosen, "client-ip", 0);
+1 -1
arch/sparc/kernel/starfire.c
··· 23 23 24 24 void check_if_starfire(void) 25 25 { 26 - int ssnode = prom_finddevice("/ssp-serial"); 26 + phandle ssnode = prom_finddevice("/ssp-serial"); 27 27 if (ssnode != 0 && ssnode != -1) 28 28 this_is_starfire = 1; 29 29 }
+1 -1
arch/sparc/kernel/tadpole.c
··· 100 100 101 101 void __init clock_stop_probe(void) 102 102 { 103 - unsigned int node, clk_nd; 103 + phandle node, clk_nd; 104 104 char name[20]; 105 105 106 106 prom_getstring(prom_root_node, "name", name, sizeof(name));
+1 -1
arch/sparc/mm/init_64.c
··· 88 88 struct linux_prom64_registers *regs, 89 89 int *num_ents) 90 90 { 91 - int node = prom_finddevice("/memory"); 91 + phandle node = prom_finddevice("/memory"); 92 92 int prop_size = prom_getproplen(node, property); 93 93 int ents, ret, i; 94 94
+5 -3
arch/sparc/mm/srmmu.c
··· 1262 1262 1263 1263 void __init srmmu_paging_init(void) 1264 1264 { 1265 - int i, cpunode; 1265 + int i; 1266 + phandle cpunode; 1266 1267 char node_str[128]; 1267 1268 pgd_t *pgd; 1268 1269 pmd_t *pmd; ··· 1399 1398 1400 1399 static void __init init_vac_layout(void) 1401 1400 { 1402 - int nd, cache_lines; 1401 + phandle nd; 1402 + int cache_lines; 1403 1403 char node_str[128]; 1404 1404 #ifdef CONFIG_SMP 1405 1405 int cpu = 0; ··· 2084 2082 2085 2083 /* Next check for Fujitsu Swift. */ 2086 2084 if(psr_typ == 0 && psr_vers == 4) { 2087 - int cpunode; 2085 + phandle cpunode; 2088 2086 char node_str[128]; 2089 2087 2090 2088 /* Look if it is not a TurboSparc emulating Swift... */
+1 -1
arch/sparc/mm/sun4c.c
··· 420 420 421 421 void __init sun4c_probe_memerr_reg(void) 422 422 { 423 - int node; 423 + phandle node; 424 424 struct linux_prom_registers regs[1]; 425 425 426 426 node = prom_getchild(prom_root_node);
+1 -1
arch/sparc/prom/init_32.c
··· 20 20 unsigned int prom_rev, prom_prev; 21 21 22 22 /* The root node of the prom device tree. */ 23 - int prom_root_node; 23 + phandle prom_root_node; 24 24 EXPORT_SYMBOL(prom_root_node); 25 25 26 26 /* Pointer to the device tree operations structure. */
+2 -2
arch/sparc/prom/init_64.c
··· 19 19 20 20 /* The root node of the prom device tree. */ 21 21 int prom_stdin, prom_stdout; 22 - int prom_chosen_node; 22 + phandle prom_chosen_node; 23 23 24 24 /* You must call prom_init() before you attempt to use any of the 25 25 * routines in the prom library. It returns 0 on success, 1 on ··· 30 30 31 31 void __init prom_init(void *cif_handler, void *cif_stack) 32 32 { 33 - int node; 33 + phandle node; 34 34 35 35 prom_cif_init(cif_handler, cif_stack); 36 36
+2 -1
arch/sparc/prom/memory.c
··· 31 31 static int __init prom_meminit_v2(void) 32 32 { 33 33 struct linux_prom_registers reg[64]; 34 - int node, size, num_ents, i; 34 + phandle node; 35 + int size, num_ents, i; 35 36 36 37 node = prom_searchsiblings(prom_getchild(prom_root_node), "memory"); 37 38 size = prom_getproperty(node, "available", (char *) reg, sizeof(reg));
+4 -2
arch/sparc/prom/misc_64.c
··· 183 183 184 184 int prom_get_mmu_ihandle(void) 185 185 { 186 - int node, ret; 186 + phandle node; 187 + int ret; 187 188 188 189 if (prom_mmu_ihandle_cache != 0) 189 190 return prom_mmu_ihandle_cache; ··· 202 201 static int prom_get_memory_ihandle(void) 203 202 { 204 203 static int memory_ihandle_cache; 205 - int node, ret; 204 + phandle node; 205 + int ret; 206 206 207 207 if (memory_ihandle_cache != 0) 208 208 return memory_ihandle_cache;
+3 -3
arch/sparc/prom/ranges.c
··· 68 68 69 69 void __init prom_ranges_init(void) 70 70 { 71 - int node, obio_node; 71 + phandle node, obio_node; 72 72 int success; 73 73 74 74 num_obio_ranges = 0; ··· 89 89 prom_printf("PROMLIB: obio_ranges %d\n", num_obio_ranges); 90 90 } 91 91 92 - void 93 - prom_apply_generic_ranges (int node, int parent, struct linux_prom_registers *regs, int nregs) 92 + void prom_apply_generic_ranges(phandle node, phandle parent, 93 + struct linux_prom_registers *regs, int nregs) 94 94 { 95 95 int success; 96 96 int num_ranges;
+30 -28
arch/sparc/prom/tree_32.c
··· 20 20 static char promlib_buf[128]; 21 21 22 22 /* Internal version of prom_getchild that does not alter return values. */ 23 - int __prom_getchild(int node) 23 + phandle __prom_getchild(phandle node) 24 24 { 25 25 unsigned long flags; 26 - int cnode; 26 + phandle cnode; 27 27 28 28 spin_lock_irqsave(&prom_lock, flags); 29 29 cnode = prom_nodeops->no_child(node); ··· 36 36 /* Return the child of node 'node' or zero if no this node has no 37 37 * direct descendent. 38 38 */ 39 - int prom_getchild(int node) 39 + phandle prom_getchild(phandle node) 40 40 { 41 - int cnode; 41 + phandle cnode; 42 42 43 43 if (node == -1) 44 44 return 0; ··· 52 52 EXPORT_SYMBOL(prom_getchild); 53 53 54 54 /* Internal version of prom_getsibling that does not alter return values. */ 55 - int __prom_getsibling(int node) 55 + phandle __prom_getsibling(phandle node) 56 56 { 57 57 unsigned long flags; 58 - int cnode; 58 + phandle cnode; 59 59 60 60 spin_lock_irqsave(&prom_lock, flags); 61 61 cnode = prom_nodeops->no_nextnode(node); ··· 68 68 /* Return the next sibling of node 'node' or zero if no more siblings 69 69 * at this level of depth in the tree. 70 70 */ 71 - int prom_getsibling(int node) 71 + phandle prom_getsibling(phandle node) 72 72 { 73 - int sibnode; 73 + phandle sibnode; 74 74 75 75 if (node == -1) 76 76 return 0; ··· 86 86 /* Return the length in bytes of property 'prop' at node 'node'. 87 87 * Return -1 on error. 88 88 */ 89 - int prom_getproplen(int node, const char *prop) 89 + int prom_getproplen(phandle node, const char *prop) 90 90 { 91 91 int ret; 92 92 unsigned long flags; ··· 106 106 * 'buffer' which has a size of 'bufsize'. If the acquisition 107 107 * was successful the length will be returned, else -1 is returned. 108 108 */ 109 - int prom_getproperty(int node, const char *prop, char *buffer, int bufsize) 109 + int prom_getproperty(phandle node, const char *prop, char *buffer, int bufsize) 110 110 { 111 111 int plen, ret; 112 112 unsigned long flags; ··· 126 126 /* Acquire an integer property and return its value. Returns -1 127 127 * on failure. 128 128 */ 129 - int prom_getint(int node, char *prop) 129 + int prom_getint(phandle node, char *prop) 130 130 { 131 131 static int intprop; 132 132 ··· 140 140 /* Acquire an integer property, upon error return the passed default 141 141 * integer. 142 142 */ 143 - int prom_getintdefault(int node, char *property, int deflt) 143 + int prom_getintdefault(phandle node, char *property, int deflt) 144 144 { 145 145 int retval; 146 146 ··· 152 152 EXPORT_SYMBOL(prom_getintdefault); 153 153 154 154 /* Acquire a boolean property, 1=TRUE 0=FALSE. */ 155 - int prom_getbool(int node, char *prop) 155 + int prom_getbool(phandle node, char *prop) 156 156 { 157 157 int retval; 158 158 ··· 166 166 * string on error. The char pointer is the user supplied string 167 167 * buffer. 168 168 */ 169 - void prom_getstring(int node, char *prop, char *user_buf, int ubuf_size) 169 + void prom_getstring(phandle node, char *prop, char *user_buf, int ubuf_size) 170 170 { 171 171 int len; 172 172 ··· 180 180 /* Does the device at node 'node' have name 'name'? 181 181 * YES = 1 NO = 0 182 182 */ 183 - int prom_nodematch(int node, char *name) 183 + int prom_nodematch(phandle node, char *name) 184 184 { 185 185 int error; 186 186 ··· 194 194 /* Search siblings at 'node_start' for a node with name 195 195 * 'nodename'. Return node if successful, zero if not. 196 196 */ 197 - int prom_searchsiblings(int node_start, char *nodename) 197 + phandle prom_searchsiblings(phandle node_start, char *nodename) 198 198 { 199 199 200 - int thisnode, error; 200 + phandle thisnode; 201 + int error; 201 202 202 203 for(thisnode = node_start; thisnode; 203 204 thisnode=prom_getsibling(thisnode)) { ··· 214 213 EXPORT_SYMBOL(prom_searchsiblings); 215 214 216 215 /* Interal version of nextprop that does not alter return values. */ 217 - char * __prom_nextprop(int node, char * oprop) 216 + char *__prom_nextprop(phandle node, char * oprop) 218 217 { 219 218 unsigned long flags; 220 219 char *prop; ··· 229 228 230 229 /* Return the first property name for node 'node'. */ 231 230 /* buffer is unused argument, but as v9 uses it, we need to have the same interface */ 232 - char * prom_firstprop(int node, char *bufer) 231 + char *prom_firstprop(phandle node, char *bufer) 233 232 { 234 233 if (node == 0 || node == -1) 235 234 return ""; ··· 242 241 * at node 'node' . Returns empty string if no more 243 242 * property types for this node. 244 243 */ 245 - char * prom_nextprop(int node, char *oprop, char *buffer) 244 + char *prom_nextprop(phandle node, char *oprop, char *buffer) 246 245 { 247 246 if (node == 0 || node == -1) 248 247 return ""; ··· 251 250 } 252 251 EXPORT_SYMBOL(prom_nextprop); 253 252 254 - int prom_finddevice(char *name) 253 + phandle prom_finddevice(char *name) 255 254 { 256 255 char nbuf[128]; 257 256 char *s = name, *d; 258 - int node = prom_root_node, node2; 257 + phandle node = prom_root_node, node2; 259 258 unsigned int which_io, phys_addr; 260 259 struct linux_prom_registers reg[PROMREG_MAX]; 261 260 ··· 299 298 } 300 299 EXPORT_SYMBOL(prom_finddevice); 301 300 302 - int prom_node_has_property(int node, char *prop) 301 + int prom_node_has_property(phandle node, char *prop) 303 302 { 304 303 char *current_property = ""; 305 304 ··· 315 314 /* Set property 'pname' at node 'node' to value 'value' which has a length 316 315 * of 'size' bytes. Return the number of bytes the prom accepted. 317 316 */ 318 - int prom_setprop(int node, const char *pname, char *value, int size) 317 + int prom_setprop(phandle node, const char *pname, char *value, int size) 319 318 { 320 319 unsigned long flags; 321 320 int ret; ··· 330 329 } 331 330 EXPORT_SYMBOL(prom_setprop); 332 331 333 - int prom_inst2pkg(int inst) 332 + phandle prom_inst2pkg(int inst) 334 333 { 335 - int node; 334 + phandle node; 336 335 unsigned long flags; 337 336 338 337 spin_lock_irqsave(&prom_lock, flags); ··· 346 345 /* Return 'node' assigned to a particular prom 'path' 347 346 * FIXME: Should work for v0 as well 348 347 */ 349 - int prom_pathtoinode(char *path) 348 + phandle prom_pathtoinode(char *path) 350 349 { 351 - int node, inst; 350 + phandle node; 351 + int inst; 352 352 353 353 inst = prom_devopen (path); 354 354 if (inst == -1) return 0;
+31 -31
arch/sparc/prom/tree_64.c
··· 16 16 #include <asm/oplib.h> 17 17 #include <asm/ldc.h> 18 18 19 - static int prom_node_to_node(const char *type, int node) 19 + static phandle prom_node_to_node(const char *type, phandle node) 20 20 { 21 21 unsigned long args[5]; 22 22 ··· 28 28 29 29 p1275_cmd_direct(args); 30 30 31 - return (int) args[4]; 31 + return (phandle) args[4]; 32 32 } 33 33 34 34 /* Return the child of node 'node' or zero if no this node has no 35 35 * direct descendent. 36 36 */ 37 - inline int __prom_getchild(int node) 37 + inline phandle __prom_getchild(phandle node) 38 38 { 39 39 return prom_node_to_node("child", node); 40 40 } 41 41 42 - inline int prom_getchild(int node) 42 + inline phandle prom_getchild(phandle node) 43 43 { 44 - int cnode; 44 + phandle cnode; 45 45 46 46 if (node == -1) 47 47 return 0; ··· 52 52 } 53 53 EXPORT_SYMBOL(prom_getchild); 54 54 55 - inline int prom_getparent(int node) 55 + inline phandle prom_getparent(phandle node) 56 56 { 57 - int cnode; 57 + phandle cnode; 58 58 59 59 if (node == -1) 60 60 return 0; ··· 67 67 /* Return the next sibling of node 'node' or zero if no more siblings 68 68 * at this level of depth in the tree. 69 69 */ 70 - inline int __prom_getsibling(int node) 70 + inline phandle __prom_getsibling(phandle node) 71 71 { 72 72 return prom_node_to_node(prom_peer_name, node); 73 73 } 74 74 75 - inline int prom_getsibling(int node) 75 + inline phandle prom_getsibling(phandle node) 76 76 { 77 - int sibnode; 77 + phandle sibnode; 78 78 79 79 if (node == -1) 80 80 return 0; ··· 89 89 /* Return the length in bytes of property 'prop' at node 'node'. 90 90 * Return -1 on error. 91 91 */ 92 - inline int prom_getproplen(int node, const char *prop) 92 + inline int prom_getproplen(phandle node, const char *prop) 93 93 { 94 94 unsigned long args[6]; 95 95 ··· 113 113 * 'buffer' which has a size of 'bufsize'. If the acquisition 114 114 * was successful the length will be returned, else -1 is returned. 115 115 */ 116 - inline int prom_getproperty(int node, const char *prop, 116 + inline int prom_getproperty(phandle node, const char *prop, 117 117 char *buffer, int bufsize) 118 118 { 119 119 unsigned long args[8]; ··· 141 141 /* Acquire an integer property and return its value. Returns -1 142 142 * on failure. 143 143 */ 144 - inline int prom_getint(int node, const char *prop) 144 + inline int prom_getint(phandle node, const char *prop) 145 145 { 146 146 int intprop; 147 147 ··· 156 156 * integer. 157 157 */ 158 158 159 - int prom_getintdefault(int node, const char *property, int deflt) 159 + int prom_getintdefault(phandle node, const char *property, int deflt) 160 160 { 161 161 int retval; 162 162 ··· 169 169 EXPORT_SYMBOL(prom_getintdefault); 170 170 171 171 /* Acquire a boolean property, 1=TRUE 0=FALSE. */ 172 - int prom_getbool(int node, const char *prop) 172 + int prom_getbool(phandle node, const char *prop) 173 173 { 174 174 int retval; 175 175 ··· 184 184 * string on error. The char pointer is the user supplied string 185 185 * buffer. 186 186 */ 187 - void prom_getstring(int node, const char *prop, char *user_buf, int ubuf_size) 187 + void prom_getstring(phandle node, const char *prop, char *user_buf, 188 + int ubuf_size) 188 189 { 189 190 int len; 190 191 ··· 199 198 /* Does the device at node 'node' have name 'name'? 200 199 * YES = 1 NO = 0 201 200 */ 202 - int prom_nodematch(int node, const char *name) 201 + int prom_nodematch(phandle node, const char *name) 203 202 { 204 203 char namebuf[128]; 205 204 prom_getproperty(node, "name", namebuf, sizeof(namebuf)); ··· 211 210 /* Search siblings at 'node_start' for a node with name 212 211 * 'nodename'. Return node if successful, zero if not. 213 212 */ 214 - int prom_searchsiblings(int node_start, const char *nodename) 213 + phandle prom_searchsiblings(phandle node_start, const char *nodename) 215 214 { 216 - 217 - int thisnode, error; 215 + phandle thisnode; 216 + int error; 218 217 char promlib_buf[128]; 219 218 220 219 for(thisnode = node_start; thisnode; ··· 235 234 /* Return the first property type for node 'node'. 236 235 * buffer should be at least 32B in length 237 236 */ 238 - inline char *prom_firstprop(int node, char *buffer) 237 + inline char *prom_firstprop(phandle node, char *buffer) 239 238 { 240 239 unsigned long args[7]; 241 240 ··· 261 260 * at node 'node' . Returns NULL string if no more 262 261 * property types for this node. 263 262 */ 264 - inline char *prom_nextprop(int node, const char *oprop, char *buffer) 263 + inline char *prom_nextprop(phandle node, const char *oprop, char *buffer) 265 264 { 266 265 unsigned long args[7]; 267 266 char buf[32]; ··· 289 288 } 290 289 EXPORT_SYMBOL(prom_nextprop); 291 290 292 - int 293 - prom_finddevice(const char *name) 291 + phandle prom_finddevice(const char *name) 294 292 { 295 293 unsigned long args[5]; 296 294 ··· 307 307 } 308 308 EXPORT_SYMBOL(prom_finddevice); 309 309 310 - int prom_node_has_property(int node, const char *prop) 310 + int prom_node_has_property(phandle node, const char *prop) 311 311 { 312 312 char buf [32]; 313 313 ··· 325 325 * of 'size' bytes. Return the number of bytes the prom accepted. 326 326 */ 327 327 int 328 - prom_setprop(int node, const char *pname, char *value, int size) 328 + prom_setprop(phandle node, const char *pname, char *value, int size) 329 329 { 330 330 unsigned long args[8]; 331 331 ··· 355 355 } 356 356 EXPORT_SYMBOL(prom_setprop); 357 357 358 - inline int prom_inst2pkg(int inst) 358 + inline phandle prom_inst2pkg(int inst) 359 359 { 360 360 unsigned long args[5]; 361 - int node; 361 + phandle node; 362 362 363 363 args[0] = (unsigned long) "instance-to-package"; 364 364 args[1] = 1; ··· 377 377 /* Return 'node' assigned to a particular prom 'path' 378 378 * FIXME: Should work for v0 as well 379 379 */ 380 - int 381 - prom_pathtoinode(const char *path) 380 + phandle prom_pathtoinode(const char *path) 382 381 { 383 - int node, inst; 382 + phandle node; 383 + int inst; 384 384 385 385 inst = prom_devopen (path); 386 386 if (inst == 0)
+1
drivers/base/platform.c
··· 147 147 struct platform_object *pa = container_of(dev, struct platform_object, 148 148 pdev.dev); 149 149 150 + of_device_node_put(&pa->pdev.dev); 150 151 kfree(pa->pdev.dev.platform_data); 151 152 kfree(pa->pdev.resource); 152 153 kfree(pa);
+2 -1
drivers/block/xsysace.c
··· 1225 1225 bus_width = ACE_BUS_WIDTH_8; 1226 1226 1227 1227 /* Call the bus-independant setup code */ 1228 - return ace_alloc(&op->dev, id ? *id : 0, physaddr, irq, bus_width); 1228 + return ace_alloc(&op->dev, id ? be32_to_cpup(id) : 0, 1229 + physaddr, irq, bus_width); 1229 1230 } 1230 1231 1231 1232 static int __devexit ace_of_remove(struct platform_device *op)
+3 -3
drivers/gpio/xilinx_gpio.c
··· 171 171 /* Update GPIO state shadow register with default value */ 172 172 tree_info = of_get_property(np, "xlnx,dout-default", NULL); 173 173 if (tree_info) 174 - chip->gpio_state = *tree_info; 174 + chip->gpio_state = be32_to_cpup(tree_info); 175 175 176 176 /* Update GPIO direction shadow register with default value */ 177 177 chip->gpio_dir = 0xFFFFFFFF; /* By default, all pins are inputs */ 178 178 tree_info = of_get_property(np, "xlnx,tri-default", NULL); 179 179 if (tree_info) 180 - chip->gpio_dir = *tree_info; 180 + chip->gpio_dir = be32_to_cpup(tree_info); 181 181 182 182 /* Check device node and parent device node for device width */ 183 183 chip->mmchip.gc.ngpio = 32; /* By default assume full GPIO controller */ ··· 186 186 tree_info = of_get_property(np->parent, 187 187 "xlnx,gpio-width", NULL); 188 188 if (tree_info) 189 - chip->mmchip.gc.ngpio = *tree_info; 189 + chip->mmchip.gc.ngpio = be32_to_cpup(tree_info); 190 190 191 191 spin_lock_init(&chip->gpio_lock); 192 192
+7
drivers/mtd/devices/m25p80.c
··· 924 924 nr_parts = data->nr_parts; 925 925 } 926 926 927 + #ifdef CONFIG_OF 928 + if (nr_parts <= 0 && spi->dev.of_node) { 929 + nr_parts = of_mtd_parse_partitions(&spi->dev, 930 + spi->dev.of_node, &parts); 931 + } 932 + #endif 933 + 927 934 if (nr_parts > 0) { 928 935 for (i = 0; i < nr_parts; i++) { 929 936 DEBUG(MTD_DEBUG_LEVEL2, "partitions[%d] = "
+1 -1
drivers/mtd/maps/physmap_of.c
··· 294 294 info->list[i].map.name = dev_name(&dev->dev); 295 295 info->list[i].map.phys = res.start; 296 296 info->list[i].map.size = res_size; 297 - info->list[i].map.bankwidth = *width; 297 + info->list[i].map.bankwidth = be32_to_cpup(width); 298 298 299 299 err = -ENOMEM; 300 300 info->list[i].map.virt = ioremap(info->list[i].map.phys,
+2 -2
drivers/mtd/ofpart.c
··· 53 53 continue; 54 54 } 55 55 56 - (*pparts)[i].offset = reg[0]; 57 - (*pparts)[i].size = reg[1]; 56 + (*pparts)[i].offset = be32_to_cpu(reg[0]); 57 + (*pparts)[i].size = be32_to_cpu(reg[1]); 58 58 59 59 partname = of_get_property(pp, "label", &len); 60 60 if (!partname)
+4 -1
drivers/of/Kconfig
··· 4 4 config OF 5 5 bool 6 6 7 - menu "Flattened Device Tree and Open Firmware support" 7 + menu "Device Tree and Open Firmware support" 8 8 depends on OF 9 9 10 10 config PROC_DEVICETREE ··· 18 18 config OF_FLATTREE 19 19 bool 20 20 select DTC 21 + 22 + config OF_PROMTREE 23 + bool 21 24 22 25 config OF_DYNAMIC 23 26 def_bool y
+1
drivers/of/Makefile
··· 1 1 obj-y = base.o 2 2 obj-$(CONFIG_OF_FLATTREE) += fdt.o 3 + obj-$(CONFIG_OF_PROMTREE) += pdt.o 3 4 obj-$(CONFIG_OF_ADDRESS) += address.o 4 5 obj-$(CONFIG_OF_IRQ) += irq.o 5 6 obj-$(CONFIG_OF_DEVICE) += device.o platform.o
+1 -1
drivers/of/address.c
··· 163 163 const u32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size, 164 164 unsigned int *flags) 165 165 { 166 - const u32 *prop; 166 + const __be32 *prop; 167 167 unsigned int psize; 168 168 struct device_node *parent; 169 169 struct of_bus *bus;
+2 -2
drivers/of/base.c
··· 33 33 34 34 int of_n_addr_cells(struct device_node *np) 35 35 { 36 - const int *ip; 36 + const __be32 *ip; 37 37 38 38 do { 39 39 if (np->parent) ··· 49 49 50 50 int of_n_size_cells(struct device_node *np) 51 51 { 52 - const int *ip; 52 + const __be32 *ip; 53 53 54 54 do { 55 55 if (np->parent)
+7 -20
drivers/of/device.c
··· 81 81 __ATTR_NULL 82 82 }; 83 83 84 - /** 85 - * of_release_dev - free an of device structure when all users of it are finished. 86 - * @dev: device that's been disconnected 87 - * 88 - * Will be called only by the device core when all users of this of device are 89 - * done. 90 - */ 91 - void of_release_dev(struct device *dev) 92 - { 93 - struct platform_device *ofdev; 94 - 95 - ofdev = to_platform_device(dev); 96 - of_node_put(ofdev->dev.of_node); 97 - kfree(ofdev); 98 - } 99 - EXPORT_SYMBOL(of_release_dev); 100 - 101 - int of_device_register(struct platform_device *ofdev) 84 + int of_device_add(struct platform_device *ofdev) 102 85 { 103 86 BUG_ON(ofdev->dev.of_node == NULL); 104 - 105 - device_initialize(&ofdev->dev); 106 87 107 88 /* name and id have to be set so that the platform bus doesn't get 108 89 * confused on matching */ ··· 97 116 set_dev_node(&ofdev->dev, of_node_to_nid(ofdev->dev.of_node)); 98 117 99 118 return device_add(&ofdev->dev); 119 + } 120 + 121 + int of_device_register(struct platform_device *pdev) 122 + { 123 + device_initialize(&pdev->dev); 124 + return of_device_add(pdev); 100 125 } 101 126 EXPORT_SYMBOL(of_device_register); 102 127
-2
drivers/of/fdt.c
··· 533 533 strlcpy(cmd_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE); 534 534 #endif /* CONFIG_CMDLINE */ 535 535 536 - early_init_dt_scan_chosen_arch(node); 537 - 538 536 pr_debug("Command line is: %s\n", cmd_line); 539 537 540 538 /* break now */
+39
drivers/of/irq.c
··· 24 24 #include <linux/of_irq.h> 25 25 #include <linux/string.h> 26 26 27 + /* For archs that don't support NO_IRQ (such as x86), provide a dummy value */ 28 + #ifndef NO_IRQ 29 + #define NO_IRQ 0 30 + #endif 31 + 27 32 /** 28 33 * irq_of_parse_and_map - Parse and map an interrupt into linux virq space 29 34 * @device: Device node of the device whose interrupt is to be mapped ··· 352 347 return irq; 353 348 } 354 349 EXPORT_SYMBOL_GPL(of_irq_to_resource); 350 + 351 + /** 352 + * of_irq_count - Count the number of IRQs a node uses 353 + * @dev: pointer to device tree node 354 + */ 355 + int of_irq_count(struct device_node *dev) 356 + { 357 + int nr = 0; 358 + 359 + while (of_irq_to_resource(dev, nr, NULL) != NO_IRQ) 360 + nr++; 361 + 362 + return nr; 363 + } 364 + 365 + /** 366 + * of_irq_to_resource_table - Fill in resource table with node's IRQ info 367 + * @dev: pointer to device tree node 368 + * @res: array of resources to fill in 369 + * @nr_irqs: the number of IRQs (and upper bound for num of @res elements) 370 + * 371 + * Returns the size of the filled in table (up to @nr_irqs). 372 + */ 373 + int of_irq_to_resource_table(struct device_node *dev, struct resource *res, 374 + int nr_irqs) 375 + { 376 + int i; 377 + 378 + for (i = 0; i < nr_irqs; i++, res++) 379 + if (of_irq_to_resource(dev, i, res) == NO_IRQ) 380 + break; 381 + 382 + return i; 383 + }
+1
drivers/of/of_i2c.c
··· 12 12 */ 13 13 14 14 #include <linux/i2c.h> 15 + #include <linux/irq.h> 15 16 #include <linux/of.h> 16 17 #include <linux/of_i2c.h> 17 18 #include <linux/of_irq.h>
+276
drivers/of/pdt.c
··· 1 + /* pdt.c: OF PROM device tree support code. 2 + * 3 + * Paul Mackerras August 1996. 4 + * Copyright (C) 1996-2005 Paul Mackerras. 5 + * 6 + * Adapted for 64bit PowerPC by Dave Engebretsen and Peter Bergner. 7 + * {engebret|bergner}@us.ibm.com 8 + * 9 + * Adapted for sparc by David S. Miller davem@davemloft.net 10 + * Adapted for multiple architectures by Andres Salomon <dilinger@queued.net> 11 + * 12 + * This program is free software; you can redistribute it and/or 13 + * modify it under the terms of the GNU General Public License 14 + * as published by the Free Software Foundation; either version 15 + * 2 of the License, or (at your option) any later version. 16 + */ 17 + 18 + #include <linux/kernel.h> 19 + #include <linux/module.h> 20 + #include <linux/errno.h> 21 + #include <linux/mutex.h> 22 + #include <linux/slab.h> 23 + #include <linux/of.h> 24 + #include <linux/of_pdt.h> 25 + #include <asm/prom.h> 26 + 27 + static struct of_pdt_ops *of_pdt_prom_ops __initdata; 28 + 29 + void __initdata (*of_pdt_build_more)(struct device_node *dp, 30 + struct device_node ***nextp); 31 + 32 + #if defined(CONFIG_SPARC) 33 + unsigned int of_pdt_unique_id __initdata; 34 + 35 + #define of_pdt_incr_unique_id(p) do { \ 36 + (p)->unique_id = of_pdt_unique_id++; \ 37 + } while (0) 38 + 39 + static inline const char *of_pdt_node_name(struct device_node *dp) 40 + { 41 + return dp->path_component_name; 42 + } 43 + 44 + #else 45 + 46 + static inline void of_pdt_incr_unique_id(void *p) { } 47 + static inline void irq_trans_init(struct device_node *dp) { } 48 + 49 + static inline const char *of_pdt_node_name(struct device_node *dp) 50 + { 51 + return dp->name; 52 + } 53 + 54 + #endif /* !CONFIG_SPARC */ 55 + 56 + static struct property * __init of_pdt_build_one_prop(phandle node, char *prev, 57 + char *special_name, 58 + void *special_val, 59 + int special_len) 60 + { 61 + static struct property *tmp = NULL; 62 + struct property *p; 63 + int err; 64 + 65 + if (tmp) { 66 + p = tmp; 67 + memset(p, 0, sizeof(*p) + 32); 68 + tmp = NULL; 69 + } else { 70 + p = prom_early_alloc(sizeof(struct property) + 32); 71 + of_pdt_incr_unique_id(p); 72 + } 73 + 74 + p->name = (char *) (p + 1); 75 + if (special_name) { 76 + strcpy(p->name, special_name); 77 + p->length = special_len; 78 + p->value = prom_early_alloc(special_len); 79 + memcpy(p->value, special_val, special_len); 80 + } else { 81 + err = of_pdt_prom_ops->nextprop(node, prev, p->name); 82 + if (err) { 83 + tmp = p; 84 + return NULL; 85 + } 86 + p->length = of_pdt_prom_ops->getproplen(node, p->name); 87 + if (p->length <= 0) { 88 + p->length = 0; 89 + } else { 90 + int len; 91 + 92 + p->value = prom_early_alloc(p->length + 1); 93 + len = of_pdt_prom_ops->getproperty(node, p->name, 94 + p->value, p->length); 95 + if (len <= 0) 96 + p->length = 0; 97 + ((unsigned char *)p->value)[p->length] = '\0'; 98 + } 99 + } 100 + return p; 101 + } 102 + 103 + static struct property * __init of_pdt_build_prop_list(phandle node) 104 + { 105 + struct property *head, *tail; 106 + 107 + head = tail = of_pdt_build_one_prop(node, NULL, 108 + ".node", &node, sizeof(node)); 109 + 110 + tail->next = of_pdt_build_one_prop(node, NULL, NULL, NULL, 0); 111 + tail = tail->next; 112 + while(tail) { 113 + tail->next = of_pdt_build_one_prop(node, tail->name, 114 + NULL, NULL, 0); 115 + tail = tail->next; 116 + } 117 + 118 + return head; 119 + } 120 + 121 + static char * __init of_pdt_get_one_property(phandle node, const char *name) 122 + { 123 + char *buf = "<NULL>"; 124 + int len; 125 + 126 + len = of_pdt_prom_ops->getproplen(node, name); 127 + if (len > 0) { 128 + buf = prom_early_alloc(len); 129 + len = of_pdt_prom_ops->getproperty(node, name, buf, len); 130 + } 131 + 132 + return buf; 133 + } 134 + 135 + static char * __init of_pdt_try_pkg2path(phandle node) 136 + { 137 + char *res, *buf = NULL; 138 + int len; 139 + 140 + if (!of_pdt_prom_ops->pkg2path) 141 + return NULL; 142 + 143 + if (of_pdt_prom_ops->pkg2path(node, buf, 0, &len)) 144 + return NULL; 145 + buf = prom_early_alloc(len + 1); 146 + if (of_pdt_prom_ops->pkg2path(node, buf, len, &len)) { 147 + pr_err("%s: package-to-path failed\n", __func__); 148 + return NULL; 149 + } 150 + 151 + res = strrchr(buf, '/'); 152 + if (!res) { 153 + pr_err("%s: couldn't find / in %s\n", __func__, buf); 154 + return NULL; 155 + } 156 + return res+1; 157 + } 158 + 159 + /* 160 + * When fetching the node's name, first try using package-to-path; if 161 + * that fails (either because the arch hasn't supplied a PROM callback, 162 + * or some other random failure), fall back to just looking at the node's 163 + * 'name' property. 164 + */ 165 + static char * __init of_pdt_build_name(phandle node) 166 + { 167 + char *buf; 168 + 169 + buf = of_pdt_try_pkg2path(node); 170 + if (!buf) 171 + buf = of_pdt_get_one_property(node, "name"); 172 + 173 + return buf; 174 + } 175 + 176 + static struct device_node * __init of_pdt_create_node(phandle node, 177 + struct device_node *parent) 178 + { 179 + struct device_node *dp; 180 + 181 + if (!node) 182 + return NULL; 183 + 184 + dp = prom_early_alloc(sizeof(*dp)); 185 + of_pdt_incr_unique_id(dp); 186 + dp->parent = parent; 187 + 188 + kref_init(&dp->kref); 189 + 190 + dp->name = of_pdt_build_name(node); 191 + dp->type = of_pdt_get_one_property(node, "device_type"); 192 + dp->phandle = node; 193 + 194 + dp->properties = of_pdt_build_prop_list(node); 195 + 196 + irq_trans_init(dp); 197 + 198 + return dp; 199 + } 200 + 201 + static char * __init of_pdt_build_full_name(struct device_node *dp) 202 + { 203 + int len, ourlen, plen; 204 + char *n; 205 + 206 + plen = strlen(dp->parent->full_name); 207 + ourlen = strlen(of_pdt_node_name(dp)); 208 + len = ourlen + plen + 2; 209 + 210 + n = prom_early_alloc(len); 211 + strcpy(n, dp->parent->full_name); 212 + if (!of_node_is_root(dp->parent)) { 213 + strcpy(n + plen, "/"); 214 + plen++; 215 + } 216 + strcpy(n + plen, of_pdt_node_name(dp)); 217 + 218 + return n; 219 + } 220 + 221 + static struct device_node * __init of_pdt_build_tree(struct device_node *parent, 222 + phandle node, 223 + struct device_node ***nextp) 224 + { 225 + struct device_node *ret = NULL, *prev_sibling = NULL; 226 + struct device_node *dp; 227 + 228 + while (1) { 229 + dp = of_pdt_create_node(node, parent); 230 + if (!dp) 231 + break; 232 + 233 + if (prev_sibling) 234 + prev_sibling->sibling = dp; 235 + 236 + if (!ret) 237 + ret = dp; 238 + prev_sibling = dp; 239 + 240 + *(*nextp) = dp; 241 + *nextp = &dp->allnext; 242 + 243 + #if defined(CONFIG_SPARC) 244 + dp->path_component_name = build_path_component(dp); 245 + #endif 246 + dp->full_name = of_pdt_build_full_name(dp); 247 + 248 + dp->child = of_pdt_build_tree(dp, 249 + of_pdt_prom_ops->getchild(node), nextp); 250 + 251 + if (of_pdt_build_more) 252 + of_pdt_build_more(dp, nextp); 253 + 254 + node = of_pdt_prom_ops->getsibling(node); 255 + } 256 + 257 + return ret; 258 + } 259 + 260 + void __init of_pdt_build_devicetree(phandle root_node, struct of_pdt_ops *ops) 261 + { 262 + struct device_node **nextp; 263 + 264 + BUG_ON(!ops); 265 + of_pdt_prom_ops = ops; 266 + 267 + allnodes = of_pdt_create_node(root_node, NULL); 268 + #if defined(CONFIG_SPARC) 269 + allnodes->path_component_name = ""; 270 + #endif 271 + allnodes->full_name = "/"; 272 + 273 + nextp = &allnodes->allnext; 274 + allnodes->child = of_pdt_build_tree(allnodes, 275 + of_pdt_prom_ops->getchild(allnodes->phandle), &nextp); 276 + }
+16 -18
drivers/of/platform.c
··· 584 584 struct device *parent) 585 585 { 586 586 struct platform_device *dev; 587 - int rc, i, num_reg = 0, num_irq = 0; 587 + int rc, i, num_reg = 0, num_irq; 588 588 struct resource *res, temp_res; 589 589 590 - /* First count how many resources are needed */ 591 - while (of_address_to_resource(np, num_reg, &temp_res) == 0) 592 - num_reg++; 593 - while (of_irq_to_resource(np, num_irq, &temp_res) != NO_IRQ) 594 - num_irq++; 595 - 596 - /* Allocate memory for both the struct device and the resource table */ 597 - dev = kzalloc(sizeof(*dev) + (sizeof(*res) * (num_reg + num_irq)), 598 - GFP_KERNEL); 590 + dev = platform_device_alloc("", -1); 599 591 if (!dev) 600 592 return NULL; 601 - res = (struct resource *) &dev[1]; 593 + 594 + /* count the io and irq resources */ 595 + while (of_address_to_resource(np, num_reg, &temp_res) == 0) 596 + num_reg++; 597 + num_irq = of_irq_count(np); 602 598 603 599 /* Populate the resource table */ 604 600 if (num_irq || num_reg) { 601 + res = kzalloc(sizeof(*res) * (num_irq + num_reg), GFP_KERNEL); 602 + if (!res) { 603 + platform_device_put(dev); 604 + return NULL; 605 + } 606 + 605 607 dev->num_resources = num_reg + num_irq; 606 608 dev->resource = res; 607 609 for (i = 0; i < num_reg; i++, res++) { 608 610 rc = of_address_to_resource(np, i, res); 609 611 WARN_ON(rc); 610 612 } 611 - for (i = 0; i < num_irq; i++, res++) { 612 - rc = of_irq_to_resource(np, i, res); 613 - WARN_ON(rc == NO_IRQ); 614 - } 613 + WARN_ON(of_irq_to_resource_table(np, res, num_irq) != num_irq); 615 614 } 616 615 617 616 dev->dev.of_node = of_node_get(np); ··· 618 619 dev->dev.dma_mask = &dev->archdata.dma_mask; 619 620 #endif 620 621 dev->dev.parent = parent; 621 - dev->dev.release = of_release_dev; 622 622 623 623 if (bus_id) 624 624 dev_set_name(&dev->dev, "%s", bus_id); ··· 655 657 * to do such, possibly using a device notifier 656 658 */ 657 659 658 - if (of_device_register(dev) != 0) { 659 - of_device_free(dev); 660 + if (of_device_add(dev) != 0) { 661 + platform_device_put(dev); 660 662 return NULL; 661 663 } 662 664
+1 -1
drivers/sbus/char/jsflash.c
··· 461 461 { 462 462 int rc; 463 463 struct jsflash *jsf; 464 - int node; 464 + phandle node; 465 465 char banner[128]; 466 466 struct linux_prom_registers reg0; 467 467
+6 -6
drivers/serial/of_serial.c
··· 31 31 { 32 32 struct resource resource; 33 33 struct device_node *np = ofdev->dev.of_node; 34 - const unsigned int *clk, *spd; 35 - const u32 *prop; 34 + const __be32 *clk, *spd; 35 + const __be32 *prop; 36 36 int ret, prop_size; 37 37 38 38 memset(port, 0, sizeof *port); ··· 55 55 /* Check for shifted address mapping */ 56 56 prop = of_get_property(np, "reg-offset", &prop_size); 57 57 if (prop && (prop_size == sizeof(u32))) 58 - port->mapbase += *prop; 58 + port->mapbase += be32_to_cpup(prop); 59 59 60 60 /* Check for registers offset within the devices address range */ 61 61 prop = of_get_property(np, "reg-shift", &prop_size); 62 62 if (prop && (prop_size == sizeof(u32))) 63 - port->regshift = *prop; 63 + port->regshift = be32_to_cpup(prop); 64 64 65 65 port->irq = irq_of_parse_and_map(np, 0); 66 66 port->iotype = UPIO_MEM; 67 67 port->type = type; 68 - port->uartclk = *clk; 68 + port->uartclk = be32_to_cpup(clk); 69 69 port->flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP 70 70 | UPF_FIXED_PORT | UPF_FIXED_TYPE; 71 71 port->dev = &ofdev->dev; 72 72 /* If current-speed was set, then try not to change it. */ 73 73 if (spd) 74 - port->custom_divisor = *clk / (16 * (*spd)); 74 + port->custom_divisor = be32_to_cpup(clk) / (16 * (be32_to_cpup(spd))); 75 75 76 76 return 0; 77 77 }
+2 -1
drivers/video/aty/atyfb_base.c
··· 2970 2970 struct atyfb_par *par = info->par; 2971 2971 struct device_node *dp; 2972 2972 char prop[128]; 2973 - int node, len, i, j, ret; 2973 + phandle node; 2974 + int len, i, j, ret; 2974 2975 u32 mem, chip_id; 2975 2976 2976 2977 /*
+7 -6
include/linux/of_device.h
··· 27 27 extern struct platform_device *of_dev_get(struct platform_device *dev); 28 28 extern void of_dev_put(struct platform_device *dev); 29 29 30 + extern int of_device_add(struct platform_device *pdev); 30 31 extern int of_device_register(struct platform_device *ofdev); 31 32 extern void of_device_unregister(struct platform_device *ofdev); 32 - extern void of_release_dev(struct device *dev); 33 - 34 - static inline void of_device_free(struct platform_device *dev) 35 - { 36 - of_release_dev(&dev->dev); 37 - } 38 33 39 34 extern ssize_t of_device_get_modalias(struct device *dev, 40 35 char *str, ssize_t len); 41 36 42 37 extern int of_device_uevent(struct device *dev, struct kobj_uevent_env *env); 43 38 39 + static inline void of_device_node_put(struct device *dev) 40 + { 41 + of_node_put(dev->of_node); 42 + } 44 43 45 44 #else /* CONFIG_OF_DEVICE */ 46 45 ··· 54 55 { 55 56 return -ENODEV; 56 57 } 58 + 59 + static inline void of_device_node_put(struct device *dev) { } 57 60 58 61 #endif /* CONFIG_OF_DEVICE */ 59 62
+1 -1
include/linux/of_fdt.h
··· 72 72 unsigned long *size); 73 73 extern int of_flat_dt_is_compatible(unsigned long node, const char *name); 74 74 extern unsigned long of_get_flat_dt_root(void); 75 - extern void early_init_dt_scan_chosen_arch(unsigned long node); 75 + 76 76 extern int early_init_dt_scan_chosen(unsigned long node, const char *uname, 77 77 int depth, void *data); 78 78 extern void early_init_dt_check_for_initrd(unsigned long node);
+4
include/linux/of_irq.h
··· 5 5 struct of_irq; 6 6 #include <linux/types.h> 7 7 #include <linux/errno.h> 8 + #include <linux/irq.h> 8 9 #include <linux/ioport.h> 9 10 #include <linux/of.h> 10 11 ··· 65 64 unsigned int intsize); 66 65 extern int of_irq_to_resource(struct device_node *dev, int index, 67 66 struct resource *r); 67 + extern int of_irq_count(struct device_node *dev); 68 + extern int of_irq_to_resource_table(struct device_node *dev, 69 + struct resource *res, int nr_irqs); 68 70 69 71 #endif /* CONFIG_OF_IRQ */ 70 72 #endif /* CONFIG_OF */
+45
include/linux/of_pdt.h
··· 1 + /* 2 + * Definitions for building a device tree by calling into the 3 + * Open Firmware PROM. 4 + * 5 + * Copyright (C) 2010 Andres Salomon <dilinger@queued.net> 6 + * 7 + * This program is free software; you can redistribute it and/or 8 + * modify it under the terms of the GNU General Public License 9 + * as published by the Free Software Foundation; either version 10 + * 2 of the License, or (at your option) any later version. 11 + */ 12 + 13 + #ifndef _LINUX_OF_PDT_H 14 + #define _LINUX_OF_PDT_H 15 + 16 + /* overridable operations for calling into the PROM */ 17 + struct of_pdt_ops { 18 + /* 19 + * buf should be 32 bytes; return 0 on success. 20 + * If prev is NULL, the first property will be returned. 21 + */ 22 + int (*nextprop)(phandle node, char *prev, char *buf); 23 + 24 + /* for both functions, return proplen on success; -1 on error */ 25 + int (*getproplen)(phandle node, const char *prop); 26 + int (*getproperty)(phandle node, const char *prop, char *buf, 27 + int bufsize); 28 + 29 + /* phandles are 0 if no child or sibling exists */ 30 + phandle (*getchild)(phandle parent); 31 + phandle (*getsibling)(phandle node); 32 + 33 + /* return 0 on success; fill in 'len' with number of bytes in path */ 34 + int (*pkg2path)(phandle node, char *buf, const int buflen, int *len); 35 + }; 36 + 37 + extern void *prom_early_alloc(unsigned long size); 38 + 39 + /* for building the device tree */ 40 + extern void of_pdt_build_devicetree(phandle root_node, struct of_pdt_ops *ops); 41 + 42 + extern void (*of_pdt_build_more)(struct device_node *dp, 43 + struct device_node ***nextp); 44 + 45 + #endif /* _LINUX_OF_PDT_H */