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> |
| 5 | * |
| 6 | * This file is released under the GPLv2 |
| 7 | * |
| 8 | * See Documentation/driver-model/ for more information. |
| 9 | */ |
| 10 | |
| 11 | #ifndef _DEVICE_H_ |
| 12 | #define _DEVICE_H_ |
| 13 | |
| 14 | #include <linux/config.h> |
| 15 | #include <linux/ioport.h> |
| 16 | #include <linux/kobject.h> |
mochel@digitalimplant.org | 465c7a3 | 2005-03-21 11:49:14 -0800 | [diff] [blame] | 17 | #include <linux/klist.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #include <linux/list.h> |
| 19 | #include <linux/types.h> |
| 20 | #include <linux/module.h> |
| 21 | #include <linux/pm.h> |
| 22 | #include <asm/semaphore.h> |
| 23 | #include <asm/atomic.h> |
| 24 | |
| 25 | #define DEVICE_NAME_SIZE 50 |
| 26 | #define DEVICE_NAME_HALF __stringify(20) /* Less than half to accommodate slop */ |
| 27 | #define DEVICE_ID_SIZE 32 |
| 28 | #define BUS_ID_SIZE KOBJ_NAME_LEN |
| 29 | |
| 30 | |
| 31 | enum { |
| 32 | SUSPEND_NOTIFY, |
| 33 | SUSPEND_SAVE_STATE, |
| 34 | SUSPEND_DISABLE, |
| 35 | SUSPEND_POWER_DOWN, |
| 36 | }; |
| 37 | |
| 38 | enum { |
| 39 | RESUME_POWER_ON, |
| 40 | RESUME_RESTORE_STATE, |
| 41 | RESUME_ENABLE, |
| 42 | }; |
| 43 | |
| 44 | struct device; |
| 45 | struct device_driver; |
| 46 | struct class; |
| 47 | struct class_device; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | |
| 49 | struct bus_type { |
Dmitry Torokhov | 8d790d7 | 2005-04-26 02:34:05 -0500 | [diff] [blame] | 50 | const char * name; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | |
| 52 | struct subsystem subsys; |
| 53 | struct kset drivers; |
| 54 | struct kset devices; |
mochel@digitalimplant.org | 465c7a3 | 2005-03-21 11:49:14 -0800 | [diff] [blame] | 55 | struct klist klist_devices; |
mochel@digitalimplant.org | 38fdac3 | 2005-03-21 12:00:18 -0800 | [diff] [blame] | 56 | struct klist klist_drivers; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | |
| 58 | struct bus_attribute * bus_attrs; |
| 59 | struct device_attribute * dev_attrs; |
| 60 | struct driver_attribute * drv_attrs; |
| 61 | |
| 62 | int (*match)(struct device * dev, struct device_driver * drv); |
| 63 | int (*hotplug) (struct device *dev, char **envp, |
| 64 | int num_envp, char *buffer, int buffer_size); |
| 65 | int (*suspend)(struct device * dev, pm_message_t state); |
| 66 | int (*resume)(struct device * dev); |
| 67 | }; |
| 68 | |
| 69 | extern int bus_register(struct bus_type * bus); |
| 70 | extern void bus_unregister(struct bus_type * bus); |
| 71 | |
Greg Kroah-Hartman | 23d3d60 | 2005-06-22 16:09:05 -0700 | [diff] [blame] | 72 | extern void bus_rescan_devices(struct bus_type * bus); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | |
| 74 | extern struct bus_type * get_bus(struct bus_type * bus); |
| 75 | extern void put_bus(struct bus_type * bus); |
| 76 | |
| 77 | extern struct bus_type * find_bus(char * name); |
| 78 | |
| 79 | /* iterator helpers for buses */ |
| 80 | |
| 81 | int bus_for_each_dev(struct bus_type * bus, struct device * start, void * data, |
| 82 | int (*fn)(struct device *, void *)); |
Cornelia Huck | 0edb586 | 2005-06-22 16:59:51 +0200 | [diff] [blame] | 83 | struct device * bus_find_device(struct bus_type *bus, struct device *start, |
| 84 | void *data, int (*match)(struct device *, void *)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | |
| 86 | int bus_for_each_drv(struct bus_type * bus, struct device_driver * start, |
| 87 | void * data, int (*fn)(struct device_driver *, void *)); |
| 88 | |
| 89 | |
| 90 | /* driverfs interface for exporting bus attributes */ |
| 91 | |
| 92 | struct bus_attribute { |
| 93 | struct attribute attr; |
| 94 | ssize_t (*show)(struct bus_type *, char * buf); |
| 95 | ssize_t (*store)(struct bus_type *, const char * buf, size_t count); |
| 96 | }; |
| 97 | |
| 98 | #define BUS_ATTR(_name,_mode,_show,_store) \ |
| 99 | struct bus_attribute bus_attr_##_name = __ATTR(_name,_mode,_show,_store) |
| 100 | |
| 101 | extern int bus_create_file(struct bus_type *, struct bus_attribute *); |
| 102 | extern void bus_remove_file(struct bus_type *, struct bus_attribute *); |
| 103 | |
| 104 | struct device_driver { |
Dmitry Torokhov | 8d790d7 | 2005-04-26 02:34:05 -0500 | [diff] [blame] | 105 | const char * name; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | struct bus_type * bus; |
| 107 | |
| 108 | struct completion unloaded; |
| 109 | struct kobject kobj; |
mochel@digitalimplant.org | 94e7b1c5 | 2005-03-21 12:25:36 -0800 | [diff] [blame] | 110 | struct klist klist_devices; |
mochel@digitalimplant.org | 38fdac3 | 2005-03-21 12:00:18 -0800 | [diff] [blame] | 111 | struct klist_node knode_bus; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | |
Dmitry Torokhov | 8d790d7 | 2005-04-26 02:34:05 -0500 | [diff] [blame] | 113 | struct module * owner; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | |
| 115 | int (*probe) (struct device * dev); |
Dmitry Torokhov | 8d790d7 | 2005-04-26 02:34:05 -0500 | [diff] [blame] | 116 | int (*remove) (struct device * dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | void (*shutdown) (struct device * dev); |
| 118 | int (*suspend) (struct device * dev, pm_message_t state, u32 level); |
| 119 | int (*resume) (struct device * dev, u32 level); |
| 120 | }; |
| 121 | |
| 122 | |
| 123 | extern int driver_register(struct device_driver * drv); |
| 124 | extern void driver_unregister(struct device_driver * drv); |
| 125 | |
| 126 | extern struct device_driver * get_driver(struct device_driver * drv); |
| 127 | extern void put_driver(struct device_driver * drv); |
| 128 | extern struct device_driver *driver_find(const char *name, struct bus_type *bus); |
| 129 | |
| 130 | |
| 131 | /* driverfs interface for exporting driver attributes */ |
| 132 | |
| 133 | struct driver_attribute { |
| 134 | struct attribute attr; |
| 135 | ssize_t (*show)(struct device_driver *, char * buf); |
| 136 | ssize_t (*store)(struct device_driver *, const char * buf, size_t count); |
| 137 | }; |
| 138 | |
| 139 | #define DRIVER_ATTR(_name,_mode,_show,_store) \ |
| 140 | struct driver_attribute driver_attr_##_name = __ATTR(_name,_mode,_show,_store) |
| 141 | |
| 142 | extern int driver_create_file(struct device_driver *, struct driver_attribute *); |
| 143 | extern void driver_remove_file(struct device_driver *, struct driver_attribute *); |
| 144 | |
mochel@digitalimplant.org | fae3cd0 | 2005-03-21 10:59:56 -0800 | [diff] [blame] | 145 | extern int driver_for_each_device(struct device_driver * drv, struct device * start, |
| 146 | void * data, int (*fn)(struct device *, void *)); |
Cornelia Huck | 0edb586 | 2005-06-22 16:59:51 +0200 | [diff] [blame] | 147 | struct device * driver_find_device(struct device_driver *drv, |
| 148 | struct device *start, void *data, |
| 149 | int (*match)(struct device *, void *)); |
mochel@digitalimplant.org | fae3cd0 | 2005-03-21 10:59:56 -0800 | [diff] [blame] | 150 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | |
| 152 | /* |
| 153 | * device classes |
| 154 | */ |
| 155 | struct class { |
Dmitry Torokhov | 8d790d7 | 2005-04-26 02:34:05 -0500 | [diff] [blame] | 156 | const char * name; |
gregkh@suse.de | e9ba636 | 2005-03-15 11:54:21 -0800 | [diff] [blame] | 157 | struct module * owner; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | |
| 159 | struct subsystem subsys; |
| 160 | struct list_head children; |
| 161 | struct list_head interfaces; |
| 162 | struct semaphore sem; /* locks both the children and interfaces lists */ |
| 163 | |
| 164 | struct class_attribute * class_attrs; |
| 165 | struct class_device_attribute * class_dev_attrs; |
| 166 | |
| 167 | int (*hotplug)(struct class_device *dev, char **envp, |
| 168 | int num_envp, char *buffer, int buffer_size); |
| 169 | |
| 170 | void (*release)(struct class_device *dev); |
| 171 | void (*class_release)(struct class *class); |
| 172 | }; |
| 173 | |
| 174 | extern int class_register(struct class *); |
| 175 | extern void class_unregister(struct class *); |
| 176 | |
| 177 | extern struct class * class_get(struct class *); |
| 178 | extern void class_put(struct class *); |
| 179 | |
| 180 | |
| 181 | struct class_attribute { |
| 182 | struct attribute attr; |
| 183 | ssize_t (*show)(struct class *, char * buf); |
| 184 | ssize_t (*store)(struct class *, const char * buf, size_t count); |
| 185 | }; |
| 186 | |
| 187 | #define CLASS_ATTR(_name,_mode,_show,_store) \ |
| 188 | struct class_attribute class_attr_##_name = __ATTR(_name,_mode,_show,_store) |
| 189 | |
| 190 | extern int class_create_file(struct class *, const struct class_attribute *); |
| 191 | extern void class_remove_file(struct class *, const struct class_attribute *); |
| 192 | |
Kay Sievers | a7fd670 | 2005-10-01 14:49:43 +0200 | [diff] [blame] | 193 | struct class_device_attribute { |
| 194 | struct attribute attr; |
| 195 | ssize_t (*show)(struct class_device *, char * buf); |
| 196 | ssize_t (*store)(struct class_device *, const char * buf, size_t count); |
| 197 | }; |
| 198 | |
| 199 | #define CLASS_DEVICE_ATTR(_name,_mode,_show,_store) \ |
| 200 | struct class_device_attribute class_device_attr_##_name = \ |
| 201 | __ATTR(_name,_mode,_show,_store) |
| 202 | |
| 203 | extern int class_device_create_file(struct class_device *, |
| 204 | const struct class_device_attribute *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | |
| 206 | struct class_device { |
| 207 | struct list_head node; |
| 208 | |
| 209 | struct kobject kobj; |
| 210 | struct class * class; /* required */ |
| 211 | dev_t devt; /* dev_t, creates the sysfs "dev" */ |
gregkh@suse.de | e9ba636 | 2005-03-15 11:54:21 -0800 | [diff] [blame] | 212 | struct class_device_attribute *devt_attr; |
Kay Sievers | a7fd670 | 2005-10-01 14:49:43 +0200 | [diff] [blame] | 213 | struct class_device_attribute uevent_attr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | struct device * dev; /* not necessary, but nice to have */ |
| 215 | void * class_data; /* class-specific data */ |
Greg Kroah-Hartman | 51d172d | 2005-10-27 22:25:43 -0700 | [diff] [blame^] | 216 | struct class_device *parent; /* parent of this child device, if there is one */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | |
Greg Kroah-Hartman | 51d172d | 2005-10-27 22:25:43 -0700 | [diff] [blame^] | 218 | void (*release)(struct class_device *dev); |
| 219 | int (*hotplug)(struct class_device *dev, char **envp, |
| 220 | int num_envp, char *buffer, int buffer_size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | char class_id[BUS_ID_SIZE]; /* unique to this class */ |
| 222 | }; |
| 223 | |
| 224 | static inline void * |
| 225 | class_get_devdata (struct class_device *dev) |
| 226 | { |
| 227 | return dev->class_data; |
| 228 | } |
| 229 | |
| 230 | static inline void |
| 231 | class_set_devdata (struct class_device *dev, void *data) |
| 232 | { |
| 233 | dev->class_data = data; |
| 234 | } |
| 235 | |
| 236 | |
| 237 | extern int class_device_register(struct class_device *); |
| 238 | extern void class_device_unregister(struct class_device *); |
| 239 | extern void class_device_initialize(struct class_device *); |
| 240 | extern int class_device_add(struct class_device *); |
| 241 | extern void class_device_del(struct class_device *); |
| 242 | |
| 243 | extern int class_device_rename(struct class_device *, char *); |
| 244 | |
| 245 | extern struct class_device * class_device_get(struct class_device *); |
| 246 | extern void class_device_put(struct class_device *); |
| 247 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | extern void class_device_remove_file(struct class_device *, |
| 249 | const struct class_device_attribute *); |
| 250 | extern int class_device_create_bin_file(struct class_device *, |
| 251 | struct bin_attribute *); |
| 252 | extern void class_device_remove_bin_file(struct class_device *, |
| 253 | struct bin_attribute *); |
| 254 | |
| 255 | struct class_interface { |
| 256 | struct list_head node; |
| 257 | struct class *class; |
| 258 | |
Dmitry Torokhov | d8539d8 | 2005-09-15 02:01:36 -0500 | [diff] [blame] | 259 | int (*add) (struct class_device *, struct class_interface *); |
| 260 | void (*remove) (struct class_device *, struct class_interface *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 261 | }; |
| 262 | |
| 263 | extern int class_interface_register(struct class_interface *); |
| 264 | extern void class_interface_unregister(struct class_interface *); |
| 265 | |
gregkh@suse.de | e9ba636 | 2005-03-15 11:54:21 -0800 | [diff] [blame] | 266 | extern struct class *class_create(struct module *owner, char *name); |
| 267 | extern void class_destroy(struct class *cls); |
Greg Kroah-Hartman | 51d172d | 2005-10-27 22:25:43 -0700 | [diff] [blame^] | 268 | extern struct class_device *class_device_create(struct class *cls, |
| 269 | struct class_device *parent, |
| 270 | dev_t devt, |
| 271 | struct device *device, |
| 272 | char *fmt, ...) |
| 273 | __attribute__((format(printf,5,6))); |
gregkh@suse.de | e9ba636 | 2005-03-15 11:54:21 -0800 | [diff] [blame] | 274 | extern void class_device_destroy(struct class *cls, dev_t devt); |
| 275 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | |
Kay Sievers | a7fd670 | 2005-10-01 14:49:43 +0200 | [diff] [blame] | 277 | /* interface for exporting device attributes */ |
| 278 | struct device_attribute { |
| 279 | struct attribute attr; |
| 280 | ssize_t (*show)(struct device *dev, struct device_attribute *attr, |
| 281 | char *buf); |
| 282 | ssize_t (*store)(struct device *dev, struct device_attribute *attr, |
| 283 | const char *buf, size_t count); |
| 284 | }; |
| 285 | |
| 286 | #define DEVICE_ATTR(_name,_mode,_show,_store) \ |
| 287 | struct device_attribute dev_attr_##_name = __ATTR(_name,_mode,_show,_store) |
| 288 | |
| 289 | extern int device_create_file(struct device *device, struct device_attribute * entry); |
| 290 | extern void device_remove_file(struct device * dev, struct device_attribute * attr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | struct device { |
mochel@digitalimplant.org | 3623957 | 2005-03-24 19:08:30 -0800 | [diff] [blame] | 292 | struct klist klist_children; |
| 293 | struct klist_node knode_parent; /* node in sibling list */ |
mochel@digitalimplant.org | 94e7b1c5 | 2005-03-21 12:25:36 -0800 | [diff] [blame] | 294 | struct klist_node knode_driver; |
mochel@digitalimplant.org | 465c7a3 | 2005-03-21 11:49:14 -0800 | [diff] [blame] | 295 | struct klist_node knode_bus; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 296 | struct device * parent; |
| 297 | |
| 298 | struct kobject kobj; |
| 299 | char bus_id[BUS_ID_SIZE]; /* position on parent bus */ |
Kay Sievers | a7fd670 | 2005-10-01 14:49:43 +0200 | [diff] [blame] | 300 | struct device_attribute uevent_attr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | |
mochel@digitalimplant.org | af70316 | 2005-03-21 10:41:04 -0800 | [diff] [blame] | 302 | struct semaphore sem; /* semaphore to synchronize calls to |
| 303 | * its driver. |
| 304 | */ |
| 305 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | struct bus_type * bus; /* type of bus device is on */ |
| 307 | struct device_driver *driver; /* which driver has allocated this |
| 308 | device */ |
| 309 | void *driver_data; /* data private to the driver */ |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 310 | void *platform_data; /* Platform specific data, device |
| 311 | core doesn't touch it */ |
| 312 | void *firmware_data; /* Firmware specific data (e.g. ACPI, |
| 313 | BIOS data),reserved for device core*/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | struct dev_pm_info power; |
| 315 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | u64 *dma_mask; /* dma mask (if dma'able device) */ |
| 317 | u64 coherent_dma_mask;/* Like dma_mask, but for |
| 318 | alloc_coherent mappings as |
| 319 | not all hardware supports |
| 320 | 64 bit addresses for consistent |
| 321 | allocations such descriptors. */ |
| 322 | |
| 323 | struct list_head dma_pools; /* dma pools (if dma'ble) */ |
| 324 | |
| 325 | struct dma_coherent_mem *dma_mem; /* internal for coherent mem |
| 326 | override */ |
| 327 | |
| 328 | void (*release)(struct device * dev); |
| 329 | }; |
| 330 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | static inline void * |
| 332 | dev_get_drvdata (struct device *dev) |
| 333 | { |
| 334 | return dev->driver_data; |
| 335 | } |
| 336 | |
| 337 | static inline void |
| 338 | dev_set_drvdata (struct device *dev, void *data) |
| 339 | { |
| 340 | dev->driver_data = data; |
| 341 | } |
| 342 | |
Daniel Ritz | d305ef5 | 2005-09-22 00:47:24 -0700 | [diff] [blame] | 343 | static inline int device_is_registered(struct device *dev) |
| 344 | { |
| 345 | return klist_node_attached(&dev->knode_bus); |
| 346 | } |
| 347 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | /* |
| 349 | * High level routines for use by the bus drivers |
| 350 | */ |
| 351 | extern int device_register(struct device * dev); |
| 352 | extern void device_unregister(struct device * dev); |
| 353 | extern void device_initialize(struct device * dev); |
| 354 | extern int device_add(struct device * dev); |
| 355 | extern void device_del(struct device * dev); |
| 356 | extern int device_for_each_child(struct device *, void *, |
| 357 | int (*fn)(struct device *, void *)); |
| 358 | |
| 359 | /* |
| 360 | * Manual binding of a device to driver. See drivers/base/bus.c |
| 361 | * for information on use. |
| 362 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | extern void device_bind_driver(struct device * dev); |
| 364 | extern void device_release_driver(struct device * dev); |
| 365 | extern int device_attach(struct device * dev); |
| 366 | extern void driver_attach(struct device_driver * drv); |
| 367 | |
| 368 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 369 | /* |
| 370 | * Platform "fixup" functions - allow the platform to have their say |
| 371 | * about devices and actions that the general device layer doesn't |
| 372 | * know about. |
| 373 | */ |
| 374 | /* Notify platform of device discovery */ |
| 375 | extern int (*platform_notify)(struct device * dev); |
| 376 | |
| 377 | extern int (*platform_notify_remove)(struct device * dev); |
| 378 | |
| 379 | |
| 380 | /** |
| 381 | * get_device - atomically increment the reference count for the device. |
| 382 | * |
| 383 | */ |
| 384 | extern struct device * get_device(struct device * dev); |
| 385 | extern void put_device(struct device * dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | |
| 387 | |
| 388 | /* drivers/base/platform.c */ |
| 389 | |
| 390 | struct platform_device { |
Dmitry Torokhov | 8d790d7 | 2005-04-26 02:34:05 -0500 | [diff] [blame] | 391 | const char * name; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 392 | u32 id; |
| 393 | struct device dev; |
| 394 | u32 num_resources; |
| 395 | struct resource * resource; |
| 396 | }; |
| 397 | |
| 398 | #define to_platform_device(x) container_of((x), struct platform_device, dev) |
| 399 | |
| 400 | extern int platform_device_register(struct platform_device *); |
| 401 | extern void platform_device_unregister(struct platform_device *); |
| 402 | |
| 403 | extern struct bus_type platform_bus_type; |
| 404 | extern struct device platform_bus; |
| 405 | |
| 406 | extern struct resource *platform_get_resource(struct platform_device *, unsigned int, unsigned int); |
| 407 | extern int platform_get_irq(struct platform_device *, unsigned int); |
| 408 | extern struct resource *platform_get_resource_byname(struct platform_device *, unsigned int, char *); |
| 409 | extern int platform_get_irq_byname(struct platform_device *, char *); |
| 410 | extern int platform_add_devices(struct platform_device **, int); |
| 411 | |
| 412 | extern struct platform_device *platform_device_register_simple(char *, unsigned int, struct resource *, unsigned int); |
| 413 | |
| 414 | /* drivers/base/power.c */ |
| 415 | extern void device_shutdown(void); |
| 416 | |
| 417 | |
| 418 | /* drivers/base/firmware.c */ |
| 419 | extern int firmware_register(struct subsystem *); |
| 420 | extern void firmware_unregister(struct subsystem *); |
| 421 | |
| 422 | /* debugging and troubleshooting/diagnostic helpers. */ |
| 423 | #define dev_printk(level, dev, format, arg...) \ |
| 424 | printk(level "%s %s: " format , (dev)->driver ? (dev)->driver->name : "" , (dev)->bus_id , ## arg) |
| 425 | |
| 426 | #ifdef DEBUG |
| 427 | #define dev_dbg(dev, format, arg...) \ |
| 428 | dev_printk(KERN_DEBUG , dev , format , ## arg) |
| 429 | #else |
| 430 | #define dev_dbg(dev, format, arg...) do { (void)(dev); } while (0) |
| 431 | #endif |
| 432 | |
| 433 | #define dev_err(dev, format, arg...) \ |
| 434 | dev_printk(KERN_ERR , dev , format , ## arg) |
| 435 | #define dev_info(dev, format, arg...) \ |
| 436 | dev_printk(KERN_INFO , dev , format , ## arg) |
| 437 | #define dev_warn(dev, format, arg...) \ |
| 438 | dev_printk(KERN_WARNING , dev , format , ## arg) |
| 439 | |
| 440 | /* Create alias, so I can be autoloaded. */ |
| 441 | #define MODULE_ALIAS_CHARDEV(major,minor) \ |
| 442 | MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor)) |
| 443 | #define MODULE_ALIAS_CHARDEV_MAJOR(major) \ |
| 444 | MODULE_ALIAS("char-major-" __stringify(major) "-*") |
| 445 | #endif /* _DEVICE_H_ */ |