Replaced bogus macros for dummy devswitch entries by functions.

These functions went away:

	enosys (hasn't been used for some time)
	enxio
	enodev
	enoioctl (was used only once, actually for a vop)

if_tun.c:
Continued cleaning up...

conf.h:
Probably fixed the type of d_reset_t.  It is hard to tell the correct
type because there are no non-dummy device reset functions.

Removed last vestige of ambiguous sleep message strings.
This commit is contained in:
Bruce Evans 1995-11-06 00:36:19 +00:00
parent bacc8b1678
commit 8b25681eb5
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=12118
12 changed files with 343 additions and 167 deletions

View File

@ -42,7 +42,7 @@
* SUCH DAMAGE.
*
* from: @(#)conf.c 5.8 (Berkeley) 5/12/91
* $Id: conf.c,v 1.103 1995/10/28 16:57:52 markm Exp $
* $Id: conf.c,v 1.104 1995/11/04 13:23:09 bde Exp $
*/
#include <sys/param.h>
@ -54,34 +54,12 @@
#include <sys/tty.h>
#include <sys/conf.h>
/* Bogus defines for compatibility. */
#define noioc noioctl
#define nostrat nostrategy
#define zerosize nopsize
/* Lots of bogus defines for shorthand purposes */
#define noopen (d_open_t *)enodev
#define noclose (d_close_t *)enodev
#define noread (d_rdwr_t *)enodev
#define nowrite noread
#define noioc (d_ioctl_t *)enodev
#define nostop (d_stop_t *)enodev
#define noselect (d_select_t *)enodev
#define nostrat nostrategy
#define nodump (d_dump_t *)enodev
#define nodevtotty (d_ttycv_t *)nullop
#define nxopen (d_open_t *)enxio
#define nxclose (d_close_t *)enxio
#define nxread (d_rdwr_t *)enxio
#define nxwrite nxread
#define nxstrategy (d_strategy_t *)enxio
#define nxioctl (d_ioctl_t *)enxio
#define nxdump (d_dump_t *)enxio
#define nxstop (d_stop_t *)enxio
#define nxreset (d_reset_t *)enxio
#define nxselect (d_select_t *)enxio
#define nxmmap nommap /* must return -1, not ENXIO */
#define nxdevtotty (d_ttycv_t *)nullop
#define zerosize (d_psize_t *)0
int lkmenodev();
#define lkmopen (d_open_t *)lkmenodev
#define lkmclose (d_close_t *)lkmenodev
@ -307,7 +285,7 @@ int lkmenodev();
#define swclose noclose
#define swioctl noioc
#define swdump nodump
#define swsize (d_psize_t *)enodev
#define swsize zerosize
struct bdevsw bdevsw[] =

View File

@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: kern_lkm.c,v 1.15 1995/09/08 11:08:34 bde Exp $
* $Id: kern_lkm.c,v 1.16 1995/10/04 03:42:39 julian Exp $
*/
/*
@ -489,7 +489,7 @@ lkmenodev(dev, flags, fmt, p)
struct proc *p;
{
return(enodev());
return(ENODEV);
}
int

View File

@ -31,62 +31,15 @@
* SUCH DAMAGE.
*
* @(#)subr_xxx.c 8.1 (Berkeley) 6/10/93
* $Id: subr_xxx.c,v 1.3 1994/08/02 07:42:36 davidg Exp $
* $Id: subr_xxx.c,v 1.4 1995/09/10 21:35:51 bde Exp $
*/
/*
* Miscellaneous trivial functions, including many
* that are often inline-expanded or done in assembler.
* Miscellaneous trivial functions.
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <machine/cpu.h>
extern int enosys __P((void));
/*
* Unsupported device function (e.g. writing to read-only device).
*/
int
enodev()
{
return (ENODEV);
}
/*
* Unconfigured device function; driver not configured.
*/
int
enxio()
{
return (ENXIO);
}
/*
* Unsupported ioctl function.
*/
int
enoioctl()
{
return (ENOTTY);
}
/*
* Unsupported system function.
* This is used for an otherwise-reasonable operation
* that is not supported by the current system binary.
*/
int
enosys()
{
return (ENOSYS);
}
/*
* Return error for operation not supported
* on a specific object or file type.
@ -108,22 +61,103 @@ nullop()
return (0);
}
/*
* Specific `no' and `null' operations.
* XXX the general ones are bogus.
* XXX device functions may belong elsewhere.
*/
#include <sys/conf.h>
/*
* Unsupported devswitch functions (e.g. for writing to read-only device).
* XXX may belong elsewhere.
*/
int
noreset(dummy)
int dummy;
noopen(dev, flags, fmt, p)
dev_t dev;
int flags;
int fmt;
struct proc *p;
{
return (ENODEV);
}
int
noclose(dev, flags, fmt, p)
dev_t dev;
int flags;
int fmt;
struct proc *p;
{
return (ENODEV);
}
int
noread(dev, uio, ioflag)
dev_t dev;
struct uio *uio;
int ioflag;
{
return (ENODEV);
}
int
nowrite(dev, uio, ioflag)
dev_t dev;
struct uio *uio;
int ioflag;
{
return (ENODEV);
}
int
noioctl(dev, cmd, data, flags, p)
dev_t dev;
int cmd;
caddr_t data;
int flags;
struct proc *p;
{
return (ENODEV);
}
void
nostop(tp, rw)
struct tty *tp;
int rw;
{
}
int
noreset(dev)
dev_t dev;
{
printf("noreset(0x%x) called\n", dev);
return (ENODEV);
}
struct tty *
nodevtotty(dev)
dev_t dev;
{
return (NULL);
}
int
noselect(dev, rw, p)
dev_t dev;
int rw;
struct proc *p;
{
/* XXX is this distinguished from 1 for data available? */
return (ENODEV);
}
int
nommap(dev, offset, nprot)
dev_t dev;
@ -135,22 +169,29 @@ nommap(dev, offset, nprot)
return (-1);
}
void
nostrategy(bp)
struct buf *bp;
int
nodump(dev)
dev_t dev;
{
return (ENODEV);
}
/*
* Null devswitch functions (for when the operation always succeeds).
* XXX may belong elsewhere.
* XXX not all are here (e.g., seltrue() isn't).
*/
/*
* XXX this is probably bogus. Any device that uses it isn't checking the
* minor number.
*/
int
nullopen(dev, flag, mode, p)
nullopen(dev, flags, fmt, p)
dev_t dev;
int flag;
int mode;
int flags;
int fmt;
struct proc *p;
{
@ -158,28 +199,102 @@ nullopen(dev, flag, mode, p)
}
int
nullclose(dev, flag, mode, p)
nullclose(dev, flags, fmt, p)
dev_t dev;
int flag;
int mode;
int flags;
int fmt;
struct proc *p;
{
return (0);
}
void
nullstop(tp, rw)
struct tty *tp;
/*
* Unconfigured devswitch functions (for unconfigured drivers).
* XXX may belong elsewhere.
*/
int
nxopen(dev, flags, fmt, p)
dev_t dev;
int flags;
int fmt;
struct proc *p;
{
return (ENXIO);
}
/*
* XXX all nx functions except nxopen() should probably go away. They
* probably can't be called for non-open devices.
*/
int
nxclose(dev, flags, fmt, p)
dev_t dev;
int flags;
int fmt;
struct proc *p;
{
printf("nxclose(0x%x) called\n", dev);
return (ENXIO);
}
int
nxread(dev, uio, ioflag)
dev_t dev;
struct uio *uio;
int ioflag;
{
printf("nxread(0x%x) called\n", dev);
return (ENXIO);
}
int
nxwrite(dev, uio, ioflag)
dev_t dev;
struct uio *uio;
int ioflag;
{
printf("nxwrite(0x%x) called\n", dev);
return (ENXIO);
}
int
nxioctl(dev, cmd, data, flags, p)
dev_t dev;
int cmd;
caddr_t data;
int flags;
struct proc *p;
{
printf("nxioctl(0x%x) called\n", dev);
return (ENXIO);
}
int
nxselect(dev, rw, p)
dev_t dev;
int rw;
struct proc *p;
{
printf("nxselect(0x%x) called\n", dev);
/* XXX is this distinguished from 1 for data available? */
return (ENXIO);
}
int
nullreset(foo)
int foo;
nxdump(dev)
dev_t dev;
{
return (0);
printf("nxdump(0x%x) called\n", dev);
return (ENXIO);
}

View File

@ -76,17 +76,18 @@ int tunoutput __P((struct ifnet *, struct mbuf *, struct sockaddr *,
struct rtentry *rt));
int tunifioctl __P((struct ifnet *, int, caddr_t));
static struct cdevsw tuncdevsw =
{ tunopen, tunclose, tunread, tunwrite,
tunioctl, (d_stop_t *)enodev, (d_reset_t *)nullop, (d_ttycv_t *)enodev,
tunselect, (d_mmap_t *)enodev, NULL };
static struct cdevsw tuncdevsw = {
tunopen, tunclose, tunread, tunwrite,
tunioctl, nullstop, noreset, nodevtotty,
tunselect, nommap, nostrategy
};
extern dev_t tuncdev;
static int tuninit __P((int));
static void
tunattach(udata)
void *udata;
tunattach(dummy)
void *dummy;
{
register int i;
struct ifnet *ifp;

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_vnops.c 8.5 (Berkeley) 2/13/94
* $Id: nfs_vnops.c,v 1.26 1995/10/22 09:37:45 davidg Exp $
* $Id: nfs_vnops.c,v 1.27 1995/10/29 15:33:15 phk Exp $
*/
/*
@ -96,6 +96,8 @@ static int nfsfifo_read __P((struct vop_read_args *));
static int nfsfifo_write __P((struct vop_write_args *));
static int nfsspec_close __P((struct vop_close_args *));
static int nfsfifo_close __P((struct vop_close_args *));
static int nfs_ioctl __P((struct vop_ioctl_args *));
static int nfs_select __P((struct vop_select_args *));
static int nfs_flush __P((struct vnode *,struct ucred *,int,struct proc *,int));
static int nfs_setattrrpc __P((struct vnode *,struct vattr *,struct ucred *,struct proc *));
static int nfs_lookup __P((struct vop_lookup_args *));
@ -3382,3 +3384,26 @@ nfsfifo_close(ap)
}
return (VOCALL(fifo_vnodeop_p, VOFFSET(vop_close), ap));
}
static int
nfs_ioctl(ap)
struct vop_ioctl_args *ap;
{
/*
* XXX we were once bogusly enoictl() which returned this (ENOTTY).
* Probably we should return ENODEV.
*/
return (ENOTTY);
}
static int
nfs_select(ap)
struct vop_select_args *ap;
{
/*
* We were once bogusly seltrue() which returns 1. Is this right?
*/
return (1);
}

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfsnode.h 8.4 (Berkeley) 2/13/94
* $Id: nfsnode.h,v 1.11 1995/07/29 11:42:23 bde Exp $
* $Id: nfsnode.h,v 1.12 1995/10/29 15:33:19 phk Exp $
*/
#ifndef _NFS_NFSNODE_H_
@ -169,8 +169,6 @@ int nfs_write __P((struct vop_write_args *));
#define nqnfs_lease_check lease_check
#endif
#endif
#define nfs_ioctl ((int (*) __P((struct vop_ioctl_args *)))enoioctl)
#define nfs_select ((int (*) __P((struct vop_select_args *)))seltrue)
#ifdef HAS_VOPREVOKE
#define nfs_revoke vop_revoke
#endif

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_vnops.c 8.5 (Berkeley) 2/13/94
* $Id: nfs_vnops.c,v 1.26 1995/10/22 09:37:45 davidg Exp $
* $Id: nfs_vnops.c,v 1.27 1995/10/29 15:33:15 phk Exp $
*/
/*
@ -96,6 +96,8 @@ static int nfsfifo_read __P((struct vop_read_args *));
static int nfsfifo_write __P((struct vop_write_args *));
static int nfsspec_close __P((struct vop_close_args *));
static int nfsfifo_close __P((struct vop_close_args *));
static int nfs_ioctl __P((struct vop_ioctl_args *));
static int nfs_select __P((struct vop_select_args *));
static int nfs_flush __P((struct vnode *,struct ucred *,int,struct proc *,int));
static int nfs_setattrrpc __P((struct vnode *,struct vattr *,struct ucred *,struct proc *));
static int nfs_lookup __P((struct vop_lookup_args *));
@ -3382,3 +3384,26 @@ nfsfifo_close(ap)
}
return (VOCALL(fifo_vnodeop_p, VOFFSET(vop_close), ap));
}
static int
nfs_ioctl(ap)
struct vop_ioctl_args *ap;
{
/*
* XXX we were once bogusly enoictl() which returned this (ENOTTY).
* Probably we should return ENODEV.
*/
return (ENOTTY);
}
static int
nfs_select(ap)
struct vop_select_args *ap;
{
/*
* We were once bogusly seltrue() which returns 1. Is this right?
*/
return (1);
}

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfsnode.h 8.4 (Berkeley) 2/13/94
* $Id: nfsnode.h,v 1.11 1995/07/29 11:42:23 bde Exp $
* $Id: nfsnode.h,v 1.12 1995/10/29 15:33:19 phk Exp $
*/
#ifndef _NFS_NFSNODE_H_
@ -169,8 +169,6 @@ int nfs_write __P((struct vop_write_args *));
#define nqnfs_lease_check lease_check
#endif
#endif
#define nfs_ioctl ((int (*) __P((struct vop_ioctl_args *)))enoioctl)
#define nfs_select ((int (*) __P((struct vop_select_args *)))seltrue)
#ifdef HAS_VOPREVOKE
#define nfs_revoke vop_revoke
#endif

View File

@ -44,7 +44,7 @@
* SUCH DAMAGE.
*End copyright
*
* $Id: su.c,v 1.4 1995/03/04 20:51:07 dufault Exp $
* $Id: su.c,v 1.5 1995/05/03 18:09:20 dufault Exp $
*
* Tabstops 4
*/
@ -71,22 +71,6 @@
*/
#define OLD_DEV(NEWDEV, OLDDEV) ((OLDDEV) | ((NEWDEV) & 0x080000FF))
/* XXX: These are taken from, and perhaps belong in, conf.c
*/
#define nxopen (d_open_t *)enxio
#define nxclose (d_close_t *)enxio
#define nxread (d_rdwr_t *)enxio
#define nxwrite nxread
#define nxstrategy (d_strategy_t *)enxio
#define nxioctl (d_ioctl_t *)enxio
#define nxdump (d_dump_t *)enxio
#define nxstop (d_stop_t *)enxio
#define nxreset (d_reset_t *)enxio
#define nxselect (d_select_t *)enxio
#define nxmmap (d_mmap_t *)enxio
#define nxdevtotty (d_ttycv_t *)nullop
#define zerosize (d_psize_t *)0
/* bnxio, cnxio: non existent device entries
*/
static struct bdevsw bnxio = {
@ -95,7 +79,7 @@ static struct bdevsw bnxio = {
nxstrategy,
nxioctl,
nxdump,
zerosize,
nxpsize,
0
};

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)conf.h 8.3 (Berkeley) 1/21/94
* $Id: conf.h,v 1.20 1995/11/05 09:37:28 peter Exp $
* $Id: conf.h,v 1.21 1995/11/05 20:25:59 bde Exp $
*/
#ifndef _SYS_CONF_H_
@ -63,7 +63,8 @@ typedef int d_read_t __P((dev_t, struct uio *, int));
typedef int d_write_t __P((dev_t, struct uio *, int));
typedef int d_rdwr_t __P((dev_t, struct uio *, int));
typedef void d_stop_t __P((struct tty *, int));
typedef int d_reset_t __P((int));
typedef int d_reset_t __P((dev_t));
typedef struct tty *d_devtotty_t __P((dev_t));
typedef int d_select_t __P((dev_t, int, struct proc *));
typedef int d_mmap_t __P((dev_t, int, int));
typedef struct tty * d_ttycv_t __P((dev_t));
@ -99,7 +100,7 @@ struct cdevsw {
d_rdwr_t *d_write;
d_ioctl_t *d_ioctl;
d_stop_t *d_stop;
d_reset_t *d_reset;
d_reset_t *d_reset; /* XXX not used */
d_ttycv_t *d_devtotty;
d_select_t *d_select;
d_mmap_t *d_mmap;
@ -108,10 +109,6 @@ struct cdevsw {
#ifdef KERNEL
extern struct cdevsw cdevsw[];
/* symbolic sleep message strings */
extern char devopn[], devio[], devwait[], devin[], devout[];
extern char devioc[], devcls[];
#endif
struct linesw {
@ -145,19 +142,48 @@ struct swdevt {
#define sw_freed sw_flags /* XXX compat */
#ifdef KERNEL
d_open_t noopen;
d_close_t noclose;
d_read_t noread;
d_write_t nowrite;
d_ioctl_t noioctl;
d_stop_t nostop;
d_reset_t noreset;
d_devtotty_t nodevtotty;
d_select_t noselect;
d_mmap_t nommap;
d_strategy_t nostrategy;
/*
* XXX d_strategy seems to be unused for cdevs that aren't associated with
* bdevs and called without checking for it being non-NULL for bdevs.
*/
#define nostrategy ((d_strategy_t *)NULL)
d_dump_t nodump;
/*
* nopsize is little used, so not worth having dummy functions for.
*/
#define nopsize ((d_psize_t *)NULL)
d_open_t nullopen;
d_close_t nullclose;
d_stop_t nullstop;
d_reset_t nullreset;
/*
* XXX d_strategy seems to be unused for cdevs and called without checking
* for it being non-NULL for bdevs.
*/
#define nullstrategy ((d_strategy *)NULL)
#define nullstop nostop /* one void return is as good as another */
#define nullreset noreset /* one unused function is as good as another */
d_open_t nxopen;
d_close_t nxclose;
d_read_t nxread;
d_write_t nxwrite;
d_ioctl_t nxioctl;
#define nxstop nostop /* one void return is as good as another */
#define nxreset noreset /* one unused function is as good as another */
#define nxdevtotty nodevtotty /* one NULL return is as good as another */
d_select_t nxselect;
#define nxmmap nommap /* one -1 return is as good as another */
#define nxstrategy nostrategy /* one NULL value is as good as another */
d_dump_t nxdump;
#define nxpsize nopsize /* one NULL value is as good as another */
l_read_t l_noread;
l_write_t l_nowrite;

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)conf.h 8.3 (Berkeley) 1/21/94
* $Id: conf.h,v 1.20 1995/11/05 09:37:28 peter Exp $
* $Id: conf.h,v 1.21 1995/11/05 20:25:59 bde Exp $
*/
#ifndef _SYS_CONF_H_
@ -63,7 +63,8 @@ typedef int d_read_t __P((dev_t, struct uio *, int));
typedef int d_write_t __P((dev_t, struct uio *, int));
typedef int d_rdwr_t __P((dev_t, struct uio *, int));
typedef void d_stop_t __P((struct tty *, int));
typedef int d_reset_t __P((int));
typedef int d_reset_t __P((dev_t));
typedef struct tty *d_devtotty_t __P((dev_t));
typedef int d_select_t __P((dev_t, int, struct proc *));
typedef int d_mmap_t __P((dev_t, int, int));
typedef struct tty * d_ttycv_t __P((dev_t));
@ -99,7 +100,7 @@ struct cdevsw {
d_rdwr_t *d_write;
d_ioctl_t *d_ioctl;
d_stop_t *d_stop;
d_reset_t *d_reset;
d_reset_t *d_reset; /* XXX not used */
d_ttycv_t *d_devtotty;
d_select_t *d_select;
d_mmap_t *d_mmap;
@ -108,10 +109,6 @@ struct cdevsw {
#ifdef KERNEL
extern struct cdevsw cdevsw[];
/* symbolic sleep message strings */
extern char devopn[], devio[], devwait[], devin[], devout[];
extern char devioc[], devcls[];
#endif
struct linesw {
@ -145,19 +142,48 @@ struct swdevt {
#define sw_freed sw_flags /* XXX compat */
#ifdef KERNEL
d_open_t noopen;
d_close_t noclose;
d_read_t noread;
d_write_t nowrite;
d_ioctl_t noioctl;
d_stop_t nostop;
d_reset_t noreset;
d_devtotty_t nodevtotty;
d_select_t noselect;
d_mmap_t nommap;
d_strategy_t nostrategy;
/*
* XXX d_strategy seems to be unused for cdevs that aren't associated with
* bdevs and called without checking for it being non-NULL for bdevs.
*/
#define nostrategy ((d_strategy_t *)NULL)
d_dump_t nodump;
/*
* nopsize is little used, so not worth having dummy functions for.
*/
#define nopsize ((d_psize_t *)NULL)
d_open_t nullopen;
d_close_t nullclose;
d_stop_t nullstop;
d_reset_t nullreset;
/*
* XXX d_strategy seems to be unused for cdevs and called without checking
* for it being non-NULL for bdevs.
*/
#define nullstrategy ((d_strategy *)NULL)
#define nullstop nostop /* one void return is as good as another */
#define nullreset noreset /* one unused function is as good as another */
d_open_t nxopen;
d_close_t nxclose;
d_read_t nxread;
d_write_t nxwrite;
d_ioctl_t nxioctl;
#define nxstop nostop /* one void return is as good as another */
#define nxreset noreset /* one unused function is as good as another */
#define nxdevtotty nodevtotty /* one NULL return is as good as another */
d_select_t nxselect;
#define nxmmap nommap /* one -1 return is as good as another */
#define nxstrategy nostrategy /* one NULL value is as good as another */
d_dump_t nxdump;
#define nxpsize nopsize /* one NULL value is as good as another */
l_read_t l_noread;
l_write_t l_nowrite;

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)device_pager.c 8.1 (Berkeley) 6/11/93
* $Id: device_pager.c,v 1.11 1995/05/30 08:15:46 rgrimes Exp $
* $Id: device_pager.c,v 1.12 1995/07/13 08:48:10 davidg Exp $
*/
#include <sys/param.h>
@ -94,7 +94,7 @@ dev_pager_alloc(handle, size, prot, foff)
*/
dev = (dev_t) (u_long) handle;
mapfunc = cdevsw[major(dev)].d_mmap;
if (mapfunc == NULL || mapfunc == enodev || mapfunc == nullop)
if (mapfunc == NULL || mapfunc == nullop)
return (NULL);
/*
@ -186,7 +186,7 @@ dev_pager_getpages(object, m, count, reqpage)
prot = PROT_READ; /* XXX should pass in? */
mapfunc = cdevsw[major(dev)].d_mmap;
if (mapfunc == NULL || mapfunc == enodev || mapfunc == nullop)
if (mapfunc == NULL || mapfunc == nullop)
panic("dev_pager_getpage: no map function");
paddr = pmap_phys_address((*mapfunc) ((dev_t) dev, (int) offset, prot));