diff options
Diffstat (limited to 'drivers/base/core.c')
-rw-r--r-- | drivers/base/core.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c index 04bbcd779e11..3972ef3f080b 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -728,6 +728,16 @@ static inline int device_is_not_partition(struct device *dev) | |||
728 | } | 728 | } |
729 | #endif | 729 | #endif |
730 | 730 | ||
731 | static int | ||
732 | device_platform_notify(struct device *dev, enum kobject_action action) | ||
733 | { | ||
734 | if (platform_notify && action == KOBJ_ADD) | ||
735 | platform_notify(dev); | ||
736 | else if (platform_notify_remove && action == KOBJ_REMOVE) | ||
737 | platform_notify_remove(dev); | ||
738 | return 0; | ||
739 | } | ||
740 | |||
731 | /** | 741 | /** |
732 | * dev_driver_string - Return a device's driver name, if at all possible | 742 | * dev_driver_string - Return a device's driver name, if at all possible |
733 | * @dev: struct device to get the name of | 743 | * @dev: struct device to get the name of |
@@ -1883,8 +1893,9 @@ int device_add(struct device *dev) | |||
1883 | } | 1893 | } |
1884 | 1894 | ||
1885 | /* notify platform of device entry */ | 1895 | /* notify platform of device entry */ |
1886 | if (platform_notify) | 1896 | error = device_platform_notify(dev, KOBJ_ADD); |
1887 | platform_notify(dev); | 1897 | if (error) |
1898 | goto platform_error; | ||
1888 | 1899 | ||
1889 | error = device_create_file(dev, &dev_attr_uevent); | 1900 | error = device_create_file(dev, &dev_attr_uevent); |
1890 | if (error) | 1901 | if (error) |
@@ -1960,6 +1971,8 @@ done: | |||
1960 | SymlinkError: | 1971 | SymlinkError: |
1961 | device_remove_file(dev, &dev_attr_uevent); | 1972 | device_remove_file(dev, &dev_attr_uevent); |
1962 | attrError: | 1973 | attrError: |
1974 | device_platform_notify(dev, KOBJ_REMOVE); | ||
1975 | platform_error: | ||
1963 | kobject_uevent(&dev->kobj, KOBJ_REMOVE); | 1976 | kobject_uevent(&dev->kobj, KOBJ_REMOVE); |
1964 | glue_dir = get_glue_dir(dev); | 1977 | glue_dir = get_glue_dir(dev); |
1965 | kobject_del(&dev->kobj); | 1978 | kobject_del(&dev->kobj); |
@@ -2077,14 +2090,10 @@ void device_del(struct device *dev) | |||
2077 | bus_remove_device(dev); | 2090 | bus_remove_device(dev); |
2078 | device_pm_remove(dev); | 2091 | device_pm_remove(dev); |
2079 | driver_deferred_probe_del(dev); | 2092 | driver_deferred_probe_del(dev); |
2093 | device_platform_notify(dev, KOBJ_REMOVE); | ||
2080 | device_remove_properties(dev); | 2094 | device_remove_properties(dev); |
2081 | device_links_purge(dev); | 2095 | device_links_purge(dev); |
2082 | 2096 | ||
2083 | /* Notify the platform of the removal, in case they | ||
2084 | * need to do anything... | ||
2085 | */ | ||
2086 | if (platform_notify_remove) | ||
2087 | platform_notify_remove(dev); | ||
2088 | if (dev->bus) | 2097 | if (dev->bus) |
2089 | blocking_notifier_call_chain(&dev->bus->p->bus_notifier, | 2098 | blocking_notifier_call_chain(&dev->bus->p->bus_notifier, |
2090 | BUS_NOTIFY_REMOVED_DEVICE, dev); | 2099 | BUS_NOTIFY_REMOVED_DEVICE, dev); |