driver core fixes for your 2.6-git tree
PATCH 1/1 driver core fixes for your 2.6-git tree
Here are 4 reverts of patches that were previously pulled into your git tree. They revert the ability for the driver core to have a private area in struct device.
Thanks to Stefan Richter for pointing out the problems with the current implementation, and for Alan Cox persuading me to rework the whole thing, which I will do for the 2.6.30 release.
Please pull from:
master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-core-2.6.git/
The patches will be sent as a follow-on to this message to lkml for people to see.
thanks,
greg k-h
------------
drivers/base/base.h | 26 -------------------------- drivers/base/bus.c | 40 +++++++++++++--------------------------- drivers/base/core.c | 45 +++++++++++++-------------------------------- drivers/base/dd.c | 13 +++++-------- drivers/base/driver.c | 13 +++---------- include/linux/device.h | 7 ++++--- 6 files changed, 38 insertions(+), 106 deletions(-)
---------------
Greg Kroah-Hartman (4):
Revert "driver core: move knode_bus into private structure" Revert "driver core: move knode_driver into private structure" Revert "driver core: move klist_children into private structure" Revert "driver core: create a private portion of struct device"
PATCH 1/4 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.
--- drivers/base/base.h | 4 ---- drivers/base/bus.c | 40 +++++++++++++--------------------------- include/linux/device.h | 1 + 3 files changed, 14 insertions(+), 31 deletions(-)
drivers/base/base.h +0 -4
@@ -69,7 +69,6 @@ struct class_private {* @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. *
@@ -79,15 +78,12 @@ 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 );
drivers/base/bus.c +13 -27
@@ -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);
include/linux/device.h +1 -0
@@ -366,6 +366,7 @@ struct device_dma_parameters { };struct device { +struct klist_node knode_bus;struct device *parent;struct device_private *p;
Signature · 1 line
1.6.0.4
PATCH 2/4 Revert "driver core: move knode_driver into private structure"
In reply to Greg KHThis 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.
--- drivers/base/base.h | 4 ---- drivers/base/dd.c | 13 +++++-------- drivers/base/driver.c | 13 +++---------- include/linux/device.h | 1 + 4 files changed, 9 insertions(+), 22 deletions(-)
drivers/base/base.h +0 -4
@@ -68,7 +68,6 @@ 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. *
@@ -77,13 +76,10 @@ 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 );
drivers/base/dd.c +5 -8
@@ -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);
drivers/base/driver.c +3 -10
@@ -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 ;
include/linux/device.h +1 -0
@@ -366,6 +366,7 @@ struct device_dma_parameters { };struct device { +struct klist_node knode_driver;struct klist_node knode_bus;struct device *parent;
Signature · 1 line
1.6.0.4
PATCH 3/4 Revert "driver core: move klist_children into private structure"
In reply to Greg KHThis 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.
--- drivers/base/base.h | 6 ------ drivers/base/core.c | 37 +++++++++++++------------------------ include/linux/device.h | 2 ++ 3 files changed, 15 insertions(+), 30 deletions(-)
drivers/base/base.h +0 -6
@@ -66,20 +66,14 @@ struct class_private {/** * 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 * @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 device *device; }; -#define to_device_private_parent (obj) \ - container_of(obj, struct device_private, knode_parent)/* initialisation functions */ extern int devices_init (void );
drivers/base/core.c +13 -24
@@ -509,16 +509,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); }
@@ -548,7 +546,7 @@ void device_initialize(struct device *dev) 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 +930,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 +1044,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 +1105,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 +1127,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 +1158,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 +1572,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 +1586,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)); } }
include/linux/device.h +2 -0
@@ -366,6 +366,8 @@ 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;
Signature · 1 line
1.6.0.4
PATCH 4/4 Revert "driver core: create a private portion of struct device"
In reply to Greg KHThis reverts commit 2831fe6f9cc4e16c103504ee09a47a084297c0f3.
Turns out that device_initialize shouldn't fail silently. This series needs to be reworked in order to get into proper shape.
--- drivers/base/base.h | 12 ------------ drivers/base/core.c | 8 -------- include/linux/device.h | 3 --- 3 files changed, 0 insertions(+), 23 deletions(-)
drivers/base/base.h +0 -12
@@ -63,18 +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. -* -* @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 device *device; -}; -/* initialisation functions */ extern int devices_init (void );extern int buses_init (void );
drivers/base/core.c +0 -8
@@ -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 = {
@@ -538,12 +536,6 @@ 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->klist_children, klist_children_get,
include/linux/device.h +0 -3
@@ -28,7 +28,6 @@#define BUS_ID_SIZE 20struct device ; -struct device_private ;struct device_driver ;struct driver_private ;struct class ;
@@ -372,8 +371,6 @@ struct device {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;
Signature · 1 line
1.6.0.4