本文整理汇总了C++中US_DEBUGP函数的典型用法代码示例。如果您正苦于以下问题:C++ US_DEBUGP函数的具体用法?C++ US_DEBUGP怎么用?C++ US_DEBUGP使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了US_DEBUGP函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: debug_swoc
static void debug_swoc(struct swoc_info *swocInfo)
{
US_DEBUGP("SWIMS: SWoC Rev: %02d \n", swocInfo->rev);
US_DEBUGP("SWIMS: Linux SKU: %04X \n", swocInfo->LinuxSKU);
US_DEBUGP("SWIMS: Linux Version: %04X \n", swocInfo->LinuxVer);
}
示例2: usb_stor_control_thread
static int usb_stor_control_thread(void * __us)
{
struct us_data *us = (struct us_data *)__us;
struct Scsi_Host *host = us_to_host(us);
//---------------------------
pr_info("7 usb stor control thread\n");
for(;;) {
//若有u盘拔插或者有命令才会awake,否则一直就在这睡觉觉
if (wait_for_completion_interruptible(&us->cmnd_ready))
break;
//从此处wake
/* */
mutex_lock(&(us->dev_mutex));
/*每当需要写us->srb时候就需要锁之 */
scsi_lock(host);
if (us->srb == NULL) {
scsi_unlock(host);
mutex_unlock(&us->dev_mutex);
US_DEBUGP("-- exiting\n");
break;
}
if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) {
us->srb->result = DID_ABORT << 16;
goto SkipForAbort;
}
scsi_unlock(host);
if (us->srb->sc_data_direction == DMA_BIDIRECTIONAL) {
US_DEBUGP("UNKNOWN data direction\n");
us->srb->result = DID_ERROR << 16;
}
else if (us->srb->device->id &&
!(us->fflags & US_FL_SCM_MULT_TARG)) {
US_DEBUGP("Bad target number (%d:%d)\n",
us->srb->device->id, us->srb->device->lun);
us->srb->result = DID_BAD_TARGET << 16;
}
else if (us->srb->device->lun > us->max_lun) {
US_DEBUGP("Bad LUN (%d:%d)\n",
us->srb->device->id, us->srb->device->lun);
us->srb->result = DID_BAD_TARGET << 16;
}
else if ((us->srb->cmnd[0] == INQUIRY) &&
(us->fflags & US_FL_FIX_INQUIRY)) {
unsigned char data_ptr[36] = {
0x00, 0x80, 0x02, 0x02,
0x1F, 0x00, 0x00, 0x00};
US_DEBUGP("Faking INQUIRY command\n");
fill_inquiry_response(us, data_ptr, 36);
us->srb->result = SAM_STAT_GOOD;
}
else {
US_DEBUG(usb_stor_show_command(us->srb));
us->proto_handler(us->srb, us);
usb_mark_last_busy(us->pusb_dev);
}
scsi_lock(host);
if (us->srb->result != DID_ABORT << 16) {
US_DEBUGP("scsi cmd done, result=0x%x\n",
us->srb->result);
us->srb->scsi_done(us->srb);
} else {
SkipForAbort:
US_DEBUGP("scsi command aborted\n");
}
/* */
if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) {
complete(&(us->notify));
clear_bit(US_FLIDX_ABORTING, &us->dflags);
clear_bit(US_FLIDX_TIMED_OUT, &us->dflags);
}
us->srb = NULL;
scsi_unlock(host);
//.........这里部分代码省略.........
示例3: freecom_transport
/*
* Transport for the Freecom USB/IDE adaptor.
*
*/
static int freecom_transport(struct scsi_cmnd *srb, struct us_data *us)
{
struct freecom_cb_wrap *fcb;
struct freecom_status *fst;
unsigned int ipipe, opipe; /* We need both pipes. */
int result;
unsigned int partial;
int length;
fcb = (struct freecom_cb_wrap *) us->iobuf;
fst = (struct freecom_status *) us->iobuf;
US_DEBUGP("Freecom TRANSPORT STARTED\n");
/* Get handles for both transports. */
opipe = us->send_bulk_pipe;
ipipe = us->recv_bulk_pipe;
/* The ATAPI Command always goes out first. */
fcb->Type = FCM_PACKET_ATAPI | 0x00;
fcb->Timeout = 0;
memcpy (fcb->Atapi, srb->cmnd, 12);
memset (fcb->Filler, 0, sizeof (fcb->Filler));
US_DEBUG(pdump (srb->cmnd, 12));
/* Send it out. */
result = usb_stor_bulk_transfer_buf (us, opipe, fcb,
FCM_PACKET_LENGTH, NULL);
/* The Freecom device will only fail if there is something wrong in
* USB land. It returns the status in its own registers, which
* come back in the bulk pipe. */
if (result != USB_STOR_XFER_GOOD) {
US_DEBUGP ("freecom transport error\n");
return USB_STOR_TRANSPORT_ERROR;
}
/* There are times we can optimize out this status read, but it
* doesn't hurt us to always do it now. */
result = usb_stor_bulk_transfer_buf (us, ipipe, fst,
FCM_STATUS_PACKET_LENGTH, &partial);
US_DEBUGP("foo Status result %d %u\n", result, partial);
if (result != USB_STOR_XFER_GOOD)
return USB_STOR_TRANSPORT_ERROR;
US_DEBUG(pdump ((void *) fst, partial));
/* The firmware will time-out commands after 20 seconds. Some commands
* can legitimately take longer than this, so we use a different
* command that only waits for the interrupt and then sends status,
* without having to send a new ATAPI command to the device.
*
* NOTE: There is some indication that a data transfer after a timeout
* may not work, but that is a condition that should never happen.
*/
while (fst->Status & FCM_STATUS_BUSY) {
US_DEBUGP("20 second USB/ATAPI bridge TIMEOUT occurred!\n");
US_DEBUGP("fst->Status is %x\n", fst->Status);
/* Get the status again */
fcb->Type = FCM_PACKET_STATUS;
fcb->Timeout = 0;
memset (fcb->Atapi, 0, sizeof(fcb->Atapi));
memset (fcb->Filler, 0, sizeof (fcb->Filler));
/* Send it out. */
result = usb_stor_bulk_transfer_buf (us, opipe, fcb,
FCM_PACKET_LENGTH, NULL);
/* The Freecom device will only fail if there is something
* wrong in USB land. It returns the status in its own
* registers, which come back in the bulk pipe.
*/
if (result != USB_STOR_XFER_GOOD) {
US_DEBUGP ("freecom transport error\n");
return USB_STOR_TRANSPORT_ERROR;
}
/* get the data */
result = usb_stor_bulk_transfer_buf (us, ipipe, fst,
FCM_STATUS_PACKET_LENGTH, &partial);
US_DEBUGP("bar Status result %d %u\n", result, partial);
if (result != USB_STOR_XFER_GOOD)
return USB_STOR_TRANSPORT_ERROR;
US_DEBUG(pdump ((void *) fst, partial));
}
if (partial != 4)
return USB_STOR_TRANSPORT_ERROR;
if ((fst->Status & 1) != 0) {
US_DEBUGP("operation failed\n");
return USB_STOR_TRANSPORT_FAILED;
}
//.........这里部分代码省略.........
示例4: sddr55_write_data
static int sddr55_write_data(struct us_data *us,
unsigned int lba,
unsigned int page,
unsigned short sectors,
unsigned char *content,
int use_sg) {
int result;
unsigned char command[8] = {
0, 0, 0, 0, 0, 0xb0, 0, 0x86
};
unsigned char status[8];
struct sddr55_card_info *info = (struct sddr55_card_info *)us->extra;
unsigned int pba;
unsigned int new_pba;
unsigned long address;
unsigned short pages;
unsigned char *buffer = NULL;
unsigned char *ptr;
struct scatterlist *sg = NULL;
int i;
int len;
int transferred;
/* check if we are allowed to write */
if (info->read_only || info->force_read_only) {
set_sense_info (7, 0x27, 0); /* read only */
return USB_STOR_TRANSPORT_FAILED;
}
// If we're using scatter-gather, we have to create a new
// buffer to write all of the data in first, since a
// scatter-gather buffer could in theory start in the middle
// of a page, which would be bad. A developer who wants a
// challenge might want to write a limited-buffer
// version of this code.
len = sectors * PAGESIZE;
if (use_sg) {
sg = (struct scatterlist *)content;
buffer = kmalloc(len, GFP_NOIO);
if (buffer == NULL)
return USB_STOR_TRANSPORT_ERROR;
transferred = 0;
for (i=0; i<use_sg && transferred<len; i++) {
memcpy(buffer+transferred, sg[i].address,
len-transferred > sg[i].length ?
sg[i].length : len-transferred);
transferred += sg[i].length;
}
ptr = buffer;
} else
ptr = content;
while (sectors > 0) {
/* have we got to end? */
if (lba >= info->max_log_blks)
break;
pba = info->lba_to_pba[lba];
// Write as many sectors as possible in this block
pages = info->blocksize - page;
if (pages > (sectors << info->smallpageshift))
pages = (sectors << info->smallpageshift);
US_DEBUGP("Write %02X pages, to PBA %04X"
" (LBA %04X) page %02X\n",
pages, pba, lba, page);
command[4] = 0;
if (pba == NOT_ALLOCATED) {
/* no pba allocated for this lba, find a free pba to use */
int max_pba = (info->max_log_blks / 250 ) * 256;
int found_count = 0;
int found_pba = -1;
/* set pba to first block in zone lba is in */
pba = (lba / 1000) * 1024;
US_DEBUGP("No PBA for LBA %04X\n",lba);
if (max_pba > 1024)
max_pba = 1024;
/* scan through the map lookiong for an unused block
* leave 16 unused blocks at start (or as many as possible)
* since the sddr55 seems to reuse a used block when it shouldn't
* if we don't leave space */
for (i = 0; i < max_pba; i++, pba++) {
if (info->pba_to_lba[pba] == UNUSED_BLOCK) {
//.........这里部分代码省略.........
示例5: sddr55_raw_bulk
static int sddr55_raw_bulk(struct us_data *us,
int direction,
unsigned char *data,
unsigned int len) {
int result;
int act_len;
int pipe;
if (direction == SCSI_DATA_READ)
pipe = usb_rcvbulkpipe(us->pusb_dev, us->ep_in);
else
pipe = usb_sndbulkpipe(us->pusb_dev, us->ep_out);
result = usb_stor_bulk_msg(us, data, pipe, len, &act_len);
/* if we stall, we need to clear it before we go on */
if (result == -EPIPE) {
US_DEBUGP("EPIPE: clearing endpoint halt for"
" pipe 0x%x, stalled at %d bytes\n",
pipe, act_len);
usb_clear_halt(us->pusb_dev, pipe);
}
if (result) {
/* NAK - that means we've retried a few times already */
if (result == -ETIMEDOUT) {
US_DEBUGP("usbat_raw_bulk():"
" device NAKed\n");
return US_BULK_TRANSFER_FAILED;
}
/* -ENOENT -- we canceled this transfer */
if (result == -ENOENT) {
US_DEBUGP("usbat_raw_bulk():"
" transfer aborted\n");
return US_BULK_TRANSFER_ABORTED;
}
if (result == -EPIPE) {
US_DEBUGP("usbat_raw_bulk():"
" output pipe stalled\n");
return US_BULK_TRANSFER_FAILED;
}
/* the catch-all case */
US_DEBUGP("us_transfer_partial(): unknown error\n");
return US_BULK_TRANSFER_FAILED;
}
if (act_len != len) {
US_DEBUGP("Warning: Transferred only %d bytes\n",
act_len);
return US_BULK_TRANSFER_SHORT;
}
US_DEBUGP("Transferred %d of %d bytes\n", act_len, len);
return US_BULK_TRANSFER_GOOD;
}
示例6: sddr55_bulk_transport
static int sddr55_bulk_transport(struct us_data *us,
int direction,
unsigned char *data,
unsigned int len) {
int result = USB_STOR_TRANSPORT_GOOD;
struct sddr55_card_info *info = (struct sddr55_card_info *)us->extra;
if (len==0)
return USB_STOR_TRANSPORT_GOOD;
info->last_access = jiffies;
#ifdef CONFIG_USB_STORAGE_DEBUG
if (direction == SCSI_DATA_WRITE) {
int i;
char string[64];
/* Debug-print the first 48 bytes of the write transfer */
strcpy(string, "wr: ");
for (i=0; i<len && i<48; i++) {
sprintf(string+strlen(string), "%02X ",
data[i]);
if ((i%16)==15) {
US_DEBUGP("%s\n", string);
strcpy(string, "wr: ");
}
}
if ((i%16)!=0)
US_DEBUGP("%s\n", string);
}
#endif
/* transfer the data */
US_DEBUGP("SCM data %s transfer %d\n",
( direction==SCSI_DATA_READ ? "in" : "out"),
len);
result = sddr55_raw_bulk(us, direction, data, len);
#ifdef CONFIG_USB_STORAGE_DEBUG
if (direction == SCSI_DATA_READ) {
int i;
char string[64];
/* Debug-print the first 48 bytes of the read transfer */
strcpy(string, "rd: ");
for (i=0; i<len && i<48; i++) {
sprintf(string+strlen(string), "%02X ",
data[i]);
if ((i%16)==15) {
US_DEBUGP("%s\n", string);
strcpy(string, "rd: ");
}
}
if ((i%16)!=0)
US_DEBUGP("%s\n", string);
}
#endif
return result;
}
示例7: sddr55_read_data
static int sddr55_read_data(struct us_data *us,
unsigned int lba,
unsigned int page,
unsigned short sectors,
unsigned char *content,
int use_sg) {
int result;
unsigned char command[8] = {
0, 0, 0, 0, 0, 0xb0, 0, 0x85
};
unsigned char status[8];
struct sddr55_card_info *info = (struct sddr55_card_info *)us->extra;
unsigned int pba;
unsigned long address;
unsigned short pages;
unsigned char *buffer = NULL;
unsigned char *ptr;
struct scatterlist *sg = NULL;
int i;
int len;
int transferred;
// If we're using scatter-gather, we have to create a new
// buffer to read all of the data in first, since a
// scatter-gather buffer could in theory start in the middle
// of a page, which would be bad. A developer who wants a
// challenge might want to write a limited-buffer
// version of this code.
len = sectors * PAGESIZE;
if (use_sg) {
sg = (struct scatterlist *)content;
buffer = kmalloc(len, GFP_NOIO);
if (buffer == NULL)
return USB_STOR_TRANSPORT_ERROR;
ptr = buffer;
} else
ptr = content;
// This could be made much more efficient by checking for
// contiguous LBA's. Another exercise left to the student.
while (sectors>0) {
/* have we got to end? */
if (lba >= info->max_log_blks)
break;
pba = info->lba_to_pba[lba];
// Read as many sectors as possible in this block
pages = info->blocksize - page;
if (pages > (sectors << info->smallpageshift))
pages = (sectors << info->smallpageshift);
US_DEBUGP("Read %02X pages, from PBA %04X"
" (LBA %04X) page %02X\n",
pages, pba, lba, page);
if (pba == NOT_ALLOCATED) {
/* no pba for this lba, fill with zeroes */
memset (ptr, 0, pages << info->pageshift);
} else {
address = (pba << info->blockshift) + page;
command[1] = LSB_of(address>>16);
command[2] = LSB_of(address>>8);
command[3] = LSB_of(address);
command[6] = LSB_of(pages << (1 - info->smallpageshift));
/* send command */
result = sddr55_bulk_transport(us,
SCSI_DATA_WRITE, command, 8);
US_DEBUGP("Result for send_command in read_data %d\n",
result);
if (result != US_BULK_TRANSFER_GOOD) {
if (use_sg)
kfree(buffer);
return result;
}
/* read data */
result = sddr55_bulk_transport(us,
SCSI_DATA_READ, ptr,
pages<<info->pageshift);
if (result != US_BULK_TRANSFER_GOOD) {
if (use_sg)
kfree(buffer);
return result;
}
//.........这里部分代码省略.........
示例8: interpret_urb_result
/*
* Interpret the results of a URB transfer
*
* This function prints appropriate debugging messages, clears halts on
* non-control endpoints, and translates the status to the corresponding
* USB_STOR_XFER_xxx return code.
*/
static int interpret_urb_result(struct us_data *us, unsigned int pipe,
unsigned int length, int result, unsigned int partial)
{
US_DEBUGP("Status code %d; transferred %u/%u\n",
result, partial, length);
switch (result) {
/* no error code; did we send all the data? */
case 0:
if (partial != length) {
US_DEBUGP("-- short transfer\n");
return USB_STOR_XFER_SHORT;
}
US_DEBUGP("-- transfer complete\n");
return USB_STOR_XFER_GOOD;
/* stalled */
case -EPIPE:
/* for control endpoints, (used by CB[I]) a stall indicates
* a failed command */
if (usb_pipecontrol(pipe)) {
US_DEBUGP("-- stall on control pipe\n");
#ifdef CONFIG_USB_STORAGE_DETECT
printk(KERN_INFO "usb storage -- stall on control pipe\n");
#endif
return USB_STOR_XFER_STALLED;
}
/* for other sorts of endpoint, clear the stall */
US_DEBUGP("clearing endpoint halt for pipe 0x%x\n", pipe);
if (usb_stor_clear_halt(us, pipe) < 0)
return USB_STOR_XFER_ERROR;
return USB_STOR_XFER_STALLED;
/* babble - the device tried to send more than we wanted to read */
case -EOVERFLOW:
US_DEBUGP("-- babble\n");
#ifdef CONFIG_USB_STORAGE_DETECT
printk(KERN_INFO "usb storage -- babble\n");
#endif
return USB_STOR_XFER_LONG;
/* the transfer was cancelled by abort, disconnect, or timeout */
case -ECONNRESET:
US_DEBUGP("-- transfer cancelled\n");
#ifdef CONFIG_USB_STORAGE_DETECT
printk(KERN_INFO "usb storage -- transfer cancelled\n");
#endif
return USB_STOR_XFER_ERROR;
/* short scatter-gather read transfer */
case -EREMOTEIO:
US_DEBUGP("-- short read transfer\n");
return USB_STOR_XFER_SHORT;
/* abort or disconnect in progress */
case -EIO:
US_DEBUGP("-- abort or disconnect in progress\n");
#ifdef CONFIG_USB_STORAGE_DETECT
printk(KERN_INFO "usb storage -- abort or disconnect in progress\n");
#endif
return USB_STOR_XFER_ERROR;
/* the catch-all error case */
default:
US_DEBUGP("-- unknown error\n");
#ifdef CONFIG_USB_STORAGE_DETECT
printk(KERN_INFO "usb storage -- unknown error %d\n", result);
#endif
return USB_STOR_XFER_ERROR;
}
}
示例9: usb_stor_invoke_transport
/* Invoke the transport and basic error-handling/recovery methods
*
* This is used by the protocol layers to actually send the message to
* the device and receive the response.
*/
void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
{
int need_auto_sense;
int result;
/* send the command to the transport layer */
srb->resid = 0;
result = us->transport(srb, us);
/* if the command gets aborted by the higher layers, we need to
* short-circuit all other processing
*/
if (test_bit(US_FLIDX_TIMED_OUT, &us->flags)) {
US_DEBUGP("-- command was aborted\n");
goto Handle_Abort;
}
/* if there is a transport error, reset and don't auto-sense */
if (result == USB_STOR_TRANSPORT_ERROR) {
US_DEBUGP("-- transport indicates error, resetting\n");
us->transport_reset(us);
srb->result = DID_ERROR << 16;
return;
}
/* if the transport provided its own sense data, don't auto-sense */
if (result == USB_STOR_TRANSPORT_NO_SENSE) {
srb->result = SAM_STAT_CHECK_CONDITION;
return;
}
srb->result = SAM_STAT_GOOD;
/* Determine if we need to auto-sense
*
* I normally don't use a flag like this, but it's almost impossible
* to understand what's going on here if I don't.
*/
need_auto_sense = 0;
/*
* If we're running the CB transport, which is incapable
* of determining status on its own, we will auto-sense
* unless the operation involved a data-in transfer. Devices
* can signal most data-in errors by stalling the bulk-in pipe.
*/
if ((us->protocol == US_PR_CB || us->protocol == US_PR_DPCM_USB) &&
srb->sc_data_direction != DMA_FROM_DEVICE) {
US_DEBUGP("-- CB transport device requiring auto-sense\n");
need_auto_sense = 1;
}
/*
* If we have a failure, we're going to do a REQUEST_SENSE
* automatically. Note that we differentiate between a command
* "failure" and an "error" in the transport mechanism.
*/
if (result == USB_STOR_TRANSPORT_FAILED) {
US_DEBUGP("-- transport indicates command failure\n");
need_auto_sense = 1;
}
/*
* A short transfer on a command where we don't expect it
* is unusual, but it doesn't mean we need to auto-sense.
*/
if ((srb->resid > 0) &&
!((srb->cmnd[0] == REQUEST_SENSE) ||
(srb->cmnd[0] == INQUIRY) ||
(srb->cmnd[0] == MODE_SENSE) ||
(srb->cmnd[0] == LOG_SENSE) ||
(srb->cmnd[0] == MODE_SENSE_10))) {
US_DEBUGP("-- unexpectedly short transfer\n");
}
/* Now, if we need to do the auto-sense, let's do it */
if (need_auto_sense) {
int temp_result;
void* old_request_buffer;
unsigned short old_sg;
unsigned old_request_bufflen;
unsigned char old_sc_data_direction;
unsigned char old_cmd_len;
unsigned char old_cmnd[MAX_COMMAND_SIZE];
unsigned long old_serial_number;
int old_resid;
US_DEBUGP("Issuing auto-REQUEST_SENSE\n");
/* save the old command */
memcpy(old_cmnd, srb->cmnd, MAX_COMMAND_SIZE);
old_cmd_len = srb->cmd_len;
/* set the command and the LUN */
memset(srb->cmnd, 0, MAX_COMMAND_SIZE);
//.........这里部分代码省略.........
示例10: usb_stor_msg_common
/* This is the common part of the URB message submission code
*
* All URBs from the usb-storage driver involved in handling a queued scsi
* command _must_ pass through this function (or something like it) for the
* abort mechanisms to work properly.
*/
static int usb_stor_msg_common(struct us_data *us, int timeout)
{
struct completion urb_done;
struct timer_list to_timer;
int status;
/* don't submit URBs during abort/disconnect processing */
if (us->flags & ABORTING_OR_DISCONNECTING)
return -EIO;
/* set up data structures for the wakeup system */
init_completion(&urb_done);
/* fill the common fields in the URB */
us->current_urb->context = &urb_done;
us->current_urb->actual_length = 0;
us->current_urb->error_count = 0;
us->current_urb->status = 0;
/* we assume that if transfer_buffer isn't us->iobuf then it
* hasn't been mapped for DMA. Yes, this is clunky, but it's
* easier than always having the caller tell us whether the
* transfer buffer has already been mapped. */
us->current_urb->transfer_flags =
URB_ASYNC_UNLINK | URB_NO_SETUP_DMA_MAP;
if (us->current_urb->transfer_buffer == us->iobuf)
us->current_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
us->current_urb->transfer_dma = us->iobuf_dma;
us->current_urb->setup_dma = us->cr_dma;
/* submit the URB */
status = usb_submit_urb(us->current_urb, GFP_NOIO);
if (status) {
/* something went wrong */
return status;
}
/* since the URB has been submitted successfully, it's now okay
* to cancel it */
set_bit(US_FLIDX_URB_ACTIVE, &us->flags);
/* did an abort/disconnect occur during the submission? */
if (us->flags & ABORTING_OR_DISCONNECTING) {
/* cancel the URB, if it hasn't been cancelled already */
if (test_and_clear_bit(US_FLIDX_URB_ACTIVE, &us->flags)) {
US_DEBUGP("-- cancelling URB\n");
usb_unlink_urb(us->current_urb);
}
}
/* submit the timeout timer, if a timeout was requested */
if (timeout > 0) {
init_timer(&to_timer);
to_timer.expires = jiffies + timeout;
to_timer.function = timeout_handler;
to_timer.data = (unsigned long) us;
add_timer(&to_timer);
}
/* wait for the completion of the URB */
wait_for_completion(&urb_done);
clear_bit(US_FLIDX_URB_ACTIVE, &us->flags);
/* clean up the timeout timer */
if (timeout > 0)
del_timer_sync(&to_timer);
/* return the URB status */
return us->current_urb->status;
}
示例11: freecom_transport
static int freecom_transport(struct scsi_cmnd *srb, struct us_data *us)
{
struct freecom_cb_wrap *fcb;
struct freecom_status *fst;
unsigned int ipipe, opipe;
int result;
unsigned int partial;
int length;
fcb = (struct freecom_cb_wrap *) us->iobuf;
fst = (struct freecom_status *) us->iobuf;
US_DEBUGP("Freecom TRANSPORT STARTED\n");
opipe = us->send_bulk_pipe;
ipipe = us->recv_bulk_pipe;
fcb->Type = FCM_PACKET_ATAPI | 0x00;
fcb->Timeout = 0;
memcpy (fcb->Atapi, srb->cmnd, 12);
memset (fcb->Filler, 0, sizeof (fcb->Filler));
US_DEBUG(pdump (srb->cmnd, 12));
result = usb_stor_bulk_transfer_buf (us, opipe, fcb,
FCM_PACKET_LENGTH, NULL);
if (result != USB_STOR_XFER_GOOD) {
US_DEBUGP ("freecom transport error\n");
return USB_STOR_TRANSPORT_ERROR;
}
result = usb_stor_bulk_transfer_buf (us, ipipe, fst,
FCM_STATUS_PACKET_LENGTH, &partial);
US_DEBUGP("foo Status result %d %u\n", result, partial);
if (result != USB_STOR_XFER_GOOD)
return USB_STOR_TRANSPORT_ERROR;
US_DEBUG(pdump ((void *) fst, partial));
while (fst->Status & FCM_STATUS_BUSY) {
US_DEBUGP("20 second USB/ATAPI bridge TIMEOUT occurred!\n");
US_DEBUGP("fst->Status is %x\n", fst->Status);
fcb->Type = FCM_PACKET_STATUS;
fcb->Timeout = 0;
memset (fcb->Atapi, 0, sizeof(fcb->Atapi));
memset (fcb->Filler, 0, sizeof (fcb->Filler));
result = usb_stor_bulk_transfer_buf (us, opipe, fcb,
FCM_PACKET_LENGTH, NULL);
if (result != USB_STOR_XFER_GOOD) {
US_DEBUGP ("freecom transport error\n");
return USB_STOR_TRANSPORT_ERROR;
}
result = usb_stor_bulk_transfer_buf (us, ipipe, fst,
FCM_STATUS_PACKET_LENGTH, &partial);
US_DEBUGP("bar Status result %d %u\n", result, partial);
if (result != USB_STOR_XFER_GOOD)
return USB_STOR_TRANSPORT_ERROR;
US_DEBUG(pdump ((void *) fst, partial));
}
if (partial != 4)
return USB_STOR_TRANSPORT_ERROR;
if ((fst->Status & 1) != 0) {
US_DEBUGP("operation failed\n");
return USB_STOR_TRANSPORT_FAILED;
}
US_DEBUGP("Device indicates that it has %d bytes available\n",
le16_to_cpu (fst->Count));
US_DEBUGP("SCSI requested %d\n", scsi_bufflen(srb));
switch (srb->cmnd[0]) {
case INQUIRY:
case REQUEST_SENSE:
case MODE_SENSE:
case MODE_SENSE_10:
length = le16_to_cpu(fst->Count);
break;
default:
length = scsi_bufflen(srb);
}
if (length > scsi_bufflen(srb)) {
length = scsi_bufflen(srb);
US_DEBUGP("Truncating request to match buffer length: %d\n", length);
//.........这里部分代码省略.........
示例12: sddr55_status
static int sddr55_status(struct us_data *us)
{
int result;
unsigned char *command = us->iobuf;
unsigned char *status = us->iobuf;
struct sddr55_card_info *info = (struct sddr55_card_info *)us->extra;
/* send command */
memset(command, 0, 8);
command[5] = 0xB0;
command[7] = 0x80;
result = sddr55_bulk_transport(us,
SCSI_DATA_WRITE, command, 8);
US_DEBUGP("Result for send_command in status %d\n",
result);
if (result != USB_STOR_XFER_GOOD) {
set_sense_info (4, 0, 0); /* hardware error */
return USB_STOR_TRANSPORT_ERROR;
}
result = sddr55_bulk_transport(us,
SCSI_DATA_READ, status, 4);
/* expect to get short transfer if no card fitted */
if (result == USB_STOR_XFER_SHORT || result == USB_STOR_XFER_STALLED) {
/* had a short transfer, no card inserted, free map memory */
if (info->lba_to_pba)
kfree(info->lba_to_pba);
if (info->pba_to_lba)
kfree(info->pba_to_lba);
info->lba_to_pba = NULL;
info->pba_to_lba = NULL;
info->fatal_error = 0;
info->force_read_only = 0;
set_sense_info (2, 0x3a, 0); /* not ready, medium not present */
return USB_STOR_TRANSPORT_FAILED;
}
if (result != USB_STOR_XFER_GOOD) {
set_sense_info (4, 0, 0); /* hardware error */
return USB_STOR_TRANSPORT_FAILED;
}
/* check write protect status */
info->read_only = (status[0] & 0x20);
/* now read status */
result = sddr55_bulk_transport(us,
SCSI_DATA_READ, status, 2);
if (result != USB_STOR_XFER_GOOD) {
set_sense_info (4, 0, 0); /* hardware error */
}
return (result == USB_STOR_XFER_GOOD ?
USB_STOR_TRANSPORT_GOOD : USB_STOR_TRANSPORT_FAILED);
}
示例13: freecom_transport
/*
* Transport for the Freecom USB/IDE adaptor.
*
*/
static int freecom_transport(struct scsi_cmnd *srb, struct us_data *us)
{
struct freecom_cb_wrap *fcb;
struct freecom_status *fst;
unsigned int ipipe, opipe; /* We need both pipes. */
int result;
unsigned int partial;
int length;
fcb = (struct freecom_cb_wrap *) us->iobuf;
fst = (struct freecom_status *) us->iobuf;
US_DEBUGP("Freecom TRANSPORT STARTED\n");
/* Get handles for both transports. */
opipe = us->send_bulk_pipe;
ipipe = us->recv_bulk_pipe;
/* The ATAPI Command always goes out first. */
fcb->Type = FCM_PACKET_ATAPI | 0x00;
fcb->Timeout = 0;
memcpy (fcb->Atapi, srb->cmnd, 12);
memset (fcb->Filler, 0, sizeof (fcb->Filler));
US_DEBUG(pdump (srb->cmnd, 12));
/* Send it out. */
result = usb_stor_bulk_transfer_buf (us, opipe, fcb,
FCM_PACKET_LENGTH, NULL);
/* The Freecom device will only fail if there is something wrong in
* USB land. It returns the status in its own registers, which
* come back in the bulk pipe. */
if (result != USB_STOR_XFER_GOOD) {
US_DEBUGP ("freecom transport error\n");
return USB_STOR_TRANSPORT_ERROR;
}
/* There are times we can optimize out this status read, but it
* doesn't hurt us to always do it now. */
result = usb_stor_bulk_transfer_buf (us, ipipe, fst,
FCM_STATUS_PACKET_LENGTH, &partial);
US_DEBUGP("foo Status result %d %u\n", result, partial);
if (result != USB_STOR_XFER_GOOD)
return USB_STOR_TRANSPORT_ERROR;
US_DEBUG(pdump ((void *) fst, partial));
/* The firmware will time-out commands after 20 seconds. Some commands
* can legitimately take longer than this, so we use a different
* command that only waits for the interrupt and then sends status,
<<<<<<< HEAD
* without having to send a new ATAPI command to the device.
=======
* without having to send a new ATAPI command to the device.
>>>>>>> 296c66da8a02d52243f45b80521febece5ed498a
*
* NOTE: There is some indication that a data transfer after a timeout
* may not work, but that is a condition that should never happen.
*/
while (fst->Status & FCM_STATUS_BUSY) {
US_DEBUGP("20 second USB/ATAPI bridge TIMEOUT occurred!\n");
US_DEBUGP("fst->Status is %x\n", fst->Status);
/* Get the status again */
fcb->Type = FCM_PACKET_STATUS;
fcb->Timeout = 0;
memset (fcb->Atapi, 0, sizeof(fcb->Atapi));
memset (fcb->Filler, 0, sizeof (fcb->Filler));
/* Send it out. */
result = usb_stor_bulk_transfer_buf (us, opipe, fcb,
FCM_PACKET_LENGTH, NULL);
/* The Freecom device will only fail if there is something
* wrong in USB land. It returns the status in its own
* registers, which come back in the bulk pipe.
*/
if (result != USB_STOR_XFER_GOOD) {
US_DEBUGP ("freecom transport error\n");
return USB_STOR_TRANSPORT_ERROR;
}
/* get the data */
result = usb_stor_bulk_transfer_buf (us, ipipe, fst,
FCM_STATUS_PACKET_LENGTH, &partial);
US_DEBUGP("bar Status result %d %u\n", result, partial);
if (result != USB_STOR_XFER_GOOD)
return USB_STOR_TRANSPORT_ERROR;
US_DEBUG(pdump ((void *) fst, partial));
}
if (partial != 4)
return USB_STOR_TRANSPORT_ERROR;
//.........这里部分代码省略.........
示例14: usb_stor_invoke_transport
/* Invoke the transport and basic error-handling/recovery methods
*
* This is used by the protocol layers to actually send the message to
* the device and receive the response.
*/
void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
{
int need_auto_sense;
int result;
/* send the command to the transport layer */
scsi_set_resid(srb, 0);
result = us->transport(srb, us);
/* if the command gets aborted by the higher layers, we need to
* short-circuit all other processing
*/
if (test_bit(US_FLIDX_TIMED_OUT, &us->flags)) {
US_DEBUGP("-- command was aborted\n");
srb->result = DID_ABORT << 16;
goto Handle_Errors;
}
/* if there is a transport error, reset and don't auto-sense */
if (result == USB_STOR_TRANSPORT_ERROR) {
US_DEBUGP("-- transport indicates error, resetting\n");
srb->result = DID_ERROR << 16;
goto Handle_Errors;
}
/* if the transport provided its own sense data, don't auto-sense */
if (result == USB_STOR_TRANSPORT_NO_SENSE) {
srb->result = SAM_STAT_CHECK_CONDITION;
return;
}
srb->result = SAM_STAT_GOOD;
/* Determine if we need to auto-sense
*
* I normally don't use a flag like this, but it's almost impossible
* to understand what's going on here if I don't.
*/
need_auto_sense = 0;
/*
* If we're running the CB transport, which is incapable
* of determining status on its own, we will auto-sense
* unless the operation involved a data-in transfer. Devices
* can signal most data-in errors by stalling the bulk-in pipe.
*/
if ((us->protocol == US_PR_CB || us->protocol == US_PR_DPCM_USB) &&
srb->sc_data_direction != DMA_FROM_DEVICE) {
US_DEBUGP("-- CB transport device requiring auto-sense\n");
need_auto_sense = 1;
}
/*
* If we have a failure, we're going to do a REQUEST_SENSE
* automatically. Note that we differentiate between a command
* "failure" and an "error" in the transport mechanism.
*/
if (result == USB_STOR_TRANSPORT_FAILED) {
US_DEBUGP("-- transport indicates command failure\n");
need_auto_sense = 1;
}
/*
* A short transfer on a command where we don't expect it
* is unusual, but it doesn't mean we need to auto-sense.
*/
if ((scsi_get_resid(srb) > 0) &&
!((srb->cmnd[0] == REQUEST_SENSE) ||
(srb->cmnd[0] == INQUIRY) ||
(srb->cmnd[0] == MODE_SENSE) ||
(srb->cmnd[0] == LOG_SENSE) ||
(srb->cmnd[0] == MODE_SENSE_10))) {
US_DEBUGP("-- unexpectedly short transfer\n");
}
/* Now, if we need to do the auto-sense, let's do it */
if (need_auto_sense) {
int temp_result;
struct scsi_eh_save ses;
US_DEBUGP("Issuing auto-REQUEST_SENSE\n");
scsi_eh_prep_cmnd(srb, &ses, NULL, 0, US_SENSE_SIZE);
/* FIXME: we must do the protocol translation here */
if (us->subclass == US_SC_RBC || us->subclass == US_SC_SCSI ||
us->subclass == US_SC_CYP_ATACB)
srb->cmd_len = 6;
else
srb->cmd_len = 12;
/* issue the auto-sense command */
scsi_set_resid(srb, 0);
temp_result = us->transport(us->srb, us);
//.........这里部分代码省略.........
示例15: usb_stor_show_sense
//.........这里部分代码省略.........
case 0x0302: what="excessive write errors"; break;
case 0x0400: what="LUN not ready, cause not reportable"; break;
case 0x0401: what="LUN in process of becoming ready"; break;
case 0x0402: what="LUN not ready, initializing cmd. required"; break;
case 0x0403: what="LUN not ready, manual intervention required"; break;
case 0x0404: what="LUN not ready, format in progress"; break;
case 0x0405: what="LUN not ready, rebuild in progress"; break;
case 0x0406: what="LUN not ready, recalculation in progress"; break;
case 0x0407: what="LUN not ready, operation in progress"; break;
case 0x0408: what="LUN not ready, long write in progress"; break;
case 0x0500: what="LUN doesn't respond to selection"; break;
case 0x0A00: what="error log overflow"; break;
case 0x0C04: what="compression check miscompare error"; break;
case 0x0C05: what="data expansion occurred during compression"; break;
case 0x0C06: what="block not compressible"; break;
case 0x1102: what="error too long to correct"; break;
case 0x1106: what="CIRC unrecovered error"; break;
case 0x1107: what="data resynchronization error"; break;
case 0x110D: what="decompression CRC error"; break;
case 0x110E: what="can't decompress using declared algorithm"; break;
case 0x110F: what="error reading UPC/EAN number"; break;
case 0x1110: what="error reading ISRC number"; break;
case 0x1200: what="address mark not found for ID field"; break;
case 0x1300: what="address mark not found for data field"; break;
case 0x1403: what="end of data not found"; break;
case 0x1404: what="block sequence error"; break;
case 0x1600: what="data sync mark error"; break;
case 0x1601: what="data sync error: data rewritten"; break;
case 0x1602: what="data sync error: recommend rewrite"; break;
case 0x1603: what="data sync error: data auto-reallocated"; break;
case 0x1604: what="data sync error: recommend reassignment"; break;
case 0x1900: what="defect list error"; break;
case 0x1901: what="defect list not available"; break;
case 0x1902: what="defect list error in primary list"; break;
case 0x1903: what="defect list error in grown list"; break;
case 0x1C00: what="defect list not found"; break;
case 0x2400: what="invalid field in CDB"; break;
case 0x2703: what="associated write protect"; break;
case 0x2800: what="not ready to ready transition"; break;
case 0x2903: what="bus device reset function occurred"; break;
case 0x2904: what="device internal reset"; break;
case 0x2B00: what="copy can't execute / host can't disconnect"; break;
case 0x2C00: what="command sequence error"; break;
case 0x2C03: what="current program area is not empty"; break;
case 0x2C04: what="current program area is empty"; break;
case 0x2F00: what="commands cleared by another initiator"; break;
case 0x3001: what="can't read medium: unknown format"; break;
case 0x3002: what="can't read medium: incompatible format"; break;
case 0x3003: what="cleaning cartridge installed"; break;
case 0x3004: what="can't write medium: unknown format"; break;
case 0x3005: what="can't write medium: incompatible format"; break;
case 0x3006: what="can't format medium: incompatible medium"; break;
case 0x3007: what="cleaning failure"; break;
case 0x3008: what="can't write: application code mismatch"; break;
case 0x3009: what="current session not fixated for append"; break;
case 0x3201: what="defect list update failure"; break;
case 0x3400: what="enclosure failure"; break;
case 0x3500: what="enclosure services failure"; break;
case 0x3502: what="enclosure services unavailable"; break;
case 0x3503: what="enclosure services transfer failure"; break;
case 0x3504: what="enclosure services transfer refused"; break;
case 0x3B0F: what="end of medium reached"; break;
case 0x3F02: what="changed operating definition"; break;
case 0x4100: what="data path failure (should use 40 NN)"; break;
case 0x4A00: what="command phase error"; break;
case 0x4B00: what="data phase error"; break;
case 0x5100: what="erase failure"; break;
case 0x5200: what="cartridge fault"; break;
case 0x6300: what="end of user area encountered on this track"; break;
case 0x6600: what="automatic document feeder cover up"; break;
case 0x6601: what="automatic document feeder lift up"; break;
case 0x6602: what="document jam in auto doc feeder"; break;
case 0x6603: what="document miss feed auto in doc feeder"; break;
case 0x6700: what="configuration failure"; break;
case 0x6701: what="configuration of incapable LUN's failed"; break;
case 0x6702: what="add logical unit failed"; break;
case 0x6706: what="attachment of logical unit failed"; break;
case 0x6707: what="creation of logical unit failed"; break;
case 0x6900: what="data loss on logical unit"; break;
case 0x6E00: what="command to logical unit failed"; break;
case 0x7100: what="decompression exception long algorithm ID"; break;
case 0x7204: what="empty or partially written reserved track"; break;
case 0x7300: what="CD control error"; break;
default:
if (asc==0x40) {
US_DEBUGP("%s: diagnostic failure on component"
" %02X\n", keystr, ascq);
return;
}
if (asc==0x70) {
US_DEBUGP("%s: decompression exception short"
" algorithm ID of %02X\n", keystr, ascq);
return;
}
what = "(unknown ASC/ASCQ)";
}
US_DEBUGP("%s: %s\n", keystr, what);
}