From 88af7f58c6f1fa28d617392c791f11317bcb590d Mon Sep 17 00:00:00 2001 From: Benoit Cousson Date: Mon, 5 Dec 2011 15:23:54 +0100 Subject: of/base: Take NULL string into account for property with multiple strings The current implementation just ignore any NULL string inserted in a multiple strings property. In some cases we can have a property with a fix number of strings but not necessarily used, like for example in a list of valid pinmux modes. prop = "uart_rx", "uart_tx", "", "", "safe_mode"; Do no skip NULL string and take them into account in of_property_read_string_index and of_property_count_strings. Reported-by: Tony Lindgren Signed-off-by: Benoit Cousson Cc: Grant Likely Signed-off-by: Rob Herring --- drivers/of/base.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'drivers/of') diff --git a/drivers/of/base.c b/drivers/of/base.c index 9b6588ef0673..b7072437eb8c 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -752,7 +752,7 @@ int of_property_read_string_index(struct device_node *np, const char *propname, for (i = 0; total < prop->length; total += l, p += l) { l = strlen(p) + 1; - if ((*p != 0) && (i++ == index)) { + if (i++ == index) { *output = p; return 0; } @@ -790,11 +790,9 @@ int of_property_count_strings(struct device_node *np, const char *propname) p = prop->value; - for (i = 0; total < prop->length; total += l, p += l) { + for (i = 0; total < prop->length; total += l, p += l, i++) l = strlen(p) + 1; - if (*p != 0) - i++; - } + return i; } EXPORT_SYMBOL_GPL(of_property_count_strings); -- cgit v1.2.3 From 7b482c8360d368fd495685a2c69ca4f1e7b29764 Mon Sep 17 00:00:00 2001 From: Uwe Kleine-König Date: Tue, 20 Dec 2011 22:56:45 +0100 Subject: ARM/of: allow *machine_desc.dt_compat to be const This allows dt_compat to point to a constant list of compatible strings. Signed-off-by: Uwe Kleine-König Signed-off-by: Rob Herring --- arch/arm/include/asm/mach/arch.h | 2 +- drivers/of/fdt.c | 4 ++-- include/linux/of_fdt.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/of') diff --git a/arch/arm/include/asm/mach/arch.h b/arch/arm/include/asm/mach/arch.h index 2b0efc3104ac..02a718adb598 100644 --- a/arch/arm/include/asm/mach/arch.h +++ b/arch/arm/include/asm/mach/arch.h @@ -19,7 +19,7 @@ struct machine_desc { unsigned int nr; /* architecture number */ const char *name; /* architecture name */ unsigned long atag_offset; /* tagged list (relative) */ - const char **dt_compat; /* array of device tree + const char *const *dt_compat; /* array of device tree * 'compatible' strings */ unsigned int nr_irqs; /* number of IRQs */ diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index fd85fa298e0f..7dc8e6da858d 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -107,7 +107,7 @@ int of_fdt_is_compatible(struct boot_param_header *blob, * of_fdt_match - Return true if node matches a list of compatible values */ int of_fdt_match(struct boot_param_header *blob, unsigned long node, - const char **compat) + const char *const *compat) { unsigned int tmp, score = 0; @@ -541,7 +541,7 @@ int __init of_flat_dt_is_compatible(unsigned long node, const char *compat) /** * of_flat_dt_match - Return true if node matches a list of compatible values */ -int __init of_flat_dt_match(unsigned long node, const char **compat) +int __init of_flat_dt_match(unsigned long node, const char *const *compat) { return of_fdt_match(initial_boot_params, node, compat); } diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h index c84d900fbbb3..ed136ad698ce 100644 --- a/include/linux/of_fdt.h +++ b/include/linux/of_fdt.h @@ -71,7 +71,7 @@ extern int of_fdt_is_compatible(struct boot_param_header *blob, unsigned long node, const char *compat); extern int of_fdt_match(struct boot_param_header *blob, unsigned long node, - const char **compat); + const char *const *compat); extern void of_fdt_unflatten_tree(unsigned long *blob, struct device_node **mynodes); @@ -88,7 +88,7 @@ extern int of_scan_flat_dt(int (*it)(unsigned long node, const char *uname, extern void *of_get_flat_dt_prop(unsigned long node, const char *name, unsigned long *size); extern int of_flat_dt_is_compatible(unsigned long node, const char *name); -extern int of_flat_dt_match(unsigned long node, const char **matches); +extern int of_flat_dt_match(unsigned long node, const char *const *matches); extern unsigned long of_get_flat_dt_root(void); extern int early_init_dt_scan_chosen(unsigned long node, const char *uname, -- cgit v1.2.3 From 8af0da93da7c40526959ab5291964581c678d3e7 Mon Sep 17 00:00:00 2001 From: Dong Aisheng Date: Thu, 22 Dec 2011 20:19:24 +0800 Subject: dt: reform for_each_property to for_each_property_of_node Make this macro easier to use(do not need to pass properties, a node is enough), also change to a more sensible name as for_each_child_of_node. Signed-off-by: Dong Aisheng Cc: Grant Likely Signed-off-by: Rob Herring --- drivers/of/base.c | 2 +- include/linux/of.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/of') diff --git a/drivers/of/base.c b/drivers/of/base.c index b7072437eb8c..0181eeb88c92 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -1157,7 +1157,7 @@ void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align)) if (!of_aliases) return; - for_each_property(pp, of_aliases->properties) { + for_each_property_of_node(of_aliases, pp) { const char *start = pp->name; const char *end = start + strlen(start); struct device_node *np; diff --git a/include/linux/of.h b/include/linux/of.h index 4948552d60f5..f1a490c37e06 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -219,8 +219,8 @@ extern int of_device_is_available(const struct device_node *device); extern const void *of_get_property(const struct device_node *node, const char *name, int *lenp); -#define for_each_property(pp, properties) \ - for (pp = properties; pp != NULL; pp = pp->next) +#define for_each_property_of_node(dn, pp) \ + for (pp = dn->properties; pp != NULL; pp = pp->next) extern int of_n_addr_cells(struct device_node *np); extern int of_n_size_cells(struct device_node *np); -- cgit v1.2.3 From 75c71848f22e6381f48614da23df2a43e374b498 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Tue, 27 Dec 2011 22:58:40 +0100 Subject: of/pdt: fix section mismatch warning Fix the following section mismatch warning - seen when building sparc32: WARNING: vmlinux.o(.text+0x1ff9c0): Section mismatch in reference from the function kernel_tree_alloc() to the function .init.text:prom_early_alloc() The function kernel_tree_alloc() references the function __init prom_early_alloc(). This is often because kernel_tree_alloc lacks a __init annotation or the annotation of prom_early_alloc is wrong. prom_early_alloc() is annotated __init, and users of kernel_tree_alloc() is also annotated __init. So simply match the annoation of these to fix the warning. Signed-off-by: Sam Ravnborg Cc: Grant Likely Acked-by: David S. Miller Signed-off-by: Rob Herring --- drivers/of/pdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/of') diff --git a/drivers/of/pdt.c b/drivers/of/pdt.c index bc5b3990f6ed..07cc1d678e4d 100644 --- a/drivers/of/pdt.c +++ b/drivers/of/pdt.c @@ -229,7 +229,7 @@ static struct device_node * __init of_pdt_build_tree(struct device_node *parent, return ret; } -static void *kernel_tree_alloc(u64 size, u64 align) +static void * __init kernel_tree_alloc(u64 size, u64 align) { return prom_early_alloc(size); } -- cgit v1.2.3 From c89810acbcf48c7004e912b2b4b862480b2d00e1 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Mon, 2 Jan 2012 14:19:03 -0200 Subject: ARM: prom.h: Fix build error by removing unneeded header file Fix the following build error: CC [M] fs/udf/balloc.o In file included from /home/fabio/next/linux-next/arch/arm/include/asm/prom.h:16, from include/linux/of.h:140, from include/asm-generic/gpio.h:7, from arch/arm/plat-mxc/include/mach/irqs.h:14, from /home/fabio/next/linux-next/arch/arm/include/asm/irq.h:4, from /home/fabio/next/linux-next/arch/arm/include/asm/hardirq.h:6, from include/linux/hardirq.h:7, from include/linux/highmem.h:8, from include/linux/pagemap.h:10, from include/linux/buffer_head.h:13, from fs/udf/udfdecl.h:11, from fs/udf/balloc.c:22: /home/fabio/next/linux-next/arch/arm/include/asm/setup.h:146: error: redefinition of 'struct tag' Signed-off-by: Fabio Estevam [grant.likely: fix build failure on drivers/of/fdt.c] Signed-off-by: Grant Likely --- arch/arm/include/asm/prom.h | 1 - drivers/of/fdt.c | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/of') diff --git a/arch/arm/include/asm/prom.h b/arch/arm/include/asm/prom.h index 6f65ca86a5ec..ee0363307918 100644 --- a/arch/arm/include/asm/prom.h +++ b/arch/arm/include/asm/prom.h @@ -13,7 +13,6 @@ #ifdef CONFIG_OF -#include #include extern struct machine_desc *setup_machine_fdt(unsigned int dt_phys); diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 7dc8e6da858d..91a375fb6ae6 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -18,6 +18,7 @@ #include #include +#include /* for COMMAND_LINE_SIZE */ #ifdef CONFIG_PPC #include #endif /* CONFIG_PPC */ -- cgit v1.2.3