Commit 3f3279aa authored by Matthew Dharm's avatar Matthew Dharm Committed by Linus Torvalds

[PATCH] usb-storage: cache pipe values

This patch to usb-storage makes all pipe values used by the driver an
unsigned int (like they should be), and caches them in the device data
structure.
parent 781aa5f1
...@@ -173,7 +173,7 @@ static void us_transfer_freecom(Scsi_Cmnd *srb, struct us_data* us, int transfer ...@@ -173,7 +173,7 @@ static void us_transfer_freecom(Scsi_Cmnd *srb, struct us_data* us, int transfer
static int static int
freecom_readdata (Scsi_Cmnd *srb, struct us_data *us, freecom_readdata (Scsi_Cmnd *srb, struct us_data *us,
int ipipe, int opipe, int count) unsigned int ipipe, unsigned int opipe, int count)
{ {
freecom_udata_t extra = (freecom_udata_t) us->extra; freecom_udata_t extra = (freecom_udata_t) us->extra;
struct freecom_xfer_wrap *fxfr = struct freecom_xfer_wrap *fxfr =
...@@ -214,7 +214,7 @@ freecom_readdata (Scsi_Cmnd *srb, struct us_data *us, ...@@ -214,7 +214,7 @@ freecom_readdata (Scsi_Cmnd *srb, struct us_data *us,
static int static int
freecom_writedata (Scsi_Cmnd *srb, struct us_data *us, freecom_writedata (Scsi_Cmnd *srb, struct us_data *us,
int ipipe, int opipe, int count) int unsigned ipipe, unsigned int opipe, int count)
{ {
freecom_udata_t extra = (freecom_udata_t) us->extra; freecom_udata_t extra = (freecom_udata_t) us->extra;
struct freecom_xfer_wrap *fxfr = struct freecom_xfer_wrap *fxfr =
...@@ -262,7 +262,7 @@ int freecom_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -262,7 +262,7 @@ int freecom_transport(Scsi_Cmnd *srb, struct us_data *us)
{ {
struct freecom_cb_wrap *fcb; struct freecom_cb_wrap *fcb;
struct freecom_status *fst; struct freecom_status *fst;
int ipipe, opipe; /* We need both pipes. */ unsigned int ipipe, opipe; /* We need both pipes. */
int result; int result;
int partial; int partial;
int length; int length;
...@@ -276,8 +276,8 @@ int freecom_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -276,8 +276,8 @@ int freecom_transport(Scsi_Cmnd *srb, struct us_data *us)
US_DEBUGP("Freecom TRANSPORT STARTED\n"); US_DEBUGP("Freecom TRANSPORT STARTED\n");
/* Get handles for both transports. */ /* Get handles for both transports. */
opipe = usb_sndbulkpipe (us->pusb_dev, us->ep_out); opipe = us->send_bulk_pipe;
ipipe = usb_rcvbulkpipe (us->pusb_dev, us->ep_in); ipipe = us->recv_bulk_pipe;
/* The ATAPI Command always goes out first. */ /* The ATAPI Command always goes out first. */
fcb->Type = FCM_PACKET_ATAPI | 0x00; fcb->Type = FCM_PACKET_ATAPI | 0x00;
...@@ -515,8 +515,7 @@ freecom_init (struct us_data *us) ...@@ -515,8 +515,7 @@ freecom_init (struct us_data *us)
} }
} }
result = usb_control_msg(us->pusb_dev, result = usb_control_msg(us->pusb_dev, us->recv_ctrl_pipe,
usb_rcvctrlpipe(us->pusb_dev, 0),
0x4c, 0xc0, 0x4346, 0x0, buffer, 0x20, 3*HZ); 0x4c, 0xc0, 0x4346, 0x0, buffer, 0x20, 3*HZ);
buffer[32] = '\0'; buffer[32] = '\0';
US_DEBUGP("String returned from FC init is: %s\n", buffer); US_DEBUGP("String returned from FC init is: %s\n", buffer);
...@@ -528,8 +527,7 @@ freecom_init (struct us_data *us) ...@@ -528,8 +527,7 @@ freecom_init (struct us_data *us)
*/ */
/* send reset */ /* send reset */
result = usb_control_msg(us->pusb_dev, result = usb_control_msg(us->pusb_dev, us->send_ctrl_pipe,
usb_sndctrlpipe(us->pusb_dev, 0),
0x4d, 0x40, 0x24d8, 0x0, NULL, 0x0, 3*HZ); 0x4d, 0x40, 0x24d8, 0x0, NULL, 0x0, 3*HZ);
US_DEBUGP("result from activate reset is %d\n", result); US_DEBUGP("result from activate reset is %d\n", result);
...@@ -537,8 +535,7 @@ freecom_init (struct us_data *us) ...@@ -537,8 +535,7 @@ freecom_init (struct us_data *us)
mdelay(250); mdelay(250);
/* clear reset */ /* clear reset */
result = usb_control_msg(us->pusb_dev, result = usb_control_msg(us->pusb_dev, us->send_ctrl_pipe,
usb_sndctrlpipe(us->pusb_dev, 0),
0x4d, 0x40, 0x24f8, 0x0, NULL, 0x0, 3*HZ); 0x4d, 0x40, 0x24f8, 0x0, NULL, 0x0, 3*HZ);
US_DEBUGP("result from clear reset is %d\n", result); US_DEBUGP("result from clear reset is %d\n", result);
......
...@@ -50,7 +50,7 @@ int usb_stor_euscsi_init(struct us_data *us) ...@@ -50,7 +50,7 @@ int usb_stor_euscsi_init(struct us_data *us)
int result; int result;
US_DEBUGP("Attempting to init eUSCSI bridge...\n"); US_DEBUGP("Attempting to init eUSCSI bridge...\n");
result = usb_control_msg(us->pusb_dev, usb_sndctrlpipe(us->pusb_dev, 0), result = usb_control_msg(us->pusb_dev, us->send_ctrl_pipe,
0x0C, USB_RECIP_INTERFACE | USB_TYPE_VENDOR, 0x0C, USB_RECIP_INTERFACE | USB_TYPE_VENDOR,
0x01, 0x0, &data, 0x1, 5*HZ); 0x01, 0x0, &data, 0x1, 5*HZ);
US_DEBUGP("-- result is %d\n", result); US_DEBUGP("-- result is %d\n", result);
......
...@@ -408,13 +408,13 @@ static int isd200_transfer_partial( struct us_data *us, ...@@ -408,13 +408,13 @@ static int isd200_transfer_partial( struct us_data *us,
{ {
int result; int result;
int partial; int partial;
int pipe; unsigned int pipe;
/* calculate the appropriate pipe information */ /* calculate the appropriate pipe information */
if (dataDirection == SCSI_DATA_READ) if (dataDirection == SCSI_DATA_READ)
pipe = usb_rcvbulkpipe(us->pusb_dev, us->ep_in); pipe = us->recv_bulk_pipe;
else else
pipe = usb_sndbulkpipe(us->pusb_dev, us->ep_out); pipe = us->send_bulk_pipe;
/* transfer the data */ /* transfer the data */
US_DEBUGP("isd200_transfer_partial(): xfer %d bytes\n", length); US_DEBUGP("isd200_transfer_partial(): xfer %d bytes\n", length);
...@@ -546,7 +546,6 @@ int isd200_Bulk_transport( struct us_data *us, Scsi_Cmnd *srb, ...@@ -546,7 +546,6 @@ int isd200_Bulk_transport( struct us_data *us, Scsi_Cmnd *srb,
struct bulk_cb_wrap bcb; struct bulk_cb_wrap bcb;
struct bulk_cs_wrap bcs; struct bulk_cs_wrap bcs;
int result; int result;
int pipe;
int partial; int partial;
unsigned int transfer_amount; unsigned int transfer_amount;
...@@ -566,9 +565,6 @@ int isd200_Bulk_transport( struct us_data *us, Scsi_Cmnd *srb, ...@@ -566,9 +565,6 @@ int isd200_Bulk_transport( struct us_data *us, Scsi_Cmnd *srb,
bcb.Length = AtaCdbLength; bcb.Length = AtaCdbLength;
/* construct the pipe handle */
pipe = usb_sndbulkpipe(us->pusb_dev, us->ep_out);
/* copy the command payload */ /* copy the command payload */
memset(bcb.CDB, 0, sizeof(bcb.CDB)); memset(bcb.CDB, 0, sizeof(bcb.CDB));
memcpy(bcb.CDB, AtaCdb, bcb.Length); memcpy(bcb.CDB, AtaCdb, bcb.Length);
...@@ -578,8 +574,8 @@ int isd200_Bulk_transport( struct us_data *us, Scsi_Cmnd *srb, ...@@ -578,8 +574,8 @@ int isd200_Bulk_transport( struct us_data *us, Scsi_Cmnd *srb,
le32_to_cpu(bcb.Signature), bcb.Tag, le32_to_cpu(bcb.Signature), bcb.Tag,
(bcb.Lun >> 4), (bcb.Lun & 0xFF), (bcb.Lun >> 4), (bcb.Lun & 0xFF),
le32_to_cpu(bcb.DataTransferLength), bcb.Flags, bcb.Length); le32_to_cpu(bcb.DataTransferLength), bcb.Flags, bcb.Length);
result = usb_stor_bulk_msg(us, &bcb, pipe, US_BULK_CB_WRAP_LEN, result = usb_stor_bulk_msg(us, &bcb, us->send_bulk_pipe,
&partial); US_BULK_CB_WRAP_LEN, &partial);
US_DEBUGP("Bulk command transfer result=%d\n", result); US_DEBUGP("Bulk command transfer result=%d\n", result);
/* did we abort this command? */ /* did we abort this command? */
...@@ -589,8 +585,9 @@ int isd200_Bulk_transport( struct us_data *us, Scsi_Cmnd *srb, ...@@ -589,8 +585,9 @@ int isd200_Bulk_transport( struct us_data *us, Scsi_Cmnd *srb,
else if (result == -EPIPE) { else if (result == -EPIPE) {
/* if we stall, we need to clear it before we go on */ /* if we stall, we need to clear it before we go on */
US_DEBUGP("clearing endpoint halt for pipe 0x%x\n", pipe); US_DEBUGP("clearing endpoint halt for pipe 0x%x\n",
if (usb_stor_clear_halt(us, pipe) < 0) us->send_bulk_pipe);
if (usb_stor_clear_halt(us, us->send_bulk_pipe) < 0)
return ISD200_TRANSPORT_ERROR; return ISD200_TRANSPORT_ERROR;
} else if (result) } else if (result)
return ISD200_TRANSPORT_ERROR; return ISD200_TRANSPORT_ERROR;
...@@ -608,13 +605,10 @@ int isd200_Bulk_transport( struct us_data *us, Scsi_Cmnd *srb, ...@@ -608,13 +605,10 @@ int isd200_Bulk_transport( struct us_data *us, Scsi_Cmnd *srb,
* an explanation of how this code works. * an explanation of how this code works.
*/ */
/* construct the pipe handle */
pipe = usb_rcvbulkpipe(us->pusb_dev, us->ep_in);
/* get CSW for device status */ /* get CSW for device status */
US_DEBUGP("Attempting to get CSW...\n"); US_DEBUGP("Attempting to get CSW...\n");
result = usb_stor_bulk_msg(us, &bcs, pipe, US_BULK_CS_WRAP_LEN, result = usb_stor_bulk_msg(us, &bcs, us->recv_bulk_pipe,
&partial); US_BULK_CS_WRAP_LEN, &partial);
/* did we abort this command? */ /* did we abort this command? */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
return ISD200_TRANSPORT_ABORTED; return ISD200_TRANSPORT_ABORTED;
...@@ -622,13 +616,14 @@ int isd200_Bulk_transport( struct us_data *us, Scsi_Cmnd *srb, ...@@ -622,13 +616,14 @@ int isd200_Bulk_transport( struct us_data *us, Scsi_Cmnd *srb,
/* did the attempt to read the CSW fail? */ /* did the attempt to read the CSW fail? */
if (result == -EPIPE) { if (result == -EPIPE) {
US_DEBUGP("clearing endpoint halt for pipe 0x%x\n", pipe); US_DEBUGP("clearing endpoint halt for pipe 0x%x\n",
if (usb_stor_clear_halt(us, pipe) < 0) us->recv_bulk_pipe);
if (usb_stor_clear_halt(us, us->recv_bulk_pipe) < 0)
return ISD200_TRANSPORT_ERROR; return ISD200_TRANSPORT_ERROR;
/* get the status again */ /* get the status again */
US_DEBUGP("Attempting to get CSW (2nd try)...\n"); US_DEBUGP("Attempting to get CSW (2nd try)...\n");
result = usb_stor_bulk_msg(us, &bcs, pipe, result = usb_stor_bulk_msg(us, &bcs, us->recv_bulk_pipe,
US_BULK_CS_WRAP_LEN, &partial); US_BULK_CS_WRAP_LEN, &partial);
/* if the command was aborted, indicate that */ /* if the command was aborted, indicate that */
...@@ -638,8 +633,9 @@ int isd200_Bulk_transport( struct us_data *us, Scsi_Cmnd *srb, ...@@ -638,8 +633,9 @@ int isd200_Bulk_transport( struct us_data *us, Scsi_Cmnd *srb,
/* if it fails again, we need a reset and return an error*/ /* if it fails again, we need a reset and return an error*/
if (result == -EPIPE) { if (result == -EPIPE) {
US_DEBUGP("clearing halt for pipe 0x%x\n", pipe); US_DEBUGP("clearing halt for pipe 0x%x\n",
usb_stor_clear_halt(us, pipe); us->recv_bulk_pipe);
usb_stor_clear_halt(us, us->recv_bulk_pipe);
return ISD200_TRANSPORT_ERROR; return ISD200_TRANSPORT_ERROR;
} }
} }
...@@ -937,7 +933,7 @@ int isd200_write_config( struct us_data *us ) ...@@ -937,7 +933,7 @@ int isd200_write_config( struct us_data *us )
/* let's send the command via the control pipe */ /* let's send the command via the control pipe */
result = usb_stor_control_msg( result = usb_stor_control_msg(
us, us,
usb_sndctrlpipe(us->pusb_dev,0), us->send_ctrl_pipe,
0x01, 0x01,
USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
0x0000, 0x0000,
...@@ -978,7 +974,7 @@ int isd200_read_config( struct us_data *us ) ...@@ -978,7 +974,7 @@ int isd200_read_config( struct us_data *us )
result = usb_stor_control_msg( result = usb_stor_control_msg(
us, us,
usb_rcvctrlpipe(us->pusb_dev,0), us->recv_ctrl_pipe,
0x02, 0x02,
USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
0x0000, 0x0000,
......
...@@ -95,8 +95,7 @@ static int jumpshot_get_status(struct us_data *us) ...@@ -95,8 +95,7 @@ static int jumpshot_get_status(struct us_data *us)
return USB_STOR_TRANSPORT_ERROR; return USB_STOR_TRANSPORT_ERROR;
// send the setup // send the setup
rc = usb_storage_send_control(us, rc = usb_storage_send_control(us, us->recv_ctrl_pipe,
usb_rcvctrlpipe(us->pusb_dev, 0),
0, 0xA0, 0, 7, &reply, 1); 0, 0xA0, 0, 7, &reply, 1);
if (rc != USB_STOR_TRANSPORT_GOOD) if (rc != USB_STOR_TRANSPORT_GOOD)
...@@ -160,8 +159,7 @@ static int jumpshot_read_data(struct us_data *us, ...@@ -160,8 +159,7 @@ static int jumpshot_read_data(struct us_data *us,
command[5] |= (sector >> 24) & 0x0F; command[5] |= (sector >> 24) & 0x0F;
// send the setup + command // send the setup + command
result = usb_storage_send_control(us, result = usb_storage_send_control(us, us->send_ctrl_pipe,
usb_sndctrlpipe(us->pusb_dev, 0),
0, 0x20, 0, 1, command, 7); 0, 0x20, 0, 1, command, 7);
if (result != USB_STOR_TRANSPORT_GOOD) if (result != USB_STOR_TRANSPORT_GOOD)
goto leave; goto leave;
...@@ -247,8 +245,7 @@ static int jumpshot_write_data(struct us_data *us, ...@@ -247,8 +245,7 @@ static int jumpshot_write_data(struct us_data *us,
command[5] |= (sector >> 24) & 0x0F; command[5] |= (sector >> 24) & 0x0F;
// send the setup + command // send the setup + command
result = usb_storage_send_control( result = usb_storage_send_control(us, us->send_ctrl_pipe,
us, usb_sndctrlpipe(us->pusb_dev, 0),
0, 0x20, 0, 1, command, 7); 0, 0x20, 0, 1, command, 7);
// send the data // send the data
...@@ -302,8 +299,7 @@ static int jumpshot_id_device(struct us_data *us, ...@@ -302,8 +299,7 @@ static int jumpshot_id_device(struct us_data *us,
return USB_STOR_TRANSPORT_ERROR; return USB_STOR_TRANSPORT_ERROR;
// send the setup // send the setup
rc = usb_storage_send_control(us, rc = usb_storage_send_control(us, us->send_ctrl_pipe,
usb_sndctrlpipe(us->pusb_dev, 0),
0, 0x20, 0, 6, command, 2); 0, 0x20, 0, 6, command, 2);
if (rc != USB_STOR_TRANSPORT_GOOD) { if (rc != USB_STOR_TRANSPORT_GOOD) {
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
int int
usb_storage_send_control(struct us_data *us, usb_storage_send_control(struct us_data *us,
int pipe, unsigned int pipe,
unsigned char request, unsigned char request,
unsigned char requesttype, unsigned char requesttype,
unsigned int value, unsigned int value,
...@@ -85,12 +85,12 @@ usb_storage_raw_bulk(struct us_data *us, int direction, unsigned char *data, ...@@ -85,12 +85,12 @@ usb_storage_raw_bulk(struct us_data *us, int direction, unsigned char *data,
unsigned int len, unsigned int *act_len) { unsigned int len, unsigned int *act_len) {
int result; int result;
int pipe; unsigned int pipe;
if (direction == SCSI_DATA_READ) if (direction == SCSI_DATA_READ)
pipe = usb_rcvbulkpipe(us->pusb_dev, us->ep_in); pipe = us->recv_bulk_pipe;
else else
pipe = usb_sndbulkpipe(us->pusb_dev, us->ep_out); pipe = us->send_bulk_pipe;
result = usb_stor_bulk_msg(us, data, pipe, len, act_len); result = usb_stor_bulk_msg(us, data, pipe, len, act_len);
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
/* usb bulk */ /* usb bulk */
extern int usb_storage_send_control( extern int usb_storage_send_control(
struct us_data *us, int pipe, struct us_data *us, unsigned int pipe,
unsigned char request, unsigned char requesttype, unsigned char request, unsigned char requesttype,
unsigned int value, unsigned int index, unsigned int value, unsigned int index,
unsigned char *xfer_data, unsigned int xfer_len); unsigned char *xfer_data, unsigned int xfer_len);
......
...@@ -224,15 +224,15 @@ sddr09_send_command(struct us_data *us, ...@@ -224,15 +224,15 @@ sddr09_send_command(struct us_data *us,
unsigned char direction, unsigned char direction,
unsigned char *xfer_data, unsigned char *xfer_data,
unsigned int xfer_len) { unsigned int xfer_len) {
int pipe; unsigned int pipe;
unsigned char requesttype = (0x41 | direction); unsigned char requesttype = (0x41 | direction);
// Get the receive or send control pipe number // Get the receive or send control pipe number
if (direction == USB_DIR_IN) if (direction == USB_DIR_IN)
pipe = usb_rcvctrlpipe(us->pusb_dev,0); pipe = us->recv_ctrl_pipe;
else else
pipe = usb_sndctrlpipe(us->pusb_dev,0); pipe = us->send_ctrl_pipe;
return usb_storage_send_control(us, pipe, request, requesttype, return usb_storage_send_control(us, pipe, request, requesttype,
0, 0, xfer_data, xfer_len); 0, 0, xfer_data, xfer_len);
......
...@@ -50,12 +50,6 @@ ...@@ -50,12 +50,6 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/slab.h> #include <linux/slab.h>
extern int usb_stor_control_msg(struct us_data *us, unsigned int pipe,
u8 request, u8 requesttype, u16 value, u16 index,
void *data, u16 size);
extern int usb_stor_bulk_msg(struct us_data *us, void *data, int pipe,
unsigned int len, unsigned int *act_len);
#define short_pack(LSB,MSB) ( ((u16)(LSB)) | ( ((u16)(MSB))<<8 ) ) #define short_pack(LSB,MSB) ( ((u16)(LSB)) | ( ((u16)(MSB))<<8 ) )
#define LSB_of(s) ((s)&0xFF) #define LSB_of(s) ((s)&0xFF)
#define MSB_of(s) ((s)>>8) #define MSB_of(s) ((s)>>8)
...@@ -70,7 +64,7 @@ int usbat_read(struct us_data *us, ...@@ -70,7 +64,7 @@ int usbat_read(struct us_data *us,
int result; int result;
result = usb_storage_send_control(us, result = usb_storage_send_control(us,
usb_rcvctrlpipe(us->pusb_dev,0), us->recv_ctrl_pipe,
access, access,
0xC0, 0xC0,
(u16)reg, (u16)reg,
...@@ -89,7 +83,7 @@ int usbat_write(struct us_data *us, ...@@ -89,7 +83,7 @@ int usbat_write(struct us_data *us,
int result; int result;
result = usb_storage_send_control(us, result = usb_storage_send_control(us,
usb_sndctrlpipe(us->pusb_dev,0), us->send_ctrl_pipe,
access|0x01, access|0x01,
0x40, 0x40,
short_pack(reg, content), short_pack(reg, content),
...@@ -115,7 +109,7 @@ int usbat_set_shuttle_features(struct us_data *us, ...@@ -115,7 +109,7 @@ int usbat_set_shuttle_features(struct us_data *us,
}; };
result = usb_storage_send_control(us, result = usb_storage_send_control(us,
usb_sndctrlpipe(us->pusb_dev,0), us->send_ctrl_pipe,
0x80, 0x80,
0x40, 0x40,
0, 0,
...@@ -140,7 +134,7 @@ int usbat_read_block(struct us_data *us, ...@@ -140,7 +134,7 @@ int usbat_read_block(struct us_data *us,
}; };
result = usb_storage_send_control(us, result = usb_storage_send_control(us,
usb_sndctrlpipe(us->pusb_dev,0), us->send_ctrl_pipe,
0x80, 0x80,
0x40, 0x40,
0, 0,
...@@ -222,7 +216,7 @@ int usbat_write_block(struct us_data *us, ...@@ -222,7 +216,7 @@ int usbat_write_block(struct us_data *us,
}; };
result = usb_storage_send_control(us, result = usb_storage_send_control(us,
usb_sndctrlpipe(us->pusb_dev,0), us->send_ctrl_pipe,
0x80, 0x80,
0x40, 0x40,
0, 0,
...@@ -293,7 +287,7 @@ int usbat_rw_block_test(struct us_data *us, ...@@ -293,7 +287,7 @@ int usbat_rw_block_test(struct us_data *us,
*/ */
result = usb_storage_send_control(us, result = usb_storage_send_control(us,
usb_sndctrlpipe(us->pusb_dev,0), us->send_ctrl_pipe,
0x80, 0x80,
0x40, 0x40,
0, 0,
...@@ -352,8 +346,7 @@ int usbat_rw_block_test(struct us_data *us, ...@@ -352,8 +346,7 @@ int usbat_rw_block_test(struct us_data *us,
if (direction==SCSI_DATA_READ && i==0) { if (direction==SCSI_DATA_READ && i==0) {
if (usb_stor_clear_halt(us, if (usb_stor_clear_halt(us,
usb_sndbulkpipe(us->pusb_dev, us->send_bulk_pipe) < 0)
us->ep_out)) < 0)
return USB_STOR_TRANSPORT_ERROR; return USB_STOR_TRANSPORT_ERROR;
} }
...@@ -413,7 +406,7 @@ int usbat_multiple_write(struct us_data *us, ...@@ -413,7 +406,7 @@ int usbat_multiple_write(struct us_data *us,
} }
result = usb_storage_send_control(us, result = usb_storage_send_control(us,
usb_sndctrlpipe(us->pusb_dev,0), us->send_ctrl_pipe,
0x80, 0x80,
0x40, 0x40,
0, 0,
...@@ -439,7 +432,7 @@ int usbat_read_user_io(struct us_data *us, ...@@ -439,7 +432,7 @@ int usbat_read_user_io(struct us_data *us,
int result; int result;
result = usb_storage_send_control(us, result = usb_storage_send_control(us,
usb_rcvctrlpipe(us->pusb_dev,0), us->recv_ctrl_pipe,
0x82, 0x82,
0xC0, 0xC0,
0, 0,
...@@ -457,7 +450,7 @@ int usbat_write_user_io(struct us_data *us, ...@@ -457,7 +450,7 @@ int usbat_write_user_io(struct us_data *us,
int result; int result;
result = usb_storage_send_control(us, result = usb_storage_send_control(us,
usb_sndctrlpipe(us->pusb_dev,0), us->send_ctrl_pipe,
0x82, 0x82,
0x40, 0x40,
short_pack(enable_flags, data_flags), short_pack(enable_flags, data_flags),
......
...@@ -488,7 +488,7 @@ int usb_stor_control_msg(struct us_data *us, unsigned int pipe, ...@@ -488,7 +488,7 @@ int usb_stor_control_msg(struct us_data *us, unsigned int pipe,
/* This is our function to emulate usb_bulk_msg() with enough control /* This is our function to emulate usb_bulk_msg() with enough control
* to make aborts/resets/timeouts work * to make aborts/resets/timeouts work
*/ */
int usb_stor_bulk_msg(struct us_data *us, void *data, int pipe, int usb_stor_bulk_msg(struct us_data *us, void *data, unsigned int pipe,
unsigned int len, unsigned int *act_len) unsigned int len, unsigned int *act_len)
{ {
int status; int status;
...@@ -515,13 +515,12 @@ int usb_stor_bulk_msg(struct us_data *us, void *data, int pipe, ...@@ -515,13 +515,12 @@ int usb_stor_bulk_msg(struct us_data *us, void *data, int pipe,
* Since many vendors in this space limit their testing to interoperability * Since many vendors in this space limit their testing to interoperability
* with these two OSes, specification violations like this one are common. * with these two OSes, specification violations like this one are common.
*/ */
int usb_stor_clear_halt(struct us_data *us, int pipe) int usb_stor_clear_halt(struct us_data *us, unsigned int pipe)
{ {
int result; int result;
int endp = usb_pipeendpoint(pipe) | (usb_pipein(pipe) << 7); int endp = usb_pipeendpoint(pipe) | (usb_pipein(pipe) << 7);
result = usb_stor_control_msg(us, result = usb_stor_control_msg(us, us->send_ctrl_pipe,
usb_sndctrlpipe(us->pusb_dev, 0),
USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT, 0, USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT, 0,
endp, NULL, 0); /* note: no 3*HZ timeout */ endp, NULL, 0); /* note: no 3*HZ timeout */
US_DEBUGP("usb_stor_clear_halt: result=%d\n", result); US_DEBUGP("usb_stor_clear_halt: result=%d\n", result);
...@@ -556,13 +555,13 @@ int usb_stor_transfer_partial(struct us_data *us, char *buf, int length) ...@@ -556,13 +555,13 @@ int usb_stor_transfer_partial(struct us_data *us, char *buf, int length)
{ {
int result; int result;
int partial; int partial;
int pipe; unsigned int pipe;
/* calculate the appropriate pipe information */ /* get the appropriate pipe value */
if (us->srb->sc_data_direction == SCSI_DATA_READ) if (us->srb->sc_data_direction == SCSI_DATA_READ)
pipe = usb_rcvbulkpipe(us->pusb_dev, us->ep_in); pipe = us->recv_bulk_pipe;
else else
pipe = usb_sndbulkpipe(us->pusb_dev, us->ep_out); pipe = us->send_bulk_pipe;
/* transfer the data */ /* transfer the data */
US_DEBUGP("usb_stor_transfer_partial(): xfer %d bytes\n", length); US_DEBUGP("usb_stor_transfer_partial(): xfer %d bytes\n", length);
...@@ -985,7 +984,7 @@ int usb_stor_CBI_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -985,7 +984,7 @@ int usb_stor_CBI_transport(Scsi_Cmnd *srb, struct us_data *us)
/* COMMAND STAGE */ /* COMMAND STAGE */
/* let's send the command via the control pipe */ /* let's send the command via the control pipe */
result = usb_stor_control_msg(us, usb_sndctrlpipe(us->pusb_dev,0), result = usb_stor_control_msg(us, us->send_ctrl_pipe,
US_CBI_ADSC, US_CBI_ADSC,
USB_TYPE_CLASS | USB_RECIP_INTERFACE, 0, USB_TYPE_CLASS | USB_RECIP_INTERFACE, 0,
us->ifnum, srb->cmnd, srb->cmd_len); us->ifnum, srb->cmnd, srb->cmd_len);
...@@ -1097,7 +1096,7 @@ int usb_stor_CB_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -1097,7 +1096,7 @@ int usb_stor_CB_transport(Scsi_Cmnd *srb, struct us_data *us)
/* COMMAND STAGE */ /* COMMAND STAGE */
/* let's send the command via the control pipe */ /* let's send the command via the control pipe */
result = usb_stor_control_msg(us, usb_sndctrlpipe(us->pusb_dev,0), result = usb_stor_control_msg(us, us->send_ctrl_pipe,
US_CBI_ADSC, US_CBI_ADSC,
USB_TYPE_CLASS | USB_RECIP_INTERFACE, 0, USB_TYPE_CLASS | USB_RECIP_INTERFACE, 0,
us->ifnum, srb->cmnd, srb->cmd_len); us->ifnum, srb->cmnd, srb->cmd_len);
...@@ -1153,12 +1152,12 @@ int usb_stor_Bulk_max_lun(struct us_data *us) ...@@ -1153,12 +1152,12 @@ int usb_stor_Bulk_max_lun(struct us_data *us)
{ {
unsigned char data; unsigned char data;
int result; int result;
int pipe;
/* issue the command -- use usb_control_msg() because /* Issue the command -- use usb_control_msg() because this is
* this is not a scsi queued-command */ * not a scsi queued-command. Also note that at this point the
pipe = usb_rcvctrlpipe(us->pusb_dev, 0); * cached pipe values have not yet been stored. */
result = usb_control_msg(us->pusb_dev, pipe, result = usb_control_msg(us->pusb_dev,
usb_rcvctrlpipe(us->pusb_dev, 0),
US_BULK_GET_MAX_LUN, US_BULK_GET_MAX_LUN,
USB_DIR_IN | USB_TYPE_CLASS | USB_DIR_IN | USB_TYPE_CLASS |
USB_RECIP_INTERFACE, USB_RECIP_INTERFACE,
...@@ -1180,7 +1179,6 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -1180,7 +1179,6 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us)
struct bulk_cb_wrap bcb; struct bulk_cb_wrap bcb;
struct bulk_cs_wrap bcs; struct bulk_cs_wrap bcs;
int result; int result;
int pipe;
int partial; int partial;
/* set up the command wrapper */ /* set up the command wrapper */
...@@ -1193,9 +1191,6 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -1193,9 +1191,6 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us)
bcb.Lun |= srb->target << 4; bcb.Lun |= srb->target << 4;
bcb.Length = srb->cmd_len; bcb.Length = srb->cmd_len;
/* construct the pipe handle */
pipe = usb_sndbulkpipe(us->pusb_dev, us->ep_out);
/* copy the command payload */ /* copy the command payload */
memset(bcb.CDB, 0, sizeof(bcb.CDB)); memset(bcb.CDB, 0, sizeof(bcb.CDB));
memcpy(bcb.CDB, srb->cmnd, bcb.Length); memcpy(bcb.CDB, srb->cmnd, bcb.Length);
...@@ -1205,8 +1200,8 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -1205,8 +1200,8 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us)
le32_to_cpu(bcb.Signature), bcb.Tag, le32_to_cpu(bcb.Signature), bcb.Tag,
(bcb.Lun >> 4), (bcb.Lun & 0x0F), (bcb.Lun >> 4), (bcb.Lun & 0x0F),
bcb.DataTransferLength, bcb.Flags, bcb.Length); bcb.DataTransferLength, bcb.Flags, bcb.Length);
result = usb_stor_bulk_msg(us, &bcb, pipe, US_BULK_CB_WRAP_LEN, result = usb_stor_bulk_msg(us, &bcb, us->send_bulk_pipe,
&partial); US_BULK_CB_WRAP_LEN, &partial);
US_DEBUGP("Bulk command transfer result=%d\n", result); US_DEBUGP("Bulk command transfer result=%d\n", result);
/* did we abort this command? */ /* did we abort this command? */
...@@ -1217,8 +1212,9 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -1217,8 +1212,9 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us)
/* if we stall, we need to clear it before we go on */ /* if we stall, we need to clear it before we go on */
if (result == -EPIPE) { if (result == -EPIPE) {
US_DEBUGP("clearing endpoint halt for pipe 0x%x\n", pipe); US_DEBUGP("clearing endpoint halt for pipe 0x%x\n",
result = usb_stor_clear_halt(us, pipe); us->send_bulk_pipe);
result = usb_stor_clear_halt(us, us->send_bulk_pipe);
/* did we abort this command? */ /* did we abort this command? */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
...@@ -1251,13 +1247,10 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -1251,13 +1247,10 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us)
* an explanation of how this code works. * an explanation of how this code works.
*/ */
/* construct the pipe handle */
pipe = usb_rcvbulkpipe(us->pusb_dev, us->ep_in);
/* get CSW for device status */ /* get CSW for device status */
US_DEBUGP("Attempting to get CSW...\n"); US_DEBUGP("Attempting to get CSW...\n");
result = usb_stor_bulk_msg(us, &bcs, pipe, US_BULK_CS_WRAP_LEN, result = usb_stor_bulk_msg(us, &bcs, us->recv_bulk_pipe,
&partial); US_BULK_CS_WRAP_LEN, &partial);
/* did we abort this command? */ /* did we abort this command? */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
...@@ -1267,8 +1260,9 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -1267,8 +1260,9 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us)
/* did the attempt to read the CSW fail? */ /* did the attempt to read the CSW fail? */
if (result == -EPIPE) { if (result == -EPIPE) {
US_DEBUGP("clearing endpoint halt for pipe 0x%x\n", pipe); US_DEBUGP("clearing endpoint halt for pipe 0x%x\n",
result = usb_stor_clear_halt(us, pipe); us->recv_bulk_pipe);
result = usb_stor_clear_halt(us, us->recv_bulk_pipe);
/* did we abort this command? */ /* did we abort this command? */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
...@@ -1280,7 +1274,7 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -1280,7 +1274,7 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us)
/* get the status again */ /* get the status again */
US_DEBUGP("Attempting to get CSW (2nd try)...\n"); US_DEBUGP("Attempting to get CSW (2nd try)...\n");
result = usb_stor_bulk_msg(us, &bcs, pipe, result = usb_stor_bulk_msg(us, &bcs, us->recv_bulk_pipe,
US_BULK_CS_WRAP_LEN, &partial); US_BULK_CS_WRAP_LEN, &partial);
/* did we abort this command? */ /* did we abort this command? */
...@@ -1291,8 +1285,9 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -1291,8 +1285,9 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us)
/* if it fails again, we need a reset and return an error*/ /* if it fails again, we need a reset and return an error*/
if (result == -EPIPE) { if (result == -EPIPE) {
US_DEBUGP("clearing halt for pipe 0x%x\n", pipe); US_DEBUGP("clearing halt for pipe 0x%x\n",
result = usb_stor_clear_halt(us, pipe); us->recv_bulk_pipe);
result = usb_stor_clear_halt(us, us->recv_bulk_pipe);
/* did we abort this command? */ /* did we abort this command? */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
...@@ -1364,7 +1359,7 @@ static int usb_stor_reset_common(struct us_data *us, ...@@ -1364,7 +1359,7 @@ static int usb_stor_reset_common(struct us_data *us,
* following a powerup or USB attach event. */ * following a powerup or USB attach event. */
/* Use usb_control_msg() because this is not a queued-command */ /* Use usb_control_msg() because this is not a queued-command */
result = usb_control_msg(us->pusb_dev, usb_sndctrlpipe(us->pusb_dev,0), result = usb_control_msg(us->pusb_dev, us->send_ctrl_pipe,
request, requesttype, value, index, data, size, request, requesttype, value, index, data, size,
20*HZ); 20*HZ);
if (result < 0) if (result < 0)
...@@ -1377,14 +1372,12 @@ static int usb_stor_reset_common(struct us_data *us, ...@@ -1377,14 +1372,12 @@ static int usb_stor_reset_common(struct us_data *us,
/* Use usb_clear_halt() because this is not a queued-command */ /* Use usb_clear_halt() because this is not a queued-command */
US_DEBUGP("Soft reset: clearing bulk-in endpoint halt\n"); US_DEBUGP("Soft reset: clearing bulk-in endpoint halt\n");
result = usb_clear_halt(us->pusb_dev, result = usb_clear_halt(us->pusb_dev, us->recv_bulk_pipe);
usb_rcvbulkpipe(us->pusb_dev, us->ep_in));
if (result < 0) if (result < 0)
goto Done; goto Done;
US_DEBUGP("Soft reset: clearing bulk-out endpoint halt\n"); US_DEBUGP("Soft reset: clearing bulk-out endpoint halt\n");
result = usb_clear_halt(us->pusb_dev, result = usb_clear_halt(us->pusb_dev, us->send_bulk_pipe);
usb_sndbulkpipe(us->pusb_dev, us->ep_out));
Done: Done:
......
...@@ -153,12 +153,12 @@ extern void usb_stor_invoke_transport(Scsi_Cmnd*, struct us_data*); ...@@ -153,12 +153,12 @@ extern void usb_stor_invoke_transport(Scsi_Cmnd*, struct us_data*);
extern void usb_stor_abort_transport(struct us_data*); extern void usb_stor_abort_transport(struct us_data*);
extern int usb_stor_transfer_partial(struct us_data*, char*, int); extern int usb_stor_transfer_partial(struct us_data*, char*, int);
extern int usb_stor_bulk_msg(struct us_data *us, void *data, int pipe, extern int usb_stor_bulk_msg(struct us_data *us, void *data,
unsigned int len, unsigned int *act_len); unsigned int pipe, unsigned int len, unsigned int *act_len);
extern int usb_stor_control_msg(struct us_data *us, unsigned int pipe, extern int usb_stor_control_msg(struct us_data *us, unsigned int pipe,
u8 request, u8 requesttype, u16 value, u16 index, u8 request, u8 requesttype, u16 value, u16 index,
void *data, u16 size); void *data, u16 size);
extern int usb_stor_clear_halt(struct us_data*, int ); extern int usb_stor_clear_halt(struct us_data*, unsigned int pipe);
extern void usb_stor_transfer(Scsi_Cmnd*, struct us_data*); extern void usb_stor_transfer(Scsi_Cmnd*, struct us_data*);
#endif #endif
...@@ -525,6 +525,12 @@ static int usb_stor_allocate_urbs(struct us_data *ss) ...@@ -525,6 +525,12 @@ static int usb_stor_allocate_urbs(struct us_data *ss)
int maxp; int maxp;
int result; int result;
/* calculate and store the pipe values */
ss->send_bulk_pipe = usb_sndbulkpipe(ss->pusb_dev, ss->ep_out);
ss->recv_bulk_pipe = usb_rcvbulkpipe(ss->pusb_dev, ss->ep_in);
ss->send_ctrl_pipe = usb_sndctrlpipe(ss->pusb_dev, 0);
ss->recv_ctrl_pipe = usb_rcvctrlpipe(ss->pusb_dev, 0);
/* allocate the usb_ctrlrequest for control packets */ /* allocate the usb_ctrlrequest for control packets */
US_DEBUGP("Allocating usb_ctrlrequest\n"); US_DEBUGP("Allocating usb_ctrlrequest\n");
ss->dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_NOIO); ss->dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_NOIO);
......
...@@ -134,6 +134,10 @@ struct us_data { ...@@ -134,6 +134,10 @@ struct us_data {
struct semaphore dev_semaphore; /* protect pusb_dev */ struct semaphore dev_semaphore; /* protect pusb_dev */
struct usb_device *pusb_dev; /* this usb_device */ struct usb_device *pusb_dev; /* this usb_device */
unsigned long flags; /* from filter initially */ unsigned long flags; /* from filter initially */
unsigned int send_bulk_pipe; /* cached pipe values */
unsigned int recv_bulk_pipe;
unsigned int send_ctrl_pipe;
unsigned int recv_ctrl_pipe;
/* information about the device -- always good */ /* information about the device -- always good */
char vendor[USB_STOR_STRING_LEN]; char vendor[USB_STOR_STRING_LEN];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment