* [PATCH 1/3] of: fix sparse warnings in of_find_next_cache_node @ 2017-05-04 18:00 Rob Herring 2017-05-04 18:00 ` [PATCH 2/3] of: fix sparse warning in of_pci_range_parser_one Rob Herring ` (2 more replies) 0 siblings, 3 replies; 6+ messages in thread From: Rob Herring @ 2017-05-04 18:00 UTC (permalink / raw) To: devicetree, Frank Rowand, Mark Rutland; +Cc: linux-kernel sparse gives a warning that 'handle' is not a __be32: ../drivers/of/base.c:2261:61: warning: incorrect type in argument 1 (different base types) ../drivers/of/base.c:2261:61: expected restricted __be32 const [usertype] *p ../drivers/of/base.c:2261:61: got unsigned int const [usertype] *[assigned] handle We could just change the type, but the code can be improved by using of_parse_phandle instead of open coding it with of_get_property and of_find_node_by_phandle. Signed-off-by: Rob Herring <robh@kernel.org> --- drivers/of/base.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/of/base.c b/drivers/of/base.c index d7c4629a3a2d..016f9d77d64d 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -2250,15 +2250,14 @@ EXPORT_SYMBOL_GPL(of_console_check); */ struct device_node *of_find_next_cache_node(const struct device_node *np) { - struct device_node *child; - const phandle *handle; + struct device_node *child, *cache_node; - handle = of_get_property(np, "l2-cache", NULL); - if (!handle) - handle = of_get_property(np, "next-level-cache", NULL); + cache_node = of_parse_phandle(np, "l2-cache", 0); + if (!cache_node) + cache_node = of_parse_phandle(np, "next-level-cache", 0); - if (handle) - return of_find_node_by_phandle(be32_to_cpup(handle)); + if (cache_node) + return cache_node; /* OF on pmac has nodes instead of properties named "l2-cache" * beneath CPU nodes. -- 2.11.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/3] of: fix sparse warning in of_pci_range_parser_one 2017-05-04 18:00 [PATCH 1/3] of: fix sparse warnings in of_find_next_cache_node Rob Herring @ 2017-05-04 18:00 ` Rob Herring 2017-05-05 5:16 ` Frank Rowand 2017-05-04 18:00 ` [PATCH 3/3] of: fix sparse warnings in fdt, irq, and resolver code Rob Herring 2017-05-05 5:15 ` [PATCH 1/3] of: fix sparse warnings in of_find_next_cache_node Frank Rowand 2 siblings, 1 reply; 6+ messages in thread From: Rob Herring @ 2017-05-04 18:00 UTC (permalink / raw) To: devicetree, Frank Rowand, Mark Rutland; +Cc: linux-kernel, stable sparse gives the following warning for 'pci_space': ../drivers/of/address.c:266:26: warning: incorrect type in assignment (different base types) ../drivers/of/address.c:266:26: expected unsigned int [unsigned] [usertype] pci_space ../drivers/of/address.c:266:26: got restricted __be32 const [usertype] <noident> It appears that pci_space is only ever accessed on powerpc, so the endian swap is often not needed. Cc: stable@vger.kernel.org Signed-off-by: Rob Herring <robh@kernel.org> --- drivers/of/address.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/of/address.c b/drivers/of/address.c index 02b2903fe9d2..72914cdfce2a 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -263,7 +263,7 @@ struct of_pci_range *of_pci_range_parser_one(struct of_pci_range_parser *parser, if (!parser->range || parser->range + parser->np > parser->end) return NULL; - range->pci_space = parser->range[0]; + range->pci_space = be32_to_cpup(parser->range); range->flags = of_bus_pci_get_flags(parser->range); range->pci_addr = of_read_number(parser->range + 1, ns); range->cpu_addr = of_translate_address(parser->node, -- 2.11.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/3] of: fix sparse warning in of_pci_range_parser_one 2017-05-04 18:00 ` [PATCH 2/3] of: fix sparse warning in of_pci_range_parser_one Rob Herring @ 2017-05-05 5:16 ` Frank Rowand 0 siblings, 0 replies; 6+ messages in thread From: Frank Rowand @ 2017-05-05 5:16 UTC (permalink / raw) To: Rob Herring, devicetree, Mark Rutland; +Cc: linux-kernel, stable On 05/04/17 11:00, Rob Herring wrote: > sparse gives the following warning for 'pci_space': > > ../drivers/of/address.c:266:26: warning: incorrect type in assignment (different base types) > ../drivers/of/address.c:266:26: expected unsigned int [unsigned] [usertype] pci_space > ../drivers/of/address.c:266:26: got restricted __be32 const [usertype] <noident> > > It appears that pci_space is only ever accessed on powerpc, so the endian > swap is often not needed. > > Cc: stable@vger.kernel.org > Signed-off-by: Rob Herring <robh@kernel.org> > --- > drivers/of/address.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/of/address.c b/drivers/of/address.c > index 02b2903fe9d2..72914cdfce2a 100644 > --- a/drivers/of/address.c > +++ b/drivers/of/address.c > @@ -263,7 +263,7 @@ struct of_pci_range *of_pci_range_parser_one(struct of_pci_range_parser *parser, > if (!parser->range || parser->range + parser->np > parser->end) > return NULL; > > - range->pci_space = parser->range[0]; > + range->pci_space = be32_to_cpup(parser->range); > range->flags = of_bus_pci_get_flags(parser->range); > range->pci_addr = of_read_number(parser->range + 1, ns); > range->cpu_addr = of_translate_address(parser->node, > Reviewed-by: Frank Rowand <frank.rowand@sony.com> ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/3] of: fix sparse warnings in fdt, irq, and resolver code 2017-05-04 18:00 [PATCH 1/3] of: fix sparse warnings in of_find_next_cache_node Rob Herring 2017-05-04 18:00 ` [PATCH 2/3] of: fix sparse warning in of_pci_range_parser_one Rob Herring @ 2017-05-04 18:00 ` Rob Herring 2017-05-05 5:16 ` Frank Rowand 2017-05-05 5:15 ` [PATCH 1/3] of: fix sparse warnings in of_find_next_cache_node Frank Rowand 2 siblings, 1 reply; 6+ messages in thread From: Rob Herring @ 2017-05-04 18:00 UTC (permalink / raw) To: devicetree, Frank Rowand, Mark Rutland; +Cc: linux-kernel sparse generates the following warnings in drivers/of/: ../drivers/of/fdt.c:63:36: warning: cast to restricted __be32 ../drivers/of/fdt.c:68:33: warning: cast to restricted __be32 ../drivers/of/irq.c:105:88: warning: incorrect type in initializer (different base types) ../drivers/of/irq.c:105:88: expected restricted __be32 ../drivers/of/irq.c:105:88: got int ../drivers/of/irq.c:526:35: warning: incorrect type in assignment (different modifiers) ../drivers/of/irq.c:526:35: expected int ( *const [usertype] irq_init_cb )( ... ) ../drivers/of/irq.c:526:35: got void const *const data ../drivers/of/resolver.c:95:42: warning: incorrect type in assignment (different base types) ../drivers/of/resolver.c:95:42: expected unsigned int [unsigned] [usertype] <noident> ../drivers/of/resolver.c:95:42: got restricted __be32 [usertype] <noident> All these are harmless type mismatches fixed by adjusting the types. Signed-off-by: Rob Herring <robh@kernel.org> --- drivers/of/fdt.c | 4 ++-- drivers/of/irq.c | 2 +- drivers/of/resolver.c | 2 +- include/linux/of_irq.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index e33f7818bc6c..a0972219ccfc 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -48,8 +48,8 @@ void of_fdt_limit_memory(int limit) const void *val; int nr_address_cells = OF_ROOT_NODE_ADDR_CELLS_DEFAULT; int nr_size_cells = OF_ROOT_NODE_SIZE_CELLS_DEFAULT; - const uint32_t *addr_prop; - const uint32_t *size_prop; + const __be32 *addr_prop; + const __be32 *size_prop; int root_offset; int cell_size; diff --git a/drivers/of/irq.c b/drivers/of/irq.c index 7c56b72d1dc6..d11437cb1187 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c @@ -102,7 +102,7 @@ int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq) struct device_node *ipar, *tnode, *old = NULL, *newpar = NULL; __be32 initial_match_array[MAX_PHANDLE_ARGS]; const __be32 *match_array = initial_match_array; - const __be32 *tmp, *imap, *imask, dummy_imask[] = { [0 ... MAX_PHANDLE_ARGS] = ~0 }; + const __be32 *tmp, *imap, *imask, dummy_imask[] = { [0 ... MAX_PHANDLE_ARGS] = cpu_to_be32(~0) }; u32 intsize = 1, addrsize, newintsize = 0, newaddrsize = 0; int imaplen, match, i, rc = -EINVAL; diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c index 7ae9863cb0a4..771f4844c781 100644 --- a/drivers/of/resolver.c +++ b/drivers/of/resolver.c @@ -92,7 +92,7 @@ static void adjust_overlay_phandles(struct device_node *overlay, if (phandle == OF_PHANDLE_ILLEGAL) continue; - *(uint32_t *)prop->value = cpu_to_be32(overlay->phandle); + *(__be32 *)prop->value = cpu_to_be32(overlay->phandle); } for_each_child_of_node(overlay, child) diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h index 1e0deb8e8494..ec6b11deb773 100644 --- a/include/linux/of_irq.h +++ b/include/linux/of_irq.h @@ -8,7 +8,7 @@ #include <linux/ioport.h> #include <linux/of.h> -typedef int (*of_irq_init_cb_t)(struct device_node *, struct device_node *); +typedef int const (*of_irq_init_cb_t)(struct device_node *, struct device_node *); /* * Workarounds only applied to 32bit powermac machines -- 2.11.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 3/3] of: fix sparse warnings in fdt, irq, and resolver code 2017-05-04 18:00 ` [PATCH 3/3] of: fix sparse warnings in fdt, irq, and resolver code Rob Herring @ 2017-05-05 5:16 ` Frank Rowand 0 siblings, 0 replies; 6+ messages in thread From: Frank Rowand @ 2017-05-05 5:16 UTC (permalink / raw) To: Rob Herring, devicetree, Mark Rutland; +Cc: linux-kernel On 05/04/17 11:00, Rob Herring wrote: > sparse generates the following warnings in drivers/of/: > > ../drivers/of/fdt.c:63:36: warning: cast to restricted __be32 > ../drivers/of/fdt.c:68:33: warning: cast to restricted __be32 > ../drivers/of/irq.c:105:88: warning: incorrect type in initializer (different base types) > ../drivers/of/irq.c:105:88: expected restricted __be32 > ../drivers/of/irq.c:105:88: got int > ../drivers/of/irq.c:526:35: warning: incorrect type in assignment (different modifiers) > ../drivers/of/irq.c:526:35: expected int ( *const [usertype] irq_init_cb )( ... ) > ../drivers/of/irq.c:526:35: got void const *const data > ../drivers/of/resolver.c:95:42: warning: incorrect type in assignment (different base types) > ../drivers/of/resolver.c:95:42: expected unsigned int [unsigned] [usertype] <noident> > ../drivers/of/resolver.c:95:42: got restricted __be32 [usertype] <noident> > > All these are harmless type mismatches fixed by adjusting the types. > > Signed-off-by: Rob Herring <robh@kernel.org> > --- > drivers/of/fdt.c | 4 ++-- > drivers/of/irq.c | 2 +- > drivers/of/resolver.c | 2 +- > include/linux/of_irq.h | 2 +- > 4 files changed, 5 insertions(+), 5 deletions(-) > > diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c > index e33f7818bc6c..a0972219ccfc 100644 > --- a/drivers/of/fdt.c > +++ b/drivers/of/fdt.c > @@ -48,8 +48,8 @@ void of_fdt_limit_memory(int limit) > const void *val; > int nr_address_cells = OF_ROOT_NODE_ADDR_CELLS_DEFAULT; > int nr_size_cells = OF_ROOT_NODE_SIZE_CELLS_DEFAULT; > - const uint32_t *addr_prop; > - const uint32_t *size_prop; > + const __be32 *addr_prop; > + const __be32 *size_prop; > int root_offset; > int cell_size; > > diff --git a/drivers/of/irq.c b/drivers/of/irq.c > index 7c56b72d1dc6..d11437cb1187 100644 > --- a/drivers/of/irq.c > +++ b/drivers/of/irq.c > @@ -102,7 +102,7 @@ int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq) > struct device_node *ipar, *tnode, *old = NULL, *newpar = NULL; > __be32 initial_match_array[MAX_PHANDLE_ARGS]; > const __be32 *match_array = initial_match_array; > - const __be32 *tmp, *imap, *imask, dummy_imask[] = { [0 ... MAX_PHANDLE_ARGS] = ~0 }; > + const __be32 *tmp, *imap, *imask, dummy_imask[] = { [0 ... MAX_PHANDLE_ARGS] = cpu_to_be32(~0) }; > u32 intsize = 1, addrsize, newintsize = 0, newaddrsize = 0; > int imaplen, match, i, rc = -EINVAL; > > diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c > index 7ae9863cb0a4..771f4844c781 100644 > --- a/drivers/of/resolver.c > +++ b/drivers/of/resolver.c > @@ -92,7 +92,7 @@ static void adjust_overlay_phandles(struct device_node *overlay, > if (phandle == OF_PHANDLE_ILLEGAL) > continue; > > - *(uint32_t *)prop->value = cpu_to_be32(overlay->phandle); > + *(__be32 *)prop->value = cpu_to_be32(overlay->phandle); > } > > for_each_child_of_node(overlay, child) > diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h > index 1e0deb8e8494..ec6b11deb773 100644 > --- a/include/linux/of_irq.h > +++ b/include/linux/of_irq.h > @@ -8,7 +8,7 @@ > #include <linux/ioport.h> > #include <linux/of.h> > > -typedef int (*of_irq_init_cb_t)(struct device_node *, struct device_node *); > +typedef int const (*of_irq_init_cb_t)(struct device_node *, struct device_node *); > > /* > * Workarounds only applied to 32bit powermac machines > Reviewed-by: Frank Rowand <frank.rowand@sony.com> ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3] of: fix sparse warnings in of_find_next_cache_node 2017-05-04 18:00 [PATCH 1/3] of: fix sparse warnings in of_find_next_cache_node Rob Herring 2017-05-04 18:00 ` [PATCH 2/3] of: fix sparse warning in of_pci_range_parser_one Rob Herring 2017-05-04 18:00 ` [PATCH 3/3] of: fix sparse warnings in fdt, irq, and resolver code Rob Herring @ 2017-05-05 5:15 ` Frank Rowand 2 siblings, 0 replies; 6+ messages in thread From: Frank Rowand @ 2017-05-05 5:15 UTC (permalink / raw) To: Rob Herring, devicetree, Mark Rutland; +Cc: linux-kernel On 05/04/17 11:00, Rob Herring wrote: > sparse gives a warning that 'handle' is not a __be32: > > ../drivers/of/base.c:2261:61: warning: incorrect type in argument 1 (different base types) > ../drivers/of/base.c:2261:61: expected restricted __be32 const [usertype] *p > ../drivers/of/base.c:2261:61: got unsigned int const [usertype] *[assigned] handle > > We could just change the type, but the code can be improved by using > of_parse_phandle instead of open coding it with of_get_property and > of_find_node_by_phandle. > > Signed-off-by: Rob Herring <robh@kernel.org> > --- > drivers/of/base.c | 13 ++++++------- > 1 file changed, 6 insertions(+), 7 deletions(-) > > diff --git a/drivers/of/base.c b/drivers/of/base.c > index d7c4629a3a2d..016f9d77d64d 100644 > --- a/drivers/of/base.c > +++ b/drivers/of/base.c > @@ -2250,15 +2250,14 @@ EXPORT_SYMBOL_GPL(of_console_check); > */ > struct device_node *of_find_next_cache_node(const struct device_node *np) > { > - struct device_node *child; > - const phandle *handle; > + struct device_node *child, *cache_node; > > - handle = of_get_property(np, "l2-cache", NULL); > - if (!handle) > - handle = of_get_property(np, "next-level-cache", NULL); > + cache_node = of_parse_phandle(np, "l2-cache", 0); > + if (!cache_node) > + cache_node = of_parse_phandle(np, "next-level-cache", 0); > > - if (handle) > - return of_find_node_by_phandle(be32_to_cpup(handle)); > + if (cache_node) > + return cache_node; > > /* OF on pmac has nodes instead of properties named "l2-cache" > * beneath CPU nodes. > Reviewed-by: Frank Rowand <frank.rowand@sony.com> ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-05-05 5:16 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2017-05-04 18:00 [PATCH 1/3] of: fix sparse warnings in of_find_next_cache_node Rob Herring 2017-05-04 18:00 ` [PATCH 2/3] of: fix sparse warning in of_pci_range_parser_one Rob Herring 2017-05-05 5:16 ` Frank Rowand 2017-05-04 18:00 ` [PATCH 3/3] of: fix sparse warnings in fdt, irq, and resolver code Rob Herring 2017-05-05 5:16 ` Frank Rowand 2017-05-05 5:15 ` [PATCH 1/3] of: fix sparse warnings in of_find_next_cache_node Frank Rowand
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).