Commit f57e69b0 authored by Alan Stern's avatar Alan Stern Committed by Greg Kroah-Hartman

[PATCH] USB: I/O buffering for sddr09

This patch makes the sddr09 subdriver use proper DMA I/O buffering.
parent 1c2bd8e2
...@@ -261,12 +261,13 @@ sddr09_send_scsi_command(struct us_data *us, ...@@ -261,12 +261,13 @@ sddr09_send_scsi_command(struct us_data *us,
*/ */
static int static int
sddr09_test_unit_ready(struct us_data *us) { sddr09_test_unit_ready(struct us_data *us) {
unsigned char command[6] = { unsigned char *command = us->iobuf;
0, LUNBITS, 0, 0, 0, 0
};
int result; int result;
result = sddr09_send_scsi_command(us, command, sizeof(command)); memset(command, 0, 6);
command[1] = LUNBITS;
result = sddr09_send_scsi_command(us, command, 6);
US_DEBUGP("sddr09_test_unit_ready returns %d\n", result); US_DEBUGP("sddr09_test_unit_ready returns %d\n", result);
...@@ -281,12 +282,15 @@ sddr09_test_unit_ready(struct us_data *us) { ...@@ -281,12 +282,15 @@ sddr09_test_unit_ready(struct us_data *us) {
*/ */
static int static int
sddr09_request_sense(struct us_data *us, unsigned char *sensebuf, int buflen) { sddr09_request_sense(struct us_data *us, unsigned char *sensebuf, int buflen) {
unsigned char command[12] = { unsigned char *command = us->iobuf;
0x03, LUNBITS, 0, 0, buflen, 0, 0, 0, 0, 0, 0, 0
};
int result; int result;
result = sddr09_send_scsi_command(us, command, sizeof(command)); memset(command, 0, 12);
command[0] = 0x03;
command[1] = LUNBITS;
command[4] = buflen;
result = sddr09_send_scsi_command(us, command, 12);
if (result != USB_STOR_TRANSPORT_GOOD) { if (result != USB_STOR_TRANSPORT_GOOD) {
US_DEBUGP("request sense failed\n"); US_DEBUGP("request sense failed\n");
return result; return result;
...@@ -331,20 +335,23 @@ sddr09_readX(struct us_data *us, int x, unsigned long fromaddress, ...@@ -331,20 +335,23 @@ sddr09_readX(struct us_data *us, int x, unsigned long fromaddress,
int nr_of_pages, int bulklen, unsigned char *buf, int nr_of_pages, int bulklen, unsigned char *buf,
int use_sg) { int use_sg) {
unsigned char command[12] = { unsigned char *command = us->iobuf;
0xe8, LUNBITS | x, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
int result; int result;
command[0] = 0xE8;
command[1] = LUNBITS | x;
command[2] = MSB_of(fromaddress>>16); command[2] = MSB_of(fromaddress>>16);
command[3] = LSB_of(fromaddress>>16); command[3] = LSB_of(fromaddress>>16);
command[4] = MSB_of(fromaddress & 0xFFFF); command[4] = MSB_of(fromaddress & 0xFFFF);
command[5] = LSB_of(fromaddress & 0xFFFF); command[5] = LSB_of(fromaddress & 0xFFFF);
command[6] = 0;
command[7] = 0;
command[8] = 0;
command[9] = 0;
command[10] = MSB_of(nr_of_pages); command[10] = MSB_of(nr_of_pages);
command[11] = LSB_of(nr_of_pages); command[11] = LSB_of(nr_of_pages);
result = sddr09_send_scsi_command(us, command, sizeof(command)); result = sddr09_send_scsi_command(us, command, 12);
if (result != USB_STOR_TRANSPORT_GOOD) { if (result != USB_STOR_TRANSPORT_GOOD) {
US_DEBUGP("Result for send_control in sddr09_read2%d %d\n", US_DEBUGP("Result for send_control in sddr09_read2%d %d\n",
...@@ -458,17 +465,18 @@ sddr09_read23(struct us_data *us, unsigned long fromaddress, ...@@ -458,17 +465,18 @@ sddr09_read23(struct us_data *us, unsigned long fromaddress,
*/ */
static int static int
sddr09_erase(struct us_data *us, unsigned long Eaddress) { sddr09_erase(struct us_data *us, unsigned long Eaddress) {
unsigned char command[12] = { unsigned char *command = us->iobuf;
0xea, LUNBITS, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
int result; int result;
memset(command, 0, 12);
command[0] = 0xEA;
command[1] = LUNBITS;
command[6] = MSB_of(Eaddress>>16); command[6] = MSB_of(Eaddress>>16);
command[7] = LSB_of(Eaddress>>16); command[7] = LSB_of(Eaddress>>16);
command[8] = MSB_of(Eaddress & 0xFFFF); command[8] = MSB_of(Eaddress & 0xFFFF);
command[9] = LSB_of(Eaddress & 0xFFFF); command[9] = LSB_of(Eaddress & 0xFFFF);
result = sddr09_send_scsi_command(us, command, sizeof(command)); result = sddr09_send_scsi_command(us, command, 12);
if (result != USB_STOR_TRANSPORT_GOOD) if (result != USB_STOR_TRANSPORT_GOOD)
US_DEBUGP("Result for send_control in sddr09_erase %d\n", US_DEBUGP("Result for send_control in sddr09_erase %d\n",
...@@ -493,11 +501,12 @@ sddr09_writeX(struct us_data *us, ...@@ -493,11 +501,12 @@ sddr09_writeX(struct us_data *us,
unsigned long Waddress, unsigned long Eaddress, unsigned long Waddress, unsigned long Eaddress,
int nr_of_pages, int bulklen, unsigned char *buf, int use_sg) { int nr_of_pages, int bulklen, unsigned char *buf, int use_sg) {
unsigned char command[12] = { unsigned char *command = us->iobuf;
0xe9, LUNBITS, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
int result; int result;
command[0] = 0xE9;
command[1] = LUNBITS;
command[2] = MSB_of(Waddress>>16); command[2] = MSB_of(Waddress>>16);
command[3] = LSB_of(Waddress>>16); command[3] = LSB_of(Waddress>>16);
command[4] = MSB_of(Waddress & 0xFFFF); command[4] = MSB_of(Waddress & 0xFFFF);
...@@ -511,7 +520,7 @@ sddr09_writeX(struct us_data *us, ...@@ -511,7 +520,7 @@ sddr09_writeX(struct us_data *us,
command[10] = MSB_of(nr_of_pages); command[10] = MSB_of(nr_of_pages);
command[11] = LSB_of(nr_of_pages); command[11] = LSB_of(nr_of_pages);
result = sddr09_send_scsi_command(us, command, sizeof(command)); result = sddr09_send_scsi_command(us, command, 12);
if (result != USB_STOR_TRANSPORT_GOOD) { if (result != USB_STOR_TRANSPORT_GOOD) {
US_DEBUGP("Result for send_control in sddr09_writeX %d\n", US_DEBUGP("Result for send_control in sddr09_writeX %d\n",
...@@ -554,15 +563,15 @@ sddr09_write_inplace(struct us_data *us, unsigned long address, ...@@ -554,15 +563,15 @@ sddr09_write_inplace(struct us_data *us, unsigned long address,
*/ */
static int static int
sddr09_read_sg_test_only(struct us_data *us) { sddr09_read_sg_test_only(struct us_data *us) {
unsigned char command[15] = { unsigned char *command = us->iobuf;
0xe7, LUNBITS, 0
};
int result, bulklen, nsg, ct; int result, bulklen, nsg, ct;
unsigned char *buf; unsigned char *buf;
unsigned long address; unsigned long address;
nsg = bulklen = 0; nsg = bulklen = 0;
command[0] = 0xE7;
command[1] = LUNBITS;
command[2] = 0;
address = 040000; ct = 1; address = 040000; ct = 1;
nsg++; nsg++;
bulklen += (ct << 9); bulklen += (ct << 9);
...@@ -628,20 +637,22 @@ sddr09_read_sg_test_only(struct us_data *us) { ...@@ -628,20 +637,22 @@ sddr09_read_sg_test_only(struct us_data *us) {
static int static int
sddr09_read_status(struct us_data *us, unsigned char *status) { sddr09_read_status(struct us_data *us, unsigned char *status) {
unsigned char command[12] = { unsigned char *command = us->iobuf;
0xec, LUNBITS, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 unsigned char *data = us->iobuf;
};
unsigned char data[64];
int result; int result;
US_DEBUGP("Reading status...\n"); US_DEBUGP("Reading status...\n");
result = sddr09_send_scsi_command(us, command, sizeof(command)); memset(command, 0, 12);
command[0] = 0xEC;
command[1] = LUNBITS;
result = sddr09_send_scsi_command(us, command, 12);
if (result != USB_STOR_TRANSPORT_GOOD) if (result != USB_STOR_TRANSPORT_GOOD)
return result; return result;
result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
data, sizeof(data), NULL); data, 64, NULL);
*status = data[0]; *status = data[0];
return (result == USB_STOR_XFER_GOOD ? return (result == USB_STOR_XFER_GOOD ?
USB_STOR_TRANSPORT_GOOD : USB_STOR_TRANSPORT_ERROR); USB_STOR_TRANSPORT_GOOD : USB_STOR_TRANSPORT_ERROR);
...@@ -953,13 +964,15 @@ sddr09_read_control(struct us_data *us, ...@@ -953,13 +964,15 @@ sddr09_read_control(struct us_data *us,
*/ */
static int static int
sddr09_read_deviceID(struct us_data *us, unsigned char *deviceID) { sddr09_read_deviceID(struct us_data *us, unsigned char *deviceID) {
unsigned char command[12] = { unsigned char *command = us->iobuf;
0xed, LUNBITS, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 unsigned char *content = us->iobuf;
};
unsigned char content[64];
int result, i; int result, i;
result = sddr09_send_scsi_command(us, command, sizeof(command)); memset(command, 0, 12);
command[0] = 0xED;
command[1] = LUNBITS;
result = sddr09_send_scsi_command(us, command, 12);
if (result != USB_STOR_TRANSPORT_GOOD) if (result != USB_STOR_TRANSPORT_GOOD)
return result; return result;
...@@ -1006,11 +1019,13 @@ sddr09_get_wp(struct us_data *us, struct sddr09_card_info *info) { ...@@ -1006,11 +1019,13 @@ sddr09_get_wp(struct us_data *us, struct sddr09_card_info *info) {
static int static int
sddr09_reset(struct us_data *us) { sddr09_reset(struct us_data *us) {
unsigned char command[12] = { unsigned char *command = us->iobuf;
0xeb, LUNBITS, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}; memset(command, 0, 12);
command[0] = 0xEB;
command[1] = LUNBITS;
return sddr09_send_scsi_command(us, command, sizeof(command)); return sddr09_send_scsi_command(us, command, 12);
} }
#endif #endif
...@@ -1313,7 +1328,7 @@ sddr09_init_card_info(struct us_data *us) { ...@@ -1313,7 +1328,7 @@ sddr09_init_card_info(struct us_data *us) {
int int
sddr09_init(struct us_data *us) { sddr09_init(struct us_data *us) {
int result; int result;
unsigned char data[18]; unsigned char *data = us->iobuf;
result = sddr09_send_command(us, 0x01, USB_DIR_IN, data, 2); result = sddr09_send_command(us, 0x01, USB_DIR_IN, data, 2);
if (result != USB_STOR_TRANSPORT_GOOD) { if (result != USB_STOR_TRANSPORT_GOOD) {
...@@ -1333,10 +1348,10 @@ sddr09_init(struct us_data *us) { ...@@ -1333,10 +1348,10 @@ sddr09_init(struct us_data *us) {
US_DEBUGP("SDDR09init: %02X %02X\n", data[0], data[1]); US_DEBUGP("SDDR09init: %02X %02X\n", data[0], data[1]);
// get 07 00 // get 07 00
result = sddr09_request_sense(us, data, sizeof(data)); result = sddr09_request_sense(us, data, 18);
if (result == USB_STOR_TRANSPORT_GOOD && data[2] != 0) { if (result == USB_STOR_TRANSPORT_GOOD && data[2] != 0) {
int j; int j;
for (j=0; j<sizeof(data); j++) for (j=0; j<18; j++)
printk(" %02X", data[j]); printk(" %02X", data[j]);
printk("\n"); printk("\n");
// get 70 00 00 00 00 00 00 * 00 00 00 00 00 00 // get 70 00 00 00 00 00 00 * 00 00 00 00 00 00
......
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