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.
This commit is contained in:
Poul-Henning Kamp 2003-09-27 12:01:01 +00:00
parent 5da172697f
commit 70cd771337
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=120506
14 changed files with 2 additions and 27 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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