diff options
author | Ian Campbell <ian.campbell@citrix.com> | 2011-03-10 11:08:09 -0500 |
---|---|---|
committer | Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> | 2011-03-10 14:48:39 -0500 |
commit | 9158c3588a0693ef11208f5961f0d6b0241694d8 (patch) | |
tree | b4faeebec2f20987a8c38208ba3f121ed7bb3e50 /drivers/xen | |
parent | cb60d11427bbdd42c27edfa2ef1fa6344f455e1d (diff) |
xen: events: turn irq_info constructors into initialiser functions
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Diffstat (limited to 'drivers/xen')
-rw-r--r-- | drivers/xen/events.c | 104 |
1 files changed, 66 insertions, 38 deletions
diff --git a/drivers/xen/events.c b/drivers/xen/events.c index 2dffa43696d8..72725faa2e85 100644 --- a/drivers/xen/events.c +++ b/drivers/xen/events.c | |||
@@ -118,46 +118,76 @@ static struct irq_chip xen_dynamic_chip; | |||
118 | static struct irq_chip xen_percpu_chip; | 118 | static struct irq_chip xen_percpu_chip; |
119 | static struct irq_chip xen_pirq_chip; | 119 | static struct irq_chip xen_pirq_chip; |
120 | 120 | ||
121 | /* Constructor for packed IRQ information. */ | 121 | /* Get info for IRQ */ |
122 | static struct irq_info mk_unbound_info(void) | 122 | static struct irq_info *info_for_irq(unsigned irq) |
123 | { | 123 | { |
124 | return (struct irq_info) { .type = IRQT_UNBOUND }; | 124 | return &irq_info[irq]; |
125 | } | 125 | } |
126 | 126 | ||
127 | static struct irq_info mk_evtchn_info(unsigned short evtchn) | 127 | /* Constructors for packed IRQ information. */ |
128 | static void xen_irq_info_common_init(struct irq_info *info, | ||
129 | enum xen_irq_type type, | ||
130 | unsigned short evtchn, | ||
131 | unsigned short cpu) | ||
128 | { | 132 | { |
129 | return (struct irq_info) { .type = IRQT_EVTCHN, .evtchn = evtchn, | 133 | |
130 | .cpu = 0 }; | 134 | BUG_ON(info->type != IRQT_UNBOUND && info->type != type); |
135 | |||
136 | info->type = type; | ||
137 | info->evtchn = evtchn; | ||
138 | info->cpu = cpu; | ||
131 | } | 139 | } |
132 | 140 | ||
133 | static struct irq_info mk_ipi_info(unsigned short evtchn, enum ipi_vector ipi) | 141 | static void xen_irq_info_evtchn_init(unsigned irq, |
142 | unsigned short evtchn) | ||
134 | { | 143 | { |
135 | return (struct irq_info) { .type = IRQT_IPI, .evtchn = evtchn, | 144 | struct irq_info *info = info_for_irq(irq); |
136 | .cpu = 0, .u.ipi = ipi }; | 145 | |
146 | xen_irq_info_common_init(info, IRQT_EVTCHN, evtchn, 0); | ||
137 | } | 147 | } |
138 | 148 | ||
139 | static struct irq_info mk_virq_info(unsigned short evtchn, unsigned short virq) | 149 | static void xen_irq_info_ipi_init(unsigned irq, |
150 | unsigned short evtchn, | ||
151 | enum ipi_vector ipi) | ||
140 | { | 152 | { |
141 | return (struct irq_info) { .type = IRQT_VIRQ, .evtchn = evtchn, | 153 | struct irq_info *info = info_for_irq(irq); |
142 | .cpu = 0, .u.virq = virq }; | 154 | |
155 | xen_irq_info_common_init(info, IRQT_IPI, evtchn, 0); | ||
156 | |||
157 | info->u.ipi = ipi; | ||
143 | } | 158 | } |
144 | 159 | ||
145 | static struct irq_info mk_pirq_info(unsigned short evtchn, unsigned short pirq, | 160 | static void xen_irq_info_virq_init(unsigned irq, |
146 | unsigned short gsi, unsigned short vector) | 161 | unsigned short evtchn, |
162 | unsigned short virq) | ||
147 | { | 163 | { |
148 | return (struct irq_info) { .type = IRQT_PIRQ, .evtchn = evtchn, | 164 | struct irq_info *info = info_for_irq(irq); |
149 | .cpu = 0, | 165 | |
150 | .u.pirq = { .pirq = pirq, .gsi = gsi, .vector = vector } }; | 166 | xen_irq_info_common_init(info, IRQT_VIRQ, evtchn, 0); |
167 | |||
168 | info->u.virq = virq; | ||
151 | } | 169 | } |
152 | 170 | ||
153 | /* | 171 | static void xen_irq_info_pirq_init(unsigned irq, |
154 | * Accessors for packed IRQ information. | 172 | unsigned short evtchn, |
155 | */ | 173 | unsigned short pirq, |
156 | static struct irq_info *info_for_irq(unsigned irq) | 174 | unsigned short gsi, |
175 | unsigned short vector, | ||
176 | unsigned char flags) | ||
157 | { | 177 | { |
158 | return &irq_info[irq]; | 178 | struct irq_info *info = info_for_irq(irq); |
179 | |||
180 | xen_irq_info_common_init(info, IRQT_PIRQ, evtchn, 0); | ||
181 | |||
182 | info->u.pirq.pirq = pirq; | ||
183 | info->u.pirq.gsi = gsi; | ||
184 | info->u.pirq.vector = vector; | ||
185 | info->u.pirq.flags = flags; | ||
159 | } | 186 | } |
160 | 187 | ||
188 | /* | ||
189 | * Accessors for packed IRQ information. | ||
190 | */ | ||
161 | static unsigned int evtchn_from_irq(unsigned irq) | 191 | static unsigned int evtchn_from_irq(unsigned irq) |
162 | { | 192 | { |
163 | if (unlikely(WARN(irq < 0 || irq >= nr_irqs, "Invalid irq %d!\n", irq))) | 193 | if (unlikely(WARN(irq < 0 || irq >= nr_irqs, "Invalid irq %d!\n", irq))) |
@@ -414,6 +444,8 @@ static int xen_allocate_irq_gsi(unsigned gsi) | |||
414 | 444 | ||
415 | static void xen_free_irq(unsigned irq) | 445 | static void xen_free_irq(unsigned irq) |
416 | { | 446 | { |
447 | irq_info[irq].type = IRQT_UNBOUND; | ||
448 | |||
417 | /* Legacy IRQ descriptors are managed by the arch. */ | 449 | /* Legacy IRQ descriptors are managed by the arch. */ |
418 | if (irq < NR_IRQS_LEGACY) | 450 | if (irq < NR_IRQS_LEGACY) |
419 | return; | 451 | return; |
@@ -610,8 +642,8 @@ int xen_bind_pirq_gsi_to_irq(unsigned gsi, | |||
610 | goto out; | 642 | goto out; |
611 | } | 643 | } |
612 | 644 | ||
613 | irq_info[irq] = mk_pirq_info(0, pirq, gsi, irq_op.vector); | 645 | xen_irq_info_pirq_init(irq, 0, pirq, gsi, irq_op.vector, |
614 | irq_info[irq].u.pirq.flags |= shareable ? PIRQ_SHAREABLE : 0; | 646 | shareable ? PIRQ_SHAREABLE : 0); |
615 | pirq_to_irq[pirq] = irq; | 647 | pirq_to_irq[pirq] = irq; |
616 | 648 | ||
617 | out: | 649 | out: |
@@ -649,7 +681,7 @@ int xen_bind_pirq_msi_to_irq(struct pci_dev *dev, struct msi_desc *msidesc, | |||
649 | set_irq_chip_and_handler_name(irq, &xen_pirq_chip, | 681 | set_irq_chip_and_handler_name(irq, &xen_pirq_chip, |
650 | handle_level_irq, name); | 682 | handle_level_irq, name); |
651 | 683 | ||
652 | irq_info[irq] = mk_pirq_info(0, pirq, 0, vector); | 684 | xen_irq_info_pirq_init(irq, 0, pirq, 0, vector, 0); |
653 | pirq_to_irq[pirq] = irq; | 685 | pirq_to_irq[pirq] = irq; |
654 | ret = set_irq_msi(irq, msidesc); | 686 | ret = set_irq_msi(irq, msidesc); |
655 | if (ret < 0) | 687 | if (ret < 0) |
@@ -688,8 +720,6 @@ int xen_destroy_irq(int irq) | |||
688 | } | 720 | } |
689 | pirq_to_irq[info->u.pirq.pirq] = -1; | 721 | pirq_to_irq[info->u.pirq.pirq] = -1; |
690 | 722 | ||
691 | irq_info[irq] = mk_unbound_info(); | ||
692 | |||
693 | xen_free_irq(irq); | 723 | xen_free_irq(irq); |
694 | 724 | ||
695 | out: | 725 | out: |
@@ -717,7 +747,7 @@ int bind_evtchn_to_irq(unsigned int evtchn) | |||
717 | handle_fasteoi_irq, "event"); | 747 | handle_fasteoi_irq, "event"); |
718 | 748 | ||
719 | evtchn_to_irq[evtchn] = irq; | 749 | evtchn_to_irq[evtchn] = irq; |
720 | irq_info[irq] = mk_evtchn_info(evtchn); | 750 | xen_irq_info_evtchn_init(irq, evtchn); |
721 | } | 751 | } |
722 | 752 | ||
723 | spin_unlock(&irq_mapping_update_lock); | 753 | spin_unlock(&irq_mapping_update_lock); |
@@ -750,7 +780,7 @@ static int bind_ipi_to_irq(unsigned int ipi, unsigned int cpu) | |||
750 | evtchn = bind_ipi.port; | 780 | evtchn = bind_ipi.port; |
751 | 781 | ||
752 | evtchn_to_irq[evtchn] = irq; | 782 | evtchn_to_irq[evtchn] = irq; |
753 | irq_info[irq] = mk_ipi_info(evtchn, ipi); | 783 | xen_irq_info_ipi_init(irq, evtchn, ipi); |
754 | per_cpu(ipi_to_irq, cpu)[ipi] = irq; | 784 | per_cpu(ipi_to_irq, cpu)[ipi] = irq; |
755 | 785 | ||
756 | bind_evtchn_to_cpu(evtchn, cpu); | 786 | bind_evtchn_to_cpu(evtchn, cpu); |
@@ -785,7 +815,7 @@ int bind_virq_to_irq(unsigned int virq, unsigned int cpu) | |||
785 | evtchn = bind_virq.port; | 815 | evtchn = bind_virq.port; |
786 | 816 | ||
787 | evtchn_to_irq[evtchn] = irq; | 817 | evtchn_to_irq[evtchn] = irq; |
788 | irq_info[irq] = mk_virq_info(evtchn, virq); | 818 | xen_irq_info_virq_init(irq, evtchn, virq); |
789 | 819 | ||
790 | per_cpu(virq_to_irq, cpu)[virq] = irq; | 820 | per_cpu(virq_to_irq, cpu)[virq] = irq; |
791 | 821 | ||
@@ -828,11 +858,9 @@ static void unbind_from_irq(unsigned int irq) | |||
828 | evtchn_to_irq[evtchn] = -1; | 858 | evtchn_to_irq[evtchn] = -1; |
829 | } | 859 | } |
830 | 860 | ||
831 | if (irq_info[irq].type != IRQT_UNBOUND) { | 861 | BUG_ON(irq_info[irq].type == IRQT_UNBOUND); |
832 | irq_info[irq] = mk_unbound_info(); | ||
833 | 862 | ||
834 | xen_free_irq(irq); | 863 | xen_free_irq(irq); |
835 | } | ||
836 | 864 | ||
837 | spin_unlock(&irq_mapping_update_lock); | 865 | spin_unlock(&irq_mapping_update_lock); |
838 | } | 866 | } |
@@ -1093,7 +1121,7 @@ void rebind_evtchn_irq(int evtchn, int irq) | |||
1093 | BUG_ON(info->type == IRQT_UNBOUND); | 1121 | BUG_ON(info->type == IRQT_UNBOUND); |
1094 | 1122 | ||
1095 | evtchn_to_irq[evtchn] = irq; | 1123 | evtchn_to_irq[evtchn] = irq; |
1096 | irq_info[irq] = mk_evtchn_info(evtchn); | 1124 | xen_irq_info_evtchn_init(irq, evtchn); |
1097 | 1125 | ||
1098 | spin_unlock(&irq_mapping_update_lock); | 1126 | spin_unlock(&irq_mapping_update_lock); |
1099 | 1127 | ||
@@ -1229,7 +1257,7 @@ static void restore_pirqs(void) | |||
1229 | if (rc) { | 1257 | if (rc) { |
1230 | printk(KERN_WARNING "xen map irq failed gsi=%d irq=%d pirq=%d rc=%d\n", | 1258 | printk(KERN_WARNING "xen map irq failed gsi=%d irq=%d pirq=%d rc=%d\n", |
1231 | gsi, irq, pirq, rc); | 1259 | gsi, irq, pirq, rc); |
1232 | irq_info[irq] = mk_unbound_info(); | 1260 | xen_free_irq(irq); |
1233 | pirq_to_irq[pirq] = -1; | 1261 | pirq_to_irq[pirq] = -1; |
1234 | continue; | 1262 | continue; |
1235 | } | 1263 | } |
@@ -1261,7 +1289,7 @@ static void restore_cpu_virqs(unsigned int cpu) | |||
1261 | 1289 | ||
1262 | /* Record the new mapping. */ | 1290 | /* Record the new mapping. */ |
1263 | evtchn_to_irq[evtchn] = irq; | 1291 | evtchn_to_irq[evtchn] = irq; |
1264 | irq_info[irq] = mk_virq_info(evtchn, virq); | 1292 | xen_irq_info_virq_init(irq, evtchn, virq); |
1265 | bind_evtchn_to_cpu(evtchn, cpu); | 1293 | bind_evtchn_to_cpu(evtchn, cpu); |
1266 | } | 1294 | } |
1267 | } | 1295 | } |
@@ -1286,7 +1314,7 @@ static void restore_cpu_ipis(unsigned int cpu) | |||
1286 | 1314 | ||
1287 | /* Record the new mapping. */ | 1315 | /* Record the new mapping. */ |
1288 | evtchn_to_irq[evtchn] = irq; | 1316 | evtchn_to_irq[evtchn] = irq; |
1289 | irq_info[irq] = mk_ipi_info(evtchn, ipi); | 1317 | xen_irq_info_ipi_init(irq, evtchn, ipi); |
1290 | bind_evtchn_to_cpu(evtchn, cpu); | 1318 | bind_evtchn_to_cpu(evtchn, cpu); |
1291 | } | 1319 | } |
1292 | } | 1320 | } |