aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/driver.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/base/driver.c')
-rw-r--r--drivers/base/driver.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 291c5954a3af..ef3fe513e398 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -142,6 +142,19 @@ void put_driver(struct device_driver * drv)
142 kobject_put(&drv->kobj); 142 kobject_put(&drv->kobj);
143} 143}
144 144
145static void klist_devices_get(struct klist_node *n)
146{
147 struct device *dev = container_of(n, struct device, knode_driver);
148
149 get_device(dev);
150}
151
152static void klist_devices_put(struct klist_node *n)
153{
154 struct device *dev = container_of(n, struct device, knode_driver);
155
156 put_device(dev);
157}
145 158
146/** 159/**
147 * driver_register - register driver with bus 160 * driver_register - register driver with bus
@@ -157,7 +170,7 @@ void put_driver(struct device_driver * drv)
157 */ 170 */
158int driver_register(struct device_driver * drv) 171int driver_register(struct device_driver * drv)
159{ 172{
160 klist_init(&drv->klist_devices); 173 klist_init(&drv->klist_devices, klist_devices_get, klist_devices_put);
161 init_completion(&drv->unloaded); 174 init_completion(&drv->unloaded);
162 return bus_add_driver(drv); 175 return bus_add_driver(drv);
163} 176}