From 1087d4752210c05aabec84357cd61532f35eb297 Mon Sep 17 00:00:00 2001 From: nyan Date: Thu, 18 Sep 2003 09:49:08 +0000 Subject: Merged from sys/isa/fd.c revisions 1.259 and 1.260. --- sys/pc98/cbus/fdc.c | 32 +++++++++++++++++--------------- sys/pc98/pc98/fd.c | 32 +++++++++++++++++--------------- 2 files changed, 34 insertions(+), 30 deletions(-) (limited to 'sys') diff --git a/sys/pc98/cbus/fdc.c b/sys/pc98/cbus/fdc.c index 9065a07..3fc145a 100644 --- a/sys/pc98/cbus/fdc.c +++ b/sys/pc98/cbus/fdc.c @@ -533,10 +533,10 @@ static void fdc_reset(fdc_p); static int fd_in(struct fdc_data *, int *); static int out_fdc(struct fdc_data *, int); /* - * The open function is named Fdopen() to avoid confusion with fdopen() + * The open function is named fdopen() to avoid confusion with fdopen() * in fd(4). The difference is now only meaningful for debuggers. */ -static d_open_t Fdopen; +static d_open_t fdopen; static d_close_t fdclose; static d_strategy_t fdstrategy; static void fdstart(struct fdc_data *); @@ -624,7 +624,7 @@ fdin_rd(fdc_p fdc) #define CDEV_MAJOR 9 static struct cdevsw fd_cdevsw = { - .d_open = Fdopen, + .d_open = fdopen, .d_close = fdclose, .d_read = physread, .d_write = physwrite, @@ -1480,6 +1480,7 @@ fd_clone(void *arg, char *name, int namelen, dev_t *dev) UID_ROOT, GID_OPERATOR, 0640, name); fd->clonedevs[i] = *dev; + fd->clonedevs[i]->si_drv1 = fd; return; } } @@ -1732,6 +1733,7 @@ fd_attach(device_t dev) #endif fd->masterdev = make_dev(&fd_cdevsw, fd->fdu << 6, UID_ROOT, GID_OPERATOR, 0640, "fd%d", fd->fdu); + fd->masterdev->si_drv1 = fd; #ifdef GONE_IN_5 { int i; @@ -1980,15 +1982,16 @@ out_fdc(struct fdc_data *fdc, int x) * auxiliary functions). */ static int -Fdopen(dev_t dev, int flags, int mode, struct thread *td) +fdopen(dev_t dev, int flags, int mode, struct thread *td) { - fdu_t fdu = FDUNIT(minor(dev)); + fdu_t fdu = FDUNIT(minor(dev)); int type = FDTYPE(minor(dev)); fd_p fd; fdc_p fdc; int rv, unitattn, dflags; - if ((fd = devclass_get_softc(fd_devclass, fdu)) == 0) + fd = dev->si_drv1; + if (fd == NULL) return (ENXIO); fdc = fd->fdc; if ((fdc == NULL) || (fd->type == FDT_NONE)) @@ -2091,10 +2094,9 @@ Fdopen(dev_t dev, int flags, int mode, struct thread *td) static int fdclose(dev_t dev, int flags, int mode, struct thread *td) { - fdu_t fdu = FDUNIT(minor(dev)); struct fd_data *fd; - fd = devclass_get_softc(fd_devclass, fdu); + fd = dev->si_drv1; fd->flags &= ~(FD_OPEN | FD_NONBLOCK); fd->options &= ~(FDOPT_NORETRY | FDOPT_NOERRLOG | FDOPT_NOERROR); @@ -2112,8 +2114,8 @@ fdstrategy(struct bio *bp) size_t fdblk; fdu = FDUNIT(minor(bp->bio_dev)); - fd = devclass_get_softc(fd_devclass, fdu); - if (fd == 0) + fd = bp->bio_dev->si_drv1; + if (fd == NULL) panic("fdstrategy: buf for nonexistent device (%#lx, %#lx)", (u_long)major(bp->bio_dev), (u_long)minor(bp->bio_dev)); fdc = fd->fdc; @@ -2310,7 +2312,7 @@ fdautoselect(dev_t dev) int i, n, oopts, rv; fdu = FDUNIT(minor(dev)); - fd = devclass_get_softc(fd_devclass, fdu); + fd = dev->si_drv1; switch (fd->type) { default: @@ -2441,7 +2443,7 @@ fdstate(fdc_p fdc) return (0); } fdu = FDUNIT(minor(bp->bio_dev)); - fd = devclass_get_softc(fd_devclass, fdu); + fd = bp->bio_dev->si_drv1; fdblk = 128 << fd->ft->secsize; if (fdc->fd && (fd != fdc->fd)) device_printf(fd->dev, "confused fd pointers\n"); @@ -3059,7 +3061,7 @@ retrier(struct fdc_data *fdc) /* XXX shouldn't this be cached somewhere? */ fdu = FDUNIT(minor(bp->bio_dev)); - fd = devclass_get_softc(fd_devclass, fdu); + fd = bp->bio_dev->si_drv1; if (fd->options & FDOPT_NORETRY) goto fail; @@ -3130,7 +3132,7 @@ fdmisccmd(dev_t dev, u_int cmd, void *data) int error; fdu = FDUNIT(minor(dev)); - fd = devclass_get_softc(fd_devclass, fdu); + fd = dev->si_drv1; fdblk = 128 << fd->ft->secsize; finfo = (struct fd_formb *)data; idfield = (struct fdc_readid *)data; @@ -3182,7 +3184,7 @@ fdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td) fdu = FDUNIT(minor(dev)); type = FDTYPE(minor(dev)); - fd = devclass_get_softc(fd_devclass, fdu); + fd = dev->si_drv1; #ifdef PC98 pc98_fd_check_ready(fdu); diff --git a/sys/pc98/pc98/fd.c b/sys/pc98/pc98/fd.c index 9065a07..3fc145a 100644 --- a/sys/pc98/pc98/fd.c +++ b/sys/pc98/pc98/fd.c @@ -533,10 +533,10 @@ static void fdc_reset(fdc_p); static int fd_in(struct fdc_data *, int *); static int out_fdc(struct fdc_data *, int); /* - * The open function is named Fdopen() to avoid confusion with fdopen() + * The open function is named fdopen() to avoid confusion with fdopen() * in fd(4). The difference is now only meaningful for debuggers. */ -static d_open_t Fdopen; +static d_open_t fdopen; static d_close_t fdclose; static d_strategy_t fdstrategy; static void fdstart(struct fdc_data *); @@ -624,7 +624,7 @@ fdin_rd(fdc_p fdc) #define CDEV_MAJOR 9 static struct cdevsw fd_cdevsw = { - .d_open = Fdopen, + .d_open = fdopen, .d_close = fdclose, .d_read = physread, .d_write = physwrite, @@ -1480,6 +1480,7 @@ fd_clone(void *arg, char *name, int namelen, dev_t *dev) UID_ROOT, GID_OPERATOR, 0640, name); fd->clonedevs[i] = *dev; + fd->clonedevs[i]->si_drv1 = fd; return; } } @@ -1732,6 +1733,7 @@ fd_attach(device_t dev) #endif fd->masterdev = make_dev(&fd_cdevsw, fd->fdu << 6, UID_ROOT, GID_OPERATOR, 0640, "fd%d", fd->fdu); + fd->masterdev->si_drv1 = fd; #ifdef GONE_IN_5 { int i; @@ -1980,15 +1982,16 @@ out_fdc(struct fdc_data *fdc, int x) * auxiliary functions). */ static int -Fdopen(dev_t dev, int flags, int mode, struct thread *td) +fdopen(dev_t dev, int flags, int mode, struct thread *td) { - fdu_t fdu = FDUNIT(minor(dev)); + fdu_t fdu = FDUNIT(minor(dev)); int type = FDTYPE(minor(dev)); fd_p fd; fdc_p fdc; int rv, unitattn, dflags; - if ((fd = devclass_get_softc(fd_devclass, fdu)) == 0) + fd = dev->si_drv1; + if (fd == NULL) return (ENXIO); fdc = fd->fdc; if ((fdc == NULL) || (fd->type == FDT_NONE)) @@ -2091,10 +2094,9 @@ Fdopen(dev_t dev, int flags, int mode, struct thread *td) static int fdclose(dev_t dev, int flags, int mode, struct thread *td) { - fdu_t fdu = FDUNIT(minor(dev)); struct fd_data *fd; - fd = devclass_get_softc(fd_devclass, fdu); + fd = dev->si_drv1; fd->flags &= ~(FD_OPEN | FD_NONBLOCK); fd->options &= ~(FDOPT_NORETRY | FDOPT_NOERRLOG | FDOPT_NOERROR); @@ -2112,8 +2114,8 @@ fdstrategy(struct bio *bp) size_t fdblk; fdu = FDUNIT(minor(bp->bio_dev)); - fd = devclass_get_softc(fd_devclass, fdu); - if (fd == 0) + fd = bp->bio_dev->si_drv1; + if (fd == NULL) panic("fdstrategy: buf for nonexistent device (%#lx, %#lx)", (u_long)major(bp->bio_dev), (u_long)minor(bp->bio_dev)); fdc = fd->fdc; @@ -2310,7 +2312,7 @@ fdautoselect(dev_t dev) int i, n, oopts, rv; fdu = FDUNIT(minor(dev)); - fd = devclass_get_softc(fd_devclass, fdu); + fd = dev->si_drv1; switch (fd->type) { default: @@ -2441,7 +2443,7 @@ fdstate(fdc_p fdc) return (0); } fdu = FDUNIT(minor(bp->bio_dev)); - fd = devclass_get_softc(fd_devclass, fdu); + fd = bp->bio_dev->si_drv1; fdblk = 128 << fd->ft->secsize; if (fdc->fd && (fd != fdc->fd)) device_printf(fd->dev, "confused fd pointers\n"); @@ -3059,7 +3061,7 @@ retrier(struct fdc_data *fdc) /* XXX shouldn't this be cached somewhere? */ fdu = FDUNIT(minor(bp->bio_dev)); - fd = devclass_get_softc(fd_devclass, fdu); + fd = bp->bio_dev->si_drv1; if (fd->options & FDOPT_NORETRY) goto fail; @@ -3130,7 +3132,7 @@ fdmisccmd(dev_t dev, u_int cmd, void *data) int error; fdu = FDUNIT(minor(dev)); - fd = devclass_get_softc(fd_devclass, fdu); + fd = dev->si_drv1; fdblk = 128 << fd->ft->secsize; finfo = (struct fd_formb *)data; idfield = (struct fdc_readid *)data; @@ -3182,7 +3184,7 @@ fdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td) fdu = FDUNIT(minor(dev)); type = FDTYPE(minor(dev)); - fd = devclass_get_softc(fd_devclass, fdu); + fd = dev->si_drv1; #ifdef PC98 pc98_fd_check_ready(fdu); -- cgit v1.1