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/sddr55.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/sddr55.c')
| -rw-r--r-- | drivers/usb/storage/sddr55.c | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/drivers/usb/storage/sddr55.c b/drivers/usb/storage/sddr55.c index e5e0a25ecd96..147c50b3e00f 100644 --- a/drivers/usb/storage/sddr55.c +++ b/drivers/usb/storage/sddr55.c | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | /* Driver for SanDisk SDDR-55 SmartMedia reader | 1 | /* |
| 2 | * Driver for SanDisk SDDR-55 SmartMedia reader | ||
| 2 | * | 3 | * |
| 3 | * SDDR55 driver v0.1: | 4 | * SDDR55 driver v0.1: |
| 4 | * | 5 | * |
| @@ -130,7 +131,8 @@ sddr55_bulk_transport(struct us_data *us, int direction, | |||
| 130 | return usb_stor_bulk_transfer_buf(us, pipe, data, len, NULL); | 131 | return usb_stor_bulk_transfer_buf(us, pipe, data, len, NULL); |
| 131 | } | 132 | } |
| 132 | 133 | ||
| 133 | /* check if card inserted, if there is, update read_only status | 134 | /* |
| 135 | * check if card inserted, if there is, update read_only status | ||
| 134 | * return non zero if no card | 136 | * return non zero if no card |
| 135 | */ | 137 | */ |
| 136 | 138 | ||
| @@ -714,15 +716,18 @@ static int sddr55_read_map(struct us_data *us) { | |||
| 714 | if (max_lba > 1000) | 716 | if (max_lba > 1000) |
| 715 | max_lba = 1000; | 717 | max_lba = 1000; |
| 716 | 718 | ||
| 717 | // Each block is 64 bytes of control data, so block i is located in | 719 | /* |
| 718 | // scatterlist block i*64/128k = i*(2^6)*(2^-17) = i*(2^-11) | 720 | * Each block is 64 bytes of control data, so block i is located in |
| 721 | * scatterlist block i*64/128k = i*(2^6)*(2^-17) = i*(2^-11) | ||
| 722 | */ | ||
| 719 | 723 | ||
| 720 | for (i=0; i<numblocks; i++) { | 724 | for (i=0; i<numblocks; i++) { |
| 721 | int zone = i / 1024; | 725 | int zone = i / 1024; |
| 722 | 726 | ||
| 723 | lba = short_pack(buffer[i * 2], buffer[i * 2 + 1]); | 727 | lba = short_pack(buffer[i * 2], buffer[i * 2 + 1]); |
| 724 | 728 | ||
| 725 | /* Every 1024 physical blocks ("zone"), the LBA numbers | 729 | /* |
| 730 | * Every 1024 physical blocks ("zone"), the LBA numbers | ||
| 726 | * go back to zero, but are within a higher | 731 | * go back to zero, but are within a higher |
| 727 | * block of LBA's. Also, there is a maximum of | 732 | * block of LBA's. Also, there is a maximum of |
| 728 | * 1000 LBA's per zone. In other words, in PBA | 733 | * 1000 LBA's per zone. In other words, in PBA |
| @@ -733,7 +738,8 @@ static int sddr55_read_map(struct us_data *us) { | |||
| 733 | * are 24 spare blocks to use when blocks do go bad. | 738 | * are 24 spare blocks to use when blocks do go bad. |
| 734 | */ | 739 | */ |
| 735 | 740 | ||
| 736 | /* SDDR55 returns 0xffff for a bad block, and 0x400 for the | 741 | /* |
| 742 | * SDDR55 returns 0xffff for a bad block, and 0x400 for the | ||
| 737 | * CIS block. (Is this true for cards 8MB or less??) | 743 | * CIS block. (Is this true for cards 8MB or less??) |
| 738 | * Record these in the physical to logical map | 744 | * Record these in the physical to logical map |
| 739 | */ | 745 | */ |
| @@ -824,8 +830,10 @@ static int sddr55_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
| 824 | 830 | ||
| 825 | memset (info->sense_data, 0, sizeof info->sense_data); | 831 | memset (info->sense_data, 0, sizeof info->sense_data); |
| 826 | 832 | ||
| 827 | /* Dummy up a response for INQUIRY since SDDR55 doesn't | 833 | /* |
| 828 | respond to INQUIRY commands */ | 834 | * Dummy up a response for INQUIRY since SDDR55 doesn't |
| 835 | * respond to INQUIRY commands | ||
| 836 | */ | ||
| 829 | 837 | ||
| 830 | if (srb->cmnd[0] == INQUIRY) { | 838 | if (srb->cmnd[0] == INQUIRY) { |
| 831 | memcpy(ptr, inquiry_response, 8); | 839 | memcpy(ptr, inquiry_response, 8); |
| @@ -833,7 +841,8 @@ static int sddr55_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
| 833 | return USB_STOR_TRANSPORT_GOOD; | 841 | return USB_STOR_TRANSPORT_GOOD; |
| 834 | } | 842 | } |
| 835 | 843 | ||
| 836 | /* only check card status if the map isn't allocated, ie no card seen yet | 844 | /* |
| 845 | * only check card status if the map isn't allocated, ie no card seen yet | ||
| 837 | * or if it's been over half a second since we last accessed it | 846 | * or if it's been over half a second since we last accessed it |
| 838 | */ | 847 | */ |
| 839 | if (info->lba_to_pba == NULL || time_after(jiffies, info->last_access + HZ/2)) { | 848 | if (info->lba_to_pba == NULL || time_after(jiffies, info->last_access + HZ/2)) { |
| @@ -849,8 +858,10 @@ static int sddr55_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
| 849 | } | 858 | } |
| 850 | } | 859 | } |
| 851 | 860 | ||
| 852 | /* if we detected a problem with the map when writing, | 861 | /* |
| 853 | don't allow any more access */ | 862 | * if we detected a problem with the map when writing, |
| 863 | * don't allow any more access | ||
| 864 | */ | ||
| 854 | if (info->fatal_error) { | 865 | if (info->fatal_error) { |
| 855 | 866 | ||
| 856 | set_sense_info (3, 0x31, 0); | 867 | set_sense_info (3, 0x31, 0); |
| @@ -868,12 +879,16 @@ static int sddr55_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
| 868 | 879 | ||
| 869 | info->capacity = capacity; | 880 | info->capacity = capacity; |
| 870 | 881 | ||
| 871 | /* figure out the maximum logical block number, allowing for | 882 | /* |
| 872 | * the fact that only 250 out of every 256 are used */ | 883 | * figure out the maximum logical block number, allowing for |
| 884 | * the fact that only 250 out of every 256 are used | ||
| 885 | */ | ||
| 873 | info->max_log_blks = ((info->capacity >> (info->pageshift + info->blockshift)) / 256) * 250; | 886 | info->max_log_blks = ((info->capacity >> (info->pageshift + info->blockshift)) / 256) * 250; |
| 874 | 887 | ||
| 875 | /* Last page in the card, adjust as we only use 250 out of | 888 | /* |
| 876 | * every 256 pages */ | 889 | * Last page in the card, adjust as we only use 250 out of |
| 890 | * every 256 pages | ||
| 891 | */ | ||
| 877 | capacity = (capacity / 256) * 250; | 892 | capacity = (capacity / 256) * 250; |
| 878 | 893 | ||
| 879 | capacity /= PAGESIZE; | 894 | capacity /= PAGESIZE; |
