udelay(110); 
udelay(125); 
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 = srb->serial_number;	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);	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(110);	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);		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) {		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);	}	/* did the attempt to read the CSW fail? */	if (result == USB_STOR_XFER_STALLED) {		/* get the status again */		US_DEBUGP("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 */	US_DEBUGP("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);	US_DEBUGP("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 != srb->serial_number || bcs->Status > US_BULK_STAT_PHASE) {		US_DEBUGP("Bulk logical error\n");		return USB_STOR_TRANSPORT_ERROR;	}	/* Some broken devices report odd signatures, so we do not check them	 * for validity against the spec. We store the first one we see,	 * and check subsequent transfers for validity against this signature.	 */	if (!us->bcs_signature) {		us->bcs_signature = bcs->Signature;		if (us->bcs_signature != cpu_to_le32(US_BULK_CS_SIGN))			US_DEBUGP("Learnt BCS signature 0x%08X\n",					le32_to_cpu(us->bcs_signature));	} else if (bcs->Signature != us->bcs_signature) {		US_DEBUGP("Signature mismatch: got %08X, expecting %08X\n",			  le32_to_cpu(bcs->Signature),			  le32_to_cpu(us->bcs_signature));		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) {		if (!(us->flags & US_FL_IGNORE_RESIDUE)) {			residue = min(residue, transfer_length);			srb->resid = max(srb->resid, (int) residue);		}	}	/* based on the status code, we report good or bad */	switch (bcs->Status) {		case US_BULK_STAT_OK:			/* device babbled -- return fake sense data */			if (fake_sense) {				memcpy(srb->sense_buffer, 				       usb_stor_sense_invalidCDB, 				       sizeof(usb_stor_sense_invalidCDB));				return USB_STOR_TRANSPORT_NO_SENSE;			}			/* 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;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/e4334fa4c5cb62f26d7e9a0a581126bcbe0dedcf/transport.c/buggy/drivers/usb/storage/transport.c