diff options
Diffstat (limited to 'include/linux/device.h')
| -rw-r--r-- | include/linux/device.h | 105 |
1 files changed, 7 insertions, 98 deletions
diff --git a/include/linux/device.h b/include/linux/device.h index 1a060265acea..8c23e3dfe3ac 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
| @@ -35,7 +35,6 @@ struct device; | |||
| 35 | struct device_driver; | 35 | struct device_driver; |
| 36 | struct driver_private; | 36 | struct driver_private; |
| 37 | struct class; | 37 | struct class; |
| 38 | struct class_device; | ||
| 39 | struct bus_type; | 38 | struct bus_type; |
| 40 | struct bus_type_private; | 39 | struct bus_type_private; |
| 41 | 40 | ||
| @@ -190,13 +189,10 @@ struct class { | |||
| 190 | struct kset class_dirs; | 189 | struct kset class_dirs; |
| 191 | struct semaphore sem; /* locks children, devices, interfaces */ | 190 | struct semaphore sem; /* locks children, devices, interfaces */ |
| 192 | struct class_attribute *class_attrs; | 191 | struct class_attribute *class_attrs; |
| 193 | struct class_device_attribute *class_dev_attrs; | ||
| 194 | struct device_attribute *dev_attrs; | 192 | struct device_attribute *dev_attrs; |
| 195 | 193 | ||
| 196 | int (*uevent)(struct class_device *dev, struct kobj_uevent_env *env); | ||
| 197 | int (*dev_uevent)(struct device *dev, struct kobj_uevent_env *env); | 194 | int (*dev_uevent)(struct device *dev, struct kobj_uevent_env *env); |
| 198 | 195 | ||
| 199 | void (*release)(struct class_device *dev); | ||
| 200 | void (*class_release)(struct class *class); | 196 | void (*class_release)(struct class *class); |
| 201 | void (*dev_release)(struct device *dev); | 197 | void (*dev_release)(struct device *dev); |
| 202 | 198 | ||
| @@ -210,9 +206,6 @@ extern int class_for_each_device(struct class *class, void *data, | |||
| 210 | int (*fn)(struct device *dev, void *data)); | 206 | int (*fn)(struct device *dev, void *data)); |
| 211 | extern struct device *class_find_device(struct class *class, void *data, | 207 | extern struct device *class_find_device(struct class *class, void *data, |
| 212 | int (*match)(struct device *, void *)); | 208 | int (*match)(struct device *, void *)); |
| 213 | extern struct class_device *class_find_child(struct class *class, void *data, | ||
| 214 | int (*match)(struct class_device *, void *)); | ||
| 215 | |||
| 216 | 209 | ||
| 217 | struct class_attribute { | 210 | struct class_attribute { |
| 218 | struct attribute attr; | 211 | struct attribute attr; |
| @@ -228,92 +221,10 @@ extern int __must_check class_create_file(struct class *class, | |||
| 228 | extern void class_remove_file(struct class *class, | 221 | extern void class_remove_file(struct class *class, |
| 229 | const struct class_attribute *attr); | 222 | const struct class_attribute *attr); |
| 230 | 223 | ||
| 231 | struct class_device_attribute { | ||
| 232 | struct attribute attr; | ||
| 233 | ssize_t (*show)(struct class_device *, char *buf); | ||
| 234 | ssize_t (*store)(struct class_device *, const char *buf, size_t count); | ||
| 235 | }; | ||
| 236 | |||
| 237 | #define CLASS_DEVICE_ATTR(_name, _mode, _show, _store) \ | ||
| 238 | struct class_device_attribute class_device_attr_##_name = \ | ||
| 239 | __ATTR(_name, _mode, _show, _store) | ||
| 240 | |||
| 241 | extern int __must_check class_device_create_file(struct class_device *, | ||
| 242 | const struct class_device_attribute *); | ||
| 243 | |||
| 244 | /** | ||
| 245 | * struct class_device - class devices | ||
| 246 | * @class: pointer to the parent class for this class device. This is required. | ||
| 247 | * @devt: for internal use by the driver core only. | ||
| 248 | * @node: for internal use by the driver core only. | ||
| 249 | * @kobj: for internal use by the driver core only. | ||
| 250 | * @groups: optional additional groups to be created | ||
| 251 | * @dev: if set, a symlink to the struct device is created in the sysfs | ||
| 252 | * directory for this struct class device. | ||
| 253 | * @class_data: pointer to whatever you want to store here for this struct | ||
| 254 | * class_device. Use class_get_devdata() and class_set_devdata() to get and | ||
| 255 | * set this pointer. | ||
| 256 | * @parent: pointer to a struct class_device that is the parent of this struct | ||
| 257 | * class_device. If NULL, this class_device will show up at the root of the | ||
| 258 | * struct class in sysfs (which is probably what you want to have happen.) | ||
| 259 | * @release: pointer to a release function for this struct class_device. If | ||
| 260 | * set, this will be called instead of the class specific release function. | ||
| 261 | * Only use this if you want to override the default release function, like | ||
| 262 | * when you are nesting class_device structures. | ||
| 263 | * @uevent: pointer to a uevent function for this struct class_device. If | ||
| 264 | * set, this will be called instead of the class specific uevent function. | ||
| 265 | * Only use this if you want to override the default uevent function, like | ||
| 266 | * when you are nesting class_device structures. | ||
| 267 | */ | ||
| 268 | struct class_device { | ||
| 269 | struct list_head node; | ||
| 270 | |||
| 271 | struct kobject kobj; | ||
| 272 | struct class *class; | ||
| 273 | dev_t devt; | ||
| 274 | struct device *dev; | ||
| 275 | void *class_data; | ||
| 276 | struct class_device *parent; | ||
| 277 | struct attribute_group **groups; | ||
| 278 | |||
| 279 | void (*release)(struct class_device *dev); | ||
| 280 | int (*uevent)(struct class_device *dev, struct kobj_uevent_env *env); | ||
| 281 | char class_id[BUS_ID_SIZE]; | ||
| 282 | }; | ||
| 283 | |||
| 284 | static inline void *class_get_devdata(struct class_device *dev) | ||
| 285 | { | ||
| 286 | return dev->class_data; | ||
| 287 | } | ||
| 288 | |||
| 289 | static inline void class_set_devdata(struct class_device *dev, void *data) | ||
| 290 | { | ||
| 291 | dev->class_data = data; | ||
| 292 | } | ||
| 293 | |||
| 294 | |||
| 295 | extern int __must_check class_device_register(struct class_device *); | ||
| 296 | extern void class_device_unregister(struct class_device *); | ||
| 297 | extern void class_device_initialize(struct class_device *); | ||
| 298 | extern int __must_check class_device_add(struct class_device *); | ||
| 299 | extern void class_device_del(struct class_device *); | ||
| 300 | |||
| 301 | extern struct class_device *class_device_get(struct class_device *); | ||
| 302 | extern void class_device_put(struct class_device *); | ||
| 303 | |||
| 304 | extern void class_device_remove_file(struct class_device *, | ||
| 305 | const struct class_device_attribute *); | ||
| 306 | extern int __must_check class_device_create_bin_file(struct class_device *, | ||
| 307 | struct bin_attribute *); | ||
| 308 | extern void class_device_remove_bin_file(struct class_device *, | ||
| 309 | struct bin_attribute *); | ||
| 310 | |||
| 311 | struct class_interface { | 224 | struct class_interface { |
| 312 | struct list_head node; | 225 | struct list_head node; |
| 313 | struct class *class; | 226 | struct class *class; |
| 314 | 227 | ||
| 315 | int (*add) (struct class_device *, struct class_interface *); | ||
| 316 | void (*remove) (struct class_device *, struct class_interface *); | ||
| 317 | int (*add_dev) (struct device *, struct class_interface *); | 228 | int (*add_dev) (struct device *, struct class_interface *); |
| 318 | void (*remove_dev) (struct device *, struct class_interface *); | 229 | void (*remove_dev) (struct device *, struct class_interface *); |
| 319 | }; | 230 | }; |
| @@ -323,13 +234,6 @@ extern void class_interface_unregister(struct class_interface *); | |||
| 323 | 234 | ||
| 324 | extern struct class *class_create(struct module *owner, const char *name); | 235 | extern struct class *class_create(struct module *owner, const char *name); |
| 325 | extern void class_destroy(struct class *cls); | 236 | extern void class_destroy(struct class *cls); |
| 326 | extern struct class_device *class_device_create(struct class *cls, | ||
| 327 | struct class_device *parent, | ||
| 328 | dev_t devt, | ||
| 329 | struct device *device, | ||
| 330 | const char *fmt, ...) | ||
| 331 | __attribute__((format(printf, 5, 6))); | ||
| 332 | extern void class_device_destroy(struct class *cls, dev_t devt); | ||
| 333 | 237 | ||
| 334 | /* | 238 | /* |
| 335 | * The type of device, "struct device" is embedded in. A class | 239 | * The type of device, "struct device" is embedded in. A class |
| @@ -465,7 +369,6 @@ struct device { | |||
| 465 | spinlock_t devres_lock; | 369 | spinlock_t devres_lock; |
| 466 | struct list_head devres_head; | 370 | struct list_head devres_head; |
| 467 | 371 | ||
| 468 | /* class_device migration path */ | ||
| 469 | struct list_head node; | 372 | struct list_head node; |
| 470 | struct class *class; | 373 | struct class *class; |
| 471 | dev_t devt; /* dev_t, creates the sysfs "dev" */ | 374 | dev_t devt; /* dev_t, creates the sysfs "dev" */ |
| @@ -477,6 +380,12 @@ struct device { | |||
| 477 | /* Get the wakeup routines, which depend on struct device */ | 380 | /* Get the wakeup routines, which depend on struct device */ |
| 478 | #include <linux/pm_wakeup.h> | 381 | #include <linux/pm_wakeup.h> |
| 479 | 382 | ||
| 383 | static inline const char *dev_name(struct device *dev) | ||
| 384 | { | ||
| 385 | /* will be changed into kobject_name(&dev->kobj) in the near future */ | ||
| 386 | return dev->bus_id; | ||
| 387 | } | ||
| 388 | |||
| 480 | #ifdef CONFIG_NUMA | 389 | #ifdef CONFIG_NUMA |
| 481 | static inline int dev_to_node(struct device *dev) | 390 | static inline int dev_to_node(struct device *dev) |
| 482 | { | 391 | { |
| @@ -575,7 +484,7 @@ extern void sysdev_shutdown(void); | |||
| 575 | extern const char *dev_driver_string(struct device *dev); | 484 | extern const char *dev_driver_string(struct device *dev); |
| 576 | #define dev_printk(level, dev, format, arg...) \ | 485 | #define dev_printk(level, dev, format, arg...) \ |
| 577 | printk(level "%s %s: " format , dev_driver_string(dev) , \ | 486 | printk(level "%s %s: " format , dev_driver_string(dev) , \ |
| 578 | (dev)->bus_id , ## arg) | 487 | dev_name(dev) , ## arg) |
| 579 | 488 | ||
| 580 | #define dev_emerg(dev, format, arg...) \ | 489 | #define dev_emerg(dev, format, arg...) \ |
| 581 | dev_printk(KERN_EMERG , dev , format , ## arg) | 490 | dev_printk(KERN_EMERG , dev , format , ## arg) |
