diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2020-09-05 14:21:53 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2020-09-05 14:21:53 +0000 |
commit | 311bd9a43d7daa17e91adc18df0e999c606882a0 (patch) | |
tree | 1bb6cae6b9a80c5242a41912d47b5c84ea929c7c /sys/dev | |
parent | 2378367b6b423b06926486b2392031f32dbd3525 (diff) |
Rename SID_INQUIRY_HDR (a.k.a. 5) to more explicit SID_SCSI2_HDRLEN and use it
to replace various uses of '5' when calculating the amount of data in the
INQUIRY response. Matches up more naturally with SID_SCSI2_ALEN.
Also use to fix SCSIDEBUG display of INQUIRY responses to show correct count of
bytes received/available.
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/pv/hvs.c | 5 | ||||
-rw-r--r-- | sys/dev/usb/umass.c | 10 |
2 files changed, 8 insertions, 7 deletions
diff --git a/sys/dev/pv/hvs.c b/sys/dev/pv/hvs.c index 271d7270455..0d5e6523561 100644 --- a/sys/dev/pv/hvs.c +++ b/sys/dev/pv/hvs.c @@ -590,7 +590,8 @@ fixup_inquiry(struct scsi_xfer *xs, struct hvs_srb *srb) int datalen, resplen; char vendor[8]; - resplen = srb->srb_datalen >= 5 ? inq->additional_length + 5 : 0; + resplen = srb->srb_datalen >= SID_SCSI2_HDRLEN ? + SID_SCSI2_HDRLEN + inq->additional_length : 0; datalen = MIN(resplen, srb->srb_datalen); /* Fixup wrong response from WS2012 */ @@ -601,7 +602,7 @@ fixup_inquiry(struct scsi_xfer *xs, struct hvs_srb *srb) (inq->version == 0 || inq->response_format == 0)) { inq->version = SCSI_REV_SPC3; inq->response_format = SID_SCSI2_RESPONSE; - } else if (datalen >= SID_INQUIRY_HDR + SID_SCSI2_ALEN) { + } else if (datalen >= SID_SCSI2_HDRLEN + SID_SCSI2_ALEN) { /* * Upgrade SPC2 to SPC3 if host is Win8 or WS2012 R2 * to support UNMAP feature. diff --git a/sys/dev/usb/umass.c b/sys/dev/usb/umass.c index 02391ee39ef..de23c439817 100644 --- a/sys/dev/usb/umass.c +++ b/sys/dev/usb/umass.c @@ -1,4 +1,4 @@ -/* $OpenBSD: umass.c,v 1.77 2020/06/24 07:46:10 patrick Exp $ */ +/* $OpenBSD: umass.c,v 1.78 2020/09/05 14:21:52 krw Exp $ */ /* $NetBSD: umass.c,v 1.116 2004/06/30 05:53:46 mycroft Exp $ */ /* @@ -819,13 +819,13 @@ umass_adjust_transfer(struct umass_softc *sc) { switch (sc->sc_cmd) { case UMASS_CPROTO_UFI: - sc->cbw.bCDBLength = UFI_COMMAND_LENGTH; + sc->cbw.bCDBLength = UFI_COMMAND_LENGTH; /* Adjust the length field in certain scsi commands. */ switch (sc->cbw.CBWCDB[0]) { case INQUIRY: - if (sc->transfer_datalen > 36) { - sc->transfer_datalen = 36; - sc->cbw.CBWCDB[4] = 36; + if (sc->transfer_datalen > SID_SCSI2_HDRLEN + SID_SCSI2_ALEN) { + sc->transfer_datalen = SID_SCSI2_HDRLEN + SID_SCSI2_ALEN; + sc->cbw.CBWCDB[4] = sc->transfer_datalen; } break; case MODE_SENSE_BIG: |