diff options
35 files changed, 152 insertions, 135 deletions
diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c index 6659a90dbcad..8b079f9d6924 100644 --- a/arch/arm/mach-davinci/board-da850-evm.c +++ b/arch/arm/mach-davinci/board-da850-evm.c | |||
@@ -127,7 +127,7 @@ static void da850_evm_m25p80_notify_add(struct mtd_info *mtd) | |||
127 | size_t retlen; | 127 | size_t retlen; |
128 | 128 | ||
129 | if (!strcmp(mtd->name, "MAC-Address")) { | 129 | if (!strcmp(mtd->name, "MAC-Address")) { |
130 | mtd->read(mtd, 0, ETH_ALEN, &retlen, mac_addr); | 130 | mtd_read(mtd, 0, ETH_ALEN, &retlen, mac_addr); |
131 | if (retlen == ETH_ALEN) | 131 | if (retlen == ETH_ALEN) |
132 | pr_info("Read MAC addr from SPI Flash: %pM\n", | 132 | pr_info("Read MAC addr from SPI Flash: %pM\n", |
133 | mac_addr); | 133 | mac_addr); |
diff --git a/arch/cris/arch-v32/drivers/axisflashmap.c b/arch/cris/arch-v32/drivers/axisflashmap.c index a2bde3744622..011bddbf073f 100644 --- a/arch/cris/arch-v32/drivers/axisflashmap.c +++ b/arch/cris/arch-v32/drivers/axisflashmap.c | |||
@@ -413,8 +413,8 @@ static int __init init_axis_flash(void) | |||
413 | } while (blockstat && ptable_sector); | 413 | } while (blockstat && ptable_sector); |
414 | #endif | 414 | #endif |
415 | if (ptable_sector) { | 415 | if (ptable_sector) { |
416 | main_mtd->read(main_mtd, ptable_sector, PAGESIZE, | 416 | mtd_read(main_mtd, ptable_sector, PAGESIZE, &len, |
417 | &len, page); | 417 | page); |
418 | ptable_head = &((struct partitiontable *) page)->head; | 418 | ptable_head = &((struct partitiontable *) page)->head; |
419 | } | 419 | } |
420 | 420 | ||
diff --git a/drivers/mtd/afs.c b/drivers/mtd/afs.c index 89a02f6f65dc..5a3942bf109c 100644 --- a/drivers/mtd/afs.c +++ b/drivers/mtd/afs.c | |||
@@ -75,7 +75,7 @@ afs_read_footer(struct mtd_info *mtd, u_int *img_start, u_int *iis_start, | |||
75 | size_t sz; | 75 | size_t sz; |
76 | int ret; | 76 | int ret; |
77 | 77 | ||
78 | ret = mtd->read(mtd, ptr, sizeof(fs), &sz, (u_char *) &fs); | 78 | ret = mtd_read(mtd, ptr, sizeof(fs), &sz, (u_char *)&fs); |
79 | if (ret >= 0 && sz != sizeof(fs)) | 79 | if (ret >= 0 && sz != sizeof(fs)) |
80 | ret = -EINVAL; | 80 | ret = -EINVAL; |
81 | 81 | ||
@@ -132,7 +132,7 @@ afs_read_iis(struct mtd_info *mtd, struct image_info_struct *iis, u_int ptr) | |||
132 | int ret, i; | 132 | int ret, i; |
133 | 133 | ||
134 | memset(iis, 0, sizeof(*iis)); | 134 | memset(iis, 0, sizeof(*iis)); |
135 | ret = mtd->read(mtd, ptr, sizeof(*iis), &sz, (u_char *) iis); | 135 | ret = mtd_read(mtd, ptr, sizeof(*iis), &sz, (u_char *)iis); |
136 | if (ret < 0) | 136 | if (ret < 0) |
137 | goto failed; | 137 | goto failed; |
138 | 138 | ||
diff --git a/drivers/mtd/ar7part.c b/drivers/mtd/ar7part.c index f40ea4547554..945393129952 100644 --- a/drivers/mtd/ar7part.c +++ b/drivers/mtd/ar7part.c | |||
@@ -73,8 +73,8 @@ static int create_mtd_partitions(struct mtd_info *master, | |||
73 | 73 | ||
74 | do { /* Try 10 blocks starting from master->erasesize */ | 74 | do { /* Try 10 blocks starting from master->erasesize */ |
75 | offset = pre_size; | 75 | offset = pre_size; |
76 | master->read(master, offset, | 76 | mtd_read(master, offset, sizeof(header), &len, |
77 | sizeof(header), &len, (uint8_t *)&header); | 77 | (uint8_t *)&header); |
78 | if (!strncmp((char *)&header, "TIENV0.8", 8)) | 78 | if (!strncmp((char *)&header, "TIENV0.8", 8)) |
79 | ar7_parts[1].offset = pre_size; | 79 | ar7_parts[1].offset = pre_size; |
80 | if (header.checksum == LOADER_MAGIC1) | 80 | if (header.checksum == LOADER_MAGIC1) |
@@ -95,16 +95,16 @@ static int create_mtd_partitions(struct mtd_info *master, | |||
95 | case LOADER_MAGIC1: | 95 | case LOADER_MAGIC1: |
96 | while (header.length) { | 96 | while (header.length) { |
97 | offset += sizeof(header) + header.length; | 97 | offset += sizeof(header) + header.length; |
98 | master->read(master, offset, sizeof(header), | 98 | mtd_read(master, offset, sizeof(header), &len, |
99 | &len, (uint8_t *)&header); | 99 | (uint8_t *)&header); |
100 | } | 100 | } |
101 | root_offset = offset + sizeof(header) + 4; | 101 | root_offset = offset + sizeof(header) + 4; |
102 | break; | 102 | break; |
103 | case LOADER_MAGIC2: | 103 | case LOADER_MAGIC2: |
104 | while (header.length) { | 104 | while (header.length) { |
105 | offset += sizeof(header) + header.length; | 105 | offset += sizeof(header) + header.length; |
106 | master->read(master, offset, sizeof(header), | 106 | mtd_read(master, offset, sizeof(header), &len, |
107 | &len, (uint8_t *)&header); | 107 | (uint8_t *)&header); |
108 | } | 108 | } |
109 | root_offset = offset + sizeof(header) + 4 + 0xff; | 109 | root_offset = offset + sizeof(header) + 4 + 0xff; |
110 | root_offset &= ~(uint32_t)0xff; | 110 | root_offset &= ~(uint32_t)0xff; |
@@ -114,8 +114,7 @@ static int create_mtd_partitions(struct mtd_info *master, | |||
114 | break; | 114 | break; |
115 | } | 115 | } |
116 | 116 | ||
117 | master->read(master, root_offset, | 117 | mtd_read(master, root_offset, sizeof(header), &len, (u8 *)&header); |
118 | sizeof(header), &len, (u8 *)&header); | ||
119 | if (header.checksum != SQUASHFS_MAGIC) { | 118 | if (header.checksum != SQUASHFS_MAGIC) { |
120 | root_offset += master->erasesize - 1; | 119 | root_offset += master->erasesize - 1; |
121 | root_offset &= ~(master->erasesize - 1); | 120 | root_offset &= ~(master->erasesize - 1); |
diff --git a/drivers/mtd/bcm63xxpart.c b/drivers/mtd/bcm63xxpart.c index 9ee8bc426e93..608321ee056e 100644 --- a/drivers/mtd/bcm63xxpart.c +++ b/drivers/mtd/bcm63xxpart.c | |||
@@ -48,8 +48,8 @@ static int bcm63xx_detect_cfe(struct mtd_info *master) | |||
48 | int ret; | 48 | int ret; |
49 | size_t retlen; | 49 | size_t retlen; |
50 | 50 | ||
51 | ret = master->read(master, BCM963XX_CFE_VERSION_OFFSET, 5, &retlen, | 51 | ret = mtd_read(master, BCM963XX_CFE_VERSION_OFFSET, 5, &retlen, |
52 | (void *)buf); | 52 | (void *)buf); |
53 | buf[retlen] = 0; | 53 | buf[retlen] = 0; |
54 | 54 | ||
55 | if (ret) | 55 | if (ret) |
@@ -59,8 +59,8 @@ static int bcm63xx_detect_cfe(struct mtd_info *master) | |||
59 | return 0; | 59 | return 0; |
60 | 60 | ||
61 | /* very old CFE's do not have the cfe-v string, so check for magic */ | 61 | /* very old CFE's do not have the cfe-v string, so check for magic */ |
62 | ret = master->read(master, BCM63XX_CFE_MAGIC_OFFSET, 8, &retlen, | 62 | ret = mtd_read(master, BCM63XX_CFE_MAGIC_OFFSET, 8, &retlen, |
63 | (void *)buf); | 63 | (void *)buf); |
64 | buf[retlen] = 0; | 64 | buf[retlen] = 0; |
65 | 65 | ||
66 | return strncmp("CFE1CFE1", buf, 8); | 66 | return strncmp("CFE1CFE1", buf, 8); |
@@ -95,8 +95,8 @@ static int bcm63xx_parse_cfe_partitions(struct mtd_info *master, | |||
95 | return -ENOMEM; | 95 | return -ENOMEM; |
96 | 96 | ||
97 | /* Get the tag */ | 97 | /* Get the tag */ |
98 | ret = master->read(master, cfelen, sizeof(struct bcm_tag), &retlen, | 98 | ret = mtd_read(master, cfelen, sizeof(struct bcm_tag), &retlen, |
99 | (void *)buf); | 99 | (void *)buf); |
100 | 100 | ||
101 | if (retlen != sizeof(struct bcm_tag)) { | 101 | if (retlen != sizeof(struct bcm_tag)) { |
102 | vfree(buf); | 102 | vfree(buf); |
diff --git a/drivers/mtd/ftl.c b/drivers/mtd/ftl.c index a982889277c8..12fd7ebd3fd8 100644 --- a/drivers/mtd/ftl.c +++ b/drivers/mtd/ftl.c | |||
@@ -168,8 +168,8 @@ static int scan_header(partition_t *part) | |||
168 | (offset + sizeof(header)) < max_offset; | 168 | (offset + sizeof(header)) < max_offset; |
169 | offset += part->mbd.mtd->erasesize ? : 0x2000) { | 169 | offset += part->mbd.mtd->erasesize ? : 0x2000) { |
170 | 170 | ||
171 | err = part->mbd.mtd->read(part->mbd.mtd, offset, sizeof(header), &ret, | 171 | err = mtd_read(part->mbd.mtd, offset, sizeof(header), &ret, |
172 | (unsigned char *)&header); | 172 | (unsigned char *)&header); |
173 | 173 | ||
174 | if (err) | 174 | if (err) |
175 | return err; | 175 | return err; |
@@ -224,8 +224,8 @@ static int build_maps(partition_t *part) | |||
224 | for (i = 0; i < le16_to_cpu(part->header.NumEraseUnits); i++) { | 224 | for (i = 0; i < le16_to_cpu(part->header.NumEraseUnits); i++) { |
225 | offset = ((i + le16_to_cpu(part->header.FirstPhysicalEUN)) | 225 | offset = ((i + le16_to_cpu(part->header.FirstPhysicalEUN)) |
226 | << part->header.EraseUnitSize); | 226 | << part->header.EraseUnitSize); |
227 | ret = part->mbd.mtd->read(part->mbd.mtd, offset, sizeof(header), &retval, | 227 | ret = mtd_read(part->mbd.mtd, offset, sizeof(header), &retval, |
228 | (unsigned char *)&header); | 228 | (unsigned char *)&header); |
229 | 229 | ||
230 | if (ret) | 230 | if (ret) |
231 | goto out_XferInfo; | 231 | goto out_XferInfo; |
@@ -289,9 +289,9 @@ static int build_maps(partition_t *part) | |||
289 | part->EUNInfo[i].Deleted = 0; | 289 | part->EUNInfo[i].Deleted = 0; |
290 | offset = part->EUNInfo[i].Offset + le32_to_cpu(header.BAMOffset); | 290 | offset = part->EUNInfo[i].Offset + le32_to_cpu(header.BAMOffset); |
291 | 291 | ||
292 | ret = part->mbd.mtd->read(part->mbd.mtd, offset, | 292 | ret = mtd_read(part->mbd.mtd, offset, |
293 | part->BlocksPerUnit * sizeof(uint32_t), &retval, | 293 | part->BlocksPerUnit * sizeof(uint32_t), &retval, |
294 | (unsigned char *)part->bam_cache); | 294 | (unsigned char *)part->bam_cache); |
295 | 295 | ||
296 | if (ret) | 296 | if (ret) |
297 | goto out_bam_cache; | 297 | goto out_bam_cache; |
@@ -485,9 +485,9 @@ static int copy_erase_unit(partition_t *part, uint16_t srcunit, | |||
485 | 485 | ||
486 | offset = eun->Offset + le32_to_cpu(part->header.BAMOffset); | 486 | offset = eun->Offset + le32_to_cpu(part->header.BAMOffset); |
487 | 487 | ||
488 | ret = part->mbd.mtd->read(part->mbd.mtd, offset, | 488 | ret = mtd_read(part->mbd.mtd, offset, |
489 | part->BlocksPerUnit * sizeof(uint32_t), | 489 | part->BlocksPerUnit * sizeof(uint32_t), &retlen, |
490 | &retlen, (u_char *) (part->bam_cache)); | 490 | (u_char *)(part->bam_cache)); |
491 | 491 | ||
492 | /* mark the cache bad, in case we get an error later */ | 492 | /* mark the cache bad, in case we get an error later */ |
493 | part->bam_index = 0xffff; | 493 | part->bam_index = 0xffff; |
@@ -523,8 +523,8 @@ static int copy_erase_unit(partition_t *part, uint16_t srcunit, | |||
523 | break; | 523 | break; |
524 | case BLOCK_DATA: | 524 | case BLOCK_DATA: |
525 | case BLOCK_REPLACEMENT: | 525 | case BLOCK_REPLACEMENT: |
526 | ret = part->mbd.mtd->read(part->mbd.mtd, src, SECTOR_SIZE, | 526 | ret = mtd_read(part->mbd.mtd, src, SECTOR_SIZE, &retlen, |
527 | &retlen, (u_char *) buf); | 527 | (u_char *)buf); |
528 | if (ret) { | 528 | if (ret) { |
529 | printk(KERN_WARNING "ftl: Error reading old xfer unit in copy_erase_unit\n"); | 529 | printk(KERN_WARNING "ftl: Error reading old xfer unit in copy_erase_unit\n"); |
530 | return ret; | 530 | return ret; |
@@ -747,10 +747,11 @@ static uint32_t find_free(partition_t *part) | |||
747 | /* Invalidate cache */ | 747 | /* Invalidate cache */ |
748 | part->bam_index = 0xffff; | 748 | part->bam_index = 0xffff; |
749 | 749 | ||
750 | ret = part->mbd.mtd->read(part->mbd.mtd, | 750 | ret = mtd_read(part->mbd.mtd, |
751 | part->EUNInfo[eun].Offset + le32_to_cpu(part->header.BAMOffset), | 751 | part->EUNInfo[eun].Offset + le32_to_cpu(part->header.BAMOffset), |
752 | part->BlocksPerUnit * sizeof(uint32_t), | 752 | part->BlocksPerUnit * sizeof(uint32_t), |
753 | &retlen, (u_char *) (part->bam_cache)); | 753 | &retlen, |
754 | (u_char *)(part->bam_cache)); | ||
754 | 755 | ||
755 | if (ret) { | 756 | if (ret) { |
756 | printk(KERN_WARNING"ftl: Error reading BAM in find_free\n"); | 757 | printk(KERN_WARNING"ftl: Error reading BAM in find_free\n"); |
@@ -810,8 +811,8 @@ static int ftl_read(partition_t *part, caddr_t buffer, | |||
810 | else { | 811 | else { |
811 | offset = (part->EUNInfo[log_addr / bsize].Offset | 812 | offset = (part->EUNInfo[log_addr / bsize].Offset |
812 | + (log_addr % bsize)); | 813 | + (log_addr % bsize)); |
813 | ret = part->mbd.mtd->read(part->mbd.mtd, offset, SECTOR_SIZE, | 814 | ret = mtd_read(part->mbd.mtd, offset, SECTOR_SIZE, &retlen, |
814 | &retlen, (u_char *) buffer); | 815 | (u_char *)buffer); |
815 | 816 | ||
816 | if (ret) { | 817 | if (ret) { |
817 | printk(KERN_WARNING "Error reading MTD device in ftl_read()\n"); | 818 | printk(KERN_WARNING "Error reading MTD device in ftl_read()\n"); |
@@ -849,8 +850,8 @@ static int set_bam_entry(partition_t *part, uint32_t log_addr, | |||
849 | le32_to_cpu(part->header.BAMOffset)); | 850 | le32_to_cpu(part->header.BAMOffset)); |
850 | 851 | ||
851 | #ifdef PSYCHO_DEBUG | 852 | #ifdef PSYCHO_DEBUG |
852 | ret = part->mbd.mtd->read(part->mbd.mtd, offset, sizeof(uint32_t), | 853 | ret = mtd_read(part->mbd.mtd, offset, sizeof(uint32_t), &retlen, |
853 | &retlen, (u_char *)&old_addr); | 854 | (u_char *)&old_addr); |
854 | if (ret) { | 855 | if (ret) { |
855 | printk(KERN_WARNING"ftl: Error reading old_addr in set_bam_entry: %d\n",ret); | 856 | printk(KERN_WARNING"ftl: Error reading old_addr in set_bam_entry: %d\n",ret); |
856 | return ret; | 857 | return ret; |
diff --git a/drivers/mtd/inftlcore.c b/drivers/mtd/inftlcore.c index dd034efd1875..0b038bed7b9c 100644 --- a/drivers/mtd/inftlcore.c +++ b/drivers/mtd/inftlcore.c | |||
@@ -343,14 +343,17 @@ static u16 INFTL_foldchain(struct INFTLrecord *inftl, unsigned thisVUC, unsigned | |||
343 | if (BlockMap[block] == BLOCK_NIL) | 343 | if (BlockMap[block] == BLOCK_NIL) |
344 | continue; | 344 | continue; |
345 | 345 | ||
346 | ret = mtd->read(mtd, (inftl->EraseSize * BlockMap[block]) + | 346 | ret = mtd_read(mtd, |
347 | (block * SECTORSIZE), SECTORSIZE, &retlen, | 347 | (inftl->EraseSize * BlockMap[block]) + (block * SECTORSIZE), |
348 | movebuf); | 348 | SECTORSIZE, |
349 | &retlen, | ||
350 | movebuf); | ||
349 | if (ret < 0 && !mtd_is_bitflip(ret)) { | 351 | if (ret < 0 && !mtd_is_bitflip(ret)) { |
350 | ret = mtd->read(mtd, | 352 | ret = mtd_read(mtd, |
351 | (inftl->EraseSize * BlockMap[block]) + | 353 | (inftl->EraseSize * BlockMap[block]) + (block * SECTORSIZE), |
352 | (block * SECTORSIZE), SECTORSIZE, | 354 | SECTORSIZE, |
353 | &retlen, movebuf); | 355 | &retlen, |
356 | movebuf); | ||
354 | if (ret != -EIO) | 357 | if (ret != -EIO) |
355 | pr_debug("INFTL: error went away on retry?\n"); | 358 | pr_debug("INFTL: error went away on retry?\n"); |
356 | } | 359 | } |
@@ -914,7 +917,7 @@ foundit: | |||
914 | } else { | 917 | } else { |
915 | size_t retlen; | 918 | size_t retlen; |
916 | loff_t ptr = (thisEUN * inftl->EraseSize) + blockofs; | 919 | loff_t ptr = (thisEUN * inftl->EraseSize) + blockofs; |
917 | int ret = mtd->read(mtd, ptr, SECTORSIZE, &retlen, buffer); | 920 | int ret = mtd_read(mtd, ptr, SECTORSIZE, &retlen, buffer); |
918 | 921 | ||
919 | /* Handle corrected bit flips gracefully */ | 922 | /* Handle corrected bit flips gracefully */ |
920 | if (ret < 0 && !mtd_is_bitflip(ret)) | 923 | if (ret < 0 && !mtd_is_bitflip(ret)) |
diff --git a/drivers/mtd/inftlmount.c b/drivers/mtd/inftlmount.c index 0d946f10a682..9bfbca5d88d6 100644 --- a/drivers/mtd/inftlmount.c +++ b/drivers/mtd/inftlmount.c | |||
@@ -73,8 +73,8 @@ static int find_boot_record(struct INFTLrecord *inftl) | |||
73 | * Check for BNAND header first. Then whinge if it's found | 73 | * Check for BNAND header first. Then whinge if it's found |
74 | * but later checks fail. | 74 | * but later checks fail. |
75 | */ | 75 | */ |
76 | ret = mtd->read(mtd, block * inftl->EraseSize, | 76 | ret = mtd_read(mtd, block * inftl->EraseSize, SECTORSIZE, |
77 | SECTORSIZE, &retlen, buf); | 77 | &retlen, buf); |
78 | /* We ignore ret in case the ECC of the MediaHeader is invalid | 78 | /* We ignore ret in case the ECC of the MediaHeader is invalid |
79 | (which is apparently acceptable) */ | 79 | (which is apparently acceptable) */ |
80 | if (retlen != SECTORSIZE) { | 80 | if (retlen != SECTORSIZE) { |
@@ -118,8 +118,8 @@ static int find_boot_record(struct INFTLrecord *inftl) | |||
118 | memcpy(mh, buf, sizeof(struct INFTLMediaHeader)); | 118 | memcpy(mh, buf, sizeof(struct INFTLMediaHeader)); |
119 | 119 | ||
120 | /* Read the spare media header at offset 4096 */ | 120 | /* Read the spare media header at offset 4096 */ |
121 | mtd->read(mtd, block * inftl->EraseSize + 4096, | 121 | mtd_read(mtd, block * inftl->EraseSize + 4096, SECTORSIZE, |
122 | SECTORSIZE, &retlen, buf); | 122 | &retlen, buf); |
123 | if (retlen != SECTORSIZE) { | 123 | if (retlen != SECTORSIZE) { |
124 | printk(KERN_WARNING "INFTL: Unable to read spare " | 124 | printk(KERN_WARNING "INFTL: Unable to read spare " |
125 | "Media Header\n"); | 125 | "Media Header\n"); |
@@ -342,7 +342,7 @@ static int check_free_sectors(struct INFTLrecord *inftl, unsigned int address, | |||
342 | int i; | 342 | int i; |
343 | 343 | ||
344 | for (i = 0; i < len; i += SECTORSIZE) { | 344 | for (i = 0; i < len; i += SECTORSIZE) { |
345 | if (mtd->read(mtd, address, SECTORSIZE, &retlen, buf)) | 345 | if (mtd_read(mtd, address, SECTORSIZE, &retlen, buf)) |
346 | return -1; | 346 | return -1; |
347 | if (memcmpb(buf, 0xff, SECTORSIZE) != 0) | 347 | if (memcmpb(buf, 0xff, SECTORSIZE) != 0) |
348 | return -1; | 348 | return -1; |
diff --git a/drivers/mtd/mtdblock.c b/drivers/mtd/mtdblock.c index 9b01cb0266e4..b0644d2d2a6e 100644 --- a/drivers/mtd/mtdblock.c +++ b/drivers/mtd/mtdblock.c | |||
@@ -184,8 +184,8 @@ static int do_cached_write (struct mtdblk_dev *mtdblk, unsigned long pos, | |||
184 | mtdblk->cache_offset != sect_start) { | 184 | mtdblk->cache_offset != sect_start) { |
185 | /* fill the cache with the current sector */ | 185 | /* fill the cache with the current sector */ |
186 | mtdblk->cache_state = STATE_EMPTY; | 186 | mtdblk->cache_state = STATE_EMPTY; |
187 | ret = mtd->read(mtd, sect_start, sect_size, | 187 | ret = mtd_read(mtd, sect_start, sect_size, |
188 | &retlen, mtdblk->cache_data); | 188 | &retlen, mtdblk->cache_data); |
189 | if (ret) | 189 | if (ret) |
190 | return ret; | 190 | return ret; |
191 | if (retlen != sect_size) | 191 | if (retlen != sect_size) |
@@ -222,7 +222,7 @@ static int do_cached_read (struct mtdblk_dev *mtdblk, unsigned long pos, | |||
222 | mtd->name, pos, len); | 222 | mtd->name, pos, len); |
223 | 223 | ||
224 | if (!sect_size) | 224 | if (!sect_size) |
225 | return mtd->read(mtd, pos, len, &retlen, buf); | 225 | return mtd_read(mtd, pos, len, &retlen, buf); |
226 | 226 | ||
227 | while (len > 0) { | 227 | while (len > 0) { |
228 | unsigned long sect_start = (pos/sect_size)*sect_size; | 228 | unsigned long sect_start = (pos/sect_size)*sect_size; |
@@ -241,7 +241,7 @@ static int do_cached_read (struct mtdblk_dev *mtdblk, unsigned long pos, | |||
241 | mtdblk->cache_offset == sect_start) { | 241 | mtdblk->cache_offset == sect_start) { |
242 | memcpy (buf, mtdblk->cache_data + offset, size); | 242 | memcpy (buf, mtdblk->cache_data + offset, size); |
243 | } else { | 243 | } else { |
244 | ret = mtd->read(mtd, pos, size, &retlen, buf); | 244 | ret = mtd_read(mtd, pos, size, &retlen, buf); |
245 | if (ret) | 245 | if (ret) |
246 | return ret; | 246 | return ret; |
247 | if (retlen != size) | 247 | if (retlen != size) |
diff --git a/drivers/mtd/mtdblock_ro.c b/drivers/mtd/mtdblock_ro.c index 0470a6e86309..f5737b1153fa 100644 --- a/drivers/mtd/mtdblock_ro.c +++ b/drivers/mtd/mtdblock_ro.c | |||
@@ -30,7 +30,7 @@ static int mtdblock_readsect(struct mtd_blktrans_dev *dev, | |||
30 | { | 30 | { |
31 | size_t retlen; | 31 | size_t retlen; |
32 | 32 | ||
33 | if (dev->mtd->read(dev->mtd, (block * 512), 512, &retlen, buf)) | 33 | if (mtd_read(dev->mtd, (block * 512), 512, &retlen, buf)) |
34 | return 1; | 34 | return 1; |
35 | return 0; | 35 | return 0; |
36 | } | 36 | } |
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c index c51f04a00afb..c7f484687fa3 100644 --- a/drivers/mtd/mtdchar.c +++ b/drivers/mtd/mtdchar.c | |||
@@ -232,7 +232,7 @@ static ssize_t mtdchar_read(struct file *file, char __user *buf, size_t count, | |||
232 | break; | 232 | break; |
233 | } | 233 | } |
234 | default: | 234 | default: |
235 | ret = mtd->read(mtd, *ppos, len, &retlen, kbuf); | 235 | ret = mtd_read(mtd, *ppos, len, &retlen, kbuf); |
236 | } | 236 | } |
237 | /* Nand returns -EBADMSG on ECC errors, but it returns | 237 | /* Nand returns -EBADMSG on ECC errors, but it returns |
238 | * the data. For our userspace tools it is important | 238 | * the data. For our userspace tools it is important |
diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c index b3895cf20bb2..45460349fd12 100644 --- a/drivers/mtd/mtdconcat.c +++ b/drivers/mtd/mtdconcat.c | |||
@@ -91,7 +91,7 @@ concat_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
91 | /* Entire transaction goes into this subdev */ | 91 | /* Entire transaction goes into this subdev */ |
92 | size = len; | 92 | size = len; |
93 | 93 | ||
94 | err = subdev->read(subdev, from, size, &retsize, buf); | 94 | err = mtd_read(subdev, from, size, &retsize, buf); |
95 | 95 | ||
96 | /* Save information about bitflips! */ | 96 | /* Save information about bitflips! */ |
97 | if (unlikely(err)) { | 97 | if (unlikely(err)) { |
diff --git a/drivers/mtd/mtdoops.c b/drivers/mtd/mtdoops.c index 9b2d86323169..23629ad08507 100644 --- a/drivers/mtd/mtdoops.c +++ b/drivers/mtd/mtdoops.c | |||
@@ -258,8 +258,8 @@ static void find_next_position(struct mtdoops_context *cxt) | |||
258 | continue; | 258 | continue; |
259 | /* Assume the page is used */ | 259 | /* Assume the page is used */ |
260 | mark_page_used(cxt, page); | 260 | mark_page_used(cxt, page); |
261 | ret = mtd->read(mtd, page * record_size, MTDOOPS_HEADER_SIZE, | 261 | ret = mtd_read(mtd, page * record_size, MTDOOPS_HEADER_SIZE, |
262 | &retlen, (u_char *) &count[0]); | 262 | &retlen, (u_char *)&count[0]); |
263 | if (retlen != MTDOOPS_HEADER_SIZE || | 263 | if (retlen != MTDOOPS_HEADER_SIZE || |
264 | (ret < 0 && !mtd_is_bitflip(ret))) { | 264 | (ret < 0 && !mtd_is_bitflip(ret))) { |
265 | printk(KERN_ERR "mtdoops: read failure at %ld (%td of %d read), err %d\n", | 265 | printk(KERN_ERR "mtdoops: read failure at %ld (%td of %d read), err %d\n", |
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c index 55a9cb544fc1..59cd7974bc50 100644 --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c | |||
@@ -70,8 +70,7 @@ static int part_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
70 | len = 0; | 70 | len = 0; |
71 | else if (from + len > mtd->size) | 71 | else if (from + len > mtd->size) |
72 | len = mtd->size - from; | 72 | len = mtd->size - from; |
73 | res = part->master->read(part->master, from + part->offset, | 73 | res = mtd_read(part->master, from + part->offset, len, retlen, buf); |
74 | len, retlen, buf); | ||
75 | if (unlikely(res)) { | 74 | if (unlikely(res)) { |
76 | if (mtd_is_bitflip(res)) | 75 | if (mtd_is_bitflip(res)) |
77 | mtd->ecc_stats.corrected += part->master->ecc_stats.corrected - stats.corrected; | 76 | mtd->ecc_stats.corrected += part->master->ecc_stats.corrected - stats.corrected; |
diff --git a/drivers/mtd/mtdswap.c b/drivers/mtd/mtdswap.c index 4e12875a916c..b3282d2aa8f8 100644 --- a/drivers/mtd/mtdswap.c +++ b/drivers/mtd/mtdswap.c | |||
@@ -736,7 +736,7 @@ static int mtdswap_move_block(struct mtdswap_dev *d, unsigned int oldblock, | |||
736 | retries = 0; | 736 | retries = 0; |
737 | 737 | ||
738 | retry: | 738 | retry: |
739 | ret = mtd->read(mtd, readpos, PAGE_SIZE, &retlen, d->page_buf); | 739 | ret = mtd_read(mtd, readpos, PAGE_SIZE, &retlen, d->page_buf); |
740 | 740 | ||
741 | if (ret < 0 && !mtd_is_bitflip(ret)) { | 741 | if (ret < 0 && !mtd_is_bitflip(ret)) { |
742 | oldeb = d->eb_data + oldblock / d->pages_per_eblk; | 742 | oldeb = d->eb_data + oldblock / d->pages_per_eblk; |
@@ -1161,7 +1161,7 @@ static int mtdswap_readsect(struct mtd_blktrans_dev *dev, | |||
1161 | retries = 0; | 1161 | retries = 0; |
1162 | 1162 | ||
1163 | retry: | 1163 | retry: |
1164 | ret = mtd->read(mtd, readpos, PAGE_SIZE, &retlen, buf); | 1164 | ret = mtd_read(mtd, readpos, PAGE_SIZE, &retlen, buf); |
1165 | 1165 | ||
1166 | d->mtd_read_count++; | 1166 | d->mtd_read_count++; |
1167 | if (mtd_is_bitflip(ret)) { | 1167 | if (mtd_is_bitflip(ret)) { |
diff --git a/drivers/mtd/nand/diskonchip.c b/drivers/mtd/nand/diskonchip.c index 5780dbab6113..df921e7a496c 100644 --- a/drivers/mtd/nand/diskonchip.c +++ b/drivers/mtd/nand/diskonchip.c | |||
@@ -1072,7 +1072,7 @@ static int __init find_media_headers(struct mtd_info *mtd, u_char *buf, const ch | |||
1072 | size_t retlen; | 1072 | size_t retlen; |
1073 | 1073 | ||
1074 | for (offs = 0; offs < mtd->size; offs += mtd->erasesize) { | 1074 | for (offs = 0; offs < mtd->size; offs += mtd->erasesize) { |
1075 | ret = mtd->read(mtd, offs, mtd->writesize, &retlen, buf); | 1075 | ret = mtd_read(mtd, offs, mtd->writesize, &retlen, buf); |
1076 | if (retlen != mtd->writesize) | 1076 | if (retlen != mtd->writesize) |
1077 | continue; | 1077 | continue; |
1078 | if (ret) { | 1078 | if (ret) { |
@@ -1097,7 +1097,7 @@ static int __init find_media_headers(struct mtd_info *mtd, u_char *buf, const ch | |||
1097 | /* Only one mediaheader was found. We want buf to contain a | 1097 | /* Only one mediaheader was found. We want buf to contain a |
1098 | mediaheader on return, so we'll have to re-read the one we found. */ | 1098 | mediaheader on return, so we'll have to re-read the one we found. */ |
1099 | offs = doc->mh0_page << this->page_shift; | 1099 | offs = doc->mh0_page << this->page_shift; |
1100 | ret = mtd->read(mtd, offs, mtd->writesize, &retlen, buf); | 1100 | ret = mtd_read(mtd, offs, mtd->writesize, &retlen, buf); |
1101 | if (retlen != mtd->writesize) { | 1101 | if (retlen != mtd->writesize) { |
1102 | /* Insanity. Give up. */ | 1102 | /* Insanity. Give up. */ |
1103 | printk(KERN_ERR "Read DiskOnChip Media Header once, but can't reread it???\n"); | 1103 | printk(KERN_ERR "Read DiskOnChip Media Header once, but can't reread it???\n"); |
diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c index 69148ae3bf58..1bcd6bc6798c 100644 --- a/drivers/mtd/nand/nand_bbt.c +++ b/drivers/mtd/nand/nand_bbt.c | |||
@@ -201,7 +201,7 @@ static int read_bbt(struct mtd_info *mtd, uint8_t *buf, int page, int num, | |||
201 | from += marker_len; | 201 | from += marker_len; |
202 | marker_len = 0; | 202 | marker_len = 0; |
203 | } | 203 | } |
204 | res = mtd->read(mtd, from, len, &retlen, buf); | 204 | res = mtd_read(mtd, from, len, &retlen, buf); |
205 | if (res < 0) { | 205 | if (res < 0) { |
206 | if (mtd_is_eccerr(res)) { | 206 | if (mtd_is_eccerr(res)) { |
207 | pr_info("nand_bbt: ECC error in BBT at " | 207 | pr_info("nand_bbt: ECC error in BBT at " |
@@ -298,7 +298,7 @@ static int scan_read_raw_data(struct mtd_info *mtd, uint8_t *buf, loff_t offs, | |||
298 | if (td->options & NAND_BBT_VERSION) | 298 | if (td->options & NAND_BBT_VERSION) |
299 | len++; | 299 | len++; |
300 | 300 | ||
301 | return mtd->read(mtd, offs, len, &retlen, buf); | 301 | return mtd_read(mtd, offs, len, &retlen, buf); |
302 | } | 302 | } |
303 | 303 | ||
304 | /* Scan read raw data from flash */ | 304 | /* Scan read raw data from flash */ |
@@ -756,7 +756,7 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf, | |||
756 | /* Make it block aligned */ | 756 | /* Make it block aligned */ |
757 | to &= ~((loff_t)((1 << this->bbt_erase_shift) - 1)); | 757 | to &= ~((loff_t)((1 << this->bbt_erase_shift) - 1)); |
758 | len = 1 << this->bbt_erase_shift; | 758 | len = 1 << this->bbt_erase_shift; |
759 | res = mtd->read(mtd, to, len, &retlen, buf); | 759 | res = mtd_read(mtd, to, len, &retlen, buf); |
760 | if (res < 0) { | 760 | if (res < 0) { |
761 | if (retlen != len) { | 761 | if (retlen != len) { |
762 | pr_info("nand_bbt: error reading block " | 762 | pr_info("nand_bbt: error reading block " |
diff --git a/drivers/mtd/nftlcore.c b/drivers/mtd/nftlcore.c index cda77b562ad4..1a9d9c1d3a74 100644 --- a/drivers/mtd/nftlcore.c +++ b/drivers/mtd/nftlcore.c | |||
@@ -423,12 +423,17 @@ static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned p | |||
423 | if (BlockMap[block] == BLOCK_NIL) | 423 | if (BlockMap[block] == BLOCK_NIL) |
424 | continue; | 424 | continue; |
425 | 425 | ||
426 | ret = mtd->read(mtd, (nftl->EraseSize * BlockMap[block]) + (block * 512), | 426 | ret = mtd_read(mtd, |
427 | 512, &retlen, movebuf); | 427 | (nftl->EraseSize * BlockMap[block]) + (block * 512), |
428 | 512, | ||
429 | &retlen, | ||
430 | movebuf); | ||
428 | if (ret < 0 && !mtd_is_bitflip(ret)) { | 431 | if (ret < 0 && !mtd_is_bitflip(ret)) { |
429 | ret = mtd->read(mtd, (nftl->EraseSize * BlockMap[block]) | 432 | ret = mtd_read(mtd, |
430 | + (block * 512), 512, &retlen, | 433 | (nftl->EraseSize * BlockMap[block]) + (block * 512), |
431 | movebuf); | 434 | 512, |
435 | &retlen, | ||
436 | movebuf); | ||
432 | if (ret != -EIO) | 437 | if (ret != -EIO) |
433 | printk("Error went away on retry.\n"); | 438 | printk("Error went away on retry.\n"); |
434 | } | 439 | } |
@@ -771,7 +776,7 @@ static int nftl_readblock(struct mtd_blktrans_dev *mbd, unsigned long block, | |||
771 | } else { | 776 | } else { |
772 | loff_t ptr = (lastgoodEUN * nftl->EraseSize) + blockofs; | 777 | loff_t ptr = (lastgoodEUN * nftl->EraseSize) + blockofs; |
773 | size_t retlen; | 778 | size_t retlen; |
774 | int res = mtd->read(mtd, ptr, 512, &retlen, buffer); | 779 | int res = mtd_read(mtd, ptr, 512, &retlen, buffer); |
775 | 780 | ||
776 | if (res < 0 && !mtd_is_bitflip(res)) | 781 | if (res < 0 && !mtd_is_bitflip(res)) |
777 | return -EIO; | 782 | return -EIO; |
diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c index 9164a56fb5c0..b068dc8a3666 100644 --- a/drivers/mtd/nftlmount.c +++ b/drivers/mtd/nftlmount.c | |||
@@ -63,8 +63,8 @@ static int find_boot_record(struct NFTLrecord *nftl) | |||
63 | 63 | ||
64 | /* Check for ANAND header first. Then can whinge if it's found but later | 64 | /* Check for ANAND header first. Then can whinge if it's found but later |
65 | checks fail */ | 65 | checks fail */ |
66 | ret = mtd->read(mtd, block * nftl->EraseSize, SECTORSIZE, | 66 | ret = mtd_read(mtd, block * nftl->EraseSize, SECTORSIZE, |
67 | &retlen, buf); | 67 | &retlen, buf); |
68 | /* We ignore ret in case the ECC of the MediaHeader is invalid | 68 | /* We ignore ret in case the ECC of the MediaHeader is invalid |
69 | (which is apparently acceptable) */ | 69 | (which is apparently acceptable) */ |
70 | if (retlen != SECTORSIZE) { | 70 | if (retlen != SECTORSIZE) { |
@@ -274,7 +274,7 @@ static int check_free_sectors(struct NFTLrecord *nftl, unsigned int address, int | |||
274 | int i; | 274 | int i; |
275 | 275 | ||
276 | for (i = 0; i < len; i += SECTORSIZE) { | 276 | for (i = 0; i < len; i += SECTORSIZE) { |
277 | if (mtd->read(mtd, address, SECTORSIZE, &retlen, buf)) | 277 | if (mtd_read(mtd, address, SECTORSIZE, &retlen, buf)) |
278 | return -1; | 278 | return -1; |
279 | if (memcmpb(buf, 0xff, SECTORSIZE) != 0) | 279 | if (memcmpb(buf, 0xff, SECTORSIZE) != 0) |
280 | return -1; | 280 | return -1; |
diff --git a/drivers/mtd/redboot.c b/drivers/mtd/redboot.c index e366b1d84ead..623d9b86d0d9 100644 --- a/drivers/mtd/redboot.c +++ b/drivers/mtd/redboot.c | |||
@@ -104,8 +104,8 @@ static int parse_redboot_partitions(struct mtd_info *master, | |||
104 | printk(KERN_NOTICE "Searching for RedBoot partition table in %s at offset 0x%lx\n", | 104 | printk(KERN_NOTICE "Searching for RedBoot partition table in %s at offset 0x%lx\n", |
105 | master->name, offset); | 105 | master->name, offset); |
106 | 106 | ||
107 | ret = master->read(master, offset, | 107 | ret = mtd_read(master, offset, master->erasesize, &retlen, |
108 | master->erasesize, &retlen, (void *)buf); | 108 | (void *)buf); |
109 | 109 | ||
110 | if (ret) | 110 | if (ret) |
111 | goto out; | 111 | goto out; |
diff --git a/drivers/mtd/rfd_ftl.c b/drivers/mtd/rfd_ftl.c index 39de8727a524..d9fe2d0533d9 100644 --- a/drivers/mtd/rfd_ftl.c +++ b/drivers/mtd/rfd_ftl.c | |||
@@ -200,9 +200,9 @@ static int scan_header(struct partition *part) | |||
200 | part->sector_map[i] = -1; | 200 | part->sector_map[i] = -1; |
201 | 201 | ||
202 | for (i=0, blocks_found=0; i<part->total_blocks; i++) { | 202 | for (i=0, blocks_found=0; i<part->total_blocks; i++) { |
203 | rc = part->mbd.mtd->read(part->mbd.mtd, | 203 | rc = mtd_read(part->mbd.mtd, i * part->block_size, |
204 | i * part->block_size, part->header_size, | 204 | part->header_size, &retlen, |
205 | &retlen, (u_char*)part->header_cache); | 205 | (u_char *)part->header_cache); |
206 | 206 | ||
207 | if (!rc && retlen != part->header_size) | 207 | if (!rc && retlen != part->header_size) |
208 | rc = -EIO; | 208 | rc = -EIO; |
@@ -250,8 +250,8 @@ static int rfd_ftl_readsect(struct mtd_blktrans_dev *dev, u_long sector, char *b | |||
250 | 250 | ||
251 | addr = part->sector_map[sector]; | 251 | addr = part->sector_map[sector]; |
252 | if (addr != -1) { | 252 | if (addr != -1) { |
253 | rc = part->mbd.mtd->read(part->mbd.mtd, addr, SECTOR_SIZE, | 253 | rc = mtd_read(part->mbd.mtd, addr, SECTOR_SIZE, &retlen, |
254 | &retlen, (u_char*)buf); | 254 | (u_char *)buf); |
255 | if (!rc && retlen != SECTOR_SIZE) | 255 | if (!rc && retlen != SECTOR_SIZE) |
256 | rc = -EIO; | 256 | rc = -EIO; |
257 | 257 | ||
@@ -372,9 +372,8 @@ static int move_block_contents(struct partition *part, int block_no, u_long *old | |||
372 | if (!map) | 372 | if (!map) |
373 | goto err2; | 373 | goto err2; |
374 | 374 | ||
375 | rc = part->mbd.mtd->read(part->mbd.mtd, | 375 | rc = mtd_read(part->mbd.mtd, part->blocks[block_no].offset, |
376 | part->blocks[block_no].offset, part->header_size, | 376 | part->header_size, &retlen, (u_char *)map); |
377 | &retlen, (u_char*)map); | ||
378 | 377 | ||
379 | if (!rc && retlen != part->header_size) | 378 | if (!rc && retlen != part->header_size) |
380 | rc = -EIO; | 379 | rc = -EIO; |
@@ -413,8 +412,8 @@ static int move_block_contents(struct partition *part, int block_no, u_long *old | |||
413 | } | 412 | } |
414 | continue; | 413 | continue; |
415 | } | 414 | } |
416 | rc = part->mbd.mtd->read(part->mbd.mtd, addr, | 415 | rc = mtd_read(part->mbd.mtd, addr, SECTOR_SIZE, &retlen, |
417 | SECTOR_SIZE, &retlen, sector_data); | 416 | sector_data); |
418 | 417 | ||
419 | if (!rc && retlen != SECTOR_SIZE) | 418 | if (!rc && retlen != SECTOR_SIZE) |
420 | rc = -EIO; | 419 | rc = -EIO; |
@@ -563,8 +562,9 @@ static int find_writable_block(struct partition *part, u_long *old_sector) | |||
563 | } | 562 | } |
564 | } | 563 | } |
565 | 564 | ||
566 | rc = part->mbd.mtd->read(part->mbd.mtd, part->blocks[block].offset, | 565 | rc = mtd_read(part->mbd.mtd, part->blocks[block].offset, |
567 | part->header_size, &retlen, (u_char*)part->header_cache); | 566 | part->header_size, &retlen, |
567 | (u_char *)part->header_cache); | ||
568 | 568 | ||
569 | if (!rc && retlen != part->header_size) | 569 | if (!rc && retlen != part->header_size) |
570 | rc = -EIO; | 570 | rc = -EIO; |
diff --git a/drivers/mtd/ssfdc.c b/drivers/mtd/ssfdc.c index 976e3d28b962..293e22a5710f 100644 --- a/drivers/mtd/ssfdc.c +++ b/drivers/mtd/ssfdc.c | |||
@@ -123,8 +123,8 @@ static int get_valid_cis_sector(struct mtd_info *mtd) | |||
123 | */ | 123 | */ |
124 | for (k = 0, offset = 0; k < 4; k++, offset += mtd->erasesize) { | 124 | for (k = 0, offset = 0; k < 4; k++, offset += mtd->erasesize) { |
125 | if (!mtd->block_isbad(mtd, offset)) { | 125 | if (!mtd->block_isbad(mtd, offset)) { |
126 | ret = mtd->read(mtd, offset, SECTOR_SIZE, &retlen, | 126 | ret = mtd_read(mtd, offset, SECTOR_SIZE, &retlen, |
127 | sect_buf); | 127 | sect_buf); |
128 | 128 | ||
129 | /* CIS pattern match on the sector buffer */ | 129 | /* CIS pattern match on the sector buffer */ |
130 | if (ret < 0 || retlen != SECTOR_SIZE) { | 130 | if (ret < 0 || retlen != SECTOR_SIZE) { |
@@ -156,7 +156,7 @@ static int read_physical_sector(struct mtd_info *mtd, uint8_t *sect_buf, | |||
156 | size_t retlen; | 156 | size_t retlen; |
157 | loff_t offset = (loff_t)sect_no << SECTOR_SHIFT; | 157 | loff_t offset = (loff_t)sect_no << SECTOR_SHIFT; |
158 | 158 | ||
159 | ret = mtd->read(mtd, offset, SECTOR_SIZE, &retlen, sect_buf); | 159 | ret = mtd_read(mtd, offset, SECTOR_SIZE, &retlen, sect_buf); |
160 | if (ret < 0 || retlen != SECTOR_SIZE) | 160 | if (ret < 0 || retlen != SECTOR_SIZE) |
161 | return -1; | 161 | return -1; |
162 | 162 | ||
diff --git a/drivers/mtd/tests/mtd_pagetest.c b/drivers/mtd/tests/mtd_pagetest.c index 271819fabb55..6d62e24a03ed 100644 --- a/drivers/mtd/tests/mtd_pagetest.c +++ b/drivers/mtd/tests/mtd_pagetest.c | |||
@@ -127,7 +127,7 @@ static int verify_eraseblock(int ebnum) | |||
127 | set_random_data(writebuf, mtd->erasesize); | 127 | set_random_data(writebuf, mtd->erasesize); |
128 | for (j = 0; j < pgcnt - 1; ++j, addr += pgsize) { | 128 | for (j = 0; j < pgcnt - 1; ++j, addr += pgsize) { |
129 | /* Do a read to set the internal dataRAMs to different data */ | 129 | /* Do a read to set the internal dataRAMs to different data */ |
130 | err = mtd->read(mtd, addr0, bufsize, &read, twopages); | 130 | err = mtd_read(mtd, addr0, bufsize, &read, twopages); |
131 | if (mtd_is_bitflip(err)) | 131 | if (mtd_is_bitflip(err)) |
132 | err = 0; | 132 | err = 0; |
133 | if (err || read != bufsize) { | 133 | if (err || read != bufsize) { |
@@ -135,7 +135,7 @@ static int verify_eraseblock(int ebnum) | |||
135 | (long long)addr0); | 135 | (long long)addr0); |
136 | return err; | 136 | return err; |
137 | } | 137 | } |
138 | err = mtd->read(mtd, addrn - bufsize, bufsize, &read, twopages); | 138 | err = mtd_read(mtd, addrn - bufsize, bufsize, &read, twopages); |
139 | if (mtd_is_bitflip(err)) | 139 | if (mtd_is_bitflip(err)) |
140 | err = 0; | 140 | err = 0; |
141 | if (err || read != bufsize) { | 141 | if (err || read != bufsize) { |
@@ -145,7 +145,7 @@ static int verify_eraseblock(int ebnum) | |||
145 | } | 145 | } |
146 | memset(twopages, 0, bufsize); | 146 | memset(twopages, 0, bufsize); |
147 | read = 0; | 147 | read = 0; |
148 | err = mtd->read(mtd, addr, bufsize, &read, twopages); | 148 | err = mtd_read(mtd, addr, bufsize, &read, twopages); |
149 | if (mtd_is_bitflip(err)) | 149 | if (mtd_is_bitflip(err)) |
150 | err = 0; | 150 | err = 0; |
151 | if (err || read != bufsize) { | 151 | if (err || read != bufsize) { |
@@ -163,7 +163,7 @@ static int verify_eraseblock(int ebnum) | |||
163 | if (addr <= addrn - pgsize - pgsize && !bbt[ebnum + 1]) { | 163 | if (addr <= addrn - pgsize - pgsize && !bbt[ebnum + 1]) { |
164 | unsigned long oldnext = next; | 164 | unsigned long oldnext = next; |
165 | /* Do a read to set the internal dataRAMs to different data */ | 165 | /* Do a read to set the internal dataRAMs to different data */ |
166 | err = mtd->read(mtd, addr0, bufsize, &read, twopages); | 166 | err = mtd_read(mtd, addr0, bufsize, &read, twopages); |
167 | if (mtd_is_bitflip(err)) | 167 | if (mtd_is_bitflip(err)) |
168 | err = 0; | 168 | err = 0; |
169 | if (err || read != bufsize) { | 169 | if (err || read != bufsize) { |
@@ -171,7 +171,7 @@ static int verify_eraseblock(int ebnum) | |||
171 | (long long)addr0); | 171 | (long long)addr0); |
172 | return err; | 172 | return err; |
173 | } | 173 | } |
174 | err = mtd->read(mtd, addrn - bufsize, bufsize, &read, twopages); | 174 | err = mtd_read(mtd, addrn - bufsize, bufsize, &read, twopages); |
175 | if (mtd_is_bitflip(err)) | 175 | if (mtd_is_bitflip(err)) |
176 | err = 0; | 176 | err = 0; |
177 | if (err || read != bufsize) { | 177 | if (err || read != bufsize) { |
@@ -181,7 +181,7 @@ static int verify_eraseblock(int ebnum) | |||
181 | } | 181 | } |
182 | memset(twopages, 0, bufsize); | 182 | memset(twopages, 0, bufsize); |
183 | read = 0; | 183 | read = 0; |
184 | err = mtd->read(mtd, addr, bufsize, &read, twopages); | 184 | err = mtd_read(mtd, addr, bufsize, &read, twopages); |
185 | if (mtd_is_bitflip(err)) | 185 | if (mtd_is_bitflip(err)) |
186 | err = 0; | 186 | err = 0; |
187 | if (err || read != bufsize) { | 187 | if (err || read != bufsize) { |
@@ -230,7 +230,7 @@ static int crosstest(void) | |||
230 | /* Read 2nd-to-last page to pp1 */ | 230 | /* Read 2nd-to-last page to pp1 */ |
231 | read = 0; | 231 | read = 0; |
232 | addr = addrn - pgsize - pgsize; | 232 | addr = addrn - pgsize - pgsize; |
233 | err = mtd->read(mtd, addr, pgsize, &read, pp1); | 233 | err = mtd_read(mtd, addr, pgsize, &read, pp1); |
234 | if (mtd_is_bitflip(err)) | 234 | if (mtd_is_bitflip(err)) |
235 | err = 0; | 235 | err = 0; |
236 | if (err || read != pgsize) { | 236 | if (err || read != pgsize) { |
@@ -243,7 +243,7 @@ static int crosstest(void) | |||
243 | /* Read 3rd-to-last page to pp1 */ | 243 | /* Read 3rd-to-last page to pp1 */ |
244 | read = 0; | 244 | read = 0; |
245 | addr = addrn - pgsize - pgsize - pgsize; | 245 | addr = addrn - pgsize - pgsize - pgsize; |
246 | err = mtd->read(mtd, addr, pgsize, &read, pp1); | 246 | err = mtd_read(mtd, addr, pgsize, &read, pp1); |
247 | if (mtd_is_bitflip(err)) | 247 | if (mtd_is_bitflip(err)) |
248 | err = 0; | 248 | err = 0; |
249 | if (err || read != pgsize) { | 249 | if (err || read != pgsize) { |
@@ -257,7 +257,7 @@ static int crosstest(void) | |||
257 | read = 0; | 257 | read = 0; |
258 | addr = addr0; | 258 | addr = addr0; |
259 | printk(PRINT_PREF "reading page at %#llx\n", (long long)addr); | 259 | printk(PRINT_PREF "reading page at %#llx\n", (long long)addr); |
260 | err = mtd->read(mtd, addr, pgsize, &read, pp2); | 260 | err = mtd_read(mtd, addr, pgsize, &read, pp2); |
261 | if (mtd_is_bitflip(err)) | 261 | if (mtd_is_bitflip(err)) |
262 | err = 0; | 262 | err = 0; |
263 | if (err || read != pgsize) { | 263 | if (err || read != pgsize) { |
@@ -271,7 +271,7 @@ static int crosstest(void) | |||
271 | read = 0; | 271 | read = 0; |
272 | addr = addrn - pgsize; | 272 | addr = addrn - pgsize; |
273 | printk(PRINT_PREF "reading page at %#llx\n", (long long)addr); | 273 | printk(PRINT_PREF "reading page at %#llx\n", (long long)addr); |
274 | err = mtd->read(mtd, addr, pgsize, &read, pp3); | 274 | err = mtd_read(mtd, addr, pgsize, &read, pp3); |
275 | if (mtd_is_bitflip(err)) | 275 | if (mtd_is_bitflip(err)) |
276 | err = 0; | 276 | err = 0; |
277 | if (err || read != pgsize) { | 277 | if (err || read != pgsize) { |
@@ -285,7 +285,7 @@ static int crosstest(void) | |||
285 | read = 0; | 285 | read = 0; |
286 | addr = addr0; | 286 | addr = addr0; |
287 | printk(PRINT_PREF "reading page at %#llx\n", (long long)addr); | 287 | printk(PRINT_PREF "reading page at %#llx\n", (long long)addr); |
288 | err = mtd->read(mtd, addr, pgsize, &read, pp4); | 288 | err = mtd_read(mtd, addr, pgsize, &read, pp4); |
289 | if (mtd_is_bitflip(err)) | 289 | if (mtd_is_bitflip(err)) |
290 | err = 0; | 290 | err = 0; |
291 | if (err || read != pgsize) { | 291 | if (err || read != pgsize) { |
@@ -344,7 +344,7 @@ static int erasecrosstest(void) | |||
344 | 344 | ||
345 | printk(PRINT_PREF "reading 1st page of block %d\n", ebnum); | 345 | printk(PRINT_PREF "reading 1st page of block %d\n", ebnum); |
346 | memset(readbuf, 0, pgsize); | 346 | memset(readbuf, 0, pgsize); |
347 | err = mtd->read(mtd, addr0, pgsize, &read, readbuf); | 347 | err = mtd_read(mtd, addr0, pgsize, &read, readbuf); |
348 | if (mtd_is_bitflip(err)) | 348 | if (mtd_is_bitflip(err)) |
349 | err = 0; | 349 | err = 0; |
350 | if (err || read != pgsize) { | 350 | if (err || read != pgsize) { |
@@ -382,7 +382,7 @@ static int erasecrosstest(void) | |||
382 | 382 | ||
383 | printk(PRINT_PREF "reading 1st page of block %d\n", ebnum); | 383 | printk(PRINT_PREF "reading 1st page of block %d\n", ebnum); |
384 | memset(readbuf, 0, pgsize); | 384 | memset(readbuf, 0, pgsize); |
385 | err = mtd->read(mtd, addr0, pgsize, &read, readbuf); | 385 | err = mtd_read(mtd, addr0, pgsize, &read, readbuf); |
386 | if (mtd_is_bitflip(err)) | 386 | if (mtd_is_bitflip(err)) |
387 | err = 0; | 387 | err = 0; |
388 | if (err || read != pgsize) { | 388 | if (err || read != pgsize) { |
@@ -438,7 +438,7 @@ static int erasetest(void) | |||
438 | return err; | 438 | return err; |
439 | 439 | ||
440 | printk(PRINT_PREF "reading 1st page of block %d\n", ebnum); | 440 | printk(PRINT_PREF "reading 1st page of block %d\n", ebnum); |
441 | err = mtd->read(mtd, addr0, pgsize, &read, twopages); | 441 | err = mtd_read(mtd, addr0, pgsize, &read, twopages); |
442 | if (mtd_is_bitflip(err)) | 442 | if (mtd_is_bitflip(err)) |
443 | err = 0; | 443 | err = 0; |
444 | if (err || read != pgsize) { | 444 | if (err || read != pgsize) { |
diff --git a/drivers/mtd/tests/mtd_readtest.c b/drivers/mtd/tests/mtd_readtest.c index 550fe51225a7..0c58d2976c76 100644 --- a/drivers/mtd/tests/mtd_readtest.c +++ b/drivers/mtd/tests/mtd_readtest.c | |||
@@ -52,7 +52,7 @@ static int read_eraseblock_by_page(int ebnum) | |||
52 | 52 | ||
53 | for (i = 0; i < pgcnt; i++) { | 53 | for (i = 0; i < pgcnt; i++) { |
54 | memset(buf, 0 , pgcnt); | 54 | memset(buf, 0 , pgcnt); |
55 | ret = mtd->read(mtd, addr, pgsize, &read, buf); | 55 | ret = mtd_read(mtd, addr, pgsize, &read, buf); |
56 | if (ret == -EUCLEAN) | 56 | if (ret == -EUCLEAN) |
57 | ret = 0; | 57 | ret = 0; |
58 | if (ret || read != pgsize) { | 58 | if (ret || read != pgsize) { |
diff --git a/drivers/mtd/tests/mtd_speedtest.c b/drivers/mtd/tests/mtd_speedtest.c index f67a65e21043..3c9529bd0a62 100644 --- a/drivers/mtd/tests/mtd_speedtest.c +++ b/drivers/mtd/tests/mtd_speedtest.c | |||
@@ -214,7 +214,7 @@ static int read_eraseblock(int ebnum) | |||
214 | int err = 0; | 214 | int err = 0; |
215 | loff_t addr = ebnum * mtd->erasesize; | 215 | loff_t addr = ebnum * mtd->erasesize; |
216 | 216 | ||
217 | err = mtd->read(mtd, addr, mtd->erasesize, &read, iobuf); | 217 | err = mtd_read(mtd, addr, mtd->erasesize, &read, iobuf); |
218 | /* Ignore corrected ECC errors */ | 218 | /* Ignore corrected ECC errors */ |
219 | if (mtd_is_bitflip(err)) | 219 | if (mtd_is_bitflip(err)) |
220 | err = 0; | 220 | err = 0; |
@@ -235,7 +235,7 @@ static int read_eraseblock_by_page(int ebnum) | |||
235 | void *buf = iobuf; | 235 | void *buf = iobuf; |
236 | 236 | ||
237 | for (i = 0; i < pgcnt; i++) { | 237 | for (i = 0; i < pgcnt; i++) { |
238 | err = mtd->read(mtd, addr, pgsize, &read, buf); | 238 | err = mtd_read(mtd, addr, pgsize, &read, buf); |
239 | /* Ignore corrected ECC errors */ | 239 | /* Ignore corrected ECC errors */ |
240 | if (mtd_is_bitflip(err)) | 240 | if (mtd_is_bitflip(err)) |
241 | err = 0; | 241 | err = 0; |
@@ -261,7 +261,7 @@ static int read_eraseblock_by_2pages(int ebnum) | |||
261 | void *buf = iobuf; | 261 | void *buf = iobuf; |
262 | 262 | ||
263 | for (i = 0; i < n; i++) { | 263 | for (i = 0; i < n; i++) { |
264 | err = mtd->read(mtd, addr, sz, &read, buf); | 264 | err = mtd_read(mtd, addr, sz, &read, buf); |
265 | /* Ignore corrected ECC errors */ | 265 | /* Ignore corrected ECC errors */ |
266 | if (mtd_is_bitflip(err)) | 266 | if (mtd_is_bitflip(err)) |
267 | err = 0; | 267 | err = 0; |
@@ -276,7 +276,7 @@ static int read_eraseblock_by_2pages(int ebnum) | |||
276 | buf += sz; | 276 | buf += sz; |
277 | } | 277 | } |
278 | if (pgcnt % 2) { | 278 | if (pgcnt % 2) { |
279 | err = mtd->read(mtd, addr, pgsize, &read, buf); | 279 | err = mtd_read(mtd, addr, pgsize, &read, buf); |
280 | /* Ignore corrected ECC errors */ | 280 | /* Ignore corrected ECC errors */ |
281 | if (mtd_is_bitflip(err)) | 281 | if (mtd_is_bitflip(err)) |
282 | err = 0; | 282 | err = 0; |
diff --git a/drivers/mtd/tests/mtd_stresstest.c b/drivers/mtd/tests/mtd_stresstest.c index a204a9f90524..83a843723880 100644 --- a/drivers/mtd/tests/mtd_stresstest.c +++ b/drivers/mtd/tests/mtd_stresstest.c | |||
@@ -153,7 +153,7 @@ static int do_read(void) | |||
153 | len = mtd->erasesize - offs; | 153 | len = mtd->erasesize - offs; |
154 | } | 154 | } |
155 | addr = eb * mtd->erasesize + offs; | 155 | addr = eb * mtd->erasesize + offs; |
156 | err = mtd->read(mtd, addr, len, &read, readbuf); | 156 | err = mtd_read(mtd, addr, len, &read, readbuf); |
157 | if (mtd_is_bitflip(err)) | 157 | if (mtd_is_bitflip(err)) |
158 | err = 0; | 158 | err = 0; |
159 | if (unlikely(err || read != len)) { | 159 | if (unlikely(err || read != len)) { |
diff --git a/drivers/mtd/tests/mtd_subpagetest.c b/drivers/mtd/tests/mtd_subpagetest.c index 16d0c05024d7..d81f89a19daa 100644 --- a/drivers/mtd/tests/mtd_subpagetest.c +++ b/drivers/mtd/tests/mtd_subpagetest.c | |||
@@ -196,7 +196,7 @@ static int verify_eraseblock(int ebnum) | |||
196 | set_random_data(writebuf, subpgsize); | 196 | set_random_data(writebuf, subpgsize); |
197 | clear_data(readbuf, subpgsize); | 197 | clear_data(readbuf, subpgsize); |
198 | read = 0; | 198 | read = 0; |
199 | err = mtd->read(mtd, addr, subpgsize, &read, readbuf); | 199 | err = mtd_read(mtd, addr, subpgsize, &read, readbuf); |
200 | if (unlikely(err || read != subpgsize)) { | 200 | if (unlikely(err || read != subpgsize)) { |
201 | if (mtd_is_bitflip(err) && read == subpgsize) { | 201 | if (mtd_is_bitflip(err) && read == subpgsize) { |
202 | printk(PRINT_PREF "ECC correction at %#llx\n", | 202 | printk(PRINT_PREF "ECC correction at %#llx\n", |
@@ -224,7 +224,7 @@ static int verify_eraseblock(int ebnum) | |||
224 | set_random_data(writebuf, subpgsize); | 224 | set_random_data(writebuf, subpgsize); |
225 | clear_data(readbuf, subpgsize); | 225 | clear_data(readbuf, subpgsize); |
226 | read = 0; | 226 | read = 0; |
227 | err = mtd->read(mtd, addr, subpgsize, &read, readbuf); | 227 | err = mtd_read(mtd, addr, subpgsize, &read, readbuf); |
228 | if (unlikely(err || read != subpgsize)) { | 228 | if (unlikely(err || read != subpgsize)) { |
229 | if (mtd_is_bitflip(err) && read == subpgsize) { | 229 | if (mtd_is_bitflip(err) && read == subpgsize) { |
230 | printk(PRINT_PREF "ECC correction at %#llx\n", | 230 | printk(PRINT_PREF "ECC correction at %#llx\n", |
@@ -262,7 +262,7 @@ static int verify_eraseblock2(int ebnum) | |||
262 | set_random_data(writebuf, subpgsize * k); | 262 | set_random_data(writebuf, subpgsize * k); |
263 | clear_data(readbuf, subpgsize * k); | 263 | clear_data(readbuf, subpgsize * k); |
264 | read = 0; | 264 | read = 0; |
265 | err = mtd->read(mtd, addr, subpgsize * k, &read, readbuf); | 265 | err = mtd_read(mtd, addr, subpgsize * k, &read, readbuf); |
266 | if (unlikely(err || read != subpgsize * k)) { | 266 | if (unlikely(err || read != subpgsize * k)) { |
267 | if (mtd_is_bitflip(err) && read == subpgsize * k) { | 267 | if (mtd_is_bitflip(err) && read == subpgsize * k) { |
268 | printk(PRINT_PREF "ECC correction at %#llx\n", | 268 | printk(PRINT_PREF "ECC correction at %#llx\n", |
@@ -296,7 +296,7 @@ static int verify_eraseblock_ff(int ebnum) | |||
296 | for (j = 0; j < mtd->erasesize / subpgsize; ++j) { | 296 | for (j = 0; j < mtd->erasesize / subpgsize; ++j) { |
297 | clear_data(readbuf, subpgsize); | 297 | clear_data(readbuf, subpgsize); |
298 | read = 0; | 298 | read = 0; |
299 | err = mtd->read(mtd, addr, subpgsize, &read, readbuf); | 299 | err = mtd_read(mtd, addr, subpgsize, &read, readbuf); |
300 | if (unlikely(err || read != subpgsize)) { | 300 | if (unlikely(err || read != subpgsize)) { |
301 | if (mtd_is_bitflip(err) && read == subpgsize) { | 301 | if (mtd_is_bitflip(err) && read == subpgsize) { |
302 | printk(PRINT_PREF "ECC correction at %#llx\n", | 302 | printk(PRINT_PREF "ECC correction at %#llx\n", |
diff --git a/drivers/mtd/tests/mtd_torturetest.c b/drivers/mtd/tests/mtd_torturetest.c index 102c79b7ac66..ecc68bf3f3f2 100644 --- a/drivers/mtd/tests/mtd_torturetest.c +++ b/drivers/mtd/tests/mtd_torturetest.c | |||
@@ -137,7 +137,7 @@ static inline int check_eraseblock(int ebnum, unsigned char *buf) | |||
137 | } | 137 | } |
138 | 138 | ||
139 | retry: | 139 | retry: |
140 | err = mtd->read(mtd, addr, len, &read, check_buf); | 140 | err = mtd_read(mtd, addr, len, &read, check_buf); |
141 | if (mtd_is_bitflip(err)) | 141 | if (mtd_is_bitflip(err)) |
142 | printk(PRINT_PREF "single bit flip occurred at EB %d " | 142 | printk(PRINT_PREF "single bit flip occurred at EB %d " |
143 | "MTD reported that it was fixed.\n", ebnum); | 143 | "MTD reported that it was fixed.\n", ebnum); |
diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c index ab80c0debac8..e2cdebf40840 100644 --- a/drivers/mtd/ubi/debug.c +++ b/drivers/mtd/ubi/debug.c | |||
@@ -216,7 +216,7 @@ void ubi_dbg_dump_flash(struct ubi_device *ubi, int pnum, int offset, int len) | |||
216 | buf = vmalloc(len); | 216 | buf = vmalloc(len); |
217 | if (!buf) | 217 | if (!buf) |
218 | return; | 218 | return; |
219 | err = ubi->mtd->read(ubi->mtd, addr, len, &read, buf); | 219 | err = mtd_read(ubi->mtd, addr, len, &read, buf); |
220 | if (err && err != -EUCLEAN) { | 220 | if (err && err != -EUCLEAN) { |
221 | ubi_err("error %d while reading %d bytes from PEB %d:%d, " | 221 | ubi_err("error %d while reading %d bytes from PEB %d:%d, " |
222 | "read %zd bytes", err, len, pnum, offset, read); | 222 | "read %zd bytes", err, len, pnum, offset, read); |
diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c index b6c8959e6c7e..433382951d3d 100644 --- a/drivers/mtd/ubi/io.c +++ b/drivers/mtd/ubi/io.c | |||
@@ -170,7 +170,7 @@ int ubi_io_read(const struct ubi_device *ubi, void *buf, int pnum, int offset, | |||
170 | 170 | ||
171 | addr = (loff_t)pnum * ubi->peb_size + offset; | 171 | addr = (loff_t)pnum * ubi->peb_size + offset; |
172 | retry: | 172 | retry: |
173 | err = ubi->mtd->read(ubi->mtd, addr, len, &read, buf); | 173 | err = mtd_read(ubi->mtd, addr, len, &read, buf); |
174 | if (err) { | 174 | if (err) { |
175 | const char *errstr = mtd_is_eccerr(err) ? " (ECC error)" : ""; | 175 | const char *errstr = mtd_is_eccerr(err) ? " (ECC error)" : ""; |
176 | 176 | ||
@@ -1357,7 +1357,7 @@ int ubi_dbg_check_write(struct ubi_device *ubi, const void *buf, int pnum, | |||
1357 | return 0; | 1357 | return 0; |
1358 | } | 1358 | } |
1359 | 1359 | ||
1360 | err = ubi->mtd->read(ubi->mtd, addr, len, &read, buf1); | 1360 | err = mtd_read(ubi->mtd, addr, len, &read, buf1); |
1361 | if (err && !mtd_is_bitflip(err)) | 1361 | if (err && !mtd_is_bitflip(err)) |
1362 | goto out_free; | 1362 | goto out_free; |
1363 | 1363 | ||
@@ -1421,7 +1421,7 @@ int ubi_dbg_check_all_ff(struct ubi_device *ubi, int pnum, int offset, int len) | |||
1421 | return 0; | 1421 | return 0; |
1422 | } | 1422 | } |
1423 | 1423 | ||
1424 | err = ubi->mtd->read(ubi->mtd, addr, len, &read, buf); | 1424 | err = mtd_read(ubi->mtd, addr, len, &read, buf); |
1425 | if (err && !mtd_is_bitflip(err)) { | 1425 | if (err && !mtd_is_bitflip(err)) { |
1426 | ubi_err("error %d while reading %d bytes from PEB %d:%d, " | 1426 | ubi_err("error %d while reading %d bytes from PEB %d:%d, " |
1427 | "read %zd bytes", err, len, pnum, offset, read); | 1427 | "read %zd bytes", err, len, pnum, offset, read); |
diff --git a/drivers/staging/spectra/lld_mtd.c b/drivers/staging/spectra/lld_mtd.c index d638fafab649..eccd08d0e009 100644 --- a/drivers/staging/spectra/lld_mtd.c +++ b/drivers/staging/spectra/lld_mtd.c | |||
@@ -283,9 +283,11 @@ u16 mtd_Read_Page_Main(u8 *read_data, u32 Block, | |||
283 | 283 | ||
284 | 284 | ||
285 | while (PageCount) { | 285 | while (PageCount) { |
286 | ret = spectra_mtd->read(spectra_mtd, | 286 | ret = mtd_read(spectra_mtd, |
287 | (Block * spectra_mtd->erasesize) + (Page * spectra_mtd->writesize), | 287 | (Block * spectra_mtd->erasesize) + (Page * spectra_mtd->writesize), |
288 | DeviceInfo.wPageDataSize, &retlen, read_data); | 288 | DeviceInfo.wPageDataSize, |
289 | &retlen, | ||
290 | read_data); | ||
289 | if (ret) { | 291 | if (ret) { |
290 | printk(KERN_ERR "%s failed %d\n", __func__, ret); | 292 | printk(KERN_ERR "%s failed %d\n", __func__, ret); |
291 | return FAIL; | 293 | return FAIL; |
diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c index ffdf4fca9c54..c59d642cade2 100644 --- a/fs/jffs2/erase.c +++ b/fs/jffs2/erase.c | |||
@@ -381,7 +381,7 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl | |||
381 | 381 | ||
382 | *bad_offset = ofs; | 382 | *bad_offset = ofs; |
383 | 383 | ||
384 | ret = c->mtd->read(c->mtd, ofs, readlen, &retlen, ebuf); | 384 | ret = mtd_read(c->mtd, ofs, readlen, &retlen, ebuf); |
385 | if (ret) { | 385 | if (ret) { |
386 | printk(KERN_WARNING "Read of newly-erased block at 0x%08x failed: %d. Putting on bad_list\n", ofs, ret); | 386 | printk(KERN_WARNING "Read of newly-erased block at 0x%08x failed: %d. Putting on bad_list\n", ofs, ret); |
387 | ret = -EIO; | 387 | ret = -EIO; |
diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c index b09e51d2f81f..a24d3d21b63d 100644 --- a/fs/jffs2/wbuf.c +++ b/fs/jffs2/wbuf.c | |||
@@ -228,7 +228,7 @@ static int jffs2_verify_write(struct jffs2_sb_info *c, unsigned char *buf, | |||
228 | size_t retlen; | 228 | size_t retlen; |
229 | char *eccstr; | 229 | char *eccstr; |
230 | 230 | ||
231 | ret = c->mtd->read(c->mtd, ofs, c->wbuf_pagesize, &retlen, c->wbuf_verify); | 231 | ret = mtd_read(c->mtd, ofs, c->wbuf_pagesize, &retlen, c->wbuf_verify); |
232 | if (ret && ret != -EUCLEAN && ret != -EBADMSG) { | 232 | if (ret && ret != -EUCLEAN && ret != -EBADMSG) { |
233 | printk(KERN_WARNING "jffs2_verify_write(): Read back of page at %08x failed: %d\n", c->wbuf_ofs, ret); | 233 | printk(KERN_WARNING "jffs2_verify_write(): Read back of page at %08x failed: %d\n", c->wbuf_ofs, ret); |
234 | return ret; | 234 | return ret; |
@@ -337,7 +337,8 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
337 | } | 337 | } |
338 | 338 | ||
339 | /* Do the read... */ | 339 | /* Do the read... */ |
340 | ret = c->mtd->read(c->mtd, start, c->wbuf_ofs - start, &retlen, buf); | 340 | ret = mtd_read(c->mtd, start, c->wbuf_ofs - start, &retlen, |
341 | buf); | ||
341 | 342 | ||
342 | /* ECC recovered ? */ | 343 | /* ECC recovered ? */ |
343 | if ((ret == -EUCLEAN || ret == -EBADMSG) && | 344 | if ((ret == -EUCLEAN || ret == -EBADMSG) && |
@@ -948,11 +949,11 @@ int jffs2_flash_read(struct jffs2_sb_info *c, loff_t ofs, size_t len, size_t *re | |||
948 | int ret; | 949 | int ret; |
949 | 950 | ||
950 | if (!jffs2_is_writebuffered(c)) | 951 | if (!jffs2_is_writebuffered(c)) |
951 | return c->mtd->read(c->mtd, ofs, len, retlen, buf); | 952 | return mtd_read(c->mtd, ofs, len, retlen, buf); |
952 | 953 | ||
953 | /* Read flash */ | 954 | /* Read flash */ |
954 | down_read(&c->wbuf_sem); | 955 | down_read(&c->wbuf_sem); |
955 | ret = c->mtd->read(c->mtd, ofs, len, retlen, buf); | 956 | ret = mtd_read(c->mtd, ofs, len, retlen, buf); |
956 | 957 | ||
957 | if ( (ret == -EBADMSG || ret == -EUCLEAN) && (*retlen == len) ) { | 958 | if ( (ret == -EBADMSG || ret == -EUCLEAN) && (*retlen == len) ) { |
958 | if (ret == -EBADMSG) | 959 | if (ret == -EBADMSG) |
diff --git a/fs/logfs/dev_mtd.c b/fs/logfs/dev_mtd.c index 046362894352..3ee64351685f 100644 --- a/fs/logfs/dev_mtd.c +++ b/fs/logfs/dev_mtd.c | |||
@@ -20,7 +20,7 @@ static int logfs_mtd_read(struct super_block *sb, loff_t ofs, size_t len, | |||
20 | size_t retlen; | 20 | size_t retlen; |
21 | int ret; | 21 | int ret; |
22 | 22 | ||
23 | ret = mtd->read(mtd, ofs, len, &retlen, buf); | 23 | ret = mtd_read(mtd, ofs, len, &retlen, buf); |
24 | BUG_ON(ret == -EINVAL); | 24 | BUG_ON(ret == -EINVAL); |
25 | if (ret) | 25 | if (ret) |
26 | return ret; | 26 | return ret; |
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index f38e8276b408..56478eb4bbc0 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h | |||
@@ -182,6 +182,8 @@ struct mtd_info { | |||
182 | unsigned long len, | 182 | unsigned long len, |
183 | unsigned long offset, | 183 | unsigned long offset, |
184 | unsigned long flags); | 184 | unsigned long flags); |
185 | int (*read) (struct mtd_info *mtd, loff_t from, size_t len, | ||
186 | size_t *retlen, u_char *buf); | ||
185 | 187 | ||
186 | /* Backing device capabilities for this device | 188 | /* Backing device capabilities for this device |
187 | * - provides mmap capabilities | 189 | * - provides mmap capabilities |
@@ -189,7 +191,6 @@ struct mtd_info { | |||
189 | struct backing_dev_info *backing_dev_info; | 191 | struct backing_dev_info *backing_dev_info; |
190 | 192 | ||
191 | 193 | ||
192 | int (*read) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf); | ||
193 | int (*write) (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf); | 194 | int (*write) (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf); |
194 | 195 | ||
195 | /* In blackbox flight recorder like scenarios we want to make successful | 196 | /* In blackbox flight recorder like scenarios we want to make successful |
@@ -301,6 +302,12 @@ static inline unsigned long mtd_get_unmapped_area(struct mtd_info *mtd, | |||
301 | return mtd->get_unmapped_area(mtd, len, offset, flags); | 302 | return mtd->get_unmapped_area(mtd, len, offset, flags); |
302 | } | 303 | } |
303 | 304 | ||
305 | static inline int mtd_read(struct mtd_info *mtd, loff_t from, size_t len, | ||
306 | size_t *retlen, u_char *buf) | ||
307 | { | ||
308 | return mtd->read(mtd, from, len, retlen, buf); | ||
309 | } | ||
310 | |||
304 | static inline struct mtd_info *dev_to_mtd(struct device *dev) | 311 | static inline struct mtd_info *dev_to_mtd(struct device *dev) |
305 | { | 312 | { |
306 | return dev ? dev_get_drvdata(dev) : NULL; | 313 | return dev ? dev_get_drvdata(dev) : NULL; |