Commit 4a2daf2d authored by Matthew Dharm's avatar Matthew Dharm Committed by Greg Kroah-Hartman

[PATCH] USB Storage: cleanups, mostly

This patch is originally from Christoph Hellwig.

This patch coverts from Scsi_Foo typefs to struct scsi_cmnd, and moved from
the SCSI data direction constants to the DMA ones.

It also switches to the proper (or so they tell me) use of <scsi/*.h>
headers.  This also includes some additional reshuffling to avoid useless
headers in the usb-storage local headers (to improve compile time).
Signed-off-by: default avatarMatthew Dharm <mdharm-usb@one-eyed-alien.net>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 201c014b
...@@ -50,16 +50,19 @@ ...@@ -50,16 +50,19 @@
* in that routine. * in that routine.
*/ */
#include <linux/sched.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
#include "transport.h" #include "transport.h"
#include "protocol.h" #include "protocol.h"
#include "usb.h" #include "usb.h"
#include "debug.h" #include "debug.h"
#include "datafab.h" #include "datafab.h"
#include <linux/sched.h>
#include <linux/errno.h>
#include <linux/slab.h>
static int datafab_determine_lun(struct us_data *us, static int datafab_determine_lun(struct us_data *us,
struct datafab_info *info); struct datafab_info *info);
...@@ -388,7 +391,7 @@ static int datafab_id_device(struct us_data *us, ...@@ -388,7 +391,7 @@ static int datafab_id_device(struct us_data *us,
static int datafab_handle_mode_sense(struct us_data *us, static int datafab_handle_mode_sense(struct us_data *us,
Scsi_Cmnd * srb, struct scsi_cmnd * srb,
int sense_6) int sense_6)
{ {
static unsigned char rw_err_page[12] = { static unsigned char rw_err_page[12] = {
...@@ -498,7 +501,7 @@ static void datafab_info_destructor(void *extra) ...@@ -498,7 +501,7 @@ static void datafab_info_destructor(void *extra)
// Transport for the Datafab MDCFE-B // Transport for the Datafab MDCFE-B
// //
int datafab_transport(Scsi_Cmnd * srb, struct us_data *us) int datafab_transport(struct scsi_cmnd * srb, struct us_data *us)
{ {
struct datafab_info *info; struct datafab_info *info;
int rc; int rc;
...@@ -625,12 +628,12 @@ int datafab_transport(Scsi_Cmnd * srb, struct us_data *us) ...@@ -625,12 +628,12 @@ int datafab_transport(Scsi_Cmnd * srb, struct us_data *us)
if (srb->cmnd[0] == MODE_SENSE) { if (srb->cmnd[0] == MODE_SENSE) {
US_DEBUGP("datafab_transport: MODE_SENSE_6 detected\n"); US_DEBUGP("datafab_transport: MODE_SENSE_6 detected\n");
return datafab_handle_mode_sense(us, srb, TRUE); return datafab_handle_mode_sense(us, srb, 1);
} }
if (srb->cmnd[0] == MODE_SENSE_10) { if (srb->cmnd[0] == MODE_SENSE_10) {
US_DEBUGP("datafab_transport: MODE_SENSE_10 detected\n"); US_DEBUGP("datafab_transport: MODE_SENSE_10 detected\n");
return datafab_handle_mode_sense(us, srb, FALSE); return datafab_handle_mode_sense(us, srb, 0);
} }
if (srb->cmnd[0] == ALLOW_MEDIUM_REMOVAL) { if (srb->cmnd[0] == ALLOW_MEDIUM_REMOVAL) {
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#ifndef _USB_DATAFAB_MDCFE_B_H #ifndef _USB_DATAFAB_MDCFE_B_H
#define _USB_DATAFAB_MDCFE_B_H #define _USB_DATAFAB_MDCFE_B_H
extern int datafab_transport(Scsi_Cmnd *srb, struct us_data *us); extern int datafab_transport(struct scsi_cmnd *srb, struct us_data *us);
struct datafab_info { struct datafab_info {
unsigned long sectors; // total sector count unsigned long sectors; // total sector count
......
...@@ -44,9 +44,15 @@ ...@@ -44,9 +44,15 @@
* 675 Mass Ave, Cambridge, MA 02139, USA. * 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <linux/cdrom.h>
#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
#include "debug.h" #include "debug.h"
#include "scsi.h"
void usb_stor_show_command(Scsi_Cmnd *srb) void usb_stor_show_command(struct scsi_cmnd *srb)
{ {
char *what = NULL; char *what = NULL;
int i; int i;
......
...@@ -46,13 +46,13 @@ ...@@ -46,13 +46,13 @@
#include <linux/config.h> #include <linux/config.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/cdrom.h>
#include "usb.h" struct scsi_cmnd;
#define USB_STORAGE "usb-storage: " #define USB_STORAGE "usb-storage: "
#ifdef CONFIG_USB_STORAGE_DEBUG #ifdef CONFIG_USB_STORAGE_DEBUG
void usb_stor_show_command(Scsi_Cmnd *srb); void usb_stor_show_command(struct scsi_cmnd *srb);
void usb_stor_show_sense( unsigned char key, void usb_stor_show_sense( unsigned char key,
unsigned char asc, unsigned char ascq ); unsigned char asc, unsigned char ascq );
#define US_DEBUGP(x...) printk( KERN_DEBUG USB_STORAGE x ) #define US_DEBUGP(x...) printk( KERN_DEBUG USB_STORAGE x )
......
...@@ -30,6 +30,10 @@ ...@@ -30,6 +30,10 @@
*/ */
#include <linux/config.h> #include <linux/config.h>
#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
#include <scsi/scsi_device.h>
#include "transport.h" #include "transport.h"
#include "protocol.h" #include "protocol.h"
#include "usb.h" #include "usb.h"
...@@ -41,7 +45,7 @@ ...@@ -41,7 +45,7 @@
* Transport for the Microtech DPCM-USB * Transport for the Microtech DPCM-USB
* *
*/ */
int dpcm_transport(Scsi_Cmnd *srb, struct us_data *us) int dpcm_transport(struct scsi_cmnd *srb, struct us_data *us)
{ {
int ret; int ret;
......
...@@ -29,6 +29,6 @@ ...@@ -29,6 +29,6 @@
#ifndef _MICROTECH_DPCM_USB_H #ifndef _MICROTECH_DPCM_USB_H
#define _MICROTECH_DPCM_USB_H #define _MICROTECH_DPCM_USB_H
extern int dpcm_transport(Scsi_Cmnd *srb, struct us_data *us); extern int dpcm_transport(struct scsi_cmnd *srb, struct us_data *us);
#endif #endif
...@@ -29,12 +29,16 @@ ...@@ -29,12 +29,16 @@
*/ */
#include <linux/config.h> #include <linux/config.h>
#include <linux/hdreg.h>
#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
#include "transport.h" #include "transport.h"
#include "protocol.h" #include "protocol.h"
#include "usb.h" #include "usb.h"
#include "debug.h" #include "debug.h"
#include "freecom.h" #include "freecom.h"
#include "linux/hdreg.h"
#ifdef CONFIG_USB_STORAGE_DEBUG #ifdef CONFIG_USB_STORAGE_DEBUG
static void pdump (void *, int); static void pdump (void *, int);
...@@ -105,7 +109,7 @@ struct freecom_status { ...@@ -105,7 +109,7 @@ struct freecom_status {
#define FCM_STATUS_PACKET_LENGTH 4 #define FCM_STATUS_PACKET_LENGTH 4
static int static int
freecom_readdata (Scsi_Cmnd *srb, struct us_data *us, freecom_readdata (struct scsi_cmnd *srb, struct us_data *us,
unsigned int ipipe, unsigned int opipe, int count) unsigned int ipipe, unsigned int opipe, int count)
{ {
struct freecom_xfer_wrap *fxfr = struct freecom_xfer_wrap *fxfr =
...@@ -139,7 +143,7 @@ freecom_readdata (Scsi_Cmnd *srb, struct us_data *us, ...@@ -139,7 +143,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 (struct scsi_cmnd *srb, struct us_data *us,
int unsigned ipipe, unsigned int opipe, int count) int unsigned ipipe, unsigned int opipe, int count)
{ {
struct freecom_xfer_wrap *fxfr = struct freecom_xfer_wrap *fxfr =
...@@ -176,7 +180,7 @@ freecom_writedata (Scsi_Cmnd *srb, struct us_data *us, ...@@ -176,7 +180,7 @@ freecom_writedata (Scsi_Cmnd *srb, struct us_data *us,
* Transport for the Freecom USB/IDE adaptor. * Transport for the Freecom USB/IDE adaptor.
* *
*/ */
int freecom_transport(Scsi_Cmnd *srb, struct us_data *us) int freecom_transport(struct 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;
...@@ -302,7 +306,7 @@ int freecom_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -302,7 +306,7 @@ int freecom_transport(Scsi_Cmnd *srb, struct us_data *us)
* move in. */ * move in. */
switch (us->srb->sc_data_direction) { switch (us->srb->sc_data_direction) {
case SCSI_DATA_READ: case DMA_FROM_DEVICE:
/* catch bogus "read 0 length" case */ /* catch bogus "read 0 length" case */
if (!length) if (!length)
break; break;
...@@ -334,7 +338,7 @@ int freecom_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -334,7 +338,7 @@ int freecom_transport(Scsi_Cmnd *srb, struct us_data *us)
US_DEBUGP("Transfer happy\n"); US_DEBUGP("Transfer happy\n");
break; break;
case SCSI_DATA_WRITE: case DMA_TO_DEVICE:
/* catch bogus "write 0 length" case */ /* catch bogus "write 0 length" case */
if (!length) if (!length)
break; break;
...@@ -364,7 +368,7 @@ int freecom_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -364,7 +368,7 @@ int freecom_transport(Scsi_Cmnd *srb, struct us_data *us)
break; break;
case SCSI_DATA_NONE: case DMA_NONE:
/* Easy, do nothing. */ /* Easy, do nothing. */
break; break;
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#ifndef _FREECOM_USB_H #ifndef _FREECOM_USB_H
#define _FREECOM_USB_H #define _FREECOM_USB_H
extern int freecom_transport(Scsi_Cmnd *srb, struct us_data *us); extern int freecom_transport(struct scsi_cmnd *srb, struct us_data *us);
extern int usb_stor_freecom_reset(struct us_data *us); extern int usb_stor_freecom_reset(struct us_data *us);
extern int freecom_init (struct us_data *us); extern int freecom_init (struct us_data *us);
......
...@@ -44,6 +44,16 @@ ...@@ -44,6 +44,16 @@
/* Include files */ /* Include files */
#include <linux/jiffies.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/hdreg.h>
#include <linux/ide.h>
#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
#include <scsi/scsi_device.h>
#include "transport.h" #include "transport.h"
#include "protocol.h" #include "protocol.h"
#include "usb.h" #include "usb.h"
...@@ -51,11 +61,6 @@ ...@@ -51,11 +61,6 @@
#include "scsiglue.h" #include "scsiglue.h"
#include "isd200.h" #include "isd200.h"
#include <linux/jiffies.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/hdreg.h>
#include <linux/ide.h>
/* Timeout defines (in Seconds) */ /* Timeout defines (in Seconds) */
...@@ -349,7 +354,7 @@ struct sense_data { ...@@ -349,7 +354,7 @@ struct sense_data {
* RETURNS: * RETURNS:
* void * void
*/ */
static void isd200_build_sense(struct us_data *us, Scsi_Cmnd *srb) static void isd200_build_sense(struct us_data *us, struct scsi_cmnd *srb)
{ {
struct isd200_info *info = (struct isd200_info *)us->extra; struct isd200_info *info = (struct isd200_info *)us->extra;
struct sense_data *buf = (struct sense_data *) &srb->sense_buffer[0]; struct sense_data *buf = (struct sense_data *) &srb->sense_buffer[0];
...@@ -427,7 +432,7 @@ static int isd200_action( struct us_data *us, int action, ...@@ -427,7 +432,7 @@ static int isd200_action( struct us_data *us, int action,
ata.generic.RegisterSelect = ata.generic.RegisterSelect =
REG_CYLINDER_LOW | REG_CYLINDER_HIGH | REG_CYLINDER_LOW | REG_CYLINDER_HIGH |
REG_STATUS | REG_ERROR; REG_STATUS | REG_ERROR;
srb->sc_data_direction = SCSI_DATA_READ; srb->sc_data_direction = DMA_FROM_DEVICE;
srb->request_buffer = pointer; srb->request_buffer = pointer;
srb->request_bufflen = value; srb->request_bufflen = value;
break; break;
...@@ -439,7 +444,7 @@ static int isd200_action( struct us_data *us, int action, ...@@ -439,7 +444,7 @@ static int isd200_action( struct us_data *us, int action,
ACTION_SELECT_5; ACTION_SELECT_5;
ata.generic.RegisterSelect = REG_DEVICE_HEAD; ata.generic.RegisterSelect = REG_DEVICE_HEAD;
ata.write.DeviceHeadByte = value; ata.write.DeviceHeadByte = value;
srb->sc_data_direction = SCSI_DATA_NONE; srb->sc_data_direction = DMA_NONE;
break; break;
case ACTION_RESET: case ACTION_RESET:
...@@ -448,7 +453,7 @@ static int isd200_action( struct us_data *us, int action, ...@@ -448,7 +453,7 @@ static int isd200_action( struct us_data *us, int action,
ACTION_SELECT_3|ACTION_SELECT_4; ACTION_SELECT_3|ACTION_SELECT_4;
ata.generic.RegisterSelect = REG_DEVICE_CONTROL; ata.generic.RegisterSelect = REG_DEVICE_CONTROL;
ata.write.DeviceControlByte = ATA_DC_RESET_CONTROLLER; ata.write.DeviceControlByte = ATA_DC_RESET_CONTROLLER;
srb->sc_data_direction = SCSI_DATA_NONE; srb->sc_data_direction = DMA_NONE;
break; break;
case ACTION_REENABLE: case ACTION_REENABLE:
...@@ -457,7 +462,7 @@ static int isd200_action( struct us_data *us, int action, ...@@ -457,7 +462,7 @@ static int isd200_action( struct us_data *us, int action,
ACTION_SELECT_3|ACTION_SELECT_4; ACTION_SELECT_3|ACTION_SELECT_4;
ata.generic.RegisterSelect = REG_DEVICE_CONTROL; ata.generic.RegisterSelect = REG_DEVICE_CONTROL;
ata.write.DeviceControlByte = ATA_DC_REENABLE_CONTROLLER; ata.write.DeviceControlByte = ATA_DC_REENABLE_CONTROLLER;
srb->sc_data_direction = SCSI_DATA_NONE; srb->sc_data_direction = DMA_NONE;
break; break;
case ACTION_SOFT_RESET: case ACTION_SOFT_RESET:
...@@ -466,14 +471,14 @@ static int isd200_action( struct us_data *us, int action, ...@@ -466,14 +471,14 @@ static int isd200_action( struct us_data *us, int action,
ata.generic.RegisterSelect = REG_DEVICE_HEAD | REG_COMMAND; ata.generic.RegisterSelect = REG_DEVICE_HEAD | REG_COMMAND;
ata.write.DeviceHeadByte = info->DeviceHead; ata.write.DeviceHeadByte = info->DeviceHead;
ata.write.CommandByte = WIN_SRST; ata.write.CommandByte = WIN_SRST;
srb->sc_data_direction = SCSI_DATA_NONE; srb->sc_data_direction = DMA_NONE;
break; break;
case ACTION_IDENTIFY: case ACTION_IDENTIFY:
US_DEBUGP(" isd200_action(IDENTIFY)\n"); US_DEBUGP(" isd200_action(IDENTIFY)\n");
ata.generic.RegisterSelect = REG_COMMAND; ata.generic.RegisterSelect = REG_COMMAND;
ata.write.CommandByte = WIN_IDENTIFY; ata.write.CommandByte = WIN_IDENTIFY;
srb->sc_data_direction = SCSI_DATA_READ; srb->sc_data_direction = DMA_FROM_DEVICE;
srb->request_buffer = (void *) info->id; srb->request_buffer = (void *) info->id;
srb->request_bufflen = sizeof(struct hd_driveid); srb->request_bufflen = sizeof(struct hd_driveid);
break; break;
...@@ -535,7 +540,7 @@ static int isd200_read_regs( struct us_data *us ) ...@@ -535,7 +540,7 @@ static int isd200_read_regs( struct us_data *us )
* the device and receive the response. * the device and receive the response.
*/ */
static void isd200_invoke_transport( struct us_data *us, static void isd200_invoke_transport( struct us_data *us,
Scsi_Cmnd *srb, struct scsi_cmnd *srb,
union ata_cdb *ataCdb ) union ata_cdb *ataCdb )
{ {
int need_auto_sense = 0; int need_auto_sense = 0;
...@@ -839,7 +844,7 @@ static int isd200_try_enum(struct us_data *us, unsigned char master_slave, ...@@ -839,7 +844,7 @@ static int isd200_try_enum(struct us_data *us, unsigned char master_slave,
unsigned long endTime; unsigned long endTime;
struct isd200_info *info = (struct isd200_info *)us->extra; struct isd200_info *info = (struct isd200_info *)us->extra;
unsigned char *regs = info->RegsBuf; unsigned char *regs = info->RegsBuf;
int recheckAsMaster = FALSE; int recheckAsMaster = 0;
if ( detect ) if ( detect )
endTime = jiffies + ISD200_ENUM_DETECT_TIMEOUT * HZ; endTime = jiffies + ISD200_ENUM_DETECT_TIMEOUT * HZ;
...@@ -847,7 +852,7 @@ static int isd200_try_enum(struct us_data *us, unsigned char master_slave, ...@@ -847,7 +852,7 @@ static int isd200_try_enum(struct us_data *us, unsigned char master_slave,
endTime = jiffies + ISD200_ENUM_BSY_TIMEOUT * HZ; endTime = jiffies + ISD200_ENUM_BSY_TIMEOUT * HZ;
/* loop until we detect !BSY or timeout */ /* loop until we detect !BSY or timeout */
while(TRUE) { while(1) {
#ifdef CONFIG_USB_STORAGE_DEBUG #ifdef CONFIG_USB_STORAGE_DEBUG
char* mstr = master_slave == ATA_ADDRESS_DEVHEAD_STD ? char* mstr = master_slave == ATA_ADDRESS_DEVHEAD_STD ?
"Master" : "Slave"; "Master" : "Slave";
...@@ -899,9 +904,9 @@ static int isd200_try_enum(struct us_data *us, unsigned char master_slave, ...@@ -899,9 +904,9 @@ static int isd200_try_enum(struct us_data *us, unsigned char master_slave,
itself okay as a master also itself okay as a master also
*/ */
if ((master_slave & ATA_ADDRESS_DEVHEAD_SLAVE) && if ((master_slave & ATA_ADDRESS_DEVHEAD_SLAVE) &&
(recheckAsMaster == FALSE)) { !recheckAsMaster) {
US_DEBUGP(" Identified ATAPI device as slave. Rechecking again as master\n"); US_DEBUGP(" Identified ATAPI device as slave. Rechecking again as master\n");
recheckAsMaster = TRUE; recheckAsMaster = 1;
master_slave = ATA_ADDRESS_DEVHEAD_STD; master_slave = ATA_ADDRESS_DEVHEAD_STD;
} else { } else {
US_DEBUGP(" Identified ATAPI device\n"); US_DEBUGP(" Identified ATAPI device\n");
...@@ -948,15 +953,15 @@ static int isd200_manual_enum(struct us_data *us) ...@@ -948,15 +953,15 @@ static int isd200_manual_enum(struct us_data *us)
if (retStatus == ISD200_GOOD) { if (retStatus == ISD200_GOOD) {
int isslave; int isslave;
/* master or slave? */ /* master or slave? */
retStatus = isd200_try_enum( us, ATA_ADDRESS_DEVHEAD_STD, FALSE ); retStatus = isd200_try_enum( us, ATA_ADDRESS_DEVHEAD_STD, 0);
if (retStatus == ISD200_GOOD) if (retStatus == ISD200_GOOD)
retStatus = isd200_try_enum( us, ATA_ADDRESS_DEVHEAD_SLAVE, FALSE ); retStatus = isd200_try_enum( us, ATA_ADDRESS_DEVHEAD_SLAVE, 0);
if (retStatus == ISD200_GOOD) { if (retStatus == ISD200_GOOD) {
retStatus = isd200_srst(us); retStatus = isd200_srst(us);
if (retStatus == ISD200_GOOD) if (retStatus == ISD200_GOOD)
/* ata or atapi? */ /* ata or atapi? */
retStatus = isd200_try_enum( us, ATA_ADDRESS_DEVHEAD_STD, TRUE ); retStatus = isd200_try_enum( us, ATA_ADDRESS_DEVHEAD_STD, 1);
} }
isslave = (info->DeviceHead & ATA_ADDRESS_DEVHEAD_SLAVE) ? 1 : 0; isslave = (info->DeviceHead & ATA_ADDRESS_DEVHEAD_SLAVE) ? 1 : 0;
...@@ -1121,15 +1126,15 @@ static int isd200_get_inquiry_data( struct us_data *us ) ...@@ -1121,15 +1126,15 @@ static int isd200_get_inquiry_data( struct us_data *us )
* Translate SCSI commands to ATA commands. * Translate SCSI commands to ATA commands.
* *
* RETURNS: * RETURNS:
* TRUE if the command needs to be sent to the transport layer * 1 if the command needs to be sent to the transport layer
* FALSE otherwise * 0 otherwise
*/ */
static int isd200_scsi_to_ata(Scsi_Cmnd *srb, struct us_data *us, static int isd200_scsi_to_ata(struct scsi_cmnd *srb, struct us_data *us,
union ata_cdb * ataCdb) union ata_cdb * ataCdb)
{ {
struct isd200_info *info = (struct isd200_info *)us->extra; struct isd200_info *info = (struct isd200_info *)us->extra;
struct hd_driveid *id = info->id; struct hd_driveid *id = info->id;
int sendToTransport = TRUE; int sendToTransport = 1;
unsigned char sectnum, head; unsigned char sectnum, head;
unsigned short cylinder; unsigned short cylinder;
unsigned long lba; unsigned long lba;
...@@ -1147,7 +1152,7 @@ static int isd200_scsi_to_ata(Scsi_Cmnd *srb, struct us_data *us, ...@@ -1147,7 +1152,7 @@ static int isd200_scsi_to_ata(Scsi_Cmnd *srb, struct us_data *us,
usb_stor_set_xfer_buf((unsigned char *) &info->InquiryData, usb_stor_set_xfer_buf((unsigned char *) &info->InquiryData,
sizeof(info->InquiryData), srb); sizeof(info->InquiryData), srb);
srb->result = SAM_STAT_GOOD; srb->result = SAM_STAT_GOOD;
sendToTransport = FALSE; sendToTransport = 0;
break; break;
case MODE_SENSE: case MODE_SENSE:
...@@ -1167,7 +1172,7 @@ static int isd200_scsi_to_ata(Scsi_Cmnd *srb, struct us_data *us, ...@@ -1167,7 +1172,7 @@ static int isd200_scsi_to_ata(Scsi_Cmnd *srb, struct us_data *us,
} else { } else {
US_DEBUGP(" Media Status not supported, just report okay\n"); US_DEBUGP(" Media Status not supported, just report okay\n");
srb->result = SAM_STAT_GOOD; srb->result = SAM_STAT_GOOD;
sendToTransport = FALSE; sendToTransport = 0;
} }
break; break;
...@@ -1185,7 +1190,7 @@ static int isd200_scsi_to_ata(Scsi_Cmnd *srb, struct us_data *us, ...@@ -1185,7 +1190,7 @@ static int isd200_scsi_to_ata(Scsi_Cmnd *srb, struct us_data *us,
} else { } else {
US_DEBUGP(" Media Status not supported, just report okay\n"); US_DEBUGP(" Media Status not supported, just report okay\n");
srb->result = SAM_STAT_GOOD; srb->result = SAM_STAT_GOOD;
sendToTransport = FALSE; sendToTransport = 0;
} }
break; break;
...@@ -1209,7 +1214,7 @@ static int isd200_scsi_to_ata(Scsi_Cmnd *srb, struct us_data *us, ...@@ -1209,7 +1214,7 @@ static int isd200_scsi_to_ata(Scsi_Cmnd *srb, struct us_data *us,
usb_stor_set_xfer_buf((unsigned char *) &readCapacityData, usb_stor_set_xfer_buf((unsigned char *) &readCapacityData,
sizeof(readCapacityData), srb); sizeof(readCapacityData), srb);
srb->result = SAM_STAT_GOOD; srb->result = SAM_STAT_GOOD;
sendToTransport = FALSE; sendToTransport = 0;
} }
break; break;
...@@ -1293,7 +1298,7 @@ static int isd200_scsi_to_ata(Scsi_Cmnd *srb, struct us_data *us, ...@@ -1293,7 +1298,7 @@ static int isd200_scsi_to_ata(Scsi_Cmnd *srb, struct us_data *us,
} else { } else {
US_DEBUGP(" Not removeable media, just report okay\n"); US_DEBUGP(" Not removeable media, just report okay\n");
srb->result = SAM_STAT_GOOD; srb->result = SAM_STAT_GOOD;
sendToTransport = FALSE; sendToTransport = 0;
} }
break; break;
...@@ -1319,14 +1324,14 @@ static int isd200_scsi_to_ata(Scsi_Cmnd *srb, struct us_data *us, ...@@ -1319,14 +1324,14 @@ static int isd200_scsi_to_ata(Scsi_Cmnd *srb, struct us_data *us,
} else { } else {
US_DEBUGP(" Nothing to do, just report okay\n"); US_DEBUGP(" Nothing to do, just report okay\n");
srb->result = SAM_STAT_GOOD; srb->result = SAM_STAT_GOOD;
sendToTransport = FALSE; sendToTransport = 0;
} }
break; break;
default: default:
US_DEBUGP("Unsupported SCSI command - 0x%X\n", srb->cmnd[0]); US_DEBUGP("Unsupported SCSI command - 0x%X\n", srb->cmnd[0]);
srb->result = DID_ERROR << 16; srb->result = DID_ERROR << 16;
sendToTransport = FALSE; sendToTransport = 0;
break; break;
} }
...@@ -1424,9 +1429,9 @@ int isd200_Initialization(struct us_data *us) ...@@ -1424,9 +1429,9 @@ int isd200_Initialization(struct us_data *us)
* *
*/ */
void isd200_ata_command(Scsi_Cmnd *srb, struct us_data *us) void isd200_ata_command(struct scsi_cmnd *srb, struct us_data *us)
{ {
int sendToTransport = TRUE; int sendToTransport = 1;
union ata_cdb ataCdb; union ata_cdb ataCdb;
/* Make sure driver was initialized */ /* Make sure driver was initialized */
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#ifndef _USB_ISD200_H #ifndef _USB_ISD200_H
#define _USB_ISD200_H #define _USB_ISD200_H
extern void isd200_ata_command(Scsi_Cmnd *srb, struct us_data *us); extern void isd200_ata_command(struct scsi_cmnd *srb, struct us_data *us);
extern int isd200_Initialization(struct us_data *us); extern int isd200_Initialization(struct us_data *us);
#endif #endif
...@@ -47,15 +47,19 @@ ...@@ -47,15 +47,19 @@
* in that routine. * in that routine.
*/ */
#include <linux/sched.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
#include "transport.h" #include "transport.h"
#include "protocol.h" #include "protocol.h"
#include "usb.h" #include "usb.h"
#include "debug.h" #include "debug.h"
#include "jumpshot.h" #include "jumpshot.h"
#include <linux/sched.h>
#include <linux/errno.h>
#include <linux/slab.h>
static inline int jumpshot_bulk_read(struct us_data *us, static inline int jumpshot_bulk_read(struct us_data *us,
unsigned char *data, unsigned char *data,
...@@ -319,7 +323,7 @@ static int jumpshot_id_device(struct us_data *us, ...@@ -319,7 +323,7 @@ static int jumpshot_id_device(struct us_data *us,
} }
static int jumpshot_handle_mode_sense(struct us_data *us, static int jumpshot_handle_mode_sense(struct us_data *us,
Scsi_Cmnd * srb, struct scsi_cmnd * srb,
int sense_6) int sense_6)
{ {
static unsigned char rw_err_page[12] = { static unsigned char rw_err_page[12] = {
...@@ -426,7 +430,7 @@ static void jumpshot_info_destructor(void *extra) ...@@ -426,7 +430,7 @@ static void jumpshot_info_destructor(void *extra)
// Transport for the Lexar 'Jumpshot' // Transport for the Lexar 'Jumpshot'
// //
int jumpshot_transport(Scsi_Cmnd * srb, struct us_data *us) int jumpshot_transport(struct scsi_cmnd * srb, struct us_data *us)
{ {
struct jumpshot_info *info; struct jumpshot_info *info;
int rc; int rc;
...@@ -551,12 +555,12 @@ int jumpshot_transport(Scsi_Cmnd * srb, struct us_data *us) ...@@ -551,12 +555,12 @@ int jumpshot_transport(Scsi_Cmnd * srb, struct us_data *us)
if (srb->cmnd[0] == MODE_SENSE) { if (srb->cmnd[0] == MODE_SENSE) {
US_DEBUGP("jumpshot_transport: MODE_SENSE_6 detected\n"); US_DEBUGP("jumpshot_transport: MODE_SENSE_6 detected\n");
return jumpshot_handle_mode_sense(us, srb, TRUE); return jumpshot_handle_mode_sense(us, srb, 1);
} }
if (srb->cmnd[0] == MODE_SENSE_10) { if (srb->cmnd[0] == MODE_SENSE_10) {
US_DEBUGP("jumpshot_transport: MODE_SENSE_10 detected\n"); US_DEBUGP("jumpshot_transport: MODE_SENSE_10 detected\n");
return jumpshot_handle_mode_sense(us, srb, FALSE); return jumpshot_handle_mode_sense(us, srb, 0);
} }
if (srb->cmnd[0] == ALLOW_MEDIUM_REMOVAL) { if (srb->cmnd[0] == ALLOW_MEDIUM_REMOVAL) {
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#ifndef _USB_JUMPSHOT_H #ifndef _USB_JUMPSHOT_H
#define _USB_JUMPSHOT_H #define _USB_JUMPSHOT_H
extern int jumpshot_transport(Scsi_Cmnd *srb, struct us_data *us); extern int jumpshot_transport(struct scsi_cmnd *srb, struct us_data *us);
struct jumpshot_info { struct jumpshot_info {
unsigned long sectors; // total sector count unsigned long sectors; // total sector count
......
...@@ -45,6 +45,8 @@ ...@@ -45,6 +45,8 @@
*/ */
#include <linux/highmem.h> #include <linux/highmem.h>
#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
#include "protocol.h" #include "protocol.h"
#include "usb.h" #include "usb.h"
#include "debug.h" #include "debug.h"
...@@ -59,7 +61,7 @@ ...@@ -59,7 +61,7 @@
* Fix-up the return data from an INQUIRY command to show * Fix-up the return data from an INQUIRY command to show
* ANSI SCSI rev 2 so we don't confuse the SCSI layers above us * ANSI SCSI rev 2 so we don't confuse the SCSI layers above us
*/ */
static void fix_inquiry_data(Scsi_Cmnd *srb) static void fix_inquiry_data(struct scsi_cmnd *srb)
{ {
unsigned char databuf[3]; unsigned char databuf[3];
unsigned int index, offset; unsigned int index, offset;
...@@ -91,7 +93,7 @@ static void fix_inquiry_data(Scsi_Cmnd *srb) ...@@ -91,7 +93,7 @@ static void fix_inquiry_data(Scsi_Cmnd *srb)
* Fix-up the return data from a READ CAPACITY command. My Feiya reader * Fix-up the return data from a READ CAPACITY command. My Feiya reader
* returns a value that is 1 too large. * returns a value that is 1 too large.
*/ */
static void fix_read_capacity(Scsi_Cmnd *srb) static void fix_read_capacity(struct scsi_cmnd *srb)
{ {
unsigned int index, offset; unsigned int index, offset;
u32 c; u32 c;
...@@ -120,11 +122,11 @@ static void fix_read_capacity(Scsi_Cmnd *srb) ...@@ -120,11 +122,11 @@ static void fix_read_capacity(Scsi_Cmnd *srb)
* Protocol routines * Protocol routines
***********************************************************************/ ***********************************************************************/
void usb_stor_qic157_command(Scsi_Cmnd *srb, struct us_data *us) void usb_stor_qic157_command(struct scsi_cmnd *srb, struct us_data *us)
{ {
/* Pad the ATAPI command with zeros /* Pad the ATAPI command with zeros
* *
* NOTE: This only works because a Scsi_Cmnd struct field contains * NOTE: This only works because a scsi_cmnd struct field contains
* a unsigned char cmnd[16], so we know we have storage available * a unsigned char cmnd[16], so we know we have storage available
*/ */
for (; srb->cmd_len<12; srb->cmd_len++) for (; srb->cmd_len<12; srb->cmd_len++)
...@@ -141,11 +143,11 @@ void usb_stor_qic157_command(Scsi_Cmnd *srb, struct us_data *us) ...@@ -141,11 +143,11 @@ void usb_stor_qic157_command(Scsi_Cmnd *srb, struct us_data *us)
} }
} }
void usb_stor_ATAPI_command(Scsi_Cmnd *srb, struct us_data *us) void usb_stor_ATAPI_command(struct scsi_cmnd *srb, struct us_data *us)
{ {
/* Pad the ATAPI command with zeros /* Pad the ATAPI command with zeros
* *
* NOTE: This only works because a Scsi_Cmnd struct field contains * NOTE: This only works because a scsi_cmnd struct field contains
* a unsigned char cmnd[16], so we know we have storage available * a unsigned char cmnd[16], so we know we have storage available
*/ */
...@@ -166,12 +168,12 @@ void usb_stor_ATAPI_command(Scsi_Cmnd *srb, struct us_data *us) ...@@ -166,12 +168,12 @@ void usb_stor_ATAPI_command(Scsi_Cmnd *srb, struct us_data *us)
} }
void usb_stor_ufi_command(Scsi_Cmnd *srb, struct us_data *us) void usb_stor_ufi_command(struct scsi_cmnd *srb, struct us_data *us)
{ {
/* fix some commands -- this is a form of mode translation /* fix some commands -- this is a form of mode translation
* UFI devices only accept 12 byte long commands * UFI devices only accept 12 byte long commands
* *
* NOTE: This only works because a Scsi_Cmnd struct field contains * NOTE: This only works because a scsi_cmnd struct field contains
* a unsigned char cmnd[16], so we know we have storage available * a unsigned char cmnd[16], so we know we have storage available
*/ */
...@@ -213,7 +215,8 @@ void usb_stor_ufi_command(Scsi_Cmnd *srb, struct us_data *us) ...@@ -213,7 +215,8 @@ void usb_stor_ufi_command(Scsi_Cmnd *srb, struct us_data *us)
} }
} }
void usb_stor_transparent_scsi_command(Scsi_Cmnd *srb, struct us_data *us) void usb_stor_transparent_scsi_command(struct scsi_cmnd *srb,
struct us_data *us)
{ {
/* send the command to the transport layer */ /* send the command to the transport layer */
usb_stor_invoke_transport(srb, us); usb_stor_invoke_transport(srb, us);
...@@ -241,7 +244,7 @@ void usb_stor_transparent_scsi_command(Scsi_Cmnd *srb, struct us_data *us) ...@@ -241,7 +244,7 @@ void usb_stor_transparent_scsi_command(Scsi_Cmnd *srb, struct us_data *us)
* pick up from where this one left off. */ * pick up from where this one left off. */
unsigned int usb_stor_access_xfer_buf(unsigned char *buffer, unsigned int usb_stor_access_xfer_buf(unsigned char *buffer,
unsigned int buflen, Scsi_Cmnd *srb, unsigned int *index, unsigned int buflen, struct scsi_cmnd *srb, unsigned int *index,
unsigned int *offset, enum xfer_buf_dir dir) unsigned int *offset, enum xfer_buf_dir dir)
{ {
unsigned int cnt; unsigned int cnt;
...@@ -327,7 +330,7 @@ unsigned int usb_stor_access_xfer_buf(unsigned char *buffer, ...@@ -327,7 +330,7 @@ unsigned int usb_stor_access_xfer_buf(unsigned char *buffer,
/* Store the contents of buffer into srb's transfer buffer and set the /* Store the contents of buffer into srb's transfer buffer and set the
* SCSI residue. */ * SCSI residue. */
void usb_stor_set_xfer_buf(unsigned char *buffer, void usb_stor_set_xfer_buf(unsigned char *buffer,
unsigned int buflen, Scsi_Cmnd *srb) unsigned int buflen, struct scsi_cmnd *srb)
{ {
unsigned int index = 0, offset = 0; unsigned int index = 0, offset = 0;
......
...@@ -41,9 +41,8 @@ ...@@ -41,9 +41,8 @@
#ifndef _PROTOCOL_H_ #ifndef _PROTOCOL_H_
#define _PROTOCOL_H_ #define _PROTOCOL_H_
#include <linux/blkdev.h> struct scsi_cmnd;
#include "scsi.h" struct us_data;
#include "usb.h"
/* Sub Classes */ /* Sub Classes */
...@@ -60,18 +59,19 @@ ...@@ -60,18 +59,19 @@
#define US_SC_DEVICE 0xff /* Use device's value */ #define US_SC_DEVICE 0xff /* Use device's value */
/* Protocol handling routines */ /* Protocol handling routines */
extern void usb_stor_ATAPI_command(Scsi_Cmnd*, struct us_data*); extern void usb_stor_ATAPI_command(struct scsi_cmnd*, struct us_data*);
extern void usb_stor_qic157_command(Scsi_Cmnd*, struct us_data*); extern void usb_stor_qic157_command(struct scsi_cmnd*, struct us_data*);
extern void usb_stor_ufi_command(Scsi_Cmnd*, struct us_data*); extern void usb_stor_ufi_command(struct scsi_cmnd*, struct us_data*);
extern void usb_stor_transparent_scsi_command(Scsi_Cmnd*, struct us_data*); extern void usb_stor_transparent_scsi_command(struct scsi_cmnd*,
struct us_data*);
/* Scsi_Cmnd transfer buffer access utilities */ /* struct scsi_cmnd transfer buffer access utilities */
enum xfer_buf_dir {TO_XFER_BUF, FROM_XFER_BUF}; enum xfer_buf_dir {TO_XFER_BUF, FROM_XFER_BUF};
extern unsigned int usb_stor_access_xfer_buf(unsigned char *buffer, extern unsigned int usb_stor_access_xfer_buf(unsigned char *buffer,
unsigned int buflen, Scsi_Cmnd *srb, unsigned int *index, unsigned int buflen, struct scsi_cmnd *srb, unsigned int *index,
unsigned int *offset, enum xfer_buf_dir dir); unsigned int *offset, enum xfer_buf_dir dir);
extern void usb_stor_set_xfer_buf(unsigned char *buffer, extern void usb_stor_set_xfer_buf(unsigned char *buffer,
unsigned int buflen, Scsi_Cmnd *srb); unsigned int buflen, struct scsi_cmnd *srb);
#endif #endif
...@@ -44,17 +44,23 @@ ...@@ -44,17 +44,23 @@
* with this program; if not, write to the Free Software Foundation, Inc., * with this program; if not, write to the Free Software Foundation, Inc.,
* 675 Mass Ave, Cambridge, MA 02139, USA. * 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include "scsiglue.h"
#include "usb.h"
#include "debug.h"
#include "transport.h"
#include "protocol.h"
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/module.h> #include <linux/module.h>
#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
#include <scsi/scsi_devinfo.h> #include <scsi/scsi_devinfo.h>
#include <scsi/scsi_device.h>
#include <scsi/scsi_eh.h>
#include <scsi/scsi_host.h> #include <scsi/scsi_host.h>
#include "scsiglue.h"
#include "usb.h"
#include "debug.h"
#include "transport.h"
#include "protocol.h"
/*********************************************************************** /***********************************************************************
* Host functions * Host functions
***********************************************************************/ ***********************************************************************/
...@@ -144,7 +150,8 @@ static int slave_configure(struct scsi_device *sdev) ...@@ -144,7 +150,8 @@ static int slave_configure(struct scsi_device *sdev)
/* queue a command */ /* queue a command */
/* This is always called with scsi_lock(srb->host) held */ /* This is always called with scsi_lock(srb->host) held */
static int queuecommand( Scsi_Cmnd *srb , void (*done)(Scsi_Cmnd *)) static int queuecommand(struct scsi_cmnd *srb,
void (*done)(struct scsi_cmnd *))
{ {
struct us_data *us = (struct us_data *)srb->device->host->hostdata[0]; struct us_data *us = (struct us_data *)srb->device->host->hostdata[0];
...@@ -174,7 +181,7 @@ static int queuecommand( Scsi_Cmnd *srb , void (*done)(Scsi_Cmnd *)) ...@@ -174,7 +181,7 @@ static int queuecommand( Scsi_Cmnd *srb , void (*done)(Scsi_Cmnd *))
/* Command abort */ /* Command abort */
/* This is always called with scsi_lock(srb->host) held */ /* This is always called with scsi_lock(srb->host) held */
static int command_abort( Scsi_Cmnd *srb ) static int command_abort(struct scsi_cmnd *srb )
{ {
struct Scsi_Host *host = srb->device->host; struct Scsi_Host *host = srb->device->host;
struct us_data *us = (struct us_data *) host->hostdata[0]; struct us_data *us = (struct us_data *) host->hostdata[0];
...@@ -221,7 +228,7 @@ static int command_abort( Scsi_Cmnd *srb ) ...@@ -221,7 +228,7 @@ static int command_abort( Scsi_Cmnd *srb )
/* This invokes the transport reset mechanism to reset the state of the /* This invokes the transport reset mechanism to reset the state of the
* device */ * device */
/* This is always called with scsi_lock(srb->host) held */ /* This is always called with scsi_lock(srb->host) held */
static int device_reset( Scsi_Cmnd *srb ) static int device_reset(struct scsi_cmnd *srb)
{ {
struct us_data *us = (struct us_data *)srb->device->host->hostdata[0]; struct us_data *us = (struct us_data *)srb->device->host->hostdata[0];
int result; int result;
...@@ -256,7 +263,7 @@ static int device_reset( Scsi_Cmnd *srb ) ...@@ -256,7 +263,7 @@ static int device_reset( Scsi_Cmnd *srb )
/* It refuses to work if there's more than one interface in /* It refuses to work if there's more than one interface in
* the device, so that other users are not affected. */ * the device, so that other users are not affected. */
/* This is always called with scsi_lock(srb->host) held */ /* This is always called with scsi_lock(srb->host) held */
static int bus_reset( Scsi_Cmnd *srb ) static int bus_reset(struct scsi_cmnd *srb)
{ {
struct us_data *us = (struct us_data *)srb->device->host->hostdata[0]; struct us_data *us = (struct us_data *)srb->device->host->hostdata[0];
int result; int result;
...@@ -442,10 +449,10 @@ struct scsi_host_template usb_stor_host_template = { ...@@ -442,10 +449,10 @@ struct scsi_host_template usb_stor_host_template = {
* periodically someone should test to see which setting is more * periodically someone should test to see which setting is more
* optimal. * optimal.
*/ */
.use_clustering = TRUE, .use_clustering = 1,
/* emulated HBA */ /* emulated HBA */
.emulated = TRUE, .emulated = 1,
/* we do our own delay after a device or bus reset */ /* we do our own delay after a device or bus reset */
.skip_settle_delay = 1, .skip_settle_delay = 1,
......
...@@ -41,17 +41,15 @@ ...@@ -41,17 +41,15 @@
#ifndef _SCSIGLUE_H_ #ifndef _SCSIGLUE_H_
#define _SCSIGLUE_H_ #define _SCSIGLUE_H_
#include <linux/blkdev.h>
#include "scsi.h"
#include <scsi/scsi_host.h> #include <scsi/scsi_host.h>
#include "usb.h"
struct us_data;
struct scsi_cmnd;
extern void usb_stor_report_device_reset(struct us_data *us); extern void usb_stor_report_device_reset(struct us_data *us);
extern unsigned char usb_stor_sense_notready[18]; extern unsigned char usb_stor_sense_notready[18];
extern unsigned char usb_stor_sense_invalidCDB[18]; extern unsigned char usb_stor_sense_invalidCDB[18];
extern struct scsi_host_template usb_stor_host_template; extern struct scsi_host_template usb_stor_host_template;
extern int usb_stor_scsiSense10to6(Scsi_Cmnd*);
extern int usb_stor_scsiSense6to10(Scsi_Cmnd*);
#endif #endif
...@@ -41,16 +41,19 @@ ...@@ -41,16 +41,19 @@
* EF: compute checksum (?) * EF: compute checksum (?)
*/ */
#include <linux/sched.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
#include "transport.h" #include "transport.h"
#include "protocol.h" #include "protocol.h"
#include "usb.h" #include "usb.h"
#include "debug.h" #include "debug.h"
#include "sddr09.h" #include "sddr09.h"
#include <linux/version.h>
#include <linux/sched.h>
#include <linux/errno.h>
#include <linux/slab.h>
#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)
...@@ -1401,7 +1404,7 @@ sddr09_init(struct us_data *us) { ...@@ -1401,7 +1404,7 @@ sddr09_init(struct us_data *us) {
/* /*
* Transport for the Sandisk SDDR-09 * Transport for the Sandisk SDDR-09
*/ */
int sddr09_transport(Scsi_Cmnd *srb, struct us_data *us) int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us)
{ {
static unsigned char sensekey = 0, sensecode = 0; static unsigned char sensekey = 0, sensecode = 0;
static unsigned char havefakesense = 0; static unsigned char havefakesense = 0;
...@@ -1581,13 +1584,13 @@ int sddr09_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -1581,13 +1584,13 @@ int sddr09_transport(Scsi_Cmnd *srb, struct us_data *us)
if (srb->request_bufflen == 0) if (srb->request_bufflen == 0)
return USB_STOR_TRANSPORT_GOOD; return USB_STOR_TRANSPORT_GOOD;
if (srb->sc_data_direction == SCSI_DATA_WRITE || if (srb->sc_data_direction == DMA_TO_DEVICE ||
srb->sc_data_direction == SCSI_DATA_READ) { srb->sc_data_direction == DMA_FROM_DEVICE) {
unsigned int pipe = (srb->sc_data_direction == SCSI_DATA_WRITE) unsigned int pipe = (srb->sc_data_direction == DMA_TO_DEVICE)
? us->send_bulk_pipe : us->recv_bulk_pipe; ? us->send_bulk_pipe : us->recv_bulk_pipe;
US_DEBUGP("SDDR09: %s %d bytes\n", US_DEBUGP("SDDR09: %s %d bytes\n",
(srb->sc_data_direction == SCSI_DATA_WRITE) ? (srb->sc_data_direction == DMA_TO_DEVICE) ?
"sending" : "receiving", "sending" : "receiving",
srb->request_bufflen); srb->request_bufflen);
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
/* Sandisk SDDR-09 stuff */ /* Sandisk SDDR-09 stuff */
extern int sddr09_transport(Scsi_Cmnd *srb, struct us_data *us); extern int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us);
struct sddr09_card_info { struct sddr09_card_info {
unsigned long capacity; /* Size of card in bytes */ unsigned long capacity; /* Size of card in bytes */
......
...@@ -24,15 +24,19 @@ ...@@ -24,15 +24,19 @@
* 675 Mass Ave, Cambridge, MA 02139, USA. * 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <linux/jiffies.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
#include "transport.h" #include "transport.h"
#include "protocol.h" #include "protocol.h"
#include "usb.h" #include "usb.h"
#include "debug.h" #include "debug.h"
#include "sddr55.h" #include "sddr55.h"
#include <linux/jiffies.h>
#include <linux/errno.h>
#include <linux/slab.h>
#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)
...@@ -74,7 +78,7 @@ static int ...@@ -74,7 +78,7 @@ static int
sddr55_bulk_transport(struct us_data *us, int direction, sddr55_bulk_transport(struct us_data *us, int direction,
unsigned char *data, unsigned int len) { unsigned char *data, unsigned int len) {
struct sddr55_card_info *info = (struct sddr55_card_info *)us->extra; struct sddr55_card_info *info = (struct sddr55_card_info *)us->extra;
unsigned int pipe = (direction == SCSI_DATA_READ) ? unsigned int pipe = (direction == DMA_FROM_DEVICE) ?
us->recv_bulk_pipe : us->send_bulk_pipe; us->recv_bulk_pipe : us->send_bulk_pipe;
if (!len) if (!len)
...@@ -99,7 +103,7 @@ static int sddr55_status(struct us_data *us) ...@@ -99,7 +103,7 @@ static int sddr55_status(struct us_data *us)
command[5] = 0xB0; command[5] = 0xB0;
command[7] = 0x80; command[7] = 0x80;
result = sddr55_bulk_transport(us, result = sddr55_bulk_transport(us,
SCSI_DATA_WRITE, command, 8); DMA_TO_DEVICE, command, 8);
US_DEBUGP("Result for send_command in status %d\n", US_DEBUGP("Result for send_command in status %d\n",
result); result);
...@@ -110,7 +114,7 @@ static int sddr55_status(struct us_data *us) ...@@ -110,7 +114,7 @@ static int sddr55_status(struct us_data *us)
} }
result = sddr55_bulk_transport(us, result = sddr55_bulk_transport(us,
SCSI_DATA_READ, status, 4); DMA_FROM_DEVICE, status, 4);
/* expect to get short transfer if no card fitted */ /* expect to get short transfer if no card fitted */
if (result == USB_STOR_XFER_SHORT || result == USB_STOR_XFER_STALLED) { if (result == USB_STOR_XFER_SHORT || result == USB_STOR_XFER_STALLED) {
...@@ -139,7 +143,7 @@ static int sddr55_status(struct us_data *us) ...@@ -139,7 +143,7 @@ static int sddr55_status(struct us_data *us)
/* now read status */ /* now read status */
result = sddr55_bulk_transport(us, result = sddr55_bulk_transport(us,
SCSI_DATA_READ, status, 2); DMA_FROM_DEVICE, status, 2);
if (result != USB_STOR_XFER_GOOD) { if (result != USB_STOR_XFER_GOOD) {
set_sense_info (4, 0, 0); /* hardware error */ set_sense_info (4, 0, 0); /* hardware error */
...@@ -215,7 +219,7 @@ static int sddr55_read_data(struct us_data *us, ...@@ -215,7 +219,7 @@ static int sddr55_read_data(struct us_data *us,
/* send command */ /* send command */
result = sddr55_bulk_transport(us, result = sddr55_bulk_transport(us,
SCSI_DATA_WRITE, command, 8); DMA_TO_DEVICE, command, 8);
US_DEBUGP("Result for send_command in read_data %d\n", US_DEBUGP("Result for send_command in read_data %d\n",
result); result);
...@@ -227,7 +231,7 @@ static int sddr55_read_data(struct us_data *us, ...@@ -227,7 +231,7 @@ static int sddr55_read_data(struct us_data *us,
/* read data */ /* read data */
result = sddr55_bulk_transport(us, result = sddr55_bulk_transport(us,
SCSI_DATA_READ, buffer, len); DMA_FROM_DEVICE, buffer, len);
if (result != USB_STOR_XFER_GOOD) { if (result != USB_STOR_XFER_GOOD) {
result = USB_STOR_TRANSPORT_ERROR; result = USB_STOR_TRANSPORT_ERROR;
...@@ -236,7 +240,7 @@ static int sddr55_read_data(struct us_data *us, ...@@ -236,7 +240,7 @@ static int sddr55_read_data(struct us_data *us,
/* now read status */ /* now read status */
result = sddr55_bulk_transport(us, result = sddr55_bulk_transport(us,
SCSI_DATA_READ, status, 2); DMA_FROM_DEVICE, status, 2);
if (result != USB_STOR_XFER_GOOD) { if (result != USB_STOR_XFER_GOOD) {
result = USB_STOR_TRANSPORT_ERROR; result = USB_STOR_TRANSPORT_ERROR;
...@@ -390,7 +394,7 @@ static int sddr55_write_data(struct us_data *us, ...@@ -390,7 +394,7 @@ static int sddr55_write_data(struct us_data *us,
/* send command */ /* send command */
result = sddr55_bulk_transport(us, result = sddr55_bulk_transport(us,
SCSI_DATA_WRITE, command, 8); DMA_TO_DEVICE, command, 8);
if (result != USB_STOR_XFER_GOOD) { if (result != USB_STOR_XFER_GOOD) {
US_DEBUGP("Result for send_command in write_data %d\n", US_DEBUGP("Result for send_command in write_data %d\n",
...@@ -404,7 +408,7 @@ static int sddr55_write_data(struct us_data *us, ...@@ -404,7 +408,7 @@ static int sddr55_write_data(struct us_data *us,
/* send the data */ /* send the data */
result = sddr55_bulk_transport(us, result = sddr55_bulk_transport(us,
SCSI_DATA_WRITE, buffer, len); DMA_TO_DEVICE, buffer, len);
if (result != USB_STOR_XFER_GOOD) { if (result != USB_STOR_XFER_GOOD) {
US_DEBUGP("Result for send_data in write_data %d\n", US_DEBUGP("Result for send_data in write_data %d\n",
...@@ -417,7 +421,7 @@ static int sddr55_write_data(struct us_data *us, ...@@ -417,7 +421,7 @@ static int sddr55_write_data(struct us_data *us,
} }
/* now read status */ /* now read status */
result = sddr55_bulk_transport(us, SCSI_DATA_READ, status, 6); result = sddr55_bulk_transport(us, DMA_FROM_DEVICE, status, 6);
if (result != USB_STOR_XFER_GOOD) { if (result != USB_STOR_XFER_GOOD) {
US_DEBUGP("Result for get_status in write_data %d\n", US_DEBUGP("Result for get_status in write_data %d\n",
...@@ -483,7 +487,7 @@ static int sddr55_read_deviceID(struct us_data *us, ...@@ -483,7 +487,7 @@ static int sddr55_read_deviceID(struct us_data *us,
memset(command, 0, 8); memset(command, 0, 8);
command[5] = 0xB0; command[5] = 0xB0;
command[7] = 0x84; command[7] = 0x84;
result = sddr55_bulk_transport(us, SCSI_DATA_WRITE, command, 8); result = sddr55_bulk_transport(us, DMA_TO_DEVICE, command, 8);
US_DEBUGP("Result of send_control for device ID is %d\n", US_DEBUGP("Result of send_control for device ID is %d\n",
result); result);
...@@ -492,7 +496,7 @@ static int sddr55_read_deviceID(struct us_data *us, ...@@ -492,7 +496,7 @@ static int sddr55_read_deviceID(struct us_data *us,
return USB_STOR_TRANSPORT_ERROR; return USB_STOR_TRANSPORT_ERROR;
result = sddr55_bulk_transport(us, result = sddr55_bulk_transport(us,
SCSI_DATA_READ, content, 4); DMA_FROM_DEVICE, content, 4);
if (result != USB_STOR_XFER_GOOD) if (result != USB_STOR_XFER_GOOD)
return USB_STOR_TRANSPORT_ERROR; return USB_STOR_TRANSPORT_ERROR;
...@@ -502,7 +506,7 @@ static int sddr55_read_deviceID(struct us_data *us, ...@@ -502,7 +506,7 @@ static int sddr55_read_deviceID(struct us_data *us,
if (content[0] != 0xff) { if (content[0] != 0xff) {
result = sddr55_bulk_transport(us, result = sddr55_bulk_transport(us,
SCSI_DATA_READ, content, 2); DMA_FROM_DEVICE, content, 2);
} }
return USB_STOR_TRANSPORT_GOOD; return USB_STOR_TRANSPORT_GOOD;
...@@ -624,21 +628,21 @@ static int sddr55_read_map(struct us_data *us) { ...@@ -624,21 +628,21 @@ static int sddr55_read_map(struct us_data *us) {
command[6] = numblocks * 2 / 256; command[6] = numblocks * 2 / 256;
command[7] = 0x8A; command[7] = 0x8A;
result = sddr55_bulk_transport(us, SCSI_DATA_WRITE, command, 8); result = sddr55_bulk_transport(us, DMA_TO_DEVICE, command, 8);
if ( result != USB_STOR_XFER_GOOD) { if ( result != USB_STOR_XFER_GOOD) {
kfree (buffer); kfree (buffer);
return -1; return -1;
} }
result = sddr55_bulk_transport(us, SCSI_DATA_READ, buffer, numblocks * 2); result = sddr55_bulk_transport(us, DMA_FROM_DEVICE, buffer, numblocks * 2);
if ( result != USB_STOR_XFER_GOOD) { if ( result != USB_STOR_XFER_GOOD) {
kfree (buffer); kfree (buffer);
return -1; return -1;
} }
result = sddr55_bulk_transport(us, SCSI_DATA_READ, command, 2); result = sddr55_bulk_transport(us, DMA_FROM_DEVICE, command, 2);
if ( result != USB_STOR_XFER_GOOD) { if ( result != USB_STOR_XFER_GOOD) {
kfree (buffer); kfree (buffer);
...@@ -734,7 +738,7 @@ static void sddr55_card_info_destructor(void *extra) { ...@@ -734,7 +738,7 @@ static void sddr55_card_info_destructor(void *extra) {
/* /*
* Transport for the Sandisk SDDR-55 * Transport for the Sandisk SDDR-55
*/ */
int sddr55_transport(Scsi_Cmnd *srb, struct us_data *us) int sddr55_transport(struct scsi_cmnd *srb, struct us_data *us)
{ {
int result; int result;
static unsigned char inquiry_response[8] = { static unsigned char inquiry_response[8] = {
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
/* Sandisk SDDR-55 stuff */ /* Sandisk SDDR-55 stuff */
extern int sddr55_transport(Scsi_Cmnd *srb, struct us_data *us); extern int sddr55_transport(struct scsi_cmnd *srb, struct us_data *us);
extern int sddr55_reset(struct us_data *us); extern int sddr55_reset(struct us_data *us);
#endif #endif
...@@ -39,16 +39,20 @@ ...@@ -39,16 +39,20 @@
* 675 Mass Ave, Cambridge, MA 02139, USA. * 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <linux/sched.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/cdrom.h>
#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
#include "transport.h" #include "transport.h"
#include "protocol.h" #include "protocol.h"
#include "usb.h" #include "usb.h"
#include "debug.h" #include "debug.h"
#include "shuttle_usbat.h" #include "shuttle_usbat.h"
#include <linux/sched.h>
#include <linux/errno.h>
#include <linux/slab.h>
#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)
...@@ -275,7 +279,7 @@ static int usbat_rw_block_test(struct us_data *us, ...@@ -275,7 +279,7 @@ static int usbat_rw_block_test(struct us_data *us,
int minutes) int minutes)
{ {
int result; int result;
unsigned int pipe = (direction == SCSI_DATA_READ) ? unsigned int pipe = (direction == DMA_FROM_DEVICE) ?
us->recv_bulk_pipe : us->send_bulk_pipe; us->recv_bulk_pipe : us->send_bulk_pipe;
// Not really sure the 0x07, 0x17, 0xfc, 0xe7 is necessary here, // Not really sure the 0x07, 0x17, 0xfc, 0xe7 is necessary here,
...@@ -315,9 +319,9 @@ static int usbat_rw_block_test(struct us_data *us, ...@@ -315,9 +319,9 @@ static int usbat_rw_block_test(struct us_data *us,
} else } else
cmdlen = 8; cmdlen = 8;
command[cmdlen-8] = (direction==SCSI_DATA_WRITE ? 0x40 : 0xC0); command[cmdlen-8] = (direction==DMA_TO_DEVICE ? 0x40 : 0xC0);
command[cmdlen-7] = access | command[cmdlen-7] = access |
(direction==SCSI_DATA_WRITE ? 0x05 : 0x04); (direction==DMA_TO_DEVICE ? 0x05 : 0x04);
command[cmdlen-6] = data_reg; command[cmdlen-6] = data_reg;
command[cmdlen-5] = status_reg; command[cmdlen-5] = status_reg;
command[cmdlen-4] = timeout; command[cmdlen-4] = timeout;
...@@ -355,7 +359,7 @@ static int usbat_rw_block_test(struct us_data *us, ...@@ -355,7 +359,7 @@ static int usbat_rw_block_test(struct us_data *us,
//US_DEBUGP("Transfer %s %d bytes, sg buffers %d\n", //US_DEBUGP("Transfer %s %d bytes, sg buffers %d\n",
// direction == SCSI_DATA_WRITE ? "out" : "in", // direction == DMA_TO_DEVICE ? "out" : "in",
// len, use_sg); // len, use_sg);
result = usb_stor_bulk_transfer_sg(us, result = usb_stor_bulk_transfer_sg(us,
...@@ -388,7 +392,7 @@ static int usbat_rw_block_test(struct us_data *us, ...@@ -388,7 +392,7 @@ static int usbat_rw_block_test(struct us_data *us,
* the bulk output pipe only the first time. * the bulk output pipe only the first time.
*/ */
if (direction==SCSI_DATA_READ && i==0) { if (direction==DMA_FROM_DEVICE && i==0) {
if (usb_stor_clear_halt(us, if (usb_stor_clear_halt(us,
us->send_bulk_pipe) < 0) us->send_bulk_pipe) < 0)
return USB_STOR_TRANSPORT_ERROR; return USB_STOR_TRANSPORT_ERROR;
...@@ -399,7 +403,7 @@ static int usbat_rw_block_test(struct us_data *us, ...@@ -399,7 +403,7 @@ static int usbat_rw_block_test(struct us_data *us,
*/ */
result = usbat_read(us, USBAT_ATA, result = usbat_read(us, USBAT_ATA,
direction==SCSI_DATA_WRITE ? 0x17 : 0x0E, direction==DMA_TO_DEVICE ? 0x17 : 0x0E,
status); status);
if (result!=USB_STOR_XFER_GOOD) if (result!=USB_STOR_XFER_GOOD)
...@@ -410,7 +414,7 @@ static int usbat_rw_block_test(struct us_data *us, ...@@ -410,7 +414,7 @@ static int usbat_rw_block_test(struct us_data *us,
return USB_STOR_TRANSPORT_FAILED; return USB_STOR_TRANSPORT_FAILED;
US_DEBUGP("Redoing %s\n", US_DEBUGP("Redoing %s\n",
direction==SCSI_DATA_WRITE ? "write" : "read"); direction==DMA_TO_DEVICE ? "write" : "read");
} else if (result != USB_STOR_XFER_GOOD) } else if (result != USB_STOR_XFER_GOOD)
return USB_STOR_TRANSPORT_ERROR; return USB_STOR_TRANSPORT_ERROR;
...@@ -420,7 +424,7 @@ static int usbat_rw_block_test(struct us_data *us, ...@@ -420,7 +424,7 @@ static int usbat_rw_block_test(struct us_data *us,
} }
US_DEBUGP("Bummer! %s bulk data 20 times failed.\n", US_DEBUGP("Bummer! %s bulk data 20 times failed.\n",
direction==SCSI_DATA_WRITE ? "Writing" : "Reading"); direction==DMA_TO_DEVICE ? "Writing" : "Reading");
return USB_STOR_TRANSPORT_FAILED; return USB_STOR_TRANSPORT_FAILED;
} }
...@@ -520,7 +524,7 @@ static int usbat_write_user_io(struct us_data *us, ...@@ -520,7 +524,7 @@ static int usbat_write_user_io(struct us_data *us,
static int usbat_handle_read10(struct us_data *us, static int usbat_handle_read10(struct us_data *us,
unsigned char *registers, unsigned char *registers,
unsigned char *data, unsigned char *data,
Scsi_Cmnd *srb) struct scsi_cmnd *srb)
{ {
int result = USB_STOR_TRANSPORT_GOOD; int result = USB_STOR_TRANSPORT_GOOD;
unsigned char *buffer; unsigned char *buffer;
...@@ -537,7 +541,7 @@ static int usbat_handle_read10(struct us_data *us, ...@@ -537,7 +541,7 @@ static int usbat_handle_read10(struct us_data *us,
result = usbat_rw_block_test(us, USBAT_ATA, result = usbat_rw_block_test(us, USBAT_ATA,
registers, data, 19, registers, data, 19,
0x10, 0x17, 0xFD, 0x30, 0x10, 0x17, 0xFD, 0x30,
SCSI_DATA_READ, DMA_FROM_DEVICE,
srb->request_buffer, srb->request_buffer,
srb->request_bufflen, srb->use_sg, 1); srb->request_bufflen, srb->use_sg, 1);
...@@ -606,7 +610,7 @@ static int usbat_handle_read10(struct us_data *us, ...@@ -606,7 +610,7 @@ static int usbat_handle_read10(struct us_data *us,
result = usbat_rw_block_test(us, USBAT_ATA, result = usbat_rw_block_test(us, USBAT_ATA,
registers, data, 19, registers, data, 19,
0x10, 0x17, 0xFD, 0x30, 0x10, 0x17, 0xFD, 0x30,
SCSI_DATA_READ, DMA_FROM_DEVICE,
buffer, buffer,
len, 0, 1); len, 0, 1);
...@@ -803,7 +807,7 @@ int init_8200e(struct us_data *us) ...@@ -803,7 +807,7 @@ int init_8200e(struct us_data *us)
/* /*
* Transport for the HP 8200e * Transport for the HP 8200e
*/ */
int hp8200e_transport(Scsi_Cmnd *srb, struct us_data *us) int hp8200e_transport(struct scsi_cmnd *srb, struct us_data *us)
{ {
int result; int result;
unsigned char *status = us->iobuf; unsigned char *status = us->iobuf;
...@@ -847,12 +851,12 @@ int hp8200e_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -847,12 +851,12 @@ int hp8200e_transport(Scsi_Cmnd *srb, struct us_data *us)
if (srb->cmnd[0] == TEST_UNIT_READY) if (srb->cmnd[0] == TEST_UNIT_READY)
transferred = 0; transferred = 0;
if (srb->sc_data_direction == SCSI_DATA_WRITE) { if (srb->sc_data_direction == DMA_TO_DEVICE) {
result = usbat_rw_block_test(us, USBAT_ATA, result = usbat_rw_block_test(us, USBAT_ATA,
registers, data, 19, registers, data, 19,
0x10, 0x17, 0xFD, 0x30, 0x10, 0x17, 0xFD, 0x30,
SCSI_DATA_WRITE, DMA_TO_DEVICE,
srb->request_buffer, srb->request_buffer,
len, srb->use_sg, 10); len, srb->use_sg, 10);
...@@ -900,7 +904,7 @@ int hp8200e_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -900,7 +904,7 @@ int hp8200e_transport(Scsi_Cmnd *srb, struct us_data *us)
// If there is response data to be read in // If there is response data to be read in
// then do it here. // then do it here.
if (len != 0 && (srb->sc_data_direction == SCSI_DATA_READ)) { if (len != 0 && (srb->sc_data_direction == DMA_FROM_DEVICE)) {
// How many bytes to read in? Check cylL register // How many bytes to read in? Check cylL register
......
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
#define USBAT_UIO_ADPRST 0x01 // Reset SCM chip #define USBAT_UIO_ADPRST 0x01 // Reset SCM chip
/* HP 8200e stuff */ /* HP 8200e stuff */
extern int hp8200e_transport(Scsi_Cmnd *srb, struct us_data *us); extern int hp8200e_transport(struct scsi_cmnd *srb, struct us_data *us);
extern int init_8200e(struct us_data *us); extern int init_8200e(struct us_data *us);
#endif #endif
...@@ -46,15 +46,20 @@ ...@@ -46,15 +46,20 @@
*/ */
#include <linux/config.h> #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 "transport.h"
#include "protocol.h" #include "protocol.h"
#include "scsiglue.h" #include "scsiglue.h"
#include "usb.h" #include "usb.h"
#include "debug.h" #include "debug.h"
#include <linux/sched.h>
#include <linux/errno.h>
#include <linux/slab.h>
/*********************************************************************** /***********************************************************************
* Data transfer routines * Data transfer routines
...@@ -522,7 +527,7 @@ int usb_stor_bulk_transfer_sg(struct us_data* us, unsigned int pipe, ...@@ -522,7 +527,7 @@ int usb_stor_bulk_transfer_sg(struct us_data* us, unsigned int pipe,
* This is used by the protocol layers to actually send the message to * This is used by the protocol layers to actually send the message to
* the device and receive the response. * 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 need_auto_sense;
int result; int result;
...@@ -569,7 +574,7 @@ void usb_stor_invoke_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -569,7 +574,7 @@ void usb_stor_invoke_transport(Scsi_Cmnd *srb, struct us_data *us)
* can signal most data-in errors by stalling the bulk-in pipe. * can signal most data-in errors by stalling the bulk-in pipe.
*/ */
if ((us->protocol == US_PR_CB || us->protocol == US_PR_DPCM_USB) && 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"); US_DEBUGP("-- CB transport device requiring auto-sense\n");
need_auto_sense = 1; need_auto_sense = 1;
} }
...@@ -629,7 +634,7 @@ void usb_stor_invoke_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -629,7 +634,7 @@ void usb_stor_invoke_transport(Scsi_Cmnd *srb, struct us_data *us)
/* set the transfer direction */ /* set the transfer direction */
old_sc_data_direction = srb->sc_data_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 */ /* use the new buffer we have */
old_request_buffer = srb->request_buffer; old_request_buffer = srb->request_buffer;
...@@ -749,7 +754,7 @@ void usb_stor_stop_transport(struct us_data *us) ...@@ -749,7 +754,7 @@ void usb_stor_stop_transport(struct us_data *us)
* Control/Bulk/Interrupt transport * 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 transfer_length = srb->request_bufflen;
unsigned int pipe = 0; unsigned int pipe = 0;
...@@ -778,7 +783,7 @@ int usb_stor_CBI_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -778,7 +783,7 @@ int usb_stor_CBI_transport(Scsi_Cmnd *srb, struct us_data *us)
/* DATA STAGE */ /* DATA STAGE */
/* transfer the data payload for this command, if one exists*/ /* transfer the data payload for this command, if one exists*/
if (transfer_length) { 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; us->recv_bulk_pipe : us->send_bulk_pipe;
result = usb_stor_bulk_transfer_sg(us, pipe, result = usb_stor_bulk_transfer_sg(us, pipe,
srb->request_buffer, transfer_length, srb->request_buffer, transfer_length,
...@@ -849,7 +854,7 @@ int usb_stor_CBI_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -849,7 +854,7 @@ int usb_stor_CBI_transport(Scsi_Cmnd *srb, struct us_data *us)
/* /*
* Control/Bulk transport * 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; unsigned int transfer_length = srb->request_bufflen;
int result; int result;
...@@ -877,7 +882,7 @@ int usb_stor_CB_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -877,7 +882,7 @@ int usb_stor_CB_transport(Scsi_Cmnd *srb, struct us_data *us)
/* DATA STAGE */ /* DATA STAGE */
/* transfer the data payload for this command, if one exists*/ /* transfer the data payload for this command, if one exists*/
if (transfer_length) { 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; us->recv_bulk_pipe : us->send_bulk_pipe;
result = usb_stor_bulk_transfer_sg(us, pipe, result = usb_stor_bulk_transfer_sg(us, pipe,
srb->request_buffer, transfer_length, srb->request_buffer, transfer_length,
...@@ -939,7 +944,7 @@ int usb_stor_Bulk_max_lun(struct us_data *us) ...@@ -939,7 +944,7 @@ int usb_stor_Bulk_max_lun(struct us_data *us)
return -1; 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_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
struct bulk_cs_wrap *bcs = (struct bulk_cs_wrap *) us->iobuf; struct bulk_cs_wrap *bcs = (struct bulk_cs_wrap *) us->iobuf;
...@@ -952,7 +957,7 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -952,7 +957,7 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us)
/* set up the command wrapper */ /* set up the command wrapper */
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
bcb->DataTransferLength = cpu_to_le32(transfer_length); 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->Tag = srb->serial_number;
bcb->Lun = srb->device->lun; bcb->Lun = srb->device->lun;
if (us->flags & US_FL_SCM_MULT_TARG) if (us->flags & US_FL_SCM_MULT_TARG)
...@@ -984,7 +989,7 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -984,7 +989,7 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us)
udelay(100); udelay(100);
if (transfer_length) { 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; us->recv_bulk_pipe : us->send_bulk_pipe;
result = usb_stor_bulk_transfer_sg(us, pipe, result = usb_stor_bulk_transfer_sg(us, pipe,
srb->request_buffer, transfer_length, srb->request_buffer, transfer_length,
......
...@@ -44,7 +44,8 @@ ...@@ -44,7 +44,8 @@
#include <linux/config.h> #include <linux/config.h>
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include "usb.h" #include "usb.h"
#include "scsi.h"
struct scsi_cmnd;
/* Protocols */ /* Protocols */
...@@ -150,16 +151,16 @@ struct bulk_cs_wrap { ...@@ -150,16 +151,16 @@ struct bulk_cs_wrap {
#define US_CBI_ADSC 0 #define US_CBI_ADSC 0
extern int usb_stor_CBI_transport(Scsi_Cmnd*, struct us_data*); extern int usb_stor_CBI_transport(struct scsi_cmnd *, struct us_data*);
extern int usb_stor_CB_transport(Scsi_Cmnd*, struct us_data*); extern int usb_stor_CB_transport(struct scsi_cmnd *, struct us_data*);
extern int usb_stor_CB_reset(struct us_data*); extern int usb_stor_CB_reset(struct us_data*);
extern int usb_stor_Bulk_transport(Scsi_Cmnd*, struct us_data*); extern int usb_stor_Bulk_transport(struct scsi_cmnd *, struct us_data*);
extern int usb_stor_Bulk_max_lun(struct us_data*); extern int usb_stor_Bulk_max_lun(struct us_data*);
extern int usb_stor_Bulk_reset(struct us_data*); extern int usb_stor_Bulk_reset(struct us_data*);
extern void usb_stor_invoke_transport(Scsi_Cmnd*, struct us_data*); extern void usb_stor_invoke_transport(struct scsi_cmnd *, struct us_data*);
extern void usb_stor_stop_transport(struct us_data*); extern void usb_stor_stop_transport(struct us_data*);
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,
......
...@@ -50,6 +50,11 @@ ...@@ -50,6 +50,11 @@
#include <linux/config.h> #include <linux/config.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
#include <scsi/scsi_device.h>
#include "usb.h" #include "usb.h"
#include "scsiglue.h" #include "scsiglue.h"
#include "transport.h" #include "transport.h"
...@@ -322,7 +327,7 @@ static int usb_stor_control_thread(void * __us) ...@@ -322,7 +327,7 @@ static int usb_stor_control_thread(void * __us)
/* reject the command if the direction indicator /* reject the command if the direction indicator
* is UNKNOWN * is UNKNOWN
*/ */
if (us->srb->sc_data_direction == SCSI_DATA_UNKNOWN) { if (us->srb->sc_data_direction == DMA_BIDIRECTIONAL) {
US_DEBUGP("UNKNOWN data direction\n"); US_DEBUGP("UNKNOWN data direction\n");
us->srb->result = DID_ERROR << 16; us->srb->result = DID_ERROR << 16;
} }
......
...@@ -48,10 +48,9 @@ ...@@ -48,10 +48,9 @@
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include <linux/smp_lock.h> #include <linux/smp_lock.h>
#include <linux/completion.h> #include <linux/completion.h>
#include "scsi.h"
#include <scsi/scsi_host.h>
struct us_data; struct us_data;
struct scsi_cmnd;
/* /*
* Unusual device list definitions * Unusual device list definitions
...@@ -102,9 +101,9 @@ struct us_unusual_dev { ...@@ -102,9 +101,9 @@ struct us_unusual_dev {
#define US_IOBUF_SIZE 64 /* Size of the DMA-mapped I/O buffer */ #define US_IOBUF_SIZE 64 /* Size of the DMA-mapped I/O buffer */
typedef int (*trans_cmnd)(Scsi_Cmnd*, struct us_data*); typedef int (*trans_cmnd)(struct scsi_cmnd *, struct us_data*);
typedef int (*trans_reset)(struct us_data*); typedef int (*trans_reset)(struct us_data*);
typedef void (*proto_cmnd)(Scsi_Cmnd*, struct us_data*); typedef void (*proto_cmnd)(struct scsi_cmnd*, struct us_data*);
typedef void (*extra_data_destructor)(void *); /* extra data destructor */ typedef void (*extra_data_destructor)(void *); /* extra data destructor */
/* we allocate one of these for every device that we remember */ /* we allocate one of these for every device that we remember */
...@@ -144,7 +143,7 @@ struct us_data { ...@@ -144,7 +143,7 @@ struct us_data {
/* SCSI interfaces */ /* SCSI interfaces */
struct Scsi_Host *host; /* our dummy host data */ struct Scsi_Host *host; /* our dummy host data */
Scsi_Cmnd *srb; /* current srb */ struct scsi_cmnd *srb; /* current srb */
/* thread information */ /* thread information */
int pid; /* control thread */ int pid; /* control thread */
......
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