diff options
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; |