ChangeSet 1.1455.1.39, 2003/07/16 10:16:36-07:00, stern@rowland.harvard.edu

[PATCH] USB: Make sddr55 use proper I/O buffering

This patch makes the sddr55 subdriver use proper DMA I/O buffering.


 drivers/usb/storage/sddr55.c |   41 ++++++++++++++++++++++++-----------------
 1 files changed, 24 insertions(+), 17 deletions(-)


diff -Nru a/drivers/usb/storage/sddr55.c b/drivers/usb/storage/sddr55.c
--- a/drivers/usb/storage/sddr55.c	Thu Jul 17 17:03:27 2003
+++ b/drivers/usb/storage/sddr55.c	Thu Jul 17 17:03:27 2003
@@ -91,13 +91,14 @@
 static int sddr55_status(struct us_data *us)
 {
 	int result;
-	unsigned char command[8] = {
-		0, 0, 0, 0, 0, 0xb0, 0, 0x80
-	};
-	unsigned char status[8];
+	unsigned char *command = us->iobuf;
+	unsigned char *status = us->iobuf;
 	struct sddr55_card_info *info = (struct sddr55_card_info *)us->extra;
 
 	/* send command */
+	memset(command, 0, 8);
+	command[5] = 0xB0;
+	command[7] = 0x80;
 	result = sddr55_bulk_transport(us,
 		SCSI_DATA_WRITE, command, 8);
 
@@ -158,10 +159,8 @@
 		int use_sg) {
 
 	int result = USB_STOR_TRANSPORT_GOOD;
-	unsigned char command[8] = {
-		0, 0, 0, 0, 0, 0xb0, 0, 0x85
-	};
-	unsigned char status[8];
+	unsigned char *command = us->iobuf;
+	unsigned char *status = us->iobuf;
 	struct sddr55_card_info *info = (struct sddr55_card_info *)us->extra;
 
 	unsigned int pba;
@@ -205,11 +204,15 @@
 
 			address = (pba << info->blockshift) + page;
 
+			command[0] = 0;
 			command[1] = LSB_of(address>>16);
 			command[2] = LSB_of(address>>8);
 			command[3] = LSB_of(address);
 
+			command[4] = 0;
+			command[5] = 0xB0;
 			command[6] = LSB_of(pages << (1 - info->smallpageshift));
+			command[7] = 0x85;
 
 			/* send command */
 			result = sddr55_bulk_transport(us,
@@ -274,10 +277,8 @@
 		int use_sg) {
 
 	int result = USB_STOR_TRANSPORT_GOOD;
-	unsigned char command[8] = {
-		0, 0, 0, 0, 0, 0xb0, 0, 0x86
-	};
-	unsigned char status[8];
+	unsigned char *command = us->iobuf;
+	unsigned char *status = us->iobuf;
 	struct sddr55_card_info *info = (struct sddr55_card_info *)us->extra;
 
 	unsigned int pba;
@@ -380,6 +381,8 @@
 		command[6] = MSB_of(lba % 1000);
 
 		command[4] |= LSB_of(pages >> info->smallpageshift);
+		command[5] = 0xB0;
+		command[7] = 0x86;
 
 		/* send command */
 		result = sddr55_bulk_transport(us,
@@ -473,11 +476,12 @@
 		unsigned char *deviceID) {
 
 	int result;
-	unsigned char command[8] = {
-		0, 0, 0, 0, 0, 0xb0, 0, 0x84
-	};
-	unsigned char content[64];
+	unsigned char *command = us->iobuf;
+	unsigned char *content = us->iobuf;
 
+	memset(command, 0, 8);
+	command[5] = 0xB0;
+	command[7] = 0x84;
 	result = sddr55_bulk_transport(us, SCSI_DATA_WRITE, command, 8);
 
 	US_DEBUGP("Result of send_control for device ID is %d\n",
@@ -598,7 +602,7 @@
 	struct sddr55_card_info *info = (struct sddr55_card_info *)(us->extra);
 	int numblocks;
 	unsigned char *buffer;
-	unsigned char command[8] = { 0, 0, 0, 0, 0, 0xb0, 0, 0x8a};	
+	unsigned char *command = us->iobuf;
 	int i;
 	unsigned short lba;
 	unsigned short max_lba;
@@ -614,7 +618,10 @@
 	if (!buffer)
 		return -1;
 
+	memset(command, 0, 8);
+	command[5] = 0xB0;
 	command[6] = numblocks * 2 / 256;
+	command[7] = 0x8A;
 
 	result = sddr55_bulk_transport(us, SCSI_DATA_WRITE, command, 8);
 
