Commit 12f77c9e authored by Kyungmin Park's avatar Kyungmin Park Committed by David Woodhouse

[MTD] [OneNAND] Use mtd_oob_ops at oob functions

To enable the main read/write at oob ops

Next time we will commit the main read/write support for yaffs2
Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: default avatarDavid Woodhouse <dwmw2@infradead.org>
parent e208520e
...@@ -921,17 +921,22 @@ static int onenand_transfer_auto_oob(struct mtd_info *mtd, uint8_t *buf, int col ...@@ -921,17 +921,22 @@ static int onenand_transfer_auto_oob(struct mtd_info *mtd, uint8_t *buf, int col
* *
* OneNAND read out-of-band data from the spare area * OneNAND read out-of-band data from the spare area
*/ */
static int onenand_do_read_oob(struct mtd_info *mtd, loff_t from, size_t len, static int onenand_do_read_oob(struct mtd_info *mtd, loff_t from,
size_t *retlen, u_char *buf, mtd_oob_mode_t mode) struct mtd_oob_ops *ops)
{ {
struct onenand_chip *this = mtd->priv; struct onenand_chip *this = mtd->priv;
int read = 0, thislen, column, oobsize; int read = 0, thislen, column, oobsize;
size_t len = ops->ooblen;
mtd_oob_mode_t mode = ops->mode;
u_char *buf = ops->oobbuf;
int ret = 0; int ret = 0;
from += ops->ooboffs;
DEBUG(MTD_DEBUG_LEVEL3, "onenand_read_oob: from = 0x%08x, len = %i\n", (unsigned int) from, (int) len); DEBUG(MTD_DEBUG_LEVEL3, "onenand_read_oob: from = 0x%08x, len = %i\n", (unsigned int) from, (int) len);
/* Initialize return length value */ /* Initialize return length value */
*retlen = 0; ops->oobretlen = 0;
if (mode == MTD_OOB_AUTO) if (mode == MTD_OOB_AUTO)
oobsize = this->ecclayout->oobavail; oobsize = this->ecclayout->oobavail;
...@@ -997,7 +1002,7 @@ static int onenand_do_read_oob(struct mtd_info *mtd, loff_t from, size_t len, ...@@ -997,7 +1002,7 @@ static int onenand_do_read_oob(struct mtd_info *mtd, loff_t from, size_t len,
/* Deselect and wake up anyone waiting on the device */ /* Deselect and wake up anyone waiting on the device */
onenand_release_device(mtd); onenand_release_device(mtd);
*retlen = read; ops->oobretlen = read;
return ret; return ret;
} }
...@@ -1019,8 +1024,7 @@ static int onenand_read_oob(struct mtd_info *mtd, loff_t from, ...@@ -1019,8 +1024,7 @@ static int onenand_read_oob(struct mtd_info *mtd, loff_t from,
default: default:
return -EINVAL; return -EINVAL;
} }
return onenand_do_read_oob(mtd, from + ops->ooboffs, ops->ooblen, return onenand_do_read_oob(mtd, from, ops);
&ops->oobretlen, ops->oobbuf, ops->mode);
} }
/** /**
...@@ -1370,18 +1374,23 @@ static int onenand_fill_auto_oob(struct mtd_info *mtd, u_char *oob_buf, ...@@ -1370,18 +1374,23 @@ static int onenand_fill_auto_oob(struct mtd_info *mtd, u_char *oob_buf,
* *
* OneNAND write out-of-band * OneNAND write out-of-band
*/ */
static int onenand_do_write_oob(struct mtd_info *mtd, loff_t to, size_t len, static int onenand_do_write_oob(struct mtd_info *mtd, loff_t to,
size_t *retlen, const u_char *buf, mtd_oob_mode_t mode) struct mtd_oob_ops *ops)
{ {
struct onenand_chip *this = mtd->priv; struct onenand_chip *this = mtd->priv;
int column, ret = 0, oobsize; int column, ret = 0, oobsize;
int written = 0; int written = 0;
u_char *oobbuf; u_char *oobbuf;
size_t len = ops->ooblen;
const u_char *buf = ops->oobbuf;
mtd_oob_mode_t mode = ops->mode;
to += ops->ooboffs;
DEBUG(MTD_DEBUG_LEVEL3, "onenand_write_oob: to = 0x%08x, len = %i\n", (unsigned int) to, (int) len); DEBUG(MTD_DEBUG_LEVEL3, "onenand_write_oob: to = 0x%08x, len = %i\n", (unsigned int) to, (int) len);
/* Initialize retlen, in case of early exit */ /* Initialize retlen, in case of early exit */
*retlen = 0; ops->oobretlen = 0;
if (mode == MTD_OOB_AUTO) if (mode == MTD_OOB_AUTO)
oobsize = this->ecclayout->oobavail; oobsize = this->ecclayout->oobavail;
...@@ -1464,7 +1473,7 @@ static int onenand_do_write_oob(struct mtd_info *mtd, loff_t to, size_t len, ...@@ -1464,7 +1473,7 @@ static int onenand_do_write_oob(struct mtd_info *mtd, loff_t to, size_t len,
/* Deselect and wake up anyone waiting on the device */ /* Deselect and wake up anyone waiting on the device */
onenand_release_device(mtd); onenand_release_device(mtd);
*retlen = written; ops->oobretlen = written;
return ret; return ret;
} }
...@@ -1487,8 +1496,7 @@ static int onenand_write_oob(struct mtd_info *mtd, loff_t to, ...@@ -1487,8 +1496,7 @@ static int onenand_write_oob(struct mtd_info *mtd, loff_t to,
default: default:
return -EINVAL; return -EINVAL;
} }
return onenand_do_write_oob(mtd, to + ops->ooboffs, ops->ooblen, return onenand_do_write_oob(mtd, to, ops);
&ops->oobretlen, ops->oobbuf, ops->mode);
} }
/** /**
...@@ -1646,7 +1654,12 @@ static int onenand_default_block_markbad(struct mtd_info *mtd, loff_t ofs) ...@@ -1646,7 +1654,12 @@ static int onenand_default_block_markbad(struct mtd_info *mtd, loff_t ofs)
struct onenand_chip *this = mtd->priv; struct onenand_chip *this = mtd->priv;
struct bbm_info *bbm = this->bbm; struct bbm_info *bbm = this->bbm;
u_char buf[2] = {0, 0}; u_char buf[2] = {0, 0};
size_t retlen; struct mtd_oob_ops ops = {
.mode = MTD_OOB_PLACE,
.ooblen = 2,
.oobbuf = buf,
.ooboffs = 0,
};
int block; int block;
/* Get block number */ /* Get block number */
...@@ -1656,7 +1669,7 @@ static int onenand_default_block_markbad(struct mtd_info *mtd, loff_t ofs) ...@@ -1656,7 +1669,7 @@ static int onenand_default_block_markbad(struct mtd_info *mtd, loff_t ofs)
/* We write two bytes, so we dont have to mess with 16 bit access */ /* We write two bytes, so we dont have to mess with 16 bit access */
ofs += mtd->oobsize + (bbm->badblockpos & ~0x01); ofs += mtd->oobsize + (bbm->badblockpos & ~0x01);
return onenand_do_write_oob(mtd, ofs , 2, &retlen, buf, MTD_OOB_PLACE); return onenand_do_write_oob(mtd, ofs, &ops);
} }
/** /**
...@@ -1945,13 +1958,21 @@ static int do_otp_lock(struct mtd_info *mtd, loff_t from, size_t len, ...@@ -1945,13 +1958,21 @@ static int do_otp_lock(struct mtd_info *mtd, loff_t from, size_t len,
size_t *retlen, u_char *buf) size_t *retlen, u_char *buf)
{ {
struct onenand_chip *this = mtd->priv; struct onenand_chip *this = mtd->priv;
struct mtd_oob_ops ops = {
.mode = MTD_OOB_PLACE,
.ooblen = len,
.oobbuf = buf,
.ooboffs = 0,
};
int ret; int ret;
/* Enter OTP access mode */ /* Enter OTP access mode */
this->command(mtd, ONENAND_CMD_OTP_ACCESS, 0, 0); this->command(mtd, ONENAND_CMD_OTP_ACCESS, 0, 0);
this->wait(mtd, FL_OTPING); this->wait(mtd, FL_OTPING);
ret = onenand_do_write_oob(mtd, from, len, retlen, buf, MTD_OOB_PLACE); ret = onenand_do_write_oob(mtd, from, &ops);
*retlen = ops.oobretlen;
/* Exit OTP access mode */ /* Exit OTP access mode */
this->command(mtd, ONENAND_CMD_RESET, 0, 0); this->command(mtd, ONENAND_CMD_RESET, 0, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment