Date: Tue, 14 Aug 2012 08:32:03 -0400 From: John Baldwin <jhb@freebsd.org> To: Hans Petter Selasky <hselasky@c2i.net> Cc: "svn-src-head@freebsd.org" <svn-src-head@freebsd.org>, "svn-src-all@freebsd.org" <svn-src-all@freebsd.org>, "src-committers@freebsd.org" <src-committers@freebsd.org> Subject: Re: svn commit: r239178 - in head/sys: kern sys Message-ID: <201208140832.03702.jhb@freebsd.org> In-Reply-To: <201208140731.58979.hselasky@c2i.net> References: <201208101502.q7AF2ofC046316@svn.freebsd.org> <201208131700.25822.jhb@freebsd.org> <201208140731.58979.hselasky@c2i.net>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201208140832.03702.jhb>
