1<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Kernel utility functions</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="Linux Device Drivers"><link rel="up" href="Basics.html" title="Chapter 1. Driver Basics"><link rel="prev" href="API-kset-create-and-add.html" title="kset_create_and_add"><link rel="next" href="API-upper-32-bits.html" title="upper_32_bits"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Kernel utility functions</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="API-kset-create-and-add.html">Prev</a> </td><th width="60%" align="center">Chapter 1. Driver Basics</th><td width="20%" align="right"> <a accesskey="n" href="API-upper-32-bits.html">Next</a></td></tr></table><hr></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id-1.3.10"></a>Kernel utility functions</h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="refentrytitle"><a href="API-upper-32-bits.html"><span class="phrase">upper_32_bits</span></a></span><span class="refpurpose"> — 
2  return bits 32-63 of a number
3 </span></dt><dt><span class="refentrytitle"><a href="API-lower-32-bits.html"><span class="phrase">lower_32_bits</span></a></span><span class="refpurpose"> — 
4     return bits 0-31 of a number
5 </span></dt><dt><span class="refentrytitle"><a href="API-might-sleep.html"><span class="phrase">might_sleep</span></a></span><span class="refpurpose"> — 
6     annotation for functions that can sleep
7 </span></dt><dt><span class="refentrytitle"><a href="API-abs.html"><span class="phrase">abs</span></a></span><span class="refpurpose"> — 
8     return absolute value of an argument
9 </span></dt><dt><span class="refentrytitle"><a href="API-reciprocal-scale.html"><span class="phrase">reciprocal_scale</span></a></span><span class="refpurpose"> — 
10     "scale" a value into range [0, ep_ro)
11 </span></dt><dt><span class="refentrytitle"><a href="API-kstrtoul.html"><span class="phrase">kstrtoul</span></a></span><span class="refpurpose"> — 
12     convert a string to an unsigned long
13 </span></dt><dt><span class="refentrytitle"><a href="API-kstrtol.html"><span class="phrase">kstrtol</span></a></span><span class="refpurpose"> — 
14     convert a string to a long
15 </span></dt><dt><span class="refentrytitle"><a href="API-trace-printk.html"><span class="phrase">trace_printk</span></a></span><span class="refpurpose"> — 
16     printf formatting in the ftrace buffer
17 </span></dt><dt><span class="refentrytitle"><a href="API-trace-puts.html"><span class="phrase">trace_puts</span></a></span><span class="refpurpose"> — 
18     write a string into the ftrace buffer
19 </span></dt><dt><span class="refentrytitle"><a href="API-min-not-zero.html"><span class="phrase">min_not_zero</span></a></span><span class="refpurpose"> — 
20     return the minimum that is _not_ zero, unless both are zero
21 </span></dt><dt><span class="refentrytitle"><a href="API-clamp.html"><span class="phrase">clamp</span></a></span><span class="refpurpose"> — 
22     return a value clamped to a given range with strict typechecking
23 </span></dt><dt><span class="refentrytitle"><a href="API-clamp-t.html"><span class="phrase">clamp_t</span></a></span><span class="refpurpose"> — 
24     return a value clamped to a given range using a given type
25 </span></dt><dt><span class="refentrytitle"><a href="API-clamp-val.html"><span class="phrase">clamp_val</span></a></span><span class="refpurpose"> — 
26     return a value clamped to a given range using val's type
27 </span></dt><dt><span class="refentrytitle"><a href="API-container-of.html"><span class="phrase">container_of</span></a></span><span class="refpurpose"> — 
28     cast a member of a structure out to the containing structure
29 </span></dt><dt><span class="refentrytitle"><a href="API-printk.html"><span class="phrase">printk</span></a></span><span class="refpurpose"> — 
30  print a kernel message
31 </span></dt><dt><span class="refentrytitle"><a href="API-console-lock.html"><span class="phrase">console_lock</span></a></span><span class="refpurpose"> — 
32     lock the console system for exclusive use.
33 </span></dt><dt><span class="refentrytitle"><a href="API-console-trylock.html"><span class="phrase">console_trylock</span></a></span><span class="refpurpose"> — 
34     try to lock the console system for exclusive use.
35 </span></dt><dt><span class="refentrytitle"><a href="API-console-unlock.html"><span class="phrase">console_unlock</span></a></span><span class="refpurpose"> — 
36     unlock the console system
37 </span></dt><dt><span class="refentrytitle"><a href="API-console-conditional-schedule.html"><span class="phrase">console_conditional_schedule</span></a></span><span class="refpurpose"> — 
38     yield the CPU if required
39 </span></dt><dt><span class="refentrytitle"><a href="API-printk-timed-ratelimit.html"><span class="phrase">printk_timed_ratelimit</span></a></span><span class="refpurpose"> — 
40     caller-controlled printk ratelimiting
41 </span></dt><dt><span class="refentrytitle"><a href="API-kmsg-dump-register.html"><span class="phrase">kmsg_dump_register</span></a></span><span class="refpurpose"> — 
42     register a kernel log dumper.
43 </span></dt><dt><span class="refentrytitle"><a href="API-kmsg-dump-unregister.html"><span class="phrase">kmsg_dump_unregister</span></a></span><span class="refpurpose"> — 
44     unregister a kmsg dumper.
45 </span></dt><dt><span class="refentrytitle"><a href="API-kmsg-dump-get-line.html"><span class="phrase">kmsg_dump_get_line</span></a></span><span class="refpurpose"> — 
46     retrieve one kmsg log line
47 </span></dt><dt><span class="refentrytitle"><a href="API-kmsg-dump-get-buffer.html"><span class="phrase">kmsg_dump_get_buffer</span></a></span><span class="refpurpose"> — 
48     copy kmsg log lines
49 </span></dt><dt><span class="refentrytitle"><a href="API-kmsg-dump-rewind.html"><span class="phrase">kmsg_dump_rewind</span></a></span><span class="refpurpose"> — 
50     reset the interator
51 </span></dt><dt><span class="refentrytitle"><a href="API-panic.html"><span class="phrase">panic</span></a></span><span class="refpurpose"> — 
52  halt the system
53 </span></dt><dt><span class="refentrytitle"><a href="API-add-taint.html"><span class="phrase">add_taint</span></a></span><span class="refpurpose"> — 
54   </span></dt><dt><span class="refentrytitle"><a href="re230.html">
55   kernel/sys.c
56  </a></span><span class="refpurpose"> — 
57   Document generation inconsistency
58  </span></dt><dt><span class="refentrytitle"><a href="API-init-srcu-struct.html"><span class="phrase">init_srcu_struct</span></a></span><span class="refpurpose"> — 
59  initialize a sleep-RCU structure
60 </span></dt><dt><span class="refentrytitle"><a href="API-cleanup-srcu-struct.html"><span class="phrase">cleanup_srcu_struct</span></a></span><span class="refpurpose"> — 
61     deconstruct a sleep-RCU structure
62 </span></dt><dt><span class="refentrytitle"><a href="API-synchronize-srcu.html"><span class="phrase">synchronize_srcu</span></a></span><span class="refpurpose"> — 
63     wait for prior SRCU read-side critical-section completion
64 </span></dt><dt><span class="refentrytitle"><a href="API-synchronize-srcu-expedited.html"><span class="phrase">synchronize_srcu_expedited</span></a></span><span class="refpurpose"> — 
65     Brute-force SRCU grace period
66 </span></dt><dt><span class="refentrytitle"><a href="API-srcu-barrier.html"><span class="phrase">srcu_barrier</span></a></span><span class="refpurpose"> — 
67     Wait until all in-flight <code class="function">call_srcu</code> callbacks complete.
68 </span></dt><dt><span class="refentrytitle"><a href="API-srcu-batches-completed.html"><span class="phrase">srcu_batches_completed</span></a></span><span class="refpurpose"> — 
69     return batches completed.
70 </span></dt><dt><span class="refentrytitle"><a href="API-rcu-idle-enter.html"><span class="phrase">rcu_idle_enter</span></a></span><span class="refpurpose"> — 
71  inform RCU that current CPU is entering idle
72 </span></dt><dt><span class="refentrytitle"><a href="API-rcu-idle-exit.html"><span class="phrase">rcu_idle_exit</span></a></span><span class="refpurpose"> — 
73     inform RCU that current CPU is leaving idle
74 </span></dt><dt><span class="refentrytitle"><a href="API-rcu-is-watching.html"><span class="phrase">rcu_is_watching</span></a></span><span class="refpurpose"> — 
75     see if RCU thinks that the current CPU is idle
76 </span></dt><dt><span class="refentrytitle"><a href="API-synchronize-sched.html"><span class="phrase">synchronize_sched</span></a></span><span class="refpurpose"> — 
77     wait until an rcu-sched grace period has elapsed.
78 </span></dt><dt><span class="refentrytitle"><a href="API-synchronize-rcu-bh.html"><span class="phrase">synchronize_rcu_bh</span></a></span><span class="refpurpose"> — 
79     wait until an rcu_bh grace period has elapsed.
80 </span></dt><dt><span class="refentrytitle"><a href="API-get-state-synchronize-rcu.html"><span class="phrase">get_state_synchronize_rcu</span></a></span><span class="refpurpose"> — 
81     Snapshot current RCU state
82 </span></dt><dt><span class="refentrytitle"><a href="API-cond-synchronize-rcu.html"><span class="phrase">cond_synchronize_rcu</span></a></span><span class="refpurpose"> — 
83     Conditionally wait for an RCU grace period
84 </span></dt><dt><span class="refentrytitle"><a href="API-get-state-synchronize-sched.html"><span class="phrase">get_state_synchronize_sched</span></a></span><span class="refpurpose"> — 
85     Snapshot current RCU-sched state
86 </span></dt><dt><span class="refentrytitle"><a href="API-cond-synchronize-sched.html"><span class="phrase">cond_synchronize_sched</span></a></span><span class="refpurpose"> — 
87     Conditionally wait for an RCU-sched grace period
88 </span></dt><dt><span class="refentrytitle"><a href="API-synchronize-sched-expedited.html"><span class="phrase">synchronize_sched_expedited</span></a></span><span class="refpurpose"> — 
89     Brute-force RCU-sched grace period
90 </span></dt><dt><span class="refentrytitle"><a href="API-rcu-barrier-bh.html"><span class="phrase">rcu_barrier_bh</span></a></span><span class="refpurpose"> — 
91     Wait until all in-flight <code class="function">call_rcu_bh</code> callbacks complete.
92 </span></dt><dt><span class="refentrytitle"><a href="API-rcu-barrier-sched.html"><span class="phrase">rcu_barrier_sched</span></a></span><span class="refpurpose"> — 
93     Wait for in-flight <code class="function">call_rcu_sched</code> callbacks.
94 </span></dt><dt><span class="refentrytitle"><a href="API-synchronize-rcu.html"><span class="phrase">synchronize_rcu</span></a></span><span class="refpurpose"> — 
95  wait until a grace period has elapsed.
96 </span></dt><dt><span class="refentrytitle"><a href="API-synchronize-rcu-expedited.html"><span class="phrase">synchronize_rcu_expedited</span></a></span><span class="refpurpose"> — 
97     Brute-force RCU grace period
98 </span></dt><dt><span class="refentrytitle"><a href="API-rcu-barrier.html"><span class="phrase">rcu_barrier</span></a></span><span class="refpurpose"> — 
99     Wait until all in-flight <code class="function">call_rcu</code> callbacks complete.
100 </span></dt><dt><span class="refentrytitle"><a href="API-rcu-read-lock-sched-held.html"><span class="phrase">rcu_read_lock_sched_held</span></a></span><span class="refpurpose"> — 
101  might we be in RCU-sched read-side critical section?
102 </span></dt><dt><span class="refentrytitle"><a href="API-rcu-expedite-gp.html"><span class="phrase">rcu_expedite_gp</span></a></span><span class="refpurpose"> — 
103     Expedite future RCU grace periods
104 </span></dt><dt><span class="refentrytitle"><a href="API-rcu-unexpedite-gp.html"><span class="phrase">rcu_unexpedite_gp</span></a></span><span class="refpurpose">
105     Cancel prior rcu_expedite_gp invocation
106 </span></dt><dt><span class="refentrytitle"><a href="API-rcu-read-lock-held.html"><span class="phrase">rcu_read_lock_held</span></a></span><span class="refpurpose"> — 
107     might we be in RCU read-side critical section?
108 </span></dt><dt><span class="refentrytitle"><a href="API-rcu-read-lock-bh-held.html"><span class="phrase">rcu_read_lock_bh_held</span></a></span><span class="refpurpose"> — 
109     might we be in RCU-bh read-side critical section?
110 </span></dt><dt><span class="refentrytitle"><a href="API-wakeme-after-rcu.html"><span class="phrase">wakeme_after_rcu</span></a></span><span class="refpurpose"> — 
111     Callback function to awaken a task after grace period
112 </span></dt><dt><span class="refentrytitle"><a href="API-init-rcu-head-on-stack.html"><span class="phrase">init_rcu_head_on_stack</span></a></span><span class="refpurpose"> — 
113     initialize on-stack rcu_head for debugobjects
114 </span></dt><dt><span class="refentrytitle"><a href="API-destroy-rcu-head-on-stack.html"><span class="phrase">destroy_rcu_head_on_stack</span></a></span><span class="refpurpose"> — 
115     destroy on-stack rcu_head for debugobjects
116 </span></dt><dt><span class="refentrytitle"><a href="API-synchronize-rcu-tasks.html"><span class="phrase">synchronize_rcu_tasks</span></a></span><span class="refpurpose"> — 
117     wait until an rcu-tasks grace period has elapsed.
118 </span></dt><dt><span class="refentrytitle"><a href="API-rcu-barrier-tasks.html"><span class="phrase">rcu_barrier_tasks</span></a></span><span class="refpurpose"> — 
119     Wait for in-flight <code class="function">call_rcu_tasks</code> callbacks.
120 </span></dt></dl></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="API-kset-create-and-add.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="Basics.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="API-upper-32-bits.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="phrase">kset_create_and_add</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> <span class="phrase">upper_32_bits</span></td></tr></table></div></body></html>
121