diff options
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/compiler.h | 5 | ||||
-rw-r--r-- | include/linux/device.h | 99 | ||||
-rw-r--r-- | include/linux/kobject.h | 16 | ||||
-rw-r--r-- | include/linux/pci.h | 36 | ||||
-rw-r--r-- | include/linux/platform_device.h | 2 | ||||
-rw-r--r-- | include/linux/pm.h | 63 | ||||
-rw-r--r-- | include/linux/sysfs.h | 28 |
7 files changed, 167 insertions, 82 deletions
diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 9b4f11094937..060b96112ec6 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h | |||
@@ -99,6 +99,11 @@ extern void __chk_io_ptr(void __iomem *); | |||
99 | #define __must_check | 99 | #define __must_check |
100 | #endif | 100 | #endif |
101 | 101 | ||
102 | #ifndef CONFIG_ENABLE_MUST_CHECK | ||
103 | #undef __must_check | ||
104 | #define __must_check | ||
105 | #endif | ||
106 | |||
102 | /* | 107 | /* |
103 | * Allow us to avoid 'defined but not used' warnings on functions and data, | 108 | * Allow us to avoid 'defined but not used' warnings on functions and data, |
104 | * as well as force them to be emitted to the assembly file. | 109 | * as well as force them to be emitted to the assembly file. |
diff --git a/include/linux/device.h b/include/linux/device.h index 1e5f30da98bc..662e6a10144e 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/kobject.h> | 15 | #include <linux/kobject.h> |
16 | #include <linux/klist.h> | 16 | #include <linux/klist.h> |
17 | #include <linux/list.h> | 17 | #include <linux/list.h> |
18 | #include <linux/compiler.h> | ||
18 | #include <linux/types.h> | 19 | #include <linux/types.h> |
19 | #include <linux/module.h> | 20 | #include <linux/module.h> |
20 | #include <linux/pm.h> | 21 | #include <linux/pm.h> |
@@ -51,14 +52,17 @@ struct bus_type { | |||
51 | int (*probe)(struct device * dev); | 52 | int (*probe)(struct device * dev); |
52 | int (*remove)(struct device * dev); | 53 | int (*remove)(struct device * dev); |
53 | void (*shutdown)(struct device * dev); | 54 | void (*shutdown)(struct device * dev); |
54 | int (*suspend)(struct device * dev, pm_message_t state); | 55 | |
55 | int (*resume)(struct device * dev); | 56 | int (*suspend)(struct device * dev, pm_message_t state); |
57 | int (*suspend_late)(struct device * dev, pm_message_t state); | ||
58 | int (*resume_early)(struct device * dev); | ||
59 | int (*resume)(struct device * dev); | ||
56 | }; | 60 | }; |
57 | 61 | ||
58 | extern int bus_register(struct bus_type * bus); | 62 | extern int __must_check bus_register(struct bus_type * bus); |
59 | extern void bus_unregister(struct bus_type * bus); | 63 | extern void bus_unregister(struct bus_type * bus); |
60 | 64 | ||
61 | extern void bus_rescan_devices(struct bus_type * bus); | 65 | extern int __must_check bus_rescan_devices(struct bus_type * bus); |
62 | 66 | ||
63 | /* iterator helpers for buses */ | 67 | /* iterator helpers for buses */ |
64 | 68 | ||
@@ -67,9 +71,9 @@ int bus_for_each_dev(struct bus_type * bus, struct device * start, void * data, | |||
67 | struct device * bus_find_device(struct bus_type *bus, struct device *start, | 71 | struct device * bus_find_device(struct bus_type *bus, struct device *start, |
68 | void *data, int (*match)(struct device *, void *)); | 72 | void *data, int (*match)(struct device *, void *)); |
69 | 73 | ||
70 | int bus_for_each_drv(struct bus_type * bus, struct device_driver * start, | 74 | int __must_check bus_for_each_drv(struct bus_type *bus, |
71 | void * data, int (*fn)(struct device_driver *, void *)); | 75 | struct device_driver *start, void *data, |
72 | 76 | int (*fn)(struct device_driver *, void *)); | |
73 | 77 | ||
74 | /* driverfs interface for exporting bus attributes */ | 78 | /* driverfs interface for exporting bus attributes */ |
75 | 79 | ||
@@ -82,7 +86,8 @@ struct bus_attribute { | |||
82 | #define BUS_ATTR(_name,_mode,_show,_store) \ | 86 | #define BUS_ATTR(_name,_mode,_show,_store) \ |
83 | struct bus_attribute bus_attr_##_name = __ATTR(_name,_mode,_show,_store) | 87 | struct bus_attribute bus_attr_##_name = __ATTR(_name,_mode,_show,_store) |
84 | 88 | ||
85 | extern int bus_create_file(struct bus_type *, struct bus_attribute *); | 89 | extern int __must_check bus_create_file(struct bus_type *, |
90 | struct bus_attribute *); | ||
86 | extern void bus_remove_file(struct bus_type *, struct bus_attribute *); | 91 | extern void bus_remove_file(struct bus_type *, struct bus_attribute *); |
87 | 92 | ||
88 | struct device_driver { | 93 | struct device_driver { |
@@ -101,16 +106,18 @@ struct device_driver { | |||
101 | void (*shutdown) (struct device * dev); | 106 | void (*shutdown) (struct device * dev); |
102 | int (*suspend) (struct device * dev, pm_message_t state); | 107 | int (*suspend) (struct device * dev, pm_message_t state); |
103 | int (*resume) (struct device * dev); | 108 | int (*resume) (struct device * dev); |
109 | |||
110 | unsigned int multithread_probe:1; | ||
104 | }; | 111 | }; |
105 | 112 | ||
106 | 113 | ||
107 | extern int driver_register(struct device_driver * drv); | 114 | extern int __must_check driver_register(struct device_driver * drv); |
108 | extern void driver_unregister(struct device_driver * drv); | 115 | extern void driver_unregister(struct device_driver * drv); |
109 | 116 | ||
110 | extern struct device_driver * get_driver(struct device_driver * drv); | 117 | extern struct device_driver * get_driver(struct device_driver * drv); |
111 | extern void put_driver(struct device_driver * drv); | 118 | extern void put_driver(struct device_driver * drv); |
112 | extern struct device_driver *driver_find(const char *name, struct bus_type *bus); | 119 | extern struct device_driver *driver_find(const char *name, struct bus_type *bus); |
113 | 120 | extern int driver_probe_done(void); | |
114 | 121 | ||
115 | /* driverfs interface for exporting driver attributes */ | 122 | /* driverfs interface for exporting driver attributes */ |
116 | 123 | ||
@@ -123,16 +130,17 @@ struct driver_attribute { | |||
123 | #define DRIVER_ATTR(_name,_mode,_show,_store) \ | 130 | #define DRIVER_ATTR(_name,_mode,_show,_store) \ |
124 | struct driver_attribute driver_attr_##_name = __ATTR(_name,_mode,_show,_store) | 131 | struct driver_attribute driver_attr_##_name = __ATTR(_name,_mode,_show,_store) |
125 | 132 | ||
126 | extern int driver_create_file(struct device_driver *, struct driver_attribute *); | 133 | extern int __must_check driver_create_file(struct device_driver *, |
134 | struct driver_attribute *); | ||
127 | extern void driver_remove_file(struct device_driver *, struct driver_attribute *); | 135 | extern void driver_remove_file(struct device_driver *, struct driver_attribute *); |
128 | 136 | ||
129 | extern int driver_for_each_device(struct device_driver * drv, struct device * start, | 137 | extern int __must_check driver_for_each_device(struct device_driver * drv, |
130 | void * data, int (*fn)(struct device *, void *)); | 138 | struct device *start, void *data, |
139 | int (*fn)(struct device *, void *)); | ||
131 | struct device * driver_find_device(struct device_driver *drv, | 140 | struct device * driver_find_device(struct device_driver *drv, |
132 | struct device *start, void *data, | 141 | struct device *start, void *data, |
133 | int (*match)(struct device *, void *)); | 142 | int (*match)(struct device *, void *)); |
134 | 143 | ||
135 | |||
136 | /* | 144 | /* |
137 | * device classes | 145 | * device classes |
138 | */ | 146 | */ |
@@ -146,17 +154,26 @@ struct class { | |||
146 | struct list_head interfaces; | 154 | struct list_head interfaces; |
147 | struct semaphore sem; /* locks both the children and interfaces lists */ | 155 | struct semaphore sem; /* locks both the children and interfaces lists */ |
148 | 156 | ||
157 | struct kobject *virtual_dir; | ||
158 | |||
149 | struct class_attribute * class_attrs; | 159 | struct class_attribute * class_attrs; |
150 | struct class_device_attribute * class_dev_attrs; | 160 | struct class_device_attribute * class_dev_attrs; |
161 | struct device_attribute * dev_attrs; | ||
151 | 162 | ||
152 | int (*uevent)(struct class_device *dev, char **envp, | 163 | int (*uevent)(struct class_device *dev, char **envp, |
153 | int num_envp, char *buffer, int buffer_size); | 164 | int num_envp, char *buffer, int buffer_size); |
165 | int (*dev_uevent)(struct device *dev, char **envp, int num_envp, | ||
166 | char *buffer, int buffer_size); | ||
154 | 167 | ||
155 | void (*release)(struct class_device *dev); | 168 | void (*release)(struct class_device *dev); |
156 | void (*class_release)(struct class *class); | 169 | void (*class_release)(struct class *class); |
170 | void (*dev_release)(struct device *dev); | ||
171 | |||
172 | int (*suspend)(struct device *, pm_message_t state); | ||
173 | int (*resume)(struct device *); | ||
157 | }; | 174 | }; |
158 | 175 | ||
159 | extern int class_register(struct class *); | 176 | extern int __must_check class_register(struct class *); |
160 | extern void class_unregister(struct class *); | 177 | extern void class_unregister(struct class *); |
161 | 178 | ||
162 | 179 | ||
@@ -169,7 +186,8 @@ struct class_attribute { | |||
169 | #define CLASS_ATTR(_name,_mode,_show,_store) \ | 186 | #define CLASS_ATTR(_name,_mode,_show,_store) \ |
170 | struct class_attribute class_attr_##_name = __ATTR(_name,_mode,_show,_store) | 187 | struct class_attribute class_attr_##_name = __ATTR(_name,_mode,_show,_store) |
171 | 188 | ||
172 | extern int class_create_file(struct class *, const struct class_attribute *); | 189 | extern int __must_check class_create_file(struct class *, |
190 | const struct class_attribute *); | ||
173 | extern void class_remove_file(struct class *, const struct class_attribute *); | 191 | extern void class_remove_file(struct class *, const struct class_attribute *); |
174 | 192 | ||
175 | struct class_device_attribute { | 193 | struct class_device_attribute { |
@@ -182,7 +200,7 @@ struct class_device_attribute { | |||
182 | struct class_device_attribute class_device_attr_##_name = \ | 200 | struct class_device_attribute class_device_attr_##_name = \ |
183 | __ATTR(_name,_mode,_show,_store) | 201 | __ATTR(_name,_mode,_show,_store) |
184 | 202 | ||
185 | extern int class_device_create_file(struct class_device *, | 203 | extern int __must_check class_device_create_file(struct class_device *, |
186 | const struct class_device_attribute *); | 204 | const struct class_device_attribute *); |
187 | 205 | ||
188 | /** | 206 | /** |
@@ -242,10 +260,10 @@ class_set_devdata (struct class_device *dev, void *data) | |||
242 | } | 260 | } |
243 | 261 | ||
244 | 262 | ||
245 | extern int class_device_register(struct class_device *); | 263 | extern int __must_check class_device_register(struct class_device *); |
246 | extern void class_device_unregister(struct class_device *); | 264 | extern void class_device_unregister(struct class_device *); |
247 | extern void class_device_initialize(struct class_device *); | 265 | extern void class_device_initialize(struct class_device *); |
248 | extern int class_device_add(struct class_device *); | 266 | extern int __must_check class_device_add(struct class_device *); |
249 | extern void class_device_del(struct class_device *); | 267 | extern void class_device_del(struct class_device *); |
250 | 268 | ||
251 | extern int class_device_rename(struct class_device *, char *); | 269 | extern int class_device_rename(struct class_device *, char *); |
@@ -255,7 +273,7 @@ extern void class_device_put(struct class_device *); | |||
255 | 273 | ||
256 | extern void class_device_remove_file(struct class_device *, | 274 | extern void class_device_remove_file(struct class_device *, |
257 | const struct class_device_attribute *); | 275 | const struct class_device_attribute *); |
258 | extern int class_device_create_bin_file(struct class_device *, | 276 | extern int __must_check class_device_create_bin_file(struct class_device *, |
259 | struct bin_attribute *); | 277 | struct bin_attribute *); |
260 | extern void class_device_remove_bin_file(struct class_device *, | 278 | extern void class_device_remove_bin_file(struct class_device *, |
261 | struct bin_attribute *); | 279 | struct bin_attribute *); |
@@ -266,22 +284,23 @@ struct class_interface { | |||
266 | 284 | ||
267 | int (*add) (struct class_device *, struct class_interface *); | 285 | int (*add) (struct class_device *, struct class_interface *); |
268 | void (*remove) (struct class_device *, struct class_interface *); | 286 | void (*remove) (struct class_device *, struct class_interface *); |
287 | int (*add_dev) (struct device *, struct class_interface *); | ||
288 | void (*remove_dev) (struct device *, struct class_interface *); | ||
269 | }; | 289 | }; |
270 | 290 | ||
271 | extern int class_interface_register(struct class_interface *); | 291 | extern int __must_check class_interface_register(struct class_interface *); |
272 | extern void class_interface_unregister(struct class_interface *); | 292 | extern void class_interface_unregister(struct class_interface *); |
273 | 293 | ||
274 | extern struct class *class_create(struct module *owner, char *name); | 294 | extern struct class *class_create(struct module *owner, const char *name); |
275 | extern void class_destroy(struct class *cls); | 295 | extern void class_destroy(struct class *cls); |
276 | extern struct class_device *class_device_create(struct class *cls, | 296 | extern struct class_device *class_device_create(struct class *cls, |
277 | struct class_device *parent, | 297 | struct class_device *parent, |
278 | dev_t devt, | 298 | dev_t devt, |
279 | struct device *device, | 299 | struct device *device, |
280 | char *fmt, ...) | 300 | const char *fmt, ...) |
281 | __attribute__((format(printf,5,6))); | 301 | __attribute__((format(printf,5,6))); |
282 | extern void class_device_destroy(struct class *cls, dev_t devt); | 302 | extern void class_device_destroy(struct class *cls, dev_t devt); |
283 | 303 | ||
284 | |||
285 | /* interface for exporting device attributes */ | 304 | /* interface for exporting device attributes */ |
286 | struct device_attribute { | 305 | struct device_attribute { |
287 | struct attribute attr; | 306 | struct attribute attr; |
@@ -294,8 +313,13 @@ struct device_attribute { | |||
294 | #define DEVICE_ATTR(_name,_mode,_show,_store) \ | 313 | #define DEVICE_ATTR(_name,_mode,_show,_store) \ |
295 | struct device_attribute dev_attr_##_name = __ATTR(_name,_mode,_show,_store) | 314 | struct device_attribute dev_attr_##_name = __ATTR(_name,_mode,_show,_store) |
296 | 315 | ||
297 | extern int device_create_file(struct device *device, struct device_attribute * entry); | 316 | extern int __must_check device_create_file(struct device *device, |
317 | struct device_attribute * entry); | ||
298 | extern void device_remove_file(struct device * dev, struct device_attribute * attr); | 318 | extern void device_remove_file(struct device * dev, struct device_attribute * attr); |
319 | extern int __must_check device_create_bin_file(struct device *dev, | ||
320 | struct bin_attribute *attr); | ||
321 | extern void device_remove_bin_file(struct device *dev, | ||
322 | struct bin_attribute *attr); | ||
299 | struct device { | 323 | struct device { |
300 | struct klist klist_children; | 324 | struct klist klist_children; |
301 | struct klist_node knode_parent; /* node in sibling list */ | 325 | struct klist_node knode_parent; /* node in sibling list */ |
@@ -305,6 +329,7 @@ struct device { | |||
305 | 329 | ||
306 | struct kobject kobj; | 330 | struct kobject kobj; |
307 | char bus_id[BUS_ID_SIZE]; /* position on parent bus */ | 331 | char bus_id[BUS_ID_SIZE]; /* position on parent bus */ |
332 | unsigned is_registered:1; | ||
308 | struct device_attribute uevent_attr; | 333 | struct device_attribute uevent_attr; |
309 | struct device_attribute *devt_attr; | 334 | struct device_attribute *devt_attr; |
310 | 335 | ||
@@ -338,6 +363,7 @@ struct device { | |||
338 | struct list_head node; | 363 | struct list_head node; |
339 | struct class *class; /* optional*/ | 364 | struct class *class; /* optional*/ |
340 | dev_t devt; /* dev_t, creates the sysfs "dev" */ | 365 | dev_t devt; /* dev_t, creates the sysfs "dev" */ |
366 | struct attribute_group **groups; /* optional groups */ | ||
341 | 367 | ||
342 | void (*release)(struct device * dev); | 368 | void (*release)(struct device * dev); |
343 | }; | 369 | }; |
@@ -356,38 +382,41 @@ dev_set_drvdata (struct device *dev, void *data) | |||
356 | 382 | ||
357 | static inline int device_is_registered(struct device *dev) | 383 | static inline int device_is_registered(struct device *dev) |
358 | { | 384 | { |
359 | return klist_node_attached(&dev->knode_bus); | 385 | return dev->is_registered; |
360 | } | 386 | } |
361 | 387 | ||
362 | /* | 388 | /* |
363 | * High level routines for use by the bus drivers | 389 | * High level routines for use by the bus drivers |
364 | */ | 390 | */ |
365 | extern int device_register(struct device * dev); | 391 | extern int __must_check device_register(struct device * dev); |
366 | extern void device_unregister(struct device * dev); | 392 | extern void device_unregister(struct device * dev); |
367 | extern void device_initialize(struct device * dev); | 393 | extern void device_initialize(struct device * dev); |
368 | extern int device_add(struct device * dev); | 394 | extern int __must_check device_add(struct device * dev); |
369 | extern void device_del(struct device * dev); | 395 | extern void device_del(struct device * dev); |
370 | extern int device_for_each_child(struct device *, void *, | 396 | extern int __must_check device_for_each_child(struct device *, void *, |
371 | int (*fn)(struct device *, void *)); | 397 | int (*fn)(struct device *, void *)); |
398 | extern int device_rename(struct device *dev, char *new_name); | ||
372 | 399 | ||
373 | /* | 400 | /* |
374 | * Manual binding of a device to driver. See drivers/base/bus.c | 401 | * Manual binding of a device to driver. See drivers/base/bus.c |
375 | * for information on use. | 402 | * for information on use. |
376 | */ | 403 | */ |
377 | extern void device_bind_driver(struct device * dev); | 404 | extern int __must_check device_bind_driver(struct device *dev); |
378 | extern void device_release_driver(struct device * dev); | 405 | extern void device_release_driver(struct device * dev); |
379 | extern int device_attach(struct device * dev); | 406 | extern int __must_check device_attach(struct device * dev); |
380 | extern void driver_attach(struct device_driver * drv); | 407 | extern int __must_check driver_attach(struct device_driver *drv); |
381 | extern void device_reprobe(struct device *dev); | 408 | extern int __must_check device_reprobe(struct device *dev); |
382 | 409 | ||
383 | /* | 410 | /* |
384 | * Easy functions for dynamically creating devices on the fly | 411 | * Easy functions for dynamically creating devices on the fly |
385 | */ | 412 | */ |
386 | extern struct device *device_create(struct class *cls, struct device *parent, | 413 | extern struct device *device_create(struct class *cls, struct device *parent, |
387 | dev_t devt, char *fmt, ...) | 414 | dev_t devt, const char *fmt, ...) |
388 | __attribute__((format(printf,4,5))); | 415 | __attribute__((format(printf,4,5))); |
389 | extern void device_destroy(struct class *cls, dev_t devt); | 416 | extern void device_destroy(struct class *cls, dev_t devt); |
390 | 417 | ||
418 | extern int virtual_device_parent(struct device *dev); | ||
419 | |||
391 | /* | 420 | /* |
392 | * Platform "fixup" functions - allow the platform to have their say | 421 | * Platform "fixup" functions - allow the platform to have their say |
393 | * about devices and actions that the general device layer doesn't | 422 | * about devices and actions that the general device layer doesn't |
@@ -412,7 +441,7 @@ extern void device_shutdown(void); | |||
412 | 441 | ||
413 | 442 | ||
414 | /* drivers/base/firmware.c */ | 443 | /* drivers/base/firmware.c */ |
415 | extern int firmware_register(struct subsystem *); | 444 | extern int __must_check firmware_register(struct subsystem *); |
416 | extern void firmware_unregister(struct subsystem *); | 445 | extern void firmware_unregister(struct subsystem *); |
417 | 446 | ||
418 | /* debugging and troubleshooting/diagnostic helpers. */ | 447 | /* debugging and troubleshooting/diagnostic helpers. */ |
diff --git a/include/linux/kobject.h b/include/linux/kobject.h index 2d229327959e..bcd9cd173c2c 100644 --- a/include/linux/kobject.h +++ b/include/linux/kobject.h | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/types.h> | 20 | #include <linux/types.h> |
21 | #include <linux/list.h> | 21 | #include <linux/list.h> |
22 | #include <linux/sysfs.h> | 22 | #include <linux/sysfs.h> |
23 | #include <linux/compiler.h> | ||
23 | #include <linux/spinlock.h> | 24 | #include <linux/spinlock.h> |
24 | #include <linux/rwsem.h> | 25 | #include <linux/rwsem.h> |
25 | #include <linux/kref.h> | 26 | #include <linux/kref.h> |
@@ -71,12 +72,12 @@ static inline const char * kobject_name(const struct kobject * kobj) | |||
71 | extern void kobject_init(struct kobject *); | 72 | extern void kobject_init(struct kobject *); |
72 | extern void kobject_cleanup(struct kobject *); | 73 | extern void kobject_cleanup(struct kobject *); |
73 | 74 | ||
74 | extern int kobject_add(struct kobject *); | 75 | extern int __must_check kobject_add(struct kobject *); |
75 | extern void kobject_del(struct kobject *); | 76 | extern void kobject_del(struct kobject *); |
76 | 77 | ||
77 | extern int kobject_rename(struct kobject *, const char *new_name); | 78 | extern int __must_check kobject_rename(struct kobject *, const char *new_name); |
78 | 79 | ||
79 | extern int kobject_register(struct kobject *); | 80 | extern int __must_check kobject_register(struct kobject *); |
80 | extern void kobject_unregister(struct kobject *); | 81 | extern void kobject_unregister(struct kobject *); |
81 | 82 | ||
82 | extern struct kobject * kobject_get(struct kobject *); | 83 | extern struct kobject * kobject_get(struct kobject *); |
@@ -128,8 +129,8 @@ struct kset { | |||
128 | 129 | ||
129 | 130 | ||
130 | extern void kset_init(struct kset * k); | 131 | extern void kset_init(struct kset * k); |
131 | extern int kset_add(struct kset * k); | 132 | extern int __must_check kset_add(struct kset * k); |
132 | extern int kset_register(struct kset * k); | 133 | extern int __must_check kset_register(struct kset * k); |
133 | extern void kset_unregister(struct kset * k); | 134 | extern void kset_unregister(struct kset * k); |
134 | 135 | ||
135 | static inline struct kset * to_kset(struct kobject * kobj) | 136 | static inline struct kset * to_kset(struct kobject * kobj) |
@@ -239,7 +240,7 @@ extern struct subsystem hypervisor_subsys; | |||
239 | (obj)->subsys.kset.kobj.kset = &(_subsys).kset | 240 | (obj)->subsys.kset.kobj.kset = &(_subsys).kset |
240 | 241 | ||
241 | extern void subsystem_init(struct subsystem *); | 242 | extern void subsystem_init(struct subsystem *); |
242 | extern int subsystem_register(struct subsystem *); | 243 | extern int __must_check subsystem_register(struct subsystem *); |
243 | extern void subsystem_unregister(struct subsystem *); | 244 | extern void subsystem_unregister(struct subsystem *); |
244 | 245 | ||
245 | static inline struct subsystem * subsys_get(struct subsystem * s) | 246 | static inline struct subsystem * subsys_get(struct subsystem * s) |
@@ -258,7 +259,8 @@ struct subsys_attribute { | |||
258 | ssize_t (*store)(struct subsystem *, const char *, size_t); | 259 | ssize_t (*store)(struct subsystem *, const char *, size_t); |
259 | }; | 260 | }; |
260 | 261 | ||
261 | extern int subsys_create_file(struct subsystem * , struct subsys_attribute *); | 262 | extern int __must_check subsys_create_file(struct subsystem * , |
263 | struct subsys_attribute *); | ||
262 | 264 | ||
263 | #if defined(CONFIG_HOTPLUG) | 265 | #if defined(CONFIG_HOTPLUG) |
264 | void kobject_uevent(struct kobject *kobj, enum kobject_action action); | 266 | void kobject_uevent(struct kobject *kobj, enum kobject_action action); |
diff --git a/include/linux/pci.h b/include/linux/pci.h index 8565b81d7fbc..3ec72551ac31 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
@@ -49,6 +49,7 @@ | |||
49 | #include <linux/types.h> | 49 | #include <linux/types.h> |
50 | #include <linux/ioport.h> | 50 | #include <linux/ioport.h> |
51 | #include <linux/list.h> | 51 | #include <linux/list.h> |
52 | #include <linux/compiler.h> | ||
52 | #include <linux/errno.h> | 53 | #include <linux/errno.h> |
53 | #include <linux/device.h> | 54 | #include <linux/device.h> |
54 | 55 | ||
@@ -346,6 +347,8 @@ struct pci_driver { | |||
346 | int (*probe) (struct pci_dev *dev, const struct pci_device_id *id); /* New device inserted */ | 347 | int (*probe) (struct pci_dev *dev, const struct pci_device_id *id); /* New device inserted */ |
347 | void (*remove) (struct pci_dev *dev); /* Device removed (NULL if not a hot-plug capable driver) */ | 348 | void (*remove) (struct pci_dev *dev); /* Device removed (NULL if not a hot-plug capable driver) */ |
348 | int (*suspend) (struct pci_dev *dev, pm_message_t state); /* Device suspended */ | 349 | int (*suspend) (struct pci_dev *dev, pm_message_t state); /* Device suspended */ |
350 | int (*suspend_late) (struct pci_dev *dev, pm_message_t state); | ||
351 | int (*resume_early) (struct pci_dev *dev); | ||
349 | int (*resume) (struct pci_dev *dev); /* Device woken up */ | 352 | int (*resume) (struct pci_dev *dev); /* Device woken up */ |
350 | int (*enable_wake) (struct pci_dev *dev, pci_power_t state, int enable); /* Enable wake event */ | 353 | int (*enable_wake) (struct pci_dev *dev, pci_power_t state, int enable); /* Enable wake event */ |
351 | void (*shutdown) (struct pci_dev *dev); | 354 | void (*shutdown) (struct pci_dev *dev); |
@@ -401,7 +404,7 @@ extern struct list_head pci_root_buses; /* list of all known PCI buses */ | |||
401 | extern struct list_head pci_devices; /* list of all devices */ | 404 | extern struct list_head pci_devices; /* list of all devices */ |
402 | 405 | ||
403 | void pcibios_fixup_bus(struct pci_bus *); | 406 | void pcibios_fixup_bus(struct pci_bus *); |
404 | int pcibios_enable_device(struct pci_dev *, int mask); | 407 | int __must_check pcibios_enable_device(struct pci_dev *, int mask); |
405 | char *pcibios_setup (char *str); | 408 | char *pcibios_setup (char *str); |
406 | 409 | ||
407 | /* Used only when drivers/pci/setup.c is used */ | 410 | /* Used only when drivers/pci/setup.c is used */ |
@@ -488,19 +491,19 @@ static inline int pci_write_config_dword(struct pci_dev *dev, int where, u32 val | |||
488 | return pci_bus_write_config_dword (dev->bus, dev->devfn, where, val); | 491 | return pci_bus_write_config_dword (dev->bus, dev->devfn, where, val); |
489 | } | 492 | } |
490 | 493 | ||
491 | int pci_enable_device(struct pci_dev *dev); | 494 | int __must_check pci_enable_device(struct pci_dev *dev); |
492 | int pci_enable_device_bars(struct pci_dev *dev, int mask); | 495 | int __must_check pci_enable_device_bars(struct pci_dev *dev, int mask); |
493 | void pci_disable_device(struct pci_dev *dev); | 496 | void pci_disable_device(struct pci_dev *dev); |
494 | void pci_set_master(struct pci_dev *dev); | 497 | void pci_set_master(struct pci_dev *dev); |
495 | #define HAVE_PCI_SET_MWI | 498 | #define HAVE_PCI_SET_MWI |
496 | int pci_set_mwi(struct pci_dev *dev); | 499 | int __must_check pci_set_mwi(struct pci_dev *dev); |
497 | void pci_clear_mwi(struct pci_dev *dev); | 500 | void pci_clear_mwi(struct pci_dev *dev); |
498 | void pci_intx(struct pci_dev *dev, int enable); | 501 | void pci_intx(struct pci_dev *dev, int enable); |
499 | int pci_set_dma_mask(struct pci_dev *dev, u64 mask); | 502 | int pci_set_dma_mask(struct pci_dev *dev, u64 mask); |
500 | int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask); | 503 | int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask); |
501 | void pci_update_resource(struct pci_dev *dev, struct resource *res, int resno); | 504 | void pci_update_resource(struct pci_dev *dev, struct resource *res, int resno); |
502 | int pci_assign_resource(struct pci_dev *dev, int i); | 505 | int __must_check pci_assign_resource(struct pci_dev *dev, int i); |
503 | int pci_assign_resource_fixed(struct pci_dev *dev, int i); | 506 | int __must_check pci_assign_resource_fixed(struct pci_dev *dev, int i); |
504 | void pci_restore_bars(struct pci_dev *dev); | 507 | void pci_restore_bars(struct pci_dev *dev); |
505 | 508 | ||
506 | /* ROM control related routines */ | 509 | /* ROM control related routines */ |
@@ -526,23 +529,24 @@ void pdev_sort_resources(struct pci_dev *, struct resource_list *); | |||
526 | void pci_fixup_irqs(u8 (*)(struct pci_dev *, u8 *), | 529 | void pci_fixup_irqs(u8 (*)(struct pci_dev *, u8 *), |
527 | int (*)(struct pci_dev *, u8, u8)); | 530 | int (*)(struct pci_dev *, u8, u8)); |
528 | #define HAVE_PCI_REQ_REGIONS 2 | 531 | #define HAVE_PCI_REQ_REGIONS 2 |
529 | int pci_request_regions(struct pci_dev *, const char *); | 532 | int __must_check pci_request_regions(struct pci_dev *, const char *); |
530 | void pci_release_regions(struct pci_dev *); | 533 | void pci_release_regions(struct pci_dev *); |
531 | int pci_request_region(struct pci_dev *, int, const char *); | 534 | int __must_check pci_request_region(struct pci_dev *, int, const char *); |
532 | void pci_release_region(struct pci_dev *, int); | 535 | void pci_release_region(struct pci_dev *, int); |
533 | 536 | ||
534 | /* drivers/pci/bus.c */ | 537 | /* drivers/pci/bus.c */ |
535 | int pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res, | 538 | int __must_check pci_bus_alloc_resource(struct pci_bus *bus, |
536 | resource_size_t size, resource_size_t align, | 539 | struct resource *res, resource_size_t size, |
537 | resource_size_t min, unsigned int type_mask, | 540 | resource_size_t align, resource_size_t min, |
538 | void (*alignf)(void *, struct resource *, | 541 | unsigned int type_mask, |
539 | resource_size_t, resource_size_t), | 542 | void (*alignf)(void *, struct resource *, |
540 | void *alignf_data); | 543 | resource_size_t, resource_size_t), |
544 | void *alignf_data); | ||
541 | void pci_enable_bridges(struct pci_bus *bus); | 545 | void pci_enable_bridges(struct pci_bus *bus); |
542 | 546 | ||
543 | /* Proper probing supporting hot-pluggable devices */ | 547 | /* Proper probing supporting hot-pluggable devices */ |
544 | int __pci_register_driver(struct pci_driver *, struct module *); | 548 | int __must_check __pci_register_driver(struct pci_driver *, struct module *); |
545 | static inline int pci_register_driver(struct pci_driver *driver) | 549 | static inline int __must_check pci_register_driver(struct pci_driver *driver) |
546 | { | 550 | { |
547 | return __pci_register_driver(driver, THIS_MODULE); | 551 | return __pci_register_driver(driver, THIS_MODULE); |
548 | } | 552 | } |
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h index 782090c68932..29cd6dee13db 100644 --- a/include/linux/platform_device.h +++ b/include/linux/platform_device.h | |||
@@ -49,6 +49,8 @@ struct platform_driver { | |||
49 | int (*remove)(struct platform_device *); | 49 | int (*remove)(struct platform_device *); |
50 | void (*shutdown)(struct platform_device *); | 50 | void (*shutdown)(struct platform_device *); |
51 | int (*suspend)(struct platform_device *, pm_message_t state); | 51 | int (*suspend)(struct platform_device *, pm_message_t state); |
52 | int (*suspend_late)(struct platform_device *, pm_message_t state); | ||
53 | int (*resume_early)(struct platform_device *); | ||
52 | int (*resume)(struct platform_device *); | 54 | int (*resume)(struct platform_device *); |
53 | struct device_driver driver; | 55 | struct device_driver driver; |
54 | }; | 56 | }; |
diff --git a/include/linux/pm.h b/include/linux/pm.h index 658c1b93d5bb..6b27e07aef19 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h | |||
@@ -142,29 +142,61 @@ typedef struct pm_message { | |||
142 | } pm_message_t; | 142 | } pm_message_t; |
143 | 143 | ||
144 | /* | 144 | /* |
145 | * There are 4 important states driver can be in: | 145 | * Several driver power state transitions are externally visible, affecting |
146 | * ON -- driver is working | 146 | * the state of pending I/O queues and (for drivers that touch hardware) |
147 | * FREEZE -- stop operations and apply whatever policy is applicable to a | 147 | * interrupts, wakeups, DMA, and other hardware state. There may also be |
148 | * suspended driver of that class, freeze queues for block like IDE | 148 | * internal transitions to various low power modes, which are transparent |
149 | * does, drop packets for ethernet, etc... stop DMA engine too etc... | 149 | * to the rest of the driver stack (such as a driver that's ON gating off |
150 | * so a consistent image can be saved; but do not power any hardware | 150 | * clocks which are not in active use). |
151 | * down. | ||
152 | * SUSPEND - like FREEZE, but hardware is doing as much powersaving as | ||
153 | * possible. Roughly pci D3. | ||
154 | * | 151 | * |
155 | * Unfortunately, current drivers only recognize numeric values 0 (ON) and 3 | 152 | * One transition is triggered by resume(), after a suspend() call; the |
156 | * (SUSPEND). We'll need to fix the drivers. So yes, putting 3 to all different | 153 | * message is implicit: |
157 | * defines is intentional, and will go away as soon as drivers are fixed. Also | 154 | * |
158 | * note that typedef is neccessary, we'll probably want to switch to | 155 | * ON Driver starts working again, responding to hardware events |
159 | * typedef struct pm_message_t { int event; int flags; } pm_message_t | 156 | * and software requests. The hardware may have gone through |
160 | * or something similar soon. | 157 | * a power-off reset, or it may have maintained state from the |
158 | * previous suspend() which the driver will rely on while | ||
159 | * resuming. On most platforms, there are no restrictions on | ||
160 | * availability of resources like clocks during resume(). | ||
161 | * | ||
162 | * Other transitions are triggered by messages sent using suspend(). All | ||
163 | * these transitions quiesce the driver, so that I/O queues are inactive. | ||
164 | * That commonly entails turning off IRQs and DMA; there may be rules | ||
165 | * about how to quiesce that are specific to the bus or the device's type. | ||
166 | * (For example, network drivers mark the link state.) Other details may | ||
167 | * differ according to the message: | ||
168 | * | ||
169 | * SUSPEND Quiesce, enter a low power device state appropriate for | ||
170 | * the upcoming system state (such as PCI_D3hot), and enable | ||
171 | * wakeup events as appropriate. | ||
172 | * | ||
173 | * FREEZE Quiesce operations so that a consistent image can be saved; | ||
174 | * but do NOT otherwise enter a low power device state, and do | ||
175 | * NOT emit system wakeup events. | ||
176 | * | ||
177 | * PRETHAW Quiesce as if for FREEZE; additionally, prepare for restoring | ||
178 | * the system from a snapshot taken after an earlier FREEZE. | ||
179 | * Some drivers will need to reset their hardware state instead | ||
180 | * of preserving it, to ensure that it's never mistaken for the | ||
181 | * state which that earlier snapshot had set up. | ||
182 | * | ||
183 | * A minimally power-aware driver treats all messages as SUSPEND, fully | ||
184 | * reinitializes its device during resume() -- whether or not it was reset | ||
185 | * during the suspend/resume cycle -- and can't issue wakeup events. | ||
186 | * | ||
187 | * More power-aware drivers may also use low power states at runtime as | ||
188 | * well as during system sleep states like PM_SUSPEND_STANDBY. They may | ||
189 | * be able to use wakeup events to exit from runtime low-power states, | ||
190 | * or from system low-power states such as standby or suspend-to-RAM. | ||
161 | */ | 191 | */ |
162 | 192 | ||
163 | #define PM_EVENT_ON 0 | 193 | #define PM_EVENT_ON 0 |
164 | #define PM_EVENT_FREEZE 1 | 194 | #define PM_EVENT_FREEZE 1 |
165 | #define PM_EVENT_SUSPEND 2 | 195 | #define PM_EVENT_SUSPEND 2 |
196 | #define PM_EVENT_PRETHAW 3 | ||
166 | 197 | ||
167 | #define PMSG_FREEZE ((struct pm_message){ .event = PM_EVENT_FREEZE, }) | 198 | #define PMSG_FREEZE ((struct pm_message){ .event = PM_EVENT_FREEZE, }) |
199 | #define PMSG_PRETHAW ((struct pm_message){ .event = PM_EVENT_PRETHAW, }) | ||
168 | #define PMSG_SUSPEND ((struct pm_message){ .event = PM_EVENT_SUSPEND, }) | 200 | #define PMSG_SUSPEND ((struct pm_message){ .event = PM_EVENT_SUSPEND, }) |
169 | #define PMSG_ON ((struct pm_message){ .event = PM_EVENT_ON, }) | 201 | #define PMSG_ON ((struct pm_message){ .event = PM_EVENT_ON, }) |
170 | 202 | ||
@@ -190,6 +222,7 @@ extern void device_resume(void); | |||
190 | extern suspend_disk_method_t pm_disk_mode; | 222 | extern suspend_disk_method_t pm_disk_mode; |
191 | 223 | ||
192 | extern int device_suspend(pm_message_t state); | 224 | extern int device_suspend(pm_message_t state); |
225 | extern int device_prepare_suspend(pm_message_t state); | ||
193 | 226 | ||
194 | #define device_set_wakeup_enable(dev,val) \ | 227 | #define device_set_wakeup_enable(dev,val) \ |
195 | ((dev)->power.should_wakeup = !!(val)) | 228 | ((dev)->power.should_wakeup = !!(val)) |
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h index 1ea5d3cda6ae..6d5c43d31dec 100644 --- a/include/linux/sysfs.h +++ b/include/linux/sysfs.h | |||
@@ -10,6 +10,7 @@ | |||
10 | #ifndef _SYSFS_H_ | 10 | #ifndef _SYSFS_H_ |
11 | #define _SYSFS_H_ | 11 | #define _SYSFS_H_ |
12 | 12 | ||
13 | #include <linux/compiler.h> | ||
13 | #include <asm/atomic.h> | 14 | #include <asm/atomic.h> |
14 | 15 | ||
15 | struct kobject; | 16 | struct kobject; |
@@ -86,40 +87,44 @@ struct sysfs_dirent { | |||
86 | 87 | ||
87 | #ifdef CONFIG_SYSFS | 88 | #ifdef CONFIG_SYSFS |
88 | 89 | ||
89 | extern int | 90 | extern int __must_check |
90 | sysfs_create_dir(struct kobject *); | 91 | sysfs_create_dir(struct kobject *); |
91 | 92 | ||
92 | extern void | 93 | extern void |
93 | sysfs_remove_dir(struct kobject *); | 94 | sysfs_remove_dir(struct kobject *); |
94 | 95 | ||
95 | extern int | 96 | extern int __must_check |
96 | sysfs_rename_dir(struct kobject *, const char *new_name); | 97 | sysfs_rename_dir(struct kobject *, const char *new_name); |
97 | 98 | ||
98 | extern int | 99 | extern int __must_check |
99 | sysfs_create_file(struct kobject *, const struct attribute *); | 100 | sysfs_create_file(struct kobject *, const struct attribute *); |
100 | 101 | ||
101 | extern int | 102 | extern int __must_check |
102 | sysfs_update_file(struct kobject *, const struct attribute *); | 103 | sysfs_update_file(struct kobject *, const struct attribute *); |
103 | 104 | ||
104 | extern int | 105 | extern int __must_check |
105 | sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, mode_t mode); | 106 | sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, mode_t mode); |
106 | 107 | ||
107 | extern void | 108 | extern void |
108 | sysfs_remove_file(struct kobject *, const struct attribute *); | 109 | sysfs_remove_file(struct kobject *, const struct attribute *); |
109 | 110 | ||
110 | extern int | 111 | extern int __must_check |
111 | sysfs_create_link(struct kobject * kobj, struct kobject * target, const char * name); | 112 | sysfs_create_link(struct kobject * kobj, struct kobject * target, const char * name); |
112 | 113 | ||
113 | extern void | 114 | extern void |
114 | sysfs_remove_link(struct kobject *, const char * name); | 115 | sysfs_remove_link(struct kobject *, const char * name); |
115 | 116 | ||
116 | int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr); | 117 | int __must_check sysfs_create_bin_file(struct kobject *kobj, |
117 | int sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr); | 118 | struct bin_attribute *attr); |
119 | void sysfs_remove_bin_file(struct kobject *kobj, struct bin_attribute *attr); | ||
118 | 120 | ||
119 | int sysfs_create_group(struct kobject *, const struct attribute_group *); | 121 | int __must_check sysfs_create_group(struct kobject *, |
122 | const struct attribute_group *); | ||
120 | void sysfs_remove_group(struct kobject *, const struct attribute_group *); | 123 | void sysfs_remove_group(struct kobject *, const struct attribute_group *); |
121 | void sysfs_notify(struct kobject * k, char *dir, char *attr); | 124 | void sysfs_notify(struct kobject * k, char *dir, char *attr); |
122 | 125 | ||
126 | extern int __must_check sysfs_init(void); | ||
127 | |||
123 | #else /* CONFIG_SYSFS */ | 128 | #else /* CONFIG_SYSFS */ |
124 | 129 | ||
125 | static inline int sysfs_create_dir(struct kobject * k) | 130 | static inline int sysfs_create_dir(struct kobject * k) |
@@ -191,6 +196,11 @@ static inline void sysfs_notify(struct kobject * k, char *dir, char *attr) | |||
191 | { | 196 | { |
192 | } | 197 | } |
193 | 198 | ||
199 | static inline int __must_check sysfs_init(void) | ||
200 | { | ||
201 | return 0; | ||
202 | } | ||
203 | |||
194 | #endif /* CONFIG_SYSFS */ | 204 | #endif /* CONFIG_SYSFS */ |
195 | 205 | ||
196 | #endif /* _SYSFS_H_ */ | 206 | #endif /* _SYSFS_H_ */ |