mtd: introduce mtd_read interface
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
This commit is contained in:
parent
04c601bfa4
commit
329ad399a9
@ -127,7 +127,7 @@ static void da850_evm_m25p80_notify_add(struct mtd_info *mtd)
|
|||||||
size_t retlen;
|
size_t retlen;
|
||||||
|
|
||||||
if (!strcmp(mtd->name, "MAC-Address")) {
|
if (!strcmp(mtd->name, "MAC-Address")) {
|
||||||
mtd->read(mtd, 0, ETH_ALEN, &retlen, mac_addr);
|
mtd_read(mtd, 0, ETH_ALEN, &retlen, mac_addr);
|
||||||
if (retlen == ETH_ALEN)
|
if (retlen == ETH_ALEN)
|
||||||
pr_info("Read MAC addr from SPI Flash: %pM\n",
|
pr_info("Read MAC addr from SPI Flash: %pM\n",
|
||||||
mac_addr);
|
mac_addr);
|
||||||
|
@ -413,8 +413,8 @@ static int __init init_axis_flash(void)
|
|||||||
} while (blockstat && ptable_sector);
|
} while (blockstat && ptable_sector);
|
||||||
#endif
|
#endif
|
||||||
if (ptable_sector) {
|
if (ptable_sector) {
|
||||||
main_mtd->read(main_mtd, ptable_sector, PAGESIZE,
|
mtd_read(main_mtd, ptable_sector, PAGESIZE, &len,
|
||||||
&len, page);
|
page);
|
||||||
ptable_head = &((struct partitiontable *) page)->head;
|
ptable_head = &((struct partitiontable *) page)->head;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ afs_read_footer(struct mtd_info *mtd, u_int *img_start, u_int *iis_start,
|
|||||||
size_t sz;
|
size_t sz;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = mtd->read(mtd, ptr, sizeof(fs), &sz, (u_char *) &fs);
|
ret = mtd_read(mtd, ptr, sizeof(fs), &sz, (u_char *)&fs);
|
||||||
if (ret >= 0 && sz != sizeof(fs))
|
if (ret >= 0 && sz != sizeof(fs))
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
|
|
||||||
@ -132,7 +132,7 @@ afs_read_iis(struct mtd_info *mtd, struct image_info_struct *iis, u_int ptr)
|
|||||||
int ret, i;
|
int ret, i;
|
||||||
|
|
||||||
memset(iis, 0, sizeof(*iis));
|
memset(iis, 0, sizeof(*iis));
|
||||||
ret = mtd->read(mtd, ptr, sizeof(*iis), &sz, (u_char *) iis);
|
ret = mtd_read(mtd, ptr, sizeof(*iis), &sz, (u_char *)iis);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto failed;
|
goto failed;
|
||||||
|
|
||||||
|
@ -73,8 +73,8 @@ static int create_mtd_partitions(struct mtd_info *master,
|
|||||||
|
|
||||||
do { /* Try 10 blocks starting from master->erasesize */
|
do { /* Try 10 blocks starting from master->erasesize */
|
||||||
offset = pre_size;
|
offset = pre_size;
|
||||||
master->read(master, offset,
|
mtd_read(master, offset, sizeof(header), &len,
|
||||||
sizeof(header), &len, (uint8_t *)&header);
|
(uint8_t *)&header);
|
||||||
if (!strncmp((char *)&header, "TIENV0.8", 8))
|
if (!strncmp((char *)&header, "TIENV0.8", 8))
|
||||||
ar7_parts[1].offset = pre_size;
|
ar7_parts[1].offset = pre_size;
|
||||||
if (header.checksum == LOADER_MAGIC1)
|
if (header.checksum == LOADER_MAGIC1)
|
||||||
@ -95,16 +95,16 @@ static int create_mtd_partitions(struct mtd_info *master,
|
|||||||
case LOADER_MAGIC1:
|
case LOADER_MAGIC1:
|
||||||
while (header.length) {
|
while (header.length) {
|
||||||
offset += sizeof(header) + header.length;
|
offset += sizeof(header) + header.length;
|
||||||
master->read(master, offset, sizeof(header),
|
mtd_read(master, offset, sizeof(header), &len,
|
||||||
&len, (uint8_t *)&header);
|
(uint8_t *)&header);
|
||||||
}
|
}
|
||||||
root_offset = offset + sizeof(header) + 4;
|
root_offset = offset + sizeof(header) + 4;
|
||||||
break;
|
break;
|
||||||
case LOADER_MAGIC2:
|
case LOADER_MAGIC2:
|
||||||
while (header.length) {
|
while (header.length) {
|
||||||
offset += sizeof(header) + header.length;
|
offset += sizeof(header) + header.length;
|
||||||
master->read(master, offset, sizeof(header),
|
mtd_read(master, offset, sizeof(header), &len,
|
||||||
&len, (uint8_t *)&header);
|
(uint8_t *)&header);
|
||||||
}
|
}
|
||||||
root_offset = offset + sizeof(header) + 4 + 0xff;
|
root_offset = offset + sizeof(header) + 4 + 0xff;
|
||||||
root_offset &= ~(uint32_t)0xff;
|
root_offset &= ~(uint32_t)0xff;
|
||||||
@ -114,8 +114,7 @@ static int create_mtd_partitions(struct mtd_info *master,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
master->read(master, root_offset,
|
mtd_read(master, root_offset, sizeof(header), &len, (u8 *)&header);
|
||||||
sizeof(header), &len, (u8 *)&header);
|
|
||||||
if (header.checksum != SQUASHFS_MAGIC) {
|
if (header.checksum != SQUASHFS_MAGIC) {
|
||||||
root_offset += master->erasesize - 1;
|
root_offset += master->erasesize - 1;
|
||||||
root_offset &= ~(master->erasesize - 1);
|
root_offset &= ~(master->erasesize - 1);
|
||||||
|
@ -48,8 +48,8 @@ static int bcm63xx_detect_cfe(struct mtd_info *master)
|
|||||||
int ret;
|
int ret;
|
||||||
size_t retlen;
|
size_t retlen;
|
||||||
|
|
||||||
ret = master->read(master, BCM963XX_CFE_VERSION_OFFSET, 5, &retlen,
|
ret = mtd_read(master, BCM963XX_CFE_VERSION_OFFSET, 5, &retlen,
|
||||||
(void *)buf);
|
(void *)buf);
|
||||||
buf[retlen] = 0;
|
buf[retlen] = 0;
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
@ -59,8 +59,8 @@ static int bcm63xx_detect_cfe(struct mtd_info *master)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* very old CFE's do not have the cfe-v string, so check for magic */
|
/* very old CFE's do not have the cfe-v string, so check for magic */
|
||||||
ret = master->read(master, BCM63XX_CFE_MAGIC_OFFSET, 8, &retlen,
|
ret = mtd_read(master, BCM63XX_CFE_MAGIC_OFFSET, 8, &retlen,
|
||||||
(void *)buf);
|
(void *)buf);
|
||||||
buf[retlen] = 0;
|
buf[retlen] = 0;
|
||||||
|
|
||||||
return strncmp("CFE1CFE1", buf, 8);
|
return strncmp("CFE1CFE1", buf, 8);
|
||||||
@ -95,8 +95,8 @@ static int bcm63xx_parse_cfe_partitions(struct mtd_info *master,
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
/* Get the tag */
|
/* Get the tag */
|
||||||
ret = master->read(master, cfelen, sizeof(struct bcm_tag), &retlen,
|
ret = mtd_read(master, cfelen, sizeof(struct bcm_tag), &retlen,
|
||||||
(void *)buf);
|
(void *)buf);
|
||||||
|
|
||||||
if (retlen != sizeof(struct bcm_tag)) {
|
if (retlen != sizeof(struct bcm_tag)) {
|
||||||
vfree(buf);
|
vfree(buf);
|
||||||
|
@ -168,8 +168,8 @@ static int scan_header(partition_t *part)
|
|||||||
(offset + sizeof(header)) < max_offset;
|
(offset + sizeof(header)) < max_offset;
|
||||||
offset += part->mbd.mtd->erasesize ? : 0x2000) {
|
offset += part->mbd.mtd->erasesize ? : 0x2000) {
|
||||||
|
|
||||||
err = part->mbd.mtd->read(part->mbd.mtd, offset, sizeof(header), &ret,
|
err = mtd_read(part->mbd.mtd, offset, sizeof(header), &ret,
|
||||||
(unsigned char *)&header);
|
(unsigned char *)&header);
|
||||||
|
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
@ -224,8 +224,8 @@ static int build_maps(partition_t *part)
|
|||||||
for (i = 0; i < le16_to_cpu(part->header.NumEraseUnits); i++) {
|
for (i = 0; i < le16_to_cpu(part->header.NumEraseUnits); i++) {
|
||||||
offset = ((i + le16_to_cpu(part->header.FirstPhysicalEUN))
|
offset = ((i + le16_to_cpu(part->header.FirstPhysicalEUN))
|
||||||
<< part->header.EraseUnitSize);
|
<< part->header.EraseUnitSize);
|
||||||
ret = part->mbd.mtd->read(part->mbd.mtd, offset, sizeof(header), &retval,
|
ret = mtd_read(part->mbd.mtd, offset, sizeof(header), &retval,
|
||||||
(unsigned char *)&header);
|
(unsigned char *)&header);
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out_XferInfo;
|
goto out_XferInfo;
|
||||||
@ -289,9 +289,9 @@ static int build_maps(partition_t *part)
|
|||||||
part->EUNInfo[i].Deleted = 0;
|
part->EUNInfo[i].Deleted = 0;
|
||||||
offset = part->EUNInfo[i].Offset + le32_to_cpu(header.BAMOffset);
|
offset = part->EUNInfo[i].Offset + le32_to_cpu(header.BAMOffset);
|
||||||
|
|
||||||
ret = part->mbd.mtd->read(part->mbd.mtd, offset,
|
ret = mtd_read(part->mbd.mtd, offset,
|
||||||
part->BlocksPerUnit * sizeof(uint32_t), &retval,
|
part->BlocksPerUnit * sizeof(uint32_t), &retval,
|
||||||
(unsigned char *)part->bam_cache);
|
(unsigned char *)part->bam_cache);
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out_bam_cache;
|
goto out_bam_cache;
|
||||||
@ -485,9 +485,9 @@ static int copy_erase_unit(partition_t *part, uint16_t srcunit,
|
|||||||
|
|
||||||
offset = eun->Offset + le32_to_cpu(part->header.BAMOffset);
|
offset = eun->Offset + le32_to_cpu(part->header.BAMOffset);
|
||||||
|
|
||||||
ret = part->mbd.mtd->read(part->mbd.mtd, offset,
|
ret = mtd_read(part->mbd.mtd, offset,
|
||||||
part->BlocksPerUnit * sizeof(uint32_t),
|
part->BlocksPerUnit * sizeof(uint32_t), &retlen,
|
||||||
&retlen, (u_char *) (part->bam_cache));
|
(u_char *)(part->bam_cache));
|
||||||
|
|
||||||
/* mark the cache bad, in case we get an error later */
|
/* mark the cache bad, in case we get an error later */
|
||||||
part->bam_index = 0xffff;
|
part->bam_index = 0xffff;
|
||||||
@ -523,8 +523,8 @@ static int copy_erase_unit(partition_t *part, uint16_t srcunit,
|
|||||||
break;
|
break;
|
||||||
case BLOCK_DATA:
|
case BLOCK_DATA:
|
||||||
case BLOCK_REPLACEMENT:
|
case BLOCK_REPLACEMENT:
|
||||||
ret = part->mbd.mtd->read(part->mbd.mtd, src, SECTOR_SIZE,
|
ret = mtd_read(part->mbd.mtd, src, SECTOR_SIZE, &retlen,
|
||||||
&retlen, (u_char *) buf);
|
(u_char *)buf);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
printk(KERN_WARNING "ftl: Error reading old xfer unit in copy_erase_unit\n");
|
printk(KERN_WARNING "ftl: Error reading old xfer unit in copy_erase_unit\n");
|
||||||
return ret;
|
return ret;
|
||||||
@ -747,10 +747,11 @@ static uint32_t find_free(partition_t *part)
|
|||||||
/* Invalidate cache */
|
/* Invalidate cache */
|
||||||
part->bam_index = 0xffff;
|
part->bam_index = 0xffff;
|
||||||
|
|
||||||
ret = part->mbd.mtd->read(part->mbd.mtd,
|
ret = mtd_read(part->mbd.mtd,
|
||||||
part->EUNInfo[eun].Offset + le32_to_cpu(part->header.BAMOffset),
|
part->EUNInfo[eun].Offset + le32_to_cpu(part->header.BAMOffset),
|
||||||
part->BlocksPerUnit * sizeof(uint32_t),
|
part->BlocksPerUnit * sizeof(uint32_t),
|
||||||
&retlen, (u_char *) (part->bam_cache));
|
&retlen,
|
||||||
|
(u_char *)(part->bam_cache));
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
printk(KERN_WARNING"ftl: Error reading BAM in find_free\n");
|
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,
|
|||||||
else {
|
else {
|
||||||
offset = (part->EUNInfo[log_addr / bsize].Offset
|
offset = (part->EUNInfo[log_addr / bsize].Offset
|
||||||
+ (log_addr % bsize));
|
+ (log_addr % bsize));
|
||||||
ret = part->mbd.mtd->read(part->mbd.mtd, offset, SECTOR_SIZE,
|
ret = mtd_read(part->mbd.mtd, offset, SECTOR_SIZE, &retlen,
|
||||||
&retlen, (u_char *) buffer);
|
(u_char *)buffer);
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
printk(KERN_WARNING "Error reading MTD device in ftl_read()\n");
|
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,
|
|||||||
le32_to_cpu(part->header.BAMOffset));
|
le32_to_cpu(part->header.BAMOffset));
|
||||||
|
|
||||||
#ifdef PSYCHO_DEBUG
|
#ifdef PSYCHO_DEBUG
|
||||||
ret = part->mbd.mtd->read(part->mbd.mtd, offset, sizeof(uint32_t),
|
ret = mtd_read(part->mbd.mtd, offset, sizeof(uint32_t), &retlen,
|
||||||
&retlen, (u_char *)&old_addr);
|
(u_char *)&old_addr);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
printk(KERN_WARNING"ftl: Error reading old_addr in set_bam_entry: %d\n",ret);
|
printk(KERN_WARNING"ftl: Error reading old_addr in set_bam_entry: %d\n",ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -343,14 +343,17 @@ static u16 INFTL_foldchain(struct INFTLrecord *inftl, unsigned thisVUC, unsigned
|
|||||||
if (BlockMap[block] == BLOCK_NIL)
|
if (BlockMap[block] == BLOCK_NIL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ret = mtd->read(mtd, (inftl->EraseSize * BlockMap[block]) +
|
ret = mtd_read(mtd,
|
||||||
(block * SECTORSIZE), SECTORSIZE, &retlen,
|
(inftl->EraseSize * BlockMap[block]) + (block * SECTORSIZE),
|
||||||
movebuf);
|
SECTORSIZE,
|
||||||
|
&retlen,
|
||||||
|
movebuf);
|
||||||
if (ret < 0 && !mtd_is_bitflip(ret)) {
|
if (ret < 0 && !mtd_is_bitflip(ret)) {
|
||||||
ret = mtd->read(mtd,
|
ret = mtd_read(mtd,
|
||||||
(inftl->EraseSize * BlockMap[block]) +
|
(inftl->EraseSize * BlockMap[block]) + (block * SECTORSIZE),
|
||||||
(block * SECTORSIZE), SECTORSIZE,
|
SECTORSIZE,
|
||||||
&retlen, movebuf);
|
&retlen,
|
||||||
|
movebuf);
|
||||||
if (ret != -EIO)
|
if (ret != -EIO)
|
||||||
pr_debug("INFTL: error went away on retry?\n");
|
pr_debug("INFTL: error went away on retry?\n");
|
||||||
}
|
}
|
||||||
@ -914,7 +917,7 @@ foundit:
|
|||||||
} else {
|
} else {
|
||||||
size_t retlen;
|
size_t retlen;
|
||||||
loff_t ptr = (thisEUN * inftl->EraseSize) + blockofs;
|
loff_t ptr = (thisEUN * inftl->EraseSize) + blockofs;
|
||||||
int ret = mtd->read(mtd, ptr, SECTORSIZE, &retlen, buffer);
|
int ret = mtd_read(mtd, ptr, SECTORSIZE, &retlen, buffer);
|
||||||
|
|
||||||
/* Handle corrected bit flips gracefully */
|
/* Handle corrected bit flips gracefully */
|
||||||
if (ret < 0 && !mtd_is_bitflip(ret))
|
if (ret < 0 && !mtd_is_bitflip(ret))
|
||||||
|
@ -73,8 +73,8 @@ static int find_boot_record(struct INFTLrecord *inftl)
|
|||||||
* Check for BNAND header first. Then whinge if it's found
|
* Check for BNAND header first. Then whinge if it's found
|
||||||
* but later checks fail.
|
* but later checks fail.
|
||||||
*/
|
*/
|
||||||
ret = mtd->read(mtd, block * inftl->EraseSize,
|
ret = mtd_read(mtd, block * inftl->EraseSize, SECTORSIZE,
|
||||||
SECTORSIZE, &retlen, buf);
|
&retlen, buf);
|
||||||
/* We ignore ret in case the ECC of the MediaHeader is invalid
|
/* We ignore ret in case the ECC of the MediaHeader is invalid
|
||||||
(which is apparently acceptable) */
|
(which is apparently acceptable) */
|
||||||
if (retlen != SECTORSIZE) {
|
if (retlen != SECTORSIZE) {
|
||||||
@ -118,8 +118,8 @@ static int find_boot_record(struct INFTLrecord *inftl)
|
|||||||
memcpy(mh, buf, sizeof(struct INFTLMediaHeader));
|
memcpy(mh, buf, sizeof(struct INFTLMediaHeader));
|
||||||
|
|
||||||
/* Read the spare media header at offset 4096 */
|
/* Read the spare media header at offset 4096 */
|
||||||
mtd->read(mtd, block * inftl->EraseSize + 4096,
|
mtd_read(mtd, block * inftl->EraseSize + 4096, SECTORSIZE,
|
||||||
SECTORSIZE, &retlen, buf);
|
&retlen, buf);
|
||||||
if (retlen != SECTORSIZE) {
|
if (retlen != SECTORSIZE) {
|
||||||
printk(KERN_WARNING "INFTL: Unable to read spare "
|
printk(KERN_WARNING "INFTL: Unable to read spare "
|
||||||
"Media Header\n");
|
"Media Header\n");
|
||||||
@ -342,7 +342,7 @@ static int check_free_sectors(struct INFTLrecord *inftl, unsigned int address,
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < len; i += SECTORSIZE) {
|
for (i = 0; i < len; i += SECTORSIZE) {
|
||||||
if (mtd->read(mtd, address, SECTORSIZE, &retlen, buf))
|
if (mtd_read(mtd, address, SECTORSIZE, &retlen, buf))
|
||||||
return -1;
|
return -1;
|
||||||
if (memcmpb(buf, 0xff, SECTORSIZE) != 0)
|
if (memcmpb(buf, 0xff, SECTORSIZE) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -184,8 +184,8 @@ static int do_cached_write (struct mtdblk_dev *mtdblk, unsigned long pos,
|
|||||||
mtdblk->cache_offset != sect_start) {
|
mtdblk->cache_offset != sect_start) {
|
||||||
/* fill the cache with the current sector */
|
/* fill the cache with the current sector */
|
||||||
mtdblk->cache_state = STATE_EMPTY;
|
mtdblk->cache_state = STATE_EMPTY;
|
||||||
ret = mtd->read(mtd, sect_start, sect_size,
|
ret = mtd_read(mtd, sect_start, sect_size,
|
||||||
&retlen, mtdblk->cache_data);
|
&retlen, mtdblk->cache_data);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
if (retlen != sect_size)
|
if (retlen != sect_size)
|
||||||
@ -222,7 +222,7 @@ static int do_cached_read (struct mtdblk_dev *mtdblk, unsigned long pos,
|
|||||||
mtd->name, pos, len);
|
mtd->name, pos, len);
|
||||||
|
|
||||||
if (!sect_size)
|
if (!sect_size)
|
||||||
return mtd->read(mtd, pos, len, &retlen, buf);
|
return mtd_read(mtd, pos, len, &retlen, buf);
|
||||||
|
|
||||||
while (len > 0) {
|
while (len > 0) {
|
||||||
unsigned long sect_start = (pos/sect_size)*sect_size;
|
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,
|
|||||||
mtdblk->cache_offset == sect_start) {
|
mtdblk->cache_offset == sect_start) {
|
||||||
memcpy (buf, mtdblk->cache_data + offset, size);
|
memcpy (buf, mtdblk->cache_data + offset, size);
|
||||||
} else {
|
} else {
|
||||||
ret = mtd->read(mtd, pos, size, &retlen, buf);
|
ret = mtd_read(mtd, pos, size, &retlen, buf);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
if (retlen != size)
|
if (retlen != size)
|
||||||
|
@ -30,7 +30,7 @@ static int mtdblock_readsect(struct mtd_blktrans_dev *dev,
|
|||||||
{
|
{
|
||||||
size_t retlen;
|
size_t retlen;
|
||||||
|
|
||||||
if (dev->mtd->read(dev->mtd, (block * 512), 512, &retlen, buf))
|
if (mtd_read(dev->mtd, (block * 512), 512, &retlen, buf))
|
||||||
return 1;
|
return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -232,7 +232,7 @@ static ssize_t mtdchar_read(struct file *file, char __user *buf, size_t count,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
ret = mtd->read(mtd, *ppos, len, &retlen, kbuf);
|
ret = mtd_read(mtd, *ppos, len, &retlen, kbuf);
|
||||||
}
|
}
|
||||||
/* Nand returns -EBADMSG on ECC errors, but it returns
|
/* Nand returns -EBADMSG on ECC errors, but it returns
|
||||||
* the data. For our userspace tools it is important
|
* the data. For our userspace tools it is important
|
||||||
|
@ -91,7 +91,7 @@ concat_read(struct mtd_info *mtd, loff_t from, size_t len,
|
|||||||
/* Entire transaction goes into this subdev */
|
/* Entire transaction goes into this subdev */
|
||||||
size = len;
|
size = len;
|
||||||
|
|
||||||
err = subdev->read(subdev, from, size, &retsize, buf);
|
err = mtd_read(subdev, from, size, &retsize, buf);
|
||||||
|
|
||||||
/* Save information about bitflips! */
|
/* Save information about bitflips! */
|
||||||
if (unlikely(err)) {
|
if (unlikely(err)) {
|
||||||
|
@ -258,8 +258,8 @@ static void find_next_position(struct mtdoops_context *cxt)
|
|||||||
continue;
|
continue;
|
||||||
/* Assume the page is used */
|
/* Assume the page is used */
|
||||||
mark_page_used(cxt, page);
|
mark_page_used(cxt, page);
|
||||||
ret = mtd->read(mtd, page * record_size, MTDOOPS_HEADER_SIZE,
|
ret = mtd_read(mtd, page * record_size, MTDOOPS_HEADER_SIZE,
|
||||||
&retlen, (u_char *) &count[0]);
|
&retlen, (u_char *)&count[0]);
|
||||||
if (retlen != MTDOOPS_HEADER_SIZE ||
|
if (retlen != MTDOOPS_HEADER_SIZE ||
|
||||||
(ret < 0 && !mtd_is_bitflip(ret))) {
|
(ret < 0 && !mtd_is_bitflip(ret))) {
|
||||||
printk(KERN_ERR "mtdoops: read failure at %ld (%td of %d read), err %d\n",
|
printk(KERN_ERR "mtdoops: read failure at %ld (%td of %d read), err %d\n",
|
||||||
|
@ -70,8 +70,7 @@ static int part_read(struct mtd_info *mtd, loff_t from, size_t len,
|
|||||||
len = 0;
|
len = 0;
|
||||||
else if (from + len > mtd->size)
|
else if (from + len > mtd->size)
|
||||||
len = mtd->size - from;
|
len = mtd->size - from;
|
||||||
res = part->master->read(part->master, from + part->offset,
|
res = mtd_read(part->master, from + part->offset, len, retlen, buf);
|
||||||
len, retlen, buf);
|
|
||||||
if (unlikely(res)) {
|
if (unlikely(res)) {
|
||||||
if (mtd_is_bitflip(res))
|
if (mtd_is_bitflip(res))
|
||||||
mtd->ecc_stats.corrected += part->master->ecc_stats.corrected - stats.corrected;
|
mtd->ecc_stats.corrected += part->master->ecc_stats.corrected - stats.corrected;
|
||||||
|
@ -736,7 +736,7 @@ static int mtdswap_move_block(struct mtdswap_dev *d, unsigned int oldblock,
|
|||||||
retries = 0;
|
retries = 0;
|
||||||
|
|
||||||
retry:
|
retry:
|
||||||
ret = mtd->read(mtd, readpos, PAGE_SIZE, &retlen, d->page_buf);
|
ret = mtd_read(mtd, readpos, PAGE_SIZE, &retlen, d->page_buf);
|
||||||
|
|
||||||
if (ret < 0 && !mtd_is_bitflip(ret)) {
|
if (ret < 0 && !mtd_is_bitflip(ret)) {
|
||||||
oldeb = d->eb_data + oldblock / d->pages_per_eblk;
|
oldeb = d->eb_data + oldblock / d->pages_per_eblk;
|
||||||
@ -1161,7 +1161,7 @@ static int mtdswap_readsect(struct mtd_blktrans_dev *dev,
|
|||||||
retries = 0;
|
retries = 0;
|
||||||
|
|
||||||
retry:
|
retry:
|
||||||
ret = mtd->read(mtd, readpos, PAGE_SIZE, &retlen, buf);
|
ret = mtd_read(mtd, readpos, PAGE_SIZE, &retlen, buf);
|
||||||
|
|
||||||
d->mtd_read_count++;
|
d->mtd_read_count++;
|
||||||
if (mtd_is_bitflip(ret)) {
|
if (mtd_is_bitflip(ret)) {
|
||||||
|
@ -1072,7 +1072,7 @@ static int __init find_media_headers(struct mtd_info *mtd, u_char *buf, const ch
|
|||||||
size_t retlen;
|
size_t retlen;
|
||||||
|
|
||||||
for (offs = 0; offs < mtd->size; offs += mtd->erasesize) {
|
for (offs = 0; offs < mtd->size; offs += mtd->erasesize) {
|
||||||
ret = mtd->read(mtd, offs, mtd->writesize, &retlen, buf);
|
ret = mtd_read(mtd, offs, mtd->writesize, &retlen, buf);
|
||||||
if (retlen != mtd->writesize)
|
if (retlen != mtd->writesize)
|
||||||
continue;
|
continue;
|
||||||
if (ret) {
|
if (ret) {
|
||||||
@ -1097,7 +1097,7 @@ static int __init find_media_headers(struct mtd_info *mtd, u_char *buf, const ch
|
|||||||
/* Only one mediaheader was found. We want buf to contain a
|
/* Only one mediaheader was found. We want buf to contain a
|
||||||
mediaheader on return, so we'll have to re-read the one we found. */
|
mediaheader on return, so we'll have to re-read the one we found. */
|
||||||
offs = doc->mh0_page << this->page_shift;
|
offs = doc->mh0_page << this->page_shift;
|
||||||
ret = mtd->read(mtd, offs, mtd->writesize, &retlen, buf);
|
ret = mtd_read(mtd, offs, mtd->writesize, &retlen, buf);
|
||||||
if (retlen != mtd->writesize) {
|
if (retlen != mtd->writesize) {
|
||||||
/* Insanity. Give up. */
|
/* Insanity. Give up. */
|
||||||
printk(KERN_ERR "Read DiskOnChip Media Header once, but can't reread it???\n");
|
printk(KERN_ERR "Read DiskOnChip Media Header once, but can't reread it???\n");
|
||||||
|
@ -201,7 +201,7 @@ static int read_bbt(struct mtd_info *mtd, uint8_t *buf, int page, int num,
|
|||||||
from += marker_len;
|
from += marker_len;
|
||||||
marker_len = 0;
|
marker_len = 0;
|
||||||
}
|
}
|
||||||
res = mtd->read(mtd, from, len, &retlen, buf);
|
res = mtd_read(mtd, from, len, &retlen, buf);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
if (mtd_is_eccerr(res)) {
|
if (mtd_is_eccerr(res)) {
|
||||||
pr_info("nand_bbt: ECC error in BBT at "
|
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,
|
|||||||
if (td->options & NAND_BBT_VERSION)
|
if (td->options & NAND_BBT_VERSION)
|
||||||
len++;
|
len++;
|
||||||
|
|
||||||
return mtd->read(mtd, offs, len, &retlen, buf);
|
return mtd_read(mtd, offs, len, &retlen, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Scan read raw data from flash */
|
/* Scan read raw data from flash */
|
||||||
@ -756,7 +756,7 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf,
|
|||||||
/* Make it block aligned */
|
/* Make it block aligned */
|
||||||
to &= ~((loff_t)((1 << this->bbt_erase_shift) - 1));
|
to &= ~((loff_t)((1 << this->bbt_erase_shift) - 1));
|
||||||
len = 1 << this->bbt_erase_shift;
|
len = 1 << this->bbt_erase_shift;
|
||||||
res = mtd->read(mtd, to, len, &retlen, buf);
|
res = mtd_read(mtd, to, len, &retlen, buf);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
if (retlen != len) {
|
if (retlen != len) {
|
||||||
pr_info("nand_bbt: error reading block "
|
pr_info("nand_bbt: error reading block "
|
||||||
|
@ -423,12 +423,17 @@ static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned p
|
|||||||
if (BlockMap[block] == BLOCK_NIL)
|
if (BlockMap[block] == BLOCK_NIL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ret = mtd->read(mtd, (nftl->EraseSize * BlockMap[block]) + (block * 512),
|
ret = mtd_read(mtd,
|
||||||
512, &retlen, movebuf);
|
(nftl->EraseSize * BlockMap[block]) + (block * 512),
|
||||||
|
512,
|
||||||
|
&retlen,
|
||||||
|
movebuf);
|
||||||
if (ret < 0 && !mtd_is_bitflip(ret)) {
|
if (ret < 0 && !mtd_is_bitflip(ret)) {
|
||||||
ret = mtd->read(mtd, (nftl->EraseSize * BlockMap[block])
|
ret = mtd_read(mtd,
|
||||||
+ (block * 512), 512, &retlen,
|
(nftl->EraseSize * BlockMap[block]) + (block * 512),
|
||||||
movebuf);
|
512,
|
||||||
|
&retlen,
|
||||||
|
movebuf);
|
||||||
if (ret != -EIO)
|
if (ret != -EIO)
|
||||||
printk("Error went away on retry.\n");
|
printk("Error went away on retry.\n");
|
||||||
}
|
}
|
||||||
@ -771,7 +776,7 @@ static int nftl_readblock(struct mtd_blktrans_dev *mbd, unsigned long block,
|
|||||||
} else {
|
} else {
|
||||||
loff_t ptr = (lastgoodEUN * nftl->EraseSize) + blockofs;
|
loff_t ptr = (lastgoodEUN * nftl->EraseSize) + blockofs;
|
||||||
size_t retlen;
|
size_t retlen;
|
||||||
int res = mtd->read(mtd, ptr, 512, &retlen, buffer);
|
int res = mtd_read(mtd, ptr, 512, &retlen, buffer);
|
||||||
|
|
||||||
if (res < 0 && !mtd_is_bitflip(res))
|
if (res < 0 && !mtd_is_bitflip(res))
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
@ -63,8 +63,8 @@ static int find_boot_record(struct NFTLrecord *nftl)
|
|||||||
|
|
||||||
/* Check for ANAND header first. Then can whinge if it's found but later
|
/* Check for ANAND header first. Then can whinge if it's found but later
|
||||||
checks fail */
|
checks fail */
|
||||||
ret = mtd->read(mtd, block * nftl->EraseSize, SECTORSIZE,
|
ret = mtd_read(mtd, block * nftl->EraseSize, SECTORSIZE,
|
||||||
&retlen, buf);
|
&retlen, buf);
|
||||||
/* We ignore ret in case the ECC of the MediaHeader is invalid
|
/* We ignore ret in case the ECC of the MediaHeader is invalid
|
||||||
(which is apparently acceptable) */
|
(which is apparently acceptable) */
|
||||||
if (retlen != SECTORSIZE) {
|
if (retlen != SECTORSIZE) {
|
||||||
@ -274,7 +274,7 @@ static int check_free_sectors(struct NFTLrecord *nftl, unsigned int address, int
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < len; i += SECTORSIZE) {
|
for (i = 0; i < len; i += SECTORSIZE) {
|
||||||
if (mtd->read(mtd, address, SECTORSIZE, &retlen, buf))
|
if (mtd_read(mtd, address, SECTORSIZE, &retlen, buf))
|
||||||
return -1;
|
return -1;
|
||||||
if (memcmpb(buf, 0xff, SECTORSIZE) != 0)
|
if (memcmpb(buf, 0xff, SECTORSIZE) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -104,8 +104,8 @@ static int parse_redboot_partitions(struct mtd_info *master,
|
|||||||
printk(KERN_NOTICE "Searching for RedBoot partition table in %s at offset 0x%lx\n",
|
printk(KERN_NOTICE "Searching for RedBoot partition table in %s at offset 0x%lx\n",
|
||||||
master->name, offset);
|
master->name, offset);
|
||||||
|
|
||||||
ret = master->read(master, offset,
|
ret = mtd_read(master, offset, master->erasesize, &retlen,
|
||||||
master->erasesize, &retlen, (void *)buf);
|
(void *)buf);
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -200,9 +200,9 @@ static int scan_header(struct partition *part)
|
|||||||
part->sector_map[i] = -1;
|
part->sector_map[i] = -1;
|
||||||
|
|
||||||
for (i=0, blocks_found=0; i<part->total_blocks; i++) {
|
for (i=0, blocks_found=0; i<part->total_blocks; i++) {
|
||||||
rc = part->mbd.mtd->read(part->mbd.mtd,
|
rc = mtd_read(part->mbd.mtd, i * part->block_size,
|
||||||
i * part->block_size, part->header_size,
|
part->header_size, &retlen,
|
||||||
&retlen, (u_char*)part->header_cache);
|
(u_char *)part->header_cache);
|
||||||
|
|
||||||
if (!rc && retlen != part->header_size)
|
if (!rc && retlen != part->header_size)
|
||||||
rc = -EIO;
|
rc = -EIO;
|
||||||
@ -250,8 +250,8 @@ static int rfd_ftl_readsect(struct mtd_blktrans_dev *dev, u_long sector, char *b
|
|||||||
|
|
||||||
addr = part->sector_map[sector];
|
addr = part->sector_map[sector];
|
||||||
if (addr != -1) {
|
if (addr != -1) {
|
||||||
rc = part->mbd.mtd->read(part->mbd.mtd, addr, SECTOR_SIZE,
|
rc = mtd_read(part->mbd.mtd, addr, SECTOR_SIZE, &retlen,
|
||||||
&retlen, (u_char*)buf);
|
(u_char *)buf);
|
||||||
if (!rc && retlen != SECTOR_SIZE)
|
if (!rc && retlen != SECTOR_SIZE)
|
||||||
rc = -EIO;
|
rc = -EIO;
|
||||||
|
|
||||||
@ -372,9 +372,8 @@ static int move_block_contents(struct partition *part, int block_no, u_long *old
|
|||||||
if (!map)
|
if (!map)
|
||||||
goto err2;
|
goto err2;
|
||||||
|
|
||||||
rc = part->mbd.mtd->read(part->mbd.mtd,
|
rc = mtd_read(part->mbd.mtd, part->blocks[block_no].offset,
|
||||||
part->blocks[block_no].offset, part->header_size,
|
part->header_size, &retlen, (u_char *)map);
|
||||||
&retlen, (u_char*)map);
|
|
||||||
|
|
||||||
if (!rc && retlen != part->header_size)
|
if (!rc && retlen != part->header_size)
|
||||||
rc = -EIO;
|
rc = -EIO;
|
||||||
@ -413,8 +412,8 @@ static int move_block_contents(struct partition *part, int block_no, u_long *old
|
|||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
rc = part->mbd.mtd->read(part->mbd.mtd, addr,
|
rc = mtd_read(part->mbd.mtd, addr, SECTOR_SIZE, &retlen,
|
||||||
SECTOR_SIZE, &retlen, sector_data);
|
sector_data);
|
||||||
|
|
||||||
if (!rc && retlen != SECTOR_SIZE)
|
if (!rc && retlen != SECTOR_SIZE)
|
||||||
rc = -EIO;
|
rc = -EIO;
|
||||||
@ -563,8 +562,9 @@ static int find_writable_block(struct partition *part, u_long *old_sector)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = part->mbd.mtd->read(part->mbd.mtd, part->blocks[block].offset,
|
rc = mtd_read(part->mbd.mtd, part->blocks[block].offset,
|
||||||
part->header_size, &retlen, (u_char*)part->header_cache);
|
part->header_size, &retlen,
|
||||||
|
(u_char *)part->header_cache);
|
||||||
|
|
||||||
if (!rc && retlen != part->header_size)
|
if (!rc && retlen != part->header_size)
|
||||||
rc = -EIO;
|
rc = -EIO;
|
||||||
|
@ -123,8 +123,8 @@ static int get_valid_cis_sector(struct mtd_info *mtd)
|
|||||||
*/
|
*/
|
||||||
for (k = 0, offset = 0; k < 4; k++, offset += mtd->erasesize) {
|
for (k = 0, offset = 0; k < 4; k++, offset += mtd->erasesize) {
|
||||||
if (!mtd->block_isbad(mtd, offset)) {
|
if (!mtd->block_isbad(mtd, offset)) {
|
||||||
ret = mtd->read(mtd, offset, SECTOR_SIZE, &retlen,
|
ret = mtd_read(mtd, offset, SECTOR_SIZE, &retlen,
|
||||||
sect_buf);
|
sect_buf);
|
||||||
|
|
||||||
/* CIS pattern match on the sector buffer */
|
/* CIS pattern match on the sector buffer */
|
||||||
if (ret < 0 || retlen != SECTOR_SIZE) {
|
if (ret < 0 || retlen != SECTOR_SIZE) {
|
||||||
@ -156,7 +156,7 @@ static int read_physical_sector(struct mtd_info *mtd, uint8_t *sect_buf,
|
|||||||
size_t retlen;
|
size_t retlen;
|
||||||
loff_t offset = (loff_t)sect_no << SECTOR_SHIFT;
|
loff_t offset = (loff_t)sect_no << SECTOR_SHIFT;
|
||||||
|
|
||||||
ret = mtd->read(mtd, offset, SECTOR_SIZE, &retlen, sect_buf);
|
ret = mtd_read(mtd, offset, SECTOR_SIZE, &retlen, sect_buf);
|
||||||
if (ret < 0 || retlen != SECTOR_SIZE)
|
if (ret < 0 || retlen != SECTOR_SIZE)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ static int verify_eraseblock(int ebnum)
|
|||||||
set_random_data(writebuf, mtd->erasesize);
|
set_random_data(writebuf, mtd->erasesize);
|
||||||
for (j = 0; j < pgcnt - 1; ++j, addr += pgsize) {
|
for (j = 0; j < pgcnt - 1; ++j, addr += pgsize) {
|
||||||
/* Do a read to set the internal dataRAMs to different data */
|
/* Do a read to set the internal dataRAMs to different data */
|
||||||
err = mtd->read(mtd, addr0, bufsize, &read, twopages);
|
err = mtd_read(mtd, addr0, bufsize, &read, twopages);
|
||||||
if (mtd_is_bitflip(err))
|
if (mtd_is_bitflip(err))
|
||||||
err = 0;
|
err = 0;
|
||||||
if (err || read != bufsize) {
|
if (err || read != bufsize) {
|
||||||
@ -135,7 +135,7 @@ static int verify_eraseblock(int ebnum)
|
|||||||
(long long)addr0);
|
(long long)addr0);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
err = mtd->read(mtd, addrn - bufsize, bufsize, &read, twopages);
|
err = mtd_read(mtd, addrn - bufsize, bufsize, &read, twopages);
|
||||||
if (mtd_is_bitflip(err))
|
if (mtd_is_bitflip(err))
|
||||||
err = 0;
|
err = 0;
|
||||||
if (err || read != bufsize) {
|
if (err || read != bufsize) {
|
||||||
@ -145,7 +145,7 @@ static int verify_eraseblock(int ebnum)
|
|||||||
}
|
}
|
||||||
memset(twopages, 0, bufsize);
|
memset(twopages, 0, bufsize);
|
||||||
read = 0;
|
read = 0;
|
||||||
err = mtd->read(mtd, addr, bufsize, &read, twopages);
|
err = mtd_read(mtd, addr, bufsize, &read, twopages);
|
||||||
if (mtd_is_bitflip(err))
|
if (mtd_is_bitflip(err))
|
||||||
err = 0;
|
err = 0;
|
||||||
if (err || read != bufsize) {
|
if (err || read != bufsize) {
|
||||||
@ -163,7 +163,7 @@ static int verify_eraseblock(int ebnum)
|
|||||||
if (addr <= addrn - pgsize - pgsize && !bbt[ebnum + 1]) {
|
if (addr <= addrn - pgsize - pgsize && !bbt[ebnum + 1]) {
|
||||||
unsigned long oldnext = next;
|
unsigned long oldnext = next;
|
||||||
/* Do a read to set the internal dataRAMs to different data */
|
/* Do a read to set the internal dataRAMs to different data */
|
||||||
err = mtd->read(mtd, addr0, bufsize, &read, twopages);
|
err = mtd_read(mtd, addr0, bufsize, &read, twopages);
|
||||||
if (mtd_is_bitflip(err))
|
if (mtd_is_bitflip(err))
|
||||||
err = 0;
|
err = 0;
|
||||||
if (err || read != bufsize) {
|
if (err || read != bufsize) {
|
||||||
@ -171,7 +171,7 @@ static int verify_eraseblock(int ebnum)
|
|||||||
(long long)addr0);
|
(long long)addr0);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
err = mtd->read(mtd, addrn - bufsize, bufsize, &read, twopages);
|
err = mtd_read(mtd, addrn - bufsize, bufsize, &read, twopages);
|
||||||
if (mtd_is_bitflip(err))
|
if (mtd_is_bitflip(err))
|
||||||
err = 0;
|
err = 0;
|
||||||
if (err || read != bufsize) {
|
if (err || read != bufsize) {
|
||||||
@ -181,7 +181,7 @@ static int verify_eraseblock(int ebnum)
|
|||||||
}
|
}
|
||||||
memset(twopages, 0, bufsize);
|
memset(twopages, 0, bufsize);
|
||||||
read = 0;
|
read = 0;
|
||||||
err = mtd->read(mtd, addr, bufsize, &read, twopages);
|
err = mtd_read(mtd, addr, bufsize, &read, twopages);
|
||||||
if (mtd_is_bitflip(err))
|
if (mtd_is_bitflip(err))
|
||||||
err = 0;
|
err = 0;
|
||||||
if (err || read != bufsize) {
|
if (err || read != bufsize) {
|
||||||
@ -230,7 +230,7 @@ static int crosstest(void)
|
|||||||
/* Read 2nd-to-last page to pp1 */
|
/* Read 2nd-to-last page to pp1 */
|
||||||
read = 0;
|
read = 0;
|
||||||
addr = addrn - pgsize - pgsize;
|
addr = addrn - pgsize - pgsize;
|
||||||
err = mtd->read(mtd, addr, pgsize, &read, pp1);
|
err = mtd_read(mtd, addr, pgsize, &read, pp1);
|
||||||
if (mtd_is_bitflip(err))
|
if (mtd_is_bitflip(err))
|
||||||
err = 0;
|
err = 0;
|
||||||
if (err || read != pgsize) {
|
if (err || read != pgsize) {
|
||||||
@ -243,7 +243,7 @@ static int crosstest(void)
|
|||||||
/* Read 3rd-to-last page to pp1 */
|
/* Read 3rd-to-last page to pp1 */
|
||||||
read = 0;
|
read = 0;
|
||||||
addr = addrn - pgsize - pgsize - pgsize;
|
addr = addrn - pgsize - pgsize - pgsize;
|
||||||
err = mtd->read(mtd, addr, pgsize, &read, pp1);
|
err = mtd_read(mtd, addr, pgsize, &read, pp1);
|
||||||
if (mtd_is_bitflip(err))
|
if (mtd_is_bitflip(err))
|
||||||
err = 0;
|
err = 0;
|
||||||
if (err || read != pgsize) {
|
if (err || read != pgsize) {
|
||||||
@ -257,7 +257,7 @@ static int crosstest(void)
|
|||||||
read = 0;
|
read = 0;
|
||||||
addr = addr0;
|
addr = addr0;
|
||||||
printk(PRINT_PREF "reading page at %#llx\n", (long long)addr);
|
printk(PRINT_PREF "reading page at %#llx\n", (long long)addr);
|
||||||
err = mtd->read(mtd, addr, pgsize, &read, pp2);
|
err = mtd_read(mtd, addr, pgsize, &read, pp2);
|
||||||
if (mtd_is_bitflip(err))
|
if (mtd_is_bitflip(err))
|
||||||
err = 0;
|
err = 0;
|
||||||
if (err || read != pgsize) {
|
if (err || read != pgsize) {
|
||||||
@ -271,7 +271,7 @@ static int crosstest(void)
|
|||||||
read = 0;
|
read = 0;
|
||||||
addr = addrn - pgsize;
|
addr = addrn - pgsize;
|
||||||
printk(PRINT_PREF "reading page at %#llx\n", (long long)addr);
|
printk(PRINT_PREF "reading page at %#llx\n", (long long)addr);
|
||||||
err = mtd->read(mtd, addr, pgsize, &read, pp3);
|
err = mtd_read(mtd, addr, pgsize, &read, pp3);
|
||||||
if (mtd_is_bitflip(err))
|
if (mtd_is_bitflip(err))
|
||||||
err = 0;
|
err = 0;
|
||||||
if (err || read != pgsize) {
|
if (err || read != pgsize) {
|
||||||
@ -285,7 +285,7 @@ static int crosstest(void)
|
|||||||
read = 0;
|
read = 0;
|
||||||
addr = addr0;
|
addr = addr0;
|
||||||
printk(PRINT_PREF "reading page at %#llx\n", (long long)addr);
|
printk(PRINT_PREF "reading page at %#llx\n", (long long)addr);
|
||||||
err = mtd->read(mtd, addr, pgsize, &read, pp4);
|
err = mtd_read(mtd, addr, pgsize, &read, pp4);
|
||||||
if (mtd_is_bitflip(err))
|
if (mtd_is_bitflip(err))
|
||||||
err = 0;
|
err = 0;
|
||||||
if (err || read != pgsize) {
|
if (err || read != pgsize) {
|
||||||
@ -344,7 +344,7 @@ static int erasecrosstest(void)
|
|||||||
|
|
||||||
printk(PRINT_PREF "reading 1st page of block %d\n", ebnum);
|
printk(PRINT_PREF "reading 1st page of block %d\n", ebnum);
|
||||||
memset(readbuf, 0, pgsize);
|
memset(readbuf, 0, pgsize);
|
||||||
err = mtd->read(mtd, addr0, pgsize, &read, readbuf);
|
err = mtd_read(mtd, addr0, pgsize, &read, readbuf);
|
||||||
if (mtd_is_bitflip(err))
|
if (mtd_is_bitflip(err))
|
||||||
err = 0;
|
err = 0;
|
||||||
if (err || read != pgsize) {
|
if (err || read != pgsize) {
|
||||||
@ -382,7 +382,7 @@ static int erasecrosstest(void)
|
|||||||
|
|
||||||
printk(PRINT_PREF "reading 1st page of block %d\n", ebnum);
|
printk(PRINT_PREF "reading 1st page of block %d\n", ebnum);
|
||||||
memset(readbuf, 0, pgsize);
|
memset(readbuf, 0, pgsize);
|
||||||
err = mtd->read(mtd, addr0, pgsize, &read, readbuf);
|
err = mtd_read(mtd, addr0, pgsize, &read, readbuf);
|
||||||
if (mtd_is_bitflip(err))
|
if (mtd_is_bitflip(err))
|
||||||
err = 0;
|
err = 0;
|
||||||
if (err || read != pgsize) {
|
if (err || read != pgsize) {
|
||||||
@ -438,7 +438,7 @@ static int erasetest(void)
|
|||||||
return err;
|
return err;
|
||||||
|
|
||||||
printk(PRINT_PREF "reading 1st page of block %d\n", ebnum);
|
printk(PRINT_PREF "reading 1st page of block %d\n", ebnum);
|
||||||
err = mtd->read(mtd, addr0, pgsize, &read, twopages);
|
err = mtd_read(mtd, addr0, pgsize, &read, twopages);
|
||||||
if (mtd_is_bitflip(err))
|
if (mtd_is_bitflip(err))
|
||||||
err = 0;
|
err = 0;
|
||||||
if (err || read != pgsize) {
|
if (err || read != pgsize) {
|
||||||
|
@ -52,7 +52,7 @@ static int read_eraseblock_by_page(int ebnum)
|
|||||||
|
|
||||||
for (i = 0; i < pgcnt; i++) {
|
for (i = 0; i < pgcnt; i++) {
|
||||||
memset(buf, 0 , pgcnt);
|
memset(buf, 0 , pgcnt);
|
||||||
ret = mtd->read(mtd, addr, pgsize, &read, buf);
|
ret = mtd_read(mtd, addr, pgsize, &read, buf);
|
||||||
if (ret == -EUCLEAN)
|
if (ret == -EUCLEAN)
|
||||||
ret = 0;
|
ret = 0;
|
||||||
if (ret || read != pgsize) {
|
if (ret || read != pgsize) {
|
||||||
|
@ -214,7 +214,7 @@ static int read_eraseblock(int ebnum)
|
|||||||
int err = 0;
|
int err = 0;
|
||||||
loff_t addr = ebnum * mtd->erasesize;
|
loff_t addr = ebnum * mtd->erasesize;
|
||||||
|
|
||||||
err = mtd->read(mtd, addr, mtd->erasesize, &read, iobuf);
|
err = mtd_read(mtd, addr, mtd->erasesize, &read, iobuf);
|
||||||
/* Ignore corrected ECC errors */
|
/* Ignore corrected ECC errors */
|
||||||
if (mtd_is_bitflip(err))
|
if (mtd_is_bitflip(err))
|
||||||
err = 0;
|
err = 0;
|
||||||
@ -235,7 +235,7 @@ static int read_eraseblock_by_page(int ebnum)
|
|||||||
void *buf = iobuf;
|
void *buf = iobuf;
|
||||||
|
|
||||||
for (i = 0; i < pgcnt; i++) {
|
for (i = 0; i < pgcnt; i++) {
|
||||||
err = mtd->read(mtd, addr, pgsize, &read, buf);
|
err = mtd_read(mtd, addr, pgsize, &read, buf);
|
||||||
/* Ignore corrected ECC errors */
|
/* Ignore corrected ECC errors */
|
||||||
if (mtd_is_bitflip(err))
|
if (mtd_is_bitflip(err))
|
||||||
err = 0;
|
err = 0;
|
||||||
@ -261,7 +261,7 @@ static int read_eraseblock_by_2pages(int ebnum)
|
|||||||
void *buf = iobuf;
|
void *buf = iobuf;
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
err = mtd->read(mtd, addr, sz, &read, buf);
|
err = mtd_read(mtd, addr, sz, &read, buf);
|
||||||
/* Ignore corrected ECC errors */
|
/* Ignore corrected ECC errors */
|
||||||
if (mtd_is_bitflip(err))
|
if (mtd_is_bitflip(err))
|
||||||
err = 0;
|
err = 0;
|
||||||
@ -276,7 +276,7 @@ static int read_eraseblock_by_2pages(int ebnum)
|
|||||||
buf += sz;
|
buf += sz;
|
||||||
}
|
}
|
||||||
if (pgcnt % 2) {
|
if (pgcnt % 2) {
|
||||||
err = mtd->read(mtd, addr, pgsize, &read, buf);
|
err = mtd_read(mtd, addr, pgsize, &read, buf);
|
||||||
/* Ignore corrected ECC errors */
|
/* Ignore corrected ECC errors */
|
||||||
if (mtd_is_bitflip(err))
|
if (mtd_is_bitflip(err))
|
||||||
err = 0;
|
err = 0;
|
||||||
|
@ -153,7 +153,7 @@ static int do_read(void)
|
|||||||
len = mtd->erasesize - offs;
|
len = mtd->erasesize - offs;
|
||||||
}
|
}
|
||||||
addr = eb * mtd->erasesize + offs;
|
addr = eb * mtd->erasesize + offs;
|
||||||
err = mtd->read(mtd, addr, len, &read, readbuf);
|
err = mtd_read(mtd, addr, len, &read, readbuf);
|
||||||
if (mtd_is_bitflip(err))
|
if (mtd_is_bitflip(err))
|
||||||
err = 0;
|
err = 0;
|
||||||
if (unlikely(err || read != len)) {
|
if (unlikely(err || read != len)) {
|
||||||
|
@ -196,7 +196,7 @@ static int verify_eraseblock(int ebnum)
|
|||||||
set_random_data(writebuf, subpgsize);
|
set_random_data(writebuf, subpgsize);
|
||||||
clear_data(readbuf, subpgsize);
|
clear_data(readbuf, subpgsize);
|
||||||
read = 0;
|
read = 0;
|
||||||
err = mtd->read(mtd, addr, subpgsize, &read, readbuf);
|
err = mtd_read(mtd, addr, subpgsize, &read, readbuf);
|
||||||
if (unlikely(err || read != subpgsize)) {
|
if (unlikely(err || read != subpgsize)) {
|
||||||
if (mtd_is_bitflip(err) && read == subpgsize) {
|
if (mtd_is_bitflip(err) && read == subpgsize) {
|
||||||
printk(PRINT_PREF "ECC correction at %#llx\n",
|
printk(PRINT_PREF "ECC correction at %#llx\n",
|
||||||
@ -224,7 +224,7 @@ static int verify_eraseblock(int ebnum)
|
|||||||
set_random_data(writebuf, subpgsize);
|
set_random_data(writebuf, subpgsize);
|
||||||
clear_data(readbuf, subpgsize);
|
clear_data(readbuf, subpgsize);
|
||||||
read = 0;
|
read = 0;
|
||||||
err = mtd->read(mtd, addr, subpgsize, &read, readbuf);
|
err = mtd_read(mtd, addr, subpgsize, &read, readbuf);
|
||||||
if (unlikely(err || read != subpgsize)) {
|
if (unlikely(err || read != subpgsize)) {
|
||||||
if (mtd_is_bitflip(err) && read == subpgsize) {
|
if (mtd_is_bitflip(err) && read == subpgsize) {
|
||||||
printk(PRINT_PREF "ECC correction at %#llx\n",
|
printk(PRINT_PREF "ECC correction at %#llx\n",
|
||||||
@ -262,7 +262,7 @@ static int verify_eraseblock2(int ebnum)
|
|||||||
set_random_data(writebuf, subpgsize * k);
|
set_random_data(writebuf, subpgsize * k);
|
||||||
clear_data(readbuf, subpgsize * k);
|
clear_data(readbuf, subpgsize * k);
|
||||||
read = 0;
|
read = 0;
|
||||||
err = mtd->read(mtd, addr, subpgsize * k, &read, readbuf);
|
err = mtd_read(mtd, addr, subpgsize * k, &read, readbuf);
|
||||||
if (unlikely(err || read != subpgsize * k)) {
|
if (unlikely(err || read != subpgsize * k)) {
|
||||||
if (mtd_is_bitflip(err) && read == subpgsize * k) {
|
if (mtd_is_bitflip(err) && read == subpgsize * k) {
|
||||||
printk(PRINT_PREF "ECC correction at %#llx\n",
|
printk(PRINT_PREF "ECC correction at %#llx\n",
|
||||||
@ -296,7 +296,7 @@ static int verify_eraseblock_ff(int ebnum)
|
|||||||
for (j = 0; j < mtd->erasesize / subpgsize; ++j) {
|
for (j = 0; j < mtd->erasesize / subpgsize; ++j) {
|
||||||
clear_data(readbuf, subpgsize);
|
clear_data(readbuf, subpgsize);
|
||||||
read = 0;
|
read = 0;
|
||||||
err = mtd->read(mtd, addr, subpgsize, &read, readbuf);
|
err = mtd_read(mtd, addr, subpgsize, &read, readbuf);
|
||||||
if (unlikely(err || read != subpgsize)) {
|
if (unlikely(err || read != subpgsize)) {
|
||||||
if (mtd_is_bitflip(err) && read == subpgsize) {
|
if (mtd_is_bitflip(err) && read == subpgsize) {
|
||||||
printk(PRINT_PREF "ECC correction at %#llx\n",
|
printk(PRINT_PREF "ECC correction at %#llx\n",
|
||||||
|
@ -137,7 +137,7 @@ static inline int check_eraseblock(int ebnum, unsigned char *buf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
retry:
|
retry:
|
||||||
err = mtd->read(mtd, addr, len, &read, check_buf);
|
err = mtd_read(mtd, addr, len, &read, check_buf);
|
||||||
if (mtd_is_bitflip(err))
|
if (mtd_is_bitflip(err))
|
||||||
printk(PRINT_PREF "single bit flip occurred at EB %d "
|
printk(PRINT_PREF "single bit flip occurred at EB %d "
|
||||||
"MTD reported that it was fixed.\n", ebnum);
|
"MTD reported that it was fixed.\n", ebnum);
|
||||||
|
@ -216,7 +216,7 @@ void ubi_dbg_dump_flash(struct ubi_device *ubi, int pnum, int offset, int len)
|
|||||||
buf = vmalloc(len);
|
buf = vmalloc(len);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return;
|
return;
|
||||||
err = ubi->mtd->read(ubi->mtd, addr, len, &read, buf);
|
err = mtd_read(ubi->mtd, addr, len, &read, buf);
|
||||||
if (err && err != -EUCLEAN) {
|
if (err && err != -EUCLEAN) {
|
||||||
ubi_err("error %d while reading %d bytes from PEB %d:%d, "
|
ubi_err("error %d while reading %d bytes from PEB %d:%d, "
|
||||||
"read %zd bytes", err, len, pnum, offset, read);
|
"read %zd bytes", err, len, pnum, offset, read);
|
||||||
|
@ -170,7 +170,7 @@ int ubi_io_read(const struct ubi_device *ubi, void *buf, int pnum, int offset,
|
|||||||
|
|
||||||
addr = (loff_t)pnum * ubi->peb_size + offset;
|
addr = (loff_t)pnum * ubi->peb_size + offset;
|
||||||
retry:
|
retry:
|
||||||
err = ubi->mtd->read(ubi->mtd, addr, len, &read, buf);
|
err = mtd_read(ubi->mtd, addr, len, &read, buf);
|
||||||
if (err) {
|
if (err) {
|
||||||
const char *errstr = mtd_is_eccerr(err) ? " (ECC error)" : "";
|
const char *errstr = mtd_is_eccerr(err) ? " (ECC error)" : "";
|
||||||
|
|
||||||
@ -1357,7 +1357,7 @@ int ubi_dbg_check_write(struct ubi_device *ubi, const void *buf, int pnum,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = ubi->mtd->read(ubi->mtd, addr, len, &read, buf1);
|
err = mtd_read(ubi->mtd, addr, len, &read, buf1);
|
||||||
if (err && !mtd_is_bitflip(err))
|
if (err && !mtd_is_bitflip(err))
|
||||||
goto out_free;
|
goto out_free;
|
||||||
|
|
||||||
@ -1421,7 +1421,7 @@ int ubi_dbg_check_all_ff(struct ubi_device *ubi, int pnum, int offset, int len)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = ubi->mtd->read(ubi->mtd, addr, len, &read, buf);
|
err = mtd_read(ubi->mtd, addr, len, &read, buf);
|
||||||
if (err && !mtd_is_bitflip(err)) {
|
if (err && !mtd_is_bitflip(err)) {
|
||||||
ubi_err("error %d while reading %d bytes from PEB %d:%d, "
|
ubi_err("error %d while reading %d bytes from PEB %d:%d, "
|
||||||
"read %zd bytes", err, len, pnum, offset, read);
|
"read %zd bytes", err, len, pnum, offset, read);
|
||||||
|
@ -283,9 +283,11 @@ u16 mtd_Read_Page_Main(u8 *read_data, u32 Block,
|
|||||||
|
|
||||||
|
|
||||||
while (PageCount) {
|
while (PageCount) {
|
||||||
ret = spectra_mtd->read(spectra_mtd,
|
ret = mtd_read(spectra_mtd,
|
||||||
(Block * spectra_mtd->erasesize) + (Page * spectra_mtd->writesize),
|
(Block * spectra_mtd->erasesize) + (Page * spectra_mtd->writesize),
|
||||||
DeviceInfo.wPageDataSize, &retlen, read_data);
|
DeviceInfo.wPageDataSize,
|
||||||
|
&retlen,
|
||||||
|
read_data);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
printk(KERN_ERR "%s failed %d\n", __func__, ret);
|
printk(KERN_ERR "%s failed %d\n", __func__, ret);
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
@ -381,7 +381,7 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl
|
|||||||
|
|
||||||
*bad_offset = ofs;
|
*bad_offset = ofs;
|
||||||
|
|
||||||
ret = c->mtd->read(c->mtd, ofs, readlen, &retlen, ebuf);
|
ret = mtd_read(c->mtd, ofs, readlen, &retlen, ebuf);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
printk(KERN_WARNING "Read of newly-erased block at 0x%08x failed: %d. Putting on bad_list\n", ofs, ret);
|
printk(KERN_WARNING "Read of newly-erased block at 0x%08x failed: %d. Putting on bad_list\n", ofs, ret);
|
||||||
ret = -EIO;
|
ret = -EIO;
|
||||||
|
@ -228,7 +228,7 @@ static int jffs2_verify_write(struct jffs2_sb_info *c, unsigned char *buf,
|
|||||||
size_t retlen;
|
size_t retlen;
|
||||||
char *eccstr;
|
char *eccstr;
|
||||||
|
|
||||||
ret = c->mtd->read(c->mtd, ofs, c->wbuf_pagesize, &retlen, c->wbuf_verify);
|
ret = mtd_read(c->mtd, ofs, c->wbuf_pagesize, &retlen, c->wbuf_verify);
|
||||||
if (ret && ret != -EUCLEAN && ret != -EBADMSG) {
|
if (ret && ret != -EUCLEAN && ret != -EBADMSG) {
|
||||||
printk(KERN_WARNING "jffs2_verify_write(): Read back of page at %08x failed: %d\n", c->wbuf_ofs, ret);
|
printk(KERN_WARNING "jffs2_verify_write(): Read back of page at %08x failed: %d\n", c->wbuf_ofs, ret);
|
||||||
return ret;
|
return ret;
|
||||||
@ -337,7 +337,8 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Do the read... */
|
/* Do the read... */
|
||||||
ret = c->mtd->read(c->mtd, start, c->wbuf_ofs - start, &retlen, buf);
|
ret = mtd_read(c->mtd, start, c->wbuf_ofs - start, &retlen,
|
||||||
|
buf);
|
||||||
|
|
||||||
/* ECC recovered ? */
|
/* ECC recovered ? */
|
||||||
if ((ret == -EUCLEAN || ret == -EBADMSG) &&
|
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
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!jffs2_is_writebuffered(c))
|
if (!jffs2_is_writebuffered(c))
|
||||||
return c->mtd->read(c->mtd, ofs, len, retlen, buf);
|
return mtd_read(c->mtd, ofs, len, retlen, buf);
|
||||||
|
|
||||||
/* Read flash */
|
/* Read flash */
|
||||||
down_read(&c->wbuf_sem);
|
down_read(&c->wbuf_sem);
|
||||||
ret = c->mtd->read(c->mtd, ofs, len, retlen, buf);
|
ret = mtd_read(c->mtd, ofs, len, retlen, buf);
|
||||||
|
|
||||||
if ( (ret == -EBADMSG || ret == -EUCLEAN) && (*retlen == len) ) {
|
if ( (ret == -EBADMSG || ret == -EUCLEAN) && (*retlen == len) ) {
|
||||||
if (ret == -EBADMSG)
|
if (ret == -EBADMSG)
|
||||||
|
@ -20,7 +20,7 @@ static int logfs_mtd_read(struct super_block *sb, loff_t ofs, size_t len,
|
|||||||
size_t retlen;
|
size_t retlen;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = mtd->read(mtd, ofs, len, &retlen, buf);
|
ret = mtd_read(mtd, ofs, len, &retlen, buf);
|
||||||
BUG_ON(ret == -EINVAL);
|
BUG_ON(ret == -EINVAL);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -182,6 +182,8 @@ struct mtd_info {
|
|||||||
unsigned long len,
|
unsigned long len,
|
||||||
unsigned long offset,
|
unsigned long offset,
|
||||||
unsigned long flags);
|
unsigned long flags);
|
||||||
|
int (*read) (struct mtd_info *mtd, loff_t from, size_t len,
|
||||||
|
size_t *retlen, u_char *buf);
|
||||||
|
|
||||||
/* Backing device capabilities for this device
|
/* Backing device capabilities for this device
|
||||||
* - provides mmap capabilities
|
* - provides mmap capabilities
|
||||||
@ -189,7 +191,6 @@ struct mtd_info {
|
|||||||
struct backing_dev_info *backing_dev_info;
|
struct backing_dev_info *backing_dev_info;
|
||||||
|
|
||||||
|
|
||||||
int (*read) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf);
|
|
||||||
int (*write) (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf);
|
int (*write) (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf);
|
||||||
|
|
||||||
/* In blackbox flight recorder like scenarios we want to make successful
|
/* 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,
|
|||||||
return mtd->get_unmapped_area(mtd, len, offset, flags);
|
return mtd->get_unmapped_area(mtd, len, offset, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int mtd_read(struct mtd_info *mtd, loff_t from, size_t len,
|
||||||
|
size_t *retlen, u_char *buf)
|
||||||
|
{
|
||||||
|
return mtd->read(mtd, from, len, retlen, buf);
|
||||||
|
}
|
||||||
|
|
||||||
static inline struct mtd_info *dev_to_mtd(struct device *dev)
|
static inline struct mtd_info *dev_to_mtd(struct device *dev)
|
||||||
{
|
{
|
||||||
return dev ? dev_get_drvdata(dev) : NULL;
|
return dev ? dev_get_drvdata(dev) : NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user