From 70cd7713375b9351501f68831aea1c52a7b9be47 Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Sat, 27 Sep 2003 12:01:01 +0000 Subject: [PATCH] The present defaults for the open and close for device drivers which provide no methods does not make any sense, and is not used by any driver. It is a pretty hard to come up with even a theoretical concept of a device driver which would always fail open and close with ENODEV. Change the defaults to be nullopen() and nullclose() which simply does nothing. Remove explicit initializations to these from the drivers which already used them. --- sys/dev/adlink/adlink.c | 1 - sys/dev/ata/ata-all.c | 2 -- sys/dev/isp/isp_freebsd.c | 2 -- sys/dev/md/md.c | 2 -- sys/dev/null/null.c | 4 ---- sys/dev/ofw/openfirmio.c | 2 -- sys/geom/geom_ctl.c | 2 -- sys/i386/bios/smapi.c | 2 -- sys/i386/i386/elan-mmcr.c | 2 -- sys/kern/kern_conf.c | 4 ++-- sys/kern/subr_devstat.c | 2 -- sys/kern/tty_tty.c | 1 - sys/netncp/ncp_mod.c | 2 -- sys/opencrypto/cryptodev.c | 1 - 14 files changed, 2 insertions(+), 27 deletions(-) diff --git a/sys/dev/adlink/adlink.c b/sys/dev/adlink/adlink.c index 53c81de45e0e..909f2ba9a28c 100644 --- a/sys/dev/adlink/adlink.c +++ b/sys/dev/adlink/adlink.c @@ -394,7 +394,6 @@ adlink_intr(void *arg) static struct cdevsw adlink_cdevsw = { .d_open = adlink_open, - .d_close = nullclose, .d_ioctl = adlink_ioctl, .d_mmap = adlink_mmap, .d_name = "adlink", diff --git a/sys/dev/ata/ata-all.c b/sys/dev/ata/ata-all.c index 010c2c2a7f76..580f1ea44b75 100644 --- a/sys/dev/ata/ata-all.c +++ b/sys/dev/ata/ata-all.c @@ -57,8 +57,6 @@ __FBSDID("$FreeBSD$"); /* device structures */ static d_ioctl_t ata_ioctl; static struct cdevsw ata_cdevsw = { - .d_open = nullopen, - .d_close = nullclose, .d_ioctl = ata_ioctl, .d_name = "ata", .d_maj = 159, diff --git a/sys/dev/isp/isp_freebsd.c b/sys/dev/isp/isp_freebsd.c index ad1dab61495c..bd41b7029b0c 100644 --- a/sys/dev/isp/isp_freebsd.c +++ b/sys/dev/isp/isp_freebsd.c @@ -54,8 +54,6 @@ static void isp_action(struct cam_sim *, union ccb *); #define ISP_CDEV_MAJOR 248 static struct cdevsw isp_cdevsw = { - .d_open = nullopen, - .d_close = nullclose, .d_ioctl = ispioctl, .d_name = "isp", .d_maj = ISP_CDEV_MAJOR, diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c index d79a4accc40b..58090ff97166 100644 --- a/sys/dev/md/md.c +++ b/sys/dev/md/md.c @@ -116,8 +116,6 @@ static dev_t status_dev = 0; static d_ioctl_t mdctlioctl; static struct cdevsw mdctl_cdevsw = { - .d_open = nullopen, - .d_close = nullclose, .d_ioctl = mdctlioctl, .d_name = MD_NAME, .d_maj = CDEV_MAJOR diff --git a/sys/dev/null/null.c b/sys/dev/null/null.c index 6afa67eaa691..4044bc7ef83c 100644 --- a/sys/dev/null/null.c +++ b/sys/dev/null/null.c @@ -53,8 +53,6 @@ static d_read_t null_read; #define ZERO_MINOR 12 static struct cdevsw null_cdevsw = { - .d_open = nullopen, - .d_close = nullclose, .d_read = null_read, .d_write = null_write, .d_ioctl = null_ioctl, @@ -64,8 +62,6 @@ static struct cdevsw null_cdevsw = { }; static struct cdevsw zero_cdevsw = { - .d_open = nullopen, - .d_close = nullclose, .d_read = zero_read, .d_write = null_write, .d_name = "zero", diff --git a/sys/dev/ofw/openfirmio.c b/sys/dev/ofw/openfirmio.c index cdf2a09eb890..37f10b5202a9 100644 --- a/sys/dev/ofw/openfirmio.c +++ b/sys/dev/ofw/openfirmio.c @@ -67,8 +67,6 @@ static d_ioctl_t openfirm_ioctl; #define OPENFIRM_MINOR 0 static struct cdevsw openfirm_cdevsw = { - .d_open = nullopen, - .d_close = nullclose, .d_ioctl = openfirm_ioctl, .d_name = "openfirm", }; diff --git a/sys/geom/geom_ctl.c b/sys/geom/geom_ctl.c index b9f2a92ca1bf..43a03135cd30 100644 --- a/sys/geom/geom_ctl.c +++ b/sys/geom/geom_ctl.c @@ -65,8 +65,6 @@ __FBSDID("$FreeBSD$"); static d_ioctl_t g_ctl_ioctl; static struct cdevsw g_ctl_cdevsw = { - .d_open = nullopen, - .d_close = nullclose, .d_ioctl = g_ctl_ioctl, .d_name = "g_ctl", }; diff --git a/sys/i386/bios/smapi.c b/sys/i386/bios/smapi.c index 5b908967755d..ed1267eed6ca 100644 --- a/sys/i386/bios/smapi.c +++ b/sys/i386/bios/smapi.c @@ -75,8 +75,6 @@ devclass_t smapi_devclass; static d_ioctl_t smapi_ioctl; static struct cdevsw smapi_cdevsw = { - .d_open = nullopen, - .d_close = nullclose, .d_ioctl = smapi_ioctl, .d_name = "smapi", .d_maj = MAJOR_AUTO, diff --git a/sys/i386/i386/elan-mmcr.c b/sys/i386/i386/elan-mmcr.c index 4cd4d5934b04..67fe5f2907d5 100644 --- a/sys/i386/i386/elan-mmcr.c +++ b/sys/i386/i386/elan-mmcr.c @@ -174,8 +174,6 @@ static d_mmap_t elan_mmap; #define CDEV_MAJOR 100 /* Share with xrpu */ static struct cdevsw elan_cdevsw = { - .d_open = nullopen, - .d_close = nullclose, .d_write = elan_write, .d_ioctl = elan_ioctl, .d_mmap = elan_mmap, diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c index acdf85e1aefd..56eaf115456b 100644 --- a/sys/kern/kern_conf.c +++ b/sys/kern/kern_conf.c @@ -276,8 +276,8 @@ make_dev(struct cdevsw *devsw, int minor, uid_t uid, gid_t gid, int perms, const KASSERT((minor & ~0xffff00ff) == 0, ("Invalid minor (0x%x) in make_dev", minor)); - if (devsw->d_open == NULL) devsw->d_open = noopen; - if (devsw->d_close == NULL) devsw->d_close = noclose; + if (devsw->d_open == NULL) devsw->d_open = nullopen; + if (devsw->d_close == NULL) devsw->d_close = nullclose; if (devsw->d_read == NULL) devsw->d_read = noread; if (devsw->d_write == NULL) devsw->d_write = nowrite; if (devsw->d_ioctl == NULL) devsw->d_ioctl = noioctl; diff --git a/sys/kern/subr_devstat.c b/sys/kern/subr_devstat.c index 6a51745aa263..f33aeb03d40f 100644 --- a/sys/kern/subr_devstat.c +++ b/sys/kern/subr_devstat.c @@ -437,8 +437,6 @@ SYSCTL_INT(_kern_devstat, OID_AUTO, version, CTLFLAG_RD, static d_mmap_t devstat_mmap; static struct cdevsw devstat_cdevsw = { - .d_open = nullopen, - .d_close = nullclose, .d_mmap = devstat_mmap, .d_name = "devstat", }; diff --git a/sys/kern/tty_tty.c b/sys/kern/tty_tty.c index 2b3b76a3f48f..985a87750a71 100644 --- a/sys/kern/tty_tty.c +++ b/sys/kern/tty_tty.c @@ -39,7 +39,6 @@ static d_open_t cttyopen; static struct cdevsw ctty_cdevsw = { .d_open = cttyopen, - .d_close = nullclose, .d_name = "ctty", .d_maj = CDEV_MAJOR, .d_flags = D_TTY, diff --git a/sys/netncp/ncp_mod.c b/sys/netncp/ncp_mod.c index 4c119f9baff7..e56495d6a2c8 100644 --- a/sys/netncp/ncp_mod.c +++ b/sys/netncp/ncp_mod.c @@ -66,8 +66,6 @@ static dev_t ncp_dev; static d_ioctl_t ncp_ioctl; static struct cdevsw ncp_cdevsw = { - .d_open = nullopen, - .d_close = nullclose, .d_ioctl = ncp_ioctl, .d_name = "ncp", }; diff --git a/sys/opencrypto/cryptodev.c b/sys/opencrypto/cryptodev.c index 7d544ab86c11..e3bbba55c6cc 100644 --- a/sys/opencrypto/cryptodev.c +++ b/sys/opencrypto/cryptodev.c @@ -769,7 +769,6 @@ cryptoioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) #define CRYPTO_MAJOR 70 /* from openbsd */ static struct cdevsw crypto_cdevsw = { .d_open = cryptoopen, - .d_close = nullclose, .d_read = cryptoread, .d_write = cryptowrite, .d_ioctl = cryptoioctl,