*/
#include <linux/config.h>
+#include <linux/sched.h>
+#include <linux/errno.h>
+#include <linux/slab.h>
+
+#include <scsi/scsi.h>
+#include <scsi/scsi_cmnd.h>
+#include <scsi/scsi_device.h>
+
#include "transport.h"
#include "protocol.h"
#include "scsiglue.h"
#include "usb.h"
#include "debug.h"
-#include <linux/sched.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
/***********************************************************************
* Data transfer routines
USB_ENDPOINT_HALT, endp,
NULL, 0, 3*HZ);
- /* reset the toggles and endpoint flags */
- usb_endpoint_running(us->pusb_dev, usb_pipeendpoint(pipe),
- usb_pipeout(pipe));
+ /* reset the endpoint toggle */
usb_settoggle(us->pusb_dev, usb_pipeendpoint(pipe),
usb_pipeout(pipe), 0);
* This is used by the protocol layers to actually send the message to
* the device and receive the response.
*/
-void usb_stor_invoke_transport(Scsi_Cmnd *srb, struct us_data *us)
+void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
{
int need_auto_sense;
int result;
* can signal most data-in errors by stalling the bulk-in pipe.
*/
if ((us->protocol == US_PR_CB || us->protocol == US_PR_DPCM_USB) &&
- srb->sc_data_direction != SCSI_DATA_READ) {
+ srb->sc_data_direction != DMA_FROM_DEVICE) {
US_DEBUGP("-- CB transport device requiring auto-sense\n");
need_auto_sense = 1;
}
/* set the transfer direction */
old_sc_data_direction = srb->sc_data_direction;
- srb->sc_data_direction = SCSI_DATA_READ;
+ srb->sc_data_direction = DMA_FROM_DEVICE;
/* use the new buffer we have */
old_request_buffer = srb->request_buffer;
* Control/Bulk/Interrupt transport
*/
-int usb_stor_CBI_transport(Scsi_Cmnd *srb, struct us_data *us)
+int usb_stor_CBI_transport(struct scsi_cmnd *srb, struct us_data *us)
{
unsigned int transfer_length = srb->request_bufflen;
unsigned int pipe = 0;
/* DATA STAGE */
/* transfer the data payload for this command, if one exists*/
if (transfer_length) {
- pipe = srb->sc_data_direction == SCSI_DATA_READ ?
+ pipe = srb->sc_data_direction == DMA_FROM_DEVICE ?
us->recv_bulk_pipe : us->send_bulk_pipe;
result = usb_stor_bulk_transfer_sg(us, pipe,
srb->request_buffer, transfer_length,
/*
* Control/Bulk transport
*/
-int usb_stor_CB_transport(Scsi_Cmnd *srb, struct us_data *us)
+int usb_stor_CB_transport(struct scsi_cmnd *srb, struct us_data *us)
{
unsigned int transfer_length = srb->request_bufflen;
int result;
/* DATA STAGE */
/* transfer the data payload for this command, if one exists*/
if (transfer_length) {
- unsigned int pipe = srb->sc_data_direction == SCSI_DATA_READ ?
+ unsigned int pipe = srb->sc_data_direction == DMA_FROM_DEVICE ?
us->recv_bulk_pipe : us->send_bulk_pipe;
result = usb_stor_bulk_transfer_sg(us, pipe,
srb->request_buffer, transfer_length,
int result;
/* issue the command */
+ us->iobuf[0] = 0;
result = usb_stor_control_msg(us, us->recv_ctrl_pipe,
US_BULK_GET_MAX_LUN,
USB_DIR_IN | USB_TYPE_CLASS |
result, us->iobuf[0]);
/* if we have a successful request, return the result */
- if (result == 1)
+ if (result >= 0)
return us->iobuf[0];
/*
return -1;
}
-int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us)
+int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
{
struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
struct bulk_cs_wrap *bcs = (struct bulk_cs_wrap *) us->iobuf;
/* set up the command wrapper */
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
bcb->DataTransferLength = cpu_to_le32(transfer_length);
- bcb->Flags = srb->sc_data_direction == SCSI_DATA_READ ? 1 << 7 : 0;
+ bcb->Flags = srb->sc_data_direction == DMA_FROM_DEVICE ? 1 << 7 : 0;
bcb->Tag = srb->serial_number;
bcb->Lun = srb->device->lun;
if (us->flags & US_FL_SCM_MULT_TARG)
/* DATA STAGE */
/* send/receive data payload, if there is any */
+
+ /* Genesys Logic interface chips need a 100us delay between the
+ * command phase and the data phase */
+ if (us->pusb_dev->descriptor.idVendor == USB_VENDOR_ID_GENESYS)
+ udelay(100);
+
if (transfer_length) {
- unsigned int pipe = srb->sc_data_direction == SCSI_DATA_READ ?
+ unsigned int pipe = srb->sc_data_direction == DMA_FROM_DEVICE ?
us->recv_bulk_pipe : us->send_bulk_pipe;
result = usb_stor_bulk_transfer_sg(us, pipe,
srb->request_buffer, transfer_length,