Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1304524 > unrolled thread

[PATCH v3 2/9] device property: convert to use match_string() helper

Started byAndy Shevchenko <andriy.shevchenko@linux.intel.com>
First post2016-01-08 14:20 +0100
Last post2016-01-09 00:10 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v3 2/9] device property: convert to use match_string() helper Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2016-01-08 14:20 +0100
    Re: [PATCH v3 2/9] device property: convert to use match_string() helper "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-01-09 00:10 +0100

#1304524 — [PATCH v3 2/9] device property: convert to use match_string() helper

FromAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Date2016-01-08 14:20 +0100
Subject[PATCH v3 2/9] device property: convert to use match_string() helper
Message-ID<qOF7s-7eQ-27@gated-at.bofh.it>
The new helper returns index of the mathing string in an array. We would use it
here.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/base/property.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/base/property.c b/drivers/base/property.c
index c359351..f902b55 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -647,7 +647,7 @@ int fwnode_property_match_string(struct fwnode_handle *fwnode,
 	const char *propname, const char *string)
 {
 	const char **values;
-	int nval, ret, i;
+	int nval, ret;
 
 	nval = fwnode_property_read_string_array(fwnode, propname, NULL, 0);
 	if (nval < 0)
@@ -664,13 +664,7 @@ int fwnode_property_match_string(struct fwnode_handle *fwnode,
 	if (ret < 0)
 		goto out;
 
-	ret = -ENODATA;
-	for (i = 0; i < nval; i++) {
-		if (!strcmp(values[i], string)) {
-			ret = i;
-			break;
-		}
-	}
+	ret = match_string(values, nval, string);
 out:
 	kfree(values);
 	return ret;
-- 
2.6.4

[toc] | [next] | [standalone]


#1305050

From"Rafael J. Wysocki" <rjw@rjwysocki.net>
Date2016-01-09 00:10 +0100
Message-ID<qOOkq-5fH-7@gated-at.bofh.it>
In reply to#1304524
On Friday, January 08, 2016 03:09:11 PM Andy Shevchenko wrote:
> The new helper returns index of the mathing string in an array. We would use it
> here.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

in case you need that.

I think though that it might be more efficient to simply push [1/9] first
maybe with one user and then send the other patches to the relevant maintainers
when that has been applied.

> ---
>  drivers/base/property.c | 10 ++--------
>  1 file changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/base/property.c b/drivers/base/property.c
> index c359351..f902b55 100644
> --- a/drivers/base/property.c
> +++ b/drivers/base/property.c
> @@ -647,7 +647,7 @@ int fwnode_property_match_string(struct fwnode_handle *fwnode,
>  	const char *propname, const char *string)
>  {
>  	const char **values;
> -	int nval, ret, i;
> +	int nval, ret;
>  
>  	nval = fwnode_property_read_string_array(fwnode, propname, NULL, 0);
>  	if (nval < 0)
> @@ -664,13 +664,7 @@ int fwnode_property_match_string(struct fwnode_handle *fwnode,
>  	if (ret < 0)
>  		goto out;
>  
> -	ret = -ENODATA;
> -	for (i = 0; i < nval; i++) {
> -		if (!strcmp(values[i], string)) {
> -			ret = i;
> -			break;
> -		}
> -	}
> +	ret = match_string(values, nval, string);
>  out:
>  	kfree(values);
>  	return ret;
> 

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web