aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/core.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/base/core.c')
-rw-r--r--drivers/base/core.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c
index da84a73f2ba6..636058bbf48a 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -1663,6 +1663,9 @@ void device_initialize(struct device *dev)
1663 kobject_init(&dev->kobj, &device_ktype); 1663 kobject_init(&dev->kobj, &device_ktype);
1664 INIT_LIST_HEAD(&dev->dma_pools); 1664 INIT_LIST_HEAD(&dev->dma_pools);
1665 mutex_init(&dev->mutex); 1665 mutex_init(&dev->mutex);
1666#ifdef CONFIG_PROVE_LOCKING
1667 mutex_init(&dev->lockdep_mutex);
1668#endif
1666 lockdep_set_novalidate_class(&dev->mutex); 1669 lockdep_set_novalidate_class(&dev->mutex);
1667 spin_lock_init(&dev->devres_lock); 1670 spin_lock_init(&dev->devres_lock);
1668 INIT_LIST_HEAD(&dev->devres_head); 1671 INIT_LIST_HEAD(&dev->devres_head);
@@ -2211,6 +2214,24 @@ void put_device(struct device *dev)
2211} 2214}
2212EXPORT_SYMBOL_GPL(put_device); 2215EXPORT_SYMBOL_GPL(put_device);
2213 2216
2217bool kill_device(struct device *dev)
2218{
2219 /*
2220 * Require the device lock and set the "dead" flag to guarantee that
2221 * the update behavior is consistent with the other bitfields near
2222 * it and that we cannot have an asynchronous probe routine trying
2223 * to run while we are tearing out the bus/class/sysfs from
2224 * underneath the device.
2225 */
2226 lockdep_assert_held(&dev->mutex);
2227
2228 if (dev->p->dead)
2229 return false;
2230 dev->p->dead = true;
2231 return true;
2232}
2233EXPORT_SYMBOL_GPL(kill_device);
2234
2214/** 2235/**
2215 * device_del - delete device from system. 2236 * device_del - delete device from system.
2216 * @dev: device. 2237 * @dev: device.
@@ -2230,15 +2251,8 @@ void device_del(struct device *dev)
2230 struct kobject *glue_dir = NULL; 2251 struct kobject *glue_dir = NULL;
2231 struct class_interface *class_intf; 2252 struct class_interface *class_intf;
2232 2253
2233 /*
2234 * Hold the device lock and set the "dead" flag to guarantee that
2235 * the update behavior is consistent with the other bitfields near
2236 * it and that we cannot have an asynchronous probe routine trying
2237 * to run while we are tearing out the bus/class/sysfs from
2238 * underneath the device.
2239 */
2240 device_lock(dev); 2254 device_lock(dev);
2241 dev->p->dead = true; 2255 kill_device(dev);
2242 device_unlock(dev); 2256 device_unlock(dev);
2243 2257
2244 /* Notify clients of device removal. This call must come 2258 /* Notify clients of device removal. This call must come