diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2009-01-09 17:32:46 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-01-09 17:32:46 -0500 |
commit | 4db8e282f2d1dfa43d51ce2a4817901312c9134d (patch) | |
tree | c2d2ee15e5d74186ad79220035b222df7c8330c5 /drivers/base/bus.c | |
parent | 73d59314e6ed268d6f322ae1bdd723b23fa5a4ed (diff) |
Revert "driver core: move knode_bus into private structure"
This reverts commit b9daa99ee533578e3f88231e7a16784dcb44ec42.
Turns out that device_initialize shouldn't fail silently.
This series needs to be reworked in order to get into proper
shape.
Reported-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base/bus.c')
-rw-r--r-- | drivers/base/bus.c | 40 |
1 files changed, 13 insertions, 27 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c index 0f0a50444672..83f32b891fa9 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c | |||
@@ -253,14 +253,7 @@ 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 | struct device *dev = NULL; | 256 | return n ? container_of(n, struct device, knode_bus) : 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; | ||
264 | } | 257 | } |
265 | 258 | ||
266 | /** | 259 | /** |
@@ -293,7 +286,7 @@ int bus_for_each_dev(struct bus_type *bus, struct device *start, | |||
293 | return -EINVAL; | 286 | return -EINVAL; |
294 | 287 | ||
295 | klist_iter_init_node(&bus->p->klist_devices, &i, | 288 | klist_iter_init_node(&bus->p->klist_devices, &i, |
296 | (start ? &start->p->knode_bus : NULL)); | 289 | (start ? &start->knode_bus : NULL)); |
297 | while ((dev = next_device(&i)) && !error) | 290 | while ((dev = next_device(&i)) && !error) |
298 | error = fn(dev, data); | 291 | error = fn(dev, data); |
299 | klist_iter_exit(&i); | 292 | klist_iter_exit(&i); |
@@ -327,7 +320,7 @@ struct device *bus_find_device(struct bus_type *bus, | |||
327 | return NULL; | 320 | return NULL; |
328 | 321 | ||
329 | klist_iter_init_node(&bus->p->klist_devices, &i, | 322 | klist_iter_init_node(&bus->p->klist_devices, &i, |
330 | (start ? &start->p->knode_bus : NULL)); | 323 | (start ? &start->knode_bus : NULL)); |
331 | while ((dev = next_device(&i))) | 324 | while ((dev = next_device(&i))) |
332 | if (match(dev, data) && get_device(dev)) | 325 | if (match(dev, data) && get_device(dev)) |
333 | break; | 326 | break; |
@@ -514,8 +507,7 @@ void bus_attach_device(struct device *dev) | |||
514 | ret = device_attach(dev); | 507 | ret = device_attach(dev); |
515 | WARN_ON(ret < 0); | 508 | WARN_ON(ret < 0); |
516 | if (ret >= 0) | 509 | if (ret >= 0) |
517 | klist_add_tail(&dev->p->knode_bus, | 510 | klist_add_tail(&dev->knode_bus, &bus->p->klist_devices); |
518 | &bus->p->klist_devices); | ||
519 | } | 511 | } |
520 | } | 512 | } |
521 | 513 | ||
@@ -536,8 +528,8 @@ void bus_remove_device(struct device *dev) | |||
536 | sysfs_remove_link(&dev->bus->p->devices_kset->kobj, | 528 | sysfs_remove_link(&dev->bus->p->devices_kset->kobj, |
537 | dev_name(dev)); | 529 | dev_name(dev)); |
538 | device_remove_attrs(dev->bus, dev); | 530 | device_remove_attrs(dev->bus, dev); |
539 | if (klist_node_attached(&dev->p->knode_bus)) | 531 | if (klist_node_attached(&dev->knode_bus)) |
540 | klist_del(&dev->p->knode_bus); | 532 | klist_del(&dev->knode_bus); |
541 | 533 | ||
542 | pr_debug("bus: '%s': remove device %s\n", | 534 | pr_debug("bus: '%s': remove device %s\n", |
543 | dev->bus->name, dev_name(dev)); | 535 | dev->bus->name, dev_name(dev)); |
@@ -839,16 +831,14 @@ static void bus_remove_attrs(struct bus_type *bus) | |||
839 | 831 | ||
840 | static void klist_devices_get(struct klist_node *n) | 832 | static void klist_devices_get(struct klist_node *n) |
841 | { | 833 | { |
842 | struct device_private *dev_prv = to_device_private_bus(n); | 834 | struct device *dev = container_of(n, struct device, knode_bus); |
843 | struct device *dev = dev_prv->device; | ||
844 | 835 | ||
845 | get_device(dev); | 836 | get_device(dev); |
846 | } | 837 | } |
847 | 838 | ||
848 | static void klist_devices_put(struct klist_node *n) | 839 | static void klist_devices_put(struct klist_node *n) |
849 | { | 840 | { |
850 | struct device_private *dev_prv = to_device_private_bus(n); | 841 | struct device *dev = container_of(n, struct device, knode_bus); |
851 | struct device *dev = dev_prv->device; | ||
852 | 842 | ||
853 | put_device(dev); | 843 | put_device(dev); |
854 | } | 844 | } |
@@ -1003,20 +993,18 @@ static void device_insertion_sort_klist(struct device *a, struct list_head *list | |||
1003 | { | 993 | { |
1004 | struct list_head *pos; | 994 | struct list_head *pos; |
1005 | struct klist_node *n; | 995 | struct klist_node *n; |
1006 | struct device_private *dev_prv; | ||
1007 | struct device *b; | 996 | struct device *b; |
1008 | 997 | ||
1009 | list_for_each(pos, list) { | 998 | list_for_each(pos, list) { |
1010 | n = container_of(pos, struct klist_node, n_node); | 999 | n = container_of(pos, struct klist_node, n_node); |
1011 | dev_prv = to_device_private_bus(n); | 1000 | b = container_of(n, struct device, knode_bus); |
1012 | b = dev_prv->device; | ||
1013 | if (compare(a, b) <= 0) { | 1001 | if (compare(a, b) <= 0) { |
1014 | list_move_tail(&a->p->knode_bus.n_node, | 1002 | list_move_tail(&a->knode_bus.n_node, |
1015 | &b->p->knode_bus.n_node); | 1003 | &b->knode_bus.n_node); |
1016 | return; | 1004 | return; |
1017 | } | 1005 | } |
1018 | } | 1006 | } |
1019 | list_move_tail(&a->p->knode_bus.n_node, list); | 1007 | list_move_tail(&a->knode_bus.n_node, list); |
1020 | } | 1008 | } |
1021 | 1009 | ||
1022 | void bus_sort_breadthfirst(struct bus_type *bus, | 1010 | void bus_sort_breadthfirst(struct bus_type *bus, |
@@ -1026,7 +1014,6 @@ void bus_sort_breadthfirst(struct bus_type *bus, | |||
1026 | LIST_HEAD(sorted_devices); | 1014 | LIST_HEAD(sorted_devices); |
1027 | struct list_head *pos, *tmp; | 1015 | struct list_head *pos, *tmp; |
1028 | struct klist_node *n; | 1016 | struct klist_node *n; |
1029 | struct device_private *dev_prv; | ||
1030 | struct device *dev; | 1017 | struct device *dev; |
1031 | struct klist *device_klist; | 1018 | struct klist *device_klist; |
1032 | 1019 | ||
@@ -1035,8 +1022,7 @@ void bus_sort_breadthfirst(struct bus_type *bus, | |||
1035 | spin_lock(&device_klist->k_lock); | 1022 | spin_lock(&device_klist->k_lock); |
1036 | list_for_each_safe(pos, tmp, &device_klist->k_list) { | 1023 | list_for_each_safe(pos, tmp, &device_klist->k_list) { |
1037 | n = container_of(pos, struct klist_node, n_node); | 1024 | n = container_of(pos, struct klist_node, n_node); |
1038 | dev_prv = to_device_private_bus(n); | 1025 | dev = container_of(n, struct device, knode_bus); |
1039 | dev = dev_prv->device; | ||
1040 | device_insertion_sort_klist(dev, &sorted_devices, compare); | 1026 | device_insertion_sort_klist(dev, &sorted_devices, compare); |
1041 | } | 1027 | } |
1042 | list_splice(&sorted_devices, &device_klist->k_list); | 1028 | list_splice(&sorted_devices, &device_klist->k_list); |