'\" t .\" Title: struct device .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.79.1 .\" Date: January 2017 .\" Manual: Device drivers infrastructure .\" Source: Kernel Hackers Manual 4.8.15 .\" Language: English .\" .TH "STRUCT DEVICE" "9" "January 2017" "Kernel Hackers Manual 4\&.8\&." "Device drivers infrastructure" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" struct_device \- The basic device structure .SH "SYNOPSIS" .sp .nf struct device { struct device * parent; struct device_private * p; struct kobject kobj; const char * init_name; const struct device_type * type; struct mutex mutex; struct bus_type * bus; struct device_driver * driver; void * platform_data; void * driver_data; struct dev_pm_info power; struct dev_pm_domain * pm_domain; #ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN struct irq_domain * msi_domain; #endif #ifdef CONFIG_PINCTRL struct dev_pin_info * pins; #endif #ifdef CONFIG_GENERIC_MSI_IRQ struct list_head msi_list; #endif #ifdef CONFIG_NUMA int numa_node; #endif u64 * dma_mask; u64 coherent_dma_mask; unsigned long dma_pfn_offset; struct device_dma_parameters * dma_parms; struct list_head dma_pools; struct dma_coherent_mem * dma_mem; #ifdef CONFIG_DMA_CMA struct cma * cma_area; #endif struct dev_archdata archdata; struct device_node * of_node; struct fwnode_handle * fwnode; dev_t devt; u32 id; spinlock_t devres_lock; struct list_head devres_head; struct klist_node knode_class; struct class * class; const struct attribute_group ** groups; void (* release) (struct device *dev); struct iommu_group * iommu_group; bool offline_disabled:1; bool offline:1; }; .fi .SH "MEMBERS" .PP parent .RS 4 The device\*(Aqs \(lqparent\(rq device, the device to which it is attached\&. In most cases, a parent device is some sort of bus or host controller\&. If parent is NULL, the device, is a top\-level device, which is not usually what you want\&. .RE .PP p .RS 4 Holds the private data of the driver core portions of the device\&. See the comment of the struct device_private for detail\&. .RE .PP kobj .RS 4 A top\-level, abstract class from which other classes are derived\&. .RE .PP init_name .RS 4 Initial name of the device\&. .RE .PP type .RS 4 The type of device\&. This identifies the device type and carries type\-specific information\&. .RE .PP mutex .RS 4 Mutex to synchronize calls to its driver\&. .RE .PP bus .RS 4 Type of bus device is on\&. .RE .PP driver .RS 4 Which driver has allocated this .RE .PP platform_data .RS 4 Platform data specific to the device\&. .RE .PP driver_data .RS 4 Private pointer for driver specific info\&. .RE .PP power .RS 4 For device power management\&. See Documentation/power/devices\&.txt for details\&. .RE .PP pm_domain .RS 4 Provide callbacks that are executed during system suspend, hibernation, system resume and during runtime PM transitions along with subsystem\-level and driver\-level callbacks\&. .RE .PP msi_domain .RS 4 The generic MSI domain this device is using\&. .RE .PP pins .RS 4 For device pin management\&. See Documentation/pinctrl\&.txt for details\&. .RE .PP msi_list .RS 4 Hosts MSI descriptors .RE .PP numa_node .RS 4 NUMA node this device is close to\&. .RE .PP dma_mask .RS 4 Dma mask (if dma\*(Aqble device)\&. .RE .PP coherent_dma_mask .RS 4 Like dma_mask, but for alloc_coherent mapping as not all hardware supports 64\-bit addresses for consistent allocations such descriptors\&. .RE .PP dma_pfn_offset .RS 4 offset of DMA memory range relatively of RAM .RE .PP dma_parms .RS 4 A low level driver may set these to teach IOMMU code about segment limitations\&. .RE .PP dma_pools .RS 4 Dma pools (if dma\*(Aqble device)\&. .RE .PP dma_mem .RS 4 Internal for coherent mem override\&. .RE .PP cma_area .RS 4 Contiguous memory area for dma allocations .RE .PP archdata .RS 4 For arch\-specific additions\&. .RE .PP of_node .RS 4 Associated device tree node\&. .RE .PP fwnode .RS 4 Associated device node supplied by platform firmware\&. .RE .PP devt .RS 4 For creating the sysfs \(lqdev\(rq\&. .RE .PP id .RS 4 device instance .RE .PP devres_lock .RS 4 Spinlock to protect the resource of the device\&. .RE .PP devres_head .RS 4 The resources list of the device\&. .RE .PP knode_class .RS 4 The node used to add the device to the class list\&. .RE .PP class .RS 4 The class of the device\&. .RE .PP groups .RS 4 Optional attribute groups\&. .RE .PP release .RS 4 Callback to free the device after all references have gone away\&. This should be set by the allocator of the device (i\&.e\&. the bus driver that discovered the device)\&. .RE .PP iommu_group .RS 4 IOMMU group the device belongs to\&. .RE .PP offline_disabled .RS 4 If set, the device is permanently online\&. .RE .PP offline .RS 4 Set after successful invocation of bus type\*(Aqs \&.\fBoffline\fR\&. .RE .SH "EXAMPLE" .sp .if n \{\ .RS 4 .\} .nf For devices on custom boards, as typical of embedded and SOC based hardware, Linux often uses platform_data to point to board\-specific structures describing devices and how they are wired\&. That can include what ports are available, chip variants, which GPIO pins act in what additional roles, and so on\&. This shrinks the \(lqBoard Support Packages\(rq (BSPs) and minimizes board\-specific #ifdefs in drivers\&. .fi .if n \{\ .RE .\} .SH "DESCRIPTION" .PP At the lowest level, every device in a Linux system is represented by an instance of struct device\&. The device structure contains the information that the device model core needs to model the system\&. Most subsystems, however, track additional information about the devices they host\&. As a result, it is rare for devices to be represented by bare device structures; instead, that structure, like kobject structures, is usually embedded within a higher\-level representation of the device\&. .SH "COPYRIGHT" .br