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/pci | |
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/pci')
-rw-r--r-- | sys/pci/brooktree848.c | 29 | ||||
-rw-r--r-- | sys/pci/meteor.c | 22 | ||||
-rw-r--r-- | sys/pci/pci.c | 7 | ||||
-rw-r--r-- | sys/pci/xrpu.c | 9 |
4 files changed, 16 insertions, 51 deletions
diff --git a/sys/pci/brooktree848.c b/sys/pci/brooktree848.c index 70d3367..558400b 100644 --- a/sys/pci/brooktree848.c +++ b/sys/pci/brooktree848.c @@ -1,4 +1,4 @@ -/* $Id: brooktree848.c,v 1.81 1999/05/25 12:43:40 roger Exp $ */ +/* $Id: brooktree848.c,v 1.82 1999/05/30 16:53:32 phk Exp $ */ /* BT848 Driver for Brooktree's Bt848, Bt848A, Bt849A, Bt878, Bt879 based cards. The Brooktree BT848 Driver driver is based upon Mark Tinguely and Jim Lowe's driver for the Matrox Meteor PCI card . The @@ -668,6 +668,10 @@ bktr_probe(struct device *parent, struct cfdata *cf, void *aux) pci_devaddr_t *pa; pci_devres_t res; struct isa_attach_args *ia = aux; + static int once; + + if (!once++) + cdevsw_add(&bktr_cdevsw); if (ia->ia_bustype != BUS_PCI) return (0); @@ -7017,29 +7021,6 @@ static void msp_autodetect( bktr_ptr_t bktr ) { /* msp_write(bktr, 0x12, 0x0014, 0x7f40); */ } -/****************************************************************************** - * magic: - */ - - -#ifdef __FreeBSD__ -static int bktr_devsw_installed; - -static void -bktr_drvinit( void *unused ) -{ - dev_t dev; - - if ( ! bktr_devsw_installed ) { - dev = makedev(CDEV_MAJOR, 0); - cdevsw_add(&dev,&bktr_cdevsw, NULL); - bktr_devsw_installed = 1; - } -} - -SYSINIT(bktrdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,bktr_drvinit,NULL) - -#endif /* __FreeBSD__ */ #endif /* !defined(__FreeBSD__) || (NBKTR > 0 && NPCI > 0) */ /* Local Variables: */ diff --git a/sys/pci/meteor.c b/sys/pci/meteor.c index ca50c9a..71f708f 100644 --- a/sys/pci/meteor.c +++ b/sys/pci/meteor.c @@ -539,6 +539,10 @@ register int err = 0; static const char * met_probe (pcici_t tag, pcidi_t type) { + static int once; + + if (!once++) + cdevsw_add(&meteor_cdevsw); switch (type) { case SAA7116_PHILIPS_ID: /* meteor */ @@ -2095,22 +2099,4 @@ meteor_mmap(dev_t dev, vm_offset_t offset, int nprot) return i386_btop(vtophys(mtr->bigbuf) + offset); } - -#if !defined(METEOR_FreeBSD_210) /* XXX */ -static int meteor_devsw_installed; - -static void meteor_drvinit(void *unused) -{ - dev_t dev; - - if( ! meteor_devsw_installed ) { - dev = makedev(CDEV_MAJOR, 0); - cdevsw_add(&dev,&meteor_cdevsw, NULL); - meteor_devsw_installed = 1; - } -} - -SYSINIT(meteordev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,meteor_drvinit,NULL) -#endif - #endif /* NMETEOR > 0 */ diff --git a/sys/pci/pci.c b/sys/pci/pci.c index bf5e657..8bc9c1d 100644 --- a/sys/pci/pci.c +++ b/sys/pci/pci.c @@ -23,7 +23,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: pci.c,v 1.105 1999/05/30 10:54:31 dfr Exp $ + * $Id: pci.c,v 1.106 1999/05/30 16:53:36 phk Exp $ * */ @@ -875,10 +875,7 @@ static void *pci_devfs_token; static void pci_cdevinit(void *dummy) { - dev_t dev; - - dev = makedev(PCI_CDEV, 0); - cdevsw_add(&dev, &pcicdev, NULL); + cdevsw_add(&pcicdev); #ifdef DEVFS pci_devfs_token = devfs_add_devswf(&pcicdev, 0, DV_CHR, UID_ROOT, GID_WHEEL, 0644, "pci"); diff --git a/sys/pci/xrpu.c b/sys/pci/xrpu.c index 309deb0..b8511b3 100644 --- a/sys/pci/xrpu.c +++ b/sys/pci/xrpu.c @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: xrpu.c,v 1.10 1999/05/09 17:07:12 peter Exp $ + * $Id: xrpu.c,v 1.11 1999/05/30 16:53:37 phk Exp $ * * A very simple device driver for PCI cards based on Xilinx 6200 series * FPGA/RPU devices. Current Functionality is to allow you to open and @@ -220,6 +220,10 @@ xrpu_probe (pcici_t tag, pcidi_t typea) { u_int id; const char *vendor, *chip, *type; + static int once; + + if (!once++) + cdevsw_add(&xrpu_cdevsw); (void)pci_conf_read(tag, PCI_CLASS_REG); id = pci_conf_read(tag, PCI_ID_REG); @@ -236,7 +240,6 @@ static void xrpu_attach (pcici_t tag, int unit) { struct softc *sc; - dev_t cdev = makedev(CDEV_MAJOR, unit); sc = (struct softc *)malloc(sizeof *sc, M_XRPU, M_WAITOK); softc[unit] = sc; @@ -253,8 +256,6 @@ xrpu_attach (pcici_t tag, int unit) printf("Mapped physbase %#lx to virbase %#lx\n", (u_long)sc->physbase, (u_long)sc->virbase); - if (!unit) - cdevsw_add(&cdev, &xrpu_cdevsw, NULL); #ifdef DEVFS devfs_add_devswf(&xrpu_cdevsw, 0, DV_CHR, UID_ROOT, GID_WHEEL, 0600, |