Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f4a43cfc authored by Thomas Gleixner's avatar Thomas Gleixner
Browse files

[MTD] Remove silly MTD_WRITE/READ macros



Most of those macros are unused and the used ones just obfuscate
the code. Remove them and fixup all users.

Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 5bd34c09
Loading
Loading
Loading
Loading
+34 −29
Original line number Original line Diff line number Diff line
@@ -197,6 +197,7 @@ static u16 INFTL_foldchain(struct INFTLrecord *inftl, unsigned thisVUC, unsigned
	u16 BlockMap[MAX_SECTORS_PER_UNIT];
	u16 BlockMap[MAX_SECTORS_PER_UNIT];
	unsigned char BlockDeleted[MAX_SECTORS_PER_UNIT];
	unsigned char BlockDeleted[MAX_SECTORS_PER_UNIT];
	unsigned int thisEUN, prevEUN, status;
	unsigned int thisEUN, prevEUN, status;
	struct mtd_info *mtd = inftl->mbd.mtd;
	int block, silly;
	int block, silly;
	unsigned int targetEUN;
	unsigned int targetEUN;
	struct inftl_oob oob;
	struct inftl_oob oob;
@@ -226,7 +227,7 @@ static u16 INFTL_foldchain(struct INFTLrecord *inftl, unsigned thisVUC, unsigned
			if ((BlockMap[block] != 0xffff) || BlockDeleted[block])
			if ((BlockMap[block] != 0xffff) || BlockDeleted[block])
				continue;
				continue;


			if (MTD_READOOB(inftl->mbd.mtd, (thisEUN * inftl->EraseSize)
			if (mtd->read_oob(mtd, (thisEUN * inftl->EraseSize)
					  + (block * SECTORSIZE), 16 , &retlen,
					  + (block * SECTORSIZE), 16 , &retlen,
					  (char *)&oob) < 0)
					  (char *)&oob) < 0)
				status = SECTOR_IGNORE;
				status = SECTOR_IGNORE;
@@ -288,13 +289,14 @@ 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(inftl->mbd.mtd, (inftl->EraseSize *
		ret = mtd->read(mtd, (inftl->EraseSize * BlockMap[block]) +
			BlockMap[block]) + (block * SECTORSIZE), SECTORSIZE,
				(block * SECTORSIZE), SECTORSIZE, &retlen,
			&retlen, movebuf);
				movebuf);
		if (ret < 0) {
		if (ret < 0) {
			ret = MTD_READ(inftl->mbd.mtd, (inftl->EraseSize *
			ret = mtd->read(mtd,
				BlockMap[block]) + (block * SECTORSIZE),
					(inftl->EraseSize * BlockMap[block]) +
				SECTORSIZE, &retlen, movebuf);
					(block * SECTORSIZE), SECTORSIZE,
					&retlen, movebuf);
			if (ret != -EIO)
			if (ret != -EIO)
				DEBUG(MTD_DEBUG_LEVEL1, "INFTL: error went "
				DEBUG(MTD_DEBUG_LEVEL1, "INFTL: error went "
				      "away on retry?\n");
				      "away on retry?\n");
@@ -415,6 +417,7 @@ static inline u16 INFTL_findwriteunit(struct INFTLrecord *inftl, unsigned block)
	unsigned int thisVUC = block / (inftl->EraseSize / SECTORSIZE);
	unsigned int thisVUC = block / (inftl->EraseSize / SECTORSIZE);
	unsigned int thisEUN, writeEUN, prev_block, status;
	unsigned int thisEUN, writeEUN, prev_block, status;
	unsigned long blockofs = (block * SECTORSIZE) & (inftl->EraseSize -1);
	unsigned long blockofs = (block * SECTORSIZE) & (inftl->EraseSize -1);
	struct mtd_info *mtd = inftl->mbd.mtd;
	struct inftl_oob oob;
	struct inftl_oob oob;
	struct inftl_bci bci;
	struct inftl_bci bci;
	unsigned char anac, nacs, parity;
	unsigned char anac, nacs, parity;
@@ -434,7 +437,7 @@ static inline u16 INFTL_findwriteunit(struct INFTLrecord *inftl, unsigned block)
		silly = MAX_LOOPS;
		silly = MAX_LOOPS;


		while (thisEUN <= inftl->lastEUN) {
		while (thisEUN <= inftl->lastEUN) {
			MTD_READOOB(inftl->mbd.mtd, (thisEUN * inftl->EraseSize) +
			mtd->read_oob(mtd, (thisEUN * inftl->EraseSize) +
				      blockofs, 8, &retlen, (char *)&bci);
				      blockofs, 8, &retlen, (char *)&bci);


			status = bci.Status | bci.Status1;
			status = bci.Status | bci.Status1;
@@ -522,7 +525,7 @@ static inline u16 INFTL_findwriteunit(struct INFTLrecord *inftl, unsigned block)
		nacs = 0;
		nacs = 0;
		thisEUN = inftl->VUtable[thisVUC];
		thisEUN = inftl->VUtable[thisVUC];
		if (thisEUN != BLOCK_NIL) {
		if (thisEUN != BLOCK_NIL) {
			MTD_READOOB(inftl->mbd.mtd, thisEUN * inftl->EraseSize
			mtd->read_oob(mtd, thisEUN * inftl->EraseSize
				      + 8, 8, &retlen, (char *)&oob.u);
				      + 8, 8, &retlen, (char *)&oob.u);
			anac = oob.u.a.ANAC + 1;
			anac = oob.u.a.ANAC + 1;
			nacs = oob.u.a.NACs + 1;
			nacs = oob.u.a.NACs + 1;
@@ -544,7 +547,7 @@ static inline u16 INFTL_findwriteunit(struct INFTLrecord *inftl, unsigned block)
		oob.u.a.parityPerField = parity;
		oob.u.a.parityPerField = parity;
		oob.u.a.discarded = 0xaa;
		oob.u.a.discarded = 0xaa;


		MTD_WRITEOOB(inftl->mbd.mtd, writeEUN * inftl->EraseSize + 8, 8,
		mtd->write_oob(mtd, writeEUN * inftl->EraseSize + 8, 8,
			       &retlen, (char *)&oob.u);
			       &retlen, (char *)&oob.u);


		/* Also back up header... */
		/* Also back up header... */
@@ -555,7 +558,7 @@ static inline u16 INFTL_findwriteunit(struct INFTLrecord *inftl, unsigned block)
		oob.u.b.parityPerField = parity;
		oob.u.b.parityPerField = parity;
		oob.u.b.discarded = 0xaa;
		oob.u.b.discarded = 0xaa;


		MTD_WRITEOOB(inftl->mbd.mtd, writeEUN * inftl->EraseSize +
		mtd->write_oob(mtd, writeEUN * inftl->EraseSize +
			       SECTORSIZE * 4 + 8, 8, &retlen, (char *)&oob.u);
			       SECTORSIZE * 4 + 8, 8, &retlen, (char *)&oob.u);


		inftl->PUtable[writeEUN] = inftl->VUtable[thisVUC];
		inftl->PUtable[writeEUN] = inftl->VUtable[thisVUC];
@@ -576,6 +579,7 @@ static inline u16 INFTL_findwriteunit(struct INFTLrecord *inftl, unsigned block)
 */
 */
static void INFTL_trydeletechain(struct INFTLrecord *inftl, unsigned thisVUC)
static void INFTL_trydeletechain(struct INFTLrecord *inftl, unsigned thisVUC)
{
{
	struct mtd_info *mtd = inftl->mbd.mtd;
	unsigned char BlockUsed[MAX_SECTORS_PER_UNIT];
	unsigned char BlockUsed[MAX_SECTORS_PER_UNIT];
	unsigned char BlockDeleted[MAX_SECTORS_PER_UNIT];
	unsigned char BlockDeleted[MAX_SECTORS_PER_UNIT];
	unsigned int thisEUN, status;
	unsigned int thisEUN, status;
@@ -606,7 +610,7 @@ static void INFTL_trydeletechain(struct INFTLrecord *inftl, unsigned thisVUC)
			if (BlockUsed[block] || BlockDeleted[block])
			if (BlockUsed[block] || BlockDeleted[block])
				continue;
				continue;


			if (MTD_READOOB(inftl->mbd.mtd, (thisEUN * inftl->EraseSize)
			if (mtd->read_oob(mtd, (thisEUN * inftl->EraseSize)
					  + (block * SECTORSIZE), 8 , &retlen,
					  + (block * SECTORSIZE), 8 , &retlen,
					  (char *)&bci) < 0)
					  (char *)&bci) < 0)
				status = SECTOR_IGNORE;
				status = SECTOR_IGNORE;
@@ -697,6 +701,7 @@ static int INFTL_deleteblock(struct INFTLrecord *inftl, unsigned block)
{
{
	unsigned int thisEUN = inftl->VUtable[block / (inftl->EraseSize / SECTORSIZE)];
	unsigned int thisEUN = inftl->VUtable[block / (inftl->EraseSize / SECTORSIZE)];
	unsigned long blockofs = (block * SECTORSIZE) & (inftl->EraseSize - 1);
	unsigned long blockofs = (block * SECTORSIZE) & (inftl->EraseSize - 1);
	struct mtd_info *mtd = inftl->mbd.mtd;
	unsigned int status;
	unsigned int status;
	int silly = MAX_LOOPS;
	int silly = MAX_LOOPS;
	size_t retlen;
	size_t retlen;
@@ -706,7 +711,7 @@ static int INFTL_deleteblock(struct INFTLrecord *inftl, unsigned block)
		"block=%d)\n", inftl, block);
		"block=%d)\n", inftl, block);


	while (thisEUN < inftl->nb_blocks) {
	while (thisEUN < inftl->nb_blocks) {
		if (MTD_READOOB(inftl->mbd.mtd, (thisEUN * inftl->EraseSize) +
		if (mtd->read_oob(mtd, (thisEUN * inftl->EraseSize) +
				  blockofs, 8, &retlen, (char *)&bci) < 0)
				  blockofs, 8, &retlen, (char *)&bci) < 0)
			status = SECTOR_IGNORE;
			status = SECTOR_IGNORE;
		else
		else
@@ -741,10 +746,10 @@ static int INFTL_deleteblock(struct INFTLrecord *inftl, unsigned block)
	if (thisEUN != BLOCK_NIL) {
	if (thisEUN != BLOCK_NIL) {
		loff_t ptr = (thisEUN * inftl->EraseSize) + blockofs;
		loff_t ptr = (thisEUN * inftl->EraseSize) + blockofs;


		if (MTD_READOOB(inftl->mbd.mtd, ptr, 8, &retlen, (char *)&bci) < 0)
		if (mtd->read_oob(mtd, ptr, 8, &retlen, (char *)&bci) < 0)
			return -EIO;
			return -EIO;
		bci.Status = bci.Status1 = SECTOR_DELETED;
		bci.Status = bci.Status1 = SECTOR_DELETED;
		if (MTD_WRITEOOB(inftl->mbd.mtd, ptr, 8, &retlen, (char *)&bci) < 0)
		if (mtd->write_oob(mtd, ptr, 8, &retlen, (char *)&bci) < 0)
			return -EIO;
			return -EIO;
		INFTL_trydeletechain(inftl, block / (inftl->EraseSize / SECTORSIZE));
		INFTL_trydeletechain(inftl, block / (inftl->EraseSize / SECTORSIZE));
	}
	}
@@ -805,6 +810,7 @@ static int inftl_readblock(struct mtd_blktrans_dev *mbd, unsigned long block,
	struct INFTLrecord *inftl = (void *)mbd;
	struct INFTLrecord *inftl = (void *)mbd;
	unsigned int thisEUN = inftl->VUtable[block / (inftl->EraseSize / SECTORSIZE)];
	unsigned int thisEUN = inftl->VUtable[block / (inftl->EraseSize / SECTORSIZE)];
	unsigned long blockofs = (block * SECTORSIZE) & (inftl->EraseSize - 1);
	unsigned long blockofs = (block * SECTORSIZE) & (inftl->EraseSize - 1);
	struct mtd_info *mtd = inftl->mbd.mtd;
	unsigned int status;
	unsigned int status;
	int silly = MAX_LOOPS;
	int silly = MAX_LOOPS;
	struct inftl_bci bci;
	struct inftl_bci bci;
@@ -814,7 +820,7 @@ static int inftl_readblock(struct mtd_blktrans_dev *mbd, unsigned long block,
		"buffer=%p)\n", inftl, block, buffer);
		"buffer=%p)\n", inftl, block, buffer);


	while (thisEUN < inftl->nb_blocks) {
	while (thisEUN < inftl->nb_blocks) {
		if (MTD_READOOB(inftl->mbd.mtd, (thisEUN * inftl->EraseSize) +
		if (mtd->read_oob(mtd, (thisEUN * inftl->EraseSize) +
				  blockofs, 8, &retlen, (char *)&bci) < 0)
				  blockofs, 8, &retlen, (char *)&bci) < 0)
			status = SECTOR_IGNORE;
			status = SECTOR_IGNORE;
		else
		else
@@ -853,8 +859,7 @@ static int inftl_readblock(struct mtd_blktrans_dev *mbd, unsigned long block,
	} else {
	} else {
		size_t retlen;
		size_t retlen;
		loff_t ptr = (thisEUN * inftl->EraseSize) + blockofs;
		loff_t ptr = (thisEUN * inftl->EraseSize) + blockofs;
		if (MTD_READ(inftl->mbd.mtd, ptr, SECTORSIZE, &retlen,
		if (mtd->read(mtd, ptr, SECTORSIZE, &retlen, buffer))
		    buffer))
			return -EIO;
			return -EIO;
	}
	}
	return 0;
	return 0;
+24 −19
Original line number Original line Diff line number Diff line
@@ -57,6 +57,7 @@ static int find_boot_record(struct INFTLrecord *inftl)
	unsigned int i, block;
	unsigned int i, block;
	u8 buf[SECTORSIZE];
	u8 buf[SECTORSIZE];
	struct INFTLMediaHeader *mh = &inftl->MediaHdr;
	struct INFTLMediaHeader *mh = &inftl->MediaHdr;
	struct mtd_info *mtd = inftl->mbd.mtd;
	struct INFTLPartition *ip;
	struct INFTLPartition *ip;
	size_t retlen;
	size_t retlen;


@@ -80,7 +81,7 @@ 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(inftl->mbd.mtd, block * inftl->EraseSize,
		ret = mtd->read(mtd, block * inftl->EraseSize,
				SECTORSIZE, &retlen, buf);
				SECTORSIZE, &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) */
@@ -106,8 +107,9 @@ static int find_boot_record(struct INFTLrecord *inftl)
		}
		}


		/* To be safer with BIOS, also use erase mark as discriminant */
		/* To be safer with BIOS, also use erase mark as discriminant */
		if ((ret = MTD_READOOB(inftl->mbd.mtd, block * inftl->EraseSize +
		if ((ret = mtd->read_oob(mtd, block * inftl->EraseSize +
		    SECTORSIZE + 8, 8, &retlen, (char *)&h1) < 0)) {
					 SECTORSIZE + 8, 8, &retlen,
					 (char *)&h1) < 0)) {
			printk(KERN_WARNING "INFTL: ANAND header found at "
			printk(KERN_WARNING "INFTL: ANAND header found at "
				"0x%x in mtd%d, but OOB data read failed "
				"0x%x in mtd%d, but OOB data read failed "
				"(err %d)\n", block * inftl->EraseSize,
				"(err %d)\n", block * inftl->EraseSize,
@@ -123,7 +125,7 @@ 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(inftl->mbd.mtd, block * inftl->EraseSize + 4096,
		mtd->read(mtd, block * inftl->EraseSize + 4096,
			  SECTORSIZE, &retlen, buf);
			  SECTORSIZE, &retlen, buf);
		if (retlen != SECTORSIZE) {
		if (retlen != SECTORSIZE) {
			printk(KERN_WARNING "INFTL: Unable to read spare "
			printk(KERN_WARNING "INFTL: Unable to read spare "
@@ -233,7 +235,7 @@ static int find_boot_record(struct INFTLrecord *inftl)
				 */
				 */
				instr->addr = ip->Reserved0 * inftl->EraseSize;
				instr->addr = ip->Reserved0 * inftl->EraseSize;
				instr->len = inftl->EraseSize;
				instr->len = inftl->EraseSize;
				MTD_ERASE(inftl->mbd.mtd, instr);
				mtd->erase(mtd, instr);
			}
			}
			if ((ip->lastUnit - ip->firstUnit + 1) < ip->virtualUnits) {
			if ((ip->lastUnit - ip->firstUnit + 1) < ip->virtualUnits) {
				printk(KERN_WARNING "INFTL: Media Header "
				printk(KERN_WARNING "INFTL: Media Header "
@@ -387,6 +389,7 @@ int INFTL_formatblock(struct INFTLrecord *inftl, int block)
	size_t retlen;
	size_t retlen;
	struct inftl_unittail uci;
	struct inftl_unittail uci;
	struct erase_info *instr = &inftl->instr;
	struct erase_info *instr = &inftl->instr;
	struct mtd_info *mtd = inftl->mbd.mtd;
	int physblock;
	int physblock;


	DEBUG(MTD_DEBUG_LEVEL3, "INFTL: INFTL_formatblock(inftl=%p,"
	DEBUG(MTD_DEBUG_LEVEL3, "INFTL: INFTL_formatblock(inftl=%p,"
@@ -404,8 +407,9 @@ int INFTL_formatblock(struct INFTLrecord *inftl, int block)
	/* Erase one physical eraseblock at a time, even though the NAND api
	/* Erase one physical eraseblock at a time, even though the NAND api
	   allows us to group them.  This way we if we have a failure, we can
	   allows us to group them.  This way we if we have a failure, we can
	   mark only the failed block in the bbt. */
	   mark only the failed block in the bbt. */
	for (physblock = 0; physblock < inftl->EraseSize; physblock += instr->len, instr->addr += instr->len) {
	for (physblock = 0; physblock < inftl->EraseSize;
		MTD_ERASE(inftl->mbd.mtd, instr);
	     physblock += instr->len, instr->addr += instr->len) {
		mtd->erase(inftl->mbd.mtd, instr);


		if (instr->state == MTD_ERASE_FAILED) {
		if (instr->state == MTD_ERASE_FAILED) {
			printk(KERN_WARNING "INFTL: error while formatting block %d\n",
			printk(KERN_WARNING "INFTL: error while formatting block %d\n",
@@ -415,8 +419,8 @@ int INFTL_formatblock(struct INFTLrecord *inftl, int block)


		/*
		/*
		 * Check the "freeness" of Erase Unit before updating metadata.
		 * Check the "freeness" of Erase Unit before updating metadata.
	 	* FixMe: is this check really necessary? Since we have check the
		 * FixMe: is this check really necessary? Since we have check
	 	*        return code after the erase operation.
		 * the return code after the erase operation.
		 */
		 */
		if (check_free_sectors(inftl, instr->addr, instr->len, 1) != 0)
		if (check_free_sectors(inftl, instr->addr, instr->len, 1) != 0)
			goto fail;
			goto fail;
@@ -429,8 +433,7 @@ int INFTL_formatblock(struct INFTLrecord *inftl, int block)
	uci.Reserved[2] = 0;
	uci.Reserved[2] = 0;
	uci.Reserved[3] = 0;
	uci.Reserved[3] = 0;
	instr->addr = block * inftl->EraseSize + SECTORSIZE * 2;
	instr->addr = block * inftl->EraseSize + SECTORSIZE * 2;
	if (MTD_WRITEOOB(inftl->mbd.mtd, instr->addr +
	if (mtd->write_oob(mtd, instr->addr + 8, 8, &retlen, (char *)&uci) < 0)
	    8, 8, &retlen, (char *)&uci) < 0)
		goto fail;
		goto fail;
	return 0;
	return 0;
fail:
fail:
@@ -549,6 +552,7 @@ void INFTL_dumpVUchains(struct INFTLrecord *s)


int INFTL_mount(struct INFTLrecord *s)
int INFTL_mount(struct INFTLrecord *s)
{
{
	struct mtd_info *mtd = s->mbd.mtd;
	unsigned int block, first_block, prev_block, last_block;
	unsigned int block, first_block, prev_block, last_block;
	unsigned int first_logical_block, logical_block, erase_mark;
	unsigned int first_logical_block, logical_block, erase_mark;
	int chain_length, do_format_chain;
	int chain_length, do_format_chain;
@@ -607,10 +611,11 @@ int INFTL_mount(struct INFTLrecord *s)
				break;
				break;
			}
			}


			if (MTD_READOOB(s->mbd.mtd, block * s->EraseSize + 8,
			if (mtd->read_oob(mtd, block * s->EraseSize + 8,
					  8, &retlen, (char *)&h0) < 0 ||
					  8, &retlen, (char *)&h0) < 0 ||
			    MTD_READOOB(s->mbd.mtd, block * s->EraseSize +
			    mtd->read_oob(mtd, block * s->EraseSize +
			    2 * SECTORSIZE + 8, 8, &retlen, (char *)&h1) < 0) {
					  2 * SECTORSIZE + 8, 8, &retlen,
					  (char *)&h1) < 0) {
				/* Should never happen? */
				/* Should never happen? */
				do_format_chain++;
				do_format_chain++;
				break;
				break;
+1 −1
Original line number Original line Diff line number Diff line
@@ -190,7 +190,7 @@ int nettel_eraseconfig(void)
		set_current_state(TASK_INTERRUPTIBLE);
		set_current_state(TASK_INTERRUPTIBLE);
		add_wait_queue(&wait_q, &wait);
		add_wait_queue(&wait_q, &wait);


		ret = MTD_ERASE(mtd, &nettel_erase);
		ret = mtd->erase(mtd, &nettel_erase);
		if (ret) {
		if (ret) {
			set_current_state(TASK_RUNNING);
			set_current_state(TASK_RUNNING);
			remove_wait_queue(&wait_q, &wait);
			remove_wait_queue(&wait_q, &wait);
+7 −6
Original line number Original line Diff line number Diff line
@@ -71,7 +71,7 @@ static int erase_write (struct mtd_info *mtd, unsigned long pos,
	set_current_state(TASK_INTERRUPTIBLE);
	set_current_state(TASK_INTERRUPTIBLE);
	add_wait_queue(&wait_q, &wait);
	add_wait_queue(&wait_q, &wait);


	ret = MTD_ERASE(mtd, &erase);
	ret = mtd->erase(mtd, &erase);
	if (ret) {
	if (ret) {
		set_current_state(TASK_RUNNING);
		set_current_state(TASK_RUNNING);
		remove_wait_queue(&wait_q, &wait);
		remove_wait_queue(&wait_q, &wait);
@@ -88,7 +88,7 @@ static int erase_write (struct mtd_info *mtd, unsigned long pos,
	 * Next, writhe data to flash.
	 * Next, writhe data to flash.
	 */
	 */


	ret = MTD_WRITE (mtd, pos, len, &retlen, buf);
	ret = mtd->write(mtd, pos, len, &retlen, buf);
	if (ret)
	if (ret)
		return ret;
		return ret;
	if (retlen != len)
	if (retlen != len)
@@ -138,7 +138,7 @@ static int do_cached_write (struct mtdblk_dev *mtdblk, unsigned long pos,
		mtd->name, pos, len);
		mtd->name, pos, len);


	if (!sect_size)
	if (!sect_size)
		return MTD_WRITE (mtd, pos, len, &retlen, buf);
		return mtd->write(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;
@@ -170,7 +170,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, &retlen, mtdblk->cache_data);
				ret = mtd->read(mtd, sect_start, sect_size,
						&retlen, mtdblk->cache_data);
				if (ret)
				if (ret)
					return ret;
					return ret;
				if (retlen != sect_size)
				if (retlen != sect_size)
@@ -207,7 +208,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;
@@ -226,7 +227,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)
+2 −2
Original line number Original line Diff line number Diff line
@@ -194,7 +194,7 @@ static ssize_t mtd_read(struct file *file, char __user *buf, size_t count,loff_t
			ret = mtd->read_user_prot_reg(mtd, *ppos, len, &retlen, kbuf);
			ret = mtd->read_user_prot_reg(mtd, *ppos, len, &retlen, kbuf);
			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
Loading