From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Grall Subject: Re: [PATCH V2 08/33] xen/arm: Add helpers to use the device tree Date: Wed, 08 May 2013 16:31:08 +0100 Message-ID: <518A6FBC.2020703@linaro.org> References: <81cae3ed3ae6da555f2f37d9aab1ba59d7e274c3.1367979526.git.julien.grall@linaro.org> <1368019086.26321.290.camel@zakaz.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1368019086.26321.290.camel@zakaz.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Campbell Cc: Stefano Stabellini , "patches@linaro.org" , "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org On 05/08/2013 02:18 PM, Ian Campbell wrote: > On Wed, 2013-05-08 at 03:33 +0100, Julien Grall wrote: >> Signed-off-by: Julien Grall >> >> Changes in v2: >> - use dt_node_cmp and dt_compat_cmp in early device tree code >> --- >> xen/common/device_tree.c | 127 ++++++++++++++++++++++++++++++++++++++++- >> xen/include/xen/device_tree.h | 120 ++++++++++++++++++++++++++++++++++++++ >> 2 files changed, 245 insertions(+), 2 deletions(-) >> >> diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c >> index bdf8871..449c332 100644 >> --- a/xen/common/device_tree.c >> +++ b/xen/common/device_tree.c >> @@ -88,20 +88,23 @@ bool_t device_tree_type_matches(const void *fdt, int node, const char *match) >> if ( prop == NULL ) >> return 0; >> >> - return !strcmp(prop, match); >> + return !dt_node_cmp(prop, match); >> } >> >> bool_t device_tree_node_compatible(const void *fdt, int node, const char *match) > > Aside: I wonder if any of these should be __init... I think yes. > >> { >> int len, l; >> + int mlen; >> const void *prop; >> >> + mlen = strlen(match); >> + >> prop = fdt_getprop(fdt, node, "compatible", &len); >> if ( prop == NULL ) >> return 0; >> >> while ( len > 0 ) { >> - if ( !strcmp(prop, match) ) >> + if ( !dt_compat_cmp(prop, match, mlen) ) > > Is there a change in behaviour here where strlen(match) < strlen(prop)? > > I may be mistaken but I think match=="foo" would be compatible with a > node "foobar" now whereas it wasn't before. I have checked the linux code and the also use strncmp with the length of "match"/"compatible". > On the otherhand this is the same behaviour as dt_device_is_compatible > so maybe it is expected. I seem to recall some name matching code which > explicitly wanted to handle foo@0 as matching foo and things, not sure > that applies here though. This behaviour only happens for the compatible node. -- Julien Grall