diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
commit | c71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch) | |
tree | ecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /include/linux/device.h | |
parent | ea53c912f8a86a8567697115b6a0d8152beee5c8 (diff) | |
parent | 6a00f206debf8a5c8899055726ad127dbeeed098 (diff) |
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts:
litmus/sched_cedf.c
Diffstat (limited to 'include/linux/device.h')
-rw-r--r-- | include/linux/device.h | 193 |
1 files changed, 173 insertions, 20 deletions
diff --git a/include/linux/device.h b/include/linux/device.h index 516fecacf27b..e4f62d8896b7 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
@@ -30,9 +30,8 @@ struct device_private; | |||
30 | struct device_driver; | 30 | struct device_driver; |
31 | struct driver_private; | 31 | struct driver_private; |
32 | struct class; | 32 | struct class; |
33 | struct class_private; | 33 | struct subsys_private; |
34 | struct bus_type; | 34 | struct bus_type; |
35 | struct bus_type_private; | ||
36 | struct device_node; | 35 | struct device_node; |
37 | 36 | ||
38 | struct bus_attribute { | 37 | struct bus_attribute { |
@@ -48,6 +47,38 @@ extern int __must_check bus_create_file(struct bus_type *, | |||
48 | struct bus_attribute *); | 47 | struct bus_attribute *); |
49 | extern void bus_remove_file(struct bus_type *, struct bus_attribute *); | 48 | extern void bus_remove_file(struct bus_type *, struct bus_attribute *); |
50 | 49 | ||
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 | */ | ||
51 | struct bus_type { | 82 | struct bus_type { |
52 | const char *name; | 83 | const char *name; |
53 | struct bus_attribute *bus_attrs; | 84 | struct bus_attribute *bus_attrs; |
@@ -65,7 +96,7 @@ struct bus_type { | |||
65 | 96 | ||
66 | const struct dev_pm_ops *pm; | 97 | const struct dev_pm_ops *pm; |
67 | 98 | ||
68 | struct bus_type_private *p; | 99 | struct subsys_private *p; |
69 | }; | 100 | }; |
70 | 101 | ||
71 | extern int __must_check bus_register(struct bus_type *bus); | 102 | extern int __must_check bus_register(struct bus_type *bus); |
@@ -120,6 +151,37 @@ extern int bus_unregister_notifier(struct bus_type *bus, | |||
120 | extern struct kset *bus_get_kset(struct bus_type *bus); | 151 | extern struct kset *bus_get_kset(struct bus_type *bus); |
121 | extern struct klist *bus_get_device_klist(struct bus_type *bus); | 152 | extern struct klist *bus_get_device_klist(struct bus_type *bus); |
122 | 153 | ||
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 | */ | ||
123 | struct device_driver { | 185 | struct device_driver { |
124 | const char *name; | 186 | const char *name; |
125 | struct bus_type *bus; | 187 | struct bus_type *bus; |
@@ -129,9 +191,7 @@ struct device_driver { | |||
129 | 191 | ||
130 | bool suppress_bind_attrs; /* disables bind/unbind via sysfs */ | 192 | bool suppress_bind_attrs; /* disables bind/unbind via sysfs */ |
131 | 193 | ||
132 | #if defined(CONFIG_OF) | ||
133 | const struct of_device_id *of_match_table; | 194 | const struct of_device_id *of_match_table; |
134 | #endif | ||
135 | 195 | ||
136 | int (*probe) (struct device *dev); | 196 | int (*probe) (struct device *dev); |
137 | int (*remove) (struct device *dev); | 197 | int (*remove) (struct device *dev); |
@@ -188,8 +248,34 @@ struct device *driver_find_device(struct device_driver *drv, | |||
188 | struct device *start, void *data, | 248 | struct device *start, void *data, |
189 | int (*match)(struct device *dev, void *data)); | 249 | int (*match)(struct device *dev, void *data)); |
190 | 250 | ||
191 | /* | 251 | /** |
192 | * device classes | 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. | ||
193 | */ | 279 | */ |
194 | struct class { | 280 | struct class { |
195 | const char *name; | 281 | const char *name; |
@@ -197,6 +283,7 @@ struct class { | |||
197 | 283 | ||
198 | struct class_attribute *class_attrs; | 284 | struct class_attribute *class_attrs; |
199 | struct device_attribute *dev_attrs; | 285 | struct device_attribute *dev_attrs; |
286 | struct bin_attribute *dev_bin_attrs; | ||
200 | struct kobject *dev_kobj; | 287 | struct kobject *dev_kobj; |
201 | 288 | ||
202 | int (*dev_uevent)(struct device *dev, struct kobj_uevent_env *env); | 289 | int (*dev_uevent)(struct device *dev, struct kobj_uevent_env *env); |
@@ -213,7 +300,7 @@ struct class { | |||
213 | 300 | ||
214 | const struct dev_pm_ops *pm; | 301 | const struct dev_pm_ops *pm; |
215 | 302 | ||
216 | struct class_private *p; | 303 | struct subsys_private *p; |
217 | }; | 304 | }; |
218 | 305 | ||
219 | struct class_dev_iter { | 306 | struct class_dev_iter { |
@@ -403,6 +490,64 @@ struct device_dma_parameters { | |||
403 | unsigned long segment_boundary_mask; | 490 | unsigned long segment_boundary_mask; |
404 | }; | 491 | }; |
405 | 492 | ||
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. | ||
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 | */ | ||
406 | struct device { | 551 | struct device { |
407 | struct device *parent; | 552 | struct device *parent; |
408 | 553 | ||
@@ -410,7 +555,7 @@ struct device { | |||
410 | 555 | ||
411 | struct kobject kobj; | 556 | struct kobject kobj; |
412 | const char *init_name; /* initial name of the device */ | 557 | const char *init_name; /* initial name of the device */ |
413 | struct device_type *type; | 558 | const struct device_type *type; |
414 | 559 | ||
415 | struct mutex mutex; /* mutex to synchronize calls to | 560 | struct mutex mutex; /* mutex to synchronize calls to |
416 | * its driver. | 561 | * its driver. |
@@ -422,6 +567,7 @@ struct device { | |||
422 | void *platform_data; /* Platform specific data, device | 567 | void *platform_data; /* Platform specific data, device |
423 | core doesn't touch it */ | 568 | core doesn't touch it */ |
424 | struct dev_pm_info power; | 569 | struct dev_pm_info power; |
570 | struct dev_power_domain *pwr_domain; | ||
425 | 571 | ||
426 | #ifdef CONFIG_NUMA | 572 | #ifdef CONFIG_NUMA |
427 | int numa_node; /* NUMA node this device is close to */ | 573 | int numa_node; /* NUMA node this device is close to */ |
@@ -441,9 +587,8 @@ struct device { | |||
441 | override */ | 587 | override */ |
442 | /* arch specific additions */ | 588 | /* arch specific additions */ |
443 | struct dev_archdata archdata; | 589 | struct dev_archdata archdata; |
444 | #ifdef CONFIG_OF | 590 | |
445 | struct device_node *of_node; | 591 | struct device_node *of_node; /* associated device tree node */ |
446 | #endif | ||
447 | 592 | ||
448 | dev_t devt; /* dev_t, creates the sysfs "dev" */ | 593 | dev_t devt; /* dev_t, creates the sysfs "dev" */ |
449 | 594 | ||
@@ -508,13 +653,13 @@ static inline int device_is_registered(struct device *dev) | |||
508 | 653 | ||
509 | static inline void device_enable_async_suspend(struct device *dev) | 654 | static inline void device_enable_async_suspend(struct device *dev) |
510 | { | 655 | { |
511 | if (dev->power.status == DPM_ON) | 656 | if (!dev->power.is_prepared) |
512 | dev->power.async_suspend = true; | 657 | dev->power.async_suspend = true; |
513 | } | 658 | } |
514 | 659 | ||
515 | static inline void device_disable_async_suspend(struct device *dev) | 660 | static inline void device_disable_async_suspend(struct device *dev) |
516 | { | 661 | { |
517 | if (dev->power.status == DPM_ON) | 662 | if (!dev->power.is_prepared) |
518 | dev->power.async_suspend = false; | 663 | dev->power.async_suspend = false; |
519 | } | 664 | } |
520 | 665 | ||
@@ -558,7 +703,7 @@ extern int device_move(struct device *dev, struct device *new_parent, | |||
558 | extern const char *device_get_devnode(struct device *dev, | 703 | extern const char *device_get_devnode(struct device *dev, |
559 | mode_t *mode, const char **tmp); | 704 | mode_t *mode, const char **tmp); |
560 | extern void *dev_get_drvdata(const struct device *dev); | 705 | extern void *dev_get_drvdata(const struct device *dev); |
561 | extern void dev_set_drvdata(struct device *dev, void *data); | 706 | extern int dev_set_drvdata(struct device *dev, void *data); |
562 | 707 | ||
563 | /* | 708 | /* |
564 | * Root device objects for grouping under /sys/devices | 709 | * Root device objects for grouping under /sys/devices |
@@ -612,7 +757,7 @@ extern int (*platform_notify)(struct device *dev); | |||
612 | extern int (*platform_notify_remove)(struct device *dev); | 757 | extern int (*platform_notify_remove)(struct device *dev); |
613 | 758 | ||
614 | 759 | ||
615 | /** | 760 | /* |
616 | * get_device - atomically increment the reference count for the device. | 761 | * get_device - atomically increment the reference count for the device. |
617 | * | 762 | * |
618 | */ | 763 | */ |
@@ -634,9 +779,6 @@ static inline int devtmpfs_mount(const char *mountpoint) { return 0; } | |||
634 | /* drivers/base/power/shutdown.c */ | 779 | /* drivers/base/power/shutdown.c */ |
635 | extern void device_shutdown(void); | 780 | extern void device_shutdown(void); |
636 | 781 | ||
637 | /* drivers/base/sys.c */ | ||
638 | extern void sysdev_shutdown(void); | ||
639 | |||
640 | /* debugging and troubleshooting/diagnostic helpers. */ | 782 | /* debugging and troubleshooting/diagnostic helpers. */ |
641 | extern const char *dev_driver_string(const struct device *dev); | 783 | extern const char *dev_driver_string(const struct device *dev); |
642 | 784 | ||
@@ -739,16 +881,27 @@ do { \ | |||
739 | #endif | 881 | #endif |
740 | 882 | ||
741 | /* | 883 | /* |
742 | * dev_WARN() acts like dev_printk(), but with the key difference | 884 | * dev_WARN*() acts like dev_printk(), but with the key difference |
743 | * of using a WARN/WARN_ON to get the message out, including the | 885 | * of using a WARN/WARN_ON to get the message out, including the |
744 | * file/line information and a backtrace. | 886 | * file/line information and a backtrace. |
745 | */ | 887 | */ |
746 | #define dev_WARN(dev, format, arg...) \ | 888 | #define dev_WARN(dev, format, arg...) \ |
747 | WARN(1, "Device: %s\n" format, dev_driver_string(dev), ## arg); | 889 | WARN(1, "Device: %s\n" format, dev_driver_string(dev), ## arg); |
748 | 890 | ||
891 | #define dev_WARN_ONCE(dev, condition, format, arg...) \ | ||
892 | WARN_ONCE(condition, "Device %s\n" format, \ | ||
893 | dev_driver_string(dev), ## arg) | ||
894 | |||
749 | /* Create alias, so I can be autoloaded. */ | 895 | /* Create alias, so I can be autoloaded. */ |
750 | #define MODULE_ALIAS_CHARDEV(major,minor) \ | 896 | #define MODULE_ALIAS_CHARDEV(major,minor) \ |
751 | MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor)) | 897 | MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor)) |
752 | #define MODULE_ALIAS_CHARDEV_MAJOR(major) \ | 898 | #define MODULE_ALIAS_CHARDEV_MAJOR(major) \ |
753 | MODULE_ALIAS("char-major-" __stringify(major) "-*") | 899 | MODULE_ALIAS("char-major-" __stringify(major) "-*") |
900 | |||
901 | #ifdef CONFIG_SYSFS_DEPRECATED | ||
902 | extern long sysfs_deprecated; | ||
903 | #else | ||
904 | #define sysfs_deprecated 0 | ||
905 | #endif | ||
906 | |||
754 | #endif /* _DEVICE_H_ */ | 907 | #endif /* _DEVICE_H_ */ |