Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

driver core: Add the device driver-model structures to kerneldoc

Add the comments to the structure bus_type, device_driver, device,
class to device.h for generating the driver-model kerneldoc. With another patch
these all removed from the files in Documentation/driver-model/ since
they are out of date. That will keep things up to date and provide a better way
to document this stuff.

Signed-off-by: Wanlong Gao <wanlong.gao@gmail.com>
Acked-by: Harry Wei <harryxiyou@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Wanlong Gao and committed by
Greg Kroah-Hartman
880ffb5c 3ccff540

+154 -6
+3 -3
Documentation/DocBook/device-drivers.tmpl
··· 96 96 97 97 <chapter id="devdrivers"> 98 98 <title>Device drivers infrastructure</title> 99 + <sect1><title>The Basic Device Driver-Model Structures </title> 100 + !Iinclude/linux/device.h 101 + </sect1> 99 102 <sect1><title>Device Drivers Base</title> 100 - <!-- 101 - X!Iinclude/linux/device.h 102 - --> 103 103 !Edrivers/base/driver.c 104 104 !Edrivers/base/core.c 105 105 !Edrivers/base/class.c
+151 -3
include/linux/device.h
··· 47 47 struct bus_attribute *); 48 48 extern void bus_remove_file(struct bus_type *, struct bus_attribute *); 49 49 50 + /** 51 + * struct bus_type - The bus type of the device 52 + * 53 + * @name: The name of the bus. 54 + * @bus_attrs: Default attributes of the bus. 55 + * @dev_attrs: Default attributes of the devices on the bus. 56 + * @drv_attrs: Default attributes of the device drivers on the bus. 57 + * @match: Called, perhaps multiple times, whenever a new device or driver 58 + * is added for this bus. It should return a nonzero value if the 59 + * given device can be handled by the given driver. 60 + * @uevent: Called when a device is added, removed, or a few other things 61 + * that generate uevents to add the environment variables. 62 + * @probe: Called when a new device or driver add to this bus, and callback 63 + * the specific driver's probe to initial the matched device. 64 + * @remove: Called when a device removed from this bus. 65 + * @shutdown: Called at shut-down time to quiesce the device. 66 + * @suspend: Called when a device on this bus wants to go to sleep mode. 67 + * @resume: Called to bring a device on this bus out of sleep mode. 68 + * @pm: Power management operations of this bus, callback the specific 69 + * device driver's pm-ops. 70 + * @p: The private data of the driver core, only the driver core can 71 + * touch this. 72 + * 73 + * A bus is a channel between the processor and one or more devices. For the 74 + * purposes of the device model, all devices are connected via a bus, even if 75 + * it is an internal, virtual, "platform" bus. Buses can plug into each other. 76 + * A USB controller is usually a PCI device, for example. The device model 77 + * represents the actual connections between buses and the devices they control. 78 + * A bus is represented by the bus_type structure. It contains the name, the 79 + * default attributes, the bus' methods, PM operations, and the driver core's 80 + * private data. 81 + */ 50 82 struct bus_type { 51 83 const char *name; 52 84 struct bus_attribute *bus_attrs; ··· 151 119 extern struct kset *bus_get_kset(struct bus_type *bus); 152 120 extern struct klist *bus_get_device_klist(struct bus_type *bus); 153 121 122 + /** 123 + * struct device_driver - The basic device driver structure 124 + * @name: Name of the device driver. 125 + * @bus: The bus which the device of this driver belongs to. 126 + * @owner: The module owner. 127 + * @mod_name: Used for built-in modules. 128 + * @suppress_bind_attrs: Disables bind/unbind via sysfs. 129 + * @of_match_table: The open firmware table. 130 + * @probe: Called to query the existence of a specific device, 131 + * whether this driver can work with it, and bind the driver 132 + * to a specific device. 133 + * @remove: Called when the device is removed from the system to 134 + * unbind a device from this driver. 135 + * @shutdown: Called at shut-down time to quiesce the device. 136 + * @suspend: Called to put the device to sleep mode. Usually to a 137 + * low power state. 138 + * @resume: Called to bring a device from sleep mode. 139 + * @groups: Default attributes that get created by the driver core 140 + * automatically. 141 + * @pm: Power management operations of the device which matched 142 + * this driver. 143 + * @p: Driver core's private data, no one other than the driver 144 + * core can touch this. 145 + * 146 + * The device driver-model tracks all of the drivers known to the system. 147 + * The main reason for this tracking is to enable the driver core to match 148 + * up drivers with new devices. Once drivers are known objects within the 149 + * system, however, a number of other things become possible. Device drivers 150 + * can export information and configuration variables that are independent 151 + * of any specific device. 152 + */ 154 153 struct device_driver { 155 154 const char *name; 156 155 struct bus_type *bus; ··· 248 185 struct device *start, void *data, 249 186 int (*match)(struct device *dev, void *data)); 250 187 251 - /* 252 - * device classes 188 + /** 189 + * struct class - device classes 190 + * @name: Name of the class. 191 + * @owner: The module owner. 192 + * @class_attrs: Default attributes of this class. 193 + * @dev_attrs: Default attributes of the devices belong to the class. 194 + * @dev_bin_attrs: Default binary attributes of the devices belong to the class. 195 + * @dev_kobj: The kobject that represents this class and links it into the hierarchy. 196 + * @dev_uevent: Called when a device is added, removed from this class, or a 197 + * few other things that generate uevents to add the environment 198 + * variables. 199 + * @devnode: Callback to provide the devtmpfs. 200 + * @class_release: Called to release this class. 201 + * @dev_release: Called to release the device. 202 + * @suspend: Used to put the device to sleep mode, usually to a low power 203 + * state. 204 + * @resume: Used to bring the device from the sleep mode. 205 + * @ns_type: Callbacks so sysfs can detemine namespaces. 206 + * @namespace: Namespace of the device belongs to this class. 207 + * @pm: The default device power management operations of this class. 208 + * @p: The private data of the driver core, no one other than the 209 + * driver core can touch this. 210 + * 211 + * A class is a higher-level view of a device that abstracts out low-level 212 + * implementation details. Drivers may see a SCSI disk or an ATA disk, but, 213 + * at the class level, they are all simply disks. Classes allow user space 214 + * to work with devices based on what they do, rather than how they are 215 + * connected or how they work. 253 216 */ 254 217 struct class { 255 218 const char *name; ··· 490 401 unsigned long segment_boundary_mask; 491 402 }; 492 403 404 + /** 405 + * struct device - The basic device structure 406 + * @parent: The device's "parent" device, the device to which it is attached. 407 + * In most cases, a parent device is some sort of bus or host 408 + * controller. If parent is NULL, the device, is a top-level device, 409 + * which is not usually what you want. 410 + * @p: Holds the private data of the driver core portions of the device. 411 + * See the comment of the struct device_private for detail. 412 + * @kobj: A top-level, abstract class from which other classes are derived. 413 + * @init_name: Initial name of the device. 414 + * @type: The type of device. 415 + * This identifies the device type and carries type-specific 416 + * information. 417 + * @mutex: Mutex to synchronize calls to its driver. 418 + * @bus: Type of bus device is on. 419 + * @driver: Which driver has allocated this 420 + * @platform_data: Platform data specific to the device. 421 + * Example: For devices on custom boards, as typical of embedded 422 + * and SOC based hardware, Linux often uses platform_data to point 423 + * to board-specific structures describing devices and how they 424 + * are wired. That can include what ports are available, chip 425 + * variants, which GPIO pins act in what additional roles, and so 426 + * on. This shrinks the "Board Support Packages" (BSPs) and 427 + * minimizes board-specific #ifdefs in drivers. 428 + * @power: For device power management. 429 + * See Documentation/power/devices.txt for details. 430 + * @pwr_domain: Provide callbacks that are executed during system suspend, 431 + * hibernation, system resume and during runtime PM transitions 432 + * along with subsystem-level and driver-level callbacks. 433 + * @numa_node: NUMA node this device is close to. 434 + * @dma_mask: Dma mask (if dma'ble device). 435 + * @coherent_dma_mask: Like dma_mask, but for alloc_coherent mapping as not all 436 + * hardware supports 64-bit addresses for consistent allocations 437 + * such descriptors. 438 + * @dma_parms: A low level driver may set these to teach IOMMU code about 439 + * segment limitations. 440 + * @dma_pools: Dma pools (if dma'ble device). 441 + * @dma_mem: Internal for coherent mem override. 442 + * @archdata: For arch-specific additions. 443 + * @of_node: Associated device tree node. 444 + * @of_match: Matching of_device_id from driver. 445 + * @devt: For creating the sysfs "dev". 446 + * @devres_lock: Spinlock to protect the resource of the device. 447 + * @devres_head: The resources list of the device. 448 + * @knode_class: The node used to add the device to the class list. 449 + * @class: The class of the device. 450 + * @groups: Optional attribute groups. 451 + * @release: Callback to free the device after all references have 452 + * gone away. This should be set by the allocator of the 453 + * device (i.e. the bus driver that discovered the device). 454 + * 455 + * At the lowest level, every device in a Linux system is represented by an 456 + * instance of struct device. The device structure contains the information 457 + * that the device model core needs to model the system. Most subsystems, 458 + * however, track additional information about the devices they host. As a 459 + * result, it is rare for devices to be represented by bare device structures; 460 + * instead, that structure, like kobject structures, is usually embedded within 461 + * a higher-level representation of the device. 462 + */ 493 463 struct device { 494 464 struct device *parent; 495 465 ··· 759 611 extern int (*platform_notify_remove)(struct device *dev); 760 612 761 613 762 - /** 614 + /* 763 615 * get_device - atomically increment the reference count for the device. 764 616 * 765 617 */