diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/contrib/dev/fla/fla.c | 3 | ||||
-rw-r--r-- | sys/dev/ata/ata-disk.c | 6 | ||||
-rw-r--r-- | sys/kern/subr_disk.c | 34 | ||||
-rw-r--r-- | sys/sys/disk.h | 8 |
4 files changed, 22 insertions, 29 deletions
diff --git a/sys/contrib/dev/fla/fla.c b/sys/contrib/dev/fla/fla.c index b550781ce63f..83b0edc59dc2 100644 --- a/sys/contrib/dev/fla/fla.c +++ b/sys/contrib/dev/fla/fla.c @@ -78,6 +78,7 @@ static struct cdevsw fla_cdevsw = { /* maxio */ 0, /* bmaj */ BDEV_MAJOR }; +static struct cdevsw fladisk_cdevsw; void * doc2k_malloc(int bytes) @@ -339,7 +340,7 @@ flaattach (device_t dev) DEVSTAT_NO_ORDERED_TAGS, DEVSTAT_TYPE_DIRECT | DEVSTAT_TYPE_IF_OTHER, 0x190); - sc->dev = disk_create(unit, &sc->disk, 0, &fla_cdevsw); + sc->dev = disk_create(unit, &sc->disk, 0, &fla_cdevsw, &fladisk_cdevsw); sc->dev->si_drv1 = sc; sc->unit = unit; diff --git a/sys/dev/ata/ata-disk.c b/sys/dev/ata/ata-disk.c index e5893a2f206b..6e10920c875b 100644 --- a/sys/dev/ata/ata-disk.c +++ b/sys/dev/ata/ata-disk.c @@ -79,7 +79,9 @@ static struct cdevsw ad_cdevsw = { /* maxio */ 0, /* bmaj */ 30, }; +static struct cdevsw addisk_cdevsw; static struct cdevsw fakewd_cdevsw; +static struct cdevsw fakewddisk_cdevsw; /* misc defines */ #define UNIT(dev) (minor(dev)>>3 & 0x1f) /* assume 8 minor # per unit */ @@ -228,9 +230,9 @@ ad_attach(void *notused) DEVSTAT_NO_ORDERED_TAGS, DEVSTAT_TYPE_DIRECT | DEVSTAT_TYPE_IF_IDE, 0x180); - dev1 = disk_create(adp->lun, &adp->disk, 0, &ad_cdevsw); + dev1 = disk_create(adp->lun, &adp->disk, 0, &ad_cdevsw, &addisk_cdevsw); dev1->si_drv1 = adp; - dev1 = disk_create(adp->lun, &adp->disk, 0, &fakewd_cdevsw); + dev1 = disk_create(adp->lun, &adp->disk, 0, &fakewd_cdevsw, &fakewddisk_cdevsw); dev1->si_drv1 = adp; bufq_init(&adp->queue); diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c index 01ace561f5f9..534a5fcb9069 100644 --- a/sys/kern/subr_disk.c +++ b/sys/kern/subr_disk.c @@ -30,28 +30,21 @@ static d_ioctl_t diskioctl; static d_psize_t diskpsize; dev_t -disk_create(int unit, struct disk *dp, int flags, struct cdevsw *cdevsw) +disk_create(int unit, struct disk *dp, int flags, struct cdevsw *cdevsw, struct cdevsw *proto) { dev_t dev; - struct cdevsw *cds; - - MALLOC(cds, struct cdevsw *, sizeof(*cds), M_DISK, M_WAITOK); bzero(dp, sizeof(*dp)); dev = makedev(cdevsw->d_maj, 0); if (!devsw(dev)) { - dp->d_open = cdevsw->d_open; - cdevsw->d_open = diskopen; - dp->d_close = cdevsw->d_close; - cdevsw->d_close = diskclose; - dp->d_ioctl = cdevsw->d_ioctl; - cdevsw->d_ioctl = diskioctl; - dp->d_strategy = cdevsw->d_strategy; - cdevsw->d_strategy = diskstrategy; - dp->d_psize = cdevsw->d_psize; - cdevsw->d_psize = diskpsize; - cdevsw_add(cdevsw); + *proto = *cdevsw; + proto->d_open = diskopen; + proto->d_close = diskclose; + proto->d_ioctl = diskioctl; + proto->d_strategy = diskstrategy; + proto->d_psize = diskpsize; + cdevsw_add(proto); } printf("Creating DISK %s%d\n", cdevsw->d_name, unit); @@ -61,6 +54,7 @@ disk_create(int unit, struct disk *dp, int flags, struct cdevsw *cdevsw) dev->si_disk = dp; dp->d_dev = dev; dp->d_flags = flags; + dp->d_devsw = cdevsw; return (dev); } @@ -126,7 +120,7 @@ diskopen(dev_t dev, int oflags, int devtype, struct proc *p) dev->si_drv2 = pdev->si_drv2; if (!dsisopen(dp->d_slice)) - error = dp->d_open(dev, oflags, devtype, p); + error = dp->d_devsw->d_open(dev, oflags, devtype, p); if (error) return(error); @@ -134,7 +128,7 @@ diskopen(dev_t dev, int oflags, int devtype, struct proc *p) error = dsopen(dev, devtype, dp->d_flags, &dp->d_slice, &dp->d_label); if (!dsisopen(dp->d_slice)) - dp->d_close(dev, oflags, devtype, p); + dp->d_devsw->d_close(dev, oflags, devtype, p); return(error); } @@ -149,7 +143,7 @@ diskclose(dev_t dev, int fflag, int devtype, struct proc *p) dp = dev->si_disk; dsclose(dev, devtype, dp->d_slice); if (dsisopen(dp->d_slice)) - error = dp->d_close(dev, fflag, devtype, p); + error = dp->d_devsw->d_close(dev, fflag, devtype, p); return (error); } @@ -182,7 +176,7 @@ diskstrategy(struct buf *bp) return; } - dp->d_strategy(bp); + dp->d_devsw->d_strategy(bp); return; } @@ -196,7 +190,7 @@ diskioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct proc *p) dp = dev->si_disk; error = dsioctl(dev, cmd, data, fflag, &dp->d_slice); if (error == ENOIOCTL) - error = dp->d_ioctl(dev, cmd, data, fflag, p); + error = dp->d_devsw->d_ioctl(dev, cmd, data, fflag, p); return (error); } diff --git a/sys/sys/disk.h b/sys/sys/disk.h index e96a3ad04ae4..d5e1f9e6b035 100644 --- a/sys/sys/disk.h +++ b/sys/sys/disk.h @@ -23,17 +23,13 @@ struct disk { int d_flags; - d_open_t *d_open; - d_close_t *d_close; - d_ioctl_t *d_ioctl; - d_strategy_t *d_strategy; - d_psize_t *d_psize; + struct cdevsw *d_devsw; dev_t d_dev; struct diskslices *d_slice; struct disklabel d_label; }; -dev_t disk_create __P((int unit, struct disk *disk, int flags, struct cdevsw *cdevsw)); +dev_t disk_create __P((int unit, struct disk *disk, int flags, struct cdevsw *cdevsw, struct cdevsw *diskdevsw)); void disk_delete __P((dev_t dev)); int disk_dumpcheck __P((dev_t dev, u_int *count, u_int *blkno, u_int *secsize)); void disk_invalidate __P((struct disk *disk)); |