MCPcopy Create free account
hub / github.com/F-Stack/f-stack / isrc_alloc_irq

Function isrc_alloc_irq

freebsd/kern/subr_intr.c:401–432  ·  view source on GitHub ↗

* Alloc unique interrupt number (resource handle) for interrupt source. * * There could be various strategies how to allocate free interrupt number * (resource handle) for new interrupt source. * * 1. Handles are always allocated forward, so handles are not recycled * immediately. However, if only one free handle left which is reused * constantly... */

Source from the content-addressed store, hash-verified

399 * constantly...
400 */
401static inline int
402isrc_alloc_irq(struct intr_irqsrc *isrc)
403{
404 u_int maxirqs, irq;
405
406 mtx_assert(&isrc_table_lock, MA_OWNED);
407
408 maxirqs = intr_nirq;
409 if (irq_next_free >= maxirqs)
410 return (ENOSPC);
411
412 for (irq = irq_next_free; irq < maxirqs; irq++) {
413 if (irq_sources[irq] == NULL)
414 goto found;
415 }
416 for (irq = 0; irq < irq_next_free; irq++) {
417 if (irq_sources[irq] == NULL)
418 goto found;
419 }
420
421 irq_next_free = maxirqs;
422 return (ENOSPC);
423
424found:
425 isrc->isrc_irq = irq;
426 irq_sources[irq] = isrc;
427
428 irq_next_free = irq + 1;
429 if (irq_next_free >= maxirqs)
430 irq_next_free = 0;
431 return (0);
432}
433
434/*
435 * Free unique interrupt number (resource handle) from interrupt source.

Callers 1

intr_isrc_registerFunction · 0.85

Calls 1

mtx_assertFunction · 0.85

Tested by

no test coverage detected