diff options
Diffstat (limited to 'include/linux/device.h')
-rw-r--r-- | include/linux/device.h | 71 |
1 files changed, 61 insertions, 10 deletions
diff --git a/include/linux/device.h b/include/linux/device.h index 2ea3e4921812..182192892d45 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
@@ -106,7 +106,7 @@ extern int bus_unregister_notifier(struct bus_type *bus, | |||
106 | 106 | ||
107 | /* All 4 notifers below get called with the target struct device * | 107 | /* All 4 notifers below get called with the target struct device * |
108 | * as an argument. Note that those functions are likely to be called | 108 | * as an argument. Note that those functions are likely to be called |
109 | * with the device semaphore held in the core, so be careful. | 109 | * with the device lock held in the core, so be careful. |
110 | */ | 110 | */ |
111 | #define BUS_NOTIFY_ADD_DEVICE 0x00000001 /* device added */ | 111 | #define BUS_NOTIFY_ADD_DEVICE 0x00000001 /* device added */ |
112 | #define BUS_NOTIFY_DEL_DEVICE 0x00000002 /* device removed */ | 112 | #define BUS_NOTIFY_DEL_DEVICE 0x00000002 /* device removed */ |
@@ -166,9 +166,9 @@ struct driver_attribute driver_attr_##_name = \ | |||
166 | __ATTR(_name, _mode, _show, _store) | 166 | __ATTR(_name, _mode, _show, _store) |
167 | 167 | ||
168 | extern int __must_check driver_create_file(struct device_driver *driver, | 168 | extern int __must_check driver_create_file(struct device_driver *driver, |
169 | struct driver_attribute *attr); | 169 | const struct driver_attribute *attr); |
170 | extern void driver_remove_file(struct device_driver *driver, | 170 | extern void driver_remove_file(struct device_driver *driver, |
171 | struct driver_attribute *attr); | 171 | const struct driver_attribute *attr); |
172 | 172 | ||
173 | extern int __must_check driver_add_kobj(struct device_driver *drv, | 173 | extern int __must_check driver_add_kobj(struct device_driver *drv, |
174 | struct kobject *kobj, | 174 | struct kobject *kobj, |
@@ -251,8 +251,10 @@ extern struct device *class_find_device(struct class *class, | |||
251 | 251 | ||
252 | struct class_attribute { | 252 | struct class_attribute { |
253 | struct attribute attr; | 253 | struct attribute attr; |
254 | ssize_t (*show)(struct class *class, char *buf); | 254 | ssize_t (*show)(struct class *class, struct class_attribute *attr, |
255 | ssize_t (*store)(struct class *class, const char *buf, size_t count); | 255 | char *buf); |
256 | ssize_t (*store)(struct class *class, struct class_attribute *attr, | ||
257 | const char *buf, size_t count); | ||
256 | }; | 258 | }; |
257 | 259 | ||
258 | #define CLASS_ATTR(_name, _mode, _show, _store) \ | 260 | #define CLASS_ATTR(_name, _mode, _show, _store) \ |
@@ -263,6 +265,23 @@ extern int __must_check class_create_file(struct class *class, | |||
263 | extern void class_remove_file(struct class *class, | 265 | extern void class_remove_file(struct class *class, |
264 | const struct class_attribute *attr); | 266 | const struct class_attribute *attr); |
265 | 267 | ||
268 | /* Simple class attribute that is just a static string */ | ||
269 | |||
270 | struct class_attribute_string { | ||
271 | struct class_attribute attr; | ||
272 | char *str; | ||
273 | }; | ||
274 | |||
275 | /* Currently read-only only */ | ||
276 | #define _CLASS_ATTR_STRING(_name, _mode, _str) \ | ||
277 | { __ATTR(_name, _mode, show_class_attr_string, NULL), _str } | ||
278 | #define CLASS_ATTR_STRING(_name, _mode, _str) \ | ||
279 | struct class_attribute_string class_attr_##_name = \ | ||
280 | _CLASS_ATTR_STRING(_name, _mode, _str) | ||
281 | |||
282 | extern ssize_t show_class_attr_string(struct class *class, struct class_attribute *attr, | ||
283 | char *buf); | ||
284 | |||
266 | struct class_interface { | 285 | struct class_interface { |
267 | struct list_head node; | 286 | struct list_head node; |
268 | struct class *class; | 287 | struct class *class; |
@@ -319,13 +338,13 @@ struct device_attribute { | |||
319 | struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show, _store) | 338 | struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show, _store) |
320 | 339 | ||
321 | extern int __must_check device_create_file(struct device *device, | 340 | extern int __must_check device_create_file(struct device *device, |
322 | struct device_attribute *entry); | 341 | const struct device_attribute *entry); |
323 | extern void device_remove_file(struct device *dev, | 342 | extern void device_remove_file(struct device *dev, |
324 | struct device_attribute *attr); | 343 | const struct device_attribute *attr); |
325 | extern int __must_check device_create_bin_file(struct device *dev, | 344 | extern int __must_check device_create_bin_file(struct device *dev, |
326 | struct bin_attribute *attr); | 345 | const struct bin_attribute *attr); |
327 | extern void device_remove_bin_file(struct device *dev, | 346 | extern void device_remove_bin_file(struct device *dev, |
328 | struct bin_attribute *attr); | 347 | const struct bin_attribute *attr); |
329 | extern int device_schedule_callback_owner(struct device *dev, | 348 | extern int device_schedule_callback_owner(struct device *dev, |
330 | void (*func)(struct device *dev), struct module *owner); | 349 | void (*func)(struct device *dev), struct module *owner); |
331 | 350 | ||
@@ -472,6 +491,38 @@ static inline int device_is_registered(struct device *dev) | |||
472 | return dev->kobj.state_in_sysfs; | 491 | return dev->kobj.state_in_sysfs; |
473 | } | 492 | } |
474 | 493 | ||
494 | static inline void device_enable_async_suspend(struct device *dev) | ||
495 | { | ||
496 | if (dev->power.status == DPM_ON) | ||
497 | dev->power.async_suspend = true; | ||
498 | } | ||
499 | |||
500 | static inline void device_disable_async_suspend(struct device *dev) | ||
501 | { | ||
502 | if (dev->power.status == DPM_ON) | ||
503 | dev->power.async_suspend = false; | ||
504 | } | ||
505 | |||
506 | static inline bool device_async_suspend_enabled(struct device *dev) | ||
507 | { | ||
508 | return !!dev->power.async_suspend; | ||
509 | } | ||
510 | |||
511 | static inline void device_lock(struct device *dev) | ||
512 | { | ||
513 | down(&dev->sem); | ||
514 | } | ||
515 | |||
516 | static inline int device_trylock(struct device *dev) | ||
517 | { | ||
518 | return down_trylock(&dev->sem); | ||
519 | } | ||
520 | |||
521 | static inline void device_unlock(struct device *dev) | ||
522 | { | ||
523 | up(&dev->sem); | ||
524 | } | ||
525 | |||
475 | void driver_init(void); | 526 | void driver_init(void); |
476 | 527 | ||
477 | /* | 528 | /* |
@@ -558,7 +609,7 @@ extern void wait_for_device_probe(void); | |||
558 | #ifdef CONFIG_DEVTMPFS | 609 | #ifdef CONFIG_DEVTMPFS |
559 | extern int devtmpfs_create_node(struct device *dev); | 610 | extern int devtmpfs_create_node(struct device *dev); |
560 | extern int devtmpfs_delete_node(struct device *dev); | 611 | extern int devtmpfs_delete_node(struct device *dev); |
561 | extern int devtmpfs_mount(const char *mountpoint); | 612 | extern int devtmpfs_mount(const char *mntdir); |
562 | #else | 613 | #else |
563 | static inline int devtmpfs_create_node(struct device *dev) { return 0; } | 614 | static inline int devtmpfs_create_node(struct device *dev) { return 0; } |
564 | static inline int devtmpfs_delete_node(struct device *dev) { return 0; } | 615 | static inline int devtmpfs_delete_node(struct device *dev) { return 0; } |