aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/irq
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2014-03-08 02:59:58 -0500
committerThomas Gleixner <tglx@linutronix.de>2014-03-12 11:00:24 -0400
commitc1bacbae8192dd2a9ebadd22d793b68054f6c6e5 (patch)
treea2d402e83d75c77a390e47c0150078230bc0101a /kernel/irq
parentfa389e220254c69ffae0d403eac4146171062d08 (diff)
genirq: Provide irq_request/release_resources chip callbacks
For certain irq types, e.g. gpios, it's necessary to request resources before starting up the irq. This might fail so we cannot use the irq_startup() callback because we might call the irq_set_type() callback before that which does not make sense when the resource is not available. Calling irq_startup() before irq_set_type() can lead to spurious interrupts which is not desired either. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: Jean-Jacques Hiblot <jjhiblot@traphandler.com> Cc: Grant Likely <grant.likely@linaro.org> Cc: linux-arm-kernel@lists.infradead.org Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Link: http://lkml.kernel.org/r/alpine.DEB.2.02.1403080857160.18573@ionos.tec.linutronix.de Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel/irq')
-rw-r--r--kernel/irq/manage.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index d3bf660cb57f..5d35cbe22896 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -896,6 +896,23 @@ static void irq_setup_forced_threading(struct irqaction *new)
896 } 896 }
897} 897}
898 898
899static int irq_request_resources(struct irq_desc *desc)
900{
901 struct irq_data *d = &desc->irq_data;
902 struct irq_chip *c = d->chip;
903
904 return c->irq_request_resources ? c->irq_request_resources(d) : 0;
905}
906
907static void irq_release_resources(struct irq_desc *desc)
908{
909 struct irq_data *d = &desc->irq_data;
910 struct irq_chip *c = d->chip;
911
912 if (c->irq_release_resources)
913 c->irq_release_resources(d);
914}
915
899/* 916/*
900 * Internal function to register an irqaction - typically used to 917 * Internal function to register an irqaction - typically used to
901 * allocate special interrupts that are part of the architecture. 918 * allocate special interrupts that are part of the architecture.
@@ -1091,6 +1108,13 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new)
1091 } 1108 }
1092 1109
1093 if (!shared) { 1110 if (!shared) {
1111 ret = irq_request_resources(desc);
1112 if (ret) {
1113 pr_err("Failed to request resources for %s (irq %d) on irqchip %s\n",
1114 new->name, irq, desc->irq_data.chip->name);
1115 goto out_mask;
1116 }
1117
1094 init_waitqueue_head(&desc->wait_for_threads); 1118 init_waitqueue_head(&desc->wait_for_threads);
1095 1119
1096 /* Setup the type (level, edge polarity) if configured: */ 1120 /* Setup the type (level, edge polarity) if configured: */
@@ -1261,8 +1285,10 @@ static struct irqaction *__free_irq(unsigned int irq, void *dev_id)
1261 *action_ptr = action->next; 1285 *action_ptr = action->next;
1262 1286
1263 /* If this was the last handler, shut down the IRQ line: */ 1287 /* If this was the last handler, shut down the IRQ line: */
1264 if (!desc->action) 1288 if (!desc->action) {
1265 irq_shutdown(desc); 1289 irq_shutdown(desc);
1290 irq_release_resources(desc);
1291 }
1266 1292
1267#ifdef CONFIG_SMP 1293#ifdef CONFIG_SMP
1268 /* make sure affinity_hint is cleaned up */ 1294 /* make sure affinity_hint is cleaned up */