Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 15491
b: refs/heads/master
c: a6c976c
h: refs/heads/master
i:
  15489: 04c9b91
  15487: 30c37ef
v: v3
  • Loading branch information
Matthew Dharm authored and Greg Kroah-Hartman committed Jan 4, 2006
1 parent a0e570f commit 5bada98
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0dc08a357538de3d93305fbf99348663abdbf2cd
refs/heads/master: a6c976c6c4628ce0c9277c47e7545956d9d4f441
33 changes: 23 additions & 10 deletions trunk/drivers/usb/storage/sddr09.c
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,13 @@ sddr09_read_data(struct us_data *us,
unsigned int len, index, offset;
int result;

// Figure out the initial LBA and page
lba = address >> info->blockshift;
page = (address & info->blockmask);
maxlba = info->capacity >> (info->pageshift + info->blockshift);
if (lba >= maxlba)
return -EIO;

// Since we only read in one block at a time, 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.
Expand All @@ -722,11 +729,6 @@ sddr09_read_data(struct us_data *us,
return -ENOMEM;
}

// Figure out the initial LBA and page
lba = address >> info->blockshift;
page = (address & info->blockmask);
maxlba = info->capacity >> (info->pageshift + info->blockshift);

// This could be made much more efficient by checking for
// contiguous LBA's. Another exercise left to the student.

Expand Down Expand Up @@ -928,13 +930,20 @@ sddr09_write_data(struct us_data *us,
unsigned int sectors) {

struct sddr09_card_info *info = (struct sddr09_card_info *) us->extra;
unsigned int lba, page, pages;
unsigned int lba, maxlba, page, pages;
unsigned int pagelen, blocklen;
unsigned char *blockbuffer;
unsigned char *buffer;
unsigned int len, index, offset;
int result;

// Figure out the initial LBA and page
lba = address >> info->blockshift;
page = (address & info->blockmask);
maxlba = info->capacity >> (info->pageshift + info->blockshift);
if (lba >= maxlba)
return -EIO;

// blockbuffer is used for reading in the old data, overwriting
// with the new data, and performing ECC calculations

Expand All @@ -961,10 +970,6 @@ sddr09_write_data(struct us_data *us,
return -ENOMEM;
}

// Figure out the initial LBA and page
lba = address >> info->blockshift;
page = (address & info->blockmask);

result = 0;
index = offset = 0;

Expand All @@ -975,6 +980,14 @@ sddr09_write_data(struct us_data *us,
pages = min(sectors, info->blocksize - page);
len = (pages << info->pageshift);

/* Not overflowing capacity? */
if (lba >= maxlba) {
US_DEBUGP("Error: Requested lba %u exceeds "
"maximum %u\n", lba, maxlba);
result = -EIO;
break;
}

// Get the data from the transfer buffer
usb_stor_access_xfer_buf(buffer, len, us->srb,
&index, &offset, FROM_XFER_BUF);
Expand Down

0 comments on commit 5bada98

Please sign in to comment.