Blame view
include/linux/device.h
47.6 KB
1da177e4c Linux-2.6.12-rc2 |
1 2 3 4 |
/* * device.h - generic, centralized driver model * * Copyright (c) 2001-2003 Patrick Mochel <mochel@osdl.org> |
b40284378 Driver core: move... |
5 6 |
* Copyright (c) 2004-2009 Greg Kroah-Hartman <gregkh@suse.de> * Copyright (c) 2008-2009 Novell Inc. |
1da177e4c Linux-2.6.12-rc2 |
7 8 9 10 11 12 13 14 |
* * This file is released under the GPLv2 * * See Documentation/driver-model/ for more information. */ #ifndef _DEVICE_H_ #define _DEVICE_H_ |
1da177e4c Linux-2.6.12-rc2 |
15 16 |
#include <linux/ioport.h> #include <linux/kobject.h> |
465c7a3a3 [PATCH] Add a kli... |
17 |
#include <linux/klist.h> |
1da177e4c Linux-2.6.12-rc2 |
18 |
#include <linux/list.h> |
d2a3b9146 class: add lockde... |
19 |
#include <linux/lockdep.h> |
4a7fb6363 add __must_check ... |
20 |
#include <linux/compiler.h> |
1da177e4c Linux-2.6.12-rc2 |
21 |
#include <linux/types.h> |
de4772542 include: replace ... |
22 |
#include <linux/mutex.h> |
ab78029ec drivers/pinctrl: ... |
23 |
#include <linux/pinctrl/devinfo.h> |
1da177e4c Linux-2.6.12-rc2 |
24 |
#include <linux/pm.h> |
60063497a atomic: use <linu... |
25 |
#include <linux/atomic.h> |
6ca045930 driver core: Add ... |
26 |
#include <linux/ratelimit.h> |
3c2670e65 driver core: add ... |
27 |
#include <linux/uidgid.h> |
64c862a83 devres: add kerne... |
28 |
#include <linux/gfp.h> |
c6dbaef22 Driver core: add ... |
29 |
#include <asm/device.h> |
1da177e4c Linux-2.6.12-rc2 |
30 |
|
1da177e4c Linux-2.6.12-rc2 |
31 |
struct device; |
fb069a5d1 driver core: crea... |
32 |
struct device_private; |
1da177e4c Linux-2.6.12-rc2 |
33 |
struct device_driver; |
e5dd12784 Driver core: move... |
34 |
struct driver_private; |
de4772542 include: replace ... |
35 |
struct module; |
1da177e4c Linux-2.6.12-rc2 |
36 |
struct class; |
6b6e39a6a driver-core: merg... |
37 |
struct subsys_private; |
b8c5cec23 Driver core: udev... |
38 |
struct bus_type; |
d706c1b05 driver-core: Add ... |
39 |
struct device_node; |
ce793486e driver core / ACP... |
40 |
struct fwnode_handle; |
ff21776d1 Driver core: Add ... |
41 |
struct iommu_ops; |
74416e1e0 driver core: Add ... |
42 |
struct iommu_group; |
57f98d2f6 iommu: Introduce ... |
43 |
struct iommu_fwspec; |
b8c5cec23 Driver core: udev... |
44 45 46 |
struct bus_attribute { struct attribute attr; |
d462943af Driver core: fix ... |
47 48 |
ssize_t (*show)(struct bus_type *bus, char *buf); ssize_t (*store)(struct bus_type *bus, const char *buf, size_t count); |
b8c5cec23 Driver core: udev... |
49 |
}; |
d462943af Driver core: fix ... |
50 |
#define BUS_ATTR(_name, _mode, _show, _store) \ |
ced321bf9 driver core: devi... |
51 52 53 54 55 |
struct bus_attribute bus_attr_##_name = __ATTR(_name, _mode, _show, _store) #define BUS_ATTR_RW(_name) \ struct bus_attribute bus_attr_##_name = __ATTR_RW(_name) #define BUS_ATTR_RO(_name) \ struct bus_attribute bus_attr_##_name = __ATTR_RO(_name) |
b8c5cec23 Driver core: udev... |
56 57 58 59 |
extern int __must_check bus_create_file(struct bus_type *, struct bus_attribute *); extern void bus_remove_file(struct bus_type *, struct bus_attribute *); |
1da177e4c Linux-2.6.12-rc2 |
60 |
|
880ffb5c6 driver core: Add ... |
61 62 63 64 |
/** * struct bus_type - The bus type of the device * * @name: The name of the bus. |
ca22e56de driver-core: impl... |
65 66 |
* @dev_name: Used for subsystems to enumerate devices like ("foo%u", dev->id). * @dev_root: Default device to use as the parent. |
880ffb5c6 driver core: Add ... |
67 |
* @dev_attrs: Default attributes of the devices on the bus. |
12478ba07 driver core: bus_... |
68 |
* @bus_groups: Default attributes of the bus. |
fa6fdb33b driver core: bus_... |
69 |
* @dev_groups: Default attributes of the devices on the bus. |
ed0617b5c driver core: bus_... |
70 |
* @drv_groups: Default attributes of the device drivers on the bus. |
880ffb5c6 driver core: Add ... |
71 |
* @match: Called, perhaps multiple times, whenever a new device or driver |
656b8035b ARM: 8524/1: driv... |
72 73 74 75 76 |
* is added for this bus. It should return a positive value if the * given device can be handled by the given driver and zero * otherwise. It may also return error code if determining that * the driver supports the device is not possible. In case of * -EPROBE_DEFER it will queue the device for deferred probing. |
880ffb5c6 driver core: Add ... |
77 78 79 80 81 82 |
* @uevent: Called when a device is added, removed, or a few other things * that generate uevents to add the environment variables. * @probe: Called when a new device or driver add to this bus, and callback * the specific driver's probe to initial the matched device. * @remove: Called when a device removed from this bus. * @shutdown: Called at shut-down time to quiesce the device. |
4f3549d72 Driver core: Add ... |
83 84 85 86 |
* * @online: Called to put the device back online (after offlining it). * @offline: Called to put the device offline for hot-removal. May fail. * |
880ffb5c6 driver core: Add ... |
87 88 89 90 |
* @suspend: Called when a device on this bus wants to go to sleep mode. * @resume: Called to bring a device on this bus out of sleep mode. * @pm: Power management operations of this bus, callback the specific * device driver's pm-ops. |
7b08fae8f device.h: Fix str... |
91 |
* @iommu_ops: IOMMU specific operations for this bus, used to attach IOMMU |
ff21776d1 Driver core: Add ... |
92 93 |
* driver implementations to a bus and allow the driver to do * bus-specific setup |
880ffb5c6 driver core: Add ... |
94 95 |
* @p: The private data of the driver core, only the driver core can * touch this. |
bfd63cd24 driver core: devi... |
96 |
* @lock_key: Lock class key for use by the lock validator |
880ffb5c6 driver core: Add ... |
97 98 99 100 101 102 103 104 105 106 |
* * A bus is a channel between the processor and one or more devices. For the * purposes of the device model, all devices are connected via a bus, even if * it is an internal, virtual, "platform" bus. Buses can plug into each other. * A USB controller is usually a PCI device, for example. The device model * represents the actual connections between buses and the devices they control. * A bus is represented by the bus_type structure. It contains the name, the * default attributes, the bus' methods, PM operations, and the driver core's * private data. */ |
1da177e4c Linux-2.6.12-rc2 |
107 |
struct bus_type { |
d462943af Driver core: fix ... |
108 |
const char *name; |
ca22e56de driver-core: impl... |
109 110 |
const char *dev_name; struct device *dev_root; |
fa6fdb33b driver core: bus_... |
111 |
struct device_attribute *dev_attrs; /* use dev_groups instead */ |
12478ba07 driver core: bus_... |
112 |
const struct attribute_group **bus_groups; |
fa6fdb33b driver core: bus_... |
113 |
const struct attribute_group **dev_groups; |
ed0617b5c driver core: bus_... |
114 |
const struct attribute_group **drv_groups; |
d462943af Driver core: fix ... |
115 116 117 118 119 120 |
int (*match)(struct device *dev, struct device_driver *drv); int (*uevent)(struct device *dev, struct kobj_uevent_env *env); int (*probe)(struct device *dev); int (*remove)(struct device *dev); void (*shutdown)(struct device *dev); |
4f3549d72 Driver core: Add ... |
121 122 |
int (*online)(struct device *dev); int (*offline)(struct device *dev); |
d462943af Driver core: fix ... |
123 |
int (*suspend)(struct device *dev, pm_message_t state); |
d462943af Driver core: fix ... |
124 |
int (*resume)(struct device *dev); |
b8c5cec23 Driver core: udev... |
125 |
|
8150f32b9 Driver Core: Make... |
126 |
const struct dev_pm_ops *pm; |
1eede070a Introduce new top... |
127 |
|
b22f6434c iommu: Constify s... |
128 |
const struct iommu_ops *iommu_ops; |
ff21776d1 Driver core: Add ... |
129 |
|
6b6e39a6a driver-core: merg... |
130 |
struct subsys_private *p; |
be871b7e5 device: separate ... |
131 |
struct lock_class_key lock_key; |
1da177e4c Linux-2.6.12-rc2 |
132 |
}; |
be871b7e5 device: separate ... |
133 |
extern int __must_check bus_register(struct bus_type *bus); |
d462943af Driver core: fix ... |
134 |
extern void bus_unregister(struct bus_type *bus); |
1da177e4c Linux-2.6.12-rc2 |
135 |
|
d462943af Driver core: fix ... |
136 |
extern int __must_check bus_rescan_devices(struct bus_type *bus); |
1da177e4c Linux-2.6.12-rc2 |
137 |
|
1da177e4c Linux-2.6.12-rc2 |
138 |
/* iterator helpers for buses */ |
ca22e56de driver-core: impl... |
139 140 141 142 |
struct subsys_dev_iter { struct klist_iter ki; const struct device_type *type; }; |
7cd9c9bb5 Revert "driver co... |
143 |
void subsys_dev_iter_init(struct subsys_dev_iter *iter, |
ca22e56de driver-core: impl... |
144 145 146 147 148 |
struct bus_type *subsys, struct device *start, const struct device_type *type); struct device *subsys_dev_iter_next(struct subsys_dev_iter *iter); void subsys_dev_iter_exit(struct subsys_dev_iter *iter); |
1da177e4c Linux-2.6.12-rc2 |
149 |
|
d462943af Driver core: fix ... |
150 151 152 153 154 |
int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data, int (*fn)(struct device *dev, void *data)); struct device *bus_find_device(struct bus_type *bus, struct device *start, void *data, int (*match)(struct device *dev, void *data)); |
1f9ffc049 Driver core: add ... |
155 156 157 |
struct device *bus_find_device_by_name(struct bus_type *bus, struct device *start, const char *name); |
ca22e56de driver-core: impl... |
158 159 |
struct device *subsys_find_device_by_id(struct bus_type *bus, unsigned int id, struct device *hint); |
cc7447a5f Driver core: Drop... |
160 161 |
int bus_for_each_drv(struct bus_type *bus, struct device_driver *start, void *data, int (*fn)(struct device_driver *, void *)); |
99178b036 Driver core: add ... |
162 163 164 |
void bus_sort_breadthfirst(struct bus_type *bus, int (*compare)(const struct device *a, const struct device *b)); |
116af3782 Driver core: add ... |
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
/* * Bus notifiers: Get notified of addition/removal of devices * and binding/unbinding of drivers to devices. * In the long run, it should be a replacement for the platform * notify hooks. */ struct notifier_block; extern int bus_register_notifier(struct bus_type *bus, struct notifier_block *nb); extern int bus_unregister_notifier(struct bus_type *bus, struct notifier_block *nb); /* All 4 notifers below get called with the target struct device * * as an argument. Note that those functions are likely to be called |
8e9394ce2 Driver core: crea... |
180 |
* with the device lock held in the core, so be careful. |
116af3782 Driver core: add ... |
181 182 |
*/ #define BUS_NOTIFY_ADD_DEVICE 0x00000001 /* device added */ |
599bad38c driver core: Add ... |
183 184 185 |
#define BUS_NOTIFY_DEL_DEVICE 0x00000002 /* device to be removed */ #define BUS_NOTIFY_REMOVED_DEVICE 0x00000003 /* device removed */ #define BUS_NOTIFY_BIND_DRIVER 0x00000004 /* driver about to be |
45daef0fd Driver core: Add ... |
186 |
bound */ |
599bad38c driver core: Add ... |
187 188 |
#define BUS_NOTIFY_BOUND_DRIVER 0x00000005 /* driver bound to device */ #define BUS_NOTIFY_UNBIND_DRIVER 0x00000006 /* driver about to be |
116af3782 Driver core: add ... |
189 |
unbound */ |
599bad38c driver core: Add ... |
190 |
#define BUS_NOTIFY_UNBOUND_DRIVER 0x00000007 /* driver is unbound |
309b7d60a driver core: add ... |
191 |
from the device */ |
14b6257a5 device core: add ... |
192 |
#define BUS_NOTIFY_DRIVER_NOT_BOUND 0x00000008 /* driver fails to be bound */ |
116af3782 Driver core: add ... |
193 |
|
0fed80f7a driver core: add ... |
194 |
extern struct kset *bus_get_kset(struct bus_type *bus); |
b249072ee driver core: add ... |
195 |
extern struct klist *bus_get_device_klist(struct bus_type *bus); |
0fed80f7a driver core: add ... |
196 |
|
880ffb5c6 driver core: Add ... |
197 |
/** |
765230b5f driver-core: add ... |
198 199 200 201 202 |
* enum probe_type - device driver probe type to try * Device drivers may opt in for special handling of their * respective probe routines. This tells the core what to * expect and prefer. * |
d173a137c driver-core: enab... |
203 204 |
* @PROBE_DEFAULT_STRATEGY: Used by drivers that work equally well * whether probed synchronously or asynchronously. |
765230b5f driver-core: add ... |
205 206 207 |
* @PROBE_PREFER_ASYNCHRONOUS: Drivers for "slow" devices which * probing order is not essential for booting the system may * opt into executing their probes asynchronously. |
d173a137c driver-core: enab... |
208 209 210 211 |
* @PROBE_FORCE_SYNCHRONOUS: Use this to annotate drivers that need * their probe routines to run synchronously with driver and * device registration (with the exception of -EPROBE_DEFER * handling - re-probing always ends up being done asynchronously). |
765230b5f driver-core: add ... |
212 213 214 215 216 217 218 219 |
* * Note that the end goal is to switch the kernel to use asynchronous * probing by default, so annotating drivers with * %PROBE_PREFER_ASYNCHRONOUS is a temporary measure that allows us * to speed up boot process while we are validating the rest of the * drivers. */ enum probe_type { |
f2411da74 driver-core: add ... |
220 |
PROBE_DEFAULT_STRATEGY, |
765230b5f driver-core: add ... |
221 |
PROBE_PREFER_ASYNCHRONOUS, |
d173a137c driver-core: enab... |
222 |
PROBE_FORCE_SYNCHRONOUS, |
765230b5f driver-core: add ... |
223 224 225 |
}; /** |
880ffb5c6 driver core: Add ... |
226 227 228 229 230 231 |
* struct device_driver - The basic device driver structure * @name: Name of the device driver. * @bus: The bus which the device of this driver belongs to. * @owner: The module owner. * @mod_name: Used for built-in modules. * @suppress_bind_attrs: Disables bind/unbind via sysfs. |
765230b5f driver-core: add ... |
232 |
* @probe_type: Type of the probe (synchronous or asynchronous) to use. |
880ffb5c6 driver core: Add ... |
233 |
* @of_match_table: The open firmware table. |
06f64c8f2 driver core / ACP... |
234 |
* @acpi_match_table: The ACPI match table. |
880ffb5c6 driver core: Add ... |
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
* @probe: Called to query the existence of a specific device, * whether this driver can work with it, and bind the driver * to a specific device. * @remove: Called when the device is removed from the system to * unbind a device from this driver. * @shutdown: Called at shut-down time to quiesce the device. * @suspend: Called to put the device to sleep mode. Usually to a * low power state. * @resume: Called to bring a device from sleep mode. * @groups: Default attributes that get created by the driver core * automatically. * @pm: Power management operations of the device which matched * this driver. * @p: Driver core's private data, no one other than the driver * core can touch this. * * The device driver-model tracks all of the drivers known to the system. * The main reason for this tracking is to enable the driver core to match * up drivers with new devices. Once drivers are known objects within the * system, however, a number of other things become possible. Device drivers * can export information and configuration variables that are independent * of any specific device. */ |
1da177e4c Linux-2.6.12-rc2 |
258 |
struct device_driver { |
e5dd12784 Driver core: move... |
259 260 |
const char *name; struct bus_type *bus; |
1da177e4c Linux-2.6.12-rc2 |
261 |
|
e5dd12784 Driver core: move... |
262 |
struct module *owner; |
1a6f2a751 Driver core: allo... |
263 264 265 |
const char *mod_name; /* used for built-in modules */ bool suppress_bind_attrs; /* disables bind/unbind via sysfs */ |
765230b5f driver-core: add ... |
266 |
enum probe_type probe_type; |
1da177e4c Linux-2.6.12-rc2 |
267 |
|
597b9d1e4 drivercore: Add o... |
268 |
const struct of_device_id *of_match_table; |
06f64c8f2 driver core / ACP... |
269 |
const struct acpi_device_id *acpi_match_table; |
597b9d1e4 drivercore: Add o... |
270 |
|
d462943af Driver core: fix ... |
271 272 273 274 275 |
int (*probe) (struct device *dev); int (*remove) (struct device *dev); void (*shutdown) (struct device *dev); int (*suspend) (struct device *dev, pm_message_t state); int (*resume) (struct device *dev); |
a4dbd6740 driver model: con... |
276 |
const struct attribute_group **groups; |
e5dd12784 Driver core: move... |
277 |
|
8150f32b9 Driver Core: Make... |
278 |
const struct dev_pm_ops *pm; |
1eede070a Introduce new top... |
279 |
|
e5dd12784 Driver core: move... |
280 |
struct driver_private *p; |
1da177e4c Linux-2.6.12-rc2 |
281 |
}; |
d462943af Driver core: fix ... |
282 283 |
extern int __must_check driver_register(struct device_driver *drv); extern void driver_unregister(struct device_driver *drv); |
1da177e4c Linux-2.6.12-rc2 |
284 |
|
d462943af Driver core: fix ... |
285 286 |
extern struct device_driver *driver_find(const char *name, struct bus_type *bus); |
d779249ed Driver Core: add ... |
287 |
extern int driver_probe_done(void); |
b23530ebc driver core: remo... |
288 |
extern void wait_for_device_probe(void); |
216773a78 Consolidate drive... |
289 |
|
1da177e4c Linux-2.6.12-rc2 |
290 |
|
405ae7d38 Replace remaining... |
291 |
/* sysfs interface for exporting driver attributes */ |
1da177e4c Linux-2.6.12-rc2 |
292 293 |
struct driver_attribute { |
d462943af Driver core: fix ... |
294 295 296 297 |
struct attribute attr; ssize_t (*show)(struct device_driver *driver, char *buf); ssize_t (*store)(struct device_driver *driver, const char *buf, size_t count); |
1da177e4c Linux-2.6.12-rc2 |
298 |
}; |
ced321bf9 driver core: devi... |
299 300 301 302 303 304 |
#define DRIVER_ATTR(_name, _mode, _show, _store) \ struct driver_attribute driver_attr_##_name = __ATTR(_name, _mode, _show, _store) #define DRIVER_ATTR_RW(_name) \ struct driver_attribute driver_attr_##_name = __ATTR_RW(_name) #define DRIVER_ATTR_RO(_name) \ struct driver_attribute driver_attr_##_name = __ATTR_RO(_name) |
1130c55c7 driver core: crea... |
305 306 |
#define DRIVER_ATTR_WO(_name) \ struct driver_attribute driver_attr_##_name = __ATTR_WO(_name) |
1da177e4c Linux-2.6.12-rc2 |
307 |
|
d462943af Driver core: fix ... |
308 |
extern int __must_check driver_create_file(struct device_driver *driver, |
099c2f21d Driver core: driv... |
309 |
const struct driver_attribute *attr); |
d462943af Driver core: fix ... |
310 |
extern void driver_remove_file(struct device_driver *driver, |
099c2f21d Driver core: driv... |
311 |
const struct driver_attribute *attr); |
1da177e4c Linux-2.6.12-rc2 |
312 |
|
d462943af Driver core: fix ... |
313 314 315 316 317 318 319 320 |
extern int __must_check driver_for_each_device(struct device_driver *drv, struct device *start, void *data, int (*fn)(struct device *dev, void *)); struct device *driver_find_device(struct device_driver *drv, struct device *start, void *data, int (*match)(struct device *dev, void *data)); |
fae3cd002 [PATCH] Add drive... |
321 |
|
880ffb5c6 driver core: Add ... |
322 |
/** |
ca22e56de driver-core: impl... |
323 |
* struct subsys_interface - interfaces to device functions |
2eda013f4 kernel-doc: fix n... |
324 325 326 327 328 |
* @name: name of the device function * @subsys: subsytem of the devices to attach to * @node: the list of functions registered at the subsystem * @add_dev: device hookup to device function handler * @remove_dev: device hookup to device function handler |
ca22e56de driver-core: impl... |
329 330 331 332 333 334 335 336 337 338 339 |
* * Simple interfaces attached to a subsystem. Multiple interfaces can * attach to a subsystem and its devices. Unlike drivers, they do not * exclusively claim or control devices. Interfaces usually represent * a specific functionality of a subsystem/class of devices. */ struct subsys_interface { const char *name; struct bus_type *subsys; struct list_head node; int (*add_dev)(struct device *dev, struct subsys_interface *sif); |
71db87ba5 bus: subsys: upda... |
340 |
void (*remove_dev)(struct device *dev, struct subsys_interface *sif); |
ca22e56de driver-core: impl... |
341 342 343 344 345 346 347 |
}; int subsys_interface_register(struct subsys_interface *sif); void subsys_interface_unregister(struct subsys_interface *sif); int subsys_system_register(struct bus_type *subsys, const struct attribute_group **groups); |
d73ce0042 driver/base: impl... |
348 349 |
int subsys_virtual_register(struct bus_type *subsys, const struct attribute_group **groups); |
ca22e56de driver-core: impl... |
350 351 |
/** |
880ffb5c6 driver core: Add ... |
352 353 354 355 |
* struct class - device classes * @name: Name of the class. * @owner: The module owner. * @class_attrs: Default attributes of this class. |
d05a6f96c driver core: add ... |
356 |
* @dev_groups: Default attributes of the devices that belong to the class. |
880ffb5c6 driver core: Add ... |
357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 |
* @dev_kobj: The kobject that represents this class and links it into the hierarchy. * @dev_uevent: Called when a device is added, removed from this class, or a * few other things that generate uevents to add the environment * variables. * @devnode: Callback to provide the devtmpfs. * @class_release: Called to release this class. * @dev_release: Called to release the device. * @suspend: Used to put the device to sleep mode, usually to a low power * state. * @resume: Used to bring the device from the sleep mode. * @ns_type: Callbacks so sysfs can detemine namespaces. * @namespace: Namespace of the device belongs to this class. * @pm: The default device power management operations of this class. * @p: The private data of the driver core, no one other than the * driver core can touch this. * * A class is a higher-level view of a device that abstracts out low-level * implementation details. Drivers may see a SCSI disk or an ATA disk, but, * at the class level, they are all simply disks. Classes allow user space * to work with devices based on what they do, rather than how they are * connected or how they work. |
1da177e4c Linux-2.6.12-rc2 |
378 379 |
*/ struct class { |
d462943af Driver core: fix ... |
380 381 |
const char *name; struct module *owner; |
1da177e4c Linux-2.6.12-rc2 |
382 |
|
d462943af Driver core: fix ... |
383 |
struct class_attribute *class_attrs; |
d05a6f96c driver core: add ... |
384 |
const struct attribute_group **dev_groups; |
e105b8bfc sysfs: add /sys/d... |
385 |
struct kobject *dev_kobj; |
1da177e4c Linux-2.6.12-rc2 |
386 |
|
d462943af Driver core: fix ... |
387 |
int (*dev_uevent)(struct device *dev, struct kobj_uevent_env *env); |
2c9ede55e switch device_get... |
388 |
char *(*devnode)(struct device *dev, umode_t *mode); |
1da177e4c Linux-2.6.12-rc2 |
389 |
|
d462943af Driver core: fix ... |
390 391 |
void (*class_release)(struct class *class); void (*dev_release)(struct device *dev); |
7c8265f51 Suspend infrastru... |
392 |
|
d462943af Driver core: fix ... |
393 394 |
int (*suspend)(struct device *dev, pm_message_t state); int (*resume)(struct device *dev); |
1eede070a Introduce new top... |
395 |
|
bc451f205 kobj: Add basic i... |
396 397 |
const struct kobj_ns_type_operations *ns_type; const void *(*namespace)(struct device *dev); |
8150f32b9 Driver Core: Make... |
398 |
const struct dev_pm_ops *pm; |
6b6e39a6a driver-core: merg... |
399 |
struct subsys_private *p; |
1da177e4c Linux-2.6.12-rc2 |
400 |
}; |
5a3ceb861 driver-core: use ... |
401 402 403 404 |
struct class_dev_iter { struct klist_iter ki; const struct device_type *type; }; |
e105b8bfc sysfs: add /sys/d... |
405 406 |
extern struct kobject *sysfs_dev_block_kobj; extern struct kobject *sysfs_dev_char_kobj; |
d2a3b9146 class: add lockde... |
407 408 |
extern int __must_check __class_register(struct class *class, struct lock_class_key *key); |
d462943af Driver core: fix ... |
409 |
extern void class_unregister(struct class *class); |
d2a3b9146 class: add lockde... |
410 411 412 413 414 415 416 417 |
/* This is a #define to keep the compiler from merging different * instances of the __key variable */ #define class_register(class) \ ({ \ static struct lock_class_key __key; \ __class_register(class, &__key); \ }) |
462270944 Driver core: Add ... |
418 419 420 421 422 423 424 |
struct class_compat; struct class_compat *class_compat_register(const char *name); void class_compat_unregister(struct class_compat *cls); int class_compat_create_link(struct class_compat *cls, struct device *dev, struct device *device_link); void class_compat_remove_link(struct class_compat *cls, struct device *dev, struct device *device_link); |
7cd9c9bb5 Revert "driver co... |
425 426 427 428 |
extern void class_dev_iter_init(struct class_dev_iter *iter, struct class *class, struct device *start, const struct device_type *type); |
5a3ceb861 driver-core: use ... |
429 430 |
extern struct device *class_dev_iter_next(struct class_dev_iter *iter); extern void class_dev_iter_exit(struct class_dev_iter *iter); |
93562b537 Driver Core: add ... |
431 432 |
extern int class_for_each_device(struct class *class, struct device *start, void *data, |
fd04897bb Driver Core: add ... |
433 |
int (*fn)(struct device *dev, void *data)); |
695794ae0 Driver Core: add ... |
434 |
extern struct device *class_find_device(struct class *class, |
9f3b795a6 driver-core: cons... |
435 436 |
struct device *start, const void *data, int (*match)(struct device *, const void *)); |
1da177e4c Linux-2.6.12-rc2 |
437 438 |
struct class_attribute { |
d462943af Driver core: fix ... |
439 |
struct attribute attr; |
28812fe11 driver-core: Add ... |
440 441 442 443 |
ssize_t (*show)(struct class *class, struct class_attribute *attr, char *buf); ssize_t (*store)(struct class *class, struct class_attribute *attr, const char *buf, size_t count); |
1da177e4c Linux-2.6.12-rc2 |
444 |
}; |
ced321bf9 driver core: devi... |
445 446 447 448 449 450 |
#define CLASS_ATTR(_name, _mode, _show, _store) \ struct class_attribute class_attr_##_name = __ATTR(_name, _mode, _show, _store) #define CLASS_ATTR_RW(_name) \ struct class_attribute class_attr_##_name = __ATTR_RW(_name) #define CLASS_ATTR_RO(_name) \ struct class_attribute class_attr_##_name = __ATTR_RO(_name) |
1da177e4c Linux-2.6.12-rc2 |
451 |
|
58292cbe6 sysfs: make attr ... |
452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 |
extern int __must_check class_create_file_ns(struct class *class, const struct class_attribute *attr, const void *ns); extern void class_remove_file_ns(struct class *class, const struct class_attribute *attr, const void *ns); static inline int __must_check class_create_file(struct class *class, const struct class_attribute *attr) { return class_create_file_ns(class, attr, NULL); } static inline void class_remove_file(struct class *class, const struct class_attribute *attr) { return class_remove_file_ns(class, attr, NULL); } |
1da177e4c Linux-2.6.12-rc2 |
470 |
|
869dfc875 driver core: Add ... |
471 |
/* Simple class attribute that is just a static string */ |
869dfc875 driver core: Add ... |
472 473 474 475 476 477 478 479 480 481 482 483 484 485 |
struct class_attribute_string { struct class_attribute attr; char *str; }; /* Currently read-only only */ #define _CLASS_ATTR_STRING(_name, _mode, _str) \ { __ATTR(_name, _mode, show_class_attr_string, NULL), _str } #define CLASS_ATTR_STRING(_name, _mode, _str) \ struct class_attribute_string class_attr_##_name = \ _CLASS_ATTR_STRING(_name, _mode, _str) extern ssize_t show_class_attr_string(struct class *class, struct class_attribute *attr, char *buf); |
1da177e4c Linux-2.6.12-rc2 |
486 487 488 |
struct class_interface { struct list_head node; struct class *class; |
c47ed219b Class: add suppor... |
489 490 |
int (*add_dev) (struct device *, struct class_interface *); void (*remove_dev) (struct device *, struct class_interface *); |
1da177e4c Linux-2.6.12-rc2 |
491 |
}; |
4a7fb6363 add __must_check ... |
492 |
extern int __must_check class_interface_register(struct class_interface *); |
1da177e4c Linux-2.6.12-rc2 |
493 |
extern void class_interface_unregister(struct class_interface *); |
d2a3b9146 class: add lockde... |
494 495 496 |
extern struct class * __must_check __class_create(struct module *owner, const char *name, struct lock_class_key *key); |
e9ba6365f [PATCH] CLASS: mo... |
497 |
extern void class_destroy(struct class *cls); |
e9ba6365f [PATCH] CLASS: mo... |
498 |
|
d2a3b9146 class: add lockde... |
499 500 501 502 503 504 505 |
/* This is a #define to keep the compiler from merging different * instances of the __key variable */ #define class_create(owner, name) \ ({ \ static struct lock_class_key __key; \ __class_create(owner, name, &__key); \ }) |
414264f95 Driver core: add ... |
506 507 508 509 510 511 512 513 514 |
/* * The type of device, "struct device" is embedded in. A class * or bus can contain devices of different types * like "partitions" and "disks", "mouse" and "event". * This identifies the device type and carries type-specific * information, equivalent to the kobj_type of a kobject. * If "name" is specified, the uevent will contain it in * the DEVTYPE variable. */ |
f9f852df2 Driver core: add ... |
515 |
struct device_type { |
414264f95 Driver core: add ... |
516 |
const char *name; |
a4dbd6740 driver model: con... |
517 |
const struct attribute_group **groups; |
7eff2e7a8 Driver core: chan... |
518 |
int (*uevent)(struct device *dev, struct kobj_uevent_env *env); |
3c2670e65 driver core: add ... |
519 |
char *(*devnode)(struct device *dev, umode_t *mode, |
4e4098a3e driver core: hand... |
520 |
kuid_t *uid, kgid_t *gid); |
f9f852df2 Driver core: add ... |
521 |
void (*release)(struct device *dev); |
1eede070a Introduce new top... |
522 |
|
8150f32b9 Driver Core: Make... |
523 |
const struct dev_pm_ops *pm; |
f9f852df2 Driver core: add ... |
524 |
}; |
a7fd67062 [PATCH] add sysfs... |
525 526 527 528 529 530 531 532 |
/* interface for exporting device attributes */ struct device_attribute { struct attribute attr; ssize_t (*show)(struct device *dev, struct device_attribute *attr, char *buf); ssize_t (*store)(struct device *dev, struct device_attribute *attr, const char *buf, size_t count); }; |
ca22e56de driver-core: impl... |
533 534 535 536 537 538 539 540 541 542 543 544 545 |
struct dev_ext_attribute { struct device_attribute attr; void *var; }; ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr, char *buf); ssize_t device_store_ulong(struct device *dev, struct device_attribute *attr, const char *buf, size_t count); ssize_t device_show_int(struct device *dev, struct device_attribute *attr, char *buf); ssize_t device_store_int(struct device *dev, struct device_attribute *attr, const char *buf, size_t count); |
91872392f drivers/base: Add... |
546 547 548 549 |
ssize_t device_show_bool(struct device *dev, struct device_attribute *attr, char *buf); ssize_t device_store_bool(struct device *dev, struct device_attribute *attr, const char *buf, size_t count); |
a7fd67062 [PATCH] add sysfs... |
550 |
|
d462943af Driver core: fix ... |
551 |
#define DEVICE_ATTR(_name, _mode, _show, _store) \ |
ca22e56de driver-core: impl... |
552 |
struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show, _store) |
ced321bf9 driver core: devi... |
553 554 555 556 |
#define DEVICE_ATTR_RW(_name) \ struct device_attribute dev_attr_##_name = __ATTR_RW(_name) #define DEVICE_ATTR_RO(_name) \ struct device_attribute dev_attr_##_name = __ATTR_RO(_name) |
1130c55c7 driver core: crea... |
557 558 |
#define DEVICE_ATTR_WO(_name) \ struct device_attribute dev_attr_##_name = __ATTR_WO(_name) |
ca22e56de driver-core: impl... |
559 560 561 562 563 |
#define DEVICE_ULONG_ATTR(_name, _mode, _var) \ struct dev_ext_attribute dev_attr_##_name = \ { __ATTR(_name, _mode, device_show_ulong, device_store_ulong), &(_var) } #define DEVICE_INT_ATTR(_name, _mode, _var) \ struct dev_ext_attribute dev_attr_##_name = \ |
947581856 driver-core: fix ... |
564 |
{ __ATTR(_name, _mode, device_show_int, device_store_int), &(_var) } |
91872392f drivers/base: Add... |
565 566 567 |
#define DEVICE_BOOL_ATTR(_name, _mode, _var) \ struct dev_ext_attribute dev_attr_##_name = \ { __ATTR(_name, _mode, device_show_bool, device_store_bool), &(_var) } |
356c05d58 sysfs: get rid of... |
568 569 570 |
#define DEVICE_ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store) \ struct device_attribute dev_attr_##_name = \ __ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store) |
a7fd67062 [PATCH] add sysfs... |
571 |
|
b9d4e714a driver core: remo... |
572 573 |
extern int device_create_file(struct device *device, const struct device_attribute *entry); |
d462943af Driver core: fix ... |
574 |
extern void device_remove_file(struct device *dev, |
26579ab70 Driver core: devi... |
575 |
const struct device_attribute *attr); |
6b0afc2a2 kernfs, sysfs, dr... |
576 577 |
extern bool device_remove_file_self(struct device *dev, const struct device_attribute *attr); |
2589f1887 Driver core: add ... |
578 |
extern int __must_check device_create_bin_file(struct device *dev, |
66ecb92be Driver core: bin_... |
579 |
const struct bin_attribute *attr); |
2589f1887 Driver core: add ... |
580 |
extern void device_remove_bin_file(struct device *dev, |
66ecb92be Driver core: bin_... |
581 |
const struct bin_attribute *attr); |
9ac7849e3 devres: device re... |
582 583 584 585 586 587 |
/* device resource management */ typedef void (*dr_release_t)(struct device *dev, void *res); typedef int (*dr_match_t)(struct device *dev, void *res, void *match_data); #ifdef CONFIG_DEBUG_DEVRES |
7c683941f devm: make alloca... |
588 |
extern void *__devres_alloc_node(dr_release_t release, size_t size, gfp_t gfp, |
48a270554 include/linux: ap... |
589 |
int nid, const char *name) __malloc; |
9ac7849e3 devres: device re... |
590 |
#define devres_alloc(release, size, gfp) \ |
7c683941f devm: make alloca... |
591 592 593 |
__devres_alloc_node(release, size, gfp, NUMA_NO_NODE, #release) #define devres_alloc_node(release, size, gfp, nid) \ __devres_alloc_node(release, size, gfp, nid, #release) |
9ac7849e3 devres: device re... |
594 |
#else |
7c683941f devm: make alloca... |
595 |
extern void *devres_alloc_node(dr_release_t release, size_t size, gfp_t gfp, |
48a270554 include/linux: ap... |
596 |
int nid) __malloc; |
7c683941f devm: make alloca... |
597 598 599 600 |
static inline void *devres_alloc(dr_release_t release, size_t size, gfp_t gfp) { return devres_alloc_node(release, size, gfp, NUMA_NO_NODE); } |
9ac7849e3 devres: device re... |
601 |
#endif |
7c683941f devm: make alloca... |
602 |
|
bddb1b907 driver core: devr... |
603 604 605 606 |
extern void devres_for_each_res(struct device *dev, dr_release_t release, dr_match_t match, void *match_data, void (*fn)(struct device *, void *, void *), void *data); |
9ac7849e3 devres: device re... |
607 608 |
extern void devres_free(void *res); extern void devres_add(struct device *dev, void *res); |
d462943af Driver core: fix ... |
609 |
extern void *devres_find(struct device *dev, dr_release_t release, |
9ac7849e3 devres: device re... |
610 |
dr_match_t match, void *match_data); |
d462943af Driver core: fix ... |
611 612 613 614 |
extern void *devres_get(struct device *dev, void *new_res, dr_match_t match, void *match_data); extern void *devres_remove(struct device *dev, dr_release_t release, dr_match_t match, void *match_data); |
9ac7849e3 devres: device re... |
615 616 |
extern int devres_destroy(struct device *dev, dr_release_t release, dr_match_t match, void *match_data); |
d926d0e4c devres: Add devre... |
617 618 |
extern int devres_release(struct device *dev, dr_release_t release, dr_match_t match, void *match_data); |
9ac7849e3 devres: device re... |
619 620 621 622 623 624 625 |
/* devres group */ extern void * __must_check devres_open_group(struct device *dev, void *id, gfp_t gfp); extern void devres_close_group(struct device *dev, void *id); extern void devres_remove_group(struct device *dev, void *id); extern int devres_release_group(struct device *dev, void *id); |
64c862a83 devres: add kerne... |
626 |
/* managed devm_k.alloc/kfree for device drivers */ |
48a270554 include/linux: ap... |
627 |
extern void *devm_kmalloc(struct device *dev, size_t size, gfp_t gfp) __malloc; |
8db148606 include, lib: add... |
628 629 |
extern __printf(3, 0) char *devm_kvasprintf(struct device *dev, gfp_t gfp, const char *fmt, |
48a270554 include/linux: ap... |
630 |
va_list ap) __malloc; |
bef59c502 devres: Improve d... |
631 |
extern __printf(3, 4) |
48a270554 include/linux: ap... |
632 |
char *devm_kasprintf(struct device *dev, gfp_t gfp, const char *fmt, ...) __malloc; |
64c862a83 devres: add kerne... |
633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 |
static inline void *devm_kzalloc(struct device *dev, size_t size, gfp_t gfp) { return devm_kmalloc(dev, size, gfp | __GFP_ZERO); } static inline void *devm_kmalloc_array(struct device *dev, size_t n, size_t size, gfp_t flags) { if (size != 0 && n > SIZE_MAX / size) return NULL; return devm_kmalloc(dev, n * size, flags); } static inline void *devm_kcalloc(struct device *dev, size_t n, size_t size, gfp_t flags) { return devm_kmalloc_array(dev, n, size, flags | __GFP_ZERO); } |
9ac7849e3 devres: device re... |
649 |
extern void devm_kfree(struct device *dev, void *p); |
48a270554 include/linux: ap... |
650 |
extern char *devm_kstrdup(struct device *dev, const char *s, gfp_t gfp) __malloc; |
3046365bb devres: introduce... |
651 652 |
extern void *devm_kmemdup(struct device *dev, const void *src, size_t len, gfp_t gfp); |
9ac7849e3 devres: device re... |
653 |
|
43339bed7 devres: Add devm_... |
654 655 656 |
extern unsigned long devm_get_free_pages(struct device *dev, gfp_t gfp_mask, unsigned int order); extern void devm_free_pages(struct device *dev, unsigned long addr); |
9ac7849e3 devres: device re... |
657 |
|
75096579c lib: devres: Intr... |
658 |
void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res); |
72f8c0bfa lib: devres: add ... |
659 |
|
d6b0c5804 devres: allow add... |
660 661 662 |
/* allows to add/remove a custom action to devres stack */ int devm_add_action(struct device *dev, void (*action)(void *), void *data); void devm_remove_action(struct device *dev, void (*action)(void *), void *data); |
a3499e9bf devm: add helper ... |
663 664 665 666 667 668 669 670 671 672 673 |
static inline int devm_add_action_or_reset(struct device *dev, void (*action)(void *), void *data) { int ret; ret = devm_add_action(dev, action, data); if (ret) action(data); return ret; } |
6b7b65105 iommu sg merging:... |
674 675 676 677 678 679 680 681 |
struct device_dma_parameters { /* * a low level driver may set these to teach IOMMU code about * sg limitations. */ unsigned int max_segment_size; unsigned long segment_boundary_mask; }; |
880ffb5c6 driver core: Add ... |
682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 |
/** * struct device - The basic device structure * @parent: The device's "parent" 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. * @p: Holds the private data of the driver core portions of the device. * See the comment of the struct device_private for detail. * @kobj: A top-level, abstract class from which other classes are derived. * @init_name: Initial name of the device. * @type: The type of device. * This identifies the device type and carries type-specific * information. * @mutex: Mutex to synchronize calls to its driver. * @bus: Type of bus device is on. * @driver: Which driver has allocated this * @platform_data: Platform data specific to the device. * Example: 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 "Board Support Packages" (BSPs) and * minimizes board-specific #ifdefs in drivers. |
1bb6c08ab driver core: Move... |
706 |
* @driver_data: Private pointer for driver specific info. |
880ffb5c6 driver core: Add ... |
707 708 |
* @power: For device power management. * See Documentation/power/devices.txt for details. |
564b905ab PM / Domains: Ren... |
709 |
* @pm_domain: Provide callbacks that are executed during system suspend, |
880ffb5c6 driver core: Add ... |
710 711 |
* hibernation, system resume and during runtime PM transitions * along with subsystem-level and driver-level callbacks. |
ab78029ec drivers/pinctrl: ... |
712 713 |
* @pins: For device pin management. * See Documentation/pinctrl.txt for details. |
4a7cc8316 genirq/MSI: Move ... |
714 |
* @msi_list: Hosts MSI descriptors |
f1421db8c device core: Intr... |
715 |
* @msi_domain: The generic MSI domain this device is using. |
880ffb5c6 driver core: Add ... |
716 717 718 719 720 |
* @numa_node: NUMA node this device is close to. * @dma_mask: Dma mask (if dma'ble device). * @coherent_dma_mask: Like dma_mask, but for alloc_coherent mapping as not all * hardware supports 64-bit addresses for consistent allocations * such descriptors. |
8febcaa2a device: introduce... |
721 |
* @dma_pfn_offset: offset of DMA memory range relatively of RAM |
880ffb5c6 driver core: Add ... |
722 723 724 725 |
* @dma_parms: A low level driver may set these to teach IOMMU code about * segment limitations. * @dma_pools: Dma pools (if dma'ble device). * @dma_mem: Internal for coherent mem override. |
bfd63cd24 driver core: devi... |
726 |
* @cma_area: Contiguous memory area for dma allocations |
880ffb5c6 driver core: Add ... |
727 728 |
* @archdata: For arch-specific additions. * @of_node: Associated device tree node. |
ce793486e driver core / ACP... |
729 |
* @fwnode: Associated device node supplied by platform firmware. |
880ffb5c6 driver core: Add ... |
730 |
* @devt: For creating the sysfs "dev". |
2eda013f4 kernel-doc: fix n... |
731 |
* @id: device instance |
880ffb5c6 driver core: Add ... |
732 733 734 735 736 737 738 739 |
* @devres_lock: Spinlock to protect the resource of the device. * @devres_head: The resources list of the device. * @knode_class: The node used to add the device to the class list. * @class: The class of the device. * @groups: Optional attribute groups. * @release: 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). |
bfd63cd24 driver core: devi... |
740 |
* @iommu_group: IOMMU group the device belongs to. |
57f98d2f6 iommu: Introduce ... |
741 |
* @iommu_fwspec: IOMMU-specific properties supplied by firmware. |
880ffb5c6 driver core: Add ... |
742 |
* |
4f3549d72 Driver core: Add ... |
743 744 |
* @offline_disabled: If set, the device is permanently online. * @offline: Set after successful invocation of bus type's .offline(). |
880ffb5c6 driver core: Add ... |
745 746 747 748 749 750 751 752 753 |
* * 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. */ |
1da177e4c Linux-2.6.12-rc2 |
754 |
struct device { |
49a4ec188 fix hotplug for l... |
755 |
struct device *parent; |
1da177e4c Linux-2.6.12-rc2 |
756 |
|
fb069a5d1 driver core: crea... |
757 |
struct device_private *p; |
1da177e4c Linux-2.6.12-rc2 |
758 |
struct kobject kobj; |
c906a48ad driver core: add ... |
759 |
const char *init_name; /* initial name of the device */ |
aed65af1c drivers: make dev... |
760 |
const struct device_type *type; |
1da177e4c Linux-2.6.12-rc2 |
761 |
|
3142788b7 drivers/base: Con... |
762 |
struct mutex mutex; /* mutex to synchronize calls to |
af70316af [PATCH] Add a sem... |
763 764 |
* its driver. */ |
d462943af Driver core: fix ... |
765 |
struct bus_type *bus; /* type of bus device is on */ |
1da177e4c Linux-2.6.12-rc2 |
766 767 |
struct device_driver *driver; /* which driver has allocated this device */ |
e67c85626 Revert driver cor... |
768 769 |
void *platform_data; /* Platform specific data, device core doesn't touch it */ |
1bb6c08ab driver core: Move... |
770 771 |
void *driver_data; /* Driver data, set and get with dev_set/get_drvdata */ |
1da177e4c Linux-2.6.12-rc2 |
772 |
struct dev_pm_info power; |
564b905ab PM / Domains: Ren... |
773 |
struct dev_pm_domain *pm_domain; |
1da177e4c Linux-2.6.12-rc2 |
774 |
|
f1421db8c device core: Intr... |
775 776 777 |
#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN struct irq_domain *msi_domain; #endif |
ab78029ec drivers/pinctrl: ... |
778 779 780 |
#ifdef CONFIG_PINCTRL struct dev_pin_info *pins; #endif |
4a7cc8316 genirq/MSI: Move ... |
781 782 783 |
#ifdef CONFIG_GENERIC_MSI_IRQ struct list_head msi_list; #endif |
ab78029ec drivers/pinctrl: ... |
784 |
|
873481367 [PATCH] add numa ... |
785 786 787 |
#ifdef CONFIG_NUMA int numa_node; /* NUMA node this device is close to */ #endif |
1da177e4c Linux-2.6.12-rc2 |
788 789 790 791 792 793 |
u64 *dma_mask; /* dma mask (if dma'able device) */ u64 coherent_dma_mask;/* Like dma_mask, but for alloc_coherent mappings as not all hardware supports 64 bit addresses for consistent allocations such descriptors. */ |
8febcaa2a device: introduce... |
794 |
unsigned long dma_pfn_offset; |
1da177e4c Linux-2.6.12-rc2 |
795 |
|
6b7b65105 iommu sg merging:... |
796 |
struct device_dma_parameters *dma_parms; |
1da177e4c Linux-2.6.12-rc2 |
797 798 799 800 |
struct list_head dma_pools; /* dma pools (if dma'ble) */ struct dma_coherent_mem *dma_mem; /* internal for coherent mem override */ |
a25473803 drivers: dma-cont... |
801 |
#ifdef CONFIG_DMA_CMA |
c64be2bb1 drivers: add Cont... |
802 803 804 |
struct cma *cma_area; /* contiguous memory area for dma allocations */ #endif |
c6dbaef22 Driver core: add ... |
805 806 |
/* arch specific additions */ struct dev_archdata archdata; |
c9e358dfc driver-core: remo... |
807 808 |
struct device_node *of_node; /* associated device tree node */ |
ce793486e driver core / ACP... |
809 |
struct fwnode_handle *fwnode; /* firmware device node */ |
1da177e4c Linux-2.6.12-rc2 |
810 |
|
929d2fa59 driver core: Rear... |
811 |
dev_t devt; /* dev_t, creates the sysfs "dev" */ |
ca22e56de driver-core: impl... |
812 |
u32 id; /* device instance */ |
929d2fa59 driver core: Rear... |
813 |
|
9ac7849e3 devres: device re... |
814 815 |
spinlock_t devres_lock; struct list_head devres_head; |
5a3ceb861 driver-core: use ... |
816 |
struct klist_node knode_class; |
b7a3e813f Driver core: allo... |
817 |
struct class *class; |
a4dbd6740 driver model: con... |
818 |
const struct attribute_group **groups; /* optional groups */ |
23681e479 [PATCH] Driver co... |
819 |
|
d462943af Driver core: fix ... |
820 |
void (*release)(struct device *dev); |
74416e1e0 driver core: Add ... |
821 |
struct iommu_group *iommu_group; |
57f98d2f6 iommu: Introduce ... |
822 |
struct iommu_fwspec *iommu_fwspec; |
4f3549d72 Driver core: Add ... |
823 824 825 |
bool offline_disabled:1; bool offline:1; |
1da177e4c Linux-2.6.12-rc2 |
826 |
}; |
a42329637 driver-core: Move... |
827 828 829 830 |
static inline struct device *kobj_to_dev(struct kobject *kobj) { return container_of(kobj, struct device, kobj); } |
9a3df1f7d PM: Convert wakeu... |
831 832 |
/* Get the wakeup routines, which depend on struct device */ #include <linux/pm_wakeup.h> |
bf9ca69fc dev_printk(): con... |
833 |
static inline const char *dev_name(const struct device *dev) |
06916639e driver-core: add ... |
834 |
{ |
a636ee7fb driver core: Earl... |
835 836 837 |
/* Use the init name until the kobject becomes available */ if (dev->init_name) return dev->init_name; |
1fa5ae857 driver core: get ... |
838 |
return kobject_name(&dev->kobj); |
06916639e driver-core: add ... |
839 |
} |
b9075fa96 treewide: use __p... |
840 841 |
extern __printf(2, 3) int dev_set_name(struct device *dev, const char *name, ...); |
413c239fa driver-core: prep... |
842 |
|
873481367 [PATCH] add numa ... |
843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 |
#ifdef CONFIG_NUMA static inline int dev_to_node(struct device *dev) { return dev->numa_node; } static inline void set_dev_node(struct device *dev, int node) { dev->numa_node = node; } #else static inline int dev_to_node(struct device *dev) { return -1; } static inline void set_dev_node(struct device *dev, int node) { } #endif |
f1421db8c device core: Intr... |
861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 |
static inline struct irq_domain *dev_get_msi_domain(const struct device *dev) { #ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN return dev->msi_domain; #else return NULL; #endif } static inline void dev_set_msi_domain(struct device *dev, struct irq_domain *d) { #ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN dev->msi_domain = d; #endif } |
a996d010b driver core: Inli... |
876 877 878 879 880 881 882 883 884 |
static inline void *dev_get_drvdata(const struct device *dev) { return dev->driver_data; } static inline void dev_set_drvdata(struct device *dev, void *data) { dev->driver_data = data; } |
5c095a0e0 PM: Introduce str... |
885 886 887 888 |
static inline struct pm_subsys_data *dev_to_psd(struct device *dev) { return dev ? dev->power.subsys_data : NULL; } |
f67f129e5 Driver core: impl... |
889 890 891 892 893 894 895 896 897 |
static inline unsigned int dev_get_uevent_suppress(const struct device *dev) { return dev->kobj.uevent_suppress; } static inline void dev_set_uevent_suppress(struct device *dev, int val) { dev->kobj.uevent_suppress = val; } |
d305ef5d2 [PATCH] driver co... |
898 899 |
static inline int device_is_registered(struct device *dev) { |
3f62e5700 Driver core: make... |
900 |
return dev->kobj.state_in_sysfs; |
d305ef5d2 [PATCH] driver co... |
901 |
} |
5af84b827 PM: Asynchronous ... |
902 903 |
static inline void device_enable_async_suspend(struct device *dev) { |
f76b168b6 PM: Rename dev_pm... |
904 |
if (!dev->power.is_prepared) |
5af84b827 PM: Asynchronous ... |
905 906 |
dev->power.async_suspend = true; } |
5a2eb8585 PM: Add facility ... |
907 908 |
static inline void device_disable_async_suspend(struct device *dev) { |
f76b168b6 PM: Rename dev_pm... |
909 |
if (!dev->power.is_prepared) |
5a2eb8585 PM: Add facility ... |
910 911 912 913 914 915 916 |
dev->power.async_suspend = false; } static inline bool device_async_suspend_enabled(struct device *dev) { return !!dev->power.async_suspend; } |
feb70af0e PM: Do not use th... |
917 918 919 920 921 922 |
static inline void dev_pm_syscore_device(struct device *dev, bool val) { #ifdef CONFIG_PM_SLEEP dev->power.syscore = val; #endif } |
8e9394ce2 Driver core: crea... |
923 924 |
static inline void device_lock(struct device *dev) { |
3142788b7 drivers/base: Con... |
925 |
mutex_lock(&dev->mutex); |
8e9394ce2 Driver core: crea... |
926 |
} |
7dd9cba5b usb: sysfs: make ... |
927 928 929 930 |
static inline int device_lock_interruptible(struct device *dev) { return mutex_lock_interruptible(&dev->mutex); } |
8e9394ce2 Driver core: crea... |
931 932 |
static inline int device_trylock(struct device *dev) { |
3142788b7 drivers/base: Con... |
933 |
return mutex_trylock(&dev->mutex); |
8e9394ce2 Driver core: crea... |
934 935 936 937 |
} static inline void device_unlock(struct device *dev) { |
3142788b7 drivers/base: Con... |
938 |
mutex_unlock(&dev->mutex); |
8e9394ce2 Driver core: crea... |
939 |
} |
ac8010221 driver core: Prov... |
940 941 942 943 |
static inline void device_lock_assert(struct device *dev) { lockdep_assert_held(&dev->mutex); } |
e8a51e1b5 device: Add dev_o... |
944 945 946 947 948 949 |
static inline struct device_node *dev_of_node(struct device *dev) { if (!IS_ENABLED(CONFIG_OF)) return NULL; return dev->of_node; } |
1f21782e6 Driver core: prop... |
950 |
void driver_init(void); |
1da177e4c Linux-2.6.12-rc2 |
951 952 953 |
/* * High level routines for use by the bus drivers */ |
d462943af Driver core: fix ... |
954 955 956 957 958 959 960 |
extern int __must_check device_register(struct device *dev); extern void device_unregister(struct device *dev); extern void device_initialize(struct device *dev); extern int __must_check device_add(struct device *dev); extern void device_del(struct device *dev); extern int device_for_each_child(struct device *dev, void *data, int (*fn)(struct device *dev, void *data)); |
3d060aeb7 driver core: impl... |
961 962 |
extern int device_for_each_child_reverse(struct device *dev, void *data, int (*fn)(struct device *dev, void *data)); |
d462943af Driver core: fix ... |
963 964 |
extern struct device *device_find_child(struct device *dev, void *data, int (*match)(struct device *dev, void *data)); |
6937e8f8c driver core: devi... |
965 |
extern int device_rename(struct device *dev, const char *new_name); |
ffa6a7054 Driver core: Fix ... |
966 967 |
extern int device_move(struct device *dev, struct device *new_parent, enum dpm_order dpm_order); |
e454cea20 Driver-Core: exte... |
968 |
extern const char *device_get_devnode(struct device *dev, |
4e4098a3e driver core: hand... |
969 |
umode_t *mode, kuid_t *uid, kgid_t *gid, |
3c2670e65 driver core: add ... |
970 |
const char **tmp); |
1da177e4c Linux-2.6.12-rc2 |
971 |
|
4f3549d72 Driver core: Add ... |
972 973 974 975 976 977 978 |
static inline bool device_supports_offline(struct device *dev) { return dev->bus && dev->bus->offline && dev->bus->online; } extern void lock_device_hotplug(void); extern void unlock_device_hotplug(void); |
5e33bc416 driver core / ACP... |
979 |
extern int lock_device_hotplug_sysfs(void); |
4f3549d72 Driver core: Add ... |
980 981 |
extern int device_offline(struct device *dev); extern int device_online(struct device *dev); |
97badf873 device property: ... |
982 983 |
extern void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode); extern void set_secondary_fwnode(struct device *dev, struct fwnode_handle *fwnode); |
1da177e4c Linux-2.6.12-rc2 |
984 |
/* |
0aa0dc41b driver core: add ... |
985 986 987 988 |
* Root device objects for grouping under /sys/devices */ extern struct device *__root_device_register(const char *name, struct module *owner); |
eb5589a8f include: convert ... |
989 |
|
33ac1257f sysfs, driver-cor... |
990 |
/* This is a macro to avoid include problems with THIS_MODULE */ |
eb5589a8f include: convert ... |
991 992 |
#define root_device_register(name) \ __root_device_register(name, THIS_MODULE) |
0aa0dc41b driver core: add ... |
993 |
extern void root_device_unregister(struct device *root); |
a5b8b1ada Driver core: Add ... |
994 995 996 997 |
static inline void *dev_get_platdata(const struct device *dev) { return dev->platform_data; } |
0aa0dc41b driver core: add ... |
998 |
/* |
1da177e4c Linux-2.6.12-rc2 |
999 1000 1001 |
* Manual binding of a device to driver. See drivers/base/bus.c * for information on use. */ |
f86db396f drivers/base: che... |
1002 |
extern int __must_check device_bind_driver(struct device *dev); |
d462943af Driver core: fix ... |
1003 1004 |
extern void device_release_driver(struct device *dev); extern int __must_check device_attach(struct device *dev); |
f86db396f drivers/base: che... |
1005 |
extern int __must_check driver_attach(struct device_driver *drv); |
765230b5f driver-core: add ... |
1006 |
extern void device_initial_probe(struct device *dev); |
f86db396f drivers/base: che... |
1007 |
extern int __must_check device_reprobe(struct device *dev); |
1da177e4c Linux-2.6.12-rc2 |
1008 |
|
6b9cb4275 device core: add ... |
1009 |
extern bool device_is_bound(struct device *dev); |
23681e479 [PATCH] Driver co... |
1010 1011 1012 |
/* * Easy functions for dynamically creating devices on the fly */ |
8db148606 include, lib: add... |
1013 1014 1015 1016 |
extern __printf(5, 0) struct device *device_create_vargs(struct class *cls, struct device *parent, dev_t devt, void *drvdata, const char *fmt, va_list vargs); |
b9075fa96 treewide: use __p... |
1017 1018 1019 1020 |
extern __printf(5, 6) struct device *device_create(struct class *cls, struct device *parent, dev_t devt, void *drvdata, const char *fmt, ...); |
39ef31120 driver core: Intr... |
1021 1022 1023 1024 1025 |
extern __printf(6, 7) struct device *device_create_with_groups(struct class *cls, struct device *parent, dev_t devt, void *drvdata, const struct attribute_group **groups, const char *fmt, ...); |
23681e479 [PATCH] Driver co... |
1026 |
extern void device_destroy(struct class *cls, dev_t devt); |
1da177e4c Linux-2.6.12-rc2 |
1027 |
|
1da177e4c Linux-2.6.12-rc2 |
1028 1029 1030 1031 1032 1033 |
/* * Platform "fixup" functions - allow the platform to have their say * about devices and actions that the general device layer doesn't * know about. */ /* Notify platform of device discovery */ |
d462943af Driver core: fix ... |
1034 |
extern int (*platform_notify)(struct device *dev); |
1da177e4c Linux-2.6.12-rc2 |
1035 |
|
d462943af Driver core: fix ... |
1036 |
extern int (*platform_notify_remove)(struct device *dev); |
1da177e4c Linux-2.6.12-rc2 |
1037 |
|
880ffb5c6 driver core: Add ... |
1038 |
/* |
1da177e4c Linux-2.6.12-rc2 |
1039 1040 1041 |
* get_device - atomically increment the reference count for the device. * */ |
d462943af Driver core: fix ... |
1042 1043 |
extern struct device *get_device(struct device *dev); extern void put_device(struct device *dev); |
1da177e4c Linux-2.6.12-rc2 |
1044 |
|
2b2af54a5 Driver Core: devt... |
1045 1046 1047 |
#ifdef CONFIG_DEVTMPFS extern int devtmpfs_create_node(struct device *dev); extern int devtmpfs_delete_node(struct device *dev); |
073120cc2 Driver Core: devt... |
1048 |
extern int devtmpfs_mount(const char *mntdir); |
2b2af54a5 Driver Core: devt... |
1049 1050 1051 1052 1053 |
#else static inline int devtmpfs_create_node(struct device *dev) { return 0; } static inline int devtmpfs_delete_node(struct device *dev) { return 0; } static inline int devtmpfs_mount(const char *mountpoint) { return 0; } #endif |
116f232b3 fixed path to mov... |
1054 |
/* drivers/base/power/shutdown.c */ |
1da177e4c Linux-2.6.12-rc2 |
1055 |
extern void device_shutdown(void); |
1da177e4c Linux-2.6.12-rc2 |
1056 |
/* debugging and troubleshooting/diagnostic helpers. */ |
bf9ca69fc dev_printk(): con... |
1057 |
extern const char *dev_driver_string(const struct device *dev); |
99bcf2171 device.h drivers/... |
1058 1059 1060 |
#ifdef CONFIG_PRINTK |
0a18b0504 device.h: Add mis... |
1061 1062 1063 |
extern __printf(3, 0) int dev_vprintk_emit(int level, const struct device *dev, const char *fmt, va_list args); |
05e4e5b87 dev: Add dev_vpri... |
1064 1065 |
extern __printf(3, 4) int dev_printk_emit(int level, const struct device *dev, const char *fmt, ...); |
798efc60e dev_dbg/dynamic_d... |
1066 |
|
b9075fa96 treewide: use __p... |
1067 |
extern __printf(3, 4) |
d1f1052c5 device: Change de... |
1068 1069 |
void dev_printk(const char *level, const struct device *dev, const char *fmt, ...); |
b9075fa96 treewide: use __p... |
1070 |
extern __printf(2, 3) |
d1f1052c5 device: Change de... |
1071 |
void dev_emerg(const struct device *dev, const char *fmt, ...); |
b9075fa96 treewide: use __p... |
1072 |
extern __printf(2, 3) |
d1f1052c5 device: Change de... |
1073 |
void dev_alert(const struct device *dev, const char *fmt, ...); |
b9075fa96 treewide: use __p... |
1074 |
extern __printf(2, 3) |
d1f1052c5 device: Change de... |
1075 |
void dev_crit(const struct device *dev, const char *fmt, ...); |
b9075fa96 treewide: use __p... |
1076 |
extern __printf(2, 3) |
d1f1052c5 device: Change de... |
1077 |
void dev_err(const struct device *dev, const char *fmt, ...); |
b9075fa96 treewide: use __p... |
1078 |
extern __printf(2, 3) |
d1f1052c5 device: Change de... |
1079 |
void dev_warn(const struct device *dev, const char *fmt, ...); |
b9075fa96 treewide: use __p... |
1080 |
extern __printf(2, 3) |
d1f1052c5 device: Change de... |
1081 |
void dev_notice(const struct device *dev, const char *fmt, ...); |
b9075fa96 treewide: use __p... |
1082 |
extern __printf(2, 3) |
d1f1052c5 device: Change de... |
1083 |
void _dev_info(const struct device *dev, const char *fmt, ...); |
99bcf2171 device.h drivers/... |
1084 1085 |
#else |
0a18b0504 device.h: Add mis... |
1086 1087 1088 |
static inline __printf(3, 0) int dev_vprintk_emit(int level, const struct device *dev, const char *fmt, va_list args) |
05e4e5b87 dev: Add dev_vpri... |
1089 1090 1091 1092 |
{ return 0; } static inline __printf(3, 4) int dev_printk_emit(int level, const struct device *dev, const char *fmt, ...) { return 0; } |
d1f1052c5 device: Change de... |
1093 1094 1095 |
static inline void __dev_printk(const char *level, const struct device *dev, struct va_format *vaf) {} |
b9075fa96 treewide: use __p... |
1096 |
static inline __printf(3, 4) |
d1f1052c5 device: Change de... |
1097 1098 1099 |
void dev_printk(const char *level, const struct device *dev, const char *fmt, ...) {} |
b9075fa96 treewide: use __p... |
1100 1101 |
static inline __printf(2, 3) |
d1f1052c5 device: Change de... |
1102 1103 |
void dev_emerg(const struct device *dev, const char *fmt, ...) {} |
b9075fa96 treewide: use __p... |
1104 |
static inline __printf(2, 3) |
d1f1052c5 device: Change de... |
1105 1106 |
void dev_crit(const struct device *dev, const char *fmt, ...) {} |
b9075fa96 treewide: use __p... |
1107 |
static inline __printf(2, 3) |
d1f1052c5 device: Change de... |
1108 1109 |
void dev_alert(const struct device *dev, const char *fmt, ...) {} |
b9075fa96 treewide: use __p... |
1110 |
static inline __printf(2, 3) |
d1f1052c5 device: Change de... |
1111 1112 |
void dev_err(const struct device *dev, const char *fmt, ...) {} |
b9075fa96 treewide: use __p... |
1113 |
static inline __printf(2, 3) |
d1f1052c5 device: Change de... |
1114 1115 |
void dev_warn(const struct device *dev, const char *fmt, ...) {} |
b9075fa96 treewide: use __p... |
1116 |
static inline __printf(2, 3) |
d1f1052c5 device: Change de... |
1117 1118 |
void dev_notice(const struct device *dev, const char *fmt, ...) {} |
b9075fa96 treewide: use __p... |
1119 |
static inline __printf(2, 3) |
d1f1052c5 device: Change de... |
1120 1121 |
void _dev_info(const struct device *dev, const char *fmt, ...) {} |
99bcf2171 device.h drivers/... |
1122 1123 |
#endif |
6f586e663 driver-core: Shut... |
1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 |
/* * Stupid hackaround for existing uses of non-printk uses dev_info * * Note that the definition of dev_info below is actually _dev_info * and a macro is used to avoid redefining dev_info */ #define dev_info(dev, fmt, arg...) _dev_info(dev, fmt, ##arg) #if defined(CONFIG_DYNAMIC_DEBUG) #define dev_dbg(dev, format, ...) \ do { \ dynamic_dev_dbg(dev, format, ##__VA_ARGS__); \ } while (0) #elif defined(DEBUG) #define dev_dbg(dev, format, arg...) \ dev_printk(KERN_DEBUG, dev, format, ##arg) #else #define dev_dbg(dev, format, arg...) \ ({ \ if (0) \ dev_printk(KERN_DEBUG, dev, format, ##arg); \ |
6f586e663 driver-core: Shut... |
1146 1147 |
}) #endif |
e135303bd device: Add dev_<... |
1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 |
#ifdef CONFIG_PRINTK #define dev_level_once(dev_level, dev, fmt, ...) \ do { \ static bool __print_once __read_mostly; \ \ if (!__print_once) { \ __print_once = true; \ dev_level(dev, fmt, ##__VA_ARGS__); \ } \ } while (0) #else #define dev_level_once(dev_level, dev, fmt, ...) \ do { \ if (0) \ dev_level(dev, fmt, ##__VA_ARGS__); \ } while (0) #endif #define dev_emerg_once(dev, fmt, ...) \ dev_level_once(dev_emerg, dev, fmt, ##__VA_ARGS__) #define dev_alert_once(dev, fmt, ...) \ dev_level_once(dev_alert, dev, fmt, ##__VA_ARGS__) #define dev_crit_once(dev, fmt, ...) \ dev_level_once(dev_crit, dev, fmt, ##__VA_ARGS__) #define dev_err_once(dev, fmt, ...) \ dev_level_once(dev_err, dev, fmt, ##__VA_ARGS__) #define dev_warn_once(dev, fmt, ...) \ dev_level_once(dev_warn, dev, fmt, ##__VA_ARGS__) #define dev_notice_once(dev, fmt, ...) \ dev_level_once(dev_notice, dev, fmt, ##__VA_ARGS__) #define dev_info_once(dev, fmt, ...) \ dev_level_once(dev_info, dev, fmt, ##__VA_ARGS__) #define dev_dbg_once(dev, fmt, ...) \ |
a2a15d54a device: Fix dev_d... |
1181 |
dev_level_once(dev_dbg, dev, fmt, ##__VA_ARGS__) |
e135303bd device: Add dev_<... |
1182 |
|
6ca045930 driver core: Add ... |
1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 |
#define dev_level_ratelimited(dev_level, dev, fmt, ...) \ do { \ static DEFINE_RATELIMIT_STATE(_rs, \ DEFAULT_RATELIMIT_INTERVAL, \ DEFAULT_RATELIMIT_BURST); \ if (__ratelimit(&_rs)) \ dev_level(dev, fmt, ##__VA_ARGS__); \ } while (0) #define dev_emerg_ratelimited(dev, fmt, ...) \ dev_level_ratelimited(dev_emerg, dev, fmt, ##__VA_ARGS__) #define dev_alert_ratelimited(dev, fmt, ...) \ dev_level_ratelimited(dev_alert, dev, fmt, ##__VA_ARGS__) #define dev_crit_ratelimited(dev, fmt, ...) \ dev_level_ratelimited(dev_crit, dev, fmt, ##__VA_ARGS__) #define dev_err_ratelimited(dev, fmt, ...) \ dev_level_ratelimited(dev_err, dev, fmt, ##__VA_ARGS__) #define dev_warn_ratelimited(dev, fmt, ...) \ dev_level_ratelimited(dev_warn, dev, fmt, ##__VA_ARGS__) #define dev_notice_ratelimited(dev, fmt, ...) \ dev_level_ratelimited(dev_notice, dev, fmt, ##__VA_ARGS__) #define dev_info_ratelimited(dev, fmt, ...) \ dev_level_ratelimited(dev_info, dev, fmt, ##__VA_ARGS__) |
8ef2d6511 dev-core: fix bui... |
1206 1207 |
#if defined(CONFIG_DYNAMIC_DEBUG) /* descriptor check is first to prevent flooding with "callbacks suppressed" */ |
6ca045930 driver core: Add ... |
1208 |
#define dev_dbg_ratelimited(dev, fmt, ...) \ |
6f586e663 driver-core: Shut... |
1209 1210 1211 1212 1213 1214 1215 |
do { \ static DEFINE_RATELIMIT_STATE(_rs, \ DEFAULT_RATELIMIT_INTERVAL, \ DEFAULT_RATELIMIT_BURST); \ DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \ if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) && \ __ratelimit(&_rs)) \ |
8ef2d6511 dev-core: fix bui... |
1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 |
__dynamic_dev_dbg(&descriptor, dev, fmt, \ ##__VA_ARGS__); \ } while (0) #elif defined(DEBUG) #define dev_dbg_ratelimited(dev, fmt, ...) \ do { \ static DEFINE_RATELIMIT_STATE(_rs, \ DEFAULT_RATELIMIT_INTERVAL, \ DEFAULT_RATELIMIT_BURST); \ if (__ratelimit(&_rs)) \ dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); \ |
99bcf2171 device.h drivers/... |
1227 |
} while (0) |
1da177e4c Linux-2.6.12-rc2 |
1228 |
#else |
1f62ff34a driver-core: use ... |
1229 1230 1231 1232 1233 |
#define dev_dbg_ratelimited(dev, fmt, ...) \ do { \ if (0) \ dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); \ } while (0) |
1da177e4c Linux-2.6.12-rc2 |
1234 |
#endif |
aebdc3b45 dev_vdbg(), avail... |
1235 1236 1237 |
#ifdef VERBOSE_DEBUG #define dev_vdbg dev_dbg #else |
99bcf2171 device.h drivers/... |
1238 1239 1240 1241 |
#define dev_vdbg(dev, format, arg...) \ ({ \ if (0) \ dev_printk(KERN_DEBUG, dev, format, ##arg); \ |
99bcf2171 device.h drivers/... |
1242 |
}) |
aebdc3b45 dev_vdbg(), avail... |
1243 |
#endif |
e61396627 debug: Introduce ... |
1244 |
/* |
3eae13671 device: Make dev_... |
1245 1246 |
* dev_WARN*() acts like dev_printk(), but with the key difference of * using WARN/WARN_ONCE to include file/line information and a backtrace. |
e61396627 debug: Introduce ... |
1247 1248 |
*/ #define dev_WARN(dev, format, arg...) \ |
3eae13671 device: Make dev_... |
1249 |
WARN(1, "%s %s: " format, dev_driver_string(dev), dev_name(dev), ## arg); |
e61396627 debug: Introduce ... |
1250 |
|
bcdd323b8 device: add dev_W... |
1251 |
#define dev_WARN_ONCE(dev, condition, format, arg...) \ |
3eae13671 device: Make dev_... |
1252 1253 |
WARN_ONCE(condition, "%s %s: " format, \ dev_driver_string(dev), dev_name(dev), ## arg) |
bcdd323b8 device: add dev_W... |
1254 |
|
1da177e4c Linux-2.6.12-rc2 |
1255 1256 1257 1258 1259 |
/* Create alias, so I can be autoloaded. */ #define MODULE_ALIAS_CHARDEV(major,minor) \ MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor)) #define MODULE_ALIAS_CHARDEV_MAJOR(major) \ MODULE_ALIAS("char-major-" __stringify(major) "-*") |
e52eec13c SYSFS: Allow boot... |
1260 1261 1262 1263 1264 1265 |
#ifdef CONFIG_SYSFS_DEPRECATED extern long sysfs_deprecated; #else #define sysfs_deprecated 0 #endif |
907d0ed1c drivercore: Gener... |
1266 1267 1268 1269 1270 1271 |
/** * module_driver() - Helper macro for drivers that don't do anything * special in module init/exit. This eliminates a lot of boilerplate. * Each module may only use this macro once, and calling it replaces * module_init() and module_exit(). * |
2eda013f4 kernel-doc: fix n... |
1272 1273 1274 |
* @__driver: driver name * @__register: register function for this driver type * @__unregister: unregister function for this driver type |
cd4946188 driver-core: Allo... |
1275 |
* @...: Additional arguments to be passed to __register and __unregister. |
2eda013f4 kernel-doc: fix n... |
1276 |
* |
907d0ed1c drivercore: Gener... |
1277 1278 1279 |
* Use this macro to construct bus specific macros for registering * drivers, and do not use it on its own. */ |
cd4946188 driver-core: Allo... |
1280 |
#define module_driver(__driver, __register, __unregister, ...) \ |
907d0ed1c drivercore: Gener... |
1281 1282 |
static int __init __driver##_init(void) \ { \ |
cd4946188 driver-core: Allo... |
1283 |
return __register(&(__driver) , ##__VA_ARGS__); \ |
907d0ed1c drivercore: Gener... |
1284 1285 1286 1287 |
} \ module_init(__driver##_init); \ static void __exit __driver##_exit(void) \ { \ |
cd4946188 driver-core: Allo... |
1288 |
__unregister(&(__driver) , ##__VA_ARGS__); \ |
907d0ed1c drivercore: Gener... |
1289 1290 |
} \ module_exit(__driver##_exit); |
f309d4443 platform_device: ... |
1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 |
/** * builtin_driver() - Helper macro for drivers that don't do anything * special in init and have no exit. This eliminates some boilerplate. * Each driver may only use this macro once, and calling it replaces * device_initcall (or in some cases, the legacy __initcall). This is * meant to be a direct parallel of module_driver() above but without * the __exit stuff that is not used for builtin cases. * * @__driver: driver name * @__register: register function for this driver type * @...: Additional arguments to be passed to __register * * Use this macro to construct bus specific macros for registering * drivers, and do not use it on its own. */ #define builtin_driver(__driver, __register, ...) \ static int __init __driver##_init(void) \ { \ return __register(&(__driver) , ##__VA_ARGS__); \ } \ device_initcall(__driver##_init); |
1da177e4c Linux-2.6.12-rc2 |
1312 |
#endif /* _DEVICE_H_ */ |