Greg:
This patch fixes an oversight in usb-storage whereby the command length
and command buffer for an automatically-generated REQUEST-SENSE command
would not be initialized properly.
Please apply both the 2.4 and 2.5 versions.
Alan Stern
---------- Forwarded message ----------
Date: Wed, 5 Mar 2003 12:24:32 -0800
From: Matthew Dharm <[EMAIL PROTECTED]>
To: Alan Stern <[EMAIL PROTECTED]>
Cc: USB Storage List <[EMAIL PROTECTED]>
Subject: Re: Patch for auto-sense cmd_len
I agree. Prep a patch and send to Greg with my blessing.
Matt
# --------------------------------------------
# Fix SCSI cmd_len for auto-sense commands
# --------------------------------------------
#
diff -Nru a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
--- a/drivers/usb/storage/transport.c Tue Mar 4 10:03:36 2003
+++ b/drivers/usb/storage/transport.c Tue Mar 4 10:07:33 2003
@@ -700,20 +700,26 @@
unsigned short old_sg;
unsigned old_request_bufflen;
unsigned char old_sc_data_direction;
+ unsigned char old_cmd_len;
unsigned char old_cmnd[MAX_COMMAND_SIZE];
US_DEBUGP("Issuing auto-REQUEST_SENSE\n");
/* save the old command */
memcpy(old_cmnd, srb->cmnd, MAX_COMMAND_SIZE);
+ old_cmd_len = srb->cmd_len;
/* set the command and the LUN */
+ memset(srb->cmnd, 0, MAX_COMMAND_SIZE);
srb->cmnd[0] = REQUEST_SENSE;
srb->cmnd[1] = old_cmnd[1] & 0xE0;
- srb->cmnd[2] = 0;
- srb->cmnd[3] = 0;
srb->cmnd[4] = 18;
- srb->cmnd[5] = 0;
+
+ /* FIXME: we must do the protocol translation here */
+ if (us->subclass == US_SC_RBC || us->subclass == US_SC_SCSI)
+ srb->cmd_len = 6;
+ else
+ srb->cmd_len = 12;
/* set the transfer direction */
old_sc_data_direction = srb->sc_data_direction;
@@ -739,6 +745,7 @@
srb->request_bufflen = old_request_bufflen;
srb->use_sg = old_sg;
srb->sc_data_direction = old_sc_data_direction;
+ srb->cmd_len = old_cmd_len;
memcpy(srb->cmnd, old_cmnd, MAX_COMMAND_SIZE);
if (temp_result == USB_STOR_TRANSPORT_ABORTED) {
# This is a BitKeeper generated patch for the following project:
# Project Name: greg k-h's linux 2.5 USB kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
# ChangeSet 1.1009 -> 1.1010
# drivers/usb/storage/transport.c 1.81 -> 1.82
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/03/04 [EMAIL PROTECTED] 1.1010
# Fix SCSI cmd_len for auto-sense commands
# --------------------------------------------
#
diff -Nru a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
--- a/drivers/usb/storage/transport.c Tue Mar 4 09:58:24 2003
+++ b/drivers/usb/storage/transport.c Tue Mar 4 09:58:24 2003
@@ -582,20 +582,26 @@
unsigned short old_sg;
unsigned old_request_bufflen;
unsigned char old_sc_data_direction;
+ unsigned char old_cmd_len;
unsigned char old_cmnd[MAX_COMMAND_SIZE];
US_DEBUGP("Issuing auto-REQUEST_SENSE\n");
/* save the old command */
memcpy(old_cmnd, srb->cmnd, MAX_COMMAND_SIZE);
+ old_cmd_len = srb->cmd_len;
/* set the command and the LUN */
+ memset(srb->cmnd, 0, MAX_COMMAND_SIZE);
srb->cmnd[0] = REQUEST_SENSE;
srb->cmnd[1] = old_cmnd[1] & 0xE0;
- srb->cmnd[2] = 0;
- srb->cmnd[3] = 0;
srb->cmnd[4] = 18;
- srb->cmnd[5] = 0;
+
+ /* FIXME: we must do the protocol translation here */
+ if (us->subclass == US_SC_RBC || us->subclass == US_SC_SCSI)
+ srb->cmd_len = 6;
+ else
+ srb->cmd_len = 12;
/* set the transfer direction */
old_sc_data_direction = srb->sc_data_direction;
@@ -621,6 +627,7 @@
srb->request_bufflen = old_request_bufflen;
srb->use_sg = old_sg;
srb->sc_data_direction = old_sc_data_direction;
+ srb->cmd_len = old_cmd_len;
memcpy(srb->cmnd, old_cmnd, MAX_COMMAND_SIZE);
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {