|
2 | 2 | The Basic Device Structure |
3 | 3 | ~~~~~~~~~~~~~~~~~~~~~~~~~~ |
4 | 4 |
|
5 | | -struct device { |
6 | | - struct list_head g_list; |
7 | | - struct list_head node; |
8 | | - struct list_head bus_list; |
9 | | - struct list_head driver_list; |
10 | | - struct list_head intf_list; |
11 | | - struct list_head children; |
12 | | - struct device * parent; |
13 | | - |
14 | | - char name[DEVICE_NAME_SIZE]; |
15 | | - char bus_id[BUS_ID_SIZE]; |
16 | | - |
17 | | - spinlock_t lock; |
18 | | - atomic_t refcount; |
19 | | - |
20 | | - struct bus_type * bus; |
21 | | - struct driver_dir_entry dir; |
22 | | - |
23 | | - u32 class_num; |
24 | | - |
25 | | - struct device_driver *driver; |
26 | | - void *driver_data; |
27 | | - void *platform_data; |
28 | | - |
29 | | - u32 current_state; |
30 | | - unsigned char *saved_state; |
31 | | - |
32 | | - void (*release)(struct device * dev); |
33 | | -}; |
34 | | - |
35 | | -Fields |
36 | | -~~~~~~ |
37 | | -g_list: Node in the global device list. |
38 | | - |
39 | | -node: Node in device's parent's children list. |
40 | | - |
41 | | -bus_list: Node in device's bus's devices list. |
42 | | - |
43 | | -driver_list: Node in device's driver's devices list. |
44 | | - |
45 | | -intf_list: List of intf_data. There is one structure allocated for |
46 | | - each interface that the device supports. |
47 | | - |
48 | | -children: List of child devices. |
49 | | - |
50 | | -parent: *** FIXME *** |
51 | | - |
52 | | -name: ASCII description of device. |
53 | | - Example: " 3Com Corporation 3c905 100BaseTX [Boomerang]" |
54 | | - |
55 | | -bus_id: ASCII representation of device's bus position. This |
56 | | - field should be a name unique across all devices on the |
57 | | - bus type the device belongs to. |
58 | | - |
59 | | - Example: PCI bus_ids are in the form of |
60 | | - <bus number>:<slot number>.<function number> |
61 | | - This name is unique across all PCI devices in the system. |
62 | | - |
63 | | -lock: Spinlock for the device. |
64 | | - |
65 | | -refcount: Reference count on the device. |
66 | | - |
67 | | -bus: Pointer to struct bus_type that device belongs to. |
68 | | - |
69 | | -dir: Device's sysfs directory. |
70 | | - |
71 | | -class_num: Class-enumerated value of the device. |
72 | | - |
73 | | -driver: Pointer to struct device_driver that controls the device. |
74 | | - |
75 | | -driver_data: Driver-specific data. |
76 | | - |
77 | | -platform_data: Platform data specific to the device. |
78 | | - |
79 | | - Example: for devices on custom boards, as typical of embedded |
80 | | - and SOC based hardware, Linux often uses platform_data to point |
81 | | - to board-specific structures describing devices and how they |
82 | | - are wired. That can include what ports are available, chip |
83 | | - variants, which GPIO pins act in what additional roles, and so |
84 | | - on. This shrinks the "Board Support Packages" (BSPs) and |
85 | | - minimizes board-specific #ifdefs in drivers. |
86 | | - |
87 | | -current_state: Current power state of the device. |
88 | | - |
89 | | -saved_state: Pointer to saved state of the device. This is usable by |
90 | | - the device driver controlling the device. |
91 | | - |
92 | | -release: Callback to free the device after all references have |
93 | | - gone away. This should be set by the allocator of the |
94 | | - device (i.e. the bus driver that discovered the device). |
| 5 | +See the kerneldoc for the struct device. |
95 | 6 |
|
96 | 7 |
|
97 | 8 | Programming Interface |
|
0 commit comments