Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F178316847
D8070.1796488540.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
D8070.1796488540.diff
View Options
Index: sys/kern/subr_bus.c
===================================================================
--- sys/kern/subr_bus.c
+++ sys/kern/subr_bus.c
@@ -1928,6 +1928,45 @@
return (child);
}
+static int
+device_detach_family(device_t dev)
+{
+ device_t child;
+ int error;
+
+ PDEBUG(("%s", DEVICENAME(dev)));
+
+ /* detach children first */
+ TAILQ_FOREACH(child, &dev->children, link) {
+ error = device_detach_family(child);
+ if (error)
+ goto done;
+ }
+ error = device_detach(dev);
+done:
+ return (error);
+}
+
+static void
+device_delete_family(device_t parent, device_t dev)
+{
+ device_t child;
+
+ PDEBUG(("%s from %s", DEVICENAME(dev), DEVICENAME(parent)));
+
+ /* delete children first */
+ while ((child = TAILQ_FIRST(&dev->children)) != NULL)
+ device_delete_family(dev, child);
+
+ if (dev->devclass)
+ devclass_delete_device(dev->devclass, dev);
+ if (dev->parent)
+ BUS_CHILD_DELETED(parent, dev);
+ TAILQ_REMOVE(&parent->children, dev, link);
+ TAILQ_REMOVE(&bus_data_devices, dev, devlink);
+ kobj_delete((kobj_t) dev, M_BUS);
+}
+
/**
* @brief Delete a device
*
@@ -1945,28 +1984,16 @@
device_delete_child(device_t dev, device_t child)
{
int error;
- device_t grandchild;
PDEBUG(("%s from %s", DEVICENAME(child), DEVICENAME(dev)));
- /* remove children first */
- while ((grandchild = TAILQ_FIRST(&child->children)) != NULL) {
- error = device_delete_child(child, grandchild);
- if (error)
- return (error);
- }
-
- if ((error = device_detach(child)) != 0)
+ error = device_detach_family(child);
+ if (error)
return (error);
- if (child->devclass)
- devclass_delete_device(child->devclass, child);
- if (child->parent)
- BUS_CHILD_DELETED(dev, child);
- TAILQ_REMOVE(&dev->children, child, link);
- TAILQ_REMOVE(&bus_data_devices, child, devlink);
- kobj_delete((kobj_t) child, M_BUS);
+ device_delete_family(dev, child);
bus_data_generation_update();
+
return (0);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 5, 4:35 PM (5 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42235354
Default Alt Text
D8070.1796488540.diff (1 KB)
Attached To
Mode
D8070: Fix device delete child function
Attached
Detach File
Event Timeline