Module Name:    src
Committed By:   riz
Date:           Mon Aug 20 19:34:20 UTC 2012

Modified Files:
        src/sys/dev/usb [netbsd-6]: umass_scsipi.c

Log Message:
Pull up following revision(s) (requested by drochner in ticket #520):
        sys/dev/usb/umass_scsipi.c: revision 1.46
For devices which don't claim SPC-3, don't request 32 bytes of sense
data but just 18. Some devices signal an error if the transfer length
is not exactly what the device expects, and it is hard to deal with
these errors afterwards.
This makes a number of USB memory sticks and SD card readers work
which were not usable before.


To generate a diff of this commit:
cvs rdiff -u -r1.38.10.1 -r1.38.10.2 src/sys/dev/usb/umass_scsipi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/umass_scsipi.c
diff -u src/sys/dev/usb/umass_scsipi.c:1.38.10.1 src/sys/dev/usb/umass_scsipi.c:1.38.10.2
--- src/sys/dev/usb/umass_scsipi.c:1.38.10.1	Mon Apr 23 16:28:31 2012
+++ src/sys/dev/usb/umass_scsipi.c	Mon Aug 20 19:34:20 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: umass_scsipi.c,v 1.38.10.1 2012/04/23 16:28:31 riz Exp $	*/
+/*	$NetBSD: umass_scsipi.c,v 1.38.10.2 2012/08/20 19:34:20 riz Exp $	*/
 
 /*
  * Copyright (c) 2001, 2003 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: umass_scsipi.c,v 1.38.10.1 2012/04/23 16:28:31 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umass_scsipi.c,v 1.38.10.2 2012/08/20 19:34:20 riz Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_umass.h"
@@ -395,7 +395,7 @@ umass_scsipi_cb(struct umass_softc *sc, 
 	struct umass_scsipi_softc *scbus = (struct umass_scsipi_softc *)sc->bus;
 	struct scsipi_xfer *xs = priv;
 	struct scsipi_periph *periph = xs->xs_periph;
-	int cmdlen;
+	int cmdlen, senselen;
 	int s;
 #ifdef UMASS_DEBUG
 	struct timeval tv;
@@ -423,16 +423,20 @@ umass_scsipi_cb(struct umass_softc *sc, 
 		scbus->sc_sense_cmd.opcode = SCSI_REQUEST_SENSE;
 		scbus->sc_sense_cmd.byte2 = periph->periph_lun <<
 		    SCSI_CMD_LUN_SHIFT;
-		scbus->sc_sense_cmd.length = sizeof(xs->sense);
 
 		if (sc->sc_cmd == UMASS_CPROTO_UFI ||
 		    sc->sc_cmd == UMASS_CPROTO_ATAPI)
 			cmdlen = UFI_COMMAND_LENGTH;	/* XXX */
 		else
 			cmdlen = sizeof(scbus->sc_sense_cmd);
+		if (periph->periph_version < 0x05) /* SPC-3 */
+			senselen = 18;
+		else
+			senselen = sizeof(xs->sense);
+		scbus->sc_sense_cmd.length = senselen;
 		sc->sc_methods->wire_xfer(sc, periph->periph_lun,
 					  &scbus->sc_sense_cmd, cmdlen,
-					  &xs->sense, sizeof(xs->sense),
+					  &xs->sense, senselen,
 					  DIR_IN, xs->timeout,
 					  umass_scsipi_sense_cb, xs);
 		return;

Reply via email to