pinmux.c (7ecdb16fe63e5b356335ebdc236adfb48cef31e1) pinmux.c (0e3db173e2b9fd3b82246516e72c17763eb5f98d)
1/*
2 * Core driver for the pin muxing portions of the pin control subsystem
3 *
4 * Copyright (C) 2011-2012 ST-Ericsson SA
5 * Written on behalf of Linaro for ST-Ericsson
6 * Based on bits of regulator core, gpio core and clk core
7 *
8 * Author: Linus Walleij <linus.walleij@linaro.org>

--- 69 unchanged lines hidden (view full) ---

78
79 desc = pin_desc_get(pctldev, pin);
80 if (desc == NULL) {
81 dev_err(pctldev->dev,
82 "pin is not registered so it cannot be requested\n");
83 goto out;
84 }
85
1/*
2 * Core driver for the pin muxing portions of the pin control subsystem
3 *
4 * Copyright (C) 2011-2012 ST-Ericsson SA
5 * Written on behalf of Linaro for ST-Ericsson
6 * Based on bits of regulator core, gpio core and clk core
7 *
8 * Author: Linus Walleij <linus.walleij@linaro.org>

--- 69 unchanged lines hidden (view full) ---

78
79 desc = pin_desc_get(pctldev, pin);
80 if (desc == NULL) {
81 dev_err(pctldev->dev,
82 "pin is not registered so it cannot be requested\n");
83 goto out;
84 }
85
86 if (desc->owner && strcmp(desc->owner, owner)) {
86 if (desc->usecount && strcmp(desc->owner, owner)) {
87 dev_err(pctldev->dev,
88 "pin already requested\n");
89 goto out;
90 }
87 dev_err(pctldev->dev,
88 "pin already requested\n");
89 goto out;
90 }
91
92 desc->usecount++;
93 if (desc->usecount > 1)
94 return 0;
95
91 desc->owner = owner;
92
93 /* Let each pin increase references to this module */
94 if (!try_module_get(pctldev->owner)) {
95 dev_err(pctldev->dev,
96 "could not increase module refcount for pin %d\n",
97 pin);
98 status = -EINVAL;

--- 7 unchanged lines hidden (view full) ---

106 if (gpio_range && ops->gpio_request_enable)
107 /* This requests and enables a single GPIO pin */
108 status = ops->gpio_request_enable(pctldev, gpio_range, pin);
109 else if (ops->request)
110 status = ops->request(pctldev, pin);
111 else
112 status = 0;
113
96 desc->owner = owner;
97
98 /* Let each pin increase references to this module */
99 if (!try_module_get(pctldev->owner)) {
100 dev_err(pctldev->dev,
101 "could not increase module refcount for pin %d\n",
102 pin);
103 status = -EINVAL;

--- 7 unchanged lines hidden (view full) ---

111 if (gpio_range && ops->gpio_request_enable)
112 /* This requests and enables a single GPIO pin */
113 status = ops->gpio_request_enable(pctldev, gpio_range, pin);
114 else if (ops->request)
115 status = ops->request(pctldev, pin);
116 else
117 status = 0;
118
114 if (status)
119 if (status) {
115 dev_err(pctldev->dev, "->request on device %s failed for pin %d\n",
116 pctldev->desc->name, pin);
120 dev_err(pctldev->dev, "->request on device %s failed for pin %d\n",
121 pctldev->desc->name, pin);
122 module_put(pctldev->owner);
123 }
124
117out_free_pin:
125out_free_pin:
118 if (status)
119 desc->owner = NULL;
126 if (status) {
127 desc->usecount--;
128 if (!desc->usecount)
129 desc->owner = NULL;
130 }
120out:
121 if (status)
122 dev_err(pctldev->dev, "pin-%d (%s) status %d\n",
123 pin, owner, status);
124
125 return status;
126}
127

--- 17 unchanged lines hidden (view full) ---

145
146 desc = pin_desc_get(pctldev, pin);
147 if (desc == NULL) {
148 dev_err(pctldev->dev,
149 "pin is not registered so it cannot be freed\n");
150 return NULL;
151 }
152
131out:
132 if (status)
133 dev_err(pctldev->dev, "pin-%d (%s) status %d\n",
134 pin, owner, status);
135
136 return status;
137}
138

--- 17 unchanged lines hidden (view full) ---

156
157 desc = pin_desc_get(pctldev, pin);
158 if (desc == NULL) {
159 dev_err(pctldev->dev,
160 "pin is not registered so it cannot be freed\n");
161 return NULL;
162 }
163
164 desc->usecount--;
165 if (desc->usecount)
166 return NULL;
167
153 /*
154 * If there is no kind of request function for the pin we just assume
155 * we got it by default and proceed.
156 */
157 if (gpio_range && ops->gpio_disable_free)
158 ops->gpio_disable_free(pctldev, gpio_range, pin);
159 else if (ops->free)
160 ops->free(pctldev, pin);

--- 331 unchanged lines hidden ---
168 /*
169 * If there is no kind of request function for the pin we just assume
170 * we got it by default and proceed.
171 */
172 if (gpio_range && ops->gpio_disable_free)
173 ops->gpio_disable_free(pctldev, gpio_range, pin);
174 else if (ops->free)
175 ops->free(pctldev, pin);

--- 331 unchanged lines hidden ---