aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/pinctrl/core.c32
-rw-r--r--drivers/pinctrl/core.h1
2 files changed, 29 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 }
diff --git a/drivers/pinctrl/core.h b/drivers/pinctrl/core.h
index 98ae8085e735..1f40ff68a8c4 100644
--- a/drivers/pinctrl/core.h
+++ b/drivers/pinctrl/core.h
@@ -148,6 +148,7 @@ struct pin_desc {
148 148
149struct pinctrl_dev *get_pinctrl_dev_from_devname(const char *dev_name); 149struct pinctrl_dev *get_pinctrl_dev_from_devname(const char *dev_name);
150int pin_get_from_name(struct pinctrl_dev *pctldev, const char *name); 150int pin_get_from_name(struct pinctrl_dev *pctldev, const char *name);
151const char *pin_get_name(struct pinctrl_dev *pctldev, const unsigned pin);
151int pinctrl_get_group_selector(struct pinctrl_dev *pctldev, 152int pinctrl_get_group_selector(struct pinctrl_dev *pctldev,
152 const char *pin_group); 153 const char *pin_group);
153 154