Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * device.h - generic, centralized driver model |
| 3 | * |
| 4 | * Copyright (c) 2001-2003 Patrick Mochel <mochel@osdl.org> |
Greg Kroah-Hartman | b402843 | 2009-05-11 14:16:57 -0700 | [diff] [blame] | 5 | * Copyright (c) 2004-2009 Greg Kroah-Hartman <gregkh@suse.de> |
| 6 | * Copyright (c) 2008-2009 Novell Inc. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * |
| 8 | * This file is released under the GPLv2 |
| 9 | * |
| 10 | * See Documentation/driver-model/ for more information. |
| 11 | */ |
| 12 | |
| 13 | #ifndef _DEVICE_H_ |
| 14 | #define _DEVICE_H_ |
| 15 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include <linux/ioport.h> |
| 17 | #include <linux/kobject.h> |
mochel@digitalimplant.org | 465c7a3 | 2005-03-21 11:49:14 -0800 | [diff] [blame] | 18 | #include <linux/klist.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #include <linux/list.h> |
Matthew Wilcox | d2a3b91 | 2008-05-28 09:28:39 -0700 | [diff] [blame] | 20 | #include <linux/lockdep.h> |
Andrew Morton | 4a7fb63 | 2006-08-14 22:43:17 -0700 | [diff] [blame] | 21 | #include <linux/compiler.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | #include <linux/types.h> |
| 23 | #include <linux/module.h> |
| 24 | #include <linux/pm.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | #include <asm/atomic.h> |
Benjamin Herrenschmidt | c6dbaef | 2006-11-11 17:18:39 +1100 | [diff] [blame] | 26 | #include <asm/device.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | struct device; |
Greg Kroah-Hartman | fb069a5 | 2008-12-16 12:23:36 -0800 | [diff] [blame] | 29 | struct device_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | struct device_driver; |
Greg Kroah-Hartman | e5dd127 | 2007-11-28 15:59:15 -0800 | [diff] [blame] | 31 | struct driver_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | struct class; |
Kay Sievers | 6b6e39a | 2010-11-15 23:13:18 +0100 | [diff] [blame] | 33 | struct subsys_private; |
Kay Sievers | b8c5cec | 2007-02-16 17:33:36 +0100 | [diff] [blame] | 34 | struct bus_type; |
Grant Likely | d706c1b | 2010-04-13 16:12:28 -0700 | [diff] [blame] | 35 | struct device_node; |
Kay Sievers | b8c5cec | 2007-02-16 17:33:36 +0100 | [diff] [blame] | 36 | |
| 37 | struct bus_attribute { |
| 38 | struct attribute attr; |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 39 | ssize_t (*show)(struct bus_type *bus, char *buf); |
| 40 | ssize_t (*store)(struct bus_type *bus, const char *buf, size_t count); |
Kay Sievers | b8c5cec | 2007-02-16 17:33:36 +0100 | [diff] [blame] | 41 | }; |
| 42 | |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 43 | #define BUS_ATTR(_name, _mode, _show, _store) \ |
| 44 | struct bus_attribute bus_attr_##_name = __ATTR(_name, _mode, _show, _store) |
Kay Sievers | b8c5cec | 2007-02-16 17:33:36 +0100 | [diff] [blame] | 45 | |
| 46 | extern int __must_check bus_create_file(struct bus_type *, |
| 47 | struct bus_attribute *); |
| 48 | extern void bus_remove_file(struct bus_type *, struct bus_attribute *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | |
Wanlong Gao | 880ffb5 | 2011-05-05 07:55:36 +0800 | [diff] [blame] | 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 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | struct bus_type { |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 83 | const char *name; |
| 84 | struct bus_attribute *bus_attrs; |
| 85 | struct device_attribute *dev_attrs; |
| 86 | struct driver_attribute *drv_attrs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 88 | int (*match)(struct device *dev, struct device_driver *drv); |
| 89 | int (*uevent)(struct device *dev, struct kobj_uevent_env *env); |
| 90 | int (*probe)(struct device *dev); |
| 91 | int (*remove)(struct device *dev); |
| 92 | void (*shutdown)(struct device *dev); |
Linus Torvalds | 7c8265f | 2006-06-24 14:50:29 -0700 | [diff] [blame] | 93 | |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 94 | int (*suspend)(struct device *dev, pm_message_t state); |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 95 | int (*resume)(struct device *dev); |
Kay Sievers | b8c5cec | 2007-02-16 17:33:36 +0100 | [diff] [blame] | 96 | |
Dmitry Torokhov | 8150f32 | 2009-07-24 22:11:32 -0700 | [diff] [blame] | 97 | const struct dev_pm_ops *pm; |
Rafael J. Wysocki | 1eede07 | 2008-05-20 23:00:01 +0200 | [diff] [blame] | 98 | |
Kay Sievers | 6b6e39a | 2010-11-15 23:13:18 +0100 | [diff] [blame] | 99 | struct subsys_private *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | }; |
| 101 | |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 102 | extern int __must_check bus_register(struct bus_type *bus); |
| 103 | extern void bus_unregister(struct bus_type *bus); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 105 | extern int __must_check bus_rescan_devices(struct bus_type *bus); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | /* iterator helpers for buses */ |
| 108 | |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 109 | int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data, |
| 110 | int (*fn)(struct device *dev, void *data)); |
| 111 | struct device *bus_find_device(struct bus_type *bus, struct device *start, |
| 112 | void *data, |
| 113 | int (*match)(struct device *dev, void *data)); |
Greg Kroah-Hartman | 1f9ffc0 | 2008-01-27 10:29:20 -0800 | [diff] [blame] | 114 | struct device *bus_find_device_by_name(struct bus_type *bus, |
| 115 | struct device *start, |
| 116 | const char *name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | |
Jean Delvare | cc7447a | 2010-06-16 11:44:18 +0200 | [diff] [blame] | 118 | int bus_for_each_drv(struct bus_type *bus, struct device_driver *start, |
| 119 | void *data, int (*fn)(struct device_driver *, void *)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | |
Greg Kroah-Hartman | 99178b0 | 2008-08-26 11:00:57 -0500 | [diff] [blame] | 121 | void bus_sort_breadthfirst(struct bus_type *bus, |
| 122 | int (*compare)(const struct device *a, |
| 123 | const struct device *b)); |
Benjamin Herrenschmidt | 116af37 | 2006-10-25 13:44:59 +1000 | [diff] [blame] | 124 | /* |
| 125 | * Bus notifiers: Get notified of addition/removal of devices |
| 126 | * and binding/unbinding of drivers to devices. |
| 127 | * In the long run, it should be a replacement for the platform |
| 128 | * notify hooks. |
| 129 | */ |
| 130 | struct notifier_block; |
| 131 | |
| 132 | extern int bus_register_notifier(struct bus_type *bus, |
| 133 | struct notifier_block *nb); |
| 134 | extern int bus_unregister_notifier(struct bus_type *bus, |
| 135 | struct notifier_block *nb); |
| 136 | |
| 137 | /* All 4 notifers below get called with the target struct device * |
| 138 | * as an argument. Note that those functions are likely to be called |
Greg Kroah-Hartman | 8e9394c | 2010-02-17 10:57:05 -0800 | [diff] [blame] | 139 | * with the device lock held in the core, so be careful. |
Benjamin Herrenschmidt | 116af37 | 2006-10-25 13:44:59 +1000 | [diff] [blame] | 140 | */ |
| 141 | #define BUS_NOTIFY_ADD_DEVICE 0x00000001 /* device added */ |
| 142 | #define BUS_NOTIFY_DEL_DEVICE 0x00000002 /* device removed */ |
Magnus Damm | 45daef0 | 2010-07-23 19:56:18 +0900 | [diff] [blame] | 143 | #define BUS_NOTIFY_BIND_DRIVER 0x00000003 /* driver about to be |
| 144 | bound */ |
| 145 | #define BUS_NOTIFY_BOUND_DRIVER 0x00000004 /* driver bound to device */ |
| 146 | #define BUS_NOTIFY_UNBIND_DRIVER 0x00000005 /* driver about to be |
Benjamin Herrenschmidt | 116af37 | 2006-10-25 13:44:59 +1000 | [diff] [blame] | 147 | unbound */ |
Magnus Damm | 45daef0 | 2010-07-23 19:56:18 +0900 | [diff] [blame] | 148 | #define BUS_NOTIFY_UNBOUND_DRIVER 0x00000006 /* driver is unbound |
Joerg Roedel | 309b7d6 | 2009-04-24 14:57:00 +0200 | [diff] [blame] | 149 | from the device */ |
Benjamin Herrenschmidt | 116af37 | 2006-10-25 13:44:59 +1000 | [diff] [blame] | 150 | |
Greg Kroah-Hartman | 0fed80f | 2007-11-01 19:41:16 -0700 | [diff] [blame] | 151 | extern struct kset *bus_get_kset(struct bus_type *bus); |
Greg Kroah-Hartman | b249072 | 2007-11-01 19:41:16 -0700 | [diff] [blame] | 152 | extern struct klist *bus_get_device_klist(struct bus_type *bus); |
Greg Kroah-Hartman | 0fed80f | 2007-11-01 19:41:16 -0700 | [diff] [blame] | 153 | |
Wanlong Gao | 880ffb5 | 2011-05-05 07:55:36 +0800 | [diff] [blame] | 154 | /** |
| 155 | * struct device_driver - The basic device driver structure |
| 156 | * @name: Name of the device driver. |
| 157 | * @bus: The bus which the device of this driver belongs to. |
| 158 | * @owner: The module owner. |
| 159 | * @mod_name: Used for built-in modules. |
| 160 | * @suppress_bind_attrs: Disables bind/unbind via sysfs. |
| 161 | * @of_match_table: The open firmware table. |
| 162 | * @probe: Called to query the existence of a specific device, |
| 163 | * whether this driver can work with it, and bind the driver |
| 164 | * to a specific device. |
| 165 | * @remove: Called when the device is removed from the system to |
| 166 | * unbind a device from this driver. |
| 167 | * @shutdown: Called at shut-down time to quiesce the device. |
| 168 | * @suspend: Called to put the device to sleep mode. Usually to a |
| 169 | * low power state. |
| 170 | * @resume: Called to bring a device from sleep mode. |
| 171 | * @groups: Default attributes that get created by the driver core |
| 172 | * automatically. |
| 173 | * @pm: Power management operations of the device which matched |
| 174 | * this driver. |
| 175 | * @p: Driver core's private data, no one other than the driver |
| 176 | * core can touch this. |
| 177 | * |
| 178 | * The device driver-model tracks all of the drivers known to the system. |
| 179 | * The main reason for this tracking is to enable the driver core to match |
| 180 | * up drivers with new devices. Once drivers are known objects within the |
| 181 | * system, however, a number of other things become possible. Device drivers |
| 182 | * can export information and configuration variables that are independent |
| 183 | * of any specific device. |
| 184 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | struct device_driver { |
Greg Kroah-Hartman | e5dd127 | 2007-11-28 15:59:15 -0800 | [diff] [blame] | 186 | const char *name; |
| 187 | struct bus_type *bus; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | |
Greg Kroah-Hartman | e5dd127 | 2007-11-28 15:59:15 -0800 | [diff] [blame] | 189 | struct module *owner; |
Dmitry Torokhov | 1a6f2a7 | 2009-10-12 20:17:41 -0700 | [diff] [blame] | 190 | const char *mod_name; /* used for built-in modules */ |
| 191 | |
| 192 | bool suppress_bind_attrs; /* disables bind/unbind via sysfs */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | |
Grant Likely | 597b9d1 | 2010-04-13 16:13:01 -0700 | [diff] [blame] | 194 | const struct of_device_id *of_match_table; |
Grant Likely | 597b9d1 | 2010-04-13 16:13:01 -0700 | [diff] [blame] | 195 | |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 196 | int (*probe) (struct device *dev); |
| 197 | int (*remove) (struct device *dev); |
| 198 | void (*shutdown) (struct device *dev); |
| 199 | int (*suspend) (struct device *dev, pm_message_t state); |
| 200 | int (*resume) (struct device *dev); |
David Brownell | a4dbd67 | 2009-06-24 10:06:31 -0700 | [diff] [blame] | 201 | const struct attribute_group **groups; |
Greg Kroah-Hartman | e5dd127 | 2007-11-28 15:59:15 -0800 | [diff] [blame] | 202 | |
Dmitry Torokhov | 8150f32 | 2009-07-24 22:11:32 -0700 | [diff] [blame] | 203 | const struct dev_pm_ops *pm; |
Rafael J. Wysocki | 1eede07 | 2008-05-20 23:00:01 +0200 | [diff] [blame] | 204 | |
Greg Kroah-Hartman | e5dd127 | 2007-11-28 15:59:15 -0800 | [diff] [blame] | 205 | struct driver_private *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | }; |
| 207 | |
| 208 | |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 209 | extern int __must_check driver_register(struct device_driver *drv); |
| 210 | extern void driver_unregister(struct device_driver *drv); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 212 | extern struct device_driver *get_driver(struct device_driver *drv); |
| 213 | extern void put_driver(struct device_driver *drv); |
| 214 | extern struct device_driver *driver_find(const char *name, |
| 215 | struct bus_type *bus); |
Greg Kroah-Hartman | d779249 | 2006-07-18 10:59:59 -0700 | [diff] [blame] | 216 | extern int driver_probe_done(void); |
Ming Lei | b23530e | 2009-02-21 16:45:07 +0800 | [diff] [blame] | 217 | extern void wait_for_device_probe(void); |
Arjan van de Ven | 216773a | 2009-02-14 01:59:06 +0100 | [diff] [blame] | 218 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | |
Robert P. J. Day | 405ae7d | 2007-02-17 19:13:42 +0100 | [diff] [blame] | 220 | /* sysfs interface for exporting driver attributes */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | |
| 222 | struct driver_attribute { |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 223 | struct attribute attr; |
| 224 | ssize_t (*show)(struct device_driver *driver, char *buf); |
| 225 | ssize_t (*store)(struct device_driver *driver, const char *buf, |
| 226 | size_t count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | }; |
| 228 | |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 229 | #define DRIVER_ATTR(_name, _mode, _show, _store) \ |
| 230 | struct driver_attribute driver_attr_##_name = \ |
| 231 | __ATTR(_name, _mode, _show, _store) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 233 | extern int __must_check driver_create_file(struct device_driver *driver, |
Phil Carmody | 099c2f2 | 2009-12-18 15:34:21 +0200 | [diff] [blame] | 234 | const struct driver_attribute *attr); |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 235 | extern void driver_remove_file(struct device_driver *driver, |
Phil Carmody | 099c2f2 | 2009-12-18 15:34:21 +0200 | [diff] [blame] | 236 | const struct driver_attribute *attr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | |
Greg Kroah-Hartman | cbe9c59 | 2007-12-19 15:54:39 -0400 | [diff] [blame] | 238 | extern int __must_check driver_add_kobj(struct device_driver *drv, |
| 239 | struct kobject *kobj, |
| 240 | const char *fmt, ...); |
| 241 | |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 242 | extern int __must_check driver_for_each_device(struct device_driver *drv, |
| 243 | struct device *start, |
| 244 | void *data, |
| 245 | int (*fn)(struct device *dev, |
| 246 | void *)); |
| 247 | struct device *driver_find_device(struct device_driver *drv, |
| 248 | struct device *start, void *data, |
| 249 | int (*match)(struct device *dev, void *data)); |
mochel@digitalimplant.org | fae3cd0 | 2005-03-21 10:59:56 -0800 | [diff] [blame] | 250 | |
Wanlong Gao | 880ffb5 | 2011-05-05 07:55:36 +0800 | [diff] [blame] | 251 | /** |
| 252 | * struct class - device classes |
| 253 | * @name: Name of the class. |
| 254 | * @owner: The module owner. |
| 255 | * @class_attrs: Default attributes of this class. |
| 256 | * @dev_attrs: Default attributes of the devices belong to the class. |
| 257 | * @dev_bin_attrs: Default binary attributes of the devices belong to the class. |
| 258 | * @dev_kobj: The kobject that represents this class and links it into the hierarchy. |
| 259 | * @dev_uevent: Called when a device is added, removed from this class, or a |
| 260 | * few other things that generate uevents to add the environment |
| 261 | * variables. |
| 262 | * @devnode: Callback to provide the devtmpfs. |
| 263 | * @class_release: Called to release this class. |
| 264 | * @dev_release: Called to release the device. |
| 265 | * @suspend: Used to put the device to sleep mode, usually to a low power |
| 266 | * state. |
| 267 | * @resume: Used to bring the device from the sleep mode. |
| 268 | * @ns_type: Callbacks so sysfs can detemine namespaces. |
| 269 | * @namespace: Namespace of the device belongs to this class. |
| 270 | * @pm: The default device power management operations of this class. |
| 271 | * @p: The private data of the driver core, no one other than the |
| 272 | * driver core can touch this. |
| 273 | * |
| 274 | * A class is a higher-level view of a device that abstracts out low-level |
| 275 | * implementation details. Drivers may see a SCSI disk or an ATA disk, but, |
| 276 | * at the class level, they are all simply disks. Classes allow user space |
| 277 | * to work with devices based on what they do, rather than how they are |
| 278 | * connected or how they work. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | */ |
| 280 | struct class { |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 281 | const char *name; |
| 282 | struct module *owner; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 284 | struct class_attribute *class_attrs; |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 285 | struct device_attribute *dev_attrs; |
Stefan Achatz | c97415a | 2010-11-26 19:57:29 +0000 | [diff] [blame] | 286 | struct bin_attribute *dev_bin_attrs; |
Dan Williams | e105b8b | 2008-04-21 10:51:07 -0700 | [diff] [blame] | 287 | struct kobject *dev_kobj; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 289 | int (*dev_uevent)(struct device *dev, struct kobj_uevent_env *env); |
Kay Sievers | e454cea | 2009-09-18 23:01:12 +0200 | [diff] [blame] | 290 | char *(*devnode)(struct device *dev, mode_t *mode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 292 | void (*class_release)(struct class *class); |
| 293 | void (*dev_release)(struct device *dev); |
Linus Torvalds | 7c8265f | 2006-06-24 14:50:29 -0700 | [diff] [blame] | 294 | |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 295 | int (*suspend)(struct device *dev, pm_message_t state); |
| 296 | int (*resume)(struct device *dev); |
Rafael J. Wysocki | 1eede07 | 2008-05-20 23:00:01 +0200 | [diff] [blame] | 297 | |
Eric W. Biederman | bc451f2 | 2010-03-30 11:31:25 -0700 | [diff] [blame] | 298 | const struct kobj_ns_type_operations *ns_type; |
| 299 | const void *(*namespace)(struct device *dev); |
| 300 | |
Dmitry Torokhov | 8150f32 | 2009-07-24 22:11:32 -0700 | [diff] [blame] | 301 | const struct dev_pm_ops *pm; |
| 302 | |
Kay Sievers | 6b6e39a | 2010-11-15 23:13:18 +0100 | [diff] [blame] | 303 | struct subsys_private *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | }; |
| 305 | |
Tejun Heo | 5a3ceb8 | 2008-08-25 19:50:19 +0200 | [diff] [blame] | 306 | struct class_dev_iter { |
| 307 | struct klist_iter ki; |
| 308 | const struct device_type *type; |
| 309 | }; |
| 310 | |
Dan Williams | e105b8b | 2008-04-21 10:51:07 -0700 | [diff] [blame] | 311 | extern struct kobject *sysfs_dev_block_kobj; |
| 312 | extern struct kobject *sysfs_dev_char_kobj; |
Matthew Wilcox | d2a3b91 | 2008-05-28 09:28:39 -0700 | [diff] [blame] | 313 | extern int __must_check __class_register(struct class *class, |
| 314 | struct lock_class_key *key); |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 315 | extern void class_unregister(struct class *class); |
Matthew Wilcox | d2a3b91 | 2008-05-28 09:28:39 -0700 | [diff] [blame] | 316 | |
| 317 | /* This is a #define to keep the compiler from merging different |
| 318 | * instances of the __key variable */ |
| 319 | #define class_register(class) \ |
| 320 | ({ \ |
| 321 | static struct lock_class_key __key; \ |
| 322 | __class_register(class, &__key); \ |
| 323 | }) |
| 324 | |
Jean Delvare | 4622709 | 2009-08-04 12:55:34 +0200 | [diff] [blame] | 325 | struct class_compat; |
| 326 | struct class_compat *class_compat_register(const char *name); |
| 327 | void class_compat_unregister(struct class_compat *cls); |
| 328 | int class_compat_create_link(struct class_compat *cls, struct device *dev, |
| 329 | struct device *device_link); |
| 330 | void class_compat_remove_link(struct class_compat *cls, struct device *dev, |
| 331 | struct device *device_link); |
| 332 | |
Tejun Heo | 5a3ceb8 | 2008-08-25 19:50:19 +0200 | [diff] [blame] | 333 | extern void class_dev_iter_init(struct class_dev_iter *iter, |
| 334 | struct class *class, |
| 335 | struct device *start, |
| 336 | const struct device_type *type); |
| 337 | extern struct device *class_dev_iter_next(struct class_dev_iter *iter); |
| 338 | extern void class_dev_iter_exit(struct class_dev_iter *iter); |
| 339 | |
Greg Kroah-Hartman | 93562b5 | 2008-05-22 17:21:08 -0400 | [diff] [blame] | 340 | extern int class_for_each_device(struct class *class, struct device *start, |
| 341 | void *data, |
Dave Young | fd04897 | 2008-01-22 15:27:08 +0800 | [diff] [blame] | 342 | int (*fn)(struct device *dev, void *data)); |
Greg Kroah-Hartman | 695794a | 2008-05-22 17:21:08 -0400 | [diff] [blame] | 343 | extern struct device *class_find_device(struct class *class, |
| 344 | struct device *start, void *data, |
Dave Young | fd04897 | 2008-01-22 15:27:08 +0800 | [diff] [blame] | 345 | int (*match)(struct device *, void *)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 346 | |
| 347 | struct class_attribute { |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 348 | struct attribute attr; |
Andi Kleen | 28812fe | 2010-01-05 12:48:07 +0100 | [diff] [blame] | 349 | ssize_t (*show)(struct class *class, struct class_attribute *attr, |
| 350 | char *buf); |
| 351 | ssize_t (*store)(struct class *class, struct class_attribute *attr, |
| 352 | const char *buf, size_t count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | }; |
| 354 | |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 355 | #define CLASS_ATTR(_name, _mode, _show, _store) \ |
| 356 | struct class_attribute class_attr_##_name = __ATTR(_name, _mode, _show, _store) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 357 | |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 358 | extern int __must_check class_create_file(struct class *class, |
| 359 | const struct class_attribute *attr); |
| 360 | extern void class_remove_file(struct class *class, |
| 361 | const struct class_attribute *attr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 | |
Andi Kleen | 869dfc8 | 2010-01-05 12:48:08 +0100 | [diff] [blame] | 363 | /* Simple class attribute that is just a static string */ |
| 364 | |
| 365 | struct class_attribute_string { |
| 366 | struct class_attribute attr; |
| 367 | char *str; |
| 368 | }; |
| 369 | |
| 370 | /* Currently read-only only */ |
| 371 | #define _CLASS_ATTR_STRING(_name, _mode, _str) \ |
| 372 | { __ATTR(_name, _mode, show_class_attr_string, NULL), _str } |
| 373 | #define CLASS_ATTR_STRING(_name, _mode, _str) \ |
| 374 | struct class_attribute_string class_attr_##_name = \ |
| 375 | _CLASS_ATTR_STRING(_name, _mode, _str) |
| 376 | |
| 377 | extern ssize_t show_class_attr_string(struct class *class, struct class_attribute *attr, |
| 378 | char *buf); |
| 379 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 380 | struct class_interface { |
| 381 | struct list_head node; |
| 382 | struct class *class; |
| 383 | |
Greg Kroah-Hartman | c47ed21 | 2006-09-13 15:34:05 +0200 | [diff] [blame] | 384 | int (*add_dev) (struct device *, struct class_interface *); |
| 385 | void (*remove_dev) (struct device *, struct class_interface *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | }; |
| 387 | |
Andrew Morton | 4a7fb63 | 2006-08-14 22:43:17 -0700 | [diff] [blame] | 388 | extern int __must_check class_interface_register(struct class_interface *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | extern void class_interface_unregister(struct class_interface *); |
| 390 | |
Matthew Wilcox | d2a3b91 | 2008-05-28 09:28:39 -0700 | [diff] [blame] | 391 | extern struct class * __must_check __class_create(struct module *owner, |
| 392 | const char *name, |
| 393 | struct lock_class_key *key); |
gregkh@suse.de | e9ba636 | 2005-03-15 11:54:21 -0800 | [diff] [blame] | 394 | extern void class_destroy(struct class *cls); |
gregkh@suse.de | e9ba636 | 2005-03-15 11:54:21 -0800 | [diff] [blame] | 395 | |
Matthew Wilcox | d2a3b91 | 2008-05-28 09:28:39 -0700 | [diff] [blame] | 396 | /* This is a #define to keep the compiler from merging different |
| 397 | * instances of the __key variable */ |
| 398 | #define class_create(owner, name) \ |
| 399 | ({ \ |
| 400 | static struct lock_class_key __key; \ |
| 401 | __class_create(owner, name, &__key); \ |
| 402 | }) |
| 403 | |
Kay Sievers | 414264f | 2007-03-12 21:08:57 +0100 | [diff] [blame] | 404 | /* |
| 405 | * The type of device, "struct device" is embedded in. A class |
| 406 | * or bus can contain devices of different types |
| 407 | * like "partitions" and "disks", "mouse" and "event". |
| 408 | * This identifies the device type and carries type-specific |
| 409 | * information, equivalent to the kobj_type of a kobject. |
| 410 | * If "name" is specified, the uevent will contain it in |
| 411 | * the DEVTYPE variable. |
| 412 | */ |
Kay Sievers | f9f852d | 2006-10-07 21:54:55 +0200 | [diff] [blame] | 413 | struct device_type { |
Kay Sievers | 414264f | 2007-03-12 21:08:57 +0100 | [diff] [blame] | 414 | const char *name; |
David Brownell | a4dbd67 | 2009-06-24 10:06:31 -0700 | [diff] [blame] | 415 | const struct attribute_group **groups; |
Kay Sievers | 7eff2e7 | 2007-08-14 15:15:12 +0200 | [diff] [blame] | 416 | int (*uevent)(struct device *dev, struct kobj_uevent_env *env); |
Kay Sievers | e454cea | 2009-09-18 23:01:12 +0200 | [diff] [blame] | 417 | char *(*devnode)(struct device *dev, mode_t *mode); |
Kay Sievers | f9f852d | 2006-10-07 21:54:55 +0200 | [diff] [blame] | 418 | void (*release)(struct device *dev); |
Rafael J. Wysocki | 1eede07 | 2008-05-20 23:00:01 +0200 | [diff] [blame] | 419 | |
Dmitry Torokhov | 8150f32 | 2009-07-24 22:11:32 -0700 | [diff] [blame] | 420 | const struct dev_pm_ops *pm; |
Kay Sievers | f9f852d | 2006-10-07 21:54:55 +0200 | [diff] [blame] | 421 | }; |
| 422 | |
Kay Sievers | a7fd670 | 2005-10-01 14:49:43 +0200 | [diff] [blame] | 423 | /* interface for exporting device attributes */ |
| 424 | struct device_attribute { |
| 425 | struct attribute attr; |
| 426 | ssize_t (*show)(struct device *dev, struct device_attribute *attr, |
| 427 | char *buf); |
| 428 | ssize_t (*store)(struct device *dev, struct device_attribute *attr, |
| 429 | const char *buf, size_t count); |
| 430 | }; |
| 431 | |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 432 | #define DEVICE_ATTR(_name, _mode, _show, _store) \ |
| 433 | struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show, _store) |
Kay Sievers | a7fd670 | 2005-10-01 14:49:43 +0200 | [diff] [blame] | 434 | |
Andrew Morton | 4a7fb63 | 2006-08-14 22:43:17 -0700 | [diff] [blame] | 435 | extern int __must_check device_create_file(struct device *device, |
Phil Carmody | 66ecb92 | 2009-12-18 15:34:20 +0200 | [diff] [blame] | 436 | const struct device_attribute *entry); |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 437 | extern void device_remove_file(struct device *dev, |
Phil Carmody | 26579ab | 2009-12-18 15:34:19 +0200 | [diff] [blame] | 438 | const struct device_attribute *attr); |
Greg Kroah-Hartman | 2589f188 | 2006-09-19 09:39:19 -0700 | [diff] [blame] | 439 | extern int __must_check device_create_bin_file(struct device *dev, |
Phil Carmody | 66ecb92 | 2009-12-18 15:34:20 +0200 | [diff] [blame] | 440 | const struct bin_attribute *attr); |
Greg Kroah-Hartman | 2589f188 | 2006-09-19 09:39:19 -0700 | [diff] [blame] | 441 | extern void device_remove_bin_file(struct device *dev, |
Phil Carmody | 66ecb92 | 2009-12-18 15:34:20 +0200 | [diff] [blame] | 442 | const struct bin_attribute *attr); |
Alan Stern | 523ded7 | 2007-04-26 00:12:04 -0700 | [diff] [blame] | 443 | extern int device_schedule_callback_owner(struct device *dev, |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 444 | void (*func)(struct device *dev), struct module *owner); |
Alan Stern | 523ded7 | 2007-04-26 00:12:04 -0700 | [diff] [blame] | 445 | |
| 446 | /* This is a macro to avoid include problems with THIS_MODULE */ |
| 447 | #define device_schedule_callback(dev, func) \ |
| 448 | device_schedule_callback_owner(dev, func, THIS_MODULE) |
Tejun Heo | 9ac7849 | 2007-01-20 16:00:26 +0900 | [diff] [blame] | 449 | |
| 450 | /* device resource management */ |
| 451 | typedef void (*dr_release_t)(struct device *dev, void *res); |
| 452 | typedef int (*dr_match_t)(struct device *dev, void *res, void *match_data); |
| 453 | |
| 454 | #ifdef CONFIG_DEBUG_DEVRES |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 455 | extern void *__devres_alloc(dr_release_t release, size_t size, gfp_t gfp, |
Tejun Heo | 9ac7849 | 2007-01-20 16:00:26 +0900 | [diff] [blame] | 456 | const char *name); |
| 457 | #define devres_alloc(release, size, gfp) \ |
| 458 | __devres_alloc(release, size, gfp, #release) |
| 459 | #else |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 460 | extern void *devres_alloc(dr_release_t release, size_t size, gfp_t gfp); |
Tejun Heo | 9ac7849 | 2007-01-20 16:00:26 +0900 | [diff] [blame] | 461 | #endif |
| 462 | extern void devres_free(void *res); |
| 463 | extern void devres_add(struct device *dev, void *res); |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 464 | extern void *devres_find(struct device *dev, dr_release_t release, |
Tejun Heo | 9ac7849 | 2007-01-20 16:00:26 +0900 | [diff] [blame] | 465 | dr_match_t match, void *match_data); |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 466 | extern void *devres_get(struct device *dev, void *new_res, |
| 467 | dr_match_t match, void *match_data); |
| 468 | extern void *devres_remove(struct device *dev, dr_release_t release, |
| 469 | dr_match_t match, void *match_data); |
Tejun Heo | 9ac7849 | 2007-01-20 16:00:26 +0900 | [diff] [blame] | 470 | extern int devres_destroy(struct device *dev, dr_release_t release, |
| 471 | dr_match_t match, void *match_data); |
| 472 | |
| 473 | /* devres group */ |
| 474 | extern void * __must_check devres_open_group(struct device *dev, void *id, |
| 475 | gfp_t gfp); |
| 476 | extern void devres_close_group(struct device *dev, void *id); |
| 477 | extern void devres_remove_group(struct device *dev, void *id); |
| 478 | extern int devres_release_group(struct device *dev, void *id); |
| 479 | |
| 480 | /* managed kzalloc/kfree for device drivers, no kmalloc, always use kzalloc */ |
| 481 | extern void *devm_kzalloc(struct device *dev, size_t size, gfp_t gfp); |
| 482 | extern void devm_kfree(struct device *dev, void *p); |
| 483 | |
FUJITA Tomonori | 6b7b651 | 2008-02-04 22:27:55 -0800 | [diff] [blame] | 484 | struct device_dma_parameters { |
| 485 | /* |
| 486 | * a low level driver may set these to teach IOMMU code about |
| 487 | * sg limitations. |
| 488 | */ |
| 489 | unsigned int max_segment_size; |
| 490 | unsigned long segment_boundary_mask; |
| 491 | }; |
| 492 | |
Wanlong Gao | 880ffb5 | 2011-05-05 07:55:36 +0800 | [diff] [blame] | 493 | /** |
| 494 | * struct device - The basic device structure |
| 495 | * @parent: The device's "parent" device, the device to which it is attached. |
| 496 | * In most cases, a parent device is some sort of bus or host |
| 497 | * controller. If parent is NULL, the device, is a top-level device, |
| 498 | * which is not usually what you want. |
| 499 | * @p: Holds the private data of the driver core portions of the device. |
| 500 | * See the comment of the struct device_private for detail. |
| 501 | * @kobj: A top-level, abstract class from which other classes are derived. |
| 502 | * @init_name: Initial name of the device. |
| 503 | * @type: The type of device. |
| 504 | * This identifies the device type and carries type-specific |
| 505 | * information. |
| 506 | * @mutex: Mutex to synchronize calls to its driver. |
| 507 | * @bus: Type of bus device is on. |
| 508 | * @driver: Which driver has allocated this |
| 509 | * @platform_data: Platform data specific to the device. |
| 510 | * Example: For devices on custom boards, as typical of embedded |
| 511 | * and SOC based hardware, Linux often uses platform_data to point |
| 512 | * to board-specific structures describing devices and how they |
| 513 | * are wired. That can include what ports are available, chip |
| 514 | * variants, which GPIO pins act in what additional roles, and so |
| 515 | * on. This shrinks the "Board Support Packages" (BSPs) and |
| 516 | * minimizes board-specific #ifdefs in drivers. |
| 517 | * @power: For device power management. |
| 518 | * See Documentation/power/devices.txt for details. |
| 519 | * @pwr_domain: Provide callbacks that are executed during system suspend, |
| 520 | * hibernation, system resume and during runtime PM transitions |
| 521 | * along with subsystem-level and driver-level callbacks. |
| 522 | * @numa_node: NUMA node this device is close to. |
| 523 | * @dma_mask: Dma mask (if dma'ble device). |
| 524 | * @coherent_dma_mask: Like dma_mask, but for alloc_coherent mapping as not all |
| 525 | * hardware supports 64-bit addresses for consistent allocations |
| 526 | * such descriptors. |
| 527 | * @dma_parms: A low level driver may set these to teach IOMMU code about |
| 528 | * segment limitations. |
| 529 | * @dma_pools: Dma pools (if dma'ble device). |
| 530 | * @dma_mem: Internal for coherent mem override. |
| 531 | * @archdata: For arch-specific additions. |
| 532 | * @of_node: Associated device tree node. |
Wanlong Gao | 880ffb5 | 2011-05-05 07:55:36 +0800 | [diff] [blame] | 533 | * @devt: For creating the sysfs "dev". |
| 534 | * @devres_lock: Spinlock to protect the resource of the device. |
| 535 | * @devres_head: The resources list of the device. |
| 536 | * @knode_class: The node used to add the device to the class list. |
| 537 | * @class: The class of the device. |
| 538 | * @groups: Optional attribute groups. |
| 539 | * @release: Callback to free the device after all references have |
| 540 | * gone away. This should be set by the allocator of the |
| 541 | * device (i.e. the bus driver that discovered the device). |
| 542 | * |
| 543 | * At the lowest level, every device in a Linux system is represented by an |
| 544 | * instance of struct device. The device structure contains the information |
| 545 | * that the device model core needs to model the system. Most subsystems, |
| 546 | * however, track additional information about the devices they host. As a |
| 547 | * result, it is rare for devices to be represented by bare device structures; |
| 548 | * instead, that structure, like kobject structures, is usually embedded within |
| 549 | * a higher-level representation of the device. |
| 550 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 551 | struct device { |
David Brownell | 49a4ec1 | 2007-05-08 00:29:39 -0700 | [diff] [blame] | 552 | struct device *parent; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 553 | |
Greg Kroah-Hartman | fb069a5 | 2008-12-16 12:23:36 -0800 | [diff] [blame] | 554 | struct device_private *p; |
| 555 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 556 | struct kobject kobj; |
Greg Kroah-Hartman | c906a48 | 2008-05-30 10:45:12 -0700 | [diff] [blame] | 557 | const char *init_name; /* initial name of the device */ |
Stephen Hemminger | aed65af | 2011-03-28 09:12:52 -0700 | [diff] [blame] | 558 | const struct device_type *type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 559 | |
Thomas Gleixner | 3142788 | 2010-01-29 20:39:02 +0000 | [diff] [blame] | 560 | struct mutex mutex; /* mutex to synchronize calls to |
mochel@digitalimplant.org | af70316 | 2005-03-21 10:41:04 -0800 | [diff] [blame] | 561 | * its driver. |
| 562 | */ |
| 563 | |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 564 | struct bus_type *bus; /* type of bus device is on */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 565 | struct device_driver *driver; /* which driver has allocated this |
| 566 | device */ |
Greg Kroah-Hartman | e67c856 | 2009-03-08 23:13:32 +0800 | [diff] [blame] | 567 | void *platform_data; /* Platform specific data, device |
| 568 | core doesn't touch it */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 569 | struct dev_pm_info power; |
Rafael J. Wysocki | 7538e3d | 2011-02-16 21:53:17 +0100 | [diff] [blame] | 570 | struct dev_power_domain *pwr_domain; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | |
Christoph Hellwig | 8734813 | 2006-12-06 20:32:33 -0800 | [diff] [blame] | 572 | #ifdef CONFIG_NUMA |
| 573 | int numa_node; /* NUMA node this device is close to */ |
| 574 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 575 | u64 *dma_mask; /* dma mask (if dma'able device) */ |
| 576 | u64 coherent_dma_mask;/* Like dma_mask, but for |
| 577 | alloc_coherent mappings as |
| 578 | not all hardware supports |
| 579 | 64 bit addresses for consistent |
| 580 | allocations such descriptors. */ |
| 581 | |
FUJITA Tomonori | 6b7b651 | 2008-02-04 22:27:55 -0800 | [diff] [blame] | 582 | struct device_dma_parameters *dma_parms; |
| 583 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 584 | struct list_head dma_pools; /* dma pools (if dma'ble) */ |
| 585 | |
| 586 | struct dma_coherent_mem *dma_mem; /* internal for coherent mem |
| 587 | override */ |
Benjamin Herrenschmidt | c6dbaef | 2006-11-11 17:18:39 +1100 | [diff] [blame] | 588 | /* arch specific additions */ |
| 589 | struct dev_archdata archdata; |
Grant Likely | c9e358d | 2011-01-21 09:24:48 -0700 | [diff] [blame] | 590 | |
| 591 | struct device_node *of_node; /* associated device tree node */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 592 | |
Matthew Wilcox | 929d2fa | 2008-10-16 15:51:35 -0600 | [diff] [blame] | 593 | dev_t devt; /* dev_t, creates the sysfs "dev" */ |
| 594 | |
Tejun Heo | 9ac7849 | 2007-01-20 16:00:26 +0900 | [diff] [blame] | 595 | spinlock_t devres_lock; |
| 596 | struct list_head devres_head; |
| 597 | |
Tejun Heo | 5a3ceb8 | 2008-08-25 19:50:19 +0200 | [diff] [blame] | 598 | struct klist_node knode_class; |
Kay Sievers | b7a3e81 | 2006-10-07 21:54:55 +0200 | [diff] [blame] | 599 | struct class *class; |
David Brownell | a4dbd67 | 2009-06-24 10:06:31 -0700 | [diff] [blame] | 600 | const struct attribute_group **groups; /* optional groups */ |
Greg Kroah-Hartman | 23681e4 | 2006-06-14 12:14:34 -0700 | [diff] [blame] | 601 | |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 602 | void (*release)(struct device *dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 603 | }; |
| 604 | |
Alan Stern | 9a3df1f | 2008-03-19 22:39:13 +0100 | [diff] [blame] | 605 | /* Get the wakeup routines, which depend on struct device */ |
| 606 | #include <linux/pm_wakeup.h> |
| 607 | |
Jean Delvare | bf9ca69 | 2008-07-30 12:29:21 -0700 | [diff] [blame] | 608 | static inline const char *dev_name(const struct device *dev) |
Kay Sievers | 0691663 | 2008-05-02 06:02:41 +0200 | [diff] [blame] | 609 | { |
Paul Mundt | a636ee7 | 2010-03-09 06:57:53 +0000 | [diff] [blame] | 610 | /* Use the init name until the kobject becomes available */ |
| 611 | if (dev->init_name) |
| 612 | return dev->init_name; |
| 613 | |
Kay Sievers | 1fa5ae8 | 2009-01-25 15:17:37 +0100 | [diff] [blame] | 614 | return kobject_name(&dev->kobj); |
Kay Sievers | 0691663 | 2008-05-02 06:02:41 +0200 | [diff] [blame] | 615 | } |
| 616 | |
Stephen Rothwell | 413c239 | 2008-05-30 10:16:40 +1000 | [diff] [blame] | 617 | extern int dev_set_name(struct device *dev, const char *name, ...) |
| 618 | __attribute__((format(printf, 2, 3))); |
| 619 | |
Christoph Hellwig | 8734813 | 2006-12-06 20:32:33 -0800 | [diff] [blame] | 620 | #ifdef CONFIG_NUMA |
| 621 | static inline int dev_to_node(struct device *dev) |
| 622 | { |
| 623 | return dev->numa_node; |
| 624 | } |
| 625 | static inline void set_dev_node(struct device *dev, int node) |
| 626 | { |
| 627 | dev->numa_node = node; |
| 628 | } |
| 629 | #else |
| 630 | static inline int dev_to_node(struct device *dev) |
| 631 | { |
| 632 | return -1; |
| 633 | } |
| 634 | static inline void set_dev_node(struct device *dev, int node) |
| 635 | { |
| 636 | } |
| 637 | #endif |
| 638 | |
Ming Lei | f67f129 | 2009-03-01 21:10:49 +0800 | [diff] [blame] | 639 | static inline unsigned int dev_get_uevent_suppress(const struct device *dev) |
| 640 | { |
| 641 | return dev->kobj.uevent_suppress; |
| 642 | } |
| 643 | |
| 644 | static inline void dev_set_uevent_suppress(struct device *dev, int val) |
| 645 | { |
| 646 | dev->kobj.uevent_suppress = val; |
| 647 | } |
| 648 | |
Daniel Ritz | d305ef5 | 2005-09-22 00:47:24 -0700 | [diff] [blame] | 649 | static inline int device_is_registered(struct device *dev) |
| 650 | { |
Greg Kroah-Hartman | 3f62e57 | 2008-03-13 17:07:03 -0400 | [diff] [blame] | 651 | return dev->kobj.state_in_sysfs; |
Daniel Ritz | d305ef5 | 2005-09-22 00:47:24 -0700 | [diff] [blame] | 652 | } |
| 653 | |
Rafael J. Wysocki | 5af84b8 | 2010-01-23 22:23:32 +0100 | [diff] [blame] | 654 | static inline void device_enable_async_suspend(struct device *dev) |
| 655 | { |
Alan Stern | f76b168 | 2011-06-18 20:22:23 +0200 | [diff] [blame] | 656 | if (!dev->power.is_prepared) |
Rafael J. Wysocki | 5af84b8 | 2010-01-23 22:23:32 +0100 | [diff] [blame] | 657 | dev->power.async_suspend = true; |
| 658 | } |
| 659 | |
Rafael J. Wysocki | 5a2eb85 | 2010-01-23 22:25:23 +0100 | [diff] [blame] | 660 | static inline void device_disable_async_suspend(struct device *dev) |
| 661 | { |
Alan Stern | f76b168 | 2011-06-18 20:22:23 +0200 | [diff] [blame] | 662 | if (!dev->power.is_prepared) |
Rafael J. Wysocki | 5a2eb85 | 2010-01-23 22:25:23 +0100 | [diff] [blame] | 663 | dev->power.async_suspend = false; |
| 664 | } |
| 665 | |
| 666 | static inline bool device_async_suspend_enabled(struct device *dev) |
| 667 | { |
| 668 | return !!dev->power.async_suspend; |
| 669 | } |
| 670 | |
Greg Kroah-Hartman | 8e9394c | 2010-02-17 10:57:05 -0800 | [diff] [blame] | 671 | static inline void device_lock(struct device *dev) |
| 672 | { |
Thomas Gleixner | 3142788 | 2010-01-29 20:39:02 +0000 | [diff] [blame] | 673 | mutex_lock(&dev->mutex); |
Greg Kroah-Hartman | 8e9394c | 2010-02-17 10:57:05 -0800 | [diff] [blame] | 674 | } |
| 675 | |
| 676 | static inline int device_trylock(struct device *dev) |
| 677 | { |
Thomas Gleixner | 3142788 | 2010-01-29 20:39:02 +0000 | [diff] [blame] | 678 | return mutex_trylock(&dev->mutex); |
Greg Kroah-Hartman | 8e9394c | 2010-02-17 10:57:05 -0800 | [diff] [blame] | 679 | } |
| 680 | |
| 681 | static inline void device_unlock(struct device *dev) |
| 682 | { |
Thomas Gleixner | 3142788 | 2010-01-29 20:39:02 +0000 | [diff] [blame] | 683 | mutex_unlock(&dev->mutex); |
Greg Kroah-Hartman | 8e9394c | 2010-02-17 10:57:05 -0800 | [diff] [blame] | 684 | } |
| 685 | |
Adrian Bunk | 1f21782 | 2006-12-19 13:01:28 -0800 | [diff] [blame] | 686 | void driver_init(void); |
| 687 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 688 | /* |
| 689 | * High level routines for use by the bus drivers |
| 690 | */ |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 691 | extern int __must_check device_register(struct device *dev); |
| 692 | extern void device_unregister(struct device *dev); |
| 693 | extern void device_initialize(struct device *dev); |
| 694 | extern int __must_check device_add(struct device *dev); |
| 695 | extern void device_del(struct device *dev); |
| 696 | extern int device_for_each_child(struct device *dev, void *data, |
| 697 | int (*fn)(struct device *dev, void *data)); |
| 698 | extern struct device *device_find_child(struct device *dev, void *data, |
| 699 | int (*match)(struct device *dev, void *data)); |
Johannes Berg | 6937e8f | 2010-08-05 17:38:18 +0200 | [diff] [blame] | 700 | extern int device_rename(struct device *dev, const char *new_name); |
Cornelia Huck | ffa6a70 | 2009-03-04 12:44:00 +0100 | [diff] [blame] | 701 | extern int device_move(struct device *dev, struct device *new_parent, |
| 702 | enum dpm_order dpm_order); |
Kay Sievers | e454cea | 2009-09-18 23:01:12 +0200 | [diff] [blame] | 703 | extern const char *device_get_devnode(struct device *dev, |
| 704 | mode_t *mode, const char **tmp); |
Greg Kroah-Hartman | b402843 | 2009-05-11 14:16:57 -0700 | [diff] [blame] | 705 | extern void *dev_get_drvdata(const struct device *dev); |
Uwe Kleine-König | c870508 | 2011-04-20 09:44:46 +0200 | [diff] [blame] | 706 | extern int dev_set_drvdata(struct device *dev, void *data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 707 | |
| 708 | /* |
Mark McLoughlin | 0aa0dc4 | 2008-12-15 12:58:26 +0000 | [diff] [blame] | 709 | * Root device objects for grouping under /sys/devices |
| 710 | */ |
| 711 | extern struct device *__root_device_register(const char *name, |
| 712 | struct module *owner); |
| 713 | static inline struct device *root_device_register(const char *name) |
| 714 | { |
| 715 | return __root_device_register(name, THIS_MODULE); |
| 716 | } |
| 717 | extern void root_device_unregister(struct device *root); |
| 718 | |
Mark Brown | a5b8b1a | 2009-07-17 15:06:08 +0100 | [diff] [blame] | 719 | static inline void *dev_get_platdata(const struct device *dev) |
| 720 | { |
| 721 | return dev->platform_data; |
| 722 | } |
| 723 | |
Mark McLoughlin | 0aa0dc4 | 2008-12-15 12:58:26 +0000 | [diff] [blame] | 724 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 725 | * Manual binding of a device to driver. See drivers/base/bus.c |
| 726 | * for information on use. |
| 727 | */ |
Andrew Morton | f86db39 | 2006-08-14 22:43:20 -0700 | [diff] [blame] | 728 | extern int __must_check device_bind_driver(struct device *dev); |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 729 | extern void device_release_driver(struct device *dev); |
| 730 | extern int __must_check device_attach(struct device *dev); |
Andrew Morton | f86db39 | 2006-08-14 22:43:20 -0700 | [diff] [blame] | 731 | extern int __must_check driver_attach(struct device_driver *drv); |
| 732 | extern int __must_check device_reprobe(struct device *dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 733 | |
Greg Kroah-Hartman | 23681e4 | 2006-06-14 12:14:34 -0700 | [diff] [blame] | 734 | /* |
| 735 | * Easy functions for dynamically creating devices on the fly |
| 736 | */ |
Greg Kroah-Hartman | 8882b39 | 2008-05-15 13:44:08 -0700 | [diff] [blame] | 737 | extern struct device *device_create_vargs(struct class *cls, |
| 738 | struct device *parent, |
| 739 | dev_t devt, |
| 740 | void *drvdata, |
| 741 | const char *fmt, |
| 742 | va_list vargs); |
Greg Kroah-Hartman | 4e10673 | 2008-07-21 20:03:34 -0700 | [diff] [blame] | 743 | extern struct device *device_create(struct class *cls, struct device *parent, |
| 744 | dev_t devt, void *drvdata, |
| 745 | const char *fmt, ...) |
Greg Kroah-Hartman | 8882b39 | 2008-05-15 13:44:08 -0700 | [diff] [blame] | 746 | __attribute__((format(printf, 5, 6))); |
Greg Kroah-Hartman | 23681e4 | 2006-06-14 12:14:34 -0700 | [diff] [blame] | 747 | extern void device_destroy(struct class *cls, dev_t devt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 748 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 749 | /* |
| 750 | * Platform "fixup" functions - allow the platform to have their say |
| 751 | * about devices and actions that the general device layer doesn't |
| 752 | * know about. |
| 753 | */ |
| 754 | /* Notify platform of device discovery */ |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 755 | extern int (*platform_notify)(struct device *dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 756 | |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 757 | extern int (*platform_notify_remove)(struct device *dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 758 | |
| 759 | |
Wanlong Gao | 880ffb5 | 2011-05-05 07:55:36 +0800 | [diff] [blame] | 760 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 761 | * get_device - atomically increment the reference count for the device. |
| 762 | * |
| 763 | */ |
Greg Kroah-Hartman | d462943 | 2008-01-24 21:04:46 -0800 | [diff] [blame] | 764 | extern struct device *get_device(struct device *dev); |
| 765 | extern void put_device(struct device *dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 766 | |
Arjan van de Ven | d4d5291 | 2009-04-21 13:32:54 -0700 | [diff] [blame] | 767 | extern void wait_for_device_probe(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 768 | |
Kay Sievers | 2b2af54 | 2009-04-30 15:23:42 +0200 | [diff] [blame] | 769 | #ifdef CONFIG_DEVTMPFS |
| 770 | extern int devtmpfs_create_node(struct device *dev); |
| 771 | extern int devtmpfs_delete_node(struct device *dev); |
Kay Sievers | 073120c | 2009-10-28 19:51:17 +0100 | [diff] [blame] | 772 | extern int devtmpfs_mount(const char *mntdir); |
Kay Sievers | 2b2af54 | 2009-04-30 15:23:42 +0200 | [diff] [blame] | 773 | #else |
| 774 | static inline int devtmpfs_create_node(struct device *dev) { return 0; } |
| 775 | static inline int devtmpfs_delete_node(struct device *dev) { return 0; } |
| 776 | static inline int devtmpfs_mount(const char *mountpoint) { return 0; } |
| 777 | #endif |
| 778 | |
Rytchkov Alexey | 116f232 | 2006-03-22 00:58:53 +0100 | [diff] [blame] | 779 | /* drivers/base/power/shutdown.c */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 780 | extern void device_shutdown(void); |
| 781 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 782 | /* debugging and troubleshooting/diagnostic helpers. */ |
Jean Delvare | bf9ca69 | 2008-07-30 12:29:21 -0700 | [diff] [blame] | 783 | extern const char *dev_driver_string(const struct device *dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 784 | |
Joe Perches | 99bcf21 | 2010-06-27 01:02:34 +0000 | [diff] [blame] | 785 | |
| 786 | #ifdef CONFIG_PRINTK |
| 787 | |
| 788 | extern int dev_printk(const char *level, const struct device *dev, |
| 789 | const char *fmt, ...) |
| 790 | __attribute__ ((format (printf, 3, 4))); |
| 791 | extern int dev_emerg(const struct device *dev, const char *fmt, ...) |
| 792 | __attribute__ ((format (printf, 2, 3))); |
| 793 | extern int dev_alert(const struct device *dev, const char *fmt, ...) |
| 794 | __attribute__ ((format (printf, 2, 3))); |
| 795 | extern int dev_crit(const struct device *dev, const char *fmt, ...) |
| 796 | __attribute__ ((format (printf, 2, 3))); |
| 797 | extern int dev_err(const struct device *dev, const char *fmt, ...) |
| 798 | __attribute__ ((format (printf, 2, 3))); |
| 799 | extern int dev_warn(const struct device *dev, const char *fmt, ...) |
| 800 | __attribute__ ((format (printf, 2, 3))); |
| 801 | extern int dev_notice(const struct device *dev, const char *fmt, ...) |
| 802 | __attribute__ ((format (printf, 2, 3))); |
| 803 | extern int _dev_info(const struct device *dev, const char *fmt, ...) |
| 804 | __attribute__ ((format (printf, 2, 3))); |
| 805 | |
| 806 | #else |
| 807 | |
| 808 | static inline int dev_printk(const char *level, const struct device *dev, |
| 809 | const char *fmt, ...) |
| 810 | __attribute__ ((format (printf, 3, 4))); |
| 811 | static inline int dev_printk(const char *level, const struct device *dev, |
| 812 | const char *fmt, ...) |
| 813 | { return 0; } |
| 814 | |
| 815 | static inline int dev_emerg(const struct device *dev, const char *fmt, ...) |
| 816 | __attribute__ ((format (printf, 2, 3))); |
| 817 | static inline int dev_emerg(const struct device *dev, const char *fmt, ...) |
| 818 | { return 0; } |
| 819 | static inline int dev_crit(const struct device *dev, const char *fmt, ...) |
| 820 | __attribute__ ((format (printf, 2, 3))); |
| 821 | static inline int dev_crit(const struct device *dev, const char *fmt, ...) |
| 822 | { return 0; } |
| 823 | static inline int dev_alert(const struct device *dev, const char *fmt, ...) |
| 824 | __attribute__ ((format (printf, 2, 3))); |
| 825 | static inline int dev_alert(const struct device *dev, const char *fmt, ...) |
| 826 | { return 0; } |
| 827 | static inline int dev_err(const struct device *dev, const char *fmt, ...) |
| 828 | __attribute__ ((format (printf, 2, 3))); |
| 829 | static inline int dev_err(const struct device *dev, const char *fmt, ...) |
| 830 | { return 0; } |
| 831 | static inline int dev_warn(const struct device *dev, const char *fmt, ...) |
| 832 | __attribute__ ((format (printf, 2, 3))); |
| 833 | static inline int dev_warn(const struct device *dev, const char *fmt, ...) |
| 834 | { return 0; } |
| 835 | static inline int dev_notice(const struct device *dev, const char *fmt, ...) |
| 836 | __attribute__ ((format (printf, 2, 3))); |
| 837 | static inline int dev_notice(const struct device *dev, const char *fmt, ...) |
| 838 | { return 0; } |
| 839 | static inline int _dev_info(const struct device *dev, const char *fmt, ...) |
| 840 | __attribute__ ((format (printf, 2, 3))); |
| 841 | static inline int _dev_info(const struct device *dev, const char *fmt, ...) |
| 842 | { return 0; } |
| 843 | |
| 844 | #endif |
| 845 | |
| 846 | /* |
| 847 | * Stupid hackaround for existing uses of non-printk uses dev_info |
| 848 | * |
| 849 | * Note that the definition of dev_info below is actually _dev_info |
| 850 | * and a macro is used to avoid redefining dev_info |
| 851 | */ |
| 852 | |
| 853 | #define dev_info(dev, fmt, arg...) _dev_info(dev, fmt, ##arg) |
Emil Medve | 7b8712e | 2007-10-30 14:37:14 -0500 | [diff] [blame] | 854 | |
Cornelia Huck | d0d85ff | 2008-12-04 16:55:47 +0100 | [diff] [blame] | 855 | #if defined(DEBUG) |
| 856 | #define dev_dbg(dev, format, arg...) \ |
Joe Perches | 99bcf21 | 2010-06-27 01:02:34 +0000 | [diff] [blame] | 857 | dev_printk(KERN_DEBUG, dev, format, ##arg) |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 858 | #elif defined(CONFIG_DYNAMIC_DEBUG) |
Joe Perches | 99bcf21 | 2010-06-27 01:02:34 +0000 | [diff] [blame] | 859 | #define dev_dbg(dev, format, ...) \ |
| 860 | do { \ |
Jason Baron | 346e15b | 2008-08-12 16:46:19 -0400 | [diff] [blame] | 861 | dynamic_dev_dbg(dev, format, ##__VA_ARGS__); \ |
Joe Perches | 99bcf21 | 2010-06-27 01:02:34 +0000 | [diff] [blame] | 862 | } while (0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 863 | #else |
Joe Perches | 99bcf21 | 2010-06-27 01:02:34 +0000 | [diff] [blame] | 864 | #define dev_dbg(dev, format, arg...) \ |
| 865 | ({ \ |
| 866 | if (0) \ |
| 867 | dev_printk(KERN_DEBUG, dev, format, ##arg); \ |
| 868 | 0; \ |
| 869 | }) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 870 | #endif |
| 871 | |
David Brownell | aebdc3b | 2007-07-12 22:08:22 -0700 | [diff] [blame] | 872 | #ifdef VERBOSE_DEBUG |
| 873 | #define dev_vdbg dev_dbg |
| 874 | #else |
Joe Perches | 99bcf21 | 2010-06-27 01:02:34 +0000 | [diff] [blame] | 875 | #define dev_vdbg(dev, format, arg...) \ |
| 876 | ({ \ |
| 877 | if (0) \ |
| 878 | dev_printk(KERN_DEBUG, dev, format, ##arg); \ |
| 879 | 0; \ |
| 880 | }) |
David Brownell | aebdc3b | 2007-07-12 22:08:22 -0700 | [diff] [blame] | 881 | #endif |
| 882 | |
Arjan van de Ven | e613966 | 2008-09-20 19:08:39 -0700 | [diff] [blame] | 883 | /* |
Felipe Balbi | bcdd323 | 2011-03-16 15:59:35 +0200 | [diff] [blame] | 884 | * dev_WARN*() acts like dev_printk(), but with the key difference |
Arjan van de Ven | e613966 | 2008-09-20 19:08:39 -0700 | [diff] [blame] | 885 | * of using a WARN/WARN_ON to get the message out, including the |
| 886 | * file/line information and a backtrace. |
| 887 | */ |
| 888 | #define dev_WARN(dev, format, arg...) \ |
| 889 | WARN(1, "Device: %s\n" format, dev_driver_string(dev), ## arg); |
| 890 | |
Felipe Balbi | bcdd323 | 2011-03-16 15:59:35 +0200 | [diff] [blame] | 891 | #define dev_WARN_ONCE(dev, condition, format, arg...) \ |
| 892 | WARN_ONCE(condition, "Device %s\n" format, \ |
| 893 | dev_driver_string(dev), ## arg) |
| 894 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 895 | /* Create alias, so I can be autoloaded. */ |
| 896 | #define MODULE_ALIAS_CHARDEV(major,minor) \ |
| 897 | MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor)) |
| 898 | #define MODULE_ALIAS_CHARDEV_MAJOR(major) \ |
| 899 | MODULE_ALIAS("char-major-" __stringify(major) "-*") |
Andi Kleen | e52eec1 | 2010-09-08 16:54:17 +0200 | [diff] [blame] | 900 | |
| 901 | #ifdef CONFIG_SYSFS_DEPRECATED |
| 902 | extern long sysfs_deprecated; |
| 903 | #else |
| 904 | #define sysfs_deprecated 0 |
| 905 | #endif |
| 906 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 907 | #endif /* _DEVICE_H_ */ |