Exemple #1
0
/*
 * Transfer an entire SCSI command's worth of data payload over the bulk
 * pipe.
 *
 * Note that this uses usb_stor_transfer_partial to achieve its goals -- this
 * function simply determines if we're going to use scatter-gather or not,
 * and acts appropriately.  For now, it also re-interprets the error codes.
 */
void usb_stor_transfer(Scsi_Cmnd *srb, struct us_data* us)
{
	int i;
	int result = -1;
	struct scatterlist *sg;
	unsigned int total_transferred = 0;
	unsigned int transfer_amount;



	/* calculate how much we want to transfer */
	transfer_amount = usb_stor_transfer_length(srb);




	/* was someone foolish enough to request more data than available
	 * buffer space? */
	if (transfer_amount > srb->request_bufflen)
		transfer_amount = srb->request_bufflen;

	/* are we scatter-gathering? */
	if (srb->use_sg) {

		/* loop over all the scatter gather structures and 
		 * make the appropriate requests for each, until done
		 */
		sg = (struct scatterlist *) srb->request_buffer;
		for (i = 0; i < srb->use_sg; i++) {






			if (transfer_amount - total_transferred >= 
					sg[i].length) {
				result = usb_stor_transfer_partial(us,
						sg[i].address, sg[i].length);
				total_transferred += sg[i].length;
			} else
				result = usb_stor_transfer_partial(us,
						sg[i].address,
						transfer_amount - total_transferred);

			/* if we get an error, end the loop here */
			if (result)
				break;
		}

	}
	else
		/* no scatter-gather, just make the request */
		result = usb_stor_transfer_partial(us, srb->request_buffer, 
					     transfer_amount);

	/* return the result in the data structure itself */
	srb->result = result;
}
Exemple #2
0
/*
 * Transfer an entire SCSI command's worth of data payload over the bulk
 * pipe.
 *
 * Note that this uses usb_stor_transfer_partial to achieve it's goals -- this
 * function simply determines if we're going to use scatter-gather or not,
 * and acts appropriately.  For now, it also re-interprets the error codes.
 */
static void us_transfer_freecom(Scsi_Cmnd *srb, struct us_data* us, int transfer_amount)
{
	int i;
	int result = -1;
	struct scatterlist *sg;
	unsigned int total_transferred = 0;

	/* was someone foolish enough to request more data than available
	 * buffer space? */
	if (transfer_amount > srb->request_bufflen)
		transfer_amount = srb->request_bufflen;

	/* are we scatter-gathering? */
	if (srb->use_sg) {

		/* loop over all the scatter gather structures and 
		 * make the appropriate requests for each, until done
		 */
		sg = (struct scatterlist *) srb->request_buffer;
		for (i = 0; i < srb->use_sg; i++) {

			US_DEBUGP("transfer_amount: %d and total_transferred: %d\n", transfer_amount, total_transferred);

			/* End this if we're done */
			if (transfer_amount == total_transferred)
				break;

			/* transfer the lesser of the next buffer or the
			 * remaining data */
			if (transfer_amount - total_transferred >= 
					sg[i].length) {
				result = usb_stor_transfer_partial(us,
						sg[i].address, sg[i].length);
				total_transferred += sg[i].length;
			} else {
				result = usb_stor_transfer_partial(us,
						sg[i].address,
						transfer_amount - total_transferred);
				total_transferred += transfer_amount - total_transferred;
			}

			/* if we get an error, end the loop here */
			if (result)
				break;
		}
	}
	else
		/* no scatter-gather, just make the request */
		result = usb_stor_transfer_partial(us, srb->request_buffer, 
					     transfer_amount);

	/* return the result in the data structure itself */
	srb->result = result;
}
Exemple #3
0
/*
 *  Transfer an entire SCSI command's worth of data payload over the bulk pipe.
 *
 *  Note that this uses usb_stor_transfer_partial to achieve it's goals -- this
 *  function simply determines if we're going to use scatter-gather or not,
 *  and acts appropriately.  For now, it also re-interprets the error codes.
 */
static void  us_transfer(SCSI_CMD_T *srb, UMAS_DATA_T* umas)
{
    int     i;
    int     result = -1;
    uint32_t  total_transferred = 0;
    uint32_t  transfer_amount;
    SCATTER_LIST_T  *sg;

    /* calculate how much we want to transfer */
    transfer_amount = usb_stor_transfer_length(srb);

    /* Was someone foolish enough to request more data than available buffer space?  */
    if(transfer_amount > srb->request_bufflen)
        transfer_amount = srb->request_bufflen;

    /* are we scatter-gathering? */
    if(srb->use_sg)
    {
        /*
         * loop over all the scatter gather structures and
         * make the appropriate requests for each, until done
         */
        sg = (SCATTER_LIST_T *) srb->request_buff;
        for(i = 0; i < srb->use_sg; i++)
        {
            /* transfer the lesser of the next buffer or the remaining data */
            if(transfer_amount - total_transferred >= sg[i].length)
            {
                result = usb_stor_transfer_partial(umas, sg[i].address, sg[i].length);
                total_transferred += sg[i].length;
            }
            else
                result = usb_stor_transfer_partial(umas, sg[i].address,
                                                   transfer_amount - total_transferred);
            /* if we get an error, end the loop here */
            if(result)
                break;
        }
    }
    else  /* no scatter-gather, just make the request */
        result = usb_stor_transfer_partial(umas, (char *)srb->request_buff, transfer_amount);

    /* return the result in the data structure itself */
    srb->result = result;
}