diff options
author | Paul Mundt <lethal@linux-sh.org> | 2010-03-10 02:41:57 -0500 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2010-03-10 02:41:57 -0500 |
commit | d28c145debb1bd53cde63ac8bccc192e3e00067e (patch) | |
tree | 87fb1d66cab7689aa662ebd0337b39ff1bf6f433 /include/linux/device.h | |
parent | 2e733b3f84fa9c2ae60513c5f7b56d599ed2ae02 (diff) | |
parent | ec0ffe2ee0e0fb9da4409d86bfd72636450f32df (diff) |
Merge branch 'sh/driver-core' into sh/clkfwk
Diffstat (limited to 'include/linux/device.h')
-rw-r--r-- | include/linux/device.h | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/include/linux/device.h b/include/linux/device.h index b30527db3ac0..241b96bcd7ad 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; |
@@ -432,6 +451,10 @@ struct device { | |||
432 | 451 | ||
433 | static inline const char *dev_name(const struct device *dev) | 452 | static inline const char *dev_name(const struct device *dev) |
434 | { | 453 | { |
454 | /* Use the init name until the kobject becomes available */ | ||
455 | if (dev->init_name) | ||
456 | return dev->init_name; | ||
457 | |||
435 | return kobject_name(&dev->kobj); | 458 | return kobject_name(&dev->kobj); |
436 | } | 459 | } |
437 | 460 | ||
@@ -489,6 +512,21 @@ static inline bool device_async_suspend_enabled(struct device *dev) | |||
489 | return !!dev->power.async_suspend; | 512 | return !!dev->power.async_suspend; |
490 | } | 513 | } |
491 | 514 | ||
515 | static inline void device_lock(struct device *dev) | ||
516 | { | ||
517 | down(&dev->sem); | ||
518 | } | ||
519 | |||
520 | static inline int device_trylock(struct device *dev) | ||
521 | { | ||
522 | return down_trylock(&dev->sem); | ||
523 | } | ||
524 | |||
525 | static inline void device_unlock(struct device *dev) | ||
526 | { | ||
527 | up(&dev->sem); | ||
528 | } | ||
529 | |||
492 | void driver_init(void); | 530 | void driver_init(void); |
493 | 531 | ||
494 | /* | 532 | /* |