Use offsetof() instead of a hard-coded constant for readability.
authorPeter Avalos <pavalos@dragonflybsd.org>
Wed, 28 Nov 2007 22:21:48 +0000 (22:21 +0000)
committerPeter Avalos <pavalos@dragonflybsd.org>
Wed, 28 Nov 2007 22:21:48 +0000 (22:21 +0000)
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

index 82d105f..007b29f 100644 (file)
@@ -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 <sys/param.h>
 #include <sys/systm.h>
@@ -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,