Function report

linux kernel

5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\irq\manage.c Create Date:2020-09-18 20:29:03
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload PLEAChinese

Name:register an interrupt

Proto:static int __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new)

Type:int

Parameter:

TypeParameterName
unsigned intirq
struct irq_desc *desc
struct irqaction *new
1276  thread_mask = 0
1277  shared = 0
1279  If Not desc Then Return -Invalid argument
1282  If low level interrupt hardware access == Generic no controller implementation Then Return -Invalid system call number
1284  If Not try_module_get(owner) Then Return -No such device
1287  interrupt number = irq
1293  If Not (flags (see IRQF_* above) & IRQF_TRIGGER_MASK) Then flags (see IRQF_* above) |= irqd_get_trigger_type( & irq_data)
1300  nested = irq_settings_is_nested_thread(desc)
1301  If nested Then
1303  ret = -Invalid argument
1304  Go to out_mput
1311  interrupt handler function = Primary handler for nested threaded interrupts
1312  Else
1313  If irq_settings_can_thread(desc) Then
1315  If ret Then Go to out_mput
1325  If interrupt handler function for threaded interrupts && Not nested Then
1326  ret = setup_irq_thread(new, irq, false)
1327  If ret Then Go to out_mput
1331  If ret Then Go to out_thread
1345  If chip specific flags & IRQCHIP_ONESHOT_SAFE Then flags (see IRQF_* above) &= ~Interrupt is not reenabled after the hardirq handler finished
1355  mutex_lock( & mutex to protect request/free before locking desc->lock)
1362  Inline functions for support of irq chips on slow busses
1365  If Not the irq action chain Then
1366  ret = irq_request_resources(desc)
1367  If ret Then
1368  pr_err("Failed to request resources for %s (irq %d) on irqchip %s\n", name of the device, irq, interrupt' name)
1370  Go to out_bus_unlock
1380  raw_spin_lock_irqsave( & locking for SMP, flags)
1381  old_ptr = the irq action chain
1382  old = old_ptr
1383  If old Then
1394  If istate & IRQS_NMI Then
1395  pr_err("Invalid attempt to share NMI for %s (irq %d) on irqchip %s.\n", name of the device, irq, interrupt' name)
1397  ret = -Invalid argument
1398  Go to out_unlock
1405  If irqd_trigger_type_was_set( & irq_data) Then
1407  Else
1412  If Not ( flags (see IRQF_* above) & flags (see IRQF_* above) & allow sharing the irq among several devices) || oldtype != (flags (see IRQF_* above) & IRQF_TRIGGER_MASK) || (flags (see IRQF_* above) ^ flags (see IRQF_* above)) & Interrupt is not reenabled after the hardirq handler finished Then Go to mismatch
1418  If (flags (see IRQF_* above) & Interrupt is per cpu) != (flags (see IRQF_* above) & Interrupt is per cpu) Then Go to mismatch
1423  Do
1431  old = old_ptr
1432  When old cycle
1433  shared = 1
1441  If flags (see IRQF_* above) & Interrupt is not reenabled after the hardirq handler finished Then
1446  If thread_mask == ~0UL Then
1448  Go to out_unlock
1470  bitmask for keeping track of @thread activity = 1UL << find first zero bit in word
1472  Else if interrupt handler function == Default primary interrupt handler for threaded interrupts && Not (chip specific flags & IRQCHIP_ONESHOT_SAFE) Then
1489  pr_err("Threaded irq requested with handler=NULL and !ONESHOT for irq %d\n", irq)
1491  ret = -Invalid argument
1492  Go to out_unlock
1495  If Not shared Then
1496  init_waitqueue_head( & wait queue for sync_irq to wait for threaded handlers)
1503  If ret Then Go to out_unlock
1518  ret = irq_activate(desc)
1519  If ret Then Go to out_unlock
1523  istate &= ~( IRQS_AUTODETECT | IRQS_SPURIOUS_DISABLED | IRQS_ONESHOT | IRQS_WAITING)
1524  irqd_clear( & irq_data, IRQD_IRQ_INPROGRESS)
1531  If flags (see IRQF_* above) & Interrupt is not reenabled after the hardirq handler finished Then istate |= IRQS_ONESHOT
1542  Else
1554  Else if flags (see IRQF_* above) & IRQF_TRIGGER_MASK Then
1555  nmsk = flags (see IRQF_* above) & IRQF_TRIGGER_MASK
1556  omsk = irqd_get_trigger_type( & irq_data)
1558  If nmsk != omsk Then pr_warn("irq %d uses trigger mode %u; requested %u\n", irq, omsk, nmsk)
1564  old_ptr = new
1566  irq_pm_install_action(desc, new)
1569  stats field to detect stalled irqs = 0
1570  stats field for spurious unhandled interrupts = 0
1576  If shared && istate & IRQS_SPURIOUS_DISABLED Then
1577  istate &= ~IRQS_SPURIOUS_DISABLED
1578  __enable_irq(desc)
1581  raw_spin_unlock_irqrestore( & locking for SMP, flags)
1582  chip_bus_sync_unlock(desc)
1583  release the mutex
1585  irq_setup_timings(desc, new)
1591  If thread pointer for threaded interrupts Then Wake up a specific process
1593  If pointer to secondary irqaction (force threading) Then Wake up a specific process
1596  register_irq_proc(irq, desc)
1597  pointer to the proc/irq/NN/name entry = NULL
1598  register_handler_proc(irq, new)
1599  Return 0
1601mismatch:
1602  If Not (flags (see IRQF_* above) & set by callers when they expect sharing mismatches to occur) Then
1603  pr_err("Flags mismatch irq %d. %08x (%s) vs. %08x (%s)\n", irq, flags (see IRQF_* above), name of the device, flags (see IRQF_* above), name of the device)
1609  ret = -Device or resource busy
1611out_unlock:
1612  raw_spin_unlock_irqrestore( & locking for SMP, flags)
1614  If Not the irq action chain Then irq_release_resources(desc)
1616out_bus_unlock:
1617  chip_bus_sync_unlock(desc)
1618  release the mutex
1620out_thread:
1621  If thread pointer for threaded interrupts Then
1622  t = thread pointer for threaded interrupts
1624  thread pointer for threaded interrupts = NULL
1625  stop a thread
1626  put_task_struct(t)
1628  If pointer to secondary irqaction (force threading) && thread pointer for threaded interrupts Then
1629  t = thread pointer for threaded interrupts
1631  thread pointer for threaded interrupts = NULL
1632  stop a thread
1633  put_task_struct(t)
1635out_mput:
1636  module_put(owner)
1637  Return ret
Caller
NameDescribe
setup_irqsetup an interrupt
request_threaded_irqallocate an interrupt line
request_nmiallocate an interrupt line for NMI delivery
setup_percpu_irqsetup a per-cpu interrupt
__request_percpu_irqallocate a percpu interrupt line
request_percpu_nmiallocate a percpu interrupt line for NMI delivery