diff options
Diffstat (limited to 'include/linux/device.h')
-rw-r--r-- | include/linux/device.h | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/include/linux/device.h b/include/linux/device.h index b30527db3ac0..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 */ |
@@ -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; |
@@ -489,6 +508,21 @@ static inline bool device_async_suspend_enabled(struct device *dev) | |||
489 | return !!dev->power.async_suspend; | 508 | return !!dev->power.async_suspend; |
490 | } | 509 | } |
491 | 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 | |||
492 | void driver_init(void); | 526 | void driver_init(void); |
493 | 527 | ||
494 | /* | 528 | /* |