aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBoaz Harrosh <bharrosh@panasas.com>2007-09-09 13:40:56 -0400
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2008-01-11 19:22:37 -0500
commit4776e99ebb171d61c7e242db437358183f27b471 (patch)
tree7e0a9516551f7d16686abb19cf1b87866b0d8377
parent41c2497b188a641c542328d08a45cf3214d453bd (diff)
[SCSI] usb: shuttle_usbat - convert to accessors and !use_sg code path removal
- functions that received char* but where passed scatterlist* mostly were changed to receive void* - Use scsi data accessors and remove of !use_sg code path Signed-off-by: Boaz Harrosh <bharrosh@panasas.com> Acked-by: Matthew Dharm <mdharm-scsi@one-eyed-alien.net> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
-rw-r--r--drivers/usb/storage/shuttle_usbat.c68
1 files changed, 26 insertions, 42 deletions
diff --git a/drivers/usb/storage/shuttle_usbat.c b/drivers/usb/storage/shuttle_usbat.c
index cb22a9ad1694..570c1250f6f3 100644
--- a/drivers/usb/storage/shuttle_usbat.c
+++ b/drivers/usb/storage/shuttle_usbat.c
@@ -130,7 +130,7 @@ static int usbat_write(struct us_data *us,
130 * Convenience function to perform a bulk read 130 * Convenience function to perform a bulk read
131 */ 131 */
132static int usbat_bulk_read(struct us_data *us, 132static int usbat_bulk_read(struct us_data *us,
133 unsigned char *data, 133 void* buf,
134 unsigned int len, 134 unsigned int len,
135 int use_sg) 135 int use_sg)
136{ 136{
@@ -138,14 +138,14 @@ static int usbat_bulk_read(struct us_data *us,
138 return USB_STOR_XFER_GOOD; 138 return USB_STOR_XFER_GOOD;
139 139
140 US_DEBUGP("usbat_bulk_read: len = %d\n", len); 140 US_DEBUGP("usbat_bulk_read: len = %d\n", len);
141 return usb_stor_bulk_transfer_sg(us, us->recv_bulk_pipe, data, len, use_sg, NULL); 141 return usb_stor_bulk_transfer_sg(us, us->recv_bulk_pipe, buf, len, use_sg, NULL);
142} 142}
143 143
144/* 144/*
145 * Convenience function to perform a bulk write 145 * Convenience function to perform a bulk write
146 */ 146 */
147static int usbat_bulk_write(struct us_data *us, 147static int usbat_bulk_write(struct us_data *us,
148 unsigned char *data, 148 void* buf,
149 unsigned int len, 149 unsigned int len,
150 int use_sg) 150 int use_sg)
151{ 151{
@@ -153,7 +153,7 @@ static int usbat_bulk_write(struct us_data *us,
153 return USB_STOR_XFER_GOOD; 153 return USB_STOR_XFER_GOOD;
154 154
155 US_DEBUGP("usbat_bulk_write: len = %d\n", len); 155 US_DEBUGP("usbat_bulk_write: len = %d\n", len);
156 return usb_stor_bulk_transfer_sg(us, us->send_bulk_pipe, data, len, use_sg, NULL); 156 return usb_stor_bulk_transfer_sg(us, us->send_bulk_pipe, buf, len, use_sg, NULL);
157} 157}
158 158
159/* 159/*
@@ -314,7 +314,7 @@ static int usbat_wait_not_busy(struct us_data *us, int minutes)
314 * Read block data from the data register 314 * Read block data from the data register
315 */ 315 */
316static int usbat_read_block(struct us_data *us, 316static int usbat_read_block(struct us_data *us,
317 unsigned char *content, 317 void* buf,
318 unsigned short len, 318 unsigned short len,
319 int use_sg) 319 int use_sg)
320{ 320{
@@ -337,7 +337,7 @@ static int usbat_read_block(struct us_data *us,
337 if (result != USB_STOR_XFER_GOOD) 337 if (result != USB_STOR_XFER_GOOD)
338 return USB_STOR_TRANSPORT_ERROR; 338 return USB_STOR_TRANSPORT_ERROR;
339 339
340 result = usbat_bulk_read(us, content, len, use_sg); 340 result = usbat_bulk_read(us, buf, len, use_sg);
341 return (result == USB_STOR_XFER_GOOD ? 341 return (result == USB_STOR_XFER_GOOD ?
342 USB_STOR_TRANSPORT_GOOD : USB_STOR_TRANSPORT_ERROR); 342 USB_STOR_TRANSPORT_GOOD : USB_STOR_TRANSPORT_ERROR);
343} 343}
@@ -347,7 +347,7 @@ static int usbat_read_block(struct us_data *us,
347 */ 347 */
348static int usbat_write_block(struct us_data *us, 348static int usbat_write_block(struct us_data *us,
349 unsigned char access, 349 unsigned char access,
350 unsigned char *content, 350 void* buf,
351 unsigned short len, 351 unsigned short len,
352 int minutes, 352 int minutes,
353 int use_sg) 353 int use_sg)
@@ -372,7 +372,7 @@ static int usbat_write_block(struct us_data *us,
372 if (result != USB_STOR_XFER_GOOD) 372 if (result != USB_STOR_XFER_GOOD)
373 return USB_STOR_TRANSPORT_ERROR; 373 return USB_STOR_TRANSPORT_ERROR;
374 374
375 result = usbat_bulk_write(us, content, len, use_sg); 375 result = usbat_bulk_write(us, buf, len, use_sg);
376 if (result != USB_STOR_XFER_GOOD) 376 if (result != USB_STOR_XFER_GOOD)
377 return USB_STOR_TRANSPORT_ERROR; 377 return USB_STOR_TRANSPORT_ERROR;
378 378
@@ -392,7 +392,7 @@ static int usbat_hp8200e_rw_block_test(struct us_data *us,
392 unsigned char timeout, 392 unsigned char timeout,
393 unsigned char qualifier, 393 unsigned char qualifier,
394 int direction, 394 int direction,
395 unsigned char *content, 395 void *buf,
396 unsigned short len, 396 unsigned short len,
397 int use_sg, 397 int use_sg,
398 int minutes) 398 int minutes)
@@ -472,7 +472,7 @@ static int usbat_hp8200e_rw_block_test(struct us_data *us,
472 } 472 }
473 473
474 result = usb_stor_bulk_transfer_sg(us, 474 result = usb_stor_bulk_transfer_sg(us,
475 pipe, content, len, use_sg, NULL); 475 pipe, buf, len, use_sg, NULL);
476 476
477 /* 477 /*
478 * If we get a stall on the bulk download, we'll retry 478 * If we get a stall on the bulk download, we'll retry
@@ -606,7 +606,7 @@ static int usbat_multiple_write(struct us_data *us,
606 * other related details) are defined beforehand with _set_shuttle_features(). 606 * other related details) are defined beforehand with _set_shuttle_features().
607 */ 607 */
608static int usbat_read_blocks(struct us_data *us, 608static int usbat_read_blocks(struct us_data *us,
609 unsigned char *buffer, 609 void* buffer,
610 int len, 610 int len,
611 int use_sg) 611 int use_sg)
612{ 612{
@@ -648,7 +648,7 @@ static int usbat_read_blocks(struct us_data *us,
648 * other related details) are defined beforehand with _set_shuttle_features(). 648 * other related details) are defined beforehand with _set_shuttle_features().
649 */ 649 */
650static int usbat_write_blocks(struct us_data *us, 650static int usbat_write_blocks(struct us_data *us,
651 unsigned char *buffer, 651 void* buffer,
652 int len, 652 int len,
653 int use_sg) 653 int use_sg)
654{ 654{
@@ -1170,15 +1170,15 @@ static int usbat_hp8200e_handle_read10(struct us_data *us,
1170 US_DEBUGP("handle_read10: transfersize %d\n", 1170 US_DEBUGP("handle_read10: transfersize %d\n",
1171 srb->transfersize); 1171 srb->transfersize);
1172 1172
1173 if (srb->request_bufflen < 0x10000) { 1173 if (scsi_bufflen(srb) < 0x10000) {
1174 1174
1175 result = usbat_hp8200e_rw_block_test(us, USBAT_ATA, 1175 result = usbat_hp8200e_rw_block_test(us, USBAT_ATA,
1176 registers, data, 19, 1176 registers, data, 19,
1177 USBAT_ATA_DATA, USBAT_ATA_STATUS, 0xFD, 1177 USBAT_ATA_DATA, USBAT_ATA_STATUS, 0xFD,
1178 (USBAT_QUAL_FCQ | USBAT_QUAL_ALQ), 1178 (USBAT_QUAL_FCQ | USBAT_QUAL_ALQ),
1179 DMA_FROM_DEVICE, 1179 DMA_FROM_DEVICE,
1180 srb->request_buffer, 1180 scsi_sglist(srb),
1181 srb->request_bufflen, srb->use_sg, 1); 1181 scsi_bufflen(srb), scsi_sg_count(srb), 1);
1182 1182
1183 return result; 1183 return result;
1184 } 1184 }
@@ -1196,7 +1196,7 @@ static int usbat_hp8200e_handle_read10(struct us_data *us,
1196 len <<= 16; 1196 len <<= 16;
1197 len |= data[7+7]; 1197 len |= data[7+7];
1198 US_DEBUGP("handle_read10: GPCMD_READ_CD: len %d\n", len); 1198 US_DEBUGP("handle_read10: GPCMD_READ_CD: len %d\n", len);
1199 srb->transfersize = srb->request_bufflen/len; 1199 srb->transfersize = scsi_bufflen(srb)/len;
1200 } 1200 }
1201 1201
1202 if (!srb->transfersize) { 1202 if (!srb->transfersize) {
@@ -1213,7 +1213,7 @@ static int usbat_hp8200e_handle_read10(struct us_data *us,
1213 1213
1214 len = (65535/srb->transfersize) * srb->transfersize; 1214 len = (65535/srb->transfersize) * srb->transfersize;
1215 US_DEBUGP("Max read is %d bytes\n", len); 1215 US_DEBUGP("Max read is %d bytes\n", len);
1216 len = min(len, srb->request_bufflen); 1216 len = min(len, scsi_bufflen(srb));
1217 buffer = kmalloc(len, GFP_NOIO); 1217 buffer = kmalloc(len, GFP_NOIO);
1218 if (buffer == NULL) /* bloody hell! */ 1218 if (buffer == NULL) /* bloody hell! */
1219 return USB_STOR_TRANSPORT_FAILED; 1219 return USB_STOR_TRANSPORT_FAILED;
@@ -1222,10 +1222,10 @@ static int usbat_hp8200e_handle_read10(struct us_data *us,
1222 sector |= short_pack(data[7+5], data[7+4]); 1222 sector |= short_pack(data[7+5], data[7+4]);
1223 transferred = 0; 1223 transferred = 0;
1224 1224
1225 while (transferred != srb->request_bufflen) { 1225 while (transferred != scsi_bufflen(srb)) {
1226 1226
1227 if (len > srb->request_bufflen - transferred) 1227 if (len > scsi_bufflen(srb) - transferred)
1228 len = srb->request_bufflen - transferred; 1228 len = scsi_bufflen(srb) - transferred;
1229 1229
1230 data[3] = len&0xFF; /* (cylL) = expected length (L) */ 1230 data[3] = len&0xFF; /* (cylL) = expected length (L) */
1231 data[4] = (len>>8)&0xFF; /* (cylH) = expected length (H) */ 1231 data[4] = (len>>8)&0xFF; /* (cylH) = expected length (H) */
@@ -1261,7 +1261,7 @@ static int usbat_hp8200e_handle_read10(struct us_data *us,
1261 transferred += len; 1261 transferred += len;
1262 sector += len / srb->transfersize; 1262 sector += len / srb->transfersize;
1263 1263
1264 } /* while transferred != srb->request_bufflen */ 1264 } /* while transferred != scsi_bufflen(srb) */
1265 1265
1266 kfree(buffer); 1266 kfree(buffer);
1267 return result; 1267 return result;
@@ -1429,9 +1429,8 @@ static int usbat_hp8200e_transport(struct scsi_cmnd *srb, struct us_data *us)
1429 unsigned char data[32]; 1429 unsigned char data[32];
1430 unsigned int len; 1430 unsigned int len;
1431 int i; 1431 int i;
1432 char string[64];
1433 1432
1434 len = srb->request_bufflen; 1433 len = scsi_bufflen(srb);
1435 1434
1436 /* Send A0 (ATA PACKET COMMAND). 1435 /* Send A0 (ATA PACKET COMMAND).
1437 Note: I guess we're never going to get any of the ATA 1436 Note: I guess we're never going to get any of the ATA
@@ -1472,8 +1471,8 @@ static int usbat_hp8200e_transport(struct scsi_cmnd *srb, struct us_data *us)
1472 USBAT_ATA_DATA, USBAT_ATA_STATUS, 0xFD, 1471 USBAT_ATA_DATA, USBAT_ATA_STATUS, 0xFD,
1473 (USBAT_QUAL_FCQ | USBAT_QUAL_ALQ), 1472 (USBAT_QUAL_FCQ | USBAT_QUAL_ALQ),
1474 DMA_TO_DEVICE, 1473 DMA_TO_DEVICE,
1475 srb->request_buffer, 1474 scsi_sglist(srb),
1476 len, srb->use_sg, 10); 1475 len, scsi_sg_count(srb), 10);
1477 1476
1478 if (result == USB_STOR_TRANSPORT_GOOD) { 1477 if (result == USB_STOR_TRANSPORT_GOOD) {
1479 transferred += len; 1478 transferred += len;
@@ -1540,23 +1539,8 @@ static int usbat_hp8200e_transport(struct scsi_cmnd *srb, struct us_data *us)
1540 len = *status; 1539 len = *status;
1541 1540
1542 1541
1543 result = usbat_read_block(us, srb->request_buffer, len, srb->use_sg); 1542 result = usbat_read_block(us, scsi_sglist(srb), len,
1544 1543 scsi_sg_count(srb));
1545 /* Debug-print the first 32 bytes of the transfer */
1546
1547 if (!srb->use_sg) {
1548 string[0] = 0;
1549 for (i=0; i<len && i<32; i++) {
1550 sprintf(string+strlen(string), "%02X ",
1551 ((unsigned char *)srb->request_buffer)[i]);
1552 if ((i%16)==15) {
1553 US_DEBUGP("%s\n", string);
1554 string[0] = 0;
1555 }
1556 }
1557 if (string[0]!=0)
1558 US_DEBUGP("%s\n", string);
1559 }
1560 } 1544 }
1561 1545
1562 return result; 1546 return result;