Skip to content

Kernel Driver API Reference

This section collects Linux kernel APIs used throughout the kernel driver learning path, including driver core, platform drivers, DMA Engine, character devices, event notification, synchronization, GPIO, IRQ, and deferred execution.

Driver Core

API Purpose
Driver Core APIs Register buses, devices, and drivers and understand matching and probe lifecycle

Platform Driver

API Purpose
module_platform_driver() Register a platform driver using the standard module initialization and cleanup helpers.
struct platform_driver Define probe, remove, matching, and driver metadata for a platform driver.
struct of_device_id Define Device Tree compatible matching entries for a driver.

DMA Engine

API Purpose
DMA Engine APIs Allocate DMA channels, prepare and submit transactions, track DMA cookies, query transaction status and residue, handle completion callbacks, manage cyclic DMA, and terminate and synchronize DMA activity

Character Device Registration

API Purpose
file_operations Define VFS callbacks for a character device
alloc_chrdev_region Allocate a dynamic device number range
cdev_add Register a character device with the VFS
class_create Create a sysfs class for device nodes
device_create Create a device object and /dev node
misc_register Register a simple misc character device

User Access and Control Plane

API Purpose
copy_to_user Copy data from kernel to user space
copy_from_user Copy data from user space to kernel
ioctl Implement command-based control plane
sysfs attributes Expose simple device attributes

Blocking I/O and Event Notification

API Purpose
wait queues Sleep until a condition becomes true
poll_wait Integrate driver readiness with poll/epoll
non-blocking I/O Implement O_NONBLOCK behavior
fasync_helper Register or unregister asynchronous listeners for SIGIO

Locking, GPIO, and IRQ

API Purpose
spinlock Protect shared state accessed from Process Context and IRQ Context using an interrupt-safe spinlock.
mutex Protect shared state in sleepable contexts such as Process Context, workqueues, and kernel threads.
rw_semaphore Reader-writer synchronization allowing multiple concurrent readers.
devm_gpiod_get Get GPIO descriptors from Device Tree
devm_request_threaded_irq Register threaded IRQ handlers

Deferred Execution

API Purpose
workqueue Execute deferred work in process context using kernel worker threads
kthread Create and manage long-lived kernel execution threads