From owner-svn-src-head@FreeBSD.ORG Tue Aug 14 12:59:23 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E225A106566B; Tue, 14 Aug 2012 12:59:23 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net [IPv6:2001:470:1f10:75::2]) by mx1.freebsd.org (Postfix) with ESMTP id B4AD58FC0A; Tue, 14 Aug 2012 12:59:23 +0000 (UTC) Received: from ralph.baldwin.cx (c-68-39-198-164.hsd1.de.comcast.net [68.39.198.164]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 1732BB94B; Tue, 14 Aug 2012 08:59:23 -0400 (EDT) From: John Baldwin To: Hans Petter Selasky Date: Tue, 14 Aug 2012 08:32:03 -0400 User-Agent: KMail/1.13.7 (FreeBSD/9.0-STABLE; KDE/4.7.4; amd64; ; ) References: <201208101502.q7AF2ofC046316@svn.freebsd.org> <201208131700.25822.jhb@freebsd.org> <201208140731.58979.hselasky@c2i.net> In-Reply-To: <201208140731.58979.hselasky@c2i.net> MIME-Version: 1.0 Content-Type: Text/Plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Message-Id: <201208140832.03702.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Tue, 14 Aug 2012 08:59:23 -0400 (EDT) Cc: "svn-src-head@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" Subject: Re: svn commit: r239178 - in head/sys: kern sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Aug 2012 12:59:24 -0000 On Tuesday, August 14, 2012 01:31:58 AM Hans Petter Selasky wrote: > On Monday 13 August 2012 23:00:25 John Baldwin wrote: > > int > > foo_attach(device_t dev) > > { > > > > struct foo_softc *sc; > > > > sc = malloc(sizeof(struct foo_softc), M_BUS, M_WAITOK | M_ZERO); > > device_set_softc(dev, sc); > > ... > > Hi, > > Here you forget that there are alot of else/if's that need free(sc, M_BUS) > for various failing cases! That's why I say +5 lines. > > BTW: If we do add device_free_softc, would it be an idea to add > device_alloc_softc aswell, to make stuff more clear for the drivers? No. I can't think of any reasonable use case for a driver to do that (i.e. not let new-bus auto-allocate a softc) where they shouldn't just manage the entire life cycle themselves. Also, I still think an extra 5 lines is not too tall of a price to pay to explicitly note that a given driver uses an abnormal softc life cycle. However, I think having a device_claim/steal_softc() / device_free_softc() is clearer than the current approach. -- John Baldwin