diff options
| author | Anup Patel <[email protected]> | 2026-04-23 10:53:35 +0530 |
|---|---|---|
| committer | Anup Patel <[email protected]> | 2026-05-12 09:55:58 +0530 |
| commit | 255df5d8022ada847e81bc68a81e0828e693f6ba (patch) | |
| tree | 761e4ac2b249d03d7e519bc582b7dbf2091bc6ae | |
| parent | 0d81a78ec54be2f7c62906b1aa945240ce519c6b (diff) | |
lib: sbi_irqchip: Keep the handler list in sorted order for irqchip
Let's keep the handler list in sorted order for irqchip so that
it is easier to allocate unused hardware interrupts based on the
sorted list.
Signed-off-by: Anup Patel <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Anup Patel <[email protected]>
| -rw-r--r-- | lib/sbi/sbi_irqchip.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/sbi/sbi_irqchip.c b/lib/sbi/sbi_irqchip.c index 503958e1..f9e2eb5a 100644 --- a/lib/sbi/sbi_irqchip.c +++ b/lib/sbi/sbi_irqchip.c @@ -139,7 +139,7 @@ int sbi_irqchip_register_handler(struct sbi_irqchip_device *chip, u32 first_hwirq, u32 num_hwirq, int (*callback)(u32 hwirq, void *opaque), void *priv) { - struct sbi_irqchip_handler *h; + struct sbi_irqchip_handler *h, *th, *nh; u32 i, j; int rc; @@ -162,7 +162,18 @@ int sbi_irqchip_register_handler(struct sbi_irqchip_device *chip, h->num_hwirq = num_hwirq; h->callback = callback; h->priv = priv; - sbi_list_add_tail(&h->node, &chip->handler_list); + + nh = NULL; + sbi_list_for_each_entry(th, &chip->handler_list, node) { + if (h->first_hwirq < th->first_hwirq) { + nh = th; + break; + } + } + if (nh) + sbi_list_add(&h->node, &nh->node); + else + sbi_list_add_tail(&h->node, &chip->handler_list); if (chip->hwirq_setup) { for (i = 0; i < h->num_hwirq; i++) { |
