Skip to contentSkip to conversation

drivers: base: core: Removed superfluous calls to put_device in device_destroy and to kobject deletion functions in device_del.

PATCH In review David Graham White 2 participants 2 messages Jul 21, 2013 Driver core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers: base: core: Removed superfluous calls to put_device in device_destroy and to kobject deletion functions in device_del.

When device_destroy is called and the device's embedded kobject may be removed, this would occur with the call to put_device in device_unregister. Further, put_device should take care of cleaning up the kobject without the need to call kobject_del indepenedently in device_del.

---
 drivers/base/core.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/base/core.c +1 -5
index 8856d74..d6494ee 100644
@@ -1292,9 +1292,7 @@ void device_del(struct device *dev)
 	 */
 	if (platform_notify_remove)
 		platform_notify_remove(dev);
-	kobject_uevent(&dev->kobj, KOBJ_REMOVE);
 	cleanup_device_parent(dev);
-	kobject_del(&dev->kobj);
 	put_device(parent);
 }
 
@@ -1849,10 +1847,8 @@ void device_destroy(struct class *class, dev_t devt)
 	struct device *dev;
 
 	dev = class_find_device(class, NULL, &devt, __match_devt);
-	if (dev) {
-		put_device(dev);
+	if (dev)
 		device_unregister(dev);
-	}
 }
 EXPORT_SYMBOL_GPL(device_destroy);
 
Signature · 1 line
1.8.3.2
maintainer
#1 lore raw
Quoted 25 lines · David Graham White

When device_destroy is called and the device's embedded kobject may be removed, this would occur with the call to put_device in device_unregister. Further, put_device should take care of cleaning up the kobject without the need to call kobject_del indepenedently in device_del.

---
 drivers/base/core.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/base/core.c +0 -2
index 8856d74..d6494ee 100644
@@ -1292,9 +1292,7 @@ void device_del(struct device *dev)
 	 */
 	if (platform_notify_remove)
 		platform_notify_remove(dev);
-	kobject_uevent(&dev->kobj, KOBJ_REMOVE);
 	cleanup_device_parent(dev);
-	kobject_del(&dev->kobj);
 	put_device(parent);
 }
 

drivers/base/core.c void device_destroy(struct class *class, dev_t devt) · line 1853

Quoted 10 lines
drivers/base/core.c +1 -3
@@ -1849,10 +1847,8 @@ void device_destroy(struct class *class, dev_t devt)
 	struct device *dev;
 
 	dev = class_find_device(class, NULL, &devt, __match_devt);
-	if (dev) {
-		put_device(dev);
+	if (dev)
 		device_unregister(dev);
-	}
 }
 EXPORT_SYMBOL_GPL(device_destroy);

Are you sure about this. It seems that every few years someone tries to make this type of "fix" to the driver code, only to find out that this really was needed.

Have you tested this to ensure that things get cleaned up properly?

thanks,

greg k-h