From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752180AbdEEFPe (ORCPT ); Fri, 5 May 2017 01:15:34 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:35592 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750927AbdEEFPc (ORCPT ); Fri, 5 May 2017 01:15:32 -0400 Subject: Re: [PATCH 1/3] of: fix sparse warnings in of_find_next_cache_node To: Rob Herring , devicetree@vger.kernel.org, Mark Rutland References: <20170504180035.12834-1-robh@kernel.org> Cc: linux-kernel@vger.kernel.org From: Frank Rowand Message-ID: <590C0A6E.1080902@gmail.com> Date: Thu, 4 May 2017 22:15:26 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <20170504180035.12834-1-robh@kernel.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Frank Rowand Subject: Re: [PATCH 1/3] of: fix sparse warnings in of_find_next_cache_node Date: Thu, 4 May 2017 22:15:26 -0700 Message-ID: <590C0A6E.1080902@gmail.com> References: <20170504180035.12834-1-robh@kernel.org> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20170504180035.12834-1-robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> Sender: devicetree-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Rob Herring , devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Mark Rutland Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: devicetree@vger.kernel.org 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 > --- > 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 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html