aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/storage/alauda.c
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2013-04-19 14:44:00 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-04-19 14:46:50 -0400
commit191648d03d20229523d9a75b8abef56421298d28 (patch)
tree2de4891a95fe1d2ee4b8326bb9834033b763d37e /drivers/usb/storage/alauda.c
parentf1175daa5312dd1b3f5940413c7c41ed195066f7 (diff)
usb: storage: Convert US_DEBUGP to usb_stor_dbg
Use a more current logging style with dev_printk where possible. o Convert uses of US_DEBUGP to usb_stor_dbg o Add "struct us_data *" to usb_stor_dbg uses o usb_stor_dbg now uses struct device */dev_vprint_emit o Removed embedded function names o Coalesce formats o Remove trailing whitespace o Remove useless OOM messages o Remove useless function entry/exit logging o Convert some US_DEBUGP uses to dev_info and dev_dbg Object size is slightly reduced when debugging is enabled, slightly increased with no debugging because some initialization and removal messages are now always emitted. Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/storage/alauda.c')
-rw-r--r--drivers/usb/storage/alauda.c101
1 files changed, 45 insertions, 56 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;