diff options
Diffstat (limited to 'drivers/base/core.c')
-rw-r--r-- | drivers/base/core.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c index efe03a024a5b..6ab73f5c799a 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -191,6 +191,20 @@ void device_remove_file(struct device * dev, struct device_attribute * attr) | |||
191 | } | 191 | } |
192 | } | 192 | } |
193 | 193 | ||
194 | static void klist_children_get(struct klist_node *n) | ||
195 | { | ||
196 | struct device *dev = container_of(n, struct device, knode_parent); | ||
197 | |||
198 | get_device(dev); | ||
199 | } | ||
200 | |||
201 | static void klist_children_put(struct klist_node *n) | ||
202 | { | ||
203 | struct device *dev = container_of(n, struct device, knode_parent); | ||
204 | |||
205 | put_device(dev); | ||
206 | } | ||
207 | |||
194 | 208 | ||
195 | /** | 209 | /** |
196 | * device_initialize - init device structure. | 210 | * device_initialize - init device structure. |
@@ -207,7 +221,8 @@ void device_initialize(struct device *dev) | |||
207 | { | 221 | { |
208 | kobj_set_kset_s(dev, devices_subsys); | 222 | kobj_set_kset_s(dev, devices_subsys); |
209 | kobject_init(&dev->kobj); | 223 | kobject_init(&dev->kobj); |
210 | klist_init(&dev->klist_children); | 224 | klist_init(&dev->klist_children, klist_children_get, |
225 | klist_children_put); | ||
211 | INIT_LIST_HEAD(&dev->dma_pools); | 226 | INIT_LIST_HEAD(&dev->dma_pools); |
212 | init_MUTEX(&dev->sem); | 227 | init_MUTEX(&dev->sem); |
213 | } | 228 | } |
@@ -249,7 +264,7 @@ int device_add(struct device *dev) | |||
249 | if ((error = bus_add_device(dev))) | 264 | if ((error = bus_add_device(dev))) |
250 | goto BusError; | 265 | goto BusError; |
251 | if (parent) | 266 | if (parent) |
252 | klist_add_tail(&parent->klist_children, &dev->knode_parent); | 267 | klist_add_tail(&dev->knode_parent, &parent->klist_children); |
253 | 268 | ||
254 | /* notify platform of device entry */ | 269 | /* notify platform of device entry */ |
255 | if (platform_notify) | 270 | if (platform_notify) |