From 00b7d1cf46676ad5e6338e80dc6230e1b6e71b86 Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Wed, 29 Aug 2018 17:21:45 -0500 Subject: of: make default address and size cells sizes private Only some old OpenFirmware implementations rely on default sizes. Any FDT and modern implementation should have explicit properties. Make the OF_ROOT_NODE_*_CELLS_DEFAULT defines private so we don't get any outside users. This also gets us one step closer to removing the asm/prom.h dependency on Sparc. Cc: "David S. Miller" Cc: Frank Rowand Cc: sparclinux@vger.kernel.org Signed-off-by: Rob Herring --- include/linux/of.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'include/linux/of.h') diff --git a/include/linux/of.h b/include/linux/of.h index 99b0ebf49632..2141490b368f 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -247,12 +247,6 @@ static inline unsigned long of_read_ulong(const __be32 *cell, int size) #include #endif -/* Default #address and #size cells. Allow arch asm/prom.h to override */ -#if !defined(OF_ROOT_NODE_ADDR_CELLS_DEFAULT) -#define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 1 -#define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1 -#endif - #define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags) #define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags) -- cgit v1.2.3-59-g8ed1b From f1f207e43b8a49ac2ee3c36a64de1f84651c6079 Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Wed, 22 Aug 2018 15:04:40 -0500 Subject: of: Add cpu node iterator for_each_of_cpu_node() Iterating thru cpu nodes is a common pattern. Create a common iterator which can find child nodes either by node name or device_type == cpu. Using the former will allow for eventually dropping device_type properties which are deprecated for FDT. Cc: Frank Rowand Reviewed-by: Geert Uytterhoeven Signed-off-by: Rob Herring --- drivers/of/base.c | 39 +++++++++++++++++++++++++++++++++++++++ include/linux/of.h | 11 +++++++++++ 2 files changed, 50 insertions(+) (limited to 'include/linux/of.h') diff --git a/drivers/of/base.c b/drivers/of/base.c index a055cd1ef96d..4807db0a35b3 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -741,6 +741,45 @@ struct device_node *of_get_next_available_child(const struct device_node *node, } EXPORT_SYMBOL(of_get_next_available_child); +/** + * of_get_next_cpu_node - Iterate on cpu nodes + * @prev: previous child of the /cpus node, or NULL to get first + * + * Returns a cpu node pointer with refcount incremented, use of_node_put() + * on it when done. Returns NULL when prev is the last child. Decrements + * the refcount of prev. + */ +struct device_node *of_get_next_cpu_node(struct device_node *prev) +{ + struct device_node *next = NULL; + unsigned long flags; + struct device_node *node; + + if (!prev) + node = of_find_node_by_path("/cpus"); + + raw_spin_lock_irqsave(&devtree_lock, flags); + if (prev) + next = prev->sibling; + else if (node) { + next = node->child; + of_node_put(node); + } + for (; next; next = next->sibling) { + if (!(of_node_name_eq(next, "cpu") || + (next->type && !of_node_cmp(next->type, "cpu")))) + continue; + if (!__of_device_is_available(next)) + continue; + if (of_node_get(next)) + break; + } + of_node_put(prev); + raw_spin_unlock_irqrestore(&devtree_lock, flags); + return next; +} +EXPORT_SYMBOL(of_get_next_cpu_node); + /** * of_get_compatible_child - Find compatible child node * @parent: parent node diff --git a/include/linux/of.h b/include/linux/of.h index 99b0ebf49632..1aca0dbd35df 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -353,6 +353,8 @@ extern const void *of_get_property(const struct device_node *node, const char *name, int *lenp); extern struct device_node *of_get_cpu_node(int cpu, unsigned int *thread); +extern struct device_node *of_get_next_cpu_node(struct device_node *prev); + #define for_each_property_of_node(dn, pp) \ for (pp = dn->properties; pp != NULL; pp = pp->next) @@ -754,6 +756,11 @@ static inline struct device_node *of_get_cpu_node(int cpu, return NULL; } +static inline struct device_node *of_get_next_cpu_node(struct device_node *prev) +{ + return NULL; +} + static inline int of_n_addr_cells(struct device_node *np) { return 0; @@ -1217,6 +1224,10 @@ static inline int of_property_read_s32(const struct device_node *np, for (child = of_get_next_available_child(parent, NULL); child != NULL; \ child = of_get_next_available_child(parent, child)) +#define for_each_of_cpu_node(cpu) \ + for (cpu = of_get_next_cpu_node(NULL); cpu != NULL; \ + cpu = of_get_next_cpu_node(cpu)) + #define for_each_node_with_property(dn, prop_name) \ for (dn = of_find_node_with_property(NULL, prop_name); dn; \ dn = of_find_node_with_property(dn, prop_name)) -- cgit v1.2.3-59-g8ed1b From 5d5a0ab1a7918fce5ca5c0fb1871a3e2000f85de Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Mon, 1 Oct 2018 10:54:51 -0500 Subject: of: Fix property name in of_node_get_device_type Commit 0413bedabc88 ("of: Add device_type access helper functions") added a new helper not yet used in preparation for some treewide clean up of accesses to 'device_type' properties. Unfortunately, there's an error and 'type' was used for the property name. Fix this. Fixes: 0413bedabc88 ("of: Add device_type access helper functions") Cc: Frank Rowand Signed-off-by: Rob Herring --- include/linux/of.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/linux/of.h') diff --git a/include/linux/of.h b/include/linux/of.h index f581531d797e..04cef4490efc 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -991,7 +991,7 @@ static inline struct device_node *of_find_matching_node( static inline const char *of_node_get_device_type(const struct device_node *np) { - return of_get_property(np, "type", NULL); + return of_get_property(np, "device_type", NULL); } static inline bool of_node_is_type(const struct device_node *np, const char *type) -- cgit v1.2.3-59-g8ed1b