diff options
author | phk <phk@FreeBSD.org> | 1999-05-31 11:29:30 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1999-05-31 11:29:30 +0000 |
commit | 6a5dc97620c08ad609e1b3c3c042f150feb46dd3 (patch) | |
tree | 6cfc9338ae83f67fd38a853cd0782713c73cad13 /sys/dev/ppbus | |
parent | 881e2636833297a207a791fabd8befc818b1b3fb (diff) | |
download | FreeBSD-src-6a5dc97620c08ad609e1b3c3c042f150feb46dd3.zip FreeBSD-src-6a5dc97620c08ad609e1b3c3c042f150feb46dd3.tar.gz |
Simplify cdevsw registration.
The cdevsw_add() function now finds the major number(s) in the
struct cdevsw passed to it. cdevsw_add_generic() is no longer
needed, cdevsw_add() does the same thing.
cdevsw_add() will print an message if the d_maj field looks bogus.
Remove nblkdev and nchrdev variables. Most places they were used
bogusly. Instead check a dev_t for validity by seeing if devsw()
or bdevsw() returns NULL.
Move bdevsw() and devsw() functions to kern/kern_conf.c
Bump __FreeBSD_version to 400006
This commit removes:
72 bogus makedev() calls
26 bogus SYSINIT functions
if_xe.c bogusly accessed cdevsw[], author/maintainer please fix.
I4b and vinum not changed. Patches emailed to authors. LINT
probably broken until they catch up.
Diffstat (limited to 'sys/dev/ppbus')
-rw-r--r-- | sys/dev/ppbus/lpt.c | 22 | ||||
-rw-r--r-- | sys/dev/ppbus/ppi.c | 21 | ||||
-rw-r--r-- | sys/dev/ppbus/pps.c | 9 |
3 files changed, 15 insertions, 37 deletions
diff --git a/sys/dev/ppbus/lpt.c b/sys/dev/ppbus/lpt.c index ab61978..67f4468 100644 --- a/sys/dev/ppbus/lpt.c +++ b/sys/dev/ppbus/lpt.c @@ -48,7 +48,7 @@ * from: unknown origin, 386BSD 0.1 * From Id: lpt.c,v 1.55.2.1 1996/11/12 09:08:38 phk Exp * From Id: nlpt.c,v 1.14 1999/02/08 13:55:43 des Exp - * $Id: lpt.c,v 1.3 1999/04/28 10:51:35 dt Exp $ + * $Id: lpt.c,v 1.4 1999/05/30 16:51:34 phk Exp $ */ /* @@ -363,6 +363,10 @@ static struct ppb_device * lptprobe(struct ppb_data *ppb) { struct lpt_data *sc; + static int once; + + if (!once++) + cdevsw_add(&lpt_cdevsw); sc = (struct lpt_data *) malloc(sizeof(struct lpt_data), M_TEMP, M_NOWAIT); @@ -954,19 +958,3 @@ lptioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) return(error); } - -static int lpt_devsw_installed; - -static void -lpt_drvinit(void *unused) -{ - dev_t dev; - - if( ! lpt_devsw_installed ) { - dev = makedev(CDEV_MAJOR, 0); - cdevsw_add(&dev,&lpt_cdevsw, NULL); - lpt_devsw_installed = 1; - } -} - -SYSINIT(lptdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,lpt_drvinit,NULL) diff --git a/sys/dev/ppbus/ppi.c b/sys/dev/ppbus/ppi.c index 315ea29..e19be8c 100644 --- a/sys/dev/ppbus/ppi.c +++ b/sys/dev/ppbus/ppi.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ppi.c,v 1.13 1999/04/28 10:51:39 dt Exp $ + * $Id: ppi.c,v 1.14 1999/05/30 16:51:35 phk Exp $ * */ #include "ppi.h" @@ -146,6 +146,10 @@ static struct ppb_device * ppiprobe(struct ppb_data *ppb) { struct ppi_data *ppi; + static int once; + + if (!once++) + cdevsw_add(&ppi_cdevsw); ppi = (struct ppi_data *) malloc(sizeof(struct ppi_data), M_TEMP, M_NOWAIT); @@ -547,19 +551,4 @@ ppiioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) return (error); } -static int ppi_devsw_installed; - -static void ppi_drvinit(void *unused) -{ - dev_t dev; - - if (!ppi_devsw_installed ) { - dev = makedev(CDEV_MAJOR, 0); - cdevsw_add(&dev, &ppi_cdevsw, NULL); - ppi_devsw_installed = 1; - } -} - -SYSINIT(ppidev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,ppi_drvinit,NULL) - #endif /* NPPI */ diff --git a/sys/dev/ppbus/pps.c b/sys/dev/ppbus/pps.c index 8fc5528..0bad854 100644 --- a/sys/dev/ppbus/pps.c +++ b/sys/dev/ppbus/pps.c @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: pps.c,v 1.17 1999/05/06 22:03:14 peter Exp $ + * $Id: pps.c,v 1.18 1999/05/30 16:51:36 phk Exp $ * * This driver implements a draft-mogul-pps-api-02.txt PPS source. * @@ -87,6 +87,10 @@ static struct ppb_device * ppsprobe(struct ppb_data *ppb) { struct pps_data *sc; + static int once; + + if (!once++) + cdevsw_add(&pps_cdevsw); sc = (struct pps_data *) malloc(sizeof(struct pps_data), M_TEMP, M_NOWAIT); @@ -113,7 +117,6 @@ ppsprobe(struct ppb_data *ppb) static int ppsattach(struct ppb_device *dev) { - dev_t devt; /* * Report ourselves @@ -126,8 +129,6 @@ ppsattach(struct ppb_device *dev) dev->id_unit, DV_CHR, UID_ROOT, GID_WHEEL, 0600, PPS_NAME "%d", dev->id_unit); #endif - devt = makedev(CDEV_MAJOR, 0); - cdevsw_add(&devt, &pps_cdevsw, NULL); return (1); } |