linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: ppc-dev <linuxppc-dev@ozlabs.org>,
	paulus@samba.org, "David S. Miller" <davem@davemloft.net>
Subject: Re: [PATCH 2/6] Consolidate of_device_is_compatible
Date: Wed, 25 Apr 2007 09:59:24 +1000	[thread overview]
Message-ID: <1177459165.14873.153.camel@localhost.localdomain> (raw)
In-Reply-To: <20070424223812.2842f3f2.sfr@canb.auug.org.au>

On Tue, 2007-04-24 at 22:38 +1000, Stephen Rothwell wrote:
> The only difference here is that Sparc uses strncmp to match compatibility
> names while PowerPC uses strncasecmp.

We should settle for a single implementation. In theory, strncmp would
be the way to go but there have been "bugs" here or there, especially in
Apple DTs, that made me use strncasecmp instead in the past.

Dave, what do you reckon ? I should try to find out the bogus machines
and add workarounds in the various drivers etc... instead or we can just
go common on strncasecmp ?

Ben.

> Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
> ---
>  arch/powerpc/kernel/prom.c |   25 -------------------------
>  arch/sparc/kernel/prom.c   |   21 ---------------------
>  arch/sparc64/kernel/prom.c |   21 ---------------------
>  drivers/openfw/base.c      |   24 ++++++++++++++++++++++++
>  include/asm-powerpc/prom.h |    2 ++
>  include/asm-sparc/prom.h   |    2 ++
>  include/asm-sparc64/prom.h |    2 ++
>  7 files changed, 30 insertions(+), 67 deletions(-)
> 
> -- 
> Cheers,
> Stephen Rothwell                    sfr@canb.auug.org.au
> 
> diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
> index d701e89..723df55 100644
> --- a/arch/powerpc/kernel/prom.c
> +++ b/arch/powerpc/kernel/prom.c
> @@ -1042,31 +1042,6 @@ void __init early_init_devtree(void *params)
>  
>  #undef printk
>  
> -/** Checks if the given "compat" string matches one of the strings in
> - * the device's "compatible" property
> - */
> -int of_device_is_compatible(const struct device_node *device,
> -		const char *compat)
> -{
> -	const char* cp;
> -	int cplen, l;
> -
> -	cp = of_get_property(device, "compatible", &cplen);
> -	if (cp == NULL)
> -		return 0;
> -	while (cplen > 0) {
> -		if (strncasecmp(cp, compat, strlen(compat)) == 0)
> -			return 1;
> -		l = strlen(cp) + 1;
> -		cp += l;
> -		cplen -= l;
> -	}
> -
> -	return 0;
> -}
> -EXPORT_SYMBOL(of_device_is_compatible);
> -
> -
>  /**
>   * Indicates whether the root node has a given value in its
>   * compatible property.
> diff --git a/arch/sparc/kernel/prom.c b/arch/sparc/kernel/prom.c
> index ac3f3c2..f2ce0d4 100644
> --- a/arch/sparc/kernel/prom.c
> +++ b/arch/sparc/kernel/prom.c
> @@ -32,27 +32,6 @@ static struct device_node *allnodes;
>   */
>  static DEFINE_RWLOCK(devtree_lock);
>  
> -int of_device_is_compatible(const struct device_node *device,
> -			    const char *compat)
> -{
> -	const char* cp;
> -	int cplen, l;
> -
> -	cp = of_get_property(device, "compatible", &cplen);
> -	if (cp == NULL)
> -		return 0;
> -	while (cplen > 0) {
> -		if (strncmp(cp, compat, strlen(compat)) == 0)
> -			return 1;
> -		l = strlen(cp) + 1;
> -		cp += l;
> -		cplen -= l;
> -	}
> -
> -	return 0;
> -}
> -EXPORT_SYMBOL(of_device_is_compatible);
> -
>  struct device_node *of_get_parent(const struct device_node *node)
>  {
>  	struct device_node *np;
> diff --git a/arch/sparc64/kernel/prom.c b/arch/sparc64/kernel/prom.c
> index 7ef5488..d6dd972 100644
> --- a/arch/sparc64/kernel/prom.c
> +++ b/arch/sparc64/kernel/prom.c
> @@ -36,27 +36,6 @@ static struct device_node *allnodes;
>   */
>  static DEFINE_RWLOCK(devtree_lock);
>  
> -int of_device_is_compatible(const struct device_node *device,
> -			    const char *compat)
> -{
> -	const char* cp;
> -	int cplen, l;
> -
> -	cp = of_get_property(device, "compatible", &cplen);
> -	if (cp == NULL)
> -		return 0;
> -	while (cplen > 0) {
> -		if (strncmp(cp, compat, strlen(compat)) == 0)
> -			return 1;
> -		l = strlen(cp) + 1;
> -		cp += l;
> -		cplen -= l;
> -	}
> -
> -	return 0;
> -}
> -EXPORT_SYMBOL(of_device_is_compatible);
> -
>  struct device_node *of_get_parent(const struct device_node *node)
>  {
>  	struct device_node *np;
> diff --git a/drivers/openfw/base.c b/drivers/openfw/base.c
> index 04a8cc2..0751313 100644
> --- a/drivers/openfw/base.c
> +++ b/drivers/openfw/base.c
> @@ -63,3 +63,27 @@ const void *of_get_property(const struct device_node *np, const char *name,
>  	return pp ? pp->value : NULL;
>  }
>  EXPORT_SYMBOL(of_get_property);
> +
> +/** Checks if the given "compat" string matches one of the strings in
> + * the device's "compatible" property
> + */
> +int of_device_is_compatible(const struct device_node *device,
> +		const char *compat)
> +{
> +	const char* cp;
> +	int cplen, l;
> +
> +	cp = of_get_property(device, "compatible", &cplen);
> +	if (cp == NULL)
> +		return 0;
> +	while (cplen > 0) {
> +		if (of_compat_cmp(cp, compat, strlen(compat)) == 0)
> +			return 1;
> +		l = strlen(cp) + 1;
> +		cp += l;
> +		cplen -= l;
> +	}
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL(of_device_is_compatible);
> diff --git a/include/asm-powerpc/prom.h b/include/asm-powerpc/prom.h
> index 30cea54..1f3e8cd 100644
> --- a/include/asm-powerpc/prom.h
> +++ b/include/asm-powerpc/prom.h
> @@ -24,6 +24,8 @@
>  #define OF_ROOT_NODE_ADDR_CELLS_DEFAULT	1
>  #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT	1
>  
> +#define of_compat_cmp(s1, s2, l)	strncasecmp((s1), (s2), (l))
> +
>  /* Definitions used by the flattened device tree */
>  #define OF_DT_HEADER		0xd00dfeed	/* marker */
>  #define OF_DT_BEGIN_NODE	0x1		/* Start of node, full name */
> diff --git a/include/asm-sparc/prom.h b/include/asm-sparc/prom.h
> index 411018d..cc049fd 100644
> --- a/include/asm-sparc/prom.h
> +++ b/include/asm-sparc/prom.h
> @@ -23,6 +23,8 @@
>  #define OF_ROOT_NODE_ADDR_CELLS_DEFAULT	2
>  #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT	1
>  
> +#define of_compat_cmp(s1, s2, l)	strncmp((s1), (s2), (l))
> +
>  typedef u32 phandle;
>  typedef u32 ihandle;
>  
> diff --git a/include/asm-sparc64/prom.h b/include/asm-sparc64/prom.h
> index 1097e66..843f9e8 100644
> --- a/include/asm-sparc64/prom.h
> +++ b/include/asm-sparc64/prom.h
> @@ -23,6 +23,8 @@
>  #define OF_ROOT_NODE_ADDR_CELLS_DEFAULT	2
>  #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT	1
>  
> +#define of_compat_cmp(s1, s2, l)	strncmp((s1), (s2), (l))
> +
>  typedef u32 phandle;
>  typedef u32 ihandle;
>  

  parent reply	other threads:[~2007-04-24 23:59 UTC|newest]

Thread overview: 109+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-03  0:52 [PATCH 1/6] [POWERPC] get_property returns const Stephen Rothwell
2007-04-03  0:54 ` [PATCH 2/6] [POWERPC] Rename get_property to of_get_property Stephen Rothwell
2007-04-03  0:55   ` [PATCH 3/6] [POWERPC] Rename device_is_compatible to of_device_is_compatible Stephen Rothwell
2007-04-03  0:56     ` [PATCH 4/6] [POWERPC] Rename prom_n_addr_cells to of_n_addr_cells Stephen Rothwell
2007-04-03  0:57       ` [PATCH 5/6] [POWERPC] Rename prom_n_size_cells to of_n_size_cells Stephen Rothwell
2007-04-03  0:58         ` [PATCH 6/6] [POWERPC] make struct property's value a void * Stephen Rothwell
2007-04-03  3:37           ` David Miller
2007-04-03 15:40             ` Segher Boessenkool
2007-04-03 12:24           ` [PATCH 01/17] [POWERPC] Rename get_property to of_get_property: include Stephen Rothwell
2007-04-03 12:26             ` [PATCH 02/17] [POWERPC] Rename get_property to of_get_property: arch/powerpc/kernel Stephen Rothwell
2007-04-03 12:28               ` [PATCH 03/17] [POWERPC] Rename get_property to of_get_property: arch/powerpc/mm Stephen Rothwell
2007-04-03 12:30                 ` [PATCH 04/17] [POWERPC] Rename get_property to of_get_property: arch/powerpc/sysdev Stephen Rothwell
2007-04-03 12:31                   ` [PATCH 05/17] [POWERPC] Rename get_property to of_get_property: arch/powerpc/platforms/pseries Stephen Rothwell
2007-04-03 12:32                     ` [PATCH 06/17] [POWERPC] Rename get_property to of_get_property: arch/powerpc/platforms/powermac Stephen Rothwell
2007-04-03 12:35                       ` [PATCH 07/17] [POWERPC] Rename get_property to of_get_property: arch/powerpc/platforms/cell Stephen Rothwell
2007-04-03 12:37                         ` [PATCH 08/17] [POWERPC] Rename get_property to of_get_property: arch/powerpc/platforms Stephen Rothwell
2007-04-03 12:39                           ` [PATCH 09/17] [POWERPC] Rename get_property to of_get_property: sound Stephen Rothwell
2007-04-03 12:40                             ` [PATCH 10/17] [POWERPC] Rename get_property to of_get_property: drivers/macintosh Stephen Rothwell
2007-04-03 12:42                               ` [PATCH 11/17] [POWERPC] Rename get_property to of_get_property: drivers/char Stephen Rothwell
2007-04-03 12:43                                 ` [PATCH 12/17] [POWERPC] Rename get_property to of_get_property: drivers/net Stephen Rothwell
2007-04-03 12:45                                   ` [PATCH 13/17] [POWERPC] Rename get_property to of_get_property: drivers/video Stephen Rothwell
2007-04-03 12:46                                     ` [PATCH 14/17] [POWERPC] Rename get_property to of_get_property: drivers/scsi Stephen Rothwell
2007-04-03 12:49                                       ` [PATCH 15/17] [POWERPC] Rename get_property to of_get_property: drivers Stephen Rothwell
2007-04-03 12:50                                         ` [PATCH 16/17] [POWERPC] Rename get_property to of_get_property: the last one Stephen Rothwell
2007-04-03 12:52                                           ` [PATCH 17/17] [POWERPC] Remove get_property Stephen Rothwell
2007-04-03 13:05                                             ` [PATCH] [SPARC/64] " Stephen Rothwell
2007-04-03 13:24                                               ` [PATCH] [SPARC/64] Make device_node name and type const Stephen Rothwell
2007-04-12  4:19                                                 ` [PATCH,RFC] Split out common parts of prom.h Stephen Rothwell
2007-04-12  4:25                                                   ` David Miller
2007-04-12 16:13                                                     ` Kumar Gala
2007-04-12 19:19                                                       ` Segher Boessenkool
2007-04-12  5:34                                                   ` [PATCH] Start split out of common open firmware code Stephen Rothwell
     [not found]                                                     ` <20070424223245.78f4fdfb.sfr@canb.auug .org.au>
2007-04-12  5:41                                                     ` David Miller
2007-04-12  5:50                                                     ` Benjamin Herrenschmidt
2007-04-12  6:25                                                       ` David Miller
2007-04-12  6:36                                                         ` Benjamin Herrenschmidt
2007-04-12  6:40                                                           ` David Miller
2007-04-12  7:00                                                         ` Segher Boessenkool
2007-04-23  7:43                                                           ` Stephen Rothwell
2007-04-23 18:30                                                             ` Segher Boessenkool
2007-04-24 12:32                                                     ` [PATCH 1/6] " Stephen Rothwell
2007-04-24 12:38                                                       ` [PATCH 2/6] Consolidate of_device_is_compatible Stephen Rothwell
2007-04-24 13:36                                                         ` Segher Boessenkool
2007-04-24 23:59                                                         ` Benjamin Herrenschmidt [this message]
2007-04-25  4:23                                                           ` David Miller
2007-04-24 12:39                                                       ` [PATCH 3/6] Consolidate of_find_property Stephen Rothwell
2007-04-24 13:41                                                         ` Segher Boessenkool
2007-04-25  1:43                                                           ` Paul Mackerras
2007-04-25  2:10                                                             ` Segher Boessenkool
2007-04-25  4:31                                                             ` David Miller
2007-04-25  5:07                                                             ` Benjamin Herrenschmidt
2007-04-25 13:13                                                               ` Segher Boessenkool
2007-04-25 17:46                                                                 ` Matt Sealey
2007-04-25 19:02                                                                   ` Segher Boessenkool
2007-04-25 22:16                                                                   ` Benjamin Herrenschmidt
2007-04-25 22:24                                                                     ` David Miller
2007-04-25 22:47                                                                       ` Benjamin Herrenschmidt
2007-04-25 23:13                                                                         ` David Miller
2007-04-25 23:18                                                                           ` Segher Boessenkool
2007-04-25 23:28                                                                             ` David Miller
2007-04-25 23:21                                                                           ` Benjamin Herrenschmidt
2007-04-26  5:54                                                                           ` Stephen Rothwell
2007-04-26  5:58                                                                             ` David Miller
2007-04-25  0:00                                                         ` Benjamin Herrenschmidt
2007-04-25  0:43                                                           ` Segher Boessenkool
2007-04-25  1:12                                                             ` Benjamin Herrenschmidt
2007-04-25  2:03                                                               ` Segher Boessenkool
2007-04-25  4:24                                                           ` David Miller
2007-04-24 12:40                                                       ` [PATCH 4/6] Consolidate of_get_parent Stephen Rothwell
2007-04-24 14:42                                                         ` Loeliger Jon-LOELIGER
2007-04-26  1:34                                                           ` Stephen Rothwell
2007-04-24 12:42                                                       ` [PATCH 5/6] Consolidate of_get_next_child Stephen Rothwell
2007-04-24 12:43                                                       ` [PATCH 6/6] Consolidate of_find_node_by routines Stephen Rothwell
2007-04-25  0:01                                                         ` Benjamin Herrenschmidt
2007-04-24 13:27                                                       ` [PATCH 1/6] Start split out of common open firmware code Segher Boessenkool
2007-04-24 14:47                                                         ` Loeliger Jon-LOELIGER
2007-04-24 18:04                                                           ` David Miller
2007-04-24 18:18                                                             ` Segher Boessenkool
2007-04-24 19:14                                                               ` Jon Loeliger
2007-04-25  0:07                                                             ` Benjamin Herrenschmidt
2007-04-25  1:03                                                               ` Segher Boessenkool
2007-04-25  4:29                                                                 ` David Miller
2007-04-25 13:11                                                                   ` Segher Boessenkool
2007-04-25  0:03                                                         ` Benjamin Herrenschmidt
2007-04-25  0:50                                                           ` Segher Boessenkool
2007-04-25  1:51                                                             ` Josh Boyer
2007-04-25  2:07                                                               ` Segher Boessenkool
2007-04-25  4:27                                                             ` David Miller
2007-04-25 13:07                                                               ` Segher Boessenkool
2007-04-24 23:35                                                       ` David Miller
2007-04-12  6:58                                                   ` [PATCH,RFC] Split out common parts of prom.h Segher Boessenkool
2007-04-12 21:41                                                 ` [PATCH] [SPARC/64] Make device_node name and type const David Miller
2007-04-12 21:42                                               ` [PATCH] [SPARC/64] Remove get_property David Miller
2007-04-27  3:41                                 ` [PATCH] [POWERPC] Rename get_property to of_get_property: partial drivers Stephen Rothwell
2007-04-03 17:36             ` [PATCH 01/17] [POWERPC] Rename get_property to of_get_property: include Olof Johansson
2007-04-05  1:49             ` Benjamin Herrenschmidt
2007-04-03 15:39           ` [PATCH 6/6] [POWERPC] make struct property's value a void * Segher Boessenkool
2007-04-03 18:28             ` David Miller
2007-04-04 11:11               ` Segher Boessenkool
2007-04-04 19:21                 ` David Miller
2007-04-05  1:48                   ` Benjamin Herrenschmidt
2007-04-05 18:12                   ` Segher Boessenkool
2007-04-05 23:01                     ` Benjamin Herrenschmidt
2007-04-05 23:12                       ` David Miller
2007-04-05 23:26                       ` Segher Boessenkool
2007-04-09 18:20                         ` Paul Mackerras
2007-04-09 22:11                           ` Segher Boessenkool
2007-04-09 23:17                           ` David Miller
2007-04-27  4:32 ` [PATCH] Partialially revert a7edd0e676d51145ae634a2acf7a447e319200fa Stephen Rothwell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1177459165.14873.153.camel@localhost.localdomain \
    --to=benh@kernel.crashing.org \
    --cc=davem@davemloft.net \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=paulus@samba.org \
    --cc=sfr@canb.auug.org.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).