Chapter 1. Driver Basics

Table of Contents

Driver Entry and Exit points
module_init — driver initialization entry point
module_exit — driver exit entry point
Atomic and pointer manipulation
atomic_read — read atomic variable
atomic_set — set atomic variable
atomic_add — add integer to atomic variable
atomic_sub — subtract the atomic variable
atomic_sub_and_test — subtract value from variable and test result
atomic_inc — increment atomic variable
atomic_dec — decrement atomic variable
atomic_dec_and_test — decrement and test
atomic_inc_and_test — increment and test
atomic_add_negative — add and test if negative
atomic_add_return — add and return
atomic_add_unless — add unless the number is a given value
get_unaligned — get value from possibly mis-aligned location
put_unaligned — put value to a possibly mis-aligned location
Delaying, scheduling, and timer routines
pid_alive — check that a task structure is not stale
is_init — check if a task structure is init
__wake_up — wake up threads blocked on a waitqueue.
__wake_up_sync — wake up threads blocked on a waitqueue.
task_nice — return the nice value of a given task.
sched_setscheduler — change the scheduling policy and/or RT priority of
yield — yield the current processor to other threads.
__round_jiffies — function to round jiffies to a full second
__round_jiffies_relative — function to round jiffies to a full second
round_jiffies — function to round jiffies to a full second
round_jiffies_relative — function to round jiffies to a full second
init_timer — initialize a timer.
mod_timer — modify a timer's timeout
del_timer — deactive a timer.
del_timer_sync — deactivate a timer and wait for the handler to finish.
getnstimeofday — Returns the time of day in a timespec
do_gettimeofday — Returns the time of day in a timeval
do_settimeofday — Sets the time of day
schedule_timeout — sleep until timeout
msleep — sleep safely even with waitqueue interruptions
msleep_interruptible — sleep waiting for signals
High-resolution timers
ktime_set — Set a ktime_t variable from a seconds/nanoseconds value
ktime_sub — subtract two ktime_t variables
ktime_add — add two ktime_t variables
ktime_add_ns — Add a scalar nanoseconds value to a ktime_t variable
timespec_to_ktime — convert a timespec to ktime_t format
timeval_to_ktime — convert a timeval to ktime_t format
ktime_to_timespec — convert a ktime_t variable to timespec format
ktime_to_timeval — convert a ktime_t variable to timeval format
ktime_to_ns — convert a ktime_t variable to scalar nanoseconds
struct hrtimer — the basic hrtimer structure
struct hrtimer_sleeper — simple sleeper structure
struct hrtimer_base — the timer base for a specific clock
ktime_get_real — get the real (wall-) time in ktime_t format
ktime_get_ts — get the monotonic clock in timespec format
hrtimer_start — (re)start an relative timer on the current CPU
hrtimer_try_to_cancel — try to deactivate a timer
hrtimer_cancel — cancel a timer and wait for the handler to finish.
hrtimer_get_remaining — get remaining time for the timer
hrtimer_init — initialize a timer to the given clock
hrtimer_get_res — get the timer resolution for a clock
Workqueues and Kevents
run_scheduled_work — run scheduled work synchronously
queue_work — queue work on a workqueue
queue_delayed_work — queue work on a workqueue after delay
queue_delayed_work_on — queue work on specific CPU after delay
flush_workqueue — ensure that any scheduled work has run to completion.
destroy_workqueue — safely terminate a workqueue
schedule_work — put work task in global workqueue
schedule_delayed_work — put work task in global workqueue after delay
schedule_delayed_work_on — queue work in global workqueue on CPU after delay
cancel_rearming_delayed_workqueue — reliably kill off a delayed
cancel_rearming_delayed_work — reliably kill off a delayed keventd
execute_in_process_context — reliably execute the routine with user context
Internal Functions
reparent_to_init — Reparent the calling kernel thread to the init task
sys_tgkill — send signal to one specific thread
kthread_run — create and wake a thread.
kthread_should_stop — should this kthread return now?
kthread_create — create a kthread.
kthread_bind — bind a just-created kthread to a cpu.
kthread_stop — stop a thread created by kthread_create.
Kernel objects manipulation
kobject_get_path — generate and return the path associated with a given kobj
kobject_init — initialize object.
kobject_add — add an object to the hierarchy.
kobject_register — initialize and add an object.
kobject_set_name — Set the name of an object
kobject_del — unlink kobject from hierarchy.
kobject_unregister — remove object from hierarchy and decrement refcount.
kobject_get — increment refcount for object.
kobject_put — decrement refcount for object.
kset_register — initialize and add a kset.
kset_unregister — remove a kset.
subsystem_register — register a subsystem.
subsys_create_file — export sysfs attribute file.
Kernel utility functions
container_of — cast a member of a structure out to the containing structure
printk — print a kernel message
acquire_console_sem — lock the console system for exclusive use.
release_console_sem — unlock the console system
console_conditional_schedule — yield the CPU if required
printk_timed_ratelimit — caller-controlled printk ratelimiting
panic — halt the system
atomic_notifier_chain_register — Add notifier to an atomic notifier chain
atomic_notifier_chain_unregister — Remove notifier from an atomic notifier chain
atomic_notifier_call_chain — Call functions in an atomic notifier chain
blocking_notifier_chain_register — Add notifier to a blocking notifier chain
blocking_notifier_chain_unregister — Remove notifier from a blocking notifier chain
blocking_notifier_call_chain — Call functions in a blocking notifier chain
raw_notifier_chain_register — Add notifier to a raw notifier chain
raw_notifier_chain_unregister — Remove notifier from a raw notifier chain
raw_notifier_call_chain — Call functions in a raw notifier chain
srcu_notifier_chain_register — Add notifier to an SRCU notifier chain
srcu_notifier_chain_unregister — Remove notifier from an SRCU notifier chain
srcu_notifier_call_chain — Call functions in an SRCU notifier chain
srcu_init_notifier_head — Initialize an SRCU notifier head
register_reboot_notifier — Register function to be called at reboot time
unregister_reboot_notifier — Unregister previously registered reboot notifier
emergency_restart — reboot the system
kernel_restart — reboot the system
kernel_halt — halt the system
kernel_power_off — power_off the system
call_rcu — Queue an RCU callback for invocation after a grace period.
call_rcu_bh — Queue an RCU for invocation after a quicker grace period.
rcu_barrier — Wait until all the in-flight RCUs are complete.
synchronize_rcu — wait until a grace period has elapsed.