From cfff1d8f5243e04c7d04d36ec7e559b5c41eeb9f Mon Sep 17 00:00:00 2001 From: Patrick Mochel Date: Fri, 24 May 2002 02:04:42 -0700 Subject: Introduce struct bus_type for describing types of buses Define bus_register for bus registration Define get_bus and put_bus for bus refcounting --- include/linux/device.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'include/linux') diff --git a/include/linux/device.h b/include/linux/device.h index ccfd221d5dcd..970b974918d6 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -55,6 +55,29 @@ enum { struct device; + +struct bus_type { + char * name; + rwlock_t lock; + atomic_t refcount; + + list_t node; + list_t devices; +}; + + +extern int bus_register(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 void put_bus(struct bus_type * bus); + + struct device_driver { int (*probe) (struct device * dev); int (*remove) (struct device * dev, u32 flags); @@ -66,6 +89,7 @@ struct device_driver { struct device { struct list_head g_list; /* node in depth-first order list */ struct list_head node; /* node in sibling list */ + struct list_head bus_list; /* node in bus's list */ struct list_head children; struct device * parent; -- cgit v1.2.3