diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-09 15:30:54 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-09 15:31:07 -0800 |
commit | 0d34052dfeba307ebc18d2f672e80e3f419714d4 (patch) | |
tree | 8f7955328cd9700c443c33f88631449a0c1208fb | |
parent | f0fb2eb7bd76b9927f1350cfb0a3653385b82c6c (diff) | |
parent | 926beadb3dfaddccb3348a5b9e6c2a1f8290a220 (diff) | |
download | op-kernel-dev-0d34052dfeba307ebc18d2f672e80e3f419714d4.zip op-kernel-dev-0d34052dfeba307ebc18d2f672e80e3f419714d4.tar.gz |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6:
Revert "driver core: create a private portion of struct device"
Revert "driver core: move klist_children into private structure"
Revert "driver core: move knode_driver into private structure"
Revert "driver core: move knode_bus into private structure"
-rw-r--r-- | drivers/base/base.h | 26 | ||||
-rw-r--r-- | drivers/base/bus.c | 40 | ||||
-rw-r--r-- | drivers/base/core.c | 45 | ||||
-rw-r--r-- | drivers/base/dd.c | 13 | ||||
-rw-r--r-- | drivers/base/driver.c | 13 | ||||
-rw-r--r-- | include/linux/device.h | 7 |
6 files changed, 38 insertions, 106 deletions
diff --git a/drivers/base/base.h b/drivers/base/base.h index b676f8f..0a5f055 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h @@ -63,32 +63,6 @@ struct class_private { #define to_class(obj) \ container_of(obj, struct class_private, class_subsys.kobj) -/** - * struct device_private - structure to hold the private to the driver core portions of the device structure. - * - * @klist_children - klist containing all children of this device - * @knode_parent - node in sibling list - * @knode_driver - node in driver list - * @knode_bus - node in bus list - * @device - pointer back to the struct class that this structure is - * associated with. - * - * Nothing outside of the driver core should ever touch these fields. - */ -struct device_private { - struct klist klist_children; - struct klist_node knode_parent; - struct klist_node knode_driver; - struct klist_node knode_bus; - 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) -#define to_device_private_bus(obj) \ - container_of(obj, struct device_private, knode_bus) - /* initialisation functions */ extern int devices_init(void); extern int buses_init(void); diff --git a/drivers/base/bus.c b/drivers/base/bus.c index 0f0a504..83f32b8 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, static struct device *next_device(struct klist_iter *i) { struct klist_node *n = klist_next(i); - struct device *dev = NULL; - struct device_private *dev_prv; - - if (n) { - dev_prv = to_device_private_bus(n); - dev = dev_prv->device; - } - return dev; + return n ? container_of(n, struct device, knode_bus) : NULL; } /** @@ -293,7 +286,7 @@ int bus_for_each_dev(struct bus_type *bus, struct device *start, return -EINVAL; klist_iter_init_node(&bus->p->klist_devices, &i, - (start ? &start->p->knode_bus : NULL)); + (start ? &start->knode_bus : NULL)); while ((dev = next_device(&i)) && !error) error = fn(dev, data); klist_iter_exit(&i); @@ -327,7 +320,7 @@ struct device *bus_find_device(struct bus_type *bus, return NULL; klist_iter_init_node(&bus->p->klist_devices, &i, - (start ? &start->p->knode_bus : NULL)); + (start ? &start->knode_bus : NULL)); while ((dev = next_device(&i))) if (match(dev, data) && get_device(dev)) break; @@ -514,8 +507,7 @@ void bus_attach_device(struct device *dev) ret = device_attach(dev); WARN_ON(ret < 0); if (ret >= 0) - klist_add_tail(&dev->p->knode_bus, - &bus->p->klist_devices); + klist_add_tail(&dev->knode_bus, &bus->p->klist_devices); } } @@ -536,8 +528,8 @@ void bus_remove_device(struct device *dev) sysfs_remove_link(&dev->bus->p->devices_kset->kobj, dev_name(dev)); device_remove_attrs(dev->bus, dev); - if (klist_node_attached(&dev->p->knode_bus)) - klist_del(&dev->p->knode_bus); + if (klist_node_attached(&dev->knode_bus)) + klist_del(&dev->knode_bus); pr_debug("bus: '%s': remove device %s\n", dev->bus->name, dev_name(dev)); @@ -839,16 +831,14 @@ static void bus_remove_attrs(struct bus_type *bus) static void klist_devices_get(struct klist_node *n) { - struct device_private *dev_prv = to_device_private_bus(n); - struct device *dev = dev_prv->device; + struct device *dev = container_of(n, struct device, knode_bus); get_device(dev); } static void klist_devices_put(struct klist_node *n) { - struct device_private *dev_prv = to_device_private_bus(n); - struct device *dev = dev_prv->device; + struct device *dev = container_of(n, struct device, knode_bus); put_device(dev); } @@ -1003,20 +993,18 @@ static void device_insertion_sort_klist(struct device *a, struct list_head *list { struct list_head *pos; struct klist_node *n; - struct device_private *dev_prv; struct device *b; list_for_each(pos, list) { n = container_of(pos, struct klist_node, n_node); - dev_prv = to_device_private_bus(n); - b = dev_prv->device; + b = container_of(n, struct device, knode_bus); if (compare(a, b) <= 0) { - list_move_tail(&a->p->knode_bus.n_node, - &b->p->knode_bus.n_node); + list_move_tail(&a->knode_bus.n_node, + &b->knode_bus.n_node); return; } } - list_move_tail(&a->p->knode_bus.n_node, list); + list_move_tail(&a->knode_bus.n_node, list); } void bus_sort_breadthfirst(struct bus_type *bus, @@ -1026,7 +1014,6 @@ void bus_sort_breadthfirst(struct bus_type *bus, LIST_HEAD(sorted_devices); struct list_head *pos, *tmp; struct klist_node *n; - struct device_private *dev_prv; struct device *dev; struct klist *device_klist; @@ -1035,8 +1022,7 @@ void bus_sort_breadthfirst(struct bus_type *bus, spin_lock(&device_klist->k_lock); list_for_each_safe(pos, tmp, &device_klist->k_list) { n = container_of(pos, struct klist_node, n_node); - dev_prv = to_device_private_bus(n); - dev = dev_prv->device; + dev = container_of(n, struct device, knode_bus); device_insertion_sort_klist(dev, &sorted_devices, compare); } list_splice(&sorted_devices, &device_klist->k_list); diff --git a/drivers/base/core.c b/drivers/base/core.c index 61df508..8079afc 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -109,7 +109,6 @@ static struct sysfs_ops dev_sysfs_ops = { static void device_release(struct kobject *kobj) { struct device *dev = to_dev(kobj); - struct device_private *p = dev->p; if (dev->release) dev->release(dev); @@ -121,7 +120,6 @@ static void device_release(struct kobject *kobj) WARN(1, KERN_ERR "Device '%s' does not have a release() " "function, it is broken and must be fixed.\n", dev_name(dev)); - kfree(p); } static struct kobj_type device_ktype = { @@ -509,16 +507,14 @@ EXPORT_SYMBOL_GPL(device_schedule_callback_owner); static void klist_children_get(struct klist_node *n) { - struct device_private *p = to_device_private_parent(n); - struct device *dev = p->device; + struct device *dev = container_of(n, struct device, knode_parent); get_device(dev); } static void klist_children_put(struct klist_node *n) { - struct device_private *p = to_device_private_parent(n); - struct device *dev = p->device; + struct device *dev = container_of(n, struct device, knode_parent); put_device(dev); } @@ -540,15 +536,9 @@ static void klist_children_put(struct klist_node *n) */ void device_initialize(struct device *dev) { - dev->p = kzalloc(sizeof(*dev->p), GFP_KERNEL); - if (!dev->p) { - WARN_ON(1); - return; - } - dev->p->device = dev; dev->kobj.kset = devices_kset; kobject_init(&dev->kobj, &device_ktype); - klist_init(&dev->p->klist_children, klist_children_get, + klist_init(&dev->klist_children, klist_children_get, klist_children_put); INIT_LIST_HEAD(&dev->dma_pools); init_MUTEX(&dev->sem); @@ -932,8 +922,7 @@ int device_add(struct device *dev) kobject_uevent(&dev->kobj, KOBJ_ADD); bus_attach_device(dev); if (parent) - klist_add_tail(&dev->p->knode_parent, - &parent->p->klist_children); + klist_add_tail(&dev->knode_parent, &parent->klist_children); if (dev->class) { mutex_lock(&dev->class->p->class_mutex); @@ -1047,7 +1036,7 @@ void device_del(struct device *dev) device_pm_remove(dev); dpm_sysfs_remove(dev); if (parent) - klist_del(&dev->p->knode_parent); + klist_del(&dev->knode_parent); if (MAJOR(dev->devt)) { device_remove_sys_dev_entry(dev); device_remove_file(dev, &devt_attr); @@ -1108,14 +1097,7 @@ void device_unregister(struct device *dev) static struct device *next_device(struct klist_iter *i) { struct klist_node *n = klist_next(i); - struct device *dev = NULL; - struct device_private *p; - - if (n) { - p = to_device_private_parent(n); - dev = p->device; - } - return dev; + return n ? container_of(n, struct device, knode_parent) : NULL; } /** @@ -1137,7 +1119,7 @@ int device_for_each_child(struct device *parent, void *data, struct device *child; int error = 0; - klist_iter_init(&parent->p->klist_children, &i); + klist_iter_init(&parent->klist_children, &i); while ((child = next_device(&i)) && !error) error = fn(child, data); klist_iter_exit(&i); @@ -1168,7 +1150,7 @@ struct device *device_find_child(struct device *parent, void *data, if (!parent) return NULL; - klist_iter_init(&parent->p->klist_children, &i); + klist_iter_init(&parent->klist_children, &i); while ((child = next_device(&i))) if (match(child, data) && get_device(child)) break; @@ -1582,10 +1564,9 @@ int device_move(struct device *dev, struct device *new_parent) old_parent = dev->parent; dev->parent = new_parent; if (old_parent) - klist_remove(&dev->p->knode_parent); + klist_remove(&dev->knode_parent); if (new_parent) { - klist_add_tail(&dev->p->knode_parent, - &new_parent->p->klist_children); + klist_add_tail(&dev->knode_parent, &new_parent->klist_children); set_dev_node(dev, dev_to_node(new_parent)); } @@ -1597,11 +1578,11 @@ int device_move(struct device *dev, struct device *new_parent) device_move_class_links(dev, new_parent, old_parent); if (!kobject_move(&dev->kobj, &old_parent->kobj)) { if (new_parent) - klist_remove(&dev->p->knode_parent); + klist_remove(&dev->knode_parent); dev->parent = old_parent; if (old_parent) { - klist_add_tail(&dev->p->knode_parent, - &old_parent->p->klist_children); + klist_add_tail(&dev->knode_parent, + &old_parent->klist_children); set_dev_node(dev, dev_to_node(old_parent)); } } diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 6fdaf76..315bed8 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -28,7 +28,7 @@ static void driver_bound(struct device *dev) { - if (klist_node_attached(&dev->p->knode_driver)) { + if (klist_node_attached(&dev->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->p->knode_driver, &dev->driver->p->klist_devices); + klist_add_tail(&dev->knode_driver, &dev->driver->p->klist_devices); } static int driver_sysfs_add(struct device *dev) @@ -310,7 +310,7 @@ static void __device_release_driver(struct device *dev) drv->remove(dev); devres_release_all(dev); dev->driver = NULL; - klist_remove(&dev->p->knode_driver); + klist_remove(&dev->knode_driver); } } @@ -340,7 +340,6 @@ EXPORT_SYMBOL_GPL(device_release_driver); */ void driver_detach(struct device_driver *drv) { - struct device_private *dev_prv; struct device *dev; for (;;) { @@ -349,10 +348,8 @@ void driver_detach(struct device_driver *drv) spin_unlock(&drv->p->klist_devices.k_lock); break; } - dev_prv = list_entry(drv->p->klist_devices.k_list.prev, - struct device_private, - knode_driver.n_node); - dev = dev_prv->device; + dev = list_entry(drv->p->klist_devices.k_list.prev, + struct device, knode_driver.n_node); get_device(dev); spin_unlock(&drv->p->klist_devices.k_lock); diff --git a/drivers/base/driver.c b/drivers/base/driver.c index b76cc69..1e2bda7 100644 --- a/drivers/base/driver.c +++ b/drivers/base/driver.c @@ -19,14 +19,7 @@ static struct device *next_device(struct klist_iter *i) { struct klist_node *n = klist_next(i); - struct device *dev = NULL; - struct device_private *dev_prv; - - if (n) { - dev_prv = to_device_private_driver(n); - dev = dev_prv->device; - } - return dev; + return n ? container_of(n, struct device, knode_driver) : NULL; } /** @@ -49,7 +42,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->p->knode_driver : NULL); + start ? &start->knode_driver : NULL); while ((dev = next_device(&i)) && !error) error = fn(dev, data); klist_iter_exit(&i); @@ -83,7 +76,7 @@ struct device *driver_find_device(struct device_driver *drv, return NULL; klist_iter_init_node(&drv->p->klist_devices, &i, - (start ? &start->p->knode_driver : NULL)); + (start ? &start->knode_driver : NULL)); while ((dev = next_device(&i))) if (match(dev, data) && get_device(dev)) break; diff --git a/include/linux/device.h b/include/linux/device.h index 7d9da4b..45e5b19 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -28,7 +28,6 @@ #define BUS_ID_SIZE 20 struct device; -struct device_private; struct device_driver; struct driver_private; struct class; @@ -366,10 +365,12 @@ struct device_dma_parameters { }; struct device { + struct klist klist_children; + struct klist_node knode_parent; /* node in sibling list */ + struct klist_node knode_driver; + struct klist_node knode_bus; struct device *parent; - struct device_private *p; - struct kobject kobj; char bus_id[BUS_ID_SIZE]; /* position on parent bus */ unsigned uevent_suppress:1; |