Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\irq\manage.c Create Date:2022-07-28 10:09:50
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

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>request_mutex Provides serialization against a concurrent free_irq()
struct irqaction *new
1276  thread_mask = 0
1277  shared = 0
1279  If Not >request_mutex Provides serialization against a concurrent free_irq() Then Return -EINVAL
1282  If chip == Generic no controller implementation Then Return -ENOSYS
1284  If Not try_module_get(owner) Then Return -ENODEV
1287  irq = irq
1293  If Not (flags & IRQF_TRIGGER_MASK) Then flags |= irqd_get_trigger_type( & irq_data)
1300  nested = irq_settings_is_nested_thread(>request_mutex Provides serialization against a concurrent free_irq())
1301  If nested Then
1302  If Not thread_fn Then
1303  ret = -EINVAL
1304  Go to out_mput
1311  handler = Primary handler for nested threaded interrupts. Should never be* called.
1312  Else
1315  If ret Then Go to out_mput
1325  If thread_fn && Not nested Then
1326  ret = setup_irq_thread(new, irq, false)
1327  If ret Then Go to out_mput
1329  If secondary Then
1330  ret = setup_irq_thread(secondary, irq, true)
1331  If ret Then Go to out_thread
1345  If flags & IRQCHIP_ONESHOT_SAFE Then flags &= ~Interrupt is not reenabled after the hardirq handler finished
1355  mutex_lock( & request_mutex)
1362  Inline functions for support of irq chips on slow busses
1365  If Not IRQ action list Then
1366  ret = irq_request_resources(>request_mutex Provides serialization against a concurrent free_irq())
1367  If ret Then
1368  pr_err("Failed to request resources for %s (irq %d) on irqchip %s\n", name, irq, interrupt' name)
1370  Go to out_bus_unlock
1380  raw_spin_lock_irqsave( & lock, flags)
1381  old_ptr = IRQ action list
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, irq, interrupt' name)
1397  ret = -EINVAL
1398  Go to out_unlock
1405  If irqd_trigger_type_was_set( & irq_data) Then
1407  Else
1412  If Not ( flags & flags & allow sharing the irq among several devices) || oldtype != (flags & IRQF_TRIGGER_MASK) || (flags ^ flags) & Interrupt is not reenabled after the hardirq handler finished Then Go to mismatch
1418  If (flags & Interrupt is per cpu) != (flags & Interrupt is per cpu) Then Go to mismatch
1423  Do
1430  old_ptr = next
1431  old = old_ptr
1432  When old cycle
1433  shared = 1
1441  If flags & Interrupt is not reenabled after the hardirq handler finished Then
1446  If thread_mask == ~0UL Then
1447  ret = -EBUSY
1448  Go to out_unlock
1470  thread_mask = 1UL << z - find first zero bit in word*@word: The word to search* Undefined if no zero exists, so code should check against ~0UL first.
1472  Else if handler == Default primary interrupt handler for threaded interrupts && Not (flags & IRQCHIP_ONESHOT_SAFE) Then
1489  pr_err("Threaded irq requested with handler=NULL and !ONESHOT for irq %d\n", irq)
1491  ret = -EINVAL
1492  Go to out_unlock
1495  If Not shared Then
1496  init_waitqueue_head( & wait_for_threads)
1499  If flags & IRQF_TRIGGER_MASK Then
1503  If ret Then Go to out_unlock
1518  ret = irq_activate(>request_mutex Provides serialization against a concurrent free_irq())
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)
1526  If flags & Interrupt is per cpu Then
1531  If flags & Interrupt is not reenabled after the hardirq handler finished Then istate |= IRQS_ONESHOT
1542  Else
1554  Else if flags & IRQF_TRIGGER_MASK Then
1555  nmsk = flags & 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(>request_mutex Provides serialization against a concurrent free_irq(), new)
1569  For detecting broken IRQs = 0
1570  irqs_unhandled = 0
1576  If shared && istate & IRQS_SPURIOUS_DISABLED Then
1577  istate &= ~IRQS_SPURIOUS_DISABLED
1578  __enable_irq(>request_mutex Provides serialization against a concurrent free_irq())
1581  raw_spin_unlock_irqrestore( & lock, flags)
1582  chip_bus_sync_unlock(>request_mutex Provides serialization against a concurrent free_irq())
1583  mutex_unlock - release the mutex*@lock: the mutex to be released* Unlock a mutex that has been locked by this task previously.* This function must not be used in interrupt context. Unlocking* of a not locked mutex is not allowed.
1585  irq_setup_timings(>request_mutex Provides serialization against a concurrent free_irq(), new)
1591  If thread Then wake_up_process - Wake up a specific process*@p: The process to be woken up.* Attempt to wake up the nominated process and move it to the set of runnable* processes.* Return: 1 if the process was woken up, 0 if it was already running.
1593  If secondary Then wake_up_process - Wake up a specific process*@p: The process to be woken up.* Attempt to wake up the nominated process and move it to the set of runnable* processes.* Return: 1 if the process was woken up, 0 if it was already running.
1596  register_irq_proc(irq, >request_mutex Provides serialization against a concurrent free_irq())
1597  dir = NULL
1598  register_handler_proc(irq, new)
1599  Return 0
1601  mismatch :
1602  If Not (flags & 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, name, flags, name)
1609  ret = -EBUSY
1611  out_unlock :
1612  raw_spin_unlock_irqrestore( & lock, flags)
1614  If Not IRQ action list Then irq_release_resources(>request_mutex Provides serialization against a concurrent free_irq())
1616  out_bus_unlock :
1617  chip_bus_sync_unlock(>request_mutex Provides serialization against a concurrent free_irq())
1618  mutex_unlock - release the mutex*@lock: the mutex to be released* Unlock a mutex that has been locked by this task previously.* This function must not be used in interrupt context. Unlocking* of a not locked mutex is not allowed.
1620  out_thread :
1621  If thread Then
1622  t = thread
1624  thread = NULL
1625  stop a thread
1626  put_task_struct(t)
1628  If secondary && thread Then
1629  t = thread
1631  thread = NULL
1632  stop a thread
1633  put_task_struct(t)
1635  out_mput :
1636  module_put(owner)
1637  Return ret
Caller
NameDescribe
setup_irqsetup_irq - setup an interrupt*@irq: Interrupt line to setup*@act: irqaction for the interrupt* Used to statically setup interrupts in the early boot process.
request_threaded_irqquest_threaded_irq - allocate an interrupt line*@irq: Interrupt line to allocate*@handler: Function to be called when the IRQ occurs
request_nmiquest_nmi - allocate an interrupt line for NMI delivery*@irq: Interrupt line to allocate*@handler: Function to be called when the IRQ occurs
setup_percpu_irqsetup_percpu_irq - setup a per-cpu interrupt*@irq: Interrupt line to setup*@act: irqaction for the interrupt* Used to statically setup per-cpu interrupts in the early boot process.
__request_percpu_irq__request_percpu_irq - allocate a percpu interrupt line*@irq: Interrupt line to allocate*@handler: Function to be called when the IRQ occurs
request_percpu_nmiquest_percpu_nmi - allocate a percpu interrupt line for NMI delivery*@irq: Interrupt line to allocate*@handler: Function to be called when the IRQ occurs