1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><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&#160;1.&#160;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>&#160;</td><th width="60%" align="center">Chapter&#160;1.&#160;Driver Basics</th><td width="20%" align="right">&#160;<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="idp1108295964"></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"> &#8212; 
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"> &#8212; 
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"> &#8212; 
6     annotation for functions that can sleep
7 </span></dt><dt><span class="refentrytitle"><a href="API-reciprocal-scale.html"><span class="phrase">reciprocal_scale</span></a></span><span class="refpurpose"> &#8212; 
8     "scale" a value into range [0, ep_ro)
9 </span></dt><dt><span class="refentrytitle"><a href="API-kstrtoul.html"><span class="phrase">kstrtoul</span></a></span><span class="refpurpose"> &#8212; 
10     convert a string to an unsigned long
11 </span></dt><dt><span class="refentrytitle"><a href="API-kstrtol.html"><span class="phrase">kstrtol</span></a></span><span class="refpurpose"> &#8212; 
12     convert a string to a long
13 </span></dt><dt><span class="refentrytitle"><a href="API-trace-printk.html"><span class="phrase">trace_printk</span></a></span><span class="refpurpose"> &#8212; 
14     printf formatting in the ftrace buffer
15 </span></dt><dt><span class="refentrytitle"><a href="API-trace-puts.html"><span class="phrase">trace_puts</span></a></span><span class="refpurpose"> &#8212; 
16     write a string into the ftrace buffer
17 </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"> &#8212; 
18     return the minimum that is _not_ zero, unless both are zero
19 </span></dt><dt><span class="refentrytitle"><a href="API-clamp.html"><span class="phrase">clamp</span></a></span><span class="refpurpose"> &#8212; 
20     return a value clamped to a given range with strict typechecking
21 </span></dt><dt><span class="refentrytitle"><a href="API-clamp-t.html"><span class="phrase">clamp_t</span></a></span><span class="refpurpose"> &#8212; 
22     return a value clamped to a given range using a given type
23 </span></dt><dt><span class="refentrytitle"><a href="API-clamp-val.html"><span class="phrase">clamp_val</span></a></span><span class="refpurpose"> &#8212; 
24     return a value clamped to a given range using val's type
25 </span></dt><dt><span class="refentrytitle"><a href="API-container-of.html"><span class="phrase">container_of</span></a></span><span class="refpurpose"> &#8212; 
26     cast a member of a structure out to the containing structure
27 </span></dt><dt><span class="refentrytitle"><a href="API-printk.html"><span class="phrase">printk</span></a></span><span class="refpurpose"> &#8212; 
28  print a kernel message
29 </span></dt><dt><span class="refentrytitle"><a href="API-console-lock.html"><span class="phrase">console_lock</span></a></span><span class="refpurpose"> &#8212; 
30     lock the console system for exclusive use.
31 </span></dt><dt><span class="refentrytitle"><a href="API-console-trylock.html"><span class="phrase">console_trylock</span></a></span><span class="refpurpose"> &#8212; 
32     try to lock the console system for exclusive use.
33 </span></dt><dt><span class="refentrytitle"><a href="API-console-unlock.html"><span class="phrase">console_unlock</span></a></span><span class="refpurpose"> &#8212; 
34     unlock the console system
35 </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"> &#8212; 
36     yield the CPU if required
37 </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"> &#8212; 
38     caller-controlled printk ratelimiting
39 </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"> &#8212; 
40     register a kernel log dumper.
41 </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"> &#8212; 
42     unregister a kmsg dumper.
43 </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"> &#8212; 
44     retrieve one kmsg log line
45 </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"> &#8212; 
46     copy kmsg log lines
47 </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"> &#8212; 
48     reset the interator
49 </span></dt><dt><span class="refentrytitle"><a href="API-panic.html"><span class="phrase">panic</span></a></span><span class="refpurpose"> &#8212; 
50  halt the system
51 </span></dt><dt><span class="refentrytitle"><a href="API-add-taint.html"><span class="phrase">add_taint</span></a></span><span class="refpurpose"> &#8212; 
52   </span></dt><dt><span class="refentrytitle"><a href="re213.html">
53   .//kernel/sys.c
54  </a></span><span class="refpurpose"> &#8212; 
55   Document generation inconsistency
56  </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"> &#8212; 
57  initialize a sleep-RCU structure
58 </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"> &#8212; 
59     deconstruct a sleep-RCU structure
60 </span></dt><dt><span class="refentrytitle"><a href="API-synchronize-srcu.html"><span class="phrase">synchronize_srcu</span></a></span><span class="refpurpose"> &#8212; 
61     wait for prior SRCU read-side critical-section completion
62 </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"> &#8212; 
63     Brute-force SRCU grace period
64 </span></dt><dt><span class="refentrytitle"><a href="API-srcu-barrier.html"><span class="phrase">srcu_barrier</span></a></span><span class="refpurpose"> &#8212; 
65     Wait until all in-flight <code class="function">call_srcu</code> callbacks complete.
66 </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"> &#8212; 
67     return batches completed.
68 </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"> &#8212; 
69  inform RCU that current CPU is entering idle
70 </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"> &#8212; 
71     inform RCU that current CPU is leaving idle
72 </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"> &#8212; 
73     see if RCU thinks that the current CPU is idle
74 </span></dt><dt><span class="refentrytitle"><a href="API-synchronize-sched.html"><span class="phrase">synchronize_sched</span></a></span><span class="refpurpose"> &#8212; 
75     wait until an rcu-sched grace period has elapsed.
76 </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"> &#8212; 
77     wait until an rcu_bh grace period has elapsed.
78 </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"> &#8212; 
79     Snapshot current RCU state
80 </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"> &#8212; 
81     Conditionally wait for an RCU grace period
82 </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"> &#8212; 
83     Brute-force RCU-sched grace period
84 </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"> &#8212; 
85     Wait until all in-flight <code class="function">call_rcu_bh</code> callbacks complete.
86 </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"> &#8212; 
87     Wait for in-flight <code class="function">call_rcu_sched</code> callbacks.
88 </span></dt><dt><span class="refentrytitle"><a href="API-synchronize-rcu.html"><span class="phrase">synchronize_rcu</span></a></span><span class="refpurpose"> &#8212; 
89  wait until a grace period has elapsed.
90 </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"> &#8212; 
91     Brute-force RCU grace period
92 </span></dt><dt><span class="refentrytitle"><a href="API-rcu-barrier.html"><span class="phrase">rcu_barrier</span></a></span><span class="refpurpose"> &#8212; 
93     Wait until all in-flight <code class="function">call_rcu</code> callbacks complete.
94 </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"> &#8212; 
95  Expedite future RCU grace periods
96 </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"> &#8212; 
97     Cancel prior <code class="function">rcu_expedite_gp</code> invocation
98 </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"> &#8212; 
99     might we be in RCU read-side critical section?
100 </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"> &#8212; 
101     might we be in RCU-bh read-side critical section?
102 </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"> &#8212; 
103     initialize on-stack rcu_head for debugobjects
104 </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"> &#8212; 
105     destroy on-stack rcu_head for debugobjects
106 </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"> &#8212; 
107     wait until an rcu-tasks grace period has elapsed.
108 </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"> &#8212; 
109     Wait for in-flight <code class="function">call_rcu_tasks</code> callbacks.
110 </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>&#160;</td><td width="20%" align="center"><a accesskey="u" href="Basics.html">Up</a></td><td width="40%" align="right">&#160;<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>&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;<span class="phrase">upper_32_bits</span></td></tr></table></div></body></html>
111