From owner-freebsd-new-bus Fri Nov 26 14:22:39 1999 Delivered-To: freebsd-new-bus@freebsd.org Received: from ns.skylink.it (ns.skylink.it [194.177.113.1]) by hub.freebsd.org (Postfix) with ESMTP id 6C1E9151AD; Fri, 26 Nov 1999 14:22:33 -0800 (PST) (envelope-from hibma@skylink.it) Received: from skylink.it (va-184.skylink.it [194.185.55.184]) by ns.skylink.it (8.9.1/8.8.8) with ESMTP id XAA01073; Fri, 26 Nov 1999 23:22:55 +0100 Received: from localhost (localhost [127.0.0.1]) by skylink.it (8.9.3/8.9.3) with ESMTP id VAA00704; Fri, 26 Nov 1999 21:27:13 +0100 (CET) (envelope-from hibma@skylink.it) Date: Fri, 26 Nov 1999 21:27:13 +0100 (CET) From: Nick Hibma X-Sender: n_hibma@henny.jrc.it Reply-To: Nick Hibma To: FreeBSD Newbus Mailing List Cc: Doug Rabson Subject: device_get_softc(devclass_get_unit(devclass, unit)) != devclass_get_softc(devclass, unit) Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-new-bus@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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