From 76c1ce7870fd9b05431da1bbd47fdafcc029a25b Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Tue, 1 May 2007 16:19:07 +1000 Subject: Split out common parts of prom.h This creates linux/of.h and includes asm/prom.h from it. We also include linux/of.h from asm/prom.h while we transition. Signed-off-by: Stephen Rothwell Acked-by: Paul Mackerras Acked-by: David S. Miller --- include/asm-sparc/prom.h | 46 ++++++---------------------------------------- 1 file changed, 6 insertions(+), 40 deletions(-) (limited to 'include/asm-sparc') diff --git a/include/asm-sparc/prom.h b/include/asm-sparc/prom.h index 9ea105ebe2ff..d67af08abb43 100644 --- a/include/asm-sparc/prom.h +++ b/include/asm-sparc/prom.h @@ -2,7 +2,6 @@ #define _SPARC_PROM_H #ifdef __KERNEL__ - /* * Definitions for talking to the Open Firmware PROM on * Power Macintosh computers. @@ -17,7 +16,6 @@ * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. */ - #include #include #include @@ -55,53 +53,21 @@ struct device_node { unsigned int unique_id; }; -/* flag descriptions */ -#define OF_DYNAMIC 1 /* node and properties were allocated via kmalloc */ - #define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags) #define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags) -#define OF_BAD_ADDR ((u64)-1) - -static inline void set_node_proc_entry(struct device_node *dn, struct proc_dir_entry *de) -{ - dn->pde = de; -} - -extern struct device_node *of_find_node_by_name(struct device_node *from, - const char *name); -#define for_each_node_by_name(dn, name) \ - for (dn = of_find_node_by_name(NULL, name); dn; \ - dn = of_find_node_by_name(dn, name)) -extern struct device_node *of_find_node_by_type(struct device_node *from, - const char *type); -#define for_each_node_by_type(dn, type) \ - for (dn = of_find_node_by_type(NULL, type); dn; \ - dn = of_find_node_by_type(dn, type)) -extern struct device_node *of_find_compatible_node(struct device_node *from, - const char *type, const char *compat); -extern struct device_node *of_find_node_by_path(const char *path); -extern struct device_node *of_find_node_by_phandle(phandle handle); -extern struct device_node *of_get_parent(const struct device_node *node); -extern struct device_node *of_get_next_child(const struct device_node *node, - struct device_node *prev); -extern struct property *of_find_property(const struct device_node *np, - const char *name, - int *lenp); -extern int of_device_is_compatible(const struct device_node *device, - const char *); -extern const void *of_get_property(const struct device_node *node, - const char *name, - int *lenp); -#define get_property(node,name,lenp) of_get_property(node,name,lenp) extern int of_set_property(struct device_node *node, const char *name, void *val, int len); extern int of_getintprop_default(struct device_node *np, const char *name, int def); -extern int of_n_addr_cells(struct device_node *np); -extern int of_n_size_cells(struct device_node *np); extern void prom_build_devicetree(void); +/* + * NB: This is here while we transition from using asm/prom.h + * to linux/of.h + */ +#include + #endif /* __KERNEL__ */ #endif /* _SPARC_PROM_H */ -- cgit v1.2.3 From 97e873e5c8ad8711ce4cca080cff4eb5d21b3aeb Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Tue, 1 May 2007 16:26:07 +1000 Subject: Start split out of common open firmware code This creates drivers/of/base.c (depending on CONFIG_OF) and puts the first trivially common bits from the prom.c files into it. Signed-off-by: Stephen Rothwell Acked-by: Paul Mackerras Acked-by: David S. Miller --- arch/powerpc/Kconfig | 3 +++ arch/powerpc/kernel/prom.c | 41 ----------------------------- arch/sparc/Kconfig | 3 +++ arch/sparc/kernel/prom.c | 42 ------------------------------ arch/sparc64/Kconfig | 3 +++ arch/sparc64/kernel/prom.c | 42 ------------------------------ drivers/Makefile | 1 + drivers/of/Makefile | 1 + drivers/of/base.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++ include/asm-powerpc/prom.h | 3 +++ include/asm-sparc/prom.h | 3 +++ include/asm-sparc64/prom.h | 3 +++ 12 files changed, 85 insertions(+), 125 deletions(-) create mode 100644 drivers/of/Makefile create mode 100644 drivers/of/base.c (limited to 'include/asm-sparc') diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index d860b640a140..853c282da22e 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -92,6 +92,9 @@ config ARCH_MAY_HAVE_PC_FDC config PPC_OF def_bool y +config OF + def_bool y + config PPC_UDBG_16550 bool default n diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c index 37ff99bd98b4..6c9419a4d70a 100644 --- a/arch/powerpc/kernel/prom.c +++ b/arch/powerpc/kernel/prom.c @@ -1056,35 +1056,6 @@ void __init early_init_devtree(void *params) DBG(" <- early_init_devtree()\n"); } -int of_n_addr_cells(struct device_node* np) -{ - const int *ip; - do { - if (np->parent) - np = np->parent; - ip = of_get_property(np, "#address-cells", NULL); - if (ip != NULL) - return *ip; - } while (np->parent); - /* No #address-cells property for the root node, default to 1 */ - return 1; -} -EXPORT_SYMBOL(of_n_addr_cells); - -int of_n_size_cells(struct device_node* np) -{ - const int* ip; - do { - if (np->parent) - np = np->parent; - ip = of_get_property(np, "#size-cells", NULL); - if (ip != NULL) - return *ip; - } while (np->parent); - /* No #size-cells property for the root node, default to 1 */ - return 1; -} -EXPORT_SYMBOL(of_n_size_cells); /** Checks if the given "compat" string matches one of the strings in * the device's "compatible" property @@ -1562,18 +1533,6 @@ struct property *of_find_property(const struct device_node *np, } EXPORT_SYMBOL(of_find_property); -/* - * Find a property with a given name for a given node - * and return the value. - */ -const void *of_get_property(const struct device_node *np, const char *name, - int *lenp) -{ - struct property *pp = of_find_property(np,name,lenp); - return pp ? pp->value : NULL; -} -EXPORT_SYMBOL(of_get_property); - /* * Add a property to a node */ diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig index 603d83ad65c8..9d327ec59759 100644 --- a/arch/sparc/Kconfig +++ b/arch/sparc/Kconfig @@ -24,6 +24,9 @@ config GENERIC_ISA_DMA config ARCH_NO_VIRT_TO_BUS def_bool y +config OF + def_bool y + source "init/Kconfig" menu "General machine setup" diff --git a/arch/sparc/kernel/prom.c b/arch/sparc/kernel/prom.c index eed140b3c739..ac3f3c29b174 100644 --- a/arch/sparc/kernel/prom.c +++ b/arch/sparc/kernel/prom.c @@ -168,18 +168,6 @@ struct property *of_find_property(const struct device_node *np, } EXPORT_SYMBOL(of_find_property); -/* - * Find a property with a given name for a given node - * and return the value. - */ -const void *of_get_property(const struct device_node *np, const char *name, - int *lenp) -{ - struct property *pp = of_find_property(np,name,lenp); - return pp ? pp->value : NULL; -} -EXPORT_SYMBOL(of_get_property); - int of_getintprop_default(struct device_node *np, const char *name, int def) { struct property *prop; @@ -193,36 +181,6 @@ int of_getintprop_default(struct device_node *np, const char *name, int def) } EXPORT_SYMBOL(of_getintprop_default); -int of_n_addr_cells(struct device_node *np) -{ - const int* ip; - do { - if (np->parent) - np = np->parent; - ip = of_get_property(np, "#address-cells", NULL); - if (ip != NULL) - return *ip; - } while (np->parent); - /* No #address-cells property for the root node, default to 2 */ - return 2; -} -EXPORT_SYMBOL(of_n_addr_cells); - -int of_n_size_cells(struct device_node *np) -{ - const int* ip; - do { - if (np->parent) - np = np->parent; - ip = of_get_property(np, "#size-cells", NULL); - if (ip != NULL) - return *ip; - } while (np->parent); - /* No #size-cells property for the root node, default to 1 */ - return 1; -} -EXPORT_SYMBOL(of_n_size_cells); - int of_set_property(struct device_node *dp, const char *name, void *val, int len) { struct property **prevp; diff --git a/arch/sparc64/Kconfig b/arch/sparc64/Kconfig index df6ee71894d1..f1cc55677ff2 100644 --- a/arch/sparc64/Kconfig +++ b/arch/sparc64/Kconfig @@ -65,6 +65,9 @@ config AUDIT_ARCH config ARCH_NO_VIRT_TO_BUS def_bool y +config OF + def_bool y + choice prompt "Kernel page size" default SPARC64_PAGE_SIZE_8KB diff --git a/arch/sparc64/kernel/prom.c b/arch/sparc64/kernel/prom.c index 5d220302cd50..8f926d439c0f 100644 --- a/arch/sparc64/kernel/prom.c +++ b/arch/sparc64/kernel/prom.c @@ -173,18 +173,6 @@ struct property *of_find_property(const struct device_node *np, } EXPORT_SYMBOL(of_find_property); -/* - * Find a property with a given name for a given node - * and return the value. - */ -const void *of_get_property(const struct device_node *np, const char *name, - int *lenp) -{ - struct property *pp = of_find_property(np,name,lenp); - return pp ? pp->value : NULL; -} -EXPORT_SYMBOL(of_get_property); - int of_getintprop_default(struct device_node *np, const char *name, int def) { struct property *prop; @@ -198,36 +186,6 @@ int of_getintprop_default(struct device_node *np, const char *name, int def) } EXPORT_SYMBOL(of_getintprop_default); -int of_n_addr_cells(struct device_node *np) -{ - const int* ip; - do { - if (np->parent) - np = np->parent; - ip = of_get_property(np, "#address-cells", NULL); - if (ip != NULL) - return *ip; - } while (np->parent); - /* No #address-cells property for the root node, default to 2 */ - return 2; -} -EXPORT_SYMBOL(of_n_addr_cells); - -int of_n_size_cells(struct device_node *np) -{ - const int* ip; - do { - if (np->parent) - np = np->parent; - ip = of_get_property(np, "#size-cells", NULL); - if (ip != NULL) - return *ip; - } while (np->parent); - /* No #size-cells property for the root node, default to 1 */ - return 1; -} -EXPORT_SYMBOL(of_n_size_cells); - int of_set_property(struct device_node *dp, const char *name, void *val, int len) { struct property **prevp; diff --git a/drivers/Makefile b/drivers/Makefile index 0ea8e3237c0d..a9e4c5f922a0 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -86,3 +86,4 @@ obj-$(CONFIG_GENERIC_TIME) += clocksource/ obj-$(CONFIG_DMA_ENGINE) += dma/ obj-$(CONFIG_HID) += hid/ obj-$(CONFIG_PPC_PS3) += ps3/ +obj-$(CONFIG_OF) += of/ diff --git a/drivers/of/Makefile b/drivers/of/Makefile new file mode 100644 index 000000000000..cddbe840e30a --- /dev/null +++ b/drivers/of/Makefile @@ -0,0 +1 @@ +obj-y = base.o diff --git a/drivers/of/base.c b/drivers/of/base.c new file mode 100644 index 000000000000..723d80d704e0 --- /dev/null +++ b/drivers/of/base.c @@ -0,0 +1,65 @@ +/* + * Procedures for creating, accessing and interpreting the device tree. + * + * Paul Mackerras August 1996. + * Copyright (C) 1996-2005 Paul Mackerras. + * + * Adapted for 64bit PowerPC by Dave Engebretsen and Peter Bergner. + * {engebret|bergner}@us.ibm.com + * + * Adapted for sparc and sparc64 by David S. Miller davem@davemloft.net + * + * Reconsolidated from arch/x/kernel/prom.c by Stephen Rothwell. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + */ +#include +#include + +int of_n_addr_cells(struct device_node *np) +{ + const int *ip; + + do { + if (np->parent) + np = np->parent; + ip = of_get_property(np, "#address-cells", NULL); + if (ip) + return *ip; + } while (np->parent); + /* No #address-cells property for the root node */ + return OF_ROOT_NODE_ADDR_CELLS_DEFAULT; +} +EXPORT_SYMBOL(of_n_addr_cells); + +int of_n_size_cells(struct device_node *np) +{ + const int *ip; + + do { + if (np->parent) + np = np->parent; + ip = of_get_property(np, "#size-cells", NULL); + if (ip) + return *ip; + } while (np->parent); + /* No #size-cells property for the root node */ + return OF_ROOT_NODE_SIZE_CELLS_DEFAULT; +} +EXPORT_SYMBOL(of_n_size_cells); + +/* + * Find a property with a given name for a given node + * and return the value. + */ +const void *of_get_property(const struct device_node *np, const char *name, + int *lenp) +{ + struct property *pp = of_find_property(np, name, lenp); + + return pp ? pp->value : NULL; +} +EXPORT_SYMBOL(of_get_property); diff --git a/include/asm-powerpc/prom.h b/include/asm-powerpc/prom.h index 1134aeab2327..9fe0152ae245 100644 --- a/include/asm-powerpc/prom.h +++ b/include/asm-powerpc/prom.h @@ -21,6 +21,9 @@ #include #include +#define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 1 +#define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1 + /* Definitions used by the flattened device tree */ #define OF_DT_HEADER 0xd00dfeed /* marker */ #define OF_DT_BEGIN_NODE 0x1 /* Start of node, full name */ diff --git a/include/asm-sparc/prom.h b/include/asm-sparc/prom.h index d67af08abb43..a8a121f6332b 100644 --- a/include/asm-sparc/prom.h +++ b/include/asm-sparc/prom.h @@ -20,6 +20,9 @@ #include #include +#define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 2 +#define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1 + typedef u32 phandle; typedef u32 ihandle; diff --git a/include/asm-sparc64/prom.h b/include/asm-sparc64/prom.h index 9905ed057d93..c98d1545ee8d 100644 --- a/include/asm-sparc64/prom.h +++ b/include/asm-sparc64/prom.h @@ -20,6 +20,9 @@ #include #include +#define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 2 +#define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1 + typedef u32 phandle; typedef u32 ihandle; -- cgit v1.2.3 From 0081cbc3731de8ad4744ba433af51f17bf27eb9c Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Tue, 1 May 2007 16:29:19 +1000 Subject: Consolidate of_device_is_compatible The only difference here is that Sparc uses strncmp to match compatibility names while PowerPC uses strncasecmp. Signed-off-by: Stephen Rothwell Acked-by: Paul Mackerras Acked-by: David S. Miller --- arch/powerpc/kernel/prom.c | 25 ------------------------- arch/sparc/kernel/prom.c | 21 --------------------- arch/sparc64/kernel/prom.c | 21 --------------------- drivers/of/base.c | 24 ++++++++++++++++++++++++ include/asm-powerpc/prom.h | 2 ++ include/asm-sparc/prom.h | 2 ++ include/asm-sparc64/prom.h | 2 ++ 7 files changed, 30 insertions(+), 67 deletions(-) (limited to 'include/asm-sparc') diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c index 6c9419a4d70a..c009d2155f9c 100644 --- a/arch/powerpc/kernel/prom.c +++ b/arch/powerpc/kernel/prom.c @@ -1057,31 +1057,6 @@ void __init early_init_devtree(void *params) } -/** Checks if the given "compat" string matches one of the strings in - * the device's "compatible" property - */ -int of_device_is_compatible(const struct device_node *device, - const char *compat) -{ - const char* cp; - int cplen, l; - - cp = of_get_property(device, "compatible", &cplen); - if (cp == NULL) - return 0; - while (cplen > 0) { - if (strncasecmp(cp, compat, strlen(compat)) == 0) - return 1; - l = strlen(cp) + 1; - cp += l; - cplen -= l; - } - - return 0; -} -EXPORT_SYMBOL(of_device_is_compatible); - - /** * Indicates whether the root node has a given value in its * compatible property. diff --git a/arch/sparc/kernel/prom.c b/arch/sparc/kernel/prom.c index ac3f3c29b174..f2ce0d48e102 100644 --- a/arch/sparc/kernel/prom.c +++ b/arch/sparc/kernel/prom.c @@ -32,27 +32,6 @@ static struct device_node *allnodes; */ static DEFINE_RWLOCK(devtree_lock); -int of_device_is_compatible(const struct device_node *device, - const char *compat) -{ - const char* cp; - int cplen, l; - - cp = of_get_property(device, "compatible", &cplen); - if (cp == NULL) - return 0; - while (cplen > 0) { - if (strncmp(cp, compat, strlen(compat)) == 0) - return 1; - l = strlen(cp) + 1; - cp += l; - cplen -= l; - } - - return 0; -} -EXPORT_SYMBOL(of_device_is_compatible); - struct device_node *of_get_parent(const struct device_node *node) { struct device_node *np; diff --git a/arch/sparc64/kernel/prom.c b/arch/sparc64/kernel/prom.c index 8f926d439c0f..4d6fb07f047f 100644 --- a/arch/sparc64/kernel/prom.c +++ b/arch/sparc64/kernel/prom.c @@ -37,27 +37,6 @@ static struct device_node *allnodes; */ static DEFINE_RWLOCK(devtree_lock); -int of_device_is_compatible(const struct device_node *device, - const char *compat) -{ - const char* cp; - int cplen, l; - - cp = of_get_property(device, "compatible", &cplen); - if (cp == NULL) - return 0; - while (cplen > 0) { - if (strncmp(cp, compat, strlen(compat)) == 0) - return 1; - l = strlen(cp) + 1; - cp += l; - cplen -= l; - } - - return 0; -} -EXPORT_SYMBOL(of_device_is_compatible); - struct device_node *of_get_parent(const struct device_node *node) { struct device_node *np; diff --git a/drivers/of/base.c b/drivers/of/base.c index 723d80d704e0..d6dc5e74c27c 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -63,3 +63,27 @@ const void *of_get_property(const struct device_node *np, const char *name, return pp ? pp->value : NULL; } EXPORT_SYMBOL(of_get_property); + +/** Checks if the given "compat" string matches one of the strings in + * the device's "compatible" property + */ +int of_device_is_compatible(const struct device_node *device, + const char *compat) +{ + const char* cp; + int cplen, l; + + cp = of_get_property(device, "compatible", &cplen); + if (cp == NULL) + return 0; + while (cplen > 0) { + if (of_compat_cmp(cp, compat, strlen(compat)) == 0) + return 1; + l = strlen(cp) + 1; + cp += l; + cplen -= l; + } + + return 0; +} +EXPORT_SYMBOL(of_device_is_compatible); diff --git a/include/asm-powerpc/prom.h b/include/asm-powerpc/prom.h index 9fe0152ae245..b05f8f26940a 100644 --- a/include/asm-powerpc/prom.h +++ b/include/asm-powerpc/prom.h @@ -24,6 +24,8 @@ #define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 1 #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1 +#define of_compat_cmp(s1, s2, l) strncasecmp((s1), (s2), (l)) + /* Definitions used by the flattened device tree */ #define OF_DT_HEADER 0xd00dfeed /* marker */ #define OF_DT_BEGIN_NODE 0x1 /* Start of node, full name */ diff --git a/include/asm-sparc/prom.h b/include/asm-sparc/prom.h index a8a121f6332b..c755c69404f7 100644 --- a/include/asm-sparc/prom.h +++ b/include/asm-sparc/prom.h @@ -23,6 +23,8 @@ #define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 2 #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1 +#define of_compat_cmp(s1, s2, l) strncmp((s1), (s2), (l)) + typedef u32 phandle; typedef u32 ihandle; diff --git a/include/asm-sparc64/prom.h b/include/asm-sparc64/prom.h index c98d1545ee8d..040d198ee842 100644 --- a/include/asm-sparc64/prom.h +++ b/include/asm-sparc64/prom.h @@ -23,6 +23,8 @@ #define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 2 #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1 +#define of_compat_cmp(s1, s2, l) strncmp((s1), (s2), (l)) + typedef u32 phandle; typedef u32 ihandle; -- cgit v1.2.3 From 581b605a83ec241a2aff8ef780e08b9414c8dfd8 Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Tue, 24 Apr 2007 16:46:53 +1000 Subject: Consolidate of_find_property The only change here is that a readlock is taken while the property list is being traversed on Sparc where it was not taken previously. Also, Sparc uses strcasecmp to compare property names while PowerPC uses strcmp. Signed-off-by: Stephen Rothwell Acked-by: Paul Mackerras Acked-by: David S. Miller --- arch/powerpc/kernel/prom.c | 24 +----------------------- arch/sparc/kernel/prom.c | 22 +--------------------- arch/sparc64/kernel/prom.c | 22 +--------------------- drivers/of/base.c | 26 ++++++++++++++++++++++++++ include/asm-powerpc/prom.h | 1 + include/asm-sparc/prom.h | 1 + include/asm-sparc64/prom.h | 1 + 7 files changed, 32 insertions(+), 65 deletions(-) (limited to 'include/asm-sparc') diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c index c009d2155f9c..3f6238d96a5d 100644 --- a/arch/powerpc/kernel/prom.c +++ b/arch/powerpc/kernel/prom.c @@ -80,10 +80,7 @@ struct boot_param_header *initial_boot_params; static struct device_node *allnodes = NULL; -/* use when traversing tree through the allnext, child, sibling, - * or parent members of struct device_node. - */ -static DEFINE_RWLOCK(devtree_lock); +extern rwlock_t devtree_lock; /* temporary while merging */ /* export that to outside world */ struct device_node *of_chosen; @@ -1489,25 +1486,6 @@ static int __init prom_reconfig_setup(void) __initcall(prom_reconfig_setup); #endif -struct property *of_find_property(const struct device_node *np, - const char *name, - int *lenp) -{ - struct property *pp; - - read_lock(&devtree_lock); - for (pp = np->properties; pp != 0; pp = pp->next) - if (strcmp(pp->name, name) == 0) { - if (lenp != 0) - *lenp = pp->length; - break; - } - read_unlock(&devtree_lock); - - return pp; -} -EXPORT_SYMBOL(of_find_property); - /* * Add a property to a node */ diff --git a/arch/sparc/kernel/prom.c b/arch/sparc/kernel/prom.c index f2ce0d48e102..0f5aab4326b3 100644 --- a/arch/sparc/kernel/prom.c +++ b/arch/sparc/kernel/prom.c @@ -27,10 +27,7 @@ static struct device_node *allnodes; -/* use when traversing tree through the allnext, child, sibling, - * or parent members of struct device_node. - */ -static DEFINE_RWLOCK(devtree_lock); +extern rwlock_t devtree_lock; /* temporary while merging */ struct device_node *of_get_parent(const struct device_node *node) { @@ -130,23 +127,6 @@ struct device_node *of_find_compatible_node(struct device_node *from, } EXPORT_SYMBOL(of_find_compatible_node); -struct property *of_find_property(const struct device_node *np, - const char *name, - int *lenp) -{ - struct property *pp; - - for (pp = np->properties; pp != 0; pp = pp->next) { - if (strcasecmp(pp->name, name) == 0) { - if (lenp != 0) - *lenp = pp->length; - break; - } - } - return pp; -} -EXPORT_SYMBOL(of_find_property); - int of_getintprop_default(struct device_node *np, const char *name, int def) { struct property *prop; diff --git a/arch/sparc64/kernel/prom.c b/arch/sparc64/kernel/prom.c index 4d6fb07f047f..a1ccc00c7958 100644 --- a/arch/sparc64/kernel/prom.c +++ b/arch/sparc64/kernel/prom.c @@ -32,10 +32,7 @@ static struct device_node *allnodes; -/* use when traversing tree through the allnext, child, sibling, - * or parent members of struct device_node. - */ -static DEFINE_RWLOCK(devtree_lock); +extern rwlock_t devtree_lock; /* temporary while merging */ struct device_node *of_get_parent(const struct device_node *node) { @@ -135,23 +132,6 @@ struct device_node *of_find_compatible_node(struct device_node *from, } EXPORT_SYMBOL(of_find_compatible_node); -struct property *of_find_property(const struct device_node *np, - const char *name, - int *lenp) -{ - struct property *pp; - - for (pp = np->properties; pp != 0; pp = pp->next) { - if (strcasecmp(pp->name, name) == 0) { - if (lenp != 0) - *lenp = pp->length; - break; - } - } - return pp; -} -EXPORT_SYMBOL(of_find_property); - int of_getintprop_default(struct device_node *np, const char *name, int def) { struct property *prop; diff --git a/drivers/of/base.c b/drivers/of/base.c index d6dc5e74c27c..70b60845140e 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -18,6 +18,12 @@ */ #include #include +#include + +/* use when traversing tree through the allnext, child, sibling, + * or parent members of struct device_node. + */ +DEFINE_RWLOCK(devtree_lock); int of_n_addr_cells(struct device_node *np) { @@ -51,6 +57,26 @@ int of_n_size_cells(struct device_node *np) } EXPORT_SYMBOL(of_n_size_cells); +struct property *of_find_property(const struct device_node *np, + const char *name, + int *lenp) +{ + struct property *pp; + + read_lock(&devtree_lock); + for (pp = np->properties; pp != 0; pp = pp->next) { + if (of_prop_cmp(pp->name, name) == 0) { + if (lenp != 0) + *lenp = pp->length; + break; + } + } + read_unlock(&devtree_lock); + + return pp; +} +EXPORT_SYMBOL(of_find_property); + /* * Find a property with a given name for a given node * and return the value. diff --git a/include/asm-powerpc/prom.h b/include/asm-powerpc/prom.h index b05f8f26940a..75b1144ca580 100644 --- a/include/asm-powerpc/prom.h +++ b/include/asm-powerpc/prom.h @@ -25,6 +25,7 @@ #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1 #define of_compat_cmp(s1, s2, l) strncasecmp((s1), (s2), (l)) +#define of_prop_cmp(s1, s2) strcmp((s1), (s2)) /* Definitions used by the flattened device tree */ #define OF_DT_HEADER 0xd00dfeed /* marker */ diff --git a/include/asm-sparc/prom.h b/include/asm-sparc/prom.h index c755c69404f7..57f86c84293b 100644 --- a/include/asm-sparc/prom.h +++ b/include/asm-sparc/prom.h @@ -24,6 +24,7 @@ #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1 #define of_compat_cmp(s1, s2, l) strncmp((s1), (s2), (l)) +#define of_prop_cmp(s1, s2) strcasecmp((s1), (s2)) typedef u32 phandle; typedef u32 ihandle; diff --git a/include/asm-sparc64/prom.h b/include/asm-sparc64/prom.h index 040d198ee842..6a5e2405cbf4 100644 --- a/include/asm-sparc64/prom.h +++ b/include/asm-sparc64/prom.h @@ -24,6 +24,7 @@ #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1 #define of_compat_cmp(s1, s2, l) strncmp((s1), (s2), (l)) +#define of_prop_cmp(s1, s2) strcasecmp((s1), (s2)) typedef u32 phandle; typedef u32 ihandle; -- cgit v1.2.3 From e679c5f445fe142940e0962de9c5c82f10d9357c Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Tue, 24 Apr 2007 17:16:16 +1000 Subject: Consolidate of_get_parent This requires creating dummy of_node_{get,put} routines for sparc and sparc64. It also adds a read_lock around the parent accesses. Signed-off-by: Stephen Rothwell Acked-by: Paul Mackerras Acked-by: David S. Miller --- arch/powerpc/kernel/prom.c | 21 --------------------- arch/sparc/kernel/prom.c | 13 ------------- arch/sparc64/kernel/prom.c | 13 ------------- drivers/of/base.c | 21 +++++++++++++++++++++ include/asm-sparc/prom.h | 9 +++++++++ include/asm-sparc64/prom.h | 9 +++++++++ 6 files changed, 39 insertions(+), 47 deletions(-) (limited to 'include/asm-sparc') diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c index 3f6238d96a5d..1ad56d3c6061 100644 --- a/arch/powerpc/kernel/prom.c +++ b/arch/powerpc/kernel/prom.c @@ -1240,27 +1240,6 @@ struct device_node *of_find_all_nodes(struct device_node *prev) } EXPORT_SYMBOL(of_find_all_nodes); -/** - * of_get_parent - Get a node's parent if any - * @node: Node to get parent - * - * Returns a node pointer with refcount incremented, use - * of_node_put() on it when done. - */ -struct device_node *of_get_parent(const struct device_node *node) -{ - struct device_node *np; - - if (!node) - return NULL; - - read_lock(&devtree_lock); - np = of_node_get(node->parent); - read_unlock(&devtree_lock); - return np; -} -EXPORT_SYMBOL(of_get_parent); - /** * of_get_next_child - Iterate a node childs * @node: parent node diff --git a/arch/sparc/kernel/prom.c b/arch/sparc/kernel/prom.c index 0f5aab4326b3..b37871578087 100644 --- a/arch/sparc/kernel/prom.c +++ b/arch/sparc/kernel/prom.c @@ -29,19 +29,6 @@ static struct device_node *allnodes; extern rwlock_t devtree_lock; /* temporary while merging */ -struct device_node *of_get_parent(const struct device_node *node) -{ - struct device_node *np; - - if (!node) - return NULL; - - np = node->parent; - - return np; -} -EXPORT_SYMBOL(of_get_parent); - struct device_node *of_get_next_child(const struct device_node *node, struct device_node *prev) { diff --git a/arch/sparc64/kernel/prom.c b/arch/sparc64/kernel/prom.c index a1ccc00c7958..2462731ac1a3 100644 --- a/arch/sparc64/kernel/prom.c +++ b/arch/sparc64/kernel/prom.c @@ -34,19 +34,6 @@ static struct device_node *allnodes; extern rwlock_t devtree_lock; /* temporary while merging */ -struct device_node *of_get_parent(const struct device_node *node) -{ - struct device_node *np; - - if (!node) - return NULL; - - np = node->parent; - - return np; -} -EXPORT_SYMBOL(of_get_parent); - struct device_node *of_get_next_child(const struct device_node *node, struct device_node *prev) { diff --git a/drivers/of/base.c b/drivers/of/base.c index 70b60845140e..82bb78680ff6 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -113,3 +113,24 @@ int of_device_is_compatible(const struct device_node *device, return 0; } EXPORT_SYMBOL(of_device_is_compatible); + +/** + * of_get_parent - Get a node's parent if any + * @node: Node to get parent + * + * Returns a node pointer with refcount incremented, use + * of_node_put() on it when done. + */ +struct device_node *of_get_parent(const struct device_node *node) +{ + struct device_node *np; + + if (!node) + return NULL; + + read_lock(&devtree_lock); + np = of_node_get(node->parent); + read_unlock(&devtree_lock); + return np; +} +EXPORT_SYMBOL(of_get_parent); diff --git a/include/asm-sparc/prom.h b/include/asm-sparc/prom.h index 57f86c84293b..c7d54958a90e 100644 --- a/include/asm-sparc/prom.h +++ b/include/asm-sparc/prom.h @@ -69,6 +69,15 @@ extern int of_getintprop_default(struct device_node *np, extern void prom_build_devicetree(void); +/* Dummy ref counting routines - to be implemented later */ +static inline struct device_node *of_node_get(struct device_node *node) +{ + return node; +} +static inline void of_node_put(struct device_node *node) +{ +} + /* * NB: This is here while we transition from using asm/prom.h * to linux/of.h diff --git a/include/asm-sparc64/prom.h b/include/asm-sparc64/prom.h index 6a5e2405cbf4..e83896f3c141 100644 --- a/include/asm-sparc64/prom.h +++ b/include/asm-sparc64/prom.h @@ -78,6 +78,15 @@ extern int of_getintprop_default(struct device_node *np, extern void prom_build_devicetree(void); +/* Dummy ref counting routines - to be implemented later */ +static inline struct device_node *of_node_get(struct device_node *node) +{ + return node; +} +static inline void of_node_put(struct device_node *node) +{ +} + /* * NB: This is here while we transition from using asm/prom.h * to linux/of.h -- cgit v1.2.3 From 1ef4d4242d9c494c49ae1ae66dc938fce0272816 Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Tue, 24 Apr 2007 17:57:33 +1000 Subject: Consolidate of_find_node_by routines This consolidates the routines of_find_node_by_path, of_find_node_by_name, of_find_node_by_type and of_find_compatible_device. Again, the comparison of strings are done differently by Sparc and PowerPC and also these add read_locks around the iterations. Signed-off-by: Stephen Rothwell Acked-by: Paul Mackerras Acked-by: David S. Miller --- arch/powerpc/kernel/prom.c | 115 +-------------------------------------------- arch/sparc/kernel/prom.c | 61 +----------------------- arch/sparc64/kernel/prom.c | 61 +----------------------- drivers/of/base.c | 115 +++++++++++++++++++++++++++++++++++++++++++++ include/asm-powerpc/prom.h | 1 + include/asm-sparc/prom.h | 1 + include/asm-sparc64/prom.h | 1 + 7 files changed, 121 insertions(+), 234 deletions(-) (limited to 'include/asm-sparc') diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c index 5fa221ce8714..bdcd23d8d8b9 100644 --- a/arch/powerpc/kernel/prom.c +++ b/arch/powerpc/kernel/prom.c @@ -78,7 +78,7 @@ static struct boot_param_header *initial_boot_params __initdata; struct boot_param_header *initial_boot_params; #endif -static struct device_node *allnodes = NULL; +extern struct device_node *allnodes; /* temporary while merging */ extern rwlock_t devtree_lock; /* temporary while merging */ @@ -1083,119 +1083,6 @@ EXPORT_SYMBOL(machine_is_compatible); * *******/ -/** - * of_find_node_by_name - Find a node by its "name" property - * @from: The node to start searching from or NULL, the node - * you pass will not be searched, only the next one - * will; typically, you pass what the previous call - * returned. of_node_put() will be called on it - * @name: The name string to match against - * - * Returns a node pointer with refcount incremented, use - * of_node_put() on it when done. - */ -struct device_node *of_find_node_by_name(struct device_node *from, - const char *name) -{ - struct device_node *np; - - read_lock(&devtree_lock); - np = from ? from->allnext : allnodes; - for (; np != NULL; np = np->allnext) - if (np->name != NULL && strcasecmp(np->name, name) == 0 - && of_node_get(np)) - break; - of_node_put(from); - read_unlock(&devtree_lock); - return np; -} -EXPORT_SYMBOL(of_find_node_by_name); - -/** - * of_find_node_by_type - Find a node by its "device_type" property - * @from: The node to start searching from, or NULL to start searching - * the entire device tree. The node you pass will not be - * searched, only the next one will; typically, you pass - * what the previous call returned. of_node_put() will be - * called on from for you. - * @type: The type string to match against - * - * Returns a node pointer with refcount incremented, use - * of_node_put() on it when done. - */ -struct device_node *of_find_node_by_type(struct device_node *from, - const char *type) -{ - struct device_node *np; - - read_lock(&devtree_lock); - np = from ? from->allnext : allnodes; - for (; np != 0; np = np->allnext) - if (np->type != 0 && strcasecmp(np->type, type) == 0 - && of_node_get(np)) - break; - of_node_put(from); - read_unlock(&devtree_lock); - return np; -} -EXPORT_SYMBOL(of_find_node_by_type); - -/** - * of_find_compatible_node - Find a node based on type and one of the - * tokens in its "compatible" property - * @from: The node to start searching from or NULL, the node - * you pass will not be searched, only the next one - * will; typically, you pass what the previous call - * returned. of_node_put() will be called on it - * @type: The type string to match "device_type" or NULL to ignore - * @compatible: The string to match to one of the tokens in the device - * "compatible" list. - * - * Returns a node pointer with refcount incremented, use - * of_node_put() on it when done. - */ -struct device_node *of_find_compatible_node(struct device_node *from, - const char *type, const char *compatible) -{ - struct device_node *np; - - read_lock(&devtree_lock); - np = from ? from->allnext : allnodes; - for (; np != 0; np = np->allnext) { - if (type != NULL - && !(np->type != 0 && strcasecmp(np->type, type) == 0)) - continue; - if (of_device_is_compatible(np, compatible) && of_node_get(np)) - break; - } - of_node_put(from); - read_unlock(&devtree_lock); - return np; -} -EXPORT_SYMBOL(of_find_compatible_node); - -/** - * of_find_node_by_path - Find a node matching a full OF path - * @path: The full path to match - * - * Returns a node pointer with refcount incremented, use - * of_node_put() on it when done. - */ -struct device_node *of_find_node_by_path(const char *path) -{ - struct device_node *np = allnodes; - - read_lock(&devtree_lock); - for (; np != 0; np = np->allnext) { - if (np->full_name != 0 && strcasecmp(np->full_name, path) == 0 - && of_node_get(np)) - break; - } - read_unlock(&devtree_lock); - return np; -} -EXPORT_SYMBOL(of_find_node_by_path); - /** * of_find_node_by_phandle - Find a node given a phandle * @handle: phandle of the node to find diff --git a/arch/sparc/kernel/prom.c b/arch/sparc/kernel/prom.c index 3f8ccfad2e01..012f98346bcd 100644 --- a/arch/sparc/kernel/prom.c +++ b/arch/sparc/kernel/prom.c @@ -25,23 +25,10 @@ #include #include -static struct device_node *allnodes; +extern struct device_node *allnodes; /* temporary while merging */ extern rwlock_t devtree_lock; /* temporary while merging */ -struct device_node *of_find_node_by_path(const char *path) -{ - struct device_node *np = allnodes; - - for (; np != 0; np = np->allnext) { - if (np->full_name != 0 && strcmp(np->full_name, path) == 0) - break; - } - - return np; -} -EXPORT_SYMBOL(of_find_node_by_path); - struct device_node *of_find_node_by_phandle(phandle handle) { struct device_node *np; @@ -54,52 +41,6 @@ struct device_node *of_find_node_by_phandle(phandle handle) } EXPORT_SYMBOL(of_find_node_by_phandle); -struct device_node *of_find_node_by_name(struct device_node *from, - const char *name) -{ - struct device_node *np; - - np = from ? from->allnext : allnodes; - for (; np != NULL; np = np->allnext) - if (np->name != NULL && strcmp(np->name, name) == 0) - break; - - return np; -} -EXPORT_SYMBOL(of_find_node_by_name); - -struct device_node *of_find_node_by_type(struct device_node *from, - const char *type) -{ - struct device_node *np; - - np = from ? from->allnext : allnodes; - for (; np != 0; np = np->allnext) - if (np->type != 0 && strcmp(np->type, type) == 0) - break; - - return np; -} -EXPORT_SYMBOL(of_find_node_by_type); - -struct device_node *of_find_compatible_node(struct device_node *from, - const char *type, const char *compatible) -{ - struct device_node *np; - - np = from ? from->allnext : allnodes; - for (; np != 0; np = np->allnext) { - if (type != NULL - && !(np->type != 0 && strcmp(np->type, type) == 0)) - continue; - if (of_device_is_compatible(np, compatible)) - break; - } - - return np; -} -EXPORT_SYMBOL(of_find_compatible_node); - int of_getintprop_default(struct device_node *np, const char *name, int def) { struct property *prop; diff --git a/arch/sparc64/kernel/prom.c b/arch/sparc64/kernel/prom.c index ee96ef61bc99..2b2017ce2267 100644 --- a/arch/sparc64/kernel/prom.c +++ b/arch/sparc64/kernel/prom.c @@ -30,23 +30,10 @@ #include #include -static struct device_node *allnodes; +extern struct device_node *allnodes; /* temporary while merging */ extern rwlock_t devtree_lock; /* temporary while merging */ -struct device_node *of_find_node_by_path(const char *path) -{ - struct device_node *np = allnodes; - - for (; np != 0; np = np->allnext) { - if (np->full_name != 0 && strcmp(np->full_name, path) == 0) - break; - } - - return np; -} -EXPORT_SYMBOL(of_find_node_by_path); - struct device_node *of_find_node_by_phandle(phandle handle) { struct device_node *np; @@ -59,52 +46,6 @@ struct device_node *of_find_node_by_phandle(phandle handle) } EXPORT_SYMBOL(of_find_node_by_phandle); -struct device_node *of_find_node_by_name(struct device_node *from, - const char *name) -{ - struct device_node *np; - - np = from ? from->allnext : allnodes; - for (; np != NULL; np = np->allnext) - if (np->name != NULL && strcmp(np->name, name) == 0) - break; - - return np; -} -EXPORT_SYMBOL(of_find_node_by_name); - -struct device_node *of_find_node_by_type(struct device_node *from, - const char *type) -{ - struct device_node *np; - - np = from ? from->allnext : allnodes; - for (; np != 0; np = np->allnext) - if (np->type != 0 && strcmp(np->type, type) == 0) - break; - - return np; -} -EXPORT_SYMBOL(of_find_node_by_type); - -struct device_node *of_find_compatible_node(struct device_node *from, - const char *type, const char *compatible) -{ - struct device_node *np; - - np = from ? from->allnext : allnodes; - for (; np != 0; np = np->allnext) { - if (type != NULL - && !(np->type != 0 && strcmp(np->type, type) == 0)) - continue; - if (of_device_is_compatible(np, compatible)) - break; - } - - return np; -} -EXPORT_SYMBOL(of_find_compatible_node); - int of_getintprop_default(struct device_node *np, const char *name, int def) { struct property *prop; diff --git a/drivers/of/base.c b/drivers/of/base.c index 6b6dfcc56522..9377f3bc410a 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -20,6 +20,8 @@ #include #include +struct device_node *allnodes; + /* use when traversing tree through the allnext, child, sibling, * or parent members of struct device_node. */ @@ -158,3 +160,116 @@ struct device_node *of_get_next_child(const struct device_node *node, return next; } EXPORT_SYMBOL(of_get_next_child); + +/** + * of_find_node_by_path - Find a node matching a full OF path + * @path: The full path to match + * + * Returns a node pointer with refcount incremented, use + * of_node_put() on it when done. + */ +struct device_node *of_find_node_by_path(const char *path) +{ + struct device_node *np = allnodes; + + read_lock(&devtree_lock); + for (; np; np = np->allnext) { + if (np->full_name && (of_node_cmp(np->full_name, path) == 0) + && of_node_get(np)) + break; + } + read_unlock(&devtree_lock); + return np; +} +EXPORT_SYMBOL(of_find_node_by_path); + +/** + * of_find_node_by_name - Find a node by its "name" property + * @from: The node to start searching from or NULL, the node + * you pass will not be searched, only the next one + * will; typically, you pass what the previous call + * returned. of_node_put() will be called on it + * @name: The name string to match against + * + * Returns a node pointer with refcount incremented, use + * of_node_put() on it when done. + */ +struct device_node *of_find_node_by_name(struct device_node *from, + const char *name) +{ + struct device_node *np; + + read_lock(&devtree_lock); + np = from ? from->allnext : allnodes; + for (; np; np = np->allnext) + if (np->name && (of_node_cmp(np->name, name) == 0) + && of_node_get(np)) + break; + of_node_put(from); + read_unlock(&devtree_lock); + return np; +} +EXPORT_SYMBOL(of_find_node_by_name); + +/** + * of_find_node_by_type - Find a node by its "device_type" property + * @from: The node to start searching from, or NULL to start searching + * the entire device tree. The node you pass will not be + * searched, only the next one will; typically, you pass + * what the previous call returned. of_node_put() will be + * called on from for you. + * @type: The type string to match against + * + * Returns a node pointer with refcount incremented, use + * of_node_put() on it when done. + */ +struct device_node *of_find_node_by_type(struct device_node *from, + const char *type) +{ + struct device_node *np; + + read_lock(&devtree_lock); + np = from ? from->allnext : allnodes; + for (; np; np = np->allnext) + if (np->type && (of_node_cmp(np->type, type) == 0) + && of_node_get(np)) + break; + of_node_put(from); + read_unlock(&devtree_lock); + return np; +} +EXPORT_SYMBOL(of_find_node_by_type); + +/** + * of_find_compatible_node - Find a node based on type and one of the + * tokens in its "compatible" property + * @from: The node to start searching from or NULL, the node + * you pass will not be searched, only the next one + * will; typically, you pass what the previous call + * returned. of_node_put() will be called on it + * @type: The type string to match "device_type" or NULL to ignore + * @compatible: The string to match to one of the tokens in the device + * "compatible" list. + * + * Returns a node pointer with refcount incremented, use + * of_node_put() on it when done. + */ +struct device_node *of_find_compatible_node(struct device_node *from, + const char *type, const char *compatible) +{ + struct device_node *np; + + read_lock(&devtree_lock); + np = from ? from->allnext : allnodes; + for (; np; np = np->allnext) { + if (type + && !(np->type && (of_node_cmp(np->type, type) == 0))) + continue; + if (of_device_is_compatible(np, compatible) && of_node_get(np)) + break; + } + of_node_put(from); + read_unlock(&devtree_lock); + return np; +} +EXPORT_SYMBOL(of_find_compatible_node); diff --git a/include/asm-powerpc/prom.h b/include/asm-powerpc/prom.h index 75b1144ca580..6e391c9894ce 100644 --- a/include/asm-powerpc/prom.h +++ b/include/asm-powerpc/prom.h @@ -26,6 +26,7 @@ #define of_compat_cmp(s1, s2, l) strncasecmp((s1), (s2), (l)) #define of_prop_cmp(s1, s2) strcmp((s1), (s2)) +#define of_node_cmp(s1, s2) strcasecmp((s1), (s2)) /* Definitions used by the flattened device tree */ #define OF_DT_HEADER 0xd00dfeed /* marker */ diff --git a/include/asm-sparc/prom.h b/include/asm-sparc/prom.h index c7d54958a90e..db9feb75bd86 100644 --- a/include/asm-sparc/prom.h +++ b/include/asm-sparc/prom.h @@ -25,6 +25,7 @@ #define of_compat_cmp(s1, s2, l) strncmp((s1), (s2), (l)) #define of_prop_cmp(s1, s2) strcasecmp((s1), (s2)) +#define of_node_cmp(s1, s2) strcmp((s1), (s2)) typedef u32 phandle; typedef u32 ihandle; diff --git a/include/asm-sparc64/prom.h b/include/asm-sparc64/prom.h index e83896f3c141..2b9e0d795faf 100644 --- a/include/asm-sparc64/prom.h +++ b/include/asm-sparc64/prom.h @@ -25,6 +25,7 @@ #define of_compat_cmp(s1, s2, l) strncmp((s1), (s2), (l)) #define of_prop_cmp(s1, s2) strcasecmp((s1), (s2)) +#define of_node_cmp(s1, s2) strcmp((s1), (s2)) typedef u32 phandle; typedef u32 ihandle; -- cgit v1.2.3 From f898f8dbcec4848cddb8c5be2d0affd75779ebe2 Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Tue, 1 May 2007 16:49:51 +1000 Subject: Begin consolidation of of_device.h This just moves the common stuff from the arch of_device.h files to linux/of_device.h. Signed-off-by: Stephen Rothwell Acked-by: Paul Mackerras Acked-by: David S. Miller --- drivers/of/device.c | 2 +- include/asm-powerpc/of_device.h | 22 +++++----------------- include/asm-sparc/of_device.h | 15 ++++----------- include/asm-sparc64/of_device.h | 15 ++++----------- include/linux/of_device.h | 26 ++++++++++++++++++++++++++ 5 files changed, 40 insertions(+), 40 deletions(-) create mode 100644 include/linux/of_device.h (limited to 'include/asm-sparc') diff --git a/drivers/of/device.c b/drivers/of/device.c index 7f233d77d62f..6245f060fb77 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -1,13 +1,13 @@ #include #include #include +#include #include #include #include #include #include -#include /** * of_match_node - Tell if an device_node has a matching of_match structure diff --git a/include/asm-powerpc/of_device.h b/include/asm-powerpc/of_device.h index e9af49eb1aa8..ec2a8a2c737c 100644 --- a/include/asm-powerpc/of_device.h +++ b/include/asm-powerpc/of_device.h @@ -3,14 +3,12 @@ #ifdef __KERNEL__ #include -#include -#include - +#include /* * The of_device is a kind of "base class" that is a superset of * struct device for use by devices attached to an OF node and - * probed using OF properties + * probed using OF properties. */ struct of_device { @@ -18,24 +16,14 @@ struct of_device u64 dma_mask; /* DMA mask */ struct device dev; /* Generic device interface */ }; -#define to_of_device(d) container_of(d, struct of_device, dev) - -extern const struct of_device_id *of_match_node( - const struct of_device_id *matches, const struct device_node *node); -extern const struct of_device_id *of_match_device( - const struct of_device_id *matches, const struct of_device *dev); - -extern struct of_device *of_dev_get(struct of_device *dev); -extern void of_dev_put(struct of_device *dev); - -extern int of_device_register(struct of_device *ofdev); -extern void of_device_unregister(struct of_device *ofdev); -extern void of_release_dev(struct device *dev); extern ssize_t of_device_get_modalias(struct of_device *ofdev, char *str, ssize_t len); extern int of_device_uevent(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size); +/* This is just here during the transition */ +#include + #endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_OF_DEVICE_H */ diff --git a/include/asm-sparc/of_device.h b/include/asm-sparc/of_device.h index 7cb00c1b09c6..b625261c9ec7 100644 --- a/include/asm-sparc/of_device.h +++ b/include/asm-sparc/of_device.h @@ -3,9 +3,9 @@ #ifdef __KERNEL__ #include +#include #include #include -#include extern struct bus_type ebus_bus_type; extern struct bus_type sbus_bus_type; @@ -30,19 +30,12 @@ struct of_device int portid; int clock_freq; }; -#define to_of_device(d) container_of(d, struct of_device, dev) extern void __iomem *of_ioremap(struct resource *res, unsigned long offset, unsigned long size, char *name); extern void of_iounmap(struct resource *res, void __iomem *base, unsigned long size); extern struct of_device *of_find_device_by_node(struct device_node *); -extern const struct of_device_id *of_match_device( - const struct of_device_id *matches, const struct of_device *dev); - -extern struct of_device *of_dev_get(struct of_device *dev); -extern void of_dev_put(struct of_device *dev); - /* * An of_platform_driver driver is attached to a basic of_device on * the ISA, EBUS, and SBUS busses on sparc64. @@ -67,13 +60,13 @@ struct of_platform_driver extern int of_register_driver(struct of_platform_driver *drv, struct bus_type *bus); extern void of_unregister_driver(struct of_platform_driver *drv); -extern int of_device_register(struct of_device *ofdev); -extern void of_device_unregister(struct of_device *ofdev); extern struct of_device *of_platform_device_create(struct device_node *np, const char *bus_id, struct device *parent, struct bus_type *bus); -extern void of_release_dev(struct device *dev); + +/* This is just here during the transition */ +#include #endif /* __KERNEL__ */ #endif /* _ASM_SPARC_OF_DEVICE_H */ diff --git a/include/asm-sparc64/of_device.h b/include/asm-sparc64/of_device.h index 60e9173c9acb..68048cb20688 100644 --- a/include/asm-sparc64/of_device.h +++ b/include/asm-sparc64/of_device.h @@ -3,9 +3,9 @@ #ifdef __KERNEL__ #include +#include #include #include -#include extern struct bus_type isa_bus_type; extern struct bus_type ebus_bus_type; @@ -31,19 +31,12 @@ struct of_device int portid; int clock_freq; }; -#define to_of_device(d) container_of(d, struct of_device, dev) extern void __iomem *of_ioremap(struct resource *res, unsigned long offset, unsigned long size, char *name); extern void of_iounmap(struct resource *res, void __iomem *base, unsigned long size); extern struct of_device *of_find_device_by_node(struct device_node *); -extern const struct of_device_id *of_match_device( - const struct of_device_id *matches, const struct of_device *dev); - -extern struct of_device *of_dev_get(struct of_device *dev); -extern void of_dev_put(struct of_device *dev); - /* * An of_platform_driver driver is attached to a basic of_device on * the ISA, EBUS, and SBUS busses on sparc64. @@ -68,13 +61,13 @@ struct of_platform_driver extern int of_register_driver(struct of_platform_driver *drv, struct bus_type *bus); extern void of_unregister_driver(struct of_platform_driver *drv); -extern int of_device_register(struct of_device *ofdev); -extern void of_device_unregister(struct of_device *ofdev); extern struct of_device *of_platform_device_create(struct device_node *np, const char *bus_id, struct device *parent, struct bus_type *bus); -extern void of_release_dev(struct device *dev); + +/* This is just here during the transition */ +#include #endif /* __KERNEL__ */ #endif /* _ASM_SPARC64_OF_DEVICE_H */ diff --git a/include/linux/of_device.h b/include/linux/of_device.h new file mode 100644 index 000000000000..91bf84b9d144 --- /dev/null +++ b/include/linux/of_device.h @@ -0,0 +1,26 @@ +#ifndef _LINUX_OF_DEVICE_H +#define _LINUX_OF_DEVICE_H +#ifdef __KERNEL__ + +#include +#include +#include + +#include + +#define to_of_device(d) container_of(d, struct of_device, dev) + +extern const struct of_device_id *of_match_node( + const struct of_device_id *matches, const struct device_node *node); +extern const struct of_device_id *of_match_device( + const struct of_device_id *matches, const struct of_device *dev); + +extern struct of_device *of_dev_get(struct of_device *dev); +extern void of_dev_put(struct of_device *dev); + +extern int of_device_register(struct of_device *ofdev); +extern void of_device_unregister(struct of_device *ofdev); +extern void of_release_dev(struct device *dev); + +#endif /* __KERNEL__ */ +#endif /* _LINUX_OF_DEVICE_H */ -- cgit v1.2.3 From 37b7754aab9a6ad7ecbba45c87f8d8a1f81b3bcc Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Mon, 30 Apr 2007 17:43:56 +1000 Subject: [SPARC/64] Rename some functions like PowerPC This is to make the of merge easier. Also rename of_bus_type. Signed-off-by: Stephen Rothwell Acked-by: David S. Miller --- arch/sparc/kernel/of_device.c | 42 +++++++++++++++++----------------- arch/sparc/kernel/time.c | 2 +- arch/sparc64/kernel/auxio.c | 2 +- arch/sparc64/kernel/of_device.c | 50 ++++++++++++++++++++--------------------- arch/sparc64/kernel/power.c | 2 +- arch/sparc64/kernel/time.c | 2 +- include/asm-sparc/of_device.h | 3 ++- include/asm-sparc64/of_device.h | 3 ++- 8 files changed, 54 insertions(+), 52 deletions(-) (limited to 'include/asm-sparc') diff --git a/arch/sparc/kernel/of_device.c b/arch/sparc/kernel/of_device.c index 0760b8157847..cb21983cff9f 100644 --- a/arch/sparc/kernel/of_device.c +++ b/arch/sparc/kernel/of_device.c @@ -21,7 +21,7 @@ static int of_platform_bus_match(struct device *dev, struct device_driver *drv) return of_match_device(matches, of_dev) != NULL; } -static int of_device_probe(struct device *dev) +static int of_platform_device_probe(struct device *dev) { int error = -ENODEV; struct of_platform_driver *drv; @@ -45,7 +45,7 @@ static int of_device_probe(struct device *dev) return error; } -static int of_device_remove(struct device *dev) +static int of_platform_device_remove(struct device *dev) { struct of_device * of_dev = to_of_device(dev); struct of_platform_driver * drv = to_of_platform_driver(dev->driver); @@ -55,7 +55,7 @@ static int of_device_remove(struct device *dev) return 0; } -static int of_device_suspend(struct device *dev, pm_message_t state) +static int of_platform_device_suspend(struct device *dev, pm_message_t state) { struct of_device * of_dev = to_of_device(dev); struct of_platform_driver * drv = to_of_platform_driver(dev->driver); @@ -66,7 +66,7 @@ static int of_device_suspend(struct device *dev, pm_message_t state) return error; } -static int of_device_resume(struct device * dev) +static int of_platform_device_resume(struct device * dev) { struct of_device * of_dev = to_of_device(dev); struct of_platform_driver * drv = to_of_platform_driver(dev->driver); @@ -87,7 +87,7 @@ static int node_match(struct device *dev, void *data) struct of_device *of_find_device_by_node(struct device_node *dp) { - struct device *dev = bus_find_device(&of_bus_type, NULL, + struct device *dev = bus_find_device(&of_platform_bus_type, NULL, dp, node_match); if (dev) @@ -101,10 +101,10 @@ EXPORT_SYMBOL(of_find_device_by_node); struct bus_type ebus_bus_type = { .name = "ebus", .match = of_platform_bus_match, - .probe = of_device_probe, - .remove = of_device_remove, - .suspend = of_device_suspend, - .resume = of_device_resume, + .probe = of_platform_device_probe, + .remove = of_platform_device_remove, + .suspend = of_platform_device_suspend, + .resume = of_platform_device_resume, }; EXPORT_SYMBOL(ebus_bus_type); #endif @@ -113,23 +113,23 @@ EXPORT_SYMBOL(ebus_bus_type); struct bus_type sbus_bus_type = { .name = "sbus", .match = of_platform_bus_match, - .probe = of_device_probe, - .remove = of_device_remove, - .suspend = of_device_suspend, - .resume = of_device_resume, + .probe = of_platform_device_probe, + .remove = of_platform_device_remove, + .suspend = of_platform_device_suspend, + .resume = of_platform_device_resume, }; EXPORT_SYMBOL(sbus_bus_type); #endif -struct bus_type of_bus_type = { +struct bus_type of_platform_bus_type = { .name = "of", .match = of_platform_bus_match, - .probe = of_device_probe, - .remove = of_device_remove, - .suspend = of_device_suspend, - .resume = of_device_resume, + .probe = of_platform_device_probe, + .remove = of_platform_device_remove, + .suspend = of_platform_device_suspend, + .resume = of_platform_device_resume, }; -EXPORT_SYMBOL(of_bus_type); +EXPORT_SYMBOL(of_platform_bus_type); static inline u64 of_read_addr(const u32 *cell, int size) { @@ -595,7 +595,7 @@ build_resources: build_device_resources(op, parent); op->dev.parent = parent; - op->dev.bus = &of_bus_type; + op->dev.bus = &of_platform_bus_type; if (!parent) strcpy(op->dev.bus_id, "root"); else @@ -639,7 +639,7 @@ static int __init of_bus_driver_init(void) { int err; - err = bus_register(&of_bus_type); + err = bus_register(&of_platform_bus_type); #ifdef CONFIG_PCI if (!err) err = bus_register(&ebus_bus_type); diff --git a/arch/sparc/kernel/time.c b/arch/sparc/kernel/time.c index 7b4612da74a6..f2fdbb3664d3 100644 --- a/arch/sparc/kernel/time.c +++ b/arch/sparc/kernel/time.c @@ -354,7 +354,7 @@ static struct of_platform_driver clock_driver = { /* Probe for the mostek real time clock chip. */ static int __init clock_init(void) { - return of_register_driver(&clock_driver, &of_bus_type); + return of_register_driver(&clock_driver, &of_platform_bus_type); } /* Must be after subsys_initcall() so that busses are probed. Must diff --git a/arch/sparc64/kernel/auxio.c b/arch/sparc64/kernel/auxio.c index 826118ee53d5..7b379761e9f8 100644 --- a/arch/sparc64/kernel/auxio.c +++ b/arch/sparc64/kernel/auxio.c @@ -155,7 +155,7 @@ static struct of_platform_driver auxio_driver = { static int __init auxio_init(void) { - return of_register_driver(&auxio_driver, &of_bus_type); + return of_register_driver(&auxio_driver, &of_platform_bus_type); } /* Must be after subsys_initcall() so that busses are probed. Must diff --git a/arch/sparc64/kernel/of_device.c b/arch/sparc64/kernel/of_device.c index 68927bc3d3a9..485f8579899a 100644 --- a/arch/sparc64/kernel/of_device.c +++ b/arch/sparc64/kernel/of_device.c @@ -21,7 +21,7 @@ static int of_platform_bus_match(struct device *dev, struct device_driver *drv) return of_match_device(matches, of_dev) != NULL; } -static int of_device_probe(struct device *dev) +static int of_platform_device_probe(struct device *dev) { int error = -ENODEV; struct of_platform_driver *drv; @@ -45,7 +45,7 @@ static int of_device_probe(struct device *dev) return error; } -static int of_device_remove(struct device *dev) +static int of_platform_device_remove(struct device *dev) { struct of_device * of_dev = to_of_device(dev); struct of_platform_driver * drv = to_of_platform_driver(dev->driver); @@ -55,7 +55,7 @@ static int of_device_remove(struct device *dev) return 0; } -static int of_device_suspend(struct device *dev, pm_message_t state) +static int of_platform_device_suspend(struct device *dev, pm_message_t state) { struct of_device * of_dev = to_of_device(dev); struct of_platform_driver * drv = to_of_platform_driver(dev->driver); @@ -66,7 +66,7 @@ static int of_device_suspend(struct device *dev, pm_message_t state) return error; } -static int of_device_resume(struct device * dev) +static int of_platform_device_resume(struct device * dev) { struct of_device * of_dev = to_of_device(dev); struct of_platform_driver * drv = to_of_platform_driver(dev->driver); @@ -112,7 +112,7 @@ static int node_match(struct device *dev, void *data) struct of_device *of_find_device_by_node(struct device_node *dp) { - struct device *dev = bus_find_device(&of_bus_type, NULL, + struct device *dev = bus_find_device(&of_platform_bus_type, NULL, dp, node_match); if (dev) @@ -126,20 +126,20 @@ EXPORT_SYMBOL(of_find_device_by_node); struct bus_type isa_bus_type = { .name = "isa", .match = of_platform_bus_match, - .probe = of_device_probe, - .remove = of_device_remove, - .suspend = of_device_suspend, - .resume = of_device_resume, + .probe = of_platform_device_probe, + .remove = of_platform_device_remove, + .suspend = of_platform_device_suspend, + .resume = of_platform_device_resume, }; EXPORT_SYMBOL(isa_bus_type); struct bus_type ebus_bus_type = { .name = "ebus", .match = of_platform_bus_match, - .probe = of_device_probe, - .remove = of_device_remove, - .suspend = of_device_suspend, - .resume = of_device_resume, + .probe = of_platform_device_probe, + .remove = of_platform_device_remove, + .suspend = of_platform_device_suspend, + .resume = of_platform_device_resume, }; EXPORT_SYMBOL(ebus_bus_type); #endif @@ -148,23 +148,23 @@ EXPORT_SYMBOL(ebus_bus_type); struct bus_type sbus_bus_type = { .name = "sbus", .match = of_platform_bus_match, - .probe = of_device_probe, - .remove = of_device_remove, - .suspend = of_device_suspend, - .resume = of_device_resume, + .probe = of_platform_device_probe, + .remove = of_platform_device_remove, + .suspend = of_platform_device_suspend, + .resume = of_platform_device_resume, }; EXPORT_SYMBOL(sbus_bus_type); #endif -struct bus_type of_bus_type = { +struct bus_type of_platform_bus_type = { .name = "of", .match = of_platform_bus_match, - .probe = of_device_probe, - .remove = of_device_remove, - .suspend = of_device_suspend, - .resume = of_device_resume, + .probe = of_platform_device_probe, + .remove = of_platform_device_remove, + .suspend = of_platform_device_suspend, + .resume = of_platform_device_resume, }; -EXPORT_SYMBOL(of_bus_type); +EXPORT_SYMBOL(of_platform_bus_type); static inline u64 of_read_addr(const u32 *cell, int size) { @@ -882,7 +882,7 @@ static struct of_device * __init scan_one_device(struct device_node *dp, op->irqs[i] = build_one_device_irq(op, parent, op->irqs[i]); op->dev.parent = parent; - op->dev.bus = &of_bus_type; + op->dev.bus = &of_platform_bus_type; if (!parent) strcpy(op->dev.bus_id, "root"); else @@ -926,7 +926,7 @@ static int __init of_bus_driver_init(void) { int err; - err = bus_register(&of_bus_type); + err = bus_register(&of_platform_bus_type); #ifdef CONFIG_PCI if (!err) err = bus_register(&isa_bus_type); diff --git a/arch/sparc64/kernel/power.c b/arch/sparc64/kernel/power.c index 8dd4294ad21e..fdc0d0b5a910 100644 --- a/arch/sparc64/kernel/power.c +++ b/arch/sparc64/kernel/power.c @@ -170,6 +170,6 @@ static struct of_platform_driver power_driver = { void __init power_init(void) { - of_register_driver(&power_driver, &of_bus_type); + of_register_driver(&power_driver, &of_platform_bus_type); return; } diff --git a/arch/sparc64/kernel/time.c b/arch/sparc64/kernel/time.c index 62e316ab1339..592ffcd57605 100644 --- a/arch/sparc64/kernel/time.c +++ b/arch/sparc64/kernel/time.c @@ -835,7 +835,7 @@ static int __init clock_init(void) return 0; } - return of_register_driver(&clock_driver, &of_bus_type); + return of_register_driver(&clock_driver, &of_platform_bus_type); } /* Must be after subsys_initcall() so that busses are probed. Must diff --git a/include/asm-sparc/of_device.h b/include/asm-sparc/of_device.h index b625261c9ec7..fd8e95743139 100644 --- a/include/asm-sparc/of_device.h +++ b/include/asm-sparc/of_device.h @@ -9,7 +9,8 @@ extern struct bus_type ebus_bus_type; extern struct bus_type sbus_bus_type; -extern struct bus_type of_bus_type; +extern struct bus_type of_platform_bus_type; +#define of_bus_type of_platform_bus_type /* for compatibility */ /* * The of_device is a kind of "base class" that is a superset of diff --git a/include/asm-sparc64/of_device.h b/include/asm-sparc64/of_device.h index 68048cb20688..daf36eb52292 100644 --- a/include/asm-sparc64/of_device.h +++ b/include/asm-sparc64/of_device.h @@ -10,7 +10,8 @@ extern struct bus_type isa_bus_type; extern struct bus_type ebus_bus_type; extern struct bus_type sbus_bus_type; -extern struct bus_type of_bus_type; +extern struct bus_type of_platform_bus_type; +#define of_bus_type of_platform_bus_type /* for compatibility */ /* * The of_device is a kind of "base class" that is a superset of -- cgit v1.2.3 From b41912ca345e6de8ec8469d57cd585881271e2b9 Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Tue, 1 May 2007 16:12:57 +1000 Subject: Create linux/of_platorm.h Move common stuff from asm-powerpc/of_platform.h to here and move the common bits from asm-sparc*/of_device.h here as well. Create asm-sparc*/of_platform.h and move appropriate parts of of_device.h to them. Signed-off-by: Stephen Rothwell Acked-by: Paul Mackerras Acked-by: David S. Miller --- include/asm-powerpc/of_platform.h | 38 +++++---------------------- include/asm-sparc/of_device.h | 39 ++------------------------- include/asm-sparc/of_platform.h | 32 +++++++++++++++++++++++ include/asm-sparc64/of_device.h | 40 ++-------------------------- include/asm-sparc64/of_platform.h | 33 +++++++++++++++++++++++ include/linux/of_platform.h | 55 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 130 insertions(+), 107 deletions(-) create mode 100644 include/asm-sparc/of_platform.h create mode 100644 include/asm-sparc64/of_platform.h create mode 100644 include/linux/of_platform.h (limited to 'include/asm-sparc') diff --git a/include/asm-powerpc/of_platform.h b/include/asm-powerpc/of_platform.h index 217eafb167e9..80e6fad28b4f 100644 --- a/include/asm-powerpc/of_platform.h +++ b/include/asm-powerpc/of_platform.h @@ -1,3 +1,5 @@ +#ifndef _ASM_POWERPC_OF_PLATFORM_H +#define _ASM_POWERPC_OF_PLATFORM_H /* * Copyright (C) 2006 Benjamin Herrenschmidt, IBM Corp. * @@ -9,37 +11,8 @@ * */ -#include - -/* - * The of_platform_bus_type is a bus type used by drivers that do not - * attach to a macio or similar bus but still use OF probing - * mechanism - */ -extern struct bus_type of_platform_bus_type; - -/* - * An of_platform_driver driver is attached to a basic of_device on - * the "platform bus" (of_platform_bus_type) - */ -struct of_platform_driver -{ - char *name; - struct of_device_id *match_table; - struct module *owner; - - int (*probe)(struct of_device* dev, - const struct of_device_id *match); - int (*remove)(struct of_device* dev); - - int (*suspend)(struct of_device* dev, pm_message_t state); - int (*resume)(struct of_device* dev); - int (*shutdown)(struct of_device* dev); - - struct device_driver driver; -}; -#define to_of_platform_driver(drv) \ - container_of(drv,struct of_platform_driver, driver) +/* This is just here during the transition */ +#include /* Platform drivers register/unregister */ extern int of_register_platform_driver(struct of_platform_driver *drv); @@ -56,5 +29,6 @@ extern int of_platform_bus_probe(struct device_node *root, struct of_device_id *matches, struct device *parent); -extern struct of_device *of_find_device_by_node(struct device_node *np); extern struct of_device *of_find_device_by_phandle(phandle ph); + +#endif /* _ASM_POWERPC_OF_PLATFORM_H */ diff --git a/include/asm-sparc/of_device.h b/include/asm-sparc/of_device.h index fd8e95743139..e5f5aedc2293 100644 --- a/include/asm-sparc/of_device.h +++ b/include/asm-sparc/of_device.h @@ -7,11 +7,6 @@ #include #include -extern struct bus_type ebus_bus_type; -extern struct bus_type sbus_bus_type; -extern struct bus_type of_platform_bus_type; -#define of_bus_type of_platform_bus_type /* for compatibility */ - /* * The of_device is a kind of "base class" that is a superset of * struct device for use by devices attached to an OF node and @@ -35,39 +30,9 @@ struct of_device extern void __iomem *of_ioremap(struct resource *res, unsigned long offset, unsigned long size, char *name); extern void of_iounmap(struct resource *res, void __iomem *base, unsigned long size); -extern struct of_device *of_find_device_by_node(struct device_node *); - -/* - * An of_platform_driver driver is attached to a basic of_device on - * the ISA, EBUS, and SBUS busses on sparc64. - */ -struct of_platform_driver -{ - char *name; - struct of_device_id *match_table; - struct module *owner; - - int (*probe)(struct of_device* dev, const struct of_device_id *match); - int (*remove)(struct of_device* dev); - - int (*suspend)(struct of_device* dev, pm_message_t state); - int (*resume)(struct of_device* dev); - int (*shutdown)(struct of_device* dev); - - struct device_driver driver; -}; -#define to_of_platform_driver(drv) container_of(drv,struct of_platform_driver, driver) - -extern int of_register_driver(struct of_platform_driver *drv, - struct bus_type *bus); -extern void of_unregister_driver(struct of_platform_driver *drv); -extern struct of_device *of_platform_device_create(struct device_node *np, - const char *bus_id, - struct device *parent, - struct bus_type *bus); - -/* This is just here during the transition */ +/* These are just here during the transition */ #include +#include #endif /* __KERNEL__ */ #endif /* _ASM_SPARC_OF_DEVICE_H */ diff --git a/include/asm-sparc/of_platform.h b/include/asm-sparc/of_platform.h new file mode 100644 index 000000000000..64a230064ef2 --- /dev/null +++ b/include/asm-sparc/of_platform.h @@ -0,0 +1,32 @@ +#ifndef _ASM_SPARC_OF_PLATFORM_H +#define _ASM_SPARC_OF_PLATFORM_H +/* + * Copyright (C) 2006 Benjamin Herrenschmidt, IBM Corp. + * + * Modified for Sparc by merging parts of asm-sparc/of_device.h + * by Stephen Rothwell + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + */ + +/* This is just here during the transition */ +#include + +extern struct bus_type ebus_bus_type; +extern struct bus_type sbus_bus_type; +extern struct bus_type of_platform_bus_type; +#define of_bus_type of_platform_bus_type /* for compatibility */ + +extern int of_register_driver(struct of_platform_driver *drv, + struct bus_type *bus); +extern void of_unregister_driver(struct of_platform_driver *drv); +extern struct of_device *of_platform_device_create(struct device_node *np, + const char *bus_id, + struct device *parent, + struct bus_type *bus); + +#endif /* _ASM_SPARC_OF_PLATFORM_H */ diff --git a/include/asm-sparc64/of_device.h b/include/asm-sparc64/of_device.h index daf36eb52292..46d69b3223c5 100644 --- a/include/asm-sparc64/of_device.h +++ b/include/asm-sparc64/of_device.h @@ -7,12 +7,6 @@ #include #include -extern struct bus_type isa_bus_type; -extern struct bus_type ebus_bus_type; -extern struct bus_type sbus_bus_type; -extern struct bus_type of_platform_bus_type; -#define of_bus_type of_platform_bus_type /* for compatibility */ - /* * The of_device is a kind of "base class" that is a superset of * struct device for use by devices attached to an OF node and @@ -36,39 +30,9 @@ struct of_device extern void __iomem *of_ioremap(struct resource *res, unsigned long offset, unsigned long size, char *name); extern void of_iounmap(struct resource *res, void __iomem *base, unsigned long size); -extern struct of_device *of_find_device_by_node(struct device_node *); - -/* - * An of_platform_driver driver is attached to a basic of_device on - * the ISA, EBUS, and SBUS busses on sparc64. - */ -struct of_platform_driver -{ - char *name; - struct of_device_id *match_table; - struct module *owner; - - int (*probe)(struct of_device* dev, const struct of_device_id *match); - int (*remove)(struct of_device* dev); - - int (*suspend)(struct of_device* dev, pm_message_t state); - int (*resume)(struct of_device* dev); - int (*shutdown)(struct of_device* dev); - - struct device_driver driver; -}; -#define to_of_platform_driver(drv) container_of(drv,struct of_platform_driver, driver) - -extern int of_register_driver(struct of_platform_driver *drv, - struct bus_type *bus); -extern void of_unregister_driver(struct of_platform_driver *drv); -extern struct of_device *of_platform_device_create(struct device_node *np, - const char *bus_id, - struct device *parent, - struct bus_type *bus); - -/* This is just here during the transition */ +/* These are just here during the transition */ #include +#include #endif /* __KERNEL__ */ #endif /* _ASM_SPARC64_OF_DEVICE_H */ diff --git a/include/asm-sparc64/of_platform.h b/include/asm-sparc64/of_platform.h new file mode 100644 index 000000000000..f7c1f17c7d52 --- /dev/null +++ b/include/asm-sparc64/of_platform.h @@ -0,0 +1,33 @@ +#ifndef _ASM_SPARC64_OF_PLATFORM_H +#define _ASM_SPARC64_OF_PLATFORM_H +/* + * Copyright (C) 2006 Benjamin Herrenschmidt, IBM Corp. + * + * Modified for Sparc by merging parts of asm-sparc/of_device.h + * by Stephen Rothwell + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + */ + +/* This is just here during the transition */ +#include + +extern struct bus_type isa_bus_type; +extern struct bus_type ebus_bus_type; +extern struct bus_type sbus_bus_type; +extern struct bus_type of_platform_bus_type; +#define of_bus_type of_platform_bus_type /* for compatibility */ + +extern int of_register_driver(struct of_platform_driver *drv, + struct bus_type *bus); +extern void of_unregister_driver(struct of_platform_driver *drv); +extern struct of_device *of_platform_device_create(struct device_node *np, + const char *bus_id, + struct device *parent, + struct bus_type *bus); + +#endif /* _ASM_SPARC64_OF_PLATFORM_H */ diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h new file mode 100644 index 000000000000..c85d0f835783 --- /dev/null +++ b/include/linux/of_platform.h @@ -0,0 +1,55 @@ +#ifndef _LINUX_OF_PLATFORM_H +#define _LINUX_OF_PLATFORM_H +/* + * Copyright (C) 2006 Benjamin Herrenschmidt, IBM Corp. + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + */ + +#include +#include +#include +#include +#include + +/* + * The of_platform_bus_type is a bus type used by drivers that do not + * attach to a macio or similar bus but still use OF probing + * mechanism + */ +extern struct bus_type of_platform_bus_type; + +/* + * An of_platform_driver driver is attached to a basic of_device on + * the "platform bus" (of_platform_bus_type) (or ISA, EBUS and SBUS + * busses on sparc). + */ +struct of_platform_driver +{ + char *name; + struct of_device_id *match_table; + struct module *owner; + + int (*probe)(struct of_device* dev, + const struct of_device_id *match); + int (*remove)(struct of_device* dev); + + int (*suspend)(struct of_device* dev, pm_message_t state); + int (*resume)(struct of_device* dev); + int (*shutdown)(struct of_device* dev); + + struct device_driver driver; +}; +#define to_of_platform_driver(drv) \ + container_of(drv,struct of_platform_driver, driver) + +#include + +extern struct of_device *of_find_device_by_node(struct device_node *np); + +#endif /* _LINUX_OF_PLATFORM_H */ -- cgit v1.2.3