diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-05-21 00:12:25 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-05-21 00:12:25 -0400 |
commit | 19e36ad292ab24980db64a5ff17973d3118a8fb9 (patch) | |
tree | 175715409a689814e5cd425a98f2d2d47f82addf /drivers/usb/storage/sddr09.c | |
parent | e10abc629f38efd9b6936cf3612583cc846104d9 (diff) | |
parent | 60d5794fe5a50d02f4a0df84b45910a4dfa8b487 (diff) |
Merge tag 'usb-4.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB updates from Greg KH:
"Here's the big pull request for USB and PHY drivers for 4.7-rc1
Full details in the shortlog, but it's the normal major gadget driver
updates, phy updates, new usbip code, as well as a bit of lots of
other stuff.
All have been in linux-next with no reported issues"
* tag 'usb-4.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (164 commits)
USB: serial: ti_usb_3410_5052: add MOXA UPORT 11x0 support
USB: serial: fix minor-number allocation
USB: serial: quatech2: fix use-after-free in probe error path
USB: serial: mxuport: fix use-after-free in probe error path
USB: serial: keyspan: fix debug and error messages
USB: serial: keyspan: fix URB unlink
USB: serial: keyspan: fix use-after-free in probe error path
USB: serial: io_edgeport: fix memory leaks in probe error path
USB: serial: io_edgeport: fix memory leaks in attach error path
usb: Remove unnecessary space before operator ','.
usb: Remove unnecessary space before open square bracket.
USB: FHCI: avoid redundant condition
usb: host: xhci-rcar: Avoid long wait in xhci_reset()
usb/host/fotg210: remove dead code in create_sysfs_files
usb: wusbcore: Do not initialise statics to 0.
usb: wusbcore: Remove space before ',' and '(' .
USB: serial: cp210x: clean up CRTSCTS flag code
USB: serial: cp210x: get rid of magic numbers in CRTSCTS flag code
USB: serial: cp210x: fix hardware flow-control disable
USB: serial: option: add even more ZTE device ids
...
Diffstat (limited to 'drivers/usb/storage/sddr09.c')
-rw-r--r-- | drivers/usb/storage/sddr09.c | 82 |
1 files changed, 52 insertions, 30 deletions
diff --git a/drivers/usb/storage/sddr09.c b/drivers/usb/storage/sddr09.c index 79224fcf9b59..c5797fa2125e 100644 --- a/drivers/usb/storage/sddr09.c +++ b/drivers/usb/storage/sddr09.c | |||
@@ -1,4 +1,5 @@ | |||
1 | /* Driver for SanDisk SDDR-09 SmartMedia reader | 1 | /* |
2 | * Driver for SanDisk SDDR-09 SmartMedia reader | ||
2 | * | 3 | * |
3 | * (c) 2000, 2001 Robert Baruch (autophile@starband.net) | 4 | * (c) 2000, 2001 Robert Baruch (autophile@starband.net) |
4 | * (c) 2002 Andries Brouwer (aeb@cwi.nl) | 5 | * (c) 2002 Andries Brouwer (aeb@cwi.nl) |
@@ -799,10 +800,12 @@ sddr09_read_data(struct us_data *us, | |||
799 | usb_stor_dbg(us, "Read %d zero pages (LBA %d) page %d\n", | 800 | usb_stor_dbg(us, "Read %d zero pages (LBA %d) page %d\n", |
800 | pages, lba, page); | 801 | pages, lba, page); |
801 | 802 | ||
802 | /* This is not really an error. It just means | 803 | /* |
803 | that the block has never been written. | 804 | * This is not really an error. It just means |
804 | Instead of returning an error | 805 | * that the block has never been written. |
805 | it is better to return all zero data. */ | 806 | * Instead of returning an error |
807 | * it is better to return all zero data. | ||
808 | */ | ||
806 | 809 | ||
807 | memset(buffer, 0, len); | 810 | memset(buffer, 0, len); |
808 | 811 | ||
@@ -890,8 +893,10 @@ sddr09_write_lba(struct us_data *us, unsigned int lba, | |||
890 | } | 893 | } |
891 | 894 | ||
892 | if (pba == 1) { | 895 | if (pba == 1) { |
893 | /* Maybe it is impossible to write to PBA 1. | 896 | /* |
894 | Fake success, but don't do anything. */ | 897 | * Maybe it is impossible to write to PBA 1. |
898 | * Fake success, but don't do anything. | ||
899 | */ | ||
895 | printk(KERN_WARNING "sddr09: avoid writing to pba 1\n"); | 900 | printk(KERN_WARNING "sddr09: avoid writing to pba 1\n"); |
896 | return 0; | 901 | return 0; |
897 | } | 902 | } |
@@ -979,18 +984,22 @@ sddr09_write_data(struct us_data *us, | |||
979 | struct scatterlist *sg; | 984 | struct scatterlist *sg; |
980 | int result; | 985 | int result; |
981 | 986 | ||
982 | // Figure out the initial LBA and page | 987 | /* Figure out the initial LBA and page */ |
983 | lba = address >> info->blockshift; | 988 | lba = address >> info->blockshift; |
984 | page = (address & info->blockmask); | 989 | page = (address & info->blockmask); |
985 | maxlba = info->capacity >> (info->pageshift + info->blockshift); | 990 | maxlba = info->capacity >> (info->pageshift + info->blockshift); |
986 | if (lba >= maxlba) | 991 | if (lba >= maxlba) |
987 | return -EIO; | 992 | return -EIO; |
988 | 993 | ||
989 | // blockbuffer is used for reading in the old data, overwriting | 994 | /* |
990 | // with the new data, and performing ECC calculations | 995 | * blockbuffer is used for reading in the old data, overwriting |
996 | * with the new data, and performing ECC calculations | ||
997 | */ | ||
991 | 998 | ||
992 | /* TODO: instead of doing kmalloc/kfree for each write, | 999 | /* |
993 | add a bufferpointer to the info structure */ | 1000 | * TODO: instead of doing kmalloc/kfree for each write, |
1001 | * add a bufferpointer to the info structure | ||
1002 | */ | ||
994 | 1003 | ||
995 | pagelen = (1 << info->pageshift) + (1 << CONTROL_SHIFT); | 1004 | pagelen = (1 << info->pageshift) + (1 << CONTROL_SHIFT); |
996 | blocklen = (pagelen << info->blockshift); | 1005 | blocklen = (pagelen << info->blockshift); |
@@ -1000,9 +1009,11 @@ sddr09_write_data(struct us_data *us, | |||
1000 | return -ENOMEM; | 1009 | return -ENOMEM; |
1001 | } | 1010 | } |
1002 | 1011 | ||
1003 | // Since we don't write the user data directly to the device, | 1012 | /* |
1004 | // we have to create a bounce buffer and move the data a piece | 1013 | * Since we don't write the user data directly to the device, |
1005 | // at a time between the bounce buffer and the actual transfer buffer. | 1014 | * we have to create a bounce buffer and move the data a piece |
1015 | * at a time between the bounce buffer and the actual transfer buffer. | ||
1016 | */ | ||
1006 | 1017 | ||
1007 | len = min(sectors, (unsigned int) info->blocksize) * info->pagesize; | 1018 | len = min(sectors, (unsigned int) info->blocksize) * info->pagesize; |
1008 | buffer = kmalloc(len, GFP_NOIO); | 1019 | buffer = kmalloc(len, GFP_NOIO); |
@@ -1018,7 +1029,7 @@ sddr09_write_data(struct us_data *us, | |||
1018 | 1029 | ||
1019 | while (sectors > 0) { | 1030 | while (sectors > 0) { |
1020 | 1031 | ||
1021 | // Write as many sectors as possible in this block | 1032 | /* Write as many sectors as possible in this block */ |
1022 | 1033 | ||
1023 | pages = min(sectors, info->blocksize - page); | 1034 | pages = min(sectors, info->blocksize - page); |
1024 | len = (pages << info->pageshift); | 1035 | len = (pages << info->pageshift); |
@@ -1031,7 +1042,7 @@ sddr09_write_data(struct us_data *us, | |||
1031 | break; | 1042 | break; |
1032 | } | 1043 | } |
1033 | 1044 | ||
1034 | // Get the data from the transfer buffer | 1045 | /* Get the data from the transfer buffer */ |
1035 | usb_stor_access_xfer_buf(buffer, len, us->srb, | 1046 | usb_stor_access_xfer_buf(buffer, len, us->srb, |
1036 | &sg, &offset, FROM_XFER_BUF); | 1047 | &sg, &offset, FROM_XFER_BUF); |
1037 | 1048 | ||
@@ -1168,9 +1179,11 @@ sddr09_get_cardinfo(struct us_data *us, unsigned char flags) { | |||
1168 | /* Byte 1 is the device type */ | 1179 | /* Byte 1 is the device type */ |
1169 | cardinfo = nand_find_id(deviceID[1]); | 1180 | cardinfo = nand_find_id(deviceID[1]); |
1170 | if (cardinfo) { | 1181 | if (cardinfo) { |
1171 | /* MB or MiB? It is neither. A 16 MB card has | 1182 | /* |
1172 | 17301504 raw bytes, of which 16384000 are | 1183 | * MB or MiB? It is neither. A 16 MB card has |
1173 | usable for user data. */ | 1184 | * 17301504 raw bytes, of which 16384000 are |
1185 | * usable for user data. | ||
1186 | */ | ||
1174 | sprintf(blurbtxt + strlen(blurbtxt), | 1187 | sprintf(blurbtxt + strlen(blurbtxt), |
1175 | ", %d MB", 1<<(cardinfo->chipshift - 20)); | 1188 | ", %d MB", 1<<(cardinfo->chipshift - 20)); |
1176 | } else { | 1189 | } else { |
@@ -1211,14 +1224,18 @@ sddr09_read_map(struct us_data *us) { | |||
1211 | if (!info->capacity) | 1224 | if (!info->capacity) |
1212 | return -1; | 1225 | return -1; |
1213 | 1226 | ||
1214 | // size of a block is 1 << (blockshift + pageshift) bytes | 1227 | /* |
1215 | // divide into the total capacity to get the number of blocks | 1228 | * size of a block is 1 << (blockshift + pageshift) bytes |
1229 | * divide into the total capacity to get the number of blocks | ||
1230 | */ | ||
1216 | 1231 | ||
1217 | numblocks = info->capacity >> (info->blockshift + info->pageshift); | 1232 | numblocks = info->capacity >> (info->blockshift + info->pageshift); |
1218 | 1233 | ||
1219 | // read 64 bytes for every block (actually 1 << CONTROL_SHIFT) | 1234 | /* |
1220 | // but only use a 64 KB buffer | 1235 | * read 64 bytes for every block (actually 1 << CONTROL_SHIFT) |
1221 | // buffer size used must be a multiple of (1 << CONTROL_SHIFT) | 1236 | * but only use a 64 KB buffer |
1237 | * buffer size used must be a multiple of (1 << CONTROL_SHIFT) | ||
1238 | */ | ||
1222 | #define SDDR09_READ_MAP_BUFSZ 65536 | 1239 | #define SDDR09_READ_MAP_BUFSZ 65536 |
1223 | 1240 | ||
1224 | alloc_blocks = min(numblocks, SDDR09_READ_MAP_BUFSZ >> CONTROL_SHIFT); | 1241 | alloc_blocks = min(numblocks, SDDR09_READ_MAP_BUFSZ >> CONTROL_SHIFT); |
@@ -1575,8 +1592,10 @@ static int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
1575 | 1592 | ||
1576 | havefakesense = 1; | 1593 | havefakesense = 1; |
1577 | 1594 | ||
1578 | /* Dummy up a response for INQUIRY since SDDR09 doesn't | 1595 | /* |
1579 | respond to INQUIRY commands */ | 1596 | * Dummy up a response for INQUIRY since SDDR09 doesn't |
1597 | * respond to INQUIRY commands | ||
1598 | */ | ||
1580 | 1599 | ||
1581 | if (srb->cmnd[0] == INQUIRY) { | 1600 | if (srb->cmnd[0] == INQUIRY) { |
1582 | memcpy(ptr, inquiry_response, 8); | 1601 | memcpy(ptr, inquiry_response, 8); |
@@ -1628,8 +1647,10 @@ static int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
1628 | if (srb->cmnd[0] == MODE_SENSE_10) { | 1647 | if (srb->cmnd[0] == MODE_SENSE_10) { |
1629 | int modepage = (srb->cmnd[2] & 0x3F); | 1648 | int modepage = (srb->cmnd[2] & 0x3F); |
1630 | 1649 | ||
1631 | /* They ask for the Read/Write error recovery page, | 1650 | /* |
1632 | or for all pages. */ | 1651 | * They ask for the Read/Write error recovery page, |
1652 | * or for all pages. | ||
1653 | */ | ||
1633 | /* %% We should check DBD %% */ | 1654 | /* %% We should check DBD %% */ |
1634 | if (modepage == 0x01 || modepage == 0x3F) { | 1655 | if (modepage == 0x01 || modepage == 0x3F) { |
1635 | usb_stor_dbg(us, "Dummy up request for mode page 0x%x\n", | 1656 | usb_stor_dbg(us, "Dummy up request for mode page 0x%x\n", |
@@ -1682,7 +1703,8 @@ static int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
1682 | USB_STOR_TRANSPORT_ERROR); | 1703 | USB_STOR_TRANSPORT_ERROR); |
1683 | } | 1704 | } |
1684 | 1705 | ||
1685 | /* catch-all for all other commands, except | 1706 | /* |
1707 | * catch-all for all other commands, except | ||
1686 | * pass TEST_UNIT_READY and REQUEST_SENSE through | 1708 | * pass TEST_UNIT_READY and REQUEST_SENSE through |
1687 | */ | 1709 | */ |
1688 | if (srb->cmnd[0] != TEST_UNIT_READY && | 1710 | if (srb->cmnd[0] != TEST_UNIT_READY && |