Date: Fri, 03 Jan 1997 13:42:56 -0600 From: "Eric L. Hernes" <erich@lodgenet.com> To: Julian Elischer <julian@whistle.com> Cc: "Eric L. Hernes" <erich@lodgenet.com>, hackers@freebsd.org Subject: Re: device driver initialization Message-ID: <199701031942.NAA24546@jake.lodgenet.com> In-Reply-To: Your message of "Fri, 03 Jan 1997 10:40:29 PST." <32CD529D.167EB0E7@whistle.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199701031942.NAA24546>
