diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2011-10-19 11:07:16 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2012-01-03 03:09:58 -0500 |
commit | 7afde8baa83b9ac409a6db86f27a41878aa6b33f (patch) | |
tree | f7d1af3bc5e5c03d2d9be10d3ede7de7fc49de53 /drivers/pinctrl | |
parent | b84e673f51799a2d0bad7a7c1e7a74021c4eba4b (diff) |
pinctrl: move group lookup to core
Now also the core needs to look up pin groups so move the lookup
function there and expose it in the internal header.
Acked-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl')
-rw-r--r-- | drivers/pinctrl/core.c | 31 | ||||
-rw-r--r-- | drivers/pinctrl/core.h | 2 | ||||
-rw-r--r-- | drivers/pinctrl/pinmux.c | 35 |
3 files changed, 35 insertions, 33 deletions
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index eadef9e191ea..9970590006d1 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c | |||
@@ -284,6 +284,37 @@ void pinctrl_remove_gpio_range(struct pinctrl_dev *pctldev, | |||
284 | mutex_unlock(&pctldev->gpio_ranges_lock); | 284 | mutex_unlock(&pctldev->gpio_ranges_lock); |
285 | } | 285 | } |
286 | 286 | ||
287 | /** | ||
288 | * pinctrl_get_group_selector() - returns the group selector for a group | ||
289 | * @pctldev: the pin controller handling the group | ||
290 | * @pin_group: the pin group to look up | ||
291 | */ | ||
292 | int pinctrl_get_group_selector(struct pinctrl_dev *pctldev, | ||
293 | const char *pin_group) | ||
294 | { | ||
295 | const struct pinctrl_ops *pctlops = pctldev->desc->pctlops; | ||
296 | unsigned group_selector = 0; | ||
297 | |||
298 | while (pctlops->list_groups(pctldev, group_selector) >= 0) { | ||
299 | const char *gname = pctlops->get_group_name(pctldev, | ||
300 | group_selector); | ||
301 | if (!strcmp(gname, pin_group)) { | ||
302 | dev_dbg(&pctldev->dev, | ||
303 | "found group selector %u for %s\n", | ||
304 | group_selector, | ||
305 | pin_group); | ||
306 | return group_selector; | ||
307 | } | ||
308 | |||
309 | group_selector++; | ||
310 | } | ||
311 | |||
312 | dev_err(&pctldev->dev, "does not have pin group %s\n", | ||
313 | pin_group); | ||
314 | |||
315 | return -EINVAL; | ||
316 | } | ||
317 | |||
287 | #ifdef CONFIG_DEBUG_FS | 318 | #ifdef CONFIG_DEBUG_FS |
288 | 319 | ||
289 | static int pinctrl_pins_show(struct seq_file *s, void *what) | 320 | static int pinctrl_pins_show(struct seq_file *s, void *what) |
diff --git a/drivers/pinctrl/core.h b/drivers/pinctrl/core.h index 472fa1341cc0..dcc6d687b653 100644 --- a/drivers/pinctrl/core.h +++ b/drivers/pinctrl/core.h | |||
@@ -69,3 +69,5 @@ struct pin_desc *pin_desc_get(struct pinctrl_dev *pctldev, int pin); | |||
69 | int pinctrl_get_device_gpio_range(unsigned gpio, | 69 | int pinctrl_get_device_gpio_range(unsigned gpio, |
70 | struct pinctrl_dev **outdev, | 70 | struct pinctrl_dev **outdev, |
71 | struct pinctrl_gpio_range **outrange); | 71 | struct pinctrl_gpio_range **outrange); |
72 | int pinctrl_get_group_selector(struct pinctrl_dev *pctldev, | ||
73 | const char *pin_group); | ||
diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c index f2c84a90df14..72b760bc880a 100644 --- a/drivers/pinctrl/pinmux.c +++ b/drivers/pinctrl/pinmux.c | |||
@@ -390,37 +390,6 @@ static void release_pins(struct pinctrl_dev *pctldev, | |||
390 | } | 390 | } |
391 | 391 | ||
392 | /** | 392 | /** |
393 | * pinmux_get_group_selector() - returns the group selector for a group | ||
394 | * @pctldev: the pin controller handling the group | ||
395 | * @pin_group: the pin group to look up | ||
396 | */ | ||
397 | static int pinmux_get_group_selector(struct pinctrl_dev *pctldev, | ||
398 | const char *pin_group) | ||
399 | { | ||
400 | const struct pinctrl_ops *pctlops = pctldev->desc->pctlops; | ||
401 | unsigned group_selector = 0; | ||
402 | |||
403 | while (pctlops->list_groups(pctldev, group_selector) >= 0) { | ||
404 | const char *gname = pctlops->get_group_name(pctldev, | ||
405 | group_selector); | ||
406 | if (!strcmp(gname, pin_group)) { | ||
407 | dev_dbg(&pctldev->dev, | ||
408 | "found group selector %u for %s\n", | ||
409 | group_selector, | ||
410 | pin_group); | ||
411 | return group_selector; | ||
412 | } | ||
413 | |||
414 | group_selector++; | ||
415 | } | ||
416 | |||
417 | dev_err(&pctldev->dev, "does not have pin group %s\n", | ||
418 | pin_group); | ||
419 | |||
420 | return -EINVAL; | ||
421 | } | ||
422 | |||
423 | /** | ||
424 | * pinmux_check_pin_group() - check function and pin group combo | 393 | * pinmux_check_pin_group() - check function and pin group combo |
425 | * @pctldev: device to check the pin group vs function for | 394 | * @pctldev: device to check the pin group vs function for |
426 | * @func_selector: the function selector to check the pin group for, we have | 395 | * @func_selector: the function selector to check the pin group for, we have |
@@ -461,7 +430,7 @@ static int pinmux_check_pin_group(struct pinctrl_dev *pctldev, | |||
461 | return ret; | 430 | return ret; |
462 | if (num_groups < 1) | 431 | if (num_groups < 1) |
463 | return -EINVAL; | 432 | return -EINVAL; |
464 | ret = pinmux_get_group_selector(pctldev, groups[0]); | 433 | ret = pinctrl_get_group_selector(pctldev, groups[0]); |
465 | if (ret < 0) { | 434 | if (ret < 0) { |
466 | dev_err(&pctldev->dev, | 435 | dev_err(&pctldev->dev, |
467 | "function %s wants group %s but the pin " | 436 | "function %s wants group %s but the pin " |
@@ -486,7 +455,7 @@ static int pinmux_check_pin_group(struct pinctrl_dev *pctldev, | |||
486 | "check if we have pin group %s on controller %s\n", | 455 | "check if we have pin group %s on controller %s\n", |
487 | pin_group, pinctrl_dev_get_name(pctldev)); | 456 | pin_group, pinctrl_dev_get_name(pctldev)); |
488 | 457 | ||
489 | ret = pinmux_get_group_selector(pctldev, pin_group); | 458 | ret = pinctrl_get_group_selector(pctldev, pin_group); |
490 | if (ret < 0) { | 459 | if (ret < 0) { |
491 | dev_dbg(&pctldev->dev, | 460 | dev_dbg(&pctldev->dev, |
492 | "%s does not support pin group %s with function %s\n", | 461 | "%s does not support pin group %s with function %s\n", |