aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2009-01-09 17:44:18 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2009-01-09 17:44:18 -0500
commitcda5e83fdea476dce9c0a9b1152cd6ca46832cc4 (patch)
tree38095e8b88c8c163cb8b61e8f071d444752fad6b /drivers
parent4db8e282f2d1dfa43d51ce2a4817901312c9134d (diff)
Revert "driver core: move knode_driver into private structure"
This reverts commit 93e746db183b3bdbbda67900f79b5835f9cb388f. 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')
-rw-r--r--drivers/base/base.h4
-rw-r--r--drivers/base/dd.c13
-rw-r--r--drivers/base/driver.c13
3 files changed, 8 insertions, 22 deletions
diff --git a/drivers/base/base.h b/drivers/base/base.h
index 8af0bb2c0aa8..f5cf31c664d7 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -68,7 +68,6 @@ 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
72 * @device - pointer back to the struct class that this structure is 71 * @device - pointer back to the struct class that this structure is
73 * associated with. 72 * associated with.
74 * 73 *
@@ -77,13 +76,10 @@ struct class_private {
77struct device_private { 76struct device_private {
78 struct klist klist_children; 77 struct klist klist_children;
79 struct klist_node knode_parent; 78 struct klist_node knode_parent;
80 struct klist_node knode_driver;
81 struct device *device; 79 struct device *device;
82}; 80};
83#define to_device_private_parent(obj) \ 81#define to_device_private_parent(obj) \
84 container_of(obj, struct device_private, knode_parent) 82 container_of(obj, struct device_private, knode_parent)
85#define to_device_private_driver(obj) \
86 container_of(obj, struct device_private, knode_driver)
87 83
88/* initialisation functions */ 84/* initialisation functions */
89extern int devices_init(void); 85extern int devices_init(void);
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 6fdaf76f033f..315bed8d5e7f 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -28,7 +28,7 @@
28 28
29static void driver_bound(struct device *dev) 29static void driver_bound(struct device *dev)
30{ 30{
31 if (klist_node_attached(&dev->p->knode_driver)) { 31 if (klist_node_attached(&dev->knode_driver)) {
32 printk(KERN_WARNING "%s: device %s already bound\n", 32 printk(KERN_WARNING "%s: device %s already bound\n",
33 __func__, kobject_name(&dev->kobj)); 33 __func__, kobject_name(&dev->kobj));
34 return; 34 return;
@@ -41,7 +41,7 @@ static void driver_bound(struct device *dev)
41 blocking_notifier_call_chain(&dev->bus->p->bus_notifier, 41 blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
42 BUS_NOTIFY_BOUND_DRIVER, dev); 42 BUS_NOTIFY_BOUND_DRIVER, dev);
43 43
44 klist_add_tail(&dev->p->knode_driver, &dev->driver->p->klist_devices); 44 klist_add_tail(&dev->knode_driver, &dev->driver->p->klist_devices);
45} 45}
46 46
47static int driver_sysfs_add(struct device *dev) 47static int driver_sysfs_add(struct device *dev)
@@ -310,7 +310,7 @@ static void __device_release_driver(struct device *dev)
310 drv->remove(dev); 310 drv->remove(dev);
311 devres_release_all(dev); 311 devres_release_all(dev);
312 dev->driver = NULL; 312 dev->driver = NULL;
313 klist_remove(&dev->p->knode_driver); 313 klist_remove(&dev->knode_driver);
314 } 314 }
315} 315}
316 316
@@ -340,7 +340,6 @@ EXPORT_SYMBOL_GPL(device_release_driver);
340 */ 340 */
341void driver_detach(struct device_driver *drv) 341void driver_detach(struct device_driver *drv)
342{ 342{
343 struct device_private *dev_prv;
344 struct device *dev; 343 struct device *dev;
345 344
346 for (;;) { 345 for (;;) {
@@ -349,10 +348,8 @@ void driver_detach(struct device_driver *drv)
349 spin_unlock(&drv->p->klist_devices.k_lock); 348 spin_unlock(&drv->p->klist_devices.k_lock);
350 break; 349 break;
351 } 350 }
352 dev_prv = list_entry(drv->p->klist_devices.k_list.prev, 351 dev = list_entry(drv->p->klist_devices.k_list.prev,
353 struct device_private, 352 struct device, knode_driver.n_node);
354 knode_driver.n_node);
355 dev = dev_prv->device;
356 get_device(dev); 353 get_device(dev);
357 spin_unlock(&drv->p->klist_devices.k_lock); 354 spin_unlock(&drv->p->klist_devices.k_lock);
358 355
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index b76cc69f1106..1e2bda780e48 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -19,14 +19,7 @@
19static struct device *next_device(struct klist_iter *i) 19static 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 struct device *dev = NULL; 22 return n ? container_of(n, struct device, knode_driver) : 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;
30} 23}
31 24
32/** 25/**
@@ -49,7 +42,7 @@ int driver_for_each_device(struct device_driver *drv, struct device *start,
49 return -EINVAL; 42 return -EINVAL;
50 43
51 klist_iter_init_node(&drv->p->klist_devices, &i, 44 klist_iter_init_node(&drv->p->klist_devices, &i,
52 start ? &start->p->knode_driver : NULL); 45 start ? &start->knode_driver : NULL);
53 while ((dev = next_device(&i)) && !error) 46 while ((dev = next_device(&i)) && !error)
54 error = fn(dev, data); 47 error = fn(dev, data);
55 klist_iter_exit(&i); 48 klist_iter_exit(&i);
@@ -83,7 +76,7 @@ struct device *driver_find_device(struct device_driver *drv,
83 return NULL; 76 return NULL;
84 77
85 klist_iter_init_node(&drv->p->klist_devices, &i, 78 klist_iter_init_node(&drv->p->klist_devices, &i,
86 (start ? &start->p->knode_driver : NULL)); 79 (start ? &start->knode_driver : NULL));
87 while ((dev = next_device(&i))) 80 while ((dev = next_device(&i)))
88 if (match(dev, data) && get_device(dev)) 81 if (match(dev, data) && get_device(dev))
89 break; 82 break;