您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ usb_stor_dbg函数代码示例

51自学网 2021-06-03 09:21:37
  C++
这篇教程C++ usb_stor_dbg函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中usb_stor_dbg函数的典型用法代码示例。如果您正苦于以下问题:C++ usb_stor_dbg函数的具体用法?C++ usb_stor_dbg怎么用?C++ usb_stor_dbg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了usb_stor_dbg函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: usb_stor_port_reset

/* Issue a USB port reset to the device.  The caller must not hold * us->dev_mutex. */int usb_stor_port_reset(struct us_data *us){	int result;	/*for these devices we must use the class specific method */	if (us->pusb_dev->quirks & USB_QUIRK_RESET)		return -EPERM;	result = usb_lock_device_for_reset(us->pusb_dev, us->pusb_intf);	if (result < 0)		usb_stor_dbg(us, "unable to lock device for reset: %d/n",			     result);	else {		/* Were we disconnected while waiting for the lock? */		if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) {			result = -EIO;			usb_stor_dbg(us, "No reset during disconnect/n");		} else {			result = usb_reset_device(us->pusb_dev);			usb_stor_dbg(us, "usb_reset_device returns %d/n",				     result);		}		usb_unlock_device(us->pusb_dev);	}	return result;}
开发者ID:ShedrockN4,项目名称:wiliteneo,代码行数:29,


示例2: usb_stor_ucr61s2b_init

/* * This function is required to activate all four slots on the UCR-61S2B * flash reader */int usb_stor_ucr61s2b_init(struct us_data *us){	struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap*) us->iobuf;	struct bulk_cs_wrap *bcs = (struct bulk_cs_wrap*) us->iobuf;	int res;	unsigned int partial;	static char init_string[] = "/xec/x0a/x06/x00$PCCHIPS";	usb_stor_dbg(us, "Sending UCR-61S2B initialization packet.../n");	bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);	bcb->Tag = 0;	bcb->DataTransferLength = cpu_to_le32(0);	bcb->Flags = bcb->Lun = 0;	bcb->Length = sizeof(init_string) - 1;	memset(bcb->CDB, 0, sizeof(bcb->CDB));	memcpy(bcb->CDB, init_string, sizeof(init_string) - 1);	res = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, bcb,			US_BULK_CB_WRAP_LEN, &partial);	if (res)		return -EIO;	usb_stor_dbg(us, "Getting status packet.../n");	res = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, bcs,			US_BULK_CS_WRAP_LEN, &partial);	if (res)		return -EIO;	return 0;}
开发者ID:SantoshShilimkar,项目名称:linux,代码行数:35,


示例3: freecom_writedata

static intfreecom_writedata (struct scsi_cmnd *srb, struct us_data *us,                   int unsigned ipipe, unsigned int opipe, int count){    struct freecom_xfer_wrap *fxfr =        (struct freecom_xfer_wrap *) us->iobuf;    int result;    fxfr->Type = FCM_PACKET_OUTPUT | 0x00;    fxfr->Timeout = 0;    /* Short timeout for debugging. */    fxfr->Count = cpu_to_le32 (count);    memset (fxfr->Pad, 0, sizeof (fxfr->Pad));    usb_stor_dbg(us, "Write data Freecom! (c=%d)/n", count);    /* Issue the transfer command. */    result = usb_stor_bulk_transfer_buf (us, opipe, fxfr,                                         FCM_PACKET_LENGTH, NULL);    if (result != USB_STOR_XFER_GOOD) {        usb_stor_dbg(us, "Freecom writedata transport error/n");        return USB_STOR_TRANSPORT_ERROR;    }    /* Now transfer all of our blocks. */    usb_stor_dbg(us, "Start of write/n");    result = usb_stor_bulk_srb(us, opipe, srb);    usb_stor_dbg(us, "freecom_writedata done!/n");    if (result > USB_STOR_XFER_SHORT)        return USB_STOR_TRANSPORT_ERROR;    return USB_STOR_TRANSPORT_GOOD;}
开发者ID:Niisp,项目名称:MT6795.kernel,代码行数:32,


示例4: 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){	usb_stor_dbg(us, "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) {			usb_stor_dbg(us, "-- short transfer/n");			return USB_STOR_XFER_SHORT;		}		usb_stor_dbg(us, "-- 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)) {			usb_stor_dbg(us, "-- stall on control pipe/n");			return USB_STOR_XFER_STALLED;		}		/* for other sorts of endpoint, clear the stall */		usb_stor_dbg(us, "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:		usb_stor_dbg(us, "-- babble/n");		return USB_STOR_XFER_LONG;	/* the transfer was cancelled by abort, disconnect, or timeout */	case -ECONNRESET:		usb_stor_dbg(us, "-- transfer cancelled/n");		return USB_STOR_XFER_ERROR;	/* short scatter-gather read transfer */	case -EREMOTEIO:		usb_stor_dbg(us, "-- short read transfer/n");		return USB_STOR_XFER_SHORT;	/* abort or disconnect in progress */	case -EIO:		usb_stor_dbg(us, "-- abort or disconnect in progress/n");		return USB_STOR_XFER_ERROR;	/* the catch-all error case */	default:		usb_stor_dbg(us, "-- unknown error/n");		return USB_STOR_XFER_ERROR;	}}
开发者ID:020gzh,项目名称:linux,代码行数:66,


示例5: usb_stor_euscsi_init

/* * This places the Shuttle/SCM USB<->SCSI bridge devices in multi-target * mode */int usb_stor_euscsi_init(struct us_data *us){	int result;	usb_stor_dbg(us, "Attempting to init eUSCSI bridge.../n");	result = usb_stor_control_msg(us, us->send_ctrl_pipe,			0x0C, USB_RECIP_INTERFACE | USB_TYPE_VENDOR,			0x01, 0x0, NULL, 0x0, 5 * HZ);	usb_stor_dbg(us, "-- result is %d/n", result);	return 0;}
开发者ID:SantoshShilimkar,项目名称:linux,代码行数:16,


示例6: pdump

static void pdump(struct us_data *us, void *ibuffer, int length){    static char line[80];    int offset = 0;    unsigned char *buffer = (unsigned char *) ibuffer;    int i, j;    int from, base;    offset = 0;    for (i = 0; i < length; i++) {        if ((i & 15) == 0) {            if (i > 0) {                offset += sprintf (line+offset, " - ");                for (j = i - 16; j < i; j++) {                    if (buffer[j] >= 32 && buffer[j] <= 126)                        line[offset++] = buffer[j];                    else                        line[offset++] = '.';                }                line[offset] = 0;                usb_stor_dbg(us, "%s/n", line);                offset = 0;            }            offset += sprintf (line+offset, "%08x:", i);        } else if ((i & 7) == 0) {            offset += sprintf (line+offset, " -");        }        offset += sprintf (line+offset, " %02x", buffer[i] & 0xff);    }    /* Add the last "chunk" of data. */    from = (length - 1) % 16;    base = ((length - 1) / 16) * 16;    for (i = from + 1; i < 16; i++)        offset += sprintf (line+offset, "   ");    if (from < 8)        offset += sprintf (line+offset, "  ");    offset += sprintf (line+offset, " - ");    for (i = 0; i <= from; i++) {        if (buffer[base+i] >= 32 && buffer[base+i] <= 126)            line[offset++] = buffer[base+i];        else            line[offset++] = '.';    }    line[offset] = 0;    usb_stor_dbg(us, "%s/n", line);    offset = 0;}
开发者ID:Niisp,项目名称:MT6795.kernel,代码行数:50,


示例7: sddr55_read_deviceID

static int sddr55_read_deviceID(struct us_data *us,		unsigned char *manufacturerID,		unsigned char *deviceID) {	int result;	unsigned char *command = us->iobuf;	unsigned char *content = us->iobuf;	memset(command, 0, 8);	command[5] = 0xB0;	command[7] = 0x84;	result = sddr55_bulk_transport(us, DMA_TO_DEVICE, command, 8);	usb_stor_dbg(us, "Result of send_control for device ID is %d/n",		     result);	if (result != USB_STOR_XFER_GOOD)		return USB_STOR_TRANSPORT_ERROR;	result = sddr55_bulk_transport(us,		DMA_FROM_DEVICE, content, 4);	if (result != USB_STOR_XFER_GOOD)		return USB_STOR_TRANSPORT_ERROR;	*manufacturerID = content[0];	*deviceID = content[1];	if (content[0] != 0xff)	{    		result = sddr55_bulk_transport(us,			DMA_FROM_DEVICE, content, 2);	}	return USB_STOR_TRANSPORT_GOOD;}
开发者ID:AlexShiLucky,项目名称:linux,代码行数:35,


示例8: usb_stor_Bulk_max_lun

/* Determine what the maximum LUN supported is */int usb_stor_Bulk_max_lun(struct us_data *us){	int result;	/* issue the command */	us->iobuf[0] = 0;	result = usb_stor_control_msg(us, us->recv_ctrl_pipe,				 US_BULK_GET_MAX_LUN, 				 USB_DIR_IN | USB_TYPE_CLASS | 				 USB_RECIP_INTERFACE,				 0, us->ifnum, us->iobuf, 1, 10*HZ);	usb_stor_dbg(us, "GetMaxLUN command result is %d, data is %d/n",		     result, us->iobuf[0]);	/* if we have a successful request, return the result */	if (result > 0)		return us->iobuf[0];	/*	 * Some devices don't like GetMaxLUN.  They may STALL the control	 * pipe, they may return a zero-length result, they may do nothing at	 * all and timeout, or they may fail in even more bizarrely creative	 * ways.  In these cases the best approach is to use the default	 * value: only one LUN.	 */	return 0;}
开发者ID:ShedrockN4,项目名称:wiliteneo,代码行数:29,


示例9: usb_stor_control_msg

/* * Transfer one control message, with timeouts, and allowing early * termination.  Return codes are usual -Exxx, *not* USB_STOR_XFER_xxx. */int usb_stor_control_msg(struct us_data *us, unsigned int pipe,		 u8 request, u8 requesttype, u16 value, u16 index, 		 void *data, u16 size, int timeout){	int status;	usb_stor_dbg(us, "rq=%02x rqtype=%02x value=%04x index=%02x len=%u/n",		     request, requesttype, value, index, size);	/* fill in the devrequest structure */	us->cr->bRequestType = requesttype;	us->cr->bRequest = request;	us->cr->wValue = cpu_to_le16(value);	us->cr->wIndex = cpu_to_le16(index);	us->cr->wLength = cpu_to_le16(size);	/* fill and submit the URB */	usb_fill_control_urb(us->current_urb, us->pusb_dev, pipe, 			 (unsigned char*) us->cr, data, size, 			 usb_stor_blocking_completion, NULL);	status = usb_stor_msg_common(us, timeout);	/* return the actual length of the data transferred if no error */	if (status == 0)		status = us->current_urb->actual_length;	return status;}
开发者ID:ShedrockN4,项目名称:wiliteneo,代码行数:31,


示例10: usb_stor_ctrl_transfer

/* * Transfer one control message, without timeouts, but allowing early * termination.  Return codes are USB_STOR_XFER_xxx. */int usb_stor_ctrl_transfer(struct us_data *us, unsigned int pipe,		u8 request, u8 requesttype, u16 value, u16 index,		void *data, u16 size){	int result;	usb_stor_dbg(us, "rq=%02x rqtype=%02x value=%04x index=%02x len=%u/n",		     request, requesttype, value, index, size);	/* fill in the devrequest structure */	us->cr->bRequestType = requesttype;	us->cr->bRequest = request;	us->cr->wValue = cpu_to_le16(value);	us->cr->wIndex = cpu_to_le16(index);	us->cr->wLength = cpu_to_le16(size);	/* fill and submit the URB */	usb_fill_control_urb(us->current_urb, us->pusb_dev, pipe, 			 (unsigned char*) us->cr, data, size, 			 usb_stor_blocking_completion, NULL);	result = usb_stor_msg_common(us, 0);	return interpret_urb_result(us, pipe, size, result,			us->current_urb->actual_length);}
开发者ID:ShedrockN4,项目名称:wiliteneo,代码行数:29,


示例11: usb_stor_stop_transport

/* Stop the current URB transfer */void usb_stor_stop_transport(struct us_data *us){	/* If the state machine is blocked waiting for an URB,	 * let's wake it up.  The test_and_clear_bit() call	 * guarantees that if a URB has just been submitted,	 * it won't be cancelled more than once. */	if (test_and_clear_bit(US_FLIDX_URB_ACTIVE, &us->dflags)) {		usb_stor_dbg(us, "-- cancelling URB/n");		usb_unlink_urb(us->current_urb);	}	/* If we are waiting for a scatter-gather operation, cancel it. */	if (test_and_clear_bit(US_FLIDX_SG_ACTIVE, &us->dflags)) {		usb_stor_dbg(us, "-- cancelling sg request/n");		usb_sg_cancel(&us->current_sg);	}}
开发者ID:ShedrockN4,项目名称:wiliteneo,代码行数:18,


示例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,		DMA_TO_DEVICE, command, 8);	usb_stor_dbg(us, "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,		DMA_FROM_DEVICE, 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 */		kfree(info->lba_to_pba);		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,		DMA_FROM_DEVICE, 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);}
开发者ID:AlexShiLucky,项目名称:linux,代码行数:58,


示例13: usb_stor_bulk_transfer_sglist

/* * Transfer a scatter-gather list via bulk transfer * * This function does basically the same thing as usb_stor_bulk_transfer_buf() * above, but it uses the usbcore scatter-gather library. */static int usb_stor_bulk_transfer_sglist(struct us_data *us, unsigned int pipe,		struct scatterlist *sg, int num_sg, unsigned int length,		unsigned int *act_len){	int result;	/* don't submit s-g requests during abort processing */	if (test_bit(US_FLIDX_ABORTING, &us->dflags))		return USB_STOR_XFER_ERROR;	/* initialize the scatter-gather request block */	usb_stor_dbg(us, "xfer %u bytes, %d entries/n", length, num_sg);	result = usb_sg_init(&us->current_sg, us->pusb_dev, pipe, 0,			sg, num_sg, length, GFP_NOIO);	if (result) {		usb_stor_dbg(us, "usb_sg_init returned %d/n", result);		return USB_STOR_XFER_ERROR;	}	/*	 * since the block has been initialized successfully, it's now	 * okay to cancel it	 */	set_bit(US_FLIDX_SG_ACTIVE, &us->dflags);	/* did an abort occur during the submission? */	if (test_bit(US_FLIDX_ABORTING, &us->dflags)) {		/* cancel the request, if it hasn't been cancelled already */		if (test_and_clear_bit(US_FLIDX_SG_ACTIVE, &us->dflags)) {			usb_stor_dbg(us, "-- cancelling sg request/n");			usb_sg_cancel(&us->current_sg);		}	}	/* wait for the completion of the transfer */	usb_sg_wait(&us->current_sg);	clear_bit(US_FLIDX_SG_ACTIVE, &us->dflags);	result = us->current_sg.status;	if (act_len)		*act_len = us->current_sg.bytes;	return interpret_urb_result(us, pipe, length, result,			us->current_sg.bytes);}
开发者ID:513855417,项目名称:linux,代码行数:51,


示例14: usb_stor_huawei_e220_init

/* This places the HUAWEI E220 devices in multi-port mode */int usb_stor_huawei_e220_init(struct us_data *us){	int result;	result = usb_stor_control_msg(us, us->send_ctrl_pipe,				      USB_REQ_SET_FEATURE,				      USB_TYPE_STANDARD | USB_RECIP_DEVICE,				      0x01, 0x0, NULL, 0x0, 1 * HZ);	usb_stor_dbg(us, "Huawei mode set result is %d/n", result);	return 0;}
开发者ID:SantoshShilimkar,项目名称:linux,代码行数:12,


示例15: usb_stor_show_sense

void usb_stor_show_sense(const struct us_data *us,			 unsigned char key,			 unsigned char asc,			 unsigned char ascq){	const char *what, *keystr, *fmt;	keystr = scsi_sense_key_string(key);	what = scsi_extd_sense_format(asc, ascq, &fmt);	if (keystr == NULL)		keystr = "(Unknown Key)";	if (what == NULL)		what = "(unknown ASC/ASCQ)";	if (fmt)		usb_stor_dbg(us, "%s: %s (%s%x)/n", keystr, what, fmt, ascq);	else		usb_stor_dbg(us, "%s: %s/n", keystr, what);}
开发者ID:AlexShiLucky,项目名称:linux,代码行数:20,


示例16: init_freecom

static int init_freecom(struct us_data *us){	int result;	char *buffer = us->iobuf;	/*	 * The DMA-mapped I/O buffer is 64 bytes long, just right for	 * all our packets.  No need to allocate any extra buffer space.	 */	result = usb_stor_control_msg(us, us->recv_ctrl_pipe,			0x4c, 0xc0, 0x4346, 0x0, buffer, 0x20, 3*HZ);	buffer[32] = '/0';	usb_stor_dbg(us, "String returned from FC init is: %s/n", buffer);	/*	 * Special thanks to the people at Freecom for providing me with	 * this "magic sequence", which they use in their Windows and MacOS	 * drivers to make sure that all the attached perhiperals are	 * properly reset.	 */	/* send reset */	result = usb_stor_control_msg(us, us->send_ctrl_pipe,			0x4d, 0x40, 0x24d8, 0x0, NULL, 0x0, 3*HZ);	usb_stor_dbg(us, "result from activate reset is %d/n", result);	/* wait 250ms */	mdelay(250);	/* clear reset */	result = usb_stor_control_msg(us, us->send_ctrl_pipe,			0x4d, 0x40, 0x24f8, 0x0, NULL, 0x0, 3*HZ);	usb_stor_dbg(us, "result from clear reset is %d/n", result);	/* wait 3 seconds */	mdelay(3 * 1000);	return USB_STOR_TRANSPORT_GOOD;}
开发者ID:513855417,项目名称:linux,代码行数:40,


示例17: usb_stor_reset_common

/* * This is the common part of the device reset code. * * It's handy that every transport mechanism uses the control endpoint for * resets. * * Basically, we send a reset with a 5-second timeout, so we don't get * jammed attempting to do the reset. */static int usb_stor_reset_common(struct us_data *us,		u8 request, u8 requesttype,		u16 value, u16 index, void *data, u16 size){	int result;	int result2;	if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) {		usb_stor_dbg(us, "No reset during disconnect/n");		return -EIO;	}	result = usb_stor_control_msg(us, us->send_ctrl_pipe,			request, requesttype, value, index, data, size,			5*HZ);	if (result < 0) {		usb_stor_dbg(us, "Soft reset failed: %d/n", result);		return result;	}	/*	 * Give the device some time to recover from the reset,	 * but don't delay disconnect processing.	 */	wait_event_interruptible_timeout(us->delay_wait,			test_bit(US_FLIDX_DISCONNECTING, &us->dflags),			HZ*6);	if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) {		usb_stor_dbg(us, "Reset interrupted by disconnect/n");		return -EIO;	}	usb_stor_dbg(us, "Soft reset: clearing bulk-in endpoint halt/n");	result = usb_stor_clear_halt(us, us->recv_bulk_pipe);	usb_stor_dbg(us, "Soft reset: clearing bulk-out endpoint halt/n");	result2 = usb_stor_clear_halt(us, us->send_bulk_pipe);	/* return a result code based on the result of the clear-halts */	if (result >= 0)		result = result2;	if (result < 0)		usb_stor_dbg(us, "Soft reset failed/n");	else		usb_stor_dbg(us, "Soft reset done/n");	return result;}
开发者ID:513855417,项目名称:linux,代码行数:56,


示例18: usb_stor_bulk_transfer_buf

/* * Transfer one buffer via bulk pipe, without timeouts, but allowing early * termination.  Return codes are USB_STOR_XFER_xxx.  If the bulk pipe * stalls during the transfer, the halt is automatically cleared. */int usb_stor_bulk_transfer_buf(struct us_data *us, unsigned int pipe,	void *buf, unsigned int length, unsigned int *act_len){	int result;	usb_stor_dbg(us, "xfer %u bytes/n", length);	/* fill and submit the URB */	usb_fill_bulk_urb(us->current_urb, us->pusb_dev, pipe, buf, length,		      usb_stor_blocking_completion, NULL);	result = usb_stor_msg_common(us, 0);	/* store the actual length of the data transferred */	if (act_len)		*act_len = us->current_urb->actual_length;	return interpret_urb_result(us, pipe, length, result, 			us->current_urb->actual_length);}
开发者ID:ShedrockN4,项目名称:wiliteneo,代码行数:23,


示例19: usb_stor_clear_halt

/* This is a version of usb_clear_halt() that allows early termination and * doesn't read the status from the device -- this is because some devices * crash their internal firmware when the status is requested after a halt. * * A definitive list of these 'bad' devices is too difficult to maintain or * make complete enough to be useful.  This problem was first observed on the * Hagiwara FlashGate DUAL unit.  However, bus traces reveal that neither * MacOS nor Windows checks the status after clearing a halt. * * Since many vendors in this space limit their testing to interoperability * with these two OSes, specification violations like this one are common. */int usb_stor_clear_halt(struct us_data *us, unsigned int pipe){	int result;	int endp = usb_pipeendpoint(pipe);	if (usb_pipein (pipe))		endp |= USB_DIR_IN;	result = usb_stor_control_msg(us, us->send_ctrl_pipe,		USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT,		USB_ENDPOINT_HALT, endp,		NULL, 0, 3*HZ);	if (result >= 0)		usb_reset_endpoint(us->pusb_dev, endp);	usb_stor_dbg(us, "result = %d/n", result);	return result;}
开发者ID:ShedrockN4,项目名称:wiliteneo,代码行数:31,


示例20: usb_stor_Bulk_max_lun

/* Determine what the maximum LUN supported is */int usb_stor_Bulk_max_lun(struct us_data *us){	int result;	/* issue the command */	us->iobuf[0] = 0;	result = usb_stor_control_msg(us, us->recv_ctrl_pipe,				 US_BULK_GET_MAX_LUN, 				 USB_DIR_IN | USB_TYPE_CLASS | 				 USB_RECIP_INTERFACE,				 0, us->ifnum, us->iobuf, 1, 10*HZ);	usb_stor_dbg(us, "GetMaxLUN command result is %d, data is %d/n",		     result, us->iobuf[0]);	/*	 * If we have a successful request, return the result if valid. The	 * CBW LUN field is 4 bits wide, so the value reported by the device	 * should fit into that.	 */	if (result > 0) {		if (us->iobuf[0] < 16) {			return us->iobuf[0];		} else {			dev_info(&us->pusb_intf->dev,				 "Max LUN %d is not valid, using 0 instead",				 us->iobuf[0]);		}	}	/*	 * Some devices don't like GetMaxLUN.  They may STALL the control	 * pipe, they may return a zero-length result, they may do nothing at	 * all and timeout, or they may fail in even more bizarrely creative	 * ways.  In these cases the best approach is to use the default	 * value: only one LUN.	 */	return 0;}
开发者ID:513855417,项目名称:linux,代码行数:40,


示例21: usb_stor_intr_transfer

/* * Receive one interrupt buffer, without timeouts, but allowing early * termination.  Return codes are USB_STOR_XFER_xxx. * * This routine always uses us->recv_intr_pipe as the pipe and * us->ep_bInterval as the interrupt interval. */static int usb_stor_intr_transfer(struct us_data *us, void *buf,				  unsigned int length){	int result;	unsigned int pipe = us->recv_intr_pipe;	unsigned int maxp;	usb_stor_dbg(us, "xfer %u bytes/n", length);	/* calculate the max packet size */	maxp = usb_maxpacket(us->pusb_dev, pipe, usb_pipeout(pipe));	if (maxp > length)		maxp = length;	/* fill and submit the URB */	usb_fill_int_urb(us->current_urb, us->pusb_dev, pipe, buf,			maxp, usb_stor_blocking_completion, NULL,			us->ep_bInterval);	result = usb_stor_msg_common(us, 0);	return interpret_urb_result(us, pipe, length, result,			us->current_urb->actual_length);}
开发者ID:ShedrockN4,项目名称:wiliteneo,代码行数:30,


示例22: usb_stor_show_command

void usb_stor_show_command(const struct us_data *us, struct scsi_cmnd *srb){	char *what = NULL;	int i;	switch (srb->cmnd[0]) {	case TEST_UNIT_READY: what = "TEST_UNIT_READY"; break;	case REZERO_UNIT: what = "REZERO_UNIT"; break;	case REQUEST_SENSE: what = "REQUEST_SENSE"; break;	case FORMAT_UNIT: what = "FORMAT_UNIT"; break;	case READ_BLOCK_LIMITS: what = "READ_BLOCK_LIMITS"; break;	case REASSIGN_BLOCKS: what = "REASSIGN_BLOCKS"; break;	case READ_6: what = "READ_6"; break;	case WRITE_6: what = "WRITE_6"; break;	case SEEK_6: what = "SEEK_6"; break;	case READ_REVERSE: what = "READ_REVERSE"; break;	case WRITE_FILEMARKS: what = "WRITE_FILEMARKS"; break;	case SPACE: what = "SPACE"; break;	case INQUIRY: what = "INQUIRY"; break;	case RECOVER_BUFFERED_DATA: what = "RECOVER_BUFFERED_DATA"; break;	case MODE_SELECT: what = "MODE_SELECT"; break;	case RESERVE: what = "RESERVE"; break;	case RELEASE: what = "RELEASE"; break;	case COPY: what = "COPY"; break;	case ERASE: what = "ERASE"; break;	case MODE_SENSE: what = "MODE_SENSE"; break;	case START_STOP: what = "START_STOP"; break;	case RECEIVE_DIAGNOSTIC: what = "RECEIVE_DIAGNOSTIC"; break;	case SEND_DIAGNOSTIC: what = "SEND_DIAGNOSTIC"; break;	case ALLOW_MEDIUM_REMOVAL: what = "ALLOW_MEDIUM_REMOVAL"; break;	case SET_WINDOW: what = "SET_WINDOW"; break;	case READ_CAPACITY: what = "READ_CAPACITY"; break;	case READ_10: what = "READ_10"; break;	case WRITE_10: what = "WRITE_10"; break;	case SEEK_10: what = "SEEK_10"; break;	case WRITE_VERIFY: what = "WRITE_VERIFY"; break;	case VERIFY: what = "VERIFY"; break;	case SEARCH_HIGH: what = "SEARCH_HIGH"; break;	case SEARCH_EQUAL: what = "SEARCH_EQUAL"; break;	case SEARCH_LOW: what = "SEARCH_LOW"; break;	case SET_LIMITS: what = "SET_LIMITS"; break;	case READ_POSITION: what = "READ_POSITION"; break;	case SYNCHRONIZE_CACHE: what = "SYNCHRONIZE_CACHE"; break;	case LOCK_UNLOCK_CACHE: what = "LOCK_UNLOCK_CACHE"; break;	case READ_DEFECT_DATA: what = "READ_DEFECT_DATA"; break;	case MEDIUM_SCAN: what = "MEDIUM_SCAN"; break;	case COMPARE: what = "COMPARE"; break;	case COPY_VERIFY: what = "COPY_VERIFY"; break;	case WRITE_BUFFER: what = "WRITE_BUFFER"; break;	case READ_BUFFER: what = "READ_BUFFER"; break;	case UPDATE_BLOCK: what = "UPDATE_BLOCK"; break;	case READ_LONG: what = "READ_LONG"; break;	case WRITE_LONG: what = "WRITE_LONG"; break;	case CHANGE_DEFINITION: what = "CHANGE_DEFINITION"; break;	case WRITE_SAME: what = "WRITE_SAME"; break;	case GPCMD_READ_SUBCHANNEL: what = "READ SUBCHANNEL"; break;	case READ_TOC: what = "READ_TOC"; break;	case GPCMD_READ_HEADER: what = "READ HEADER"; break;	case GPCMD_PLAY_AUDIO_10: what = "PLAY AUDIO (10)"; break;	case GPCMD_PLAY_AUDIO_MSF: what = "PLAY AUDIO MSF"; break;	case GPCMD_GET_EVENT_STATUS_NOTIFICATION:		what = "GET EVENT/STATUS NOTIFICATION"; break;	case GPCMD_PAUSE_RESUME: what = "PAUSE/RESUME"; break;	case LOG_SELECT: what = "LOG_SELECT"; break;	case LOG_SENSE: what = "LOG_SENSE"; break;	case GPCMD_STOP_PLAY_SCAN: what = "STOP PLAY/SCAN"; break;	case GPCMD_READ_DISC_INFO: what = "READ DISC INFORMATION"; break;	case GPCMD_READ_TRACK_RZONE_INFO:		what = "READ TRACK INFORMATION"; break;	case GPCMD_RESERVE_RZONE_TRACK: what = "RESERVE TRACK"; break;	case GPCMD_SEND_OPC: what = "SEND OPC"; break;	case MODE_SELECT_10: what = "MODE_SELECT_10"; break;	case GPCMD_REPAIR_RZONE_TRACK: what = "REPAIR TRACK"; break;	case 0x59: what = "READ MASTER CUE"; break;	case MODE_SENSE_10: what = "MODE_SENSE_10"; break;	case GPCMD_CLOSE_TRACK: what = "CLOSE TRACK/SESSION"; break;	case 0x5C: what = "READ BUFFER CAPACITY"; break;	case 0x5D: what = "SEND CUE SHEET"; break;	case GPCMD_BLANK: what = "BLANK"; break;	case REPORT_LUNS: what = "REPORT LUNS"; break;	case MOVE_MEDIUM: what = "MOVE_MEDIUM or PLAY AUDIO (12)"; break;	case READ_12: what = "READ_12"; break;	case WRITE_12: what = "WRITE_12"; break;	case WRITE_VERIFY_12: what = "WRITE_VERIFY_12"; break;	case SEARCH_HIGH_12: what = "SEARCH_HIGH_12"; break;	case SEARCH_EQUAL_12: what = "SEARCH_EQUAL_12"; break;	case SEARCH_LOW_12: what = "SEARCH_LOW_12"; break;	case SEND_VOLUME_TAG: what = "SEND_VOLUME_TAG"; break;	case READ_ELEMENT_STATUS: what = "READ_ELEMENT_STATUS"; break;	case GPCMD_READ_CD_MSF: what = "READ CD MSF"; break;	case GPCMD_SCAN: what = "SCAN"; break;	case GPCMD_SET_SPEED: what = "SET CD SPEED"; break;	case GPCMD_MECHANISM_STATUS: what = "MECHANISM STATUS"; break;	case GPCMD_READ_CD: what = "READ CD"; break;	case 0xE1: what = "WRITE CONTINUE"; break;	case WRITE_LONG_2: what = "WRITE_LONG_2"; break;	default: what = "(unknown command)"; break;	}	usb_stor_dbg(us, "Command %s (%d bytes)/n", what, srb->cmd_len);	usb_stor_dbg(us, "bytes: ");//.........这里部分代码省略.........
开发者ID:valexandersaulys,项目名称:linux,代码行数:101,


示例23: usb_stor_CB_transport

int usb_stor_CB_transport(struct scsi_cmnd *srb, struct us_data *us){	unsigned int transfer_length = scsi_bufflen(srb);	unsigned int pipe = 0;	int result;	/* COMMAND STAGE */	/* let's send the command via the control pipe */	result = usb_stor_ctrl_transfer(us, us->send_ctrl_pipe,				      US_CBI_ADSC, 				      USB_TYPE_CLASS | USB_RECIP_INTERFACE, 0, 				      us->ifnum, srb->cmnd, srb->cmd_len);	/* check the return code for the command */	usb_stor_dbg(us, "Call to usb_stor_ctrl_transfer() returned %d/n",		     result);	/* if we stalled the command, it means command failed */	if (result == USB_STOR_XFER_STALLED) {		return USB_STOR_TRANSPORT_FAILED;	}	/* Uh oh... serious problem here */	if (result != USB_STOR_XFER_GOOD) {		return USB_STOR_TRANSPORT_ERROR;	}	/* DATA STAGE */	/* transfer the data payload for this command, if one exists*/	if (transfer_length) {		pipe = srb->sc_data_direction == DMA_FROM_DEVICE ? 				us->recv_bulk_pipe : us->send_bulk_pipe;		result = usb_stor_bulk_srb(us, pipe, srb);		usb_stor_dbg(us, "CBI data stage result is 0x%x/n", result);		/* if we stalled the data transfer it means command failed */		if (result == USB_STOR_XFER_STALLED)			return USB_STOR_TRANSPORT_FAILED;		if (result > USB_STOR_XFER_STALLED)			return USB_STOR_TRANSPORT_ERROR;	}	/* STATUS STAGE */	/* NOTE: CB does not have a status stage.  Silly, I know.  So	 * we have to catch this at a higher level.	 */	if (us->protocol != USB_PR_CBI)		return USB_STOR_TRANSPORT_GOOD;	result = usb_stor_intr_transfer(us, us->iobuf, 2);	usb_stor_dbg(us, "Got interrupt data (0x%x, 0x%x)/n",		     us->iobuf[0], us->iobuf[1]);	if (result != USB_STOR_XFER_GOOD)		return USB_STOR_TRANSPORT_ERROR;	/* UFI gives us ASC and ASCQ, like a request sense	 *	 * REQUEST_SENSE and INQUIRY don't affect the sense data on UFI	 * devices, so we ignore the information for those commands.  Note	 * that this means we could be ignoring a real error on these	 * commands, but that can't be helped.	 */	if (us->subclass == USB_SC_UFI) {		if (srb->cmnd[0] == REQUEST_SENSE ||		    srb->cmnd[0] == INQUIRY)			return USB_STOR_TRANSPORT_GOOD;		if (us->iobuf[0])			goto Failed;		return USB_STOR_TRANSPORT_GOOD;	}	/* If not UFI, we interpret the data as a result code 	 * The first byte should always be a 0x0.	 *	 * Some bogus devices don't follow that rule.  They stuff the ASC	 * into the first byte -- so if it's non-zero, call it a failure.	 */	if (us->iobuf[0]) {		usb_stor_dbg(us, "CBI IRQ data showed reserved bType 0x%x/n",			     us->iobuf[0]);		goto Failed;	}	/* The second byte & 0x0F should be 0x0 for good, otherwise error */	switch (us->iobuf[1] & 0x0F) {		case 0x00: 			return USB_STOR_TRANSPORT_GOOD;		case 0x01: 			goto Failed;	}	return USB_STOR_TRANSPORT_ERROR;	/* the CBI spec requires that the bulk pipe must be cleared	 * following any data-in/out command failure (section 2.4.3.1.3)	 */  Failed:	if (pipe)		usb_stor_clear_halt(us, pipe);//.........这里部分代码省略.........
开发者ID:ShedrockN4,项目名称:wiliteneo,代码行数:101,


示例24: sddr55_get_capacity

static unsigned long sddr55_get_capacity(struct us_data *us) {	unsigned char uninitialized_var(manufacturerID);	unsigned char uninitialized_var(deviceID);	int result;	struct sddr55_card_info *info = (struct sddr55_card_info *)us->extra;	usb_stor_dbg(us, "Reading capacity.../n");	result = sddr55_read_deviceID(us,		&manufacturerID,		&deviceID);	usb_stor_dbg(us, "Result of read_deviceID is %d/n", result);	if (result != USB_STOR_XFER_GOOD)		return 0;	usb_stor_dbg(us, "Device ID = %02X/n", deviceID);	usb_stor_dbg(us, "Manuf  ID = %02X/n", manufacturerID);	info->pageshift = 9;	info->smallpageshift = 0;	info->blocksize = 16;	info->blockshift = 4;	info->blockmask = 15;	switch (deviceID) {	case 0x6e: // 1MB	case 0xe8:	case 0xec:		info->pageshift = 8;		info->smallpageshift = 1;		return 0x00100000;	case 0xea: // 2MB	case 0x64:		info->pageshift = 8;		info->smallpageshift = 1;		/* fall through */	case 0x5d: // 5d is a ROM card with pagesize 512.		return 0x00200000;	case 0xe3: // 4MB	case 0xe5:	case 0x6b:	case 0xd5:		return 0x00400000;	case 0xe6: // 8MB	case 0xd6:		return 0x00800000;	case 0x73: // 16MB		info->blocksize = 32;		info->blockshift = 5;		info->blockmask = 31;		return 0x01000000;	case 0x75: // 32MB		info->blocksize = 32;		info->blockshift = 5;		info->blockmask = 31;		return 0x02000000;	case 0x76: // 64MB		info->blocksize = 32;		info->blockshift = 5;		info->blockmask = 31;		return 0x04000000;	case 0x79: // 128MB		info->blocksize = 32;		info->blockshift = 5;		info->blockmask = 31;		return 0x08000000;	default: // unknown		return 0;	}}
开发者ID:AlexShiLucky,项目名称:linux,代码行数:83,


示例25: 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->dflags)) {		usb_stor_dbg(us, "-- command was aborted/n");#ifdef CONFIG_USB_DEBUG_DETAILED_LOG		printk(KERN_ERR "usb storage -- command was aborted/n");#endif		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) {		usb_stor_dbg(us, "-- transport indicates error, resetting/n");#ifdef CONFIG_USB_DEBUG_DETAILED_LOG		printk(KERN_ERR "usb storage -- transport indicates error, resetting/n");#endif		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;		last_sector_hacks(us, srb);		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 == USB_PR_CB || us->protocol == USB_PR_DPCM_USB) &&			srb->sc_data_direction != DMA_FROM_DEVICE) {		usb_stor_dbg(us, "-- 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) {		usb_stor_dbg(us, "-- transport indicates command failure/n");		need_auto_sense = 1;	}	/*	 * Determine if this device is SAT by seeing if the	 * command executed successfully.  Otherwise we'll have	 * to wait for at least one CHECK_CONDITION to determine	 * SANE_SENSE support	 */	if (unlikely((srb->cmnd[0] == ATA_16 || srb->cmnd[0] == ATA_12) &&	    result == USB_STOR_TRANSPORT_GOOD &&	    !(us->fflags & US_FL_SANE_SENSE) &&	    !(us->fflags & US_FL_BAD_SENSE) &&	    !(srb->cmnd[2] & 0x20))) {		usb_stor_dbg(us, "-- SAT supported, increasing auto-sense/n");		us->fflags |= US_FL_SANE_SENSE;	}	/*	 * 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))) {		usb_stor_dbg(us, "-- unexpectedly short transfer/n");//.........这里部分代码省略.........
开发者ID:ShedrockN4,项目名称:wiliteneo,代码行数:101,


示例26: sddr55_read_map

//.........这里部分代码省略.........	memset(command, 0, 8);	command[5] = 0xB0;	command[6] = numblocks * 2 / 256;	command[7] = 0x8A;	result = sddr55_bulk_transport(us, DMA_TO_DEVICE, command, 8);	if ( result != USB_STOR_XFER_GOOD) {		kfree (buffer);		return -1;	}	result = sddr55_bulk_transport(us, DMA_FROM_DEVICE, buffer, numblocks * 2);	if ( result != USB_STOR_XFER_GOOD) {		kfree (buffer);		return -1;	}	result = sddr55_bulk_transport(us, DMA_FROM_DEVICE, command, 2);	if ( result != USB_STOR_XFER_GOOD) {		kfree (buffer);		return -1;	}	kfree(info->lba_to_pba);	kfree(info->pba_to_lba);	info->lba_to_pba = kmalloc_array(numblocks, sizeof(int), GFP_NOIO);	info->pba_to_lba = kmalloc_array(numblocks, sizeof(int), GFP_NOIO);	if (info->lba_to_pba == NULL || info->pba_to_lba == NULL) {		kfree(info->lba_to_pba);		kfree(info->pba_to_lba);		info->lba_to_pba = NULL;		info->pba_to_lba = NULL;		kfree(buffer);		return -1;	}	memset(info->lba_to_pba, 0xff, numblocks*sizeof(int));	memset(info->pba_to_lba, 0xff, numblocks*sizeof(int));	/* set maximum lba */	max_lba = info->max_log_blks;	if (max_lba > 1000)		max_lba = 1000;	/*	 * Each block is 64 bytes of control data, so block i is located in	 * scatterlist block i*64/128k = i*(2^6)*(2^-17) = i*(2^-11)	 */	for (i=0; i<numblocks; i++) {		int zone = i / 1024;		lba = short_pack(buffer[i * 2], buffer[i * 2 + 1]);			/*			 * Every 1024 physical blocks ("zone"), the LBA numbers			 * go back to zero, but are within a higher			 * block of LBA's. Also, there is a maximum of			 * 1000 LBA's per zone. In other words, in PBA			 * 1024-2047 you will find LBA 0-999 which are			 * really LBA 1000-1999. Yes, this wastes 24			 * physical blocks per zone. Go figure. 			 * These devices can have blocks go bad, so there			 * are 24 spare blocks to use when blocks do go bad.			 */			/*			 * SDDR55 returns 0xffff for a bad block, and 0x400 for the 			 * CIS block. (Is this true for cards 8MB or less??)			 * Record these in the physical to logical map			 */ 		info->pba_to_lba[i] = lba;		if (lba >= max_lba) {			continue;		}				if (info->lba_to_pba[lba + zone * 1000] != NOT_ALLOCATED &&		    !info->force_read_only) {			printk(KERN_WARNING			       "sddr55: map inconsistency at LBA %04X/n",			       lba + zone * 1000);			info->force_read_only = 1;		}		if (lba<0x10 || (lba>=0x3E0 && lba<0x3EF))			usb_stor_dbg(us, "LBA %04X <-> PBA %04X/n", lba, i);		info->lba_to_pba[lba + zone * 1000] = i;	}	kfree(buffer);	return 0;}
开发者ID:AlexShiLucky,项目名称:linux,代码行数:101,


示例27: sddr55_transport

/* * Transport for the Sandisk SDDR-55 */static int sddr55_transport(struct scsi_cmnd *srb, struct us_data *us){	int result;	static unsigned char inquiry_response[8] = {		0x00, 0x80, 0x00, 0x02, 0x1F, 0x00, 0x00, 0x00	}; 	// write-protected for now, no block descriptor support	static unsigned char mode_page_01[20] = {		0x0, 0x12, 0x00, 0x80, 0x0, 0x0, 0x0, 0x0,		0x01, 0x0A,		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00	};	unsigned char *ptr = us->iobuf;	unsigned long capacity;	unsigned int lba;	unsigned int pba;	unsigned int page;	unsigned short pages;	struct sddr55_card_info *info;	if (!us->extra) {		us->extra = kzalloc(			sizeof(struct sddr55_card_info), GFP_NOIO);		if (!us->extra)			return USB_STOR_TRANSPORT_ERROR;		us->extra_destructor = sddr55_card_info_destructor;	}	info = (struct sddr55_card_info *)(us->extra);	if (srb->cmnd[0] == REQUEST_SENSE) {		usb_stor_dbg(us, "request sense %02x/%02x/%02x/n",			     info->sense_data[2],			     info->sense_data[12],			     info->sense_data[13]);		memcpy (ptr, info->sense_data, sizeof info->sense_data);		ptr[0] = 0x70;		ptr[7] = 11;		usb_stor_set_xfer_buf (ptr, sizeof info->sense_data, srb);		memset (info->sense_data, 0, sizeof info->sense_data);		return USB_STOR_TRANSPORT_GOOD;	}	memset (info->sense_data, 0, sizeof info->sense_data);	/*	 * Dummy up a response for INQUIRY since SDDR55 doesn't	 * respond to INQUIRY commands	 */	if (srb->cmnd[0] == INQUIRY) {		memcpy(ptr, inquiry_response, 8);		fill_inquiry_response(us, ptr, 36);		return USB_STOR_TRANSPORT_GOOD;	}	/*	 * only check card status if the map isn't allocated, ie no card seen yet	 * or if it's been over half a second since we last accessed it	 */	if (info->lba_to_pba == NULL || time_after(jiffies, info->last_access + HZ/2)) {		/* check to see if a card is fitted */		result = sddr55_status (us);		if (result) {			result = sddr55_status (us);			if (!result) {			set_sense_info (6, 0x28, 0);	/* new media, set unit attention, not ready to ready */			}			return USB_STOR_TRANSPORT_FAILED;		}	}	/*	 * if we detected a problem with the map when writing,	 * don't allow any more access	 */	if (info->fatal_error) {		set_sense_info (3, 0x31, 0);		return USB_STOR_TRANSPORT_FAILED;	}	if (srb->cmnd[0] == READ_CAPACITY) {		capacity = sddr55_get_capacity(us);		if (!capacity) {			set_sense_info (3, 0x30, 0); /* incompatible medium */			return USB_STOR_TRANSPORT_FAILED;		}		info->capacity = capacity;		/*//.........这里部分代码省略.........
开发者ID:AlexShiLucky,项目名称:linux,代码行数:101,


示例28: 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;    usb_stor_dbg(us, "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(us, 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) {        usb_stor_dbg(us, "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);    usb_stor_dbg(us, "foo Status result %d %u/n", result, partial);    if (result != USB_STOR_XFER_GOOD)        return USB_STOR_TRANSPORT_ERROR;    US_DEBUG(pdump(us, (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) {        usb_stor_dbg(us, "20 second USB/ATAPI bridge TIMEOUT occurred!/n");        usb_stor_dbg(us, "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) {            usb_stor_dbg(us, "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);        usb_stor_dbg(us, "bar Status result %d %u/n", result, partial);        if (result != USB_STOR_XFER_GOOD)            return USB_STOR_TRANSPORT_ERROR;        US_DEBUG(pdump(us, (void *)fst, partial));    }    if (partial != 4)        return USB_STOR_TRANSPORT_ERROR;    if ((fst->Status & 1) != 0) {        usb_stor_dbg(us, "operation failed/n");        return USB_STOR_TRANSPORT_FAILED;    }//.........这里部分代码省略.........
开发者ID:Niisp,项目名称:MT6795.kernel,代码行数:101,


示例29: 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;	long timeleft;	int status;	/* don't submit URBs during abort processing */	if (test_bit(US_FLIDX_ABORTING, &us->dflags))		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->transfer_flags = 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. */	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;	/* 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->dflags);	/* did an abort occur during the submission? */	if (test_bit(US_FLIDX_ABORTING, &us->dflags)) {		/* cancel the URB, if it hasn't been cancelled already */		if (test_and_clear_bit(US_FLIDX_URB_ACTIVE, &us->dflags)) {			usb_stor_dbg(us, "-- cancelling URB/n");			usb_unlink_urb(us->current_urb);		}	} 	/* wait for the completion of the URB */	timeleft = wait_for_completion_interruptible_timeout(			&urb_done, timeout ? : MAX_SCHEDULE_TIMEOUT); 	clear_bit(US_FLIDX_URB_ACTIVE, &us->dflags);	if (timeleft <= 0) {		usb_stor_dbg(us, "%s -- cancelling URB/n",			     timeleft == 0 ? "Timeout" : "Signal");		usb_kill_urb(us->current_urb);	}	/* return the URB status */	return us->current_urb->status;}
开发者ID:ShedrockN4,项目名称:wiliteneo,代码行数:67,


示例30: usb_stor_Bulk_transport

int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us){	struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;	struct bulk_cs_wrap *bcs = (struct bulk_cs_wrap *) us->iobuf;	unsigned int transfer_length = scsi_bufflen(srb);	unsigned int residue;	int result;	int fake_sense = 0;	unsigned int cswlen;	unsigned int cbwlen = US_BULK_CB_WRAP_LEN;	/* Take care of BULK32 devices; set extra byte to 0 */	if (unlikely(us->fflags & US_FL_BULK32)) {		cbwlen = 32;		us->iobuf[31] = 0;	}	/* set up the command wrapper */	bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);	bcb->DataTransferLength = cpu_to_le32(transfer_length);	bcb->Flags = srb->sc_data_direction == DMA_FROM_DEVICE ?		US_BULK_FLAG_IN : 0;	bcb->Tag = ++us->tag;	bcb->Lun = srb->device->lun;	if (us->fflags & US_FL_SCM_MULT_TARG)		bcb->Lun |= srb->device->id << 4;	bcb->Length = srb->cmd_len;	/* copy the command payload */	memset(bcb->CDB, 0, sizeof(bcb->CDB));	memcpy(bcb->CDB, srb->cmnd, bcb->Length);	/* send it to out endpoint */	usb_stor_dbg(us, "Bulk Command S 0x%x T 0x%x L %d F %d Trg %d LUN %d CL %d/n",		     le32_to_cpu(bcb->Signature), bcb->Tag,		     le32_to_cpu(bcb->DataTransferLength), bcb->Flags,		     (bcb->Lun >> 4), (bcb->Lun & 0x0F),		     bcb->Length);	result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,				bcb, cbwlen, NULL);	usb_stor_dbg(us, "Bulk command transfer result=%d/n", result);	if (result != USB_STOR_XFER_GOOD)		return USB_STOR_TRANSPORT_ERROR;	/* DATA STAGE */	/* send/receive data payload, if there is any */	/* Some USB-IDE converter chips need a 100us delay between the	 * command phase and the data phase.  Some devices need a little	 * more than that, probably because of clock rate inaccuracies. */	if (unlikely(us->fflags & US_FL_GO_SLOW))		udelay(125);	if (transfer_length) {		unsigned int pipe = srb->sc_data_direction == DMA_FROM_DEVICE ? 				us->recv_bulk_pipe : us->send_bulk_pipe;		result = usb_stor_bulk_srb(us, pipe, srb);		usb_stor_dbg(us, "Bulk data transfer result 0x%x/n", result);		if (result == USB_STOR_XFER_ERROR)			return USB_STOR_TRANSPORT_ERROR;		/* If the device tried to send back more data than the		 * amount requested, the spec requires us to transfer		 * the CSW anyway.  Since there's no point retrying the		 * the command, we'll return fake sense data indicating		 * Illegal Request, Invalid Field in CDB.		 */		if (result == USB_STOR_XFER_LONG)			fake_sense = 1;		/*		 * Sometimes a device will mistakenly skip the data phase		 * and go directly to the status phase without sending a		 * zero-length packet.  If we get a 13-byte response here,		 * check whether it really is a CSW.		 */		if (result == USB_STOR_XFER_SHORT &&				srb->sc_data_direction == DMA_FROM_DEVICE &&				transfer_length - scsi_get_resid(srb) ==					US_BULK_CS_WRAP_LEN) {			struct scatterlist *sg = NULL;			unsigned int offset = 0;			if (usb_stor_access_xfer_buf((unsigned char *) bcs,					US_BULK_CS_WRAP_LEN, srb, &sg,					&offset, FROM_XFER_BUF) ==						US_BULK_CS_WRAP_LEN &&					bcs->Signature ==						cpu_to_le32(US_BULK_CS_SIGN)) {				usb_stor_dbg(us, "Device skipped data phase/n");				scsi_set_resid(srb, transfer_length);				goto skipped_data_phase;			}		}	}	/* See flow chart on pg 15 of the Bulk Only Transport spec for	 * an explanation of how this code works.	 *///.........这里部分代码省略.........
开发者ID:ShedrockN4,项目名称:wiliteneo,代码行数:101,



注:本文中的usb_stor_dbg函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ usb_stor_msg_common函数代码示例
C++ usb_stor_control_msg函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。