From owner-freebsd-hackers Fri Jan 3 11:44:17 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.4/8.8.4) id LAA10115 for hackers-outgoing; Fri, 3 Jan 1997 11:44:17 -0800 (PST) Received: from bacall.lodgenet.com (bacall.lodgenet.com [205.138.147.242]) by freefall.freebsd.org (8.8.4/8.8.4) with SMTP id LAA10105 for ; Fri, 3 Jan 1997 11:44:02 -0800 (PST) Received: (from mail@localhost) by bacall.lodgenet.com (8.6.12/8.6.12) id NAA18263; Fri, 3 Jan 1997 13:42:06 -0600 Received: from garbo.lodgenet.com(204.124.123.250) by bacall via smap (V1.3) id sma018260; Fri Jan 3 13:41:55 1997 Received: from jake.lodgenet.com (jake.lodgenet.com [10.0.11.30]) by garbo.lodgenet.com (8.6.12/8.6.9) with ESMTP id NAA07726; Fri, 3 Jan 1997 13:42:34 -0600 Received: from jake.lodgenet.com (localhost [127.0.0.1]) by jake.lodgenet.com (8.8.4/8.6.12) with ESMTP id NAA24546; Fri, 3 Jan 1997 13:42:57 -0600 (CST) Message-Id: <199701031942.NAA24546@jake.lodgenet.com> X-Mailer: exmh version 2.0beta 12/23/96 To: Julian Elischer cc: "Eric L. Hernes" , hackers@freebsd.org Subject: Re: device driver initialization In-reply-to: Your message of "Fri, 03 Jan 1997 10:40:29 PST." <32CD529D.167EB0E7@whistle.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Fri, 03 Jan 1997 13:42:56 -0600 From: "Eric L. Hernes" Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk Julian Elischer writes: >Eric L. Hernes wrote: >> >> Howdy, >> >> It looks like most of the ISA drivers now days have a frag like: >> >> SYSINIT(foo,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,foo_drvinit,NULL) >> >> foo_drvinit(void *nothing){ >> static int foo_devsw_installed=0; >> dev_t dev; >> >> if (! foo_devsw_installed ) { >> dev = makedev(CDEV_MAJOR, 0); >> cdevsw_add(&dev, &foo_cdevsw, NULL); >> foo_devsw_installed = 1; >> } >> } >> >> Is there any reason that this can't be absorbed in the attach function, >> somewhere around where the devfs stuff is done? What's the reason for >> adding yet another entry point during re-boot. Isn't probe/attach enough? >> >> > >The addition of a devsw entry is done ONCE PER DRIVER > >the probe/attach is done ONCE PER INSTANCE yea, but the `if (!devsw_installed) {}' clause should take care of that. I'm guessing now that the order in which devsw entries are installed is important, maybe sequential? Since the SYSINIT() macro has the SI_ORDER_MIDDLE+CDEV_MAJOR, does cdevsw_add, simply tack the devsw on the end of the list; so that the seemingly random probe/attach order will break things? > >so the usages are slightly different. > >other than that, yes it could be done.... >remember also that the eventual aim is to make drivers LKMable >in which case the SYSINIT part would be done by the LKM installation. > I usually have my foo_load call probe/attach as in the autoconf code. >It was easier to add this to every driver in a 'boilerplate' manner >(in fact I used a combination of scripts and manual editing >to add it), than to add more specialist code to each attach routine.. > That I understand, should a new driver use SYSINIT to be like most of the others, or stick it in attach? If order is important, there is no choice. >julian thanks, eric. -- erich@lodgenet.com http://rrnet.com/~erich erich@rrnet.com