Skip to content

Kernel Driver API Reference

This section collects Linux kernel APIs used by the character driver, blocking I/O, pollable driver, fasync/SIGIO, GPIO, and IRQ labs.

Driver Core

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

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

Platform Driver Helpers