aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChanho Park <chanho61.park@samsung.com>2012-01-03 02:47:50 -0500
committerLinus Walleij <linus.walleij@linaro.org>2012-01-03 03:10:09 -0500
commit706e8520e8450a631ca6f798f8c811faf56f0a59 (patch)
tree68b0f77fc1f3b92be3e905e36f14e184403d0b67
parente6337c3c96a7ee5cfd5e7afed825f894d4576f58 (diff)
pinctrl: correct a offset while enumerating pins
This patch modifies a offset while enumerating pins to support a partial pin space. If we use a pin number for enumerating pins, the pin space always starts with zero base. Indeed, we always check the pin is in the pin space. An extreme example, there is only two pins. One is 0. Another is 1000. We always enumerate whole offsets until 1000. For solving this problem, we use the offset of the pin array instead of the zero-based pin number. Signed-off-by: Chanho Park <chanho61.park@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> [Restored sparse pin space comment] Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r--drivers/pinctrl/core.c14
-rw-r--r--drivers/pinctrl/pinconf.c9
-rw-r--r--drivers/pinctrl/pinmux.c9
3 files changed, 18 insertions, 14 deletions
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index 9e32ea311432..79c56d90fcc5 100644
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -102,12 +102,13 @@ struct pin_desc *pin_desc_get(struct pinctrl_dev *pctldev, unsigned int pin)
102 */ 102 */
103int pin_get_from_name(struct pinctrl_dev *pctldev, const char *name) 103int pin_get_from_name(struct pinctrl_dev *pctldev, const char *name)
104{ 104{
105 unsigned pin; 105 unsigned i, pin;
106 106
107 /* The highest pin number need to be included in the loop, thus <= */ 107 /* The pin number can be retrived from the pin controller descriptor */
108 for (pin = 0; pin <= pctldev->desc->maxpin; pin++) { 108 for (i = 0; i < pctldev->desc->npins; i++) {
109 struct pin_desc *desc; 109 struct pin_desc *desc;
110 110
111 pin = pctldev->desc->pins[i].number;
111 desc = pin_desc_get(pctldev, pin); 112 desc = pin_desc_get(pctldev, pin);
112 /* Pin space may be sparse */ 113 /* Pin space may be sparse */
113 if (desc == NULL) 114 if (desc == NULL)
@@ -350,15 +351,16 @@ static int pinctrl_pins_show(struct seq_file *s, void *what)
350{ 351{
351 struct pinctrl_dev *pctldev = s->private; 352 struct pinctrl_dev *pctldev = s->private;
352 const struct pinctrl_ops *ops = pctldev->desc->pctlops; 353 const struct pinctrl_ops *ops = pctldev->desc->pctlops;
353 unsigned pin; 354 unsigned i, pin;
354 355
355 seq_printf(s, "registered pins: %d\n", pctldev->desc->npins); 356 seq_printf(s, "registered pins: %d\n", pctldev->desc->npins);
356 seq_printf(s, "max pin number: %d\n", pctldev->desc->maxpin); 357 seq_printf(s, "max pin number: %d\n", pctldev->desc->maxpin);
357 358
358 /* The highest pin number need to be included in the loop, thus <= */ 359 /* The pin number can be retrived from the pin controller descriptor */
359 for (pin = 0; pin <= pctldev->desc->maxpin; pin++) { 360 for (i = 0; i < pctldev->desc->npins; i++) {
360 struct pin_desc *desc; 361 struct pin_desc *desc;
361 362
363 pin = pctldev->desc->pins[i].number;
362 desc = pin_desc_get(pctldev, pin); 364 desc = pin_desc_get(pctldev, pin);
363 /* Pin space may be sparse */ 365 /* Pin space may be sparse */
364 if (desc == NULL) 366 if (desc == NULL)
diff --git a/drivers/pinctrl/pinconf.c b/drivers/pinctrl/pinconf.c
index 57dbb4b478db..1259872b0a1d 100644
--- a/drivers/pinctrl/pinconf.c
+++ b/drivers/pinctrl/pinconf.c
@@ -230,17 +230,18 @@ static void pinconf_dump_pin(struct pinctrl_dev *pctldev,
230static int pinconf_pins_show(struct seq_file *s, void *what) 230static int pinconf_pins_show(struct seq_file *s, void *what)
231{ 231{
232 struct pinctrl_dev *pctldev = s->private; 232 struct pinctrl_dev *pctldev = s->private;
233 unsigned pin; 233 unsigned i, pin;
234 234
235 seq_puts(s, "Pin config settings per pin\n"); 235 seq_puts(s, "Pin config settings per pin\n");
236 seq_puts(s, "Format: pin (name): pinmux setting array\n"); 236 seq_puts(s, "Format: pin (name): pinmux setting array\n");
237 237
238 /* The highest pin number need to be included in the loop, thus <= */ 238 /* The pin number can be retrived from the pin controller descriptor */
239 for (pin = 0; pin <= pctldev->desc->maxpin; pin++) { 239 for (i = 0; pin < pctldev->desc->npins; i++) {
240 struct pin_desc *desc; 240 struct pin_desc *desc;
241 241
242 pin = pctldev->desc->pins[i].number;
242 desc = pin_desc_get(pctldev, pin); 243 desc = pin_desc_get(pctldev, pin);
243 /* Pin space may be sparse */ 244 /* Skip if we cannot search the pin */
244 if (desc == NULL) 245 if (desc == NULL)
245 continue; 246 continue;
246 247
diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
index 0916222dd7d2..a76a348321bb 100644
--- a/drivers/pinctrl/pinmux.c
+++ b/drivers/pinctrl/pinmux.c
@@ -1063,18 +1063,19 @@ static int pinmux_functions_show(struct seq_file *s, void *what)
1063static int pinmux_pins_show(struct seq_file *s, void *what) 1063static int pinmux_pins_show(struct seq_file *s, void *what)
1064{ 1064{
1065 struct pinctrl_dev *pctldev = s->private; 1065 struct pinctrl_dev *pctldev = s->private;
1066 unsigned pin; 1066 unsigned i, pin;
1067 1067
1068 seq_puts(s, "Pinmux settings per pin\n"); 1068 seq_puts(s, "Pinmux settings per pin\n");
1069 seq_puts(s, "Format: pin (name): pinmuxfunction\n"); 1069 seq_puts(s, "Format: pin (name): pinmuxfunction\n");
1070 1070
1071 /* The highest pin number need to be included in the loop, thus <= */ 1071 /* The pin number can be retrived from the pin controller descriptor */
1072 for (pin = 0; pin <= pctldev->desc->maxpin; pin++) { 1072 for (i = 0; i < pctldev->desc->npins; i++) {
1073 1073
1074 struct pin_desc *desc; 1074 struct pin_desc *desc;
1075 1075
1076 pin = pctldev->desc->pins[i].number;
1076 desc = pin_desc_get(pctldev, pin); 1077 desc = pin_desc_get(pctldev, pin);
1077 /* Pin space may be sparse */ 1078 /* Skip if we cannot search the pin */
1078 if (desc == NULL) 1079 if (desc == NULL)
1079 continue; 1080 continue;
1080 1081