aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/pinctrl.txt
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 /Documentation/pinctrl.txt
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 'Documentation/pinctrl.txt')
-rw-r--r--Documentation/pinctrl.txt37
1 files changed, 15 insertions, 22 deletions
diff --git a/Documentation/pinctrl.txt b/Documentation/pinctrl.txt
index 2d88b3c7b61c..eb46b1c0b07a 100644
--- a/Documentation/pinctrl.txt
+++ b/Documentation/pinctrl.txt
@@ -152,11 +152,9 @@ static const struct foo_group foo_groups[] = {
152}; 152};
153 153
154 154
155static int foo_list_groups(struct pinctrl_dev *pctldev, unsigned selector) 155static int foo_get_groups_count(struct pinctrl_dev *pctldev)
156{ 156{
157 if (selector >= ARRAY_SIZE(foo_groups)) 157 return ARRAY_SIZE(foo_groups);
158 return -EINVAL;
159 return 0;
160} 158}
161 159
162static const char *foo_get_group_name(struct pinctrl_dev *pctldev, 160static const char *foo_get_group_name(struct pinctrl_dev *pctldev,
@@ -175,7 +173,7 @@ static int foo_get_group_pins(struct pinctrl_dev *pctldev, unsigned selector,
175} 173}
176 174
177static struct pinctrl_ops foo_pctrl_ops = { 175static struct pinctrl_ops foo_pctrl_ops = {
178 .list_groups = foo_list_groups, 176 .get_groups_count = foo_get_groups_count,
179 .get_group_name = foo_get_group_name, 177 .get_group_name = foo_get_group_name,
180 .get_group_pins = foo_get_group_pins, 178 .get_group_pins = foo_get_group_pins,
181}; 179};
@@ -186,13 +184,12 @@ static struct pinctrl_desc foo_desc = {
186 .pctlops = &foo_pctrl_ops, 184 .pctlops = &foo_pctrl_ops,
187}; 185};
188 186
189The pin control subsystem will call the .list_groups() function repeatedly 187The pin control subsystem will call the .get_groups_count() function to
190beginning on 0 until it returns non-zero to determine legal selectors, then 188determine total number of legal selectors, then it will call the other functions
191it will call the other functions to retrieve the name and pins of the group. 189to retrieve the name and pins of the group. Maintaining the data structure of
192Maintaining the data structure of the groups is up to the driver, this is 190the groups is up to the driver, this is just a simple example - in practice you
193just a simple example - in practice you may need more entries in your group 191may need more entries in your group structure, for example specific register
194structure, for example specific register ranges associated with each group 192ranges associated with each group and so on.
195and so on.
196 193
197 194
198Pin configuration 195Pin configuration
@@ -606,11 +603,9 @@ static const struct foo_group foo_groups[] = {
606}; 603};
607 604
608 605
609static int foo_list_groups(struct pinctrl_dev *pctldev, unsigned selector) 606static int foo_get_groups_count(struct pinctrl_dev *pctldev)
610{ 607{
611 if (selector >= ARRAY_SIZE(foo_groups)) 608 return ARRAY_SIZE(foo_groups);
612 return -EINVAL;
613 return 0;
614} 609}
615 610
616static const char *foo_get_group_name(struct pinctrl_dev *pctldev, 611static const char *foo_get_group_name(struct pinctrl_dev *pctldev,
@@ -629,7 +624,7 @@ static int foo_get_group_pins(struct pinctrl_dev *pctldev, unsigned selector,
629} 624}
630 625
631static struct pinctrl_ops foo_pctrl_ops = { 626static struct pinctrl_ops foo_pctrl_ops = {
632 .list_groups = foo_list_groups, 627 .get_groups_count = foo_get_groups_count,
633 .get_group_name = foo_get_group_name, 628 .get_group_name = foo_get_group_name,
634 .get_group_pins = foo_get_group_pins, 629 .get_group_pins = foo_get_group_pins,
635}; 630};
@@ -663,11 +658,9 @@ static const struct foo_pmx_func foo_functions[] = {
663 }, 658 },
664}; 659};
665 660
666int foo_list_funcs(struct pinctrl_dev *pctldev, unsigned selector) 661int foo_get_functions_count(struct pinctrl_dev *pctldev)
667{ 662{
668 if (selector >= ARRAY_SIZE(foo_functions)) 663 return ARRAY_SIZE(foo_functions);
669 return -EINVAL;
670 return 0;
671} 664}
672 665
673const char *foo_get_fname(struct pinctrl_dev *pctldev, unsigned selector) 666const char *foo_get_fname(struct pinctrl_dev *pctldev, unsigned selector)
@@ -703,7 +696,7 @@ void foo_disable(struct pinctrl_dev *pctldev, unsigned selector,
703} 696}
704 697
705struct pinmux_ops foo_pmxops = { 698struct pinmux_ops foo_pmxops = {
706 .list_functions = foo_list_funcs, 699 .get_functions_count = foo_get_functions_count,
707 .get_function_name = foo_get_fname, 700 .get_function_name = foo_get_fname,
708 .get_function_groups = foo_get_groups, 701 .get_function_groups = foo_get_groups,
709 .enable = foo_enable, 702 .enable = foo_enable,