Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 191648d0 authored by Joe Perches's avatar Joe Perches Committed by Greg Kroah-Hartman
Browse files

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: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f1175daa
Loading
Loading
Loading
Loading
+45 −56
Original line number Diff line number Diff line
@@ -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,14 +412,14 @@ 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",
	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) {
@@ -432,7 +431,7 @@ 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",
	usb_stor_dbg(us, "Found media with capacity: %ldMB\n",
		     MEDIA_INFO(us).capacity >> 20);

	MEDIA_INFO(us).pageshift = media_info->pageshift;
@@ -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],
			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,13 +862,13 @@ 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",
			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",
			usb_stor_dbg(us, "Warning: bad ecc in page %d+ of pba %d\n",
				     i, pba);
			nand_store_ecc(cptr+8, ecc);
		}
@@ -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,7 +973,7 @@ 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",
			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
@@ -988,8 +983,7 @@ 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",
			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);
@@ -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,7 +1226,7 @@ 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",
	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;
+1 −1
Original line number Diff line number Diff line
@@ -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;
	}

+30 −29
Original line number Diff line number Diff line
@@ -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,8 +300,7 @@ 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",
			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,7 +587,7 @@ 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",
		usb_stor_dbg(us, "READ_CAPACITY:  %ld sectors, %ld bytes per sector\n",
			     info->sectors, info->ssize);

		// build the reply
@@ -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,7 +713,7 @@ 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",
	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;
+13 −15
Original line number Diff line number Diff line
@@ -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(
void usb_stor_show_sense(const struct us_data *us,
			 unsigned char key,
			 unsigned char asc,
		unsigned char ascq) {

			 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);

+10 −7
Original line number Diff line number Diff line
@@ -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,
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(1, 2) int usb_stor_dbg(const char *fmt, ...);
__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)
Loading