diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2011-10-19 17:07:16 +0200 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2012-01-03 09:09:58 +0100 |
commit | 7afde8baa83b9ac409a6db86f27a41878aa6b33f (patch) | |
tree | f7d1af3bc5e5c03d2d9be10d3ede7de7fc49de53 /drivers/pinctrl/core.c | |
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/core.c')
-rw-r--r-- | drivers/pinctrl/core.c | 31 |
1 files changed, 31 insertions, 0 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, mutex_unlock(&pctldev->gpio_ranges_lock); } +/** + * pinctrl_get_group_selector() - returns the group selector for a group + * @pctldev: the pin controller handling the group + * @pin_group: the pin group to look up + */ +int pinctrl_get_group_selector(struct pinctrl_dev *pctldev, + const char *pin_group) +{ + const struct pinctrl_ops *pctlops = pctldev->desc->pctlops; + unsigned group_selector = 0; + + while (pctlops->list_groups(pctldev, group_selector) >= 0) { + const char *gname = pctlops->get_group_name(pctldev, + group_selector); + if (!strcmp(gname, pin_group)) { + dev_dbg(&pctldev->dev, + "found group selector %u for %s\n", + group_selector, + pin_group); + return group_selector; + } + + group_selector++; + } + + dev_err(&pctldev->dev, "does not have pin group %s\n", + pin_group); + + return -EINVAL; +} + #ifdef CONFIG_DEBUG_FS static int pinctrl_pins_show(struct seq_file *s, void *what) |