Commit 61e36850 authored by Matthew Dharm's avatar Matthew Dharm Committed by Greg Kroah-Hartman

[PATCH] USB: convert ISD200 and Jumpshot to DMA-safe buffer

This patch converts the ISD200 and Jumpshot drivers to use the new DMA-safe
buffer.


I'd also like to take a moment to thank Alan Stern, who writes many of
these patches.  Without his help, many of the improvements everyone has
seen over the 2.5.x series would not have been possible.
parent 27c19834
......@@ -280,6 +280,7 @@ struct isd200_info {
/* maximum number of LUNs supported */
unsigned char MaxLUNs;
struct scsi_cmnd srb;
};
......@@ -404,15 +405,15 @@ static int isd200_action( struct us_data *us, int action,
void* pointer, int value )
{
union ata_cdb ata;
struct scsi_cmnd srb;
struct scsi_device srb_dev;
struct isd200_info *info = (struct isd200_info *)us->extra;
struct scsi_cmnd *srb = &info->srb;
int status;
memset(&ata, 0, sizeof(ata));
memset(&srb, 0, sizeof(srb));
memset(&srb_dev, 0, sizeof(srb_dev));
srb.device = &srb_dev;
srb->device = &srb_dev;
++srb->serial_number;
ata.generic.SignatureByte0 = info->ConfigData.ATAMajorCommand;
ata.generic.SignatureByte1 = info->ConfigData.ATAMinorCommand;
......@@ -425,9 +426,9 @@ static int isd200_action( struct us_data *us, int action,
ata.generic.RegisterSelect =
REG_CYLINDER_LOW | REG_CYLINDER_HIGH |
REG_STATUS | REG_ERROR;
srb.sc_data_direction = SCSI_DATA_READ;
srb.request_buffer = pointer;
srb.request_bufflen = value;
srb->sc_data_direction = SCSI_DATA_READ;
srb->request_buffer = pointer;
srb->request_bufflen = value;
break;
case ACTION_ENUM:
......@@ -437,7 +438,7 @@ static int isd200_action( struct us_data *us, int action,
ACTION_SELECT_5;
ata.generic.RegisterSelect = REG_DEVICE_HEAD;
ata.write.DeviceHeadByte = value;
srb.sc_data_direction = SCSI_DATA_NONE;
srb->sc_data_direction = SCSI_DATA_NONE;
break;
case ACTION_RESET:
......@@ -446,7 +447,7 @@ static int isd200_action( struct us_data *us, int action,
ACTION_SELECT_3|ACTION_SELECT_4;
ata.generic.RegisterSelect = REG_DEVICE_CONTROL;
ata.write.DeviceControlByte = ATA_DC_RESET_CONTROLLER;
srb.sc_data_direction = SCSI_DATA_NONE;
srb->sc_data_direction = SCSI_DATA_NONE;
break;
case ACTION_REENABLE:
......@@ -455,7 +456,7 @@ static int isd200_action( struct us_data *us, int action,
ACTION_SELECT_3|ACTION_SELECT_4;
ata.generic.RegisterSelect = REG_DEVICE_CONTROL;
ata.write.DeviceControlByte = ATA_DC_REENABLE_CONTROLLER;
srb.sc_data_direction = SCSI_DATA_NONE;
srb->sc_data_direction = SCSI_DATA_NONE;
break;
case ACTION_SOFT_RESET:
......@@ -464,16 +465,16 @@ static int isd200_action( struct us_data *us, int action,
ata.generic.RegisterSelect = REG_DEVICE_HEAD | REG_COMMAND;
ata.write.DeviceHeadByte = info->DeviceHead;
ata.write.CommandByte = WIN_SRST;
srb.sc_data_direction = SCSI_DATA_NONE;
srb->sc_data_direction = SCSI_DATA_NONE;
break;
case ACTION_IDENTIFY:
US_DEBUGP(" isd200_action(IDENTIFY)\n");
ata.generic.RegisterSelect = REG_COMMAND;
ata.write.CommandByte = WIN_IDENTIFY;
srb.sc_data_direction = SCSI_DATA_READ;
srb.request_buffer = (void *)&info->drive;
srb.request_bufflen = sizeof(struct hd_driveid);
srb->sc_data_direction = SCSI_DATA_READ;
srb->request_buffer = (void *)&info->drive;
srb->request_bufflen = sizeof(struct hd_driveid);
break;
default:
......@@ -481,9 +482,9 @@ static int isd200_action( struct us_data *us, int action,
break;
}
memcpy(srb.cmnd, &ata, sizeof(ata.generic));
srb.cmd_len = sizeof(ata.generic);
status = usb_stor_Bulk_transport(&srb, us);
memcpy(srb->cmnd, &ata, sizeof(ata.generic));
srb->cmd_len = sizeof(ata.generic);
status = usb_stor_Bulk_transport(srb, us);
if (status == USB_STOR_TRANSPORT_GOOD)
status = ISD200_GOOD;
else {
......@@ -834,7 +835,7 @@ static int isd200_try_enum(struct us_data *us, unsigned char master_slave,
int detect )
{
int status = ISD200_GOOD;
unsigned char regs[8];
unsigned char *regs = us->iobuf;
unsigned long endTime;
struct isd200_info *info = (struct isd200_info *)us->extra;
int recheckAsMaster = FALSE;
......@@ -856,7 +857,7 @@ static int isd200_try_enum(struct us_data *us, unsigned char master_slave,
break;
status = isd200_action( us, ACTION_READ_STATUS,
regs, sizeof(regs) );
regs, 8 );
if ( status != ISD200_GOOD )
break;
......
......@@ -86,7 +86,6 @@ static inline int jumpshot_bulk_write(struct us_data *us,
static int jumpshot_get_status(struct us_data *us)
{
unsigned char reply;
int rc;
if (!us)
......@@ -94,14 +93,14 @@ static int jumpshot_get_status(struct us_data *us)
// send the setup
rc = usb_stor_ctrl_transfer(us, us->recv_ctrl_pipe,
0, 0xA0, 0, 7, &reply, 1);
0, 0xA0, 0, 7, us->iobuf, 1);
if (rc != USB_STOR_XFER_GOOD)
return USB_STOR_TRANSPORT_ERROR;
if (reply != 0x50) {
if (us->iobuf[0] != 0x50) {
US_DEBUGP("jumpshot_get_status: 0x%2x\n",
(unsigned short) (reply));
us->iobuf[0]);
return USB_STOR_TRANSPORT_ERROR;
}
......@@ -115,7 +114,7 @@ static int jumpshot_read_data(struct us_data *us,
unsigned char *dest,
int use_sg)
{
unsigned char command[] = { 0, 0, 0, 0, 0, 0xe0, 0x20 };
unsigned char *command = us->iobuf;
unsigned char *buffer = NULL;
unsigned char *ptr;
unsigned char thistime;
......@@ -154,7 +153,8 @@ static int jumpshot_read_data(struct us_data *us,
command[3] = (sector >> 8) & 0xFF;
command[4] = (sector >> 16) & 0xFF;
command[5] |= (sector >> 24) & 0x0F;
command[5] = 0xE0 | ((sector >> 24) & 0x0F);
command[6] = 0x20;
// send the setup + command
result = usb_stor_ctrl_transfer(us, us->send_ctrl_pipe,
......@@ -199,7 +199,7 @@ static int jumpshot_write_data(struct us_data *us,
unsigned char *src,
int use_sg)
{
unsigned char command[7] = { 0, 0, 0, 0, 0, 0xE0, 0x30 };
unsigned char *command = us->iobuf;
unsigned char *buffer = NULL;
unsigned char *ptr;
unsigned char thistime;
......@@ -240,7 +240,8 @@ static int jumpshot_write_data(struct us_data *us,
command[3] = (sector >> 8) & 0xFF;
command[4] = (sector >> 16) & 0xFF;
command[5] |= (sector >> 24) & 0x0F;
command[5] = 0xE0 | ((sector >> 24) & 0x0F);
command[6] = 0x30;
// send the setup + command
result = usb_stor_ctrl_transfer(us, us->send_ctrl_pipe,
......@@ -291,13 +292,19 @@ static int jumpshot_write_data(struct us_data *us,
static int jumpshot_id_device(struct us_data *us,
struct jumpshot_info *info)
{
unsigned char command[2] = { 0xe0, 0xec };
unsigned char reply[512];
unsigned char *command = us->iobuf;
unsigned char *reply;
int rc;
if (!us || !info)
return USB_STOR_TRANSPORT_ERROR;
command[0] = 0xE0;
command[1] = 0xEC;
reply = kmalloc(512, GFP_NOIO);
if (!reply)
return USB_STOR_TRANSPORT_ERROR;
// send the setup
rc = usb_stor_ctrl_transfer(us, us->send_ctrl_pipe,
0, 0x20, 0, 6, command, 2);
......@@ -305,20 +312,27 @@ static int jumpshot_id_device(struct us_data *us,
if (rc != USB_STOR_XFER_GOOD) {
US_DEBUGP("jumpshot_id_device: Gah! "
"send_control for read_capacity failed\n");
return rc;
rc = USB_STOR_TRANSPORT_ERROR;
goto leave;
}
// read the reply
rc = jumpshot_bulk_read(us, reply, sizeof(reply));
if (rc != USB_STOR_XFER_GOOD)
return USB_STOR_TRANSPORT_ERROR;
if (rc != USB_STOR_XFER_GOOD) {
rc = USB_STOR_TRANSPORT_ERROR;
goto leave;
}
info->sectors = ((u32)(reply[117]) << 24) |
((u32)(reply[116]) << 16) |
((u32)(reply[115]) << 8) |
((u32)(reply[114]) );
return USB_STOR_TRANSPORT_GOOD;
rc = USB_STOR_TRANSPORT_GOOD;
leave:
kfree(reply);
return rc;
}
static int jumpshot_handle_mode_sense(struct us_data *us,
......
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