aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl/pinmux.c
diff options
context:
space:
mode:
authorStephen Warren <swarren@nvidia.com>2011-12-09 18:59:05 -0500
committerLinus Walleij <linus.walleij@linaro.org>2012-01-03 03:10:06 -0500
commit51cd24ee625c348654114032499914d0311e5832 (patch)
tree7483fbdc4db119f9a8f013035005f374e729ffd0 /drivers/pinctrl/pinmux.c
parent528b78306ecf82af06c4862aa5518643fe20a440 (diff)
pinctrl: don't create a device for each pin controller
Pin controllers should already be instantiated as a device, so there's no need for the pinctrl core to create a new struct device for each controller. This allows the controller's real name to be used in the mux mapping table, rather than e.g. "pinctrl.0", "pinctrl.1", etc. This necessitates removal of the PINMUX_MAP_PRIMARY*() macros, since their sole purpose was to hard-code the .ctrl_dev_name field to be "pinctrl.0". Signed-off-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/pinmux.c')
-rw-r--r--drivers/pinctrl/pinmux.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
index a11681b4bd91..3bcc64137ddc 100644
--- a/drivers/pinctrl/pinmux.c
+++ b/drivers/pinctrl/pinmux.c
@@ -106,24 +106,24 @@ static int pin_request(struct pinctrl_dev *pctldev,
106 const struct pinmux_ops *ops = pctldev->desc->pmxops; 106 const struct pinmux_ops *ops = pctldev->desc->pmxops;
107 int status = -EINVAL; 107 int status = -EINVAL;
108 108
109 dev_dbg(&pctldev->dev, "request pin %d for %s\n", pin, function); 109 dev_dbg(pctldev->dev, "request pin %d for %s\n", pin, function);
110 110
111 desc = pin_desc_get(pctldev, pin); 111 desc = pin_desc_get(pctldev, pin);
112 if (desc == NULL) { 112 if (desc == NULL) {
113 dev_err(&pctldev->dev, 113 dev_err(pctldev->dev,
114 "pin is not registered so it cannot be requested\n"); 114 "pin is not registered so it cannot be requested\n");
115 goto out; 115 goto out;
116 } 116 }
117 117
118 if (!function) { 118 if (!function) {
119 dev_err(&pctldev->dev, "no function name given\n"); 119 dev_err(pctldev->dev, "no function name given\n");
120 return -EINVAL; 120 return -EINVAL;
121 } 121 }
122 122
123 spin_lock(&desc->lock); 123 spin_lock(&desc->lock);
124 if (desc->mux_function) { 124 if (desc->mux_function) {
125 spin_unlock(&desc->lock); 125 spin_unlock(&desc->lock);
126 dev_err(&pctldev->dev, 126 dev_err(pctldev->dev,
127 "pin already requested\n"); 127 "pin already requested\n");
128 goto out; 128 goto out;
129 } 129 }
@@ -132,7 +132,7 @@ static int pin_request(struct pinctrl_dev *pctldev,
132 132
133 /* Let each pin increase references to this module */ 133 /* Let each pin increase references to this module */
134 if (!try_module_get(pctldev->owner)) { 134 if (!try_module_get(pctldev->owner)) {
135 dev_err(&pctldev->dev, 135 dev_err(pctldev->dev,
136 "could not increase module refcount for pin %d\n", 136 "could not increase module refcount for pin %d\n",
137 pin); 137 pin);
138 status = -EINVAL; 138 status = -EINVAL;
@@ -152,7 +152,7 @@ static int pin_request(struct pinctrl_dev *pctldev,
152 status = 0; 152 status = 0;
153 153
154 if (status) 154 if (status)
155 dev_err(&pctldev->dev, "->request on device %s failed " 155 dev_err(pctldev->dev, "->request on device %s failed "
156 "for pin %d\n", 156 "for pin %d\n",
157 pctldev->desc->name, pin); 157 pctldev->desc->name, pin);
158out_free_pin: 158out_free_pin:
@@ -163,7 +163,7 @@ out_free_pin:
163 } 163 }
164out: 164out:
165 if (status) 165 if (status)
166 dev_err(&pctldev->dev, "pin-%d (%s) status %d\n", 166 dev_err(pctldev->dev, "pin-%d (%s) status %d\n",
167 pin, function ? : "?", status); 167 pin, function ? : "?", status);
168 168
169 return status; 169 return status;
@@ -189,7 +189,7 @@ static const char *pin_free(struct pinctrl_dev *pctldev, int pin,
189 189
190 desc = pin_desc_get(pctldev, pin); 190 desc = pin_desc_get(pctldev, pin);
191 if (desc == NULL) { 191 if (desc == NULL) {
192 dev_err(&pctldev->dev, 192 dev_err(pctldev->dev,
193 "pin is not registered so it cannot be freed\n"); 193 "pin is not registered so it cannot be freed\n");
194 return NULL; 194 return NULL;
195 } 195 }
@@ -434,14 +434,14 @@ static int acquire_pins(struct pinctrl_dev *pctldev,
434 if (ret) 434 if (ret)
435 return ret; 435 return ret;
436 436
437 dev_dbg(&pctldev->dev, "requesting the %u pins from group %u\n", 437 dev_dbg(pctldev->dev, "requesting the %u pins from group %u\n",
438 num_pins, group_selector); 438 num_pins, group_selector);
439 439
440 /* Try to allocate all pins in this group, one by one */ 440 /* Try to allocate all pins in this group, one by one */
441 for (i = 0; i < num_pins; i++) { 441 for (i = 0; i < num_pins; i++) {
442 ret = pin_request(pctldev, pins[i], func, NULL); 442 ret = pin_request(pctldev, pins[i], func, NULL);
443 if (ret) { 443 if (ret) {
444 dev_err(&pctldev->dev, 444 dev_err(pctldev->dev,
445 "could not get pin %d for function %s " 445 "could not get pin %d for function %s "
446 "on device %s - conflicting mux mappings?\n", 446 "on device %s - conflicting mux mappings?\n",
447 pins[i], func ? : "(undefined)", 447 pins[i], func ? : "(undefined)",
@@ -473,7 +473,7 @@ static void release_pins(struct pinctrl_dev *pctldev,
473 ret = pctlops->get_group_pins(pctldev, group_selector, 473 ret = pctlops->get_group_pins(pctldev, group_selector,
474 &pins, &num_pins); 474 &pins, &num_pins);
475 if (ret) { 475 if (ret) {
476 dev_err(&pctldev->dev, "could not get pins to release for " 476 dev_err(pctldev->dev, "could not get pins to release for "
477 "group selector %d\n", 477 "group selector %d\n",
478 group_selector); 478 group_selector);
479 return; 479 return;
@@ -525,7 +525,7 @@ static int pinmux_check_pin_group(struct pinctrl_dev *pctldev,
525 return -EINVAL; 525 return -EINVAL;
526 ret = pinctrl_get_group_selector(pctldev, groups[0]); 526 ret = pinctrl_get_group_selector(pctldev, groups[0]);
527 if (ret < 0) { 527 if (ret < 0) {
528 dev_err(&pctldev->dev, 528 dev_err(pctldev->dev,
529 "function %s wants group %s but the pin " 529 "function %s wants group %s but the pin "
530 "controller does not seem to have that group\n", 530 "controller does not seem to have that group\n",
531 pmxops->get_function_name(pctldev, func_selector), 531 pmxops->get_function_name(pctldev, func_selector),
@@ -534,7 +534,7 @@ static int pinmux_check_pin_group(struct pinctrl_dev *pctldev,
534 } 534 }
535 535
536 if (num_groups > 1) 536 if (num_groups > 1)
537 dev_dbg(&pctldev->dev, 537 dev_dbg(pctldev->dev,
538 "function %s support more than one group, " 538 "function %s support more than one group, "
539 "default-selecting first group %s (%d)\n", 539 "default-selecting first group %s (%d)\n",
540 pmxops->get_function_name(pctldev, func_selector), 540 pmxops->get_function_name(pctldev, func_selector),
@@ -544,13 +544,13 @@ static int pinmux_check_pin_group(struct pinctrl_dev *pctldev,
544 return ret; 544 return ret;
545 } 545 }
546 546
547 dev_dbg(&pctldev->dev, 547 dev_dbg(pctldev->dev,
548 "check if we have pin group %s on controller %s\n", 548 "check if we have pin group %s on controller %s\n",
549 pin_group, pinctrl_dev_get_name(pctldev)); 549 pin_group, pinctrl_dev_get_name(pctldev));
550 550
551 ret = pinctrl_get_group_selector(pctldev, pin_group); 551 ret = pinctrl_get_group_selector(pctldev, pin_group);
552 if (ret < 0) { 552 if (ret < 0) {
553 dev_dbg(&pctldev->dev, 553 dev_dbg(pctldev->dev,
554 "%s does not support pin group %s with function %s\n", 554 "%s does not support pin group %s with function %s\n",
555 pinctrl_dev_get_name(pctldev), 555 pinctrl_dev_get_name(pctldev),
556 pin_group, 556 pin_group,
@@ -627,7 +627,7 @@ static int pinmux_enable_muxmap(struct pinctrl_dev *pctldev,
627 */ 627 */
628 628
629 if (pmx->pctldev && pmx->pctldev != pctldev) { 629 if (pmx->pctldev && pmx->pctldev != pctldev) {
630 dev_err(&pctldev->dev, 630 dev_err(pctldev->dev,
631 "different pin control devices given for device %s, " 631 "different pin control devices given for device %s, "
632 "function %s\n", 632 "function %s\n",
633 devname, 633 devname,
@@ -650,7 +650,7 @@ static int pinmux_enable_muxmap(struct pinctrl_dev *pctldev,
650 */ 650 */
651 if (pmx->func_selector != UINT_MAX && 651 if (pmx->func_selector != UINT_MAX &&
652 pmx->func_selector != func_selector) { 652 pmx->func_selector != func_selector) {
653 dev_err(&pctldev->dev, 653 dev_err(pctldev->dev,
654 "dual function defines in the map for device %s\n", 654 "dual function defines in the map for device %s\n",
655 devname); 655 devname);
656 return -EINVAL; 656 return -EINVAL;
@@ -756,7 +756,7 @@ struct pinmux *pinmux_get(struct device *dev, const char *name)
756 } 756 }
757 757
758 pr_debug("in map, found pctldev %s to handle function %s", 758 pr_debug("in map, found pctldev %s to handle function %s",
759 dev_name(&pctldev->dev), map->function); 759 dev_name(pctldev->dev), map->function);
760 760
761 761
762 /* 762 /*
@@ -932,7 +932,7 @@ static int pinmux_hog_map(struct pinctrl_dev *pctldev,
932 * without any problems, so then we can hog pinmuxes for 932 * without any problems, so then we can hog pinmuxes for
933 * all devices that just want a static pin mux at this point. 933 * all devices that just want a static pin mux at this point.
934 */ 934 */
935 dev_err(&pctldev->dev, "map %s wants to hog a non-system " 935 dev_err(pctldev->dev, "map %s wants to hog a non-system "
936 "pinmux, this is not going to work\n", map->name); 936 "pinmux, this is not going to work\n", map->name);
937 return -EINVAL; 937 return -EINVAL;
938 } 938 }
@@ -944,7 +944,7 @@ static int pinmux_hog_map(struct pinctrl_dev *pctldev,
944 pmx = pinmux_get(NULL, map->name); 944 pmx = pinmux_get(NULL, map->name);
945 if (IS_ERR(pmx)) { 945 if (IS_ERR(pmx)) {
946 kfree(hog); 946 kfree(hog);
947 dev_err(&pctldev->dev, 947 dev_err(pctldev->dev,
948 "could not get the %s pinmux mapping for hogging\n", 948 "could not get the %s pinmux mapping for hogging\n",
949 map->name); 949 map->name);
950 return PTR_ERR(pmx); 950 return PTR_ERR(pmx);
@@ -954,7 +954,7 @@ static int pinmux_hog_map(struct pinctrl_dev *pctldev,
954 if (ret) { 954 if (ret) {
955 pinmux_put(pmx); 955 pinmux_put(pmx);
956 kfree(hog); 956 kfree(hog);
957 dev_err(&pctldev->dev, 957 dev_err(pctldev->dev,
958 "could not enable the %s pinmux mapping for hogging\n", 958 "could not enable the %s pinmux mapping for hogging\n",
959 map->name); 959 map->name);
960 return ret; 960 return ret;
@@ -963,7 +963,7 @@ static int pinmux_hog_map(struct pinctrl_dev *pctldev,
963 hog->map = map; 963 hog->map = map;
964 hog->pmx = pmx; 964 hog->pmx = pmx;
965 965
966 dev_info(&pctldev->dev, "hogged map %s, function %s\n", map->name, 966 dev_info(pctldev->dev, "hogged map %s, function %s\n", map->name,
967 map->function); 967 map->function);
968 mutex_lock(&pctldev->pinmux_hogs_lock); 968 mutex_lock(&pctldev->pinmux_hogs_lock);
969 list_add(&hog->node, &pctldev->pinmux_hogs); 969 list_add(&hog->node, &pctldev->pinmux_hogs);
@@ -982,7 +982,7 @@ static int pinmux_hog_map(struct pinctrl_dev *pctldev,
982 */ 982 */
983int pinmux_hog_maps(struct pinctrl_dev *pctldev) 983int pinmux_hog_maps(struct pinctrl_dev *pctldev)
984{ 984{
985 struct device *dev = &pctldev->dev; 985 struct device *dev = pctldev->dev;
986 const char *devname = dev_name(dev); 986 const char *devname = dev_name(dev);
987 int ret; 987 int ret;
988 int i; 988 int i;