diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/pinctrl/core.c | 10 | ||||
-rw-r--r-- | drivers/pinctrl/pinconf.c | 3 | ||||
-rw-r--r-- | drivers/pinctrl/pinctrl-pxa3xx.c | 24 | ||||
-rw-r--r-- | drivers/pinctrl/pinctrl-sirf.c | 20 | ||||
-rw-r--r-- | drivers/pinctrl/pinctrl-tegra.c | 40 | ||||
-rw-r--r-- | drivers/pinctrl/pinctrl-u300.c | 20 | ||||
-rw-r--r-- | drivers/pinctrl/pinmux.c | 11 |
7 files changed, 43 insertions, 85 deletions
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index 832f71dcd8c4..7ff869007ba4 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c | |||
@@ -319,9 +319,10 @@ int pinctrl_get_group_selector(struct pinctrl_dev *pctldev, | |||
319 | const char *pin_group) | 319 | const char *pin_group) |
320 | { | 320 | { |
321 | const struct pinctrl_ops *pctlops = pctldev->desc->pctlops; | 321 | const struct pinctrl_ops *pctlops = pctldev->desc->pctlops; |
322 | unsigned ngroups = pctlops->get_groups_count(pctldev); | ||
322 | unsigned group_selector = 0; | 323 | unsigned group_selector = 0; |
323 | 324 | ||
324 | while (pctlops->list_groups(pctldev, group_selector) >= 0) { | 325 | while (group_selector < ngroups) { |
325 | const char *gname = pctlops->get_group_name(pctldev, | 326 | const char *gname = pctlops->get_group_name(pctldev, |
326 | group_selector); | 327 | group_selector); |
327 | if (!strcmp(gname, pin_group)) { | 328 | if (!strcmp(gname, pin_group)) { |
@@ -941,12 +942,13 @@ static int pinctrl_groups_show(struct seq_file *s, void *what) | |||
941 | { | 942 | { |
942 | struct pinctrl_dev *pctldev = s->private; | 943 | struct pinctrl_dev *pctldev = s->private; |
943 | const struct pinctrl_ops *ops = pctldev->desc->pctlops; | 944 | const struct pinctrl_ops *ops = pctldev->desc->pctlops; |
944 | unsigned selector = 0; | 945 | unsigned ngroups, selector = 0; |
945 | 946 | ||
947 | ngroups = ops->get_groups_count(pctldev); | ||
946 | mutex_lock(&pinctrl_mutex); | 948 | mutex_lock(&pinctrl_mutex); |
947 | 949 | ||
948 | seq_puts(s, "registered pin groups:\n"); | 950 | seq_puts(s, "registered pin groups:\n"); |
949 | while (ops->list_groups(pctldev, selector) >= 0) { | 951 | while (selector < ngroups) { |
950 | const unsigned *pins; | 952 | const unsigned *pins; |
951 | unsigned num_pins; | 953 | unsigned num_pins; |
952 | const char *gname = ops->get_group_name(pctldev, selector); | 954 | const char *gname = ops->get_group_name(pctldev, selector); |
@@ -1261,7 +1263,7 @@ static int pinctrl_check_ops(struct pinctrl_dev *pctldev) | |||
1261 | const struct pinctrl_ops *ops = pctldev->desc->pctlops; | 1263 | const struct pinctrl_ops *ops = pctldev->desc->pctlops; |
1262 | 1264 | ||
1263 | if (!ops || | 1265 | if (!ops || |
1264 | !ops->list_groups || | 1266 | !ops->get_groups_count || |
1265 | !ops->get_group_name || | 1267 | !ops->get_group_name || |
1266 | !ops->get_group_pins) | 1268 | !ops->get_group_pins) |
1267 | return -EINVAL; | 1269 | return -EINVAL; |
diff --git a/drivers/pinctrl/pinconf.c b/drivers/pinctrl/pinconf.c index 7321e8601294..eb3a14f4b866 100644 --- a/drivers/pinctrl/pinconf.c +++ b/drivers/pinctrl/pinconf.c | |||
@@ -495,6 +495,7 @@ static int pinconf_groups_show(struct seq_file *s, void *what) | |||
495 | struct pinctrl_dev *pctldev = s->private; | 495 | struct pinctrl_dev *pctldev = s->private; |
496 | const struct pinctrl_ops *pctlops = pctldev->desc->pctlops; | 496 | const struct pinctrl_ops *pctlops = pctldev->desc->pctlops; |
497 | const struct pinconf_ops *ops = pctldev->desc->confops; | 497 | const struct pinconf_ops *ops = pctldev->desc->confops; |
498 | unsigned ngroups = pctlops->get_groups_count(pctldev); | ||
498 | unsigned selector = 0; | 499 | unsigned selector = 0; |
499 | 500 | ||
500 | if (!ops || !ops->pin_config_group_get) | 501 | if (!ops || !ops->pin_config_group_get) |
@@ -505,7 +506,7 @@ static int pinconf_groups_show(struct seq_file *s, void *what) | |||
505 | 506 | ||
506 | mutex_lock(&pinctrl_mutex); | 507 | mutex_lock(&pinctrl_mutex); |
507 | 508 | ||
508 | while (pctlops->list_groups(pctldev, selector) >= 0) { | 509 | while (selector < ngroups) { |
509 | const char *gname = pctlops->get_group_name(pctldev, selector); | 510 | const char *gname = pctlops->get_group_name(pctldev, selector); |
510 | 511 | ||
511 | seq_printf(s, "%u (%s):", selector, gname); | 512 | seq_printf(s, "%u (%s):", selector, gname); |
diff --git a/drivers/pinctrl/pinctrl-pxa3xx.c b/drivers/pinctrl/pinctrl-pxa3xx.c index 079dce0e93e9..7644e42ac211 100644 --- a/drivers/pinctrl/pinctrl-pxa3xx.c +++ b/drivers/pinctrl/pinctrl-pxa3xx.c | |||
@@ -25,20 +25,18 @@ static struct pinctrl_gpio_range pxa3xx_pinctrl_gpio_range = { | |||
25 | .pin_base = 0, | 25 | .pin_base = 0, |
26 | }; | 26 | }; |
27 | 27 | ||
28 | static int pxa3xx_list_groups(struct pinctrl_dev *pctrldev, unsigned selector) | 28 | static int pxa3xx_get_groups_count(struct pinctrl_dev *pctrldev) |
29 | { | 29 | { |
30 | struct pxa3xx_pinmux_info *info = pinctrl_dev_get_drvdata(pctrldev); | 30 | struct pxa3xx_pinmux_info *info = pinctrl_dev_get_drvdata(pctrldev); |
31 | if (selector >= info->num_grps) | 31 | |
32 | return -EINVAL; | 32 | return info->num_grps; |
33 | return 0; | ||
34 | } | 33 | } |
35 | 34 | ||
36 | static const char *pxa3xx_get_group_name(struct pinctrl_dev *pctrldev, | 35 | static const char *pxa3xx_get_group_name(struct pinctrl_dev *pctrldev, |
37 | unsigned selector) | 36 | unsigned selector) |
38 | { | 37 | { |
39 | struct pxa3xx_pinmux_info *info = pinctrl_dev_get_drvdata(pctrldev); | 38 | struct pxa3xx_pinmux_info *info = pinctrl_dev_get_drvdata(pctrldev); |
40 | if (selector >= info->num_grps) | 39 | |
41 | return NULL; | ||
42 | return info->grps[selector].name; | 40 | return info->grps[selector].name; |
43 | } | 41 | } |
44 | 42 | ||
@@ -48,25 +46,23 @@ static int pxa3xx_get_group_pins(struct pinctrl_dev *pctrldev, | |||
48 | unsigned *num_pins) | 46 | unsigned *num_pins) |
49 | { | 47 | { |
50 | struct pxa3xx_pinmux_info *info = pinctrl_dev_get_drvdata(pctrldev); | 48 | struct pxa3xx_pinmux_info *info = pinctrl_dev_get_drvdata(pctrldev); |
51 | if (selector >= info->num_grps) | 49 | |
52 | return -EINVAL; | ||
53 | *pins = info->grps[selector].pins; | 50 | *pins = info->grps[selector].pins; |
54 | *num_pins = info->grps[selector].npins; | 51 | *num_pins = info->grps[selector].npins; |
55 | return 0; | 52 | return 0; |
56 | } | 53 | } |
57 | 54 | ||
58 | static struct pinctrl_ops pxa3xx_pctrl_ops = { | 55 | static struct pinctrl_ops pxa3xx_pctrl_ops = { |
59 | .list_groups = pxa3xx_list_groups, | 56 | .get_groups_count = pxa3xx_get_groups_count, |
60 | .get_group_name = pxa3xx_get_group_name, | 57 | .get_group_name = pxa3xx_get_group_name, |
61 | .get_group_pins = pxa3xx_get_group_pins, | 58 | .get_group_pins = pxa3xx_get_group_pins, |
62 | }; | 59 | }; |
63 | 60 | ||
64 | static int pxa3xx_pmx_list_func(struct pinctrl_dev *pctrldev, unsigned func) | 61 | static int pxa3xx_pmx_get_funcs_count(struct pinctrl_dev *pctrldev) |
65 | { | 62 | { |
66 | struct pxa3xx_pinmux_info *info = pinctrl_dev_get_drvdata(pctrldev); | 63 | struct pxa3xx_pinmux_info *info = pinctrl_dev_get_drvdata(pctrldev); |
67 | if (func >= info->num_funcs) | 64 | |
68 | return -EINVAL; | 65 | return info->num_funcs; |
69 | return 0; | ||
70 | } | 66 | } |
71 | 67 | ||
72 | static const char *pxa3xx_pmx_get_func_name(struct pinctrl_dev *pctrldev, | 68 | static const char *pxa3xx_pmx_get_func_name(struct pinctrl_dev *pctrldev, |
@@ -170,7 +166,7 @@ static int pxa3xx_pmx_request_gpio(struct pinctrl_dev *pctrldev, | |||
170 | } | 166 | } |
171 | 167 | ||
172 | static struct pinmux_ops pxa3xx_pmx_ops = { | 168 | static struct pinmux_ops pxa3xx_pmx_ops = { |
173 | .list_functions = pxa3xx_pmx_list_func, | 169 | .get_functions_count = pxa3xx_pmx_get_funcs_count, |
174 | .get_function_name = pxa3xx_pmx_get_func_name, | 170 | .get_function_name = pxa3xx_pmx_get_func_name, |
175 | .get_function_groups = pxa3xx_pmx_get_groups, | 171 | .get_function_groups = pxa3xx_pmx_get_groups, |
176 | .enable = pxa3xx_pmx_enable, | 172 | .enable = pxa3xx_pmx_enable, |
diff --git a/drivers/pinctrl/pinctrl-sirf.c b/drivers/pinctrl/pinctrl-sirf.c index 6b3534cc051a..ba15b1a29e52 100644 --- a/drivers/pinctrl/pinctrl-sirf.c +++ b/drivers/pinctrl/pinctrl-sirf.c | |||
@@ -853,18 +853,14 @@ static const struct sirfsoc_pin_group sirfsoc_pin_groups[] = { | |||
853 | SIRFSOC_PIN_GROUP("gpsgrp", gps_pins), | 853 | SIRFSOC_PIN_GROUP("gpsgrp", gps_pins), |
854 | }; | 854 | }; |
855 | 855 | ||
856 | static int sirfsoc_list_groups(struct pinctrl_dev *pctldev, unsigned selector) | 856 | static int sirfsoc_get_groups_count(struct pinctrl_dev *pctldev) |
857 | { | 857 | { |
858 | if (selector >= ARRAY_SIZE(sirfsoc_pin_groups)) | 858 | return ARRAY_SIZE(sirfsoc_pin_groups); |
859 | return -EINVAL; | ||
860 | return 0; | ||
861 | } | 859 | } |
862 | 860 | ||
863 | static const char *sirfsoc_get_group_name(struct pinctrl_dev *pctldev, | 861 | static const char *sirfsoc_get_group_name(struct pinctrl_dev *pctldev, |
864 | unsigned selector) | 862 | unsigned selector) |
865 | { | 863 | { |
866 | if (selector >= ARRAY_SIZE(sirfsoc_pin_groups)) | ||
867 | return NULL; | ||
868 | return sirfsoc_pin_groups[selector].name; | 864 | return sirfsoc_pin_groups[selector].name; |
869 | } | 865 | } |
870 | 866 | ||
@@ -872,8 +868,6 @@ static int sirfsoc_get_group_pins(struct pinctrl_dev *pctldev, unsigned selector | |||
872 | const unsigned **pins, | 868 | const unsigned **pins, |
873 | unsigned *num_pins) | 869 | unsigned *num_pins) |
874 | { | 870 | { |
875 | if (selector >= ARRAY_SIZE(sirfsoc_pin_groups)) | ||
876 | return -EINVAL; | ||
877 | *pins = sirfsoc_pin_groups[selector].pins; | 871 | *pins = sirfsoc_pin_groups[selector].pins; |
878 | *num_pins = sirfsoc_pin_groups[selector].num_pins; | 872 | *num_pins = sirfsoc_pin_groups[selector].num_pins; |
879 | return 0; | 873 | return 0; |
@@ -886,7 +880,7 @@ static void sirfsoc_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s | |||
886 | } | 880 | } |
887 | 881 | ||
888 | static struct pinctrl_ops sirfsoc_pctrl_ops = { | 882 | static struct pinctrl_ops sirfsoc_pctrl_ops = { |
889 | .list_groups = sirfsoc_list_groups, | 883 | .get_groups_count = sirfsoc_get_groups_count, |
890 | .get_group_name = sirfsoc_get_group_name, | 884 | .get_group_name = sirfsoc_get_group_name, |
891 | .get_group_pins = sirfsoc_get_group_pins, | 885 | .get_group_pins = sirfsoc_get_group_pins, |
892 | .pin_dbg_show = sirfsoc_pin_dbg_show, | 886 | .pin_dbg_show = sirfsoc_pin_dbg_show, |
@@ -1033,11 +1027,9 @@ static void sirfsoc_pinmux_disable(struct pinctrl_dev *pmxdev, unsigned selector | |||
1033 | sirfsoc_pinmux_endisable(spmx, selector, false); | 1027 | sirfsoc_pinmux_endisable(spmx, selector, false); |
1034 | } | 1028 | } |
1035 | 1029 | ||
1036 | static int sirfsoc_pinmux_list_funcs(struct pinctrl_dev *pmxdev, unsigned selector) | 1030 | static int sirfsoc_pinmux_get_funcs_count(struct pinctrl_dev *pmxdev) |
1037 | { | 1031 | { |
1038 | if (selector >= ARRAY_SIZE(sirfsoc_pmx_functions)) | 1032 | return ARRAY_SIZE(sirfsoc_pmx_functions); |
1039 | return -EINVAL; | ||
1040 | return 0; | ||
1041 | } | 1033 | } |
1042 | 1034 | ||
1043 | static const char *sirfsoc_pinmux_get_func_name(struct pinctrl_dev *pctldev, | 1035 | static const char *sirfsoc_pinmux_get_func_name(struct pinctrl_dev *pctldev, |
@@ -1074,9 +1066,9 @@ static int sirfsoc_pinmux_request_gpio(struct pinctrl_dev *pmxdev, | |||
1074 | } | 1066 | } |
1075 | 1067 | ||
1076 | static struct pinmux_ops sirfsoc_pinmux_ops = { | 1068 | static struct pinmux_ops sirfsoc_pinmux_ops = { |
1077 | .list_functions = sirfsoc_pinmux_list_funcs, | ||
1078 | .enable = sirfsoc_pinmux_enable, | 1069 | .enable = sirfsoc_pinmux_enable, |
1079 | .disable = sirfsoc_pinmux_disable, | 1070 | .disable = sirfsoc_pinmux_disable, |
1071 | .get_functions_count = sirfsoc_pinmux_get_funcs_count, | ||
1080 | .get_function_name = sirfsoc_pinmux_get_func_name, | 1072 | .get_function_name = sirfsoc_pinmux_get_func_name, |
1081 | .get_function_groups = sirfsoc_pinmux_get_groups, | 1073 | .get_function_groups = sirfsoc_pinmux_get_groups, |
1082 | .gpio_request_enable = sirfsoc_pinmux_request_gpio, | 1074 | .gpio_request_enable = sirfsoc_pinmux_request_gpio, |
diff --git a/drivers/pinctrl/pinctrl-tegra.c b/drivers/pinctrl/pinctrl-tegra.c index 9b329688120c..41311a2a4256 100644 --- a/drivers/pinctrl/pinctrl-tegra.c +++ b/drivers/pinctrl/pinctrl-tegra.c | |||
@@ -53,15 +53,11 @@ static inline void pmx_writel(struct tegra_pmx *pmx, u32 val, u32 bank, u32 reg) | |||
53 | writel(val, pmx->regs[bank] + reg); | 53 | writel(val, pmx->regs[bank] + reg); |
54 | } | 54 | } |
55 | 55 | ||
56 | static int tegra_pinctrl_list_groups(struct pinctrl_dev *pctldev, | 56 | static int tegra_pinctrl_get_groups_count(struct pinctrl_dev *pctldev) |
57 | unsigned group) | ||
58 | { | 57 | { |
59 | struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); | 58 | struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); |
60 | 59 | ||
61 | if (group >= pmx->soc->ngroups) | 60 | return pmx->soc->ngroups; |
62 | return -EINVAL; | ||
63 | |||
64 | return 0; | ||
65 | } | 61 | } |
66 | 62 | ||
67 | static const char *tegra_pinctrl_get_group_name(struct pinctrl_dev *pctldev, | 63 | static const char *tegra_pinctrl_get_group_name(struct pinctrl_dev *pctldev, |
@@ -69,9 +65,6 @@ static const char *tegra_pinctrl_get_group_name(struct pinctrl_dev *pctldev, | |||
69 | { | 65 | { |
70 | struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); | 66 | struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); |
71 | 67 | ||
72 | if (group >= pmx->soc->ngroups) | ||
73 | return NULL; | ||
74 | |||
75 | return pmx->soc->groups[group].name; | 68 | return pmx->soc->groups[group].name; |
76 | } | 69 | } |
77 | 70 | ||
@@ -82,9 +75,6 @@ static int tegra_pinctrl_get_group_pins(struct pinctrl_dev *pctldev, | |||
82 | { | 75 | { |
83 | struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); | 76 | struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); |
84 | 77 | ||
85 | if (group >= pmx->soc->ngroups) | ||
86 | return -EINVAL; | ||
87 | |||
88 | *pins = pmx->soc->groups[group].pins; | 78 | *pins = pmx->soc->groups[group].pins; |
89 | *num_pins = pmx->soc->groups[group].npins; | 79 | *num_pins = pmx->soc->groups[group].npins; |
90 | 80 | ||
@@ -99,21 +89,17 @@ static void tegra_pinctrl_pin_dbg_show(struct pinctrl_dev *pctldev, | |||
99 | } | 89 | } |
100 | 90 | ||
101 | static struct pinctrl_ops tegra_pinctrl_ops = { | 91 | static struct pinctrl_ops tegra_pinctrl_ops = { |
102 | .list_groups = tegra_pinctrl_list_groups, | 92 | .get_groups_count = tegra_pinctrl_get_groups_count, |
103 | .get_group_name = tegra_pinctrl_get_group_name, | 93 | .get_group_name = tegra_pinctrl_get_group_name, |
104 | .get_group_pins = tegra_pinctrl_get_group_pins, | 94 | .get_group_pins = tegra_pinctrl_get_group_pins, |
105 | .pin_dbg_show = tegra_pinctrl_pin_dbg_show, | 95 | .pin_dbg_show = tegra_pinctrl_pin_dbg_show, |
106 | }; | 96 | }; |
107 | 97 | ||
108 | static int tegra_pinctrl_list_funcs(struct pinctrl_dev *pctldev, | 98 | static int tegra_pinctrl_get_funcs_count(struct pinctrl_dev *pctldev) |
109 | unsigned function) | ||
110 | { | 99 | { |
111 | struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); | 100 | struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); |
112 | 101 | ||
113 | if (function >= pmx->soc->nfunctions) | 102 | return pmx->soc->nfunctions; |
114 | return -EINVAL; | ||
115 | |||
116 | return 0; | ||
117 | } | 103 | } |
118 | 104 | ||
119 | static const char *tegra_pinctrl_get_func_name(struct pinctrl_dev *pctldev, | 105 | static const char *tegra_pinctrl_get_func_name(struct pinctrl_dev *pctldev, |
@@ -121,9 +107,6 @@ static const char *tegra_pinctrl_get_func_name(struct pinctrl_dev *pctldev, | |||
121 | { | 107 | { |
122 | struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); | 108 | struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); |
123 | 109 | ||
124 | if (function >= pmx->soc->nfunctions) | ||
125 | return NULL; | ||
126 | |||
127 | return pmx->soc->functions[function].name; | 110 | return pmx->soc->functions[function].name; |
128 | } | 111 | } |
129 | 112 | ||
@@ -134,9 +117,6 @@ static int tegra_pinctrl_get_func_groups(struct pinctrl_dev *pctldev, | |||
134 | { | 117 | { |
135 | struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); | 118 | struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); |
136 | 119 | ||
137 | if (function >= pmx->soc->nfunctions) | ||
138 | return -EINVAL; | ||
139 | |||
140 | *groups = pmx->soc->functions[function].groups; | 120 | *groups = pmx->soc->functions[function].groups; |
141 | *num_groups = pmx->soc->functions[function].ngroups; | 121 | *num_groups = pmx->soc->functions[function].ngroups; |
142 | 122 | ||
@@ -151,8 +131,6 @@ static int tegra_pinctrl_enable(struct pinctrl_dev *pctldev, unsigned function, | |||
151 | int i; | 131 | int i; |
152 | u32 val; | 132 | u32 val; |
153 | 133 | ||
154 | if (group >= pmx->soc->ngroups) | ||
155 | return -EINVAL; | ||
156 | g = &pmx->soc->groups[group]; | 134 | g = &pmx->soc->groups[group]; |
157 | 135 | ||
158 | if (g->mux_reg < 0) | 136 | if (g->mux_reg < 0) |
@@ -180,8 +158,6 @@ static void tegra_pinctrl_disable(struct pinctrl_dev *pctldev, | |||
180 | const struct tegra_pingroup *g; | 158 | const struct tegra_pingroup *g; |
181 | u32 val; | 159 | u32 val; |
182 | 160 | ||
183 | if (group >= pmx->soc->ngroups) | ||
184 | return; | ||
185 | g = &pmx->soc->groups[group]; | 161 | g = &pmx->soc->groups[group]; |
186 | 162 | ||
187 | if (g->mux_reg < 0) | 163 | if (g->mux_reg < 0) |
@@ -194,7 +170,7 @@ static void tegra_pinctrl_disable(struct pinctrl_dev *pctldev, | |||
194 | } | 170 | } |
195 | 171 | ||
196 | static struct pinmux_ops tegra_pinmux_ops = { | 172 | static struct pinmux_ops tegra_pinmux_ops = { |
197 | .list_functions = tegra_pinctrl_list_funcs, | 173 | .get_functions_count = tegra_pinctrl_get_funcs_count, |
198 | .get_function_name = tegra_pinctrl_get_func_name, | 174 | .get_function_name = tegra_pinctrl_get_func_name, |
199 | .get_function_groups = tegra_pinctrl_get_func_groups, | 175 | .get_function_groups = tegra_pinctrl_get_func_groups, |
200 | .enable = tegra_pinctrl_enable, | 176 | .enable = tegra_pinctrl_enable, |
@@ -324,8 +300,6 @@ static int tegra_pinconf_group_get(struct pinctrl_dev *pctldev, | |||
324 | s16 reg; | 300 | s16 reg; |
325 | u32 val, mask; | 301 | u32 val, mask; |
326 | 302 | ||
327 | if (group >= pmx->soc->ngroups) | ||
328 | return -EINVAL; | ||
329 | g = &pmx->soc->groups[group]; | 303 | g = &pmx->soc->groups[group]; |
330 | 304 | ||
331 | ret = tegra_pinconf_reg(pmx, g, param, &bank, ®, &bit, &width); | 305 | ret = tegra_pinconf_reg(pmx, g, param, &bank, ®, &bit, &width); |
@@ -353,8 +327,6 @@ static int tegra_pinconf_group_set(struct pinctrl_dev *pctldev, | |||
353 | s16 reg; | 327 | s16 reg; |
354 | u32 val, mask; | 328 | u32 val, mask; |
355 | 329 | ||
356 | if (group >= pmx->soc->ngroups) | ||
357 | return -EINVAL; | ||
358 | g = &pmx->soc->groups[group]; | 330 | g = &pmx->soc->groups[group]; |
359 | 331 | ||
360 | ret = tegra_pinconf_reg(pmx, g, param, &bank, ®, &bit, &width); | 332 | ret = tegra_pinconf_reg(pmx, g, param, &bank, ®, &bit, &width); |
diff --git a/drivers/pinctrl/pinctrl-u300.c b/drivers/pinctrl/pinctrl-u300.c index 26eb8ccd72d5..05d029911be6 100644 --- a/drivers/pinctrl/pinctrl-u300.c +++ b/drivers/pinctrl/pinctrl-u300.c | |||
@@ -836,18 +836,14 @@ static const struct u300_pin_group u300_pin_groups[] = { | |||
836 | }, | 836 | }, |
837 | }; | 837 | }; |
838 | 838 | ||
839 | static int u300_list_groups(struct pinctrl_dev *pctldev, unsigned selector) | 839 | static int u300_get_groups_count(struct pinctrl_dev *pctldev) |
840 | { | 840 | { |
841 | if (selector >= ARRAY_SIZE(u300_pin_groups)) | 841 | return ARRAY_SIZE(u300_pin_groups); |
842 | return -EINVAL; | ||
843 | return 0; | ||
844 | } | 842 | } |
845 | 843 | ||
846 | static const char *u300_get_group_name(struct pinctrl_dev *pctldev, | 844 | static const char *u300_get_group_name(struct pinctrl_dev *pctldev, |
847 | unsigned selector) | 845 | unsigned selector) |
848 | { | 846 | { |
849 | if (selector >= ARRAY_SIZE(u300_pin_groups)) | ||
850 | return NULL; | ||
851 | return u300_pin_groups[selector].name; | 847 | return u300_pin_groups[selector].name; |
852 | } | 848 | } |
853 | 849 | ||
@@ -855,8 +851,6 @@ static int u300_get_group_pins(struct pinctrl_dev *pctldev, unsigned selector, | |||
855 | const unsigned **pins, | 851 | const unsigned **pins, |
856 | unsigned *num_pins) | 852 | unsigned *num_pins) |
857 | { | 853 | { |
858 | if (selector >= ARRAY_SIZE(u300_pin_groups)) | ||
859 | return -EINVAL; | ||
860 | *pins = u300_pin_groups[selector].pins; | 854 | *pins = u300_pin_groups[selector].pins; |
861 | *num_pins = u300_pin_groups[selector].num_pins; | 855 | *num_pins = u300_pin_groups[selector].num_pins; |
862 | return 0; | 856 | return 0; |
@@ -869,7 +863,7 @@ static void u300_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s, | |||
869 | } | 863 | } |
870 | 864 | ||
871 | static struct pinctrl_ops u300_pctrl_ops = { | 865 | static struct pinctrl_ops u300_pctrl_ops = { |
872 | .list_groups = u300_list_groups, | 866 | .get_groups_count = u300_get_groups_count, |
873 | .get_group_name = u300_get_group_name, | 867 | .get_group_name = u300_get_group_name, |
874 | .get_group_pins = u300_get_group_pins, | 868 | .get_group_pins = u300_get_group_pins, |
875 | .pin_dbg_show = u300_pin_dbg_show, | 869 | .pin_dbg_show = u300_pin_dbg_show, |
@@ -991,11 +985,9 @@ static void u300_pmx_disable(struct pinctrl_dev *pctldev, unsigned selector, | |||
991 | u300_pmx_endisable(upmx, selector, false); | 985 | u300_pmx_endisable(upmx, selector, false); |
992 | } | 986 | } |
993 | 987 | ||
994 | static int u300_pmx_list_funcs(struct pinctrl_dev *pctldev, unsigned selector) | 988 | static int u300_pmx_get_funcs_count(struct pinctrl_dev *pctldev) |
995 | { | 989 | { |
996 | if (selector >= ARRAY_SIZE(u300_pmx_functions)) | 990 | return ARRAY_SIZE(u300_pmx_functions); |
997 | return -EINVAL; | ||
998 | return 0; | ||
999 | } | 991 | } |
1000 | 992 | ||
1001 | static const char *u300_pmx_get_func_name(struct pinctrl_dev *pctldev, | 993 | static const char *u300_pmx_get_func_name(struct pinctrl_dev *pctldev, |
@@ -1014,7 +1006,7 @@ static int u300_pmx_get_groups(struct pinctrl_dev *pctldev, unsigned selector, | |||
1014 | } | 1006 | } |
1015 | 1007 | ||
1016 | static struct pinmux_ops u300_pmx_ops = { | 1008 | static struct pinmux_ops u300_pmx_ops = { |
1017 | .list_functions = u300_pmx_list_funcs, | 1009 | .get_functions_count = u300_pmx_get_funcs_count, |
1018 | .get_function_name = u300_pmx_get_func_name, | 1010 | .get_function_name = u300_pmx_get_func_name, |
1019 | .get_function_groups = u300_pmx_get_groups, | 1011 | .get_function_groups = u300_pmx_get_groups, |
1020 | .enable = u300_pmx_enable, | 1012 | .enable = u300_pmx_enable, |
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 @@ | |||
33 | int pinmux_check_ops(struct pinctrl_dev *pctldev) | 33 | int 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; |