The Linux Kernel APIThe Linux Kernel API This documentation is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA For more details see the file COPYING in the source distribution of Linux. The Linux Kernel APIThe Linux Kernel APITable of Contents1. Driver Basics Driver Entry and Exit points Atomic and pointer manipulation Delaying, scheduling, and timer routines High-resolution timers Internal Functions Kernel objects manipulation Kernel utility functions 2. Data Types Doubly Linked Lists 3. Basic C Library Functions String Conversions String Manipulation Bit Operations 4. Memory Management in Linux The Slab Cache User Space Memory Access More Memory Management Functions 5. Kernel IPC facilities IPC utilities 6. FIFO Buffer kfifo interface 7. The proc filesystem sysctl interface proc filesystem interface 8. The debugfs filesystem debugfs interface 9. The Linux VFS The Filesystem types The Directory Cache Inode Handling Registration and Superblocks File Locks Other Functions 10. Linux Networking Networking Base Types Socket Buffer Functions Socket Filter Generic Network Statistics SUN RPC subsystem 11. Network device support Driver Support Synchronous PPP 12. Module Support Module Loading Inter Module support 13. Hardware Interfaces Interrupt Handling Resources Management MTRR Handling PCI Support Library PCI Hotplug Support Library MCA Architecture MCA Device Functions MCA Bus DMA 14. The Device File System devfs_mk_dir 15. The Filesystem for Exporting Kernel Objects sysfs_create_file sysfs_update_file sysfs_chmod_file sysfs_remove_file sysfs_create_dir sysfs_remove_dir sysfs_create_link sysfs_remove_link sysfs_create_bin_file sysfs_remove_bin_file 16. Security Framework register_security unregister_security mod_reg_security mod_unreg_security capable 17. Power Management pm_register pm_unregister pm_unregister_all pm_send_all 18. Device drivers infrastructure Device Drivers Base Device Drivers Power Management Device Drivers ACPI Support Device drivers PnP support 19. Block Devices blk_get_backing_dev_info blk_queue_prep_rq blk_queue_merge_bvec blk_queue_make_request blk_queue_ordered blk_queue_issue_flush_fn blk_queue_bounce_limit blk_queue_max_sectors blk_queue_max_phys_segments blk_queue_max_hw_segments blk_queue_max_segment_size blk_queue_hardsect_size blk_queue_stack_limits blk_queue_segment_boundary blk_queue_dma_alignment blk_queue_find_tag blk_queue_free_tags blk_queue_init_tags blk_queue_resize_tags blk_queue_end_tag blk_queue_start_tag blk_queue_invalidate_tags generic_unplug_device blk_start_queue blk_stop_queue blk_sync_queue blk_run_queue blk_cleanup_queue blk_init_queue blk_requeue_request blk_insert_request blk_rq_map_user blk_rq_map_user_iov blk_rq_unmap_user blk_rq_map_kern blk_execute_rq_nowait blk_execute_rq blkdev_issue_flush blk_end_sync_rq blk_congestion_wait generic_make_request submit_bio end_that_request_first end_that_request_chunk blk_complete_request 20. Miscellaneous Devices misc_register misc_deregister 21. Video4Linux video_register_device video_unregister_device 22. Sound Devices snd_printk snd_printd snd_assert snd_printdd register_sound_special_device register_sound_mixer register_sound_midi register_sound_dsp register_sound_synth unregister_sound_special unregister_sound_mixer unregister_sound_midi unregister_sound_dsp unregister_sound_synth snd_pcm_playback_ready snd_pcm_capture_ready snd_pcm_playback_data snd_pcm_playback_empty snd_pcm_capture_empty snd_pcm_format_cpu_endian snd_pcm_new_stream snd_pcm_new snd_device_new snd_device_free snd_device_register snd_iprintf snd_info_get_line snd_info_get_str snd_info_create_module_entry snd_info_create_card_entry snd_card_proc_new snd_info_free_entry snd_info_register snd_info_unregister snd_rawmidi_receive snd_rawmidi_transmit_empty snd_rawmidi_transmit_peek snd_rawmidi_transmit_ack snd_rawmidi_transmit snd_rawmidi_new snd_rawmidi_set_ops snd_request_card snd_lookup_minor_data snd_register_device snd_unregister_device copy_to_user_fromio copy_from_user_toio snd_pcm_lib_preallocate_free_for_all snd_pcm_lib_preallocate_pages snd_pcm_lib_preallocate_pages_for_all snd_pcm_sgbuf_ops_page snd_pcm_lib_malloc_pages snd_pcm_lib_free_pages snd_card_new snd_card_disconnect snd_card_free snd_card_free_in_thread snd_card_register snd_component_add snd_card_file_add snd_card_file_remove snd_power_wait snd_dma_program snd_dma_disable snd_dma_pointer snd_ctl_new snd_ctl_new1 snd_ctl_free_one snd_ctl_add snd_ctl_remove snd_ctl_remove_id snd_ctl_rename_id snd_ctl_find_numid snd_ctl_find_id snd_pcm_set_ops snd_pcm_set_sync snd_interval_refine snd_interval_ratnum snd_interval_list snd_pcm_hw_rule_add snd_pcm_hw_constraint_integer snd_pcm_hw_constraint_minmax snd_pcm_hw_constraint_list snd_pcm_hw_constraint_ratnums snd_pcm_hw_constraint_ratdens snd_pcm_hw_constraint_msbits snd_pcm_hw_constraint_step snd_pcm_hw_constraint_pow2 snd_pcm_hw_param_value_min snd_pcm_hw_param_value_max snd_pcm_hw_param_first snd_pcm_hw_param_last snd_pcm_hw_param_set snd_pcm_hw_param_mask snd_pcm_hw_param_near snd_pcm_lib_ioctl snd_pcm_period_elapsed snd_hwdep_new snd_pcm_stop snd_pcm_suspend snd_pcm_suspend_all snd_malloc_pages snd_free_pages snd_dma_alloc_pages snd_dma_alloc_pages_fallback snd_dma_free_pages snd_dma_get_reserved_buf snd_dma_reserve_buf 23. 16x50 UART Driver uart_handle_dcd_change uart_handle_cts_change uart_update_timeout uart_get_baud_rate uart_get_divisor uart_register_driver uart_unregister_driver uart_add_one_port uart_remove_one_port serial8250_suspend_port serial8250_resume_port serial8250_register_port serial8250_unregister_port 24. Z85230 Support Library z8530_interrupt z8530_sync_open z8530_sync_close z8530_sync_dma_open z8530_sync_dma_close z8530_sync_txdma_open z8530_sync_txdma_close z8530_describe z8530_init z8530_shutdown z8530_channel_load z8530_null_rx z8530_queue_xmit z8530_get_stats 25. Frame Buffer Library Frame Buffer Memory Frame Buffer Colormap Frame Buffer Video Mode Database Frame Buffer Macintosh Video Mode Database Frame Buffer Fonts Driver BasicsDriver BasicsChapter 1. Driver BasicsDriver Entry and Exit pointsDriver Entry and Exit pointsNamemodule_init -- driver initialization entry point SynopsisSynopsis module_init (x); x;ArgumentsArgumentsx function to be run at kernel boot time or module insertion DescriptionDescription module_init will either be called during do_initcalls (if builtin) or at module insertion time (if a module). There can only be one per module. Namemodule_exit -- driver exit entry point SynopsisSynopsis module_exit (x); x;ArgumentsArgumentsx function to be run when driver is removed DescriptionDescription module_exit will wrap the driver clean-up code with cleanup_module when used with rmmod when the driver is a module. If the driver is statically compiled into the kernel, module_exit has no effect. There can only be one per module. Atomic and pointer manipulationAtomic and pointer manipulationNameatomic_read -- read atomic variable SynopsisSynopsis atomic_read (v); v;ArgumentsArgumentsv pointer of type atomic_t DescriptionDescription Atomically reads the value of v. Nameatomic_set -- set atomic variable SynopsisSynopsis atomic_set (v, i); v; i;ArgumentsArgumentsv pointer of type atomic_t i required value DescriptionDescription Atomically sets the value of v to i. Nameatomic_add -- add integer to atomic variable SynopsisSynopsisvoid atomic_add (i, v);int i;atomic_t * v;ArgumentsArgumentsi integer value to add v pointer of type atomic_t DescriptionDescription Atomically adds i to v. Nameatomic_sub -- subtract the atomic variable SynopsisSynopsisvoid atomic_sub (i, v);int i;atomic_t * v;ArgumentsArgumentsi integer value to subtract v pointer of type atomic_t DescriptionDescription Atomically subtracts i from v. Nameatomic_sub_and_test -- subtract value from variable and test result SynopsisSynopsisint atomic_sub_and_test (i, v);int i;atomic_t * v;ArgumentsArgumentsi integer value to subtract v pointer of type atomic_t DescriptionDescription Atomically subtracts i from v and returns true if the result is zero, or false for all other cases. Nameatomic_inc -- increment atomic variable SynopsisSynopsisvoid atomic_inc (v);atomic_t * v;ArgumentsArgumentsv pointer of type atomic_t DescriptionDescription Atomically increments v by 1. Nameatomic_dec -- decrement atomic variable SynopsisSynopsisvoid atomic_dec (v);atomic_t * v;ArgumentsArgumentsv pointer of type atomic_t DescriptionDescription Atomically decrements v by 1. Nameatomic_dec_and_test -- decrement and test SynopsisSynopsisint atomic_dec_and_test (v);atomic_t * v;ArgumentsArgumentsv pointer of type atomic_t DescriptionDescription Atomically decrements v by 1 and returns true if the result is 0, or false for all other cases. Nameatomic_inc_and_test -- increment and test SynopsisSynopsisint atomic_inc_and_test (v);atomic_t * v;ArgumentsArgumentsv pointer of type atomic_t DescriptionDescription Atomically increments v by 1 and returns true if the result is zero, or false for all other cases. Nameatomic_add_negative -- add and test if negative SynopsisSynopsisint atomic_add_negative (i, v);int i;atomic_t * v;ArgumentsArgumentsi integer value to add v pointer of type atomic_t DescriptionDescription Atomically adds i to v and returns true if the result is negative, or false when result is greater than or equal to zero. Nameatomic_add_return -- add and return SynopsisSynopsisint atomic_add_return (i, v);int i;atomic_t * v;ArgumentsArgumentsi integer value to add v pointer of type atomic_t DescriptionDescription Atomically adds i to v and returns i + v Nameatomic_add_unless -- add unless the number is a given value SynopsisSynopsis atomic_add_unless (v, a, u); v; a; u;ArgumentsArgumentsv pointer of type atomic_t a the amount to add to v... u ...unless v is equal to u. DescriptionDescription Atomically adds a to v, so long as it was not u. Returns non-zero if v was not u, and zero otherwise. Nameget_unaligned -- get value from possibly mis-aligned location SynopsisSynopsis get_unaligned (ptr); ptr;ArgumentsArgumentsptr pointer to value DescriptionDescription This macro should be used for accessing values larger in size than single bytes at locations that are expected to be improperly aligned, e.g. retrieving a u16 value from a location not u16-aligned. Note that unaligned accesses can be very expensive on some architectures. Nameput_unaligned -- put value to a possibly mis-aligned location SynopsisSynopsis put_unaligned (val, ptr); val; ptr;ArgumentsArgumentsval value to place ptr pointer to location DescriptionDescription This macro should be used for placing values larger in size than single bytes at locations that are expected to be improperly aligned, e.g. writing a u16 value to a location not u16-aligned. Note that unaligned accesses can be very expensive on some architectures. Delaying, scheduling, and timer routinesDelaying, scheduling, and timer routinesNamepid_alive -- check that a task structure is not stale SynopsisSynopsisint pid_alive (p);struct task_struct * p;ArgumentsArgumentsp Task structure to be checked. DescriptionDescription Test if a process is not yet dead (at most zombie state) If pid_alive fails, then pointers within the task structure can be stale and must not be dereferenced. Name__wake_up -- wake up threads blocked on a waitqueue. SynopsisSynopsisvoid fastcall __wake_up (q, mode, nr_exclusive, key);wait_queue_head_t * q;unsigned int mode;int nr_exclusive;void * key;ArgumentsArgumentsq the waitqueue mode which threads nr_exclusive how many wake-one or wake-many threads to wake up key is directly passed to the wakeup function Name__wake_up_sync -- wake up threads blocked on a waitqueue. SynopsisSynopsisvoid fastcall __wake_up_sync (q, mode, nr_exclusive);wait_queue_head_t * q;unsigned int mode;int nr_exclusive;ArgumentsArgumentsq the waitqueue mode which threads nr_exclusive how many wake-one or wake-many threads to wake up DescriptionDescription The sync wakeup differs that the waker knows that it will schedule away soon, so while the target thread will be woken up, it will not be migrated to another CPU - ie. the two threads are 'synchronized' with each other. This can prevent needless bouncing between CPUs. On UP it can prevent extra preemption. Nametask_nice -- return the nice value of a given task. SynopsisSynopsisint task_nice (p);const task_t * p;ArgumentsArgumentsp the task in question. Namesched_setscheduler -- change the scheduling policy and/or RT priority of SynopsisSynopsisint sched_setscheduler (p, policy, param);struct task_struct * p;int policy;struct sched_param * param;ArgumentsArgumentsp the task in question. policy new policy. param structure containing the new RT priority. DescriptionDescription a thread. Nameyield -- yield the current processor to other threads. SynopsisSynopsisvoid __sched yield (void); void;ArgumentsArgumentsvoid no arguments DescriptionDescription this is a shortcut for kernel-space yielding - it marks the thread runnable and calls sys_sched_yield. Nameschedule_timeout -- sleep until timeout SynopsisSynopsissigned long __sched schedule_timeout (timeout);signed long timeout;ArgumentsArgumentstimeout timeout value in jiffies DescriptionDescription Make the current task sleep until timeout jiffies have elapsed. The routine will return immediately unless the current task state has been set (see set_current_state). You can set the task state as follows - TASK_UNINTERRUPTIBLE - at least timeout jiffies are guaranteed to pass before the routine returns. The routine will return 0 TASK_INTERRUPTIBLE - the routine may return early if a signal is delivered to the current task. In this case the remaining time in jiffies will be returned, or 0 if the timer expired in time The current task state is guaranteed to be TASK_RUNNING when this routine returns. Specifying a timeout value of MAX_SCHEDULE_TIMEOUT will schedule the CPU away without a bound on the timeout. In this case the return value will be MAX_SCHEDULE_TIMEOUT. In all cases the return value is guaranteed to be non-negative. Namemsleep -- sleep safely even with waitqueue interruptions SynopsisSynopsisvoid msleep (msecs);unsigned int msecs;ArgumentsArgumentsmsecs Time in milliseconds to sleep for Namemsleep_interruptible -- sleep waiting for signals SynopsisSynopsisunsigned long msleep_interruptible (msecs);unsigned int msecs;ArgumentsArgumentsmsecs Time in milliseconds to sleep for High-resolution timersHigh-resolution timersNamektime_set -- Set a ktime_t variable from a seconds/nanoseconds value SynopsisSynopsisktime_t ktime_set (secs, nsecs);const long secs;const unsigned long nsecs;ArgumentsArgumentssecs seconds to set nsecs nanoseconds to set DescriptionDescription Return the ktime_t representation of the value DescriptionDescription Return the ktime_t representation of the value Namektime_sub -- subtract two ktime_t variables SynopsisSynopsisktime_t ktime_sub (lhs, rhs);const ktime_t lhs;const ktime_t rhs;ArgumentsArgumentslhs minuend rhs subtrahend DescriptionDescription Returns the remainder of the substraction DescriptionDescription Returns the remainder of the substraction Namektime_add -- add two ktime_t variables SynopsisSynopsisktime_t ktime_add (add1, add2);const ktime_t add1;const ktime_t add2;ArgumentsArgumentsadd1 addend1 add2 addend2 DescriptionDescription Returns the sum of addend1 and addend2 DescriptionDescription Returns the sum of addend1 and addend2 Namektime_add_ns -- Add a scalar nanoseconds value to a ktime_t variable SynopsisSynopsisktime_t ktime_add_ns (kt, nsec);const ktime_t kt;u64 nsec;ArgumentsArgumentskt addend nsec the scalar nsec value to add DescriptionDescription Returns the sum of kt and nsec in ktime_t format DescriptionDescription Returns the sum of kt and nsec in ktime_t format Nametimespec_to_ktime -- convert a timespec to ktime_t format SynopsisSynopsisktime_t timespec_to_ktime (ts);const struct timespec ts;ArgumentsArgumentsts the timespec variable to convert DescriptionDescription Returns a ktime_t variable with the converted timespec value DescriptionDescription Returns a ktime_t variable with the converted timespec value Nametimeval_to_ktime -- convert a timeval to ktime_t format SynopsisSynopsisktime_t timeval_to_ktime (tv);const struct timeval tv;ArgumentsArgumentstv the timeval variable to convert DescriptionDescription Returns a ktime_t variable with the converted timeval value DescriptionDescription Returns a ktime_t variable with the converted timeval value Namektime_to_timespec -- convert a ktime_t variable to timespec format SynopsisSynopsisstruct timespec ktime_to_timespec (kt);const ktime_t kt;ArgumentsArgumentskt the ktime_t variable to convert DescriptionDescription Returns the timespec representation of the ktime value DescriptionDescription Returns the timespec representation of the ktime value Namektime_to_timeval -- convert a ktime_t variable to timeval format SynopsisSynopsisstruct timeval ktime_to_timeval (kt);const ktime_t kt;ArgumentsArgumentskt the ktime_t variable to convert DescriptionDescription Returns the timeval representation of the ktime value DescriptionDescription Returns the timeval representation of the ktime value Namektime_to_clock_t -- convert a ktime_t variable to clock_t format SynopsisSynopsisclock_t ktime_to_clock_t (kt);const ktime_t kt;ArgumentsArgumentskt the ktime_t variable to convert DescriptionDescription Returns a clock_t variable with the converted value Namektime_to_ns -- convert a ktime_t variable to scalar nanoseconds SynopsisSynopsisu64 ktime_to_ns (kt);const ktime_t kt;ArgumentsArgumentskt the ktime_t variable to convert DescriptionDescription Returns the scalar nanoseconds representation of kt Namestruct hrtimer -- the basic hrtimer structure SynopsisSynopsis struct hrtimer { struct rb_node node; ktime_t expires; enum hrtimer_state state; int (* function) (void *); void * data; struct hrtimer_base * base; }; MembersMembersnode red black tree node for time ordered insertion expires the absolute expiry time in the hrtimers internal representation. The time is related to the clock on which the timer is based. state state of the timer function timer expiry callback function data argument for the callback function base pointer to the timer base (per cpu and per clock) DescriptionDescription The hrtimer structure must be initialized by init_hrtimer_#CLOCKTYPE DescriptionDescription The hrtimer structure must be initialized by init_hrtimer_#CLOCKTYPE Namestruct hrtimer_base -- the timer base for a specific clock SynopsisSynopsis struct hrtimer_base { clockid_t index; spinlock_t lock; struct rb_root active; struct rb_node * first; ktime_t resolution; ktime_t (* get_time) (void); struct hrtimer * curr_timer; }; MembersMembersindex clock type index for per_cpu support when moving a timer to a base on another cpu. lock lock protecting the base and associated timers active red black tree root node for the active timers first pointer to the timer node which expires first resolution the resolution of the clock, in nanoseconds get_time function to retrieve the current time of the clock curr_timer the timer which is executing a callback right now DescriptionDescription Namektime_get_real -- get the real (wall-) time in ktime_t format SynopsisSynopsisktime_t ktime_get_real (void); void;ArgumentsArgumentsvoid no arguments DescriptionDescription returns the time in ktime_t format Namektime_get_ts -- get the monotonic clock in timespec format SynopsisSynopsisvoid ktime_get_ts (ts);struct timespec * ts;ArgumentsArgumentsts pointer to timespec variable DescriptionDescription The function calculates the monotonic clock from the realtime clock and the wall_to_monotonic offset and stores the result in normalized timespec format in the variable pointed to by ts. DescriptionDescription The function calculates the monotonic clock from the realtime clock and the wall_to_monotonic offset and stores the result in normalized timespec format in the variable pointed to by ts. Internal FunctionsInternal FunctionsNamereparent_to_init -- Reparent the calling kernel thread to the init task. SynopsisSynopsisvoid reparent_to_init (void); void;ArgumentsArgumentsvoid no arguments DescriptionDescription If a kernel thread is launched as a result of a system call, or if it ever exits, it should generally reparent itself to init so that it is correctly cleaned up on exit. The various task state such as scheduling policy and priority may have been inherited from a user process, so we reset them to sane values here. NOTE that reparent_to_init gives the caller full capabilities. Namesys_tgkill -- send signal to one specific thread SynopsisSynopsislong sys_tgkill (tgid, pid, sig);int tgid;int pid;int sig;ArgumentsArgumentstgid the thread group ID of the thread pid the PID of the thread sig signal to be sent DescriptionDescription This syscall also checks the tgid and returns -ESRCH even if the PID exists but it's not belonging to the target process anymore. This method solves the problem of threads exiting and PIDs getting reused. Kernel objects manipulationKernel objects manipulationNamekobject_init -- initialize object. SynopsisSynopsisvoid kobject_init (kobj);struct kobject * kobj;ArgumentsArgumentskobj object in question. Namekobject_add -- add an object to the hierarchy. SynopsisSynopsisint kobject_add (kobj);struct kobject * kobj;ArgumentsArgumentskobj object. Namekobject_register -- initialize and add an object. SynopsisSynopsisint kobject_register (kobj);struct kobject * kobj;ArgumentsArgumentskobj object in question. Namekobject_set_name -- Set the name of an object SynopsisSynopsisint kobject_set_name (kobj, fmt, ...);struct kobject * kobj;const char * fmt; ...;ArgumentsArgumentskobj object. fmt format string used to build the name ... variable arguments DescriptionDescription If strlen(name) >= KOBJ_NAME_LEN, then use a dynamically allocated string that kobj->k_name points to. Otherwise, use the static kobj->name array. Namekobject_del -- unlink kobject from hierarchy. SynopsisSynopsisvoid kobject_del (kobj);struct kobject * kobj;ArgumentsArgumentskobj object. Namekobject_unregister -- remove object from hierarchy and decrement refcount. SynopsisSynopsisvoid kobject_unregister (kobj);struct kobject * kobj;ArgumentsArgumentskobj object going away. Namekobject_get -- increment refcount for object. SynopsisSynopsisstruct kobject * kobject_get (kobj);struct kobject * kobj;ArgumentsArgumentskobj object. Namekobject_put -- decrement refcount for object. SynopsisSynopsisvoid kobject_put (kobj);struct kobject * kobj;ArgumentsArgumentskobj object. DescriptionDescription Decrement the refcount, and if 0, call kobject_cleanup. Namekset_register -- initialize and add a kset. SynopsisSynopsisint kset_register (k);struct kset * k;ArgumentsArgumentsk kset. Namekset_unregister -- remove a kset. SynopsisSynopsisvoid kset_unregister (k);struct kset * k;ArgumentsArgumentsk kset. Namekset_find_obj -- search for object in kset. SynopsisSynopsisstruct kobject * kset_find_obj (kset, name);struct kset * kset;const char * name;ArgumentsArgumentskset kset we're looking in. name object's name. DescriptionDescription Lock kset via kset->subsys, and iterate over kset->list, looking for a matching kobject. If matching object is found take a reference and return the object. Namesubsystem_register -- register a subsystem. SynopsisSynopsisint subsystem_register (s);struct subsystem * s;ArgumentsArgumentss the subsystem we're registering. DescriptionDescription Once we register the subsystem, we want to make sure that the kset points back to this subsystem for correct usage of the rwsem. Namesubsys_create_file -- export sysfs attribute file. SynopsisSynopsisint subsys_create_file (s, a);struct subsystem * s;struct subsys_attribute * a;ArgumentsArgumentss subsystem. a subsystem attribute descriptor. Namesubsys_remove_file -- remove sysfs attribute file. SynopsisSynopsisvoid subsys_remove_file (s, a);struct subsystem * s;struct subsys_attribute * a;ArgumentsArgumentss subsystem. a attribute desciptor. Kernel utility functionsKernel utility functionsNamecontainer_of -- cast a member of a structure out to the containing structure SynopsisSynopsis container_of (ptr, type, member); ptr; type; member;ArgumentsArgumentsptr the pointer to the member. type the type of the container struct this is embedded in. member the name of the member within the struct. Nameprintk -- print a kernel message SynopsisSynopsisint printk (fmt, ...);const char * fmt; ...;ArgumentsArgumentsfmt format string ... variable arguments DescriptionDescription This is printk. It can be called from any context. We want it to work. We try to grab the console_sem. If we succeed, it's easy - we log the output and call the console drivers. If we fail to get the semaphore we place the output into the log buffer and return. The current holder of the console_sem will notice the new output in release_console_sem and will send it to the consoles before releasing the semaphore. One effect of this deferred printing is that code which calls printk and then changes console_loglevel may break. This is because console_loglevel is inspected when the actual printing occurs. See alsoSee also printf(3) Nameacquire_console_sem -- lock the console system for exclusive use. SynopsisSynopsisvoid acquire_console_sem (void); void;ArgumentsArgumentsvoid no arguments DescriptionDescription Acquires a semaphore which guarantees that the caller has exclusive access to the console system and the console_drivers list. Can sleep, returns nothing. Namerelease_console_sem -- unlock the console system SynopsisSynopsisvoid release_console_sem (void); void;ArgumentsArgumentsvoid no arguments DescriptionDescription Releases the semaphore which the caller holds on the console system and the console driver list. While the semaphore was held, console output may have been buffered by printk. If this is the case, release_console_sem emits the output prior to releasing the semaphore. If there is output waiting for klogd, we wake it up. release_console_sem may be called from any context. Nameconsole_conditional_schedule -- yield the CPU if required SynopsisSynopsisvoid __sched console_conditional_schedule (void); void;ArgumentsArgumentsvoid no arguments DescriptionDescription If the console code is currently allowed to sleep, and if this CPU should yield the CPU to another task, do so here. Must be called within acquire_console_sem. Namepanic -- halt the system SynopsisSynopsisNORET_TYPE void panic (fmt, ...);const char * fmt; ...;ArgumentsArgumentsfmt The text string to print ... variable arguments DescriptionDescription Display a message, then perform cleanups. This function never returns. Namenotifier_chain_register -- Add notifier to a notifier chain SynopsisSynopsisint notifier_chain_register (list, n);struct notifier_block ** list;struct notifier_block * n;ArgumentsArgumentslist Pointer to root list pointer n New entry in notifier chain DescriptionDescription Adds a notifier to a notifier chain. Currently always returns zero. Namenotifier_chain_unregister -- Remove notifier from a notifier chain SynopsisSynopsisint notifier_chain_unregister (nl, n);struct notifier_block ** nl;struct notifier_block * n;ArgumentsArgumentsnl Pointer to root list pointer n New entry in notifier chain DescriptionDescription Removes a notifier from a notifier chain. Returns zero on success, or -ENOENT on failure. Namenotifier_call_chain -- Call functions in a notifier chain SynopsisSynopsisint __kprobes notifier_call_chain (n, val, v);struct notifier_block ** n;unsigned long val;void * v;ArgumentsArgumentsn Pointer to root pointer of notifier chain val Value passed unmodified to notifier function v Pointer passed unmodified to notifier function DescriptionDescription Calls each function in a notifier chain in turn. If the return value of the notifier can be and'd with NOTIFY_STOP_MASK, then notifier_call_chain will return immediately, with the return value of the notifier function which halted execution. Otherwise, the return value is the return value of the last notifier function called.