diff options
author | phk <phk@FreeBSD.org> | 1999-09-12 20:40:29 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1999-09-12 20:40:29 +0000 |
commit | 12c22f65a5bb7ee59be3065b48b191434c23cc08 (patch) | |
tree | 50edd0d506d2d3925ab4a05f30c1482db2b31b6f /sys/kern/subr_disk.c | |
parent | 78e49a27cc1f5572ecffaca16688aebe823504a6 (diff) | |
download | FreeBSD-src-12c22f65a5bb7ee59be3065b48b191434c23cc08.zip FreeBSD-src-12c22f65a5bb7ee59be3065b48b191434c23cc08.tar.gz |
Bite the bullet and allocate the devsw entry at compile time.
Diffstat (limited to 'sys/kern/subr_disk.c')
-rw-r--r-- | sys/kern/subr_disk.c | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c index 01ace56..534a5fc 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); } |