/* Interrupt types. */
 enum xen_irq_type {
-       IRQT_UNBOUND,
+       IRQT_UNBOUND = 0,
        IRQT_PIRQ,
        IRQT_VIRQ,
        IRQT_IPI,
        return cpu_evtchn_mask_p[cpu].bits;
 }
 
-/* Reference counts for bindings to IRQs. */
-static int irq_bindcount[NR_IRQS];
-
 /* Xen will never allocate port zero for any purpose. */
 #define VALID_EVTCHN(chn)      ((chn) != 0)
 
        int irq;
        struct irq_desc *desc;
 
-       /* Only allocate from dynirq range */
        for (irq = 0; irq < nr_irqs; irq++)
-               if (irq_bindcount[irq] == 0)
+               if (irq_info[irq].type == IRQT_UNBOUND)
                        break;
 
        if (irq == nr_irqs)
                irq_info[irq] = mk_evtchn_info(evtchn);
        }
 
-       irq_bindcount[irq]++;
-
        spin_unlock(&irq_mapping_update_lock);
 
        return irq;
                bind_evtchn_to_cpu(evtchn, cpu);
        }
 
-       irq_bindcount[irq]++;
-
  out:
        spin_unlock(&irq_mapping_update_lock);
        return irq;
                bind_evtchn_to_cpu(evtchn, cpu);
        }
 
-       irq_bindcount[irq]++;
-
        spin_unlock(&irq_mapping_update_lock);
 
        return irq;
 
        spin_lock(&irq_mapping_update_lock);
 
-       if ((--irq_bindcount[irq] == 0) && VALID_EVTCHN(evtchn)) {
+       if (VALID_EVTCHN(evtchn)) {
                close.port = evtchn;
                if (HYPERVISOR_event_channel_op(EVTCHNOP_close, &close) != 0)
                        BUG();
 /* Rebind a new event channel to an existing irq. */
 void rebind_evtchn_irq(int evtchn, int irq)
 {
+       struct irq_info *info = info_for_irq(irq);
+
        /* Make sure the irq is masked, since the new event channel
           will also be masked. */
        disable_irq(irq);
        /* After resume the irq<->evtchn mappings are all cleared out */
        BUG_ON(evtchn_to_irq[evtchn] != -1);
        /* Expect irq to have been bound before,
-          so the bindcount should be non-0 */
-       BUG_ON(irq_bindcount[irq] == 0);
+          so there should be a proper type */
+       BUG_ON(info->type == IRQT_UNBOUND);
 
        evtchn_to_irq[evtchn] = irq;
        irq_info[irq] = mk_evtchn_info(evtchn);
        for (i = 0; i < NR_EVENT_CHANNELS; i++)
                mask_evtchn(i);
 
-       /* Dynamic IRQ space is currently unbound. Zero the refcnts. */
-       for (i = 0; i < nr_irqs; i++)
-               irq_bindcount[i] = 0;
-
        irq_ctx_init(smp_processor_id());
 }