From owner-cvs-all@FreeBSD.ORG Wed Oct 26 17:24:48 2005 Return-Path: X-Original-To: cvs-all@freebsd.org Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 33E8416A41F for ; Wed, 26 Oct 2005 17:24:48 +0000 (GMT) (envelope-from maksim.yevmenkin@gmail.com) Received: from nproxy.gmail.com (nproxy.gmail.com [64.233.182.206]) by mx1.FreeBSD.org (Postfix) with ESMTP id 988AA43D45 for ; Wed, 26 Oct 2005 17:24:44 +0000 (GMT) (envelope-from maksim.yevmenkin@gmail.com) Received: by nproxy.gmail.com with SMTP id p48so43971nfa for ; Wed, 26 Oct 2005 10:24:42 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=LQjXCaFZ52sUHQKxJ8UGWA7nFSJVU/3L9nwEVkl6dbGZ6zbx2M7WDTrBu3bq+veUBFveKehe5jijYLIxsqHXy+Mxg1n5DbGSVNFAYfdps80+uWxNJ5tYJsiOVeE6RPSs6zHEvsoS634Xs9KGHvpcz54w4iryWHIdDuEQlxm/iFk= Received: by 10.48.240.15 with SMTP id n15mr288547nfh; Wed, 26 Oct 2005 10:24:42 -0700 (PDT) Received: by 10.48.127.20 with HTTP; Wed, 26 Oct 2005 10:24:42 -0700 (PDT) Message-ID: Date: Wed, 26 Oct 2005 10:24:42 -0700 From: Maksim Yevmenkin To: John Baldwin In-Reply-To: <200510261258.51651.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <200510260617.j9Q6HRqh082376@repoman.freebsd.org> <200510261100.55974.jhb@freebsd.org> <200510261258.51651.jhb@freebsd.org> Cc: cvs-src@freebsd.org, src-committers@freebsd.org, Ruslan Ermilov , cvs-all@freebsd.org Subject: Re: cvs commit: src/sys/netgraph/bluetooth/drivers/bt3c ng_bt3c_pccard.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Oct 2005 17:24:48 -0000 On 10/26/05, John Baldwin wrote: > On Wednesday 26 October 2005 12:33 pm, Maksim Yevmenkin wrote: > > John, > > > > [...] > > > > > Sorry about that, will be fixing it more cleanly. BTW, does anyone k= now > > > why this driver allocates its softc manualn in its attach routine? > > > > ng_bt3c(4) is a netgraph device driver. there could be failures in > > both device part (i/o port, interrupts etc.) as well as in netgraph > > part (could not create node). so decided to do it this way. right now > > i can not recall any other reason :) > > Even if netgraph fails then new-bus will still free it for you when attac= h > returns ENXIO. All you have to do is set the size in your driver_t and a= xe > the malloc, free, and device_set_softc calls and you should be done. would something like this do? or am i missing something? please note: i have not tested the patch. cvs diff: Diffing . Index: ng_bt3c_pccard.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/ncvs/src/sys/netgraph/bluetooth/drivers/bt3c/ng_bt3c_pccard= .c,v retrieving revision 1.17 diff -u -r1.17 ng_bt3c_pccard.c --- ng_bt3c_pccard.c 26 Oct 2005 15:52:16 -0000 1.17 +++ ng_bt3c_pccard.c 26 Oct 2005 17:23:02 -0000 @@ -612,11 +612,7 @@ static int bt3c_pccard_attach(device_t dev) { - bt3c_softc_p sc =3D NULL; - - sc =3D (bt3c_softc_p) malloc(sizeof(*sc), M_BT3C, M_NOWAIT|M_ZERO); - if (sc =3D=3D NULL) - return (ENOMEM); + bt3c_softc_p sc =3D (bt3c_softc_p) device_get_softc(dev); /* Allocate I/O ports */ sc->iobase_rid =3D 0; @@ -677,7 +673,6 @@ sc->want =3D 1; NG_NODE_SET_PRIVATE(sc->node, sc); - device_set_softc(dev, sc); return (0); bad: @@ -705,8 +700,6 @@ sc->iobase_rid =3D 0; } - free(sc, M_BT3C); - return (ENXIO); } /* bt3c_pccacd_attach */ @@ -1197,7 +1190,7 @@ static driver_t bt3c_pccard_driver =3D { NG_BT3C_NODE_TYPE, bt3c_pccard_methods, - 0 + sizeof(bt3c_softc_t) }; static devclass_t bt3c_devclass; =3D=3D max