diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2008-12-16 15:25:49 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-03-24 19:38:25 -0400 |
commit | 8940b4f312dced51b45004819b776ec3aa7fcd5d (patch) | |
tree | f994df6952a12ad5a3b46762e8a53eaa99f215b6 /drivers | |
parent | f791b8c836307b58cbf62133a6a772ed1a92fb33 (diff) |
driver core: move knode_driver into private structure
Nothing outside of the driver core should ever touch knode_driver, so
move it out of the public eye.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/base/base.h | 4 | ||||
-rw-r--r-- | drivers/base/dd.c | 13 | ||||
-rw-r--r-- | drivers/base/driver.c | 13 |
3 files changed, 22 insertions, 8 deletions
diff --git a/drivers/base/base.h b/drivers/base/base.h index 7c4fafc314c4..4fc5fd3984cc 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h | |||
@@ -68,6 +68,7 @@ struct class_private { | |||
68 | * | 68 | * |
69 | * @klist_children - klist containing all children of this device | 69 | * @klist_children - klist containing all children of this device |
70 | * @knode_parent - node in sibling list | 70 | * @knode_parent - node in sibling list |
71 | * @knode_driver - node in driver list | ||
71 | * @device - pointer back to the struct class that this structure is | 72 | * @device - pointer back to the struct class that this structure is |
72 | * associated with. | 73 | * associated with. |
73 | * | 74 | * |
@@ -76,10 +77,13 @@ struct class_private { | |||
76 | struct device_private { | 77 | struct device_private { |
77 | struct klist klist_children; | 78 | struct klist klist_children; |
78 | struct klist_node knode_parent; | 79 | struct klist_node knode_parent; |
80 | struct klist_node knode_driver; | ||
79 | struct device *device; | 81 | struct device *device; |
80 | }; | 82 | }; |
81 | #define to_device_private_parent(obj) \ | 83 | #define to_device_private_parent(obj) \ |
82 | container_of(obj, struct device_private, knode_parent) | 84 | container_of(obj, struct device_private, knode_parent) |
85 | #define to_device_private_driver(obj) \ | ||
86 | container_of(obj, struct device_private, knode_driver) | ||
83 | 87 | ||
84 | /* initialisation functions */ | 88 | /* initialisation functions */ |
85 | extern int devices_init(void); | 89 | extern int devices_init(void); |
diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 0dfd08c15921..f17c3266a0e0 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c | |||
@@ -30,7 +30,7 @@ | |||
30 | 30 | ||
31 | static void driver_bound(struct device *dev) | 31 | static void driver_bound(struct device *dev) |
32 | { | 32 | { |
33 | if (klist_node_attached(&dev->knode_driver)) { | 33 | if (klist_node_attached(&dev->p->knode_driver)) { |
34 | printk(KERN_WARNING "%s: device %s already bound\n", | 34 | printk(KERN_WARNING "%s: device %s already bound\n", |
35 | __func__, kobject_name(&dev->kobj)); | 35 | __func__, kobject_name(&dev->kobj)); |
36 | return; | 36 | return; |
@@ -43,7 +43,7 @@ static void driver_bound(struct device *dev) | |||
43 | blocking_notifier_call_chain(&dev->bus->p->bus_notifier, | 43 | blocking_notifier_call_chain(&dev->bus->p->bus_notifier, |
44 | BUS_NOTIFY_BOUND_DRIVER, dev); | 44 | BUS_NOTIFY_BOUND_DRIVER, dev); |
45 | 45 | ||
46 | klist_add_tail(&dev->knode_driver, &dev->driver->p->klist_devices); | 46 | klist_add_tail(&dev->p->knode_driver, &dev->driver->p->klist_devices); |
47 | } | 47 | } |
48 | 48 | ||
49 | static int driver_sysfs_add(struct device *dev) | 49 | static int driver_sysfs_add(struct device *dev) |
@@ -318,7 +318,7 @@ static void __device_release_driver(struct device *dev) | |||
318 | drv->remove(dev); | 318 | drv->remove(dev); |
319 | devres_release_all(dev); | 319 | devres_release_all(dev); |
320 | dev->driver = NULL; | 320 | dev->driver = NULL; |
321 | klist_remove(&dev->knode_driver); | 321 | klist_remove(&dev->p->knode_driver); |
322 | } | 322 | } |
323 | } | 323 | } |
324 | 324 | ||
@@ -348,6 +348,7 @@ EXPORT_SYMBOL_GPL(device_release_driver); | |||
348 | */ | 348 | */ |
349 | void driver_detach(struct device_driver *drv) | 349 | void driver_detach(struct device_driver *drv) |
350 | { | 350 | { |
351 | struct device_private *dev_prv; | ||
351 | struct device *dev; | 352 | struct device *dev; |
352 | 353 | ||
353 | for (;;) { | 354 | for (;;) { |
@@ -356,8 +357,10 @@ void driver_detach(struct device_driver *drv) | |||
356 | spin_unlock(&drv->p->klist_devices.k_lock); | 357 | spin_unlock(&drv->p->klist_devices.k_lock); |
357 | break; | 358 | break; |
358 | } | 359 | } |
359 | dev = list_entry(drv->p->klist_devices.k_list.prev, | 360 | dev_prv = list_entry(drv->p->klist_devices.k_list.prev, |
360 | struct device, knode_driver.n_node); | 361 | struct device_private, |
362 | knode_driver.n_node); | ||
363 | dev = dev_prv->device; | ||
361 | get_device(dev); | 364 | get_device(dev); |
362 | spin_unlock(&drv->p->klist_devices.k_lock); | 365 | spin_unlock(&drv->p->klist_devices.k_lock); |
363 | 366 | ||
diff --git a/drivers/base/driver.c b/drivers/base/driver.c index 2889ad57e48b..c51f11bb29ae 100644 --- a/drivers/base/driver.c +++ b/drivers/base/driver.c | |||
@@ -19,7 +19,14 @@ | |||
19 | static struct device *next_device(struct klist_iter *i) | 19 | static struct device *next_device(struct klist_iter *i) |
20 | { | 20 | { |
21 | struct klist_node *n = klist_next(i); | 21 | struct klist_node *n = klist_next(i); |
22 | return n ? container_of(n, struct device, knode_driver) : NULL; | 22 | struct device *dev = NULL; |
23 | struct device_private *dev_prv; | ||
24 | |||
25 | if (n) { | ||
26 | dev_prv = to_device_private_driver(n); | ||
27 | dev = dev_prv->device; | ||
28 | } | ||
29 | return dev; | ||
23 | } | 30 | } |
24 | 31 | ||
25 | /** | 32 | /** |
@@ -42,7 +49,7 @@ int driver_for_each_device(struct device_driver *drv, struct device *start, | |||
42 | return -EINVAL; | 49 | return -EINVAL; |
43 | 50 | ||
44 | klist_iter_init_node(&drv->p->klist_devices, &i, | 51 | klist_iter_init_node(&drv->p->klist_devices, &i, |
45 | start ? &start->knode_driver : NULL); | 52 | start ? &start->p->knode_driver : NULL); |
46 | while ((dev = next_device(&i)) && !error) | 53 | while ((dev = next_device(&i)) && !error) |
47 | error = fn(dev, data); | 54 | error = fn(dev, data); |
48 | klist_iter_exit(&i); | 55 | klist_iter_exit(&i); |
@@ -76,7 +83,7 @@ struct device *driver_find_device(struct device_driver *drv, | |||
76 | return NULL; | 83 | return NULL; |
77 | 84 | ||
78 | klist_iter_init_node(&drv->p->klist_devices, &i, | 85 | klist_iter_init_node(&drv->p->klist_devices, &i, |
79 | (start ? &start->knode_driver : NULL)); | 86 | (start ? &start->p->knode_driver : NULL)); |
80 | while ((dev = next_device(&i))) | 87 | while ((dev = next_device(&i))) |
81 | if (match(dev, data) && get_device(dev)) | 88 | if (match(dev, data) && get_device(dev)) |
82 | break; | 89 | break; |