All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: "Rafał Miłecki" <zajec5@gmail.com>
Cc: "David Woodhouse" <dwmw2@infradead.org>,
	"Brian Norris" <computersforpeace@gmail.com>,
	"Marek Vasut" <marek.vasut@gmail.com>,
	"Richard Weinberger" <richard@nod.at>,
	"Cyrille Pitchen" <cyrille.pitchen@atmel.com>,
	"Linus Walleij" <linus.walleij@linaro.org>,
	"Jason Gunthorpe" <jgunthorpe@obsidianresearch.com>,
	linux-mtd@lists.infradead.org, devicetree@vger.kernel.org,
	"Rafał Miłecki" <rafal@milecki.pl>
Subject: Re: [PATCH] mtd: physmap_of: use OF helpers for reading strings
Date: Fri, 31 Mar 2017 10:02:39 +0200	[thread overview]
Message-ID: <20170331100239.37a14f37@bbrezillon> (raw)
In-Reply-To: <20170330155853.30349-1-zajec5@gmail.com>

On Thu, 30 Mar 2017 17:58:53 +0200
Rafał Miłecki <zajec5@gmail.com> wrote:

> From: Rafał Miłecki <rafal@milecki.pl>
> 
> OF core code provides helpers for counting strings and reading them so
> use them instead of doing this manually. This simplifies the code a bit.
> 
> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>

Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>

> ---
>  drivers/mtd/maps/physmap_of.c | 30 ++++++++++--------------------
>  1 file changed, 10 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/mtd/maps/physmap_of.c b/drivers/mtd/maps/physmap_of.c
> index 14e8909c9955..62fa6836f218 100644
> --- a/drivers/mtd/maps/physmap_of.c
> +++ b/drivers/mtd/maps/physmap_of.c
> @@ -116,32 +116,22 @@ static const char * const part_probe_types_def[] = {
>  
>  static const char * const *of_get_probes(struct device_node *dp)
>  {
> -	const char *cp;
> -	int cplen;
> -	unsigned int l;
> -	unsigned int count;
>  	const char **res;
> +	int count;
>  
> -	cp = of_get_property(dp, "linux,part-probe", &cplen);
> -	if (cp == NULL)
> +	count = of_property_count_strings(dp, "linux,part-probe");
> +	if (count < 0)
>  		return part_probe_types_def;
>  
> -	count = 0;
> -	for (l = 0; l != cplen; l++)
> -		if (cp[l] == 0)
> -			count++;
> -
> -	res = kzalloc((count + 1)*sizeof(*res), GFP_KERNEL);
> +	res = kzalloc((count + 1) * sizeof(*res), GFP_KERNEL);
>  	if (!res)
>  		return NULL;
> -	count = 0;
> -	while (cplen > 0) {
> -		res[count] = cp;
> -		l = strlen(cp) + 1;
> -		cp += l;
> -		cplen -= l;
> -		count++;
> -	}
> +
> +	count = of_property_read_string_array(dp, "linux,part-probe", res,
> +					      count);
> +	if (count < 0)
> +		return NULL;
> +
>  	return res;
>  }
>  

WARNING: multiple messages have this Message-ID (diff)
From: Boris Brezillon <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
To: "Rafał Miłecki" <zajec5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: "David Woodhouse" <dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>,
	"Brian Norris"
	<computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	"Marek Vasut"
	<marek.vasut-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	"Richard Weinberger" <richard-/L3Ra7n9ekc@public.gmane.org>,
	"Cyrille Pitchen"
	<cyrille.pitchen-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>,
	"Linus Walleij"
	<linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	"Jason Gunthorpe"
	<jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>,
	linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	"Rafał Miłecki" <rafal-g1n6cQUeyibVItvQsEIGlw@public.gmane.org>
Subject: Re: [PATCH] mtd: physmap_of: use OF helpers for reading strings
Date: Fri, 31 Mar 2017 10:02:39 +0200	[thread overview]
Message-ID: <20170331100239.37a14f37@bbrezillon> (raw)
In-Reply-To: <20170330155853.30349-1-zajec5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

On Thu, 30 Mar 2017 17:58:53 +0200
Rafał Miłecki <zajec5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

> From: Rafał Miłecki <rafal-g1n6cQUeyibVItvQsEIGlw@public.gmane.org>
> 
> OF core code provides helpers for counting strings and reading them so
> use them instead of doing this manually. This simplifies the code a bit.
> 
> Signed-off-by: Rafał Miłecki <rafal-g1n6cQUeyibVItvQsEIGlw@public.gmane.org>

Reviewed-by: Boris Brezillon <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>

> ---
>  drivers/mtd/maps/physmap_of.c | 30 ++++++++++--------------------
>  1 file changed, 10 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/mtd/maps/physmap_of.c b/drivers/mtd/maps/physmap_of.c
> index 14e8909c9955..62fa6836f218 100644
> --- a/drivers/mtd/maps/physmap_of.c
> +++ b/drivers/mtd/maps/physmap_of.c
> @@ -116,32 +116,22 @@ static const char * const part_probe_types_def[] = {
>  
>  static const char * const *of_get_probes(struct device_node *dp)
>  {
> -	const char *cp;
> -	int cplen;
> -	unsigned int l;
> -	unsigned int count;
>  	const char **res;
> +	int count;
>  
> -	cp = of_get_property(dp, "linux,part-probe", &cplen);
> -	if (cp == NULL)
> +	count = of_property_count_strings(dp, "linux,part-probe");
> +	if (count < 0)
>  		return part_probe_types_def;
>  
> -	count = 0;
> -	for (l = 0; l != cplen; l++)
> -		if (cp[l] == 0)
> -			count++;
> -
> -	res = kzalloc((count + 1)*sizeof(*res), GFP_KERNEL);
> +	res = kzalloc((count + 1) * sizeof(*res), GFP_KERNEL);
>  	if (!res)
>  		return NULL;
> -	count = 0;
> -	while (cplen > 0) {
> -		res[count] = cp;
> -		l = strlen(cp) + 1;
> -		cp += l;
> -		cplen -= l;
> -		count++;
> -	}
> +
> +	count = of_property_read_string_array(dp, "linux,part-probe", res,
> +					      count);
> +	if (count < 0)
> +		return NULL;
> +
>  	return res;
>  }
>  

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2017-03-31  8:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-30 15:58 [PATCH] mtd: physmap_of: use OF helpers for reading strings Rafał Miłecki
2017-03-30 15:58 ` Rafał Miłecki
2017-03-31  8:02 ` Boris Brezillon [this message]
2017-03-31  8:02   ` Boris Brezillon
2017-04-20 22:27   ` Brian Norris
2017-04-20 22:27     ` Brian Norris

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=20170331100239.37a14f37@bbrezillon \
    --to=boris.brezillon@free-electrons.com \
    --cc=computersforpeace@gmail.com \
    --cc=cyrille.pitchen@atmel.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dwmw2@infradead.org \
    --cc=jgunthorpe@obsidianresearch.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marek.vasut@gmail.com \
    --cc=rafal@milecki.pl \
    --cc=richard@nod.at \
    --cc=zajec5@gmail.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.