diff options
author | Alexandre TORGUE <alexandre.torgue@st.com> | 2017-01-27 11:15:14 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2017-01-30 10:26:28 -0500 |
commit | dca72e09e0cd50f7caa8517264f552657b671a69 (patch) | |
tree | 056e8a96747c4aaef60e1f7fb4bdf6f99940b6eb /drivers/pinctrl/stm32 | |
parent | 838adb576d4a3da03d4e35a3149dc015dfeec299 (diff) |
pinctrl: stm32: fix bad location of gpiochip_lock_as_irq
Move gpio lock as irq from "domain alloc" callback to "domain activate"
callback. It will allow to use gpiolib sysfs correctly.
Signed-off-by: Alexandre TORGUE <alexandre.torgue@st.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/stm32')
-rw-r--r-- | drivers/pinctrl/stm32/pinctrl-stm32.c | 37 |
1 files changed, 12 insertions, 25 deletions
diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.c b/drivers/pinctrl/stm32/pinctrl-stm32.c index c983a1e33dbe..abc405be0212 100644 --- a/drivers/pinctrl/stm32/pinctrl-stm32.c +++ b/drivers/pinctrl/stm32/pinctrl-stm32.c | |||
@@ -236,6 +236,15 @@ static void stm32_gpio_domain_activate(struct irq_domain *d, | |||
236 | struct stm32_pinctrl *pctl = dev_get_drvdata(bank->gpio_chip.parent); | 236 | struct stm32_pinctrl *pctl = dev_get_drvdata(bank->gpio_chip.parent); |
237 | 237 | ||
238 | regmap_field_write(pctl->irqmux[irq_data->hwirq], bank->range.id); | 238 | regmap_field_write(pctl->irqmux[irq_data->hwirq], bank->range.id); |
239 | gpiochip_lock_as_irq(&bank->gpio_chip, irq_data->hwirq); | ||
240 | } | ||
241 | |||
242 | static void stm32_gpio_domain_deactivate(struct irq_domain *d, | ||
243 | struct irq_data *irq_data) | ||
244 | { | ||
245 | struct stm32_gpio_bank *bank = d->host_data; | ||
246 | |||
247 | gpiochip_unlock_as_irq(&bank->gpio_chip, irq_data->hwirq); | ||
239 | } | 248 | } |
240 | 249 | ||
241 | static int stm32_gpio_domain_alloc(struct irq_domain *d, | 250 | static int stm32_gpio_domain_alloc(struct irq_domain *d, |
@@ -243,11 +252,9 @@ static int stm32_gpio_domain_alloc(struct irq_domain *d, | |||
243 | unsigned int nr_irqs, void *data) | 252 | unsigned int nr_irqs, void *data) |
244 | { | 253 | { |
245 | struct stm32_gpio_bank *bank = d->host_data; | 254 | struct stm32_gpio_bank *bank = d->host_data; |
246 | struct stm32_pinctrl *pctl = dev_get_drvdata(bank->gpio_chip.parent); | ||
247 | struct irq_fwspec *fwspec = data; | 255 | struct irq_fwspec *fwspec = data; |
248 | struct irq_fwspec parent_fwspec; | 256 | struct irq_fwspec parent_fwspec; |
249 | irq_hw_number_t hwirq; | 257 | irq_hw_number_t hwirq; |
250 | int ret; | ||
251 | 258 | ||
252 | hwirq = fwspec->param[0]; | 259 | hwirq = fwspec->param[0]; |
253 | parent_fwspec.fwnode = d->parent->fwnode; | 260 | parent_fwspec.fwnode = d->parent->fwnode; |
@@ -258,35 +265,15 @@ static int stm32_gpio_domain_alloc(struct irq_domain *d, | |||
258 | irq_domain_set_hwirq_and_chip(d, virq, hwirq, &stm32_gpio_irq_chip, | 265 | irq_domain_set_hwirq_and_chip(d, virq, hwirq, &stm32_gpio_irq_chip, |
259 | bank); | 266 | bank); |
260 | 267 | ||
261 | ret = gpiochip_lock_as_irq(&bank->gpio_chip, hwirq); | 268 | return irq_domain_alloc_irqs_parent(d, virq, nr_irqs, &parent_fwspec); |
262 | if (ret) { | ||
263 | dev_err(pctl->dev, "Unable to configure STM32 %s%ld as IRQ\n", | ||
264 | bank->gpio_chip.label, hwirq); | ||
265 | return ret; | ||
266 | } | ||
267 | |||
268 | ret = irq_domain_alloc_irqs_parent(d, virq, nr_irqs, &parent_fwspec); | ||
269 | if (ret) | ||
270 | gpiochip_unlock_as_irq(&bank->gpio_chip, hwirq); | ||
271 | |||
272 | return ret; | ||
273 | } | ||
274 | |||
275 | static void stm32_gpio_domain_free(struct irq_domain *d, unsigned int virq, | ||
276 | unsigned int nr_irqs) | ||
277 | { | ||
278 | struct stm32_gpio_bank *bank = d->host_data; | ||
279 | struct irq_data *data = irq_get_irq_data(virq); | ||
280 | |||
281 | irq_domain_free_irqs_common(d, virq, nr_irqs); | ||
282 | gpiochip_unlock_as_irq(&bank->gpio_chip, data->hwirq); | ||
283 | } | 269 | } |
284 | 270 | ||
285 | static const struct irq_domain_ops stm32_gpio_domain_ops = { | 271 | static const struct irq_domain_ops stm32_gpio_domain_ops = { |
286 | .translate = stm32_gpio_domain_translate, | 272 | .translate = stm32_gpio_domain_translate, |
287 | .alloc = stm32_gpio_domain_alloc, | 273 | .alloc = stm32_gpio_domain_alloc, |
288 | .free = stm32_gpio_domain_free, | 274 | .free = irq_domain_free_irqs_common, |
289 | .activate = stm32_gpio_domain_activate, | 275 | .activate = stm32_gpio_domain_activate, |
276 | .deactivate = stm32_gpio_domain_deactivate, | ||
290 | }; | 277 | }; |
291 | 278 | ||
292 | /* Pinctrl functions */ | 279 | /* Pinctrl functions */ |