From: "Cousson, Benoit" <b-cousson@ti.com>
To: "Hilman, Kevin" <khilman@ti.com>
Cc: "grant.likely@secretlab.ca" <grant.likely@secretlab.ca>,
"paul@pwsan.com" <paul@pwsan.com>,
"linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>
Subject: Re: [RFC PATCH 2/3] OMAP: omap_device: Add a DT parser for multiple strings
Date: Fri, 2 Sep 2011 17:32:52 +0200 [thread overview]
Message-ID: <4E60F724.8060702@ti.com> (raw)
In-Reply-To: <87d3fkds69.fsf@ti.com>
On 9/1/2011 8:38 PM, Hilman, Kevin wrote:
> 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.)
I did that because I was hoping to generalize them or to remove them if
something better become available in DT core. And it seems that Stephen
Warren from nvidia introduced a generic iterator for properties:
http://www.spinics.net/lists/arm-kernel/msg138013.html
But since it is not in mainline or even in devicetree/test, I still have
to add mine for the moment.
Regards,
Benoit
>
> 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 */
WARNING: multiple messages have this Message-ID (diff)
From: b-cousson@ti.com (Cousson, Benoit)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 2/3] OMAP: omap_device: Add a DT parser for multiple strings
Date: Fri, 2 Sep 2011 17:32:52 +0200 [thread overview]
Message-ID: <4E60F724.8060702@ti.com> (raw)
In-Reply-To: <87d3fkds69.fsf@ti.com>
On 9/1/2011 8:38 PM, Hilman, Kevin wrote:
> 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.)
I did that because I was hoping to generalize them or to remove them if
something better become available in DT core. And it seems that Stephen
Warren from nvidia introduced a generic iterator for properties:
http://www.spinics.net/lists/arm-kernel/msg138013.html
But since it is not in mainline or even in devicetree/test, I still have
to add mine for the moment.
Regards,
Benoit
>
> 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 */
next prev parent reply other threads:[~2011-09-02 15:32 UTC|newest]
Thread overview: 24+ 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 ` 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-08-22 18:22 ` Benoit Cousson
2011-09-01 18:30 ` Kevin Hilman
2011-09-01 18:30 ` Kevin Hilman
2011-09-02 15:22 ` Cousson, Benoit
2011-09-02 15:22 ` Cousson, Benoit
2011-09-02 16:20 ` Kevin Hilman
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-08-22 18:22 ` Benoit Cousson
2011-09-01 18:38 ` Kevin Hilman
2011-09-01 18:38 ` Kevin Hilman
2011-09-02 15:32 ` Cousson, Benoit [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-22 18:22 ` Benoit Cousson
2011-08-30 13:31 ` Cousson, Benoit
2011-08-30 13:31 ` Cousson, Benoit
2011-09-01 23:40 ` Kevin Hilman
2011-09-01 23:40 ` Kevin Hilman
2011-09-02 15:35 ` Cousson, Benoit
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=4E60F724.8060702@ti.com \
--to=b-cousson@ti.com \
--cc=grant.likely@secretlab.ca \
--cc=khilman@ti.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.