diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2010-10-12 06:31:46 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2010-10-12 10:39:07 -0400 |
commit | 06f6c3399e9f9ff6eafc200e80f9226c3cee0eaf (patch) | |
tree | f4d8fc67194b1a50bfe501634088b3776ca6bbd4 | |
parent | a98d24b71b6e229965f18dc00d28dc71cb8fe324 (diff) |
genirq: Implement irq reservation
Mark a range of interrupts as allocated. In the SPARSE_IRQ=n case we
need this to update the bitmap for the legacy irqs so the enumerator
via irq_get_next_irq() works.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r-- | include/linux/irq.h | 1 | ||||
-rw-r--r-- | kernel/irq/irqdesc.c | 26 |
2 files changed, 27 insertions, 0 deletions
diff --git a/include/linux/irq.h b/include/linux/irq.h index cefacf928b33..096b74d5d0d7 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h | |||
@@ -400,6 +400,7 @@ static inline struct irq_2_iommu *irq_data_get_iommu(struct irq_data *d) | |||
400 | 400 | ||
401 | int irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node); | 401 | int irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node); |
402 | void irq_free_descs(unsigned int irq, unsigned int cnt); | 402 | void irq_free_descs(unsigned int irq, unsigned int cnt); |
403 | int irq_reserve_irqs(unsigned int from, unsigned int cnt); | ||
403 | 404 | ||
404 | static inline int irq_alloc_desc(int node) | 405 | static inline int irq_alloc_desc(int node) |
405 | { | 406 | { |
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c index 2e7e94ef64da..35d9052901b9 100644 --- a/kernel/irq/irqdesc.c +++ b/kernel/irq/irqdesc.c | |||
@@ -464,6 +464,32 @@ err: | |||
464 | } | 464 | } |
465 | 465 | ||
466 | /** | 466 | /** |
467 | * irq_reserve_irqs - mark irqs allocated | ||
468 | * @from: mark from irq number | ||
469 | * @cnt: number of irqs to mark | ||
470 | * | ||
471 | * Returns 0 on success or an appropriate error code | ||
472 | */ | ||
473 | int irq_reserve_irqs(unsigned int from, unsigned int cnt) | ||
474 | { | ||
475 | unsigned long flags; | ||
476 | unsigned int start; | ||
477 | int ret = 0; | ||
478 | |||
479 | if (!cnt || (from + cnt) > nr_irqs) | ||
480 | return -EINVAL; | ||
481 | |||
482 | raw_spin_lock_irqsave(&sparse_irq_lock, flags); | ||
483 | start = bitmap_find_next_zero_area(allocated_irqs, nr_irqs, from, cnt, 0); | ||
484 | if (start == from) | ||
485 | bitmap_set(allocated_irqs, start, cnt); | ||
486 | else | ||
487 | ret = -EEXIST; | ||
488 | raw_spin_unlock_irqrestore(&sparse_irq_lock, flags); | ||
489 | return ret; | ||
490 | } | ||
491 | |||
492 | /** | ||
467 | * irq_get_next_irq - get next allocated irq number | 493 | * irq_get_next_irq - get next allocated irq number |
468 | * @offset: where to start the search | 494 | * @offset: where to start the search |
469 | * | 495 | * |