diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2011-02-12 04:37:36 -0500 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2011-02-19 06:58:23 -0500 |
commit | 02725e7471b8dd58fa96f6604bdb5dde45405a2e (patch) | |
tree | 7c5243d0a2e33f2165d1531febbe9752fad389c7 /kernel/irq/chip.c | |
parent | d5eb4ad2dfb2dfae43fd51bc8630b4fc3ef00e92 (diff) |
genirq: Use irq_get/put functions
Convert the management functions to use the common irq_get/put
function.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel/irq/chip.c')
-rw-r--r-- | kernel/irq/chip.c | 93 |
1 files changed, 26 insertions, 67 deletions
diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c index c19c0b562c80..3ea6aecd99c0 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c | |||
@@ -25,22 +25,18 @@ | |||
25 | */ | 25 | */ |
26 | int irq_set_chip(unsigned int irq, struct irq_chip *chip) | 26 | int irq_set_chip(unsigned int irq, struct irq_chip *chip) |
27 | { | 27 | { |
28 | struct irq_desc *desc = irq_to_desc(irq); | ||
29 | unsigned long flags; | 28 | unsigned long flags; |
29 | struct irq_desc *desc = irq_get_desc_lock(irq, &flags); | ||
30 | 30 | ||
31 | if (!desc) { | 31 | if (!desc) |
32 | WARN(1, KERN_ERR "Trying to install chip for IRQ%d\n", irq); | ||
33 | return -EINVAL; | 32 | return -EINVAL; |
34 | } | ||
35 | 33 | ||
36 | if (!chip) | 34 | if (!chip) |
37 | chip = &no_irq_chip; | 35 | chip = &no_irq_chip; |
38 | 36 | ||
39 | raw_spin_lock_irqsave(&desc->lock, flags); | ||
40 | irq_chip_set_defaults(chip); | 37 | irq_chip_set_defaults(chip); |
41 | desc->irq_data.chip = chip; | 38 | desc->irq_data.chip = chip; |
42 | raw_spin_unlock_irqrestore(&desc->lock, flags); | 39 | irq_put_desc_unlock(desc, flags); |
43 | |||
44 | return 0; | 40 | return 0; |
45 | } | 41 | } |
46 | EXPORT_SYMBOL(irq_set_chip); | 42 | EXPORT_SYMBOL(irq_set_chip); |
@@ -52,24 +48,17 @@ EXPORT_SYMBOL(irq_set_chip); | |||
52 | */ | 48 | */ |
53 | int irq_set_irq_type(unsigned int irq, unsigned int type) | 49 | int irq_set_irq_type(unsigned int irq, unsigned int type) |
54 | { | 50 | { |
55 | struct irq_desc *desc = irq_to_desc(irq); | ||
56 | unsigned long flags; | 51 | unsigned long flags; |
57 | int ret = -ENXIO; | 52 | struct irq_desc *desc = irq_get_desc_buslock(irq, &flags); |
53 | int ret = 0; | ||
58 | 54 | ||
59 | if (!desc) { | 55 | if (!desc) |
60 | printk(KERN_ERR "Trying to set irq type for IRQ%d\n", irq); | 56 | return -EINVAL; |
61 | return -ENODEV; | ||
62 | } | ||
63 | 57 | ||
64 | type &= IRQ_TYPE_SENSE_MASK; | 58 | type &= IRQ_TYPE_SENSE_MASK; |
65 | if (type == IRQ_TYPE_NONE) | 59 | if (type != IRQ_TYPE_NONE) |
66 | return 0; | 60 | ret = __irq_set_trigger(desc, irq, type); |
67 | 61 | irq_put_desc_busunlock(desc, flags); | |
68 | chip_bus_lock(desc); | ||
69 | raw_spin_lock_irqsave(&desc->lock, flags); | ||
70 | ret = __irq_set_trigger(desc, irq, type); | ||
71 | raw_spin_unlock_irqrestore(&desc->lock, flags); | ||
72 | chip_bus_sync_unlock(desc); | ||
73 | return ret; | 62 | return ret; |
74 | } | 63 | } |
75 | EXPORT_SYMBOL(irq_set_irq_type); | 64 | EXPORT_SYMBOL(irq_set_irq_type); |
@@ -83,18 +72,13 @@ EXPORT_SYMBOL(irq_set_irq_type); | |||
83 | */ | 72 | */ |
84 | int irq_set_handler_data(unsigned int irq, void *data) | 73 | int irq_set_handler_data(unsigned int irq, void *data) |
85 | { | 74 | { |
86 | struct irq_desc *desc = irq_to_desc(irq); | ||
87 | unsigned long flags; | 75 | unsigned long flags; |
76 | struct irq_desc *desc = irq_get_desc_lock(irq, &flags); | ||
88 | 77 | ||
89 | if (!desc) { | 78 | if (!desc) |
90 | printk(KERN_ERR | ||
91 | "Trying to install controller data for IRQ%d\n", irq); | ||
92 | return -EINVAL; | 79 | return -EINVAL; |
93 | } | ||
94 | |||
95 | raw_spin_lock_irqsave(&desc->lock, flags); | ||
96 | desc->irq_data.handler_data = data; | 80 | desc->irq_data.handler_data = data; |
97 | raw_spin_unlock_irqrestore(&desc->lock, flags); | 81 | irq_put_desc_unlock(desc, flags); |
98 | return 0; | 82 | return 0; |
99 | } | 83 | } |
100 | EXPORT_SYMBOL(irq_set_handler_data); | 84 | EXPORT_SYMBOL(irq_set_handler_data); |
@@ -108,20 +92,15 @@ EXPORT_SYMBOL(irq_set_handler_data); | |||
108 | */ | 92 | */ |
109 | int irq_set_msi_desc(unsigned int irq, struct msi_desc *entry) | 93 | int irq_set_msi_desc(unsigned int irq, struct msi_desc *entry) |
110 | { | 94 | { |
111 | struct irq_desc *desc = irq_to_desc(irq); | ||
112 | unsigned long flags; | 95 | unsigned long flags; |
96 | struct irq_desc *desc = irq_get_desc_lock(irq, &flags); | ||
113 | 97 | ||
114 | if (!desc) { | 98 | if (!desc) |
115 | printk(KERN_ERR | ||
116 | "Trying to install msi data for IRQ%d\n", irq); | ||
117 | return -EINVAL; | 99 | return -EINVAL; |
118 | } | ||
119 | |||
120 | raw_spin_lock_irqsave(&desc->lock, flags); | ||
121 | desc->irq_data.msi_desc = entry; | 100 | desc->irq_data.msi_desc = entry; |
122 | if (entry) | 101 | if (entry) |
123 | entry->irq = irq; | 102 | entry->irq = irq; |
124 | raw_spin_unlock_irqrestore(&desc->lock, flags); | 103 | irq_put_desc_unlock(desc, flags); |
125 | return 0; | 104 | return 0; |
126 | } | 105 | } |
127 | 106 | ||
@@ -134,24 +113,13 @@ int irq_set_msi_desc(unsigned int irq, struct msi_desc *entry) | |||
134 | */ | 113 | */ |
135 | int irq_set_chip_data(unsigned int irq, void *data) | 114 | int irq_set_chip_data(unsigned int irq, void *data) |
136 | { | 115 | { |
137 | struct irq_desc *desc = irq_to_desc(irq); | ||
138 | unsigned long flags; | 116 | unsigned long flags; |
117 | struct irq_desc *desc = irq_get_desc_lock(irq, &flags); | ||
139 | 118 | ||
140 | if (!desc) { | 119 | if (!desc) |
141 | printk(KERN_ERR | ||
142 | "Trying to install chip data for IRQ%d\n", irq); | ||
143 | return -EINVAL; | ||
144 | } | ||
145 | |||
146 | if (!desc->irq_data.chip) { | ||
147 | printk(KERN_ERR "BUG: bad set_irq_chip_data(IRQ#%d)\n", irq); | ||
148 | return -EINVAL; | 120 | return -EINVAL; |
149 | } | ||
150 | |||
151 | raw_spin_lock_irqsave(&desc->lock, flags); | ||
152 | desc->irq_data.chip_data = data; | 121 | desc->irq_data.chip_data = data; |
153 | raw_spin_unlock_irqrestore(&desc->lock, flags); | 122 | irq_put_desc_unlock(desc, flags); |
154 | |||
155 | return 0; | 123 | return 0; |
156 | } | 124 | } |
157 | EXPORT_SYMBOL(irq_set_chip_data); | 125 | EXPORT_SYMBOL(irq_set_chip_data); |
@@ -635,25 +603,19 @@ void | |||
635 | __set_irq_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained, | 603 | __set_irq_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained, |
636 | const char *name) | 604 | const char *name) |
637 | { | 605 | { |
638 | struct irq_desc *desc = irq_to_desc(irq); | ||
639 | unsigned long flags; | 606 | unsigned long flags; |
607 | struct irq_desc *desc = irq_get_desc_buslock(irq, &flags); | ||
640 | 608 | ||
641 | if (!desc) { | 609 | if (!desc) |
642 | printk(KERN_ERR | ||
643 | "Trying to install type control for IRQ%d\n", irq); | ||
644 | return; | 610 | return; |
645 | } | ||
646 | 611 | ||
647 | if (!handle) { | 612 | if (!handle) { |
648 | handle = handle_bad_irq; | 613 | handle = handle_bad_irq; |
649 | } else { | 614 | } else { |
650 | if (WARN_ON(desc->irq_data.chip == &no_irq_chip)) | 615 | if (WARN_ON(desc->irq_data.chip == &no_irq_chip)) |
651 | return; | 616 | goto out; |
652 | } | 617 | } |
653 | 618 | ||
654 | chip_bus_lock(desc); | ||
655 | raw_spin_lock_irqsave(&desc->lock, flags); | ||
656 | |||
657 | /* Uninstall? */ | 619 | /* Uninstall? */ |
658 | if (handle == handle_bad_irq) { | 620 | if (handle == handle_bad_irq) { |
659 | if (desc->irq_data.chip != &no_irq_chip) | 621 | 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 | irq_settings_set_norequest(desc); | 632 | irq_settings_set_norequest(desc); |
671 | irq_startup(desc); | 633 | irq_startup(desc); |
672 | } | 634 | } |
673 | raw_spin_unlock_irqrestore(&desc->lock, flags); | 635 | out: |
674 | chip_bus_sync_unlock(desc); | 636 | irq_put_desc_busunlock(desc, flags); |
675 | } | 637 | } |
676 | EXPORT_SYMBOL_GPL(__set_irq_handler); | 638 | EXPORT_SYMBOL_GPL(__set_irq_handler); |
677 | 639 | ||
@@ -693,14 +655,11 @@ set_irq_chip_and_handler_name(unsigned int irq, struct irq_chip *chip, | |||
693 | 655 | ||
694 | void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set) | 656 | void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set) |
695 | { | 657 | { |
696 | struct irq_desc *desc = irq_to_desc(irq); | ||
697 | unsigned long flags; | 658 | unsigned long flags; |
659 | struct irq_desc *desc = irq_get_desc_lock(irq, &flags); | ||
698 | 660 | ||
699 | if (!desc) | 661 | if (!desc) |
700 | return; | 662 | return; |
701 | |||
702 | raw_spin_lock_irqsave(&desc->lock, flags); | ||
703 | |||
704 | irq_settings_clr_and_set(desc, clr, set); | 663 | irq_settings_clr_and_set(desc, clr, set); |
705 | 664 | ||
706 | irqd_clear(&desc->irq_data, IRQD_NO_BALANCING | IRQD_PER_CPU | | 665 | 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 | 673 | ||
715 | irqd_set(&desc->irq_data, irq_settings_get_trigger_mask(desc)); | 674 | irqd_set(&desc->irq_data, irq_settings_get_trigger_mask(desc)); |
716 | 675 | ||
717 | raw_spin_unlock_irqrestore(&desc->lock, flags); | 676 | irq_put_desc_unlock(desc, flags); |
718 | } | 677 | } |