diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2009-01-09 17:55:37 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-01-09 17:55:37 -0500 |
commit | e2d4077678c7ec7661003c268120582adc544897 (patch) | |
tree | 73397637de1d8274ae3f908a9534634afc9ea903 | |
parent | cda5e83fdea476dce9c0a9b1152cd6ca46832cc4 (diff) |
Revert "driver core: move klist_children into private structure"
This reverts commit 11c3b5c3e08f4d855cbef52883c266b9ab9df879.
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>
-rw-r--r-- | drivers/base/base.h | 6 | ||||
-rw-r--r-- | drivers/base/core.c | 37 | ||||
-rw-r--r-- | include/linux/device.h | 2 |
3 files changed, 15 insertions, 30 deletions
diff --git a/drivers/base/base.h b/drivers/base/base.h index f5cf31c664d7..6b20809b5fd4 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h | |||
@@ -66,20 +66,14 @@ struct class_private { | |||
66 | /** | 66 | /** |
67 | * struct device_private - structure to hold the private to the driver core portions of the device structure. | 67 | * struct device_private - structure to hold the private to the driver core portions of the device structure. |
68 | * | 68 | * |
69 | * @klist_children - klist containing all children of this device | ||
70 | * @knode_parent - node in sibling list | ||
71 | * @device - pointer back to the struct class that this structure is | 69 | * @device - pointer back to the struct class that this structure is |
72 | * associated with. | 70 | * associated with. |
73 | * | 71 | * |
74 | * Nothing outside of the driver core should ever touch these fields. | 72 | * Nothing outside of the driver core should ever touch these fields. |
75 | */ | 73 | */ |
76 | struct device_private { | 74 | struct device_private { |
77 | struct klist klist_children; | ||
78 | struct klist_node knode_parent; | ||
79 | struct device *device; | 75 | struct device *device; |
80 | }; | 76 | }; |
81 | #define to_device_private_parent(obj) \ | ||
82 | container_of(obj, struct device_private, knode_parent) | ||
83 | 77 | ||
84 | /* initialisation functions */ | 78 | /* initialisation functions */ |
85 | extern int devices_init(void); | 79 | extern int devices_init(void); |
diff --git a/drivers/base/core.c b/drivers/base/core.c index 61df508fa62b..5c2acf7116d7 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -509,16 +509,14 @@ EXPORT_SYMBOL_GPL(device_schedule_callback_owner); | |||
509 | 509 | ||
510 | static void klist_children_get(struct klist_node *n) | 510 | static void klist_children_get(struct klist_node *n) |
511 | { | 511 | { |
512 | struct device_private *p = to_device_private_parent(n); | 512 | struct device *dev = container_of(n, struct device, knode_parent); |
513 | struct device *dev = p->device; | ||
514 | 513 | ||
515 | get_device(dev); | 514 | get_device(dev); |
516 | } | 515 | } |
517 | 516 | ||
518 | static void klist_children_put(struct klist_node *n) | 517 | static void klist_children_put(struct klist_node *n) |
519 | { | 518 | { |
520 | struct device_private *p = to_device_private_parent(n); | 519 | struct device *dev = container_of(n, struct device, knode_parent); |
521 | struct device *dev = p->device; | ||
522 | 520 | ||
523 | put_device(dev); | 521 | put_device(dev); |
524 | } | 522 | } |
@@ -548,7 +546,7 @@ void device_initialize(struct device *dev) | |||
548 | dev->p->device = dev; | 546 | dev->p->device = dev; |
549 | dev->kobj.kset = devices_kset; | 547 | dev->kobj.kset = devices_kset; |
550 | kobject_init(&dev->kobj, &device_ktype); | 548 | kobject_init(&dev->kobj, &device_ktype); |
551 | klist_init(&dev->p->klist_children, klist_children_get, | 549 | klist_init(&dev->klist_children, klist_children_get, |
552 | klist_children_put); | 550 | klist_children_put); |
553 | INIT_LIST_HEAD(&dev->dma_pools); | 551 | INIT_LIST_HEAD(&dev->dma_pools); |
554 | init_MUTEX(&dev->sem); | 552 | init_MUTEX(&dev->sem); |
@@ -932,8 +930,7 @@ int device_add(struct device *dev) | |||
932 | kobject_uevent(&dev->kobj, KOBJ_ADD); | 930 | kobject_uevent(&dev->kobj, KOBJ_ADD); |
933 | bus_attach_device(dev); | 931 | bus_attach_device(dev); |
934 | if (parent) | 932 | if (parent) |
935 | klist_add_tail(&dev->p->knode_parent, | 933 | klist_add_tail(&dev->knode_parent, &parent->klist_children); |
936 | &parent->p->klist_children); | ||
937 | 934 | ||
938 | if (dev->class) { | 935 | if (dev->class) { |
939 | mutex_lock(&dev->class->p->class_mutex); | 936 | mutex_lock(&dev->class->p->class_mutex); |
@@ -1047,7 +1044,7 @@ void device_del(struct device *dev) | |||
1047 | device_pm_remove(dev); | 1044 | device_pm_remove(dev); |
1048 | dpm_sysfs_remove(dev); | 1045 | dpm_sysfs_remove(dev); |
1049 | if (parent) | 1046 | if (parent) |
1050 | klist_del(&dev->p->knode_parent); | 1047 | klist_del(&dev->knode_parent); |
1051 | if (MAJOR(dev->devt)) { | 1048 | if (MAJOR(dev->devt)) { |
1052 | device_remove_sys_dev_entry(dev); | 1049 | device_remove_sys_dev_entry(dev); |
1053 | device_remove_file(dev, &devt_attr); | 1050 | device_remove_file(dev, &devt_attr); |
@@ -1108,14 +1105,7 @@ void device_unregister(struct device *dev) | |||
1108 | static struct device *next_device(struct klist_iter *i) | 1105 | static struct device *next_device(struct klist_iter *i) |
1109 | { | 1106 | { |
1110 | struct klist_node *n = klist_next(i); | 1107 | struct klist_node *n = klist_next(i); |
1111 | struct device *dev = NULL; | 1108 | return n ? container_of(n, struct device, knode_parent) : NULL; |
1112 | struct device_private *p; | ||
1113 | |||
1114 | if (n) { | ||
1115 | p = to_device_private_parent(n); | ||
1116 | dev = p->device; | ||
1117 | } | ||
1118 | return dev; | ||
1119 | } | 1109 | } |
1120 | 1110 | ||
1121 | /** | 1111 | /** |
@@ -1137,7 +1127,7 @@ int device_for_each_child(struct device *parent, void *data, | |||
1137 | struct device *child; | 1127 | struct device *child; |
1138 | int error = 0; | 1128 | int error = 0; |
1139 | 1129 | ||
1140 | klist_iter_init(&parent->p->klist_children, &i); | 1130 | klist_iter_init(&parent->klist_children, &i); |
1141 | while ((child = next_device(&i)) && !error) | 1131 | while ((child = next_device(&i)) && !error) |
1142 | error = fn(child, data); | 1132 | error = fn(child, data); |
1143 | klist_iter_exit(&i); | 1133 | klist_iter_exit(&i); |
@@ -1168,7 +1158,7 @@ struct device *device_find_child(struct device *parent, void *data, | |||
1168 | if (!parent) | 1158 | if (!parent) |
1169 | return NULL; | 1159 | return NULL; |
1170 | 1160 | ||
1171 | klist_iter_init(&parent->p->klist_children, &i); | 1161 | klist_iter_init(&parent->klist_children, &i); |
1172 | while ((child = next_device(&i))) | 1162 | while ((child = next_device(&i))) |
1173 | if (match(child, data) && get_device(child)) | 1163 | if (match(child, data) && get_device(child)) |
1174 | break; | 1164 | break; |
@@ -1582,10 +1572,9 @@ int device_move(struct device *dev, struct device *new_parent) | |||
1582 | old_parent = dev->parent; | 1572 | old_parent = dev->parent; |
1583 | dev->parent = new_parent; | 1573 | dev->parent = new_parent; |
1584 | if (old_parent) | 1574 | if (old_parent) |
1585 | klist_remove(&dev->p->knode_parent); | 1575 | klist_remove(&dev->knode_parent); |
1586 | if (new_parent) { | 1576 | if (new_parent) { |
1587 | klist_add_tail(&dev->p->knode_parent, | 1577 | klist_add_tail(&dev->knode_parent, &new_parent->klist_children); |
1588 | &new_parent->p->klist_children); | ||
1589 | set_dev_node(dev, dev_to_node(new_parent)); | 1578 | set_dev_node(dev, dev_to_node(new_parent)); |
1590 | } | 1579 | } |
1591 | 1580 | ||
@@ -1597,11 +1586,11 @@ int device_move(struct device *dev, struct device *new_parent) | |||
1597 | device_move_class_links(dev, new_parent, old_parent); | 1586 | device_move_class_links(dev, new_parent, old_parent); |
1598 | if (!kobject_move(&dev->kobj, &old_parent->kobj)) { | 1587 | if (!kobject_move(&dev->kobj, &old_parent->kobj)) { |
1599 | if (new_parent) | 1588 | if (new_parent) |
1600 | klist_remove(&dev->p->knode_parent); | 1589 | klist_remove(&dev->knode_parent); |
1601 | dev->parent = old_parent; | 1590 | dev->parent = old_parent; |
1602 | if (old_parent) { | 1591 | if (old_parent) { |
1603 | klist_add_tail(&dev->p->knode_parent, | 1592 | klist_add_tail(&dev->knode_parent, |
1604 | &old_parent->p->klist_children); | 1593 | &old_parent->klist_children); |
1605 | set_dev_node(dev, dev_to_node(old_parent)); | 1594 | set_dev_node(dev, dev_to_node(old_parent)); |
1606 | } | 1595 | } |
1607 | } | 1596 | } |
diff --git a/include/linux/device.h b/include/linux/device.h index c66ceb15acd8..2975351635d3 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
@@ -366,6 +366,8 @@ struct device_dma_parameters { | |||
366 | }; | 366 | }; |
367 | 367 | ||
368 | struct device { | 368 | struct device { |
369 | struct klist klist_children; | ||
370 | struct klist_node knode_parent; /* node in sibling list */ | ||
369 | struct klist_node knode_driver; | 371 | struct klist_node knode_driver; |
370 | struct klist_node knode_bus; | 372 | struct klist_node knode_bus; |
371 | struct device *parent; | 373 | struct device *parent; |