summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2009-12-13 01:20:15 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2009-12-13 01:20:15 +0000
commit3f78e35c9177f1ff7dad54328d18e623527959be (patch)
treeda142890c2a6468c354fd537b76196d82b43e7a4
parent8917aa45d9a866e3a908b2afc7542f53b78550e1 (diff)
use sc consistently as the name of the pointer to the softc variable, not
cd.
-rw-r--r--sys/scsi/cd.c482
1 files changed, 241 insertions, 241 deletions
diff --git a/sys/scsi/cd.c b/sys/scsi/cd.c
index 82e0ed36073..0fe5eb62db6 100644
--- a/sys/scsi/cd.c
+++ b/sys/scsi/cd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cd.c,v 1.154 2009/12/12 13:03:56 dlg Exp $ */
+/* $OpenBSD: cd.c,v 1.155 2009/12/13 01:20:14 dlg Exp $ */
/* $NetBSD: cd.c,v 1.100 1997/04/02 02:29:30 mycroft Exp $ */
/*
@@ -186,45 +186,45 @@ cdmatch(struct device *parent, void *match, void *aux)
void
cdattach(struct device *parent, struct device *self, void *aux)
{
+ struct cd_softc *sc = (struct cd_softc *)self;
struct scsi_attach_args *sa = aux;
struct scsi_link *sc_link = sa->sa_sc_link;
- struct cd_softc *cd = (struct cd_softc *)self;
SC_DEBUG(sc_link, SDEV_DB2, ("cdattach:\n"));
- mtx_init(&cd->sc_queue_mtx, IPL_BIO);
- mtx_init(&cd->sc_start_mtx, IPL_BIO);
+ mtx_init(&sc->sc_queue_mtx, IPL_BIO);
+ mtx_init(&sc->sc_start_mtx, IPL_BIO);
/*
* Store information needed to contact our base driver
*/
- cd->sc_link = sc_link;
+ sc->sc_link = sc_link;
sc_link->device = &cd_switch;
- sc_link->device_softc = cd;
+ sc_link->device_softc = sc;
if (sc_link->openings > CDOUTSTANDING)
sc_link->openings = CDOUTSTANDING;
/*
* Initialize and attach the disk structure.
*/
- cd->sc_dk.dk_driver = &cddkdriver;
- cd->sc_dk.dk_name = cd->sc_dev.dv_xname;
- disk_attach(&cd->sc_dk);
+ sc->sc_dk.dk_driver = &cddkdriver;
+ sc->sc_dk.dk_name = sc->sc_dev.dv_xname;
+ disk_attach(&sc->sc_dk);
/*
* Note if this device is ancient. This is used in cdminphys().
*/
if (!(sc_link->flags & SDEV_ATAPI) &&
SCSISPC(sa->sa_inqbuf->version) == 0)
- cd->flags |= CDF_ANCIENT;
+ sc->flags |= CDF_ANCIENT;
printf("\n");
- timeout_set(&cd->sc_timeout, cdstart, cd);
+ timeout_set(&sc->sc_timeout, cdstart, sc);
- if ((cd->sc_cdpwrhook = powerhook_establish(cd_powerhook, cd)) == NULL)
+ if ((sc->sc_cdpwrhook = powerhook_establish(cd_powerhook, sc)) == NULL)
printf("%s: WARNING: unable to establish power hook\n",
- cd->sc_dev.dv_xname);
+ sc->sc_dev.dv_xname);
}
@@ -250,10 +250,10 @@ cdactivate(struct device *self, int act)
int
cddetach(struct device *self, int flags)
{
- struct cd_softc *cd = (struct cd_softc *)self;
+ struct cd_softc *sc = (struct cd_softc *)self;
int bmaj, cmaj, mn;
- cd_kill_buffers(cd);
+ cd_kill_buffers(sc);
/* Locate the lowest minor number to be detached. */
mn = DISKMINOR(self->dv_unit, 0);
@@ -266,11 +266,11 @@ cddetach(struct device *self, int flags)
vdevgone(cmaj, mn, mn + MAXPARTITIONS - 1, VCHR);
/* Get rid of the power hook. */
- if (cd->sc_cdpwrhook != NULL)
- powerhook_disestablish(cd->sc_cdpwrhook);
+ if (sc->sc_cdpwrhook != NULL)
+ powerhook_disestablish(sc->sc_cdpwrhook);
/* Detach disk. */
- disk_detach(&cd->sc_dk);
+ disk_detach(&sc->sc_dk);
return (0);
}
@@ -282,7 +282,7 @@ int
cdopen(dev_t dev, int flag, int fmt, struct proc *p)
{
struct scsi_link *sc_link;
- struct cd_softc *cd;
+ struct cd_softc *sc;
int error = 0, part, rawopen, unit;
unit = DISKUNIT(dev);
@@ -290,21 +290,21 @@ cdopen(dev_t dev, int flag, int fmt, struct proc *p)
rawopen = (part == RAW_PART) && (fmt == S_IFCHR);
- cd = cdlookup(unit);
- if (cd == NULL)
+ sc = cdlookup(unit);
+ if (sc == NULL)
return (ENXIO);
- sc_link = cd->sc_link;
+ sc_link = sc->sc_link;
SC_DEBUG(sc_link, SDEV_DB1,
("cdopen: dev=0x%x (unit %d (of %d), partition %d)\n", dev, unit,
cd_cd.cd_ndevs, part));
- if ((error = cdlock(cd)) != 0) {
- device_unref(&cd->sc_dev);
+ if ((error = cdlock(sc)) != 0) {
+ device_unref(&sc->sc_dev);
return (error);
}
- if (cd->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.
@@ -352,7 +352,7 @@ cdopen(dev_t dev, int flag, int fmt, struct proc *p)
/* Load the physical device parameters. */
sc_link->flags |= SDEV_MEDIA_LOADED;
- if (cd_get_parms(cd, (rawopen ? SCSI_SILENT : 0) |
+ if (cd_get_parms(sc, (rawopen ? SCSI_SILENT : 0) |
SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_MEDIA_CHANGE)) {
sc_link->flags &= ~SDEV_MEDIA_LOADED;
error = ENXIO;
@@ -361,13 +361,13 @@ cdopen(dev_t dev, int flag, int fmt, struct proc *p)
SC_DEBUG(sc_link, SDEV_DB3, ("Params loaded\n"));
/* Fabricate a disk label. */
- cdgetdisklabel(dev, cd, cd->sc_dk.dk_label, 0);
+ cdgetdisklabel(dev, sc, sc->sc_dk.dk_label, 0);
SC_DEBUG(sc_link, SDEV_DB3, ("Disklabel fabricated\n"));
}
/* Check that the partition exists. */
- if (part != RAW_PART && (part >= cd->sc_dk.dk_label->d_npartitions ||
- cd->sc_dk.dk_label->d_partitions[part].p_fstype == FS_UNUSED)) {
+ if (part != RAW_PART && (part >= sc->sc_dk.dk_label->d_npartitions ||
+ sc->sc_dk.dk_label->d_partitions[part].p_fstype == FS_UNUSED)) {
error = ENXIO;
goto bad;
}
@@ -375,27 +375,27 @@ cdopen(dev_t dev, int flag, int fmt, struct proc *p)
out: /* Insure only one open at a time. */
switch (fmt) {
case S_IFCHR:
- cd->sc_dk.dk_copenmask |= (1 << part);
+ sc->sc_dk.dk_copenmask |= (1 << part);
break;
case S_IFBLK:
- cd->sc_dk.dk_bopenmask |= (1 << part);
+ sc->sc_dk.dk_bopenmask |= (1 << part);
break;
}
- cd->sc_dk.dk_openmask = cd->sc_dk.dk_copenmask | cd->sc_dk.dk_bopenmask;
+ sc->sc_dk.dk_openmask = sc->sc_dk.dk_copenmask | sc->sc_dk.dk_bopenmask;
sc_link->flags |= SDEV_OPEN;
SC_DEBUG(sc_link, SDEV_DB3, ("open complete\n"));
/* It's OK to fall through because dk_openmask is now non-zero. */
bad:
- if (cd->sc_dk.dk_openmask == 0) {
+ if (sc->sc_dk.dk_openmask == 0) {
scsi_prevent(sc_link, PR_ALLOW,
SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_MEDIA_CHANGE |
SCSI_SILENT);
sc_link->flags &= ~(SDEV_OPEN | SDEV_MEDIA_LOADED);
}
- cdunlock(cd);
- device_unref(&cd->sc_dev);
+ cdunlock(sc);
+ device_unref(&sc->sc_dev);
return (error);
}
@@ -406,49 +406,49 @@ bad:
int
cdclose(dev_t dev, int flag, int fmt, struct proc *p)
{
- struct cd_softc *cd;
+ struct cd_softc *sc;
int part = DISKPART(dev);
int error;
- cd = cdlookup(DISKUNIT(dev));
- if (cd == NULL)
+ sc = cdlookup(DISKUNIT(dev));
+ if (sc == NULL)
return ENXIO;
- if ((error = cdlock(cd)) != 0) {
- device_unref(&cd->sc_dev);
+ if ((error = cdlock(sc)) != 0) {
+ device_unref(&sc->sc_dev);
return error;
}
switch (fmt) {
case S_IFCHR:
- cd->sc_dk.dk_copenmask &= ~(1 << part);
+ sc->sc_dk.dk_copenmask &= ~(1 << part);
break;
case S_IFBLK:
- cd->sc_dk.dk_bopenmask &= ~(1 << part);
+ sc->sc_dk.dk_bopenmask &= ~(1 << part);
break;
}
- cd->sc_dk.dk_openmask = cd->sc_dk.dk_copenmask | cd->sc_dk.dk_bopenmask;
+ sc->sc_dk.dk_openmask = sc->sc_dk.dk_copenmask | sc->sc_dk.dk_bopenmask;
- if (cd->sc_dk.dk_openmask == 0) {
+ if (sc->sc_dk.dk_openmask == 0) {
/* XXXX Must wait for I/O to complete! */
- scsi_prevent(cd->sc_link, PR_ALLOW,
+ scsi_prevent(sc->sc_link, PR_ALLOW,
SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_NOT_READY |
SCSI_SILENT);
- cd->sc_link->flags &= ~(SDEV_OPEN | SDEV_MEDIA_LOADED);
+ sc->sc_link->flags &= ~(SDEV_OPEN | SDEV_MEDIA_LOADED);
- if (cd->sc_link->flags & SDEV_EJECTING) {
- scsi_start(cd->sc_link, SSS_STOP|SSS_LOEJ, 0);
+ if (sc->sc_link->flags & SDEV_EJECTING) {
+ scsi_start(sc->sc_link, SSS_STOP|SSS_LOEJ, 0);
- cd->sc_link->flags &= ~SDEV_EJECTING;
+ sc->sc_link->flags &= ~SDEV_EJECTING;
}
- timeout_del(&cd->sc_timeout);
+ timeout_del(&sc->sc_timeout);
}
- cdunlock(cd);
+ cdunlock(sc);
- device_unref(&cd->sc_dev);
+ device_unref(&sc->sc_dev);
return 0;
}
@@ -460,28 +460,28 @@ cdclose(dev_t dev, int flag, int fmt, struct proc *p)
void
cdstrategy(struct buf *bp)
{
- struct cd_softc *cd;
+ struct cd_softc *sc;
int s;
- if ((cd = cdlookup(DISKUNIT(bp->b_dev))) == NULL) {
+ if ((sc = cdlookup(DISKUNIT(bp->b_dev))) == NULL) {
bp->b_error = ENXIO;
goto bad;
}
- SC_DEBUG(cd->sc_link, SDEV_DB2, ("cdstrategy: %ld bytes @ blk %d\n",
+ SC_DEBUG(sc->sc_link, SDEV_DB2, ("cdstrategy: %ld bytes @ blk %d\n",
bp->b_bcount, bp->b_blkno));
/*
* If the device has been made invalid, error out
* maybe the media changed, or no media loaded
*/
- if ((cd->sc_link->flags & SDEV_MEDIA_LOADED) == 0) {
+ if ((sc->sc_link->flags & SDEV_MEDIA_LOADED) == 0) {
bp->b_error = EIO;
goto bad;
}
/*
* The transfer must be a whole number of blocks.
*/
- if ((bp->b_bcount % cd->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;
}
@@ -495,24 +495,24 @@ cdstrategy(struct buf *bp)
* Do bounds checking, adjust transfer. if error, process.
* If end of partition, just return.
*/
- if (bounds_check_with_label(bp, cd->sc_dk.dk_label,
- (cd->flags & (CDF_WLABEL|CDF_LABELLING)) != 0) <= 0)
+ if (bounds_check_with_label(bp, sc->sc_dk.dk_label,
+ (sc->flags & (CDF_WLABEL|CDF_LABELLING)) != 0) <= 0)
goto done;
/*
* Place it in the queue of disk activities for this disk
*/
- mtx_enter(&cd->sc_queue_mtx);
- disksort(&cd->buf_queue, bp);
- mtx_leave(&cd->sc_queue_mtx);
+ mtx_enter(&sc->sc_queue_mtx);
+ disksort(&sc->buf_queue, bp);
+ mtx_leave(&sc->sc_queue_mtx);
/*
* Tell the device to get going on the transfer if it's
* not doing anything, otherwise just wait for completion
*/
- cdstart(cd);
+ cdstart(sc);
- device_unref(&cd->sc_dev);
+ device_unref(&sc->sc_dev);
return;
bad:
@@ -525,8 +525,8 @@ done:
s = splbio();
biodone(bp);
splx(s);
- if (cd != NULL)
- device_unref(&cd->sc_dev);
+ if (sc != NULL)
+ device_unref(&sc->sc_dev);
}
struct buf *
@@ -571,8 +571,8 @@ cd_buf_requeue(struct cd_softc *sc, struct buf *bp)
void
cdstart(void *v)
{
- struct cd_softc *cd = v;
- struct scsi_link *sc_link = cd->sc_link;
+ struct cd_softc *sc = v;
+ struct scsi_link *sc_link = sc->sc_link;
struct buf *bp;
struct scsi_rw_big *cmd_big;
struct scsi_rw *cmd_small;
@@ -587,18 +587,18 @@ cdstart(void *v)
* Check if the device has room for another command
*/
- mtx_enter(&cd->sc_start_mtx);
- if (ISSET(cd->flags, CDF_STARTING)) {
- mtx_leave(&cd->sc_start_mtx);
+ mtx_enter(&sc->sc_start_mtx);
+ if (ISSET(sc->flags, CDF_STARTING)) {
+ mtx_leave(&sc->sc_start_mtx);
return;
}
- SET(cd->flags, CDF_STARTING);
- mtx_leave(&cd->sc_start_mtx);
+ SET(sc->flags, CDF_STARTING);
+ mtx_leave(&sc->sc_start_mtx);
- CLR(cd->flags, CDF_WAITING);
- while (!ISSET(cd->flags, CDF_WAITING) &&
- (bp = cd_buf_dequeue(cd)) != NULL) {
+ CLR(sc->flags, CDF_WAITING);
+ while (!ISSET(sc->flags, CDF_WAITING) &&
+ (bp = cd_buf_dequeue(sc)) != NULL) {
/*
* If the device has become invalid, abort all the
@@ -617,7 +617,7 @@ cdstart(void *v)
xs = scsi_xs_get(sc_link, SCSI_NOSLEEP);
if (xs == NULL) {
- cd_buf_requeue(cd, bp);
+ cd_buf_requeue(sc, bp);
break;
}
@@ -628,10 +628,10 @@ cdstart(void *v)
* of the logical blocksize of the device.
*/
blkno =
- bp->b_blkno / (cd->sc_dk.dk_label->d_secsize / DEV_BSIZE);
- p = &cd->sc_dk.dk_label->d_partitions[DISKPART(bp->b_dev)];
+ bp->b_blkno / (sc->sc_dk.dk_label->d_secsize / DEV_BSIZE);
+ p = &sc->sc_dk.dk_label->d_partitions[DISKPART(bp->b_dev)];
blkno += DL_GETPOFFSET(p);
- nblks = howmany(bp->b_bcount, cd->sc_dk.dk_label->d_secsize);
+ nblks = howmany(bp->b_bcount, sc->sc_dk.dk_label->d_secsize);
read = (bp->b_flags & B_READ);
@@ -672,13 +672,13 @@ cdstart(void *v)
xs->cookie = bp;
/* Instrumentation. */
- disk_busy(&cd->sc_dk);
+ disk_busy(&sc->sc_dk);
scsi_xs_exec(xs);
}
- mtx_enter(&cd->sc_start_mtx);
- CLR(cd->flags, CDF_STARTING);
- mtx_leave(&cd->sc_start_mtx);
+ mtx_enter(&sc->sc_start_mtx);
+ CLR(sc->flags, CDF_STARTING);
+ mtx_leave(&sc->sc_start_mtx);
}
void
@@ -737,11 +737,11 @@ cd_buf_done(struct scsi_xfer *xs)
void
cdminphys(struct buf *bp)
{
- struct cd_softc *cd;
+ struct cd_softc *sc;
long max;
- cd = cdlookup(DISKUNIT(bp->b_dev));
- if (cd == NULL)
+ sc = cdlookup(DISKUNIT(bp->b_dev));
+ if (sc == NULL)
return;
/*
@@ -755,16 +755,16 @@ cdminphys(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 (cd->flags & CDF_ANCIENT) {
- max = cd->sc_dk.dk_label->d_secsize * 0xff;
+ if (sc->flags & CDF_ANCIENT) {
+ max = sc->sc_dk.dk_label->d_secsize * 0xff;
if (bp->b_bcount > max)
bp->b_bcount = max;
}
- (*cd->sc_link->adapter->scsi_minphys)(bp, cd->sc_link);
+ (*sc->sc_link->adapter->scsi_minphys)(bp, sc->sc_link);
- device_unref(&cd->sc_dev);
+ device_unref(&sc->sc_dev);
}
int
@@ -788,21 +788,21 @@ cdwrite(dev_t dev, struct uio *uio, int ioflag)
int
cdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
{
- struct cd_softc *cd;
+ struct cd_softc *sc;
struct disklabel *lp;
int part = DISKPART(dev);
int error = 0;
- cd = cdlookup(DISKUNIT(dev));
- if (cd == NULL)
+ sc = cdlookup(DISKUNIT(dev));
+ if (sc == NULL)
return ENXIO;
- SC_DEBUG(cd->sc_link, SDEV_DB2, ("cdioctl 0x%lx\n", cmd));
+ SC_DEBUG(sc->sc_link, SDEV_DB2, ("cdioctl 0x%lx\n", cmd));
/*
* If the device is not valid.. abandon ship
*/
- if ((cd->sc_link->flags & SDEV_MEDIA_LOADED) == 0) {
+ if ((sc->sc_link->flags & SDEV_MEDIA_LOADED) == 0) {
switch (cmd) {
case DIOCWLABEL:
case DIOCLOCK:
@@ -833,7 +833,7 @@ cdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
break;
/* FALLTHROUGH */
default:
- if ((cd->sc_link->flags & SDEV_OPEN) == 0)
+ if ((sc->sc_link->flags & SDEV_OPEN) == 0)
error = ENODEV;
else
error = EIO;
@@ -844,19 +844,19 @@ cdioctl(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);
- cdgetdisklabel(dev, cd, lp, 0);
- bcopy(lp, cd->sc_dk.dk_label, sizeof(*lp));
+ cdgetdisklabel(dev, sc, lp, 0);
+ bcopy(lp, sc->sc_dk.dk_label, sizeof(*lp));
free(lp, M_TEMP);
break;
case DIOCGDINFO:
case DIOCGPDINFO:
- *(struct disklabel *)addr = *(cd->sc_dk.dk_label);
+ *(struct disklabel *)addr = *(sc->sc_dk.dk_label);
break;
case DIOCGPART:
- ((struct partinfo *)addr)->disklab = cd->sc_dk.dk_label;
+ ((struct partinfo *)addr)->disklab = sc->sc_dk.dk_label;
((struct partinfo *)addr)->part =
- &cd->sc_dk.dk_label->d_partitions[DISKPART(dev)];
+ &sc->sc_dk.dk_label->d_partitions[DISKPART(dev)];
break;
case DIOCWDINFO:
@@ -866,18 +866,18 @@ cdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
break;
}
- if ((error = cdlock(cd)) != 0)
+ if ((error = cdlock(sc)) != 0)
break;
- cd->flags |= CDF_LABELLING;
+ sc->flags |= CDF_LABELLING;
- error = setdisklabel(cd->sc_dk.dk_label,
+ error = setdisklabel(sc->sc_dk.dk_label,
(struct disklabel *)addr, /*cd->sc_dk.dk_openmask : */0);
if (error == 0) {
}
- cd->flags &= ~CDF_LABELLING;
- cdunlock(cd);
+ sc->flags &= ~CDF_LABELLING;
+ cdunlock(sc);
break;
case DIOCWLABEL:
@@ -887,27 +887,27 @@ cdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
case CDIOCPLAYTRACKS: {
struct ioc_play_track *args = (struct ioc_play_track *)addr;
- if ((error = cd_set_pa_immed(cd, 0)) != 0)
+ if ((error = cd_set_pa_immed(sc, 0)) != 0)
break;
- error = cd_play_tracks(cd, args->start_track,
+ error = cd_play_tracks(sc, args->start_track,
args->start_index, args->end_track, args->end_index);
break;
}
case CDIOCPLAYMSF: {
struct ioc_play_msf *args = (struct ioc_play_msf *)addr;
- if ((error = cd_set_pa_immed(cd, 0)) != 0)
+ if ((error = cd_set_pa_immed(sc, 0)) != 0)
break;
- error = cd_play_msf(cd, args->start_m, args->start_s,
+ error = cd_play_msf(sc, args->start_m, args->start_s,
args->start_f, args->end_m, args->end_s, args->end_f);
break;
}
case CDIOCPLAYBLOCKS: {
struct ioc_play_blocks *args = (struct ioc_play_blocks *)addr;
- if ((error = cd_set_pa_immed(cd, 0)) != 0)
+ if ((error = cd_set_pa_immed(sc, 0)) != 0)
break;
- error = cd_play(cd, args->blk, args->len);
+ error = cd_play(sc, args->blk, args->len);
break;
}
case CDIOCREADSUBCHANNEL: {
@@ -920,7 +920,7 @@ cdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
error = EINVAL;
break;
}
- error = cd_read_subchannel(cd, args->address_format,
+ error = cd_read_subchannel(sc, args->address_format,
args->data_format, args->track, &data, len);
if (error)
break;
@@ -932,9 +932,9 @@ cdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
case CDIOREADTOCHEADER: {
struct ioc_toc_header th;
- if ((error = cd_read_toc(cd, 0, 0, &th, sizeof(th), 0)) != 0)
+ if ((error = cd_read_toc(sc, 0, 0, &th, sizeof(th), 0)) != 0)
break;
- if (cd->sc_link->quirks & ADEV_LITTLETOC)
+ if (sc->sc_link->quirks & ADEV_LITTLETOC)
th.len = letoh16(th.len);
else
th.len = betoh16(th.len);
@@ -960,7 +960,7 @@ cdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
error = EINVAL;
break;
}
- error = cd_read_toc(cd, te->address_format, te->starting_track,
+ error = cd_read_toc(sc, te->address_format, te->starting_track,
toc, len + sizeof(struct ioc_toc_header), 0);
if (error) {
free(toc, M_TEMP);
@@ -972,7 +972,7 @@ cdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
ntracks >= 0; ntracks--) {
cte = &toc->entries[ntracks];
cte->addr_type = CD_LBA_FORMAT;
- if (cd->sc_link->quirks & ADEV_LITTLETOC) {
+ if (sc->sc_link->quirks & ADEV_LITTLETOC) {
#if BYTE_ORDER == BIG_ENDIAN
swap16_multi((u_int16_t *)&cte->addr,
sizeof(cte->addr) / 2);
@@ -980,7 +980,7 @@ cdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
} else
cte->addr.lba = betoh32(cte->addr.lba);
}
- if (cd->sc_link->quirks & ADEV_LITTLETOC) {
+ if (sc->sc_link->quirks & ADEV_LITTLETOC) {
th->len = letoh16(th->len);
} else
th->len = betoh16(th->len);
@@ -1003,7 +1003,7 @@ cdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
toc = malloc(sizeof(*toc), M_TEMP, M_WAITOK | M_ZERO);
- error = cd_read_toc(cd, 0, 0, toc,
+ error = cd_read_toc(sc, 0, 0, toc,
sizeof(struct ioc_toc_header) + sizeof(struct cd_toc_entry),
0x40 /* control word for "get MS info" */);
@@ -1013,14 +1013,14 @@ cdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
}
cte = &toc->entries[0];
- if (cd->sc_link->quirks & ADEV_LITTLETOC) {
+ if (sc->sc_link->quirks & ADEV_LITTLETOC) {
#if BYTE_ORDER == BIG_ENDIAN
swap16_multi((u_int16_t *)&cte->addr,
sizeof(cte->addr) / 2);
#endif
} else
cte->addr.lba = betoh32(cte->addr.lba);
- if (cd->sc_link->quirks & ADEV_LITTLETOC)
+ if (sc->sc_link->quirks & ADEV_LITTLETOC)
toc->header.len = letoh16(toc->header.len);
else
toc->header.len = betoh16(toc->header.len);
@@ -1033,66 +1033,66 @@ cdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
case CDIOCSETPATCH: {
struct ioc_patch *arg = (struct ioc_patch *)addr;
- error = cd_setchan(cd, arg->patch[0], arg->patch[1],
+ error = cd_setchan(sc, arg->patch[0], arg->patch[1],
arg->patch[2], arg->patch[3], 0);
break;
}
case CDIOCGETVOL: {
struct ioc_vol *arg = (struct ioc_vol *)addr;
- error = cd_getvol(cd, arg, 0);
+ error = cd_getvol(sc, arg, 0);
break;
}
case CDIOCSETVOL: {
struct ioc_vol *arg = (struct ioc_vol *)addr;
- error = cd_setvol(cd, arg, 0);
+ error = cd_setvol(sc, arg, 0);
break;
}
case CDIOCSETMONO:
- error = cd_setchan(cd, BOTH_CHANNEL, BOTH_CHANNEL, MUTE_CHANNEL,
+ error = cd_setchan(sc, BOTH_CHANNEL, BOTH_CHANNEL, MUTE_CHANNEL,
MUTE_CHANNEL, 0);
break;
case CDIOCSETSTEREO:
- error = cd_setchan(cd, LEFT_CHANNEL, RIGHT_CHANNEL,
+ error = cd_setchan(sc, LEFT_CHANNEL, RIGHT_CHANNEL,
MUTE_CHANNEL, MUTE_CHANNEL, 0);
break;
case CDIOCSETMUTE:
- error = cd_setchan(cd, MUTE_CHANNEL, MUTE_CHANNEL, MUTE_CHANNEL,
+ error = cd_setchan(sc, MUTE_CHANNEL, MUTE_CHANNEL, MUTE_CHANNEL,
MUTE_CHANNEL, 0);
break;
case CDIOCSETLEFT:
- error = cd_setchan(cd, LEFT_CHANNEL, LEFT_CHANNEL, MUTE_CHANNEL,
+ error = cd_setchan(sc, LEFT_CHANNEL, LEFT_CHANNEL, MUTE_CHANNEL,
MUTE_CHANNEL, 0);
break;
case CDIOCSETRIGHT:
- error = cd_setchan(cd, RIGHT_CHANNEL, RIGHT_CHANNEL,
+ error = cd_setchan(sc, RIGHT_CHANNEL, RIGHT_CHANNEL,
MUTE_CHANNEL, MUTE_CHANNEL, 0);
break;
case CDIOCRESUME:
- error = cd_pause(cd, 1);
+ error = cd_pause(sc, 1);
break;
case CDIOCPAUSE:
- error = cd_pause(cd, 0);
+ error = cd_pause(sc, 0);
break;
case CDIOCSTART:
- error = scsi_start(cd->sc_link, SSS_START, 0);
+ error = scsi_start(sc->sc_link, SSS_START, 0);
break;
case CDIOCSTOP:
- error = scsi_start(cd->sc_link, SSS_STOP, 0);
+ error = scsi_start(sc->sc_link, SSS_STOP, 0);
break;
close_tray:
case CDIOCCLOSE:
- error = scsi_start(cd->sc_link, SSS_START|SSS_LOEJ,
+ error = scsi_start(sc->sc_link, SSS_START|SSS_LOEJ,
SCSI_IGNORE_NOT_READY | SCSI_IGNORE_MEDIA_CHANGE);
break;
@@ -1106,53 +1106,53 @@ cdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
/* FALLTHROUGH */
case CDIOCEJECT: /* FALLTHROUGH */
case DIOCEJECT:
- cd->sc_link->flags |= SDEV_EJECTING;
+ sc->sc_link->flags |= SDEV_EJECTING;
break;
case CDIOCALLOW:
- error = scsi_prevent(cd->sc_link, PR_ALLOW, 0);
+ error = scsi_prevent(sc->sc_link, PR_ALLOW, 0);
break;
case CDIOCPREVENT:
- error = scsi_prevent(cd->sc_link, PR_PREVENT, 0);
+ error = scsi_prevent(sc->sc_link, PR_PREVENT, 0);
break;
case DIOCLOCK:
- error = scsi_prevent(cd->sc_link,
+ error = scsi_prevent(sc->sc_link,
(*(int *)addr) ? PR_PREVENT : PR_ALLOW, 0);
break;
case CDIOCSETDEBUG:
- cd->sc_link->flags |= (SDEV_DB1 | SDEV_DB2);
+ sc->sc_link->flags |= (SDEV_DB1 | SDEV_DB2);
break;
case CDIOCCLRDEBUG:
- cd->sc_link->flags &= ~(SDEV_DB1 | SDEV_DB2);
+ sc->sc_link->flags &= ~(SDEV_DB1 | SDEV_DB2);
break;
case CDIOCRESET:
case SCIOCRESET:
- error = cd_reset(cd);
+ error = cd_reset(sc);
break;
case CDIOCLOADUNLOAD: {
struct ioc_load_unload *args = (struct ioc_load_unload *)addr;
- error = cd_load_unload(cd, args->options, args->slot);
+ error = cd_load_unload(sc, args->options, args->slot);
break;
}
case DVD_AUTH:
- error = dvd_auth(cd, (union dvd_authinfo *)addr);
+ error = dvd_auth(sc, (union dvd_authinfo *)addr);
break;
case DVD_READ_STRUCT:
- error = dvd_read_struct(cd, (union dvd_struct *)addr);
+ error = dvd_read_struct(sc, (union dvd_struct *)addr);
break;
default:
if (DISKPART(dev) != RAW_PART) {
error = ENOTTY;
break;
}
- error = scsi_do_ioctl(cd->sc_link, dev, cmd, addr, flag, p);
+ error = scsi_do_ioctl(sc->sc_link, dev, cmd, addr, flag, p);
break;
}
exit:
- device_unref(&cd->sc_dev);
+ device_unref(&sc->sc_dev);
return (error);
}
@@ -1164,7 +1164,7 @@ cdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
* data tracks from the TOC and put it in the disklabel
*/
int
-cdgetdisklabel(dev_t dev, struct cd_softc *cd, struct disklabel *lp,
+cdgetdisklabel(dev_t dev, struct cd_softc *sc, struct disklabel *lp,
int spoofonly)
{
struct cd_toc *toc;
@@ -1174,13 +1174,13 @@ cdgetdisklabel(dev_t dev, struct cd_softc *cd, struct disklabel *lp,
toc = malloc(sizeof(*toc), M_TEMP, M_WAITOK | M_ZERO);
- lp->d_secsize = cd->params.blksize;
+ lp->d_secsize = sc->params.blksize;
lp->d_ntracks = 1;
lp->d_nsectors = 100;
lp->d_secpercyl = 100;
- lp->d_ncylinders = (cd->params.disksize / 100) + 1;
+ lp->d_ncylinders = (sc->params.disksize / 100) + 1;
- if (cd->sc_link->flags & SDEV_ATAPI) {
+ if (sc->sc_link->flags & SDEV_ATAPI) {
strncpy(lp->d_typename, "ATAPI CD-ROM", sizeof(lp->d_typename));
lp->d_type = DTYPE_ATAPI;
} else {
@@ -1189,7 +1189,7 @@ cdgetdisklabel(dev_t dev, struct cd_softc *cd, struct disklabel *lp,
}
strncpy(lp->d_packname, "fictitious", sizeof(lp->d_packname));
- DL_SETDSIZE(lp, cd->params.disksize);
+ DL_SETDSIZE(lp, sc->params.disksize);
lp->d_rpm = 300;
lp->d_interleave = 1;
lp->d_version = 1;
@@ -1202,7 +1202,7 @@ cdgetdisklabel(dev_t dev, struct cd_softc *cd, struct disklabel *lp,
lp->d_magic2 = DISKMAGIC;
lp->d_checksum = dkcksum(lp);
- if (cd_load_toc(cd, toc, CD_LBA_FORMAT)) {
+ if (cd_load_toc(sc, toc, CD_LBA_FORMAT)) {
audioonly = 0; /* No valid TOC found == not an audio CD. */
goto done;
}
@@ -1223,7 +1223,7 @@ done:
}
int
-cd_setchan(struct cd_softc *cd, int p0, int p1, int p2, int p3, int flags)
+cd_setchan(struct cd_softc *sc, int p0, int p1, int p2, int p3, int flags)
{
union scsi_mode_sense_buf *data;
struct cd_audio_page *audio = NULL;
@@ -1233,7 +1233,7 @@ cd_setchan(struct cd_softc *cd, int p0, int p1, int p2, int p3, int flags)
if (data == NULL)
return (ENOMEM);
- error = scsi_do_mode_sense(cd->sc_link, AUDIO_PAGE, data,
+ error = scsi_do_mode_sense(sc->sc_link, AUDIO_PAGE, data,
(void **)&audio, NULL, NULL, NULL, sizeof(*audio), flags, &big);
if (error == 0 && audio == NULL)
error = EIO;
@@ -1244,10 +1244,10 @@ cd_setchan(struct cd_softc *cd, int p0, int p1, int p2, int p3, int flags)
audio->port[2].channels = p2;
audio->port[3].channels = p3;
if (big)
- error = scsi_mode_select_big(cd->sc_link, SMS_PF,
+ error = scsi_mode_select_big(sc->sc_link, SMS_PF,
&data->hdr_big, flags, 20000);
else
- error = scsi_mode_select(cd->sc_link, SMS_PF,
+ error = scsi_mode_select(sc->sc_link, SMS_PF,
&data->hdr, flags, 20000);
}
@@ -1256,7 +1256,7 @@ cd_setchan(struct cd_softc *cd, int p0, int p1, int p2, int p3, int flags)
}
int
-cd_getvol(struct cd_softc *cd, struct ioc_vol *arg, int flags)
+cd_getvol(struct cd_softc *sc, struct ioc_vol *arg, int flags)
{
union scsi_mode_sense_buf *data;
struct cd_audio_page *audio = NULL;
@@ -1266,7 +1266,7 @@ cd_getvol(struct cd_softc *cd, struct ioc_vol *arg, int flags)
if (data == NULL)
return (ENOMEM);
- error = scsi_do_mode_sense(cd->sc_link, AUDIO_PAGE, data,
+ error = scsi_do_mode_sense(sc->sc_link, AUDIO_PAGE, data,
(void **)&audio, NULL, NULL, NULL, sizeof(*audio), flags, NULL);
if (error == 0 && audio == NULL)
error = EIO;
@@ -1283,7 +1283,7 @@ cd_getvol(struct cd_softc *cd, struct ioc_vol *arg, int flags)
}
int
-cd_setvol(struct cd_softc *cd, const struct ioc_vol *arg, int flags)
+cd_setvol(struct cd_softc *sc, const struct ioc_vol *arg, int flags)
{
union scsi_mode_sense_buf *data;
struct cd_audio_page *audio = NULL;
@@ -1294,7 +1294,7 @@ cd_setvol(struct cd_softc *cd, const struct ioc_vol *arg, int flags)
if (data == NULL)
return (ENOMEM);
- error = scsi_do_mode_sense(cd->sc_link,
+ error = scsi_do_mode_sense(sc->sc_link,
AUDIO_PAGE | SMS_PAGE_CTRL_CHANGEABLE, data, (void **)&audio, NULL,
NULL, NULL, sizeof(*audio), flags, NULL);
if (error == 0 && audio == NULL)
@@ -1309,7 +1309,7 @@ cd_setvol(struct cd_softc *cd, const struct ioc_vol *arg, int flags)
mask_volume[2] = audio->port[2].volume;
mask_volume[3] = audio->port[3].volume;
- error = scsi_do_mode_sense(cd->sc_link, AUDIO_PAGE, data,
+ error = scsi_do_mode_sense(sc->sc_link, AUDIO_PAGE, data,
(void **)&audio, NULL, NULL, NULL, sizeof(*audio), flags, &big);
if (error == 0 && audio == NULL)
error = EIO;
@@ -1324,10 +1324,10 @@ cd_setvol(struct cd_softc *cd, const struct ioc_vol *arg, int flags)
audio->port[3].volume = arg->vol[3] & mask_volume[3];
if (big)
- error = scsi_mode_select_big(cd->sc_link, SMS_PF,
+ error = scsi_mode_select_big(sc->sc_link, SMS_PF,
&data->hdr_big, flags, 20000);
else
- error = scsi_mode_select(cd->sc_link, SMS_PF,
+ error = scsi_mode_select(sc->sc_link, SMS_PF,
&data->hdr, flags, 20000);
free(data, M_TEMP);
@@ -1335,7 +1335,7 @@ cd_setvol(struct cd_softc *cd, const struct ioc_vol *arg, int flags)
}
int
-cd_load_unload(struct cd_softc *cd, int options, int slot)
+cd_load_unload(struct cd_softc *sc, int options, int slot)
{
struct scsi_load_unload cmd;
@@ -1344,18 +1344,18 @@ cd_load_unload(struct cd_softc *cd, int options, int slot)
cmd.options = options; /* ioctl uses ATAPI values */
cmd.slot = slot;
- return (scsi_scsi_cmd(cd->sc_link, (struct scsi_generic *)&cmd,
+ return (scsi_scsi_cmd(sc->sc_link, (struct scsi_generic *)&cmd,
sizeof(cmd), 0, 0, SCSI_RETRIES, 200000, NULL, 0));
}
int
-cd_set_pa_immed(struct cd_softc *cd, int flags)
+cd_set_pa_immed(struct cd_softc *sc, int flags)
{
union scsi_mode_sense_buf *data;
struct cd_audio_page *audio = NULL;
int error, oflags, big;
- if (cd->sc_link->flags & SDEV_ATAPI)
+ if (sc->sc_link->flags & SDEV_ATAPI)
/* XXX Noop? */
return (0);
@@ -1363,7 +1363,7 @@ cd_set_pa_immed(struct cd_softc *cd, int flags)
if (data == NULL)
return (ENOMEM);
- error = scsi_do_mode_sense(cd->sc_link, AUDIO_PAGE, data,
+ error = scsi_do_mode_sense(sc->sc_link, AUDIO_PAGE, data,
(void **)&audio, NULL, NULL, NULL, sizeof(*audio), flags, &big);
if (error == 0 && audio == NULL)
error = EIO;
@@ -1374,10 +1374,10 @@ cd_set_pa_immed(struct cd_softc *cd, int flags)
audio->flags |= CD_PA_IMMED;
if (audio->flags != oflags) {
if (big)
- error = scsi_mode_select_big(cd->sc_link,
+ error = scsi_mode_select_big(sc->sc_link,
SMS_PF, &data->hdr_big, flags, 20000);
else
- error = scsi_mode_select(cd->sc_link, SMS_PF,
+ error = scsi_mode_select(sc->sc_link, SMS_PF,
&data->hdr, flags, 20000);
}
}
@@ -1390,7 +1390,7 @@ cd_set_pa_immed(struct cd_softc *cd, int flags)
* Get scsi driver to send a "start playing" command
*/
int
-cd_play(struct cd_softc *cd, int blkno, int nblks)
+cd_play(struct cd_softc *sc, int blkno, int nblks)
{
struct scsi_play scsi_cmd;
@@ -1398,7 +1398,7 @@ cd_play(struct cd_softc *cd, int blkno, int nblks)
scsi_cmd.opcode = PLAY;
_lto4b(blkno, scsi_cmd.blk_addr);
_lto2b(nblks, scsi_cmd.xfer_len);
- return (scsi_scsi_cmd(cd->sc_link,
+ return (scsi_scsi_cmd(sc->sc_link,
(struct scsi_generic *)&scsi_cmd, sizeof(scsi_cmd),
0, 0, SCSI_RETRIES, 200000, NULL, 0));
}
@@ -1407,7 +1407,7 @@ cd_play(struct cd_softc *cd, int blkno, int nblks)
* Get scsi driver to send a "start playing" command
*/
int
-cd_play_tracks(struct cd_softc *cd, int strack, int sindex, int etrack,
+cd_play_tracks(struct cd_softc *sc, int strack, int sindex, int etrack,
int eindex)
{
struct cd_toc *toc;
@@ -1421,7 +1421,7 @@ cd_play_tracks(struct cd_softc *cd, int strack, int sindex, int etrack,
toc = malloc(sizeof(*toc), M_TEMP, M_WAITOK | M_ZERO);
- if ((error = cd_load_toc(cd, toc, CD_MSF_FORMAT)) != 0)
+ if ((error = cd_load_toc(sc, toc, CD_MSF_FORMAT)) != 0)
goto done;
if (++etrack > (toc->header.ending_track+1))
@@ -1452,7 +1452,7 @@ cd_play_tracks(struct cd_softc *cd, int strack, int sindex, int etrack,
}
}
- error = cd_play_msf(cd, toc->entries[strack].addr.msf.minute,
+ error = cd_play_msf(sc, toc->entries[strack].addr.msf.minute,
toc->entries[strack].addr.msf.second,
toc->entries[strack].addr.msf.frame,
endm, ends, endf);
@@ -1466,7 +1466,7 @@ done:
* Get scsi driver to send a "play msf" command
*/
int
-cd_play_msf(struct cd_softc *cd, int startm, int starts, int startf, int endm,
+cd_play_msf(struct cd_softc *sc, int startm, int starts, int startf, int endm,
int ends, int endf)
{
struct scsi_play_msf scsi_cmd;
@@ -1479,7 +1479,7 @@ cd_play_msf(struct cd_softc *cd, int startm, int starts, int startf, int endm,
scsi_cmd.end_m = endm;
scsi_cmd.end_s = ends;
scsi_cmd.end_f = endf;
- return (scsi_scsi_cmd(cd->sc_link,
+ return (scsi_scsi_cmd(sc->sc_link,
(struct scsi_generic *)&scsi_cmd, sizeof(scsi_cmd),
0, 0, SCSI_RETRIES, 20000, NULL, 0));
}
@@ -1488,14 +1488,14 @@ cd_play_msf(struct cd_softc *cd, int startm, int starts, int startf, int endm,
* Get scsi driver to send a "start up" command
*/
int
-cd_pause(struct cd_softc *cd, int go)
+cd_pause(struct cd_softc *sc, int go)
{
struct scsi_pause scsi_cmd;
bzero(&scsi_cmd, sizeof(scsi_cmd));
scsi_cmd.opcode = PAUSE;
scsi_cmd.resume = go;
- return scsi_scsi_cmd(cd->sc_link, (struct scsi_generic *)&scsi_cmd,
+ return scsi_scsi_cmd(sc->sc_link, (struct scsi_generic *)&scsi_cmd,
sizeof(scsi_cmd), 0, 0, SCSI_RETRIES, 2000, NULL, 0);
}
@@ -1503,9 +1503,9 @@ cd_pause(struct cd_softc *cd, int go)
* Get scsi driver to send a "RESET" command
*/
int
-cd_reset(struct cd_softc *cd)
+cd_reset(struct cd_softc *sc)
{
- return scsi_scsi_cmd(cd->sc_link, 0, 0, 0, 0, SCSI_RETRIES, 2000, NULL,
+ return scsi_scsi_cmd(sc->sc_link, 0, 0, 0, 0, SCSI_RETRIES, 2000, NULL,
SCSI_RESET);
}
@@ -1513,7 +1513,7 @@ cd_reset(struct cd_softc *cd)
* Read subchannel
*/
int
-cd_read_subchannel(struct cd_softc *cd, int mode, int format, int track,
+cd_read_subchannel(struct cd_softc *sc, int mode, int format, int track,
struct cd_sub_channel_info *data, int len)
{
struct scsi_read_subchannel scsi_cmd;
@@ -1526,7 +1526,7 @@ cd_read_subchannel(struct cd_softc *cd, int mode, int format, int track,
scsi_cmd.subchan_format = format;
scsi_cmd.track = track;
_lto2b(len, scsi_cmd.data_len);
- return scsi_scsi_cmd(cd->sc_link, (struct scsi_generic *)&scsi_cmd,
+ return scsi_scsi_cmd(sc->sc_link, (struct scsi_generic *)&scsi_cmd,
sizeof(struct scsi_read_subchannel), (u_char *)data, len,
SCSI_RETRIES, 5000, NULL, SCSI_DATA_IN|SCSI_SILENT);
}
@@ -1535,7 +1535,7 @@ cd_read_subchannel(struct cd_softc *cd, int mode, int format, int track,
* Read table of contents
*/
int
-cd_read_toc(struct cd_softc *cd, int mode, int start, void *data, int len,
+cd_read_toc(struct cd_softc *sc, int mode, int start, void *data, int len,
int control)
{
struct scsi_read_toc scsi_cmd;
@@ -1550,17 +1550,17 @@ cd_read_toc(struct cd_softc *cd, int mode, int start, void *data, int len,
_lto2b(len, scsi_cmd.data_len);
scsi_cmd.control = control;
- return scsi_scsi_cmd(cd->sc_link, (struct scsi_generic *)&scsi_cmd,
+ return scsi_scsi_cmd(sc->sc_link, (struct scsi_generic *)&scsi_cmd,
sizeof(struct scsi_read_toc), (u_char *)data, len, SCSI_RETRIES,
5000, NULL, SCSI_DATA_IN | SCSI_IGNORE_ILLEGAL_REQUEST);
}
int
-cd_load_toc(struct cd_softc *cd, struct cd_toc *toc, int fmt)
+cd_load_toc(struct cd_softc *sc, struct cd_toc *toc, int fmt)
{
int n, len, error;
- error = cd_read_toc(cd, 0, 0, toc, sizeof(toc->header), 0);
+ error = cd_read_toc(sc, 0, 0, toc, sizeof(toc->header), 0);
if (error == 0) {
if (toc->header.ending_track < toc->header.starting_track)
@@ -1568,7 +1568,7 @@ cd_load_toc(struct cd_softc *cd, struct cd_toc *toc, int fmt)
/* +2 to account for leading out track. */
n = toc->header.ending_track - toc->header.starting_track + 2;
len = n * sizeof(struct cd_toc_entry) + sizeof(toc->header);
- error = cd_read_toc(cd, fmt, 0, toc, len, 0);
+ error = cd_read_toc(sc, fmt, 0, toc, len, 0);
}
return (error);
@@ -1580,23 +1580,23 @@ cd_load_toc(struct cd_softc *cd, struct cd_toc *toc, int fmt)
* results to fill out the disk parameter structure.
*/
int
-cd_get_parms(struct cd_softc *cd, int flags)
+cd_get_parms(struct cd_softc *sc, int flags)
{
/* Reasonable defaults for drives that don't support READ_CAPACITY */
- cd->params.blksize = 2048;
- cd->params.disksize = 400000;
+ sc->params.blksize = 2048;
+ sc->params.disksize = 400000;
- if (cd->sc_link->quirks & ADEV_NOCAPACITY)
+ if (sc->sc_link->quirks & ADEV_NOCAPACITY)
return (0);
- cd->params.disksize = scsi_size(cd->sc_link, flags,
- &cd->params.blksize);
+ sc->params.disksize = scsi_size(sc->sc_link, flags,
+ &sc->params.blksize);
- if ((cd->params.blksize < 512) || ((cd->params.blksize & 511) != 0))
- cd->params.blksize = 2048; /* some drives lie ! */
+ if ((sc->params.blksize < 512) || ((sc->params.blksize & 511) != 0))
+ sc->params.blksize = 2048; /* some drives lie ! */
- if (cd->params.disksize < 100)
- cd->params.disksize = 400000;
+ if (sc->params.disksize < 100)
+ sc->params.disksize = 400000;
return (0);
}
@@ -1620,7 +1620,7 @@ cddump(dev_t dev, daddr64_t blkno, caddr_t va, size_t size)
#define dvd_copy_challenge(dst, src) bcopy((src), (dst), DVD_CHALLENGE_SIZE)
int
-dvd_auth(struct cd_softc *cd, union dvd_authinfo *a)
+dvd_auth(struct cd_softc *sc, union dvd_authinfo *a)
{
struct scsi_generic cmd;
u_int8_t buf[20];
@@ -1634,7 +1634,7 @@ dvd_auth(struct cd_softc *cd, union dvd_authinfo *a)
cmd.opcode = GPCMD_REPORT_KEY;
cmd.bytes[8] = 8;
cmd.bytes[9] = 0 | (0 << 6);
- error = scsi_scsi_cmd(cd->sc_link, &cmd, sizeof(cmd), buf, 8,
+ error = scsi_scsi_cmd(sc->sc_link, &cmd, sizeof(cmd), buf, 8,
SCSI_RETRIES, 30000, NULL, SCSI_DATA_IN);
if (error)
return (error);
@@ -1645,7 +1645,7 @@ dvd_auth(struct cd_softc *cd, union dvd_authinfo *a)
cmd.opcode = GPCMD_REPORT_KEY;
cmd.bytes[8] = 16;
cmd.bytes[9] = 1 | (a->lsc.agid << 6);
- error = scsi_scsi_cmd(cd->sc_link, &cmd, sizeof(cmd), buf, 16,
+ error = scsi_scsi_cmd(sc->sc_link, &cmd, sizeof(cmd), buf, 16,
SCSI_RETRIES, 30000, NULL, SCSI_DATA_IN);
if (error)
return (error);
@@ -1656,7 +1656,7 @@ dvd_auth(struct cd_softc *cd, union dvd_authinfo *a)
cmd.opcode = GPCMD_REPORT_KEY;
cmd.bytes[8] = 12;
cmd.bytes[9] = 2 | (a->lsk.agid << 6);
- error = scsi_scsi_cmd(cd->sc_link, &cmd, sizeof(cmd), buf, 12,
+ error = scsi_scsi_cmd(sc->sc_link, &cmd, sizeof(cmd), buf, 12,
SCSI_RETRIES, 30000, NULL, SCSI_DATA_IN);
if (error)
return (error);
@@ -1668,7 +1668,7 @@ dvd_auth(struct cd_softc *cd, union dvd_authinfo *a)
_lto4b(a->lstk.lba, &cmd.bytes[1]);
cmd.bytes[8] = 12;
cmd.bytes[9] = 4 | (a->lstk.agid << 6);
- error = scsi_scsi_cmd(cd->sc_link, &cmd, sizeof(cmd), buf, 12,
+ error = scsi_scsi_cmd(sc->sc_link, &cmd, sizeof(cmd), buf, 12,
SCSI_RETRIES, 30000, NULL, SCSI_DATA_IN);
if (error)
return (error);
@@ -1682,7 +1682,7 @@ dvd_auth(struct cd_softc *cd, union dvd_authinfo *a)
cmd.opcode = GPCMD_REPORT_KEY;
cmd.bytes[8] = 8;
cmd.bytes[9] = 5 | (a->lsasf.agid << 6);
- error = scsi_scsi_cmd(cd->sc_link, &cmd, sizeof(cmd), buf, 8,
+ error = scsi_scsi_cmd(sc->sc_link, &cmd, sizeof(cmd), buf, 8,
SCSI_RETRIES, 30000, NULL, SCSI_DATA_IN);
if (error)
return (error);
@@ -1695,7 +1695,7 @@ dvd_auth(struct cd_softc *cd, union dvd_authinfo *a)
cmd.bytes[9] = 1 | (a->hsc.agid << 6);
buf[1] = 14;
dvd_copy_challenge(&buf[4], a->hsc.chal);
- error = scsi_scsi_cmd(cd->sc_link, &cmd, sizeof(cmd), buf, 16,
+ error = scsi_scsi_cmd(sc->sc_link, &cmd, sizeof(cmd), buf, 16,
SCSI_RETRIES, 30000, NULL, SCSI_DATA_OUT);
if (error)
return (error);
@@ -1708,7 +1708,7 @@ dvd_auth(struct cd_softc *cd, union dvd_authinfo *a)
cmd.bytes[9] = 3 | (a->hsk.agid << 6);
buf[1] = 10;
dvd_copy_key(&buf[4], a->hsk.key);
- error = scsi_scsi_cmd(cd->sc_link, &cmd, sizeof(cmd), buf, 12,
+ error = scsi_scsi_cmd(sc->sc_link, &cmd, sizeof(cmd), buf, 12,
SCSI_RETRIES, 30000, NULL, SCSI_DATA_OUT);
if (error) {
a->type = DVD_AUTH_FAILURE;
@@ -1720,7 +1720,7 @@ dvd_auth(struct cd_softc *cd, union dvd_authinfo *a)
case DVD_INVALIDATE_AGID:
cmd.opcode = GPCMD_REPORT_KEY;
cmd.bytes[9] = 0x3f | (a->lsa.agid << 6);
- error = scsi_scsi_cmd(cd->sc_link, &cmd, sizeof(cmd), buf, 16,
+ error = scsi_scsi_cmd(sc->sc_link, &cmd, sizeof(cmd), buf, 16,
SCSI_RETRIES, 30000, NULL, 0);
if (error)
return (error);
@@ -1730,7 +1730,7 @@ dvd_auth(struct cd_softc *cd, union dvd_authinfo *a)
cmd.opcode = GPCMD_REPORT_KEY;
cmd.bytes[8] = 8;
cmd.bytes[9] = 8 | (0 << 6);
- error = scsi_scsi_cmd(cd->sc_link, &cmd, sizeof(cmd), buf, 8,
+ error = scsi_scsi_cmd(sc->sc_link, &cmd, sizeof(cmd), buf, 8,
SCSI_RETRIES, 30000, NULL, SCSI_DATA_IN);
if (error)
return (error);
@@ -1747,7 +1747,7 @@ dvd_auth(struct cd_softc *cd, union dvd_authinfo *a)
cmd.bytes[9] = 6 | (0 << 6);
buf[1] = 6;
buf[4] = a->hrpcs.pdrc;
- error = scsi_scsi_cmd(cd->sc_link, &cmd, sizeof(cmd), buf, 8,
+ error = scsi_scsi_cmd(sc->sc_link, &cmd, sizeof(cmd), buf, 8,
SCSI_RETRIES, 30000, NULL, SCSI_DATA_OUT);
if (error)
return (error);
@@ -1759,7 +1759,7 @@ dvd_auth(struct cd_softc *cd, union dvd_authinfo *a)
}
int
-dvd_read_physical(struct cd_softc *cd, union dvd_struct *s)
+dvd_read_physical(struct cd_softc *sc, union dvd_struct *s)
{
struct scsi_generic cmd;
u_int8_t buf[4 + 4 * 20], *bufp;
@@ -1774,7 +1774,7 @@ dvd_read_physical(struct cd_softc *cd, union dvd_struct *s)
_lto2b(sizeof(buf), &cmd.bytes[7]);
cmd.bytes[5] = s->physical.layer_num;
- error = scsi_scsi_cmd(cd->sc_link, &cmd, sizeof(cmd), buf, sizeof(buf),
+ error = scsi_scsi_cmd(sc->sc_link, &cmd, sizeof(cmd), buf, sizeof(buf),
SCSI_RETRIES, 30000, NULL, SCSI_DATA_IN);
if (error)
return (error);
@@ -1799,7 +1799,7 @@ dvd_read_physical(struct cd_softc *cd, union dvd_struct *s)
}
int
-dvd_read_copyright(struct cd_softc *cd, union dvd_struct *s)
+dvd_read_copyright(struct cd_softc *sc, union dvd_struct *s)
{
struct scsi_generic cmd;
u_int8_t buf[8];
@@ -1812,7 +1812,7 @@ dvd_read_copyright(struct cd_softc *cd, union dvd_struct *s)
_lto2b(sizeof(buf), &cmd.bytes[7]);
cmd.bytes[5] = s->copyright.layer_num;
- error = scsi_scsi_cmd(cd->sc_link, &cmd, sizeof(cmd), buf, sizeof(buf),
+ error = scsi_scsi_cmd(sc->sc_link, &cmd, sizeof(cmd), buf, sizeof(buf),
SCSI_RETRIES, 30000, NULL, SCSI_DATA_IN);
if (error)
return (error);
@@ -1822,7 +1822,7 @@ dvd_read_copyright(struct cd_softc *cd, union dvd_struct *s)
}
int
-dvd_read_disckey(struct cd_softc *cd, union dvd_struct *s)
+dvd_read_disckey(struct cd_softc *sc, union dvd_struct *s)
{
struct scsi_read_dvd_structure cmd;
struct scsi_read_dvd_structure_data *buf;
@@ -1838,7 +1838,7 @@ dvd_read_disckey(struct cd_softc *cd, union dvd_struct *s)
cmd.agid = s->disckey.agid << 6;
_lto2b(sizeof(*buf), cmd.length);
- error = scsi_scsi_cmd(cd->sc_link, (struct scsi_generic *)&cmd,
+ error = scsi_scsi_cmd(sc->sc_link, (struct scsi_generic *)&cmd,
sizeof(cmd), (u_char *)buf, sizeof(*buf), SCSI_RETRIES, 30000, NULL,
SCSI_DATA_IN);
if (error == 0)
@@ -1849,7 +1849,7 @@ dvd_read_disckey(struct cd_softc *cd, union dvd_struct *s)
}
int
-dvd_read_bca(struct cd_softc *cd, union dvd_struct *s)
+dvd_read_bca(struct cd_softc *sc, union dvd_struct *s)
{
struct scsi_generic cmd;
u_int8_t buf[4 + 188];
@@ -1861,7 +1861,7 @@ dvd_read_bca(struct cd_softc *cd, union dvd_struct *s)
cmd.bytes[6] = s->type;
_lto2b(sizeof(buf), &cmd.bytes[7]);
- error = scsi_scsi_cmd(cd->sc_link, &cmd, sizeof(cmd), buf, sizeof(buf),
+ error = scsi_scsi_cmd(sc->sc_link, &cmd, sizeof(cmd), buf, sizeof(buf),
SCSI_RETRIES, 30000, NULL, SCSI_DATA_IN);
if (error)
return (error);
@@ -1873,7 +1873,7 @@ dvd_read_bca(struct cd_softc *cd, union dvd_struct *s)
}
int
-dvd_read_manufact(struct cd_softc *cd, union dvd_struct *s)
+dvd_read_manufact(struct cd_softc *sc, union dvd_struct *s)
{
struct scsi_read_dvd_structure cmd;
struct scsi_read_dvd_structure_data *buf;
@@ -1888,7 +1888,7 @@ dvd_read_manufact(struct cd_softc *cd, union dvd_struct *s)
cmd.format = s->type;
_lto2b(sizeof(*buf), cmd.length);
- error = scsi_scsi_cmd(cd->sc_link, (struct scsi_generic *)&cmd,
+ error = scsi_scsi_cmd(sc->sc_link, (struct scsi_generic *)&cmd,
sizeof(cmd), (u_char *)buf, sizeof(*buf), SCSI_RETRIES, 30000, NULL,
SCSI_DATA_IN);
if (error == 0) {
@@ -1904,20 +1904,20 @@ dvd_read_manufact(struct cd_softc *cd, union dvd_struct *s)
}
int
-dvd_read_struct(struct cd_softc *cd, union dvd_struct *s)
+dvd_read_struct(struct cd_softc *sc, union dvd_struct *s)
{
switch (s->type) {
case DVD_STRUCT_PHYSICAL:
- return (dvd_read_physical(cd, s));
+ return (dvd_read_physical(sc, s));
case DVD_STRUCT_COPYRIGHT:
- return (dvd_read_copyright(cd, s));
+ return (dvd_read_copyright(sc, s));
case DVD_STRUCT_DISCKEY:
- return (dvd_read_disckey(cd, s));
+ return (dvd_read_disckey(sc, s));
case DVD_STRUCT_BCA:
- return (dvd_read_bca(cd, s));
+ return (dvd_read_bca(sc, s));
case DVD_STRUCT_MANUFACT:
- return (dvd_read_manufact(cd, s));
+ return (dvd_read_manufact(sc, s));
default:
return (EINVAL);
}
@@ -1926,14 +1926,14 @@ dvd_read_struct(struct cd_softc *cd, union dvd_struct *s)
void
cd_powerhook(int why, void *arg)
{
- struct cd_softc *cd = arg;
+ struct cd_softc *sc = arg;
/*
* When resuming, hardware may have forgotten we locked it. So if
* there are any open partitions, lock the CD.
*/
- if (why == PWR_RESUME && cd->sc_dk.dk_openmask != 0)
- scsi_prevent(cd->sc_link, PR_PREVENT,
+ if (why == PWR_RESUME && sc->sc_dk.dk_openmask != 0)
+ scsi_prevent(sc->sc_link, PR_PREVENT,
SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_MEDIA_CHANGE |
SCSI_SILENT);
}
@@ -1985,12 +1985,12 @@ cd_interpret_sense(struct scsi_xfer *xs)
* Remove unprocessed buffers from queue.
*/
void
-cd_kill_buffers(struct cd_softc *cd)
+cd_kill_buffers(struct cd_softc *sc)
{
struct buf *bp;
int s;
- while ((bp = cd_buf_dequeue(cd)) != NULL) {
+ while ((bp = cd_buf_dequeue(sc)) != NULL) {
bp->b_error = ENXIO;
bp->b_flags |= B_ERROR;
s = splbio();
@@ -2003,28 +2003,28 @@ cd_kill_buffers(struct cd_softc *cd)
int
cd_eject(void)
{
- struct cd_softc *cd;
+ struct cd_softc *sc;
int error = 0;
- if (cd_cd.cd_ndevs == 0 || (cd = cd_cd.cd_devs[0]) == NULL)
+ if (cd_cd.cd_ndevs == 0 || (sc = cd_cd.cd_devs[0]) == NULL)
return (ENXIO);
- if ((error = cdlock(cd)) != 0)
+ if ((error = cdlock(sc)) != 0)
return (error);
- if (cd->sc_dk.dk_openmask == 0) {
- cd->sc_link->flags |= SDEV_EJECTING;
+ if (sc->sc_dk.dk_openmask == 0) {
+ sc->sc_link->flags |= SDEV_EJECTING;
- scsi_prevent(cd->sc_link, PR_ALLOW,
+ scsi_prevent(sc->sc_link, PR_ALLOW,
SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_NOT_READY |
SCSI_SILENT | SCSI_IGNORE_MEDIA_CHANGE);
- cd->sc_link->flags &= ~SDEV_MEDIA_LOADED;
+ sc->sc_link->flags &= ~SDEV_MEDIA_LOADED;
- scsi_start(cd->sc_link, SSS_STOP|SSS_LOEJ, 0);
+ scsi_start(sc->sc_link, SSS_STOP|SSS_LOEJ, 0);
- cd->sc_link->flags &= ~SDEV_EJECTING;
+ sc->sc_link->flags &= ~SDEV_EJECTING;
}
- cdunlock(cd);
+ cdunlock(sc);
return (error);
}