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.
This commit is contained in:
Bruce Evans 1995-12-14 22:03:12 +00:00
parent 7cbb44a1d9
commit d1022821ae
7 changed files with 41 additions and 145 deletions

View File

@ -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;
}

View File

@ -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);
}

View File

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

View File

@ -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;
}

View File

@ -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;
}

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)conf.h 8.3 (Berkeley) 1/21/94
* $Id: conf.h,v 1.27 1995/12/10 15:55:34 bde Exp $
* $Id: conf.h,v 1.28 1995/12/13 15:13:44 julian Exp $
*/
#ifndef _SYS_CONF_H_
@ -202,13 +202,10 @@ l_write_t l_nowrite;
int bdevsw_add __P((dev_t *descrip,struct bdevsw *new,struct bdevsw **old));
int cdevsw_add __P((dev_t *descrip,struct cdevsw *new,struct cdevsw **old));
dev_t chrtoblk __P((dev_t dev));
int getmajorbyname __P((const char *name));
int isdisk __P((dev_t dev, int type));
int iskmemdev __P((dev_t dev));
int iszerodev __P((dev_t dev));
int register_cdev __P((const char *name, const struct cdevsw *cdp));
void setconf __P((void));
int unregister_cdev __P((const char *name, const struct cdevsw *cdp));
#endif /* KERNEL */
#include <machine/conf.h>

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)conf.h 8.3 (Berkeley) 1/21/94
* $Id: conf.h,v 1.27 1995/12/10 15:55:34 bde Exp $
* $Id: conf.h,v 1.28 1995/12/13 15:13:44 julian Exp $
*/
#ifndef _SYS_CONF_H_
@ -202,13 +202,10 @@ l_write_t l_nowrite;
int bdevsw_add __P((dev_t *descrip,struct bdevsw *new,struct bdevsw **old));
int cdevsw_add __P((dev_t *descrip,struct cdevsw *new,struct cdevsw **old));
dev_t chrtoblk __P((dev_t dev));
int getmajorbyname __P((const char *name));
int isdisk __P((dev_t dev, int type));
int iskmemdev __P((dev_t dev));
int iszerodev __P((dev_t dev));
int register_cdev __P((const char *name, const struct cdevsw *cdp));
void setconf __P((void));
int unregister_cdev __P((const char *name, const struct cdevsw *cdp));
#endif /* KERNEL */
#include <machine/conf.h>