From f5c4d53efc98baa07554c96fed6a0ebab566c762 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Wed, 30 Aug 2000 06:56:03 +0000 Subject: [PATCH] Add comment about why the deletion of children is necessary in detach. --- sys/dev/pcic/i82365.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sys/dev/pcic/i82365.c b/sys/dev/pcic/i82365.c index 3e7b58a4b35..dd36c3ac176 100644 --- a/sys/dev/pcic/i82365.c +++ b/sys/dev/pcic/i82365.c @@ -1524,6 +1524,14 @@ pcic_detach(device_t dev) ret = bus_generic_detach(dev); if (ret != 0) return (ret); + /* + * Normally, one wouldn't delete the children. However, detach + * merely detaches the children w/o deleting them. So if + * we were to reattach, we add additional children and wind up + * with duplicates. So, we remove them here following the + * implicit "if you add it in attach, you should delete it in + * detach" rule that may or may not be documented. + */ device_get_children(dev, &kids, &nkids); for (i = 0; i < nkids; i++) { if ((ret = device_delete_child(dev, kids[i])) != 0)