diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2008-12-16 15:26:21 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-01-06 13:44:33 -0500 |
commit | b9daa99ee533578e3f88231e7a16784dcb44ec42 (patch) | |
tree | 10f572ac695927866ec8293efdf4b937c11c4597 /drivers/base | |
parent | 93e746db183b3bdbbda67900f79b5835f9cb388f (diff) |
driver core: move knode_bus into private structure
Nothing outside of the driver core should ever touch knode_bus, 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/base')
-rw-r--r-- | drivers/base/base.h | 4 | ||||
-rw-r--r-- | drivers/base/bus.c | 40 |
2 files changed, 31 insertions, 13 deletions
diff --git a/drivers/base/base.h b/drivers/base/base.h index 8af0bb2c0aa8..b676f8f801f8 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h | |||
@@ -69,6 +69,7 @@ struct class_private { | |||
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 | * @knode_driver - node in driver list |
72 | * @knode_bus - node in bus list | ||
72 | * @device - pointer back to the struct class that this structure is | 73 | * @device - pointer back to the struct class that this structure is |
73 | * associated with. | 74 | * associated with. |
74 | * | 75 | * |
@@ -78,12 +79,15 @@ struct device_private { | |||
78 | struct klist klist_children; | 79 | struct klist klist_children; |
79 | struct klist_node knode_parent; | 80 | struct klist_node knode_parent; |
80 | struct klist_node knode_driver; | 81 | struct klist_node knode_driver; |
82 | struct klist_node knode_bus; | ||
81 | struct device *device; | 83 | struct device *device; |
82 | }; | 84 | }; |
83 | #define to_device_private_parent(obj) \ | 85 | #define to_device_private_parent(obj) \ |
84 | container_of(obj, struct device_private, knode_parent) | 86 | container_of(obj, struct device_private, knode_parent) |
85 | #define to_device_private_driver(obj) \ | 87 | #define to_device_private_driver(obj) \ |
86 | container_of(obj, struct device_private, knode_driver) | 88 | container_of(obj, struct device_private, knode_driver) |
89 | #define to_device_private_bus(obj) \ | ||
90 | container_of(obj, struct device_private, knode_bus) | ||
87 | 91 | ||
88 | /* initialisation functions */ | 92 | /* initialisation functions */ |
89 | extern int devices_init(void); | 93 | extern int devices_init(void); |
diff --git a/drivers/base/bus.c b/drivers/base/bus.c index 83f32b891fa9..0f0a50444672 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c | |||
@@ -253,7 +253,14 @@ static ssize_t store_drivers_probe(struct bus_type *bus, | |||
253 | static struct device *next_device(struct klist_iter *i) | 253 | static struct device *next_device(struct klist_iter *i) |
254 | { | 254 | { |
255 | struct klist_node *n = klist_next(i); | 255 | struct klist_node *n = klist_next(i); |
256 | return n ? container_of(n, struct device, knode_bus) : NULL; | 256 | struct device *dev = NULL; |
257 | struct device_private *dev_prv; | ||
258 | |||
259 | if (n) { | ||
260 | dev_prv = to_device_private_bus(n); | ||
261 | dev = dev_prv->device; | ||
262 | } | ||
263 | return dev; | ||
257 | } | 264 | } |
258 | 265 | ||
259 | /** | 266 | /** |
@@ -286,7 +293,7 @@ int bus_for_each_dev(struct bus_type *bus, struct device *start, | |||
286 | return -EINVAL; | 293 | return -EINVAL; |
287 | 294 | ||
288 | klist_iter_init_node(&bus->p->klist_devices, &i, | 295 | klist_iter_init_node(&bus->p->klist_devices, &i, |
289 | (start ? &start->knode_bus : NULL)); | 296 | (start ? &start->p->knode_bus : NULL)); |
290 | while ((dev = next_device(&i)) && !error) | 297 | while ((dev = next_device(&i)) && !error) |
291 | error = fn(dev, data); | 298 | error = fn(dev, data); |
292 | klist_iter_exit(&i); | 299 | klist_iter_exit(&i); |
@@ -320,7 +327,7 @@ struct device *bus_find_device(struct bus_type *bus, | |||
320 | return NULL; | 327 | return NULL; |
321 | 328 | ||
322 | klist_iter_init_node(&bus->p->klist_devices, &i, | 329 | klist_iter_init_node(&bus->p->klist_devices, &i, |
323 | (start ? &start->knode_bus : NULL)); | 330 | (start ? &start->p->knode_bus : NULL)); |
324 | while ((dev = next_device(&i))) | 331 | while ((dev = next_device(&i))) |
325 | if (match(dev, data) && get_device(dev)) | 332 | if (match(dev, data) && get_device(dev)) |
326 | break; | 333 | break; |
@@ -507,7 +514,8 @@ void bus_attach_device(struct device *dev) | |||
507 | ret = device_attach(dev); | 514 | ret = device_attach(dev); |
508 | WARN_ON(ret < 0); | 515 | WARN_ON(ret < 0); |
509 | if (ret >= 0) | 516 | if (ret >= 0) |
510 | klist_add_tail(&dev->knode_bus, &bus->p->klist_devices); | 517 | klist_add_tail(&dev->p->knode_bus, |
518 | &bus->p->klist_devices); | ||
511 | } | 519 | } |
512 | } | 520 | } |
513 | 521 | ||
@@ -528,8 +536,8 @@ void bus_remove_device(struct device *dev) | |||
528 | sysfs_remove_link(&dev->bus->p->devices_kset->kobj, | 536 | sysfs_remove_link(&dev->bus->p->devices_kset->kobj, |
529 | dev_name(dev)); | 537 | dev_name(dev)); |
530 | device_remove_attrs(dev->bus, dev); | 538 | device_remove_attrs(dev->bus, dev); |
531 | if (klist_node_attached(&dev->knode_bus)) | 539 | if (klist_node_attached(&dev->p->knode_bus)) |
532 | klist_del(&dev->knode_bus); | 540 | klist_del(&dev->p->knode_bus); |
533 | 541 | ||
534 | pr_debug("bus: '%s': remove device %s\n", | 542 | pr_debug("bus: '%s': remove device %s\n", |
535 | dev->bus->name, dev_name(dev)); | 543 | dev->bus->name, dev_name(dev)); |
@@ -831,14 +839,16 @@ static void bus_remove_attrs(struct bus_type *bus) | |||
831 | 839 | ||
832 | static void klist_devices_get(struct klist_node *n) | 840 | static void klist_devices_get(struct klist_node *n) |
833 | { | 841 | { |
834 | struct device *dev = container_of(n, struct device, knode_bus); | 842 | struct device_private *dev_prv = to_device_private_bus(n); |
843 | struct device *dev = dev_prv->device; | ||
835 | 844 | ||
836 | get_device(dev); | 845 | get_device(dev); |
837 | } | 846 | } |
838 | 847 | ||
839 | static void klist_devices_put(struct klist_node *n) | 848 | static void klist_devices_put(struct klist_node *n) |
840 | { | 849 | { |
841 | struct device *dev = container_of(n, struct device, knode_bus); | 850 | struct device_private *dev_prv = to_device_private_bus(n); |
851 | struct device *dev = dev_prv->device; | ||
842 | 852 | ||
843 | put_device(dev); | 853 | put_device(dev); |
844 | } | 854 | } |
@@ -993,18 +1003,20 @@ static void device_insertion_sort_klist(struct device *a, struct list_head *list | |||
993 | { | 1003 | { |
994 | struct list_head *pos; | 1004 | struct list_head *pos; |
995 | struct klist_node *n; | 1005 | struct klist_node *n; |
1006 | struct device_private *dev_prv; | ||
996 | struct device *b; | 1007 | struct device *b; |
997 | 1008 | ||
998 | list_for_each(pos, list) { | 1009 | list_for_each(pos, list) { |
999 | n = container_of(pos, struct klist_node, n_node); | 1010 | n = container_of(pos, struct klist_node, n_node); |
1000 | b = container_of(n, struct device, knode_bus); | 1011 | dev_prv = to_device_private_bus(n); |
1012 | b = dev_prv->device; | ||
1001 | if (compare(a, b) <= 0) { | 1013 | if (compare(a, b) <= 0) { |
1002 | list_move_tail(&a->knode_bus.n_node, | 1014 | list_move_tail(&a->p->knode_bus.n_node, |
1003 | &b->knode_bus.n_node); | 1015 | &b->p->knode_bus.n_node); |
1004 | return; | 1016 | return; |
1005 | } | 1017 | } |
1006 | } | 1018 | } |
1007 | list_move_tail(&a->knode_bus.n_node, list); | 1019 | list_move_tail(&a->p->knode_bus.n_node, list); |
1008 | } | 1020 | } |
1009 | 1021 | ||
1010 | void bus_sort_breadthfirst(struct bus_type *bus, | 1022 | void bus_sort_breadthfirst(struct bus_type *bus, |
@@ -1014,6 +1026,7 @@ void bus_sort_breadthfirst(struct bus_type *bus, | |||
1014 | LIST_HEAD(sorted_devices); | 1026 | LIST_HEAD(sorted_devices); |
1015 | struct list_head *pos, *tmp; | 1027 | struct list_head *pos, *tmp; |
1016 | struct klist_node *n; | 1028 | struct klist_node *n; |
1029 | struct device_private *dev_prv; | ||
1017 | struct device *dev; | 1030 | struct device *dev; |
1018 | struct klist *device_klist; | 1031 | struct klist *device_klist; |
1019 | 1032 | ||
@@ -1022,7 +1035,8 @@ void bus_sort_breadthfirst(struct bus_type *bus, | |||
1022 | spin_lock(&device_klist->k_lock); | 1035 | spin_lock(&device_klist->k_lock); |
1023 | list_for_each_safe(pos, tmp, &device_klist->k_list) { | 1036 | list_for_each_safe(pos, tmp, &device_klist->k_list) { |
1024 | n = container_of(pos, struct klist_node, n_node); | 1037 | n = container_of(pos, struct klist_node, n_node); |
1025 | dev = container_of(n, struct device, knode_bus); | 1038 | dev_prv = to_device_private_bus(n); |
1039 | dev = dev_prv->device; | ||
1026 | device_insertion_sort_klist(dev, &sorted_devices, compare); | 1040 | device_insertion_sort_klist(dev, &sorted_devices, compare); |
1027 | } | 1041 | } |
1028 | list_splice(&sorted_devices, &device_klist->k_list); | 1042 | list_splice(&sorted_devices, &device_klist->k_list); |