aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/usb/storage/alauda.c101
-rw-r--r--drivers/usb/storage/cypress_atacb.c2
-rw-r--r--drivers/usb/storage/datafab.c59
-rw-r--r--drivers/usb/storage/debug.c28
-rw-r--r--drivers/usb/storage/debug.h17
-rw-r--r--drivers/usb/storage/ene_ub6250.c86
-rw-r--r--drivers/usb/storage/freecom.c85
-rw-r--r--drivers/usb/storage/initializers.c10
-rw-r--r--drivers/usb/storage/isd200.c292
-rw-r--r--drivers/usb/storage/jumpshot.c69
-rw-r--r--drivers/usb/storage/karma.c6
-rw-r--r--drivers/usb/storage/option_ms.c23
-rw-r--r--drivers/usb/storage/realtek_cr.c128
-rw-r--r--drivers/usb/storage/scsiglue.c13
-rw-r--r--drivers/usb/storage/sddr09.c146
-rw-r--r--drivers/usb/storage/sddr55.c86
-rw-r--r--drivers/usb/storage/shuttle_usbat.c119
-rw-r--r--drivers/usb/storage/sierra_ms.c43
-rw-r--r--drivers/usb/storage/transport.c181
-rw-r--r--drivers/usb/storage/usb.c93
20 files changed, 753 insertions, 834 deletions
diff --git a/drivers/usb/storage/alauda.c b/drivers/usb/storage/alauda.c
index be5564cc8e01..77a2ddfe6487 100644
--- a/drivers/usb/storage/alauda.c
+++ b/drivers/usb/storage/alauda.c
@@ -326,8 +326,7 @@ static int alauda_get_media_status(struct us_data *us, unsigned char *data)
326 rc = usb_stor_ctrl_transfer(us, us->recv_ctrl_pipe, 326 rc = usb_stor_ctrl_transfer(us, us->recv_ctrl_pipe,
327 command, 0xc0, 0, 1, data, 2); 327 command, 0xc0, 0, 1, data, 2);
328 328
329 US_DEBUGP("alauda_get_media_status: Media status %02X %02X\n", 329 usb_stor_dbg(us, "Media status %02X %02X\n", data[0], data[1]);
330 data[0], data[1]);
331 330
332 return rc; 331 return rc;
333} 332}
@@ -402,7 +401,7 @@ static int alauda_init_media(struct us_data *us)
402 ready = 1; 401 ready = 1;
403 } 402 }
404 403
405 US_DEBUGP("alauda_init_media: We are ready for action!\n"); 404 usb_stor_dbg(us, "We are ready for action!\n");
406 405
407 if (alauda_ack_media(us) != USB_STOR_XFER_GOOD) 406 if (alauda_ack_media(us) != USB_STOR_XFER_GOOD)
408 return USB_STOR_TRANSPORT_ERROR; 407 return USB_STOR_TRANSPORT_ERROR;
@@ -413,15 +412,15 @@ static int alauda_init_media(struct us_data *us)
413 return USB_STOR_TRANSPORT_ERROR; 412 return USB_STOR_TRANSPORT_ERROR;
414 413
415 if (data[0] != 0x14) { 414 if (data[0] != 0x14) {
416 US_DEBUGP("alauda_init_media: Media not ready after ack\n"); 415 usb_stor_dbg(us, "Media not ready after ack\n");
417 return USB_STOR_TRANSPORT_ERROR; 416 return USB_STOR_TRANSPORT_ERROR;
418 } 417 }
419 418
420 if (alauda_get_media_signature(us, data) != USB_STOR_XFER_GOOD) 419 if (alauda_get_media_signature(us, data) != USB_STOR_XFER_GOOD)
421 return USB_STOR_TRANSPORT_ERROR; 420 return USB_STOR_TRANSPORT_ERROR;
422 421
423 US_DEBUGP("alauda_init_media: Media signature: %02X %02X %02X %02X\n", 422 usb_stor_dbg(us, "Media signature: %02X %02X %02X %02X\n",
424 data[0], data[1], data[2], data[3]); 423 data[0], data[1], data[2], data[3]);
425 media_info = alauda_card_find_id(data[1]); 424 media_info = alauda_card_find_id(data[1]);
426 if (media_info == NULL) { 425 if (media_info == NULL) {
427 printk(KERN_WARNING 426 printk(KERN_WARNING
@@ -432,8 +431,8 @@ static int alauda_init_media(struct us_data *us)
432 } 431 }
433 432
434 MEDIA_INFO(us).capacity = 1 << media_info->chipshift; 433 MEDIA_INFO(us).capacity = 1 << media_info->chipshift;
435 US_DEBUGP("Found media with capacity: %ldMB\n", 434 usb_stor_dbg(us, "Found media with capacity: %ldMB\n",
436 MEDIA_INFO(us).capacity >> 20); 435 MEDIA_INFO(us).capacity >> 20);
437 436
438 MEDIA_INFO(us).pageshift = media_info->pageshift; 437 MEDIA_INFO(us).pageshift = media_info->pageshift;
439 MEDIA_INFO(us).blockshift = media_info->blockshift; 438 MEDIA_INFO(us).blockshift = media_info->blockshift;
@@ -472,7 +471,7 @@ static int alauda_check_media(struct us_data *us)
472 /* Check for no media or door open */ 471 /* Check for no media or door open */
473 if ((status[0] & 0x80) || ((status[0] & 0x1F) == 0x10) 472 if ((status[0] & 0x80) || ((status[0] & 0x1F) == 0x10)
474 || ((status[1] & 0x01) == 0)) { 473 || ((status[1] & 0x01) == 0)) {
475 US_DEBUGP("alauda_check_media: No media, or door open\n"); 474 usb_stor_dbg(us, "No media, or door open\n");
476 alauda_free_maps(&MEDIA_INFO(us)); 475 alauda_free_maps(&MEDIA_INFO(us));
477 info->sense_key = 0x02; 476 info->sense_key = 0x02;
478 info->sense_asc = 0x3A; 477 info->sense_asc = 0x3A;
@@ -482,7 +481,7 @@ static int alauda_check_media(struct us_data *us)
482 481
483 /* Check for media change */ 482 /* Check for media change */
484 if (status[0] & 0x08) { 483 if (status[0] & 0x08) {
485 US_DEBUGP("alauda_check_media: Media change detected\n"); 484 usb_stor_dbg(us, "Media change detected\n");
486 alauda_free_maps(&MEDIA_INFO(us)); 485 alauda_free_maps(&MEDIA_INFO(us));
487 alauda_init_media(us); 486 alauda_init_media(us);
488 487
@@ -518,7 +517,7 @@ static int alauda_check_status2(struct us_data *us)
518 if (rc != USB_STOR_XFER_GOOD) 517 if (rc != USB_STOR_XFER_GOOD)
519 return rc; 518 return rc;
520 519
521 US_DEBUGP("alauda_check_status2: %02X %02X %02X\n", data[0], data[1], data[2]); 520 usb_stor_dbg(us, "%02X %02X %02X\n", data[0], data[1], data[2]);
522 if (data[0] & ALAUDA_STATUS_ERROR) 521 if (data[0] & ALAUDA_STATUS_ERROR)
523 return USB_STOR_XFER_ERROR; 522 return USB_STOR_XFER_ERROR;
524 523
@@ -584,7 +583,7 @@ static int alauda_read_map(struct us_data *us, unsigned int zone)
584 goto error; 583 goto error;
585 } 584 }
586 585
587 US_DEBUGP("alauda_read_map: Mapping blocks for zone %d\n", zone); 586 usb_stor_dbg(us, "Mapping blocks for zone %d\n", zone);
588 587
589 /* 1024 PBA's per zone */ 588 /* 1024 PBA's per zone */
590 for (i = 0; i < zonesize; i++) 589 for (i = 0; i < zonesize; i++)
@@ -604,7 +603,7 @@ static int alauda_read_map(struct us_data *us, unsigned int zone)
604 if (data[j] != 0) 603 if (data[j] != 0)
605 goto nonz; 604 goto nonz;
606 pba_to_lba[i] = UNUSABLE; 605 pba_to_lba[i] = UNUSABLE;
607 US_DEBUGP("alauda_read_map: PBA %d has no logical mapping\n", blocknum); 606 usb_stor_dbg(us, "PBA %d has no logical mapping\n", blocknum);
608 continue; 607 continue;
609 608
610 nonz: 609 nonz:
@@ -617,19 +616,18 @@ static int alauda_read_map(struct us_data *us, unsigned int zone)
617 nonff: 616 nonff:
618 /* normal PBAs start with six FFs */ 617 /* normal PBAs start with six FFs */
619 if (j < 6) { 618 if (j < 6) {
620 US_DEBUGP("alauda_read_map: PBA %d has no logical mapping: " 619 usb_stor_dbg(us, "PBA %d has no logical mapping: reserved area = %02X%02X%02X%02X data status %02X block status %02X\n",
621 "reserved area = %02X%02X%02X%02X " 620 blocknum,
622 "data status %02X block status %02X\n", 621 data[0], data[1], data[2], data[3],
623 blocknum, data[0], data[1], data[2], data[3], 622 data[4], data[5]);
624 data[4], data[5]);
625 pba_to_lba[i] = UNUSABLE; 623 pba_to_lba[i] = UNUSABLE;
626 continue; 624 continue;
627 } 625 }
628 626
629 if ((data[6] >> 4) != 0x01) { 627 if ((data[6] >> 4) != 0x01) {
630 US_DEBUGP("alauda_read_map: PBA %d has invalid address " 628 usb_stor_dbg(us, "PBA %d has invalid address field %02X%02X/%02X%02X\n",
631 "field %02X%02X/%02X%02X\n", 629 blocknum, data[6], data[7],
632 blocknum, data[6], data[7], data[11], data[12]); 630 data[11], data[12]);
633 pba_to_lba[i] = UNUSABLE; 631 pba_to_lba[i] = UNUSABLE;
634 continue; 632 continue;
635 } 633 }
@@ -711,7 +709,7 @@ static int alauda_erase_block(struct us_data *us, u16 pba)
711 }; 709 };
712 unsigned char buf[2]; 710 unsigned char buf[2];
713 711
714 US_DEBUGP("alauda_erase_block: Erasing PBA %d\n", pba); 712 usb_stor_dbg(us, "Erasing PBA %d\n", pba);
715 713
716 rc = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, 714 rc = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,
717 command, 9, NULL); 715 command, 9, NULL);
@@ -723,8 +721,7 @@ static int alauda_erase_block(struct us_data *us, u16 pba)
723 if (rc != USB_STOR_XFER_GOOD) 721 if (rc != USB_STOR_XFER_GOOD)
724 return rc; 722 return rc;
725 723
726 US_DEBUGP("alauda_erase_block: Erase result: %02X %02X\n", 724 usb_stor_dbg(us, "Erase result: %02X %02X\n", buf[0], buf[1]);
727 buf[0], buf[1]);
728 return rc; 725 return rc;
729} 726}
730 727
@@ -741,8 +738,7 @@ static int alauda_read_block_raw(struct us_data *us, u16 pba,
741 PBA_ZONE(pba), 0, PBA_LO(pba) + page, pages, 0, MEDIA_PORT(us) 738 PBA_ZONE(pba), 0, PBA_LO(pba) + page, pages, 0, MEDIA_PORT(us)
742 }; 739 };
743 740
744 US_DEBUGP("alauda_read_block: pba %d page %d count %d\n", 741 usb_stor_dbg(us, "pba %d page %d count %d\n", pba, page, pages);
745 pba, page, pages);
746 742
747 rc = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, 743 rc = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,
748 command, 9, NULL); 744 command, 9, NULL);
@@ -793,7 +789,7 @@ static int alauda_write_block(struct us_data *us, u16 pba, unsigned char *data)
793 PBA_ZONE(pba), 0, PBA_LO(pba), 32, 0, MEDIA_PORT(us) 789 PBA_ZONE(pba), 0, PBA_LO(pba), 32, 0, MEDIA_PORT(us)
794 }; 790 };
795 791
796 US_DEBUGP("alauda_write_block: pba %d\n", pba); 792 usb_stor_dbg(us, "pba %d\n", pba);
797 793
798 rc = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, 794 rc = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,
799 command, 9, NULL); 795 command, 9, NULL);
@@ -866,14 +862,14 @@ static int alauda_write_lba(struct us_data *us, u16 lba,
866 cptr = bptr + pagesize; 862 cptr = bptr + pagesize;
867 nand_compute_ecc(bptr, ecc); 863 nand_compute_ecc(bptr, ecc);
868 if (!nand_compare_ecc(cptr+13, ecc)) { 864 if (!nand_compare_ecc(cptr+13, ecc)) {
869 US_DEBUGP("Warning: bad ecc in page %d- of pba %d\n", 865 usb_stor_dbg(us, "Warning: bad ecc in page %d- of pba %d\n",
870 i, pba); 866 i, pba);
871 nand_store_ecc(cptr+13, ecc); 867 nand_store_ecc(cptr+13, ecc);
872 } 868 }
873 nand_compute_ecc(bptr + (pagesize / 2), ecc); 869 nand_compute_ecc(bptr + (pagesize / 2), ecc);
874 if (!nand_compare_ecc(cptr+8, ecc)) { 870 if (!nand_compare_ecc(cptr+8, ecc)) {
875 US_DEBUGP("Warning: bad ecc in page %d+ of pba %d\n", 871 usb_stor_dbg(us, "Warning: bad ecc in page %d+ of pba %d\n",
876 i, pba); 872 i, pba);
877 nand_store_ecc(cptr+8, ecc); 873 nand_store_ecc(cptr+8, ecc);
878 } 874 }
879 cptr[6] = cptr[11] = MSB_of(lbap); 875 cptr[6] = cptr[11] = MSB_of(lbap);
@@ -900,8 +896,7 @@ static int alauda_write_lba(struct us_data *us, u16 lba,
900 new_pba_offset = new_pba - (zone * zonesize); 896 new_pba_offset = new_pba - (zone * zonesize);
901 MEDIA_INFO(us).pba_to_lba[zone][new_pba_offset] = lba; 897 MEDIA_INFO(us).pba_to_lba[zone][new_pba_offset] = lba;
902 MEDIA_INFO(us).lba_to_pba[zone][lba_offset] = new_pba; 898 MEDIA_INFO(us).lba_to_pba[zone][lba_offset] = new_pba;
903 US_DEBUGP("alauda_write_lba: Remapped LBA %d to PBA %d\n", 899 usb_stor_dbg(us, "Remapped LBA %d to PBA %d\n", lba, new_pba);
904 lba, new_pba);
905 900
906 if (pba != UNDEF) { 901 if (pba != UNDEF) {
907 unsigned int pba_offset = pba - (zone * zonesize); 902 unsigned int pba_offset = pba - (zone * zonesize);
@@ -964,8 +959,8 @@ static int alauda_read_data(struct us_data *us, unsigned long address,
964 959
965 /* Not overflowing capacity? */ 960 /* Not overflowing capacity? */
966 if (lba >= max_lba) { 961 if (lba >= max_lba) {
967 US_DEBUGP("Error: Requested lba %u exceeds " 962 usb_stor_dbg(us, "Error: Requested lba %u exceeds maximum %u\n",
968 "maximum %u\n", lba, max_lba); 963 lba, max_lba);
969 result = USB_STOR_TRANSPORT_ERROR; 964 result = USB_STOR_TRANSPORT_ERROR;
970 break; 965 break;
971 } 966 }
@@ -978,8 +973,8 @@ static int alauda_read_data(struct us_data *us, unsigned long address,
978 pba = MEDIA_INFO(us).lba_to_pba[zone][lba_offset]; 973 pba = MEDIA_INFO(us).lba_to_pba[zone][lba_offset];
979 974
980 if (pba == UNDEF) { /* this lba was never written */ 975 if (pba == UNDEF) { /* this lba was never written */
981 US_DEBUGP("Read %d zero pages (LBA %d) page %d\n", 976 usb_stor_dbg(us, "Read %d zero pages (LBA %d) page %d\n",
982 pages, lba, page); 977 pages, lba, page);
983 978
984 /* This is not really an error. It just means 979 /* This is not really an error. It just means
985 that the block has never been written. 980 that the block has never been written.
@@ -988,9 +983,8 @@ static int alauda_read_data(struct us_data *us, unsigned long address,
988 983
989 memset(buffer, 0, len); 984 memset(buffer, 0, len);
990 } else { 985 } else {
991 US_DEBUGP("Read %d pages, from PBA %d" 986 usb_stor_dbg(us, "Read %d pages, from PBA %d (LBA %d) page %d\n",
992 " (LBA %d) page %d\n", 987 pages, pba, lba, page);
993 pages, pba, lba, page);
994 988
995 result = alauda_read_block(us, pba, page, pages, buffer); 989 result = alauda_read_block(us, pba, page, pages, buffer);
996 if (result != USB_STOR_TRANSPORT_GOOD) 990 if (result != USB_STOR_TRANSPORT_GOOD)
@@ -1066,8 +1060,8 @@ static int alauda_write_data(struct us_data *us, unsigned long address,
1066 1060
1067 /* Not overflowing capacity? */ 1061 /* Not overflowing capacity? */
1068 if (lba >= max_lba) { 1062 if (lba >= max_lba) {
1069 US_DEBUGP("alauda_write_data: Requested lba %u exceeds " 1063 usb_stor_dbg(us, "Requested lba %u exceeds maximum %u\n",
1070 "maximum %u\n", lba, max_lba); 1064 lba, max_lba);
1071 result = USB_STOR_TRANSPORT_ERROR; 1065 result = USB_STOR_TRANSPORT_ERROR;
1072 break; 1066 break;
1073 } 1067 }
@@ -1122,11 +1116,9 @@ static int init_alauda(struct us_data *us)
1122 nand_init_ecc(); 1116 nand_init_ecc();
1123 1117
1124 us->extra = kzalloc(sizeof(struct alauda_info), GFP_NOIO); 1118 us->extra = kzalloc(sizeof(struct alauda_info), GFP_NOIO);
1125 if (!us->extra) { 1119 if (!us->extra)
1126 US_DEBUGP("init_alauda: Gah! Can't allocate storage for"
1127 "alauda info struct!\n");
1128 return USB_STOR_TRANSPORT_ERROR; 1120 return USB_STOR_TRANSPORT_ERROR;
1129 } 1121
1130 info = (struct alauda_info *) us->extra; 1122 info = (struct alauda_info *) us->extra;
1131 us->extra_destructor = alauda_info_destructor; 1123 us->extra_destructor = alauda_info_destructor;
1132 1124
@@ -1147,15 +1139,14 @@ static int alauda_transport(struct scsi_cmnd *srb, struct us_data *us)
1147 }; 1139 };
1148 1140
1149 if (srb->cmnd[0] == INQUIRY) { 1141 if (srb->cmnd[0] == INQUIRY) {
1150 US_DEBUGP("alauda_transport: INQUIRY. " 1142 usb_stor_dbg(us, "INQUIRY - Returning bogus response\n");
1151 "Returning bogus response.\n");
1152 memcpy(ptr, inquiry_response, sizeof(inquiry_response)); 1143 memcpy(ptr, inquiry_response, sizeof(inquiry_response));
1153 fill_inquiry_response(us, ptr, 36); 1144 fill_inquiry_response(us, ptr, 36);
1154 return USB_STOR_TRANSPORT_GOOD; 1145 return USB_STOR_TRANSPORT_GOOD;
1155 } 1146 }
1156 1147
1157 if (srb->cmnd[0] == TEST_UNIT_READY) { 1148 if (srb->cmnd[0] == TEST_UNIT_READY) {
1158 US_DEBUGP("alauda_transport: TEST_UNIT_READY.\n"); 1149 usb_stor_dbg(us, "TEST_UNIT_READY\n");
1159 return alauda_check_media(us); 1150 return alauda_check_media(us);
1160 } 1151 }
1161 1152
@@ -1193,8 +1184,7 @@ static int alauda_transport(struct scsi_cmnd *srb, struct us_data *us)
1193 page |= short_pack(srb->cmnd[5], srb->cmnd[4]); 1184 page |= short_pack(srb->cmnd[5], srb->cmnd[4]);
1194 pages = short_pack(srb->cmnd[8], srb->cmnd[7]); 1185 pages = short_pack(srb->cmnd[8], srb->cmnd[7]);
1195 1186
1196 US_DEBUGP("alauda_transport: READ_10: page %d pagect %d\n", 1187 usb_stor_dbg(us, "READ_10: page %d pagect %d\n", page, pages);
1197 page, pages);
1198 1188
1199 return alauda_read_data(us, page, pages); 1189 return alauda_read_data(us, page, pages);
1200 } 1190 }
@@ -1211,14 +1201,13 @@ static int alauda_transport(struct scsi_cmnd *srb, struct us_data *us)
1211 page |= short_pack(srb->cmnd[5], srb->cmnd[4]); 1201 page |= short_pack(srb->cmnd[5], srb->cmnd[4]);
1212 pages = short_pack(srb->cmnd[8], srb->cmnd[7]); 1202 pages = short_pack(srb->cmnd[8], srb->cmnd[7]);
1213 1203
1214 US_DEBUGP("alauda_transport: WRITE_10: page %d pagect %d\n", 1204 usb_stor_dbg(us, "WRITE_10: page %d pagect %d\n", page, pages);
1215 page, pages);
1216 1205
1217 return alauda_write_data(us, page, pages); 1206 return alauda_write_data(us, page, pages);
1218 } 1207 }
1219 1208
1220 if (srb->cmnd[0] == REQUEST_SENSE) { 1209 if (srb->cmnd[0] == REQUEST_SENSE) {
1221 US_DEBUGP("alauda_transport: REQUEST_SENSE.\n"); 1210 usb_stor_dbg(us, "REQUEST_SENSE\n");
1222 1211
1223 memset(ptr, 0, 18); 1212 memset(ptr, 0, 18);
1224 ptr[0] = 0xF0; 1213 ptr[0] = 0xF0;
@@ -1237,8 +1226,8 @@ static int alauda_transport(struct scsi_cmnd *srb, struct us_data *us)
1237 return USB_STOR_TRANSPORT_GOOD; 1226 return USB_STOR_TRANSPORT_GOOD;
1238 } 1227 }
1239 1228
1240 US_DEBUGP("alauda_transport: Gah! Unknown command: %d (0x%x)\n", 1229 usb_stor_dbg(us, "Gah! Unknown command: %d (0x%x)\n",
1241 srb->cmnd[0], srb->cmnd[0]); 1230 srb->cmnd[0], srb->cmnd[0]);
1242 info->sense_key = 0x05; 1231 info->sense_key = 0x05;
1243 info->sense_asc = 0x20; 1232 info->sense_asc = 0x20;
1244 info->sense_ascq = 0x00; 1233 info->sense_ascq = 0x00;
diff --git a/drivers/usb/storage/cypress_atacb.c b/drivers/usb/storage/cypress_atacb.c
index 070b5c0ebbf9..e4efc7bb833f 100644
--- a/drivers/usb/storage/cypress_atacb.c
+++ b/drivers/usb/storage/cypress_atacb.c
@@ -159,7 +159,7 @@ static void cypress_atacb_passthrough(struct scsi_cmnd *srb, struct us_data *us)
159 if (srb->result == SAM_STAT_CHECK_CONDITION && 159 if (srb->result == SAM_STAT_CHECK_CONDITION &&
160 memcmp(srb->sense_buffer, usb_stor_sense_invalidCDB, 160 memcmp(srb->sense_buffer, usb_stor_sense_invalidCDB,
161 sizeof(usb_stor_sense_invalidCDB)) == 0) { 161 sizeof(usb_stor_sense_invalidCDB)) == 0) {
162 US_DEBUGP("cypress atacb not supported ???\n"); 162 usb_stor_dbg(us, "cypress atacb not supported ???\n");
163 goto end; 163 goto end;
164 } 164 }
165 165
diff --git a/drivers/usb/storage/datafab.c b/drivers/usb/storage/datafab.c
index 494fee5af41d..7b17c2169812 100644
--- a/drivers/usb/storage/datafab.c
+++ b/drivers/usb/storage/datafab.c
@@ -123,7 +123,7 @@ datafab_bulk_read(struct us_data *us, unsigned char *data, unsigned int len) {
123 if (len == 0) 123 if (len == 0)
124 return USB_STOR_XFER_GOOD; 124 return USB_STOR_XFER_GOOD;
125 125
126 US_DEBUGP("datafab_bulk_read: len = %d\n", len); 126 usb_stor_dbg(us, "len = %d\n", len);
127 return usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, 127 return usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
128 data, len, NULL); 128 data, len, NULL);
129} 129}
@@ -134,7 +134,7 @@ datafab_bulk_write(struct us_data *us, unsigned char *data, unsigned int len) {
134 if (len == 0) 134 if (len == 0)
135 return USB_STOR_XFER_GOOD; 135 return USB_STOR_XFER_GOOD;
136 136
137 US_DEBUGP("datafab_bulk_write: len = %d\n", len); 137 usb_stor_dbg(us, "len = %d\n", len);
138 return usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, 138 return usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,
139 data, len, NULL); 139 data, len, NULL);
140} 140}
@@ -300,9 +300,8 @@ static int datafab_write_data(struct us_data *us,
300 goto leave; 300 goto leave;
301 301
302 if (reply[0] != 0x50 && reply[1] != 0) { 302 if (reply[0] != 0x50 && reply[1] != 0) {
303 US_DEBUGP("datafab_write_data: Gah! " 303 usb_stor_dbg(us, "Gah! write return code: %02x %02x\n",
304 "write return code: %02x %02x\n", 304 reply[0], reply[1]);
305 reply[0], reply[1]);
306 result = USB_STOR_TRANSPORT_ERROR; 305 result = USB_STOR_TRANSPORT_ERROR;
307 goto leave; 306 goto leave;
308 } 307 }
@@ -342,7 +341,7 @@ static int datafab_determine_lun(struct us_data *us,
342 if (!buf) 341 if (!buf)
343 return USB_STOR_TRANSPORT_ERROR; 342 return USB_STOR_TRANSPORT_ERROR;
344 343
345 US_DEBUGP("datafab_determine_lun: locating...\n"); 344 usb_stor_dbg(us, "locating...\n");
346 345
347 // we'll try 3 times before giving up... 346 // we'll try 3 times before giving up...
348 // 347 //
@@ -474,16 +473,16 @@ static int datafab_handle_mode_sense(struct us_data *us,
474 473
475 switch (pc) { 474 switch (pc) {
476 case 0x0: 475 case 0x0:
477 US_DEBUGP("datafab_handle_mode_sense: Current values\n"); 476 usb_stor_dbg(us, "Current values\n");
478 break; 477 break;
479 case 0x1: 478 case 0x1:
480 US_DEBUGP("datafab_handle_mode_sense: Changeable values\n"); 479 usb_stor_dbg(us, "Changeable values\n");
481 break; 480 break;
482 case 0x2: 481 case 0x2:
483 US_DEBUGP("datafab_handle_mode_sense: Default values\n"); 482 usb_stor_dbg(us, "Default values\n");
484 break; 483 break;
485 case 0x3: 484 case 0x3:
486 US_DEBUGP("datafab_handle_mode_sense: Saves values\n"); 485 usb_stor_dbg(us, "Saves values\n");
487 break; 486 break;
488 } 487 }
489 488
@@ -566,11 +565,9 @@ static int datafab_transport(struct scsi_cmnd *srb, struct us_data *us)
566 565
567 if (!us->extra) { 566 if (!us->extra) {
568 us->extra = kzalloc(sizeof(struct datafab_info), GFP_NOIO); 567 us->extra = kzalloc(sizeof(struct datafab_info), GFP_NOIO);
569 if (!us->extra) { 568 if (!us->extra)
570 US_DEBUGP("datafab_transport: Gah! "
571 "Can't allocate storage for Datafab info struct!\n");
572 return USB_STOR_TRANSPORT_ERROR; 569 return USB_STOR_TRANSPORT_ERROR;
573 } 570
574 us->extra_destructor = datafab_info_destructor; 571 us->extra_destructor = datafab_info_destructor;
575 ((struct datafab_info *)us->extra)->lun = -1; 572 ((struct datafab_info *)us->extra)->lun = -1;
576 } 573 }
@@ -578,7 +575,7 @@ static int datafab_transport(struct scsi_cmnd *srb, struct us_data *us)
578 info = (struct datafab_info *) (us->extra); 575 info = (struct datafab_info *) (us->extra);
579 576
580 if (srb->cmnd[0] == INQUIRY) { 577 if (srb->cmnd[0] == INQUIRY) {
581 US_DEBUGP("datafab_transport: INQUIRY. Returning bogus response"); 578 usb_stor_dbg(us, "INQUIRY - Returning bogus response\n");
582 memcpy(ptr, inquiry_reply, sizeof(inquiry_reply)); 579 memcpy(ptr, inquiry_reply, sizeof(inquiry_reply));
583 fill_inquiry_response(us, ptr, 36); 580 fill_inquiry_response(us, ptr, 36);
584 return USB_STOR_TRANSPORT_GOOD; 581 return USB_STOR_TRANSPORT_GOOD;
@@ -590,8 +587,8 @@ static int datafab_transport(struct scsi_cmnd *srb, struct us_data *us)
590 if (rc != USB_STOR_TRANSPORT_GOOD) 587 if (rc != USB_STOR_TRANSPORT_GOOD)
591 return rc; 588 return rc;
592 589
593 US_DEBUGP("datafab_transport: READ_CAPACITY: %ld sectors, %ld bytes per sector\n", 590 usb_stor_dbg(us, "READ_CAPACITY: %ld sectors, %ld bytes per sector\n",
594 info->sectors, info->ssize); 591 info->sectors, info->ssize);
595 592
596 // build the reply 593 // build the reply
597 // we need the last sector, not the number of sectors 594 // we need the last sector, not the number of sectors
@@ -603,7 +600,7 @@ static int datafab_transport(struct scsi_cmnd *srb, struct us_data *us)
603 } 600 }
604 601
605 if (srb->cmnd[0] == MODE_SELECT_10) { 602 if (srb->cmnd[0] == MODE_SELECT_10) {
606 US_DEBUGP("datafab_transport: Gah! MODE_SELECT_10.\n"); 603 usb_stor_dbg(us, "Gah! MODE_SELECT_10\n");
607 return USB_STOR_TRANSPORT_ERROR; 604 return USB_STOR_TRANSPORT_ERROR;
608 } 605 }
609 606
@@ -615,7 +612,8 @@ static int datafab_transport(struct scsi_cmnd *srb, struct us_data *us)
615 612
616 blocks = ((u32)(srb->cmnd[7]) << 8) | ((u32)(srb->cmnd[8])); 613 blocks = ((u32)(srb->cmnd[7]) << 8) | ((u32)(srb->cmnd[8]));
617 614
618 US_DEBUGP("datafab_transport: READ_10: read block 0x%04lx count %ld\n", block, blocks); 615 usb_stor_dbg(us, "READ_10: read block 0x%04lx count %ld\n",
616 block, blocks);
619 return datafab_read_data(us, info, block, blocks); 617 return datafab_read_data(us, info, block, blocks);
620 } 618 }
621 619
@@ -628,7 +626,8 @@ static int datafab_transport(struct scsi_cmnd *srb, struct us_data *us)
628 blocks = ((u32)(srb->cmnd[6]) << 24) | ((u32)(srb->cmnd[7]) << 16) | 626 blocks = ((u32)(srb->cmnd[6]) << 24) | ((u32)(srb->cmnd[7]) << 16) |
629 ((u32)(srb->cmnd[8]) << 8) | ((u32)(srb->cmnd[9])); 627 ((u32)(srb->cmnd[8]) << 8) | ((u32)(srb->cmnd[9]));
630 628
631 US_DEBUGP("datafab_transport: READ_12: read block 0x%04lx count %ld\n", block, blocks); 629 usb_stor_dbg(us, "READ_12: read block 0x%04lx count %ld\n",
630 block, blocks);
632 return datafab_read_data(us, info, block, blocks); 631 return datafab_read_data(us, info, block, blocks);
633 } 632 }
634 633
@@ -638,7 +637,8 @@ static int datafab_transport(struct scsi_cmnd *srb, struct us_data *us)
638 637
639 blocks = ((u32)(srb->cmnd[7]) << 8) | ((u32)(srb->cmnd[8])); 638 blocks = ((u32)(srb->cmnd[7]) << 8) | ((u32)(srb->cmnd[8]));
640 639
641 US_DEBUGP("datafab_transport: WRITE_10: write block 0x%04lx count %ld\n", block, blocks); 640 usb_stor_dbg(us, "WRITE_10: write block 0x%04lx count %ld\n",
641 block, blocks);
642 return datafab_write_data(us, info, block, blocks); 642 return datafab_write_data(us, info, block, blocks);
643 } 643 }
644 644
@@ -651,17 +651,18 @@ static int datafab_transport(struct scsi_cmnd *srb, struct us_data *us)
651 blocks = ((u32)(srb->cmnd[6]) << 24) | ((u32)(srb->cmnd[7]) << 16) | 651 blocks = ((u32)(srb->cmnd[6]) << 24) | ((u32)(srb->cmnd[7]) << 16) |
652 ((u32)(srb->cmnd[8]) << 8) | ((u32)(srb->cmnd[9])); 652 ((u32)(srb->cmnd[8]) << 8) | ((u32)(srb->cmnd[9]));
653 653
654 US_DEBUGP("datafab_transport: WRITE_12: write block 0x%04lx count %ld\n", block, blocks); 654 usb_stor_dbg(us, "WRITE_12: write block 0x%04lx count %ld\n",
655 block, blocks);
655 return datafab_write_data(us, info, block, blocks); 656 return datafab_write_data(us, info, block, blocks);
656 } 657 }
657 658
658 if (srb->cmnd[0] == TEST_UNIT_READY) { 659 if (srb->cmnd[0] == TEST_UNIT_READY) {
659 US_DEBUGP("datafab_transport: TEST_UNIT_READY.\n"); 660 usb_stor_dbg(us, "TEST_UNIT_READY\n");
660 return datafab_id_device(us, info); 661 return datafab_id_device(us, info);
661 } 662 }
662 663
663 if (srb->cmnd[0] == REQUEST_SENSE) { 664 if (srb->cmnd[0] == REQUEST_SENSE) {
664 US_DEBUGP("datafab_transport: REQUEST_SENSE. Returning faked response\n"); 665 usb_stor_dbg(us, "REQUEST_SENSE - Returning faked response\n");
665 666
666 // this response is pretty bogus right now. eventually if necessary 667 // this response is pretty bogus right now. eventually if necessary
667 // we can set the correct sense data. so far though it hasn't been 668 // we can set the correct sense data. so far though it hasn't been
@@ -679,12 +680,12 @@ static int datafab_transport(struct scsi_cmnd *srb, struct us_data *us)
679 } 680 }
680 681
681 if (srb->cmnd[0] == MODE_SENSE) { 682 if (srb->cmnd[0] == MODE_SENSE) {
682 US_DEBUGP("datafab_transport: MODE_SENSE_6 detected\n"); 683 usb_stor_dbg(us, "MODE_SENSE_6 detected\n");
683 return datafab_handle_mode_sense(us, srb, 1); 684 return datafab_handle_mode_sense(us, srb, 1);
684 } 685 }
685 686
686 if (srb->cmnd[0] == MODE_SENSE_10) { 687 if (srb->cmnd[0] == MODE_SENSE_10) {
687 US_DEBUGP("datafab_transport: MODE_SENSE_10 detected\n"); 688 usb_stor_dbg(us, "MODE_SENSE_10 detected\n");
688 return datafab_handle_mode_sense(us, srb, 0); 689 return datafab_handle_mode_sense(us, srb, 0);
689 } 690 }
690 691
@@ -698,7 +699,7 @@ static int datafab_transport(struct scsi_cmnd *srb, struct us_data *us)
698 if (srb->cmnd[0] == START_STOP) { 699 if (srb->cmnd[0] == START_STOP) {
699 /* this is used by sd.c'check_scsidisk_media_change to detect 700 /* this is used by sd.c'check_scsidisk_media_change to detect
700 media change */ 701 media change */
701 US_DEBUGP("datafab_transport: START_STOP.\n"); 702 usb_stor_dbg(us, "START_STOP\n");
702 /* the first datafab_id_device after a media change returns 703 /* the first datafab_id_device after a media change returns
703 an error (determined experimentally) */ 704 an error (determined experimentally) */
704 rc = datafab_id_device(us, info); 705 rc = datafab_id_device(us, info);
@@ -712,8 +713,8 @@ static int datafab_transport(struct scsi_cmnd *srb, struct us_data *us)
712 return rc; 713 return rc;
713 } 714 }
714 715
715 US_DEBUGP("datafab_transport: Gah! Unknown command: %d (0x%x)\n", 716 usb_stor_dbg(us, "Gah! Unknown command: %d (0x%x)\n",
716 srb->cmnd[0], srb->cmnd[0]); 717 srb->cmnd[0], srb->cmnd[0]);
717 info->sense_key = 0x05; 718 info->sense_key = 0x05;
718 info->sense_asc = 0x20; 719 info->sense_asc = 0x20;
719 info->sense_ascq = 0x00; 720 info->sense_ascq = 0x00;
diff --git a/drivers/usb/storage/debug.c b/drivers/usb/storage/debug.c
index 29fe08ffe3c8..e08f64780e30 100644
--- a/drivers/usb/storage/debug.c
+++ b/drivers/usb/storage/debug.c
@@ -42,17 +42,19 @@
42 * 675 Mass Ave, Cambridge, MA 02139, USA. 42 * 675 Mass Ave, Cambridge, MA 02139, USA.
43 */ 43 */
44 44
45#include <linux/device.h>
45#include <linux/cdrom.h> 46#include <linux/cdrom.h>
46#include <linux/export.h> 47#include <linux/export.h>
47#include <scsi/scsi.h> 48#include <scsi/scsi.h>
48#include <scsi/scsi_cmnd.h> 49#include <scsi/scsi_cmnd.h>
49#include <scsi/scsi_dbg.h> 50#include <scsi/scsi_dbg.h>
50 51
52#include "usb.h"
51#include "debug.h" 53#include "debug.h"
52#include "scsi.h" 54#include "scsi.h"
53 55
54 56
55void usb_stor_show_command(struct scsi_cmnd *srb) 57void usb_stor_show_command(const struct us_data *us, struct scsi_cmnd *srb)
56{ 58{
57 char *what = NULL; 59 char *what = NULL;
58 int i; 60 int i;
@@ -150,18 +152,18 @@ void usb_stor_show_command(struct scsi_cmnd *srb)
150 case WRITE_LONG_2: what = "WRITE_LONG_2"; break; 152 case WRITE_LONG_2: what = "WRITE_LONG_2"; break;
151 default: what = "(unknown command)"; break; 153 default: what = "(unknown command)"; break;
152 } 154 }
153 US_DEBUGP("Command %s (%d bytes)\n", what, srb->cmd_len); 155 usb_stor_dbg(us, "Command %s (%d bytes)\n", what, srb->cmd_len);
154 US_DEBUGP("bytes: "); 156 usb_stor_dbg(us, "bytes: ");
155 for (i = 0; i < srb->cmd_len && i < 16; i++) 157 for (i = 0; i < srb->cmd_len && i < 16; i++)
156 US_DEBUGPX(" %02x", srb->cmnd[i]); 158 US_DEBUGPX(" %02x", srb->cmnd[i]);
157 US_DEBUGPX("\n"); 159 US_DEBUGPX("\n");
158} 160}
159 161
160void usb_stor_show_sense( 162void usb_stor_show_sense(const struct us_data *us,
161 unsigned char key, 163 unsigned char key,
162 unsigned char asc, 164 unsigned char asc,
163 unsigned char ascq) { 165 unsigned char ascq)
164 166{
165 const char *what, *keystr; 167 const char *what, *keystr;
166 168
167 keystr = scsi_sense_key_string(key); 169 keystr = scsi_sense_key_string(key);
@@ -172,23 +174,19 @@ void usb_stor_show_sense(
172 if (what == NULL) 174 if (what == NULL)
173 what = "(unknown ASC/ASCQ)"; 175 what = "(unknown ASC/ASCQ)";
174 176
175 US_DEBUGP("%s: ", keystr); 177 usb_stor_dbg(us, "%s: ", keystr);
176 US_DEBUGPX(what, ascq); 178 US_DEBUGPX(what, ascq);
177 US_DEBUGPX("\n"); 179 US_DEBUGPX("\n");
178} 180}
179 181
180int usb_stor_dbg(const char *fmt, ...) 182int usb_stor_dbg(const struct us_data *us, const char *fmt, ...)
181{ 183{
182 struct va_format vaf;
183 va_list args; 184 va_list args;
184 int r; 185 int r;
185 186
186 va_start(args, fmt); 187 va_start(args, fmt);
187 188
188 vaf.fmt = fmt; 189 r = dev_vprintk_emit(7, &us->pusb_dev->dev, fmt, args);
189 vaf.va = &args;
190
191 r = printk(KERN_DEBUG USB_STORAGE "%pV", &vaf);
192 190
193 va_end(args); 191 va_end(args);
194 192
diff --git a/drivers/usb/storage/debug.h b/drivers/usb/storage/debug.h
index d4280e1541a3..b1273f03e223 100644
--- a/drivers/usb/storage/debug.h
+++ b/drivers/usb/storage/debug.h
@@ -47,17 +47,20 @@
47#define USB_STORAGE "usb-storage: " 47#define USB_STORAGE "usb-storage: "
48 48
49#ifdef CONFIG_USB_STORAGE_DEBUG 49#ifdef CONFIG_USB_STORAGE_DEBUG
50void usb_stor_show_command(struct scsi_cmnd *srb); 50void usb_stor_show_command(const struct us_data *us, struct scsi_cmnd *srb);
51void usb_stor_show_sense( unsigned char key, 51void usb_stor_show_sense(const struct us_data *us, unsigned char key,
52 unsigned char asc, unsigned char ascq ); 52 unsigned char asc, unsigned char ascq);
53__printf(1, 2) int usb_stor_dbg(const char *fmt, ...); 53__printf(2, 3) int usb_stor_dbg(const struct us_data *us,
54 const char *fmt, ...);
54 55
55#define US_DEBUGP(fmt, ...) usb_stor_dbg(fmt, ##__VA_ARGS__)
56#define US_DEBUGPX(fmt, ...) printk(fmt, ##__VA_ARGS__) 56#define US_DEBUGPX(fmt, ...) printk(fmt, ##__VA_ARGS__)
57#define US_DEBUG(x) x 57#define US_DEBUG(x) x
58#else 58#else
59#define US_DEBUGP(fmt, ...) \ 59__printf(2, 3)
60 do { if (0) printk(fmt, ##__VA_ARGS__); } while (0) 60static inline int _usb_stor_dbg(const struct us_data *us,
61 const char *fmt, ...) {return 1;}
62#define usb_stor_dbg(us, fmt, ...) \
63 do { if (0) _usb_stor_dbg(us, fmt, ##__VA_ARGS__); } while (0)
61#define US_DEBUGPX(fmt, ...) \ 64#define US_DEBUGPX(fmt, ...) \
62 do { if (0) printk(fmt, ##__VA_ARGS__); } while (0) 65 do { if (0) printk(fmt, ##__VA_ARGS__); } while (0)
63#define US_DEBUG(x) 66#define US_DEBUG(x)
diff --git a/drivers/usb/storage/ene_ub6250.c b/drivers/usb/storage/ene_ub6250.c
index 118b134a1dad..1bfc9a6cab5f 100644
--- a/drivers/usb/storage/ene_ub6250.c
+++ b/drivers/usb/storage/ene_ub6250.c
@@ -504,12 +504,12 @@ static int ene_send_scsi_cmd(struct us_data *us, u8 fDir, void *buf, int use_sg)
504 unsigned int cswlen = 0, partial = 0; 504 unsigned int cswlen = 0, partial = 0;
505 unsigned int transfer_length = bcb->DataTransferLength; 505 unsigned int transfer_length = bcb->DataTransferLength;
506 506
507 /* US_DEBUGP("transport --- ene_send_scsi_cmd\n"); */ 507 /* usb_stor_dbg(us, "transport --- ene_send_scsi_cmd\n"); */
508 /* send cmd to out endpoint */ 508 /* send cmd to out endpoint */
509 result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, 509 result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,
510 bcb, US_BULK_CB_WRAP_LEN, NULL); 510 bcb, US_BULK_CB_WRAP_LEN, NULL);
511 if (result != USB_STOR_XFER_GOOD) { 511 if (result != USB_STOR_XFER_GOOD) {
512 US_DEBUGP("send cmd to out endpoint fail ---\n"); 512 usb_stor_dbg(us, "send cmd to out endpoint fail ---\n");
513 return USB_STOR_TRANSPORT_ERROR; 513 return USB_STOR_TRANSPORT_ERROR;
514 } 514 }
515 515
@@ -529,7 +529,7 @@ static int ene_send_scsi_cmd(struct us_data *us, u8 fDir, void *buf, int use_sg)
529 transfer_length, 0, &partial); 529 transfer_length, 0, &partial);
530 } 530 }
531 if (result != USB_STOR_XFER_GOOD) { 531 if (result != USB_STOR_XFER_GOOD) {
532 US_DEBUGP("data transfer fail ---\n"); 532 usb_stor_dbg(us, "data transfer fail ---\n");
533 return USB_STOR_TRANSPORT_ERROR; 533 return USB_STOR_TRANSPORT_ERROR;
534 } 534 }
535 } 535 }
@@ -539,14 +539,14 @@ static int ene_send_scsi_cmd(struct us_data *us, u8 fDir, void *buf, int use_sg)
539 US_BULK_CS_WRAP_LEN, &cswlen); 539 US_BULK_CS_WRAP_LEN, &cswlen);
540 540
541 if (result == USB_STOR_XFER_SHORT && cswlen == 0) { 541 if (result == USB_STOR_XFER_SHORT && cswlen == 0) {
542 US_DEBUGP("Received 0-length CSW; retrying...\n"); 542 usb_stor_dbg(us, "Received 0-length CSW; retrying...\n");
543 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, 543 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
544 bcs, US_BULK_CS_WRAP_LEN, &cswlen); 544 bcs, US_BULK_CS_WRAP_LEN, &cswlen);
545 } 545 }
546 546
547 if (result == USB_STOR_XFER_STALLED) { 547 if (result == USB_STOR_XFER_STALLED) {
548 /* get the status again */ 548 /* get the status again */
549 US_DEBUGP("Attempting to get CSW (2nd try)...\n"); 549 usb_stor_dbg(us, "Attempting to get CSW (2nd try)...\n");
550 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, 550 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
551 bcs, US_BULK_CS_WRAP_LEN, NULL); 551 bcs, US_BULK_CS_WRAP_LEN, NULL);
552 } 552 }
@@ -626,7 +626,7 @@ static int sd_scsi_read_capacity(struct us_data *us, struct scsi_cmnd *srb)
626 struct scatterlist *sg = NULL; 626 struct scatterlist *sg = NULL;
627 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; 627 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra;
628 628
629 US_DEBUGP("sd_scsi_read_capacity\n"); 629 usb_stor_dbg(us, "sd_scsi_read_capacity\n");
630 if (info->SD_Status.HiCapacity) { 630 if (info->SD_Status.HiCapacity) {
631 bl_len = 0x200; 631 bl_len = 0x200;
632 if (info->SD_Status.IsMMC) 632 if (info->SD_Status.IsMMC)
@@ -639,8 +639,8 @@ static int sd_scsi_read_capacity(struct us_data *us, struct scsi_cmnd *srb)
639 * (1 << (info->SD_C_SIZE_MULT + 2)) - 1; 639 * (1 << (info->SD_C_SIZE_MULT + 2)) - 1;
640 } 640 }
641 info->bl_num = bl_num; 641 info->bl_num = bl_num;
642 US_DEBUGP("bl_len = %x\n", bl_len); 642 usb_stor_dbg(us, "bl_len = %x\n", bl_len);
643 US_DEBUGP("bl_num = %x\n", bl_num); 643 usb_stor_dbg(us, "bl_num = %x\n", bl_num);
644 644
645 /*srb->request_bufflen = 8; */ 645 /*srb->request_bufflen = 8; */
646 buf[0] = (bl_num >> 24) & 0xff; 646 buf[0] = (bl_num >> 24) & 0xff;
@@ -675,7 +675,7 @@ static int sd_scsi_read(struct us_data *us, struct scsi_cmnd *srb)
675 675
676 result = ene_load_bincode(us, SD_RW_PATTERN); 676 result = ene_load_bincode(us, SD_RW_PATTERN);
677 if (result != USB_STOR_XFER_GOOD) { 677 if (result != USB_STOR_XFER_GOOD) {
678 US_DEBUGP("Load SD RW pattern Fail !!\n"); 678 usb_stor_dbg(us, "Load SD RW pattern Fail !!\n");
679 return USB_STOR_TRANSPORT_ERROR; 679 return USB_STOR_TRANSPORT_ERROR;
680 } 680 }
681 681
@@ -715,7 +715,7 @@ static int sd_scsi_write(struct us_data *us, struct scsi_cmnd *srb)
715 715
716 result = ene_load_bincode(us, SD_RW_PATTERN); 716 result = ene_load_bincode(us, SD_RW_PATTERN);
717 if (result != USB_STOR_XFER_GOOD) { 717 if (result != USB_STOR_XFER_GOOD) {
718 US_DEBUGP("Load SD RW pattern Fail !!\n"); 718 usb_stor_dbg(us, "Load SD RW pattern Fail !!\n");
719 return USB_STOR_TRANSPORT_ERROR; 719 return USB_STOR_TRANSPORT_ERROR;
720 } 720 }
721 721
@@ -1493,7 +1493,7 @@ static int ms_scsi_read_capacity(struct us_data *us, struct scsi_cmnd *srb)
1493 struct scatterlist *sg = NULL; 1493 struct scatterlist *sg = NULL;
1494 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; 1494 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra;
1495 1495
1496 US_DEBUGP("ms_scsi_read_capacity\n"); 1496 usb_stor_dbg(us, "ms_scsi_read_capacity\n");
1497 bl_len = 0x200; 1497 bl_len = 0x200;
1498 if (info->MS_Status.IsMSPro) 1498 if (info->MS_Status.IsMSPro)
1499 bl_num = info->MSP_TotalBlock - 1; 1499 bl_num = info->MSP_TotalBlock - 1;
@@ -1501,8 +1501,8 @@ static int ms_scsi_read_capacity(struct us_data *us, struct scsi_cmnd *srb)
1501 bl_num = info->MS_Lib.NumberOfLogBlock * info->MS_Lib.blockSize * 2 - 1; 1501 bl_num = info->MS_Lib.NumberOfLogBlock * info->MS_Lib.blockSize * 2 - 1;
1502 1502
1503 info->bl_num = bl_num; 1503 info->bl_num = bl_num;
1504 US_DEBUGP("bl_len = %x\n", bl_len); 1504 usb_stor_dbg(us, "bl_len = %x\n", bl_len);
1505 US_DEBUGP("bl_num = %x\n", bl_num); 1505 usb_stor_dbg(us, "bl_num = %x\n", bl_num);
1506 1506
1507 /*srb->request_bufflen = 8; */ 1507 /*srb->request_bufflen = 8; */
1508 buf[0] = (bl_num >> 24) & 0xff; 1508 buf[0] = (bl_num >> 24) & 0xff;
@@ -1654,7 +1654,7 @@ static int ms_scsi_read(struct us_data *us, struct scsi_cmnd *srb)
1654 if (info->MS_Status.IsMSPro) { 1654 if (info->MS_Status.IsMSPro) {
1655 result = ene_load_bincode(us, MSP_RW_PATTERN); 1655 result = ene_load_bincode(us, MSP_RW_PATTERN);
1656 if (result != USB_STOR_XFER_GOOD) { 1656 if (result != USB_STOR_XFER_GOOD) {
1657 US_DEBUGP("Load MPS RW pattern Fail !!\n"); 1657 usb_stor_dbg(us, "Load MPS RW pattern Fail !!\n");
1658 return USB_STOR_TRANSPORT_ERROR; 1658 return USB_STOR_TRANSPORT_ERROR;
1659 } 1659 }
1660 1660
@@ -1854,7 +1854,7 @@ static int ene_get_card_status(struct us_data *us, u8 *buf)
1854 u32 reg4b; 1854 u32 reg4b;
1855 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; 1855 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra;
1856 1856
1857 /*US_DEBUGP("transport --- ENE_ReadSDReg\n");*/ 1857 /*usb_stor_dbg(us, "transport --- ENE_ReadSDReg\n");*/
1858 reg4b = *(u32 *)&buf[0x18]; 1858 reg4b = *(u32 *)&buf[0x18];
1859 info->SD_READ_BL_LEN = (u8)((reg4b >> 8) & 0x0f); 1859 info->SD_READ_BL_LEN = (u8)((reg4b >> 8) & 0x0f);
1860 1860
@@ -1894,45 +1894,44 @@ static int ene_load_bincode(struct us_data *us, unsigned char flag)
1894 switch (flag) { 1894 switch (flag) {
1895 /* For SD */ 1895 /* For SD */
1896 case SD_INIT1_PATTERN: 1896 case SD_INIT1_PATTERN:
1897 US_DEBUGP("SD_INIT1_PATTERN\n"); 1897 usb_stor_dbg(us, "SD_INIT1_PATTERN\n");
1898 fw_name = SD_INIT1_FIRMWARE; 1898 fw_name = SD_INIT1_FIRMWARE;
1899 break; 1899 break;
1900 case SD_INIT2_PATTERN: 1900 case SD_INIT2_PATTERN:
1901 US_DEBUGP("SD_INIT2_PATTERN\n"); 1901 usb_stor_dbg(us, "SD_INIT2_PATTERN\n");
1902 fw_name = SD_INIT2_FIRMWARE; 1902 fw_name = SD_INIT2_FIRMWARE;
1903 break; 1903 break;
1904 case SD_RW_PATTERN: 1904 case SD_RW_PATTERN:
1905 US_DEBUGP("SD_RW_PATTERN\n"); 1905 usb_stor_dbg(us, "SD_RW_PATTERN\n");
1906 fw_name = SD_RW_FIRMWARE; 1906 fw_name = SD_RW_FIRMWARE;
1907 break; 1907 break;
1908 /* For MS */ 1908 /* For MS */
1909 case MS_INIT_PATTERN: 1909 case MS_INIT_PATTERN:
1910 US_DEBUGP("MS_INIT_PATTERN\n"); 1910 usb_stor_dbg(us, "MS_INIT_PATTERN\n");
1911 fw_name = MS_INIT_FIRMWARE; 1911 fw_name = MS_INIT_FIRMWARE;
1912 break; 1912 break;
1913 case MSP_RW_PATTERN: 1913 case MSP_RW_PATTERN:
1914 US_DEBUGP("MSP_RW_PATTERN\n"); 1914 usb_stor_dbg(us, "MSP_RW_PATTERN\n");
1915 fw_name = MSP_RW_FIRMWARE; 1915 fw_name = MSP_RW_FIRMWARE;
1916 break; 1916 break;
1917 case MS_RW_PATTERN: 1917 case MS_RW_PATTERN:
1918 US_DEBUGP("MS_RW_PATTERN\n"); 1918 usb_stor_dbg(us, "MS_RW_PATTERN\n");
1919 fw_name = MS_RW_FIRMWARE; 1919 fw_name = MS_RW_FIRMWARE;
1920 break; 1920 break;
1921 default: 1921 default:
1922 US_DEBUGP("----------- Unknown PATTERN ----------\n"); 1922 usb_stor_dbg(us, "----------- Unknown PATTERN ----------\n");
1923 goto nofw; 1923 goto nofw;
1924 } 1924 }
1925 1925
1926 err = request_firmware(&sd_fw, fw_name, &us->pusb_dev->dev); 1926 err = request_firmware(&sd_fw, fw_name, &us->pusb_dev->dev);
1927 if (err) { 1927 if (err) {
1928 US_DEBUGP("load firmware %s failed\n", fw_name); 1928 usb_stor_dbg(us, "load firmware %s failed\n", fw_name);
1929 goto nofw; 1929 goto nofw;
1930 } 1930 }
1931 buf = kmalloc(sd_fw->size, GFP_KERNEL); 1931 buf = kmalloc(sd_fw->size, GFP_KERNEL);
1932 if (buf == NULL) { 1932 if (buf == NULL)
1933 US_DEBUGP("Malloc memory for fireware failed!\n");
1934 goto nofw; 1933 goto nofw;
1935 } 1934
1936 memcpy(buf, sd_fw->data, sd_fw->size); 1935 memcpy(buf, sd_fw->data, sd_fw->size);
1937 memset(bcb, 0, sizeof(struct bulk_cb_wrap)); 1936 memset(bcb, 0, sizeof(struct bulk_cb_wrap));
1938 bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); 1937 bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
@@ -2116,9 +2115,9 @@ static int ene_ms_init(struct us_data *us)
2116 } else { 2115 } else {
2117 ms_card_init(us); /* Card is MS (to ms.c)*/ 2116 ms_card_init(us); /* Card is MS (to ms.c)*/
2118 } 2117 }
2119 US_DEBUGP("MS Init Code OK !!\n"); 2118 usb_stor_dbg(us, "MS Init Code OK !!\n");
2120 } else { 2119 } else {
2121 US_DEBUGP("MS Card Not Ready --- %x\n", buf[0]); 2120 usb_stor_dbg(us, "MS Card Not Ready --- %x\n", buf[0]);
2122 return USB_STOR_TRANSPORT_ERROR; 2121 return USB_STOR_TRANSPORT_ERROR;
2123 } 2122 }
2124 2123
@@ -2132,11 +2131,11 @@ static int ene_sd_init(struct us_data *us)
2132 struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; 2131 struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
2133 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; 2132 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra;
2134 2133
2135 US_DEBUGP("transport --- ENE_SDInit\n"); 2134 usb_stor_dbg(us, "transport --- ENE_SDInit\n");
2136 /* SD Init Part-1 */ 2135 /* SD Init Part-1 */
2137 result = ene_load_bincode(us, SD_INIT1_PATTERN); 2136 result = ene_load_bincode(us, SD_INIT1_PATTERN);
2138 if (result != USB_STOR_XFER_GOOD) { 2137 if (result != USB_STOR_XFER_GOOD) {
2139 US_DEBUGP("Load SD Init Code Part-1 Fail !!\n"); 2138 usb_stor_dbg(us, "Load SD Init Code Part-1 Fail !!\n");
2140 return USB_STOR_TRANSPORT_ERROR; 2139 return USB_STOR_TRANSPORT_ERROR;
2141 } 2140 }
2142 2141
@@ -2147,14 +2146,14 @@ static int ene_sd_init(struct us_data *us)
2147 2146
2148 result = ene_send_scsi_cmd(us, FDIR_READ, NULL, 0); 2147 result = ene_send_scsi_cmd(us, FDIR_READ, NULL, 0);
2149 if (result != USB_STOR_XFER_GOOD) { 2148 if (result != USB_STOR_XFER_GOOD) {
2150 US_DEBUGP("Execution SD Init Code Fail !!\n"); 2149 usb_stor_dbg(us, "Execution SD Init Code Fail !!\n");
2151 return USB_STOR_TRANSPORT_ERROR; 2150 return USB_STOR_TRANSPORT_ERROR;
2152 } 2151 }
2153 2152
2154 /* SD Init Part-2 */ 2153 /* SD Init Part-2 */
2155 result = ene_load_bincode(us, SD_INIT2_PATTERN); 2154 result = ene_load_bincode(us, SD_INIT2_PATTERN);
2156 if (result != USB_STOR_XFER_GOOD) { 2155 if (result != USB_STOR_XFER_GOOD) {
2157 US_DEBUGP("Load SD Init Code Part-2 Fail !!\n"); 2156 usb_stor_dbg(us, "Load SD Init Code Part-2 Fail !!\n");
2158 return USB_STOR_TRANSPORT_ERROR; 2157 return USB_STOR_TRANSPORT_ERROR;
2159 } 2158 }
2160 2159
@@ -2166,21 +2165,23 @@ static int ene_sd_init(struct us_data *us)
2166 2165
2167 result = ene_send_scsi_cmd(us, FDIR_READ, &buf, 0); 2166 result = ene_send_scsi_cmd(us, FDIR_READ, &buf, 0);
2168 if (result != USB_STOR_XFER_GOOD) { 2167 if (result != USB_STOR_XFER_GOOD) {
2169 US_DEBUGP("Execution SD Init Code Fail !!\n"); 2168 usb_stor_dbg(us, "Execution SD Init Code Fail !!\n");
2170 return USB_STOR_TRANSPORT_ERROR; 2169 return USB_STOR_TRANSPORT_ERROR;
2171 } 2170 }
2172 2171
2173 info->SD_Status = *(struct SD_STATUS *)&buf[0]; 2172 info->SD_Status = *(struct SD_STATUS *)&buf[0];
2174 if (info->SD_Status.Insert && info->SD_Status.Ready) { 2173 if (info->SD_Status.Insert && info->SD_Status.Ready) {
2174 struct SD_STATUS *s = &info->SD_Status;
2175
2175 ene_get_card_status(us, (unsigned char *)&buf); 2176 ene_get_card_status(us, (unsigned char *)&buf);
2176 US_DEBUGP("Insert = %x\n", info->SD_Status.Insert); 2177 usb_stor_dbg(us, "Insert = %x\n", s->Insert);
2177 US_DEBUGP("Ready = %x\n", info->SD_Status.Ready); 2178 usb_stor_dbg(us, "Ready = %x\n", s->Ready);
2178 US_DEBUGP("IsMMC = %x\n", info->SD_Status.IsMMC); 2179 usb_stor_dbg(us, "IsMMC = %x\n", s->IsMMC);
2179 US_DEBUGP("HiCapacity = %x\n", info->SD_Status.HiCapacity); 2180 usb_stor_dbg(us, "HiCapacity = %x\n", s->HiCapacity);
2180 US_DEBUGP("HiSpeed = %x\n", info->SD_Status.HiSpeed); 2181 usb_stor_dbg(us, "HiSpeed = %x\n", s->HiSpeed);
2181 US_DEBUGP("WtP = %x\n", info->SD_Status.WtP); 2182 usb_stor_dbg(us, "WtP = %x\n", s->WtP);
2182 } else { 2183 } else {
2183 US_DEBUGP("SD Card Not Ready --- %x\n", buf[0]); 2184 usb_stor_dbg(us, "SD Card Not Ready --- %x\n", buf[0]);
2184 return USB_STOR_TRANSPORT_ERROR; 2185 return USB_STOR_TRANSPORT_ERROR;
2185 } 2186 }
2186 return USB_STOR_TRANSPORT_GOOD; 2187 return USB_STOR_TRANSPORT_GOOD;
@@ -2293,7 +2294,7 @@ static int ene_transport(struct scsi_cmnd *srb, struct us_data *us)
2293 int result = 0; 2294 int result = 0;
2294 struct ene_ub6250_info *info = (struct ene_ub6250_info *)(us->extra); 2295 struct ene_ub6250_info *info = (struct ene_ub6250_info *)(us->extra);
2295 2296
2296 /*US_DEBUG(usb_stor_show_command(srb)); */ 2297 /*US_DEBUG(usb_stor_show_command(us, srb)); */
2297 scsi_set_resid(srb, 0); 2298 scsi_set_resid(srb, 0);
2298 if (unlikely(!(info->SD_Status.Ready || info->MS_Status.Ready))) { 2299 if (unlikely(!(info->SD_Status.Ready || info->MS_Status.Ready))) {
2299 result = ene_init(us); 2300 result = ene_init(us);
@@ -2362,7 +2363,6 @@ static int ene_ub6250_resume(struct usb_interface *iface)
2362 2363
2363 mutex_lock(&us->dev_mutex); 2364 mutex_lock(&us->dev_mutex);
2364 2365
2365 US_DEBUGP("%s\n", __func__);
2366 if (us->suspend_resume_hook) 2366 if (us->suspend_resume_hook)
2367 (us->suspend_resume_hook)(us, US_RESUME); 2367 (us->suspend_resume_hook)(us, US_RESUME);
2368 2368
@@ -2382,7 +2382,7 @@ static int ene_ub6250_reset_resume(struct usb_interface *iface)
2382 u8 tmp = 0; 2382 u8 tmp = 0;
2383 struct us_data *us = usb_get_intfdata(iface); 2383 struct us_data *us = usb_get_intfdata(iface);
2384 struct ene_ub6250_info *info = (struct ene_ub6250_info *)(us->extra); 2384 struct ene_ub6250_info *info = (struct ene_ub6250_info *)(us->extra);
2385 US_DEBUGP("%s\n", __func__); 2385
2386 /* Report the reset to the SCSI core */ 2386 /* Report the reset to the SCSI core */
2387 usb_stor_reset_resume(iface); 2387 usb_stor_reset_resume(iface);
2388 2388
diff --git a/drivers/usb/storage/freecom.c b/drivers/usb/storage/freecom.c
index e6df087dca9d..ef16068b7087 100644
--- a/drivers/usb/storage/freecom.c
+++ b/drivers/usb/storage/freecom.c
@@ -40,7 +40,7 @@ MODULE_AUTHOR("David Brown <usb-storage@davidb.org>");
40MODULE_LICENSE("GPL"); 40MODULE_LICENSE("GPL");
41 41
42#ifdef CONFIG_USB_STORAGE_DEBUG 42#ifdef CONFIG_USB_STORAGE_DEBUG
43static void pdump (void *, int); 43static void pdump(struct us_data *us, void *ibuffer, int length);
44#endif 44#endif
45 45
46/* Bits of HD_STATUS */ 46/* Bits of HD_STATUS */
@@ -161,20 +161,20 @@ freecom_readdata (struct scsi_cmnd *srb, struct us_data *us,
161 fxfr->Count = cpu_to_le32 (count); 161 fxfr->Count = cpu_to_le32 (count);
162 memset (fxfr->Pad, 0, sizeof (fxfr->Pad)); 162 memset (fxfr->Pad, 0, sizeof (fxfr->Pad));
163 163
164 US_DEBUGP("Read data Freecom! (c=%d)\n", count); 164 usb_stor_dbg(us, "Read data Freecom! (c=%d)\n", count);
165 165
166 /* Issue the transfer command. */ 166 /* Issue the transfer command. */
167 result = usb_stor_bulk_transfer_buf (us, opipe, fxfr, 167 result = usb_stor_bulk_transfer_buf (us, opipe, fxfr,
168 FCM_PACKET_LENGTH, NULL); 168 FCM_PACKET_LENGTH, NULL);
169 if (result != USB_STOR_XFER_GOOD) { 169 if (result != USB_STOR_XFER_GOOD) {
170 US_DEBUGP ("Freecom readdata transport error\n"); 170 usb_stor_dbg(us, "Freecom readdata transport error\n");
171 return USB_STOR_TRANSPORT_ERROR; 171 return USB_STOR_TRANSPORT_ERROR;
172 } 172 }
173 173
174 /* Now transfer all of our blocks. */ 174 /* Now transfer all of our blocks. */
175 US_DEBUGP("Start of read\n"); 175 usb_stor_dbg(us, "Start of read\n");
176 result = usb_stor_bulk_srb(us, ipipe, srb); 176 result = usb_stor_bulk_srb(us, ipipe, srb);
177 US_DEBUGP("freecom_readdata done!\n"); 177 usb_stor_dbg(us, "freecom_readdata done!\n");
178 178
179 if (result > USB_STOR_XFER_SHORT) 179 if (result > USB_STOR_XFER_SHORT)
180 return USB_STOR_TRANSPORT_ERROR; 180 return USB_STOR_TRANSPORT_ERROR;
@@ -194,21 +194,21 @@ freecom_writedata (struct scsi_cmnd *srb, struct us_data *us,
194 fxfr->Count = cpu_to_le32 (count); 194 fxfr->Count = cpu_to_le32 (count);
195 memset (fxfr->Pad, 0, sizeof (fxfr->Pad)); 195 memset (fxfr->Pad, 0, sizeof (fxfr->Pad));
196 196
197 US_DEBUGP("Write data Freecom! (c=%d)\n", count); 197 usb_stor_dbg(us, "Write data Freecom! (c=%d)\n", count);
198 198
199 /* Issue the transfer command. */ 199 /* Issue the transfer command. */
200 result = usb_stor_bulk_transfer_buf (us, opipe, fxfr, 200 result = usb_stor_bulk_transfer_buf (us, opipe, fxfr,
201 FCM_PACKET_LENGTH, NULL); 201 FCM_PACKET_LENGTH, NULL);
202 if (result != USB_STOR_XFER_GOOD) { 202 if (result != USB_STOR_XFER_GOOD) {
203 US_DEBUGP ("Freecom writedata transport error\n"); 203 usb_stor_dbg(us, "Freecom writedata transport error\n");
204 return USB_STOR_TRANSPORT_ERROR; 204 return USB_STOR_TRANSPORT_ERROR;
205 } 205 }
206 206
207 /* Now transfer all of our blocks. */ 207 /* Now transfer all of our blocks. */
208 US_DEBUGP("Start of write\n"); 208 usb_stor_dbg(us, "Start of write\n");
209 result = usb_stor_bulk_srb(us, opipe, srb); 209 result = usb_stor_bulk_srb(us, opipe, srb);
210 210
211 US_DEBUGP("freecom_writedata done!\n"); 211 usb_stor_dbg(us, "freecom_writedata done!\n");
212 if (result > USB_STOR_XFER_SHORT) 212 if (result > USB_STOR_XFER_SHORT)
213 return USB_STOR_TRANSPORT_ERROR; 213 return USB_STOR_TRANSPORT_ERROR;
214 return USB_STOR_TRANSPORT_GOOD; 214 return USB_STOR_TRANSPORT_GOOD;
@@ -230,7 +230,7 @@ static int freecom_transport(struct scsi_cmnd *srb, struct us_data *us)
230 fcb = (struct freecom_cb_wrap *) us->iobuf; 230 fcb = (struct freecom_cb_wrap *) us->iobuf;
231 fst = (struct freecom_status *) us->iobuf; 231 fst = (struct freecom_status *) us->iobuf;
232 232
233 US_DEBUGP("Freecom TRANSPORT STARTED\n"); 233 usb_stor_dbg(us, "Freecom TRANSPORT STARTED\n");
234 234
235 /* Get handles for both transports. */ 235 /* Get handles for both transports. */
236 opipe = us->send_bulk_pipe; 236 opipe = us->send_bulk_pipe;
@@ -242,7 +242,7 @@ static int freecom_transport(struct scsi_cmnd *srb, struct us_data *us)
242 memcpy (fcb->Atapi, srb->cmnd, 12); 242 memcpy (fcb->Atapi, srb->cmnd, 12);
243 memset (fcb->Filler, 0, sizeof (fcb->Filler)); 243 memset (fcb->Filler, 0, sizeof (fcb->Filler));
244 244
245 US_DEBUG(pdump (srb->cmnd, 12)); 245 US_DEBUG(pdump(us, srb->cmnd, 12));
246 246
247 /* Send it out. */ 247 /* Send it out. */
248 result = usb_stor_bulk_transfer_buf (us, opipe, fcb, 248 result = usb_stor_bulk_transfer_buf (us, opipe, fcb,
@@ -252,7 +252,7 @@ static int freecom_transport(struct scsi_cmnd *srb, struct us_data *us)
252 * USB land. It returns the status in its own registers, which 252 * USB land. It returns the status in its own registers, which
253 * come back in the bulk pipe. */ 253 * come back in the bulk pipe. */
254 if (result != USB_STOR_XFER_GOOD) { 254 if (result != USB_STOR_XFER_GOOD) {
255 US_DEBUGP ("freecom transport error\n"); 255 usb_stor_dbg(us, "freecom transport error\n");
256 return USB_STOR_TRANSPORT_ERROR; 256 return USB_STOR_TRANSPORT_ERROR;
257 } 257 }
258 258
@@ -260,11 +260,11 @@ static int freecom_transport(struct scsi_cmnd *srb, struct us_data *us)
260 * doesn't hurt us to always do it now. */ 260 * doesn't hurt us to always do it now. */
261 result = usb_stor_bulk_transfer_buf (us, ipipe, fst, 261 result = usb_stor_bulk_transfer_buf (us, ipipe, fst,
262 FCM_STATUS_PACKET_LENGTH, &partial); 262 FCM_STATUS_PACKET_LENGTH, &partial);
263 US_DEBUGP("foo Status result %d %u\n", result, partial); 263 usb_stor_dbg(us, "foo Status result %d %u\n", result, partial);
264 if (result != USB_STOR_XFER_GOOD) 264 if (result != USB_STOR_XFER_GOOD)
265 return USB_STOR_TRANSPORT_ERROR; 265 return USB_STOR_TRANSPORT_ERROR;
266 266
267 US_DEBUG(pdump ((void *) fst, partial)); 267 US_DEBUG(pdump(us, (void *)fst, partial));
268 268
269 /* The firmware will time-out commands after 20 seconds. Some commands 269 /* The firmware will time-out commands after 20 seconds. Some commands
270 * can legitimately take longer than this, so we use a different 270 * can legitimately take longer than this, so we use a different
@@ -275,8 +275,8 @@ static int freecom_transport(struct scsi_cmnd *srb, struct us_data *us)
275 * may not work, but that is a condition that should never happen. 275 * may not work, but that is a condition that should never happen.
276 */ 276 */
277 while (fst->Status & FCM_STATUS_BUSY) { 277 while (fst->Status & FCM_STATUS_BUSY) {
278 US_DEBUGP("20 second USB/ATAPI bridge TIMEOUT occurred!\n"); 278 usb_stor_dbg(us, "20 second USB/ATAPI bridge TIMEOUT occurred!\n");
279 US_DEBUGP("fst->Status is %x\n", fst->Status); 279 usb_stor_dbg(us, "fst->Status is %x\n", fst->Status);
280 280
281 /* Get the status again */ 281 /* Get the status again */
282 fcb->Type = FCM_PACKET_STATUS; 282 fcb->Type = FCM_PACKET_STATUS;
@@ -293,7 +293,7 @@ static int freecom_transport(struct scsi_cmnd *srb, struct us_data *us)
293 * registers, which come back in the bulk pipe. 293 * registers, which come back in the bulk pipe.
294 */ 294 */
295 if (result != USB_STOR_XFER_GOOD) { 295 if (result != USB_STOR_XFER_GOOD) {
296 US_DEBUGP ("freecom transport error\n"); 296 usb_stor_dbg(us, "freecom transport error\n");
297 return USB_STOR_TRANSPORT_ERROR; 297 return USB_STOR_TRANSPORT_ERROR;
298 } 298 }
299 299
@@ -301,26 +301,26 @@ static int freecom_transport(struct scsi_cmnd *srb, struct us_data *us)
301 result = usb_stor_bulk_transfer_buf (us, ipipe, fst, 301 result = usb_stor_bulk_transfer_buf (us, ipipe, fst,
302 FCM_STATUS_PACKET_LENGTH, &partial); 302 FCM_STATUS_PACKET_LENGTH, &partial);
303 303
304 US_DEBUGP("bar Status result %d %u\n", result, partial); 304 usb_stor_dbg(us, "bar Status result %d %u\n", result, partial);
305 if (result != USB_STOR_XFER_GOOD) 305 if (result != USB_STOR_XFER_GOOD)
306 return USB_STOR_TRANSPORT_ERROR; 306 return USB_STOR_TRANSPORT_ERROR;
307 307
308 US_DEBUG(pdump ((void *) fst, partial)); 308 US_DEBUG(pdump(us, (void *)fst, partial));
309 } 309 }
310 310
311 if (partial != 4) 311 if (partial != 4)
312 return USB_STOR_TRANSPORT_ERROR; 312 return USB_STOR_TRANSPORT_ERROR;
313 if ((fst->Status & 1) != 0) { 313 if ((fst->Status & 1) != 0) {
314 US_DEBUGP("operation failed\n"); 314 usb_stor_dbg(us, "operation failed\n");
315 return USB_STOR_TRANSPORT_FAILED; 315 return USB_STOR_TRANSPORT_FAILED;
316 } 316 }
317 317
318 /* The device might not have as much data available as we 318 /* The device might not have as much data available as we
319 * requested. If you ask for more than the device has, this reads 319 * requested. If you ask for more than the device has, this reads
320 * and such will hang. */ 320 * and such will hang. */
321 US_DEBUGP("Device indicates that it has %d bytes available\n", 321 usb_stor_dbg(us, "Device indicates that it has %d bytes available\n",
322 le16_to_cpu (fst->Count)); 322 le16_to_cpu(fst->Count));
323 US_DEBUGP("SCSI requested %d\n", scsi_bufflen(srb)); 323 usb_stor_dbg(us, "SCSI requested %d\n", scsi_bufflen(srb));
324 324
325 /* Find the length we desire to read. */ 325 /* Find the length we desire to read. */
326 switch (srb->cmnd[0]) { 326 switch (srb->cmnd[0]) {
@@ -337,7 +337,8 @@ static int freecom_transport(struct scsi_cmnd *srb, struct us_data *us)
337 /* verify that this amount is legal */ 337 /* verify that this amount is legal */
338 if (length > scsi_bufflen(srb)) { 338 if (length > scsi_bufflen(srb)) {
339 length = scsi_bufflen(srb); 339 length = scsi_bufflen(srb);
340 US_DEBUGP("Truncating request to match buffer length: %d\n", length); 340 usb_stor_dbg(us, "Truncating request to match buffer length: %d\n",
341 length);
341 } 342 }
342 343
343 /* What we do now depends on what direction the data is supposed to 344 /* What we do now depends on what direction the data is supposed to
@@ -351,29 +352,29 @@ static int freecom_transport(struct scsi_cmnd *srb, struct us_data *us)
351 /* Make sure that the status indicates that the device 352 /* Make sure that the status indicates that the device
352 * wants data as well. */ 353 * wants data as well. */
353 if ((fst->Status & DRQ_STAT) == 0 || (fst->Reason & 3) != 2) { 354 if ((fst->Status & DRQ_STAT) == 0 || (fst->Reason & 3) != 2) {
354 US_DEBUGP("SCSI wants data, drive doesn't have any\n"); 355 usb_stor_dbg(us, "SCSI wants data, drive doesn't have any\n");
355 return USB_STOR_TRANSPORT_FAILED; 356 return USB_STOR_TRANSPORT_FAILED;
356 } 357 }
357 result = freecom_readdata (srb, us, ipipe, opipe, length); 358 result = freecom_readdata (srb, us, ipipe, opipe, length);
358 if (result != USB_STOR_TRANSPORT_GOOD) 359 if (result != USB_STOR_TRANSPORT_GOOD)
359 return result; 360 return result;
360 361
361 US_DEBUGP("FCM: Waiting for status\n"); 362 usb_stor_dbg(us, "Waiting for status\n");
362 result = usb_stor_bulk_transfer_buf (us, ipipe, fst, 363 result = usb_stor_bulk_transfer_buf (us, ipipe, fst,
363 FCM_PACKET_LENGTH, &partial); 364 FCM_PACKET_LENGTH, &partial);
364 US_DEBUG(pdump ((void *) fst, partial)); 365 US_DEBUG(pdump(us, (void *)fst, partial));
365 366
366 if (partial != 4 || result > USB_STOR_XFER_SHORT) 367 if (partial != 4 || result > USB_STOR_XFER_SHORT)
367 return USB_STOR_TRANSPORT_ERROR; 368 return USB_STOR_TRANSPORT_ERROR;
368 if ((fst->Status & ERR_STAT) != 0) { 369 if ((fst->Status & ERR_STAT) != 0) {
369 US_DEBUGP("operation failed\n"); 370 usb_stor_dbg(us, "operation failed\n");
370 return USB_STOR_TRANSPORT_FAILED; 371 return USB_STOR_TRANSPORT_FAILED;
371 } 372 }
372 if ((fst->Reason & 3) != 3) { 373 if ((fst->Reason & 3) != 3) {
373 US_DEBUGP("Drive seems still hungry\n"); 374 usb_stor_dbg(us, "Drive seems still hungry\n");
374 return USB_STOR_TRANSPORT_FAILED; 375 return USB_STOR_TRANSPORT_FAILED;
375 } 376 }
376 US_DEBUGP("Transfer happy\n"); 377 usb_stor_dbg(us, "Transfer happy\n");
377 break; 378 break;
378 379
379 case DMA_TO_DEVICE: 380 case DMA_TO_DEVICE:
@@ -387,22 +388,22 @@ static int freecom_transport(struct scsi_cmnd *srb, struct us_data *us)
387 if (result != USB_STOR_TRANSPORT_GOOD) 388 if (result != USB_STOR_TRANSPORT_GOOD)
388 return result; 389 return result;
389 390
390 US_DEBUGP("FCM: Waiting for status\n"); 391 usb_stor_dbg(us, "Waiting for status\n");
391 result = usb_stor_bulk_transfer_buf (us, ipipe, fst, 392 result = usb_stor_bulk_transfer_buf (us, ipipe, fst,
392 FCM_PACKET_LENGTH, &partial); 393 FCM_PACKET_LENGTH, &partial);
393 394
394 if (partial != 4 || result > USB_STOR_XFER_SHORT) 395 if (partial != 4 || result > USB_STOR_XFER_SHORT)
395 return USB_STOR_TRANSPORT_ERROR; 396 return USB_STOR_TRANSPORT_ERROR;
396 if ((fst->Status & ERR_STAT) != 0) { 397 if ((fst->Status & ERR_STAT) != 0) {
397 US_DEBUGP("operation failed\n"); 398 usb_stor_dbg(us, "operation failed\n");
398 return USB_STOR_TRANSPORT_FAILED; 399 return USB_STOR_TRANSPORT_FAILED;
399 } 400 }
400 if ((fst->Reason & 3) != 3) { 401 if ((fst->Reason & 3) != 3) {
401 US_DEBUGP("Drive seems still hungry\n"); 402 usb_stor_dbg(us, "Drive seems still hungry\n");
402 return USB_STOR_TRANSPORT_FAILED; 403 return USB_STOR_TRANSPORT_FAILED;
403 } 404 }
404 405
405 US_DEBUGP("Transfer happy\n"); 406 usb_stor_dbg(us, "Transfer happy\n");
406 break; 407 break;
407 408
408 409
@@ -412,8 +413,8 @@ static int freecom_transport(struct scsi_cmnd *srb, struct us_data *us)
412 413
413 default: 414 default:
414 /* should never hit here -- filtered in usb.c */ 415 /* should never hit here -- filtered in usb.c */
415 US_DEBUGP ("freecom unimplemented direction: %d\n", 416 usb_stor_dbg(us, "freecom unimplemented direction: %d\n",
416 us->srb->sc_data_direction); 417 us->srb->sc_data_direction);
417 /* Return fail, SCSI seems to handle this better. */ 418 /* Return fail, SCSI seems to handle this better. */
418 return USB_STOR_TRANSPORT_FAILED; 419 return USB_STOR_TRANSPORT_FAILED;
419 break; 420 break;
@@ -434,7 +435,7 @@ static int init_freecom(struct us_data *us)
434 result = usb_stor_control_msg(us, us->recv_ctrl_pipe, 435 result = usb_stor_control_msg(us, us->recv_ctrl_pipe,
435 0x4c, 0xc0, 0x4346, 0x0, buffer, 0x20, 3*HZ); 436 0x4c, 0xc0, 0x4346, 0x0, buffer, 0x20, 3*HZ);
436 buffer[32] = '\0'; 437 buffer[32] = '\0';
437 US_DEBUGP("String returned from FC init is: %s\n", buffer); 438 usb_stor_dbg(us, "String returned from FC init is: %s\n", buffer);
438 439
439 /* Special thanks to the people at Freecom for providing me with 440 /* Special thanks to the people at Freecom for providing me with
440 * this "magic sequence", which they use in their Windows and MacOS 441 * this "magic sequence", which they use in their Windows and MacOS
@@ -445,7 +446,7 @@ static int init_freecom(struct us_data *us)
445 /* send reset */ 446 /* send reset */
446 result = usb_stor_control_msg(us, us->send_ctrl_pipe, 447 result = usb_stor_control_msg(us, us->send_ctrl_pipe,
447 0x4d, 0x40, 0x24d8, 0x0, NULL, 0x0, 3*HZ); 448 0x4d, 0x40, 0x24d8, 0x0, NULL, 0x0, 3*HZ);
448 US_DEBUGP("result from activate reset is %d\n", result); 449 usb_stor_dbg(us, "result from activate reset is %d\n", result);
449 450
450 /* wait 250ms */ 451 /* wait 250ms */
451 mdelay(250); 452 mdelay(250);
@@ -453,7 +454,7 @@ static int init_freecom(struct us_data *us)
453 /* clear reset */ 454 /* clear reset */
454 result = usb_stor_control_msg(us, us->send_ctrl_pipe, 455 result = usb_stor_control_msg(us, us->send_ctrl_pipe,
455 0x4d, 0x40, 0x24f8, 0x0, NULL, 0x0, 3*HZ); 456 0x4d, 0x40, 0x24f8, 0x0, NULL, 0x0, 3*HZ);
456 US_DEBUGP("result from clear reset is %d\n", result); 457 usb_stor_dbg(us, "result from clear reset is %d\n", result);
457 458
458 /* wait 3 seconds */ 459 /* wait 3 seconds */
459 mdelay(3 * 1000); 460 mdelay(3 * 1000);
@@ -470,7 +471,7 @@ static int usb_stor_freecom_reset(struct us_data *us)
470} 471}
471 472
472#ifdef CONFIG_USB_STORAGE_DEBUG 473#ifdef CONFIG_USB_STORAGE_DEBUG
473static void pdump (void *ibuffer, int length) 474static void pdump(struct us_data *us, void *ibuffer, int length)
474{ 475{
475 static char line[80]; 476 static char line[80];
476 int offset = 0; 477 int offset = 0;
@@ -490,7 +491,7 @@ static void pdump (void *ibuffer, int length)
490 line[offset++] = '.'; 491 line[offset++] = '.';
491 } 492 }
492 line[offset] = 0; 493 line[offset] = 0;
493 US_DEBUGP("%s\n", line); 494 usb_stor_dbg(us, "%s\n", line);
494 offset = 0; 495 offset = 0;
495 } 496 }
496 offset += sprintf (line+offset, "%08x:", i); 497 offset += sprintf (line+offset, "%08x:", i);
@@ -517,7 +518,7 @@ static void pdump (void *ibuffer, int length)
517 line[offset++] = '.'; 518 line[offset++] = '.';
518 } 519 }
519 line[offset] = 0; 520 line[offset] = 0;
520 US_DEBUGP("%s\n", line); 521 usb_stor_dbg(us, "%s\n", line);
521 offset = 0; 522 offset = 0;
522} 523}
523#endif 524#endif
diff --git a/drivers/usb/storage/initializers.c b/drivers/usb/storage/initializers.c
index 105d900150c1..5a8b5ff1e45b 100644
--- a/drivers/usb/storage/initializers.c
+++ b/drivers/usb/storage/initializers.c
@@ -48,12 +48,12 @@ int usb_stor_euscsi_init(struct us_data *us)
48{ 48{
49 int result; 49 int result;
50 50
51 US_DEBUGP("Attempting to init eUSCSI bridge...\n"); 51 usb_stor_dbg(us, "Attempting to init eUSCSI bridge...\n");
52 us->iobuf[0] = 0x1; 52 us->iobuf[0] = 0x1;
53 result = usb_stor_control_msg(us, us->send_ctrl_pipe, 53 result = usb_stor_control_msg(us, us->send_ctrl_pipe,
54 0x0C, USB_RECIP_INTERFACE | USB_TYPE_VENDOR, 54 0x0C, USB_RECIP_INTERFACE | USB_TYPE_VENDOR,
55 0x01, 0x0, us->iobuf, 0x1, 5000); 55 0x01, 0x0, us->iobuf, 0x1, 5000);
56 US_DEBUGP("-- result is %d\n", result); 56 usb_stor_dbg(us, "-- result is %d\n", result);
57 57
58 return 0; 58 return 0;
59} 59}
@@ -68,7 +68,7 @@ int usb_stor_ucr61s2b_init(struct us_data *us)
68 unsigned int partial; 68 unsigned int partial;
69 static char init_string[] = "\xec\x0a\x06\x00$PCCHIPS"; 69 static char init_string[] = "\xec\x0a\x06\x00$PCCHIPS";
70 70
71 US_DEBUGP("Sending UCR-61S2B initialization packet...\n"); 71 usb_stor_dbg(us, "Sending UCR-61S2B initialization packet...\n");
72 72
73 bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); 73 bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
74 bcb->Tag = 0; 74 bcb->Tag = 0;
@@ -83,7 +83,7 @@ int usb_stor_ucr61s2b_init(struct us_data *us)
83 if (res) 83 if (res)
84 return -EIO; 84 return -EIO;
85 85
86 US_DEBUGP("Getting status packet...\n"); 86 usb_stor_dbg(us, "Getting status packet...\n");
87 res = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, bcs, 87 res = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, bcs,
88 US_BULK_CS_WRAP_LEN, &partial); 88 US_BULK_CS_WRAP_LEN, &partial);
89 if (res) 89 if (res)
@@ -101,6 +101,6 @@ int usb_stor_huawei_e220_init(struct us_data *us)
101 USB_REQ_SET_FEATURE, 101 USB_REQ_SET_FEATURE,
102 USB_TYPE_STANDARD | USB_RECIP_DEVICE, 102 USB_TYPE_STANDARD | USB_RECIP_DEVICE,
103 0x01, 0x0, NULL, 0x0, 1000); 103 0x01, 0x0, NULL, 0x0, 1000);
104 US_DEBUGP("Huawei mode set result is %d\n", result); 104 usb_stor_dbg(us, "Huawei mode set result is %d\n", result);
105 return 0; 105 return 0;
106} 106}
diff --git a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c
index 55571ae59592..599d8bff26c3 100644
--- a/drivers/usb/storage/isd200.c
+++ b/drivers/usb/storage/isd200.c
@@ -503,7 +503,7 @@ static int isd200_action( struct us_data *us, int action,
503 503
504 switch ( action ) { 504 switch ( action ) {
505 case ACTION_READ_STATUS: 505 case ACTION_READ_STATUS:
506 US_DEBUGP(" isd200_action(READ_STATUS)\n"); 506 usb_stor_dbg(us, " isd200_action(READ_STATUS)\n");
507 ata.generic.ActionSelect = ACTION_SELECT_0|ACTION_SELECT_2; 507 ata.generic.ActionSelect = ACTION_SELECT_0|ACTION_SELECT_2;
508 ata.generic.RegisterSelect = 508 ata.generic.RegisterSelect =
509 REG_CYLINDER_LOW | REG_CYLINDER_HIGH | 509 REG_CYLINDER_LOW | REG_CYLINDER_HIGH |
@@ -512,7 +512,7 @@ static int isd200_action( struct us_data *us, int action,
512 break; 512 break;
513 513
514 case ACTION_ENUM: 514 case ACTION_ENUM:
515 US_DEBUGP(" isd200_action(ENUM,0x%02x)\n",value); 515 usb_stor_dbg(us, " isd200_action(ENUM,0x%02x)\n", value);
516 ata.generic.ActionSelect = ACTION_SELECT_1|ACTION_SELECT_2| 516 ata.generic.ActionSelect = ACTION_SELECT_1|ACTION_SELECT_2|
517 ACTION_SELECT_3|ACTION_SELECT_4| 517 ACTION_SELECT_3|ACTION_SELECT_4|
518 ACTION_SELECT_5; 518 ACTION_SELECT_5;
@@ -522,7 +522,7 @@ static int isd200_action( struct us_data *us, int action,
522 break; 522 break;
523 523
524 case ACTION_RESET: 524 case ACTION_RESET:
525 US_DEBUGP(" isd200_action(RESET)\n"); 525 usb_stor_dbg(us, " isd200_action(RESET)\n");
526 ata.generic.ActionSelect = ACTION_SELECT_1|ACTION_SELECT_2| 526 ata.generic.ActionSelect = ACTION_SELECT_1|ACTION_SELECT_2|
527 ACTION_SELECT_3|ACTION_SELECT_4; 527 ACTION_SELECT_3|ACTION_SELECT_4;
528 ata.generic.RegisterSelect = REG_DEVICE_CONTROL; 528 ata.generic.RegisterSelect = REG_DEVICE_CONTROL;
@@ -531,7 +531,7 @@ static int isd200_action( struct us_data *us, int action,
531 break; 531 break;
532 532
533 case ACTION_REENABLE: 533 case ACTION_REENABLE:
534 US_DEBUGP(" isd200_action(REENABLE)\n"); 534 usb_stor_dbg(us, " isd200_action(REENABLE)\n");
535 ata.generic.ActionSelect = ACTION_SELECT_1|ACTION_SELECT_2| 535 ata.generic.ActionSelect = ACTION_SELECT_1|ACTION_SELECT_2|
536 ACTION_SELECT_3|ACTION_SELECT_4; 536 ACTION_SELECT_3|ACTION_SELECT_4;
537 ata.generic.RegisterSelect = REG_DEVICE_CONTROL; 537 ata.generic.RegisterSelect = REG_DEVICE_CONTROL;
@@ -540,7 +540,7 @@ static int isd200_action( struct us_data *us, int action,
540 break; 540 break;
541 541
542 case ACTION_SOFT_RESET: 542 case ACTION_SOFT_RESET:
543 US_DEBUGP(" isd200_action(SOFT_RESET)\n"); 543 usb_stor_dbg(us, " isd200_action(SOFT_RESET)\n");
544 ata.generic.ActionSelect = ACTION_SELECT_1|ACTION_SELECT_5; 544 ata.generic.ActionSelect = ACTION_SELECT_1|ACTION_SELECT_5;
545 ata.generic.RegisterSelect = REG_DEVICE_HEAD | REG_COMMAND; 545 ata.generic.RegisterSelect = REG_DEVICE_HEAD | REG_COMMAND;
546 ata.write.DeviceHeadByte = info->DeviceHead; 546 ata.write.DeviceHeadByte = info->DeviceHead;
@@ -549,7 +549,7 @@ static int isd200_action( struct us_data *us, int action,
549 break; 549 break;
550 550
551 case ACTION_IDENTIFY: 551 case ACTION_IDENTIFY:
552 US_DEBUGP(" isd200_action(IDENTIFY)\n"); 552 usb_stor_dbg(us, " isd200_action(IDENTIFY)\n");
553 ata.generic.RegisterSelect = REG_COMMAND; 553 ata.generic.RegisterSelect = REG_COMMAND;
554 ata.write.CommandByte = ATA_CMD_ID_ATA; 554 ata.write.CommandByte = ATA_CMD_ID_ATA;
555 isd200_set_srb(info, DMA_FROM_DEVICE, info->id, 555 isd200_set_srb(info, DMA_FROM_DEVICE, info->id,
@@ -557,7 +557,7 @@ static int isd200_action( struct us_data *us, int action,
557 break; 557 break;
558 558
559 default: 559 default:
560 US_DEBUGP("Error: Undefined action %d\n",action); 560 usb_stor_dbg(us, "Error: Undefined action %d\n", action);
561 return ISD200_ERROR; 561 return ISD200_ERROR;
562 } 562 }
563 563
@@ -567,7 +567,8 @@ static int isd200_action( struct us_data *us, int action,
567 if (status == USB_STOR_TRANSPORT_GOOD) 567 if (status == USB_STOR_TRANSPORT_GOOD)
568 status = ISD200_GOOD; 568 status = ISD200_GOOD;
569 else { 569 else {
570 US_DEBUGP(" isd200_action(0x%02x) error: %d\n",action,status); 570 usb_stor_dbg(us, " isd200_action(0x%02x) error: %d\n",
571 action, status);
571 status = ISD200_ERROR; 572 status = ISD200_ERROR;
572 /* need to reset device here */ 573 /* need to reset device here */
573 } 574 }
@@ -589,17 +590,17 @@ static int isd200_read_regs( struct us_data *us )
589 int retStatus = ISD200_GOOD; 590 int retStatus = ISD200_GOOD;
590 int transferStatus; 591 int transferStatus;
591 592
592 US_DEBUGP("Entering isd200_IssueATAReadRegs\n"); 593 usb_stor_dbg(us, "Entering isd200_IssueATAReadRegs\n");
593 594
594 transferStatus = isd200_action( us, ACTION_READ_STATUS, 595 transferStatus = isd200_action( us, ACTION_READ_STATUS,
595 info->RegsBuf, sizeof(info->ATARegs) ); 596 info->RegsBuf, sizeof(info->ATARegs) );
596 if (transferStatus != ISD200_TRANSPORT_GOOD) { 597 if (transferStatus != ISD200_TRANSPORT_GOOD) {
597 US_DEBUGP(" Error reading ATA registers\n"); 598 usb_stor_dbg(us, " Error reading ATA registers\n");
598 retStatus = ISD200_ERROR; 599 retStatus = ISD200_ERROR;
599 } else { 600 } else {
600 memcpy(info->ATARegs, info->RegsBuf, sizeof(info->ATARegs)); 601 memcpy(info->ATARegs, info->RegsBuf, sizeof(info->ATARegs));
601 US_DEBUGP(" Got ATA Register[ATA_REG_ERROR_OFFSET] = 0x%x\n", 602 usb_stor_dbg(us, " Got ATA Register[ATA_REG_ERROR_OFFSET] = 0x%x\n",
602 info->ATARegs[ATA_REG_ERROR_OFFSET]); 603 info->ATARegs[ATA_REG_ERROR_OFFSET]);
603 } 604 }
604 605
605 return retStatus; 606 return retStatus;
@@ -629,7 +630,7 @@ static void isd200_invoke_transport( struct us_data *us,
629 * short-circuit all other processing 630 * short-circuit all other processing
630 */ 631 */
631 if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) { 632 if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) {
632 US_DEBUGP("-- command was aborted\n"); 633 usb_stor_dbg(us, "-- command was aborted\n");
633 goto Handle_Abort; 634 goto Handle_Abort;
634 } 635 }
635 636
@@ -641,23 +642,23 @@ static void isd200_invoke_transport( struct us_data *us,
641 break; 642 break;
642 643
643 case USB_STOR_TRANSPORT_NO_SENSE: 644 case USB_STOR_TRANSPORT_NO_SENSE:
644 US_DEBUGP("-- transport indicates protocol failure\n"); 645 usb_stor_dbg(us, "-- transport indicates protocol failure\n");
645 srb->result = SAM_STAT_CHECK_CONDITION; 646 srb->result = SAM_STAT_CHECK_CONDITION;
646 return; 647 return;
647 648
648 case USB_STOR_TRANSPORT_FAILED: 649 case USB_STOR_TRANSPORT_FAILED:
649 US_DEBUGP("-- transport indicates command failure\n"); 650 usb_stor_dbg(us, "-- transport indicates command failure\n");
650 need_auto_sense = 1; 651 need_auto_sense = 1;
651 break; 652 break;
652 653
653 case USB_STOR_TRANSPORT_ERROR: 654 case USB_STOR_TRANSPORT_ERROR:
654 US_DEBUGP("-- transport indicates transport error\n"); 655 usb_stor_dbg(us, "-- transport indicates transport error\n");
655 srb->result = DID_ERROR << 16; 656 srb->result = DID_ERROR << 16;
656 /* Need reset here */ 657 /* Need reset here */
657 return; 658 return;
658 659
659 default: 660 default:
660 US_DEBUGP("-- transport indicates unknown error\n"); 661 usb_stor_dbg(us, "-- transport indicates unknown error\n");
661 srb->result = DID_ERROR << 16; 662 srb->result = DID_ERROR << 16;
662 /* Need reset here */ 663 /* Need reset here */
663 return; 664 return;
@@ -669,14 +670,14 @@ static void isd200_invoke_transport( struct us_data *us,
669 (srb->cmnd[0] == MODE_SENSE) || 670 (srb->cmnd[0] == MODE_SENSE) ||
670 (srb->cmnd[0] == LOG_SENSE) || 671 (srb->cmnd[0] == LOG_SENSE) ||
671 (srb->cmnd[0] == MODE_SENSE_10))) { 672 (srb->cmnd[0] == MODE_SENSE_10))) {
672 US_DEBUGP("-- unexpectedly short transfer\n"); 673 usb_stor_dbg(us, "-- unexpectedly short transfer\n");
673 need_auto_sense = 1; 674 need_auto_sense = 1;
674 } 675 }
675 676
676 if (need_auto_sense) { 677 if (need_auto_sense) {
677 result = isd200_read_regs(us); 678 result = isd200_read_regs(us);
678 if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) { 679 if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) {
679 US_DEBUGP("-- auto-sense aborted\n"); 680 usb_stor_dbg(us, "-- auto-sense aborted\n");
680 goto Handle_Abort; 681 goto Handle_Abort;
681 } 682 }
682 if (result == ISD200_GOOD) { 683 if (result == ISD200_GOOD) {
@@ -710,40 +711,40 @@ static void isd200_invoke_transport( struct us_data *us,
710} 711}
711 712
712#ifdef CONFIG_USB_STORAGE_DEBUG 713#ifdef CONFIG_USB_STORAGE_DEBUG
713static void isd200_log_config( struct isd200_info* info ) 714static void isd200_log_config(struct us_data *us, struct isd200_info *info)
714{ 715{
715 US_DEBUGP(" Event Notification: 0x%x\n", 716 usb_stor_dbg(us, " Event Notification: 0x%x\n",
716 info->ConfigData.EventNotification); 717 info->ConfigData.EventNotification);
717 US_DEBUGP(" External Clock: 0x%x\n", 718 usb_stor_dbg(us, " External Clock: 0x%x\n",
718 info->ConfigData.ExternalClock); 719 info->ConfigData.ExternalClock);
719 US_DEBUGP(" ATA Init Timeout: 0x%x\n", 720 usb_stor_dbg(us, " ATA Init Timeout: 0x%x\n",
720 info->ConfigData.ATAInitTimeout); 721 info->ConfigData.ATAInitTimeout);
721 US_DEBUGP(" ATAPI Command Block Size: 0x%x\n", 722 usb_stor_dbg(us, " ATAPI Command Block Size: 0x%x\n",
722 (info->ConfigData.ATAConfig & ATACFG_BLOCKSIZE) >> 6); 723 (info->ConfigData.ATAConfig & ATACFG_BLOCKSIZE) >> 6);
723 US_DEBUGP(" Master/Slave Selection: 0x%x\n", 724 usb_stor_dbg(us, " Master/Slave Selection: 0x%x\n",
724 info->ConfigData.ATAConfig & ATACFG_MASTER); 725 info->ConfigData.ATAConfig & ATACFG_MASTER);
725 US_DEBUGP(" ATAPI Reset: 0x%x\n", 726 usb_stor_dbg(us, " ATAPI Reset: 0x%x\n",
726 info->ConfigData.ATAConfig & ATACFG_ATAPI_RESET); 727 info->ConfigData.ATAConfig & ATACFG_ATAPI_RESET);
727 US_DEBUGP(" ATA Timing: 0x%x\n", 728 usb_stor_dbg(us, " ATA Timing: 0x%x\n",
728 info->ConfigData.ATAConfig & ATACFG_TIMING); 729 info->ConfigData.ATAConfig & ATACFG_TIMING);
729 US_DEBUGP(" ATA Major Command: 0x%x\n", 730 usb_stor_dbg(us, " ATA Major Command: 0x%x\n",
730 info->ConfigData.ATAMajorCommand); 731 info->ConfigData.ATAMajorCommand);
731 US_DEBUGP(" ATA Minor Command: 0x%x\n", 732 usb_stor_dbg(us, " ATA Minor Command: 0x%x\n",
732 info->ConfigData.ATAMinorCommand); 733 info->ConfigData.ATAMinorCommand);
733 US_DEBUGP(" Init Status: 0x%x\n", 734 usb_stor_dbg(us, " Init Status: 0x%x\n",
734 info->ConfigData.ATAExtraConfig & ATACFGE_INIT_STATUS); 735 info->ConfigData.ATAExtraConfig & ATACFGE_INIT_STATUS);
735 US_DEBUGP(" Config Descriptor 2: 0x%x\n", 736 usb_stor_dbg(us, " Config Descriptor 2: 0x%x\n",
736 info->ConfigData.ATAExtraConfig & ATACFGE_CONF_DESC2); 737 info->ConfigData.ATAExtraConfig & ATACFGE_CONF_DESC2);
737 US_DEBUGP(" Skip Device Boot: 0x%x\n", 738 usb_stor_dbg(us, " Skip Device Boot: 0x%x\n",
738 info->ConfigData.ATAExtraConfig & ATACFGE_SKIP_BOOT); 739 info->ConfigData.ATAExtraConfig & ATACFGE_SKIP_BOOT);
739 US_DEBUGP(" ATA 3 State Supsend: 0x%x\n", 740 usb_stor_dbg(us, " ATA 3 State Supsend: 0x%x\n",
740 info->ConfigData.ATAExtraConfig & ATACFGE_STATE_SUSPEND); 741 info->ConfigData.ATAExtraConfig & ATACFGE_STATE_SUSPEND);
741 US_DEBUGP(" Descriptor Override: 0x%x\n", 742 usb_stor_dbg(us, " Descriptor Override: 0x%x\n",
742 info->ConfigData.ATAExtraConfig & ATACFGE_DESC_OVERRIDE); 743 info->ConfigData.ATAExtraConfig & ATACFGE_DESC_OVERRIDE);
743 US_DEBUGP(" Last LUN Identifier: 0x%x\n", 744 usb_stor_dbg(us, " Last LUN Identifier: 0x%x\n",
744 info->ConfigData.ATAExtraConfig & ATACFGE_LAST_LUN); 745 info->ConfigData.ATAExtraConfig & ATACFGE_LAST_LUN);
745 US_DEBUGP(" SRST Enable: 0x%x\n", 746 usb_stor_dbg(us, " SRST Enable: 0x%x\n",
746 info->ConfigData.ATAExtraConfig & CFG_CAPABILITY_SRST); 747 info->ConfigData.ATAExtraConfig & CFG_CAPABILITY_SRST);
747} 748}
748#endif 749#endif
749 750
@@ -762,9 +763,9 @@ static int isd200_write_config( struct us_data *us )
762 int result; 763 int result;
763 764
764#ifdef CONFIG_USB_STORAGE_DEBUG 765#ifdef CONFIG_USB_STORAGE_DEBUG
765 US_DEBUGP("Entering isd200_write_config\n"); 766 usb_stor_dbg(us, "Entering isd200_write_config\n");
766 US_DEBUGP(" Writing the following ISD200 Config Data:\n"); 767 usb_stor_dbg(us, " Writing the following ISD200 Config Data:\n");
767 isd200_log_config(info); 768 isd200_log_config(us, info);
768#endif 769#endif
769 770
770 /* let's send the command via the control pipe */ 771 /* let's send the command via the control pipe */
@@ -779,13 +780,13 @@ static int isd200_write_config( struct us_data *us )
779 sizeof(info->ConfigData)); 780 sizeof(info->ConfigData));
780 781
781 if (result >= 0) { 782 if (result >= 0) {
782 US_DEBUGP(" ISD200 Config Data was written successfully\n"); 783 usb_stor_dbg(us, " ISD200 Config Data was written successfully\n");
783 } else { 784 } else {
784 US_DEBUGP(" Request to write ISD200 Config Data failed!\n"); 785 usb_stor_dbg(us, " Request to write ISD200 Config Data failed!\n");
785 retStatus = ISD200_ERROR; 786 retStatus = ISD200_ERROR;
786 } 787 }
787 788
788 US_DEBUGP("Leaving isd200_write_config %08X\n", retStatus); 789 usb_stor_dbg(us, "Leaving isd200_write_config %08X\n", retStatus);
789 return retStatus; 790 return retStatus;
790} 791}
791 792
@@ -804,7 +805,7 @@ static int isd200_read_config( struct us_data *us )
804 int retStatus = ISD200_GOOD; 805 int retStatus = ISD200_GOOD;
805 int result; 806 int result;
806 807
807 US_DEBUGP("Entering isd200_read_config\n"); 808 usb_stor_dbg(us, "Entering isd200_read_config\n");
808 809
809 /* read the configuration information from ISD200. Use this to */ 810 /* read the configuration information from ISD200. Use this to */
810 /* determine what the special ATA CDB bytes are. */ 811 /* determine what the special ATA CDB bytes are. */
@@ -821,16 +822,16 @@ static int isd200_read_config( struct us_data *us )
821 822
822 823
823 if (result >= 0) { 824 if (result >= 0) {
824 US_DEBUGP(" Retrieved the following ISD200 Config Data:\n"); 825 usb_stor_dbg(us, " Retrieved the following ISD200 Config Data:\n");
825#ifdef CONFIG_USB_STORAGE_DEBUG 826#ifdef CONFIG_USB_STORAGE_DEBUG
826 isd200_log_config(info); 827 isd200_log_config(us, info);
827#endif 828#endif
828 } else { 829 } else {
829 US_DEBUGP(" Request to get ISD200 Config Data failed!\n"); 830 usb_stor_dbg(us, " Request to get ISD200 Config Data failed!\n");
830 retStatus = ISD200_ERROR; 831 retStatus = ISD200_ERROR;
831 } 832 }
832 833
833 US_DEBUGP("Leaving isd200_read_config %08X\n", retStatus); 834 usb_stor_dbg(us, "Leaving isd200_read_config %08X\n", retStatus);
834 return retStatus; 835 return retStatus;
835} 836}
836 837
@@ -848,15 +849,15 @@ static int isd200_atapi_soft_reset( struct us_data *us )
848 int retStatus = ISD200_GOOD; 849 int retStatus = ISD200_GOOD;
849 int transferStatus; 850 int transferStatus;
850 851
851 US_DEBUGP("Entering isd200_atapi_soft_reset\n"); 852 usb_stor_dbg(us, "Entering isd200_atapi_soft_reset\n");
852 853
853 transferStatus = isd200_action( us, ACTION_SOFT_RESET, NULL, 0 ); 854 transferStatus = isd200_action( us, ACTION_SOFT_RESET, NULL, 0 );
854 if (transferStatus != ISD200_TRANSPORT_GOOD) { 855 if (transferStatus != ISD200_TRANSPORT_GOOD) {
855 US_DEBUGP(" Error issuing Atapi Soft Reset\n"); 856 usb_stor_dbg(us, " Error issuing Atapi Soft Reset\n");
856 retStatus = ISD200_ERROR; 857 retStatus = ISD200_ERROR;
857 } 858 }
858 859
859 US_DEBUGP("Leaving isd200_atapi_soft_reset %08X\n", retStatus); 860 usb_stor_dbg(us, "Leaving isd200_atapi_soft_reset %08X\n", retStatus);
860 return retStatus; 861 return retStatus;
861} 862}
862 863
@@ -874,13 +875,13 @@ static int isd200_srst( struct us_data *us )
874 int retStatus = ISD200_GOOD; 875 int retStatus = ISD200_GOOD;
875 int transferStatus; 876 int transferStatus;
876 877
877 US_DEBUGP("Entering isd200_SRST\n"); 878 usb_stor_dbg(us, "Entering isd200_SRST\n");
878 879
879 transferStatus = isd200_action( us, ACTION_RESET, NULL, 0 ); 880 transferStatus = isd200_action( us, ACTION_RESET, NULL, 0 );
880 881
881 /* check to see if this request failed */ 882 /* check to see if this request failed */
882 if (transferStatus != ISD200_TRANSPORT_GOOD) { 883 if (transferStatus != ISD200_TRANSPORT_GOOD) {
883 US_DEBUGP(" Error issuing SRST\n"); 884 usb_stor_dbg(us, " Error issuing SRST\n");
884 retStatus = ISD200_ERROR; 885 retStatus = ISD200_ERROR;
885 } else { 886 } else {
886 /* delay 10ms to give the drive a chance to see it */ 887 /* delay 10ms to give the drive a chance to see it */
@@ -888,7 +889,7 @@ static int isd200_srst( struct us_data *us )
888 889
889 transferStatus = isd200_action( us, ACTION_REENABLE, NULL, 0 ); 890 transferStatus = isd200_action( us, ACTION_REENABLE, NULL, 0 );
890 if (transferStatus != ISD200_TRANSPORT_GOOD) { 891 if (transferStatus != ISD200_TRANSPORT_GOOD) {
891 US_DEBUGP(" Error taking drive out of reset\n"); 892 usb_stor_dbg(us, " Error taking drive out of reset\n");
892 retStatus = ISD200_ERROR; 893 retStatus = ISD200_ERROR;
893 } else { 894 } else {
894 /* delay 50ms to give the drive a chance to recover after SRST */ 895 /* delay 50ms to give the drive a chance to recover after SRST */
@@ -896,7 +897,7 @@ static int isd200_srst( struct us_data *us )
896 } 897 }
897 } 898 }
898 899
899 US_DEBUGP("Leaving isd200_srst %08X\n", retStatus); 900 usb_stor_dbg(us, "Leaving isd200_srst %08X\n", retStatus);
900 return retStatus; 901 return retStatus;
901} 902}
902 903
@@ -938,13 +939,13 @@ static int isd200_try_enum(struct us_data *us, unsigned char master_slave,
938 939
939 if (!detect) { 940 if (!detect) {
940 if (regs[ATA_REG_STATUS_OFFSET] & ATA_BUSY) { 941 if (regs[ATA_REG_STATUS_OFFSET] & ATA_BUSY) {
941 US_DEBUGP(" %s status is still BSY, try again...\n", 942 usb_stor_dbg(us, " %s status is still BSY, try again...\n",
942 master_slave == ATA_ADDRESS_DEVHEAD_STD ? 943 master_slave == ATA_ADDRESS_DEVHEAD_STD ?
943 "Master" : "Slave"); 944 "Master" : "Slave");
944 } else { 945 } else {
945 US_DEBUGP(" %s status !BSY, continue with next operation\n", 946 usb_stor_dbg(us, " %s status !BSY, continue with next operation\n",
946 master_slave == ATA_ADDRESS_DEVHEAD_STD ? 947 master_slave == ATA_ADDRESS_DEVHEAD_STD ?
947 "Master" : "Slave"); 948 "Master" : "Slave");
948 break; 949 break;
949 } 950 }
950 } 951 }
@@ -953,11 +954,11 @@ static int isd200_try_enum(struct us_data *us, unsigned char master_slave,
953 /* ATA_ERR (workaround for Archos CD-ROM) */ 954 /* ATA_ERR (workaround for Archos CD-ROM) */
954 else if (regs[ATA_REG_STATUS_OFFSET] & 955 else if (regs[ATA_REG_STATUS_OFFSET] &
955 (ATA_BUSY | ATA_DF | ATA_ERR)) { 956 (ATA_BUSY | ATA_DF | ATA_ERR)) {
956 US_DEBUGP(" Status indicates it is not ready, try again...\n"); 957 usb_stor_dbg(us, " Status indicates it is not ready, try again...\n");
957 } 958 }
958 /* check for DRDY, ATA devices set DRDY after SRST */ 959 /* check for DRDY, ATA devices set DRDY after SRST */
959 else if (regs[ATA_REG_STATUS_OFFSET] & ATA_DRDY) { 960 else if (regs[ATA_REG_STATUS_OFFSET] & ATA_DRDY) {
960 US_DEBUGP(" Identified ATA device\n"); 961 usb_stor_dbg(us, " Identified ATA device\n");
961 info->DeviceFlags |= DF_ATA_DEVICE; 962 info->DeviceFlags |= DF_ATA_DEVICE;
962 info->DeviceHead = master_slave; 963 info->DeviceHead = master_slave;
963 break; 964 break;
@@ -978,27 +979,27 @@ static int isd200_try_enum(struct us_data *us, unsigned char master_slave,
978 */ 979 */
979 if ((master_slave & ATA_ADDRESS_DEVHEAD_SLAVE) && 980 if ((master_slave & ATA_ADDRESS_DEVHEAD_SLAVE) &&
980 !recheckAsMaster) { 981 !recheckAsMaster) {
981 US_DEBUGP(" Identified ATAPI device as slave. Rechecking again as master\n"); 982 usb_stor_dbg(us, " Identified ATAPI device as slave. Rechecking again as master\n");
982 recheckAsMaster = 1; 983 recheckAsMaster = 1;
983 master_slave = ATA_ADDRESS_DEVHEAD_STD; 984 master_slave = ATA_ADDRESS_DEVHEAD_STD;
984 } else { 985 } else {
985 US_DEBUGP(" Identified ATAPI device\n"); 986 usb_stor_dbg(us, " Identified ATAPI device\n");
986 info->DeviceHead = master_slave; 987 info->DeviceHead = master_slave;
987 988
988 status = isd200_atapi_soft_reset(us); 989 status = isd200_atapi_soft_reset(us);
989 break; 990 break;
990 } 991 }
991 } else { 992 } else {
992 US_DEBUGP(" Not ATA, not ATAPI. Weird.\n"); 993 usb_stor_dbg(us, " Not ATA, not ATAPI - Weird\n");
993 break; 994 break;
994 } 995 }
995 996
996 /* check for timeout on this request */ 997 /* check for timeout on this request */
997 if (time_after_eq(jiffies, endTime)) { 998 if (time_after_eq(jiffies, endTime)) {
998 if (!detect) 999 if (!detect)
999 US_DEBUGP(" BSY check timeout, just continue with next operation...\n"); 1000 usb_stor_dbg(us, " BSY check timeout, just continue with next operation...\n");
1000 else 1001 else
1001 US_DEBUGP(" Device detect timeout!\n"); 1002 usb_stor_dbg(us, " Device detect timeout!\n");
1002 break; 1003 break;
1003 } 1004 }
1004 } 1005 }
@@ -1020,7 +1021,7 @@ static int isd200_manual_enum(struct us_data *us)
1020 struct isd200_info *info = (struct isd200_info *)us->extra; 1021 struct isd200_info *info = (struct isd200_info *)us->extra;
1021 int retStatus = ISD200_GOOD; 1022 int retStatus = ISD200_GOOD;
1022 1023
1023 US_DEBUGP("Entering isd200_manual_enum\n"); 1024 usb_stor_dbg(us, "Entering isd200_manual_enum\n");
1024 1025
1025 retStatus = isd200_read_config(us); 1026 retStatus = isd200_read_config(us);
1026 if (retStatus == ISD200_GOOD) { 1027 if (retStatus == ISD200_GOOD) {
@@ -1039,14 +1040,15 @@ static int isd200_manual_enum(struct us_data *us)
1039 1040
1040 isslave = (info->DeviceHead & ATA_ADDRESS_DEVHEAD_SLAVE) ? 1 : 0; 1041 isslave = (info->DeviceHead & ATA_ADDRESS_DEVHEAD_SLAVE) ? 1 : 0;
1041 if (!(info->ConfigData.ATAConfig & ATACFG_MASTER)) { 1042 if (!(info->ConfigData.ATAConfig & ATACFG_MASTER)) {
1042 US_DEBUGP(" Setting Master/Slave selection to %d\n", isslave); 1043 usb_stor_dbg(us, " Setting Master/Slave selection to %d\n",
1044 isslave);
1043 info->ConfigData.ATAConfig &= 0x3f; 1045 info->ConfigData.ATAConfig &= 0x3f;
1044 info->ConfigData.ATAConfig |= (isslave<<6); 1046 info->ConfigData.ATAConfig |= (isslave<<6);
1045 retStatus = isd200_write_config(us); 1047 retStatus = isd200_write_config(us);
1046 } 1048 }
1047 } 1049 }
1048 1050
1049 US_DEBUGP("Leaving isd200_manual_enum %08X\n", retStatus); 1051 usb_stor_dbg(us, "Leaving isd200_manual_enum %08X\n", retStatus);
1050 return(retStatus); 1052 return(retStatus);
1051} 1053}
1052 1054
@@ -1064,35 +1066,35 @@ static void isd200_fix_driveid(u16 *id)
1064#endif 1066#endif
1065} 1067}
1066 1068
1067static void isd200_dump_driveid(u16 *id) 1069static void isd200_dump_driveid(struct us_data *us, u16 *id)
1068{ 1070{
1069 US_DEBUGP(" Identify Data Structure:\n"); 1071 usb_stor_dbg(us, " Identify Data Structure:\n");
1070 US_DEBUGP(" config = 0x%x\n", id[ATA_ID_CONFIG]); 1072 usb_stor_dbg(us, " config = 0x%x\n", id[ATA_ID_CONFIG]);
1071 US_DEBUGP(" cyls = 0x%x\n", id[ATA_ID_CYLS]); 1073 usb_stor_dbg(us, " cyls = 0x%x\n", id[ATA_ID_CYLS]);
1072 US_DEBUGP(" heads = 0x%x\n", id[ATA_ID_HEADS]); 1074 usb_stor_dbg(us, " heads = 0x%x\n", id[ATA_ID_HEADS]);
1073 US_DEBUGP(" track_bytes = 0x%x\n", id[4]); 1075 usb_stor_dbg(us, " track_bytes = 0x%x\n", id[4]);
1074 US_DEBUGP(" sector_bytes = 0x%x\n", id[5]); 1076 usb_stor_dbg(us, " sector_bytes = 0x%x\n", id[5]);
1075 US_DEBUGP(" sectors = 0x%x\n", id[ATA_ID_SECTORS]); 1077 usb_stor_dbg(us, " sectors = 0x%x\n", id[ATA_ID_SECTORS]);
1076 US_DEBUGP(" serial_no[0] = 0x%x\n", *(char *)&id[ATA_ID_SERNO]); 1078 usb_stor_dbg(us, " serial_no[0] = 0x%x\n", *(char *)&id[ATA_ID_SERNO]);
1077 US_DEBUGP(" buf_type = 0x%x\n", id[20]); 1079 usb_stor_dbg(us, " buf_type = 0x%x\n", id[20]);
1078 US_DEBUGP(" buf_size = 0x%x\n", id[ATA_ID_BUF_SIZE]); 1080 usb_stor_dbg(us, " buf_size = 0x%x\n", id[ATA_ID_BUF_SIZE]);
1079 US_DEBUGP(" ecc_bytes = 0x%x\n", id[22]); 1081 usb_stor_dbg(us, " ecc_bytes = 0x%x\n", id[22]);
1080 US_DEBUGP(" fw_rev[0] = 0x%x\n", *(char *)&id[ATA_ID_FW_REV]); 1082 usb_stor_dbg(us, " fw_rev[0] = 0x%x\n", *(char *)&id[ATA_ID_FW_REV]);
1081 US_DEBUGP(" model[0] = 0x%x\n", *(char *)&id[ATA_ID_PROD]); 1083 usb_stor_dbg(us, " model[0] = 0x%x\n", *(char *)&id[ATA_ID_PROD]);
1082 US_DEBUGP(" max_multsect = 0x%x\n", id[ATA_ID_MAX_MULTSECT] & 0xff); 1084 usb_stor_dbg(us, " max_multsect = 0x%x\n", id[ATA_ID_MAX_MULTSECT] & 0xff);
1083 US_DEBUGP(" dword_io = 0x%x\n", id[ATA_ID_DWORD_IO]); 1085 usb_stor_dbg(us, " dword_io = 0x%x\n", id[ATA_ID_DWORD_IO]);
1084 US_DEBUGP(" capability = 0x%x\n", id[ATA_ID_CAPABILITY] >> 8); 1086 usb_stor_dbg(us, " capability = 0x%x\n", id[ATA_ID_CAPABILITY] >> 8);
1085 US_DEBUGP(" tPIO = 0x%x\n", id[ATA_ID_OLD_PIO_MODES] >> 8); 1087 usb_stor_dbg(us, " tPIO = 0x%x\n", id[ATA_ID_OLD_PIO_MODES] >> 8);
1086 US_DEBUGP(" tDMA = 0x%x\n", id[ATA_ID_OLD_DMA_MODES] >> 8); 1088 usb_stor_dbg(us, " tDMA = 0x%x\n", id[ATA_ID_OLD_DMA_MODES] >> 8);
1087 US_DEBUGP(" field_valid = 0x%x\n", id[ATA_ID_FIELD_VALID]); 1089 usb_stor_dbg(us, " field_valid = 0x%x\n", id[ATA_ID_FIELD_VALID]);
1088 US_DEBUGP(" cur_cyls = 0x%x\n", id[ATA_ID_CUR_CYLS]); 1090 usb_stor_dbg(us, " cur_cyls = 0x%x\n", id[ATA_ID_CUR_CYLS]);
1089 US_DEBUGP(" cur_heads = 0x%x\n", id[ATA_ID_CUR_HEADS]); 1091 usb_stor_dbg(us, " cur_heads = 0x%x\n", id[ATA_ID_CUR_HEADS]);
1090 US_DEBUGP(" cur_sectors = 0x%x\n", id[ATA_ID_CUR_SECTORS]); 1092 usb_stor_dbg(us, " cur_sectors = 0x%x\n", id[ATA_ID_CUR_SECTORS]);
1091 US_DEBUGP(" cur_capacity = 0x%x\n", ata_id_u32(id, 57)); 1093 usb_stor_dbg(us, " cur_capacity = 0x%x\n", ata_id_u32(id, 57));
1092 US_DEBUGP(" multsect = 0x%x\n", id[ATA_ID_MULTSECT] & 0xff); 1094 usb_stor_dbg(us, " multsect = 0x%x\n", id[ATA_ID_MULTSECT] & 0xff);
1093 US_DEBUGP(" lba_capacity = 0x%x\n", ata_id_u32(id, ATA_ID_LBA_CAPACITY)); 1095 usb_stor_dbg(us, " lba_capacity = 0x%x\n", ata_id_u32(id, ATA_ID_LBA_CAPACITY));
1094 US_DEBUGP(" command_set_1 = 0x%x\n", id[ATA_ID_COMMAND_SET_1]); 1096 usb_stor_dbg(us, " command_set_1 = 0x%x\n", id[ATA_ID_COMMAND_SET_1]);
1095 US_DEBUGP(" command_set_2 = 0x%x\n", id[ATA_ID_COMMAND_SET_2]); 1097 usb_stor_dbg(us, " command_set_2 = 0x%x\n", id[ATA_ID_COMMAND_SET_2]);
1096} 1098}
1097 1099
1098/************************************************************************** 1100/**************************************************************************
@@ -1109,7 +1111,7 @@ static int isd200_get_inquiry_data( struct us_data *us )
1109 int retStatus = ISD200_GOOD; 1111 int retStatus = ISD200_GOOD;
1110 u16 *id = info->id; 1112 u16 *id = info->id;
1111 1113
1112 US_DEBUGP("Entering isd200_get_inquiry_data\n"); 1114 usb_stor_dbg(us, "Entering isd200_get_inquiry_data\n");
1113 1115
1114 /* set default to Master */ 1116 /* set default to Master */
1115 info->DeviceHead = ATA_ADDRESS_DEVHEAD_STD; 1117 info->DeviceHead = ATA_ADDRESS_DEVHEAD_STD;
@@ -1127,7 +1129,7 @@ static int isd200_get_inquiry_data( struct us_data *us )
1127 id, ATA_ID_WORDS * 2); 1129 id, ATA_ID_WORDS * 2);
1128 if (transferStatus != ISD200_TRANSPORT_GOOD) { 1130 if (transferStatus != ISD200_TRANSPORT_GOOD) {
1129 /* Error issuing ATA Command Identify */ 1131 /* Error issuing ATA Command Identify */
1130 US_DEBUGP(" Error issuing ATA Command Identify\n"); 1132 usb_stor_dbg(us, " Error issuing ATA Command Identify\n");
1131 retStatus = ISD200_ERROR; 1133 retStatus = ISD200_ERROR;
1132 } else { 1134 } else {
1133 /* ATA Command Identify successful */ 1135 /* ATA Command Identify successful */
@@ -1136,7 +1138,7 @@ static int isd200_get_inquiry_data( struct us_data *us )
1136 __u16 *dest; 1138 __u16 *dest;
1137 1139
1138 isd200_fix_driveid(id); 1140 isd200_fix_driveid(id);
1139 isd200_dump_driveid(id); 1141 isd200_dump_driveid(us, id);
1140 1142
1141 memset(&info->InquiryData, 0, sizeof(info->InquiryData)); 1143 memset(&info->InquiryData, 0, sizeof(info->InquiryData));
1142 1144
@@ -1170,7 +1172,7 @@ static int isd200_get_inquiry_data( struct us_data *us )
1170 1172
1171 /* determine if it supports Media Status Notification */ 1173 /* determine if it supports Media Status Notification */
1172 if (id[ATA_ID_COMMAND_SET_2] & COMMANDSET_MEDIA_STATUS) { 1174 if (id[ATA_ID_COMMAND_SET_2] & COMMANDSET_MEDIA_STATUS) {
1173 US_DEBUGP(" Device supports Media Status Notification\n"); 1175 usb_stor_dbg(us, " Device supports Media Status Notification\n");
1174 1176
1175 /* Indicate that it is enabled, even though it is not 1177 /* Indicate that it is enabled, even though it is not
1176 * This allows the lock/unlock of the media to work 1178 * This allows the lock/unlock of the media to work
@@ -1190,7 +1192,8 @@ static int isd200_get_inquiry_data( struct us_data *us )
1190 us->protocol_name = "Transparent SCSI"; 1192 us->protocol_name = "Transparent SCSI";
1191 us->proto_handler = usb_stor_transparent_scsi_command; 1193 us->proto_handler = usb_stor_transparent_scsi_command;
1192 1194
1193 US_DEBUGP("Protocol changed to: %s\n", us->protocol_name); 1195 usb_stor_dbg(us, "Protocol changed to: %s\n",
1196 us->protocol_name);
1194 1197
1195 /* Free driver structure */ 1198 /* Free driver structure */
1196 us->extra_destructor(info); 1199 us->extra_destructor(info);
@@ -1200,7 +1203,7 @@ static int isd200_get_inquiry_data( struct us_data *us )
1200 } 1203 }
1201 } 1204 }
1202 1205
1203 US_DEBUGP("Leaving isd200_get_inquiry_data %08X\n", retStatus); 1206 usb_stor_dbg(us, "Leaving isd200_get_inquiry_data %08X\n", retStatus);
1204 1207
1205 return(retStatus); 1208 return(retStatus);
1206} 1209}
@@ -1231,7 +1234,7 @@ static int isd200_scsi_to_ata(struct scsi_cmnd *srb, struct us_data *us,
1231 /* SCSI Command */ 1234 /* SCSI Command */
1232 switch (srb->cmnd[0]) { 1235 switch (srb->cmnd[0]) {
1233 case INQUIRY: 1236 case INQUIRY:
1234 US_DEBUGP(" ATA OUT - INQUIRY\n"); 1237 usb_stor_dbg(us, " ATA OUT - INQUIRY\n");
1235 1238
1236 /* copy InquiryData */ 1239 /* copy InquiryData */
1237 usb_stor_set_xfer_buf((unsigned char *) &info->InquiryData, 1240 usb_stor_set_xfer_buf((unsigned char *) &info->InquiryData,
@@ -1241,7 +1244,7 @@ static int isd200_scsi_to_ata(struct scsi_cmnd *srb, struct us_data *us,
1241 break; 1244 break;
1242 1245
1243 case MODE_SENSE: 1246 case MODE_SENSE:
1244 US_DEBUGP(" ATA OUT - SCSIOP_MODE_SENSE\n"); 1247 usb_stor_dbg(us, " ATA OUT - SCSIOP_MODE_SENSE\n");
1245 1248
1246 /* Initialize the return buffer */ 1249 /* Initialize the return buffer */
1247 usb_stor_set_xfer_buf(senseData, sizeof(senseData), srb); 1250 usb_stor_set_xfer_buf(senseData, sizeof(senseData), srb);
@@ -1255,14 +1258,14 @@ static int isd200_scsi_to_ata(struct scsi_cmnd *srb, struct us_data *us,
1255 ataCdb->write.CommandByte = ATA_COMMAND_GET_MEDIA_STATUS; 1258 ataCdb->write.CommandByte = ATA_COMMAND_GET_MEDIA_STATUS;
1256 isd200_srb_set_bufflen(srb, 0); 1259 isd200_srb_set_bufflen(srb, 0);
1257 } else { 1260 } else {
1258 US_DEBUGP(" Media Status not supported, just report okay\n"); 1261 usb_stor_dbg(us, " Media Status not supported, just report okay\n");
1259 srb->result = SAM_STAT_GOOD; 1262 srb->result = SAM_STAT_GOOD;
1260 sendToTransport = 0; 1263 sendToTransport = 0;
1261 } 1264 }
1262 break; 1265 break;
1263 1266
1264 case TEST_UNIT_READY: 1267 case TEST_UNIT_READY:
1265 US_DEBUGP(" ATA OUT - SCSIOP_TEST_UNIT_READY\n"); 1268 usb_stor_dbg(us, " ATA OUT - SCSIOP_TEST_UNIT_READY\n");
1266 1269
1267 if (info->DeviceFlags & DF_MEDIA_STATUS_ENABLED) 1270 if (info->DeviceFlags & DF_MEDIA_STATUS_ENABLED)
1268 { 1271 {
@@ -1273,7 +1276,7 @@ static int isd200_scsi_to_ata(struct scsi_cmnd *srb, struct us_data *us,
1273 ataCdb->write.CommandByte = ATA_COMMAND_GET_MEDIA_STATUS; 1276 ataCdb->write.CommandByte = ATA_COMMAND_GET_MEDIA_STATUS;
1274 isd200_srb_set_bufflen(srb, 0); 1277 isd200_srb_set_bufflen(srb, 0);
1275 } else { 1278 } else {
1276 US_DEBUGP(" Media Status not supported, just report okay\n"); 1279 usb_stor_dbg(us, " Media Status not supported, just report okay\n");
1277 srb->result = SAM_STAT_GOOD; 1280 srb->result = SAM_STAT_GOOD;
1278 sendToTransport = 0; 1281 sendToTransport = 0;
1279 } 1282 }
@@ -1284,7 +1287,7 @@ static int isd200_scsi_to_ata(struct scsi_cmnd *srb, struct us_data *us,
1284 unsigned long capacity; 1287 unsigned long capacity;
1285 struct read_capacity_data readCapacityData; 1288 struct read_capacity_data readCapacityData;
1286 1289
1287 US_DEBUGP(" ATA OUT - SCSIOP_READ_CAPACITY\n"); 1290 usb_stor_dbg(us, " ATA OUT - SCSIOP_READ_CAPACITY\n");
1288 1291
1289 if (ata_id_has_lba(id)) 1292 if (ata_id_has_lba(id))
1290 capacity = ata_id_u32(id, ATA_ID_LBA_CAPACITY) - 1; 1293 capacity = ata_id_u32(id, ATA_ID_LBA_CAPACITY) - 1;
@@ -1303,7 +1306,7 @@ static int isd200_scsi_to_ata(struct scsi_cmnd *srb, struct us_data *us,
1303 break; 1306 break;
1304 1307
1305 case READ_10: 1308 case READ_10:
1306 US_DEBUGP(" ATA OUT - SCSIOP_READ\n"); 1309 usb_stor_dbg(us, " ATA OUT - SCSIOP_READ\n");
1307 1310
1308 lba = be32_to_cpu(*(__be32 *)&srb->cmnd[2]); 1311 lba = be32_to_cpu(*(__be32 *)&srb->cmnd[2]);
1309 blockCount = (unsigned long)srb->cmnd[7]<<8 | (unsigned long)srb->cmnd[8]; 1312 blockCount = (unsigned long)srb->cmnd[7]<<8 | (unsigned long)srb->cmnd[8];
@@ -1335,7 +1338,7 @@ static int isd200_scsi_to_ata(struct scsi_cmnd *srb, struct us_data *us,
1335 break; 1338 break;
1336 1339
1337 case WRITE_10: 1340 case WRITE_10:
1338 US_DEBUGP(" ATA OUT - SCSIOP_WRITE\n"); 1341 usb_stor_dbg(us, " ATA OUT - SCSIOP_WRITE\n");
1339 1342
1340 lba = be32_to_cpu(*(__be32 *)&srb->cmnd[2]); 1343 lba = be32_to_cpu(*(__be32 *)&srb->cmnd[2]);
1341 blockCount = (unsigned long)srb->cmnd[7]<<8 | (unsigned long)srb->cmnd[8]; 1344 blockCount = (unsigned long)srb->cmnd[7]<<8 | (unsigned long)srb->cmnd[8];
@@ -1367,10 +1370,11 @@ static int isd200_scsi_to_ata(struct scsi_cmnd *srb, struct us_data *us,
1367 break; 1370 break;
1368 1371
1369 case ALLOW_MEDIUM_REMOVAL: 1372 case ALLOW_MEDIUM_REMOVAL:
1370 US_DEBUGP(" ATA OUT - SCSIOP_MEDIUM_REMOVAL\n"); 1373 usb_stor_dbg(us, " ATA OUT - SCSIOP_MEDIUM_REMOVAL\n");
1371 1374
1372 if (info->DeviceFlags & DF_REMOVABLE_MEDIA) { 1375 if (info->DeviceFlags & DF_REMOVABLE_MEDIA) {
1373 US_DEBUGP(" srb->cmnd[4] = 0x%X\n", srb->cmnd[4]); 1376 usb_stor_dbg(us, " srb->cmnd[4] = 0x%X\n",
1377 srb->cmnd[4]);
1374 1378
1375 ataCdb->generic.SignatureByte0 = info->ConfigData.ATAMajorCommand; 1379 ataCdb->generic.SignatureByte0 = info->ConfigData.ATAMajorCommand;
1376 ataCdb->generic.SignatureByte1 = info->ConfigData.ATAMinorCommand; 1380 ataCdb->generic.SignatureByte1 = info->ConfigData.ATAMinorCommand;
@@ -1380,25 +1384,25 @@ static int isd200_scsi_to_ata(struct scsi_cmnd *srb, struct us_data *us,
1380 ATA_CMD_MEDIA_LOCK : ATA_CMD_MEDIA_UNLOCK; 1384 ATA_CMD_MEDIA_LOCK : ATA_CMD_MEDIA_UNLOCK;
1381 isd200_srb_set_bufflen(srb, 0); 1385 isd200_srb_set_bufflen(srb, 0);
1382 } else { 1386 } else {
1383 US_DEBUGP(" Not removeable media, just report okay\n"); 1387 usb_stor_dbg(us, " Not removeable media, just report okay\n");
1384 srb->result = SAM_STAT_GOOD; 1388 srb->result = SAM_STAT_GOOD;
1385 sendToTransport = 0; 1389 sendToTransport = 0;
1386 } 1390 }
1387 break; 1391 break;
1388 1392
1389 case START_STOP: 1393 case START_STOP:
1390 US_DEBUGP(" ATA OUT - SCSIOP_START_STOP_UNIT\n"); 1394 usb_stor_dbg(us, " ATA OUT - SCSIOP_START_STOP_UNIT\n");
1391 US_DEBUGP(" srb->cmnd[4] = 0x%X\n", srb->cmnd[4]); 1395 usb_stor_dbg(us, " srb->cmnd[4] = 0x%X\n", srb->cmnd[4]);
1392 1396
1393 if ((srb->cmnd[4] & 0x3) == 0x2) { 1397 if ((srb->cmnd[4] & 0x3) == 0x2) {
1394 US_DEBUGP(" Media Eject\n"); 1398 usb_stor_dbg(us, " Media Eject\n");
1395 ataCdb->generic.SignatureByte0 = info->ConfigData.ATAMajorCommand; 1399 ataCdb->generic.SignatureByte0 = info->ConfigData.ATAMajorCommand;
1396 ataCdb->generic.SignatureByte1 = info->ConfigData.ATAMinorCommand; 1400 ataCdb->generic.SignatureByte1 = info->ConfigData.ATAMinorCommand;
1397 ataCdb->generic.TransferBlockSize = 0; 1401 ataCdb->generic.TransferBlockSize = 0;
1398 ataCdb->generic.RegisterSelect = REG_COMMAND; 1402 ataCdb->generic.RegisterSelect = REG_COMMAND;
1399 ataCdb->write.CommandByte = ATA_COMMAND_MEDIA_EJECT; 1403 ataCdb->write.CommandByte = ATA_COMMAND_MEDIA_EJECT;
1400 } else if ((srb->cmnd[4] & 0x3) == 0x1) { 1404 } else if ((srb->cmnd[4] & 0x3) == 0x1) {
1401 US_DEBUGP(" Get Media Status\n"); 1405 usb_stor_dbg(us, " Get Media Status\n");
1402 ataCdb->generic.SignatureByte0 = info->ConfigData.ATAMajorCommand; 1406 ataCdb->generic.SignatureByte0 = info->ConfigData.ATAMajorCommand;
1403 ataCdb->generic.SignatureByte1 = info->ConfigData.ATAMinorCommand; 1407 ataCdb->generic.SignatureByte1 = info->ConfigData.ATAMinorCommand;
1404 ataCdb->generic.TransferBlockSize = 1; 1408 ataCdb->generic.TransferBlockSize = 1;
@@ -1406,14 +1410,15 @@ static int isd200_scsi_to_ata(struct scsi_cmnd *srb, struct us_data *us,
1406 ataCdb->write.CommandByte = ATA_COMMAND_GET_MEDIA_STATUS; 1410 ataCdb->write.CommandByte = ATA_COMMAND_GET_MEDIA_STATUS;
1407 isd200_srb_set_bufflen(srb, 0); 1411 isd200_srb_set_bufflen(srb, 0);
1408 } else { 1412 } else {
1409 US_DEBUGP(" Nothing to do, just report okay\n"); 1413 usb_stor_dbg(us, " Nothing to do, just report okay\n");
1410 srb->result = SAM_STAT_GOOD; 1414 srb->result = SAM_STAT_GOOD;
1411 sendToTransport = 0; 1415 sendToTransport = 0;
1412 } 1416 }
1413 break; 1417 break;
1414 1418
1415 default: 1419 default:
1416 US_DEBUGP("Unsupported SCSI command - 0x%X\n", srb->cmnd[0]); 1420 usb_stor_dbg(us, "Unsupported SCSI command - 0x%X\n",
1421 srb->cmnd[0]);
1417 srb->result = DID_ERROR << 16; 1422 srb->result = DID_ERROR << 16;
1418 sendToTransport = 0; 1423 sendToTransport = 0;
1419 break; 1424 break;
@@ -1470,8 +1475,7 @@ static int isd200_init_info(struct us_data *us)
1470 if (retStatus == ISD200_GOOD) { 1475 if (retStatus == ISD200_GOOD) {
1471 us->extra = info; 1476 us->extra = info;
1472 us->extra_destructor = isd200_free_info_ptrs; 1477 us->extra_destructor = isd200_free_info_ptrs;
1473 } else 1478 }
1474 US_DEBUGP("ERROR - kmalloc failure\n");
1475 1479
1476 return retStatus; 1480 return retStatus;
1477} 1481}
@@ -1482,19 +1486,19 @@ static int isd200_init_info(struct us_data *us)
1482 1486
1483static int isd200_Initialization(struct us_data *us) 1487static int isd200_Initialization(struct us_data *us)
1484{ 1488{
1485 US_DEBUGP("ISD200 Initialization...\n"); 1489 usb_stor_dbg(us, "ISD200 Initialization...\n");
1486 1490
1487 /* Initialize ISD200 info struct */ 1491 /* Initialize ISD200 info struct */
1488 1492
1489 if (isd200_init_info(us) == ISD200_ERROR) { 1493 if (isd200_init_info(us) == ISD200_ERROR) {
1490 US_DEBUGP("ERROR Initializing ISD200 Info struct\n"); 1494 usb_stor_dbg(us, "ERROR Initializing ISD200 Info struct\n");
1491 } else { 1495 } else {
1492 /* Get device specific data */ 1496 /* Get device specific data */
1493 1497
1494 if (isd200_get_inquiry_data(us) != ISD200_GOOD) 1498 if (isd200_get_inquiry_data(us) != ISD200_GOOD)
1495 US_DEBUGP("ISD200 Initialization Failure\n"); 1499 usb_stor_dbg(us, "ISD200 Initialization Failure\n");
1496 else 1500 else
1497 US_DEBUGP("ISD200 Initialization complete\n"); 1501 usb_stor_dbg(us, "ISD200 Initialization complete\n");
1498 } 1502 }
1499 1503
1500 return 0; 1504 return 0;
@@ -1519,7 +1523,7 @@ static void isd200_ata_command(struct scsi_cmnd *srb, struct us_data *us)
1519 /* Make sure driver was initialized */ 1523 /* Make sure driver was initialized */
1520 1524
1521 if (us->extra == NULL) 1525 if (us->extra == NULL)
1522 US_DEBUGP("ERROR Driver not initialized\n"); 1526 usb_stor_dbg(us, "ERROR Driver not initialized\n");
1523 1527
1524 scsi_set_resid(srb, 0); 1528 scsi_set_resid(srb, 0);
1525 /* scsi_bufflen might change in protocol translation to ata */ 1529 /* scsi_bufflen might change in protocol translation to ata */
diff --git a/drivers/usb/storage/jumpshot.c b/drivers/usb/storage/jumpshot.c
index ddc78780b1ad..563078be6547 100644
--- a/drivers/usb/storage/jumpshot.c
+++ b/drivers/usb/storage/jumpshot.c
@@ -118,7 +118,7 @@ static inline int jumpshot_bulk_read(struct us_data *us,
118 if (len == 0) 118 if (len == 0)
119 return USB_STOR_XFER_GOOD; 119 return USB_STOR_XFER_GOOD;
120 120
121 US_DEBUGP("jumpshot_bulk_read: len = %d\n", len); 121 usb_stor_dbg(us, "len = %d\n", len);
122 return usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, 122 return usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
123 data, len, NULL); 123 data, len, NULL);
124} 124}
@@ -131,7 +131,7 @@ static inline int jumpshot_bulk_write(struct us_data *us,
131 if (len == 0) 131 if (len == 0)
132 return USB_STOR_XFER_GOOD; 132 return USB_STOR_XFER_GOOD;
133 133
134 US_DEBUGP("jumpshot_bulk_write: len = %d\n", len); 134 usb_stor_dbg(us, "len = %d\n", len);
135 return usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, 135 return usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,
136 data, len, NULL); 136 data, len, NULL);
137} 137}
@@ -152,8 +152,7 @@ static int jumpshot_get_status(struct us_data *us)
152 return USB_STOR_TRANSPORT_ERROR; 152 return USB_STOR_TRANSPORT_ERROR;
153 153
154 if (us->iobuf[0] != 0x50) { 154 if (us->iobuf[0] != 0x50) {
155 US_DEBUGP("jumpshot_get_status: 0x%2x\n", 155 usb_stor_dbg(us, "0x%2x\n", us->iobuf[0]);
156 us->iobuf[0]);
157 return USB_STOR_TRANSPORT_ERROR; 156 return USB_STOR_TRANSPORT_ERROR;
158 } 157 }
159 158
@@ -218,7 +217,7 @@ static int jumpshot_read_data(struct us_data *us,
218 if (result != USB_STOR_XFER_GOOD) 217 if (result != USB_STOR_XFER_GOOD)
219 goto leave; 218 goto leave;
220 219
221 US_DEBUGP("jumpshot_read_data: %d bytes\n", len); 220 usb_stor_dbg(us, "%d bytes\n", len);
222 221
223 // Store the data in the transfer buffer 222 // Store the data in the transfer buffer
224 usb_stor_access_xfer_buf(buffer, len, us->srb, 223 usb_stor_access_xfer_buf(buffer, len, us->srb,
@@ -314,7 +313,7 @@ static int jumpshot_write_data(struct us_data *us,
314 } while ((result != USB_STOR_TRANSPORT_GOOD) && (waitcount < 10)); 313 } while ((result != USB_STOR_TRANSPORT_GOOD) && (waitcount < 10));
315 314
316 if (result != USB_STOR_TRANSPORT_GOOD) 315 if (result != USB_STOR_TRANSPORT_GOOD)
317 US_DEBUGP("jumpshot_write_data: Gah! Waitcount = 10. Bad write!?\n"); 316 usb_stor_dbg(us, "Gah! Waitcount = 10. Bad write!?\n");
318 317
319 sector += thistime; 318 sector += thistime;
320 totallen -= len; 319 totallen -= len;
@@ -349,8 +348,7 @@ static int jumpshot_id_device(struct us_data *us,
349 0, 0x20, 0, 6, command, 2); 348 0, 0x20, 0, 6, command, 2);
350 349
351 if (rc != USB_STOR_XFER_GOOD) { 350 if (rc != USB_STOR_XFER_GOOD) {
352 US_DEBUGP("jumpshot_id_device: Gah! " 351 usb_stor_dbg(us, "Gah! send_control for read_capacity failed\n");
353 "send_control for read_capacity failed\n");
354 rc = USB_STOR_TRANSPORT_ERROR; 352 rc = USB_STOR_TRANSPORT_ERROR;
355 goto leave; 353 goto leave;
356 } 354 }
@@ -400,17 +398,17 @@ static int jumpshot_handle_mode_sense(struct us_data *us,
400 398
401 switch (pc) { 399 switch (pc) {
402 case 0x0: 400 case 0x0:
403 US_DEBUGP("jumpshot_handle_mode_sense: Current values\n"); 401 usb_stor_dbg(us, "Current values\n");
404 break; 402 break;
405 case 0x1: 403 case 0x1:
406 US_DEBUGP("jumpshot_handle_mode_sense: Changeable values\n"); 404 usb_stor_dbg(us, "Changeable values\n");
407 break; 405 break;
408 case 0x2: 406 case 0x2:
409 US_DEBUGP("jumpshot_handle_mode_sense: Default values\n"); 407 usb_stor_dbg(us, "Default values\n");
410 break; 408 break;
411 case 0x3: 409 case 0x3:
412 US_DEBUGP("jumpshot_handle_mode_sense: Saves values\n"); 410 usb_stor_dbg(us, "Saves values\n");
413 break; 411 break;
414 } 412 }
415 413
416 memset(ptr, 0, 8); 414 memset(ptr, 0, 8);
@@ -494,17 +492,16 @@ static int jumpshot_transport(struct scsi_cmnd *srb, struct us_data *us)
494 492
495 if (!us->extra) { 493 if (!us->extra) {
496 us->extra = kzalloc(sizeof(struct jumpshot_info), GFP_NOIO); 494 us->extra = kzalloc(sizeof(struct jumpshot_info), GFP_NOIO);
497 if (!us->extra) { 495 if (!us->extra)
498 US_DEBUGP("jumpshot_transport: Gah! Can't allocate storage for jumpshot info struct!\n");
499 return USB_STOR_TRANSPORT_ERROR; 496 return USB_STOR_TRANSPORT_ERROR;
500 } 497
501 us->extra_destructor = jumpshot_info_destructor; 498 us->extra_destructor = jumpshot_info_destructor;
502 } 499 }
503 500
504 info = (struct jumpshot_info *) (us->extra); 501 info = (struct jumpshot_info *) (us->extra);
505 502
506 if (srb->cmnd[0] == INQUIRY) { 503 if (srb->cmnd[0] == INQUIRY) {
507 US_DEBUGP("jumpshot_transport: INQUIRY. Returning bogus response.\n"); 504 usb_stor_dbg(us, "INQUIRY - Returning bogus response\n");
508 memcpy(ptr, inquiry_response, sizeof(inquiry_response)); 505 memcpy(ptr, inquiry_response, sizeof(inquiry_response));
509 fill_inquiry_response(us, ptr, 36); 506 fill_inquiry_response(us, ptr, 36);
510 return USB_STOR_TRANSPORT_GOOD; 507 return USB_STOR_TRANSPORT_GOOD;
@@ -521,8 +518,8 @@ static int jumpshot_transport(struct scsi_cmnd *srb, struct us_data *us)
521 if (rc != USB_STOR_TRANSPORT_GOOD) 518 if (rc != USB_STOR_TRANSPORT_GOOD)
522 return rc; 519 return rc;
523 520
524 US_DEBUGP("jumpshot_transport: READ_CAPACITY: %ld sectors, %ld bytes per sector\n", 521 usb_stor_dbg(us, "READ_CAPACITY: %ld sectors, %ld bytes per sector\n",
525 info->sectors, info->ssize); 522 info->sectors, info->ssize);
526 523
527 // build the reply 524 // build the reply
528 // 525 //
@@ -534,7 +531,7 @@ static int jumpshot_transport(struct scsi_cmnd *srb, struct us_data *us)
534 } 531 }
535 532
536 if (srb->cmnd[0] == MODE_SELECT_10) { 533 if (srb->cmnd[0] == MODE_SELECT_10) {
537 US_DEBUGP("jumpshot_transport: Gah! MODE_SELECT_10.\n"); 534 usb_stor_dbg(us, "Gah! MODE_SELECT_10\n");
538 return USB_STOR_TRANSPORT_ERROR; 535 return USB_STOR_TRANSPORT_ERROR;
539 } 536 }
540 537
@@ -544,7 +541,8 @@ static int jumpshot_transport(struct scsi_cmnd *srb, struct us_data *us)
544 541
545 blocks = ((u32)(srb->cmnd[7]) << 8) | ((u32)(srb->cmnd[8])); 542 blocks = ((u32)(srb->cmnd[7]) << 8) | ((u32)(srb->cmnd[8]));
546 543
547 US_DEBUGP("jumpshot_transport: READ_10: read block 0x%04lx count %ld\n", block, blocks); 544 usb_stor_dbg(us, "READ_10: read block 0x%04lx count %ld\n",
545 block, blocks);
548 return jumpshot_read_data(us, info, block, blocks); 546 return jumpshot_read_data(us, info, block, blocks);
549 } 547 }
550 548
@@ -557,7 +555,8 @@ static int jumpshot_transport(struct scsi_cmnd *srb, struct us_data *us)
557 blocks = ((u32)(srb->cmnd[6]) << 24) | ((u32)(srb->cmnd[7]) << 16) | 555 blocks = ((u32)(srb->cmnd[6]) << 24) | ((u32)(srb->cmnd[7]) << 16) |
558 ((u32)(srb->cmnd[8]) << 8) | ((u32)(srb->cmnd[9])); 556 ((u32)(srb->cmnd[8]) << 8) | ((u32)(srb->cmnd[9]));
559 557
560 US_DEBUGP("jumpshot_transport: READ_12: read block 0x%04lx count %ld\n", block, blocks); 558 usb_stor_dbg(us, "READ_12: read block 0x%04lx count %ld\n",
559 block, blocks);
561 return jumpshot_read_data(us, info, block, blocks); 560 return jumpshot_read_data(us, info, block, blocks);
562 } 561 }
563 562
@@ -567,7 +566,8 @@ static int jumpshot_transport(struct scsi_cmnd *srb, struct us_data *us)
567 566
568 blocks = ((u32)(srb->cmnd[7]) << 8) | ((u32)(srb->cmnd[8])); 567 blocks = ((u32)(srb->cmnd[7]) << 8) | ((u32)(srb->cmnd[8]));
569 568
570 US_DEBUGP("jumpshot_transport: WRITE_10: write block 0x%04lx count %ld\n", block, blocks); 569 usb_stor_dbg(us, "WRITE_10: write block 0x%04lx count %ld\n",
570 block, blocks);
571 return jumpshot_write_data(us, info, block, blocks); 571 return jumpshot_write_data(us, info, block, blocks);
572 } 572 }
573 573
@@ -580,18 +580,19 @@ static int jumpshot_transport(struct scsi_cmnd *srb, struct us_data *us)
580 blocks = ((u32)(srb->cmnd[6]) << 24) | ((u32)(srb->cmnd[7]) << 16) | 580 blocks = ((u32)(srb->cmnd[6]) << 24) | ((u32)(srb->cmnd[7]) << 16) |
581 ((u32)(srb->cmnd[8]) << 8) | ((u32)(srb->cmnd[9])); 581 ((u32)(srb->cmnd[8]) << 8) | ((u32)(srb->cmnd[9]));
582 582
583 US_DEBUGP("jumpshot_transport: WRITE_12: write block 0x%04lx count %ld\n", block, blocks); 583 usb_stor_dbg(us, "WRITE_12: write block 0x%04lx count %ld\n",
584 block, blocks);
584 return jumpshot_write_data(us, info, block, blocks); 585 return jumpshot_write_data(us, info, block, blocks);
585 } 586 }
586 587
587 588
588 if (srb->cmnd[0] == TEST_UNIT_READY) { 589 if (srb->cmnd[0] == TEST_UNIT_READY) {
589 US_DEBUGP("jumpshot_transport: TEST_UNIT_READY.\n"); 590 usb_stor_dbg(us, "TEST_UNIT_READY\n");
590 return jumpshot_get_status(us); 591 return jumpshot_get_status(us);
591 } 592 }
592 593
593 if (srb->cmnd[0] == REQUEST_SENSE) { 594 if (srb->cmnd[0] == REQUEST_SENSE) {
594 US_DEBUGP("jumpshot_transport: REQUEST_SENSE.\n"); 595 usb_stor_dbg(us, "REQUEST_SENSE\n");
595 596
596 memset(ptr, 0, 18); 597 memset(ptr, 0, 18);
597 ptr[0] = 0xF0; 598 ptr[0] = 0xF0;
@@ -605,12 +606,12 @@ static int jumpshot_transport(struct scsi_cmnd *srb, struct us_data *us)
605 } 606 }
606 607
607 if (srb->cmnd[0] == MODE_SENSE) { 608 if (srb->cmnd[0] == MODE_SENSE) {
608 US_DEBUGP("jumpshot_transport: MODE_SENSE_6 detected\n"); 609 usb_stor_dbg(us, "MODE_SENSE_6 detected\n");
609 return jumpshot_handle_mode_sense(us, srb, 1); 610 return jumpshot_handle_mode_sense(us, srb, 1);
610 } 611 }
611 612
612 if (srb->cmnd[0] == MODE_SENSE_10) { 613 if (srb->cmnd[0] == MODE_SENSE_10) {
613 US_DEBUGP("jumpshot_transport: MODE_SENSE_10 detected\n"); 614 usb_stor_dbg(us, "MODE_SENSE_10 detected\n");
614 return jumpshot_handle_mode_sense(us, srb, 0); 615 return jumpshot_handle_mode_sense(us, srb, 0);
615 } 616 }
616 617
@@ -624,7 +625,7 @@ static int jumpshot_transport(struct scsi_cmnd *srb, struct us_data *us)
624 if (srb->cmnd[0] == START_STOP) { 625 if (srb->cmnd[0] == START_STOP) {
625 /* this is used by sd.c'check_scsidisk_media_change to detect 626 /* this is used by sd.c'check_scsidisk_media_change to detect
626 media change */ 627 media change */
627 US_DEBUGP("jumpshot_transport: START_STOP.\n"); 628 usb_stor_dbg(us, "START_STOP\n");
628 /* the first jumpshot_id_device after a media change returns 629 /* the first jumpshot_id_device after a media change returns
629 an error (determined experimentally) */ 630 an error (determined experimentally) */
630 rc = jumpshot_id_device(us, info); 631 rc = jumpshot_id_device(us, info);
@@ -638,8 +639,8 @@ static int jumpshot_transport(struct scsi_cmnd *srb, struct us_data *us)
638 return rc; 639 return rc;
639 } 640 }
640 641
641 US_DEBUGP("jumpshot_transport: Gah! Unknown command: %d (0x%x)\n", 642 usb_stor_dbg(us, "Gah! Unknown command: %d (0x%x)\n",
642 srb->cmnd[0], srb->cmnd[0]); 643 srb->cmnd[0], srb->cmnd[0]);
643 info->sense_key = 0x05; 644 info->sense_key = 0x05;
644 info->sense_asc = 0x20; 645 info->sense_asc = 0x20;
645 info->sense_ascq = 0x00; 646 info->sense_ascq = 0x00;
diff --git a/drivers/usb/storage/karma.c b/drivers/usb/storage/karma.c
index f085ffb606c8..94d16ee5e84b 100644
--- a/drivers/usb/storage/karma.c
+++ b/drivers/usb/storage/karma.c
@@ -106,7 +106,7 @@ static int rio_karma_send_command(char cmd, struct us_data *us)
106 static unsigned char seq = 1; 106 static unsigned char seq = 1;
107 struct karma_data *data = (struct karma_data *) us->extra; 107 struct karma_data *data = (struct karma_data *) us->extra;
108 108
109 US_DEBUGP("karma: sending command %04x\n", cmd); 109 usb_stor_dbg(us, "sending command %04x\n", cmd);
110 memset(us->iobuf, 0, RIO_SEND_LEN); 110 memset(us->iobuf, 0, RIO_SEND_LEN);
111 memcpy(us->iobuf, RIO_PREFIX, RIO_PREFIX_LEN); 111 memcpy(us->iobuf, RIO_PREFIX, RIO_PREFIX_LEN);
112 us->iobuf[5] = cmd; 112 us->iobuf[5] = cmd;
@@ -139,10 +139,10 @@ static int rio_karma_send_command(char cmd, struct us_data *us)
139 if (seq == 0) 139 if (seq == 0)
140 seq = 1; 140 seq = 1;
141 141
142 US_DEBUGP("karma: sent command %04x\n", cmd); 142 usb_stor_dbg(us, "sent command %04x\n", cmd);
143 return 0; 143 return 0;
144err: 144err:
145 US_DEBUGP("karma: command %04x failed\n", cmd); 145 usb_stor_dbg(us, "command %04x failed\n", cmd);
146 return USB_STOR_TRANSPORT_FAILED; 146 return USB_STOR_TRANSPORT_FAILED;
147} 147}
148 148
diff --git a/drivers/usb/storage/option_ms.c b/drivers/usb/storage/option_ms.c
index e0f76bb05915..b2b35b1d7de8 100644
--- a/drivers/usb/storage/option_ms.c
+++ b/drivers/usb/storage/option_ms.c
@@ -50,7 +50,7 @@ static int option_rezero(struct us_data *us)
50 char *buffer; 50 char *buffer;
51 int result; 51 int result;
52 52
53 US_DEBUGP("Option MS: %s", "DEVICE MODE SWITCH\n"); 53 usb_stor_dbg(us, "Option MS: %s\n", "DEVICE MODE SWITCH");
54 54
55 buffer = kzalloc(RESPONSE_LEN, GFP_KERNEL); 55 buffer = kzalloc(RESPONSE_LEN, GFP_KERNEL);
56 if (buffer == NULL) 56 if (buffer == NULL)
@@ -95,7 +95,7 @@ static int option_inquiry(struct us_data *us)
95 char *buffer; 95 char *buffer;
96 int result; 96 int result;
97 97
98 US_DEBUGP("Option MS: %s", "device inquiry for vendor name\n"); 98 usb_stor_dbg(us, "Option MS: %s\n", "device inquiry for vendor name");
99 99
100 buffer = kzalloc(0x24, GFP_KERNEL); 100 buffer = kzalloc(0x24, GFP_KERNEL);
101 if (buffer == NULL) 101 if (buffer == NULL)
@@ -138,31 +138,32 @@ int option_ms_init(struct us_data *us)
138{ 138{
139 int result; 139 int result;
140 140
141 US_DEBUGP("Option MS: option_ms_init called\n"); 141 usb_stor_dbg(us, "Option MS: %s\n", "option_ms_init called");
142 142
143 /* Additional test for vendor information via INQUIRY, 143 /* Additional test for vendor information via INQUIRY,
144 * because some vendor/product IDs are ambiguous 144 * because some vendor/product IDs are ambiguous
145 */ 145 */
146 result = option_inquiry(us); 146 result = option_inquiry(us);
147 if (result != 0) { 147 if (result != 0) {
148 US_DEBUGP("Option MS: vendor is not Option or not determinable," 148 usb_stor_dbg(us, "Option MS: %s\n",
149 " no action taken\n"); 149 "vendor is not Option or not determinable, no action taken");
150 return 0; 150 return 0;
151 } else 151 } else
152 US_DEBUGP("Option MS: this is a genuine Option device," 152 usb_stor_dbg(us, "Option MS: %s\n",
153 " proceeding\n"); 153 "this is a genuine Option device, proceeding");
154 154
155 /* Force Modem mode */ 155 /* Force Modem mode */
156 if (option_zero_cd == ZCD_FORCE_MODEM) { 156 if (option_zero_cd == ZCD_FORCE_MODEM) {
157 US_DEBUGP("Option MS: %s", "Forcing Modem Mode\n"); 157 usb_stor_dbg(us, "Option MS: %s\n", "Forcing Modem Mode");
158 result = option_rezero(us); 158 result = option_rezero(us);
159 if (result != USB_STOR_XFER_GOOD) 159 if (result != USB_STOR_XFER_GOOD)
160 US_DEBUGP("Option MS: Failed to switch to modem mode.\n"); 160 usb_stor_dbg(us, "Option MS: %s\n",
161 "Failed to switch to modem mode");
161 return -EIO; 162 return -EIO;
162 } else if (option_zero_cd == ZCD_ALLOW_MS) { 163 } else if (option_zero_cd == ZCD_ALLOW_MS) {
163 /* Allow Mass Storage mode (keep CD-Rom) */ 164 /* Allow Mass Storage mode (keep CD-Rom) */
164 US_DEBUGP("Option MS: %s", "Allowing Mass Storage Mode if device" 165 usb_stor_dbg(us, "Option MS: %s\n",
165 " requests it\n"); 166 "Allowing Mass Storage Mode if device requests it");
166 } 167 }
167 168
168 return 0; 169 return 0;
diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c
index 6c3586a4c956..4797228747fb 100644
--- a/drivers/usb/storage/realtek_cr.c
+++ b/drivers/usb/storage/realtek_cr.c
@@ -254,8 +254,8 @@ static int rts51x_bulk_transport(struct us_data *us, u8 lun,
254 254
255 /* check bulk status */ 255 /* check bulk status */
256 if (bcs->Signature != cpu_to_le32(US_BULK_CS_SIGN)) { 256 if (bcs->Signature != cpu_to_le32(US_BULK_CS_SIGN)) {
257 US_DEBUGP("Signature mismatch: got %08X, expecting %08X\n", 257 usb_stor_dbg(us, "Signature mismatch: got %08X, expecting %08X\n",
258 le32_to_cpu(bcs->Signature), US_BULK_CS_SIGN); 258 le32_to_cpu(bcs->Signature), US_BULK_CS_SIGN);
259 return USB_STOR_TRANSPORT_ERROR; 259 return USB_STOR_TRANSPORT_ERROR;
260 } 260 }
261 261
@@ -351,8 +351,8 @@ static int rts51x_get_max_lun(struct us_data *us)
351 USB_RECIP_INTERFACE, 351 USB_RECIP_INTERFACE,
352 0, us->ifnum, us->iobuf, 1, 10 * HZ); 352 0, us->ifnum, us->iobuf, 1, 10 * HZ);
353 353
354 US_DEBUGP("GetMaxLUN command result is %d, data is %d\n", 354 usb_stor_dbg(us, "GetMaxLUN command result is %d, data is %d\n",
355 result, us->iobuf[0]); 355 result, us->iobuf[0]);
356 356
357 /* if we have a successful request, return the result */ 357 /* if we have a successful request, return the result */
358 if (result > 0) 358 if (result > 0)
@@ -371,7 +371,7 @@ static int rts51x_read_mem(struct us_data *us, u16 addr, u8 *data, u16 len)
371 if (buf == NULL) 371 if (buf == NULL)
372 return USB_STOR_TRANSPORT_ERROR; 372 return USB_STOR_TRANSPORT_ERROR;
373 373
374 US_DEBUGP("%s, addr = 0x%x, len = %d\n", __func__, addr, len); 374 usb_stor_dbg(us, "addr = 0x%x, len = %d\n", addr, len);
375 375
376 cmnd[0] = 0xF0; 376 cmnd[0] = 0xF0;
377 cmnd[1] = 0x0D; 377 cmnd[1] = 0x0D;
@@ -402,7 +402,7 @@ static int rts51x_write_mem(struct us_data *us, u16 addr, u8 *data, u16 len)
402 if (buf == NULL) 402 if (buf == NULL)
403 return USB_STOR_TRANSPORT_ERROR; 403 return USB_STOR_TRANSPORT_ERROR;
404 404
405 US_DEBUGP("%s, addr = 0x%x, len = %d\n", __func__, addr, len); 405 usb_stor_dbg(us, "addr = 0x%x, len = %d\n", addr, len);
406 406
407 cmnd[0] = 0xF0; 407 cmnd[0] = 0xF0;
408 cmnd[1] = 0x0E; 408 cmnd[1] = 0x0E;
@@ -431,7 +431,7 @@ static int rts51x_read_status(struct us_data *us,
431 if (buf == NULL) 431 if (buf == NULL)
432 return USB_STOR_TRANSPORT_ERROR; 432 return USB_STOR_TRANSPORT_ERROR;
433 433
434 US_DEBUGP("%s, lun = %d\n", __func__, lun); 434 usb_stor_dbg(us, "lun = %d\n", lun);
435 435
436 cmnd[0] = 0xF0; 436 cmnd[0] = 0xF0;
437 cmnd[1] = 0x09; 437 cmnd[1] = 0x09;
@@ -458,7 +458,7 @@ static int rts51x_check_status(struct us_data *us, u8 lun)
458 if (retval != STATUS_SUCCESS) 458 if (retval != STATUS_SUCCESS)
459 return -EIO; 459 return -EIO;
460 460
461 US_DEBUGP("chip->status_len = %d\n", chip->status_len); 461 usb_stor_dbg(us, "chip->status_len = %d\n", chip->status_len);
462 462
463 chip->status[lun].vid = ((u16) buf[0] << 8) | buf[1]; 463 chip->status[lun].vid = ((u16) buf[0] << 8) | buf[1];
464 chip->status[lun].pid = ((u16) buf[2] << 8) | buf[3]; 464 chip->status[lun].pid = ((u16) buf[2] << 8) | buf[3];
@@ -509,7 +509,7 @@ static int __do_config_autodelink(struct us_data *us, u8 *data, u16 len)
509 u8 cmnd[12] = {0}; 509 u8 cmnd[12] = {0};
510 u8 *buf; 510 u8 *buf;
511 511
512 US_DEBUGP("%s, addr = 0xfe47, len = %d\n", __FUNCTION__, len); 512 usb_stor_dbg(us, "addr = 0xfe47, len = %d\n", len);
513 513
514 buf = kmemdup(data, len, GFP_NOIO); 514 buf = kmemdup(data, len, GFP_NOIO);
515 if (!buf) 515 if (!buf)
@@ -549,7 +549,7 @@ static int do_config_autodelink(struct us_data *us, int enable, int force)
549 value &= ~0x03; 549 value &= ~0x03;
550 } 550 }
551 551
552 US_DEBUGP("In %s,set 0xfe47 to 0x%x\n", __func__, value); 552 usb_stor_dbg(us, "set 0xfe47 to 0x%x\n", value);
553 553
554 /* retval = rts51x_write_mem(us, 0xFE47, &value, 1); */ 554 /* retval = rts51x_write_mem(us, 0xFE47, &value, 1); */
555 retval = __do_config_autodelink(us, &value, 1); 555 retval = __do_config_autodelink(us, &value, 1);
@@ -565,8 +565,6 @@ static int config_autodelink_after_power_on(struct us_data *us)
565 int retval; 565 int retval;
566 u8 value; 566 u8 value;
567 567
568 US_DEBUGP("%s: <---\n", __func__);
569
570 if (!CHK_AUTO_DELINK(chip)) 568 if (!CHK_AUTO_DELINK(chip))
571 return 0; 569 return 0;
572 570
@@ -624,8 +622,6 @@ static int config_autodelink_after_power_on(struct us_data *us)
624 } 622 }
625 } 623 }
626 624
627 US_DEBUGP("%s: --->\n", __func__);
628
629 return 0; 625 return 0;
630} 626}
631 627
@@ -635,8 +631,6 @@ static int config_autodelink_before_power_down(struct us_data *us)
635 int retval; 631 int retval;
636 u8 value; 632 u8 value;
637 633
638 US_DEBUGP("%s: <---\n", __func__);
639
640 if (!CHK_AUTO_DELINK(chip)) 634 if (!CHK_AUTO_DELINK(chip))
641 return 0; 635 return 0;
642 636
@@ -698,8 +692,6 @@ static int config_autodelink_before_power_down(struct us_data *us)
698 } 692 }
699 } 693 }
700 694
701 US_DEBUGP("%s: --->\n", __func__);
702
703 return 0; 695 return 0;
704} 696}
705 697
@@ -709,23 +701,19 @@ static void fw5895_init(struct us_data *us)
709 int retval; 701 int retval;
710 u8 val; 702 u8 val;
711 703
712 US_DEBUGP("%s: <---\n", __func__);
713
714 if ((PRODUCT_ID(chip) != 0x0158) || (FW_VERSION(chip) != 0x5895)) { 704 if ((PRODUCT_ID(chip) != 0x0158) || (FW_VERSION(chip) != 0x5895)) {
715 US_DEBUGP("Not the specified device, return immediately!\n"); 705 usb_stor_dbg(us, "Not the specified device, return immediately!\n");
716 } else { 706 } else {
717 retval = rts51x_read_mem(us, 0xFD6F, &val, 1); 707 retval = rts51x_read_mem(us, 0xFD6F, &val, 1);
718 if (retval == STATUS_SUCCESS && (val & 0x1F) == 0) { 708 if (retval == STATUS_SUCCESS && (val & 0x1F) == 0) {
719 val = 0x1F; 709 val = 0x1F;
720 retval = rts51x_write_mem(us, 0xFD70, &val, 1); 710 retval = rts51x_write_mem(us, 0xFD70, &val, 1);
721 if (retval != STATUS_SUCCESS) 711 if (retval != STATUS_SUCCESS)
722 US_DEBUGP("Write memory fail\n"); 712 usb_stor_dbg(us, "Write memory fail\n");
723 } else { 713 } else {
724 US_DEBUGP("Read memory fail, OR (val & 0x1F) != 0\n"); 714 usb_stor_dbg(us, "Read memory fail, OR (val & 0x1F) != 0\n");
725 } 715 }
726 } 716 }
727
728 US_DEBUGP("%s: --->\n", __func__);
729} 717}
730 718
731#ifdef CONFIG_REALTEK_AUTOPM 719#ifdef CONFIG_REALTEK_AUTOPM
@@ -735,10 +723,8 @@ static void fw5895_set_mmc_wp(struct us_data *us)
735 int retval; 723 int retval;
736 u8 buf[13]; 724 u8 buf[13];
737 725
738 US_DEBUGP("%s: <---\n", __func__);
739
740 if ((PRODUCT_ID(chip) != 0x0158) || (FW_VERSION(chip) != 0x5895)) { 726 if ((PRODUCT_ID(chip) != 0x0158) || (FW_VERSION(chip) != 0x5895)) {
741 US_DEBUGP("Not the specified device, return immediately!\n"); 727 usb_stor_dbg(us, "Not the specified device, return immediately!\n");
742 } else { 728 } else {
743 retval = rts51x_read_mem(us, 0xFD6F, buf, 1); 729 retval = rts51x_read_mem(us, 0xFD6F, buf, 1);
744 if (retval == STATUS_SUCCESS && (buf[0] & 0x24) == 0x24) { 730 if (retval == STATUS_SUCCESS && (buf[0] & 0x24) == 0x24) {
@@ -748,26 +734,24 @@ static void fw5895_set_mmc_wp(struct us_data *us)
748 buf[0] |= 0x04; 734 buf[0] |= 0x04;
749 retval = rts51x_write_mem(us, 0xFD70, buf, 1); 735 retval = rts51x_write_mem(us, 0xFD70, buf, 1);
750 if (retval != STATUS_SUCCESS) 736 if (retval != STATUS_SUCCESS)
751 US_DEBUGP("Write memory fail\n"); 737 usb_stor_dbg(us, "Write memory fail\n");
752 } else { 738 } else {
753 US_DEBUGP("Read memory fail\n"); 739 usb_stor_dbg(us, "Read memory fail\n");
754 } 740 }
755 } else { 741 } else {
756 US_DEBUGP("Read memory fail, OR (buf[0]&0x24)!=0x24\n"); 742 usb_stor_dbg(us, "Read memory fail, OR (buf[0]&0x24)!=0x24\n");
757 } 743 }
758 } 744 }
759
760 US_DEBUGP("%s: --->\n", __func__);
761} 745}
762 746
763static void rts51x_modi_suspend_timer(struct rts51x_chip *chip) 747static void rts51x_modi_suspend_timer(struct rts51x_chip *chip)
764{ 748{
765 US_DEBUGP("%s: <---, state:%d\n", __func__, rts51x_get_stat(chip)); 749 struct us_data *us = chip->us;
750
751 usb_stor_dbg(us, "state:%d\n", rts51x_get_stat(chip));
766 752
767 chip->timer_expires = jiffies + msecs_to_jiffies(1000*ss_delay); 753 chip->timer_expires = jiffies + msecs_to_jiffies(1000*ss_delay);
768 mod_timer(&chip->rts51x_suspend_timer, chip->timer_expires); 754 mod_timer(&chip->rts51x_suspend_timer, chip->timer_expires);
769
770 US_DEBUGP("%s: --->\n", __func__);
771} 755}
772 756
773static void rts51x_suspend_timer_fn(unsigned long data) 757static void rts51x_suspend_timer_fn(unsigned long data)
@@ -775,8 +759,6 @@ static void rts51x_suspend_timer_fn(unsigned long data)
775 struct rts51x_chip *chip = (struct rts51x_chip *)data; 759 struct rts51x_chip *chip = (struct rts51x_chip *)data;
776 struct us_data *us = chip->us; 760 struct us_data *us = chip->us;
777 761
778 US_DEBUGP("%s: <---\n", __func__);
779
780 switch (rts51x_get_stat(chip)) { 762 switch (rts51x_get_stat(chip)) {
781 case RTS51X_STAT_INIT: 763 case RTS51X_STAT_INIT:
782 case RTS51X_STAT_RUN: 764 case RTS51X_STAT_RUN:
@@ -784,32 +766,25 @@ static void rts51x_suspend_timer_fn(unsigned long data)
784 break; 766 break;
785 case RTS51X_STAT_IDLE: 767 case RTS51X_STAT_IDLE:
786 case RTS51X_STAT_SS: 768 case RTS51X_STAT_SS:
787 US_DEBUGP("%s: RTS51X_STAT_SS, intf->pm_usage_cnt:%d," 769 usb_stor_dbg(us, "RTS51X_STAT_SS, intf->pm_usage_cnt:%d, power.usage:%d\n",
788 "power.usage:%d\n", __func__, 770 atomic_read(&us->pusb_intf->pm_usage_cnt),
789 atomic_read(&us->pusb_intf->pm_usage_cnt), 771 atomic_read(&us->pusb_intf->dev.power.usage_count));
790 atomic_read(&us->pusb_intf->dev.power.usage_count));
791 772
792 if (atomic_read(&us->pusb_intf->pm_usage_cnt) > 0) { 773 if (atomic_read(&us->pusb_intf->pm_usage_cnt) > 0) {
793 US_DEBUGP("%s: Ready to enter SS state.\n", 774 usb_stor_dbg(us, "Ready to enter SS state\n");
794 __func__);
795 rts51x_set_stat(chip, RTS51X_STAT_SS); 775 rts51x_set_stat(chip, RTS51X_STAT_SS);
796 /* ignore mass storage interface's children */ 776 /* ignore mass storage interface's children */
797 pm_suspend_ignore_children(&us->pusb_intf->dev, true); 777 pm_suspend_ignore_children(&us->pusb_intf->dev, true);
798 usb_autopm_put_interface_async(us->pusb_intf); 778 usb_autopm_put_interface_async(us->pusb_intf);
799 US_DEBUGP("%s: RTS51X_STAT_SS 01," 779 usb_stor_dbg(us, "RTS51X_STAT_SS 01, intf->pm_usage_cnt:%d, power.usage:%d\n",
800 "intf->pm_usage_cnt:%d, power.usage:%d\n", 780 atomic_read(&us->pusb_intf->pm_usage_cnt),
801 __func__, 781 atomic_read(&us->pusb_intf->dev.power.usage_count));
802 atomic_read(&us->pusb_intf->pm_usage_cnt),
803 atomic_read(
804 &us->pusb_intf->dev.power.usage_count));
805 } 782 }
806 break; 783 break;
807 default: 784 default:
808 US_DEBUGP("%s: Unknonwn state !!!\n", __func__); 785 usb_stor_dbg(us, "Unknown state !!!\n");
809 break; 786 break;
810 } 787 }
811
812 US_DEBUGP("%s: --->\n", __func__);
813} 788}
814 789
815static inline int working_scsi(struct scsi_cmnd *srb) 790static inline int working_scsi(struct scsi_cmnd *srb)
@@ -834,24 +809,21 @@ static void rts51x_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
834 }; 809 };
835 int ret; 810 int ret;
836 811
837 US_DEBUGP("%s: <---\n", __func__);
838
839 if (working_scsi(srb)) { 812 if (working_scsi(srb)) {
840 US_DEBUGP("%s: working scsi, intf->pm_usage_cnt:%d," 813 usb_stor_dbg(us, "working scsi, intf->pm_usage_cnt:%d, power.usage:%d\n",
841 "power.usage:%d\n", __func__, 814 atomic_read(&us->pusb_intf->pm_usage_cnt),
842 atomic_read(&us->pusb_intf->pm_usage_cnt), 815 atomic_read(&us->pusb_intf->dev.power.usage_count));
843 atomic_read(&us->pusb_intf->dev.power.usage_count));
844 816
845 if (atomic_read(&us->pusb_intf->pm_usage_cnt) <= 0) { 817 if (atomic_read(&us->pusb_intf->pm_usage_cnt) <= 0) {
846 ret = usb_autopm_get_interface(us->pusb_intf); 818 ret = usb_autopm_get_interface(us->pusb_intf);
847 US_DEBUGP("%s: working scsi, ret=%d\n", __func__, ret); 819 usb_stor_dbg(us, "working scsi, ret=%d\n", ret);
848 } 820 }
849 if (rts51x_get_stat(chip) != RTS51X_STAT_RUN) 821 if (rts51x_get_stat(chip) != RTS51X_STAT_RUN)
850 rts51x_set_stat(chip, RTS51X_STAT_RUN); 822 rts51x_set_stat(chip, RTS51X_STAT_RUN);
851 chip->proto_handler_backup(srb, us); 823 chip->proto_handler_backup(srb, us);
852 } else { 824 } else {
853 if (rts51x_get_stat(chip) == RTS51X_STAT_SS) { 825 if (rts51x_get_stat(chip) == RTS51X_STAT_SS) {
854 US_DEBUGP("%s: NOT working scsi\n", __func__); 826 usb_stor_dbg(us, "NOT working scsi\n");
855 if ((srb->cmnd[0] == TEST_UNIT_READY) && 827 if ((srb->cmnd[0] == TEST_UNIT_READY) &&
856 (chip->pwr_state == US_SUSPEND)) { 828 (chip->pwr_state == US_SUSPEND)) {
857 if (TST_LUN_READY(chip, srb->device->lun)) { 829 if (TST_LUN_READY(chip, srb->device->lun)) {
@@ -862,8 +834,7 @@ static void rts51x_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
862 media_not_present, 834 media_not_present,
863 US_SENSE_SIZE); 835 US_SENSE_SIZE);
864 } 836 }
865 US_DEBUGP("%s: TEST_UNIT_READY--->\n", 837 usb_stor_dbg(us, "TEST_UNIT_READY\n");
866 __func__);
867 goto out; 838 goto out;
868 } 839 }
869 if (srb->cmnd[0] == ALLOW_MEDIUM_REMOVAL) { 840 if (srb->cmnd[0] == ALLOW_MEDIUM_REMOVAL) {
@@ -876,12 +847,11 @@ static void rts51x_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
876 } else { 847 } else {
877 srb->result = SAM_STAT_GOOD; 848 srb->result = SAM_STAT_GOOD;
878 } 849 }
879 US_DEBUGP("%s: ALLOW_MEDIUM_REMOVAL--->\n", 850 usb_stor_dbg(us, "ALLOW_MEDIUM_REMOVAL\n");
880 __func__);
881 goto out; 851 goto out;
882 } 852 }
883 } else { 853 } else {
884 US_DEBUGP("%s: NOT working scsi, not SS\n", __func__); 854 usb_stor_dbg(us, "NOT working scsi, not SS\n");
885 chip->proto_handler_backup(srb, us); 855 chip->proto_handler_backup(srb, us);
886 /* Check whether card is plugged in */ 856 /* Check whether card is plugged in */
887 if (srb->cmnd[0] == TEST_UNIT_READY) { 857 if (srb->cmnd[0] == TEST_UNIT_READY) {
@@ -901,11 +871,9 @@ static void rts51x_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
901 } 871 }
902 } 872 }
903out: 873out:
904 US_DEBUGP("%s: state:%d\n", __func__, rts51x_get_stat(chip)); 874 usb_stor_dbg(us, "state:%d\n", rts51x_get_stat(chip));
905 if (rts51x_get_stat(chip) == RTS51X_STAT_RUN) 875 if (rts51x_get_stat(chip) == RTS51X_STAT_RUN)
906 rts51x_modi_suspend_timer(chip); 876 rts51x_modi_suspend_timer(chip);
907
908 US_DEBUGP("%s: --->\n", __func__);
909} 877}
910 878
911static int realtek_cr_autosuspend_setup(struct us_data *us) 879static int realtek_cr_autosuspend_setup(struct us_data *us)
@@ -923,7 +891,7 @@ static int realtek_cr_autosuspend_setup(struct us_data *us)
923 891
924 retval = rts51x_read_status(us, 0, buf, 16, &(chip->status_len)); 892 retval = rts51x_read_status(us, 0, buf, 16, &(chip->status_len));
925 if (retval != STATUS_SUCCESS) { 893 if (retval != STATUS_SUCCESS) {
926 US_DEBUGP("Read status fail\n"); 894 usb_stor_dbg(us, "Read status fail\n");
927 return -EIO; 895 return -EIO;
928 } 896 }
929 status = chip->status; 897 status = chip->status;
@@ -966,11 +934,13 @@ static int realtek_cr_autosuspend_setup(struct us_data *us)
966static void realtek_cr_destructor(void *extra) 934static void realtek_cr_destructor(void *extra)
967{ 935{
968 struct rts51x_chip *chip = (struct rts51x_chip *)extra; 936 struct rts51x_chip *chip = (struct rts51x_chip *)extra;
969 937 struct us_data *us;
970 US_DEBUGP("%s: <---\n", __func__);
971 938
972 if (!chip) 939 if (!chip)
973 return; 940 return;
941
942 us = chip->us;
943
974#ifdef CONFIG_REALTEK_AUTOPM 944#ifdef CONFIG_REALTEK_AUTOPM
975 if (ss_en) { 945 if (ss_en) {
976 del_timer(&chip->rts51x_suspend_timer); 946 del_timer(&chip->rts51x_suspend_timer);
@@ -985,8 +955,6 @@ static int realtek_cr_suspend(struct usb_interface *iface, pm_message_t message)
985{ 955{
986 struct us_data *us = usb_get_intfdata(iface); 956 struct us_data *us = usb_get_intfdata(iface);
987 957
988 US_DEBUGP("%s: <---\n", __func__);
989
990 /* wait until no command is running */ 958 /* wait until no command is running */
991 mutex_lock(&us->dev_mutex); 959 mutex_lock(&us->dev_mutex);
992 960
@@ -994,8 +962,6 @@ static int realtek_cr_suspend(struct usb_interface *iface, pm_message_t message)
994 962
995 mutex_unlock(&us->dev_mutex); 963 mutex_unlock(&us->dev_mutex);
996 964
997 US_DEBUGP("%s: --->\n", __func__);
998
999 return 0; 965 return 0;
1000} 966}
1001 967
@@ -1003,13 +969,9 @@ static int realtek_cr_resume(struct usb_interface *iface)
1003{ 969{
1004 struct us_data *us = usb_get_intfdata(iface); 970 struct us_data *us = usb_get_intfdata(iface);
1005 971
1006 US_DEBUGP("%s: <---\n", __func__);
1007
1008 fw5895_init(us); 972 fw5895_init(us);
1009 config_autodelink_after_power_on(us); 973 config_autodelink_after_power_on(us);
1010 974
1011 US_DEBUGP("%s: --->\n", __func__);
1012
1013 return 0; 975 return 0;
1014} 976}
1015#else 977#else
@@ -1030,7 +992,7 @@ static int init_realtek_cr(struct us_data *us)
1030 us->extra_destructor = realtek_cr_destructor; 992 us->extra_destructor = realtek_cr_destructor;
1031 us->max_lun = chip->max_lun = rts51x_get_max_lun(us); 993 us->max_lun = chip->max_lun = rts51x_get_max_lun(us);
1032 994
1033 US_DEBUGP("chip->max_lun = %d\n", chip->max_lun); 995 usb_stor_dbg(us, "chip->max_lun = %d\n", chip->max_lun);
1034 996
1035 size = (chip->max_lun + 1) * sizeof(struct rts51x_status); 997 size = (chip->max_lun + 1) * sizeof(struct rts51x_status);
1036 chip->status = kzalloc(size, GFP_KERNEL); 998 chip->status = kzalloc(size, GFP_KERNEL);
@@ -1057,7 +1019,7 @@ static int init_realtek_cr(struct us_data *us)
1057 } 1019 }
1058#endif 1020#endif
1059 1021
1060 US_DEBUGP("chip->flag = 0x%x\n", chip->flag); 1022 usb_stor_dbg(us, "chip->flag = 0x%x\n", chip->flag);
1061 1023
1062 (void)config_autodelink_after_power_on(us); 1024 (void)config_autodelink_after_power_on(us);
1063 1025
@@ -1079,7 +1041,7 @@ static int realtek_cr_probe(struct usb_interface *intf,
1079 struct us_data *us; 1041 struct us_data *us;
1080 int result; 1042 int result;
1081 1043
1082 US_DEBUGP("Probe Realtek Card Reader!\n"); 1044 dev_dbg(&intf->dev, "Probe Realtek Card Reader!\n");
1083 1045
1084 result = usb_stor_probe1(&us, intf, id, 1046 result = usb_stor_probe1(&us, intf, id,
1085 (id - realtek_cr_ids) + 1047 (id - realtek_cr_ids) +
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index 92f35abee92d..4faa982807f2 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -313,8 +313,6 @@ static int queuecommand_lck(struct scsi_cmnd *srb,
313{ 313{
314 struct us_data *us = host_to_us(srb->device->host); 314 struct us_data *us = host_to_us(srb->device->host);
315 315
316 US_DEBUGP("%s called\n", __func__);
317
318 /* check for state-transition errors */ 316 /* check for state-transition errors */
319 if (us->srb != NULL) { 317 if (us->srb != NULL) {
320 printk(KERN_ERR USB_STORAGE "Error in %s: us->srb = %p\n", 318 printk(KERN_ERR USB_STORAGE "Error in %s: us->srb = %p\n",
@@ -324,7 +322,7 @@ static int queuecommand_lck(struct scsi_cmnd *srb,
324 322
325 /* fail the command if we are disconnecting */ 323 /* fail the command if we are disconnecting */
326 if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) { 324 if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) {
327 US_DEBUGP("Fail command during disconnect\n"); 325 usb_stor_dbg(us, "Fail command during disconnect\n");
328 srb->result = DID_NO_CONNECT << 16; 326 srb->result = DID_NO_CONNECT << 16;
329 done(srb); 327 done(srb);
330 return 0; 328 return 0;
@@ -349,7 +347,7 @@ static int command_abort(struct scsi_cmnd *srb)
349{ 347{
350 struct us_data *us = host_to_us(srb->device->host); 348 struct us_data *us = host_to_us(srb->device->host);
351 349
352 US_DEBUGP("%s called\n", __func__); 350 usb_stor_dbg(us, "%s called\n", __func__);
353 351
354 /* us->srb together with the TIMED_OUT, RESETTING, and ABORTING 352 /* us->srb together with the TIMED_OUT, RESETTING, and ABORTING
355 * bits are protected by the host lock. */ 353 * bits are protected by the host lock. */
@@ -358,7 +356,7 @@ static int command_abort(struct scsi_cmnd *srb)
358 /* Is this command still active? */ 356 /* Is this command still active? */
359 if (us->srb != srb) { 357 if (us->srb != srb) {
360 scsi_unlock(us_to_host(us)); 358 scsi_unlock(us_to_host(us));
361 US_DEBUGP ("-- nothing to abort\n"); 359 usb_stor_dbg(us, "-- nothing to abort\n");
362 return FAILED; 360 return FAILED;
363 } 361 }
364 362
@@ -386,7 +384,7 @@ static int device_reset(struct scsi_cmnd *srb)
386 struct us_data *us = host_to_us(srb->device->host); 384 struct us_data *us = host_to_us(srb->device->host);
387 int result; 385 int result;
388 386
389 US_DEBUGP("%s called\n", __func__); 387 usb_stor_dbg(us, "%s called\n", __func__);
390 388
391 /* lock the device pointers and do the reset */ 389 /* lock the device pointers and do the reset */
392 mutex_lock(&(us->dev_mutex)); 390 mutex_lock(&(us->dev_mutex));
@@ -402,7 +400,8 @@ static int bus_reset(struct scsi_cmnd *srb)
402 struct us_data *us = host_to_us(srb->device->host); 400 struct us_data *us = host_to_us(srb->device->host);
403 int result; 401 int result;
404 402
405 US_DEBUGP("%s called\n", __func__); 403 usb_stor_dbg(us, "%s called\n", __func__);
404
406 result = usb_stor_port_reset(us); 405 result = usb_stor_port_reset(us);
407 return result < 0 ? FAILED : SUCCESS; 406 return result < 0 ? FAILED : SUCCESS;
408} 407}
diff --git a/drivers/usb/storage/sddr09.c b/drivers/usb/storage/sddr09.c
index 7bd54e0d5120..732027f33200 100644
--- a/drivers/usb/storage/sddr09.c
+++ b/drivers/usb/storage/sddr09.c
@@ -105,8 +105,6 @@ static struct us_unusual_dev sddr09_unusual_dev_list[] = {
105#define LSB_of(s) ((s)&0xFF) 105#define LSB_of(s) ((s)&0xFF)
106#define MSB_of(s) ((s)>>8) 106#define MSB_of(s) ((s)>>8)
107 107
108/* #define US_DEBUGP printk */
109
110/* 108/*
111 * First some stuff that does not belong here: 109 * First some stuff that does not belong here:
112 * data on SmartMedia and other cards, completely 110 * data on SmartMedia and other cards, completely
@@ -347,7 +345,7 @@ sddr09_test_unit_ready(struct us_data *us) {
347 345
348 result = sddr09_send_scsi_command(us, command, 6); 346 result = sddr09_send_scsi_command(us, command, 6);
349 347
350 US_DEBUGP("sddr09_test_unit_ready returns %d\n", result); 348 usb_stor_dbg(us, "sddr09_test_unit_ready returns %d\n", result);
351 349
352 return result; 350 return result;
353} 351}
@@ -423,8 +421,8 @@ sddr09_readX(struct us_data *us, int x, unsigned long fromaddress,
423 result = sddr09_send_scsi_command(us, command, 12); 421 result = sddr09_send_scsi_command(us, command, 12);
424 422
425 if (result) { 423 if (result) {
426 US_DEBUGP("Result for send_control in sddr09_read2%d %d\n", 424 usb_stor_dbg(us, "Result for send_control in sddr09_read2%d %d\n",
427 x, result); 425 x, result);
428 return result; 426 return result;
429 } 427 }
430 428
@@ -432,8 +430,8 @@ sddr09_readX(struct us_data *us, int x, unsigned long fromaddress,
432 buf, bulklen, use_sg, NULL); 430 buf, bulklen, use_sg, NULL);
433 431
434 if (result != USB_STOR_XFER_GOOD) { 432 if (result != USB_STOR_XFER_GOOD) {
435 US_DEBUGP("Result for bulk_transfer in sddr09_read2%d %d\n", 433 usb_stor_dbg(us, "Result for bulk_transfer in sddr09_read2%d %d\n",
436 x, result); 434 x, result);
437 return -EIO; 435 return -EIO;
438 } 436 }
439 return 0; 437 return 0;
@@ -494,8 +492,7 @@ sddr09_read22(struct us_data *us, unsigned long fromaddress,
494 int nr_of_pages, int pageshift, unsigned char *buf, int use_sg) { 492 int nr_of_pages, int pageshift, unsigned char *buf, int use_sg) {
495 493
496 int bulklen = (nr_of_pages << pageshift) + (nr_of_pages << CONTROL_SHIFT); 494 int bulklen = (nr_of_pages << pageshift) + (nr_of_pages << CONTROL_SHIFT);
497 US_DEBUGP("sddr09_read22: reading %d pages, %d bytes\n", 495 usb_stor_dbg(us, "reading %d pages, %d bytes\n", nr_of_pages, bulklen);
498 nr_of_pages, bulklen);
499 return sddr09_readX(us, 2, fromaddress, nr_of_pages, bulklen, 496 return sddr09_readX(us, 2, fromaddress, nr_of_pages, bulklen,
500 buf, use_sg); 497 buf, use_sg);
501} 498}
@@ -538,7 +535,7 @@ sddr09_erase(struct us_data *us, unsigned long Eaddress) {
538 unsigned char *command = us->iobuf; 535 unsigned char *command = us->iobuf;
539 int result; 536 int result;
540 537
541 US_DEBUGP("sddr09_erase: erase address %lu\n", Eaddress); 538 usb_stor_dbg(us, "erase address %lu\n", Eaddress);
542 539
543 memset(command, 0, 12); 540 memset(command, 0, 12);
544 command[0] = 0xEA; 541 command[0] = 0xEA;
@@ -551,8 +548,8 @@ sddr09_erase(struct us_data *us, unsigned long Eaddress) {
551 result = sddr09_send_scsi_command(us, command, 12); 548 result = sddr09_send_scsi_command(us, command, 12);
552 549
553 if (result) 550 if (result)
554 US_DEBUGP("Result for send_control in sddr09_erase %d\n", 551 usb_stor_dbg(us, "Result for send_control in sddr09_erase %d\n",
555 result); 552 result);
556 553
557 return result; 554 return result;
558} 555}
@@ -609,8 +606,8 @@ sddr09_writeX(struct us_data *us,
609 result = sddr09_send_scsi_command(us, command, 12); 606 result = sddr09_send_scsi_command(us, command, 12);
610 607
611 if (result) { 608 if (result) {
612 US_DEBUGP("Result for send_control in sddr09_writeX %d\n", 609 usb_stor_dbg(us, "Result for send_control in sddr09_writeX %d\n",
613 result); 610 result);
614 return result; 611 return result;
615 } 612 }
616 613
@@ -618,8 +615,8 @@ sddr09_writeX(struct us_data *us,
618 buf, bulklen, use_sg, NULL); 615 buf, bulklen, use_sg, NULL);
619 616
620 if (result != USB_STOR_XFER_GOOD) { 617 if (result != USB_STOR_XFER_GOOD) {
621 US_DEBUGP("Result for bulk_transfer in sddr09_writeX %d\n", 618 usb_stor_dbg(us, "Result for bulk_transfer in sddr09_writeX %d\n",
622 result); 619 result);
623 return -EIO; 620 return -EIO;
624 } 621 }
625 return 0; 622 return 0;
@@ -687,8 +684,8 @@ sddr09_read_sg_test_only(struct us_data *us) {
687 result = sddr09_send_scsi_command(us, command, 4*nsg+3); 684 result = sddr09_send_scsi_command(us, command, 4*nsg+3);
688 685
689 if (result) { 686 if (result) {
690 US_DEBUGP("Result for send_control in sddr09_read_sg %d\n", 687 usb_stor_dbg(us, "Result for send_control in sddr09_read_sg %d\n",
691 result); 688 result);
692 return result; 689 return result;
693 } 690 }
694 691
@@ -700,8 +697,8 @@ sddr09_read_sg_test_only(struct us_data *us) {
700 buf, bulklen, NULL); 697 buf, bulklen, NULL);
701 kfree(buf); 698 kfree(buf);
702 if (result != USB_STOR_XFER_GOOD) { 699 if (result != USB_STOR_XFER_GOOD) {
703 US_DEBUGP("Result for bulk_transfer in sddr09_read_sg %d\n", 700 usb_stor_dbg(us, "Result for bulk_transfer in sddr09_read_sg %d\n",
704 result); 701 result);
705 return -EIO; 702 return -EIO;
706 } 703 }
707 704
@@ -727,7 +724,7 @@ sddr09_read_status(struct us_data *us, unsigned char *status) {
727 unsigned char *data = us->iobuf; 724 unsigned char *data = us->iobuf;
728 int result; 725 int result;
729 726
730 US_DEBUGP("Reading status...\n"); 727 usb_stor_dbg(us, "Reading status...\n");
731 728
732 memset(command, 0, 12); 729 memset(command, 0, 12);
733 command[0] = 0xEC; 730 command[0] = 0xEC;
@@ -789,8 +786,8 @@ sddr09_read_data(struct us_data *us,
789 786
790 /* Not overflowing capacity? */ 787 /* Not overflowing capacity? */
791 if (lba >= maxlba) { 788 if (lba >= maxlba) {
792 US_DEBUGP("Error: Requested lba %u exceeds " 789 usb_stor_dbg(us, "Error: Requested lba %u exceeds maximum %u\n",
793 "maximum %u\n", lba, maxlba); 790 lba, maxlba);
794 result = -EIO; 791 result = -EIO;
795 break; 792 break;
796 } 793 }
@@ -800,8 +797,8 @@ sddr09_read_data(struct us_data *us,
800 797
801 if (pba == UNDEF) { /* this lba was never written */ 798 if (pba == UNDEF) { /* this lba was never written */
802 799
803 US_DEBUGP("Read %d zero pages (LBA %d) page %d\n", 800 usb_stor_dbg(us, "Read %d zero pages (LBA %d) page %d\n",
804 pages, lba, page); 801 pages, lba, page);
805 802
806 /* This is not really an error. It just means 803 /* This is not really an error. It just means
807 that the block has never been written. 804 that the block has never been written.
@@ -811,9 +808,8 @@ sddr09_read_data(struct us_data *us,
811 memset(buffer, 0, len); 808 memset(buffer, 0, len);
812 809
813 } else { 810 } else {
814 US_DEBUGP("Read %d pages, from PBA %d" 811 usb_stor_dbg(us, "Read %d pages, from PBA %d (LBA %d) page %d\n",
815 " (LBA %d) page %d\n", 812 pages, pba, lba, page);
816 pages, pba, lba, page);
817 813
818 address = ((pba << info->blockshift) + page) << 814 address = ((pba << info->blockshift) + page) <<
819 info->pageshift; 815 info->pageshift;
@@ -916,14 +912,14 @@ sddr09_write_lba(struct us_data *us, unsigned int lba,
916 cptr = bptr + info->pagesize; 912 cptr = bptr + info->pagesize;
917 nand_compute_ecc(bptr, ecc); 913 nand_compute_ecc(bptr, ecc);
918 if (!nand_compare_ecc(cptr+13, ecc)) { 914 if (!nand_compare_ecc(cptr+13, ecc)) {
919 US_DEBUGP("Warning: bad ecc in page %d- of pba %d\n", 915 usb_stor_dbg(us, "Warning: bad ecc in page %d- of pba %d\n",
920 i, pba); 916 i, pba);
921 nand_store_ecc(cptr+13, ecc); 917 nand_store_ecc(cptr+13, ecc);
922 } 918 }
923 nand_compute_ecc(bptr+(info->pagesize / 2), ecc); 919 nand_compute_ecc(bptr+(info->pagesize / 2), ecc);
924 if (!nand_compare_ecc(cptr+8, ecc)) { 920 if (!nand_compare_ecc(cptr+8, ecc)) {
925 US_DEBUGP("Warning: bad ecc in page %d+ of pba %d\n", 921 usb_stor_dbg(us, "Warning: bad ecc in page %d+ of pba %d\n",
926 i, pba); 922 i, pba);
927 nand_store_ecc(cptr+8, ecc); 923 nand_store_ecc(cptr+8, ecc);
928 } 924 }
929 cptr[6] = cptr[11] = MSB_of(lbap); 925 cptr[6] = cptr[11] = MSB_of(lbap);
@@ -943,22 +939,21 @@ sddr09_write_lba(struct us_data *us, unsigned int lba,
943 nand_store_ecc(cptr+8, ecc); 939 nand_store_ecc(cptr+8, ecc);
944 } 940 }
945 941
946 US_DEBUGP("Rewrite PBA %d (LBA %d)\n", pba, lba); 942 usb_stor_dbg(us, "Rewrite PBA %d (LBA %d)\n", pba, lba);
947 943
948 result = sddr09_write_inplace(us, address>>1, info->blocksize, 944 result = sddr09_write_inplace(us, address>>1, info->blocksize,
949 info->pageshift, blockbuffer, 0); 945 info->pageshift, blockbuffer, 0);
950 946
951 US_DEBUGP("sddr09_write_inplace returns %d\n", result); 947 usb_stor_dbg(us, "sddr09_write_inplace returns %d\n", result);
952 948
953#if 0 949#if 0
954 { 950 {
955 unsigned char status = 0; 951 unsigned char status = 0;
956 int result2 = sddr09_read_status(us, &status); 952 int result2 = sddr09_read_status(us, &status);
957 if (result2) 953 if (result2)
958 US_DEBUGP("sddr09_write_inplace: cannot read status\n"); 954 usb_stor_dbg(us, "cannot read status\n");
959 else if (status != 0xc0) 955 else if (status != 0xc0)
960 US_DEBUGP("sddr09_write_inplace: status after write: 0x%x\n", 956 usb_stor_dbg(us, "status after write: 0x%x\n", status);
961 status);
962 } 957 }
963#endif 958#endif
964 959
@@ -1031,8 +1026,8 @@ sddr09_write_data(struct us_data *us,
1031 1026
1032 /* Not overflowing capacity? */ 1027 /* Not overflowing capacity? */
1033 if (lba >= maxlba) { 1028 if (lba >= maxlba) {
1034 US_DEBUGP("Error: Requested lba %u exceeds " 1029 usb_stor_dbg(us, "Error: Requested lba %u exceeds maximum %u\n",
1035 "maximum %u\n", lba, maxlba); 1030 lba, maxlba);
1036 result = -EIO; 1031 result = -EIO;
1037 break; 1032 break;
1038 } 1033 }
@@ -1064,8 +1059,8 @@ sddr09_read_control(struct us_data *us,
1064 unsigned char *content, 1059 unsigned char *content,
1065 int use_sg) { 1060 int use_sg) {
1066 1061
1067 US_DEBUGP("Read control address %lu, blocks %d\n", 1062 usb_stor_dbg(us, "Read control address %lu, blocks %d\n",
1068 address, blocks); 1063 address, blocks);
1069 1064
1070 return sddr09_read21(us, address, blocks, 1065 return sddr09_read21(us, address, blocks,
1071 CONTROL_SHIFT, content, use_sg); 1066 CONTROL_SHIFT, content, use_sg);
@@ -1111,21 +1106,21 @@ sddr09_get_wp(struct us_data *us, struct sddr09_card_info *info) {
1111 1106
1112 result = sddr09_read_status(us, &status); 1107 result = sddr09_read_status(us, &status);
1113 if (result) { 1108 if (result) {
1114 US_DEBUGP("sddr09_get_wp: read_status fails\n"); 1109 usb_stor_dbg(us, "read_status fails\n");
1115 return result; 1110 return result;
1116 } 1111 }
1117 US_DEBUGP("sddr09_get_wp: status 0x%02X", status); 1112 usb_stor_dbg(us, "status 0x%02X", status);
1118 if ((status & 0x80) == 0) { 1113 if ((status & 0x80) == 0) {
1119 info->flags |= SDDR09_WP; /* write protected */ 1114 info->flags |= SDDR09_WP; /* write protected */
1120 US_DEBUGP(" WP"); 1115 US_DEBUGPX(" WP");
1121 } 1116 }
1122 if (status & 0x40) 1117 if (status & 0x40)
1123 US_DEBUGP(" Ready"); 1118 US_DEBUGPX(" Ready");
1124 if (status & LUNBITS) 1119 if (status & LUNBITS)
1125 US_DEBUGP(" Suspended"); 1120 US_DEBUGPX(" Suspended");
1126 if (status & 0x1) 1121 if (status & 0x1)
1127 US_DEBUGP(" Error"); 1122 US_DEBUGPX(" Error");
1128 US_DEBUGP("\n"); 1123 US_DEBUGPX("\n");
1129 return 0; 1124 return 0;
1130} 1125}
1131 1126
@@ -1154,12 +1149,12 @@ sddr09_get_cardinfo(struct us_data *us, unsigned char flags) {
1154 char blurbtxt[256]; 1149 char blurbtxt[256];
1155 int result; 1150 int result;
1156 1151
1157 US_DEBUGP("Reading capacity...\n"); 1152 usb_stor_dbg(us, "Reading capacity...\n");
1158 1153
1159 result = sddr09_read_deviceID(us, deviceID); 1154 result = sddr09_read_deviceID(us, deviceID);
1160 1155
1161 if (result) { 1156 if (result) {
1162 US_DEBUGP("Result of read_deviceID is %d\n", result); 1157 usb_stor_dbg(us, "Result of read_deviceID is %d\n", result);
1163 printk(KERN_WARNING "sddr09: could not read card info\n"); 1158 printk(KERN_WARNING "sddr09: could not read card info\n");
1164 return NULL; 1159 return NULL;
1165 } 1160 }
@@ -1392,7 +1387,7 @@ sddr09_read_map(struct us_data *us) {
1392 lbact += ct; 1387 lbact += ct;
1393 } 1388 }
1394 info->lbact = lbact; 1389 info->lbact = lbact;
1395 US_DEBUGP("Found %d LBA's\n", lbact); 1390 usb_stor_dbg(us, "Found %d LBA's\n", lbact);
1396 result = 0; 1391 result = 0;
1397 1392
1398 done: 1393 done:
@@ -1423,18 +1418,18 @@ sddr09_common_init(struct us_data *us) {
1423 1418
1424 /* set the configuration -- STALL is an acceptable response here */ 1419 /* set the configuration -- STALL is an acceptable response here */
1425 if (us->pusb_dev->actconfig->desc.bConfigurationValue != 1) { 1420 if (us->pusb_dev->actconfig->desc.bConfigurationValue != 1) {
1426 US_DEBUGP("active config #%d != 1 ??\n", us->pusb_dev 1421 usb_stor_dbg(us, "active config #%d != 1 ??\n",
1427 ->actconfig->desc.bConfigurationValue); 1422 us->pusb_dev->actconfig->desc.bConfigurationValue);
1428 return -EINVAL; 1423 return -EINVAL;
1429 } 1424 }
1430 1425
1431 result = usb_reset_configuration(us->pusb_dev); 1426 result = usb_reset_configuration(us->pusb_dev);
1432 US_DEBUGP("Result of usb_reset_configuration is %d\n", result); 1427 usb_stor_dbg(us, "Result of usb_reset_configuration is %d\n", result);
1433 if (result == -EPIPE) { 1428 if (result == -EPIPE) {
1434 US_DEBUGP("-- stall on control interface\n"); 1429 usb_stor_dbg(us, "-- stall on control interface\n");
1435 } else if (result != 0) { 1430 } else if (result != 0) {
1436 /* it's not a stall, but another error -- time to bail */ 1431 /* it's not a stall, but another error -- time to bail */
1437 US_DEBUGP("-- Unknown error. Rejecting device\n"); 1432 usb_stor_dbg(us, "-- Unknown error. Rejecting device\n");
1438 return -EINVAL; 1433 return -EINVAL;
1439 } 1434 }
1440 1435
@@ -1464,20 +1459,20 @@ usb_stor_sddr09_dpcm_init(struct us_data *us) {
1464 1459
1465 result = sddr09_send_command(us, 0x01, USB_DIR_IN, data, 2); 1460 result = sddr09_send_command(us, 0x01, USB_DIR_IN, data, 2);
1466 if (result) { 1461 if (result) {
1467 US_DEBUGP("sddr09_init: send_command fails\n"); 1462 usb_stor_dbg(us, "send_command fails\n");
1468 return result; 1463 return result;
1469 } 1464 }
1470 1465
1471 US_DEBUGP("SDDR09init: %02X %02X\n", data[0], data[1]); 1466 usb_stor_dbg(us, "%02X %02X\n", data[0], data[1]);
1472 // get 07 02 1467 // get 07 02
1473 1468
1474 result = sddr09_send_command(us, 0x08, USB_DIR_IN, data, 2); 1469 result = sddr09_send_command(us, 0x08, USB_DIR_IN, data, 2);
1475 if (result) { 1470 if (result) {
1476 US_DEBUGP("sddr09_init: 2nd send_command fails\n"); 1471 usb_stor_dbg(us, "2nd send_command fails\n");
1477 return result; 1472 return result;
1478 } 1473 }
1479 1474
1480 US_DEBUGP("SDDR09init: %02X %02X\n", data[0], data[1]); 1475 usb_stor_dbg(us, "%02X %02X\n", data[0], data[1]);
1481 // get 07 00 1476 // get 07 00
1482 1477
1483 result = sddr09_request_sense(us, data, 18); 1478 result = sddr09_request_sense(us, data, 18);
@@ -1507,7 +1502,7 @@ static int dpcm_transport(struct scsi_cmnd *srb, struct us_data *us)
1507{ 1502{
1508 int ret; 1503 int ret;
1509 1504
1510 US_DEBUGP("dpcm_transport: LUN=%d\n", srb->device->lun); 1505 usb_stor_dbg(us, "LUN=%d\n", srb->device->lun);
1511 1506
1512 switch (srb->device->lun) { 1507 switch (srb->device->lun) {
1513 case 0: 1508 case 0:
@@ -1533,8 +1528,7 @@ static int dpcm_transport(struct scsi_cmnd *srb, struct us_data *us)
1533 break; 1528 break;
1534 1529
1535 default: 1530 default:
1536 US_DEBUGP("dpcm_transport: Invalid LUN %d\n", 1531 usb_stor_dbg(us, "Invalid LUN %d\n", srb->device->lun);
1537 srb->device->lun);
1538 ret = USB_STOR_TRANSPORT_ERROR; 1532 ret = USB_STOR_TRANSPORT_ERROR;
1539 break; 1533 break;
1540 } 1534 }
@@ -1640,8 +1634,8 @@ static int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us)
1640 or for all pages. */ 1634 or for all pages. */
1641 /* %% We should check DBD %% */ 1635 /* %% We should check DBD %% */
1642 if (modepage == 0x01 || modepage == 0x3F) { 1636 if (modepage == 0x01 || modepage == 0x3F) {
1643 US_DEBUGP("SDDR09: Dummy up request for " 1637 usb_stor_dbg(us, "Dummy up request for mode page 0x%x\n",
1644 "mode page 0x%x\n", modepage); 1638 modepage);
1645 1639
1646 memcpy(ptr, mode_page_01, sizeof(mode_page_01)); 1640 memcpy(ptr, mode_page_01, sizeof(mode_page_01));
1647 ((__be16*)ptr)[0] = cpu_to_be16(sizeof(mode_page_01) - 2); 1641 ((__be16*)ptr)[0] = cpu_to_be16(sizeof(mode_page_01) - 2);
@@ -1667,8 +1661,8 @@ static int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us)
1667 page |= short_pack(srb->cmnd[5], srb->cmnd[4]); 1661 page |= short_pack(srb->cmnd[5], srb->cmnd[4]);
1668 pages = short_pack(srb->cmnd[8], srb->cmnd[7]); 1662 pages = short_pack(srb->cmnd[8], srb->cmnd[7]);
1669 1663
1670 US_DEBUGP("READ_10: read page %d pagect %d\n", 1664 usb_stor_dbg(us, "READ_10: read page %d pagect %d\n",
1671 page, pages); 1665 page, pages);
1672 1666
1673 result = sddr09_read_data(us, page, pages); 1667 result = sddr09_read_data(us, page, pages);
1674 return (result == 0 ? USB_STOR_TRANSPORT_GOOD : 1668 return (result == 0 ? USB_STOR_TRANSPORT_GOOD :
@@ -1682,8 +1676,8 @@ static int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us)
1682 page |= short_pack(srb->cmnd[5], srb->cmnd[4]); 1676 page |= short_pack(srb->cmnd[5], srb->cmnd[4]);
1683 pages = short_pack(srb->cmnd[8], srb->cmnd[7]); 1677 pages = short_pack(srb->cmnd[8], srb->cmnd[7]);
1684 1678
1685 US_DEBUGP("WRITE_10: write page %d pagect %d\n", 1679 usb_stor_dbg(us, "WRITE_10: write page %d pagect %d\n",
1686 page, pages); 1680 page, pages);
1687 1681
1688 result = sddr09_write_data(us, page, pages); 1682 result = sddr09_write_data(us, page, pages);
1689 return (result == 0 ? USB_STOR_TRANSPORT_GOOD : 1683 return (result == 0 ? USB_STOR_TRANSPORT_GOOD :
@@ -1710,12 +1704,12 @@ static int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us)
1710 for (i=0; i<12; i++) 1704 for (i=0; i<12; i++)
1711 sprintf(ptr+strlen(ptr), "%02X ", srb->cmnd[i]); 1705 sprintf(ptr+strlen(ptr), "%02X ", srb->cmnd[i]);
1712 1706
1713 US_DEBUGP("SDDR09: Send control for command %s\n", ptr); 1707 usb_stor_dbg(us, "Send control for command %s\n", ptr);
1714 1708
1715 result = sddr09_send_scsi_command(us, srb->cmnd, 12); 1709 result = sddr09_send_scsi_command(us, srb->cmnd, 12);
1716 if (result) { 1710 if (result) {
1717 US_DEBUGP("sddr09_transport: sddr09_send_scsi_command " 1711 usb_stor_dbg(us, "sddr09_send_scsi_command returns %d\n",
1718 "returns %d\n", result); 1712 result);
1719 return USB_STOR_TRANSPORT_ERROR; 1713 return USB_STOR_TRANSPORT_ERROR;
1720 } 1714 }
1721 1715
@@ -1727,10 +1721,10 @@ static int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us)
1727 unsigned int pipe = (srb->sc_data_direction == DMA_TO_DEVICE) 1721 unsigned int pipe = (srb->sc_data_direction == DMA_TO_DEVICE)
1728 ? us->send_bulk_pipe : us->recv_bulk_pipe; 1722 ? us->send_bulk_pipe : us->recv_bulk_pipe;
1729 1723
1730 US_DEBUGP("SDDR09: %s %d bytes\n", 1724 usb_stor_dbg(us, "%s %d bytes\n",
1731 (srb->sc_data_direction == DMA_TO_DEVICE) ? 1725 (srb->sc_data_direction == DMA_TO_DEVICE) ?
1732 "sending" : "receiving", 1726 "sending" : "receiving",
1733 scsi_bufflen(srb)); 1727 scsi_bufflen(srb));
1734 1728
1735 result = usb_stor_bulk_srb(us, pipe, srb); 1729 result = usb_stor_bulk_srb(us, pipe, srb);
1736 1730
diff --git a/drivers/usb/storage/sddr55.c b/drivers/usb/storage/sddr55.c
index d278c5a99b7a..aacedef9667c 100644
--- a/drivers/usb/storage/sddr55.c
+++ b/drivers/usb/storage/sddr55.c
@@ -145,8 +145,7 @@ static int sddr55_status(struct us_data *us)
145 result = sddr55_bulk_transport(us, 145 result = sddr55_bulk_transport(us,
146 DMA_TO_DEVICE, command, 8); 146 DMA_TO_DEVICE, command, 8);
147 147
148 US_DEBUGP("Result for send_command in status %d\n", 148 usb_stor_dbg(us, "Result for send_command in status %d\n", result);
149 result);
150 149
151 if (result != USB_STOR_XFER_GOOD) { 150 if (result != USB_STOR_XFER_GOOD) {
152 set_sense_info (4, 0, 0); /* hardware error */ 151 set_sense_info (4, 0, 0); /* hardware error */
@@ -236,9 +235,8 @@ static int sddr55_read_data(struct us_data *us,
236 info->blocksize - page); 235 info->blocksize - page);
237 len = pages << info->pageshift; 236 len = pages << info->pageshift;
238 237
239 US_DEBUGP("Read %02X pages, from PBA %04X" 238 usb_stor_dbg(us, "Read %02X pages, from PBA %04X (LBA %04X) page %02X\n",
240 " (LBA %04X) page %02X\n", 239 pages, pba, lba, page);
241 pages, pba, lba, page);
242 240
243 if (pba == NOT_ALLOCATED) { 241 if (pba == NOT_ALLOCATED) {
244 /* no pba for this lba, fill with zeroes */ 242 /* no pba for this lba, fill with zeroes */
@@ -261,8 +259,8 @@ static int sddr55_read_data(struct us_data *us,
261 result = sddr55_bulk_transport(us, 259 result = sddr55_bulk_transport(us,
262 DMA_TO_DEVICE, command, 8); 260 DMA_TO_DEVICE, command, 8);
263 261
264 US_DEBUGP("Result for send_command in read_data %d\n", 262 usb_stor_dbg(us, "Result for send_command in read_data %d\n",
265 result); 263 result);
266 264
267 if (result != USB_STOR_XFER_GOOD) { 265 if (result != USB_STOR_XFER_GOOD) {
268 result = USB_STOR_TRANSPORT_ERROR; 266 result = USB_STOR_TRANSPORT_ERROR;
@@ -368,9 +366,8 @@ static int sddr55_write_data(struct us_data *us,
368 usb_stor_access_xfer_buf(buffer, len, us->srb, 366 usb_stor_access_xfer_buf(buffer, len, us->srb,
369 &sg, &offset, FROM_XFER_BUF); 367 &sg, &offset, FROM_XFER_BUF);
370 368
371 US_DEBUGP("Write %02X pages, to PBA %04X" 369 usb_stor_dbg(us, "Write %02X pages, to PBA %04X (LBA %04X) page %02X\n",
372 " (LBA %04X) page %02X\n", 370 pages, pba, lba, page);
373 pages, pba, lba, page);
374 371
375 command[4] = 0; 372 command[4] = 0;
376 373
@@ -384,7 +381,7 @@ static int sddr55_write_data(struct us_data *us,
384 /* set pba to first block in zone lba is in */ 381 /* set pba to first block in zone lba is in */
385 pba = (lba / 1000) * 1024; 382 pba = (lba / 1000) * 1024;
386 383
387 US_DEBUGP("No PBA for LBA %04X\n",lba); 384 usb_stor_dbg(us, "No PBA for LBA %04X\n", lba);
388 385
389 if (max_pba > 1024) 386 if (max_pba > 1024)
390 max_pba = 1024; 387 max_pba = 1024;
@@ -407,14 +404,15 @@ static int sddr55_write_data(struct us_data *us,
407 404
408 if (pba == -1) { 405 if (pba == -1) {
409 /* oh dear */ 406 /* oh dear */
410 US_DEBUGP("Couldn't find unallocated block\n"); 407 usb_stor_dbg(us, "Couldn't find unallocated block\n");
411 408
412 set_sense_info (3, 0x31, 0); /* medium error */ 409 set_sense_info (3, 0x31, 0); /* medium error */
413 result = USB_STOR_TRANSPORT_FAILED; 410 result = USB_STOR_TRANSPORT_FAILED;
414 goto leave; 411 goto leave;
415 } 412 }
416 413
417 US_DEBUGP("Allocating PBA %04X for LBA %04X\n", pba, lba); 414 usb_stor_dbg(us, "Allocating PBA %04X for LBA %04X\n",
415 pba, lba);
418 416
419 /* set writing to unallocated block flag */ 417 /* set writing to unallocated block flag */
420 command[4] = 0x40; 418 command[4] = 0x40;
@@ -439,8 +437,8 @@ static int sddr55_write_data(struct us_data *us,
439 DMA_TO_DEVICE, command, 8); 437 DMA_TO_DEVICE, command, 8);
440 438
441 if (result != USB_STOR_XFER_GOOD) { 439 if (result != USB_STOR_XFER_GOOD) {
442 US_DEBUGP("Result for send_command in write_data %d\n", 440 usb_stor_dbg(us, "Result for send_command in write_data %d\n",
443 result); 441 result);
444 442
445 /* set_sense_info is superfluous here? */ 443 /* set_sense_info is superfluous here? */
446 set_sense_info (3, 0x3, 0);/* peripheral write error */ 444 set_sense_info (3, 0x3, 0);/* peripheral write error */
@@ -453,8 +451,8 @@ static int sddr55_write_data(struct us_data *us,
453 DMA_TO_DEVICE, buffer, len); 451 DMA_TO_DEVICE, buffer, len);
454 452
455 if (result != USB_STOR_XFER_GOOD) { 453 if (result != USB_STOR_XFER_GOOD) {
456 US_DEBUGP("Result for send_data in write_data %d\n", 454 usb_stor_dbg(us, "Result for send_data in write_data %d\n",
457 result); 455 result);
458 456
459 /* set_sense_info is superfluous here? */ 457 /* set_sense_info is superfluous here? */
460 set_sense_info (3, 0x3, 0);/* peripheral write error */ 458 set_sense_info (3, 0x3, 0);/* peripheral write error */
@@ -466,8 +464,8 @@ static int sddr55_write_data(struct us_data *us,
466 result = sddr55_bulk_transport(us, DMA_FROM_DEVICE, status, 6); 464 result = sddr55_bulk_transport(us, DMA_FROM_DEVICE, status, 6);
467 465
468 if (result != USB_STOR_XFER_GOOD) { 466 if (result != USB_STOR_XFER_GOOD) {
469 US_DEBUGP("Result for get_status in write_data %d\n", 467 usb_stor_dbg(us, "Result for get_status in write_data %d\n",
470 result); 468 result);
471 469
472 /* set_sense_info is superfluous here? */ 470 /* set_sense_info is superfluous here? */
473 set_sense_info (3, 0x3, 0);/* peripheral write error */ 471 set_sense_info (3, 0x3, 0);/* peripheral write error */
@@ -487,8 +485,8 @@ static int sddr55_write_data(struct us_data *us,
487 goto leave; 485 goto leave;
488 } 486 }
489 487
490 US_DEBUGP("Updating maps for LBA %04X: old PBA %04X, new PBA %04X\n", 488 usb_stor_dbg(us, "Updating maps for LBA %04X: old PBA %04X, new PBA %04X\n",
491 lba, pba, new_pba); 489 lba, pba, new_pba);
492 490
493 /* update the lba<->pba maps, note new_pba might be the same as pba */ 491 /* update the lba<->pba maps, note new_pba might be the same as pba */
494 info->lba_to_pba[lba] = new_pba; 492 info->lba_to_pba[lba] = new_pba;
@@ -531,8 +529,8 @@ static int sddr55_read_deviceID(struct us_data *us,
531 command[7] = 0x84; 529 command[7] = 0x84;
532 result = sddr55_bulk_transport(us, DMA_TO_DEVICE, command, 8); 530 result = sddr55_bulk_transport(us, DMA_TO_DEVICE, command, 8);
533 531
534 US_DEBUGP("Result of send_control for device ID is %d\n", 532 usb_stor_dbg(us, "Result of send_control for device ID is %d\n",
535 result); 533 result);
536 534
537 if (result != USB_STOR_XFER_GOOD) 535 if (result != USB_STOR_XFER_GOOD)
538 return USB_STOR_TRANSPORT_ERROR; 536 return USB_STOR_TRANSPORT_ERROR;
@@ -568,20 +566,19 @@ static unsigned long sddr55_get_capacity(struct us_data *us) {
568 int result; 566 int result;
569 struct sddr55_card_info *info = (struct sddr55_card_info *)us->extra; 567 struct sddr55_card_info *info = (struct sddr55_card_info *)us->extra;
570 568
571 US_DEBUGP("Reading capacity...\n"); 569 usb_stor_dbg(us, "Reading capacity...\n");
572 570
573 result = sddr55_read_deviceID(us, 571 result = sddr55_read_deviceID(us,
574 &manufacturerID, 572 &manufacturerID,
575 &deviceID); 573 &deviceID);
576 574
577 US_DEBUGP("Result of read_deviceID is %d\n", 575 usb_stor_dbg(us, "Result of read_deviceID is %d\n", result);
578 result);
579 576
580 if (result != USB_STOR_XFER_GOOD) 577 if (result != USB_STOR_XFER_GOOD)
581 return 0; 578 return 0;
582 579
583 US_DEBUGP("Device ID = %02X\n", deviceID); 580 usb_stor_dbg(us, "Device ID = %02X\n", deviceID);
584 US_DEBUGP("Manuf ID = %02X\n", manufacturerID); 581 usb_stor_dbg(us, "Manuf ID = %02X\n", manufacturerID);
585 582
586 info->pageshift = 9; 583 info->pageshift = 9;
587 info->smallpageshift = 0; 584 info->smallpageshift = 0;
@@ -753,7 +750,7 @@ static int sddr55_read_map(struct us_data *us) {
753 } 750 }
754 751
755 if (lba<0x10 || (lba>=0x3E0 && lba<0x3EF)) 752 if (lba<0x10 || (lba>=0x3E0 && lba<0x3EF))
756 US_DEBUGP("LBA %04X <-> PBA %04X\n", lba, i); 753 usb_stor_dbg(us, "LBA %04X <-> PBA %04X\n", lba, i);
757 754
758 info->lba_to_pba[lba + zone * 1000] = i; 755 info->lba_to_pba[lba + zone * 1000] = i;
759 } 756 }
@@ -808,7 +805,10 @@ static int sddr55_transport(struct scsi_cmnd *srb, struct us_data *us)
808 info = (struct sddr55_card_info *)(us->extra); 805 info = (struct sddr55_card_info *)(us->extra);
809 806
810 if (srb->cmnd[0] == REQUEST_SENSE) { 807 if (srb->cmnd[0] == REQUEST_SENSE) {
811 US_DEBUGP("SDDR55: request sense %02x/%02x/%02x\n", info->sense_data[2], info->sense_data[12], info->sense_data[13]); 808 usb_stor_dbg(us, "request sense %02x/%02x/%02x\n",
809 info->sense_data[2],
810 info->sense_data[12],
811 info->sense_data[13]);
812 812
813 memcpy (ptr, info->sense_data, sizeof info->sense_data); 813 memcpy (ptr, info->sense_data, sizeof info->sense_data);
814 ptr[0] = 0x70; 814 ptr[0] = 0x70;
@@ -892,13 +892,11 @@ static int sddr55_transport(struct scsi_cmnd *srb, struct us_data *us)
892 usb_stor_set_xfer_buf(ptr, sizeof(mode_page_01), srb); 892 usb_stor_set_xfer_buf(ptr, sizeof(mode_page_01), srb);
893 893
894 if ( (srb->cmnd[2] & 0x3F) == 0x01 ) { 894 if ( (srb->cmnd[2] & 0x3F) == 0x01 ) {
895 US_DEBUGP( 895 usb_stor_dbg(us, "Dummy up request for mode page 1\n");
896 "SDDR55: Dummy up request for mode page 1\n");
897 return USB_STOR_TRANSPORT_GOOD; 896 return USB_STOR_TRANSPORT_GOOD;
898 897
899 } else if ( (srb->cmnd[2] & 0x3F) == 0x3F ) { 898 } else if ( (srb->cmnd[2] & 0x3F) == 0x3F ) {
900 US_DEBUGP( 899 usb_stor_dbg(us, "Dummy up request for all mode pages\n");
901 "SDDR55: Dummy up request for all mode pages\n");
902 return USB_STOR_TRANSPORT_GOOD; 900 return USB_STOR_TRANSPORT_GOOD;
903 } 901 }
904 902
@@ -908,10 +906,8 @@ static int sddr55_transport(struct scsi_cmnd *srb, struct us_data *us)
908 906
909 if (srb->cmnd[0] == ALLOW_MEDIUM_REMOVAL) { 907 if (srb->cmnd[0] == ALLOW_MEDIUM_REMOVAL) {
910 908
911 US_DEBUGP( 909 usb_stor_dbg(us, "%s medium removal. Not that I can do anything about it...\n",
912 "SDDR55: %s medium removal. Not that I can do" 910 (srb->cmnd[4]&0x03) ? "Prevent" : "Allow");
913 " anything about it...\n",
914 (srb->cmnd[4]&0x03) ? "Prevent" : "Allow");
915 911
916 return USB_STOR_TRANSPORT_GOOD; 912 return USB_STOR_TRANSPORT_GOOD;
917 913
@@ -935,8 +931,8 @@ static int sddr55_transport(struct scsi_cmnd *srb, struct us_data *us)
935 931
936 if (lba >= info->max_log_blks) { 932 if (lba >= info->max_log_blks) {
937 933
938 US_DEBUGP("Error: Requested LBA %04X exceeds maximum " 934 usb_stor_dbg(us, "Error: Requested LBA %04X exceeds maximum block %04X\n",
939 "block %04X\n", lba, info->max_log_blks-1); 935 lba, info->max_log_blks - 1);
940 936
941 set_sense_info (5, 0x24, 0); /* invalid field in command */ 937 set_sense_info (5, 0x24, 0); /* invalid field in command */
942 938
@@ -946,15 +942,13 @@ static int sddr55_transport(struct scsi_cmnd *srb, struct us_data *us)
946 pba = info->lba_to_pba[lba]; 942 pba = info->lba_to_pba[lba];
947 943
948 if (srb->cmnd[0] == WRITE_10) { 944 if (srb->cmnd[0] == WRITE_10) {
949 US_DEBUGP("WRITE_10: write block %04X (LBA %04X) page %01X" 945 usb_stor_dbg(us, "WRITE_10: write block %04X (LBA %04X) page %01X pages %d\n",
950 " pages %d\n", 946 pba, lba, page, pages);
951 pba, lba, page, pages);
952 947
953 return sddr55_write_data(us, lba, page, pages); 948 return sddr55_write_data(us, lba, page, pages);
954 } else { 949 } else {
955 US_DEBUGP("READ_10: read block %04X (LBA %04X) page %01X" 950 usb_stor_dbg(us, "READ_10: read block %04X (LBA %04X) page %01X pages %d\n",
956 " pages %d\n", 951 pba, lba, page, pages);
957 pba, lba, page, pages);
958 952
959 return sddr55_read_data(us, lba, page, pages); 953 return sddr55_read_data(us, lba, page, pages);
960 } 954 }
diff --git a/drivers/usb/storage/shuttle_usbat.c b/drivers/usb/storage/shuttle_usbat.c
index daf2fc58ae02..4ef2a80728f7 100644
--- a/drivers/usb/storage/shuttle_usbat.c
+++ b/drivers/usb/storage/shuttle_usbat.c
@@ -271,7 +271,7 @@ static int usbat_bulk_read(struct us_data *us,
271 if (len == 0) 271 if (len == 0)
272 return USB_STOR_XFER_GOOD; 272 return USB_STOR_XFER_GOOD;
273 273
274 US_DEBUGP("usbat_bulk_read: len = %d\n", len); 274 usb_stor_dbg(us, "len = %d\n", len);
275 return usb_stor_bulk_transfer_sg(us, us->recv_bulk_pipe, buf, len, use_sg, NULL); 275 return usb_stor_bulk_transfer_sg(us, us->recv_bulk_pipe, buf, len, use_sg, NULL);
276} 276}
277 277
@@ -286,7 +286,7 @@ static int usbat_bulk_write(struct us_data *us,
286 if (len == 0) 286 if (len == 0)
287 return USB_STOR_XFER_GOOD; 287 return USB_STOR_XFER_GOOD;
288 288
289 US_DEBUGP("usbat_bulk_write: len = %d\n", len); 289 usb_stor_dbg(us, "len = %d\n", len);
290 return usb_stor_bulk_transfer_sg(us, us->send_bulk_pipe, buf, len, use_sg, NULL); 290 return usb_stor_bulk_transfer_sg(us, us->send_bulk_pipe, buf, len, use_sg, NULL);
291} 291}
292 292
@@ -312,7 +312,7 @@ static int usbat_get_status(struct us_data *us, unsigned char *status)
312 int rc; 312 int rc;
313 rc = usbat_read(us, USBAT_ATA, USBAT_ATA_STATUS, status); 313 rc = usbat_read(us, USBAT_ATA, USBAT_ATA_STATUS, status);
314 314
315 US_DEBUGP("usbat_get_status: 0x%02X\n", (unsigned short) (*status)); 315 usb_stor_dbg(us, "0x%02X\n", *status);
316 return rc; 316 return rc;
317} 317}
318 318
@@ -425,7 +425,7 @@ static int usbat_wait_not_busy(struct us_data *us, int minutes)
425 return USB_STOR_TRANSPORT_FAILED; 425 return USB_STOR_TRANSPORT_FAILED;
426 426
427 if ((*status & 0x80)==0x00) { /* not busy */ 427 if ((*status & 0x80)==0x00) { /* not busy */
428 US_DEBUGP("Waited not busy for %d steps\n", i); 428 usb_stor_dbg(us, "Waited not busy for %d steps\n", i);
429 return USB_STOR_TRANSPORT_GOOD; 429 return USB_STOR_TRANSPORT_GOOD;
430 } 430 }
431 431
@@ -439,8 +439,8 @@ static int usbat_wait_not_busy(struct us_data *us, int minutes)
439 msleep(1000); /* X minutes */ 439 msleep(1000); /* X minutes */
440 } 440 }
441 441
442 US_DEBUGP("Waited not busy for %d minutes, timing out.\n", 442 usb_stor_dbg(us, "Waited not busy for %d minutes, timing out\n",
443 minutes); 443 minutes);
444 return USB_STOR_TRANSPORT_FAILED; 444 return USB_STOR_TRANSPORT_FAILED;
445} 445}
446 446
@@ -657,8 +657,9 @@ static int usbat_hp8200e_rw_block_test(struct us_data *us,
657 if (*status & 0x20) /* device fault */ 657 if (*status & 0x20) /* device fault */
658 return USB_STOR_TRANSPORT_FAILED; 658 return USB_STOR_TRANSPORT_FAILED;
659 659
660 US_DEBUGP("Redoing %s\n", 660 usb_stor_dbg(us, "Redoing %s\n",
661 direction==DMA_TO_DEVICE ? "write" : "read"); 661 direction == DMA_TO_DEVICE
662 ? "write" : "read");
662 663
663 } else if (result != USB_STOR_XFER_GOOD) 664 } else if (result != USB_STOR_XFER_GOOD)
664 return USB_STOR_TRANSPORT_ERROR; 665 return USB_STOR_TRANSPORT_ERROR;
@@ -667,8 +668,8 @@ static int usbat_hp8200e_rw_block_test(struct us_data *us,
667 668
668 } 669 }
669 670
670 US_DEBUGP("Bummer! %s bulk data 20 times failed.\n", 671 usb_stor_dbg(us, "Bummer! %s bulk data 20 times failed\n",
671 direction==DMA_TO_DEVICE ? "Writing" : "Reading"); 672 direction == DMA_TO_DEVICE ? "Writing" : "Reading");
672 673
673 return USB_STOR_TRANSPORT_FAILED; 674 return USB_STOR_TRANSPORT_FAILED;
674} 675}
@@ -827,7 +828,7 @@ static int usbat_read_user_io(struct us_data *us, unsigned char *data_flags)
827 data_flags, 828 data_flags,
828 USBAT_UIO_READ); 829 USBAT_UIO_READ);
829 830
830 US_DEBUGP("usbat_read_user_io: UIO register reads %02X\n", (unsigned short) (*data_flags)); 831 usb_stor_dbg(us, "UIO register reads %02X\n", *data_flags);
831 832
832 return result; 833 return result;
833} 834}
@@ -900,10 +901,11 @@ static int usbat_device_enable_cdt(struct us_data *us)
900/* 901/*
901 * Determine if media is present. 902 * Determine if media is present.
902 */ 903 */
903static int usbat_flash_check_media_present(unsigned char *uio) 904static int usbat_flash_check_media_present(struct us_data *us,
905 unsigned char *uio)
904{ 906{
905 if (*uio & USBAT_UIO_UI0) { 907 if (*uio & USBAT_UIO_UI0) {
906 US_DEBUGP("usbat_flash_check_media_present: no media detected\n"); 908 usb_stor_dbg(us, "no media detected\n");
907 return USBAT_FLASH_MEDIA_NONE; 909 return USBAT_FLASH_MEDIA_NONE;
908 } 910 }
909 911
@@ -913,10 +915,11 @@ static int usbat_flash_check_media_present(unsigned char *uio)
913/* 915/*
914 * Determine if media has changed since last operation 916 * Determine if media has changed since last operation
915 */ 917 */
916static int usbat_flash_check_media_changed(unsigned char *uio) 918static int usbat_flash_check_media_changed(struct us_data *us,
919 unsigned char *uio)
917{ 920{
918 if (*uio & USBAT_UIO_0) { 921 if (*uio & USBAT_UIO_0) {
919 US_DEBUGP("usbat_flash_check_media_changed: media change detected\n"); 922 usb_stor_dbg(us, "media change detected\n");
920 return USBAT_FLASH_MEDIA_CHANGED; 923 return USBAT_FLASH_MEDIA_CHANGED;
921 } 924 }
922 925
@@ -937,7 +940,7 @@ static int usbat_flash_check_media(struct us_data *us,
937 return USB_STOR_TRANSPORT_ERROR; 940 return USB_STOR_TRANSPORT_ERROR;
938 941
939 /* Check for media existence */ 942 /* Check for media existence */
940 rc = usbat_flash_check_media_present(uio); 943 rc = usbat_flash_check_media_present(us, uio);
941 if (rc == USBAT_FLASH_MEDIA_NONE) { 944 if (rc == USBAT_FLASH_MEDIA_NONE) {
942 info->sense_key = 0x02; 945 info->sense_key = 0x02;
943 info->sense_asc = 0x3A; 946 info->sense_asc = 0x3A;
@@ -946,7 +949,7 @@ static int usbat_flash_check_media(struct us_data *us,
946 } 949 }
947 950
948 /* Check for media change */ 951 /* Check for media change */
949 rc = usbat_flash_check_media_changed(uio); 952 rc = usbat_flash_check_media_changed(us, uio);
950 if (rc == USBAT_FLASH_MEDIA_CHANGED) { 953 if (rc == USBAT_FLASH_MEDIA_CHANGED) {
951 954
952 /* Reset and re-enable card detect */ 955 /* Reset and re-enable card detect */
@@ -1008,11 +1011,11 @@ static int usbat_identify_device(struct us_data *us,
1008 /* Check for error bit, or if the command 'fell through' */ 1011 /* Check for error bit, or if the command 'fell through' */
1009 if (status == 0xA1 || !(status & 0x01)) { 1012 if (status == 0xA1 || !(status & 0x01)) {
1010 /* Device is HP 8200 */ 1013 /* Device is HP 8200 */
1011 US_DEBUGP("usbat_identify_device: Detected HP8200 CDRW\n"); 1014 usb_stor_dbg(us, "Detected HP8200 CDRW\n");
1012 info->devicetype = USBAT_DEV_HP8200; 1015 info->devicetype = USBAT_DEV_HP8200;
1013 } else { 1016 } else {
1014 /* Device is a CompactFlash reader/writer */ 1017 /* Device is a CompactFlash reader/writer */
1015 US_DEBUGP("usbat_identify_device: Detected Flash reader/writer\n"); 1018 usb_stor_dbg(us, "Detected Flash reader/writer\n");
1016 info->devicetype = USBAT_DEV_FLASH; 1019 info->devicetype = USBAT_DEV_FLASH;
1017 } 1020 }
1018 1021
@@ -1075,7 +1078,7 @@ static int usbat_flash_get_sector_count(struct us_data *us,
1075 /* ATA command : IDENTIFY DEVICE */ 1078 /* ATA command : IDENTIFY DEVICE */
1076 rc = usbat_multiple_write(us, registers, command, 3); 1079 rc = usbat_multiple_write(us, registers, command, 3);
1077 if (rc != USB_STOR_XFER_GOOD) { 1080 if (rc != USB_STOR_XFER_GOOD) {
1078 US_DEBUGP("usbat_flash_get_sector_count: Gah! identify_device failed\n"); 1081 usb_stor_dbg(us, "Gah! identify_device failed\n");
1079 rc = USB_STOR_TRANSPORT_ERROR; 1082 rc = USB_STOR_TRANSPORT_ERROR;
1080 goto leave; 1083 goto leave;
1081 } 1084 }
@@ -1178,7 +1181,7 @@ static int usbat_flash_read_data(struct us_data *us,
1178 if (result != USB_STOR_TRANSPORT_GOOD) 1181 if (result != USB_STOR_TRANSPORT_GOOD)
1179 goto leave; 1182 goto leave;
1180 1183
1181 US_DEBUGP("usbat_flash_read_data: %d bytes\n", len); 1184 usb_stor_dbg(us, "%d bytes\n", len);
1182 1185
1183 /* Store the data in the transfer buffer */ 1186 /* Store the data in the transfer buffer */
1184 usb_stor_access_xfer_buf(buffer, len, us->srb, 1187 usb_stor_access_xfer_buf(buffer, len, us->srb,
@@ -1301,8 +1304,7 @@ static int usbat_hp8200e_handle_read10(struct us_data *us,
1301 unsigned int sg_offset = 0; 1304 unsigned int sg_offset = 0;
1302 struct scatterlist *sg = NULL; 1305 struct scatterlist *sg = NULL;
1303 1306
1304 US_DEBUGP("handle_read10: transfersize %d\n", 1307 usb_stor_dbg(us, "transfersize %d\n", srb->transfersize);
1305 srb->transfersize);
1306 1308
1307 if (scsi_bufflen(srb) < 0x10000) { 1309 if (scsi_bufflen(srb) < 0x10000) {
1308 1310
@@ -1329,14 +1331,14 @@ static int usbat_hp8200e_handle_read10(struct us_data *us,
1329 len = short_pack(data[7+9], data[7+8]); 1331 len = short_pack(data[7+9], data[7+8]);
1330 len <<= 16; 1332 len <<= 16;
1331 len |= data[7+7]; 1333 len |= data[7+7];
1332 US_DEBUGP("handle_read10: GPCMD_READ_CD: len %d\n", len); 1334 usb_stor_dbg(us, "GPCMD_READ_CD: len %d\n", len);
1333 srb->transfersize = scsi_bufflen(srb)/len; 1335 srb->transfersize = scsi_bufflen(srb)/len;
1334 } 1336 }
1335 1337
1336 if (!srb->transfersize) { 1338 if (!srb->transfersize) {
1337 srb->transfersize = 2048; /* A guess */ 1339 srb->transfersize = 2048; /* A guess */
1338 US_DEBUGP("handle_read10: transfersize 0, forcing %d\n", 1340 usb_stor_dbg(us, "transfersize 0, forcing %d\n",
1339 srb->transfersize); 1341 srb->transfersize);
1340 } 1342 }
1341 1343
1342 /* 1344 /*
@@ -1346,7 +1348,7 @@ static int usbat_hp8200e_handle_read10(struct us_data *us,
1346 */ 1348 */
1347 1349
1348 len = (65535/srb->transfersize) * srb->transfersize; 1350 len = (65535/srb->transfersize) * srb->transfersize;
1349 US_DEBUGP("Max read is %d bytes\n", len); 1351 usb_stor_dbg(us, "Max read is %d bytes\n", len);
1350 len = min(len, scsi_bufflen(srb)); 1352 len = min(len, scsi_bufflen(srb));
1351 buffer = kmalloc(len, GFP_NOIO); 1353 buffer = kmalloc(len, GFP_NOIO);
1352 if (buffer == NULL) /* bloody hell! */ 1354 if (buffer == NULL) /* bloody hell! */
@@ -1460,10 +1462,9 @@ static int init_usbat(struct us_data *us, int devicetype)
1460 unsigned char *status = us->iobuf; 1462 unsigned char *status = us->iobuf;
1461 1463
1462 us->extra = kzalloc(sizeof(struct usbat_info), GFP_NOIO); 1464 us->extra = kzalloc(sizeof(struct usbat_info), GFP_NOIO);
1463 if (!us->extra) { 1465 if (!us->extra)
1464 US_DEBUGP("init_usbat: Gah! Can't allocate storage for usbat info struct!\n");
1465 return 1; 1466 return 1;
1466 } 1467
1467 info = (struct usbat_info *) (us->extra); 1468 info = (struct usbat_info *) (us->extra);
1468 1469
1469 /* Enable peripheral control signals */ 1470 /* Enable peripheral control signals */
@@ -1473,7 +1474,7 @@ static int init_usbat(struct us_data *us, int devicetype)
1473 if (rc != USB_STOR_XFER_GOOD) 1474 if (rc != USB_STOR_XFER_GOOD)
1474 return USB_STOR_TRANSPORT_ERROR; 1475 return USB_STOR_TRANSPORT_ERROR;
1475 1476
1476 US_DEBUGP("INIT 1\n"); 1477 usb_stor_dbg(us, "INIT 1\n");
1477 1478
1478 msleep(2000); 1479 msleep(2000);
1479 1480
@@ -1481,7 +1482,7 @@ static int init_usbat(struct us_data *us, int devicetype)
1481 if (rc != USB_STOR_TRANSPORT_GOOD) 1482 if (rc != USB_STOR_TRANSPORT_GOOD)
1482 return rc; 1483 return rc;
1483 1484
1484 US_DEBUGP("INIT 2\n"); 1485 usb_stor_dbg(us, "INIT 2\n");
1485 1486
1486 rc = usbat_read_user_io(us, status); 1487 rc = usbat_read_user_io(us, status);
1487 if (rc != USB_STOR_XFER_GOOD) 1488 if (rc != USB_STOR_XFER_GOOD)
@@ -1491,32 +1492,32 @@ static int init_usbat(struct us_data *us, int devicetype)
1491 if (rc != USB_STOR_XFER_GOOD) 1492 if (rc != USB_STOR_XFER_GOOD)
1492 return USB_STOR_TRANSPORT_ERROR; 1493 return USB_STOR_TRANSPORT_ERROR;
1493 1494
1494 US_DEBUGP("INIT 3\n"); 1495 usb_stor_dbg(us, "INIT 3\n");
1495 1496
1496 rc = usbat_select_and_test_registers(us); 1497 rc = usbat_select_and_test_registers(us);
1497 if (rc != USB_STOR_TRANSPORT_GOOD) 1498 if (rc != USB_STOR_TRANSPORT_GOOD)
1498 return rc; 1499 return rc;
1499 1500
1500 US_DEBUGP("INIT 4\n"); 1501 usb_stor_dbg(us, "INIT 4\n");
1501 1502
1502 rc = usbat_read_user_io(us, status); 1503 rc = usbat_read_user_io(us, status);
1503 if (rc != USB_STOR_XFER_GOOD) 1504 if (rc != USB_STOR_XFER_GOOD)
1504 return USB_STOR_TRANSPORT_ERROR; 1505 return USB_STOR_TRANSPORT_ERROR;
1505 1506
1506 US_DEBUGP("INIT 5\n"); 1507 usb_stor_dbg(us, "INIT 5\n");
1507 1508
1508 /* Enable peripheral control signals and card detect */ 1509 /* Enable peripheral control signals and card detect */
1509 rc = usbat_device_enable_cdt(us); 1510 rc = usbat_device_enable_cdt(us);
1510 if (rc != USB_STOR_TRANSPORT_GOOD) 1511 if (rc != USB_STOR_TRANSPORT_GOOD)
1511 return rc; 1512 return rc;
1512 1513
1513 US_DEBUGP("INIT 6\n"); 1514 usb_stor_dbg(us, "INIT 6\n");
1514 1515
1515 rc = usbat_read_user_io(us, status); 1516 rc = usbat_read_user_io(us, status);
1516 if (rc != USB_STOR_XFER_GOOD) 1517 if (rc != USB_STOR_XFER_GOOD)
1517 return USB_STOR_TRANSPORT_ERROR; 1518 return USB_STOR_TRANSPORT_ERROR;
1518 1519
1519 US_DEBUGP("INIT 7\n"); 1520 usb_stor_dbg(us, "INIT 7\n");
1520 1521
1521 msleep(1400); 1522 msleep(1400);
1522 1523
@@ -1524,19 +1525,19 @@ static int init_usbat(struct us_data *us, int devicetype)
1524 if (rc != USB_STOR_XFER_GOOD) 1525 if (rc != USB_STOR_XFER_GOOD)
1525 return USB_STOR_TRANSPORT_ERROR; 1526 return USB_STOR_TRANSPORT_ERROR;
1526 1527
1527 US_DEBUGP("INIT 8\n"); 1528 usb_stor_dbg(us, "INIT 8\n");
1528 1529
1529 rc = usbat_select_and_test_registers(us); 1530 rc = usbat_select_and_test_registers(us);
1530 if (rc != USB_STOR_TRANSPORT_GOOD) 1531 if (rc != USB_STOR_TRANSPORT_GOOD)
1531 return rc; 1532 return rc;
1532 1533
1533 US_DEBUGP("INIT 9\n"); 1534 usb_stor_dbg(us, "INIT 9\n");
1534 1535
1535 /* At this point, we need to detect which device we are using */ 1536 /* At this point, we need to detect which device we are using */
1536 if (usbat_set_transport(us, info, devicetype)) 1537 if (usbat_set_transport(us, info, devicetype))
1537 return USB_STOR_TRANSPORT_ERROR; 1538 return USB_STOR_TRANSPORT_ERROR;
1538 1539
1539 US_DEBUGP("INIT 10\n"); 1540 usb_stor_dbg(us, "INIT 10\n");
1540 1541
1541 if (usbat_get_device_type(us) == USBAT_DEV_FLASH) { 1542 if (usbat_get_device_type(us) == USBAT_DEV_FLASH) {
1542 subcountH = 0x02; 1543 subcountH = 0x02;
@@ -1547,7 +1548,7 @@ static int init_usbat(struct us_data *us, int devicetype)
1547 if (rc != USB_STOR_XFER_GOOD) 1548 if (rc != USB_STOR_XFER_GOOD)
1548 return USB_STOR_TRANSPORT_ERROR; 1549 return USB_STOR_TRANSPORT_ERROR;
1549 1550
1550 US_DEBUGP("INIT 11\n"); 1551 usb_stor_dbg(us, "INIT 11\n");
1551 1552
1552 return USB_STOR_TRANSPORT_GOOD; 1553 return USB_STOR_TRANSPORT_GOOD;
1553} 1554}
@@ -1592,7 +1593,7 @@ static int usbat_hp8200e_transport(struct scsi_cmnd *srb, struct us_data *us)
1592 } 1593 }
1593 1594
1594 result = usbat_get_status(us, status); 1595 result = usbat_get_status(us, status);
1595 US_DEBUGP("Status = %02X\n", *status); 1596 usb_stor_dbg(us, "Status = %02X\n", *status);
1596 if (result != USB_STOR_XFER_GOOD) 1597 if (result != USB_STOR_XFER_GOOD)
1597 return USB_STOR_TRANSPORT_ERROR; 1598 return USB_STOR_TRANSPORT_ERROR;
1598 if (srb->cmnd[0] == TEST_UNIT_READY) 1599 if (srb->cmnd[0] == TEST_UNIT_READY)
@@ -1610,7 +1611,7 @@ static int usbat_hp8200e_transport(struct scsi_cmnd *srb, struct us_data *us)
1610 1611
1611 if (result == USB_STOR_TRANSPORT_GOOD) { 1612 if (result == USB_STOR_TRANSPORT_GOOD) {
1612 transferred += len; 1613 transferred += len;
1613 US_DEBUGP("Wrote %08X bytes\n", transferred); 1614 usb_stor_dbg(us, "Wrote %08X bytes\n", transferred);
1614 } 1615 }
1615 1616
1616 return result; 1617 return result;
@@ -1623,8 +1624,8 @@ static int usbat_hp8200e_transport(struct scsi_cmnd *srb, struct us_data *us)
1623 } 1624 }
1624 1625
1625 if (len > 0xFFFF) { 1626 if (len > 0xFFFF) {
1626 US_DEBUGP("Error: len = %08X... what do I do now?\n", 1627 usb_stor_dbg(us, "Error: len = %08X... what do I do now?\n",
1627 len); 1628 len);
1628 return USB_STOR_TRANSPORT_ERROR; 1629 return USB_STOR_TRANSPORT_ERROR;
1629 } 1630 }
1630 1631
@@ -1693,7 +1694,7 @@ static int usbat_flash_transport(struct scsi_cmnd * srb, struct us_data *us)
1693 }; 1694 };
1694 1695
1695 if (srb->cmnd[0] == INQUIRY) { 1696 if (srb->cmnd[0] == INQUIRY) {
1696 US_DEBUGP("usbat_flash_transport: INQUIRY. Returning bogus response.\n"); 1697 usb_stor_dbg(us, "INQUIRY - Returning bogus response\n");
1697 memcpy(ptr, inquiry_response, sizeof(inquiry_response)); 1698 memcpy(ptr, inquiry_response, sizeof(inquiry_response));
1698 fill_inquiry_response(us, ptr, 36); 1699 fill_inquiry_response(us, ptr, 36);
1699 return USB_STOR_TRANSPORT_GOOD; 1700 return USB_STOR_TRANSPORT_GOOD;
@@ -1710,8 +1711,8 @@ static int usbat_flash_transport(struct scsi_cmnd * srb, struct us_data *us)
1710 1711
1711 /* hard coded 512 byte sectors as per ATA spec */ 1712 /* hard coded 512 byte sectors as per ATA spec */
1712 info->ssize = 0x200; 1713 info->ssize = 0x200;
1713 US_DEBUGP("usbat_flash_transport: READ_CAPACITY: %ld sectors, %ld bytes per sector\n", 1714 usb_stor_dbg(us, "READ_CAPACITY: %ld sectors, %ld bytes per sector\n",
1714 info->sectors, info->ssize); 1715 info->sectors, info->ssize);
1715 1716
1716 /* 1717 /*
1717 * build the reply 1718 * build the reply
@@ -1726,7 +1727,7 @@ static int usbat_flash_transport(struct scsi_cmnd * srb, struct us_data *us)
1726 } 1727 }
1727 1728
1728 if (srb->cmnd[0] == MODE_SELECT_10) { 1729 if (srb->cmnd[0] == MODE_SELECT_10) {
1729 US_DEBUGP("usbat_flash_transport: Gah! MODE_SELECT_10.\n"); 1730 usb_stor_dbg(us, "Gah! MODE_SELECT_10\n");
1730 return USB_STOR_TRANSPORT_ERROR; 1731 return USB_STOR_TRANSPORT_ERROR;
1731 } 1732 }
1732 1733
@@ -1736,7 +1737,8 @@ static int usbat_flash_transport(struct scsi_cmnd * srb, struct us_data *us)
1736 1737
1737 blocks = ((u32)(srb->cmnd[7]) << 8) | ((u32)(srb->cmnd[8])); 1738 blocks = ((u32)(srb->cmnd[7]) << 8) | ((u32)(srb->cmnd[8]));
1738 1739
1739 US_DEBUGP("usbat_flash_transport: READ_10: read block 0x%04lx count %ld\n", block, blocks); 1740 usb_stor_dbg(us, "READ_10: read block 0x%04lx count %ld\n",
1741 block, blocks);
1740 return usbat_flash_read_data(us, info, block, blocks); 1742 return usbat_flash_read_data(us, info, block, blocks);
1741 } 1743 }
1742 1744
@@ -1750,7 +1752,8 @@ static int usbat_flash_transport(struct scsi_cmnd * srb, struct us_data *us)
1750 blocks = ((u32)(srb->cmnd[6]) << 24) | ((u32)(srb->cmnd[7]) << 16) | 1752 blocks = ((u32)(srb->cmnd[6]) << 24) | ((u32)(srb->cmnd[7]) << 16) |
1751 ((u32)(srb->cmnd[8]) << 8) | ((u32)(srb->cmnd[9])); 1753 ((u32)(srb->cmnd[8]) << 8) | ((u32)(srb->cmnd[9]));
1752 1754
1753 US_DEBUGP("usbat_flash_transport: READ_12: read block 0x%04lx count %ld\n", block, blocks); 1755 usb_stor_dbg(us, "READ_12: read block 0x%04lx count %ld\n",
1756 block, blocks);
1754 return usbat_flash_read_data(us, info, block, blocks); 1757 return usbat_flash_read_data(us, info, block, blocks);
1755 } 1758 }
1756 1759
@@ -1760,7 +1763,8 @@ static int usbat_flash_transport(struct scsi_cmnd * srb, struct us_data *us)
1760 1763
1761 blocks = ((u32)(srb->cmnd[7]) << 8) | ((u32)(srb->cmnd[8])); 1764 blocks = ((u32)(srb->cmnd[7]) << 8) | ((u32)(srb->cmnd[8]));
1762 1765
1763 US_DEBUGP("usbat_flash_transport: WRITE_10: write block 0x%04lx count %ld\n", block, blocks); 1766 usb_stor_dbg(us, "WRITE_10: write block 0x%04lx count %ld\n",
1767 block, blocks);
1764 return usbat_flash_write_data(us, info, block, blocks); 1768 return usbat_flash_write_data(us, info, block, blocks);
1765 } 1769 }
1766 1770
@@ -1774,13 +1778,14 @@ static int usbat_flash_transport(struct scsi_cmnd * srb, struct us_data *us)
1774 blocks = ((u32)(srb->cmnd[6]) << 24) | ((u32)(srb->cmnd[7]) << 16) | 1778 blocks = ((u32)(srb->cmnd[6]) << 24) | ((u32)(srb->cmnd[7]) << 16) |
1775 ((u32)(srb->cmnd[8]) << 8) | ((u32)(srb->cmnd[9])); 1779 ((u32)(srb->cmnd[8]) << 8) | ((u32)(srb->cmnd[9]));
1776 1780
1777 US_DEBUGP("usbat_flash_transport: WRITE_12: write block 0x%04lx count %ld\n", block, blocks); 1781 usb_stor_dbg(us, "WRITE_12: write block 0x%04lx count %ld\n",
1782 block, blocks);
1778 return usbat_flash_write_data(us, info, block, blocks); 1783 return usbat_flash_write_data(us, info, block, blocks);
1779 } 1784 }
1780 1785
1781 1786
1782 if (srb->cmnd[0] == TEST_UNIT_READY) { 1787 if (srb->cmnd[0] == TEST_UNIT_READY) {
1783 US_DEBUGP("usbat_flash_transport: TEST_UNIT_READY.\n"); 1788 usb_stor_dbg(us, "TEST_UNIT_READY\n");
1784 1789
1785 rc = usbat_flash_check_media(us, info); 1790 rc = usbat_flash_check_media(us, info);
1786 if (rc != USB_STOR_TRANSPORT_GOOD) 1791 if (rc != USB_STOR_TRANSPORT_GOOD)
@@ -1790,7 +1795,7 @@ static int usbat_flash_transport(struct scsi_cmnd * srb, struct us_data *us)
1790 } 1795 }
1791 1796
1792 if (srb->cmnd[0] == REQUEST_SENSE) { 1797 if (srb->cmnd[0] == REQUEST_SENSE) {
1793 US_DEBUGP("usbat_flash_transport: REQUEST_SENSE.\n"); 1798 usb_stor_dbg(us, "REQUEST_SENSE\n");
1794 1799
1795 memset(ptr, 0, 18); 1800 memset(ptr, 0, 18);
1796 ptr[0] = 0xF0; 1801 ptr[0] = 0xF0;
@@ -1811,8 +1816,8 @@ static int usbat_flash_transport(struct scsi_cmnd * srb, struct us_data *us)
1811 return USB_STOR_TRANSPORT_GOOD; 1816 return USB_STOR_TRANSPORT_GOOD;
1812 } 1817 }
1813 1818
1814 US_DEBUGP("usbat_flash_transport: Gah! Unknown command: %d (0x%x)\n", 1819 usb_stor_dbg(us, "Gah! Unknown command: %d (0x%x)\n",
1815 srb->cmnd[0], srb->cmnd[0]); 1820 srb->cmnd[0], srb->cmnd[0]);
1816 info->sense_key = 0x05; 1821 info->sense_key = 0x05;
1817 info->sense_asc = 0x20; 1822 info->sense_asc = 0x20;
1818 info->sense_ascq = 0x00; 1823 info->sense_ascq = 0x00;
diff --git a/drivers/usb/storage/sierra_ms.c b/drivers/usb/storage/sierra_ms.c
index 17e36952bced..2ea657be14c8 100644
--- a/drivers/usb/storage/sierra_ms.c
+++ b/drivers/usb/storage/sierra_ms.c
@@ -47,7 +47,7 @@ static bool containsFullLinuxPackage(struct swoc_info *swocInfo)
47static int sierra_set_ms_mode(struct usb_device *udev, __u16 eSWocMode) 47static int sierra_set_ms_mode(struct usb_device *udev, __u16 eSWocMode)
48{ 48{
49 int result; 49 int result;
50 US_DEBUGP("SWIMS: %s", "DEVICE MODE SWITCH\n"); 50 dev_dbg(&udev->dev, "SWIMS: %s", "DEVICE MODE SWITCH\n");
51 result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 51 result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
52 SWIMS_USB_REQUEST_SetSwocMode, /* __u8 request */ 52 SWIMS_USB_REQUEST_SetSwocMode, /* __u8 request */
53 USB_TYPE_VENDOR | USB_DIR_OUT, /* __u8 request type */ 53 USB_TYPE_VENDOR | USB_DIR_OUT, /* __u8 request type */
@@ -65,7 +65,7 @@ static int sierra_get_swoc_info(struct usb_device *udev,
65{ 65{
66 int result; 66 int result;
67 67
68 US_DEBUGP("SWIMS: Attempting to get TRU-Install info.\n"); 68 dev_dbg(&udev->dev, "SWIMS: Attempting to get TRU-Install info\n");
69 69
70 result = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 70 result = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
71 SWIMS_USB_REQUEST_GetSwocInfo, /* __u8 request */ 71 SWIMS_USB_REQUEST_GetSwocInfo, /* __u8 request */
@@ -81,11 +81,11 @@ static int sierra_get_swoc_info(struct usb_device *udev,
81 return result; 81 return result;
82} 82}
83 83
84static void debug_swoc(struct swoc_info *swocInfo) 84static void debug_swoc(const struct device *dev, struct swoc_info *swocInfo)
85{ 85{
86 US_DEBUGP("SWIMS: SWoC Rev: %02d \n", swocInfo->rev); 86 dev_dbg(dev, "SWIMS: SWoC Rev: %02d\n", swocInfo->rev);
87 US_DEBUGP("SWIMS: Linux SKU: %04X \n", swocInfo->LinuxSKU); 87 dev_dbg(dev, "SWIMS: Linux SKU: %04X\n", swocInfo->LinuxSKU);
88 US_DEBUGP("SWIMS: Linux Version: %04X \n", swocInfo->LinuxVer); 88 dev_dbg(dev, "SWIMS: Linux Version: %04X\n", swocInfo->LinuxVer);
89} 89}
90 90
91 91
@@ -101,18 +101,17 @@ static ssize_t show_truinst(struct device *dev, struct device_attribute *attr,
101 } else { 101 } else {
102 swocInfo = kmalloc(sizeof(struct swoc_info), GFP_KERNEL); 102 swocInfo = kmalloc(sizeof(struct swoc_info), GFP_KERNEL);
103 if (!swocInfo) { 103 if (!swocInfo) {
104 US_DEBUGP("SWIMS: Allocation failure\n");
105 snprintf(buf, PAGE_SIZE, "Error\n"); 104 snprintf(buf, PAGE_SIZE, "Error\n");
106 return -ENOMEM; 105 return -ENOMEM;
107 } 106 }
108 result = sierra_get_swoc_info(udev, swocInfo); 107 result = sierra_get_swoc_info(udev, swocInfo);
109 if (result < 0) { 108 if (result < 0) {
110 US_DEBUGP("SWIMS: failed SWoC query\n"); 109 dev_dbg(dev, "SWIMS: failed SWoC query\n");
111 kfree(swocInfo); 110 kfree(swocInfo);
112 snprintf(buf, PAGE_SIZE, "Error\n"); 111 snprintf(buf, PAGE_SIZE, "Error\n");
113 return -EIO; 112 return -EIO;
114 } 113 }
115 debug_swoc(swocInfo); 114 debug_swoc(dev, swocInfo);
116 result = snprintf(buf, PAGE_SIZE, 115 result = snprintf(buf, PAGE_SIZE,
117 "REV=%02d SKU=%04X VER=%04X\n", 116 "REV=%02d SKU=%04X VER=%04X\n",
118 swocInfo->rev, 117 swocInfo->rev,
@@ -138,61 +137,55 @@ int sierra_ms_init(struct us_data *us)
138 sh = us_to_host(us); 137 sh = us_to_host(us);
139 scsi_get_host_dev(sh); 138 scsi_get_host_dev(sh);
140 139
141 US_DEBUGP("SWIMS: sierra_ms_init called\n");
142
143 /* Force Modem mode */ 140 /* Force Modem mode */
144 if (swi_tru_install == TRU_FORCE_MODEM) { 141 if (swi_tru_install == TRU_FORCE_MODEM) {
145 US_DEBUGP("SWIMS: %s", "Forcing Modem Mode\n"); 142 usb_stor_dbg(us, "SWIMS: Forcing Modem Mode\n");
146 result = sierra_set_ms_mode(udev, SWIMS_SET_MODE_Modem); 143 result = sierra_set_ms_mode(udev, SWIMS_SET_MODE_Modem);
147 if (result < 0) 144 if (result < 0)
148 US_DEBUGP("SWIMS: Failed to switch to modem mode.\n"); 145 usb_stor_dbg(us, "SWIMS: Failed to switch to modem mode\n");
149 return -EIO; 146 return -EIO;
150 } 147 }
151 /* Force Mass Storage mode (keep CD-Rom) */ 148 /* Force Mass Storage mode (keep CD-Rom) */
152 else if (swi_tru_install == TRU_FORCE_MS) { 149 else if (swi_tru_install == TRU_FORCE_MS) {
153 US_DEBUGP("SWIMS: %s", "Forcing Mass Storage Mode\n"); 150 usb_stor_dbg(us, "SWIMS: Forcing Mass Storage Mode\n");
154 goto complete; 151 goto complete;
155 } 152 }
156 /* Normal TRU-Install Logic */ 153 /* Normal TRU-Install Logic */
157 else { 154 else {
158 US_DEBUGP("SWIMS: %s", "Normal SWoC Logic\n"); 155 usb_stor_dbg(us, "SWIMS: Normal SWoC Logic\n");
159 156
160 swocInfo = kmalloc(sizeof(struct swoc_info), 157 swocInfo = kmalloc(sizeof(struct swoc_info),
161 GFP_KERNEL); 158 GFP_KERNEL);
162 if (!swocInfo) { 159 if (!swocInfo)
163 US_DEBUGP("SWIMS: %s", "Allocation failure\n");
164 return -ENOMEM; 160 return -ENOMEM;
165 }
166 161
167 retries = 3; 162 retries = 3;
168 do { 163 do {
169 retries--; 164 retries--;
170 result = sierra_get_swoc_info(udev, swocInfo); 165 result = sierra_get_swoc_info(udev, swocInfo);
171 if (result < 0) { 166 if (result < 0) {
172 US_DEBUGP("SWIMS: %s", "Failed SWoC query\n"); 167 usb_stor_dbg(us, "SWIMS: Failed SWoC query\n");
173 schedule_timeout_uninterruptible(2*HZ); 168 schedule_timeout_uninterruptible(2*HZ);
174 } 169 }
175 } while (retries && result < 0); 170 } while (retries && result < 0);
176 171
177 if (result < 0) { 172 if (result < 0) {
178 US_DEBUGP("SWIMS: %s", 173 usb_stor_dbg(us, "SWIMS: Completely failed SWoC query\n");
179 "Completely failed SWoC query\n");
180 kfree(swocInfo); 174 kfree(swocInfo);
181 return -EIO; 175 return -EIO;
182 } 176 }
183 177
184 debug_swoc(swocInfo); 178 debug_swoc(&us->pusb_dev->dev, swocInfo);
185 179
186 /* If there is not Linux software on the TRU-Install device 180 /* If there is not Linux software on the TRU-Install device
187 * then switch to modem mode 181 * then switch to modem mode
188 */ 182 */
189 if (!containsFullLinuxPackage(swocInfo)) { 183 if (!containsFullLinuxPackage(swocInfo)) {
190 US_DEBUGP("SWIMS: %s", 184 usb_stor_dbg(us, "SWIMS: Switching to Modem Mode\n");
191 "Switching to Modem Mode\n");
192 result = sierra_set_ms_mode(udev, 185 result = sierra_set_ms_mode(udev,
193 SWIMS_SET_MODE_Modem); 186 SWIMS_SET_MODE_Modem);
194 if (result < 0) 187 if (result < 0)
195 US_DEBUGP("SWIMS: Failed to switch modem\n"); 188 usb_stor_dbg(us, "SWIMS: Failed to switch modem\n");
196 kfree(swocInfo); 189 kfree(swocInfo);
197 return -EIO; 190 return -EIO;
198 } 191 }
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index c0543c83923e..22c7d4360fa2 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -166,7 +166,7 @@ static int usb_stor_msg_common(struct us_data *us, int timeout)
166 166
167 /* cancel the URB, if it hasn't been cancelled already */ 167 /* cancel the URB, if it hasn't been cancelled already */
168 if (test_and_clear_bit(US_FLIDX_URB_ACTIVE, &us->dflags)) { 168 if (test_and_clear_bit(US_FLIDX_URB_ACTIVE, &us->dflags)) {
169 US_DEBUGP("-- cancelling URB\n"); 169 usb_stor_dbg(us, "-- cancelling URB\n");
170 usb_unlink_urb(us->current_urb); 170 usb_unlink_urb(us->current_urb);
171 } 171 }
172 } 172 }
@@ -178,8 +178,8 @@ static int usb_stor_msg_common(struct us_data *us, int timeout)
178 clear_bit(US_FLIDX_URB_ACTIVE, &us->dflags); 178 clear_bit(US_FLIDX_URB_ACTIVE, &us->dflags);
179 179
180 if (timeleft <= 0) { 180 if (timeleft <= 0) {
181 US_DEBUGP("%s -- cancelling URB\n", 181 usb_stor_dbg(us, "%s -- cancelling URB\n",
182 timeleft == 0 ? "Timeout" : "Signal"); 182 timeleft == 0 ? "Timeout" : "Signal");
183 usb_kill_urb(us->current_urb); 183 usb_kill_urb(us->current_urb);
184 } 184 }
185 185
@@ -197,9 +197,8 @@ int usb_stor_control_msg(struct us_data *us, unsigned int pipe,
197{ 197{
198 int status; 198 int status;
199 199
200 US_DEBUGP("%s: rq=%02x rqtype=%02x value=%04x index=%02x len=%u\n", 200 usb_stor_dbg(us, "rq=%02x rqtype=%02x value=%04x index=%02x len=%u\n",
201 __func__, request, requesttype, 201 request, requesttype, value, index, size);
202 value, index, size);
203 202
204 /* fill in the devrequest structure */ 203 /* fill in the devrequest structure */
205 us->cr->bRequestType = requesttype; 204 us->cr->bRequestType = requesttype;
@@ -249,7 +248,7 @@ int usb_stor_clear_halt(struct us_data *us, unsigned int pipe)
249 if (result >= 0) 248 if (result >= 0)
250 usb_reset_endpoint(us->pusb_dev, endp); 249 usb_reset_endpoint(us->pusb_dev, endp);
251 250
252 US_DEBUGP("%s: result = %d\n", __func__, result); 251 usb_stor_dbg(us, "result = %d\n", result);
253 return result; 252 return result;
254} 253}
255EXPORT_SYMBOL_GPL(usb_stor_clear_halt); 254EXPORT_SYMBOL_GPL(usb_stor_clear_halt);
@@ -265,18 +264,18 @@ EXPORT_SYMBOL_GPL(usb_stor_clear_halt);
265static int interpret_urb_result(struct us_data *us, unsigned int pipe, 264static int interpret_urb_result(struct us_data *us, unsigned int pipe,
266 unsigned int length, int result, unsigned int partial) 265 unsigned int length, int result, unsigned int partial)
267{ 266{
268 US_DEBUGP("Status code %d; transferred %u/%u\n", 267 usb_stor_dbg(us, "Status code %d; transferred %u/%u\n",
269 result, partial, length); 268 result, partial, length);
270 switch (result) { 269 switch (result) {
271 270
272 /* no error code; did we send all the data? */ 271 /* no error code; did we send all the data? */
273 case 0: 272 case 0:
274 if (partial != length) { 273 if (partial != length) {
275 US_DEBUGP("-- short transfer\n"); 274 usb_stor_dbg(us, "-- short transfer\n");
276 return USB_STOR_XFER_SHORT; 275 return USB_STOR_XFER_SHORT;
277 } 276 }
278 277
279 US_DEBUGP("-- transfer complete\n"); 278 usb_stor_dbg(us, "-- transfer complete\n");
280 return USB_STOR_XFER_GOOD; 279 return USB_STOR_XFER_GOOD;
281 280
282 /* stalled */ 281 /* stalled */
@@ -284,39 +283,40 @@ static int interpret_urb_result(struct us_data *us, unsigned int pipe,
284 /* for control endpoints, (used by CB[I]) a stall indicates 283 /* for control endpoints, (used by CB[I]) a stall indicates
285 * a failed command */ 284 * a failed command */
286 if (usb_pipecontrol(pipe)) { 285 if (usb_pipecontrol(pipe)) {
287 US_DEBUGP("-- stall on control pipe\n"); 286 usb_stor_dbg(us, "-- stall on control pipe\n");
288 return USB_STOR_XFER_STALLED; 287 return USB_STOR_XFER_STALLED;
289 } 288 }
290 289
291 /* for other sorts of endpoint, clear the stall */ 290 /* for other sorts of endpoint, clear the stall */
292 US_DEBUGP("clearing endpoint halt for pipe 0x%x\n", pipe); 291 usb_stor_dbg(us, "clearing endpoint halt for pipe 0x%x\n",
292 pipe);
293 if (usb_stor_clear_halt(us, pipe) < 0) 293 if (usb_stor_clear_halt(us, pipe) < 0)
294 return USB_STOR_XFER_ERROR; 294 return USB_STOR_XFER_ERROR;
295 return USB_STOR_XFER_STALLED; 295 return USB_STOR_XFER_STALLED;
296 296
297 /* babble - the device tried to send more than we wanted to read */ 297 /* babble - the device tried to send more than we wanted to read */
298 case -EOVERFLOW: 298 case -EOVERFLOW:
299 US_DEBUGP("-- babble\n"); 299 usb_stor_dbg(us, "-- babble\n");
300 return USB_STOR_XFER_LONG; 300 return USB_STOR_XFER_LONG;
301 301
302 /* the transfer was cancelled by abort, disconnect, or timeout */ 302 /* the transfer was cancelled by abort, disconnect, or timeout */
303 case -ECONNRESET: 303 case -ECONNRESET:
304 US_DEBUGP("-- transfer cancelled\n"); 304 usb_stor_dbg(us, "-- transfer cancelled\n");
305 return USB_STOR_XFER_ERROR; 305 return USB_STOR_XFER_ERROR;
306 306
307 /* short scatter-gather read transfer */ 307 /* short scatter-gather read transfer */
308 case -EREMOTEIO: 308 case -EREMOTEIO:
309 US_DEBUGP("-- short read transfer\n"); 309 usb_stor_dbg(us, "-- short read transfer\n");
310 return USB_STOR_XFER_SHORT; 310 return USB_STOR_XFER_SHORT;
311 311
312 /* abort or disconnect in progress */ 312 /* abort or disconnect in progress */
313 case -EIO: 313 case -EIO:
314 US_DEBUGP("-- abort or disconnect in progress\n"); 314 usb_stor_dbg(us, "-- abort or disconnect in progress\n");
315 return USB_STOR_XFER_ERROR; 315 return USB_STOR_XFER_ERROR;
316 316
317 /* the catch-all error case */ 317 /* the catch-all error case */
318 default: 318 default:
319 US_DEBUGP("-- unknown error\n"); 319 usb_stor_dbg(us, "-- unknown error\n");
320 return USB_STOR_XFER_ERROR; 320 return USB_STOR_XFER_ERROR;
321 } 321 }
322} 322}
@@ -331,9 +331,8 @@ int usb_stor_ctrl_transfer(struct us_data *us, unsigned int pipe,
331{ 331{
332 int result; 332 int result;
333 333
334 US_DEBUGP("%s: rq=%02x rqtype=%02x value=%04x index=%02x len=%u\n", 334 usb_stor_dbg(us, "rq=%02x rqtype=%02x value=%04x index=%02x len=%u\n",
335 __func__, request, requesttype, 335 request, requesttype, value, index, size);
336 value, index, size);
337 336
338 /* fill in the devrequest structure */ 337 /* fill in the devrequest structure */
339 us->cr->bRequestType = requesttype; 338 us->cr->bRequestType = requesttype;
@@ -367,7 +366,7 @@ static int usb_stor_intr_transfer(struct us_data *us, void *buf,
367 unsigned int pipe = us->recv_intr_pipe; 366 unsigned int pipe = us->recv_intr_pipe;
368 unsigned int maxp; 367 unsigned int maxp;
369 368
370 US_DEBUGP("%s: xfer %u bytes\n", __func__, length); 369 usb_stor_dbg(us, "xfer %u bytes\n", length);
371 370
372 /* calculate the max packet size */ 371 /* calculate the max packet size */
373 maxp = usb_maxpacket(us->pusb_dev, pipe, usb_pipeout(pipe)); 372 maxp = usb_maxpacket(us->pusb_dev, pipe, usb_pipeout(pipe));
@@ -394,7 +393,7 @@ int usb_stor_bulk_transfer_buf(struct us_data *us, unsigned int pipe,
394{ 393{
395 int result; 394 int result;
396 395
397 US_DEBUGP("%s: xfer %u bytes\n", __func__, length); 396 usb_stor_dbg(us, "xfer %u bytes\n", length);
398 397
399 /* fill and submit the URB */ 398 /* fill and submit the URB */
400 usb_fill_bulk_urb(us->current_urb, us->pusb_dev, pipe, buf, length, 399 usb_fill_bulk_urb(us->current_urb, us->pusb_dev, pipe, buf, length,
@@ -426,12 +425,11 @@ static int usb_stor_bulk_transfer_sglist(struct us_data *us, unsigned int pipe,
426 return USB_STOR_XFER_ERROR; 425 return USB_STOR_XFER_ERROR;
427 426
428 /* initialize the scatter-gather request block */ 427 /* initialize the scatter-gather request block */
429 US_DEBUGP("%s: xfer %u bytes, %d entries\n", __func__, 428 usb_stor_dbg(us, "xfer %u bytes, %d entries\n", length, num_sg);
430 length, num_sg);
431 result = usb_sg_init(&us->current_sg, us->pusb_dev, pipe, 0, 429 result = usb_sg_init(&us->current_sg, us->pusb_dev, pipe, 0,
432 sg, num_sg, length, GFP_NOIO); 430 sg, num_sg, length, GFP_NOIO);
433 if (result) { 431 if (result) {
434 US_DEBUGP("usb_sg_init returned %d\n", result); 432 usb_stor_dbg(us, "usb_sg_init returned %d\n", result);
435 return USB_STOR_XFER_ERROR; 433 return USB_STOR_XFER_ERROR;
436 } 434 }
437 435
@@ -444,7 +442,7 @@ static int usb_stor_bulk_transfer_sglist(struct us_data *us, unsigned int pipe,
444 442
445 /* cancel the request, if it hasn't been cancelled already */ 443 /* cancel the request, if it hasn't been cancelled already */
446 if (test_and_clear_bit(US_FLIDX_SG_ACTIVE, &us->dflags)) { 444 if (test_and_clear_bit(US_FLIDX_SG_ACTIVE, &us->dflags)) {
447 US_DEBUGP("-- cancelling sg request\n"); 445 usb_stor_dbg(us, "-- cancelling sg request\n");
448 usb_sg_cancel(&us->current_sg); 446 usb_sg_cancel(&us->current_sg);
449 } 447 }
450 } 448 }
@@ -609,14 +607,14 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
609 * short-circuit all other processing 607 * short-circuit all other processing
610 */ 608 */
611 if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) { 609 if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) {
612 US_DEBUGP("-- command was aborted\n"); 610 usb_stor_dbg(us, "-- command was aborted\n");
613 srb->result = DID_ABORT << 16; 611 srb->result = DID_ABORT << 16;
614 goto Handle_Errors; 612 goto Handle_Errors;
615 } 613 }
616 614
617 /* if there is a transport error, reset and don't auto-sense */ 615 /* if there is a transport error, reset and don't auto-sense */
618 if (result == USB_STOR_TRANSPORT_ERROR) { 616 if (result == USB_STOR_TRANSPORT_ERROR) {
619 US_DEBUGP("-- transport indicates error, resetting\n"); 617 usb_stor_dbg(us, "-- transport indicates error, resetting\n");
620 srb->result = DID_ERROR << 16; 618 srb->result = DID_ERROR << 16;
621 goto Handle_Errors; 619 goto Handle_Errors;
622 } 620 }
@@ -645,7 +643,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
645 */ 643 */
646 if ((us->protocol == USB_PR_CB || us->protocol == USB_PR_DPCM_USB) && 644 if ((us->protocol == USB_PR_CB || us->protocol == USB_PR_DPCM_USB) &&
647 srb->sc_data_direction != DMA_FROM_DEVICE) { 645 srb->sc_data_direction != DMA_FROM_DEVICE) {
648 US_DEBUGP("-- CB transport device requiring auto-sense\n"); 646 usb_stor_dbg(us, "-- CB transport device requiring auto-sense\n");
649 need_auto_sense = 1; 647 need_auto_sense = 1;
650 } 648 }
651 649
@@ -655,7 +653,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
655 * "failure" and an "error" in the transport mechanism. 653 * "failure" and an "error" in the transport mechanism.
656 */ 654 */
657 if (result == USB_STOR_TRANSPORT_FAILED) { 655 if (result == USB_STOR_TRANSPORT_FAILED) {
658 US_DEBUGP("-- transport indicates command failure\n"); 656 usb_stor_dbg(us, "-- transport indicates command failure\n");
659 need_auto_sense = 1; 657 need_auto_sense = 1;
660 } 658 }
661 659
@@ -670,7 +668,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
670 !(us->fflags & US_FL_SANE_SENSE) && 668 !(us->fflags & US_FL_SANE_SENSE) &&
671 !(us->fflags & US_FL_BAD_SENSE) && 669 !(us->fflags & US_FL_BAD_SENSE) &&
672 !(srb->cmnd[2] & 0x20))) { 670 !(srb->cmnd[2] & 0x20))) {
673 US_DEBUGP("-- SAT supported, increasing auto-sense\n"); 671 usb_stor_dbg(us, "-- SAT supported, increasing auto-sense\n");
674 us->fflags |= US_FL_SANE_SENSE; 672 us->fflags |= US_FL_SANE_SENSE;
675 } 673 }
676 674
@@ -684,7 +682,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
684 (srb->cmnd[0] == MODE_SENSE) || 682 (srb->cmnd[0] == MODE_SENSE) ||
685 (srb->cmnd[0] == LOG_SENSE) || 683 (srb->cmnd[0] == LOG_SENSE) ||
686 (srb->cmnd[0] == MODE_SENSE_10))) { 684 (srb->cmnd[0] == MODE_SENSE_10))) {
687 US_DEBUGP("-- unexpectedly short transfer\n"); 685 usb_stor_dbg(us, "-- unexpectedly short transfer\n");
688 } 686 }
689 687
690 /* Now, if we need to do the auto-sense, let's do it */ 688 /* Now, if we need to do the auto-sense, let's do it */
@@ -700,7 +698,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
700 if (us->fflags & US_FL_SANE_SENSE) 698 if (us->fflags & US_FL_SANE_SENSE)
701 sense_size = ~0; 699 sense_size = ~0;
702Retry_Sense: 700Retry_Sense:
703 US_DEBUGP("Issuing auto-REQUEST_SENSE\n"); 701 usb_stor_dbg(us, "Issuing auto-REQUEST_SENSE\n");
704 702
705 scsi_eh_prep_cmnd(srb, &ses, NULL, 0, sense_size); 703 scsi_eh_prep_cmnd(srb, &ses, NULL, 0, sense_size);
706 704
@@ -719,7 +717,7 @@ Retry_Sense:
719 scsi_eh_restore_cmnd(srb, &ses); 717 scsi_eh_restore_cmnd(srb, &ses);
720 718
721 if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) { 719 if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) {
722 US_DEBUGP("-- auto-sense aborted\n"); 720 usb_stor_dbg(us, "-- auto-sense aborted\n");
723 srb->result = DID_ABORT << 16; 721 srb->result = DID_ABORT << 16;
724 722
725 /* If SANE_SENSE caused this problem, disable it */ 723 /* If SANE_SENSE caused this problem, disable it */
@@ -737,7 +735,7 @@ Retry_Sense:
737 */ 735 */
738 if (temp_result == USB_STOR_TRANSPORT_FAILED && 736 if (temp_result == USB_STOR_TRANSPORT_FAILED &&
739 sense_size != US_SENSE_SIZE) { 737 sense_size != US_SENSE_SIZE) {
740 US_DEBUGP("-- auto-sense failure, retry small sense\n"); 738 usb_stor_dbg(us, "-- auto-sense failure, retry small sense\n");
741 sense_size = US_SENSE_SIZE; 739 sense_size = US_SENSE_SIZE;
742 us->fflags &= ~US_FL_SANE_SENSE; 740 us->fflags &= ~US_FL_SANE_SENSE;
743 us->fflags |= US_FL_BAD_SENSE; 741 us->fflags |= US_FL_BAD_SENSE;
@@ -746,7 +744,7 @@ Retry_Sense:
746 744
747 /* Other failures */ 745 /* Other failures */
748 if (temp_result != USB_STOR_TRANSPORT_GOOD) { 746 if (temp_result != USB_STOR_TRANSPORT_GOOD) {
749 US_DEBUGP("-- auto-sense failure\n"); 747 usb_stor_dbg(us, "-- auto-sense failure\n");
750 748
751 /* we skip the reset if this happens to be a 749 /* we skip the reset if this happens to be a
752 * multi-target device, since failure of an 750 * multi-target device, since failure of an
@@ -766,27 +764,28 @@ Retry_Sense:
766 !(us->fflags & US_FL_SANE_SENSE) && 764 !(us->fflags & US_FL_SANE_SENSE) &&
767 !(us->fflags & US_FL_BAD_SENSE) && 765 !(us->fflags & US_FL_BAD_SENSE) &&
768 (srb->sense_buffer[0] & 0x7C) == 0x70) { 766 (srb->sense_buffer[0] & 0x7C) == 0x70) {
769 US_DEBUGP("-- SANE_SENSE support enabled\n"); 767 usb_stor_dbg(us, "-- SANE_SENSE support enabled\n");
770 us->fflags |= US_FL_SANE_SENSE; 768 us->fflags |= US_FL_SANE_SENSE;
771 769
772 /* Indicate to the user that we truncated their sense 770 /* Indicate to the user that we truncated their sense
773 * because we didn't know it supported larger sense. 771 * because we didn't know it supported larger sense.
774 */ 772 */
775 US_DEBUGP("-- Sense data truncated to %i from %i\n", 773 usb_stor_dbg(us, "-- Sense data truncated to %i from %i\n",
776 US_SENSE_SIZE, 774 US_SENSE_SIZE,
777 srb->sense_buffer[7] + 8); 775 srb->sense_buffer[7] + 8);
778 srb->sense_buffer[7] = (US_SENSE_SIZE - 8); 776 srb->sense_buffer[7] = (US_SENSE_SIZE - 8);
779 } 777 }
780 778
781 scsi_normalize_sense(srb->sense_buffer, SCSI_SENSE_BUFFERSIZE, 779 scsi_normalize_sense(srb->sense_buffer, SCSI_SENSE_BUFFERSIZE,
782 &sshdr); 780 &sshdr);
783 781
784 US_DEBUGP("-- Result from auto-sense is %d\n", temp_result); 782 usb_stor_dbg(us, "-- Result from auto-sense is %d\n",
785 US_DEBUGP("-- code: 0x%x, key: 0x%x, ASC: 0x%x, ASCQ: 0x%x\n", 783 temp_result);
786 sshdr.response_code, sshdr.sense_key, 784 usb_stor_dbg(us, "-- code: 0x%x, key: 0x%x, ASC: 0x%x, ASCQ: 0x%x\n",
787 sshdr.asc, sshdr.ascq); 785 sshdr.response_code, sshdr.sense_key,
786 sshdr.asc, sshdr.ascq);
788#ifdef CONFIG_USB_STORAGE_DEBUG 787#ifdef CONFIG_USB_STORAGE_DEBUG
789 usb_stor_show_sense(sshdr.sense_key, sshdr.asc, sshdr.ascq); 788 usb_stor_show_sense(us, sshdr.sense_key, sshdr.asc, sshdr.ascq);
790#endif 789#endif
791 790
792 /* set the result so the higher layers expect this data */ 791 /* set the result so the higher layers expect this data */
@@ -892,20 +891,18 @@ Retry_Sense:
892/* Stop the current URB transfer */ 891/* Stop the current URB transfer */
893void usb_stor_stop_transport(struct us_data *us) 892void usb_stor_stop_transport(struct us_data *us)
894{ 893{
895 US_DEBUGP("%s called\n", __func__);
896
897 /* If the state machine is blocked waiting for an URB, 894 /* If the state machine is blocked waiting for an URB,
898 * let's wake it up. The test_and_clear_bit() call 895 * let's wake it up. The test_and_clear_bit() call
899 * guarantees that if a URB has just been submitted, 896 * guarantees that if a URB has just been submitted,
900 * it won't be cancelled more than once. */ 897 * it won't be cancelled more than once. */
901 if (test_and_clear_bit(US_FLIDX_URB_ACTIVE, &us->dflags)) { 898 if (test_and_clear_bit(US_FLIDX_URB_ACTIVE, &us->dflags)) {
902 US_DEBUGP("-- cancelling URB\n"); 899 usb_stor_dbg(us, "-- cancelling URB\n");
903 usb_unlink_urb(us->current_urb); 900 usb_unlink_urb(us->current_urb);
904 } 901 }
905 902
906 /* If we are waiting for a scatter-gather operation, cancel it. */ 903 /* If we are waiting for a scatter-gather operation, cancel it. */
907 if (test_and_clear_bit(US_FLIDX_SG_ACTIVE, &us->dflags)) { 904 if (test_and_clear_bit(US_FLIDX_SG_ACTIVE, &us->dflags)) {
908 US_DEBUGP("-- cancelling sg request\n"); 905 usb_stor_dbg(us, "-- cancelling sg request\n");
909 usb_sg_cancel(&us->current_sg); 906 usb_sg_cancel(&us->current_sg);
910 } 907 }
911} 908}
@@ -928,7 +925,8 @@ int usb_stor_CB_transport(struct scsi_cmnd *srb, struct us_data *us)
928 us->ifnum, srb->cmnd, srb->cmd_len); 925 us->ifnum, srb->cmnd, srb->cmd_len);
929 926
930 /* check the return code for the command */ 927 /* check the return code for the command */
931 US_DEBUGP("Call to usb_stor_ctrl_transfer() returned %d\n", result); 928 usb_stor_dbg(us, "Call to usb_stor_ctrl_transfer() returned %d\n",
929 result);
932 930
933 /* if we stalled the command, it means command failed */ 931 /* if we stalled the command, it means command failed */
934 if (result == USB_STOR_XFER_STALLED) { 932 if (result == USB_STOR_XFER_STALLED) {
@@ -946,7 +944,7 @@ int usb_stor_CB_transport(struct scsi_cmnd *srb, struct us_data *us)
946 pipe = srb->sc_data_direction == DMA_FROM_DEVICE ? 944 pipe = srb->sc_data_direction == DMA_FROM_DEVICE ?
947 us->recv_bulk_pipe : us->send_bulk_pipe; 945 us->recv_bulk_pipe : us->send_bulk_pipe;
948 result = usb_stor_bulk_srb(us, pipe, srb); 946 result = usb_stor_bulk_srb(us, pipe, srb);
949 US_DEBUGP("CBI data stage result is 0x%x\n", result); 947 usb_stor_dbg(us, "CBI data stage result is 0x%x\n", result);
950 948
951 /* if we stalled the data transfer it means command failed */ 949 /* if we stalled the data transfer it means command failed */
952 if (result == USB_STOR_XFER_STALLED) 950 if (result == USB_STOR_XFER_STALLED)
@@ -964,8 +962,8 @@ int usb_stor_CB_transport(struct scsi_cmnd *srb, struct us_data *us)
964 return USB_STOR_TRANSPORT_GOOD; 962 return USB_STOR_TRANSPORT_GOOD;
965 963
966 result = usb_stor_intr_transfer(us, us->iobuf, 2); 964 result = usb_stor_intr_transfer(us, us->iobuf, 2);
967 US_DEBUGP("Got interrupt data (0x%x, 0x%x)\n", 965 usb_stor_dbg(us, "Got interrupt data (0x%x, 0x%x)\n",
968 us->iobuf[0], us->iobuf[1]); 966 us->iobuf[0], us->iobuf[1]);
969 if (result != USB_STOR_XFER_GOOD) 967 if (result != USB_STOR_XFER_GOOD)
970 return USB_STOR_TRANSPORT_ERROR; 968 return USB_STOR_TRANSPORT_ERROR;
971 969
@@ -992,8 +990,8 @@ int usb_stor_CB_transport(struct scsi_cmnd *srb, struct us_data *us)
992 * into the first byte -- so if it's non-zero, call it a failure. 990 * into the first byte -- so if it's non-zero, call it a failure.
993 */ 991 */
994 if (us->iobuf[0]) { 992 if (us->iobuf[0]) {
995 US_DEBUGP("CBI IRQ data showed reserved bType 0x%x\n", 993 usb_stor_dbg(us, "CBI IRQ data showed reserved bType 0x%x\n",
996 us->iobuf[0]); 994 us->iobuf[0]);
997 goto Failed; 995 goto Failed;
998 996
999 } 997 }
@@ -1034,8 +1032,8 @@ int usb_stor_Bulk_max_lun(struct us_data *us)
1034 USB_RECIP_INTERFACE, 1032 USB_RECIP_INTERFACE,
1035 0, us->ifnum, us->iobuf, 1, 10*HZ); 1033 0, us->ifnum, us->iobuf, 1, 10*HZ);
1036 1034
1037 US_DEBUGP("GetMaxLUN command result is %d, data is %d\n", 1035 usb_stor_dbg(us, "GetMaxLUN command result is %d, data is %d\n",
1038 result, us->iobuf[0]); 1036 result, us->iobuf[0]);
1039 1037
1040 /* if we have a successful request, return the result */ 1038 /* if we have a successful request, return the result */
1041 if (result > 0) 1039 if (result > 0)
@@ -1084,14 +1082,14 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
1084 memcpy(bcb->CDB, srb->cmnd, bcb->Length); 1082 memcpy(bcb->CDB, srb->cmnd, bcb->Length);
1085 1083
1086 /* send it to out endpoint */ 1084 /* send it to out endpoint */
1087 US_DEBUGP("Bulk Command S 0x%x T 0x%x L %d F %d Trg %d LUN %d CL %d\n", 1085 usb_stor_dbg(us, "Bulk Command S 0x%x T 0x%x L %d F %d Trg %d LUN %d CL %d\n",
1088 le32_to_cpu(bcb->Signature), bcb->Tag, 1086 le32_to_cpu(bcb->Signature), bcb->Tag,
1089 le32_to_cpu(bcb->DataTransferLength), bcb->Flags, 1087 le32_to_cpu(bcb->DataTransferLength), bcb->Flags,
1090 (bcb->Lun >> 4), (bcb->Lun & 0x0F), 1088 (bcb->Lun >> 4), (bcb->Lun & 0x0F),
1091 bcb->Length); 1089 bcb->Length);
1092 result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, 1090 result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,
1093 bcb, cbwlen, NULL); 1091 bcb, cbwlen, NULL);
1094 US_DEBUGP("Bulk command transfer result=%d\n", result); 1092 usb_stor_dbg(us, "Bulk command transfer result=%d\n", result);
1095 if (result != USB_STOR_XFER_GOOD) 1093 if (result != USB_STOR_XFER_GOOD)
1096 return USB_STOR_TRANSPORT_ERROR; 1094 return USB_STOR_TRANSPORT_ERROR;
1097 1095
@@ -1108,7 +1106,7 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
1108 unsigned int pipe = srb->sc_data_direction == DMA_FROM_DEVICE ? 1106 unsigned int pipe = srb->sc_data_direction == DMA_FROM_DEVICE ?
1109 us->recv_bulk_pipe : us->send_bulk_pipe; 1107 us->recv_bulk_pipe : us->send_bulk_pipe;
1110 result = usb_stor_bulk_srb(us, pipe, srb); 1108 result = usb_stor_bulk_srb(us, pipe, srb);
1111 US_DEBUGP("Bulk data transfer result 0x%x\n", result); 1109 usb_stor_dbg(us, "Bulk data transfer result 0x%x\n", result);
1112 if (result == USB_STOR_XFER_ERROR) 1110 if (result == USB_STOR_XFER_ERROR)
1113 return USB_STOR_TRANSPORT_ERROR; 1111 return USB_STOR_TRANSPORT_ERROR;
1114 1112
@@ -1127,7 +1125,7 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
1127 */ 1125 */
1128 1126
1129 /* get CSW for device status */ 1127 /* get CSW for device status */
1130 US_DEBUGP("Attempting to get CSW...\n"); 1128 usb_stor_dbg(us, "Attempting to get CSW...\n");
1131 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, 1129 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
1132 bcs, US_BULK_CS_WRAP_LEN, &cswlen); 1130 bcs, US_BULK_CS_WRAP_LEN, &cswlen);
1133 1131
@@ -1136,7 +1134,7 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
1136 * CSWs. If we encounter such a thing, try to read the CSW again. 1134 * CSWs. If we encounter such a thing, try to read the CSW again.
1137 */ 1135 */
1138 if (result == USB_STOR_XFER_SHORT && cswlen == 0) { 1136 if (result == USB_STOR_XFER_SHORT && cswlen == 0) {
1139 US_DEBUGP("Received 0-length CSW; retrying...\n"); 1137 usb_stor_dbg(us, "Received 0-length CSW; retrying...\n");
1140 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, 1138 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
1141 bcs, US_BULK_CS_WRAP_LEN, &cswlen); 1139 bcs, US_BULK_CS_WRAP_LEN, &cswlen);
1142 } 1140 }
@@ -1145,24 +1143,24 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
1145 if (result == USB_STOR_XFER_STALLED) { 1143 if (result == USB_STOR_XFER_STALLED) {
1146 1144
1147 /* get the status again */ 1145 /* get the status again */
1148 US_DEBUGP("Attempting to get CSW (2nd try)...\n"); 1146 usb_stor_dbg(us, "Attempting to get CSW (2nd try)...\n");
1149 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, 1147 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
1150 bcs, US_BULK_CS_WRAP_LEN, NULL); 1148 bcs, US_BULK_CS_WRAP_LEN, NULL);
1151 } 1149 }
1152 1150
1153 /* if we still have a failure at this point, we're in trouble */ 1151 /* if we still have a failure at this point, we're in trouble */
1154 US_DEBUGP("Bulk status result = %d\n", result); 1152 usb_stor_dbg(us, "Bulk status result = %d\n", result);
1155 if (result != USB_STOR_XFER_GOOD) 1153 if (result != USB_STOR_XFER_GOOD)
1156 return USB_STOR_TRANSPORT_ERROR; 1154 return USB_STOR_TRANSPORT_ERROR;
1157 1155
1158 /* check bulk status */ 1156 /* check bulk status */
1159 residue = le32_to_cpu(bcs->Residue); 1157 residue = le32_to_cpu(bcs->Residue);
1160 US_DEBUGP("Bulk Status S 0x%x T 0x%x R %u Stat 0x%x\n", 1158 usb_stor_dbg(us, "Bulk Status S 0x%x T 0x%x R %u Stat 0x%x\n",
1161 le32_to_cpu(bcs->Signature), bcs->Tag, 1159 le32_to_cpu(bcs->Signature), bcs->Tag,
1162 residue, bcs->Status); 1160 residue, bcs->Status);
1163 if (!(bcs->Tag == us->tag || (us->fflags & US_FL_BULK_IGNORE_TAG)) || 1161 if (!(bcs->Tag == us->tag || (us->fflags & US_FL_BULK_IGNORE_TAG)) ||
1164 bcs->Status > US_BULK_STAT_PHASE) { 1162 bcs->Status > US_BULK_STAT_PHASE) {
1165 US_DEBUGP("Bulk logical error\n"); 1163 usb_stor_dbg(us, "Bulk logical error\n");
1166 return USB_STOR_TRANSPORT_ERROR; 1164 return USB_STOR_TRANSPORT_ERROR;
1167 } 1165 }
1168 1166
@@ -1173,12 +1171,12 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
1173 if (!us->bcs_signature) { 1171 if (!us->bcs_signature) {
1174 us->bcs_signature = bcs->Signature; 1172 us->bcs_signature = bcs->Signature;
1175 if (us->bcs_signature != cpu_to_le32(US_BULK_CS_SIGN)) 1173 if (us->bcs_signature != cpu_to_le32(US_BULK_CS_SIGN))
1176 US_DEBUGP("Learnt BCS signature 0x%08X\n", 1174 usb_stor_dbg(us, "Learnt BCS signature 0x%08X\n",
1177 le32_to_cpu(us->bcs_signature)); 1175 le32_to_cpu(us->bcs_signature));
1178 } else if (bcs->Signature != us->bcs_signature) { 1176 } else if (bcs->Signature != us->bcs_signature) {
1179 US_DEBUGP("Signature mismatch: got %08X, expecting %08X\n", 1177 usb_stor_dbg(us, "Signature mismatch: got %08X, expecting %08X\n",
1180 le32_to_cpu(bcs->Signature), 1178 le32_to_cpu(bcs->Signature),
1181 le32_to_cpu(us->bcs_signature)); 1179 le32_to_cpu(us->bcs_signature));
1182 return USB_STOR_TRANSPORT_ERROR; 1180 return USB_STOR_TRANSPORT_ERROR;
1183 } 1181 }
1184 1182
@@ -1255,7 +1253,7 @@ static int usb_stor_reset_common(struct us_data *us,
1255 int result2; 1253 int result2;
1256 1254
1257 if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) { 1255 if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) {
1258 US_DEBUGP("No reset during disconnect\n"); 1256 usb_stor_dbg(us, "No reset during disconnect\n");
1259 return -EIO; 1257 return -EIO;
1260 } 1258 }
1261 1259
@@ -1263,7 +1261,7 @@ static int usb_stor_reset_common(struct us_data *us,
1263 request, requesttype, value, index, data, size, 1261 request, requesttype, value, index, data, size,
1264 5*HZ); 1262 5*HZ);
1265 if (result < 0) { 1263 if (result < 0) {
1266 US_DEBUGP("Soft reset failed: %d\n", result); 1264 usb_stor_dbg(us, "Soft reset failed: %d\n", result);
1267 return result; 1265 return result;
1268 } 1266 }
1269 1267
@@ -1273,23 +1271,23 @@ static int usb_stor_reset_common(struct us_data *us,
1273 test_bit(US_FLIDX_DISCONNECTING, &us->dflags), 1271 test_bit(US_FLIDX_DISCONNECTING, &us->dflags),
1274 HZ*6); 1272 HZ*6);
1275 if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) { 1273 if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) {
1276 US_DEBUGP("Reset interrupted by disconnect\n"); 1274 usb_stor_dbg(us, "Reset interrupted by disconnect\n");
1277 return -EIO; 1275 return -EIO;
1278 } 1276 }
1279 1277
1280 US_DEBUGP("Soft reset: clearing bulk-in endpoint halt\n"); 1278 usb_stor_dbg(us, "Soft reset: clearing bulk-in endpoint halt\n");
1281 result = usb_stor_clear_halt(us, us->recv_bulk_pipe); 1279 result = usb_stor_clear_halt(us, us->recv_bulk_pipe);
1282 1280
1283 US_DEBUGP("Soft reset: clearing bulk-out endpoint halt\n"); 1281 usb_stor_dbg(us, "Soft reset: clearing bulk-out endpoint halt\n");
1284 result2 = usb_stor_clear_halt(us, us->send_bulk_pipe); 1282 result2 = usb_stor_clear_halt(us, us->send_bulk_pipe);
1285 1283
1286 /* return a result code based on the result of the clear-halts */ 1284 /* return a result code based on the result of the clear-halts */
1287 if (result >= 0) 1285 if (result >= 0)
1288 result = result2; 1286 result = result2;
1289 if (result < 0) 1287 if (result < 0)
1290 US_DEBUGP("Soft reset failed\n"); 1288 usb_stor_dbg(us, "Soft reset failed\n");
1291 else 1289 else
1292 US_DEBUGP("Soft reset done\n"); 1290 usb_stor_dbg(us, "Soft reset done\n");
1293 return result; 1291 return result;
1294} 1292}
1295 1293
@@ -1299,8 +1297,6 @@ static int usb_stor_reset_common(struct us_data *us,
1299 1297
1300int usb_stor_CB_reset(struct us_data *us) 1298int usb_stor_CB_reset(struct us_data *us)
1301{ 1299{
1302 US_DEBUGP("%s called\n", __func__);
1303
1304 memset(us->iobuf, 0xFF, CB_RESET_CMD_SIZE); 1300 memset(us->iobuf, 0xFF, CB_RESET_CMD_SIZE);
1305 us->iobuf[0] = SEND_DIAGNOSTIC; 1301 us->iobuf[0] = SEND_DIAGNOSTIC;
1306 us->iobuf[1] = 4; 1302 us->iobuf[1] = 4;
@@ -1315,8 +1311,6 @@ EXPORT_SYMBOL_GPL(usb_stor_CB_reset);
1315 */ 1311 */
1316int usb_stor_Bulk_reset(struct us_data *us) 1312int usb_stor_Bulk_reset(struct us_data *us)
1317{ 1313{
1318 US_DEBUGP("%s called\n", __func__);
1319
1320 return usb_stor_reset_common(us, US_BULK_RESET_REQUEST, 1314 return usb_stor_reset_common(us, US_BULK_RESET_REQUEST,
1321 USB_TYPE_CLASS | USB_RECIP_INTERFACE, 1315 USB_TYPE_CLASS | USB_RECIP_INTERFACE,
1322 0, us->ifnum, NULL, 0); 1316 0, us->ifnum, NULL, 0);
@@ -1336,16 +1330,17 @@ int usb_stor_port_reset(struct us_data *us)
1336 1330
1337 result = usb_lock_device_for_reset(us->pusb_dev, us->pusb_intf); 1331 result = usb_lock_device_for_reset(us->pusb_dev, us->pusb_intf);
1338 if (result < 0) 1332 if (result < 0)
1339 US_DEBUGP("unable to lock device for reset: %d\n", result); 1333 usb_stor_dbg(us, "unable to lock device for reset: %d\n",
1334 result);
1340 else { 1335 else {
1341 /* Were we disconnected while waiting for the lock? */ 1336 /* Were we disconnected while waiting for the lock? */
1342 if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) { 1337 if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) {
1343 result = -EIO; 1338 result = -EIO;
1344 US_DEBUGP("No reset during disconnect\n"); 1339 usb_stor_dbg(us, "No reset during disconnect\n");
1345 } else { 1340 } else {
1346 result = usb_reset_device(us->pusb_dev); 1341 result = usb_reset_device(us->pusb_dev);
1347 US_DEBUGP("usb_reset_device returns %d\n", 1342 usb_stor_dbg(us, "usb_reset_device returns %d\n",
1348 result); 1343 result);
1349 } 1344 }
1350 usb_unlock_device(us->pusb_dev); 1345 usb_unlock_device(us->pusb_dev);
1351 } 1346 }
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index d6bee407af02..b4c63fcf7b0b 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -183,7 +183,6 @@ int usb_stor_suspend(struct usb_interface *iface, pm_message_t message)
183 /* Wait until no command is running */ 183 /* Wait until no command is running */
184 mutex_lock(&us->dev_mutex); 184 mutex_lock(&us->dev_mutex);
185 185
186 US_DEBUGP("%s\n", __func__);
187 if (us->suspend_resume_hook) 186 if (us->suspend_resume_hook)
188 (us->suspend_resume_hook)(us, US_SUSPEND); 187 (us->suspend_resume_hook)(us, US_SUSPEND);
189 188
@@ -201,7 +200,6 @@ int usb_stor_resume(struct usb_interface *iface)
201 200
202 mutex_lock(&us->dev_mutex); 201 mutex_lock(&us->dev_mutex);
203 202
204 US_DEBUGP("%s\n", __func__);
205 if (us->suspend_resume_hook) 203 if (us->suspend_resume_hook)
206 (us->suspend_resume_hook)(us, US_RESUME); 204 (us->suspend_resume_hook)(us, US_RESUME);
207 205
@@ -214,8 +212,6 @@ int usb_stor_reset_resume(struct usb_interface *iface)
214{ 212{
215 struct us_data *us = usb_get_intfdata(iface); 213 struct us_data *us = usb_get_intfdata(iface);
216 214
217 US_DEBUGP("%s\n", __func__);
218
219 /* Report the reset to the SCSI core */ 215 /* Report the reset to the SCSI core */
220 usb_stor_report_bus_reset(us); 216 usb_stor_report_bus_reset(us);
221 217
@@ -236,8 +232,6 @@ int usb_stor_pre_reset(struct usb_interface *iface)
236{ 232{
237 struct us_data *us = usb_get_intfdata(iface); 233 struct us_data *us = usb_get_intfdata(iface);
238 234
239 US_DEBUGP("%s\n", __func__);
240
241 /* Make sure no command runs during the reset */ 235 /* Make sure no command runs during the reset */
242 mutex_lock(&us->dev_mutex); 236 mutex_lock(&us->dev_mutex);
243 return 0; 237 return 0;
@@ -248,8 +242,6 @@ int usb_stor_post_reset(struct usb_interface *iface)
248{ 242{
249 struct us_data *us = usb_get_intfdata(iface); 243 struct us_data *us = usb_get_intfdata(iface);
250 244
251 US_DEBUGP("%s\n", __func__);
252
253 /* Report the reset to the SCSI core */ 245 /* Report the reset to the SCSI core */
254 usb_stor_report_bus_reset(us); 246 usb_stor_report_bus_reset(us);
255 247
@@ -311,11 +303,11 @@ static int usb_stor_control_thread(void * __us)
311 struct Scsi_Host *host = us_to_host(us); 303 struct Scsi_Host *host = us_to_host(us);
312 304
313 for (;;) { 305 for (;;) {
314 US_DEBUGP("*** thread sleeping.\n"); 306 usb_stor_dbg(us, "*** thread sleeping\n");
315 if (wait_for_completion_interruptible(&us->cmnd_ready)) 307 if (wait_for_completion_interruptible(&us->cmnd_ready))
316 break; 308 break;
317 309
318 US_DEBUGP("*** thread awakened.\n"); 310 usb_stor_dbg(us, "*** thread awakened\n");
319 311
320 /* lock the device pointers */ 312 /* lock the device pointers */
321 mutex_lock(&(us->dev_mutex)); 313 mutex_lock(&(us->dev_mutex));
@@ -327,7 +319,7 @@ static int usb_stor_control_thread(void * __us)
327 if (us->srb == NULL) { 319 if (us->srb == NULL) {
328 scsi_unlock(host); 320 scsi_unlock(host);
329 mutex_unlock(&us->dev_mutex); 321 mutex_unlock(&us->dev_mutex);
330 US_DEBUGP("-- exiting\n"); 322 usb_stor_dbg(us, "-- exiting\n");
331 break; 323 break;
332 } 324 }
333 325
@@ -343,7 +335,7 @@ static int usb_stor_control_thread(void * __us)
343 * is UNKNOWN 335 * is UNKNOWN
344 */ 336 */
345 if (us->srb->sc_data_direction == DMA_BIDIRECTIONAL) { 337 if (us->srb->sc_data_direction == DMA_BIDIRECTIONAL) {
346 US_DEBUGP("UNKNOWN data direction\n"); 338 usb_stor_dbg(us, "UNKNOWN data direction\n");
347 us->srb->result = DID_ERROR << 16; 339 us->srb->result = DID_ERROR << 16;
348 } 340 }
349 341
@@ -352,14 +344,14 @@ static int usb_stor_control_thread(void * __us)
352 */ 344 */
353 else if (us->srb->device->id && 345 else if (us->srb->device->id &&
354 !(us->fflags & US_FL_SCM_MULT_TARG)) { 346 !(us->fflags & US_FL_SCM_MULT_TARG)) {
355 US_DEBUGP("Bad target number (%d:%d)\n", 347 usb_stor_dbg(us, "Bad target number (%d:%d)\n",
356 us->srb->device->id, us->srb->device->lun); 348 us->srb->device->id, us->srb->device->lun);
357 us->srb->result = DID_BAD_TARGET << 16; 349 us->srb->result = DID_BAD_TARGET << 16;
358 } 350 }
359 351
360 else if (us->srb->device->lun > us->max_lun) { 352 else if (us->srb->device->lun > us->max_lun) {
361 US_DEBUGP("Bad LUN (%d:%d)\n", 353 usb_stor_dbg(us, "Bad LUN (%d:%d)\n",
362 us->srb->device->id, us->srb->device->lun); 354 us->srb->device->id, us->srb->device->lun);
363 us->srb->result = DID_BAD_TARGET << 16; 355 us->srb->result = DID_BAD_TARGET << 16;
364 } 356 }
365 357
@@ -371,14 +363,14 @@ static int usb_stor_control_thread(void * __us)
371 0x00, 0x80, 0x02, 0x02, 363 0x00, 0x80, 0x02, 0x02,
372 0x1F, 0x00, 0x00, 0x00}; 364 0x1F, 0x00, 0x00, 0x00};
373 365
374 US_DEBUGP("Faking INQUIRY command\n"); 366 usb_stor_dbg(us, "Faking INQUIRY command\n");
375 fill_inquiry_response(us, data_ptr, 36); 367 fill_inquiry_response(us, data_ptr, 36);
376 us->srb->result = SAM_STAT_GOOD; 368 us->srb->result = SAM_STAT_GOOD;
377 } 369 }
378 370
379 /* we've got a command, let's do it! */ 371 /* we've got a command, let's do it! */
380 else { 372 else {
381 US_DEBUG(usb_stor_show_command(us->srb)); 373 US_DEBUG(usb_stor_show_command(us, us->srb));
382 us->proto_handler(us->srb, us); 374 us->proto_handler(us->srb, us);
383 usb_mark_last_busy(us->pusb_dev); 375 usb_mark_last_busy(us->pusb_dev);
384 } 376 }
@@ -388,12 +380,12 @@ static int usb_stor_control_thread(void * __us)
388 380
389 /* indicate that the command is done */ 381 /* indicate that the command is done */
390 if (us->srb->result != DID_ABORT << 16) { 382 if (us->srb->result != DID_ABORT << 16) {
391 US_DEBUGP("scsi cmd done, result=0x%x\n", 383 usb_stor_dbg(us, "scsi cmd done, result=0x%x\n",
392 us->srb->result); 384 us->srb->result);
393 us->srb->scsi_done(us->srb); 385 us->srb->scsi_done(us->srb);
394 } else { 386 } else {
395SkipForAbort: 387SkipForAbort:
396 US_DEBUGP("scsi command aborted\n"); 388 usb_stor_dbg(us, "scsi command aborted\n");
397 } 389 }
398 390
399 /* If an abort request was received we need to signal that 391 /* If an abort request was received we need to signal that
@@ -435,34 +427,30 @@ SkipForAbort:
435/* Associate our private data with the USB device */ 427/* Associate our private data with the USB device */
436static int associate_dev(struct us_data *us, struct usb_interface *intf) 428static int associate_dev(struct us_data *us, struct usb_interface *intf)
437{ 429{
438 US_DEBUGP("-- %s\n", __func__);
439
440 /* Fill in the device-related fields */ 430 /* Fill in the device-related fields */
441 us->pusb_dev = interface_to_usbdev(intf); 431 us->pusb_dev = interface_to_usbdev(intf);
442 us->pusb_intf = intf; 432 us->pusb_intf = intf;
443 us->ifnum = intf->cur_altsetting->desc.bInterfaceNumber; 433 us->ifnum = intf->cur_altsetting->desc.bInterfaceNumber;
444 US_DEBUGP("Vendor: 0x%04x, Product: 0x%04x, Revision: 0x%04x\n", 434 usb_stor_dbg(us, "Vendor: 0x%04x, Product: 0x%04x, Revision: 0x%04x\n",
445 le16_to_cpu(us->pusb_dev->descriptor.idVendor), 435 le16_to_cpu(us->pusb_dev->descriptor.idVendor),
446 le16_to_cpu(us->pusb_dev->descriptor.idProduct), 436 le16_to_cpu(us->pusb_dev->descriptor.idProduct),
447 le16_to_cpu(us->pusb_dev->descriptor.bcdDevice)); 437 le16_to_cpu(us->pusb_dev->descriptor.bcdDevice));
448 US_DEBUGP("Interface Subclass: 0x%02x, Protocol: 0x%02x\n", 438 usb_stor_dbg(us, "Interface Subclass: 0x%02x, Protocol: 0x%02x\n",
449 intf->cur_altsetting->desc.bInterfaceSubClass, 439 intf->cur_altsetting->desc.bInterfaceSubClass,
450 intf->cur_altsetting->desc.bInterfaceProtocol); 440 intf->cur_altsetting->desc.bInterfaceProtocol);
451 441
452 /* Store our private data in the interface */ 442 /* Store our private data in the interface */
453 usb_set_intfdata(intf, us); 443 usb_set_intfdata(intf, us);
454 444
455 /* Allocate the control/setup and DMA-mapped buffers */ 445 /* Allocate the control/setup and DMA-mapped buffers */
456 us->cr = kmalloc(sizeof(*us->cr), GFP_KERNEL); 446 us->cr = kmalloc(sizeof(*us->cr), GFP_KERNEL);
457 if (!us->cr) { 447 if (!us->cr)
458 US_DEBUGP("usb_ctrlrequest allocation failed\n");
459 return -ENOMEM; 448 return -ENOMEM;
460 }
461 449
462 us->iobuf = usb_alloc_coherent(us->pusb_dev, US_IOBUF_SIZE, 450 us->iobuf = usb_alloc_coherent(us->pusb_dev, US_IOBUF_SIZE,
463 GFP_KERNEL, &us->iobuf_dma); 451 GFP_KERNEL, &us->iobuf_dma);
464 if (!us->iobuf) { 452 if (!us->iobuf) {
465 US_DEBUGP("I/O buffer allocation failed\n"); 453 usb_stor_dbg(us, "I/O buffer allocation failed\n");
466 return -ENOMEM; 454 return -ENOMEM;
467 } 455 }
468 return 0; 456 return 0;
@@ -738,7 +726,7 @@ static int get_pipes(struct us_data *us)
738 } 726 }
739 727
740 if (!ep_in || !ep_out || (us->protocol == USB_PR_CBI && !ep_int)) { 728 if (!ep_in || !ep_out || (us->protocol == USB_PR_CBI && !ep_int)) {
741 US_DEBUGP("Endpoint sanity check failed! Rejecting dev.\n"); 729 usb_stor_dbg(us, "Endpoint sanity check failed! Rejecting dev.\n");
742 return -EIO; 730 return -EIO;
743 } 731 }
744 732
@@ -765,7 +753,7 @@ static int usb_stor_acquire_resources(struct us_data *us)
765 753
766 us->current_urb = usb_alloc_urb(0, GFP_KERNEL); 754 us->current_urb = usb_alloc_urb(0, GFP_KERNEL);
767 if (!us->current_urb) { 755 if (!us->current_urb) {
768 US_DEBUGP("URB allocation failed\n"); 756 usb_stor_dbg(us, "URB allocation failed\n");
769 return -ENOMEM; 757 return -ENOMEM;
770 } 758 }
771 759
@@ -792,20 +780,18 @@ static int usb_stor_acquire_resources(struct us_data *us)
792/* Release all our dynamic resources */ 780/* Release all our dynamic resources */
793static void usb_stor_release_resources(struct us_data *us) 781static void usb_stor_release_resources(struct us_data *us)
794{ 782{
795 US_DEBUGP("-- %s\n", __func__);
796
797 /* Tell the control thread to exit. The SCSI host must 783 /* Tell the control thread to exit. The SCSI host must
798 * already have been removed and the DISCONNECTING flag set 784 * already have been removed and the DISCONNECTING flag set
799 * so that we won't accept any more commands. 785 * so that we won't accept any more commands.
800 */ 786 */
801 US_DEBUGP("-- sending exit command to thread\n"); 787 usb_stor_dbg(us, "-- sending exit command to thread\n");
802 complete(&us->cmnd_ready); 788 complete(&us->cmnd_ready);
803 if (us->ctl_thread) 789 if (us->ctl_thread)
804 kthread_stop(us->ctl_thread); 790 kthread_stop(us->ctl_thread);
805 791
806 /* Call the destructor routine, if it exists */ 792 /* Call the destructor routine, if it exists */
807 if (us->extra_destructor) { 793 if (us->extra_destructor) {
808 US_DEBUGP("-- calling extra_destructor()\n"); 794 usb_stor_dbg(us, "-- calling extra_destructor()\n");
809 us->extra_destructor(us->extra); 795 us->extra_destructor(us->extra);
810 } 796 }
811 797
@@ -817,8 +803,6 @@ static void usb_stor_release_resources(struct us_data *us)
817/* Dissociate from the USB device */ 803/* Dissociate from the USB device */
818static void dissociate_dev(struct us_data *us) 804static void dissociate_dev(struct us_data *us)
819{ 805{
820 US_DEBUGP("-- %s\n", __func__);
821
822 /* Free the buffers */ 806 /* Free the buffers */
823 kfree(us->cr); 807 kfree(us->cr);
824 usb_free_coherent(us->pusb_dev, US_IOBUF_SIZE, us->iobuf, us->iobuf_dma); 808 usb_free_coherent(us->pusb_dev, US_IOBUF_SIZE, us->iobuf, us->iobuf_dma);
@@ -918,7 +902,7 @@ int usb_stor_probe1(struct us_data **pus,
918 struct us_data *us; 902 struct us_data *us;
919 int result; 903 int result;
920 904
921 US_DEBUGP("USB Mass Storage device detected\n"); 905 dev_info(&intf->dev, "USB Mass Storage device detected\n");
922 906
923 /* 907 /*
924 * Ask the SCSI layer to allocate a host structure, with extra 908 * Ask the SCSI layer to allocate a host structure, with extra
@@ -926,8 +910,7 @@ int usb_stor_probe1(struct us_data **pus,
926 */ 910 */
927 host = scsi_host_alloc(&usb_stor_host_template, sizeof(*us)); 911 host = scsi_host_alloc(&usb_stor_host_template, sizeof(*us));
928 if (!host) { 912 if (!host) {
929 dev_warn(&intf->dev, 913 dev_warn(&intf->dev, "Unable to allocate the scsi host\n");
930 "Unable to allocate the scsi host\n");
931 return -ENOMEM; 914 return -ENOMEM;
932 } 915 }
933 916
@@ -964,7 +947,7 @@ int usb_stor_probe1(struct us_data **pus,
964 return 0; 947 return 0;
965 948
966BadDevice: 949BadDevice:
967 US_DEBUGP("storage_probe() failed\n"); 950 usb_stor_dbg(us, "storage_probe() failed\n");
968 release_everything(us); 951 release_everything(us);
969 return result; 952 return result;
970} 953}
@@ -981,8 +964,8 @@ int usb_stor_probe2(struct us_data *us)
981 result = -ENXIO; 964 result = -ENXIO;
982 goto BadDevice; 965 goto BadDevice;
983 } 966 }
984 US_DEBUGP("Transport: %s\n", us->transport_name); 967 usb_stor_dbg(us, "Transport: %s\n", us->transport_name);
985 US_DEBUGP("Protocol: %s\n", us->protocol_name); 968 usb_stor_dbg(us, "Protocol: %s\n", us->protocol_name);
986 969
987 /* fix for single-lun devices */ 970 /* fix for single-lun devices */
988 if (us->fflags & US_FL_SINGLE_LUN) 971 if (us->fflags & US_FL_SINGLE_LUN)
@@ -1028,7 +1011,7 @@ int usb_stor_probe2(struct us_data *us)
1028 1011
1029 /* We come here if there are any problems */ 1012 /* We come here if there are any problems */
1030BadDevice: 1013BadDevice:
1031 US_DEBUGP("storage_probe() failed\n"); 1014 usb_stor_dbg(us, "storage_probe() failed\n");
1032 release_everything(us); 1015 release_everything(us);
1033 return result; 1016 return result;
1034} 1017}
@@ -1039,7 +1022,6 @@ void usb_stor_disconnect(struct usb_interface *intf)
1039{ 1022{
1040 struct us_data *us = usb_get_intfdata(intf); 1023 struct us_data *us = usb_get_intfdata(intf);
1041 1024
1042 US_DEBUGP("storage_disconnect() called\n");
1043 quiesce_and_remove_host(us); 1025 quiesce_and_remove_host(us);
1044 release_everything(us); 1026 release_everything(us);
1045} 1027}
@@ -1075,8 +1057,7 @@ static int storage_probe(struct usb_interface *intf,
1075 } else { 1057 } else {
1076 unusual_dev = &for_dynamic_ids; 1058 unusual_dev = &for_dynamic_ids;
1077 1059
1078 US_DEBUGP("%s %s 0x%04x 0x%04x\n", "Use Bulk-Only transport", 1060 dev_dbg(&intf->dev, "Use Bulk-Only transport with the Transparent SCSI protocol for dynamic id: 0x%04x 0x%04x\n",
1079 "with the Transparent SCSI protocol for dynamic id:",
1080 id->idVendor, id->idProduct); 1061 id->idVendor, id->idProduct);
1081 } 1062 }
1082 1063
@@ -1117,20 +1098,18 @@ static int __init usb_stor_init(void)
1117 /* register the driver, return usb_register return code if error */ 1098 /* register the driver, return usb_register return code if error */
1118 retval = usb_register(&usb_storage_driver); 1099 retval = usb_register(&usb_storage_driver);
1119 if (retval == 0) 1100 if (retval == 0)
1120 pr_info("USB Mass Storage support registered.\n"); 1101 pr_info("USB Mass Storage support registered\n");
1121 return retval; 1102 return retval;
1122} 1103}
1123 1104
1124static void __exit usb_stor_exit(void) 1105static void __exit usb_stor_exit(void)
1125{ 1106{
1126 US_DEBUGP("usb_stor_exit() called\n");
1127
1128 /* Deregister the driver 1107 /* Deregister the driver
1129 * This will cause disconnect() to be called for each 1108 * This will cause disconnect() to be called for each
1130 * attached unit 1109 * attached unit
1131 */ 1110 */
1132 US_DEBUGP("-- calling usb_deregister()\n"); 1111 pr_info("Deregistering USB Mass Storage driver...\n");
1133 usb_deregister(&usb_storage_driver) ; 1112 usb_deregister(&usb_storage_driver);
1134} 1113}
1135 1114
1136module_init(usb_stor_init); 1115module_init(usb_stor_init);