diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2009-12-06 07:26:36 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2009-12-06 07:26:36 +0000 |
commit | 7ae056ef93496e5b61d87fc83d93c2db6ff32495 (patch) | |
tree | e8bf6bfa997f4f1287dcd10882477717ecb58927 /sys | |
parent | ce2a310a47f433c9f9b3c1d0b7b0e24b4bab0e82 (diff) |
consistently refer to the softc pointer as sc, not sd.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/scsi/sd.c | 340 |
1 files changed, 170 insertions, 170 deletions
diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c index 5c387e34cf1..e86801a2d15 100644 --- a/sys/scsi/sd.c +++ b/sys/scsi/sd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sd.c,v 1.170 2009/12/06 03:35:27 dlg Exp $ */ +/* $OpenBSD: sd.c,v 1.171 2009/12/06 07:26:35 dlg Exp $ */ /* $NetBSD: sd.c,v 1.111 1997/04/02 02:29:41 mycroft Exp $ */ /*- @@ -160,32 +160,32 @@ sdmatch(struct device *parent, void *match, void *aux) void sdattach(struct device *parent, struct device *self, void *aux) { - int error, result; - struct sd_softc *sd = (struct sd_softc *)self; - struct disk_parms *dp = &sd->params; + struct sd_softc *sc = (struct sd_softc *)self; struct scsi_attach_args *sa = aux; + struct disk_parms *dp = &sc->params; struct scsi_link *sc_link = sa->sa_sc_link; int sd_autoconf = scsi_autoconf | SCSI_SILENT | SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_MEDIA_CHANGE; + int error, result; SC_DEBUG(sc_link, SDEV_DB2, ("sdattach:\n")); - mtx_init(&sd->sc_buf_mtx, IPL_BIO); - mtx_init(&sd->sc_start_mtx, IPL_BIO); + mtx_init(&sc->sc_buf_mtx, IPL_BIO); + mtx_init(&sc->sc_start_mtx, IPL_BIO); /* * Store information needed to contact our base driver */ - sd->sc_link = sc_link; + sc->sc_link = sc_link; sc_link->device = &sd_switch; - sc_link->device_softc = sd; + sc_link->device_softc = sc; /* * Initialize and attach the disk structure. */ - sd->sc_dk.dk_driver = &sddkdriver; - sd->sc_dk.dk_name = sd->sc_dev.dv_xname; - disk_attach(&sd->sc_dk); + sc->sc_dk.dk_driver = &sddkdriver; + sc->sc_dk.dk_name = sc->sc_dev.dv_xname; + disk_attach(&sc->sc_dk); if ((sc_link->flags & SDEV_ATAPI) && (sc_link->flags & SDEV_REMOVABLE)) sc_link->quirks |= SDEV_NOSYNCCACHE; @@ -198,7 +198,7 @@ sdattach(struct device *parent, struct device *self, void *aux) */ if (!(sc_link->flags & SDEV_ATAPI) && SCSISPC(sa->sa_inqbuf->version) == 0) - sd->flags |= SDF_ANCIENT; + sc->flags |= SDF_ANCIENT; /* * Use the subdriver to request information regarding @@ -207,10 +207,10 @@ sdattach(struct device *parent, struct device *self, void *aux) */ printf("\n"); - timeout_set(&sd->sc_timeout, sdstart, sd); + timeout_set(&sc->sc_timeout, sdstart, sc); /* Spin up non-UMASS devices ready or not. */ - if ((sd->sc_link->flags & SDEV_UMASS) == 0) + if ((sc->sc_link->flags & SDEV_UMASS) == 0) scsi_start(sc_link, SSS_START, sd_autoconf); /* @@ -221,18 +221,18 @@ sdattach(struct device *parent, struct device *self, void *aux) scsi_prevent(sc_link, PR_PREVENT, sd_autoconf); /* Check that it is still responding and ok. */ - error = scsi_test_unit_ready(sd->sc_link, TEST_READY_RETRIES * 3, + error = scsi_test_unit_ready(sc->sc_link, TEST_READY_RETRIES * 3, sd_autoconf); if (error) result = SDGP_RESULT_OFFLINE; else - result = sd_get_parms(sd, &sd->params, sd_autoconf); + result = sd_get_parms(sc, &sc->params, sd_autoconf); if ((sc_link->flags & SDEV_REMOVABLE) != 0) scsi_prevent(sc_link, PR_ALLOW, sd_autoconf); - printf("%s: ", sd->sc_dev.dv_xname); + printf("%s: ", sc->sc_dev.dv_xname); switch (result) { case SDGP_RESULT_OK: printf("%lldMB, %lu bytes/sec, %lld sec total", @@ -260,16 +260,16 @@ sdattach(struct device *parent, struct device *self, void *aux) * the list (thus guaranteeing that our hook runs before * our ancestors'). */ - if ((sd->sc_sdhook = - shutdownhook_establish(sd_shutdown, sd)) == NULL) + if ((sc->sc_sdhook = + shutdownhook_establish(sd_shutdown, sc)) == NULL) printf("%s: WARNING: unable to establish shutdown hook\n", - sd->sc_dev.dv_xname); + sc->sc_dev.dv_xname); } int sdactivate(struct device *self, int act) { - struct sd_softc *sd = (struct sd_softc *)self; + struct sd_softc *sc = (struct sd_softc *)self; int rv = 0; switch (act) { @@ -277,8 +277,8 @@ sdactivate(struct device *self, int act) break; case DVACT_DEACTIVATE: - sd->flags |= SDF_DYING; - sd_kill_buffers(sd); + sc->flags |= SDF_DYING; + sd_kill_buffers(sc); break; } @@ -289,10 +289,10 @@ sdactivate(struct device *self, int act) int sddetach(struct device *self, int flags) { - struct sd_softc *sd = (struct sd_softc *)self; + struct sd_softc *sc = (struct sd_softc *)self; int bmaj, cmaj, mn; - sd_kill_buffers(sd); + sd_kill_buffers(sc); /* Locate the lowest minor number to be detached. */ mn = DISKMINOR(self->dv_unit, 0); @@ -305,11 +305,11 @@ sddetach(struct device *self, int flags) vdevgone(cmaj, mn, mn + MAXPARTITIONS - 1, VCHR); /* Get rid of the shutdown hook. */ - if (sd->sc_sdhook != NULL) - shutdownhook_disestablish(sd->sc_sdhook); + if (sc->sc_sdhook != NULL) + shutdownhook_disestablish(sc->sc_sdhook); /* Detach disk. */ - disk_detach(&sd->sc_dk); + disk_detach(&sc->sc_dk); return (0); } @@ -321,7 +321,7 @@ int sdopen(dev_t dev, int flag, int fmt, struct proc *p) { struct scsi_link *sc_link; - struct sd_softc *sd; + struct sd_softc *sc; int error = 0, part, rawopen, unit; unit = DISKUNIT(dev); @@ -329,25 +329,25 @@ sdopen(dev_t dev, int flag, int fmt, struct proc *p) rawopen = (part == RAW_PART) && (fmt == S_IFCHR); - sd = sdlookup(unit); - if (sd == NULL) + sc = sdlookup(unit); + if (sc == NULL) return (ENXIO); - if (sd->flags & SDF_DYING) { - device_unref(&sd->sc_dev); + if (sc->flags & SDF_DYING) { + device_unref(&sc->sc_dev); return (ENXIO); } - sc_link = sd->sc_link; + sc_link = sc->sc_link; SC_DEBUG(sc_link, SDEV_DB1, ("sdopen: dev=0x%x (unit %d (of %d), partition %d)\n", dev, unit, sd_cd.cd_ndevs, part)); - if ((error = sdlock(sd)) != 0) { - device_unref(&sd->sc_dev); + if ((error = sdlock(sc)) != 0) { + device_unref(&sc->sc_dev); return (error); } - if (sd->sc_dk.dk_openmask != 0) { + if (sc->sc_dk.dk_openmask != 0) { /* * If any partition is open, but the disk has been invalidated, * disallow further opens of non-raw partition. @@ -360,7 +360,7 @@ sdopen(dev_t dev, int flag, int fmt, struct proc *p) } } else { /* Spin up non-UMASS devices ready or not. */ - if ((sd->sc_link->flags & SDEV_UMASS) == 0) + if ((sc->sc_link->flags & SDEV_UMASS) == 0) scsi_start(sc_link, SSS_START, (rawopen ? SCSI_SILENT : 0) | SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_MEDIA_CHANGE); @@ -399,7 +399,7 @@ sdopen(dev_t dev, int flag, int fmt, struct proc *p) /* Load the physical device parameters. */ sc_link->flags |= SDEV_MEDIA_LOADED; - if (sd_get_parms(sd, &sd->params, (rawopen ? SCSI_SILENT : 0)) + if (sd_get_parms(sc, &sc->params, (rawopen ? SCSI_SILENT : 0)) == SDGP_RESULT_OFFLINE) { sc_link->flags &= ~SDEV_MEDIA_LOADED; error = ENXIO; @@ -408,7 +408,7 @@ sdopen(dev_t dev, int flag, int fmt, struct proc *p) SC_DEBUG(sc_link, SDEV_DB3, ("Params loaded\n")); /* Load the partition info if not already loaded. */ - if (sdgetdisklabel(dev, sd, sd->sc_dk.dk_label, 0) == EIO) { + if (sdgetdisklabel(dev, sc, sc->sc_dk.dk_label, 0) == EIO) { error = EIO; goto bad; } @@ -417,8 +417,8 @@ sdopen(dev_t dev, int flag, int fmt, struct proc *p) /* Check that the partition exists. */ if (part != RAW_PART && - (part >= sd->sc_dk.dk_label->d_npartitions || - sd->sc_dk.dk_label->d_partitions[part].p_fstype == FS_UNUSED)) { + (part >= sc->sc_dk.dk_label->d_npartitions || + sc->sc_dk.dk_label->d_partitions[part].p_fstype == FS_UNUSED)) { error = ENXIO; goto bad; } @@ -426,27 +426,27 @@ sdopen(dev_t dev, int flag, int fmt, struct proc *p) out: /* Insure only one open at a time. */ switch (fmt) { case S_IFCHR: - sd->sc_dk.dk_copenmask |= (1 << part); + sc->sc_dk.dk_copenmask |= (1 << part); break; case S_IFBLK: - sd->sc_dk.dk_bopenmask |= (1 << part); + sc->sc_dk.dk_bopenmask |= (1 << part); break; } - sd->sc_dk.dk_openmask = sd->sc_dk.dk_copenmask | sd->sc_dk.dk_bopenmask; + sc->sc_dk.dk_openmask = sc->sc_dk.dk_copenmask | sc->sc_dk.dk_bopenmask; SC_DEBUG(sc_link, SDEV_DB3, ("open complete\n")); /* It's OK to fall through because dk_openmask is now non-zero. */ bad: - if (sd->sc_dk.dk_openmask == 0) { - if ((sd->sc_link->flags & SDEV_REMOVABLE) != 0) + if (sc->sc_dk.dk_openmask == 0) { + if ((sc->sc_link->flags & SDEV_REMOVABLE) != 0) scsi_prevent(sc_link, PR_ALLOW, SCSI_SILENT | SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_MEDIA_CHANGE); sc_link->flags &= ~(SDEV_OPEN | SDEV_MEDIA_LOADED); } - sdunlock(sd); - device_unref(&sd->sc_dev); + sdunlock(sc); + device_unref(&sc->sc_dev); return (error); } @@ -457,53 +457,53 @@ bad: int sdclose(dev_t dev, int flag, int fmt, struct proc *p) { - struct sd_softc *sd; + struct sd_softc *sc; int part = DISKPART(dev); int error; - sd = sdlookup(DISKUNIT(dev)); - if (sd == NULL) + sc = sdlookup(DISKUNIT(dev)); + if (sc == NULL) return (ENXIO); - if (sd->flags & SDF_DYING) { - device_unref(&sd->sc_dev); + if (sc->flags & SDF_DYING) { + device_unref(&sc->sc_dev); return (ENXIO); } - if ((error = sdlock(sd)) != 0) { - device_unref(&sd->sc_dev); + if ((error = sdlock(sc)) != 0) { + device_unref(&sc->sc_dev); return (error); } switch (fmt) { case S_IFCHR: - sd->sc_dk.dk_copenmask &= ~(1 << part); + sc->sc_dk.dk_copenmask &= ~(1 << part); break; case S_IFBLK: - sd->sc_dk.dk_bopenmask &= ~(1 << part); + sc->sc_dk.dk_bopenmask &= ~(1 << part); break; } - sd->sc_dk.dk_openmask = sd->sc_dk.dk_copenmask | sd->sc_dk.dk_bopenmask; + sc->sc_dk.dk_openmask = sc->sc_dk.dk_copenmask | sc->sc_dk.dk_bopenmask; - if (sd->sc_dk.dk_openmask == 0) { - if ((sd->flags & SDF_DIRTY) != 0) - sd_flush(sd, 0); + if (sc->sc_dk.dk_openmask == 0) { + if ((sc->flags & SDF_DIRTY) != 0) + sd_flush(sc, 0); - if ((sd->sc_link->flags & SDEV_REMOVABLE) != 0) - scsi_prevent(sd->sc_link, PR_ALLOW, + if ((sc->sc_link->flags & SDEV_REMOVABLE) != 0) + scsi_prevent(sc->sc_link, PR_ALLOW, SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_NOT_READY | SCSI_SILENT); - sd->sc_link->flags &= ~(SDEV_OPEN | SDEV_MEDIA_LOADED); + sc->sc_link->flags &= ~(SDEV_OPEN | SDEV_MEDIA_LOADED); - if (sd->sc_link->flags & SDEV_EJECTING) { - scsi_start(sd->sc_link, SSS_STOP|SSS_LOEJ, 0); - sd->sc_link->flags &= ~SDEV_EJECTING; + if (sc->sc_link->flags & SDEV_EJECTING) { + scsi_start(sc->sc_link, SSS_STOP|SSS_LOEJ, 0); + sc->sc_link->flags &= ~SDEV_EJECTING; } - timeout_del(&sd->sc_timeout); + timeout_del(&sc->sc_timeout); } - sdunlock(sd); - device_unref(&sd->sc_dev); + sdunlock(sc); + device_unref(&sc->sc_dev); return 0; } @@ -515,26 +515,26 @@ sdclose(dev_t dev, int flag, int fmt, struct proc *p) void sdstrategy(struct buf *bp) { - struct sd_softc *sd; + struct sd_softc *sc; int s; - sd = sdlookup(DISKUNIT(bp->b_dev)); - if (sd == NULL) { + sc = sdlookup(DISKUNIT(bp->b_dev)); + if (sc == NULL) { bp->b_error = ENXIO; goto bad; } - if (sd->flags & SDF_DYING) { + if (sc->flags & SDF_DYING) { bp->b_error = ENXIO; goto bad; } - SC_DEBUG(sd->sc_link, SDEV_DB2, ("sdstrategy: %ld bytes @ blk %d\n", + SC_DEBUG(sc->sc_link, SDEV_DB2, ("sdstrategy: %ld bytes @ blk %d\n", bp->b_bcount, bp->b_blkno)); /* * If the device has been made invalid, error out */ - if ((sd->sc_link->flags & SDEV_MEDIA_LOADED) == 0) { - if (sd->sc_link->flags & SDEV_OPEN) + if ((sc->sc_link->flags & SDEV_MEDIA_LOADED) == 0) { + if (sc->sc_link->flags & SDEV_OPEN) bp->b_error = EIO; else bp->b_error = ENODEV; @@ -549,7 +549,7 @@ sdstrategy(struct buf *bp) /* * The transfer must be a whole number of sectors. */ - if ((bp->b_bcount % sd->sc_dk.dk_label->d_secsize) != 0) { + if ((bp->b_bcount % sc->sc_dk.dk_label->d_secsize) != 0) { bp->b_error = EINVAL; goto bad; } @@ -557,24 +557,24 @@ sdstrategy(struct buf *bp) * Do bounds checking, adjust transfer. if error, process. * If end of partition, just return. */ - if (bounds_check_with_label(bp, sd->sc_dk.dk_label, - (sd->flags & (SDF_WLABEL|SDF_LABELLING)) != 0) <= 0) + if (bounds_check_with_label(bp, sc->sc_dk.dk_label, + (sc->flags & (SDF_WLABEL|SDF_LABELLING)) != 0) <= 0) goto done; /* * Place it in the queue of disk activities for this disk */ - mtx_enter(&sd->sc_buf_mtx); - disksort(&sd->sc_buf_queue, bp); - mtx_leave(&sd->sc_buf_mtx); + mtx_enter(&sc->sc_buf_mtx); + disksort(&sc->sc_buf_queue, bp); + mtx_leave(&sc->sc_buf_mtx); /* * Tell the device to get going on the transfer if it's * not doing anything, otherwise just wait for completion */ - sdstart(sd); + sdstart(sc); - device_unref(&sd->sc_dev); + device_unref(&sc->sc_dev); return; bad: @@ -587,8 +587,8 @@ done: s = splbio(); biodone(bp); splx(s); - if (sd != NULL) - device_unref(&sd->sc_dev); + if (sc != NULL) + device_unref(&sc->sc_dev); } struct buf * @@ -828,11 +828,11 @@ sd_buf_done(struct scsi_xfer *xs) void sdminphys(struct buf *bp) { - struct sd_softc *sd; + struct sd_softc *sc; long max; - sd = sdlookup(DISKUNIT(bp->b_dev)); - if (sd == NULL) + sc = sdlookup(DISKUNIT(bp->b_dev)); + if (sc == NULL) return; /* XXX - right way to fail this? */ /* @@ -846,16 +846,16 @@ sdminphys(struct buf *bp) * ancient device gets confused by length == 0. A length of 0 * in a 10-byte read/write actually means 0 blocks. */ - if (sd->flags & SDF_ANCIENT) { - max = sd->sc_dk.dk_label->d_secsize * 0xff; + if (sc->flags & SDF_ANCIENT) { + max = sc->sc_dk.dk_label->d_secsize * 0xff; if (bp->b_bcount > max) bp->b_bcount = max; } - (*sd->sc_link->adapter->scsi_minphys)(bp, sd->sc_link); + (*sc->sc_link->adapter->scsi_minphys)(bp, sc->sc_link); - device_unref(&sd->sc_dev); + device_unref(&sc->sc_dev); } int @@ -877,25 +877,25 @@ sdwrite(dev_t dev, struct uio *uio, int ioflag) int sdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) { - struct sd_softc *sd; + struct sd_softc *sc; struct disklabel *lp; int error = 0; int part = DISKPART(dev); - sd = sdlookup(DISKUNIT(dev)); - if (sd == NULL) + sc = sdlookup(DISKUNIT(dev)); + if (sc == NULL) return (ENXIO); - if (sd->flags & SDF_DYING) { - device_unref(&sd->sc_dev); + if (sc->flags & SDF_DYING) { + device_unref(&sc->sc_dev); return (ENXIO); } - SC_DEBUG(sd->sc_link, SDEV_DB2, ("sdioctl 0x%lx\n", cmd)); + SC_DEBUG(sc->sc_link, SDEV_DB2, ("sdioctl 0x%lx\n", cmd)); /* * If the device is not valid.. abandon ship */ - if ((sd->sc_link->flags & SDEV_MEDIA_LOADED) == 0) { + if ((sc->sc_link->flags & SDEV_MEDIA_LOADED) == 0) { switch (cmd) { case DIOCWLABEL: case DIOCLOCK: @@ -907,7 +907,7 @@ sdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) break; /* FALLTHROUGH */ default: - if ((sd->sc_link->flags & SDEV_OPEN) == 0) { + if ((sc->sc_link->flags & SDEV_OPEN) == 0) { error = ENODEV; goto exit; } else { @@ -920,22 +920,22 @@ sdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) switch (cmd) { case DIOCRLDINFO: lp = malloc(sizeof(*lp), M_TEMP, M_WAITOK); - sdgetdisklabel(dev, sd, lp, 0); - bcopy(lp, sd->sc_dk.dk_label, sizeof(*lp)); + sdgetdisklabel(dev, sc, lp, 0); + bcopy(lp, sc->sc_dk.dk_label, sizeof(*lp)); free(lp, M_TEMP); goto exit; case DIOCGPDINFO: - sdgetdisklabel(dev, sd, (struct disklabel *)addr, 1); + sdgetdisklabel(dev, sc, (struct disklabel *)addr, 1); goto exit; case DIOCGDINFO: - *(struct disklabel *)addr = *(sd->sc_dk.dk_label); + *(struct disklabel *)addr = *(sc->sc_dk.dk_label); goto exit; case DIOCGPART: - ((struct partinfo *)addr)->disklab = sd->sc_dk.dk_label; + ((struct partinfo *)addr)->disklab = sc->sc_dk.dk_label; ((struct partinfo *)addr)->part = - &sd->sc_dk.dk_label->d_partitions[DISKPART(dev)]; + &sc->sc_dk.dk_label->d_partitions[DISKPART(dev)]; goto exit; case DIOCWDINFO: @@ -945,20 +945,20 @@ sdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) goto exit; } - if ((error = sdlock(sd)) != 0) + if ((error = sdlock(sc)) != 0) goto exit; - sd->flags |= SDF_LABELLING; + sc->flags |= SDF_LABELLING; - error = setdisklabel(sd->sc_dk.dk_label, + error = setdisklabel(sc->sc_dk.dk_label, (struct disklabel *)addr, /*sd->sc_dk.dk_openmask : */0); if (error == 0) { if (cmd == DIOCWDINFO) error = writedisklabel(DISKLABELDEV(dev), - sdstrategy, sd->sc_dk.dk_label); + sdstrategy, sc->sc_dk.dk_label); } - sd->flags &= ~SDF_LABELLING; - sdunlock(sd); + sc->flags &= ~SDF_LABELLING; + sdunlock(sc); goto exit; case DIOCWLABEL: @@ -967,13 +967,13 @@ sdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) goto exit; } if (*(int *)addr) - sd->flags |= SDF_WLABEL; + sc->flags |= SDF_WLABEL; else - sd->flags &= ~SDF_WLABEL; + sc->flags &= ~SDF_WLABEL; goto exit; case DIOCLOCK: - error = scsi_prevent(sd->sc_link, + error = scsi_prevent(sc->sc_link, (*(int *)addr) ? PR_PREVENT : PR_ALLOW, 0); goto exit; @@ -984,17 +984,17 @@ sdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) } /* FALLTHROUGH */ case DIOCEJECT: - if ((sd->sc_link->flags & SDEV_REMOVABLE) == 0) { + if ((sc->sc_link->flags & SDEV_REMOVABLE) == 0) { error = ENOTTY; goto exit; } - sd->sc_link->flags |= SDEV_EJECTING; + sc->sc_link->flags |= SDEV_EJECTING; goto exit; case DIOCINQ: - error = scsi_do_ioctl(sd->sc_link, dev, cmd, addr, flag, p); + error = scsi_do_ioctl(sc->sc_link, dev, cmd, addr, flag, p); if (error == ENOTTY) - error = sd_ioctl_inquiry(sd, + error = sd_ioctl_inquiry(sc, (struct dk_inquiry *)addr); goto exit; @@ -1003,29 +1003,29 @@ sdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) error = ENOTTY; goto exit; } - error = scsi_do_ioctl(sd->sc_link, dev, cmd, addr, flag, p); + error = scsi_do_ioctl(sc->sc_link, dev, cmd, addr, flag, p); } exit: - device_unref(&sd->sc_dev); + device_unref(&sc->sc_dev); return (error); } int -sd_ioctl_inquiry(struct sd_softc *sd, struct dk_inquiry *di) +sd_ioctl_inquiry(struct sd_softc *sc, struct dk_inquiry *di) { struct scsi_vpd_serial vpd; bzero(di, sizeof(struct dk_inquiry)); - scsi_strvis(di->vendor, sd->sc_link->inqdata.vendor, - sizeof(sd->sc_link->inqdata.vendor)); - scsi_strvis(di->product, sd->sc_link->inqdata.product, - sizeof(sd->sc_link->inqdata.product)); - scsi_strvis(di->revision, sd->sc_link->inqdata.revision, - sizeof(sd->sc_link->inqdata.revision)); + scsi_strvis(di->vendor, sc->sc_link->inqdata.vendor, + sizeof(sc->sc_link->inqdata.vendor)); + scsi_strvis(di->product, sc->sc_link->inqdata.product, + sizeof(sc->sc_link->inqdata.product)); + scsi_strvis(di->revision, sc->sc_link->inqdata.revision, + sizeof(sc->sc_link->inqdata.revision)); /* the serial vpd page is optional */ - if (scsi_inquire_vpd(sd->sc_link, &vpd, sizeof(vpd), + if (scsi_inquire_vpd(sc->sc_link, &vpd, sizeof(vpd), SI_PG_SERIAL, 0) == 0) scsi_strvis(di->serial, vpd.serial, sizeof(vpd.serial)); else @@ -1038,7 +1038,7 @@ sd_ioctl_inquiry(struct sd_softc *sd, struct dk_inquiry *di) * Load the label information on the named device */ int -sdgetdisklabel(dev_t dev, struct sd_softc *sd, struct disklabel *lp, +sdgetdisklabel(dev_t dev, struct sd_softc *sc, struct disklabel *lp, int spoofonly) { size_t len; @@ -1047,10 +1047,10 @@ sdgetdisklabel(dev_t dev, struct sd_softc *sd, struct disklabel *lp, bzero(lp, sizeof(struct disklabel)); - lp->d_secsize = sd->params.blksize; - lp->d_ntracks = sd->params.heads; - lp->d_nsectors = sd->params.sectors; - lp->d_ncylinders = sd->params.cyls; + lp->d_secsize = sc->params.blksize; + lp->d_ntracks = sc->params.heads; + lp->d_nsectors = sc->params.sectors; + lp->d_ncylinders = sc->params.cyls; lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors; if (lp->d_secpercyl == 0) { lp->d_secpercyl = 100; @@ -1058,7 +1058,7 @@ sdgetdisklabel(dev_t dev, struct sd_softc *sd, struct disklabel *lp, } lp->d_type = DTYPE_SCSI; - if ((sd->sc_link->inqdata.device & SID_TYPE) == T_OPTICAL) + if ((sc->sc_link->inqdata.device & SID_TYPE) == T_OPTICAL) strncpy(lp->d_typename, "SCSI optical", sizeof(lp->d_typename)); else @@ -1070,8 +1070,8 @@ sdgetdisklabel(dev_t dev, struct sd_softc *sd, struct disklabel *lp, * then leave out '<vendor> ' and use only as much of '<product>' as * does fit. */ - viscpy(vendor, sd->sc_link->inqdata.vendor, 8); - viscpy(product, sd->sc_link->inqdata.product, 16); + viscpy(vendor, sc->sc_link->inqdata.vendor, 8); + viscpy(product, sc->sc_link->inqdata.product, 16); len = snprintf(packname, sizeof(packname), "%s %s", vendor, product); if (len > sizeof(lp->d_packname)) { strlcpy(packname, product, sizeof(packname)); @@ -1085,8 +1085,8 @@ sdgetdisklabel(dev_t dev, struct sd_softc *sd, struct disklabel *lp, */ bcopy(packname, lp->d_packname, len); - DL_SETDSIZE(lp, sd->params.disksize); - lp->d_rpm = sd->params.rot_rate; + DL_SETDSIZE(lp, sc->params.disksize); + lp->d_rpm = sc->params.rot_rate; lp->d_interleave = 1; lp->d_version = 1; lp->d_flags = 0; @@ -1109,17 +1109,17 @@ sdgetdisklabel(dev_t dev, struct sd_softc *sd, struct disklabel *lp, void sd_shutdown(void *arg) { - struct sd_softc *sd = (struct sd_softc *)arg; + struct sd_softc *sc = (struct sd_softc *)arg; /* * If the disk cache needs to be flushed, and the disk supports * it, flush it. We're cold at this point, so we poll for * completion. */ - if ((sd->flags & SDF_DIRTY) != 0) - sd_flush(sd, SCSI_AUTOCONF); + if ((sc->flags & SDF_DIRTY) != 0) + sd_flush(sc, SCSI_AUTOCONF); - timeout_del(&sd->sc_timeout); + timeout_del(&sc->sc_timeout); } /* @@ -1130,7 +1130,7 @@ sd_interpret_sense(struct scsi_xfer *xs) { struct scsi_sense_data *sense = &xs->sense; struct scsi_link *sc_link = xs->sc_link; - struct sd_softc *sd = sc_link->device_softc; + struct sd_softc *sc = sc_link->device_softc; u_int8_t serr = sense->error_code & SSD_ERRCODE; int retval; @@ -1152,7 +1152,7 @@ sd_interpret_sense(struct scsi_xfer *xs) case SENSE_NOT_READY_INIT_REQUIRED: SC_DEBUG(sc_link, SDEV_DB1, ("spinning up\n")); - retval = scsi_start(sd->sc_link, SSS_START, + retval = scsi_start(sc->sc_link, SSS_START, SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_URGENT | SCSI_NOSLEEP); if (retval == 0) retval = ERESTART; @@ -1172,37 +1172,37 @@ sd_interpret_sense(struct scsi_xfer *xs) daddr64_t sdsize(dev_t dev) { - struct sd_softc *sd; + struct sd_softc *sc; int part, omask; int64_t size; - sd = sdlookup(DISKUNIT(dev)); - if (sd == NULL) + sc = sdlookup(DISKUNIT(dev)); + if (sc == NULL) return -1; - if (sd->flags & SDF_DYING) { + if (sc->flags & SDF_DYING) { size = -1; goto exit; } part = DISKPART(dev); - omask = sd->sc_dk.dk_openmask & (1 << part); + omask = sc->sc_dk.dk_openmask & (1 << part); if (omask == 0 && sdopen(dev, 0, S_IFBLK, NULL) != 0) { size = -1; goto exit; } - if ((sd->sc_link->flags & SDEV_MEDIA_LOADED) == 0) + if ((sc->sc_link->flags & SDEV_MEDIA_LOADED) == 0) size = -1; - else if (sd->sc_dk.dk_label->d_partitions[part].p_fstype != FS_SWAP) + else if (sc->sc_dk.dk_label->d_partitions[part].p_fstype != FS_SWAP) size = -1; else - size = DL_GETPSIZE(&sd->sc_dk.dk_label->d_partitions[part]) * - (sd->sc_dk.dk_label->d_secsize / DEV_BSIZE); + size = DL_GETPSIZE(&sc->sc_dk.dk_label->d_partitions[part]) * + (sc->sc_dk.dk_label->d_secsize / DEV_BSIZE); if (omask == 0 && sdclose(dev, 0, S_IFBLK, NULL) != 0) size = -1; exit: - device_unref(&sd->sc_dev); + device_unref(&sc->sc_dev); return size; } @@ -1331,7 +1331,7 @@ viscpy(u_char *dst, u_char *src, int len) * cannot be completed. */ int -sd_get_parms(struct sd_softc *sd, struct disk_parms *dp, int flags) +sd_get_parms(struct sd_softc *sc, struct disk_parms *dp, int flags) { union scsi_mode_sense_buf *buf = NULL; struct page_rigid_geometry *rigid; @@ -1340,28 +1340,28 @@ sd_get_parms(struct sd_softc *sd, struct disk_parms *dp, int flags) u_int32_t heads = 0, sectors = 0, cyls = 0, blksize = 0, ssblksize; u_int16_t rpm = 0; - dp->disksize = scsi_size(sd->sc_link, flags, &ssblksize); + dp->disksize = scsi_size(sc->sc_link, flags, &ssblksize); /* * Many UMASS devices choke when asked about their geometry. Most * don't have a meaningful geometry anyway, so just fake it if * scsi_size() worked. */ - if ((sd->sc_link->flags & SDEV_UMASS) && (dp->disksize > 0)) + if ((sc->sc_link->flags & SDEV_UMASS) && (dp->disksize > 0)) goto validate; /* N.B. buf will be NULL at validate. */ buf = malloc(sizeof(*buf), M_TEMP, M_NOWAIT); if (buf == NULL) goto validate; - switch (sd->sc_link->inqdata.device & SID_TYPE) { + switch (sc->sc_link->inqdata.device & SID_TYPE) { case T_OPTICAL: /* No more information needed or available. */ break; case T_RDIRECT: /* T_RDIRECT supports only PAGE_REDUCED_GEOMETRY (6). */ - scsi_do_mode_sense(sd->sc_link, PAGE_REDUCED_GEOMETRY, buf, + scsi_do_mode_sense(sc->sc_link, PAGE_REDUCED_GEOMETRY, buf, (void **)&reduced, NULL, NULL, &blksize, sizeof(*reduced), flags | SCSI_SILENT, NULL); if (DISK_PGCODE(reduced, PAGE_REDUCED_GEOMETRY)) { @@ -1381,9 +1381,9 @@ sd_get_parms(struct sd_softc *sd, struct disk_parms *dp, int flags) * end up with the default value of 3600. */ rigid = NULL; - if (((sd->sc_link->flags & SDEV_ATAPI) == 0) || - ((sd->sc_link->flags & SDEV_REMOVABLE) == 0)) - scsi_do_mode_sense(sd->sc_link, PAGE_RIGID_GEOMETRY, + if (((sc->sc_link->flags & SDEV_ATAPI) == 0) || + ((sc->sc_link->flags & SDEV_REMOVABLE) == 0)) + scsi_do_mode_sense(sc->sc_link, PAGE_RIGID_GEOMETRY, buf, (void **)&rigid, NULL, NULL, &blksize, sizeof(*rigid) - 4, flags | SCSI_SILENT, NULL); if (DISK_PGCODE(rigid, PAGE_RIGID_GEOMETRY)) { @@ -1393,7 +1393,7 @@ sd_get_parms(struct sd_softc *sd, struct disk_parms *dp, int flags) if (heads * cyls > 0) sectors = dp->disksize / (heads * cyls); } else { - scsi_do_mode_sense(sd->sc_link, PAGE_FLEX_GEOMETRY, + scsi_do_mode_sense(sc->sc_link, PAGE_FLEX_GEOMETRY, buf, (void **)&flex, NULL, NULL, &blksize, sizeof(*flex) - 4, flags | SCSI_SILENT, NULL); if (DISK_PGCODE(flex, PAGE_FLEX_GEOMETRY)) { @@ -1436,7 +1436,7 @@ validate: case 0x10000: break; default: - SC_DEBUG(sd->sc_link, SDEV_DB1, + SC_DEBUG(sc->sc_link, SDEV_DB1, ("sd_get_parms: bad blksize: %#x\n", dp->blksize)); return (SDGP_RESULT_OFFLINE); } @@ -1531,12 +1531,12 @@ sd_flush_done(struct scsi_xfer *xs) * Remove unprocessed buffers from queue. */ void -sd_kill_buffers(struct sd_softc *sd) +sd_kill_buffers(struct sd_softc *sc) { struct buf *bp; int s; - while ((bp = sd_buf_dequeue(sd)) != NULL) { + while ((bp = sd_buf_dequeue(sc)) != NULL) { bp->b_error = ENXIO; bp->b_flags |= B_ERROR; s = splbio(); |