summaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl/pinmux.c
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@st.com>2012-03-30 01:55:40 -0400
committerLinus Walleij <linus.walleij@linaro.org>2012-04-18 07:53:10 -0400
commitd1e90e9e7467dbfe521b25ba79f520bf676ebc36 (patch)
tree2c4a2b8bfa2a984cb57a781b034a204a12fcc4b6 /drivers/pinctrl/pinmux.c
parent122dbe7e58c7d064a17eefd33205227e6bce85ca (diff)
pinctrl: replace list_*() with get_*_count()
Most of the SoC drivers implement list_groups() and list_functions() routines for pinctrl and pinmux. These routines continue returning zero until the selector argument is greater than total count of available groups or functions. This patch replaces these list_*() routines with get_*_count() routines, which returns the number of available selection for SoC driver. pinctrl layer will use this value to check the range it can choose. This patch fixes all user drivers for this change. There are other routines in user drivers, which have checks to check validity of selector passed to them. It is also no more required and hence removed. Documentation updated as well. Acked-by: Stephen Warren <swarren@wwwdotorg.org> Signed-off-by: Viresh Kumar <viresh.kumar@st.com> [Folded in fix and fixed a minor merge artifact manually] Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/pinmux.c')
-rw-r--r--drivers/pinctrl/pinmux.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
index 4e62783a573a..375b214780e9 100644
--- a/drivers/pinctrl/pinmux.c
+++ b/drivers/pinctrl/pinmux.c
@@ -33,10 +33,11 @@
33int pinmux_check_ops(struct pinctrl_dev *pctldev) 33int pinmux_check_ops(struct pinctrl_dev *pctldev)
34{ 34{
35 const struct pinmux_ops *ops = pctldev->desc->pmxops; 35 const struct pinmux_ops *ops = pctldev->desc->pmxops;
36 unsigned nfuncs = ops->get_functions_count(pctldev);
36 unsigned selector = 0; 37 unsigned selector = 0;
37 38
38 /* Check that we implement required operations */ 39 /* Check that we implement required operations */
39 if (!ops->list_functions || 40 if (!ops->get_functions_count ||
40 !ops->get_function_name || 41 !ops->get_function_name ||
41 !ops->get_function_groups || 42 !ops->get_function_groups ||
42 !ops->enable || 43 !ops->enable ||
@@ -44,7 +45,7 @@ int pinmux_check_ops(struct pinctrl_dev *pctldev)
44 return -EINVAL; 45 return -EINVAL;
45 46
46 /* Check that all functions registered have names */ 47 /* Check that all functions registered have names */
47 while (ops->list_functions(pctldev, selector) >= 0) { 48 while (selector < nfuncs) {
48 const char *fname = ops->get_function_name(pctldev, 49 const char *fname = ops->get_function_name(pctldev,
49 selector); 50 selector);
50 if (!fname) { 51 if (!fname) {
@@ -287,10 +288,11 @@ static int pinmux_func_name_to_selector(struct pinctrl_dev *pctldev,
287 const char *function) 288 const char *function)
288{ 289{
289 const struct pinmux_ops *ops = pctldev->desc->pmxops; 290 const struct pinmux_ops *ops = pctldev->desc->pmxops;
291 unsigned nfuncs = ops->get_functions_count(pctldev);
290 unsigned selector = 0; 292 unsigned selector = 0;
291 293
292 /* See if this pctldev has this function */ 294 /* See if this pctldev has this function */
293 while (ops->list_functions(pctldev, selector) >= 0) { 295 while (selector < nfuncs) {
294 const char *fname = ops->get_function_name(pctldev, 296 const char *fname = ops->get_function_name(pctldev,
295 selector); 297 selector);
296 298
@@ -477,11 +479,12 @@ static int pinmux_functions_show(struct seq_file *s, void *what)
477{ 479{
478 struct pinctrl_dev *pctldev = s->private; 480 struct pinctrl_dev *pctldev = s->private;
479 const struct pinmux_ops *pmxops = pctldev->desc->pmxops; 481 const struct pinmux_ops *pmxops = pctldev->desc->pmxops;
482 unsigned nfuncs = pmxops->get_functions_count(pctldev);
480 unsigned func_selector = 0; 483 unsigned func_selector = 0;
481 484
482 mutex_lock(&pinctrl_mutex); 485 mutex_lock(&pinctrl_mutex);
483 486
484 while (pmxops->list_functions(pctldev, func_selector) >= 0) { 487 while (func_selector < nfuncs) {
485 const char *func = pmxops->get_function_name(pctldev, 488 const char *func = pmxops->get_function_name(pctldev,
486 func_selector); 489 func_selector);
487 const char * const *groups; 490 const char * const *groups;