Commit f08cf2ca authored by Patrick Mochel's avatar Patrick Mochel

[power] Make sure devices get added to the PM lists before bus_add_device().

- Prevents ordering issues when drivers add more devices ->probe(). 
parent f0d99f82
...@@ -225,28 +225,30 @@ int device_add(struct device *dev) ...@@ -225,28 +225,30 @@ int device_add(struct device *dev)
dev->kobj.parent = &parent->kobj; dev->kobj.parent = &parent->kobj;
if ((error = kobject_add(&dev->kobj))) if ((error = kobject_add(&dev->kobj)))
goto register_done; goto Error;
if ((error = device_pm_add(dev)))
/* now take care of our own registration */ goto PMError;
if ((error = bus_add_device(dev)))
goto BusError;
down_write(&devices_subsys.rwsem); down_write(&devices_subsys.rwsem);
if (parent) if (parent)
list_add_tail(&dev->node,&parent->children); list_add_tail(&dev->node,&parent->children);
up_write(&devices_subsys.rwsem); up_write(&devices_subsys.rwsem);
bus_add_device(dev);
device_pm_add(dev);
/* notify platform of device entry */ /* notify platform of device entry */
if (platform_notify) if (platform_notify)
platform_notify(dev); platform_notify(dev);
Done:
register_done:
if (error && parent)
put_device(parent);
put_device(dev); put_device(dev);
return error; return error;
BusError:
device_pm_remove(dev);
PMError:
kobject_unregister(&dev->kobj);
Error:
if (parent)
put_device(parent);
goto Done;
} }
...@@ -312,8 +314,6 @@ void device_del(struct device * dev) ...@@ -312,8 +314,6 @@ void device_del(struct device * dev)
{ {
struct device * parent = dev->parent; struct device * parent = dev->parent;
device_pm_remove(dev);
down_write(&devices_subsys.rwsem); down_write(&devices_subsys.rwsem);
if (parent) if (parent)
list_del_init(&dev->node); list_del_init(&dev->node);
...@@ -324,14 +324,11 @@ void device_del(struct device * dev) ...@@ -324,14 +324,11 @@ void device_del(struct device * dev)
*/ */
if (platform_notify_remove) if (platform_notify_remove)
platform_notify_remove(dev); platform_notify_remove(dev);
bus_remove_device(dev); bus_remove_device(dev);
device_pm_remove(dev);
kobject_del(&dev->kobj); kobject_del(&dev->kobj);
if (parent) if (parent)
put_device(parent); put_device(parent);
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment