Re: [PATCH] mtd: physmap_of: use OF helpers for reading strings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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

> From: Rafał Miłecki <rafal@xxxxxxxxxx>
> 
> 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@xxxxxxxxxx>

Reviewed-by: Boris Brezillon <boris.brezillon@xxxxxxxxxxxxxxxxxx>

> ---
>  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@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]
  Powered by Linux