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

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

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

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

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

示例1: 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";	US_DEBUGP("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;	US_DEBUGP("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:softbalajibi,项目名称:android_kernel_huawei_mediapad10fhd,代码行数:33,


示例2: usb_stor_huawei_init

int usb_stor_huawei_init(struct us_data *us){    int idProduct;    idProduct = us->pusb_dev->descriptor.idProduct;    if(idProduct==0x1F01) {        int result ;        int act_len;        unsigned  char  cmd[32] =  {0x55,  0x53, 0x42,  0x43,  0x00, 0x00,  0x00, 0x00,                                    0x00,  0x00, 0x00,  0x00,  0x00,  0x00,  0x00, 0x11,                                    0x06,  0x30, 0x00,  0x00,  0x01,  0x00,  0x01, 0x00,                                    0x00,  0x00, 0x00,  0x00,  0x00,  0x00, 0x00                                   };        result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, cmd, 31, &act_len);        printk("usb_stor_bulk_transfer_buf performing result is %d, transfer the actual length=%d/n", result,act_len);        return result;    } else {        int result = 0;        int act_len = 0;        struct bulk_cb_wrap *bcbw = (struct bulk_cb_wrap *) us->iobuf;        char rewind_cmd[] = {0x11, 0x06, 0x20, 0x00, 0x00, 0x01, 0x01, 0x00,                             0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00                            };        bcbw->Signature = cpu_to_le32(US_BULK_CB_SIGN);        bcbw->Tag = 0;        bcbw->DataTransferLength = 0;        bcbw->Flags = bcbw->Lun = 0;        bcbw->Length = sizeof(rewind_cmd);        memset(bcbw->CDB, 0, sizeof(bcbw->CDB));        memcpy(bcbw->CDB, rewind_cmd, sizeof(rewind_cmd));        result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, bcbw,                                            US_BULK_CB_WRAP_LEN, &act_len);        printk("transfer actual length=%d, result=%d/n", act_len, result);        return result;    }}
开发者ID:KuronekoDungeon,项目名称:stock_firefly-rk3288-kernel,代码行数:35,


示例3: rio_karma_init

/* Place the Rio Karma into mass storage mode. * * The initialization begins by sending 40 bytes starting * RIOP/x00/x01/x08/x00, which the device will ack with a 512-byte * packet with the high four bits set and everything else null. * * Next, we send RIOP/x80/x00/x08/x00.  Each time, a 512 byte response * must be read, but we must loop until byte 5 in the response is 0x08, * indicating success.  */int rio_karma_init(struct us_data *us){    int result, partial;    char *recv;    unsigned long timeout;    // us->iobuf is big enough to hold cmd but not receive    if (!(recv = kmalloc(RIO_RECV_LEN, GFP_KERNEL)))        goto die_nomem;    US_DEBUGP("Initializing Karma.../n");    memset(us->iobuf, 0, RIO_SEND_LEN);    memcpy(us->iobuf, RIOP_INIT, RIOP_INIT_LEN);    result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,                                        us->iobuf, RIO_SEND_LEN, &partial);    if (result != USB_STOR_XFER_GOOD)        goto die;    result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,                                        recv, RIO_RECV_LEN, &partial);    if (result != USB_STOR_XFER_GOOD)        goto die;    us->iobuf[4] = 0x80;    us->iobuf[5] = 0;    timeout = jiffies + msecs_to_jiffies(3000);    for (;;) {        US_DEBUGP("Sending init command/n");        result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,                                            us->iobuf, RIO_SEND_LEN, &partial);        if (result != USB_STOR_XFER_GOOD)            goto die;        result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,                                            recv, RIO_RECV_LEN, &partial);        if (result != USB_STOR_XFER_GOOD)            goto die;        if (recv[5] == RIO_MSC)            break;        if (time_after(jiffies, timeout))            goto die;        msleep(10);    }    US_DEBUGP("Karma initialized./n");    kfree(recv);    return 0;die:    kfree(recv);die_nomem:    US_DEBUGP("Could not initialize karma./n");    return USB_STOR_TRANSPORT_FAILED;}
开发者ID:FatSunHYS,项目名称:OSCourseDesign,代码行数:65,


示例4: ene_send_scsi_cmd

static int ene_send_scsi_cmd(struct us_data *us, u8 fDir, void *buf, int use_sg){	struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;	struct bulk_cs_wrap *bcs = (struct bulk_cs_wrap *) us->iobuf;	int result;	unsigned int residue;	unsigned int cswlen = 0, partial = 0;	unsigned int transfer_length = bcb->DataTransferLength;	/* US_DEBUGP("transport --- ene_send_scsi_cmd/n"); */	/* send cmd to out endpoint */	result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,					    bcb, US_BULK_CB_WRAP_LEN, NULL);	if (result != USB_STOR_XFER_GOOD) {		US_DEBUGP("send cmd to out endpoint fail ---/n");		return USB_STOR_TRANSPORT_ERROR;	}	if (buf) {		unsigned int pipe = fDir;		if (fDir  == FDIR_READ)			pipe = us->recv_bulk_pipe;		else			pipe = us->send_bulk_pipe;		/* Bulk */		if (use_sg) {			result = usb_stor_bulk_srb(us, pipe, us->srb);		} else {			result = usb_stor_bulk_transfer_sg(us, pipe, buf,						transfer_length, 0, &partial);		}		if (result != USB_STOR_XFER_GOOD) {			US_DEBUGP("data transfer fail ---/n");			return USB_STOR_TRANSPORT_ERROR;		}	}	/* Get CSW for device status */	result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, bcs,					    US_BULK_CS_WRAP_LEN, &cswlen);	if (result == USB_STOR_XFER_SHORT && cswlen == 0) {		US_DEBUGP("Received 0-length CSW; retrying.../n");		result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,					    bcs, US_BULK_CS_WRAP_LEN, &cswlen);	}	if (result == USB_STOR_XFER_STALLED) {		/* get the status again */		US_DEBUGP("Attempting 
开发者ID:ccrsno1,项目名称:linux,代码行数:53,


示例5: option_inquiry

static int option_inquiry(struct us_data *us){	const unsigned char inquiry_msg[] = {	  0x55, 0x53, 0x42, 0x43, 0x12, 0x34, 0x56, 0x78,	  0x24, 0x00, 0x00, 0x00, 0x80, 0x00, 0x06, 0x12,	  0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00,	  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00	};	char *buffer;	int result;	US_DEBUGP("Option MS: %s", "device inquiry for vendor name/n");	buffer = kzalloc(0x24, GFP_KERNEL);	if (buffer == NULL)		return USB_STOR_TRANSPORT_ERROR;	memcpy(buffer, inquiry_msg, sizeof(inquiry_msg));	result = usb_stor_bulk_transfer_buf(us,			us->send_bulk_pipe,			buffer, sizeof(inquiry_msg), NULL);	if (result != USB_STOR_XFER_GOOD) {		result = USB_STOR_XFER_ERROR;		goto out;	}	result = usb_stor_bulk_transfer_buf(us,			us->recv_bulk_pipe,			buffer, 0x24, NULL);	if (result != USB_STOR_XFER_GOOD) {		result = USB_STOR_XFER_ERROR;		goto out;	}	result = memcmp(buffer+8, "Option", 6);	if (result != 0)		result = memcmp(buffer+8, "ZCOPTION", 8);	/* Read the CSW */	usb_stor_bulk_transfer_buf(us,			us->recv_bulk_pipe,			buffer, 13, NULL);out:	kfree(buffer);	return result;}
开发者ID:3sOx,项目名称:asuswrt-merlin,代码行数:48,


示例6: usb_stor_bulk_transfer_sg

/* * Transfer an entire SCSI command's worth of data payload over the bulk * pipe. * * Note that this uses usb_stor_bulk_transfer_buf() and * usb_stor_bulk_transfer_sglist() to achieve its goals -- * this function simply determines whether we're going to use * scatter-gather or not, and acts appropriately. */int usb_stor_bulk_transfer_sg(struct us_data* us, unsigned int pipe,		void *buf, unsigned int length_left, int use_sg, int *residual){	int result;	unsigned int partial;	/* are we scatter-gathering? */	if (use_sg) {		/* use the usb core scatter-gather primitives */		result = usb_stor_bulk_transfer_sglist(us, pipe,				(struct scatterlist *) buf, use_sg,				length_left, &partial);		length_left -= partial;	} else {		/* no scatter-gather, just make the request */		result = usb_stor_bulk_transfer_buf(us, pipe, buf, 				length_left, &partial);		length_left -= partial;	}	/* store the residual and return the error code */	if (residual)		*residual = length_left;	return result;}
开发者ID:loginab,项目名称:esxdrivers,代码行数:34,


示例7: freecom_readdata

static intfreecom_readdata (struct scsi_cmnd *srb, struct us_data *us,		unsigned int ipipe, unsigned int opipe, int count){	struct freecom_xfer_wrap *fxfr =		(struct freecom_xfer_wrap *) us->iobuf;	int result;	fxfr->Type = FCM_PACKET_INPUT | 0x00;	fxfr->Timeout = 0;    	fxfr->Count = cpu_to_le32 (count);	memset (fxfr->Pad, 0, sizeof (fxfr->Pad));	US_DEBUGP("Read data Freecom! (c=%d)/n", count);		result = usb_stor_bulk_transfer_buf (us, opipe, fxfr,			FCM_PACKET_LENGTH, NULL);	if (result != USB_STOR_XFER_GOOD) {		US_DEBUGP ("Freecom readdata transport error/n");		return USB_STOR_TRANSPORT_ERROR;	}		US_DEBUGP("Start of read/n");	result = usb_stor_bulk_srb(us, ipipe, srb);	US_DEBUGP("freecom_readdata done!/n");	if (result > USB_STOR_XFER_SHORT)		return USB_STOR_TRANSPORT_ERROR;	return USB_STOR_TRANSPORT_GOOD;}
开发者ID:Albinoman887,项目名称:pyramid-3.4.10,代码行数:32,


示例8: 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));	US_DEBUGP("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) {		US_DEBUGP ("Freecom writedata transport error/n");		return USB_STOR_TRANSPORT_ERROR;	}	/* Now transfer all of our blocks. */	US_DEBUGP("Start of write/n");	result = usb_stor_bulk_srb(us, opipe, srb);	US_DEBUGP("freecom_writedata done!/n");	if (result > USB_STOR_XFER_SHORT)		return USB_STOR_TRANSPORT_ERROR;	return USB_STOR_TRANSPORT_GOOD;}
开发者ID:CSCLOG,项目名称:beaglebone,代码行数:32,


示例9: usb_stor_S10_lte_init

int usb_stor_S10_lte_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[] = {17, 06, 00, 00, 00,		01, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00};	printk(KERN_INFO "usb_stor_S10_lte_init.../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 = 0;	memset(bcb->CDB, 0, sizeof(bcb->CDB));	memcpy(bcb->CDB, init_string, 16);	res = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, bcb,			US_BULK_CB_WRAP_LEN, &partial);	if (res)		return -EIO;	return 0;}
开发者ID:softbalajibi,项目名称:android_kernel_huawei_mediapad10fhd,代码行数:26,


示例10: usb_stor_bulk_transfer_sg

/* * Transfer an entire SCSI command's worth of data payload over the bulk * pipe. * * Note that this uses usb_stor_bulk_transfer_buf() and * usb_stor_bulk_transfer_sglist() to achieve its goals -- * this function simply determines whether we're going to use * scatter-gather or not, and acts appropriately. */int usb_stor_bulk_transfer_sg(struct us_data* us, unsigned int pipe,		void *buf, unsigned int length_left, int use_sg, int *residual){	int result;	unsigned int partial;	//ALPS00445134, add more debug message for CR debugging	US_DEBUGP("%s, line %d: /n", __func__, __LINE__);	//ALPS00445134, add more debug message for CR debugging	/* are we scatter-gathering? */	if (use_sg) {		/* use the usb core scatter-gather primitives */		result = usb_stor_bulk_transfer_sglist(us, pipe,				(struct scatterlist *) buf, use_sg,				length_left, &partial);		length_left -= partial;	} else {		/* no scatter-gather, just make the request */		result = usb_stor_bulk_transfer_buf(us, pipe, buf, 				length_left, &partial);		length_left -= partial;	}	/* store the residual and return the error code */	if (residual)		*residual = length_left;	return result;}
开发者ID:openube,项目名称:android_kernel_sony_c2305,代码行数:38,


示例11: rio_karma_send_command

static int rio_karma_send_command(char cmd, struct us_data *us){	int result, partial;	unsigned long timeout;	static unsigned char seq = 1;	struct karma_data *data = (struct karma_data *) us->extra;	US_DEBUGP("karma: sending command %04x/n", cmd);	memset(us->iobuf, 0, RIO_SEND_LEN);	memcpy(us->iobuf, RIO_PREFIX, RIO_PREFIX_LEN);	us->iobuf[5] = cmd;	us->iobuf[6] = seq;	timeout = jiffies + msecs_to_jiffies(6000);	for (;;) {		result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,			us->iobuf, RIO_SEND_LEN, &partial);		if (result != USB_STOR_XFER_GOOD)			goto err;		result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,			data->recv, RIO_RECV_LEN, &partial);		if (result != USB_STOR_XFER_GOOD)			goto err;		if (data->recv[5] == seq)			break;		if (time_after(jiffies, timeout))			goto err;		us->iobuf[4] = 0x80;		us->iobuf[5] = 0;		msleep(50);	}	seq++;	if (seq == 0)		seq = 1;	US_DEBUGP("karma: sent command %04x/n", cmd);	return 0;err:	US_DEBUGP("karma: command %04x failed/n", cmd);	return USB_STOR_TRANSPORT_FAILED;}
开发者ID:Albinoman887,项目名称:pyramid-3.4.10,代码行数:46,


示例12: option_rezero

static int option_rezero(struct us_data *us){	const unsigned char rezero_msg[] = {	  0x55, 0x53, 0x42, 0x43, 0x78, 0x56, 0x34, 0x12,	  0x01, 0x00, 0x00, 0x00, 0x80, 0x00, 0x06, 0x01,	  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,	  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00	};	char *buffer;	int result;	US_DEBUGP("Option MS: %s", "DEVICE MODE SWITCH/n");	buffer = kzalloc(RESPONSE_LEN, GFP_KERNEL);	if (buffer == NULL)		return USB_STOR_TRANSPORT_ERROR;	memcpy(buffer, rezero_msg, sizeof(rezero_msg));	result = usb_stor_bulk_transfer_buf(us,			us->send_bulk_pipe,			buffer, sizeof(rezero_msg), NULL);	if (result != USB_STOR_XFER_GOOD) {		result = USB_STOR_XFER_ERROR;		goto out;	}	/* Some of the devices need to be asked for a response, but we don't	 * care what that response is.	 */	usb_stor_bulk_transfer_buf(us,			us->recv_bulk_pipe,			buffer, RESPONSE_LEN, NULL);	/* Read the CSW */	usb_stor_bulk_transfer_buf(us,			us->recv_bulk_pipe,			buffer, 13, NULL);	result = USB_STOR_XFER_GOOD;out:	kfree(buffer);	return result;}
开发者ID:3sOx,项目名称:asuswrt-merlin,代码行数:44,


示例13: usb_stor_huawei_scsi_init

int usb_stor_huawei_scsi_init(struct us_data *us){	int result = 0;	int act_len = 0;	unsigned  char  cmd[32] =  {0x55,  0x53, 0x42,  0x43,  0x00, 0x00,  0x00, 0x00,								0x00,  0x00, 0x00,  0x00,  0x00,  0x00,  0x00, 0x11,								0x06,  0x30, 0x00,  0x00,  0x01,  0x00,  0x01, 0x00,								0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};	result = usb_stor_bulk_transfer_buf (us, us->send_bulk_pipe, cmd, 31, &act_len);	US_DEBUGP("usb_stor_bulk_transfer_buf  performing  result  is  %d, transfer the actual length=%d/n", result, act_len);	return result;}
开发者ID:32743069,项目名称:amlogic_common_3050,代码行数:12,


示例14: sddr55_bulk_transport

static intsddr55_bulk_transport(struct us_data *us, int direction,		      unsigned char *data, unsigned int len) {	struct sddr55_card_info *info = (struct sddr55_card_info *)us->extra;	unsigned int pipe = (direction == DMA_FROM_DEVICE) ?			us->recv_bulk_pipe : us->send_bulk_pipe;	if (!len)		return USB_STOR_XFER_GOOD;	info->last_access = jiffies;	return usb_stor_bulk_transfer_buf(us, pipe, data, len, NULL);}
开发者ID:3sOx,项目名称:asuswrt-merlin,代码行数:12,


示例15: usb_stor_zte_k4505_init

int usb_stor_zte_k4505_init(struct us_data *us) {		int result = 0;		int act_len = 0;		unsigned char cmd[32] = {				 0x55,0x53,0x42,0x43,0x12,0x34,0x56,0x78,				 0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x1b,				 0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,				 0x00,0x00,0x00,0x00,0x00,0x00,0x00				 };		result = usb_stor_bulk_transfer_buf (us, us->send_bulk_pipe, cmd, 31,&act_len);	    printk("usb_stor_bulk_transfer_buf performing result is %d, transfer the actual length=%d/n", result, act_len);		return (result ? 0 : -ENODEV);}
开发者ID:Dee-UK,项目名称:RK3188_KK_4.4.02_Beta,代码行数:14,


示例16: usb_stor_huawei_scsi_init

/* * It will send a scsi switch command called rewind' to huawei dongle. * When the dongle receives this command at the first time, * it will reboot immediately. After rebooted, it will ignore this command. * So it is  unnecessary to read its response. */static int usb_stor_huawei_scsi_init(struct us_data *us){	int result = 0;	int act_len = 0;	struct bulk_cb_wrap *bcbw = (struct bulk_cb_wrap *) us->iobuf;	char rewind_cmd[] = {0x11, 0x06, 0x20, 0x00, 0x00, 0x01, 0x01, 0x00,			0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};	bcbw->Signature = cpu_to_le32(US_BULK_CB_SIGN);	bcbw->Tag = 0;	bcbw->DataTransferLength = 0;	bcbw->Flags = bcbw->Lun = 0;	bcbw->Length = sizeof(rewind_cmd);	memset(bcbw->CDB, 0, sizeof(bcbw->CDB));	memcpy(bcbw->CDB, rewind_cmd, sizeof(rewind_cmd));	result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, bcbw,					US_BULK_CB_WRAP_LEN, &act_len);	US_DEBUGP("transfer actual length=%d, result=%d/n", act_len, result);	return result;}
开发者ID:Mr-Aloof,项目名称:wl500g,代码行数:27,


示例17: 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;	}//.........这里部分代码省略.........
开发者ID:CSCLOG,项目名称:beaglebone,代码行数:101,


示例18: rts51x_bulk_transport

static int rts51x_bulk_transport(struct us_data *us, u8 lun,				 u8 *cmd, int cmd_len, u8 *buf, int buf_len,				 enum dma_data_direction dir, int *act_len){	struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;	struct bulk_cs_wrap *bcs = (struct bulk_cs_wrap *) us->iobuf;	int result;	unsigned int residue;	unsigned int cswlen;	unsigned int cbwlen = US_BULK_CB_WRAP_LEN;	/* set up the command wrapper */	bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);	bcb->DataTransferLength = cpu_to_le32(buf_len);	bcb->Flags = (dir == DMA_FROM_DEVICE) ? 1 << 7 : 0;	bcb->Tag = ++us->tag;	bcb->Lun = lun;	bcb->Length = cmd_len;	/* copy the command payload */	memset(bcb->CDB, 0, sizeof(bcb->CDB));	memcpy(bcb->CDB, cmd, bcb->Length);	/* send it to out endpoint */	result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,				bcb, cbwlen, NULL);	if (result != USB_STOR_XFER_GOOD)		return USB_STOR_TRANSPORT_ERROR;	/* DATA STAGE */	/* send/receive data payload, if there is any */	if (buf && buf_len) {		unsigned int pipe = (dir == DMA_FROM_DEVICE) ?				us->recv_bulk_pipe : us->send_bulk_pipe;		result = usb_stor_bulk_transfer_buf(us, pipe,				buf, buf_len, NULL);		if (result == USB_STOR_XFER_ERROR)			return USB_STOR_TRANSPORT_ERROR;	}	/* get CSW for device status */	result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,				bcs, US_BULK_CS_WRAP_LEN, &cswlen);	if (result != USB_STOR_XFER_GOOD)		return USB_STOR_TRANSPORT_ERROR;	/* check bulk status */	if (bcs->Signature != cpu_to_le32(US_BULK_CS_SIGN)) {		US_DEBUGP("Signature mismatch: got %08X, expecting %08X/n",			  le32_to_cpu(bcs->Signature),			  US_BULK_CS_SIGN);		return USB_STOR_TRANSPORT_ERROR;	}	residue = bcs->Residue;	if (bcs->Tag != us->tag)		return USB_STOR_TRANSPORT_ERROR;	/* try to compute the actual residue, based on how much data	 * was really transferred and what the device tells us */	if (residue)		residue = residue < buf_len ? residue : buf_len;	if (act_len)		*act_len = buf_len - residue;	/* based on the status code, we report good or bad */	switch (bcs->Status) {	case US_BULK_STAT_OK:		/* command good -- note that data could be short */		return USB_STOR_TRANSPORT_GOOD;	case US_BULK_STAT_FAIL:		/* command failed */		return USB_STOR_TRANSPORT_FAILED;	case US_BULK_STAT_PHASE:		/* phase error -- note that a transport reset will be			* invoked by the invoke_transport() function			*/		return USB_STOR_TRANSPORT_ERROR;	}	/* we should never get here, but if we do, we're in trouble */	return USB_STOR_TRANSPORT_ERROR;}
开发者ID:119-org,项目名称:hi3518-osdrv,代码行数:87,


示例19: 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);//.........这里部分代码省略.........
开发者ID:Albinoman887,项目名称:pyramid-3.4.10,代码行数:101,


示例20: 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;//.........这里部分代码省略.........
开发者ID:Core2idiot,项目名称:Kernel-Samsung-3.0...-,代码行数:101,


示例21: 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 = srb->request_bufflen;	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->flags & 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 ? 1 << 7 : 0;	bcb->Tag = ++us->tag;	bcb->Lun = srb->device->lun;	if (us->flags & 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 */	US_DEBUGP("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);	_VMKLNX_USB_STOR_MSG("Bulk command transfer result=%d/n", srb, result);	US_DEBUGP("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->flags & US_FL_GO_SLOW))		udelay(125);#if defined(__VMKLNX__)	if (!in_interrupt() &&	    VMKLNX_STRESS_COUNTER(stressUSBStorageDelaySCSIDataPhase)) {		// XXX make sleep duration a random value?		info("Sleeping for 5 seconds to delay USB SCSI data phase");		ssleep(5);		dbg("Done sleeping; proceeding with USB SCSI data phase");	}#endif /* __VMKLNX__ */	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_transfer_sg(us, pipe,					srb->request_buffer, transfer_length,					srb->use_sg, &srb->resid);		_VMKLNX_USB_STOR_MSG("Bulk data transfer result 0x%x/n", srb, result);		US_DEBUGP("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;	}	/* See flow chart on pg 15 of the Bulk Only Transport spec for	 * an explanation of how this code works.	 */	/* get CSW for device status */	US_DEBUGP("Attempting to get CSW.../n");	result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,				bcs, US_BULK_CS_WRAP_LEN, &cswlen);	/* Some broken devices add unnecessary zero-length packets to the	 * end of their data transfers.  Such packets show up as 0-length	 * CSWs.  If we encounter such a thing, try to read the CSW again.	 */	if (result == USB_STOR_XFER_SHORT && cswlen == 0) {		_VMKLNX_USB_STOR_MSG("Received 0-length CSW; retrying.../n", us->srb);		US_DEBUGP("Received 0-length CSW; retrying.../n");//.........这里部分代码省略.........
开发者ID:loginab,项目名称:esxdrivers,代码行数:101,


示例22: 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 */	US_DEBUGP("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);	US_DEBUGP("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);		US_DEBUGP("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)) {				US_DEBUGP("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:LiquidSmooth-Devices,项目名称:Deathly_Kernel_D2,代码行数:101,


示例23: usb_stor_Bulk_transport

/* * 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;	/* pr_info("transport --- usb_stor_Bulk_transport/n"); */	/* 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 ? 1 << 7 : 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 command */	/* send it to out endpoint */	/* pr_info("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);	/* pr_info("Bulk command transfer result=%d/n", result); */	if (result != USB_STOR_XFER_GOOD)		return USB_STOR_TRANSPORT_ERROR;	if (unlikely(us->fflags & US_FL_GO_SLOW))		udelay(125);	/*  R/W data */	if (transfer_length) {		unsigned int pipe;		if (srb->sc_data_direction == DMA_FROM_DEVICE)			pipe = us->recv_bulk_pipe;		else			pipe = us->send_bulk_pipe;		result = usb_stor_bulk_srb(us, pipe, srb);		/* pr_info("Bulk data transfer result 0x%x/n", result); */		if (result == USB_STOR_XFER_ERROR)			return USB_STOR_TRANSPORT_ERROR;		if (result == USB_STOR_XFER_LONG)			fake_sense = 1;	}	/* get CSW for device status */	/* pr_info("Attempting to get CSW.../n"); */	result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, bcs,						US_BULK_CS_WRAP_LEN, &cswlen);	if (result == USB_STOR_XFER_SHORT && cswlen == 0) {		/* pr_info("Received 0-length CSW; retrying.../n"); */		result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, bcs,						US_BULK_CS_WRAP_LEN, &cswlen);	}	/* did the attempt to read the CSW fail? */	if (result == USB_STOR_XFER_STALLED) {		/* get the status again */		/* pr_info("Attempting to get CSW (2nd try).../n"); */		result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, bcs,						US_BULK_CS_WRAP_LEN, NULL);	}	/* if we still have a failure at this point, we're in trouble */	/* pr_info("Bulk status result = %d/n", result); */	if (result != USB_STOR_XFER_GOOD)		return USB_STOR_TRANSPORT_ERROR;	/* check bulk status */	residue = le32_to_cpu(bcs->Residue);	/* pr_info("Bulk Status S 0x%x T 0x%x R %u Stat 0x%x/n",				le32_to_cpu(bcs->Signature),				bcs->Tag, residue, bcs->Status); */	if (!(bcs->Tag == us->tag ||		(us->fflags & US_FL_BULK_IGNORE_TAG)) ||		bcs->Status > US_BULK_STAT_PHASE) {//.........这里部分代码省略.........
开发者ID:119-org,项目名称:hi3518-osdrv,代码行数:101,



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


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