From owner-p4-projects@FreeBSD.ORG Fri Sep 15 15:10:09 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 1DC6116A47B; Fri, 15 Sep 2006 15:10:09 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D8ECC16A415; Fri, 15 Sep 2006 15:10:08 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe13.swip.net [212.247.155.129]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2A90543D58; Fri, 15 Sep 2006 15:10:03 +0000 (GMT) (envelope-from hselasky@c2i.net) X-T2-Posting-ID: gvlK0tOCzrqh9CPROFOFPw== X-Cloudmark-Score: 0.000000 [] Received: from [193.217.137.89] (HELO [10.0.0.249]) by mailfe13.swip.net (CommuniGate Pro SMTP 5.0.8) with ESMTP id 111423715; Fri, 15 Sep 2006 17:10:01 +0200 From: Hans Petter Selasky To: John Baldwin Date: Fri, 15 Sep 2006 17:10:16 +0200 User-Agent: KMail/1.7 References: <200609151417.k8FEHSFx098273@repoman.freebsd.org> <200609151039.16523.jhb@freebsd.org> In-Reply-To: <200609151039.16523.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200609151710.17572.hselasky@c2i.net> Cc: Perforce Change Reviews Subject: Re: PERFORCE change 106148 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Sep 2006 15:10:09 -0000 On Friday 15 September 2006 16:39, you wrote: > On Friday 15 September 2006 10:17, Hans Petter Selasky wrote: > > http://perforce.freebsd.org/chv.cgi?CH=106148 > > > > Change 106148 by hselasky@hselasky_mini_itx on 2006/09/15 14:17:12 > > > > Initialize all driver_t structures by record. Bugfix: Some of the > > modem drivers did not use the "ucom_devclass". Make sure that all > > modem drivers use this devclass. > > That doesn't actually matter. Also, no other drivers use this style to > initialize their driver_t. If you really wanted to do a change, you should > change them to use DEFINE_CLASS macros to define a KOBJ class instead. Ok. Will consider that next time. > BTW, why the devclass doesn't matter: the devclass_t is just a pointer to > a device class. The device classes are based on the driver name, so if you > add a new driver with the name "foo", it will look up the device class by > name ("foo"), creating one if it doesn't exist. My implementation for NetBSD works like this: static u_int8_t devclass_create(devclass_t *dc_pp) { if (dc_pp == NULL) { return 1; } if (dc_pp[0] == NULL) { dc_pp[0] = malloc(sizeof(**(dc_pp)), M_DEVBUF, M_WAITOK|M_ZERO); if (dc_pp[0] == NULL) { return 1; } } return 0; } static const struct bsd_module_data * devclass_find_create(const char *classname) { const struct bsd_module_data *mod; for(mod = &bsd_module_data_start[0]; mod < &bsd_module_data_end[0]; mod++) { if(mod->mod_name && (strcmp(classname, mod->mod_name) == 0)) { if(devclass_create(mod->devclass_pp)) { continue; } return mod; } } return NULL; } > It then saves a pointer to > that device class object in the devclass_t pointer specified in > DRIVER_MODULE(). So, by making them all share the same devclass_t, they are > all just going to overwrite the same pointer when the driver module loads. No, wrong. The devclass_t pointer is not overwritten if it is already initialized! > To be honest, most drivers don't even use the devclass pointer, and I'd > actually like to axe it and make the few drivers that do care use > 'devclass_find("foo")' when they need the devclass pointer instead. I need the devclass to get unique unit numbers. --HPS