aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/storage/sddr55.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/sddr55.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/sddr55.c')
-rw-r--r--drivers/usb/storage/sddr55.c86
1 files changed, 40 insertions, 46 deletions
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 }