On Wed, Jul 11, 2007 at 12:54:58PM +0200, Stefan Richter wrote:if other device overwrite that, it is OK.Yinghai Lu wrote:--- a/drivers/base/core.cTwo remarks:
+++ b/drivers/base/core.c
@@ -547,6 +547,8 @@ static void klist_children_put(struct klist_node *n)
void device_initialize(struct device *dev)
{
+ int node;
+
kobj_set_kset_s(dev, devices_subsys);
kobject_init(&dev->kobj);
klist_init(&dev->klist_children, klist_children_get,
@@ -557,7 +559,9 @@ void device_initialize(struct device *dev)
spin_lock_init(&dev->devres_lock);
INIT_LIST_HEAD(&dev->devres_head);
device_init_wakeup(dev, 0);
- set_dev_node(dev, -1);
+
+ node = dev->parent ? dev_to_node(dev->parent) : -1;
+ set_dev_node(dev, node);
}
- device_add() is perhaps a better place to do this. Otherwise you
had to change code like drivers/input/gameport/gameport.c::
gameport_init_port() which sets the parent device *after* the
call to device_initialize().
I agree, lots of code sets up the parent pointer after initialize and
before add. One such example is the whole USB subsystem.
Which makes me wonder how this code was really tested at all to show
that it actually had an affect...