From 338d394261298b2efb4c13afaa5722c629e929d7 Mon Sep 17 00:00:00 2001 From: Peter Avalos Date: Wed, 28 Nov 2007 22:21:48 +0000 Subject: [PATCH] Use offsetof() instead of a hard-coded constant for readability. Round odd long inquiry lengths up so as to avoid tickling ignore wide residue bugs in broken parallel SCSI devices running with a wide transfer negotiation. Obtained-from: FreeBSD --- sys/bus/cam/cam_xpt.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/sys/bus/cam/cam_xpt.c b/sys/bus/cam/cam_xpt.c index 82d105f5f0..007b29f598 100644 --- a/sys/bus/cam/cam_xpt.c +++ b/sys/bus/cam/cam_xpt.c @@ -27,7 +27,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/cam/cam_xpt.c,v 1.80.2.18 2002/12/09 17:31:55 gibbs Exp $ - * $DragonFly: src/sys/bus/cam/cam_xpt.c,v 1.46 2007/11/28 22:11:02 pavalos Exp $ + * $DragonFly: src/sys/bus/cam/cam_xpt.c,v 1.47 2007/11/28 22:21:48 pavalos Exp $ */ #include #include @@ -5463,7 +5463,17 @@ probestart(struct cam_periph *periph, union ccb *start_ccb) if (softc->action == PROBE_INQUIRY) inquiry_len = SHORT_INQUIRY_LENGTH; else - inquiry_len = inq_buf->additional_length + 5; + inquiry_len = inq_buf->additional_length + + offsetof(struct scsi_inquiry_data, + additional_length) + 1; + + /* + * Some parallel SCSI devices fail to send an + * ignore wide residue message when dealing with + * odd length inquiry requests. Round up to be + * safe. + */ + inquiry_len = roundup2(inquiry_len, 2); scsi_inquiry(csio, /*retries*/4, -- 2.41.0