static int datafab_read_data(struct us_data *us,
struct datafab_info *info,
u32 sector,
- u32 sectors,
- unsigned char *buffer,
- int use_sg)
+ u32 sectors)
{
unsigned char *command = us->iobuf;
+ unsigned char *buffer;
unsigned char thistime;
unsigned int totallen, alloclen;
int len, result;
totallen = sectors * info->ssize;
// Since we don't read more than 64 KB at a time, we have to create
- // a bounce buffer if the transfer uses scatter-gather. We will
- // move the data a piece at a time between the bounce buffer and
- // the actual transfer buffer. If we're not using scatter-gather,
- // we can simply update the transfer buffer pointer to get the
- // same effect.
+ // a bounce buffer and move the data a piece at a time between the
+ // bounce buffer and the actual transfer buffer.
alloclen = min(totallen, 65536u);
- if (use_sg) {
- buffer = kmalloc(alloclen, GFP_NOIO);
- if (buffer == NULL)
- return USB_STOR_TRANSPORT_ERROR;
- }
+ buffer = kmalloc(alloclen, GFP_NOIO);
+ if (buffer == NULL)
+ return USB_STOR_TRANSPORT_ERROR;
do {
// loop, never allocate or transfer more than 64k at once
if (result != USB_STOR_XFER_GOOD)
goto leave;
- // Store the data (s-g) or update the pointer (!s-g)
- if (use_sg)
- usb_stor_access_xfer_buf(buffer, len, us->srb,
- &sg_idx, &sg_offset, TO_XFER_BUF);
- else
- buffer += len;
+ // Store the data in the transfer buffer
+ usb_stor_access_xfer_buf(buffer, len, us->srb,
+ &sg_idx, &sg_offset, TO_XFER_BUF);
sector += thistime;
totallen -= len;
} while (totallen > 0);
- if (use_sg)
- kfree(buffer);
+ kfree(buffer);
return USB_STOR_TRANSPORT_GOOD;
leave:
- if (use_sg)
- kfree(buffer);
+ kfree(buffer);
return USB_STOR_TRANSPORT_ERROR;
}
static int datafab_write_data(struct us_data *us,
struct datafab_info *info,
u32 sector,
- u32 sectors,
- unsigned char *buffer,
- int use_sg)
+ u32 sectors)
{
unsigned char *command = us->iobuf;
unsigned char *reply = us->iobuf;
+ unsigned char *buffer;
unsigned char thistime;
unsigned int totallen, alloclen;
int len, result;
totallen = sectors * info->ssize;
// Since we don't write more than 64 KB at a time, we have to create
- // a bounce buffer if the transfer uses scatter-gather. We will
- // move the data a piece at a time between the bounce buffer and
- // the actual transfer buffer. If we're not using scatter-gather,
- // we can simply update the transfer buffer pointer to get the
- // same effect.
+ // a bounce buffer and move the data a piece at a time between the
+ // bounce buffer and the actual transfer buffer.
alloclen = min(totallen, 65536u);
- if (use_sg) {
- buffer = kmalloc(alloclen, GFP_NOIO);
- if (buffer == NULL)
- return USB_STOR_TRANSPORT_ERROR;
- }
+ buffer = kmalloc(alloclen, GFP_NOIO);
+ if (buffer == NULL)
+ return USB_STOR_TRANSPORT_ERROR;
do {
// loop, never allocate or transfer more than 64k at once
len = min(totallen, alloclen);
thistime = (len / info->ssize) & 0xff;
- // Get the data from the transfer buffer (s-g)
- if (use_sg)
- usb_stor_access_xfer_buf(buffer, len, us->srb,
- &sg_idx, &sg_offset, FROM_XFER_BUF);
+ // Get the data from the transfer buffer
+ usb_stor_access_xfer_buf(buffer, len, us->srb,
+ &sg_idx, &sg_offset, FROM_XFER_BUF);
command[0] = 0;
command[1] = thistime;
goto leave;
}
- // Update the transfer buffer pointer (!s-g)
- if (!use_sg)
- buffer += len;
-
sector += thistime;
totallen -= len;
} while (totallen > 0);
- if (use_sg)
- kfree(buffer);
+ kfree(buffer);
return USB_STOR_TRANSPORT_GOOD;
leave:
- if (use_sg)
- kfree(buffer);
+ kfree(buffer);
return USB_STOR_TRANSPORT_ERROR;
}
blocks = ((u32)(srb->cmnd[7]) << 8) | ((u32)(srb->cmnd[8]));
US_DEBUGP("datafab_transport: READ_10: read block 0x%04lx count %ld\n", block, blocks);
- return datafab_read_data(us, info, block, blocks, ptr, srb->use_sg);
+ return datafab_read_data(us, info, block, blocks);
}
if (srb->cmnd[0] == READ_12) {
((u32)(srb->cmnd[8]) << 8) | ((u32)(srb->cmnd[9]));
US_DEBUGP("datafab_transport: READ_12: read block 0x%04lx count %ld\n", block, blocks);
- return datafab_read_data(us, info, block, blocks, ptr, srb->use_sg);
+ return datafab_read_data(us, info, block, blocks);
}
if (srb->cmnd[0] == WRITE_10) {
blocks = ((u32)(srb->cmnd[7]) << 8) | ((u32)(srb->cmnd[8]));
US_DEBUGP("datafab_transport: WRITE_10: write block 0x%04lx count %ld\n", block, blocks);
- return datafab_write_data(us, info, block, blocks, ptr, srb->use_sg);
+ return datafab_write_data(us, info, block, blocks);
}
if (srb->cmnd[0] == WRITE_12) {
((u32)(srb->cmnd[8]) << 8) | ((u32)(srb->cmnd[9]));
US_DEBUGP("datafab_transport: WRITE_12: write block 0x%04lx count %ld\n", block, blocks);
- return datafab_write_data(us, info, block, blocks, ptr, srb->use_sg);
+ return datafab_write_data(us, info, block, blocks);
}
if (srb->cmnd[0] == TEST_UNIT_READY) {
static int jumpshot_read_data(struct us_data *us,
struct jumpshot_info *info,
u32 sector,
- u32 sectors,
- unsigned char *buffer,
- int use_sg)
+ u32 sectors)
{
unsigned char *command = us->iobuf;
+ unsigned char *buffer;
unsigned char thistime;
unsigned int totallen, alloclen;
int len, result;
totallen = sectors * info->ssize;
// Since we don't read more than 64 KB at a time, we have to create
- // a bounce buffer if the transfer uses scatter-gather. We will
- // move the data a piece at a time between the bounce buffer and
- // the actual transfer buffer. If we're not using scatter-gather,
- // we can simply update the transfer buffer pointer to get the
- // same effect.
+ // a bounce buffer and move the data a piece at a time between the
+ // bounce buffer and the actual transfer buffer.
alloclen = min(totallen, 65536u);
- if (use_sg) {
- buffer = kmalloc(alloclen, GFP_NOIO);
- if (buffer == NULL)
- return USB_STOR_TRANSPORT_ERROR;
- }
+ buffer = kmalloc(alloclen, GFP_NOIO);
+ if (buffer == NULL)
+ return USB_STOR_TRANSPORT_ERROR;
do {
// loop, never allocate or transfer more than 64k at once
US_DEBUGP("jumpshot_read_data: %d bytes\n", len);
- // Store the data (s-g) or update the pointer (!s-g)
- if (use_sg)
- usb_stor_access_xfer_buf(buffer, len, us->srb,
- &sg_idx, &sg_offset, TO_XFER_BUF);
- else
- buffer += len;
+ // Store the data in the transfer buffer
+ usb_stor_access_xfer_buf(buffer, len, us->srb,
+ &sg_idx, &sg_offset, TO_XFER_BUF);
sector += thistime;
totallen -= len;
} while (totallen > 0);
- if (use_sg)
- kfree(buffer);
+ kfree(buffer);
return USB_STOR_TRANSPORT_GOOD;
leave:
- if (use_sg)
- kfree(buffer);
+ kfree(buffer);
return USB_STOR_TRANSPORT_ERROR;
}
static int jumpshot_write_data(struct us_data *us,
struct jumpshot_info *info,
u32 sector,
- u32 sectors,
- unsigned char *buffer,
- int use_sg)
+ u32 sectors)
{
unsigned char *command = us->iobuf;
+ unsigned char *buffer;
unsigned char thistime;
unsigned int totallen, alloclen;
int len, result, waitcount;
totallen = sectors * info->ssize;
// Since we don't write more than 64 KB at a time, we have to create
- // a bounce buffer if the transfer uses scatter-gather. We will
- // move the data a piece at a time between the bounce buffer and
- // the actual transfer buffer. If we're not using scatter-gather,
- // we can simply update the transfer buffer pointer to get the
- // same effect.
+ // a bounce buffer and move the data a piece at a time between the
+ // bounce buffer and the actual transfer buffer.
alloclen = min(totallen, 65536u);
- if (use_sg) {
- buffer = kmalloc(alloclen, GFP_NOIO);
- if (buffer == NULL)
- return USB_STOR_TRANSPORT_ERROR;
- }
+ buffer = kmalloc(alloclen, GFP_NOIO);
+ if (buffer == NULL)
+ return USB_STOR_TRANSPORT_ERROR;
do {
// loop, never allocate or transfer more than 64k at once
len = min(totallen, alloclen);
thistime = (len / info->ssize) & 0xff;
- // Get the data from the transfer buffer (s-g)
- if (use_sg)
- usb_stor_access_xfer_buf(buffer, len, us->srb,
- &sg_idx, &sg_offset, FROM_XFER_BUF);
+ // Get the data from the transfer buffer
+ usb_stor_access_xfer_buf(buffer, len, us->srb,
+ &sg_idx, &sg_offset, FROM_XFER_BUF);
command[0] = 0;
command[1] = thistime;
if (result != USB_STOR_TRANSPORT_GOOD)
US_DEBUGP("jumpshot_write_data: Gah! Waitcount = 10. Bad write!?\n");
- // Update the transfer buffer pointer (!s-g)
- if (!use_sg)
- buffer += len;
-
sector += thistime;
totallen -= len;
} while (totallen > 0);
- if (use_sg)
- kfree(buffer);
+ kfree(buffer);
return result;
leave:
- if (use_sg)
- kfree(buffer);
+ kfree(buffer);
return USB_STOR_TRANSPORT_ERROR;
}
blocks = ((u32)(srb->cmnd[7]) << 8) | ((u32)(srb->cmnd[8]));
US_DEBUGP("jumpshot_transport: READ_10: read block 0x%04lx count %ld\n", block, blocks);
- return jumpshot_read_data(us, info, block, blocks, ptr, srb->use_sg);
+ return jumpshot_read_data(us, info, block, blocks);
}
if (srb->cmnd[0] == READ_12) {
((u32)(srb->cmnd[8]) << 8) | ((u32)(srb->cmnd[9]));
US_DEBUGP("jumpshot_transport: READ_12: read block 0x%04lx count %ld\n", block, blocks);
- return jumpshot_read_data(us, info, block, blocks, ptr, srb->use_sg);
+ return jumpshot_read_data(us, info, block, blocks);
}
if (srb->cmnd[0] == WRITE_10) {
blocks = ((u32)(srb->cmnd[7]) << 8) | ((u32)(srb->cmnd[8]));
US_DEBUGP("jumpshot_transport: WRITE_10: write block 0x%04lx count %ld\n", block, blocks);
- return jumpshot_write_data(us, info, block, blocks, ptr, srb->use_sg);
+ return jumpshot_write_data(us, info, block, blocks);
}
if (srb->cmnd[0] == WRITE_12) {
((u32)(srb->cmnd[8]) << 8) | ((u32)(srb->cmnd[9]));
US_DEBUGP("jumpshot_transport: WRITE_12: write block 0x%04lx count %ld\n", block, blocks);
- return jumpshot_write_data(us, info, block, blocks, ptr, srb->use_sg);
+ return jumpshot_write_data(us, info, block, blocks);
}
static int
sddr09_read_data(struct us_data *us,
unsigned long address,
- unsigned int sectors,
- unsigned char *buffer,
- int use_sg) {
+ unsigned int sectors) {
struct sddr09_card_info *info = (struct sddr09_card_info *) us->extra;
+ unsigned char *buffer;
unsigned int lba, maxlba, pba;
unsigned int page, pages;
unsigned int len, index, offset;
int result;
// Since we only read in one block at a time, we have to create
- // a bounce buffer if the transfer uses scatter-gather. We will
- // move the data a piece at a time between the bounce buffer and
- // the actual transfer buffer. If we're not using scatter-gather,
- // we can simply update the transfer buffer pointer to get the
- // same effect.
-
- if (use_sg) {
- len = min(sectors, (unsigned int) info->blocksize) *
- info->pagesize;
- buffer = kmalloc(len, GFP_NOIO);
- if (buffer == NULL) {
- printk("sddr09_read_data: Out of memory\n");
- return USB_STOR_TRANSPORT_ERROR;
- }
+ // a bounce buffer and move the data a piece at a time between the
+ // bounce buffer and the actual transfer buffer.
+
+ len = min(sectors, (unsigned int) info->blocksize) * info->pagesize;
+ buffer = kmalloc(len, GFP_NOIO);
+ if (buffer == NULL) {
+ printk("sddr09_read_data: Out of memory\n");
+ return USB_STOR_TRANSPORT_ERROR;
}
// Figure out the initial LBA and page
break;
}
- // Store the data (s-g) or update the pointer (!s-g)
- if (use_sg)
- usb_stor_access_xfer_buf(buffer, len, us->srb,
- &index, &offset, TO_XFER_BUF);
- else
- buffer += len;
+ // Store the data in the transfer buffer
+ usb_stor_access_xfer_buf(buffer, len, us->srb,
+ &index, &offset, TO_XFER_BUF);
page = 0;
lba++;
sectors -= pages;
}
- if (use_sg)
- kfree(buffer);
-
+ kfree(buffer);
return result;
}
static int
sddr09_write_data(struct us_data *us,
unsigned long address,
- unsigned int sectors,
- unsigned char *buffer,
- int use_sg) {
+ unsigned int sectors) {
struct sddr09_card_info *info = (struct sddr09_card_info *) us->extra;
unsigned int lba, page, pages;
unsigned int pagelen, blocklen;
unsigned char *blockbuffer;
+ unsigned char *buffer;
unsigned int len, index, offset;
int result;
}
// Since we don't write the user data directly to the device,
- // we have to create a bounce buffer if the transfer uses
- // scatter-gather. We will move the data a piece at a time
- // between the bounce buffer and the actual transfer buffer.
- // If we're not using scatter-gather, we can simply update
- // the transfer buffer pointer to get the same effect.
-
- if (use_sg) {
- len = min(sectors, (unsigned int) info->blocksize) *
- info->pagesize;
- buffer = kmalloc(len, GFP_NOIO);
- if (buffer == NULL) {
- printk("sddr09_write_data: Out of memory\n");
- kfree(blockbuffer);
- return USB_STOR_TRANSPORT_ERROR;
- }
+ // we have to create a bounce buffer and move the data a piece
+ // at a time between the bounce buffer and the actual transfer buffer.
+
+ len = min(sectors, (unsigned int) info->blocksize) * info->pagesize;
+ buffer = kmalloc(len, GFP_NOIO);
+ if (buffer == NULL) {
+ printk("sddr09_write_data: Out of memory\n");
+ kfree(blockbuffer);
+ return USB_STOR_TRANSPORT_ERROR;
}
// Figure out the initial LBA and page
pages = min(sectors, info->blocksize - page);
len = (pages << info->pageshift);
- // Get the data from the transfer buffer (s-g)
- if (use_sg)
- usb_stor_access_xfer_buf(buffer, len, us->srb,
- &index, &offset, FROM_XFER_BUF);
+ // Get the data from the transfer buffer
+ usb_stor_access_xfer_buf(buffer, len, us->srb,
+ &index, &offset, FROM_XFER_BUF);
result = sddr09_write_lba(us, lba, page, pages,
buffer, blockbuffer);
if (result != USB_STOR_TRANSPORT_GOOD)
break;
- // Update the transfer buffer pointer (!s-g)
- if (!use_sg)
- buffer += len;
-
page = 0;
lba++;
sectors -= pages;
}
- if (use_sg)
- kfree(buffer);
+ kfree(buffer);
kfree(blockbuffer);
return result;
US_DEBUGP("READ_10: read page %d pagect %d\n",
page, pages);
- return sddr09_read_data(us, page, pages, ptr, srb->use_sg);
+ return sddr09_read_data(us, page, pages);
}
if (srb->cmnd[0] == WRITE_10) {
US_DEBUGP("WRITE_10: write page %d pagect %d\n",
page, pages);
- return sddr09_write_data(us, page, pages, ptr, srb->use_sg);
+ return sddr09_write_data(us, page, pages);
}
// Pass TEST_UNIT_READY and REQUEST_SENSE through
static int sddr55_read_data(struct us_data *us,
unsigned int lba,
unsigned int page,
- unsigned short sectors,
- unsigned char *buffer,
- int use_sg) {
+ unsigned short sectors) {
int result = USB_STOR_TRANSPORT_GOOD;
unsigned char *command = us->iobuf;
unsigned char *status = us->iobuf;
struct sddr55_card_info *info = (struct sddr55_card_info *)us->extra;
+ unsigned char *buffer;
unsigned int pba;
unsigned long address;
unsigned int len, index, offset;
// Since we only read in one block at a time, we have to create
- // a bounce buffer if the transfer uses scatter-gather. We will
- // move the data a piece at a time between the bounce buffer and
- // the actual transfer buffer. If we're not using scatter-gather,
- // we can simply update the transfer buffer pointer to get the
- // same effect.
-
- if (use_sg) {
- len = min((unsigned int) sectors,
- (unsigned int) info->blocksize >>
- info->smallpageshift) * PAGESIZE;
- buffer = kmalloc(len, GFP_NOIO);
- if (buffer == NULL)
- return USB_STOR_TRANSPORT_ERROR; /* out of memory */
- }
+ // a bounce buffer and move the data a piece at a time between the
+ // bounce buffer and the actual transfer buffer.
+
+ len = min((unsigned int) sectors, (unsigned int) info->blocksize >>
+ info->smallpageshift) * PAGESIZE;
+ buffer = kmalloc(len, GFP_NOIO);
+ if (buffer == NULL)
+ return USB_STOR_TRANSPORT_ERROR; /* out of memory */
index = offset = 0;
while (sectors>0) {
}
}
- // Store the data (s-g) or update the pointer (!s-g)
- if (use_sg)
- usb_stor_access_xfer_buf(buffer, len, us->srb,
- &index, &offset, TO_XFER_BUF);
- else
- buffer += len;
+ // Store the data in the transfer buffer
+ usb_stor_access_xfer_buf(buffer, len, us->srb,
+ &index, &offset, TO_XFER_BUF);
page = 0;
lba++;
result = USB_STOR_TRANSPORT_GOOD;
leave:
- if (use_sg)
- kfree(buffer);
+ kfree(buffer);
return result;
}
static int sddr55_write_data(struct us_data *us,
unsigned int lba,
unsigned int page,
- unsigned short sectors,
- unsigned char *buffer,
- int use_sg) {
+ unsigned short sectors) {
int result = USB_STOR_TRANSPORT_GOOD;
unsigned char *command = us->iobuf;
unsigned char *status = us->iobuf;
struct sddr55_card_info *info = (struct sddr55_card_info *)us->extra;
+ unsigned char *buffer;
unsigned int pba;
unsigned int new_pba;
}
// Since we only write one block at a time, we have to create
- // a bounce buffer if the transfer uses scatter-gather. We will
- // move the data a piece at a time between the bounce buffer and
- // the actual transfer buffer. If we're not using scatter-gather,
- // we can simply update the transfer buffer pointer to get the
- // same effect.
-
- if (use_sg) {
- len = min((unsigned int) sectors,
- (unsigned int) info->blocksize >>
- info->smallpageshift) * PAGESIZE;
- buffer = kmalloc(len, GFP_NOIO);
- if (buffer == NULL)
- return USB_STOR_TRANSPORT_ERROR;
- }
+ // a bounce buffer and move the data a piece at a time between the
+ // bounce buffer and the actual transfer buffer.
+
+ len = min((unsigned int) sectors, (unsigned int) info->blocksize >>
+ info->smallpageshift) * PAGESIZE;
+ buffer = kmalloc(len, GFP_NOIO);
+ if (buffer == NULL)
+ return USB_STOR_TRANSPORT_ERROR;
index = offset = 0;
while (sectors > 0) {
info->blocksize - page);
len = pages << info->pageshift;
- // Get the data from the transfer buffer (s-g)
- if (use_sg)
- usb_stor_access_xfer_buf(buffer, len, us->srb,
- &index, &offset, FROM_XFER_BUF);
+ // Get the data from the transfer buffer
+ usb_stor_access_xfer_buf(buffer, len, us->srb,
+ &index, &offset, FROM_XFER_BUF);
US_DEBUGP("Write %02X pages, to PBA %04X"
" (LBA %04X) page %02X\n",
/* update the pba<->lba maps for new_pba */
info->pba_to_lba[new_pba] = lba % 1000;
- // Update the transfer buffer pointer (!s-g)
- if (!use_sg)
- buffer += len;
page = 0;
lba++;
sectors -= pages >> info->smallpageshift;
result = USB_STOR_TRANSPORT_GOOD;
leave:
- if (use_sg)
- kfree(buffer);
+ kfree(buffer);
return result;
}
" pages %d\n",
pba, lba, page, pages);
- return sddr55_write_data(us, lba, page, pages, ptr, srb->use_sg);
+ return sddr55_write_data(us, lba, page, pages);
} else {
US_DEBUGP("READ_10: read block %04X (LBA %04X) page %01X"
" pages %d\n",
pba, lba, page, pages);
- return sddr55_read_data(us, lba, page, pages, ptr, srb->use_sg);
+ return sddr55_read_data(us, lba, page, pages);
}
}
}
// Since we only read in one block at a time, we have to create
- // a bounce buffer if the transfer uses scatter-gather. We will
- // move the data a piece at a time between the bounce buffer and
- // the actual transfer buffer. If we're not using scatter-gather,
- // we can simply update the transfer buffer pointer to get the
- // same effect.
+ // a bounce buffer and move the data a piece at a time between the
+ // bounce buffer and the actual transfer buffer.
len = (65535/srb->transfersize) * srb->transfersize;
US_DEBUGP("Max read is %d bytes\n", len);
len = min(len, srb->request_bufflen);
- if (srb->use_sg) {
- buffer = kmalloc(len, GFP_NOIO);
- if (buffer == NULL) // bloody hell!
- return USB_STOR_TRANSPORT_FAILED;
- } else
- buffer = srb->request_buffer;
+ buffer = kmalloc(len, GFP_NOIO);
+ if (buffer == NULL) // bloody hell!
+ return USB_STOR_TRANSPORT_FAILED;
sector = short_pack(data[7+3], data[7+2]);
sector <<= 16;
sector |= short_pack(data[7+5], data[7+4]);
if (result != USB_STOR_TRANSPORT_GOOD)
break;
- // Store the data (s-g) or update the pointer (!s-g)
- if (srb->use_sg)
- usb_stor_access_xfer_buf(buffer, len, srb,
- &sg_segment, &sg_offset, TO_XFER_BUF);
- else
- buffer += len;
+ // Store the data in the transfer buffer
+ usb_stor_access_xfer_buf(buffer, len, srb,
+ &sg_segment, &sg_offset, TO_XFER_BUF);
// Update the amount transferred and the sector number
} // while transferred != srb->request_bufflen
- if (srb->use_sg)
- kfree(buffer);
+ kfree(buffer);
return result;
}