Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/usb For devices which don't claim SPC-3, don't reque...



details:   https://anonhg.NetBSD.org/src/rev/26b08f483f27
branches:  trunk
changeset: 781108:26b08f483f27
user:      drochner <drochner%NetBSD.org@localhost>
date:      Mon Aug 20 10:32:31 2012 +0000

description:
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.

diffstat:

 sys/dev/usb/umass_scsipi.c |  14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diffs (50 lines):

diff -r 9a140f46e48d -r 26b08f483f27 sys/dev/usb/umass_scsipi.c
--- a/sys/dev/usb/umass_scsipi.c        Mon Aug 20 08:38:32 2012 +0000
+++ b/sys/dev/usb/umass_scsipi.c        Mon Aug 20 10:32:31 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: umass_scsipi.c,v 1.45 2012/04/20 20:23:21 bouyer Exp $ */
+/*     $NetBSD: umass_scsipi.c,v 1.46 2012/08/20 10:32:31 drochner Exp $       */
 
 /*
  * Copyright (c) 2001, 2003, 2012 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: umass_scsipi.c,v 1.45 2012/04/20 20:23:21 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umass_scsipi.c,v 1.46 2012/08/20 10:32:31 drochner Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_umass.h"
@@ -398,7 +398,7 @@
        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;
@@ -426,16 +426,20 @@
                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, 0,
                                          umass_scsipi_sense_cb, xs);
                return;



Home | Main Index | Thread Index | Old Index