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


Groups > linux.kernel > #1303507 > unrolled thread

[PATCH v1 3/8] pinctrl: convert to use match_string() helper

Started byAndy Shevchenko <andriy.shevchenko@linux.intel.com>
First post2016-01-07 13:10 +0100
Last post2016-01-07 16:30 +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 v1 3/8] pinctrl: convert to use match_string() helper Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2016-01-07 13:10 +0100
    Re: [PATCH v1 3/8] pinctrl: convert to use match_string() helper Linus Walleij <linus.walleij@linaro.org> - 2016-01-07 16:30 +0100

#1303507 — [PATCH v1 3/8] pinctrl: convert to use match_string() helper

FromAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Date2016-01-07 13:10 +0100
Subject[PATCH v1 3/8] pinctrl: convert to use match_string() helper
Message-ID<qOhy9-7Vb-1@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>
---
 drivers/pinctrl/pinmux.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
index 29984b3..c223a9e 100644
--- a/drivers/pinctrl/pinmux.c
+++ b/drivers/pinctrl/pinmux.c
@@ -334,7 +334,6 @@ int pinmux_map_to_setting(struct pinctrl_map const *map,
 	unsigned num_groups;
 	int ret;
 	const char *group;
-	int i;
 
 	if (!pmxops) {
 		dev_err(pctldev->dev, "does not support mux function\n");
@@ -363,19 +362,13 @@ int pinmux_map_to_setting(struct pinctrl_map const *map,
 		return -EINVAL;
 	}
 	if (map->data.mux.group) {
-		bool found = false;
 		group = map->data.mux.group;
-		for (i = 0; i < num_groups; i++) {
-			if (!strcmp(group, groups[i])) {
-				found = true;
-				break;
-			}
-		}
-		if (!found) {
+		ret = match_string(groups, num_groups, group);
+		if (ret < 0) {
 			dev_err(pctldev->dev,
 				"invalid group \"%s\" for function \"%s\"\n",
 				group, map->data.mux.function);
-			return -EINVAL;
+			return ret;
 		}
 	} else {
 		group = groups[0];
-- 
2.6.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1303659

FromLinus Walleij <linus.walleij@linaro.org>
Date2016-01-07 16:30 +0100
Message-ID<qOkFI-1wu-25@gated-at.bofh.it>
In reply to#1303507
On Thu, Jan 7, 2016 at 1:06 PM, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> 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>

Pretty cool ...
Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web