Commit 02725e74 authored by Thomas Gleixner's avatar Thomas Gleixner

genirq: Use irq_get/put functions

Convert the management functions to use the common irq_get/put
function.
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent d5eb4ad2
...@@ -25,22 +25,18 @@ ...@@ -25,22 +25,18 @@
*/ */
int irq_set_chip(unsigned int irq, struct irq_chip *chip) int irq_set_chip(unsigned int irq, struct irq_chip *chip)
{ {
struct irq_desc *desc = irq_to_desc(irq);
unsigned long flags; unsigned long flags;
struct irq_desc *desc = irq_get_desc_lock(irq, &flags);
if (!desc) { if (!desc)
WARN(1, KERN_ERR "Trying to install chip for IRQ%d\n", irq);
return -EINVAL; return -EINVAL;
}
if (!chip) if (!chip)
chip = &no_irq_chip; chip = &no_irq_chip;
raw_spin_lock_irqsave(&desc->lock, flags);
irq_chip_set_defaults(chip); irq_chip_set_defaults(chip);
desc->irq_data.chip = chip; desc->irq_data.chip = chip;
raw_spin_unlock_irqrestore(&desc->lock, flags); irq_put_desc_unlock(desc, flags);
return 0; return 0;
} }
EXPORT_SYMBOL(irq_set_chip); EXPORT_SYMBOL(irq_set_chip);
...@@ -52,24 +48,17 @@ EXPORT_SYMBOL(irq_set_chip); ...@@ -52,24 +48,17 @@ EXPORT_SYMBOL(irq_set_chip);
*/ */
int irq_set_irq_type(unsigned int irq, unsigned int type) int irq_set_irq_type(unsigned int irq, unsigned int type)
{ {
struct irq_desc *desc = irq_to_desc(irq);
unsigned long flags; unsigned long flags;
int ret = -ENXIO; struct irq_desc *desc = irq_get_desc_buslock(irq, &flags);
int ret = 0;
if (!desc) { if (!desc)
printk(KERN_ERR "Trying to set irq type for IRQ%d\n", irq); return -EINVAL;
return -ENODEV;
}
type &= IRQ_TYPE_SENSE_MASK; type &= IRQ_TYPE_SENSE_MASK;
if (type == IRQ_TYPE_NONE) if (type != IRQ_TYPE_NONE)
return 0; ret = __irq_set_trigger(desc, irq, type);
irq_put_desc_busunlock(desc, flags);
chip_bus_lock(desc);
raw_spin_lock_irqsave(&desc->lock, flags);
ret = __irq_set_trigger(desc, irq, type);
raw_spin_unlock_irqrestore(&desc->lock, flags);
chip_bus_sync_unlock(desc);
return ret; return ret;
} }
EXPORT_SYMBOL(irq_set_irq_type); EXPORT_SYMBOL(irq_set_irq_type);
...@@ -83,18 +72,13 @@ EXPORT_SYMBOL(irq_set_irq_type); ...@@ -83,18 +72,13 @@ EXPORT_SYMBOL(irq_set_irq_type);
*/ */
int irq_set_handler_data(unsigned int irq, void *data) int irq_set_handler_data(unsigned int irq, void *data)
{ {
struct irq_desc *desc = irq_to_desc(irq);
unsigned long flags; unsigned long flags;
struct irq_desc *desc = irq_get_desc_lock(irq, &flags);
if (!desc) { if (!desc)
printk(KERN_ERR
"Trying to install controller data for IRQ%d\n", irq);
return -EINVAL; return -EINVAL;
}
raw_spin_lock_irqsave(&desc->lock, flags);
desc->irq_data.handler_data = data; desc->irq_data.handler_data = data;
raw_spin_unlock_irqrestore(&desc->lock, flags); irq_put_desc_unlock(desc, flags);
return 0; return 0;
} }
EXPORT_SYMBOL(irq_set_handler_data); EXPORT_SYMBOL(irq_set_handler_data);
...@@ -108,20 +92,15 @@ EXPORT_SYMBOL(irq_set_handler_data); ...@@ -108,20 +92,15 @@ EXPORT_SYMBOL(irq_set_handler_data);
*/ */
int irq_set_msi_desc(unsigned int irq, struct msi_desc *entry) int irq_set_msi_desc(unsigned int irq, struct msi_desc *entry)
{ {
struct irq_desc *desc = irq_to_desc(irq);
unsigned long flags; unsigned long flags;
struct irq_desc *desc = irq_get_desc_lock(irq, &flags);
if (!desc) { if (!desc)
printk(KERN_ERR
"Trying to install msi data for IRQ%d\n", irq);
return -EINVAL; return -EINVAL;
}
raw_spin_lock_irqsave(&desc->lock, flags);
desc->irq_data.msi_desc = entry; desc->irq_data.msi_desc = entry;
if (entry) if (entry)
entry->irq = irq; entry->irq = irq;
raw_spin_unlock_irqrestore(&desc->lock, flags); irq_put_desc_unlock(desc, flags);
return 0; return 0;
} }
...@@ -134,24 +113,13 @@ int irq_set_msi_desc(unsigned int irq, struct msi_desc *entry) ...@@ -134,24 +113,13 @@ int irq_set_msi_desc(unsigned int irq, struct msi_desc *entry)
*/ */
int irq_set_chip_data(unsigned int irq, void *data) int irq_set_chip_data(unsigned int irq, void *data)
{ {
struct irq_desc *desc = irq_to_desc(irq);
unsigned long flags; unsigned long flags;
struct irq_desc *desc = irq_get_desc_lock(irq, &flags);
if (!desc) { if (!desc)
printk(KERN_ERR
"Trying to install chip data for IRQ%d\n", irq);
return -EINVAL;
}
if (!desc->irq_data.chip) {
printk(KERN_ERR "BUG: bad set_irq_chip_data(IRQ#%d)\n", irq);
return -EINVAL; return -EINVAL;
}
raw_spin_lock_irqsave(&desc->lock, flags);
desc->irq_data.chip_data = data; desc->irq_data.chip_data = data;
raw_spin_unlock_irqrestore(&desc->lock, flags); irq_put_desc_unlock(desc, flags);
return 0; return 0;
} }
EXPORT_SYMBOL(irq_set_chip_data); EXPORT_SYMBOL(irq_set_chip_data);
...@@ -635,25 +603,19 @@ void ...@@ -635,25 +603,19 @@ void
__set_irq_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained, __set_irq_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained,
const char *name) const char *name)
{ {
struct irq_desc *desc = irq_to_desc(irq);
unsigned long flags; unsigned long flags;
struct irq_desc *desc = irq_get_desc_buslock(irq, &flags);
if (!desc) { if (!desc)
printk(KERN_ERR
"Trying to install type control for IRQ%d\n", irq);
return; return;
}
if (!handle) { if (!handle) {
handle = handle_bad_irq; handle = handle_bad_irq;
} else { } else {
if (WARN_ON(desc->irq_data.chip == &no_irq_chip)) if (WARN_ON(desc->irq_data.chip == &no_irq_chip))
return; goto out;
} }
chip_bus_lock(desc);
raw_spin_lock_irqsave(&desc->lock, flags);
/* Uninstall? */ /* Uninstall? */
if (handle == handle_bad_irq) { if (handle == handle_bad_irq) {
if (desc->irq_data.chip != &no_irq_chip) if (desc->irq_data.chip != &no_irq_chip)
...@@ -670,8 +632,8 @@ __set_irq_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained, ...@@ -670,8 +632,8 @@ __set_irq_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained,
irq_settings_set_norequest(desc); irq_settings_set_norequest(desc);
irq_startup(desc); irq_startup(desc);
} }
raw_spin_unlock_irqrestore(&desc->lock, flags); out:
chip_bus_sync_unlock(desc); irq_put_desc_busunlock(desc, flags);
} }
EXPORT_SYMBOL_GPL(__set_irq_handler); EXPORT_SYMBOL_GPL(__set_irq_handler);
...@@ -693,14 +655,11 @@ set_irq_chip_and_handler_name(unsigned int irq, struct irq_chip *chip, ...@@ -693,14 +655,11 @@ set_irq_chip_and_handler_name(unsigned int irq, struct irq_chip *chip,
void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set) void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set)
{ {
struct irq_desc *desc = irq_to_desc(irq);
unsigned long flags; unsigned long flags;
struct irq_desc *desc = irq_get_desc_lock(irq, &flags);
if (!desc) if (!desc)
return; return;
raw_spin_lock_irqsave(&desc->lock, flags);
irq_settings_clr_and_set(desc, clr, set); irq_settings_clr_and_set(desc, clr, set);
irqd_clear(&desc->irq_data, IRQD_NO_BALANCING | IRQD_PER_CPU | irqd_clear(&desc->irq_data, IRQD_NO_BALANCING | IRQD_PER_CPU |
...@@ -714,5 +673,5 @@ void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set) ...@@ -714,5 +673,5 @@ void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set)
irqd_set(&desc->irq_data, irq_settings_get_trigger_mask(desc)); irqd_set(&desc->irq_data, irq_settings_get_trigger_mask(desc));
raw_spin_unlock_irqrestore(&desc->lock, flags); irq_put_desc_unlock(desc, flags);
} }
...@@ -172,16 +172,13 @@ int irq_set_affinity(unsigned int irq, const struct cpumask *mask) ...@@ -172,16 +172,13 @@ int irq_set_affinity(unsigned int irq, const struct cpumask *mask)
int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m) int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m)
{ {
struct irq_desc *desc = irq_to_desc(irq);
unsigned long flags; unsigned long flags;
struct irq_desc *desc = irq_get_desc_lock(irq, &flags);
if (!desc) if (!desc)
return -EINVAL; return -EINVAL;
raw_spin_lock_irqsave(&desc->lock, flags);
desc->affinity_hint = m; desc->affinity_hint = m;
raw_spin_unlock_irqrestore(&desc->lock, flags); irq_put_desc_unlock(desc, flags);
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(irq_set_affinity_hint); EXPORT_SYMBOL_GPL(irq_set_affinity_hint);
...@@ -336,6 +333,18 @@ void __disable_irq(struct irq_desc *desc, unsigned int irq, bool suspend) ...@@ -336,6 +333,18 @@ void __disable_irq(struct irq_desc *desc, unsigned int irq, bool suspend)
irq_disable(desc); irq_disable(desc);
} }
static int __disable_irq_nosync(unsigned int irq)
{
unsigned long flags;
struct irq_desc *desc = irq_get_desc_buslock(irq, &flags);
if (!desc)
return -EINVAL;
__disable_irq(desc, irq, false);
irq_put_desc_busunlock(desc, flags);
return 0;
}
/** /**
* disable_irq_nosync - disable an irq without waiting * disable_irq_nosync - disable an irq without waiting
* @irq: Interrupt to disable * @irq: Interrupt to disable
...@@ -349,17 +358,7 @@ void __disable_irq(struct irq_desc *desc, unsigned int irq, bool suspend) ...@@ -349,17 +358,7 @@ void __disable_irq(struct irq_desc *desc, unsigned int irq, bool suspend)
*/ */
void disable_irq_nosync(unsigned int irq) void disable_irq_nosync(unsigned int irq)
{ {
struct irq_desc *desc = irq_to_desc(irq); __disable_irq_nosync(irq);
unsigned long flags;
if (!desc)
return;
chip_bus_lock(desc);
raw_spin_lock_irqsave(&desc->lock, flags);
__disable_irq(desc, irq, false);
raw_spin_unlock_irqrestore(&desc->lock, flags);
chip_bus_sync_unlock(desc);
} }
EXPORT_SYMBOL(disable_irq_nosync); EXPORT_SYMBOL(disable_irq_nosync);
...@@ -377,13 +376,7 @@ EXPORT_SYMBOL(disable_irq_nosync); ...@@ -377,13 +376,7 @@ EXPORT_SYMBOL(disable_irq_nosync);
*/ */
void disable_irq(unsigned int irq) void disable_irq(unsigned int irq)
{ {
struct irq_desc *desc = irq_to_desc(irq); if (!__disable_irq_nosync(irq))
if (!desc)
return;
disable_irq_nosync(irq);
if (desc->action)
synchronize_irq(irq); synchronize_irq(irq);
} }
EXPORT_SYMBOL(disable_irq); EXPORT_SYMBOL(disable_irq);
...@@ -434,21 +427,18 @@ void __enable_irq(struct irq_desc *desc, unsigned int irq, bool resume) ...@@ -434,21 +427,18 @@ void __enable_irq(struct irq_desc *desc, unsigned int irq, bool resume)
*/ */
void enable_irq(unsigned int irq) void enable_irq(unsigned int irq)
{ {
struct irq_desc *desc = irq_to_desc(irq);
unsigned long flags; unsigned long flags;
struct irq_desc *desc = irq_get_desc_buslock(irq, &flags);
if (!desc) if (!desc)
return; return;
if (WARN(!desc->irq_data.chip, if (WARN(!desc->irq_data.chip,
KERN_ERR "enable_irq before setup/request_irq: irq %u\n", irq)) KERN_ERR "enable_irq before setup/request_irq: irq %u\n", irq))
return; goto out;
chip_bus_lock(desc);
raw_spin_lock_irqsave(&desc->lock, flags);
__enable_irq(desc, irq, false); __enable_irq(desc, irq, false);
raw_spin_unlock_irqrestore(&desc->lock, flags); out:
chip_bus_sync_unlock(desc); irq_put_desc_busunlock(desc, flags);
} }
EXPORT_SYMBOL(enable_irq); EXPORT_SYMBOL(enable_irq);
...@@ -477,15 +467,13 @@ static int set_irq_wake_real(unsigned int irq, unsigned int on) ...@@ -477,15 +467,13 @@ static int set_irq_wake_real(unsigned int irq, unsigned int on)
*/ */
int irq_set_irq_wake(unsigned int irq, unsigned int on) int irq_set_irq_wake(unsigned int irq, unsigned int on)
{ {
struct irq_desc *desc = irq_to_desc(irq);
unsigned long flags; unsigned long flags;
struct irq_desc *desc = irq_get_desc_buslock(irq, &flags);
int ret = 0; int ret = 0;
/* wakeup-capable irqs can be shared between drivers that /* wakeup-capable irqs can be shared between drivers that
* don't need to have the same sleep mode behaviors. * don't need to have the same sleep mode behaviors.
*/ */
chip_bus_lock(desc);
raw_spin_lock_irqsave(&desc->lock, flags);
if (on) { if (on) {
if (desc->wake_depth++ == 0) { if (desc->wake_depth++ == 0) {
ret = set_irq_wake_real(irq, on); ret = set_irq_wake_real(irq, on);
...@@ -505,9 +493,7 @@ int irq_set_irq_wake(unsigned int irq, unsigned int on) ...@@ -505,9 +493,7 @@ int irq_set_irq_wake(unsigned int irq, unsigned int on)
irqd_clear(&desc->irq_data, IRQD_WAKEUP_STATE); irqd_clear(&desc->irq_data, IRQD_WAKEUP_STATE);
} }
} }
irq_put_desc_busunlock(desc, flags);
raw_spin_unlock_irqrestore(&desc->lock, flags);
chip_bus_sync_unlock(desc);
return ret; return ret;
} }
EXPORT_SYMBOL(irq_set_irq_wake); EXPORT_SYMBOL(irq_set_irq_wake);
...@@ -519,25 +505,20 @@ EXPORT_SYMBOL(irq_set_irq_wake); ...@@ -519,25 +505,20 @@ EXPORT_SYMBOL(irq_set_irq_wake);
*/ */
int can_request_irq(unsigned int irq, unsigned long irqflags) int can_request_irq(unsigned int irq, unsigned long irqflags)
{ {
struct irq_desc *desc = irq_to_desc(irq);
struct irqaction *action;
unsigned long flags; unsigned long flags;
struct irq_desc *desc = irq_get_desc_lock(irq, &flags);
int canrequest = 0;
if (!desc) if (!desc)
return 0; return 0;
if (!irq_settings_can_request(desc)) if (irq_settings_can_request(desc)) {
return 0; if (desc->action)
if (irqflags & desc->action->flags & IRQF_SHARED)
raw_spin_lock_irqsave(&desc->lock, flags); canrequest =1;
action = desc->action; }
if (action) irq_put_desc_unlock(desc, flags);
if (irqflags & action->flags & IRQF_SHARED) return canrequest;
action = NULL;
raw_spin_unlock_irqrestore(&desc->lock, flags);
return !action;
} }
int __irq_set_trigger(struct irq_desc *desc, unsigned int irq, int __irq_set_trigger(struct irq_desc *desc, unsigned int irq,
......
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