hv: pirq: refactor irq num alloc/free

This commit refactors the alloc/free irq num, two functions are defined:
- uint32_t alloc_irq_num(uint32_t irq)
  - if irq is valid, mark the irq_desc as used; if it's IRQ_INVALID,
    alloc a free irq, or else do nothing;
  - return: irq num on success, or IRQ_INVALID on failure.

- void free_irq_num(uint32_t irq)
  - free the irq num allocated via alloc_irq_num();

And a global spinlock to protect it from concurrent allocation/free.

Signed-off-by: Yan, Like <like.yan@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
This commit is contained in:
Yan, Like
2018-08-16 16:50:57 +08:00
committed by lijinxia
parent f77d885d7e
commit 1bf2fc342a
4 changed files with 45 additions and 41 deletions

View File

@@ -34,8 +34,6 @@ struct irq_desc {
spinlock_t lock;
};
uint32_t irq_mark_used(uint32_t irq);
uint32_t irq_desc_alloc_vector(uint32_t irq);
void irq_desc_try_free_vector(uint32_t irq);