aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl/core.c
diff options
context:
space:
mode:
authorDong Aisheng <dong.aisheng@linaro.org>2012-04-17 03:00:46 -0400
committerLinus Walleij <linus.walleij@linaro.org>2012-04-18 07:53:13 -0400
commitdcb5dbc305b975cccf40942feba40964069541d3 (patch)
treef5dc39743766d69ef05b8df844d71758a5ee1dfc /drivers/pinctrl/core.c
parentd0bd8df56ebffe4a5ca42e27aca2a1243c70ed53 (diff)
pinctrl: show pin name for pingroups in sysfs
Pin name is more useful to users. After change, when cat pingroups in sysfs, it becomes: root@freescale /sys/kernel/debug/pinctrl/20e0000.iomuxc$ cat pingroups registered pin groups: group: uart4grp-1 pin 219 (MX6Q_PAD_KEY_ROW0) pin 218 (MX6Q_PAD_KEY_COL0) group: usdhc4grp-1 pin 305 (MX6Q_PAD_SD4_CMD) pin 306 (MX6Q_PAD_SD4_CLK) pin 315 (MX6Q_PAD_SD4_DAT0) pin 316 (MX6Q_PAD_SD4_DAT1) pin 317 (MX6Q_PAD_SD4_DAT2) pin 318 (MX6Q_PAD_SD4_DAT3) pin 319 (MX6Q_PAD_SD4_DAT4) pin 320 (MX6Q_PAD_SD4_DAT5) pin 321 (MX6Q_PAD_SD4_DAT6) pin 322 (MX6Q_PAD_SD4_DAT7) Acked-by: Stephen Warren <swarren@wwwdotorg.org> Signed-off-by: Dong Aisheng <dong.aisheng@linaro.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/core.c')
-rw-r--r--drivers/pinctrl/core.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index 2eaa1876534b..5cd5a5a3a403 100644
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -126,6 +126,25 @@ int pin_get_from_name(struct pinctrl_dev *pctldev, const char *name)
126} 126}
127 127
128/** 128/**
129 * pin_get_name_from_id() - look up a pin name from a pin id
130 * @pctldev: the pin control device to lookup the pin on
131 * @name: the name of the pin to look up
132 */
133const char *pin_get_name(struct pinctrl_dev *pctldev, const unsigned pin)
134{
135 const struct pin_desc *desc;
136
137 desc = pin_desc_get(pctldev, pin);
138 if (desc == NULL) {
139 dev_err(pctldev->dev, "failed to get pin(%d) name\n",
140 pin);
141 return NULL;
142 }
143
144 return desc->name;
145}
146
147/**
129 * pin_is_valid() - check if pin exists on controller 148 * pin_is_valid() - check if pin exists on controller
130 * @pctldev: the pin control device to check the pin on 149 * @pctldev: the pin control device to check the pin on
131 * @pin: pin to check, use the local pin controller index number 150 * @pin: pin to check, use the local pin controller index number
@@ -1011,6 +1030,7 @@ static int pinctrl_groups_show(struct seq_file *s, void *what)
1011 const unsigned *pins; 1030 const unsigned *pins;
1012 unsigned num_pins; 1031 unsigned num_pins;
1013 const char *gname = ops->get_group_name(pctldev, selector); 1032 const char *gname = ops->get_group_name(pctldev, selector);
1033 const char *pname;
1014 int ret; 1034 int ret;
1015 int i; 1035 int i;
1016 1036
@@ -1020,10 +1040,14 @@ static int pinctrl_groups_show(struct seq_file *s, void *what)
1020 seq_printf(s, "%s [ERROR GETTING PINS]\n", 1040 seq_printf(s, "%s [ERROR GETTING PINS]\n",
1021 gname); 1041 gname);
1022 else { 1042 else {
1023 seq_printf(s, "group: %s, pins = [ ", gname); 1043 seq_printf(s, "group: %s\n", gname);
1024 for (i = 0; i < num_pins; i++) 1044 for (i = 0; i < num_pins; i++) {
1025 seq_printf(s, "%d ", pins[i]); 1045 pname = pin_get_name(pctldev, pins[i]);
1026 seq_puts(s, "]\n"); 1046 if (WARN_ON(!pname))
1047 return -EINVAL;
1048 seq_printf(s, "pin %d (%s)\n", pins[i], pname);
1049 }
1050 seq_puts(s, "\n");
1027 } 1051 }
1028 selector++; 1052 selector++;
1029 } 1053 }