From f371ab1c59dab04bfe7d239c3d5e85550bf31365 Mon Sep 17 00:00:00 2001 From: Patrick Mochel Date: Tue, 28 May 2002 03:59:17 -0700 Subject: Beef up centralized driver mgmt: - add name, bus, lock, refcount, bus_list, devices, and dir fields to struct - add release callback to be called when refcount hits 0 - add helpers for registration and refcounting - create directory for driver in bus's directory --- include/linux/device.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'include/linux') diff --git a/include/linux/device.h b/include/linux/device.h index 078c65e02370..2ad1e9ff4f75 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -84,17 +84,48 @@ extern void put_bus(struct bus_type * bus); struct device_driver { + char * name; + struct bus_type * bus; + + rwlock_t lock; + atomic_t refcount; + + list_t bus_list; + list_t devices; + + struct driver_dir_entry dir; + int (*probe) (struct device * dev); int (*remove) (struct device * dev, u32 flags); int (*suspend) (struct device * dev, u32 state, u32 level); int (*resume) (struct device * dev, u32 level); + + void (*release) (struct device_driver * drv); }; + + +extern int driver_register(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 void put_driver(struct device_driver * drv); + +extern int driver_for_each_dev(struct device_driver * drv, void * data, + int (*callback)(struct device * dev, void * data)); + + 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 driver_list; struct list_head children; struct device * parent; -- cgit v1.2.3