Date: Sat, 15 Feb 2003 21:52:38 -0800 (PST) From: Nate Lawson <nate@root.org> To: "Matthew N. Dodd" <winter@jurai.net> Cc: current@FreeBSD.ORG, wpaul@FreeBSD.ORG Subject: Re: sys/pci/if* fixes Message-ID: <Pine.BSF.4.21.0302152147310.43757-100000@root.org> In-Reply-To: <20030215092452.E73971@sasami.jurai.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 15 Feb 2003, Matthew N. Dodd wrote:
> On Fri, 14 Feb 2003, Nate Lawson wrote:
> > Also, except for xl, all drivers have a common cleanup on error in
> > attach that backs out allocated resources with no assumptions about the
> > order they were allocated in.
>
> Please see if_pcn.c for the correct approach to freeing resources; its not
> necessary to wrap evrything in 'if (sc && error != 0) {}'. If execution
> reaches the 'fail' label then you assume that is what happened.
The 'if' is a matter of coding style. Which is preferred: multiple
returns from the same function (one which is only reachable from a goto)
or one linear path with an 'if' to see if this is an error exit?
Regardless, the 'if (sc)' is necessary in ti.diff because the KLD_MODULE
check at the beginning may goto fail before device_get_softc().
> I also think you should just drop and reaquire locks around the
> bus_setup_intr() rather than moving code around.
See the previous thread on this regarding my original dc(4) changes. It
is bogus to create a lock with mtx_init and then immediately lock it for
the entire attach routine just for the intention of ensuring exclusive
access to the device.
-Nate
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0302152147310.43757-100000>
