mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: yegorslists@googlemail.com
Cc: barebox@lists.infradead.org, tpiepho@kymetacorp.com
Subject: Re: [PATCH v2 1/2] of: rework of_node_cmp() to support short and full node names
Date: Wed, 13 Jan 2016 16:50:13 +0100	[thread overview]
Message-ID: <20160113155013.GY13058@pengutronix.de> (raw)
In-Reply-To: <1452593799-21408-1-git-send-email-yegorslists@googlemail.com>

Hi Yegor,

On Tue, Jan 12, 2016 at 11:16:38AM +0100, yegorslists@googlemail.com wrote:
> + * Compare node names using the length of the node in question
> + * and then check, if the in-tree node has '@' as next character.
> + * This way both short names like 'name' and full like 'name@1' will
> + * be accepted.
> + */
> +int of_node_cmp(const char *s1, const char *s2)
> +{
> +	int len = strlen(s2);
> +
> +	if (strncasecmp(s1, s2, len) != 0)
> +		return 1;
> +
> +	if (s1[len] == '\0')
> +		return 0;
> +	else if (!memchr(s2, '@', len) && (s1[len] == '@'))
> +		return 0;
> +	else
> +		return 1;
> +}
> +
> +/*
>   * Iterate over all nodes of a tree. As a devicetree does not
>   * have a dedicated list head, the start node (usually the root
>   * node) will not be iterated over.
> diff --git a/include/of.h b/include/of.h
> index 75cc3c1..3b18eef 100644
> --- a/include/of.h
> +++ b/include/of.h
> @@ -10,7 +10,6 @@
>  /* Default string compare functions */
>  #define of_compat_cmp(s1, s2, l)	strcasecmp((s1), (s2))
>  #define of_prop_cmp(s1, s2)		strcmp((s1), (s2))
> -#define of_node_cmp(s1, s2)		strcasecmp((s1), (s2))

of_node_cmp is used elsewhere and a direct copy from the Kernel. You
should introduce a new function for your purpose instead of modifying
it.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2016-01-13 15:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-12 10:16 yegorslists
2016-01-12 10:16 ` [PATCH v2 2/2] FIT: bootm: accept configuration name as string yegorslists
2016-01-13 15:50 ` Sascha Hauer [this message]
2016-01-13 16:01   ` [PATCH v2 1/2] of: rework of_node_cmp() to support short and full node names Yegor Yefremov

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=20160113155013.GY13058@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=tpiepho@kymetacorp.com \
    --cc=yegorslists@googlemail.com \
    /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