diff options
| author | Patrick Mochel <mochel@osdl.org> | 2002-10-17 21:54:46 -0700 |
|---|---|---|
| committer | Patrick Mochel <mochel@osdl.org> | 2002-10-17 21:54:46 -0700 |
| commit | f85645c71d1fe93b99ef25ecff0736cc9f116ccf (patch) | |
| tree | 5cbf81dd1f1504869de1cbf76649a87e367c8fe9 /include/linux | |
| parent | 9533d71048be05ad266aa432dd550c59d3296e33 (diff) | |
| parent | 879a1092976b201f23c69c7159fe51be1c8c7bc2 (diff) | |
Merge osdl.org:/home/mochel/src/kernel/devel/linux-2.5-core
into osdl.org:/home/mochel/src/kernel/devel/linux-2.5-sysfs
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/device.h | 49 | ||||
| -rw-r--r-- | include/linux/driverfs_fs.h | 2 |
2 files changed, 30 insertions, 21 deletions
diff --git a/include/linux/device.h b/include/linux/device.h index 80a63939f924..3dd9a4081298 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -48,14 +48,22 @@ enum { RESUME_ENABLE, }; +enum device_state { + DEVICE_UNINITIALIZED = 0, + DEVICE_INITIALIZED = 1, + DEVICE_REGISTERED = 2, + DEVICE_GONE = 3, +}; + struct device; struct device_driver; struct device_class; struct bus_type { char * name; - rwlock_t lock; + struct rw_semaphore rwsem; atomic_t refcount; + u32 present; struct list_head node; struct list_head devices; @@ -73,14 +81,9 @@ struct bus_type { extern int bus_register(struct bus_type * bus); +extern void bus_unregister(struct bus_type * bus); -static inline struct bus_type * get_bus(struct bus_type * bus) -{ - BUG_ON(!atomic_read(&bus->refcount)); - atomic_inc(&bus->refcount); - return bus; -} - +extern struct bus_type * get_bus(struct bus_type * bus); extern void put_bus(struct bus_type * bus); extern int bus_for_each_dev(struct bus_type * bus, void * data, @@ -114,6 +117,7 @@ struct device_driver { rwlock_t lock; atomic_t refcount; + u32 present; struct list_head bus_list; struct list_head class_list; @@ -123,7 +127,7 @@ struct device_driver { int (*probe) (struct device * dev); int (*remove) (struct device * dev); - + void (*shutdown) (struct device * dev); int (*suspend) (struct device * dev, u32 state, u32 level); int (*resume) (struct device * dev, u32 level); @@ -131,16 +135,10 @@ struct device_driver { }; - extern int driver_register(struct device_driver * drv); +extern void driver_unregister(struct device_driver * drv); -static inline struct device_driver * get_driver(struct device_driver * drv) -{ - BUG_ON(!atomic_read(&drv->refcount)); - atomic_inc(&drv->refcount); - return drv; -} - +extern struct device_driver * get_driver(struct device_driver * drv); extern void put_driver(struct device_driver * drv); extern void remove_driver(struct device_driver * drv); @@ -172,6 +170,11 @@ extern void driver_remove_file(struct device_driver *, struct driver_attribute * */ struct device_class { char * name; + struct rw_semaphore rwsem; + + atomic_t refcount; + u32 present; + u32 devnum; struct list_head node; @@ -189,6 +192,9 @@ struct device_class { extern int devclass_register(struct device_class *); extern void devclass_unregister(struct device_class *); +extern struct device_class * get_devclass(struct device_class *); +extern void put_devclass(struct device_class *); + struct devclass_attribute { struct attribute attr; @@ -289,8 +295,8 @@ struct device { void *platform_data; /* Platform specific data (e.g. ACPI, BIOS data relevant to device) */ - u32 present; - u32 current_state; /* Current operating state. In + enum device_state state; + u32 power_state; /* Current operating state. In ACPI-speak, this is D0-D3, D0 being fully functional, and D3 being off. */ @@ -362,6 +368,11 @@ extern int (*platform_notify)(struct device * dev); extern int (*platform_notify_remove)(struct device * dev); +static inline int device_present(struct device * dev) +{ + return (dev && (dev->state == DEVICE_INITIALIZED || dev->state == DEVICE_REGISTERED)); +} + /* device and bus locking helpers. * * FIXME: Is there anything else we need to do? diff --git a/include/linux/driverfs_fs.h b/include/linux/driverfs_fs.h index d859f8c2e041..b4270e947a1e 100644 --- a/include/linux/driverfs_fs.h +++ b/include/linux/driverfs_fs.h @@ -65,6 +65,4 @@ driverfs_create_symlink(struct driver_dir_entry * parent, extern void driverfs_remove_file(struct driver_dir_entry *, const char * name); -extern int init_driverfs_fs(void); - #endif /* _DDFS_H_ */ |
