diff options
| author | Greg Kroah-Hartman <gregkh@suse.de> | 2008-12-16 15:26:21 -0500 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-03-24 19:38:25 -0400 |
| commit | ae1b41715ee2aae356fbcca032838b71d70b855f (patch) | |
| tree | d053c68c0d15a219d58298ebb020b8b6bcfcff8b | |
| parent | 8940b4f312dced51b45004819b776ec3aa7fcd5d (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>
| -rw-r--r-- | drivers/base/base.h | 4 | ||||
| -rw-r--r-- | drivers/base/bus.c | 40 | ||||
| -rw-r--r-- | include/linux/device.h | 1 |
3 files changed, 31 insertions, 14 deletions
diff --git a/drivers/base/base.h b/drivers/base/base.h index 4fc5fd3984cc..ddc97496db4a 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 11463c00451e..dc030f1f00f1 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 | } |
| @@ -995,18 +1005,20 @@ static void device_insertion_sort_klist(struct device *a, struct list_head *list | |||
| 995 | { | 1005 | { |
| 996 | struct list_head *pos; | 1006 | struct list_head *pos; |
| 997 | struct klist_node *n; | 1007 | struct klist_node *n; |
| 1008 | struct device_private *dev_prv; | ||
| 998 | struct device *b; | 1009 | struct device *b; |
| 999 | 1010 | ||
| 1000 | list_for_each(pos, list) { | 1011 | list_for_each(pos, list) { |
| 1001 | n = container_of(pos, struct klist_node, n_node); | 1012 | n = container_of(pos, struct klist_node, n_node); |
| 1002 | b = container_of(n, struct device, knode_bus); | 1013 | dev_prv = to_device_private_bus(n); |
| 1014 | b = dev_prv->device; | ||
| 1003 | if (compare(a, b) <= 0) { | 1015 | if (compare(a, b) <= 0) { |
| 1004 | list_move_tail(&a->knode_bus.n_node, | 1016 | list_move_tail(&a->p->knode_bus.n_node, |
| 1005 | &b->knode_bus.n_node); | 1017 | &b->p->knode_bus.n_node); |
| 1006 | return; | 1018 | return; |
| 1007 | } | 1019 | } |
| 1008 | } | 1020 | } |
| 1009 | list_move_tail(&a->knode_bus.n_node, list); | 1021 | list_move_tail(&a->p->knode_bus.n_node, list); |
| 1010 | } | 1022 | } |
| 1011 | 1023 | ||
| 1012 | void bus_sort_breadthfirst(struct bus_type *bus, | 1024 | void bus_sort_breadthfirst(struct bus_type *bus, |
| @@ -1016,6 +1028,7 @@ void bus_sort_breadthfirst(struct bus_type *bus, | |||
| 1016 | LIST_HEAD(sorted_devices); | 1028 | LIST_HEAD(sorted_devices); |
| 1017 | struct list_head *pos, *tmp; | 1029 | struct list_head *pos, *tmp; |
| 1018 | struct klist_node *n; | 1030 | struct klist_node *n; |
| 1031 | struct device_private *dev_prv; | ||
| 1019 | struct device *dev; | 1032 | struct device *dev; |
| 1020 | struct klist *device_klist; | 1033 | struct klist *device_klist; |
| 1021 | 1034 | ||
| @@ -1024,7 +1037,8 @@ void bus_sort_breadthfirst(struct bus_type *bus, | |||
| 1024 | spin_lock(&device_klist->k_lock); | 1037 | spin_lock(&device_klist->k_lock); |
| 1025 | list_for_each_safe(pos, tmp, &device_klist->k_list) { | 1038 | list_for_each_safe(pos, tmp, &device_klist->k_list) { |
| 1026 | n = container_of(pos, struct klist_node, n_node); | 1039 | n = container_of(pos, struct klist_node, n_node); |
| 1027 | dev = container_of(n, struct device, knode_bus); | 1040 | dev_prv = to_device_private_bus(n); |
| 1041 | dev = dev_prv->device; | ||
| 1028 | device_insertion_sort_klist(dev, &sorted_devices, compare); | 1042 | device_insertion_sort_klist(dev, &sorted_devices, compare); |
| 1029 | } | 1043 | } |
| 1030 | list_splice(&sorted_devices, &device_klist->k_list); | 1044 | list_splice(&sorted_devices, &device_klist->k_list); |
diff --git a/include/linux/device.h b/include/linux/device.h index 83e241f407be..5a64775e68e4 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
| @@ -368,7 +368,6 @@ struct device_dma_parameters { | |||
| 368 | }; | 368 | }; |
| 369 | 369 | ||
| 370 | struct device { | 370 | struct device { |
| 371 | struct klist_node knode_bus; | ||
| 372 | struct device *parent; | 371 | struct device *parent; |
| 373 | 372 | ||
| 374 | struct device_private *p; | 373 | struct device_private *p; |
