Commit 46999238 authored by Thomas Gleixner's avatar Thomas Gleixner

genirq: Consolidate startup/shutdown of interrupts

Aside of duplicated code some of the startup/shutdown sites do not
handle the MASKED/DISABLED flags and the depth field at all. Move that
to a helper function and take care of it there.
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
LKML-Reference: <20110202212551.787481468@linutronix.de>
parent 3b56f058
...@@ -60,7 +60,7 @@ unsigned long probe_irq_on(void) ...@@ -60,7 +60,7 @@ unsigned long probe_irq_on(void)
if (desc->irq_data.chip->irq_set_type) if (desc->irq_data.chip->irq_set_type)
desc->irq_data.chip->irq_set_type(&desc->irq_data, desc->irq_data.chip->irq_set_type(&desc->irq_data,
IRQ_TYPE_PROBE); IRQ_TYPE_PROBE);
desc->irq_data.chip->irq_startup(&desc->irq_data); irq_startup(desc);
} }
raw_spin_unlock_irq(&desc->lock); raw_spin_unlock_irq(&desc->lock);
} }
...@@ -77,7 +77,7 @@ unsigned long probe_irq_on(void) ...@@ -77,7 +77,7 @@ unsigned long probe_irq_on(void)
raw_spin_lock_irq(&desc->lock); raw_spin_lock_irq(&desc->lock);
if (!desc->action && !(desc->status & IRQ_NOPROBE)) { if (!desc->action && !(desc->status & IRQ_NOPROBE)) {
desc->status |= IRQ_AUTODETECT | IRQ_WAITING; desc->status |= IRQ_AUTODETECT | IRQ_WAITING;
if (desc->irq_data.chip->irq_startup(&desc->irq_data)) if (irq_startup(desc))
desc->status |= IRQ_PENDING; desc->status |= IRQ_PENDING;
} }
raw_spin_unlock_irq(&desc->lock); raw_spin_unlock_irq(&desc->lock);
...@@ -99,7 +99,7 @@ unsigned long probe_irq_on(void) ...@@ -99,7 +99,7 @@ unsigned long probe_irq_on(void)
/* It triggered already - consider it spurious. */ /* It triggered already - consider it spurious. */
if (!(status & IRQ_WAITING)) { if (!(status & IRQ_WAITING)) {
desc->status = status & ~IRQ_AUTODETECT; desc->status = status & ~IRQ_AUTODETECT;
desc->irq_data.chip->irq_shutdown(&desc->irq_data); irq_shutdown(desc);
} else } else
if (i < 32) if (i < 32)
mask |= 1 << i; mask |= 1 << i;
...@@ -138,7 +138,7 @@ unsigned int probe_irq_mask(unsigned long val) ...@@ -138,7 +138,7 @@ unsigned int probe_irq_mask(unsigned long val)
mask |= 1 << i; mask |= 1 << i;
desc->status = status & ~IRQ_AUTODETECT; desc->status = status & ~IRQ_AUTODETECT;
desc->irq_data.chip->irq_shutdown(&desc->irq_data); irq_shutdown(desc);
} }
raw_spin_unlock_irq(&desc->lock); raw_spin_unlock_irq(&desc->lock);
} }
...@@ -182,7 +182,7 @@ int probe_irq_off(unsigned long val) ...@@ -182,7 +182,7 @@ int probe_irq_off(unsigned long val)
nr_of_irqs++; nr_of_irqs++;
} }
desc->status = status & ~IRQ_AUTODETECT; desc->status = status & ~IRQ_AUTODETECT;
desc->irq_data.chip->irq_shutdown(&desc->irq_data); irq_shutdown(desc);
} }
raw_spin_unlock_irq(&desc->lock); raw_spin_unlock_irq(&desc->lock);
} }
......
...@@ -192,6 +192,25 @@ void set_irq_nested_thread(unsigned int irq, int nest) ...@@ -192,6 +192,25 @@ void set_irq_nested_thread(unsigned int irq, int nest)
} }
EXPORT_SYMBOL_GPL(set_irq_nested_thread); EXPORT_SYMBOL_GPL(set_irq_nested_thread);
int irq_startup(struct irq_desc *desc)
{
desc->status &= ~(IRQ_MASKED | IRQ_DISABLED);
desc->depth = 0;
if (desc->irq_data.chip->irq_startup)
return desc->irq_data.chip->irq_startup(&desc->irq_data);
desc->irq_data.chip->irq_enable(&desc->irq_data);
return 0;
}
void irq_shutdown(struct irq_desc *desc)
{
desc->status |= IRQ_MASKED | IRQ_DISABLED;
desc->depth = 1;
desc->irq_data.chip->irq_shutdown(&desc->irq_data);
}
/* /*
* default enable function * default enable function
*/ */
...@@ -210,17 +229,6 @@ static void default_disable(struct irq_data *data) ...@@ -210,17 +229,6 @@ static void default_disable(struct irq_data *data)
{ {
} }
/*
* default startup function
*/
static unsigned int default_startup(struct irq_data *data)
{
struct irq_desc *desc = irq_data_to_desc(data);
desc->irq_data.chip->irq_enable(data);
return 0;
}
/* /*
* default shutdown function * default shutdown function
*/ */
...@@ -229,7 +237,6 @@ static void default_shutdown(struct irq_data *data) ...@@ -229,7 +237,6 @@ static void default_shutdown(struct irq_data *data)
struct irq_desc *desc = irq_data_to_desc(data); struct irq_desc *desc = irq_data_to_desc(data);
desc->irq_data.chip->irq_mask(&desc->irq_data); desc->irq_data.chip->irq_mask(&desc->irq_data);
desc->status |= IRQ_MASKED;
} }
#ifndef CONFIG_GENERIC_HARDIRQS_NO_DEPRECATED #ifndef CONFIG_GENERIC_HARDIRQS_NO_DEPRECATED
...@@ -337,8 +344,6 @@ void irq_chip_set_defaults(struct irq_chip *chip) ...@@ -337,8 +344,6 @@ void irq_chip_set_defaults(struct irq_chip *chip)
chip->irq_enable = default_enable; chip->irq_enable = default_enable;
if (!chip->irq_disable) if (!chip->irq_disable)
chip->irq_disable = default_disable; chip->irq_disable = default_disable;
if (!chip->irq_startup)
chip->irq_startup = default_startup;
/* /*
* We use chip->irq_disable, when the user provided its own. When * We use chip->irq_disable, when the user provided its own. When
* we have default_disable set for chip->irq_disable, then we need * we have default_disable set for chip->irq_disable, then we need
...@@ -747,10 +752,8 @@ __set_irq_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained, ...@@ -747,10 +752,8 @@ __set_irq_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained,
desc->name = name; desc->name = name;
if (handle != handle_bad_irq && is_chained) { if (handle != handle_bad_irq && is_chained) {
desc->status &= ~IRQ_DISABLED;
desc->status |= IRQ_NOREQUEST | IRQ_NOPROBE; desc->status |= IRQ_NOREQUEST | IRQ_NOPROBE;
desc->depth = 0; irq_startup(desc);
desc->irq_data.chip->irq_startup(&desc->irq_data);
} }
raw_spin_unlock_irqrestore(&desc->lock, flags); raw_spin_unlock_irqrestore(&desc->lock, flags);
chip_bus_sync_unlock(desc); chip_bus_sync_unlock(desc);
......
...@@ -38,6 +38,9 @@ extern int __irq_set_trigger(struct irq_desc *desc, unsigned int irq, ...@@ -38,6 +38,9 @@ extern int __irq_set_trigger(struct irq_desc *desc, unsigned int irq,
extern void __disable_irq(struct irq_desc *desc, unsigned int irq, bool susp); extern void __disable_irq(struct irq_desc *desc, unsigned int irq, bool susp);
extern void __enable_irq(struct irq_desc *desc, unsigned int irq, bool resume); extern void __enable_irq(struct irq_desc *desc, unsigned int irq, bool resume);
extern int irq_startup(struct irq_desc *desc);
extern void irq_shutdown(struct irq_desc *desc);
extern void init_kstat_irqs(struct irq_desc *desc, int node, int nr); extern void init_kstat_irqs(struct irq_desc *desc, int node, int nr);
/* Resending of interrupts :*/ /* Resending of interrupts :*/
......
...@@ -906,11 +906,9 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new) ...@@ -906,11 +906,9 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new)
if (new->flags & IRQF_ONESHOT) if (new->flags & IRQF_ONESHOT)
desc->status |= IRQ_ONESHOT; desc->status |= IRQ_ONESHOT;
if (!(desc->status & IRQ_NOAUTOEN)) { if (!(desc->status & IRQ_NOAUTOEN))
desc->depth = 0; irq_startup(desc);
desc->status &= ~IRQ_DISABLED; else
desc->irq_data.chip->irq_startup(&desc->irq_data);
} else
/* Undo nested disables: */ /* Undo nested disables: */
desc->depth = 1; desc->depth = 1;
...@@ -1055,10 +1053,8 @@ static struct irqaction *__free_irq(unsigned int irq, void *dev_id) ...@@ -1055,10 +1053,8 @@ static struct irqaction *__free_irq(unsigned int irq, void *dev_id)
#endif #endif
/* If this was the last handler, shut down the IRQ line: */ /* If this was the last handler, shut down the IRQ line: */
if (!desc->action) { if (!desc->action)
desc->status |= IRQ_DISABLED; irq_shutdown(desc);
desc->irq_data.chip->irq_shutdown(&desc->irq_data);
}
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
/* make sure affinity_hint is cleaned up */ /* make sure affinity_hint is cleaned up */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment