diff options
author | Joe Perches <joe@perches.com> | 2013-04-19 11:44:00 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-04-19 11:46:50 -0700 |
commit | 191648d03d20229523d9a75b8abef56421298d28 (patch) | |
tree | 2de4891a95fe1d2ee4b8326bb9834033b763d37e | |
parent | f1175daa5312dd1b3f5940413c7c41ed195066f7 (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>
-rw-r--r-- | drivers/usb/storage/alauda.c | 101 | ||||
-rw-r--r-- | drivers/usb/storage/cypress_atacb.c | 2 | ||||
-rw-r--r-- | drivers/usb/storage/datafab.c | 59 | ||||
-rw-r--r-- | drivers/usb/storage/debug.c | 28 | ||||
-rw-r--r-- | drivers/usb/storage/debug.h | 17 | ||||
-rw-r--r-- | drivers/usb/storage/ene_ub6250.c | 86 | ||||
-rw-r--r-- | drivers/usb/storage/freecom.c | 85 | ||||
-rw-r--r-- | drivers/usb/storage/initializers.c | 10 | ||||
-rw-r--r-- | drivers/usb/storage/isd200.c | 292 | ||||
-rw-r--r-- | drivers/usb/storage/jumpshot.c | 69 | ||||
-rw-r--r-- | drivers/usb/storage/karma.c | 6 | ||||
-rw-r--r-- | drivers/usb/storage/option_ms.c | 23 | ||||
-rw-r--r-- | drivers/usb/storage/realtek_cr.c | 128 | ||||
-rw-r--r-- | drivers/usb/storage/scsiglue.c | 13 | ||||
-rw-r--r-- | drivers/usb/storage/sddr09.c | 146 | ||||
-rw-r--r-- | drivers/usb/storage/sddr55.c | 86 | ||||
-rw-r--r-- | drivers/usb/storage/shuttle_usbat.c | 119 | ||||
-rw-r--r-- | drivers/usb/storage/sierra_ms.c | 43 | ||||
-rw-r--r-- | drivers/usb/storage/transport.c | 181 | ||||
-rw-r--r-- | drivers/usb/storage/usb.c | 93 |
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) rc = usb_stor_ctrl_transfer(us, us->recv_ctrl_pipe, command, 0xc0, 0, 1, data, 2); - US_DEBUGP("alauda_get_media_status: Media status %02X %02X\n", - data[0], data[1]); + usb_stor_dbg(us, "Media status %02X %02X\n", data[0], data[1]); return rc; } @@ -402,7 +401,7 @@ static int alauda_init_media(struct us_data *us) ready = 1; } - US_DEBUGP("alauda_init_media: We are ready for action!\n"); + usb_stor_dbg(us, "We are ready for action!\n"); if (alauda_ack_media(us) != USB_STOR_XFER_GOOD) return USB_STOR_TRANSPORT_ERROR; @@ -413,15 +412,15 @@ static int alauda_init_media(struct us_data *us) return USB_STOR_TRANSPORT_ERROR; if (data[0] != 0x14) { - US_DEBUGP("alauda_init_media: Media not ready after ack\n"); + usb_stor_dbg(us, "Media not ready after ack\n"); return USB_STOR_TRANSPORT_ERROR; } if (alauda_get_media_signature(us, data) != USB_STOR_XFER_GOOD) return USB_STOR_TRANSPORT_ERROR; - US_DEBUGP("alauda_init_media: Media signature: %02X %02X %02X %02X\n", - data[0], data[1], data[2], data[3]); + usb_stor_dbg(us, "Media signature: %02X %02X %02X %02X\n", + data[0], data[1], data[2], data[3]); media_info = alauda_card_find_id(data[1]); if (media_info == NULL) { printk(KERN_WARNING @@ -432,8 +431,8 @@ static int alauda_init_media(struct us_data *us) } MEDIA_INFO(us).capacity = 1 << media_info->chipshift; - US_DEBUGP("Found media with capacity: %ldMB\n", - MEDIA_INFO(us).capacity >> 20); + usb_stor_dbg(us, "Found media with capacity: %ldMB\n", + MEDIA_INFO(us).capacity >> 20); MEDIA_INFO(us).pageshift = media_info->pageshift; MEDIA_INFO(us).blockshift = media_info->blockshift; @@ -472,7 +471,7 @@ static int alauda_check_media(struct us_data *us) /* Check for no media or door open */ if ((status[0] & 0x80) || ((status[0] & 0x1F) == 0x10) || ((status[1] & 0x01) == 0)) { - US_DEBUGP("alauda_check_media: No media, or door open\n"); + usb_stor_dbg(us, "No media, or door open\n"); alauda_free_maps(&MEDIA_INFO(us)); info->sense_key = 0x02; info->sense_asc = 0x3A; @@ -482,7 +481,7 @@ static int alauda_check_media(struct us_data *us) /* Check for media change */ if (status[0] & 0x08) { - US_DEBUGP("alauda_check_media: Media change detected\n"); + usb_stor_dbg(us, "Media change detected\n"); alauda_free_maps(&MEDIA_INFO(us)); alauda_init_media(us); @@ -518,7 +517,7 @@ static int alauda_check_status2(struct us_data *us) if (rc != USB_STOR_XFER_GOOD) return rc; - US_DEBUGP("alauda_check_status2: %02X %02X %02X\n", data[0], data[1], data[2]); + usb_stor_dbg(us, "%02X %02X %02X\n", data[0], data[1], data[2]); if (data[0] & ALAUDA_STATUS_ERROR) return USB_STOR_XFER_ERROR; @@ -584,7 +583,7 @@ static int alauda_read_map(struct us_data *us, unsigned int zone) goto error; } - US_DEBUGP("alauda_read_map: Mapping blocks for zone %d\n", zone); + usb_stor_dbg(us, "Mapping blocks for zone %d\n", zone); /* 1024 PBA's per zone */ for (i = 0; i < zonesize; i++) @@ -604,7 +603,7 @@ static int alauda_read_map(struct us_data *us, unsigned int zone) if (data[j] != 0) goto nonz; pba_to_lba[i] = UNUSABLE; - US_DEBUGP("alauda_read_map: PBA %d has no logical mapping\n", blocknum); + usb_stor_dbg(us, "PBA %d has no logical mapping\n", blocknum); continue; nonz: @@ -617,19 +616,18 @@ static int alauda_read_map(struct us_data *us, unsigned int zone) nonff: /* normal PBAs start with six FFs */ if (j < 6) { - US_DEBUGP("alauda_read_map: PBA %d has no logical mapping: " - "reserved area = %02X%02X%02X%02X " - "data status %02X block status %02X\n", - blocknum, data[0], data[1], data[2], data[3], - data[4], data[5]); + usb_stor_dbg(us, "PBA %d has no logical mapping: reserved area = %02X%02X%02X%02X data status %02X block status %02X\n", + blocknum, + data[0], data[1], data[2], data[3], + data[4], data[5]); pba_to_lba[i] = UNUSABLE; continue; } if ((data[6] >> 4) != 0x01) { - US_DEBUGP("alauda_read_map: PBA %d has invalid address " - "field %02X%02X/%02X%02X\n", - blocknum, data[6], data[7], data[11], data[12]); + usb_stor_dbg(us, "PBA %d has invalid address field %02X%02X/%02X%02X\n", + blocknum, data[6], data[7], + data[11], data[12]); pba_to_lba[i] = UNUSABLE; continue; } @@ -711,7 +709,7 @@ static int alauda_erase_block(struct us_data *us, u16 pba) }; unsigned char buf[2]; - US_DEBUGP("alauda_erase_block: Erasing PBA %d\n", pba); + usb_stor_dbg(us, "Erasing PBA %d\n", pba); rc = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, command, 9, NULL); @@ -723,8 +721,7 @@ static int alauda_erase_block(struct us_data *us, u16 pba) if (rc != USB_STOR_XFER_GOOD) return rc; - US_DEBUGP("alauda_erase_block: Erase result: %02X %02X\n", - buf[0], buf[1]); + usb_stor_dbg(us, "Erase result: %02X %02X\n", buf[0], buf[1]); return rc; } @@ -741,8 +738,7 @@ static int alauda_read_block_raw(struct us_data *us, u16 pba, PBA_ZONE(pba), 0, PBA_LO(pba) + page, pages, 0, MEDIA_PORT(us) }; - US_DEBUGP("alauda_read_block: pba %d page %d count %d\n", - pba, page, pages); + usb_stor_dbg(us, "pba %d page %d count %d\n", pba, page, pages); rc = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, command, 9, NULL); @@ -793,7 +789,7 @@ static int alauda_write_block(struct us_data *us, u16 pba, unsigned char *data) PBA_ZONE(pba), 0, PBA_LO(pba), 32, 0, MEDIA_PORT(us) }; - US_DEBUGP("alauda_write_block: pba %d\n", pba); + usb_stor_dbg(us, "pba %d\n", pba); rc = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, command, 9, NULL); @@ -866,14 +862,14 @@ static int alauda_write_lba(struct us_data *us, u16 lba, cptr = bptr + pagesize; nand_compute_ecc(bptr, ecc); if (!nand_compare_ecc(cptr+13, ecc)) { - US_DEBUGP("Warning: bad ecc in page %d- of pba %d\n", - i, pba); + usb_stor_dbg(us, "Warning: bad ecc in page %d- of pba %d\n", + i, pba); nand_store_ecc(cptr+13, ecc); } nand_compute_ecc(bptr + (pagesize / 2), ecc); if (!nand_compare_ecc(cptr+8, ecc)) { - US_DEBUGP("Warning: bad ecc in page %d+ of pba %d\n", - i, pba); + usb_stor_dbg(us, "Warning: bad ecc in page %d+ of pba %d\n", + i, pba); nand_store_ecc(cptr+8, ecc); } cptr[6] = cptr[11] = MSB_of(lbap); @@ -900,8 +896,7 @@ static int alauda_write_lba(struct us_data *us, u16 lba, new_pba_offset = new_pba - (zone * zonesize); MEDIA_INFO(us).pba_to_lba[zone][new_pba_offset] = lba; MEDIA_INFO(us).lba_to_pba[zone][lba_offset] = new_pba; - US_DEBUGP("alauda_write_lba: Remapped LBA %d to PBA %d\n", - lba, new_pba); + usb_stor_dbg(us, "Remapped LBA %d to PBA %d\n", lba, new_pba); if (pba != UNDEF) { unsigned int pba_offset = pba - (zone * zonesize); @@ -964,8 +959,8 @@ static int alauda_read_data(struct us_data *us, unsigned long address, /* Not overflowing capacity? */ if (lba >= max_lba) { - US_DEBUGP("Error: Requested lba %u exceeds " - "maximum %u\n", lba, max_lba); + usb_stor_dbg(us, "Error: Requested lba %u exceeds maximum %u\n", + lba, max_lba); result = USB_STOR_TRANSPORT_ERROR; break; } @@ -978,8 +973,8 @@ static int alauda_read_data(struct us_data *us, unsigned long address, pba = MEDIA_INFO(us).lba_to_pba[zone][lba_offset]; if (pba == UNDEF) { /* this lba was never written */ - US_DEBUGP("Read %d zero pages (LBA %d) page %d\n", - pages, lba, page); + usb_stor_dbg(us, "Read %d zero pages (LBA %d) page %d\n", + pages, lba, page); /* This is not really an error. It just means that the block has never been written. @@ -988,9 +983,8 @@ static int alauda_read_data(struct us_data *us, unsigned long address, memset(buffer, 0, len); } else { - US_DEBUGP("Read %d pages, from PBA %d" - " (LBA %d) page %d\n", - pages, pba, lba, page); + usb_stor_dbg(us, "Read %d pages, from PBA %d (LBA %d) page %d\n", + pages, pba, lba, page); result = alauda_read_block(us, pba, page, pages, buffer); if (result != USB_STOR_TRANSPORT_GOOD) @@ -1066,8 +1060,8 @@ static int alauda_write_data(struct us_data *us, unsigned long address, /* Not overflowing capacity? */ if (lba >= max_lba) { - US_DEBUGP("alauda_write_data: Requested lba %u exceeds " - "maximum %u\n", lba, max_lba); + usb_stor_dbg(us, "Requested lba %u exceeds maximum %u\n", + lba, max_lba); result = USB_STOR_TRANSPORT_ERROR; break; } @@ -1122,11 +1116,9 @@ static int init_alauda(struct us_data *us) nand_init_ecc(); us->extra = kzalloc(sizeof(struct alauda_info), GFP_NOIO); - if (!us->extra) { - US_DEBUGP("init_alauda: Gah! Can't allocate storage for" - "alauda info struct!\n"); + if (!us->extra) return USB_STOR_TRANSPORT_ERROR; - } + info = (struct alauda_info *) us->extra; us->extra_destructor = alauda_info_destructor; @@ -1147,15 +1139,14 @@ static int alauda_transport(struct scsi_cmnd *srb, struct us_data *us) }; if (srb->cmnd[0] == INQUIRY) { - US_DEBUGP("alauda_transport: INQUIRY. " - "Returning bogus response.\n"); + usb_stor_dbg(us, "INQUIRY - Returning bogus response\n"); memcpy(ptr, inquiry_response, sizeof(inquiry_response)); fill_inquiry_response(us, ptr, 36); return USB_STOR_TRANSPORT_GOOD; } if (srb->cmnd[0] == TEST_UNIT_READY) { - US_DEBUGP("alauda_transport: TEST_UNIT_READY.\n"); + usb_stor_dbg(us, "TEST_UNIT_READY\n"); return alauda_check_media(us); } @@ -1193,8 +1184,7 @@ static int alauda_transport(struct scsi_cmnd *srb, struct us_data *us) page |= short_pack(srb->cmnd[5], srb->cmnd[4]); pages = short_pack(srb->cmnd[8], srb->cmnd[7]); - US_DEBUGP("alauda_transport: READ_10: page %d pagect %d\n", - page, pages); + usb_stor_dbg(us, "READ_10: page %d pagect %d\n", page, pages); return alauda_read_data(us, page, pages); } @@ -1211,14 +1201,13 @@ static int alauda_transport(struct scsi_cmnd *srb, struct us_data *us) page |= short_pack(srb->cmnd[5], srb->cmnd[4]); pages = short_pack(srb->cmnd[8], srb->cmnd[7]); - US_DEBUGP("alauda_transport: WRITE_10: page %d pagect %d\n", - page, pages); + usb_stor_dbg(us, "WRITE_10: page %d pagect %d\n", page, pages); return alauda_write_data(us, page, pages); } if (srb->cmnd[0] == REQUEST_SENSE) { - US_DEBUGP("alauda_transport: REQUEST_SENSE.\n"); + usb_stor_dbg(us, "REQUEST_SENSE\n"); memset(ptr, 0, 18); ptr[0] = 0xF0; @@ -1237,8 +1226,8 @@ static int alauda_transport(struct scsi_cmnd *srb, struct us_data *us) return USB_STOR_TRANSPORT_GOOD; } - US_DEBUGP("alauda_transport: Gah! Unknown command: %d (0x%x)\n", - srb->cmnd[0], srb->cmnd[0]); + usb_stor_dbg(us, "Gah! Unknown command: %d (0x%x)\n", + srb->cmnd[0], srb->cmnd[0]); info->sense_key = 0x05; info->sense_asc = 0x20; 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) if (srb->result == SAM_STAT_CHECK_CONDITION && memcmp(srb->sense_buffer, usb_stor_sense_invalidCDB, sizeof(usb_stor_sense_invalidCDB)) == 0) { - US_DEBUGP("cypress atacb not supported ???\n"); + usb_stor_dbg(us, "cypress atacb not supported ???\n"); goto end; } 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) { if (len == 0) return USB_STOR_XFER_GOOD; - US_DEBUGP("datafab_bulk_read: len = %d\n", len); + usb_stor_dbg(us, "len = %d\n", len); return usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, data, len, NULL); } @@ -134,7 +134,7 @@ datafab_bulk_write(struct us_data *us, unsigned char *data, unsigned int len) { if (len == 0) return USB_STOR_XFER_GOOD; - US_DEBUGP("datafab_bulk_write: len = %d\n", len); + usb_stor_dbg(us, "len = %d\n", len); return usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, data, len, NULL); } @@ -300,9 +300,8 @@ static int datafab_write_data(struct us_data *us, goto leave; if (reply[0] != 0x50 && reply[1] != 0) { - US_DEBUGP("datafab_write_data: Gah! " - "write return code: %02x %02x\n", - reply[0], reply[1]); + usb_stor_dbg(us, "Gah! write return code: %02x %02x\n", + reply[0], reply[1]); result = USB_STOR_TRANSPORT_ERROR; goto leave; } @@ -342,7 +341,7 @@ static int datafab_determine_lun(struct us_data *us, if (!buf) return USB_STOR_TRANSPORT_ERROR; - US_DEBUGP("datafab_determine_lun: locating...\n"); + usb_stor_dbg(us, "locating...\n"); // we'll try 3 times before giving up... // @@ -474,16 +473,16 @@ static int datafab_handle_mode_sense(struct us_data *us, switch (pc) { case 0x0: - US_DEBUGP("datafab_handle_mode_sense: Current values\n"); + usb_stor_dbg(us, "Current values\n"); break; case 0x1: - US_DEBUGP("datafab_handle_mode_sense: Changeable values\n"); + usb_stor_dbg(us, "Changeable values\n"); break; case 0x2: - US_DEBUGP("datafab_handle_mode_sense: Default values\n"); + usb_stor_dbg(us, "Default values\n"); break; case 0x3: - US_DEBUGP("datafab_handle_mode_sense: Saves values\n"); + usb_stor_dbg(us, "Saves values\n"); break; } @@ -566,11 +565,9 @@ static int datafab_transport(struct scsi_cmnd *srb, struct us_data *us) if (!us->extra) { us->extra = kzalloc(sizeof(struct datafab_info), GFP_NOIO); - if (!us->extra) { - US_DEBUGP("datafab_transport: Gah! " - "Can't allocate storage for Datafab info struct!\n"); + if (!us->extra) return USB_STOR_TRANSPORT_ERROR; - } + us->extra_destructor = datafab_info_destructor; ((struct datafab_info *)us->extra)->lun = -1; } @@ -578,7 +575,7 @@ static int datafab_transport(struct scsi_cmnd *srb, struct us_data *us) info = (struct datafab_info *) (us->extra); if (srb->cmnd[0] == INQUIRY) { - US_DEBUGP("datafab_transport: INQUIRY. Returning bogus response"); + usb_stor_dbg(us, "INQUIRY - Returning bogus response\n"); memcpy(ptr, inquiry_reply, sizeof(inquiry_reply)); fill_inquiry_response(us, ptr, 36); return USB_STOR_TRANSPORT_GOOD; @@ -590,8 +587,8 @@ static int datafab_transport(struct scsi_cmnd *srb, struct us_data *us) if (rc != USB_STOR_TRANSPORT_GOOD) return rc; - US_DEBUGP("datafab_transport: READ_CAPACITY: %ld sectors, %ld bytes per sector\n", - info->sectors, info->ssize); + usb_stor_dbg(us, "READ_CAPACITY: %ld sectors, %ld bytes per sector\n", + info->sectors, info->ssize); // build the reply // 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) } if (srb->cmnd[0] == MODE_SELECT_10) { - US_DEBUGP("datafab_transport: Gah! MODE_SELECT_10.\n"); + usb_stor_dbg(us, "Gah! MODE_SELECT_10\n"); return USB_STOR_TRANSPORT_ERROR; } @@ -615,7 +612,8 @@ static int datafab_transport(struct scsi_cmnd *srb, struct us_data *us) blocks = ((u32)(srb->cmnd[7]) << 8) | ((u32)(srb->cmnd[8])); - US_DEBUGP("datafab_transport: READ_10: read block 0x%04lx count %ld\n", block, blocks); + usb_stor_dbg(us, "READ_10: read block 0x%04lx count %ld\n", + block, blocks); return datafab_read_data(us, info, block, blocks); } @@ -628,7 +626,8 @@ static int datafab_transport(struct scsi_cmnd *srb, struct us_data *us) blocks = ((u32)(srb->cmnd[6]) << 24) | ((u32)(srb->cmnd[7]) << 16) | ((u32)(srb->cmnd[8]) << 8) | ((u32)(srb->cmnd[9])); - US_DEBUGP("datafab_transport: READ_12: read block 0x%04lx count %ld\n", block, blocks); + usb_stor_dbg(us, "READ_12: read block 0x%04lx count %ld\n", + block, blocks); return datafab_read_data(us, info, block, blocks); } @@ -638,7 +637,8 @@ static int datafab_transport(struct scsi_cmnd *srb, struct us_data *us) blocks = ((u32)(srb->cmnd[7]) << 8) | ((u32)(srb->cmnd[8])); - US_DEBUGP("datafab_transport: WRITE_10: write block 0x%04lx count %ld\n", block, blocks); + usb_stor_dbg(us, "WRITE_10: write block 0x%04lx count %ld\n", + block, blocks); return datafab_write_data(us, info, block, blocks); } @@ -651,17 +651,18 @@ static int datafab_transport(struct scsi_cmnd *srb, struct us_data *us) blocks = ((u32)(srb->cmnd[6]) << 24) | ((u32)(srb->cmnd[7]) << 16) | ((u32)(srb->cmnd[8]) << 8) | ((u32)(srb->cmnd[9])); - US_DEBUGP("datafab_transport: WRITE_12: write block 0x%04lx count %ld\n", block, blocks); + usb_stor_dbg(us, "WRITE_12: write block 0x%04lx count %ld\n", + block, blocks); return datafab_write_data(us, info, block, blocks); } if (srb->cmnd[0] == TEST_UNIT_READY) { - US_DEBUGP("datafab_transport: TEST_UNIT_READY.\n"); + usb_stor_dbg(us, "TEST_UNIT_READY\n"); return datafab_id_device(us, info); } if (srb->cmnd[0] == REQUEST_SENSE) { - US_DEBUGP("datafab_transport: REQUEST_SENSE. Returning faked response\n"); + usb_stor_dbg(us, "REQUEST_SENSE - Returning faked response\n"); // this response is pretty bogus right now. eventually if necessary // 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) } if (srb->cmnd[0] == MODE_SENSE) { - US_DEBUGP("datafab_transport: MODE_SENSE_6 detected\n"); + usb_stor_dbg(us, "MODE_SENSE_6 detected\n"); return datafab_handle_mode_sense(us, srb, 1); } if (srb->cmnd[0] == MODE_SENSE_10) { - US_DEBUGP("datafab_transport: MODE_SENSE_10 detected\n"); + usb_stor_dbg(us, "MODE_SENSE_10 detected\n"); return datafab_handle_mode_sense(us, srb, 0); } @@ -698,7 +699,7 @@ static int datafab_transport(struct scsi_cmnd *srb, struct us_data *us) if (srb->cmnd[0] == START_STOP) { /* this is used by sd.c'check_scsidisk_media_change to detect media change */ - US_DEBUGP("datafab_transport: START_STOP.\n"); + usb_stor_dbg(us, "START_STOP\n"); /* the first datafab_id_device after a media change returns an error (determined experimentally) */ rc = datafab_id_device(us, info); @@ -712,8 +713,8 @@ static int datafab_transport(struct scsi_cmnd *srb, struct us_data *us) return rc; } - US_DEBUGP("datafab_transport: Gah! Unknown command: %d (0x%x)\n", - srb->cmnd[0], srb->cmnd[0]); + usb_stor_dbg(us, "Gah! Unknown command: %d (0x%x)\n", + srb->cmnd[0], srb->cmnd[0]); info->sense_key = 0x05; info->sense_asc = 0x20; 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 @@ * 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include <linux/device.h> #include <linux/cdrom.h> #include <linux/export.h> #include <scsi/scsi.h> #include <scsi/scsi_cmnd.h> #include <scsi/scsi_dbg.h> +#include "usb.h" #include "debug.h" #include "scsi.h" -void usb_stor_show_command(struct scsi_cmnd *srb) +void usb_stor_show_command(const struct us_data *us, struct scsi_cmnd *srb) { char *what = NULL; int i; @@ -150,18 +152,18 @@ void usb_stor_show_command(struct scsi_cmnd *srb) case WRITE_LONG_2: what = "WRITE_LONG_2"; break; default: what = "(unknown command)"; break; } - US_DEBUGP("Command %s (%d bytes)\n", what, srb->cmd_len); - US_DEBUGP("bytes: "); + usb_stor_dbg(us, "Command %s (%d bytes)\n", what, srb->cmd_len); + usb_stor_dbg(us, "bytes: "); for (i = 0; i < srb->cmd_len && i < 16; i++) US_DEBUGPX(" %02x", srb->cmnd[i]); US_DEBUGPX("\n"); } -void usb_stor_show_sense( - unsigned char key, - unsigned char asc, - unsigned char ascq) { - +void usb_stor_show_sense(const struct us_data *us, + unsigned char key, + unsigned char asc, + unsigned char ascq) +{ const char *what, *keystr; keystr = scsi_sense_key_string(key); @@ -172,23 +174,19 @@ void usb_stor_show_sense( if (what == NULL) what = "(unknown ASC/ASCQ)"; - US_DEBUGP("%s: ", keystr); + usb_stor_dbg(us, "%s: ", keystr); US_DEBUGPX(what, ascq); US_DEBUGPX("\n"); } -int usb_stor_dbg(const char *fmt, ...) +int usb_stor_dbg(const struct us_data *us, const char *fmt, ...) { - struct va_format vaf; va_list args; int r; va_start(args, fmt); - vaf.fmt = fmt; - vaf.va = &args; - - r = printk(KERN_DEBUG USB_STORAGE "%pV", &vaf); + r = dev_vprintk_emit(7, &us->pusb_dev->dev, fmt, args); va_end(args); 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 @@ #define USB_STORAGE "usb-storage: " #ifdef CONFIG_USB_STORAGE_DEBUG -void usb_stor_show_command(struct scsi_cmnd *srb); -void usb_stor_show_sense( unsigned char key, - unsigned char asc, unsigned char ascq ); -__printf(1, 2) int usb_stor_dbg(const char *fmt, ...); +void usb_stor_show_command(const struct us_data *us, struct scsi_cmnd *srb); +void usb_stor_show_sense(const struct us_data *us, unsigned char key, + unsigned char asc, unsigned char ascq); +__printf(2, 3) int usb_stor_dbg(const struct us_data *us, + const char *fmt, ...); -#define US_DEBUGP(fmt, ...) usb_stor_dbg(fmt, ##__VA_ARGS__) #define US_DEBUGPX(fmt, ...) printk(fmt, ##__VA_ARGS__) #define US_DEBUG(x) x #else -#define US_DEBUGP(fmt, ...) \ - do { if (0) printk(fmt, ##__VA_ARGS__); } while (0) +__printf(2, 3) +static inline int _usb_stor_dbg(const struct us_data *us, + const char *fmt, ...) {return 1;} +#define usb_stor_dbg(us, fmt, ...) \ + do { if (0) _usb_stor_dbg(us, fmt, ##__VA_ARGS__); } while (0) #define US_DEBUGPX(fmt, ...) \ do { if (0) printk(fmt, ##__VA_ARGS__); } while (0) #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) unsigned int cswlen = 0, partial = 0; unsigned int transfer_length = bcb->DataTransferLength; - /* US_DEBUGP("transport --- ene_send_scsi_cmd\n"); */ + /* usb_stor_dbg(us, "transport --- ene_send_scsi_cmd\n"); */ /* send cmd to out endpoint */ result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, bcb, US_BULK_CB_WRAP_LEN, NULL); if (result != USB_STOR_XFER_GOOD) { - US_DEBUGP("send cmd to out endpoint fail ---\n"); + usb_stor_dbg(us, "send cmd to out endpoint fail ---\n"); return USB_STOR_TRANSPORT_ERROR; } @@ -529,7 +529,7 @@ static int ene_send_scsi_cmd(struct us_data *us, u8 fDir, void *buf, int use_sg) transfer_length, 0, &partial); } if (result != USB_STOR_XFER_GOOD) { - US_DEBUGP("data transfer fail ---\n"); + usb_stor_dbg(us, "data transfer fail ---\n"); return USB_STOR_TRANSPORT_ERROR; } } @@ -539,14 +539,14 @@ static int ene_send_scsi_cmd(struct us_data *us, u8 fDir, void *buf, int use_sg) US_BULK_CS_WRAP_LEN, &cswlen); if (result == USB_STOR_XFER_SHORT && cswlen == 0) { - US_DEBUGP("Received 0-length CSW; retrying...\n"); + usb_stor_dbg(us, "Received 0-length CSW; retrying...\n"); result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, bcs, US_BULK_CS_WRAP_LEN, &cswlen); } if (result == USB_STOR_XFER_STALLED) { /* get the status again */ - US_DEBUGP("Attempting to get CSW (2nd try)...\n"); + usb_stor_dbg(us, "Attempting to get CSW (2nd try)...\n"); result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, bcs, US_BULK_CS_WRAP_LEN, NULL); } @@ -626,7 +626,7 @@ static int sd_scsi_read_capacity(struct us_data *us, struct scsi_cmnd *srb) struct scatterlist *sg = NULL; struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; - US_DEBUGP("sd_scsi_read_capacity\n"); + usb_stor_dbg(us, "sd_scsi_read_capacity\n"); if (info->SD_Status.HiCapacity) { bl_len = 0x200; if (info->SD_Status.IsMMC) @@ -639,8 +639,8 @@ static int sd_scsi_read_capacity(struct us_data *us, struct scsi_cmnd *srb) * (1 << (info->SD_C_SIZE_MULT + 2)) - 1; } info->bl_num = bl_num; - US_DEBUGP("bl_len = %x\n", bl_len); - US_DEBUGP("bl_num = %x\n", bl_num); + usb_stor_dbg(us, "bl_len = %x\n", bl_len); + usb_stor_dbg(us, "bl_num = %x\n", bl_num); /*srb->request_bufflen = 8; */ buf[0] = (bl_num >> 24) & 0xff; @@ -675,7 +675,7 @@ static int sd_scsi_read(struct us_data *us, struct scsi_cmnd *srb) result = ene_load_bincode(us, SD_RW_PATTERN); if (result != USB_STOR_XFER_GOOD) { - US_DEBUGP("Load SD RW pattern Fail !!\n"); + usb_stor_dbg(us, "Load SD RW pattern Fail !!\n"); return USB_STOR_TRANSPORT_ERROR; } @@ -715,7 +715,7 @@ static int sd_scsi_write(struct us_data *us, struct scsi_cmnd *srb) result = ene_load_bincode(us, SD_RW_PATTERN); if (result != USB_STOR_XFER_GOOD) { - US_DEBUGP("Load SD RW pattern Fail !!\n"); + usb_stor_dbg(us, "Load SD RW pattern Fail !!\n"); return USB_STOR_TRANSPORT_ERROR; } @@ -1493,7 +1493,7 @@ static int ms_scsi_read_capacity(struct us_data *us, struct scsi_cmnd *srb) struct scatterlist *sg = NULL; struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; - US_DEBUGP("ms_scsi_read_capacity\n"); + usb_stor_dbg(us, "ms_scsi_read_capacity\n"); bl_len = 0x200; if (info->MS_Status.IsMSPro) bl_num = info->MSP_TotalBlock - 1; @@ -1501,8 +1501,8 @@ static int ms_scsi_read_capacity(struct us_data *us, struct scsi_cmnd *srb) bl_num = info->MS_Lib.NumberOfLogBlock * info->MS_Lib.blockSize * 2 - 1; info->bl_num = bl_num; - US_DEBUGP("bl_len = %x\n", bl_len); - US_DEBUGP("bl_num = %x\n", bl_num); + usb_stor_dbg(us, "bl_len = %x\n", bl_len); + usb_stor_dbg(us, "bl_num = %x\n", bl_num); /*srb->request_bufflen = 8; */ buf[0] = (bl_num >> 24) & 0xff; @@ -1654,7 +1654,7 @@ static int ms_scsi_read(struct us_data *us, struct scsi_cmnd *srb) if (info->MS_Status.IsMSPro) { result = ene_load_bincode(us, MSP_RW_PATTERN); if (result != USB_STOR_XFER_GOOD) { - US_DEBUGP("Load MPS RW pattern Fail !!\n"); + usb_stor_dbg(us, "Load MPS RW pattern Fail !!\n"); return USB_STOR_TRANSPORT_ERROR; } @@ -1854,7 +1854,7 @@ static int ene_get_card_status(struct us_data *us, u8 *buf) u32 reg4b; struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; - /*US_DEBUGP("transport --- ENE_ReadSDReg\n");*/ + /*usb_stor_dbg(us, "transport --- ENE_ReadSDReg\n");*/ reg4b = *(u32 *)&buf[0x18]; info->SD_READ_BL_LEN = (u8)((reg4b >> 8) & 0x0f); @@ -1894,45 +1894,44 @@ static int ene_load_bincode(struct us_data *us, unsigned char flag) switch (flag) { /* For SD */ case SD_INIT1_PATTERN: - US_DEBUGP("SD_INIT1_PATTERN\n"); + usb_stor_dbg(us, "SD_INIT1_PATTERN\n"); fw_name = SD_INIT1_FIRMWARE; break; case SD_INIT2_PATTERN: - US_DEBUGP("SD_INIT2_PATTERN\n"); + usb_stor_dbg(us, "SD_INIT2_PATTERN\n"); fw_name = SD_INIT2_FIRMWARE; break; case SD_RW_PATTERN: - US_DEBUGP("SD_RW_PATTERN\n"); + usb_stor_dbg(us, "SD_RW_PATTERN\n"); fw_name = SD_RW_FIRMWARE; break; /* For MS */ case MS_INIT_PATTERN: - US_DEBUGP("MS_INIT_PATTERN\n"); + usb_stor_dbg(us, "MS_INIT_PATTERN\n"); fw_name = MS_INIT_FIRMWARE; break; case MSP_RW_PATTERN: - US_DEBUGP("MSP_RW_PATTERN\n"); + usb_stor_dbg(us, "MSP_RW_PATTERN\n"); fw_name = MSP_RW_FIRMWARE; break; case MS_RW_PATTERN: - US_DEBUGP("MS_RW_PATTERN\n"); + usb_stor_dbg(us, "MS_RW_PATTERN\n"); fw_name = MS_RW_FIRMWARE; break; default: - US_DEBUGP("----------- Unknown PATTERN ----------\n"); + usb_stor_dbg(us, "----------- Unknown PATTERN ----------\n"); goto nofw; } err = request_firmware(&sd_fw, fw_name, &us->pusb_dev->dev); if (err) { - US_DEBUGP("load firmware %s failed\n", fw_name); + usb_stor_dbg(us, "load firmware %s failed\n", fw_name); goto nofw; } buf = kmalloc(sd_fw->size, GFP_KERNEL); - if (buf == NULL) { - US_DEBUGP("Malloc memory for fireware failed!\n"); + if (buf == NULL) goto nofw; - } + memcpy(buf, sd_fw->data, sd_fw->size); memset(bcb, 0, sizeof(struct bulk_cb_wrap)); bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); @@ -2116,9 +2115,9 @@ static int ene_ms_init(struct us_data *us) } else { ms_card_init(us); /* Card is MS (to ms.c)*/ } - US_DEBUGP("MS Init Code OK !!\n"); + usb_stor_dbg(us, "MS Init Code OK !!\n"); } else { - US_DEBUGP("MS Card Not Ready --- %x\n", buf[0]); + usb_stor_dbg(us, "MS Card Not Ready --- %x\n", buf[0]); return USB_STOR_TRANSPORT_ERROR; } @@ -2132,11 +2131,11 @@ static int ene_sd_init(struct us_data *us) struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; - US_DEBUGP("transport --- ENE_SDInit\n"); + usb_stor_dbg(us, "transport --- ENE_SDInit\n"); /* SD Init Part-1 */ result = ene_load_bincode(us, SD_INIT1_PATTERN); if (result != USB_STOR_XFER_GOOD) { - US_DEBUGP("Load SD Init Code Part-1 Fail !!\n"); + usb_stor_dbg(us, "Load SD Init Code Part-1 Fail !!\n"); return USB_STOR_TRANSPORT_ERROR; } @@ -2147,14 +2146,14 @@ static int ene_sd_init(struct us_data *us) result = ene_send_scsi_cmd(us, FDIR_READ, NULL, 0); if (result != USB_STOR_XFER_GOOD) { - US_DEBUGP("Execution SD Init Code Fail !!\n"); + usb_stor_dbg(us, "Execution SD Init Code Fail !!\n"); return USB_STOR_TRANSPORT_ERROR; } /* SD Init Part-2 */ result = ene_load_bincode(us, SD_INIT2_PATTERN); if (result != USB_STOR_XFER_GOOD) { - US_DEBUGP("Load SD Init Code Part-2 Fail !!\n"); + usb_stor_dbg(us, "Load SD Init Code Part-2 Fail !!\n"); return USB_STOR_TRANSPORT_ERROR; } @@ -2166,21 +2165,23 @@ static int ene_sd_init(struct us_data *us) result = ene_send_scsi_cmd(us, FDIR_READ, &buf, 0); if (result != USB_STOR_XFER_GOOD) { - US_DEBUGP("Execution SD Init Code Fail !!\n"); + usb_stor_dbg(us, "Execution SD Init Code Fail !!\n"); return USB_STOR_TRANSPORT_ERROR; } < |