]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
driver core: move knode_driver into private structure
authorGreg Kroah-Hartman <gregkh@suse.de>
Tue, 16 Dec 2008 20:25:49 +0000 (12:25 -0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 6 Jan 2009 18:44:32 +0000 (10:44 -0800)
Nothing outside of the driver core should ever touch knode_driver, so
move it out of the public eye.

Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/base/base.h
drivers/base/dd.c
drivers/base/driver.c
include/linux/device.h

index f5cf31c664d78c3ad7ffcb6baf247956645b6ab9..8af0bb2c0aa879e9e20bfc4ad6acf5e328b5331e 100644 (file)
@@ -68,6 +68,7 @@ struct class_private {
  *
  * @klist_children - klist containing all children of this device
  * @knode_parent - node in sibling list
+ * @knode_driver - node in driver list
  * @device - pointer back to the struct class that this structure is
  * associated with.
  *
@@ -76,10 +77,13 @@ struct class_private {
 struct device_private {
        struct klist klist_children;
        struct klist_node knode_parent;
+       struct klist_node knode_driver;
        struct device *device;
 };
 #define to_device_private_parent(obj)  \
        container_of(obj, struct device_private, knode_parent)
+#define to_device_private_driver(obj)  \
+       container_of(obj, struct device_private, knode_driver)
 
 /* initialisation functions */
 extern int devices_init(void);
index 17a8e45cf9c6d52a01152c628d21a68132fef020..bb5f1eb83c0363d84de8eca98d894b95809ac763 100644 (file)
@@ -28,7 +28,7 @@
 
 static void driver_bound(struct device *dev)
 {
-       if (klist_node_attached(&dev->knode_driver)) {
+       if (klist_node_attached(&dev->p->knode_driver)) {
                printk(KERN_WARNING "%s: device %s already bound\n",
                        __func__, kobject_name(&dev->kobj));
                return;
@@ -41,7 +41,7 @@ static void driver_bound(struct device *dev)
                blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
                                             BUS_NOTIFY_BOUND_DRIVER, dev);
 
-       klist_add_tail(&dev->knode_driver, &dev->driver->p->klist_devices);
+       klist_add_tail(&dev->p->knode_driver, &dev->driver->p->klist_devices);
 }
 
 static int driver_sysfs_add(struct device *dev)
@@ -311,7 +311,7 @@ static void __device_release_driver(struct device *dev)
                        drv->remove(dev);
                devres_release_all(dev);
                dev->driver = NULL;
-               klist_remove(&dev->knode_driver);
+               klist_remove(&dev->p->knode_driver);
        }
 }
 
@@ -341,6 +341,7 @@ EXPORT_SYMBOL_GPL(device_release_driver);
  */
 void driver_detach(struct device_driver *drv)
 {
+       struct device_private *dev_prv;
        struct device *dev;
 
        for (;;) {
@@ -349,8 +350,10 @@ void driver_detach(struct device_driver *drv)
                        spin_unlock(&drv->p->klist_devices.k_lock);
                        break;
                }
-               dev = list_entry(drv->p->klist_devices.k_list.prev,
-                               struct device, knode_driver.n_node);
+               dev_prv = list_entry(drv->p->klist_devices.k_list.prev,
+                                    struct device_private,
+                                    knode_driver.n_node);
+               dev = dev_prv->device;
                get_device(dev);
                spin_unlock(&drv->p->klist_devices.k_lock);
 
index 1e2bda780e48268eb38b834f7078644689b5dc7b..b76cc69f11067801e85f830573d098561eb97727 100644 (file)
 static struct device *next_device(struct klist_iter *i)
 {
        struct klist_node *n = klist_next(i);
-       return n ? container_of(n, struct device, knode_driver) : NULL;
+       struct device *dev = NULL;
+       struct device_private *dev_prv;
+
+       if (n) {
+               dev_prv = to_device_private_driver(n);
+               dev = dev_prv->device;
+       }
+       return dev;
 }
 
 /**
@@ -42,7 +49,7 @@ int driver_for_each_device(struct device_driver *drv, struct device *start,
                return -EINVAL;
 
        klist_iter_init_node(&drv->p->klist_devices, &i,
-                            start ? &start->knode_driver : NULL);
+                            start ? &start->p->knode_driver : NULL);
        while ((dev = next_device(&i)) && !error)
                error = fn(dev, data);
        klist_iter_exit(&i);
@@ -76,7 +83,7 @@ struct device *driver_find_device(struct device_driver *drv,
                return NULL;
 
        klist_iter_init_node(&drv->p->klist_devices, &i,
-                            (start ? &start->knode_driver : NULL));
+                            (start ? &start->p->knode_driver : NULL));
        while ((dev = next_device(&i)))
                if (match(dev, data) && get_device(dev))
                        break;
index 60423e68720591ba11827f2454a7a3afd979b3b7..e3630222c3c10f642730a65a2ea9a17730640546 100644 (file)
@@ -366,7 +366,6 @@ struct device_dma_parameters {
 };
 
 struct device {
-       struct klist_node       knode_driver;
        struct klist_node       knode_bus;
        struct device           *parent;