From a8bf7527a2e17ccf1366e67f6ac728327ca34c40 Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Mon, 26 Aug 2013 11:22:45 -0500 Subject: of: create unflatten_and_copy_device_tree Several architectures using DT support built-in dtb's in the init section. These platforms need to copy the dtb from init since the strings are referenced after unflattening. Every arch has their own copying routine which do the same thing. Create a common function, unflatten_and_copy_device_tree, to copy the dtb when unflattening the dtb. Signed-off-by: Rob Herring Acked-by: Grant Likely --- include/linux/of_fdt.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h index a478c62a2aab..58c28a8cc257 100644 --- a/include/linux/of_fdt.h +++ b/include/linux/of_fdt.h @@ -118,9 +118,11 @@ extern int early_init_dt_scan_root(unsigned long node, const char *uname, /* Other Prototypes */ extern void unflatten_device_tree(void); +extern void unflatten_and_copy_device_tree(void); extern void early_init_devtree(void *); #else /* CONFIG_OF_FLATTREE */ static inline void unflatten_device_tree(void) {} +static inline void unflatten_and_copy_device_tree(void) {} #endif /* CONFIG_OF_FLATTREE */ #endif /* __ASSEMBLY__ */ -- cgit v1.2.3 From 0288ffcbfdf9b8656e7320c24caa1e4c1d498287 Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Mon, 26 Aug 2013 09:47:40 -0500 Subject: of: Introduce common early_init_dt_scan Most architectures scan the all the same items early in the FDT and none are really architecture specific. Create a common early_init_dt_scan to unify the early scan of root, memory, and chosen nodes in the flattened DT. Signed-off-by: Rob Herring Acked-by: Grant Likely --- drivers/of/fdt.c | 26 ++++++++++++++++++++++++++ include/linux/of_fdt.h | 2 ++ 2 files changed, 28 insertions(+) (limited to 'include') diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 51776166d2b0..bfbfda543768 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -785,6 +785,32 @@ void * __init __weak early_init_dt_alloc_memory_arch(u64 size, u64 align) } #endif +bool __init early_init_dt_scan(void *params) +{ + if (!params) + return false; + + /* Setup flat device-tree pointer */ + initial_boot_params = params; + + /* check device tree validity */ + if (be32_to_cpu(initial_boot_params->magic) != OF_DT_HEADER) { + initial_boot_params = NULL; + return false; + } + + /* Retrieve various information from the /chosen node */ + of_scan_flat_dt(early_init_dt_scan_chosen, boot_command_line); + + /* Initialize {size,address}-cells info */ + of_scan_flat_dt(early_init_dt_scan_root, NULL); + + /* Setup memory, calling early_init_dt_add_memory_arch */ + of_scan_flat_dt(early_init_dt_scan_memory, NULL); + + return true; +} + /** * unflatten_device_tree - create tree of device_nodes from flat blob * diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h index 58c28a8cc257..73e16511134e 100644 --- a/include/linux/of_fdt.h +++ b/include/linux/of_fdt.h @@ -116,6 +116,8 @@ extern void early_init_dt_setup_initrd_arch(u64 start, u64 end); extern int early_init_dt_scan_root(unsigned long node, const char *uname, int depth, void *data); +extern bool early_init_dt_scan(void *params); + /* Other Prototypes */ extern void unflatten_device_tree(void); extern void unflatten_and_copy_device_tree(void); -- cgit v1.2.3 From 29eb45a9ab4839a1e9cef2bcf369b918c9c4fcad Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Fri, 30 Aug 2013 17:06:53 -0500 Subject: of: remove early_init_dt_setup_initrd_arch All arches do essentially the same thing now for early_init_dt_setup_initrd_arch, so it can now be removed. Signed-off-by: Rob Herring Acked-by: Vineet Gupta Cc: Russell King Cc: Mark Salter Cc: Aurelien Jacquiot Cc: James Hogan Cc: Michal Simek Cc: Ralf Baechle Cc: Jonas Bonn Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: x86@kernel.org Cc: Chris Zankel Cc: Max Filippov Acked-by: Grant Likely --- arch/arc/mm/init.c | 7 ------- arch/arm/mm/init.c | 8 -------- arch/c6x/kernel/devicetree.c | 10 ---------- arch/metag/mm/init.c | 9 --------- arch/microblaze/kernel/prom.c | 9 --------- arch/mips/kernel/prom.c | 10 ---------- arch/openrisc/kernel/prom.c | 9 --------- arch/powerpc/kernel/prom.c | 9 --------- arch/x86/kernel/devicetree.c | 9 --------- arch/xtensa/kernel/setup.c | 15 ++++----------- drivers/of/fdt.c | 9 ++++++--- include/linux/of_fdt.h | 10 ---------- 12 files changed, 10 insertions(+), 104 deletions(-) (limited to 'include') diff --git a/arch/arc/mm/init.c b/arch/arc/mm/init.c index 81279ec73a6a..55e0a85bea78 100644 --- a/arch/arc/mm/init.c +++ b/arch/arc/mm/init.c @@ -125,10 +125,3 @@ void __init free_initrd_mem(unsigned long start, unsigned long end) free_reserved_area((void *)start, (void *)end, -1, "initrd"); } #endif - -#ifdef CONFIG_OF_FLATTREE -void __init early_init_dt_setup_initrd_arch(u64 start, u64 end) -{ - pr_err("%s(%llx, %llx)\n", __func__, start, end); -} -#endif /* CONFIG_OF_FLATTREE */ diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 9eeb1cd1c401..9d0b91dccf37 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -77,14 +77,6 @@ static int __init parse_tag_initrd2(const struct tag *tag) __tagtable(ATAG_INITRD2, parse_tag_initrd2); -#if defined(CONFIG_OF_FLATTREE) && defined(CONFIG_BLK_DEV_INITRD) -void __init early_init_dt_setup_initrd_arch(u64 start, u64 end) -{ - initrd_start = (unsigned long)__va(start); - initrd_end = (unsigned long)__va(end); -} -#endif /* CONFIG_OF_FLATTREE */ - /* * This keeps memory configuration data used by a couple memory * initialization functions, as well as show_mem() for the skipping diff --git a/arch/c6x/kernel/devicetree.c b/arch/c6x/kernel/devicetree.c index d28a92fc0c52..fa3e5741514e 100644 --- a/arch/c6x/kernel/devicetree.c +++ b/arch/c6x/kernel/devicetree.c @@ -10,18 +10,8 @@ * */ #include -#include #include -#ifdef CONFIG_BLK_DEV_INITRD -void __init early_init_dt_setup_initrd_arch(u64 start, u64 end) -{ - initrd_start = (unsigned long)__va(start); - initrd_end = (unsigned long)__va(end); - initrd_below_start_ok = 1; -} -#endif - void __init early_init_dt_add_memory_arch(u64 base, u64 size) { c6x_add_memory(base, size); diff --git a/arch/metag/mm/init.c b/arch/metag/mm/init.c index 123919534b80..249fff66add3 100644 --- a/arch/metag/mm/init.c +++ b/arch/metag/mm/init.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include @@ -405,11 +404,3 @@ void free_initrd_mem(unsigned long start, unsigned long end) "initrd"); } #endif - -#ifdef CONFIG_OF_FLATTREE -void __init early_init_dt_setup_initrd_arch(u64 start, u64 end) -{ - pr_err("%s(%llx, %llx)\n", - __func__, start, end); -} -#endif /* CONFIG_OF_FLATTREE */ diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c index 951e4d61ca2d..cab6dc356119 100644 --- a/arch/microblaze/kernel/prom.c +++ b/arch/microblaze/kernel/prom.c @@ -114,15 +114,6 @@ void __init early_init_devtree(void *params) pr_debug(" <- early_init_devtree()\n"); } -#ifdef CONFIG_BLK_DEV_INITRD -void __init early_init_dt_setup_initrd_arch(u64 start, u64 end) -{ - initrd_start = (unsigned long)__va(start); - initrd_end = (unsigned long)__va(end); - initrd_below_start_ok = 1; -} -#endif - /******* * * New implementation of the OF "find" APIs, return a refcounted diff --git a/arch/mips/kernel/prom.c b/arch/mips/kernel/prom.c index 67a4c53b2b54..0b2485f9a6c1 100644 --- a/arch/mips/kernel/prom.c +++ b/arch/mips/kernel/prom.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include @@ -48,15 +47,6 @@ void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align) return __alloc_bootmem(size, align, __pa(MAX_DMA_ADDRESS)); } -#ifdef CONFIG_BLK_DEV_INITRD -void __init early_init_dt_setup_initrd_arch(u64 start, u64 end) -{ - initrd_start = (unsigned long)__va(start); - initrd_end = (unsigned long)__va(end); - initrd_below_start_ok = 1; -} -#endif - int __init early_init_dt_scan_model(unsigned long node, const char *uname, int depth, void *data) { diff --git a/arch/openrisc/kernel/prom.c b/arch/openrisc/kernel/prom.c index 6dbcaa85421c..2aae474b44c3 100644 --- a/arch/openrisc/kernel/prom.c +++ b/arch/openrisc/kernel/prom.c @@ -52,12 +52,3 @@ void __init early_init_devtree(void *params) early_init_dt_scan(params); memblock_allow_resize(); } - -#ifdef CONFIG_BLK_DEV_INITRD -void __init early_init_dt_setup_initrd_arch(u64 start, u64 end) -{ - initrd_start = (unsigned long)__va(start); - initrd_end = (unsigned long)__va(end); - initrd_below_start_ok = 1; -} -#endif diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c index b7634ce41dbc..a0894688daef 100644 --- a/arch/powerpc/kernel/prom.c +++ b/arch/powerpc/kernel/prom.c @@ -546,15 +546,6 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size) memblock_add(base, size); } -#ifdef CONFIG_BLK_DEV_INITRD -void __init early_init_dt_setup_initrd_arch(u64 start, u64 end) -{ - initrd_start = (unsigned long)__va(start); - initrd_end = (unsigned long)__va(end); - initrd_below_start_ok = 1; -} -#endif - static void __init early_reserve_mem_dt(void) { unsigned long i, len, dt_root; diff --git a/arch/x86/kernel/devicetree.c b/arch/x86/kernel/devicetree.c index 0db805c4b9e8..0e1f95b06336 100644 --- a/arch/x86/kernel/devicetree.c +++ b/arch/x86/kernel/devicetree.c @@ -51,15 +51,6 @@ void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align) return __alloc_bootmem(size, align, __pa(MAX_DMA_ADDRESS)); } -#ifdef CONFIG_BLK_DEV_INITRD -void __init early_init_dt_setup_initrd_arch(u64 start, u64 end) -{ - initrd_start = (unsigned long)__va(start); - initrd_end = (unsigned long)__va(end); - initrd_below_start_ok = 1; -} -#endif - void __init add_dtb(u64 data) { initial_dtb = data + offsetof(struct setup_data, data); diff --git a/arch/xtensa/kernel/setup.c b/arch/xtensa/kernel/setup.c index 65974a8f41a4..6e2b6638122d 100644 --- a/arch/xtensa/kernel/setup.c +++ b/arch/xtensa/kernel/setup.c @@ -61,8 +61,8 @@ extern struct rtc_ops no_rtc_ops; struct rtc_ops *rtc_ops; #ifdef CONFIG_BLK_DEV_INITRD -extern void *initrd_start; -extern void *initrd_end; +extern unsigned long initrd_start; +extern unsigned long initrd_end; int initrd_is_mapped = 0; extern int initrd_below_start_ok; #endif @@ -149,8 +149,8 @@ static int __init parse_tag_initrd(const bp_tag_t* tag) { meminfo_t* mi; mi = (meminfo_t*)(tag->data); - initrd_start = __va(mi->start); - initrd_end = __va(mi->end); + initrd_start = (unsigned long)__va(mi->start); + initrd_end = (unsigned long)__va(mi->end); return 0; } @@ -167,13 +167,6 @@ static int __init parse_tag_fdt(const bp_tag_t *tag) __tagtable(BP_TAG_FDT, parse_tag_fdt); -void __init early_init_dt_setup_initrd_arch(u64 start, u64 end) -{ - initrd_start = (void *)__va(start); - initrd_end = (void *)__va(end); - initrd_below_start_ok = 1; -} - #endif /* CONFIG_OF */ #endif /* CONFIG_BLK_DEV_INITRD */ diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 5bc55b6e2b41..5f4cc88cd89e 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -624,7 +624,7 @@ int __init of_scan_flat_dt_by_path(const char *path, * early_init_dt_check_for_initrd - Decode initrd location from flat tree * @node: reference to node containing initrd location ('chosen') */ -void __init early_init_dt_check_for_initrd(unsigned long node) +static void __init early_init_dt_check_for_initrd(unsigned long node) { u64 start, end; unsigned long len; @@ -642,12 +642,15 @@ void __init early_init_dt_check_for_initrd(unsigned long node) return; end = of_read_number(prop, len/4); - early_init_dt_setup_initrd_arch(start, end); + initrd_start = (unsigned long)__va(start); + initrd_end = (unsigned long)__va(end); + initrd_below_start_ok = 1; + pr_debug("initrd_start=0x%llx initrd_end=0x%llx\n", (unsigned long long)start, (unsigned long long)end); } #else -inline void early_init_dt_check_for_initrd(unsigned long node) +static inline void early_init_dt_check_for_initrd(unsigned long node) { } #endif /* CONFIG_BLK_DEV_INITRD */ diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h index 73e16511134e..b365f5ac7b54 100644 --- a/include/linux/of_fdt.h +++ b/include/linux/of_fdt.h @@ -96,22 +96,12 @@ extern int of_scan_flat_dt_by_path(const char *path, extern int early_init_dt_scan_chosen(unsigned long node, const char *uname, int depth, void *data); -extern void early_init_dt_check_for_initrd(unsigned long node); extern int early_init_dt_scan_memory(unsigned long node, const char *uname, int depth, void *data); extern void early_init_dt_add_memory_arch(u64 base, u64 size); extern void * early_init_dt_alloc_memory_arch(u64 size, u64 align); extern u64 dt_mem_next_cell(int s, __be32 **cellp); -/* - * If BLK_DEV_INITRD, the fdt early init code will call this function, - * to be provided by the arch code. start and end are specified as - * physical addresses. - */ -#ifdef CONFIG_BLK_DEV_INITRD -extern void early_init_dt_setup_initrd_arch(u64 start, u64 end); -#endif - /* Early flat tree scan hooks */ extern int early_init_dt_scan_root(unsigned long node, const char *uname, int depth, void *data); -- cgit v1.2.3 From 6a903a2551ef778d60ce4341722d611144251398 Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Tue, 27 Aug 2013 21:41:56 -0500 Subject: of: introduce common FDT machine related functions Introduce common of_flat_dt_match_machine and of_flat_dt_get_machine_name functions to unify architectures' handling of machine level model and compatible properties. Several architectures match the root compatible string with an arch specific list of machine descriptors duplicating the same search algorithm. Create a common implementation with a simple architecture specific hook to iterate over each machine's match table. Signed-off-by: Rob Herring Acked-by: Grant Likely --- drivers/of/fdt.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/of_fdt.h | 5 +++++ 2 files changed, 65 insertions(+) (limited to 'include') diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 5f4cc88cd89e..5c479104fc67 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -619,6 +619,66 @@ int __init of_scan_flat_dt_by_path(const char *path, return ret; } +const char * __init of_flat_dt_get_machine_name(void) +{ + const char *name; + unsigned long dt_root = of_get_flat_dt_root(); + + name = of_get_flat_dt_prop(dt_root, "model", NULL); + if (!name) + name = of_get_flat_dt_prop(dt_root, "compatible", NULL); + return name; +} + +/** + * of_flat_dt_match_machine - Iterate match tables to find matching machine. + * + * @default_match: A machine specific ptr to return in case of no match. + * @get_next_compat: callback function to return next compatible match table. + * + * Iterate through machine match tables to find the best match for the machine + * compatible string in the FDT. + */ +const void * __init of_flat_dt_match_machine(const void *default_match, + const void * (*get_next_compat)(const char * const**)) +{ + const void *data = NULL; + const void *best_data = default_match; + const char *const *compat; + unsigned long dt_root; + unsigned int best_score = ~1, score = 0; + + dt_root = of_get_flat_dt_root(); + while ((data = get_next_compat(&compat))) { + score = of_flat_dt_match(dt_root, compat); + if (score > 0 && score < best_score) { + best_data = data; + best_score = score; + } + } + if (!best_data) { + const char *prop; + long size; + + pr_err("\n unrecognized device tree list:\n[ "); + + prop = of_get_flat_dt_prop(dt_root, "compatible", &size); + if (prop) { + while (size > 0) { + printk("'%s' ", prop); + size -= strlen(prop) + 1; + prop += strlen(prop) + 1; + } + } + printk("]\n\n"); + return NULL; + } + + pr_info("Machine model: %s\n", of_flat_dt_get_machine_name()); + + return best_data; +} + #ifdef CONFIG_BLK_DEV_INITRD /** * early_init_dt_check_for_initrd - Decode initrd location from flat tree diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h index b365f5ac7b54..0beaee9dac1f 100644 --- a/include/linux/of_fdt.h +++ b/include/linux/of_fdt.h @@ -108,11 +108,16 @@ extern int early_init_dt_scan_root(unsigned long node, const char *uname, extern bool early_init_dt_scan(void *params); +extern const char *of_flat_dt_get_machine_name(void); +extern const void *of_flat_dt_match_machine(const void *default_match, + const void * (*get_next_compat)(const char * const**)); + /* Other Prototypes */ extern void unflatten_device_tree(void); extern void unflatten_and_copy_device_tree(void); extern void early_init_devtree(void *); #else /* CONFIG_OF_FLATTREE */ +static inline const char *of_flat_dt_get_machine_name(void) { return NULL; } static inline void unflatten_device_tree(void) {} static inline void unflatten_and_copy_device_tree(void) {} #endif /* CONFIG_OF_FLATTREE */ -- cgit v1.2.3 From 25ff79443cbfa924b8df1d4a8a0fbff83816938a Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Sat, 7 Sep 2013 14:07:11 -0500 Subject: of: implement pci_address_to_pio as weak function Implement pci_address_to_pio as weak function to remove the dependency on asm/prom.h. This is in preparation to make prom.h optional. Signed-off-by: Rob Herring Acked-by: Grant Likely Cc: Michal Simek Cc: Ralf Baechle Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: x86@kernel.org Cc: Grant Likely --- arch/microblaze/include/asm/prom.h | 9 --------- arch/mips/include/asm/prom.h | 11 ----------- arch/powerpc/include/asm/prom.h | 5 ----- arch/x86/include/asm/prom.h | 3 --- arch/x86/kernel/devicetree.c | 10 ---------- drivers/of/address.c | 8 ++++++++ drivers/of/of_pci.c | 1 - include/linux/of_address.h | 5 +---- 8 files changed, 9 insertions(+), 43 deletions(-) (limited to 'include') diff --git a/arch/microblaze/include/asm/prom.h b/arch/microblaze/include/asm/prom.h index f05bedce70d0..0ebd924902df 100644 --- a/arch/microblaze/include/asm/prom.h +++ b/arch/microblaze/include/asm/prom.h @@ -26,13 +26,4 @@ enum early_consoles { extern int of_early_console(void *version); -/* - * OF address retreival & translation - */ - -#ifdef CONFIG_PCI -extern unsigned long pci_address_to_pio(phys_addr_t address); -#define pci_address_to_pio pci_address_to_pio -#endif /* CONFIG_PCI */ - #endif /* _ASM_MICROBLAZE_PROM_H */ diff --git a/arch/mips/include/asm/prom.h b/arch/mips/include/asm/prom.h index e3dbd0e0608e..ccd2b75f152c 100644 --- a/arch/mips/include/asm/prom.h +++ b/arch/mips/include/asm/prom.h @@ -19,17 +19,6 @@ extern void device_tree_init(void); -static inline unsigned long pci_address_to_pio(phys_addr_t address) -{ - /* - * The ioport address can be directly used by inX() / outX() - */ - BUG_ON(address > IO_SPACE_LIMIT); - - return (unsigned long) address; -} -#define pci_address_to_pio pci_address_to_pio - struct boot_param_header; extern void __dt_setup_arch(struct boot_param_header *bph); diff --git a/arch/powerpc/include/asm/prom.h b/arch/powerpc/include/asm/prom.h index 7d0c7f3a7171..bd215f74df0f 100644 --- a/arch/powerpc/include/asm/prom.h +++ b/arch/powerpc/include/asm/prom.h @@ -30,11 +30,6 @@ extern u64 of_translate_dma_address(struct device_node *dev, const __be32 *in_addr); -#ifdef CONFIG_PCI -extern unsigned long pci_address_to_pio(phys_addr_t address); -#define pci_address_to_pio pci_address_to_pio -#endif /* CONFIG_PCI */ - /* Parse the ibm,dma-window property of an OF node into the busno, phys and * size parameters. */ diff --git a/arch/x86/include/asm/prom.h b/arch/x86/include/asm/prom.h index bade6ac3b14f..8ef2ec70858f 100644 --- a/arch/x86/include/asm/prom.h +++ b/arch/x86/include/asm/prom.h @@ -39,9 +39,6 @@ static inline void x86_dtb_init(void) { } extern char cmd_line[COMMAND_LINE_SIZE]; -#define pci_address_to_pio pci_address_to_pio -unsigned long pci_address_to_pio(phys_addr_t addr); - #define HAVE_ARCH_DEVTREE_FIXUPS #endif /* __ASSEMBLY__ */ diff --git a/arch/x86/kernel/devicetree.c b/arch/x86/kernel/devicetree.c index 679d676a30d7..cffd07368547 100644 --- a/arch/x86/kernel/devicetree.c +++ b/arch/x86/kernel/devicetree.c @@ -27,16 +27,6 @@ char __initdata cmd_line[COMMAND_LINE_SIZE]; int __initdata of_ioapic; -unsigned long pci_address_to_pio(phys_addr_t address) -{ - /* - * The ioport address can be directly used by inX / outX - */ - BUG_ON(address >= (1 << 16)); - return (unsigned long)address; -} -EXPORT_SYMBOL_GPL(pci_address_to_pio); - void __init early_init_dt_scan_chosen_arch(unsigned long node) { BUG(); diff --git a/drivers/of/address.c b/drivers/of/address.c index b55c21890760..556a7fb6ead3 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -626,6 +626,14 @@ const __be32 *of_get_address(struct device_node *dev, int index, u64 *size, } EXPORT_SYMBOL(of_get_address); +unsigned long __weak pci_address_to_pio(phys_addr_t address) +{ + if (address > IO_SPACE_LIMIT) + return (unsigned long)-1; + + return (unsigned long) address; +} + static int __of_address_to_resource(struct device_node *dev, const __be32 *addrp, u64 size, unsigned int flags, const char *name, struct resource *r) diff --git a/drivers/of/of_pci.c b/drivers/of/of_pci.c index e5ca00893c0c..848199633798 100644 --- a/drivers/of/of_pci.c +++ b/drivers/of/of_pci.c @@ -2,7 +2,6 @@ #include #include #include -#include static inline int __of_pci_pci_compare(struct device_node *node, unsigned int data) diff --git a/include/linux/of_address.h b/include/linux/of_address.h index 4c2e6f26432c..f6fc6899ceae 100644 --- a/include/linux/of_address.h +++ b/include/linux/of_address.h @@ -52,10 +52,7 @@ extern void __iomem *of_iomap(struct device_node *device, int index); extern const __be32 *of_get_address(struct device_node *dev, int index, u64 *size, unsigned int *flags); -#ifndef pci_address_to_pio -static inline unsigned long pci_address_to_pio(phys_addr_t addr) { return -1; } -#define pci_address_to_pio pci_address_to_pio -#endif +extern unsigned long pci_address_to_pio(phys_addr_t addr); extern int of_pci_range_parser_init(struct of_pci_range_parser *parser, struct device_node *node); -- cgit v1.2.3 From 0c3f061c195ceb891067b6de9e4ecc347c4dea31 Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Tue, 17 Sep 2013 10:42:50 -0500 Subject: of: implement of_node_to_nid as a weak function Implement of_node_to_nid as weak function to remove the dependency on asm/prom.h. This is in preparation to make prom.h optional. Signed-off-by: Rob Herring Acked-by: Grant Likely --- arch/powerpc/include/asm/prom.h | 7 ------- arch/sparc/include/asm/prom.h | 4 ---- drivers/of/base.c | 7 +++++++ include/linux/of.h | 11 ++++------- 4 files changed, 11 insertions(+), 18 deletions(-) (limited to 'include') diff --git a/arch/powerpc/include/asm/prom.h b/arch/powerpc/include/asm/prom.h index bd215f74df0f..6707c16d8fc5 100644 --- a/arch/powerpc/include/asm/prom.h +++ b/arch/powerpc/include/asm/prom.h @@ -42,13 +42,6 @@ extern void kdump_move_device_tree(void); /* cache lookup */ struct device_node *of_find_next_cache_node(struct device_node *np); -#ifdef CONFIG_NUMA -extern int of_node_to_nid(struct device_node *device); -#else -static inline int of_node_to_nid(struct device_node *device) { return 0; } -#endif -#define of_node_to_nid of_node_to_nid - extern void of_instantiate_rtc(void); extern int of_get_ibm_chip_id(struct device_node *np); diff --git a/arch/sparc/include/asm/prom.h b/arch/sparc/include/asm/prom.h index 67c62578d170..60c8d7bd4058 100644 --- a/arch/sparc/include/asm/prom.h +++ b/arch/sparc/include/asm/prom.h @@ -43,10 +43,6 @@ extern int of_getintprop_default(struct device_node *np, const char *name, int def); extern int of_find_in_proplist(const char *list, const char *match, int len); -#ifdef CONFIG_NUMA -extern int of_node_to_nid(struct device_node *dp); -#define of_node_to_nid of_node_to_nid -#endif extern void prom_build_devicetree(void); extern void of_populate_present_mask(void); diff --git a/drivers/of/base.c b/drivers/of/base.c index 865d3f66c86b..ced4c06d79b3 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -74,6 +74,13 @@ int of_n_size_cells(struct device_node *np) } EXPORT_SYMBOL(of_n_size_cells); +#ifdef CONFIG_NUMA +int __weak of_node_to_nid(struct device_node *np) +{ + return numa_node_id(); +} +#endif + #if defined(CONFIG_OF_DYNAMIC) /** * of_node_get - Increment refcount of a node diff --git a/include/linux/of.h b/include/linux/of.h index f95aee391e30..4d294a0b8a57 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -534,13 +534,10 @@ static inline const char *of_prop_next_string(struct property *prop, #define of_match_node(_matches, _node) NULL #endif /* CONFIG_OF */ -#ifndef of_node_to_nid -static inline int of_node_to_nid(struct device_node *np) -{ - return numa_node_id(); -} - -#define of_node_to_nid of_node_to_nid +#if defined(CONFIG_OF) && defined(CONFIG_NUMA) +extern int of_node_to_nid(struct device_node *np); +#else +static inline int of_node_to_nid(struct device_node *device) { return 0; } #endif /** -- cgit v1.2.3 From 4acf4b9cd4534aaa9102004937e1ba79da01d008 Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Mon, 16 Sep 2013 21:03:24 -0500 Subject: of: move of_address_to_resource and of_iomap declarations from sparc Move of_address_to_resource and of_iomap declarations to common code. These only differ on sparc, but the declarations are the same and don't need to be in arch header. Signed-off-by: Rob Herring Acked-by: Grant Likely Cc: "David S. Miller" Cc: sparclinux@vger.kernel.org --- arch/sparc/include/asm/prom.h | 8 -------- include/linux/of_address.h | 30 +++++++++++++++++------------- 2 files changed, 17 insertions(+), 21 deletions(-) (limited to 'include') diff --git a/arch/sparc/include/asm/prom.h b/arch/sparc/include/asm/prom.h index 60c8d7bd4058..11ebd659e7b6 100644 --- a/arch/sparc/include/asm/prom.h +++ b/arch/sparc/include/asm/prom.h @@ -59,13 +59,5 @@ extern char *of_console_options; extern void irq_trans_init(struct device_node *dp); extern char *build_path_component(struct device_node *dp); -/* SPARC has local implementations */ -extern int of_address_to_resource(struct device_node *dev, int index, - struct resource *r); -#define of_address_to_resource of_address_to_resource - -void __iomem *of_iomap(struct device_node *node, int index); -#define of_iomap of_iomap - #endif /* __KERNEL__ */ #endif /* _SPARC_PROM_H */ diff --git a/include/linux/of_address.h b/include/linux/of_address.h index f6fc6899ceae..e8a179773a1a 100644 --- a/include/linux/of_address.h +++ b/include/linux/of_address.h @@ -60,13 +60,6 @@ extern struct of_pci_range *of_pci_range_parser_one( struct of_pci_range_parser *parser, struct of_pci_range *range); #else /* CONFIG_OF_ADDRESS */ -#ifndef of_address_to_resource -static inline int of_address_to_resource(struct device_node *dev, int index, - struct resource *r) -{ - return -EINVAL; -} -#endif static inline struct device_node *of_find_matching_node_by_address( struct device_node *from, const struct of_device_id *matches, @@ -74,12 +67,7 @@ static inline struct device_node *of_find_matching_node_by_address( { return NULL; } -#ifndef of_iomap -static inline void __iomem *of_iomap(struct device_node *device, int index) -{ - return NULL; -} -#endif + static inline const __be32 *of_get_address(struct device_node *dev, int index, u64 *size, unsigned int *flags) { @@ -100,6 +88,22 @@ static inline struct of_pci_range *of_pci_range_parser_one( } #endif /* CONFIG_OF_ADDRESS */ +#ifdef CONFIG_OF +extern int of_address_to_resource(struct device_node *dev, int index, + struct resource *r); +void __iomem *of_iomap(struct device_node *node, int index); +#else +static inline int of_address_to_resource(struct device_node *dev, int index, + struct resource *r) +{ + return -EINVAL; +} + +static inline void __iomem *of_iomap(struct device_node *device, int index) +{ + return NULL; +} +#endif #if defined(CONFIG_OF_ADDRESS) && defined(CONFIG_PCI) extern const __be32 *of_get_pci_address(struct device_node *dev, int bar_no, -- cgit v1.2.3 From d0dfa16a600190d142f7538e5909d13c35b60d98 Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Mon, 16 Sep 2013 21:05:05 -0500 Subject: of: move of_translate_dma_address to of_address.h of_translate_dma_address is implemented in common code, so move the declaration there too. Signed-off-by: Rob Herring Acked-by: Grant Likely Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: linuxppc-dev@lists.ozlabs.org --- arch/powerpc/include/asm/prom.h | 4 ---- include/linux/of_address.h | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/arch/powerpc/include/asm/prom.h b/arch/powerpc/include/asm/prom.h index 43fe0023d722..b8774bdc69e0 100644 --- a/arch/powerpc/include/asm/prom.h +++ b/arch/powerpc/include/asm/prom.h @@ -24,10 +24,6 @@ * OF address retreival & translation */ -/* Translate a DMA address from device space to CPU space */ -extern u64 of_translate_dma_address(struct device_node *dev, - const __be32 *in_addr); - /* Parse the ibm,dma-window property of an OF node into the busno, phys and * size parameters. */ diff --git a/include/linux/of_address.h b/include/linux/of_address.h index e8a179773a1a..5f6ed6b182b8 100644 --- a/include/linux/of_address.h +++ b/include/linux/of_address.h @@ -34,6 +34,10 @@ static inline void of_pci_range_to_resource(struct of_pci_range *range, res->name = np->full_name; } +/* Translate a DMA address from device space to CPU space */ +extern u64 of_translate_dma_address(struct device_node *dev, + const __be32 *in_addr); + #ifdef CONFIG_OF_ADDRESS extern u64 of_translate_address(struct device_node *np, const __be32 *addr); extern bool of_can_translate_address(struct device_node *dev); -- cgit v1.2.3 From b5b4bb3f6a11f9c37b6d53138244f2ffe5bacd12 Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Sat, 7 Sep 2013 14:08:20 -0500 Subject: of: only include prom.h on sparc The dependency on prom.h by the core DT code is now removed and only sparc needs to include prom.h for the core code. Signed-off-by: Rob Herring Acked-by: Grant Likely --- include/linux/of.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/linux/of.h b/include/linux/of.h index 4d294a0b8a57..54017b83650b 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -136,7 +136,9 @@ static inline unsigned long of_read_ulong(const __be32 *cell, int size) return of_read_number(cell, size); } +#if defined(CONFIG_SPARC) #include +#endif /* Default #address and #size cells. Allow arch asm/prom.h to override */ #if !defined(OF_ROOT_NODE_ADDR_CELLS_DEFAULT) -- cgit v1.2.3 From d1cb9d1af0bc11b7450a6032f43935c746609418 Mon Sep 17 00:00:00 2001 From: David Miller Date: Thu, 3 Oct 2013 17:24:51 -0400 Subject: of: Make cpu node handling more portable. Use for_each_node_by_type() to iterate all cpu nodes in the system. Provide and overridable function arch_find_n_match_cpu_physical_id, which sees if the given device node matches 'cpu' and if so sets '*thread' when non-NULL to the cpu thread number within the core. The default implementation behaves the same as the existing code. Add a sparc64 implementation. Signed-off-by: David S. Miller Tested-by: Sudeep KarkadaNagesha Signed-off-by: Grant Likely --- arch/sparc/kernel/prom_64.c | 53 +++++++++++++++++++++++++++++++++++++++++++++ drivers/of/base.c | 45 +++++++++++++++++++++++--------------- include/linux/cpu.h | 3 +++ 3 files changed, 84 insertions(+), 17 deletions(-) (limited to 'include') diff --git a/arch/sparc/kernel/prom_64.c b/arch/sparc/kernel/prom_64.c index d397d7fc5c28..6b39125eb927 100644 --- a/arch/sparc/kernel/prom_64.c +++ b/arch/sparc/kernel/prom_64.c @@ -373,6 +373,59 @@ static const char *get_mid_prop(void) return (tlb_type == spitfire ? "upa-portid" : "portid"); } +bool arch_find_n_match_cpu_physical_id(struct device_node *cpun, + int cpu, unsigned int *thread) +{ + const char *mid_prop = get_mid_prop(); + int this_cpu_id; + + /* On hypervisor based platforms we interrogate the 'reg' + * property. On everything else we look for a 'upa-portis', + * 'portid', or 'cpuid' property. + */ + + if (tlb_type == hypervisor) { + struct property *prop = of_find_property(cpun, "reg", NULL); + u32 *regs; + + if (!prop) { + pr_warn("CPU node missing reg property\n"); + return false; + } + regs = prop->value; + this_cpu_id = regs[0] & 0x0fffffff; + } else { + this_cpu_id = of_getintprop_default(cpun, mid_prop, -1); + + if (this_cpu_id < 0) { + mid_prop = "cpuid"; + this_cpu_id = of_getintprop_default(cpun, mid_prop, -1); + } + if (this_cpu_id < 0) { + pr_warn("CPU node missing cpu ID property\n"); + return false; + } + } + if (this_cpu_id == cpu) { + if (thread) { + int proc_id = cpu_data(cpu).proc_id; + + /* On sparc64, the cpu thread information is obtained + * either from OBP or the machine description. We've + * actually probed this information already long before + * this interface gets called so instead of interrogating + * both the OF node and the MDESC again, just use what + * we discovered already. + */ + if (proc_id < 0) + proc_id = 0; + *thread = proc_id; + } + return true; + } + return false; +} + static void *of_iterate_over_cpus(void *(*func)(struct device_node *, int, int), int arg) { struct device_node *dp; diff --git a/drivers/of/base.c b/drivers/of/base.c index 7d4c70f859e3..e4c99453adf1 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -280,6 +280,31 @@ static bool __of_find_n_match_cpu_property(struct device_node *cpun, return false; } +/* + * arch_find_n_match_cpu_physical_id - See if the given device node is + * for the cpu corresponding to logical cpu 'cpu'. Return true if so, + * else false. If 'thread' is non-NULL, the local thread number within the + * core is returned in it. + */ +bool __weak arch_find_n_match_cpu_physical_id(struct device_node *cpun, + int cpu, unsigned int *thread) +{ + /* Check for non-standard "ibm,ppc-interrupt-server#s" property + * for thread ids on PowerPC. If it doesn't exist fallback to + * standard "reg" property. + */ + if (IS_ENABLED(CONFIG_PPC) && + __of_find_n_match_cpu_property(cpun, + "ibm,ppc-interrupt-server#s", + cpu, thread)) + return true; + + if (__of_find_n_match_cpu_property(cpun, "reg", cpu, thread)) + return true; + + return false; +} + /** * of_get_cpu_node - Get device node associated with the given logical CPU * @@ -300,24 +325,10 @@ static bool __of_find_n_match_cpu_property(struct device_node *cpun, */ struct device_node *of_get_cpu_node(int cpu, unsigned int *thread) { - struct device_node *cpun, *cpus; - - cpus = of_find_node_by_path("/cpus"); - if (!cpus) - return NULL; + struct device_node *cpun; - for_each_child_of_node(cpus, cpun) { - if (of_node_cmp(cpun->type, "cpu")) - continue; - /* Check for non-standard "ibm,ppc-interrupt-server#s" property - * for thread ids on PowerPC. If it doesn't exist fallback to - * standard "reg" property. - */ - if (IS_ENABLED(CONFIG_PPC) && - __of_find_n_match_cpu_property(cpun, - "ibm,ppc-interrupt-server#s", cpu, thread)) - return cpun; - if (__of_find_n_match_cpu_property(cpun, "reg", cpu, thread)) + for_each_node_by_type(cpun, "cpu") { + if (arch_find_n_match_cpu_physical_id(cpun, cpu, thread)) return cpun; } return NULL; diff --git a/include/linux/cpu.h b/include/linux/cpu.h index 801ff9e73679..fbd25c3c2923 100644 --- a/include/linux/cpu.h +++ b/include/linux/cpu.h @@ -18,6 +18,7 @@ #include struct device; +struct device_node; struct cpu { int node_id; /* The node which contains the CPU */ @@ -29,6 +30,8 @@ extern int register_cpu(struct cpu *cpu, int num); extern struct device *get_cpu_device(unsigned cpu); extern bool cpu_is_hotpluggable(unsigned cpu); extern bool arch_match_cpu_phys_id(int cpu, u64 phys_id); +extern bool arch_find_n_match_cpu_physical_id(struct device_node *cpun, + int cpu, unsigned int *thread); extern int cpu_add_dev_attr(struct device_attribute *attr); extern void cpu_remove_dev_attr(struct device_attribute *attr); -- cgit v1.2.3 From 0c02c8007ea5554d028f99fd3e29fc201fdeeab3 Mon Sep 17 00:00:00 2001 From: Grant Likely Date: Thu, 19 Sep 2013 11:22:36 -0500 Subject: of/irq: Rename of_irq_map_* functions to of_irq_parse_* The OF irq handling code has been overloading the term 'map' to refer to both parsing the data in the device tree and mapping it to the internal linux irq system. This is probably because the device tree does have the concept of an 'interrupt-map' function for translating interrupt references from one node to another, but 'map' is still confusing when the primary purpose of some of the functions are to parse the DT data. This patch renames all the of_irq_map_* functions to of_irq_parse_* which makes it clear that there is a difference between the parsing phase and the mapping phase. Kernel code can make use of just the parsing or just the mapping support as needed by the subsystem. The patch was generated mechanically with a handful of sed commands. Signed-off-by: Grant Likely Acked-by: Michal Simek Acked-by: Tony Lindgren Cc: Ralf Baechle Cc: Benjamin Herrenschmidt --- arch/arm/mach-integrator/pci_v3.c | 4 ++-- arch/microblaze/pci/pci-common.c | 2 +- arch/mips/pci/fixup-lantiq.c | 2 +- arch/mips/pci/pci-rt3883.c | 2 +- arch/powerpc/kernel/pci-common.c | 2 +- arch/powerpc/platforms/cell/celleb_scc_pciex.c | 2 +- arch/powerpc/platforms/cell/celleb_scc_sio.c | 2 +- arch/powerpc/platforms/cell/spider-pic.c | 2 +- arch/powerpc/platforms/cell/spu_manage.c | 2 +- arch/powerpc/platforms/fsl_uli1575.c | 2 +- arch/powerpc/platforms/powermac/pic.c | 2 +- arch/powerpc/platforms/pseries/event_sources.c | 2 +- arch/powerpc/sysdev/mpic_msi.c | 2 +- arch/x86/kernel/devicetree.c | 2 +- drivers/of/address.c | 4 ++-- drivers/of/irq.c | 28 +++++++++++++------------- drivers/of/of_pci_irq.c | 10 ++++----- drivers/pci/host/pci-mvebu.c | 2 +- include/linux/of_irq.h | 8 ++++---- include/linux/of_pci.h | 2 +- 20 files changed, 42 insertions(+), 42 deletions(-) (limited to 'include') diff --git a/arch/arm/mach-integrator/pci_v3.c b/arch/arm/mach-integrator/pci_v3.c index bef100527c42..0f496cc51f36 100644 --- a/arch/arm/mach-integrator/pci_v3.c +++ b/arch/arm/mach-integrator/pci_v3.c @@ -840,9 +840,9 @@ static int __init pci_v3_map_irq_dt(const struct pci_dev *dev, u8 slot, u8 pin) struct of_irq oirq; int ret; - ret = of_irq_map_pci(dev, &oirq); + ret = of_irq_parse_pci(dev, &oirq); if (ret) { - dev_err(&dev->dev, "of_irq_map_pci() %d\n", ret); + dev_err(&dev->dev, "of_irq_parse_pci() %d\n", ret); /* Proper return code 0 == NO_IRQ */ return 0; } diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c index 1b93bf0892a0..4d5b1a9cd790 100644 --- a/arch/microblaze/pci/pci-common.c +++ b/arch/microblaze/pci/pci-common.c @@ -217,7 +217,7 @@ int pci_read_irq_line(struct pci_dev *pci_dev) memset(&oirq, 0xff, sizeof(oirq)); #endif /* Try to get a mapping from the device-tree */ - if (of_irq_map_pci(pci_dev, &oirq)) { + if (of_irq_parse_pci(pci_dev, &oirq)) { u8 line, pin; /* If that fails, lets fallback to what is in the config diff --git a/arch/mips/pci/fixup-lantiq.c b/arch/mips/pci/fixup-lantiq.c index 6c829df28dc7..2e8dbfedae53 100644 --- a/arch/mips/pci/fixup-lantiq.c +++ b/arch/mips/pci/fixup-lantiq.c @@ -28,7 +28,7 @@ int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) struct of_irq dev_irq; int irq; - if (of_irq_map_pci(dev, &dev_irq)) { + if (of_irq_parse_pci(dev, &dev_irq)) { dev_err(&dev->dev, "trying to map irq for unknown slot:%d pin:%d\n", slot, pin); return 0; diff --git a/arch/mips/pci/pci-rt3883.c b/arch/mips/pci/pci-rt3883.c index 95c9d41382e7..cae92a05ee70 100644 --- a/arch/mips/pci/pci-rt3883.c +++ b/arch/mips/pci/pci-rt3883.c @@ -587,7 +587,7 @@ int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) int err; int irq; - err = of_irq_map_pci(dev, &dev_irq); + err = of_irq_parse_pci(dev, &dev_irq); if (err) { pr_err("pci %s: unable to get irq map, err=%d\n", pci_name((struct pci_dev *) dev), err); diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index 905a24bb7acc..2f4185425ed5 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -237,7 +237,7 @@ static int pci_read_irq_line(struct pci_dev *pci_dev) memset(&oirq, 0xff, sizeof(oirq)); #endif /* Try to get a mapping from the device-tree */ - if (of_irq_map_pci(pci_dev, &oirq)) { + if (of_irq_parse_pci(pci_dev, &oirq)) { u8 line, pin; /* If that fails, lets fallback to what is in the config diff --git a/arch/powerpc/platforms/cell/celleb_scc_pciex.c b/arch/powerpc/platforms/cell/celleb_scc_pciex.c index 14be2bd358b8..40bc371096b7 100644 --- a/arch/powerpc/platforms/cell/celleb_scc_pciex.c +++ b/arch/powerpc/platforms/cell/celleb_scc_pciex.c @@ -507,7 +507,7 @@ static __init int celleb_setup_pciex(struct device_node *node, phb->ops = &scc_pciex_pci_ops; /* internal interrupt handler */ - if (of_irq_map_one(node, 1, &oirq)) { + if (of_irq_parse_one(node, 1, &oirq)) { pr_err("PCIEXC:Failed to map irq\n"); goto error; } diff --git a/arch/powerpc/platforms/cell/celleb_scc_sio.c b/arch/powerpc/platforms/cell/celleb_scc_sio.c index 9c339ec646f5..96388b202f4e 100644 --- a/arch/powerpc/platforms/cell/celleb_scc_sio.c +++ b/arch/powerpc/platforms/cell/celleb_scc_sio.c @@ -53,7 +53,7 @@ static int __init txx9_serial_init(void) if (!(txx9_serial_bitmap & (1<host->of_node, 0, &oirq) == 0) { + if (of_irq_parse_one(pic->host->of_node, 0, &oirq) == 0) { virq = irq_create_of_mapping(oirq.controller, oirq.specifier, oirq.size); return virq; diff --git a/arch/powerpc/platforms/cell/spu_manage.c b/arch/powerpc/platforms/cell/spu_manage.c index 2bb6977c0a5a..e6cdb81a0959 100644 --- a/arch/powerpc/platforms/cell/spu_manage.c +++ b/arch/powerpc/platforms/cell/spu_manage.c @@ -182,7 +182,7 @@ static int __init spu_map_interrupts(struct spu *spu, struct device_node *np) int i; for (i=0; i < 3; i++) { - ret = of_irq_map_one(np, i, &oirq); + ret = of_irq_parse_one(np, i, &oirq); if (ret) { pr_debug("spu_new: failed to get irq %d\n", i); goto err; diff --git a/arch/powerpc/platforms/fsl_uli1575.c b/arch/powerpc/platforms/fsl_uli1575.c index 92ac9b52b32d..ac539c1cd808 100644 --- a/arch/powerpc/platforms/fsl_uli1575.c +++ b/arch/powerpc/platforms/fsl_uli1575.c @@ -333,7 +333,7 @@ static void hpcd_final_uli5288(struct pci_dev *dev) laddr[0] = (hose->first_busno << 16) | (PCI_DEVFN(31, 0) << 8); laddr[1] = laddr[2] = 0; - of_irq_map_raw(hosenode, &pin, 1, laddr, &oirq); + of_irq_parse_raw(hosenode, &pin, 1, laddr, &oirq); virq = irq_create_of_mapping(oirq.controller, oirq.specifier, oirq.size); dev->irq = virq; diff --git a/arch/powerpc/platforms/powermac/pic.c b/arch/powerpc/platforms/powermac/pic.c index 31036b56670e..720663e29f47 100644 --- a/arch/powerpc/platforms/powermac/pic.c +++ b/arch/powerpc/platforms/powermac/pic.c @@ -393,7 +393,7 @@ static void __init pmac_pic_probe_oldstyle(void) #endif } -int of_irq_map_oldworld(struct device_node *device, int index, +int of_irq_parse_oldworld(struct device_node *device, int index, struct of_irq *out_irq) { const u32 *ints = NULL; diff --git a/arch/powerpc/platforms/pseries/event_sources.c b/arch/powerpc/platforms/pseries/event_sources.c index 2605c310166a..850c18c457ad 100644 --- a/arch/powerpc/platforms/pseries/event_sources.c +++ b/arch/powerpc/platforms/pseries/event_sources.c @@ -55,7 +55,7 @@ void request_event_sources_irqs(struct device_node *np, /* Else use normal interrupt tree parsing */ else { /* First try to do a proper OF tree parsing */ - for (index = 0; of_irq_map_one(np, index, &oirq) == 0; + for (index = 0; of_irq_parse_one(np, index, &oirq) == 0; index++) { if (count > 15) break; diff --git a/arch/powerpc/sysdev/mpic_msi.c b/arch/powerpc/sysdev/mpic_msi.c index bbf342c88314..463e3a7c193c 100644 --- a/arch/powerpc/sysdev/mpic_msi.c +++ b/arch/powerpc/sysdev/mpic_msi.c @@ -63,7 +63,7 @@ static int mpic_msi_reserve_u3_hwirqs(struct mpic *mpic) pr_debug("mpic: mapping hwirqs for %s\n", np->full_name); index = 0; - while (of_irq_map_one(np, index++, &oirq) == 0) { + while (of_irq_parse_one(np, index++, &oirq) == 0) { ops->xlate(mpic->irqhost, NULL, oirq.specifier, oirq.size, &hwirq, &flags); msi_bitmap_reserve_hwirq(&mpic->msi_bitmap, hwirq); diff --git a/arch/x86/kernel/devicetree.c b/arch/x86/kernel/devicetree.c index 376dc7873447..3ac6398e5361 100644 --- a/arch/x86/kernel/devicetree.c +++ b/arch/x86/kernel/devicetree.c @@ -116,7 +116,7 @@ static int x86_of_pci_irq_enable(struct pci_dev *dev) if (!pin) return 0; - ret = of_irq_map_pci(dev, &oirq); + ret = of_irq_parse_pci(dev, &oirq); if (ret) return ret; diff --git a/drivers/of/address.c b/drivers/of/address.c index 71180b91bfbe..994f293baebf 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -532,12 +532,12 @@ static u64 __of_translate_address(struct device_node *dev, pbus->count_cells(dev, &pna, &pns); if (!OF_CHECK_COUNTS(pna, pns)) { printk(KERN_ERR "prom_parse: Bad cell count for %s\n", - dev->full_name); + of_node_full_name(dev)); break; } pr_debug("OF: parent bus is %s (na=%d, ns=%d) on %s\n", - pbus->name, pna, pns, parent->full_name); + pbus->name, pna, pns, of_node_full_name(parent)); /* Apply bus translation */ if (of_translate_one(dev, bus, pbus, addr, na, ns, pna, rprop)) diff --git a/drivers/of/irq.c b/drivers/of/irq.c index 90068f914911..410aa2415f42 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c @@ -31,14 +31,14 @@ * @dev: Device node of the device whose interrupt is to be mapped * @index: Index of the interrupt to map * - * This function is a wrapper that chains of_irq_map_one() and + * This function is a wrapper that chains of_irq_parse_one() and * irq_create_of_mapping() to make things easier to callers */ unsigned int irq_of_parse_and_map(struct device_node *dev, int index) { struct of_irq oirq; - if (of_irq_map_one(dev, index, &oirq)) + if (of_irq_parse_one(dev, index, &oirq)) return 0; return irq_create_of_mapping(oirq.controller, oirq.specifier, @@ -79,7 +79,7 @@ struct device_node *of_irq_find_parent(struct device_node *child) } /** - * of_irq_map_raw - Low level interrupt tree parsing + * of_irq_parse_raw - Low level interrupt tree parsing * @parent: the device interrupt parent * @intspec: interrupt specifier ("interrupts" property of the device) * @ointsize: size of the passed in interrupt specifier @@ -93,7 +93,7 @@ struct device_node *of_irq_find_parent(struct device_node *child) * properties, for example when resolving PCI interrupts when no device * node exist for the parent. */ -int of_irq_map_raw(struct device_node *parent, const __be32 *intspec, +int of_irq_parse_raw(struct device_node *parent, const __be32 *intspec, u32 ointsize, const __be32 *addr, struct of_irq *out_irq) { struct device_node *ipar, *tnode, *old = NULL, *newpar = NULL; @@ -101,7 +101,7 @@ int of_irq_map_raw(struct device_node *parent, const __be32 *intspec, u32 intsize = 1, addrsize, newintsize = 0, newaddrsize = 0; int imaplen, match, i; - pr_debug("of_irq_map_raw: par=%s,intspec=[0x%08x 0x%08x...],ointsize=%d\n", + pr_debug("of_irq_parse_raw: par=%s,intspec=[0x%08x 0x%08x...],ointsize=%d\n", of_node_full_name(parent), be32_to_cpup(intspec), be32_to_cpup(intspec + 1), ointsize); @@ -126,7 +126,7 @@ int of_irq_map_raw(struct device_node *parent, const __be32 *intspec, goto fail; } - pr_debug("of_irq_map_raw: ipar=%s, size=%d\n", of_node_full_name(ipar), intsize); + pr_debug("of_irq_parse_raw: ipar=%s, size=%d\n", of_node_full_name(ipar), intsize); if (ointsize != intsize) return -EINVAL; @@ -269,29 +269,29 @@ int of_irq_map_raw(struct device_node *parent, const __be32 *intspec, return -EINVAL; } -EXPORT_SYMBOL_GPL(of_irq_map_raw); +EXPORT_SYMBOL_GPL(of_irq_parse_raw); /** - * of_irq_map_one - Resolve an interrupt for a device + * of_irq_parse_one - Resolve an interrupt for a device * @device: the device whose interrupt is to be resolved * @index: index of the interrupt to resolve * @out_irq: structure of_irq filled by this function * * This function resolves an interrupt, walking the tree, for a given - * device-tree node. It's the high level pendant to of_irq_map_raw(). + * device-tree node. It's the high level pendant to of_irq_parse_raw(). */ -int of_irq_map_one(struct device_node *device, int index, struct of_irq *out_irq) +int of_irq_parse_one(struct device_node *device, int index, struct of_irq *out_irq) { struct device_node *p; const __be32 *intspec, *tmp, *addr; u32 intsize, intlen; int res = -EINVAL; - pr_debug("of_irq_map_one: dev=%s, index=%d\n", of_node_full_name(device), index); + pr_debug("of_irq_parse_one: dev=%s, index=%d\n", of_node_full_name(device), index); /* OldWorld mac stuff is "special", handle out of line */ if (of_irq_workarounds & OF_IMAP_OLDWORLD_MAC) - return of_irq_map_oldworld(device, index, out_irq); + return of_irq_parse_oldworld(device, index, out_irq); /* Get the interrupts property */ intspec = of_get_property(device, "interrupts", &intlen); @@ -322,13 +322,13 @@ int of_irq_map_one(struct device_node *device, int index, struct of_irq *out_irq goto out; /* Get new specifier and map it */ - res = of_irq_map_raw(p, intspec + index * intsize, intsize, + res = of_irq_parse_raw(p, intspec + index * intsize, intsize, addr, out_irq); out: of_node_put(p); return res; } -EXPORT_SYMBOL_GPL(of_irq_map_one); +EXPORT_SYMBOL_GPL(of_irq_parse_one); /** * of_irq_to_resource - Decode a node's IRQ and return it as a resource diff --git a/drivers/of/of_pci_irq.c b/drivers/of/of_pci_irq.c index 677053813211..dceec1048dab 100644 --- a/drivers/of/of_pci_irq.c +++ b/drivers/of/of_pci_irq.c @@ -5,7 +5,7 @@ #include /** - * of_irq_map_pci - Resolve the interrupt for a PCI device + * of_irq_parse_pci - Resolve the interrupt for a PCI device * @pdev: the device whose interrupt is to be resolved * @out_irq: structure of_irq filled by this function * @@ -15,7 +15,7 @@ * PCI tree until an device-node is found, at which point it will finish * resolving using the OF tree walking. */ -int of_irq_map_pci(const struct pci_dev *pdev, struct of_irq *out_irq) +int of_irq_parse_pci(const struct pci_dev *pdev, struct of_irq *out_irq) { struct device_node *dn, *ppnode; struct pci_dev *ppdev; @@ -30,7 +30,7 @@ int of_irq_map_pci(const struct pci_dev *pdev, struct of_irq *out_irq) */ dn = pci_device_to_OF_node(pdev); if (dn) { - rc = of_irq_map_one(dn, 0, out_irq); + rc = of_irq_parse_one(dn, 0, out_irq); if (!rc) return rc; } @@ -88,6 +88,6 @@ int of_irq_map_pci(const struct pci_dev *pdev, struct of_irq *out_irq) lspec_be = cpu_to_be32(lspec); laddr[0] = cpu_to_be32((pdev->bus->number << 16) | (pdev->devfn << 8)); laddr[1] = laddr[2] = cpu_to_be32(0); - return of_irq_map_raw(ppnode, &lspec_be, 1, laddr, out_irq); + return of_irq_parse_raw(ppnode, &lspec_be, 1, laddr, out_irq); } -EXPORT_SYMBOL_GPL(of_irq_map_pci); +EXPORT_SYMBOL_GPL(of_irq_parse_pci); diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c index 729d5a101d62..05f81807d05b 100644 --- a/drivers/pci/host/pci-mvebu.c +++ b/drivers/pci/host/pci-mvebu.c @@ -650,7 +650,7 @@ static int __init mvebu_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) struct of_irq oirq; int ret; - ret = of_irq_map_pci(dev, &oirq); + ret = of_irq_parse_pci(dev, &oirq); if (ret) return ret; diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h index fcd63baee5f2..a00bc71e62a3 100644 --- a/include/linux/of_irq.h +++ b/include/linux/of_irq.h @@ -35,12 +35,12 @@ typedef int (*of_irq_init_cb_t)(struct device_node *, struct device_node *); #if defined(CONFIG_PPC32) && defined(CONFIG_PPC_PMAC) extern unsigned int of_irq_workarounds; extern struct device_node *of_irq_dflt_pic; -extern int of_irq_map_oldworld(struct device_node *device, int index, +extern int of_irq_parse_oldworld(struct device_node *device, int index, struct of_irq *out_irq); #else /* CONFIG_PPC32 && CONFIG_PPC_PMAC */ #define of_irq_workarounds (0) #define of_irq_dflt_pic (NULL) -static inline int of_irq_map_oldworld(struct device_node *device, int index, +static inline int of_irq_parse_oldworld(struct device_node *device, int index, struct of_irq *out_irq) { return -EINVAL; @@ -48,10 +48,10 @@ static inline int of_irq_map_oldworld(struct device_node *device, int index, #endif /* CONFIG_PPC32 && CONFIG_PPC_PMAC */ -extern int of_irq_map_raw(struct device_node *parent, const __be32 *intspec, +extern int of_irq_parse_raw(struct device_node *parent, const __be32 *intspec, u32 ointsize, const __be32 *addr, struct of_irq *out_irq); -extern int of_irq_map_one(struct device_node *device, int index, +extern int of_irq_parse_one(struct device_node *device, int index, struct of_irq *out_irq); extern unsigned int irq_create_of_mapping(struct device_node *controller, const u32 *intspec, diff --git a/include/linux/of_pci.h b/include/linux/of_pci.h index fd9c408631a0..839ba20808fe 100644 --- a/include/linux/of_pci.h +++ b/include/linux/of_pci.h @@ -6,7 +6,7 @@ struct pci_dev; struct of_irq; -int of_irq_map_pci(const struct pci_dev *pdev, struct of_irq *out_irq); +int of_irq_parse_pci(const struct pci_dev *pdev, struct of_irq *out_irq); struct device_node; struct device_node *of_pci_find_child_device(struct device_node *parent, -- cgit v1.2.3 From 530210c7814e83564c7ca7bca8192515042c0b63 Mon Sep 17 00:00:00 2001 From: Grant Likely Date: Sun, 15 Sep 2013 16:39:11 +0100 Subject: of/irq: Replace of_irq with of_phandle_args struct of_irq and struct of_phandle_args are exactly the same structure. This patch makes the kernel use of_phandle_args everywhere. This in itself isn't a big deal, but it makes some follow-on patches simpler. Signed-off-by: Grant Likely Acked-by: Michal Simek Acked-by: Tony Lindgren Cc: Russell King Cc: Ralf Baechle Cc: Benjamin Herrenschmidt --- arch/arm/mach-integrator/pci_v3.c | 5 ++--- arch/microblaze/pci/pci-common.c | 9 ++++----- arch/mips/pci/fixup-lantiq.c | 5 ++--- arch/mips/pci/pci-rt3883.c | 6 ++---- arch/powerpc/kernel/pci-common.c | 9 ++++----- arch/powerpc/platforms/cell/celleb_scc_pciex.c | 5 ++--- arch/powerpc/platforms/cell/celleb_scc_sio.c | 5 ++--- arch/powerpc/platforms/cell/spider-pic.c | 6 +++--- arch/powerpc/platforms/cell/spu_manage.c | 12 ++++++------ arch/powerpc/platforms/fsl_uli1575.c | 8 +++----- arch/powerpc/platforms/powermac/pic.c | 8 ++++---- arch/powerpc/platforms/pseries/event_sources.c | 7 +++---- arch/powerpc/sysdev/mpic_msi.c | 6 +++--- arch/x86/kernel/devicetree.c | 5 ++--- drivers/of/irq.c | 15 +++++++-------- drivers/of/of_pci_irq.c | 2 +- drivers/pci/host/pci-mvebu.c | 5 ++--- include/linux/of_irq.h | 24 ++++-------------------- include/linux/of_pci.h | 4 ++-- 19 files changed, 58 insertions(+), 88 deletions(-) (limited to 'include') diff --git a/arch/arm/mach-integrator/pci_v3.c b/arch/arm/mach-integrator/pci_v3.c index 0f496cc51f36..2d6b4da90fb4 100644 --- a/arch/arm/mach-integrator/pci_v3.c +++ b/arch/arm/mach-integrator/pci_v3.c @@ -837,7 +837,7 @@ static struct hw_pci pci_v3 __initdata = { static int __init pci_v3_map_irq_dt(const struct pci_dev *dev, u8 slot, u8 pin) { - struct of_irq oirq; + struct of_phandle_args oirq; int ret; ret = of_irq_parse_pci(dev, &oirq); @@ -847,8 +847,7 @@ static int __init pci_v3_map_irq_dt(const struct pci_dev *dev, u8 slot, u8 pin) return 0; } - return irq_create_of_mapping(oirq.controller, oirq.specifier, - oirq.size); + return irq_create_of_mapping(oirq.np, oirq.args, oirq.args_count); } static int __init pci_v3_dtprobe(struct platform_device *pdev, diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c index 4d5b1a9cd790..c9302c4f8a57 100644 --- a/arch/microblaze/pci/pci-common.c +++ b/arch/microblaze/pci/pci-common.c @@ -199,7 +199,7 @@ void pcibios_set_master(struct pci_dev *dev) */ int pci_read_irq_line(struct pci_dev *pci_dev) { - struct of_irq oirq; + struct of_phandle_args oirq; unsigned int virq; /* The current device-tree that iSeries generates from the HV @@ -243,11 +243,10 @@ int pci_read_irq_line(struct pci_dev *pci_dev) irq_set_irq_type(virq, IRQ_TYPE_LEVEL_LOW); } else { pr_debug(" Got one, spec %d cells (0x%08x 0x%08x...) on %s\n", - oirq.size, oirq.specifier[0], oirq.specifier[1], - of_node_full_name(oirq.controller)); + oirq.args_count, oirq.args[0], oirq.args[1], + of_node_full_name(oirq.np)); - virq = irq_create_of_mapping(oirq.controller, oirq.specifier, - oirq.size); + virq = irq_create_of_mapping(oirq.np, oirq.args, oirq.args_count); } if (!virq) { pr_debug(" Failed to map !\n"); diff --git a/arch/mips/pci/fixup-lantiq.c b/arch/mips/pci/fixup-lantiq.c index 2e8dbfedae53..81ff0b5e6efa 100644 --- a/arch/mips/pci/fixup-lantiq.c +++ b/arch/mips/pci/fixup-lantiq.c @@ -25,7 +25,7 @@ int pcibios_plat_dev_init(struct pci_dev *dev) int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) { - struct of_irq dev_irq; + struct of_phandle_args dev_irq; int irq; if (of_irq_parse_pci(dev, &dev_irq)) { @@ -33,8 +33,7 @@ int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) slot, pin); return 0; } - irq = irq_create_of_mapping(dev_irq.controller, dev_irq.specifier, - dev_irq.size); + irq = irq_create_of_mapping(dev_irq.np, dev_irq.args, dev_irq.args_count); dev_info(&dev->dev, "SLOT:%d PIN:%d IRQ:%d\n", slot, pin, irq); return irq; } diff --git a/arch/mips/pci/pci-rt3883.c b/arch/mips/pci/pci-rt3883.c index cae92a05ee70..0f08a5ba0b2a 100644 --- a/arch/mips/pci/pci-rt3883.c +++ b/arch/mips/pci/pci-rt3883.c @@ -583,7 +583,7 @@ err_put_intc_node: int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) { - struct of_irq dev_irq; + struct of_phandle_args dev_irq; int err; int irq; @@ -594,9 +594,7 @@ int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) return 0; } - irq = irq_create_of_mapping(dev_irq.controller, - dev_irq.specifier, - dev_irq.size); + irq = irq_create_of_mapping(dev_irq.np, dev_irq.args, dev_irq.args_count); if (irq == 0) pr_crit("pci %s: no irq found for pin %u\n", diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index 2f4185425ed5..96c46235fda2 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -228,7 +228,7 @@ int pcibios_add_platform_entries(struct pci_dev *pdev) */ static int pci_read_irq_line(struct pci_dev *pci_dev) { - struct of_irq oirq; + struct of_phandle_args oirq; unsigned int virq; pr_debug("PCI: Try to map irq for %s...\n", pci_name(pci_dev)); @@ -263,11 +263,10 @@ static int pci_read_irq_line(struct pci_dev *pci_dev) irq_set_irq_type(virq, IRQ_TYPE_LEVEL_LOW); } else { pr_debug(" Got one, spec %d cells (0x%08x 0x%08x...) on %s\n", - oirq.size, oirq.specifier[0], oirq.specifier[1], - of_node_full_name(oirq.controller)); + oirq.args_count, oirq.args[0], oirq.args[1], + of_node_full_name(oirq.np)); - virq = irq_create_of_mapping(oirq.controller, oirq.specifier, - oirq.size); + virq = irq_create_of_mapping(oirq.np, oirq.args, oirq.args_count); } if(virq == NO_IRQ) { pr_debug(" Failed to map !\n"); diff --git a/arch/powerpc/platforms/cell/celleb_scc_pciex.c b/arch/powerpc/platforms/cell/celleb_scc_pciex.c index 40bc371096b7..e8d34d1f640d 100644 --- a/arch/powerpc/platforms/cell/celleb_scc_pciex.c +++ b/arch/powerpc/platforms/cell/celleb_scc_pciex.c @@ -486,7 +486,7 @@ static __init int celleb_setup_pciex(struct device_node *node, struct pci_controller *phb) { struct resource r; - struct of_irq oirq; + struct of_phandle_args oirq; int virq; /* SMMIO registers; used inside this file */ @@ -511,8 +511,7 @@ static __init int celleb_setup_pciex(struct device_node *node, pr_err("PCIEXC:Failed to map irq\n"); goto error; } - virq = irq_create_of_mapping(oirq.controller, oirq.specifier, - oirq.size); + virq = irq_create_of_mapping(oirq.np, oirq.args, oirq.args_count); if (request_irq(virq, pciex_handle_internal_irq, 0, "pciex", (void *)phb)) { pr_err("PCIEXC:Failed to request irq\n"); diff --git a/arch/powerpc/platforms/cell/celleb_scc_sio.c b/arch/powerpc/platforms/cell/celleb_scc_sio.c index 96388b202f4e..06046d512130 100644 --- a/arch/powerpc/platforms/cell/celleb_scc_sio.c +++ b/arch/powerpc/platforms/cell/celleb_scc_sio.c @@ -45,7 +45,7 @@ static int __init txx9_serial_init(void) struct device_node *node; int i; struct uart_port req; - struct of_irq irq; + struct of_phandle_args irq; struct resource res; for_each_compatible_node(node, "serial", "toshiba,sio-scc") { @@ -66,8 +66,7 @@ static int __init txx9_serial_init(void) #ifdef CONFIG_SERIAL_TXX9_CONSOLE req.membase = ioremap(req.mapbase, 0x24); #endif - req.irq = irq_create_of_mapping(irq.controller, - irq.specifier, irq.size); + req.irq = irq_create_of_mapping(irq.np, irq.args, irq.args_count); req.flags |= UPF_IOREMAP | UPF_BUGGY_UART /*HAVE_CTS_LINE*/; req.uartclk = 83300000; diff --git a/arch/powerpc/platforms/cell/spider-pic.c b/arch/powerpc/platforms/cell/spider-pic.c index b491f406560a..6e842fdbfcab 100644 --- a/arch/powerpc/platforms/cell/spider-pic.c +++ b/arch/powerpc/platforms/cell/spider-pic.c @@ -235,10 +235,10 @@ static unsigned int __init spider_find_cascade_and_node(struct spider_pic *pic) /* First, we check whether we have a real "interrupts" in the device * tree in case the device-tree is ever fixed */ - struct of_irq oirq; + struct of_phandle_args oirq; if (of_irq_parse_one(pic->host->of_node, 0, &oirq) == 0) { - virq = irq_create_of_mapping(oirq.controller, oirq.specifier, - oirq.size); + virq = irq_create_of_mapping(oirq.np, oirq.args, + oirq.args_count); return virq; } diff --git a/arch/powerpc/platforms/cell/spu_manage.c b/arch/powerpc/platforms/cell/spu_manage.c index e6cdb81a0959..e9eb4f83b1d5 100644 --- a/arch/powerpc/platforms/cell/spu_manage.c +++ b/arch/powerpc/platforms/cell/spu_manage.c @@ -177,7 +177,7 @@ out: static int __init spu_map_interrupts(struct spu *spu, struct device_node *np) { - struct of_irq oirq; + struct of_phandle_args oirq; int ret; int i; @@ -188,10 +188,10 @@ static int __init spu_map_interrupts(struct spu *spu, struct device_node *np) goto err; } ret = -EINVAL; - pr_debug(" irq %d no 0x%x on %s\n", i, oirq.specifier[0], - oirq.controller->full_name); - spu->irqs[i] = irq_create_of_mapping(oirq.controller, - oirq.specifier, oirq.size); + pr_debug(" irq %d no 0x%x on %s\n", i, oirq.args[0], + oirq.np->full_name); + spu->irqs[i] = irq_create_of_mapping(oirq.np, + oirq.args, oirq.args_count); if (spu->irqs[i] == NO_IRQ) { pr_debug("spu_new: failed to map it !\n"); goto err; @@ -200,7 +200,7 @@ static int __init spu_map_interrupts(struct spu *spu, struct device_node *np) return 0; err: - pr_debug("failed to map irq %x for spu %s\n", *oirq.specifier, + pr_debug("failed to map irq %x for spu %s\n", *oirq.args, spu->name); for (; i >= 0; i--) { if (spu->irqs[i] != NO_IRQ) diff --git a/arch/powerpc/platforms/fsl_uli1575.c b/arch/powerpc/platforms/fsl_uli1575.c index ac539c1cd808..288226deffa3 100644 --- a/arch/powerpc/platforms/fsl_uli1575.c +++ b/arch/powerpc/platforms/fsl_uli1575.c @@ -321,8 +321,8 @@ static void hpcd_final_uli5288(struct pci_dev *dev) { struct pci_controller *hose = pci_bus_to_host(dev->bus); struct device_node *hosenode = hose ? hose->dn : NULL; - struct of_irq oirq; - int virq, pin = 2; + struct of_phandle_args oirq; + int pin = 2; u32 laddr[3]; if (!machine_is(mpc86xx_hpcd)) @@ -334,9 +334,7 @@ static void hpcd_final_uli5288(struct pci_dev *dev) laddr[0] = (hose->first_busno << 16) | (PCI_DEVFN(31, 0) << 8); laddr[1] = laddr[2] = 0; of_irq_parse_raw(hosenode, &pin, 1, laddr, &oirq); - virq = irq_create_of_mapping(oirq.controller, oirq.specifier, - oirq.size); - dev->irq = virq; + dev->irq = irq_create_of_mapping(oirq.np, oirq.args, oirq.args_count); } DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, 0x1575, hpcd_quirk_uli1575); diff --git a/arch/powerpc/platforms/powermac/pic.c b/arch/powerpc/platforms/powermac/pic.c index 720663e29f47..4c24bf60d39d 100644 --- a/arch/powerpc/platforms/powermac/pic.c +++ b/arch/powerpc/platforms/powermac/pic.c @@ -394,7 +394,7 @@ static void __init pmac_pic_probe_oldstyle(void) } int of_irq_parse_oldworld(struct device_node *device, int index, - struct of_irq *out_irq) + struct of_phandle_args *out_irq) { const u32 *ints = NULL; int intlen; @@ -422,9 +422,9 @@ int of_irq_parse_oldworld(struct device_node *device, int index, if (index >= intlen) return -EINVAL; - out_irq->controller = NULL; - out_irq->specifier[0] = ints[index]; - out_irq->size = 1; + out_irq->np = NULL; + out_irq->args[0] = ints[index]; + out_irq->args_count = 1; return 0; } diff --git a/arch/powerpc/platforms/pseries/event_sources.c b/arch/powerpc/platforms/pseries/event_sources.c index 850c18c457ad..6dcf9cc38ffb 100644 --- a/arch/powerpc/platforms/pseries/event_sources.c +++ b/arch/powerpc/platforms/pseries/event_sources.c @@ -25,7 +25,7 @@ void request_event_sources_irqs(struct device_node *np, const char *name) { int i, index, count = 0; - struct of_irq oirq; + struct of_phandle_args oirq; const u32 *opicprop; unsigned int opicplen; unsigned int virqs[16]; @@ -59,9 +59,8 @@ void request_event_sources_irqs(struct device_node *np, index++) { if (count > 15) break; - virqs[count] = irq_create_of_mapping(oirq.controller, - oirq.specifier, - oirq.size); + virqs[count] = irq_create_of_mapping(oirq.np, oirq.args, + oirq.args_count); if (virqs[count] == NO_IRQ) { pr_err("event-sources: Unable to allocate " "interrupt number for %s\n", diff --git a/arch/powerpc/sysdev/mpic_msi.c b/arch/powerpc/sysdev/mpic_msi.c index 463e3a7c193c..7dc39f35a4cc 100644 --- a/arch/powerpc/sysdev/mpic_msi.c +++ b/arch/powerpc/sysdev/mpic_msi.c @@ -35,7 +35,7 @@ static int mpic_msi_reserve_u3_hwirqs(struct mpic *mpic) const struct irq_domain_ops *ops = mpic->irqhost->ops; struct device_node *np; int flags, index, i; - struct of_irq oirq; + struct of_phandle_args oirq; pr_debug("mpic: found U3, guessing msi allocator setup\n"); @@ -64,8 +64,8 @@ static int mpic_msi_reserve_u3_hwirqs(struct mpic *mpic) index = 0; while (of_irq_parse_one(np, index++, &oirq) == 0) { - ops->xlate(mpic->irqhost, NULL, oirq.specifier, - oirq.size, &hwirq, &flags); + ops->xlate(mpic->irqhost, NULL, oirq.args, + oirq.args_count, &hwirq, &flags); msi_bitmap_reserve_hwirq(&mpic->msi_bitmap, hwirq); } } diff --git a/arch/x86/kernel/devicetree.c b/arch/x86/kernel/devicetree.c index 3ac6398e5361..00986988a10e 100644 --- a/arch/x86/kernel/devicetree.c +++ b/arch/x86/kernel/devicetree.c @@ -105,7 +105,7 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus) static int x86_of_pci_irq_enable(struct pci_dev *dev) { - struct of_irq oirq; + struct of_phandle_args oirq; u32 virq; int ret; u8 pin; @@ -120,8 +120,7 @@ static int x86_of_pci_irq_enable(struct pci_dev *dev) if (ret) return ret; - virq = irq_create_of_mapping(oirq.controller, oirq.specifier, - oirq.size); + virq = irq_create_of_mapping(oirq.np, oirq.args, oirq.args_count); if (virq == 0) return -EINVAL; dev->irq = virq; diff --git a/drivers/of/irq.c b/drivers/of/irq.c index 410aa2415f42..a7db38a63403 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c @@ -36,13 +36,12 @@ */ unsigned int irq_of_parse_and_map(struct device_node *dev, int index) { - struct of_irq oirq; + struct of_phandle_args oirq; if (of_irq_parse_one(dev, index, &oirq)) return 0; - return irq_create_of_mapping(oirq.controller, oirq.specifier, - oirq.size); + return irq_create_of_mapping(oirq.np, oirq.args, oirq.args_count); } EXPORT_SYMBOL_GPL(irq_of_parse_and_map); @@ -94,7 +93,7 @@ struct device_node *of_irq_find_parent(struct device_node *child) * node exist for the parent. */ int of_irq_parse_raw(struct device_node *parent, const __be32 *intspec, - u32 ointsize, const __be32 *addr, struct of_irq *out_irq) + u32 ointsize, const __be32 *addr, struct of_phandle_args *out_irq) { struct device_node *ipar, *tnode, *old = NULL, *newpar = NULL; const __be32 *tmp, *imap, *imask; @@ -156,10 +155,10 @@ int of_irq_parse_raw(struct device_node *parent, const __be32 *intspec, NULL) { pr_debug(" -> got it !\n"); for (i = 0; i < intsize; i++) - out_irq->specifier[i] = + out_irq->args[i] = of_read_number(intspec +i, 1); - out_irq->size = intsize; - out_irq->controller = ipar; + out_irq->args_count = intsize; + out_irq->np = ipar; of_node_put(old); return 0; } @@ -280,7 +279,7 @@ EXPORT_SYMBOL_GPL(of_irq_parse_raw); * This function resolves an interrupt, walking the tree, for a given * device-tree node. It's the high level pendant to of_irq_parse_raw(). */ -int of_irq_parse_one(struct device_node *device, int index, struct of_irq *out_irq) +int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_args *out_irq) { struct device_node *p; const __be32 *intspec, *tmp, *addr; diff --git a/drivers/of/of_pci_irq.c b/drivers/of/of_pci_irq.c index dceec1048dab..ee3293d4b66b 100644 --- a/drivers/of/of_pci_irq.c +++ b/drivers/of/of_pci_irq.c @@ -15,7 +15,7 @@ * PCI tree until an device-node is found, at which point it will finish * resolving using the OF tree walking. */ -int of_irq_parse_pci(const struct pci_dev *pdev, struct of_irq *out_irq) +int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq) { struct device_node *dn, *ppnode; struct pci_dev *ppdev; diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c index 05f81807d05b..c5e57f82b9af 100644 --- a/drivers/pci/host/pci-mvebu.c +++ b/drivers/pci/host/pci-mvebu.c @@ -647,15 +647,14 @@ static int __init mvebu_pcie_setup(int nr, struct pci_sys_data *sys) static int __init mvebu_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) { - struct of_irq oirq; + struct of_phandle_args oirq; int ret; ret = of_irq_parse_pci(dev, &oirq); if (ret) return ret; - return irq_create_of_mapping(oirq.controller, oirq.specifier, - oirq.size); + return irq_create_of_mapping(oirq.np, oirq.args, oirq.args_count); } static struct pci_bus *mvebu_pcie_scan_bus(int nr, struct pci_sys_data *sys) diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h index a00bc71e62a3..8d9f85560d48 100644 --- a/include/linux/of_irq.h +++ b/include/linux/of_irq.h @@ -8,22 +8,6 @@ #include #include -/** - * of_irq - container for device_node/irq_specifier pair for an irq controller - * @controller: pointer to interrupt controller device tree node - * @size: size of interrupt specifier - * @specifier: array of cells @size long specifing the specific interrupt - * - * This structure is returned when an interrupt is mapped. The controller - * field needs to be put() after use - */ -#define OF_MAX_IRQ_SPEC 4 /* We handle specifiers of at most 4 cells */ -struct of_irq { - struct device_node *controller; /* Interrupt controller node */ - u32 size; /* Specifier size */ - u32 specifier[OF_MAX_IRQ_SPEC]; /* Specifier copy */ -}; - typedef int (*of_irq_init_cb_t)(struct device_node *, struct device_node *); /* @@ -36,12 +20,12 @@ typedef int (*of_irq_init_cb_t)(struct device_node *, struct device_node *); extern unsigned int of_irq_workarounds; extern struct device_node *of_irq_dflt_pic; extern int of_irq_parse_oldworld(struct device_node *device, int index, - struct of_irq *out_irq); + struct of_phandle_args *out_irq); #else /* CONFIG_PPC32 && CONFIG_PPC_PMAC */ #define of_irq_workarounds (0) #define of_irq_dflt_pic (NULL) static inline int of_irq_parse_oldworld(struct device_node *device, int index, - struct of_irq *out_irq) + struct of_phandle_args *out_irq) { return -EINVAL; } @@ -50,9 +34,9 @@ static inline int of_irq_parse_oldworld(struct device_node *device, int index, extern int of_irq_parse_raw(struct device_node *parent, const __be32 *intspec, u32 ointsize, const __be32 *addr, - struct of_irq *out_irq); + struct of_phandle_args *out_irq); extern int of_irq_parse_one(struct device_node *device, int index, - struct of_irq *out_irq); + struct of_phandle_args *out_irq); extern unsigned int irq_create_of_mapping(struct device_node *controller, const u32 *intspec, unsigned int intsize); diff --git a/include/linux/of_pci.h b/include/linux/of_pci.h index 839ba20808fe..f297237349e8 100644 --- a/include/linux/of_pci.h +++ b/include/linux/of_pci.h @@ -5,8 +5,8 @@ #include struct pci_dev; -struct of_irq; -int of_irq_parse_pci(const struct pci_dev *pdev, struct of_irq *out_irq); +struct of_phandle_args; +int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq); struct device_node; struct device_node *of_pci_find_child_device(struct device_node *parent, -- cgit v1.2.3 From e6d30ab1e7d1281784672c0fc2ffa385cfb7279e Mon Sep 17 00:00:00 2001 From: Grant Likely Date: Sun, 15 Sep 2013 16:55:53 +0100 Subject: of/irq: simplify args to irq_create_of_mapping All the callers of irq_create_of_mapping() pass the contents of a struct of_phandle_args structure to the function. Since all the callers already have an of_phandle_args pointer, why not pass it directly to irq_create_of_mapping()? Signed-off-by: Grant Likely Acked-by: Michal Simek Acked-by: Tony Lindgren Cc: Thomas Gleixner Cc: Russell King Cc: Ralf Baechle Cc: Benjamin Herrenschmidt --- arch/arm/mach-integrator/pci_v3.c | 2 +- arch/microblaze/pci/pci-common.c | 2 +- arch/mips/pci/fixup-lantiq.c | 2 +- arch/mips/pci/pci-rt3883.c | 2 +- arch/powerpc/kernel/pci-common.c | 2 +- arch/powerpc/platforms/cell/celleb_scc_pciex.c | 2 +- arch/powerpc/platforms/cell/celleb_scc_sio.c | 2 +- arch/powerpc/platforms/cell/spider-pic.c | 7 ++----- arch/powerpc/platforms/cell/spu_manage.c | 3 +-- arch/powerpc/platforms/fsl_uli1575.c | 2 +- arch/powerpc/platforms/pseries/event_sources.c | 3 +-- arch/x86/kernel/devicetree.c | 2 +- drivers/of/irq.c | 2 +- drivers/pci/host/pci-mvebu.c | 2 +- include/linux/of_irq.h | 4 +--- kernel/irq/irqdomain.c | 13 ++++++------- 16 files changed, 22 insertions(+), 30 deletions(-) (limited to 'include') diff --git a/arch/arm/mach-integrator/pci_v3.c b/arch/arm/mach-integrator/pci_v3.c index 2d6b4da90fb4..bb3aeb31a54e 100644 --- a/arch/arm/mach-integrator/pci_v3.c +++ b/arch/arm/mach-integrator/pci_v3.c @@ -847,7 +847,7 @@ static int __init pci_v3_map_irq_dt(const struct pci_dev *dev, u8 slot, u8 pin) return 0; } - return irq_create_of_mapping(oirq.np, oirq.args, oirq.args_count); + return irq_create_of_mapping(&oirq); } static int __init pci_v3_dtprobe(struct platform_device *pdev, diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c index c9302c4f8a57..60b386c72c57 100644 --- a/arch/microblaze/pci/pci-common.c +++ b/arch/microblaze/pci/pci-common.c @@ -246,7 +246,7 @@ int pci_read_irq_line(struct pci_dev *pci_dev) oirq.args_count, oirq.args[0], oirq.args[1], of_node_full_name(oirq.np)); - virq = irq_create_of_mapping(oirq.np, oirq.args, oirq.args_count); + virq = irq_create_of_mapping(&oirq); } if (!virq) { pr_debug(" Failed to map !\n"); diff --git a/arch/mips/pci/fixup-lantiq.c b/arch/mips/pci/fixup-lantiq.c index 81ff0b5e6efa..aef60e75003e 100644 --- a/arch/mips/pci/fixup-lantiq.c +++ b/arch/mips/pci/fixup-lantiq.c @@ -33,7 +33,7 @@ int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) slot, pin); return 0; } - irq = irq_create_of_mapping(dev_irq.np, dev_irq.args, dev_irq.args_count); + irq = irq_create_of_mapping(&dev_irq); dev_info(&dev->dev, "SLOT:%d PIN:%d IRQ:%d\n", slot, pin, irq); return irq; } diff --git a/arch/mips/pci/pci-rt3883.c b/arch/mips/pci/pci-rt3883.c index 0f08a5ba0b2a..eadc4310cd36 100644 --- a/arch/mips/pci/pci-rt3883.c +++ b/arch/mips/pci/pci-rt3883.c @@ -594,7 +594,7 @@ int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) return 0; } - irq = irq_create_of_mapping(dev_irq.np, dev_irq.args, dev_irq.args_count); + irq = irq_create_of_mapping(&dev_irq); if (irq == 0) pr_crit("pci %s: no irq found for pin %u\n", diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index 96c46235fda2..a1e3e40ca3fd 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -266,7 +266,7 @@ static int pci_read_irq_line(struct pci_dev *pci_dev) oirq.args_count, oirq.args[0], oirq.args[1], of_node_full_name(oirq.np)); - virq = irq_create_of_mapping(oirq.np, oirq.args, oirq.args_count); + virq = irq_create_of_mapping(&oirq); } if(virq == NO_IRQ) { pr_debug(" Failed to map !\n"); diff --git a/arch/powerpc/platforms/cell/celleb_scc_pciex.c b/arch/powerpc/platforms/cell/celleb_scc_pciex.c index e8d34d1f640d..b3ea96db5b06 100644 --- a/arch/powerpc/platforms/cell/celleb_scc_pciex.c +++ b/arch/powerpc/platforms/cell/celleb_scc_pciex.c @@ -511,7 +511,7 @@ static __init int celleb_setup_pciex(struct device_node *node, pr_err("PCIEXC:Failed to map irq\n"); goto error; } - virq = irq_create_of_mapping(oirq.np, oirq.args, oirq.args_count); + virq = irq_create_of_mapping(&oirq); if (request_irq(virq, pciex_handle_internal_irq, 0, "pciex", (void *)phb)) { pr_err("PCIEXC:Failed to request irq\n"); diff --git a/arch/powerpc/platforms/cell/celleb_scc_sio.c b/arch/powerpc/platforms/cell/celleb_scc_sio.c index 06046d512130..c8eb57193826 100644 --- a/arch/powerpc/platforms/cell/celleb_scc_sio.c +++ b/arch/powerpc/platforms/cell/celleb_scc_sio.c @@ -66,7 +66,7 @@ static int __init txx9_serial_init(void) #ifdef CONFIG_SERIAL_TXX9_CONSOLE req.membase = ioremap(req.mapbase, 0x24); #endif - req.irq = irq_create_of_mapping(irq.np, irq.args, irq.args_count); + req.irq = irq_create_of_mapping(&irq); req.flags |= UPF_IOREMAP | UPF_BUGGY_UART /*HAVE_CTS_LINE*/; req.uartclk = 83300000; diff --git a/arch/powerpc/platforms/cell/spider-pic.c b/arch/powerpc/platforms/cell/spider-pic.c index 6e842fdbfcab..d20680446174 100644 --- a/arch/powerpc/platforms/cell/spider-pic.c +++ b/arch/powerpc/platforms/cell/spider-pic.c @@ -236,11 +236,8 @@ static unsigned int __init spider_find_cascade_and_node(struct spider_pic *pic) * tree in case the device-tree is ever fixed */ struct of_phandle_args oirq; - if (of_irq_parse_one(pic->host->of_node, 0, &oirq) == 0) { - virq = irq_create_of_mapping(oirq.np, oirq.args, - oirq.args_count); - return virq; - } + if (of_irq_parse_one(pic->host->of_node, 0, &oirq) == 0) + return irq_create_of_mapping(&oirq); /* Now do the horrible hacks */ tmp = of_get_property(pic->host->of_node, "#interrupt-cells", NULL); diff --git a/arch/powerpc/platforms/cell/spu_manage.c b/arch/powerpc/platforms/cell/spu_manage.c index e9eb4f83b1d5..c3327f3d8cf7 100644 --- a/arch/powerpc/platforms/cell/spu_manage.c +++ b/arch/powerpc/platforms/cell/spu_manage.c @@ -190,8 +190,7 @@ static int __init spu_map_interrupts(struct spu *spu, struct device_node *np) ret = -EINVAL; pr_debug(" irq %d no 0x%x on %s\n", i, oirq.args[0], oirq.np->full_name); - spu->irqs[i] = irq_create_of_mapping(oirq.np, - oirq.args, oirq.args_count); + spu->irqs[i] = irq_create_of_mapping(&oirq); if (spu->irqs[i] == NO_IRQ) { pr_debug("spu_new: failed to map it !\n"); goto err; diff --git a/arch/powerpc/platforms/fsl_uli1575.c b/arch/powerpc/platforms/fsl_uli1575.c index 288226deffa3..8904046556ad 100644 --- a/arch/powerpc/platforms/fsl_uli1575.c +++ b/arch/powerpc/platforms/fsl_uli1575.c @@ -334,7 +334,7 @@ static void hpcd_final_uli5288(struct pci_dev *dev) laddr[0] = (hose->first_busno << 16) | (PCI_DEVFN(31, 0) << 8); laddr[1] = laddr[2] = 0; of_irq_parse_raw(hosenode, &pin, 1, laddr, &oirq); - dev->irq = irq_create_of_mapping(oirq.np, oirq.args, oirq.args_count); + dev->irq = irq_create_of_mapping(&oirq); } DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, 0x1575, hpcd_quirk_uli1575); diff --git a/arch/powerpc/platforms/pseries/event_sources.c b/arch/powerpc/platforms/pseries/event_sources.c index 6dcf9cc38ffb..18380e8f6dfe 100644 --- a/arch/powerpc/platforms/pseries/event_sources.c +++ b/arch/powerpc/platforms/pseries/event_sources.c @@ -59,8 +59,7 @@ void request_event_sources_irqs(struct device_node *np, index++) { if (count > 15) break; - virqs[count] = irq_create_of_mapping(oirq.np, oirq.args, - oirq.args_count); + virqs[count] = irq_create_of_mapping(&oirq); if (virqs[count] == NO_IRQ) { pr_err("event-sources: Unable to allocate " "interrupt number for %s\n", diff --git a/arch/x86/kernel/devicetree.c b/arch/x86/kernel/devicetree.c index 00986988a10e..d39948f654a0 100644 --- a/arch/x86/kernel/devicetree.c +++ b/arch/x86/kernel/devicetree.c @@ -120,7 +120,7 @@ static int x86_of_pci_irq_enable(struct pci_dev *dev) if (ret) return ret; - virq = irq_create_of_mapping(oirq.np, oirq.args, oirq.args_count); + virq = irq_create_of_mapping(&oirq); if (virq == 0) return -EINVAL; dev->irq = virq; diff --git a/drivers/of/irq.c b/drivers/of/irq.c index a7db38a63403..84184c44e8db 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c @@ -41,7 +41,7 @@ unsigned int irq_of_parse_and_map(struct device_node *dev, int index) if (of_irq_parse_one(dev, index, &oirq)) return 0; - return irq_create_of_mapping(oirq.np, oirq.args, oirq.args_count); + return irq_create_of_mapping(&oirq); } EXPORT_SYMBOL_GPL(irq_of_parse_and_map); diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c index c5e57f82b9af..3a8d01ec50f7 100644 --- a/drivers/pci/host/pci-mvebu.c +++ b/drivers/pci/host/pci-mvebu.c @@ -654,7 +654,7 @@ static int __init mvebu_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) if (ret) return ret; - return irq_create_of_mapping(oirq.np, oirq.args, oirq.args_count); + return irq_create_of_mapping(&oirq); } static struct pci_bus *mvebu_pcie_scan_bus(int nr, struct pci_sys_data *sys) diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h index 8d9f85560d48..3bbba8d6adc8 100644 --- a/include/linux/of_irq.h +++ b/include/linux/of_irq.h @@ -37,9 +37,7 @@ extern int of_irq_parse_raw(struct device_node *parent, const __be32 *intspec, struct of_phandle_args *out_irq); extern int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_args *out_irq); -extern unsigned int irq_create_of_mapping(struct device_node *controller, - const u32 *intspec, - unsigned int intsize); +extern unsigned int irq_create_of_mapping(struct of_phandle_args *irq_data); extern int of_irq_to_resource(struct device_node *dev, int index, struct resource *r); extern int of_irq_count(struct device_node *dev); diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 706724e9835d..cf68bb36fe58 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -465,27 +465,26 @@ int irq_create_strict_mappings(struct irq_domain *domain, unsigned int irq_base, } EXPORT_SYMBOL_GPL(irq_create_strict_mappings); -unsigned int irq_create_of_mapping(struct device_node *controller, - const u32 *intspec, unsigned int intsize) +unsigned int irq_create_of_mapping(struct of_phandle_args *irq_data) { struct irq_domain *domain; irq_hw_number_t hwirq; unsigned int type = IRQ_TYPE_NONE; unsigned int virq; - domain = controller ? irq_find_host(controller) : irq_default_domain; + domain = irq_data->np ? irq_find_host(irq_data->np) : irq_default_domain; if (!domain) { pr_warn("no irq domain found for %s !\n", - of_node_full_name(controller)); + of_node_full_name(irq_data->np)); return 0; } /* If domain has no translation, then we assume interrupt line */ if (domain->ops->xlate == NULL) - hwirq = intspec[0]; + hwirq = irq_data->args[0]; else { - if (domain->ops->xlate(domain, controller, intspec, intsize, - &hwirq, &type)) + if (domain->ops->xlate(domain, irq_data->np, irq_data->args, + irq_data->args_count, &hwirq, &type)) return 0; } -- cgit v1.2.3 From 2361613206e66ce59cc0e08efa8d98ec15b84ed1 Mon Sep 17 00:00:00 2001 From: Grant Likely Date: Sun, 15 Sep 2013 22:32:39 +0100 Subject: of/irq: Refactor interrupt-map parsing All the users of of_irq_parse_raw pass in a raw interrupt specifier from the device tree and expect it to be returned (possibly modified) in an of_phandle_args structure. However, the primary function of of_irq_parse_raw() is to check for translations due to the presence of one or more interrupt-map properties. The actual placing of the data into an of_phandle_args structure is trivial. If it is refactored to accept an of_phandle_args structure directly, then it becomes possible to consume of_phandle_args from other sources. This is important for an upcoming patch that allows a device to be connected to more than one interrupt parent. It also simplifies the code a bit. The biggest complication with this patch is that the old version works on the interrupt specifiers in __be32 form, but the of_phandle_args structure is intended to carry it in the cpu-native version. A bit of churn was required to make this work. In the end it results in tighter code, so the churn is worth it. Signed-off-by: Grant Likely Acked-by: Tony Lindgren Cc: Benjamin Herrenschmidt --- arch/powerpc/platforms/fsl_uli1575.c | 6 +- drivers/of/irq.c | 108 ++++++++++++++++++----------------- drivers/of/of_pci_irq.c | 7 ++- include/linux/of_irq.h | 5 +- 4 files changed, 67 insertions(+), 59 deletions(-) (limited to 'include') diff --git a/arch/powerpc/platforms/fsl_uli1575.c b/arch/powerpc/platforms/fsl_uli1575.c index 8904046556ad..b97f6f3d3c5b 100644 --- a/arch/powerpc/platforms/fsl_uli1575.c +++ b/arch/powerpc/platforms/fsl_uli1575.c @@ -322,7 +322,6 @@ static void hpcd_final_uli5288(struct pci_dev *dev) struct pci_controller *hose = pci_bus_to_host(dev->bus); struct device_node *hosenode = hose ? hose->dn : NULL; struct of_phandle_args oirq; - int pin = 2; u32 laddr[3]; if (!machine_is(mpc86xx_hpcd)) @@ -331,9 +330,12 @@ static void hpcd_final_uli5288(struct pci_dev *dev) if (!hosenode) return; + oirq.np = hosenode; + oirq.args[0] = 2; + oirq.args_count = 1; laddr[0] = (hose->first_busno << 16) | (PCI_DEVFN(31, 0) << 8); laddr[1] = laddr[2] = 0; - of_irq_parse_raw(hosenode, &pin, 1, laddr, &oirq); + of_irq_parse_raw(laddr, &oirq); dev->irq = irq_create_of_mapping(&oirq); } diff --git a/drivers/of/irq.c b/drivers/of/irq.c index 84184c44e8db..0ed5ed4a5f9b 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c @@ -80,31 +80,32 @@ struct device_node *of_irq_find_parent(struct device_node *child) /** * of_irq_parse_raw - Low level interrupt tree parsing * @parent: the device interrupt parent - * @intspec: interrupt specifier ("interrupts" property of the device) - * @ointsize: size of the passed in interrupt specifier - * @addr: address specifier (start of "reg" property of the device) - * @out_irq: structure of_irq filled by this function + * @addr: address specifier (start of "reg" property of the device) in be32 format + * @out_irq: structure of_irq updated by this function * * Returns 0 on success and a negative number on error * * This function is a low-level interrupt tree walking function. It * can be used to do a partial walk with synthetized reg and interrupts * properties, for example when resolving PCI interrupts when no device - * node exist for the parent. + * node exist for the parent. It takes an interrupt specifier structure as + * input, walks the tree looking for any interrupt-map properties, translates + * the specifier for each map, and then returns the translated map. */ -int of_irq_parse_raw(struct device_node *parent, const __be32 *intspec, - u32 ointsize, const __be32 *addr, struct of_phandle_args *out_irq) +int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq) { struct device_node *ipar, *tnode, *old = NULL, *newpar = NULL; - const __be32 *tmp, *imap, *imask; + __be32 initial_match_array[8]; + const __be32 *match_array = initial_match_array; + const __be32 *tmp, *imap, *imask, dummy_imask[] = { ~0, ~0, ~0, ~0, ~0 }; u32 intsize = 1, addrsize, newintsize = 0, newaddrsize = 0; int imaplen, match, i; pr_debug("of_irq_parse_raw: par=%s,intspec=[0x%08x 0x%08x...],ointsize=%d\n", - of_node_full_name(parent), be32_to_cpup(intspec), - be32_to_cpup(intspec + 1), ointsize); + of_node_full_name(out_irq->np), out_irq->args[0], out_irq->args[1], + out_irq->args_count); - ipar = of_node_get(parent); + ipar = of_node_get(out_irq->np); /* First get the #interrupt-cells property of the current cursor * that tells us how to interpret the passed-in intspec. If there @@ -127,7 +128,7 @@ int of_irq_parse_raw(struct device_node *parent, const __be32 *intspec, pr_debug("of_irq_parse_raw: ipar=%s, size=%d\n", of_node_full_name(ipar), intsize); - if (ointsize != intsize) + if (out_irq->args_count != intsize) return -EINVAL; /* Look for this #address-cells. We have to implement the old linux @@ -146,6 +147,21 @@ int of_irq_parse_raw(struct device_node *parent, const __be32 *intspec, pr_debug(" -> addrsize=%d\n", addrsize); + /* If we were passed no "reg" property and we attempt to parse + * an interrupt-map, then #address-cells must be 0. + * Fail if it's not. + */ + if (addr == NULL && addrsize != 0) { + pr_debug(" -> no reg passed in when needed !\n"); + return -EINVAL; + } + + /* Precalculate the match array - this simplifies match loop */ + for (i = 0; i < addrsize; i++) + initial_match_array[i] = addr[i]; + for (i = 0; i < intsize; i++) + initial_match_array[addrsize + i] = cpu_to_be32(out_irq->args[i]); + /* Now start the actual "proper" walk of the interrupt tree */ while (ipar != NULL) { /* Now check if cursor is an interrupt-controller and if it is @@ -154,11 +170,6 @@ int of_irq_parse_raw(struct device_node *parent, const __be32 *intspec, if (of_get_property(ipar, "interrupt-controller", NULL) != NULL) { pr_debug(" -> got it !\n"); - for (i = 0; i < intsize; i++) - out_irq->args[i] = - of_read_number(intspec +i, 1); - out_irq->args_count = intsize; - out_irq->np = ipar; of_node_put(old); return 0; } @@ -175,34 +186,16 @@ int of_irq_parse_raw(struct device_node *parent, const __be32 *intspec, /* Look for a mask */ imask = of_get_property(ipar, "interrupt-map-mask", NULL); - - /* If we were passed no "reg" property and we attempt to parse - * an interrupt-map, then #address-cells must be 0. - * Fail if it's not. - */ - if (addr == NULL && addrsize != 0) { - pr_debug(" -> no reg passed in when needed !\n"); - goto fail; - } + if (!imask) + imask = dummy_imask; /* Parse interrupt-map */ match = 0; while (imaplen > (addrsize + intsize + 1) && !match) { /* Compare specifiers */ match = 1; - for (i = 0; i < addrsize && match; ++i) { - __be32 mask = imask ? imask[i] - : cpu_to_be32(0xffffffffu); - match = ((addr[i] ^ imap[i]) & mask) == 0; - } - for (; i < (addrsize + intsize) && match; ++i) { - __be32 mask = imask ? imask[i] - : cpu_to_be32(0xffffffffu); - match = - ((intspec[i-addrsize] ^ imap[i]) & mask) == 0; - } - imap += addrsize + intsize; - imaplen -= addrsize + intsize; + for (i = 0; i < (addrsize + intsize); i++, imaplen--) + match = !((match_array[i] ^ *imap++) & imask[i]); pr_debug(" -> match=%d (imaplen=%d)\n", match, imaplen); @@ -247,12 +240,18 @@ int of_irq_parse_raw(struct device_node *parent, const __be32 *intspec, if (!match) goto fail; - of_node_put(old); - old = of_node_get(newpar); + /* + * Successfully parsed an interrrupt-map translation; copy new + * interrupt specifier into the out_irq structure + */ + of_node_put(out_irq->np); + out_irq->np = of_node_get(newpar); + + match_array = imap - newaddrsize - newintsize; + for (i = 0; i < newintsize; i++) + out_irq->args[i] = be32_to_cpup(imap - newintsize + i); + out_irq->args_count = intsize = newintsize; addrsize = newaddrsize; - intsize = newintsize; - intspec = imap - intsize; - addr = intspec - addrsize; skiplevel: /* Iterate again with new parent */ @@ -263,7 +262,7 @@ int of_irq_parse_raw(struct device_node *parent, const __be32 *intspec, } fail: of_node_put(ipar); - of_node_put(old); + of_node_put(out_irq->np); of_node_put(newpar); return -EINVAL; @@ -276,15 +275,16 @@ EXPORT_SYMBOL_GPL(of_irq_parse_raw); * @index: index of the interrupt to resolve * @out_irq: structure of_irq filled by this function * - * This function resolves an interrupt, walking the tree, for a given - * device-tree node. It's the high level pendant to of_irq_parse_raw(). + * This function resolves an interrupt for a node by walking the interrupt tree, + * finding which interrupt controller node it is attached to, and returning the + * interrupt specifier that can be used to retrieve a Linux IRQ number. */ int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_args *out_irq) { struct device_node *p; const __be32 *intspec, *tmp, *addr; u32 intsize, intlen; - int res = -EINVAL; + int i, res = -EINVAL; pr_debug("of_irq_parse_one: dev=%s, index=%d\n", of_node_full_name(device), index); @@ -320,9 +320,15 @@ int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_ar if ((index + 1) * intsize > intlen) goto out; - /* Get new specifier and map it */ - res = of_irq_parse_raw(p, intspec + index * intsize, intsize, - addr, out_irq); + /* Copy intspec into irq structure */ + intspec += index * intsize; + out_irq->np = p; + out_irq->args_count = intsize; + for (i = 0; i < intsize; i++) + out_irq->args[i] = be32_to_cpup(intspec++); + + /* Check if there are any interrupt-map translations to process */ + res = of_irq_parse_raw(addr, out_irq); out: of_node_put(p); return res; diff --git a/drivers/of/of_pci_irq.c b/drivers/of/of_pci_irq.c index ee3293d4b66b..303afebc247a 100644 --- a/drivers/of/of_pci_irq.c +++ b/drivers/of/of_pci_irq.c @@ -85,9 +85,12 @@ int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq pdev = ppdev; } + out_irq->np = ppnode; + out_irq->args_count = 1; + out_irq->args[0] = lspec; lspec_be = cpu_to_be32(lspec); laddr[0] = cpu_to_be32((pdev->bus->number << 16) | (pdev->devfn << 8)); - laddr[1] = laddr[2] = cpu_to_be32(0); - return of_irq_parse_raw(ppnode, &lspec_be, 1, laddr, out_irq); + laddr[1] = laddr[2] = cpu_to_be32(0); + return of_irq_parse_raw(laddr, out_irq); } EXPORT_SYMBOL_GPL(of_irq_parse_pci); diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h index 3bbba8d6adc8..c0d6dfe80895 100644 --- a/include/linux/of_irq.h +++ b/include/linux/of_irq.h @@ -31,10 +31,7 @@ static inline int of_irq_parse_oldworld(struct device_node *device, int index, } #endif /* CONFIG_PPC32 && CONFIG_PPC_PMAC */ - -extern int of_irq_parse_raw(struct device_node *parent, const __be32 *intspec, - u32 ointsize, const __be32 *addr, - struct of_phandle_args *out_irq); +extern int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq); extern int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_args *out_irq); extern unsigned int irq_create_of_mapping(struct of_phandle_args *irq_data); -- cgit v1.2.3 From 624cfca534f9b1ffb1326617b4e973a3d5ecff4a Mon Sep 17 00:00:00 2001 From: Grant Likely Date: Fri, 11 Oct 2013 22:05:10 +0100 Subject: of: Add helper for printing an of_phandle_args structure It is sometimes useful for debug to get the contents of an of_phandle_args structure out into the kernel log. Signed-off-by: Grant Likely --- drivers/of/base.c | 9 +++++++++ drivers/of/irq.c | 6 +++--- include/linux/of.h | 1 + 3 files changed, 13 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/drivers/of/base.c b/drivers/of/base.c index 3ae106d89791..021db96245e7 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -1185,6 +1185,15 @@ int of_property_count_strings(struct device_node *np, const char *propname) } EXPORT_SYMBOL_GPL(of_property_count_strings); +void of_print_phandle_args(const char *msg, const struct of_phandle_args *args) +{ + int i; + printk("%s %s", msg, of_node_full_name(args->np)); + for (i = 0; i < args->args_count; i++) + printk(i ? ",%08x" : ":%08x", args->args[i]); + printk("\n"); +} + static int __of_parse_phandle_with_args(const struct device_node *np, const char *list_name, const char *cells_name, diff --git a/drivers/of/irq.c b/drivers/of/irq.c index 0ed5ed4a5f9b..ddea945ec29e 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c @@ -101,9 +101,9 @@ int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq) u32 intsize = 1, addrsize, newintsize = 0, newaddrsize = 0; int imaplen, match, i; - pr_debug("of_irq_parse_raw: par=%s,intspec=[0x%08x 0x%08x...],ointsize=%d\n", - of_node_full_name(out_irq->np), out_irq->args[0], out_irq->args[1], - out_irq->args_count); +#ifdef DEBUG + of_print_phandle_args("of_irq_parse_raw: ", out_irq); +#endif ipar = of_node_get(out_irq->np); diff --git a/include/linux/of.h b/include/linux/of.h index f95aee391e30..374e03536135 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -275,6 +275,7 @@ extern int of_n_size_cells(struct device_node *np); extern const struct of_device_id *of_match_node( const struct of_device_id *matches, const struct device_node *node); extern int of_modalias_node(struct device_node *node, char *modalias, int len); +extern void of_print_phandle_args(const char *msg, const struct of_phandle_args *args); extern struct device_node *of_parse_phandle(const struct device_node *np, const char *phandle_name, int index); -- cgit v1.2.3 From 16b84e5a505c790538e534ad8dfda9c288691e40 Mon Sep 17 00:00:00 2001 From: Grant Likely Date: Thu, 19 Sep 2013 16:44:55 -0500 Subject: of/irq: Create of_irq_parse_and_map_pci() to consolidate arch code. Several architectures open code effectively the same code block for finding and mapping PCI irqs. This patch consolidates it down to a single function. Signed-off-by: Grant Likely Acked-by: Michal Simek Cc: Russell King Cc: Ralf Baechle Cc: Benjamin Herrenschmidt --- arch/arm/mach-integrator/pci_v3.c | 17 +---------------- arch/mips/pci/fixup-lantiq.c | 12 +----------- arch/mips/pci/pci-rt3883.c | 22 +--------------------- arch/x86/kernel/devicetree.c | 7 +------ drivers/of/of_pci_irq.c | 25 +++++++++++++++++++++++++ drivers/pci/host/pci-mvebu.c | 14 +------------- include/linux/of_pci.h | 1 + 7 files changed, 31 insertions(+), 67 deletions(-) (limited to 'include') diff --git a/arch/arm/mach-integrator/pci_v3.c b/arch/arm/mach-integrator/pci_v3.c index bb3aeb31a54e..a87e510fe0c4 100644 --- a/arch/arm/mach-integrator/pci_v3.c +++ b/arch/arm/mach-integrator/pci_v3.c @@ -835,21 +835,6 @@ static struct hw_pci pci_v3 __initdata = { #ifdef CONFIG_OF -static int __init pci_v3_map_irq_dt(const struct pci_dev *dev, u8 slot, u8 pin) -{ - struct of_phandle_args oirq; - int ret; - - ret = of_irq_parse_pci(dev, &oirq); - if (ret) { - dev_err(&dev->dev, "of_irq_parse_pci() %d\n", ret); - /* Proper return code 0 == NO_IRQ */ - return 0; - } - - return irq_create_of_mapping(&oirq); -} - static int __init pci_v3_dtprobe(struct platform_device *pdev, struct device_node *np) { @@ -918,7 +903,7 @@ static int __init pci_v3_dtprobe(struct platform_device *pdev, return -EINVAL; } - pci_v3.map_irq = pci_v3_map_irq_dt; + pci_v3.map_irq = of_irq_parse_and_map_pci; pci_common_init_dev(&pdev->dev, &pci_v3); return 0; diff --git a/arch/mips/pci/fixup-lantiq.c b/arch/mips/pci/fixup-lantiq.c index aef60e75003e..c2ce41ea61d7 100644 --- a/arch/mips/pci/fixup-lantiq.c +++ b/arch/mips/pci/fixup-lantiq.c @@ -25,15 +25,5 @@ int pcibios_plat_dev_init(struct pci_dev *dev) int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) { - struct of_phandle_args dev_irq; - int irq; - - if (of_irq_parse_pci(dev, &dev_irq)) { - dev_err(&dev->dev, "trying to map irq for unknown slot:%d pin:%d\n", - slot, pin); - return 0; - } - irq = irq_create_of_mapping(&dev_irq); - dev_info(&dev->dev, "SLOT:%d PIN:%d IRQ:%d\n", slot, pin, irq); - return irq; + return of_irq_parse_and_map_pci(dev, slot, pin); } diff --git a/arch/mips/pci/pci-rt3883.c b/arch/mips/pci/pci-rt3883.c index eadc4310cd36..adeff2bfe4cd 100644 --- a/arch/mips/pci/pci-rt3883.c +++ b/arch/mips/pci/pci-rt3883.c @@ -583,27 +583,7 @@ err_put_intc_node: int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) { - struct of_phandle_args dev_irq; - int err; - int irq; - - err = of_irq_parse_pci(dev, &dev_irq); - if (err) { - pr_err("pci %s: unable to get irq map, err=%d\n", - pci_name((struct pci_dev *) dev), err); - return 0; - } - - irq = irq_create_of_mapping(&dev_irq); - - if (irq == 0) - pr_crit("pci %s: no irq found for pin %u\n", - pci_name((struct pci_dev *) dev), pin); - else - pr_info("pci %s: using irq %d for pin %u\n", - pci_name((struct pci_dev *) dev), irq, pin); - - return irq; + return of_irq_parse_and_map_pci(dev, slot, pin); } int pcibios_plat_dev_init(struct pci_dev *dev) diff --git a/arch/x86/kernel/devicetree.c b/arch/x86/kernel/devicetree.c index d39948f654a0..69c826a3d07e 100644 --- a/arch/x86/kernel/devicetree.c +++ b/arch/x86/kernel/devicetree.c @@ -105,7 +105,6 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus) static int x86_of_pci_irq_enable(struct pci_dev *dev) { - struct of_phandle_args oirq; u32 virq; int ret; u8 pin; @@ -116,11 +115,7 @@ static int x86_of_pci_irq_enable(struct pci_dev *dev) if (!pin) return 0; - ret = of_irq_parse_pci(dev, &oirq); - if (ret) - return ret; - - virq = irq_create_of_mapping(&oirq); + virq = of_irq_parse_and_map_pci(dev, 0, 0); if (virq == 0) return -EINVAL; dev->irq = virq; diff --git a/drivers/of/of_pci_irq.c b/drivers/of/of_pci_irq.c index 303afebc247a..8e92acd8253f 100644 --- a/drivers/of/of_pci_irq.c +++ b/drivers/of/of_pci_irq.c @@ -94,3 +94,28 @@ int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq return of_irq_parse_raw(laddr, out_irq); } EXPORT_SYMBOL_GPL(of_irq_parse_pci); + +/** + * of_irq_parse_and_map_pci() - Decode a PCI irq from the device tree and map to a virq + * @dev: The pci device needing an irq + * @slot: PCI slot number; passed when used as map_irq callback. Unused + * @pin: PCI irq pin number; passed when used as map_irq callback. Unused + * + * @slot and @pin are unused, but included in the function so that this + * function can be used directly as the map_irq callback to pci_fixup_irqs(). + */ +int of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin) +{ + struct of_phandle_args oirq; + int ret; + + ret = of_irq_parse_pci(dev, &oirq); + if (ret) { + dev_err(&dev->dev, "of_irq_parse_pci() failed with rc=%d\n", ret); + return 0; /* Proper return code 0 == NO_IRQ */ + } + + return irq_create_of_mapping(&oirq); +} +EXPORT_SYMBOL_GPL(of_irq_parse_and_map_pci); + diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c index 3a8d01ec50f7..07ddb3a13c6e 100644 --- a/drivers/pci/host/pci-mvebu.c +++ b/drivers/pci/host/pci-mvebu.c @@ -645,18 +645,6 @@ static int __init mvebu_pcie_setup(int nr, struct pci_sys_data *sys) return 1; } -static int __init mvebu_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) -{ - struct of_phandle_args oirq; - int ret; - - ret = of_irq_parse_pci(dev, &oirq); - if (ret) - return ret; - - return irq_create_of_mapping(&oirq); -} - static struct pci_bus *mvebu_pcie_scan_bus(int nr, struct pci_sys_data *sys) { struct mvebu_pcie *pcie = sys_to_pcie(sys); @@ -705,7 +693,7 @@ static void __init mvebu_pcie_enable(struct mvebu_pcie *pcie) hw.private_data = (void **)&pcie; hw.setup = mvebu_pcie_setup; hw.scan = mvebu_pcie_scan_bus; - hw.map_irq = mvebu_pcie_map_irq; + hw.map_irq = of_irq_parse_and_map_pci; hw.ops = &mvebu_pcie_ops; hw.align_resource = mvebu_pcie_align_resource; diff --git a/include/linux/of_pci.h b/include/linux/of_pci.h index f297237349e8..1a1f5ffd5288 100644 --- a/include/linux/of_pci.h +++ b/include/linux/of_pci.h @@ -7,6 +7,7 @@ struct pci_dev; struct of_phandle_args; int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq); +int of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin); struct device_node; struct device_node *of_pci_find_child_device(struct device_node *parent, -- cgit v1.2.3 From f6f0747e5bc69401d7f90313aa1b46709d27840a Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Mon, 28 Oct 2013 13:12:35 -0500 Subject: of: Add empty for_each_available_child_of_node() macro definition Add this empty macro definition so users can be compiled without excluding this macro call with preprocessor directives when CONFIG_OF is disabled. Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park Signed-off-by: Rob Herring --- include/linux/of.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/linux/of.h b/include/linux/of.h index 54017b83650b..b97f685c941f 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -366,6 +366,9 @@ static inline bool of_have_populated_dt(void) #define for_each_child_of_node(parent, child) \ while (0) +#define for_each_available_child_of_node(parent, child) \ + while (0) + static inline struct device_node *of_get_child_by_name( const struct device_node *node, const char *name) -- cgit v1.2.3 From a8d3f362f52b65207cacbfb4c50f75e9d4751ef6 Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Thu, 7 Nov 2013 12:13:27 -0600 Subject: dt/irq: add empty of_irq_count for !OF_IRQ Add an empty version of of_irq_count for !OF_IRQ. This fixes build error on sparc in linux-next: drivers/gpio/gpio-bcm-kona.c:542: undefined reference to `of_irq_count' Signed-off-by: Rob Herring --- include/linux/of_irq.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h index c0d6dfe80895..3f23b4472c31 100644 --- a/include/linux/of_irq.h +++ b/include/linux/of_irq.h @@ -37,12 +37,20 @@ extern int of_irq_parse_one(struct device_node *device, int index, extern unsigned int irq_create_of_mapping(struct of_phandle_args *irq_data); extern int of_irq_to_resource(struct device_node *dev, int index, struct resource *r); -extern int of_irq_count(struct device_node *dev); extern int of_irq_to_resource_table(struct device_node *dev, struct resource *res, int nr_irqs); extern void of_irq_init(const struct of_device_id *matches); +#ifdef CONFIG_OF_IRQ +extern int of_irq_count(struct device_node *dev); +#else +static inline int of_irq_count(struct device_node *dev) +{ + return 0; +} +#endif + #if defined(CONFIG_OF) /* * irq_of_parse_and_map() is used by all OF enabled platforms; but SPARC -- cgit v1.2.3