Date: Fri, 26 Nov 1999 21:27:13 +0100 (CET) From: Nick Hibma <hibma@skylink.it> To: FreeBSD Newbus Mailing List <new-bus@FreeBSD.org> Cc: Doug Rabson <dfr@FreeBSD.org> Subject: device_get_softc(devclass_get_unit(devclass, unit)) != devclass_get_softc(devclass, unit) Message-ID: <Pine.BSF.4.20.9911262000300.366-100000@henny.jrc.it>
index | next in thread | raw e-mail
Executed _during_attach_, a
sc = devclass_get_softc(devclass, unit);
returns NULL, but a
sc = device_get_softc(devclass_get_unit(devclass, unit));
returns the softc. The statements are equivalent but the result is
inconsistent.
I suggest removing the limitation
if (!dev || dev->state < DS_ATTACHED)
return NULL;
from devclass_get_softc (diff below).
Reason: if you do initialisation (for example CAM, XPT_SCAN_BUS in my
case), you will end up in the routines that need this function before
attach is finished and state >= DS_ATTACHED.
Second, none of the other functions uses this limitation
(devclass_get_devices(), devclass_get_unit()).
Let me know your thoughts.
Nick
--
hibma@skylink.it
n_hibma@freebsd.org USB project
http://www.etla.net/~n_hibma/
Index: subr_bus.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/subr_bus.c,v
retrieving revision 1.46
diff -u -u -w -r1.46 subr_bus.c
--- subr_bus.c 1999/11/18 06:05:30 1.46
+++ subr_bus.c 1999/11/26 20:25:58
@@ -432,11 +432,13 @@
{
device_t dev;
- if (unit < 0 || unit >= dc->maxunit)
+ if (dc == NULL || unit < 0 || unit >= dc->maxunit)
return NULL;
+
dev = dc->devices[unit];
- if (!dev || dev->state < DS_ATTACHED)
+ if (dev == NULL)
return NULL;
+
return dev->softc;
}
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-new-bus" in the body of the message
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.20.9911262000300.366-100000>
