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

Commit 0305c865 authored by David Woodhouse's avatar David Woodhouse
Browse files
parents 99988f7b d470a97c
Loading
Loading
Loading
Loading
+0 −66
Original line number Diff line number Diff line
@@ -59,9 +59,6 @@ static int doc_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
			size_t *retlen, u_char *buf, u_char *eccbuf, struct nand_oobinfo *oobsel);
static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
			 size_t *retlen, const u_char *buf, u_char *eccbuf, struct nand_oobinfo *oobsel);
static int doc_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs,
			  unsigned long count, loff_t to, size_t *retlen,
			  u_char *eccbuf, struct nand_oobinfo *oobsel);
static int doc_read_oob(struct mtd_info *mtd, loff_t ofs, size_t len,
			size_t *retlen, u_char *buf);
static int doc_write_oob(struct mtd_info *mtd, loff_t ofs, size_t len,
@@ -587,9 +584,6 @@ void DoC2k_init(struct mtd_info *mtd)
	mtd->unpoint = NULL;
	mtd->read = doc_read;
	mtd->write = doc_write;
	mtd->read_ecc = doc_read_ecc;
	mtd->write_ecc = doc_write_ecc;
	mtd->writev_ecc = doc_writev_ecc;
	mtd->read_oob = doc_read_oob;
	mtd->write_oob = doc_write_oob;
	mtd->sync = NULL;
@@ -965,66 +959,6 @@ static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
	return 0;
}

static int doc_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs,
			  unsigned long count, loff_t to, size_t *retlen,
			  u_char *eccbuf, struct nand_oobinfo *oobsel)
{
	static char static_buf[512];
	static DEFINE_MUTEX(writev_buf_mutex);

	size_t totretlen = 0;
	size_t thisvecofs = 0;
	int ret= 0;

	mutex_lock(&writev_buf_mutex);

	while(count) {
		size_t thislen, thisretlen;
		unsigned char *buf;

		buf = vecs->iov_base + thisvecofs;
		thislen = vecs->iov_len - thisvecofs;


		if (thislen >= 512) {
			thislen = thislen & ~(512-1);
			thisvecofs += thislen;
		} else {
			/* Not enough to fill a page. Copy into buf */
			memcpy(static_buf, buf, thislen);
			buf = &static_buf[thislen];

			while(count && thislen < 512) {
				vecs++;
				count--;
				thisvecofs = min((512-thislen), vecs->iov_len);
				memcpy(buf, vecs->iov_base, thisvecofs);
				thislen += thisvecofs;
				buf += thisvecofs;
			}
			buf = static_buf;
		}
		if (count && thisvecofs == vecs->iov_len) {
			thisvecofs = 0;
			vecs++;
			count--;
		}
		ret = doc_write_ecc(mtd, to, thislen, &thisretlen, buf, eccbuf, oobsel);

		totretlen += thisretlen;

		if (ret || thisretlen != thislen)
			break;

		to += thislen;
	}

	mutex_unlock(&writev_buf_mutex);
	*retlen = totretlen;
	return ret;
}


static int doc_read_oob(struct mtd_info *mtd, loff_t ofs, size_t len,
			size_t * retlen, u_char * buf)
{
+0 −2
Original line number Diff line number Diff line
@@ -369,8 +369,6 @@ void DoCMil_init(struct mtd_info *mtd)
	mtd->unpoint = NULL;
	mtd->read = doc_read;
	mtd->write = doc_write;
	mtd->read_ecc = doc_read_ecc;
	mtd->write_ecc = doc_write_ecc;
	mtd->read_oob = doc_read_oob;
	mtd->write_oob = doc_write_oob;
	mtd->sync = NULL;
+0 −2
Original line number Diff line number Diff line
@@ -491,8 +491,6 @@ void DoCMilPlus_init(struct mtd_info *mtd)
	mtd->unpoint = NULL;
	mtd->read = doc_read;
	mtd->write = doc_write;
	mtd->read_ecc = doc_read_ecc;
	mtd->write_ecc = doc_write_ecc;
	mtd->read_oob = doc_read_oob;
	mtd->write_oob = doc_write_oob;
	mtd->sync = NULL;
+32 −31
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@
#include <linux/mtd/mtd.h>
#include <linux/mtd/nftl.h>
#include <linux/mtd/inftl.h>
#include <linux/mtd/nand.h>
#include <asm/uaccess.h>
#include <asm/errno.h>
#include <asm/io.h>
@@ -79,8 +80,6 @@ static void inftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
	inftl->mbd.devnum = -1;
	inftl->mbd.blksize = 512;
	inftl->mbd.tr = tr;
	memcpy(&inftl->oobinfo, &mtd->oobinfo, sizeof(struct nand_oobinfo));
	inftl->oobinfo.useecc = MTD_NANDECC_PLACEONLY;

	if (INFTL_mount(inftl) < 0) {
		printk(KERN_WARNING "INFTL: could not mount device\n");
@@ -302,9 +301,10 @@ static u16 INFTL_foldchain(struct INFTLrecord *inftl, unsigned thisVUC, unsigned
		}
		memset(&oob, 0xff, sizeof(struct inftl_oob));
		oob.b.Status = oob.b.Status1 = SECTOR_USED;
                MTD_WRITEECC(inftl->mbd.mtd, (inftl->EraseSize * targetEUN) +

		nand_write_raw(inftl->mbd.mtd, (inftl->EraseSize * targetEUN) +
			       (block * SECTORSIZE), SECTORSIZE, &retlen,
			movebuf, (char *)&oob, &inftl->oobinfo);
			       movebuf, (char *)&oob);
	}

	/*
@@ -784,9 +784,10 @@ static int inftl_writeblock(struct mtd_blktrans_dev *mbd, unsigned long block,

		memset(&oob, 0xff, sizeof(struct inftl_oob));
		oob.b.Status = oob.b.Status1 = SECTOR_USED;
		MTD_WRITEECC(inftl->mbd.mtd, (writeEUN * inftl->EraseSize) +

		nand_write_raw(inftl->mbd.mtd, (writeEUN * inftl->EraseSize) +
			       blockofs, SECTORSIZE, &retlen, (char *)buffer,
			(char *)&oob, &inftl->oobinfo);
			       (char *)&oob);
		/*
		 * need to write SECTOR_USED flags since they are not written
		 * in mtd_writeecc
+6 −6
Original line number Diff line number Diff line
@@ -350,21 +350,21 @@ static int check_free_sectors(struct INFTLrecord *inftl, unsigned int address,
	int len, int check_oob)
{
	u8 buf[SECTORSIZE + inftl->mbd.mtd->oobsize];
	struct mtd_info *mtd = inftl->mbd.mtd;
	size_t retlen;
	int i;

	DEBUG(MTD_DEBUG_LEVEL3, "INFTL: check_free_sectors(inftl=%p,"
		"address=0x%x,len=%d,check_oob=%d)\n", inftl,
		address, len, check_oob);

	for (i = 0; i < len; i += SECTORSIZE) {
		if (MTD_READECC(inftl->mbd.mtd, address, SECTORSIZE, &retlen, buf, &buf[SECTORSIZE], &inftl->oobinfo) < 0)
		if (mtd->read(mtd, address, SECTORSIZE, &retlen, buf))
			return -1;
		if (memcmpb(buf, 0xff, SECTORSIZE) != 0)
			return -1;

		if (check_oob) {
			if (memcmpb(buf + SECTORSIZE, 0xff, inftl->mbd.mtd->oobsize) != 0)
			if(mtd->read_oob(mtd, address, mtd->oobsize,
					 &retlen, &buf[SECTORSIZE]) < 0)
				return -1;
			if (memcmpb(buf + SECTORSIZE, 0xff, mtd->oobsize) != 0)
				return -1;
		}
		address += SECTORSIZE;
Loading