linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Hilman <khilman@ti.com>
To: Benoit Cousson <b-cousson@ti.com>
Cc: grant.likely@secretlab.ca, paul@pwsan.com,
	linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Subject: Re: [RFC PATCH 2/3] OMAP: omap_device: Add a DT parser for multiple strings
Date: Thu, 01 Sep 2011 11:38:22 -0700	[thread overview]
Message-ID: <87d3fkds69.fsf@ti.com> (raw)
In-Reply-To: <1314037343-19783-3-git-send-email-b-cousson@ti.com> (Benoit Cousson's message of "Mon, 22 Aug 2011 20:22:22 +0200")

Benoit Cousson <b-cousson@ti.com> writes:

> Add two helpers function to parse a property that contains multiple
> strings.
>
> These functions might be exported and moved to a common place if they
> can to be useful elsewhere.
>
> Signed-off-by: Benoit Cousson <b-cousson@ti.com>
> Cc: Kevin Hilman <khilman@ti.com>

These should just be folded into 3/3 where they are used (with a comment
changelog of course.)

Kevin

> ---
>  arch/arm/plat-omap/omap_device.c |   39 ++++++++++++++++++++++++++++++++++++++
>  1 files changed, 39 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/plat-omap/omap_device.c b/arch/arm/plat-omap/omap_device.c
> index 752d72a..70361f8 100644
> --- a/arch/arm/plat-omap/omap_device.c
> +++ b/arch/arm/plat-omap/omap_device.c
> @@ -315,6 +315,45 @@ static void _add_hwmod_clocks_clkdev(struct omap_device *od,
>  		_add_clkdev(od, oh->opt_clks[i].role, oh->opt_clks[i].clk);
>  }
>  
> +/*
> + * XXX: DT helper functions that should probably move elsewhere if
> + * they become usefull for other needs.
> + */
> +static int _dt_count_property_string(const char *prop, int len)
> +{
> +	int i = 0;
> +	size_t l = 0, total = 0;
> +
> +	if (!prop || !len)
> +		return -EINVAL;
> +
> +	for (i = 0; len >= total; total += l, prop += l) {
> +		l = strlen(prop) + 1;
> +		if (*prop != 0)
> +			i++;
> +	}
> +	return i;
> +}
> +
> +static int _dt_get_property(const char *prop, int len, int index, char *output,
> +			    int size)
> +{
> +	int i = 0;
> +	size_t l = 0, total = 0;
> +
> +	if (!prop || !len)
> +		return -EINVAL;
> +
> +	for (i = 0; len >= total; total += l, prop += l) {
> +		l = strlcpy(output, prop, size) + 1;
> +		if (*prop != 0) {
> +			if (i++ == index)
> +				return 0;
> +		}
> +	}
> +	return -ENODEV;
> +}
> +
>  
>  /* Public functions for use by core code */

  reply	other threads:[~2011-09-01 18:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-22 18:22 [RFC PATCH 0/3] OMAP: omap_device: Add a method to build an omap_device from a DT node Benoit Cousson
2011-08-22 18:22 ` [RFC PATCH 1/3] OMAP: omap_device: Add omap_device_[alloc|delete] for DT integration Benoit Cousson
2011-09-01 18:30   ` Kevin Hilman
2011-09-02 15:22     ` Cousson, Benoit
2011-09-02 16:20       ` Kevin Hilman
2011-08-22 18:22 ` [RFC PATCH 2/3] OMAP: omap_device: Add a DT parser for multiple strings Benoit Cousson
2011-09-01 18:38   ` Kevin Hilman [this message]
2011-09-02 15:32     ` Cousson, Benoit
2011-08-22 18:22 ` [RFC PATCH 3/3] OMAP: omap_device: Add a method to build an omap_device from a DT node Benoit Cousson
2011-08-30 13:31   ` Cousson, Benoit
2011-09-01 23:40   ` Kevin Hilman
2011-09-02 15:35     ` Cousson, Benoit

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=87d3fkds69.fsf@ti.com \
    --to=khilman@ti.com \
    --cc=b-cousson@ti.com \
    --cc=grant.likely@secretlab.ca \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=paul@pwsan.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;
as well as URLs for NNTP newsgroup(s).