最終更新:2014-06-06 (金) 08:12:37 (3611d)
kernel.org/doc/htmldocs/device-drivers
https://www.kernel.org/doc/htmldocs/device-drivers/index.html
目次
1. Driver Basics
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 integer from 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 integer and return
- atomic_sub_return? — subtract integer and return
- __atomic_add_unless? — add unless the number is already a given value
- atomic_inc_short? — increment of a short integer
- atomic_or_long? — OR of two long integers
Delaying, scheduling, and timer routines
Wait queues and Wake events
- wait_event — sleep until a condition gets true
- wait_event_timeout — sleep until a condition gets true or a timeout elapses
- wait_event_cmd? — sleep until a condition gets true
- wait_event_interruptible — sleep until a condition gets true
- wait_event_interruptible_timeout? — sleep until a condition gets true or a timeout elapses
- wait_event_hrtimeout? — sleep until a condition gets true or a timeout elapses
- wait_event_interruptible_hrtimeout? — sleep until a condition gets true or a timeout elapses
- wait_event_interruptible_locked? — sleep until a condition gets true
- wait_event_interruptible_locked_irq? — sleep until a condition gets true
- wait_event_interruptible_exclusive_locked? — sleep exclusively until a condition gets true
- wait_event_interruptible_exclusive_locked_irq? — sleep until a condition gets true
- wait_event_killable? — sleep until a condition gets true
- wait_event_lock_irq_cmd? — sleep until a condition gets true. The condition is checked under the lock. This is expected to be called with the lock taken.
- wait_event_lock_irq? — sleep until a condition gets true. The condition is checked under the lock. This is expected to be called with the lock taken.
- wait_event_interruptible_lock_irq_cmd? — sleep until a condition gets true. The condition is checked under the lock. This is expected to be called with the lock taken.
- wait_event_interruptible_lock_irq? — sleep until a condition gets true. The condition is checked under the lock. This is expected to be called with the lock taken.
- wait_event_interruptible_lock_irq_timeout? — sleep until a condition gets true or a timeout elapses. The condition is checked under the lock. This is expected to be called with the lock taken.
- wait_on_bit? — wait for a bit to be cleared
- wait_on_bit_lock? — wait for a bit to be cleared, when wanting to set it
- wait_on_atomic_t? — Wait for an atomic_t to become 0
- __wake_up — wake up threads blocked on a waitqueue.
- __wake_up_sync_key? — wake up threads blocked on a waitqueue.
- finish_wait? — clean up after waiting in a queue
- abort_exclusive_wait? — abort exclusive waiting in a queue
- wake_up_bit? — wake up a waiter on a bit
- wake_up_atomic_t? — Wake up a waiter on a atomic_t
High-resolution timers
Workqueues and Kevents
- queue_work_on? — queue work on specific cpu
- queue_delayed_work_on? — queue work on specific CPU after delay
- mod_delayed_work_on? — modify delay of or queue a delayed work on specific CPU
- flush_workqueue? — ensure that any scheduled work has run to completion.
- drain_workqueue? — drain a workqueue
- flush_work? — wait for a work to finish executing the last queueing instance
- cancel_work_sync? — cancel a work and wait for it to finish
- flush_delayed_work? — wait for a dwork to finish executing the last queueing
- cancel_delayed_work? — cancel a delayed work
- cancel_delayed_work_sync? — cancel a delayed work and wait for it to finish
- flush_scheduled_work? — ensure that any scheduled work has run to completion.
- execute_in_process_context? — reliably execute the routine with user context
- destroy_workqueue? — safely terminate a workqueue
- workqueue_set_max_active? — adjust max_active of a workqueue
- workqueue_congested? — test whether a workqueue is congested
- work_busy? — test whether a work is currently pending or running
- work_on_cpu? — run a function in user context on a particular cpu
Internal Functions
Kernel objects manipulation
Kernel utility functions
Device Resource Management
- devres_alloc — Allocate device resource data
- devres_for_each_res? — Resource iterator
- devres_free? — Free device resource data
- devres_add — Register device resource
- devres_find? — Find device resource
- devres_get? — Find devres, if non-existent, add one atomically
- devres_remove? — Find a device resource and remove it
- devres_destroy? — Find a device resource and destroy it
- devres_release? — Find a device resource and destroy it, calling release
- devres_open_group? — Open a new devres group
- devres_close_group? — Close a devres group
- devres_remove_group? — Remove a devres group
- devres_release_group? — Release resources in a devres group
- devm_add_action? — add a custom action to list of managed resources
- devm_remove_action? — removes previously added custom action
- devm_kmalloc? — Resource-managed kmalloc
- devm_kstrdup? — Allocate resource managed space and copy an existing string into that.
- devm_kfree? — Resource-managed kfree
2. Device drivers infrastructure
The Basic Device Driver-Model Structures
- bus_type — The bus type of the device
- device_driver — The basic device driver structure
- subsys_interface? — interfaces to device functions
- class — device classes
- device — The basic device structure
- module_driver — Helper macro for drivers that don't do anything special in module init/exit. This eliminates a lot of boilerplate. Each module may only use this macro once, and calling it replaces module_init and module_exit.
Device Drivers Base
- driver_init — initialize driver model.
- driver_for_each_device? — Iterator for devices bound to a driver.
- driver_find_device? — device iterator for locating a particular device.
- driver_create_file — create sysfs file for driver.
- driver_remove_file? — remove sysfs file for driver.
- driver_register — register driver with bus
- driver_unregister? — remove driver from system.
- driver_find? — locate driver on a bus by its name.
- dev_driver_string? — Return a device's driver name, if at all possible
- device_create_file — create sysfs attribute file for device.
- device_remove_file? — remove sysfs attribute file.
- device_remove_file_self? — remove sysfs attribute file from its own method.
- device_create_bin_file? — create sysfs binary attribute file for device.
- device_remove_bin_file? — remove sysfs binary attribute file
- device_initialize — init device structure.
- dev_set_name — set a device name
- device_add — add device to device hierarchy.
- device_register — register a device with the system.
- get_device? — increment reference count for device.
- put_device? — decrement reference count.
- device_del? — delete device from system.
- device_unregister? — unregister device from system.
- device_for_each_child? — device child iterator.
- device_find_child? — device iterator for locating a particular device.
- __root_device_register? — allocate and register a root device
- root_device_unregister? — unregister and free a root device
- device_create_vargs? — creates a device and registers it with sysfs
- device_create — creates a device and registers it with sysfs
- device_create_with_groups? — creates a device and registers it with sysfs
- device_destroy? — removes a device that was created with device_create
- device_rename? — renames a device
- device_move? — moves a device to a new parent
- register_syscore_ops? — Register a set of system core operations.
- unregister_syscore_ops? — Unregister a set of system core operations.
- syscore_suspend? — Execute all the registered system core suspend callbacks.
- syscore_resume? — Execute all the registered system core resume callbacks.
- __class_create — create a struct class structure
- class_destroy? — destroys a struct class structure
- class_dev_iter_init? — initialize class device iterator
- class_dev_iter_next? — iterate to the next device
- class_dev_iter_exit? — finish iteration
- class_for_each_device? — device iterator
- class_find_device? — device iterator for locating a particular device
- class_compat_register? — register a compatibility class
- class_compat_unregister? — unregister a compatibility class
- class_compat_create_link? — create a compatibility class device link to a bus device
- class_compat_remove_link? — remove a compatibility class device link to a bus device
- unregister_node? — unregister a node device
- request_firmware? — send firmware request and wait for it
- request_firmware_direct? — load firmware directly without usermode helper
- release_firmware? — release the resource associated with a firmware image
- request_firmware_nowait? — asynchronous version of request_firmware
- transport_class_register? — register an initial transport class
- transport_class_unregister? — unregister a previously registered class
- anon_transport_class_register? — register an anonymous class
- anon_transport_class_unregister? — unregister an anon class
- transport_setup_device? — declare a new dev for transport class association but don't make it visible yet.
- transport_add_device? — declare a new dev for transport class association
- transport_configure_device? — configure an already set up device
- transport_remove_device? — remove the visibility of a device
- transport_destroy_device? — destroy a removed device
- device_bind_driver — bind a driver to one device.
- wait_for_device_probe? —
- device_attach — try to attach device to a driver.
- driver_attach — try to bind driver to devices.
- device_release_driver? — manually detach device from driver.
- platform_device_register_resndata? — add a platform-level device with resources and platform-specific data
- platform_device_register_simple? — add a platform-level device and its resources
- platform_device_register_data? — add a platform-level device with platform-specific data
- platform_get_resource — get a resource for a device
- platform_get_irq — get an IRQ for a device
- platform_get_resource_byname? — get a resource for a device by name
- platform_get_irq_byname? — get an IRQ for a device by name
- platform_add_devices — add a numbers of platform devices
- platform_device_put? — destroy a platform device
- platform_device_alloc? — create a platform device
- platform_device_add_resources? — add resources to a platform device
- platform_device_add_data? — add platform-specific data to a platform device
- platform_device_add — add a platform device to device hierarchy
- platform_device_del? — remove a platform-level device
- platform_device_register — add a platform-level device
- platform_device_unregister? — unregister a platform-level device
- platform_device_register_full? — add a platform-level device with resources and platform-specific data
- __platform_driver_register — register a driver for platform-level devices
- platform_driver_unregister? — unregister a driver for platform-level devices
- platform_driver_probe — register driver for non-hotpluggable device
- platform_create_bundle? — register driver and create corresponding device
- bus_for_each_dev — device iterator.
- bus_find_device? — device iterator for locating a particular device.
- bus_find_device_by_name? — device iterator for locating a particular device of a specific name
- subsys_find_device_by_id? — find a device with a specific enumeration number
- bus_for_each_drv? — driver iterator
- bus_rescan_devices? — rescan devices on the bus for possible drivers
- device_reprobe? — remove driver for a device and probe for a new driver
- bus_register — register a driver-core subsystem
- bus_unregister? — remove a bus from the system
- subsys_dev_iter_init? — initialize subsys device iterator
- subsys_dev_iter_next? — iterate to the next device
- subsys_dev_iter_exit? — finish iteration
- subsys_system_register? — register a subsystem at /sys/devices/system/
- subsys_virtual_register? — register a subsystem at /sys/devices/virtual/
Device Drivers DMA Management
- dma_buf_export_named? — Creates a new dma_buf, and associates an anon file with this buffer, so it can be exported. Also connect the allocator specific data and ops to the buffer. Additionally, provide a name string for exporter; useful in debugging.
- dma_buf_fd? — returns a file descriptor for the given dma_buf
- dma_buf_get? — returns the dma_buf structure related to an fd
- dma_buf_put? — decreases refcount of the buffer
- dma_buf_attach? — Add the device to dma_buf's attachments list; optionally, calls attach of dma_buf_ops to allow device-specific attach functionality
- dma_buf_detach? — Remove the given attachment from dmabuf's attachments list; optionally calls detach of dma_buf_ops for device-specific detach
- dma_buf_map_attachment? — Returns the scatterlist table of the attachment; mapped into _device_ address space. Is a wrapper for map_dma_buf of the dma_buf_ops.
- dma_buf_unmap_attachment? — unmaps and decreases usecount of the buffer;might deallocate the scatterlist associated. Is a wrapper for unmap_dma_buf of dma_buf_ops.
- dma_buf_begin_cpu_access? — Must be called before accessing a dma_buf from the cpu in the kernel context. Calls begin_cpu_access to allow exporter-specific preparations. Coherency is only guaranteed in the specified range for the specified access direction.
- dma_buf_end_cpu_access? — Must be called after accessing a dma_buf from the cpu in the kernel context. Calls end_cpu_access to allow exporter-specific actions. Coherency is only guaranteed in the specified range for the specified access direction.
- dma_buf_kmap_atomic? — Map a page of the buffer object into kernel address space. The same restrictions as for kmap_atomic and friends apply.
- dma_buf_kunmap_atomic? — Unmap a page obtained by dma_buf_kmap_atomic.
- dma_buf_kmap? — Map a page of the buffer object into kernel address space. The same restrictions as for kmap and friends apply.
- dma_buf_kunmap? — Unmap a page obtained by dma_buf_kmap.
- dma_buf_mmap? — Setup up a userspace mmap with the given vma
- dma_buf_vmap? — Create virtual mapping for the buffer object into kernel address space. Same restrictions as for vmap and friends apply.
- dma_buf_vunmap? — Unmap a vmap obtained by dma_buf_vmap.
- dma_alloc_from_coherent? — try to allocate memory from the per-device coherent area
- dma_release_from_coherent? — try to free the memory allocated from per-device coherent memory pool
- dma_mmap_from_coherent? — try to mmap the memory allocated from per-device coherent memory pool to userspace
- dmam_alloc_coherent? — Managed dma_alloc_coherent
- dmam_free_coherent? — Managed dma_free_coherent
- dmam_alloc_noncoherent? — Managed dma_alloc_non_coherent
- dmam_free_noncoherent? — Managed dma_free_noncoherent
- dmam_declare_coherent_memory? — Managed dma_declare_coherent_memory
- dmam_release_declared_memory? — Managed dma_release_declared_memory.
Device Drivers Power Management
- dpm_resume_end? — Execute “resume” callbacks and complete system transition.
- dpm_suspend_end? — Execute “late” and “noirq” device suspend callbacks.
- dpm_suspend_start? — Prepare devices for PM transition and suspend them.
- device_pm_wait_for_dev? — Wait for suspend/resume of a device to complete.
- dpm_for_each_dev? — device iterator.
Device Drivers ACPI Support
- acpi_match_device? — Match a struct device against a given list of ACPI IDs
- acpi_bus_register_driver? — register a driver with the ACPI bus
- acpi_bus_unregister_driver? — unregisters a driver with the ACPI bus
- acpi_bus_scan? — Add ACPI device node objects in a given namespace scope.
- acpi_bus_trim? — Detach scan handlers and drivers from ACPI device objects.
- acpi_scan_drop_device? — Drop an ACPI device object.
Device drivers PnP support
- pnp_register_protocol? — adds a pnp protocol to the pnp layer
- pnp_unregister_protocol? — removes a pnp protocol from the pnp layer
- pnp_request_card_device? — Searches for a PnP device under the specified card
- pnp_release_card_device? — call this when the driver no longer needs the device
- pnp_register_card_driver? — registers a PnP card driver with the PnP Layer
- pnp_unregister_card_driver? — unregisters a PnP card driver from the PnP Layer
- pnp_add_id? — adds an EISA id to the specified device
- pnp_start_dev? — low-level start of the PnP device
- pnp_stop_dev? — low-level disable of the PnP device
- pnp_activate_dev? — activates a PnP device for use
- pnp_disable_dev? — disables device
- pnp_is_active? — Determines if a device is active based on its current resources
Userspace IO devices
- uio_event_notify? — trigger an interrupt event
- __uio_register_device? — register a new userspace IO device
- uio_unregister_device? — unregister a industrial IO device
- uio_mem? — description of a UIO memory region
- uio_port? — description of a UIO port region
- uio_info? — UIO device capabilities