From owner-svn-src-all@FreeBSD.ORG Mon Nov 21 16:16:49 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 223661065673; Mon, 21 Nov 2011 16:16:49 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id EC50F8FC1D; Mon, 21 Nov 2011 16:16:48 +0000 (UTC) Received: from bigwig.baldwin.cx (96.47.65.170.static.nyinternet.net [96.47.65.170]) by cyrus.watson.org (Postfix) with ESMTPSA id A164146B06; Mon, 21 Nov 2011 11:16:48 -0500 (EST) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 94C04B94B; Mon, 21 Nov 2011 11:16:45 -0500 (EST) From: John Baldwin To: Hans Petter Selasky Date: Mon, 21 Nov 2011 11:16:47 -0500 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p8; KDE/4.5.5; amd64; ; ) References: <201111191011.pAJABp0N034812@svn.freebsd.org> In-Reply-To: <201111191011.pAJABp0N034812@svn.freebsd.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201111211116.47529.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Mon, 21 Nov 2011 11:16:45 -0500 (EST) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r227701 - in head/sys: arm/xscale/ixp425 dev/ahci dev/ata dev/gpio dev/mvs dev/ppbus dev/ppc dev/siba dev/siis dev/usb kern sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Nov 2011 16:16:49 -0000 On Saturday, November 19, 2011 5:11:51 am Hans Petter Selasky wrote: > Author: hselasky > Date: Sat Nov 19 10:11:50 2011 > New Revision: 227701 > URL: http://svn.freebsd.org/changeset/base/227701 > > Log: > Move the device_delete_all_children() function from usb_util.c > to kern/subr_bus.c. Simplify this function so that it no longer > depends on malloc() to execute. Identify a few other places where > it makes sense to use device_delete_all_children(). > > MFC after: 1 week Sorry I didn't review this earlier when you sent it to me. In general I think this is a good idea, and reducing the duplicated code is great. One style nit below: > Modified: head/sys/kern/subr_bus.c > ============================================================================== > --- head/sys/kern/subr_bus.c Sat Nov 19 09:16:52 2011 (r227700) > +++ head/sys/kern/subr_bus.c Sat Nov 19 10:11:50 2011 (r227701) > @@ -1881,6 +1881,39 @@ device_delete_child(device_t dev, device > } > > /** > + * @brief Delete all children devices of the given device, if any. > + * > + * This function deletes all children devices of the given device, if > + * any, using the device_delete_child() function for each device it > + * finds. If a child device cannot be deleted, this function will > + * return an error code. > + * > + * @param dev the parent device > + * > + * @retval 0 success > + * @retval non-zero a device would not detach > + */ > +int > +device_delete_all_children(device_t dev) > +{ > + device_t child; > + int error; > + > + PDEBUG(("Deleting all children of %s", DEVICENAME(dev))); > + > + error = 0; > + > + while ( (child = TAILQ_FIRST(&dev->children)) ) { Can you fix the extra whitespace here and explicitly test against NULL? > + error = device_delete_child(dev, child); > + if (error) { > + PDEBUG(("Failed deleting %s", DEVICENAME(child))); > + break; > + } > + } > + return (error); > +} > + > +/** > * @brief Find a device given a unit number > * > * This is similar to devclass_get_devices() but only searches for > -- John Baldwin