28
28
#include <linux/overflow.h>
29
29
#include <linux/device/bus.h>
30
30
#include <linux/device/class.h>
31
+ #include <linux/device/driver.h>
31
32
#include <asm/device.h>
32
33
33
34
struct device ;
@@ -45,227 +46,6 @@ struct iommu_fwspec;
45
46
struct dev_pin_info ;
46
47
struct iommu_param ;
47
48
48
- /**
49
- * enum probe_type - device driver probe type to try
50
- * Device drivers may opt in for special handling of their
51
- * respective probe routines. This tells the core what to
52
- * expect and prefer.
53
- *
54
- * @PROBE_DEFAULT_STRATEGY: Used by drivers that work equally well
55
- * whether probed synchronously or asynchronously.
56
- * @PROBE_PREFER_ASYNCHRONOUS: Drivers for "slow" devices which
57
- * probing order is not essential for booting the system may
58
- * opt into executing their probes asynchronously.
59
- * @PROBE_FORCE_SYNCHRONOUS: Use this to annotate drivers that need
60
- * their probe routines to run synchronously with driver and
61
- * device registration (with the exception of -EPROBE_DEFER
62
- * handling - re-probing always ends up being done asynchronously).
63
- *
64
- * Note that the end goal is to switch the kernel to use asynchronous
65
- * probing by default, so annotating drivers with
66
- * %PROBE_PREFER_ASYNCHRONOUS is a temporary measure that allows us
67
- * to speed up boot process while we are validating the rest of the
68
- * drivers.
69
- */
70
- enum probe_type {
71
- PROBE_DEFAULT_STRATEGY ,
72
- PROBE_PREFER_ASYNCHRONOUS ,
73
- PROBE_FORCE_SYNCHRONOUS ,
74
- };
75
-
76
- /**
77
- * struct device_driver - The basic device driver structure
78
- * @name: Name of the device driver.
79
- * @bus: The bus which the device of this driver belongs to.
80
- * @owner: The module owner.
81
- * @mod_name: Used for built-in modules.
82
- * @suppress_bind_attrs: Disables bind/unbind via sysfs.
83
- * @probe_type: Type of the probe (synchronous or asynchronous) to use.
84
- * @of_match_table: The open firmware table.
85
- * @acpi_match_table: The ACPI match table.
86
- * @probe: Called to query the existence of a specific device,
87
- * whether this driver can work with it, and bind the driver
88
- * to a specific device.
89
- * @sync_state: Called to sync device state to software state after all the
90
- * state tracking consumers linked to this device (present at
91
- * the time of late_initcall) have successfully bound to a
92
- * driver. If the device has no consumers, this function will
93
- * be called at late_initcall_sync level. If the device has
94
- * consumers that are never bound to a driver, this function
95
- * will never get called until they do.
96
- * @remove: Called when the device is removed from the system to
97
- * unbind a device from this driver.
98
- * @shutdown: Called at shut-down time to quiesce the device.
99
- * @suspend: Called to put the device to sleep mode. Usually to a
100
- * low power state.
101
- * @resume: Called to bring a device from sleep mode.
102
- * @groups: Default attributes that get created by the driver core
103
- * automatically.
104
- * @dev_groups: Additional attributes attached to device instance once the
105
- * it is bound to the driver.
106
- * @pm: Power management operations of the device which matched
107
- * this driver.
108
- * @coredump: Called when sysfs entry is written to. The device driver
109
- * is expected to call the dev_coredump API resulting in a
110
- * uevent.
111
- * @p: Driver core's private data, no one other than the driver
112
- * core can touch this.
113
- *
114
- * The device driver-model tracks all of the drivers known to the system.
115
- * The main reason for this tracking is to enable the driver core to match
116
- * up drivers with new devices. Once drivers are known objects within the
117
- * system, however, a number of other things become possible. Device drivers
118
- * can export information and configuration variables that are independent
119
- * of any specific device.
120
- */
121
- struct device_driver {
122
- const char * name ;
123
- struct bus_type * bus ;
124
-
125
- struct module * owner ;
126
- const char * mod_name ; /* used for built-in modules */
127
-
128
- bool suppress_bind_attrs ; /* disables bind/unbind via sysfs */
129
- enum probe_type probe_type ;
130
-
131
- const struct of_device_id * of_match_table ;
132
- const struct acpi_device_id * acpi_match_table ;
133
-
134
- int (* probe ) (struct device * dev );
135
- void (* sync_state )(struct device * dev );
136
- int (* remove ) (struct device * dev );
137
- void (* shutdown ) (struct device * dev );
138
- int (* suspend ) (struct device * dev , pm_message_t state );
139
- int (* resume ) (struct device * dev );
140
- const struct attribute_group * * groups ;
141
- const struct attribute_group * * dev_groups ;
142
-
143
- const struct dev_pm_ops * pm ;
144
- void (* coredump ) (struct device * dev );
145
-
146
- struct driver_private * p ;
147
- };
148
-
149
-
150
- extern int __must_check driver_register (struct device_driver * drv );
151
- extern void driver_unregister (struct device_driver * drv );
152
-
153
- extern struct device_driver * driver_find (const char * name ,
154
- struct bus_type * bus );
155
- extern int driver_probe_done (void );
156
- extern void wait_for_device_probe (void );
157
-
158
- /* sysfs interface for exporting driver attributes */
159
-
160
- struct driver_attribute {
161
- struct attribute attr ;
162
- ssize_t (* show )(struct device_driver * driver , char * buf );
163
- ssize_t (* store )(struct device_driver * driver , const char * buf ,
164
- size_t count );
165
- };
166
-
167
- #define DRIVER_ATTR_RW (_name ) \
168
- struct driver_attribute driver_attr_##_name = __ATTR_RW(_name)
169
- #define DRIVER_ATTR_RO (_name ) \
170
- struct driver_attribute driver_attr_##_name = __ATTR_RO(_name)
171
- #define DRIVER_ATTR_WO (_name ) \
172
- struct driver_attribute driver_attr_##_name = __ATTR_WO(_name)
173
-
174
- extern int __must_check driver_create_file (struct device_driver * driver ,
175
- const struct driver_attribute * attr );
176
- extern void driver_remove_file (struct device_driver * driver ,
177
- const struct driver_attribute * attr );
178
-
179
- extern int __must_check driver_for_each_device (struct device_driver * drv ,
180
- struct device * start ,
181
- void * data ,
182
- int (* fn )(struct device * dev ,
183
- void * ));
184
- struct device * driver_find_device (struct device_driver * drv ,
185
- struct device * start , const void * data ,
186
- int (* match )(struct device * dev , const void * data ));
187
-
188
- /**
189
- * driver_find_device_by_name - device iterator for locating a particular device
190
- * of a specific name.
191
- * @drv: the driver we're iterating
192
- * @name: name of the device to match
193
- */
194
- static inline struct device * driver_find_device_by_name (struct device_driver * drv ,
195
- const char * name )
196
- {
197
- return driver_find_device (drv , NULL , name , device_match_name );
198
- }
199
-
200
- /**
201
- * driver_find_device_by_of_node- device iterator for locating a particular device
202
- * by of_node pointer.
203
- * @drv: the driver we're iterating
204
- * @np: of_node pointer to match.
205
- */
206
- static inline struct device *
207
- driver_find_device_by_of_node (struct device_driver * drv ,
208
- const struct device_node * np )
209
- {
210
- return driver_find_device (drv , NULL , np , device_match_of_node );
211
- }
212
-
213
- /**
214
- * driver_find_device_by_fwnode- device iterator for locating a particular device
215
- * by fwnode pointer.
216
- * @drv: the driver we're iterating
217
- * @fwnode: fwnode pointer to match.
218
- */
219
- static inline struct device *
220
- driver_find_device_by_fwnode (struct device_driver * drv ,
221
- const struct fwnode_handle * fwnode )
222
- {
223
- return driver_find_device (drv , NULL , fwnode , device_match_fwnode );
224
- }
225
-
226
- /**
227
- * driver_find_device_by_devt- device iterator for locating a particular device
228
- * by devt.
229
- * @drv: the driver we're iterating
230
- * @devt: devt pointer to match.
231
- */
232
- static inline struct device * driver_find_device_by_devt (struct device_driver * drv ,
233
- dev_t devt )
234
- {
235
- return driver_find_device (drv , NULL , & devt , device_match_devt );
236
- }
237
-
238
- static inline struct device * driver_find_next_device (struct device_driver * drv ,
239
- struct device * start )
240
- {
241
- return driver_find_device (drv , start , NULL , device_match_any );
242
- }
243
-
244
- #ifdef CONFIG_ACPI
245
- /**
246
- * driver_find_device_by_acpi_dev : device iterator for locating a particular
247
- * device matching the ACPI_COMPANION device.
248
- * @drv: the driver we're iterating
249
- * @adev: ACPI_COMPANION device to match.
250
- */
251
- static inline struct device *
252
- driver_find_device_by_acpi_dev (struct device_driver * drv ,
253
- const struct acpi_device * adev )
254
- {
255
- return driver_find_device (drv , NULL , adev , device_match_acpi_dev );
256
- }
257
- #else
258
- static inline struct device *
259
- driver_find_device_by_acpi_dev (struct device_driver * drv , const void * adev )
260
- {
261
- return NULL ;
262
- }
263
- #endif
264
-
265
- void driver_deferred_probe_add (struct device * dev );
266
- int driver_deferred_probe_check_state (struct device * dev );
267
- int driver_deferred_probe_check_state_continue (struct device * dev );
268
-
269
49
/**
270
50
* struct subsys_interface - interfaces to device functions
271
51
* @name: name of the device function
@@ -1018,8 +798,6 @@ static inline struct device_node *dev_of_node(struct device *dev)
1018
798
return dev -> of_node ;
1019
799
}
1020
800
1021
- void driver_init (void );
1022
-
1023
801
/*
1024
802
* High level routines for use by the bus drivers
1025
803
*/
@@ -1193,52 +971,4 @@ extern long sysfs_deprecated;
1193
971
#define sysfs_deprecated 0
1194
972
#endif
1195
973
1196
- /**
1197
- * module_driver() - Helper macro for drivers that don't do anything
1198
- * special in module init/exit. This eliminates a lot of boilerplate.
1199
- * Each module may only use this macro once, and calling it replaces
1200
- * module_init() and module_exit().
1201
- *
1202
- * @__driver: driver name
1203
- * @__register: register function for this driver type
1204
- * @__unregister: unregister function for this driver type
1205
- * @...: Additional arguments to be passed to __register and __unregister.
1206
- *
1207
- * Use this macro to construct bus specific macros for registering
1208
- * drivers, and do not use it on its own.
1209
- */
1210
- #define module_driver (__driver , __register , __unregister , ...) \
1211
- static int __init __driver ##_init (void ) \
1212
- { \
1213
- return __register (& (__driver ) , ##__VA_ARGS__ ); \
1214
- } \
1215
- module_init (__driver ##_init ); \
1216
- static void __exit __driver ##_exit (void ) \
1217
- { \
1218
- __unregister (& (__driver ) , ##__VA_ARGS__ ); \
1219
- } \
1220
- module_exit (__driver ##_exit );
1221
-
1222
- /**
1223
- * builtin_driver() - Helper macro for drivers that don't do anything
1224
- * special in init and have no exit. This eliminates some boilerplate.
1225
- * Each driver may only use this macro once, and calling it replaces
1226
- * device_initcall (or in some cases, the legacy __initcall). This is
1227
- * meant to be a direct parallel of module_driver() above but without
1228
- * the __exit stuff that is not used for builtin cases.
1229
- *
1230
- * @__driver: driver name
1231
- * @__register: register function for this driver type
1232
- * @...: Additional arguments to be passed to __register
1233
- *
1234
- * Use this macro to construct bus specific macros for registering
1235
- * drivers, and do not use it on its own.
1236
- */
1237
- #define builtin_driver (__driver , __register , ...) \
1238
- static int __init __driver##_init(void) \
1239
- { \
1240
- return __register(&(__driver) , ##__VA_ARGS__); \
1241
- } \
1242
- device_initcall(__driver##_init);
1243
-
1244
974
#endif /* _DEVICE_H_ */
0 commit comments