1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>struct device</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="Linux Device Drivers"><link rel="up" href="devdrivers.html#idp1109043876" title="The Basic Device Driver-Model Structures"><link rel="prev" href="API-struct-class.html" title="struct class"><link rel="next" href="API-module-driver.html" title="module_driver"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center"><span class="phrase">struct device</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="API-struct-class.html">Prev</a> </td><th width="60%" align="center">The Basic Device Driver-Model Structures </th><td width="20%" align="right"> <a accesskey="n" href="API-module-driver.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="API-struct-device"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>struct device — 2 The basic device structure 3 </p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="programlisting"> 4struct device { 5 struct device * parent; 6 struct device_private * p; 7 struct kobject kobj; 8 const char * init_name; 9 const struct device_type * type; 10 struct mutex mutex; 11 struct bus_type * bus; 12 struct device_driver * driver; 13 void * platform_data; 14 void * driver_data; 15 struct dev_pm_info power; 16 struct dev_pm_domain * pm_domain; 17#ifdef CONFIG_PINCTRL 18 struct dev_pin_info * pins; 19#endif 20#ifdef CONFIG_NUMA 21 int numa_node; 22#endif 23 u64 * dma_mask; 24 u64 coherent_dma_mask; 25 unsigned long dma_pfn_offset; 26 struct device_dma_parameters * dma_parms; 27 struct list_head dma_pools; 28 struct dma_coherent_mem * dma_mem; 29#ifdef CONFIG_DMA_CMA 30 struct cma * cma_area; 31#endif 32 struct dev_archdata archdata; 33 struct device_node * of_node; 34 struct fwnode_handle * fwnode; 35 dev_t devt; 36 u32 id; 37 spinlock_t devres_lock; 38 struct list_head devres_head; 39 struct klist_node knode_class; 40 struct class * class; 41 const struct attribute_group ** groups; 42 void (* release) (struct device *dev); 43 struct iommu_group * iommu_group; 44 bool offline_disabled:1; 45 bool offline:1; 46}; </pre></div><div class="refsect1"><a name="idp1109121900"></a><h2>Members</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term">parent</span></dt><dd><p> 47 The device's <span class="quote">“<span class="quote">parent</span>”</span> device, the device to which it is attached. 48 In most cases, a parent device is some sort of bus or host 49 controller. If parent is NULL, the device, is a top-level device, 50 which is not usually what you want. 51 </p></dd><dt><span class="term">p</span></dt><dd><p> 52 Holds the private data of the driver core portions of the device. 53 See the comment of the struct device_private for detail. 54 </p></dd><dt><span class="term">kobj</span></dt><dd><p> 55 A top-level, abstract class from which other classes are derived. 56 </p></dd><dt><span class="term">init_name</span></dt><dd><p> 57 Initial name of the device. 58 </p></dd><dt><span class="term">type</span></dt><dd><p> 59 The type of device. 60 This identifies the device type and carries type-specific 61 information. 62 </p></dd><dt><span class="term">mutex</span></dt><dd><p> 63 Mutex to synchronize calls to its driver. 64 </p></dd><dt><span class="term">bus</span></dt><dd><p> 65 Type of bus device is on. 66 </p></dd><dt><span class="term">driver</span></dt><dd><p> 67 Which driver has allocated this 68 </p></dd><dt><span class="term">platform_data</span></dt><dd><p> 69 Platform data specific to the device. 70 </p></dd><dt><span class="term">driver_data</span></dt><dd><p> 71 Private pointer for driver specific info. 72 </p></dd><dt><span class="term">power</span></dt><dd><p> 73 For device power management. 74 See Documentation/power/devices.txt for details. 75 </p></dd><dt><span class="term">pm_domain</span></dt><dd><p> 76 Provide callbacks that are executed during system suspend, 77 hibernation, system resume and during runtime PM transitions 78 along with subsystem-level and driver-level callbacks. 79 </p></dd><dt><span class="term">pins</span></dt><dd><p> 80 For device pin management. 81 See Documentation/pinctrl.txt for details. 82 </p></dd><dt><span class="term">numa_node</span></dt><dd><p> 83 NUMA node this device is close to. 84 </p></dd><dt><span class="term">dma_mask</span></dt><dd><p> 85 Dma mask (if dma'ble device). 86 </p></dd><dt><span class="term">coherent_dma_mask</span></dt><dd><p> 87 Like dma_mask, but for alloc_coherent mapping as not all 88 hardware supports 64-bit addresses for consistent allocations 89 such descriptors. 90 </p></dd><dt><span class="term">dma_pfn_offset</span></dt><dd><p> 91 offset of DMA memory range relatively of RAM 92 </p></dd><dt><span class="term">dma_parms</span></dt><dd><p> 93 A low level driver may set these to teach IOMMU code about 94 segment limitations. 95 </p></dd><dt><span class="term">dma_pools</span></dt><dd><p> 96 Dma pools (if dma'ble device). 97 </p></dd><dt><span class="term">dma_mem</span></dt><dd><p> 98 Internal for coherent mem override. 99 </p></dd><dt><span class="term">cma_area</span></dt><dd><p> 100 Contiguous memory area for dma allocations 101 </p></dd><dt><span class="term">archdata</span></dt><dd><p> 102 For arch-specific additions. 103 </p></dd><dt><span class="term">of_node</span></dt><dd><p> 104 Associated device tree node. 105 </p></dd><dt><span class="term">fwnode</span></dt><dd><p> 106 Associated device node supplied by platform firmware. 107 </p></dd><dt><span class="term">devt</span></dt><dd><p> 108 For creating the sysfs <span class="quote">“<span class="quote">dev</span>”</span>. 109 </p></dd><dt><span class="term">id</span></dt><dd><p> 110 device instance 111 </p></dd><dt><span class="term">devres_lock</span></dt><dd><p> 112 Spinlock to protect the resource of the device. 113 </p></dd><dt><span class="term">devres_head</span></dt><dd><p> 114 The resources list of the device. 115 </p></dd><dt><span class="term">knode_class</span></dt><dd><p> 116 The node used to add the device to the class list. 117 </p></dd><dt><span class="term">class</span></dt><dd><p> 118 The class of the device. 119 </p></dd><dt><span class="term">groups</span></dt><dd><p> 120 Optional attribute groups. 121 </p></dd><dt><span class="term">release</span></dt><dd><p> 122 Callback to free the device after all references have 123 gone away. This should be set by the allocator of the 124 device (i.e. the bus driver that discovered the device). 125 </p></dd><dt><span class="term">iommu_group</span></dt><dd><p> 126 IOMMU group the device belongs to. 127 </p></dd><dt><span class="term">offline_disabled</span></dt><dd><p> 128 If set, the device is permanently online. 129 </p></dd><dt><span class="term">offline</span></dt><dd><p> 130 Set after successful invocation of bus type's .<code class="function">offline</code>. 131 </p></dd></dl></div></div><div class="refsect1"><a name="idp1109149004"></a><h2>Example</h2><div class="informalexample"><pre class="programlisting"> 132 For devices on custom boards, as typical of embedded 133 and SOC based hardware, Linux often uses platform_data to point 134 to board-specific structures describing devices and how they 135 are wired. That can include what ports are available, chip 136 variants, which GPIO pins act in what additional roles, and so 137 on. This shrinks the <span class="quote">“<span class="quote">Board Support Packages</span>”</span> (BSPs) and 138 minimizes board-specific #ifdefs in drivers. 139</pre></div></div><div class="refsect1"><a name="idp1109150460"></a><h2>Description</h2><p> 140 At the lowest level, every device in a Linux system is represented by an 141 instance of struct device. The device structure contains the information 142 that the device model core needs to model the system. Most subsystems, 143 however, track additional information about the devices they host. As a 144 result, it is rare for devices to be represented by bare device structures; 145 instead, that structure, like kobject structures, is usually embedded within 146 a higher-level representation of the device. 147</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="API-struct-class.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="devdrivers.html#idp1109043876">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="API-module-driver.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="phrase">struct class</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> <span class="phrase">module_driver</span></td></tr></table></div></body></html> 148