Function Report

Linux Kernel (v4.4)

Source File:kernel\irq\manage.c Create Date:2016-01-14 10:59:01
Last Modify:2016-01-11 07:01:32 Copyright©Brick
home page Tree
Annotate the kernelChinese

Function Name:__setup_irq

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

Return Type:static int

Parameter:

Type Parameter NameRemarks
unsigned int irqinterrupe number
struct irq_desc * desc
struct irqaction * new

Function description:register an interrupt

1107  thread_mask = 0
1108  shared = 0
1111  If !Interrupt descriptor then Returning -Invalid argument
1114  If low level interrupt hardware access == &Generic no controller implementation then Returning -Invalid system call number
1116  If !try_module_get(Interrupt descriptor) then Returning -No such device
1119  interrupt number = interrupe number
1125  irq_settings_is_nested_thread(Interrupt descriptor)
1126  If result of irq_settings_is_nested_thread(Interrupt descriptor) then
1128  ret = -Invalid argument
1129  Go to out_mput
1136  interrupt handler function = Primary handler for nested threaded interrupts. Should never be called.
1137  Else
1150  If interrupt handler function for threaded interrupts && !result of irq_settings_is_nested_thread(Interrupt descriptor) then
1151  setup_irq_thread(per interrupt action descriptor, interrupe number, false)
1152  If result of setup_irq_thread(per interrupt action descriptor, interrupe number, false) then Go to out_mput
1161  If !alloc_cpumask_var( &mask, GFP_KERNEL) then
1162  result of setup_irq_thread( pointer to secondary irqaction(force threading), interrupe number, true) = -Out of memory
1163  Go to out_thread
1175  If chip specific flags & One shot does not require mask/unmask then flags(see IRQF_* above) &= ^Interrupt is not reenabled after the hardirq handler finished
1181  raw_spin_lock_irqsave
1182  old_ptr = & the irq action chain
1183  old = *old_ptr
1184  If old then
1194  If !( flags(see IRQF_* above) & flags(see IRQF_* above) & allow sharing the irq among several devices) || ( flags(see IRQF_* above) ^ 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
1199  If ( flags(see IRQF_* above) & Interrupt is per cpu) != ( flags(see IRQF_* above) & Interrupt is per cpu) then Go to mismatch
1203  Do
1211  old = *old_ptr
1212  While old
1213  shared = 1
1221  If flags(see IRQF_* above) & Interrupt is not reenabled after the hardirq handler finished then
1226  If thread_mask == ^0UL then
1228  Go to out_mask
1250  bitmask for keeping track of@thread activity = 1 << find first zero bit in word
1253  Else if interrupt handler function == Default primary interrupt handler for threaded interrupts && !( chip specific flags & One shot does not require mask/unmask) then
1270  pr_err
1271  ret = -Invalid argument
1272  Go to out_mask
1275  If !shared then
1276  irq_request_resources(Interrupt descriptor)
1279  pr_err
1280  Go to out_mask
1283  init_waitqueue_head
1295  core internal status information &= ^(IRQS_AUTODETECT | IRQS_SPURIOUS_DISABLED | IRQS_ONESHOT | IRQS_WAITING)
1296  irqd_clear( &Interrupt descriptor, In progress state of the interrupt)
1303  If flags(see IRQF_* above) & Interrupt is not reenabled after the hardirq handler finished then core internal status information |= IRQS_ONESHOT
1306  If irq_settings_can_autoenable(Interrupt descriptor) then irq_startup(Interrupt descriptor, true)
1308  Else disable-depth, for nested irq_disable() calls = 1
1319  Generic version of the affinity autoselector.
1321  Else if flags(see IRQF_* above) & IRQF_TRIGGER_MASK then
1322  nmsk = flags(see IRQF_* above) & IRQF_TRIGGER_MASK
1323  irq_settings_get_trigger_mask(Interrupt descriptor)
1325  If nmsk != result of irq_settings_get_trigger_mask(Interrupt descriptor) then pr_warning
1331  *old_ptr = per interrupt action descriptor
1333  Called from __setup_irq() with desc->lock held after@action has been installed in the action chain.
1336  stats field to detect stalled irqs = 0
1337  stats field for spurious unhandled interrupts = 0
1343  If shared && core internal status information & IRQS_SPURIOUS_DISABLED then
1344  core internal status information &= ^IRQS_SPURIOUS_DISABLED
1345  __enable_irq(Interrupt descriptor)
1348  raw_spin_unlock_irqrestore
1354  If thread pointer for threaded interrupts then Wake up a specific process
1356  If pointer to secondary irqaction(force threading) then Wake up a specific process
1359  register_irq_proc(interrupe number, Interrupt descriptor)
1360  pointer to the proc/irq/NN/name entry = NULL
1361  register_handler_proc(interrupe number, per interrupt action descriptor)
1362  free_cpumask_var(mask)
1364  Returning 0
1366  mismatch
1367  If !( flags(see IRQF_* above) & set by callers when they expect sharing mismatches to occur) then
1369  pr_err
1374  result of __irq_set_trigger(Interrupt descriptor, flags(see IRQF_* above) & IRQF_TRIGGER_MASK) = -Device or resource busy
1376  out_mask
1377  raw_spin_unlock_irqrestore
1378  free_cpumask_var(mask)
1380  out_thread
1381  If thread pointer for threaded interrupts then
1382  *t = thread pointer for threaded interrupts
1384  thread pointer for threaded interrupts = NULL
1385  stop a thread
1386  put_task_struct(t)
1388  If pointer to secondary irqaction(force threading) && thread pointer for threaded interrupts then
1389  *t = thread pointer for threaded interrupts
1391  thread pointer for threaded interrupts = NULL
1392  stop a thread
1393  put_task_struct(t)
1395  out_mput
1396  module_put(Interrupt descriptor)
1397  Returning ret
Caller
Function NameFunction description
setup_irq setup an interrupt
request_threaded_irq allocate an interrupt line
setup_percpu_irq setup a per-cpu interrupt
request_percpu_irq allocate a percpu interrupt line