diff options
author | bde <bde@FreeBSD.org> | 1995-12-14 22:03:12 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 1995-12-14 22:03:12 +0000 |
commit | 956b9c95d2207ac92e31e30c9df2462c12336c25 (patch) | |
tree | 11ce3a123854b60fee7cdc42f084330319586201 /sys/i386 | |
parent | 2141527fc798c021b7f0cc65339fbb6f9eef475d (diff) | |
download | FreeBSD-src-956b9c95d2207ac92e31e30c9df2462c12336c25.zip FreeBSD-src-956b9c95d2207ac92e31e30c9df2462c12336c25.tar.gz |
Removed my devsw access functions [un]register_cdev() and
getmajorbyname() which were a better (sigh) temporary interface to
the going-away devswitches.
Note that SYSINIT()s to initialize the devswitches would be fatal
in syscons.c and pcvt_drv.c (and are bogus elsewhere) because they
get called independently of whether the device is attached; thus
devices that share a major clobber each other's devswitch entries
until the last one wins.
conf.c:
Removed stale #includes and comments.
Diffstat (limited to 'sys/i386')
-rw-r--r-- | sys/i386/i386/conf.c | 119 | ||||
-rw-r--r-- | sys/i386/isa/pcvt/pcvt_drv.c | 12 | ||||
-rw-r--r-- | sys/i386/isa/syscons.c | 15 |
3 files changed, 21 insertions, 125 deletions
diff --git a/sys/i386/i386/conf.c b/sys/i386/i386/conf.c index 18f9ed8..2b8a47d 100644 --- a/sys/i386/i386/conf.c +++ b/sys/i386/i386/conf.c @@ -42,34 +42,23 @@ * SUCH DAMAGE. * * from: @(#)conf.c 5.8 (Berkeley) 5/12/91 - * $Id: conf.c,v 1.114 1995/12/13 15:12:18 julian Exp $ + * $Id: conf.c,v 1.115 1995/12/14 09:52:37 phk Exp $ */ #include <sys/param.h> -#include <sys/systm.h> -#include <sys/buf.h> -#include <sys/ioctl.h> -#include <sys/proc.h> -#include <sys/vnode.h> -#include <sys/tty.h> #include <sys/conf.h> - -#include <vm/vm.h> -#include <vm/vm_param.h> -#include <vm/vm_extern.h> - +#include <sys/vnode.h> #define NUMCDEV 96 #define NUMBDEV 32 -struct bdevsw *bdevsw[NUMBDEV]; +struct bdevsw *bdevsw[NUMBDEV]; int nblkdev = NUMBDEV; -struct cdevsw *cdevsw[NUMCDEV]; +struct cdevsw *cdevsw[NUMCDEV]; int nchrdev = NUMCDEV; /* * The routines below are total "BULLSHIT" and will be trashed - * When I have 'proved' the JREMOD changes above.. */ /* @@ -180,31 +169,8 @@ chrtoblk(dev) return (makedev(blkmaj, minor(dev))); } -int -getmajorbyname(name) - const char *name; -{ - - if (strcmp(name, "sc") == 0) - return (12); - if (strcmp(name, "vt") == 0) - return (12); - return (NULL); -} - - -static struct cdevsw ** -getcdevbyname(char *name) -{ - int maj; - - maj = getmajorbyname(name); - return (maj < 0 ? NULL : &cdevsw[maj]); -} - #else /* NEW_STUFF_JRE *//*===============================================*/ - /* * Routine to convert from character to block device number. * @@ -223,81 +189,4 @@ chrtoblk(dev_t dev) return(NODEV); } -/* Only checks cdevs */ -int -getmajorbyname(const char *name) -{ - struct cdevsw *cd; - int maj; - char *dname; - - for( maj = 0; maj <nchrdev ; maj++) { - if ( dname = cdevsw[maj]->d_name) { - if ( strcmp(name, dname) == 0 ) { - return maj; - } - } - } - return -1; /* XXX */ /* Was 0 */ -} - - -/* utterly pointless with devfs */ -static struct cdevsw ** -getcdevbyname(const char *name) -{ - struct cdevsw *cd; - int maj; - char *dname; - - for( maj = 0; maj <nchrdev ; maj++) { - if ( dname = cdevsw[maj]->d_name) { - if ( strcmp(name, dname) == 0 ) { - return &cdevsw[maj]; - } - } - } - return NULL; -} #endif /* NEW_STUFF_JRE */ - -/* Zap these as soon as we find out who calls them , and "why?"*/ -int -register_cdev(name, cdp) - const char *name; - const struct cdevsw *cdp; -{ - struct cdevsw **dst_cdp; - - dst_cdp = getcdevbyname(name); - if (dst_cdp == NULL) - return (ENXIO); - if ((*dst_cdp != NULL) - && ((*dst_cdp)->d_open != nxopen) - && ((*dst_cdp)->d_open != NULL)) - return (EBUSY); - *dst_cdp = cdp; - return (0); -} - -static struct cdevsw nxcdevsw = { - nxopen, nxclose, nxread, nxwrite, - nxioctl, nxstop, nxreset, nxdevtotty, - nxselect, nxmmap, NULL, -}; - -int -unregister_cdev(name, cdp) - const char *name; - const struct cdevsw *cdp; -{ - struct cdevsw **dst_cdp; - - dst_cdp = getcdevbyname(name); - if (dst_cdp == NULL) - return (ENXIO); - if ((*dst_cdp)->d_open != cdp->d_open) - return (EBUSY); - *dst_cdp = &nxcdevsw; - return (0); -} diff --git a/sys/i386/isa/pcvt/pcvt_drv.c b/sys/i386/isa/pcvt/pcvt_drv.c index 6e5529e..bee2269 100644 --- a/sys/i386/isa/pcvt/pcvt_drv.c +++ b/sys/i386/isa/pcvt/pcvt_drv.c @@ -115,6 +115,7 @@ static d_ioctl_t pcioctl; static d_devtotty_t pcdevtotty; static d_mmap_t pcmmap; +#define CDEV_MAJOR 12 static struct cdevsw pcdevsw = { pcopen, pcclose, pcread, pcwrite, pcioctl, nullstop, noreset, pcdevtotty, @@ -326,7 +327,11 @@ pcattach(struct isa_device *dev) pcvt_is_console? DC_IDLE: DC_BUSY; vt_registerdev(dev, (char *)vga_string(vga_type)); - register_cdev("vt", &pcdevsw); + { + dev_t dev = makedev(CDEV_MAJOR, 0); + + cdevsw_add(&dev, &pcdevsw, NULL); + } #endif /* PCVT_FREEBSD > 205 */ #if PCVT_NETBSD > 9 @@ -1107,15 +1112,14 @@ pccnprobe(struct consdev *cp) * Take control if we are the highest priority enabled display device. */ dvp = find_display(); - maj = getmajorbyname("vt"); - if (dvp->id_driver != &vtdriver || maj < 0) { + if (dvp != NULL && dvp->id_driver != &vtdriver) { cp->cn_pri = CN_DEAD; return; } /* initialize required fields */ - cp->cn_dev = makedev(maj, 0); + cp->cn_dev = makedev(CDEV_MAJOR, 0); cp->cn_pri = CN_INTERNAL; #if !PCVT_NETBSD diff --git a/sys/i386/isa/syscons.c b/sys/i386/isa/syscons.c index dc628c7..9dc2e14 100644 --- a/sys/i386/isa/syscons.c +++ b/sys/i386/isa/syscons.c @@ -25,7 +25,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: syscons.c,v 1.136 1995/12/10 13:39:18 phk Exp $ + * $Id: syscons.c,v 1.137 1995/12/10 15:54:55 bde Exp $ */ #include "sc.h" @@ -164,6 +164,7 @@ static d_ioctl_t scioctl; static d_devtotty_t scdevtotty; static d_mmap_t scmmap; +#define CDEV_MAJOR 12 static struct cdevsw scdevsw = { scopen, scclose, scread, scwrite, scioctl, nullstop, noreset, scdevtotty, @@ -361,7 +362,11 @@ scattach(struct isa_device *dev) DV_CHR, 0, 0, 0600 ); } #endif - register_cdev("sc", &scdevsw); + { + dev_t dev = makedev(CDEV_MAJOR, 0); + + cdevsw_add(&dev, &scdevsw, NULL); + } return 0; } @@ -1181,20 +1186,18 @@ void sccnprobe(struct consdev *cp) { struct isa_device *dvp; - int maj; /* * Take control if we are the highest priority enabled display device. */ dvp = find_display(); - maj = getmajorbyname("sc"); - if (dvp->id_driver != &scdriver || maj < 0) { + if (dvp != NULL && dvp->id_driver != &scdriver) { cp->cn_pri = CN_DEAD; return; } /* initialize required fields */ - cp->cn_dev = makedev(maj, MAXCONS); + cp->cn_dev = makedev(CDEV_MAJOR, MAXCONS); cp->cn_pri = CN_INTERNAL; } |