|
|
@@ -2031,6 +2031,24 @@ void put_device(struct device *dev)
|
|
|
}
|
|
|
EXPORT_SYMBOL_GPL(put_device);
|
|
|
|
|
|
+bool kill_device(struct device *dev)
|
|
|
+{
|
|
|
+ /*
|
|
|
+ * Require the device lock and set the "dead" flag to guarantee that
|
|
|
+ * the update behavior is consistent with the other bitfields near
|
|
|
+ * it and that we cannot have an asynchronous probe routine trying
|
|
|
+ * to run while we are tearing out the bus/class/sysfs from
|
|
|
+ * underneath the device.
|
|
|
+ */
|
|
|
+ lockdep_assert_held(&dev->mutex);
|
|
|
+
|
|
|
+ if (dev->p->dead)
|
|
|
+ return false;
|
|
|
+ dev->p->dead = true;
|
|
|
+ return true;
|
|
|
+}
|
|
|
+EXPORT_SYMBOL_GPL(kill_device);
|
|
|
+
|
|
|
/**
|
|
|
* device_del - delete device from system.
|
|
|
* @dev: device.
|
|
|
@@ -2050,15 +2068,8 @@ void device_del(struct device *dev)
|
|
|
struct kobject *glue_dir = NULL;
|
|
|
struct class_interface *class_intf;
|
|
|
|
|
|
- /*
|
|
|
- * Hold the device lock and set the "dead" flag to guarantee that
|
|
|
- * the update behavior is consistent with the other bitfields near
|
|
|
- * it and that we cannot have an asynchronous probe routine trying
|
|
|
- * to run while we are tearing out the bus/class/sysfs from
|
|
|
- * underneath the device.
|
|
|
- */
|
|
|
device_lock(dev);
|
|
|
- dev->p->dead = true;
|
|
|
+ kill_device(dev);
|
|
|
device_unlock(dev);
|
|
|
|
|
|
/* Notify clients of device removal. This call must come
|