summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorPatrick Mochel <mochel@osdl.org>2002-10-15 20:54:20 -0700
committerPatrick Mochel <mochel@osdl.org>2002-10-15 20:54:20 -0700
commit4278bccc2d9707c9c4ee1769b464bffe4dfd820a (patch)
tree3e012877913aafa17597149206cc050c576ba995 /include
parent67d93a0ad7b87d740f25f93d12eb5d5e870d7030 (diff)
driver model: change bus refcounting scheme to match devices'.
Based on recent changes to device refcounting/unregistration. struct bus_type gets a ->present field, which is set when the bus is registered. bus_unregister() is added, which only clears ->present and calls put_bus(). get_bus() checks the ->present and returns NULL if clear. This allows all current references to buses to keep valid structures, while preventing any new references to the bus structure.
Diffstat (limited to 'include')
-rw-r--r--include/linux/device.h10
1 files changed, 3 insertions, 7 deletions
diff --git a/include/linux/device.h b/include/linux/device.h
index 80a63939f924..03c7d995e96c 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -56,6 +56,7 @@ struct bus_type {
char * name;
rwlock_t lock;
atomic_t refcount;
+ u32 present;
struct list_head node;
struct list_head devices;
@@ -73,14 +74,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,