pinctrl: correct a offset while enumerating pins
authorChanho Park <chanho61.park@samsung.com>
Tue, 3 Jan 2012 07:47:50 +0000 (16:47 +0900)
committerLinus Walleij <linus.walleij@linaro.org>
Tue, 3 Jan 2012 08:10:09 +0000 (09:10 +0100)
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>
drivers/pinctrl/core.c
drivers/pinctrl/pinconf.c
drivers/pinctrl/pinmux.c

index 9e32ea311432a5ce39f69b8cca75c7deb47ec22f..79c56d90fcc59968c92280313fc1309805f370d8 100644 (file)
@@ -102,12 +102,13 @@ struct pin_desc *pin_desc_get(struct pinctrl_dev *pctldev, unsigned int pin)
  */
 int pin_get_from_name(struct pinctrl_dev *pctldev, const char *name)
 {
-       unsigned pin;
+       unsigned i, pin;
 
-       /* The highest pin number need to be included in the loop, thus <= */
-       for (pin = 0; pin <= pctldev->desc->maxpin; pin++) {
+       /* The pin number can be retrived from the pin controller descriptor */
+       for (i = 0; i < pctldev->desc->npins; i++) {
                struct pin_desc *desc;
 
+               pin = pctldev->desc->pins[i].number;
                desc = pin_desc_get(pctldev, pin);
                /* Pin space may be sparse */
                if (desc == NULL)
@@ -350,15 +351,16 @@ static int pinctrl_pins_show(struct seq_file *s, void *what)
 {
        struct pinctrl_dev *pctldev = s->private;
        const struct pinctrl_ops *ops = pctldev->desc->pctlops;
-       unsigned pin;
+       unsigned i, pin;
 
        seq_printf(s, "registered pins: %d\n", pctldev->desc->npins);
        seq_printf(s, "max pin number: %d\n", pctldev->desc->maxpin);
 
-       /* The highest pin number need to be included in the loop, thus <= */
-       for (pin = 0; pin <= pctldev->desc->maxpin; pin++) {
+       /* The pin number can be retrived from the pin controller descriptor */
+       for (i = 0; i < pctldev->desc->npins; i++) {
                struct pin_desc *desc;
 
+               pin = pctldev->desc->pins[i].number;
                desc = pin_desc_get(pctldev, pin);
                /* Pin space may be sparse */
                if (desc == NULL)
index 57dbb4b478db3a062ee4a5bbe3f877a9a247c70d..1259872b0a1d641e9da7f34cfd57a1f9e2ae1c91 100644 (file)
@@ -230,17 +230,18 @@ static void pinconf_dump_pin(struct pinctrl_dev *pctldev,
 static int pinconf_pins_show(struct seq_file *s, void *what)
 {
        struct pinctrl_dev *pctldev = s->private;
-       unsigned pin;
+       unsigned i, pin;
 
        seq_puts(s, "Pin config settings per pin\n");
        seq_puts(s, "Format: pin (name): pinmux setting array\n");
 
-       /* The highest pin number need to be included in the loop, thus <= */
-       for (pin = 0; pin <= pctldev->desc->maxpin; pin++) {
+       /* The pin number can be retrived from the pin controller descriptor */
+       for (i = 0; pin < pctldev->desc->npins; i++) {
                struct pin_desc *desc;
 
+               pin = pctldev->desc->pins[i].number;
                desc = pin_desc_get(pctldev, pin);
-               /* Pin space may be sparse */
+               /* Skip if we cannot search the pin */
                if (desc == NULL)
                        continue;
 
index 0916222dd7d2d09ddc837e83339f81582ed236a6..a76a348321bb4284d6820279fed3bb679cd23fcf 100644 (file)
@@ -1063,18 +1063,19 @@ static int pinmux_functions_show(struct seq_file *s, void *what)
 static int pinmux_pins_show(struct seq_file *s, void *what)
 {
        struct pinctrl_dev *pctldev = s->private;
-       unsigned pin;
+       unsigned i, pin;
 
        seq_puts(s, "Pinmux settings per pin\n");
        seq_puts(s, "Format: pin (name): pinmuxfunction\n");
 
-       /* The highest pin number need to be included in the loop, thus <= */
-       for (pin = 0; pin <= pctldev->desc->maxpin; pin++) {
+       /* The pin number can be retrived from the pin controller descriptor */
+       for (i = 0; i < pctldev->desc->npins; i++) {
 
                struct pin_desc *desc;
 
+               pin = pctldev->desc->pins[i].number;
                desc = pin_desc_get(pctldev, pin);
-               /* Pin space may be sparse */
+               /* Skip if we cannot search the pin */
                if (desc == NULL)
                        continue;
 
This page took 0.029824 seconds and 5 git commands to generate.