Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 03 Jan 1997 10:40:29 -0800
From:      Julian Elischer <julian@whistle.com>
To:        "Eric L. Hernes" <erich@lodgenet.com>
Cc:        hackers@freebsd.org
Subject:   Re: device driver initialization
Message-ID:  <32CD529D.167EB0E7@whistle.com>
References:  <199701031536.JAA16890@jake.lodgenet.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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

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.

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..

julian



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?32CD529D.167EB0E7>