From fe20f8344a8978179ffb6791db70b191919ba2a8 Mon Sep 17 00:00:00 2001 From: Kenneth R Westerback Date: Wed, 17 May 2006 03:43:04 +0000 Subject: Detach children devices in reverse order. This gives better display, and allows cf_unit to be decremented correctly. 'put it in' deraadt@ "i think it's good' tedu@ --- sys/kern/subr_autoconf.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'sys') diff --git a/sys/kern/subr_autoconf.c b/sys/kern/subr_autoconf.c index 8b05039bf50..f4d98814050 100644 --- a/sys/kern/subr_autoconf.c +++ b/sys/kern/subr_autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_autoconf.c,v 1.44 2006/05/14 14:07:20 krw Exp $ */ +/* $OpenBSD: subr_autoconf.c,v 1.45 2006/05/17 03:43:03 krw Exp $ */ /* $NetBSD: subr_autoconf.c,v 1.21 1996/04/04 06:06:18 cgd Exp $ */ /* @@ -732,14 +732,17 @@ config_detach_children(struct device *parent, int flags) * we are about to detach, so it would disappear. * Just play it safe and restart from the parent. */ - for (prev_dev = NULL, dev = TAILQ_FIRST(&alldevs); + for (prev_dev = NULL, dev = TAILQ_LAST(&alldevs, devicelist); dev != NULL; dev = next_dev) { if (dev->dv_parent == parent) { if ((rv = config_detach(dev, flags)) != 0) return (rv); - next_dev = prev_dev ? prev_dev : TAILQ_FIRST(&alldevs); - } else - next_dev = TAILQ_NEXT(prev_dev = dev, dv_list); + next_dev = prev_dev ? prev_dev : TAILQ_LAST(&alldevs, + devicelist); + } else { + prev_dev = dev; + next_dev = TAILQ_PREV(dev, devicelist, dv_list); + } } return (0); -- cgit v1.2.3