diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/device.h | 40 | ||||
| -rw-r--r-- | include/linux/kobject.h | 14 | ||||
| -rw-r--r-- | include/linux/platform_device.h | 9 | ||||
| -rw-r--r-- | include/linux/sysdev.h | 21 | ||||
| -rw-r--r-- | include/linux/sysfs.h | 61 | ||||
| -rw-r--r-- | include/linux/usb.h | 6 |
6 files changed, 134 insertions, 17 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 | /* |
diff --git a/include/linux/kobject.h b/include/linux/kobject.h index 58ae8e00fcdd..3950d3c2850d 100644 --- a/include/linux/kobject.h +++ b/include/linux/kobject.h | |||
| @@ -106,7 +106,7 @@ extern char *kobject_get_path(struct kobject *kobj, gfp_t flag); | |||
| 106 | 106 | ||
| 107 | struct kobj_type { | 107 | struct kobj_type { |
| 108 | void (*release)(struct kobject *kobj); | 108 | void (*release)(struct kobject *kobj); |
| 109 | struct sysfs_ops *sysfs_ops; | 109 | const struct sysfs_ops *sysfs_ops; |
| 110 | struct attribute **default_attrs; | 110 | struct attribute **default_attrs; |
| 111 | }; | 111 | }; |
| 112 | 112 | ||
| @@ -118,9 +118,9 @@ struct kobj_uevent_env { | |||
| 118 | }; | 118 | }; |
| 119 | 119 | ||
| 120 | struct kset_uevent_ops { | 120 | struct kset_uevent_ops { |
| 121 | int (*filter)(struct kset *kset, struct kobject *kobj); | 121 | int (* const filter)(struct kset *kset, struct kobject *kobj); |
| 122 | const char *(*name)(struct kset *kset, struct kobject *kobj); | 122 | const char *(* const name)(struct kset *kset, struct kobject *kobj); |
| 123 | int (*uevent)(struct kset *kset, struct kobject *kobj, | 123 | int (* const uevent)(struct kset *kset, struct kobject *kobj, |
| 124 | struct kobj_uevent_env *env); | 124 | struct kobj_uevent_env *env); |
| 125 | }; | 125 | }; |
| 126 | 126 | ||
| @@ -132,7 +132,7 @@ struct kobj_attribute { | |||
| 132 | const char *buf, size_t count); | 132 | const char *buf, size_t count); |
| 133 | }; | 133 | }; |
| 134 | 134 | ||
| 135 | extern struct sysfs_ops kobj_sysfs_ops; | 135 | extern const struct sysfs_ops kobj_sysfs_ops; |
| 136 | 136 | ||
| 137 | /** | 137 | /** |
| 138 | * struct kset - a set of kobjects of a specific type, belonging to a specific subsystem. | 138 | * struct kset - a set of kobjects of a specific type, belonging to a specific subsystem. |
| @@ -155,14 +155,14 @@ struct kset { | |||
| 155 | struct list_head list; | 155 | struct list_head list; |
| 156 | spinlock_t list_lock; | 156 | spinlock_t list_lock; |
| 157 | struct kobject kobj; | 157 | struct kobject kobj; |
| 158 | struct kset_uevent_ops *uevent_ops; | 158 | const struct kset_uevent_ops *uevent_ops; |
| 159 | }; | 159 | }; |
| 160 | 160 | ||
| 161 | extern void kset_init(struct kset *kset); | 161 | extern void kset_init(struct kset *kset); |
| 162 | extern int __must_check kset_register(struct kset *kset); | 162 | extern int __must_check kset_register(struct kset *kset); |
| 163 | extern void kset_unregister(struct kset *kset); | 163 | extern void kset_unregister(struct kset *kset); |
| 164 | extern struct kset * __must_check kset_create_and_add(const char *name, | 164 | extern struct kset * __must_check kset_create_and_add(const char *name, |
| 165 | struct kset_uevent_ops *u, | 165 | const struct kset_uevent_ops *u, |
| 166 | struct kobject *parent_kobj); | 166 | struct kobject *parent_kobj); |
| 167 | 167 | ||
| 168 | static inline struct kset *to_kset(struct kobject *kobj) | 168 | static inline struct kset *to_kset(struct kobject *kobj) |
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h index 71ff887ca44e..212da17d06af 100644 --- a/include/linux/platform_device.h +++ b/include/linux/platform_device.h | |||
| @@ -21,7 +21,7 @@ struct platform_device { | |||
| 21 | u32 num_resources; | 21 | u32 num_resources; |
| 22 | struct resource * resource; | 22 | struct resource * resource; |
| 23 | 23 | ||
| 24 | struct platform_device_id *id_entry; | 24 | const struct platform_device_id *id_entry; |
| 25 | 25 | ||
| 26 | /* arch specific additions */ | 26 | /* arch specific additions */ |
| 27 | struct pdev_archdata archdata; | 27 | struct pdev_archdata archdata; |
| @@ -62,7 +62,7 @@ struct platform_driver { | |||
| 62 | int (*suspend)(struct platform_device *, pm_message_t state); | 62 | int (*suspend)(struct platform_device *, pm_message_t state); |
| 63 | int (*resume)(struct platform_device *); | 63 | int (*resume)(struct platform_device *); |
| 64 | struct device_driver driver; | 64 | struct device_driver driver; |
| 65 | struct platform_device_id *id_table; | 65 | const struct platform_device_id *id_table; |
| 66 | }; | 66 | }; |
| 67 | 67 | ||
| 68 | extern int platform_driver_register(struct platform_driver *); | 68 | extern int platform_driver_register(struct platform_driver *); |
| @@ -77,6 +77,11 @@ extern int platform_driver_probe(struct platform_driver *driver, | |||
| 77 | #define platform_get_drvdata(_dev) dev_get_drvdata(&(_dev)->dev) | 77 | #define platform_get_drvdata(_dev) dev_get_drvdata(&(_dev)->dev) |
| 78 | #define platform_set_drvdata(_dev,data) dev_set_drvdata(&(_dev)->dev, (data)) | 78 | #define platform_set_drvdata(_dev,data) dev_set_drvdata(&(_dev)->dev, (data)) |
| 79 | 79 | ||
| 80 | extern struct platform_device *platform_create_bundle(struct platform_driver *driver, | ||
| 81 | int (*probe)(struct platform_device *), | ||
| 82 | struct resource *res, unsigned int n_res, | ||
| 83 | const void *data, size_t size); | ||
| 84 | |||
| 80 | /* early platform driver interface */ | 85 | /* early platform driver interface */ |
| 81 | struct early_platform_driver { | 86 | struct early_platform_driver { |
| 82 | const char *class_str; | 87 | const char *class_str; |
diff --git a/include/linux/sysdev.h b/include/linux/sysdev.h index f395bb3fa2f2..1154c29f4101 100644 --- a/include/linux/sysdev.h +++ b/include/linux/sysdev.h | |||
| @@ -27,10 +27,12 @@ | |||
| 27 | 27 | ||
| 28 | 28 | ||
| 29 | struct sys_device; | 29 | struct sys_device; |
| 30 | struct sysdev_class_attribute; | ||
| 30 | 31 | ||
| 31 | struct sysdev_class { | 32 | struct sysdev_class { |
| 32 | const char *name; | 33 | const char *name; |
| 33 | struct list_head drivers; | 34 | struct list_head drivers; |
| 35 | struct sysdev_class_attribute **attrs; | ||
| 34 | 36 | ||
| 35 | /* Default operations for these types of devices */ | 37 | /* Default operations for these types of devices */ |
| 36 | int (*shutdown)(struct sys_device *); | 38 | int (*shutdown)(struct sys_device *); |
| @@ -41,8 +43,10 @@ struct sysdev_class { | |||
| 41 | 43 | ||
| 42 | struct sysdev_class_attribute { | 44 | struct sysdev_class_attribute { |
| 43 | struct attribute attr; | 45 | struct attribute attr; |
| 44 | ssize_t (*show)(struct sysdev_class *, char *); | 46 | ssize_t (*show)(struct sysdev_class *, struct sysdev_class_attribute *, |
| 45 | ssize_t (*store)(struct sysdev_class *, const char *, size_t); | 47 | char *); |
| 48 | ssize_t (*store)(struct sysdev_class *, struct sysdev_class_attribute *, | ||
| 49 | const char *, size_t); | ||
| 46 | }; | 50 | }; |
| 47 | 51 | ||
| 48 | #define _SYSDEV_CLASS_ATTR(_name,_mode,_show,_store) \ | 52 | #define _SYSDEV_CLASS_ATTR(_name,_mode,_show,_store) \ |
| @@ -119,6 +123,19 @@ struct sysdev_attribute { | |||
| 119 | extern int sysdev_create_file(struct sys_device *, struct sysdev_attribute *); | 123 | extern int sysdev_create_file(struct sys_device *, struct sysdev_attribute *); |
| 120 | extern void sysdev_remove_file(struct sys_device *, struct sysdev_attribute *); | 124 | extern void sysdev_remove_file(struct sys_device *, struct sysdev_attribute *); |
| 121 | 125 | ||
| 126 | /* Create/remove NULL terminated attribute list */ | ||
| 127 | static inline int | ||
| 128 | sysdev_create_files(struct sys_device *d, struct sysdev_attribute **a) | ||
| 129 | { | ||
| 130 | return sysfs_create_files(&d->kobj, (const struct attribute **)a); | ||
| 131 | } | ||
| 132 | |||
| 133 | static inline void | ||
| 134 | sysdev_remove_files(struct sys_device *d, struct sysdev_attribute **a) | ||
| 135 | { | ||
| 136 | return sysfs_remove_files(&d->kobj, (const struct attribute **)a); | ||
| 137 | } | ||
| 138 | |||
| 122 | struct sysdev_ext_attribute { | 139 | struct sysdev_ext_attribute { |
| 123 | struct sysdev_attribute attr; | 140 | struct sysdev_attribute attr; |
| 124 | void *var; | 141 | void *var; |
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h index cfa83083a2d4..f0496b3d1811 100644 --- a/include/linux/sysfs.h +++ b/include/linux/sysfs.h | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | #include <linux/compiler.h> | 15 | #include <linux/compiler.h> |
| 16 | #include <linux/errno.h> | 16 | #include <linux/errno.h> |
| 17 | #include <linux/list.h> | 17 | #include <linux/list.h> |
| 18 | #include <linux/lockdep.h> | ||
| 18 | #include <asm/atomic.h> | 19 | #include <asm/atomic.h> |
| 19 | 20 | ||
| 20 | struct kobject; | 21 | struct kobject; |
| @@ -29,8 +30,33 @@ struct attribute { | |||
| 29 | const char *name; | 30 | const char *name; |
| 30 | struct module *owner; | 31 | struct module *owner; |
| 31 | mode_t mode; | 32 | mode_t mode; |
| 33 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
| 34 | struct lock_class_key *key; | ||
| 35 | struct lock_class_key skey; | ||
| 36 | #endif | ||
| 32 | }; | 37 | }; |
| 33 | 38 | ||
| 39 | /** | ||
| 40 | * sysfs_attr_init - initialize a dynamically allocated sysfs attribute | ||
| 41 | * @attr: struct attribute to initialize | ||
| 42 | * | ||
| 43 | * Initialize a dynamically allocated struct attribute so we can | ||
| 44 | * make lockdep happy. This is a new requirement for attributes | ||
| 45 | * and initially this is only needed when lockdep is enabled. | ||
| 46 | * Lockdep gives a nice error when your attribute is added to | ||
| 47 | * sysfs if you don't have this. | ||
| 48 | */ | ||
| 49 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
| 50 | #define sysfs_attr_init(attr) \ | ||
| 51 | do { \ | ||
| 52 | static struct lock_class_key __key; \ | ||
| 53 | \ | ||
| 54 | (attr)->key = &__key; \ | ||
| 55 | } while(0) | ||
| 56 | #else | ||
| 57 | #define sysfs_attr_init(attr) do {} while(0) | ||
| 58 | #endif | ||
| 59 | |||
| 34 | struct attribute_group { | 60 | struct attribute_group { |
| 35 | const char *name; | 61 | const char *name; |
| 36 | mode_t (*is_visible)(struct kobject *, | 62 | mode_t (*is_visible)(struct kobject *, |
| @@ -74,6 +100,18 @@ struct bin_attribute { | |||
| 74 | struct vm_area_struct *vma); | 100 | struct vm_area_struct *vma); |
| 75 | }; | 101 | }; |
| 76 | 102 | ||
| 103 | /** | ||
| 104 | * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute | ||
| 105 | * @attr: struct bin_attribute to initialize | ||
| 106 | * | ||
| 107 | * Initialize a dynamically allocated struct bin_attribute so we | ||
| 108 | * can make lockdep happy. This is a new requirement for | ||
| 109 | * attributes and initially this is only needed when lockdep is | ||
| 110 | * enabled. Lockdep gives a nice error when your attribute is | ||
| 111 | * added to sysfs if you don't have this. | ||
| 112 | */ | ||
| 113 | #define sysfs_bin_attr_init(bin_attr) sysfs_attr_init(&(bin_attr)->attr) | ||
| 114 | |||
| 77 | struct sysfs_ops { | 115 | struct sysfs_ops { |
| 78 | ssize_t (*show)(struct kobject *, struct attribute *,char *); | 116 | ssize_t (*show)(struct kobject *, struct attribute *,char *); |
| 79 | ssize_t (*store)(struct kobject *,struct attribute *,const char *, size_t); | 117 | ssize_t (*store)(struct kobject *,struct attribute *,const char *, size_t); |
| @@ -94,9 +132,12 @@ int __must_check sysfs_move_dir(struct kobject *kobj, | |||
| 94 | 132 | ||
| 95 | int __must_check sysfs_create_file(struct kobject *kobj, | 133 | int __must_check sysfs_create_file(struct kobject *kobj, |
| 96 | const struct attribute *attr); | 134 | const struct attribute *attr); |
| 135 | int __must_check sysfs_create_files(struct kobject *kobj, | ||
| 136 | const struct attribute **attr); | ||
| 97 | int __must_check sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, | 137 | int __must_check sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, |
| 98 | mode_t mode); | 138 | mode_t mode); |
| 99 | void sysfs_remove_file(struct kobject *kobj, const struct attribute *attr); | 139 | void sysfs_remove_file(struct kobject *kobj, const struct attribute *attr); |
| 140 | void sysfs_remove_files(struct kobject *kobj, const struct attribute **attr); | ||
| 100 | 141 | ||
| 101 | int __must_check sysfs_create_bin_file(struct kobject *kobj, | 142 | int __must_check sysfs_create_bin_file(struct kobject *kobj, |
| 102 | const struct bin_attribute *attr); | 143 | const struct bin_attribute *attr); |
| @@ -110,6 +151,9 @@ int __must_check sysfs_create_link_nowarn(struct kobject *kobj, | |||
| 110 | const char *name); | 151 | const char *name); |
| 111 | void sysfs_remove_link(struct kobject *kobj, const char *name); | 152 | void sysfs_remove_link(struct kobject *kobj, const char *name); |
| 112 | 153 | ||
| 154 | int sysfs_rename_link(struct kobject *kobj, struct kobject *target, | ||
| 155 | const char *old_name, const char *new_name); | ||
| 156 | |||
| 113 | int __must_check sysfs_create_group(struct kobject *kobj, | 157 | int __must_check sysfs_create_group(struct kobject *kobj, |
| 114 | const struct attribute_group *grp); | 158 | const struct attribute_group *grp); |
| 115 | int sysfs_update_group(struct kobject *kobj, | 159 | int sysfs_update_group(struct kobject *kobj, |
| @@ -164,6 +208,12 @@ static inline int sysfs_create_file(struct kobject *kobj, | |||
| 164 | return 0; | 208 | return 0; |
| 165 | } | 209 | } |
| 166 | 210 | ||
| 211 | static inline int sysfs_create_files(struct kobject *kobj, | ||
| 212 | const struct attribute **attr) | ||
| 213 | { | ||
| 214 | return 0; | ||
| 215 | } | ||
| 216 | |||
| 167 | static inline int sysfs_chmod_file(struct kobject *kobj, | 217 | static inline int sysfs_chmod_file(struct kobject *kobj, |
| 168 | struct attribute *attr, mode_t mode) | 218 | struct attribute *attr, mode_t mode) |
| 169 | { | 219 | { |
| @@ -175,6 +225,11 @@ static inline void sysfs_remove_file(struct kobject *kobj, | |||
| 175 | { | 225 | { |
| 176 | } | 226 | } |
| 177 | 227 | ||
| 228 | static inline void sysfs_remove_files(struct kobject *kobj, | ||
| 229 | const struct attribute **attr) | ||
| 230 | { | ||
| 231 | } | ||
| 232 | |||
| 178 | static inline int sysfs_create_bin_file(struct kobject *kobj, | 233 | static inline int sysfs_create_bin_file(struct kobject *kobj, |
| 179 | const struct bin_attribute *attr) | 234 | const struct bin_attribute *attr) |
| 180 | { | 235 | { |
| @@ -203,6 +258,12 @@ static inline void sysfs_remove_link(struct kobject *kobj, const char *name) | |||
| 203 | { | 258 | { |
| 204 | } | 259 | } |
| 205 | 260 | ||
| 261 | static inline int sysfs_rename_link(struct kobject *k, struct kobject *t, | ||
| 262 | const char *old_name, const char *new_name) | ||
| 263 | { | ||
| 264 | return 0; | ||
| 265 | } | ||
| 266 | |||
| 206 | static inline int sysfs_create_group(struct kobject *kobj, | 267 | static inline int sysfs_create_group(struct kobject *kobj, |
| 207 | const struct attribute_group *grp) | 268 | const struct attribute_group *grp) |
| 208 | { | 269 | { |
diff --git a/include/linux/usb.h b/include/linux/usb.h index 3492abf82e75..8c9f053111bb 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h | |||
| @@ -512,9 +512,9 @@ extern struct usb_device *usb_get_dev(struct usb_device *dev); | |||
| 512 | extern void usb_put_dev(struct usb_device *dev); | 512 | extern void usb_put_dev(struct usb_device *dev); |
| 513 | 513 | ||
| 514 | /* USB device locking */ | 514 | /* USB device locking */ |
| 515 | #define usb_lock_device(udev) down(&(udev)->dev.sem) | 515 | #define usb_lock_device(udev) device_lock(&(udev)->dev) |
| 516 | #define usb_unlock_device(udev) up(&(udev)->dev.sem) | 516 | #define usb_unlock_device(udev) device_unlock(&(udev)->dev) |
| 517 | #define usb_trylock_device(udev) down_trylock(&(udev)->dev.sem) | 517 | #define usb_trylock_device(udev) device_trylock(&(udev)->dev) |
| 518 | extern int usb_lock_device_for_reset(struct usb_device *udev, | 518 | extern int usb_lock_device_for_reset(struct usb_device *udev, |
| 519 | const struct usb_interface *iface); | 519 | const struct usb_interface *iface); |
| 520 | 520 | ||
