Commit ec0676ee authored by Alan Stern's avatar Alan Stern Committed by Greg Kroah-Hartman

Driver core: move the bus notifier call points

This patch (as1184) changes the location of the notifications in
device_add() and device_del().  Now the BUS_NOTIFY_ADD_DEVICE message
is sent after dpm_sysfs_add(), which is necessary for clients that
want to add attributes to the power/ subdirectory.  The
BUS_NOTIFY_DEL_DEVICE message is correspondingly moved before
dpm_sysfs_remove().
Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent d0d85ff9
...@@ -894,11 +894,6 @@ int device_add(struct device *dev) ...@@ -894,11 +894,6 @@ int device_add(struct device *dev)
if (platform_notify) if (platform_notify)
platform_notify(dev); platform_notify(dev);
/* notify clients of device entry (new way) */
if (dev->bus)
blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
BUS_NOTIFY_ADD_DEVICE, dev);
error = device_create_file(dev, &uevent_attr); error = device_create_file(dev, &uevent_attr);
if (error) if (error)
goto attrError; goto attrError;
...@@ -926,6 +921,14 @@ int device_add(struct device *dev) ...@@ -926,6 +921,14 @@ int device_add(struct device *dev)
if (error) if (error)
goto DPMError; goto DPMError;
device_pm_add(dev); device_pm_add(dev);
/* Notify clients of device addition. This call must come
* after dpm_sysf_add() and before kobject_uevent().
*/
if (dev->bus)
blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
BUS_NOTIFY_ADD_DEVICE, dev);
kobject_uevent(&dev->kobj, KOBJ_ADD); kobject_uevent(&dev->kobj, KOBJ_ADD);
bus_attach_device(dev); bus_attach_device(dev);
if (parent) if (parent)
...@@ -951,9 +954,6 @@ int device_add(struct device *dev) ...@@ -951,9 +954,6 @@ int device_add(struct device *dev)
DPMError: DPMError:
bus_remove_device(dev); bus_remove_device(dev);
BusError: BusError:
if (dev->bus)
blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
BUS_NOTIFY_DEL_DEVICE, dev);
device_remove_attrs(dev); device_remove_attrs(dev);
AttrsError: AttrsError:
device_remove_class_symlinks(dev); device_remove_class_symlinks(dev);
...@@ -1038,6 +1038,12 @@ void device_del(struct device *dev) ...@@ -1038,6 +1038,12 @@ void device_del(struct device *dev)
struct device *parent = dev->parent; struct device *parent = dev->parent;
struct class_interface *class_intf; struct class_interface *class_intf;
/* Notify clients of device removal. This call must come
* before dpm_sysfs_remove().
*/
if (dev->bus)
blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
BUS_NOTIFY_DEL_DEVICE, dev);
device_pm_remove(dev); device_pm_remove(dev);
dpm_sysfs_remove(dev); dpm_sysfs_remove(dev);
if (parent) if (parent)
...@@ -1075,9 +1081,6 @@ void device_del(struct device *dev) ...@@ -1075,9 +1081,6 @@ void device_del(struct device *dev)
*/ */
if (platform_notify_remove) if (platform_notify_remove)
platform_notify_remove(dev); platform_notify_remove(dev);
if (dev->bus)
blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
BUS_NOTIFY_DEL_DEVICE, dev);
kobject_uevent(&dev->kobj, KOBJ_REMOVE); kobject_uevent(&dev->kobj, KOBJ_REMOVE);
cleanup_device_parent(dev); cleanup_device_parent(dev);
kobject_del(&dev->kobj); kobject_del(&dev->kobj);
......
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