Skip to content

Commit

Permalink
mtd: rename MTD_OOB_* to MTD_OPS_*
Browse files Browse the repository at this point in the history
These modes are not necessarily for OOB only. Particularly, MTD_OOB_RAW
affected operations on in-band page data as well. To clarify these
options and to emphasize that their effect is applied per-operation, we
change the primary prefix to MTD_OPS_.

Signed-off-by: Brian Norris <[email protected]>
Signed-off-by: Artem Bityutskiy <[email protected]>
  • Loading branch information
computersforpeace authored and dedekind committed Sep 11, 2011
1 parent 905c6bc commit 0612b9d
Show file tree
Hide file tree
Showing 22 changed files with 99 additions and 97 deletions.
4 changes: 2 additions & 2 deletions drivers/mtd/devices/doc2000.c
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ static int doc_read_oob(struct mtd_info *mtd, loff_t ofs,
uint8_t *buf = ops->oobbuf;
size_t len = ops->len;

BUG_ON(ops->mode != MTD_OOB_PLACE);
BUG_ON(ops->mode != MTD_OPS_PLACE_OOB);

ofs += ops->ooboffs;

Expand Down Expand Up @@ -1091,7 +1091,7 @@ static int doc_write_oob(struct mtd_info *mtd, loff_t ofs,
struct DiskOnChip *this = mtd->priv;
int ret;

BUG_ON(ops->mode != MTD_OOB_PLACE);
BUG_ON(ops->mode != MTD_OPS_PLACE_OOB);

mutex_lock(&this->lock);
ret = doc_write_oob_nolock(mtd, ofs + ops->ooboffs, ops->len,
Expand Down
4 changes: 2 additions & 2 deletions drivers/mtd/devices/doc2001.c
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ static int doc_read_oob(struct mtd_info *mtd, loff_t ofs,
uint8_t *buf = ops->oobbuf;
size_t len = ops->len;

BUG_ON(ops->mode != MTD_OOB_PLACE);
BUG_ON(ops->mode != MTD_OPS_PLACE_OOB);

ofs += ops->ooboffs;

Expand Down Expand Up @@ -689,7 +689,7 @@ static int doc_write_oob(struct mtd_info *mtd, loff_t ofs,
uint8_t *buf = ops->oobbuf;
size_t len = ops->len;

BUG_ON(ops->mode != MTD_OOB_PLACE);
BUG_ON(ops->mode != MTD_OPS_PLACE_OOB);

ofs += ops->ooboffs;

Expand Down
4 changes: 2 additions & 2 deletions drivers/mtd/devices/doc2001plus.c
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ static int doc_read_oob(struct mtd_info *mtd, loff_t ofs,
uint8_t *buf = ops->oobbuf;
size_t len = ops->len;

BUG_ON(ops->mode != MTD_OOB_PLACE);
BUG_ON(ops->mode != MTD_OPS_PLACE_OOB);

ofs += ops->ooboffs;

Expand Down Expand Up @@ -919,7 +919,7 @@ static int doc_write_oob(struct mtd_info *mtd, loff_t ofs,
uint8_t *buf = ops->oobbuf;
size_t len = ops->len;

BUG_ON(ops->mode != MTD_OOB_PLACE);
BUG_ON(ops->mode != MTD_OPS_PLACE_OOB);

ofs += ops->ooboffs;

Expand Down
6 changes: 3 additions & 3 deletions drivers/mtd/inftlcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ int inftl_read_oob(struct mtd_info *mtd, loff_t offs, size_t len,
struct mtd_oob_ops ops;
int res;

ops.mode = MTD_OOB_PLACE;
ops.mode = MTD_OPS_PLACE_OOB;
ops.ooboffs = offs & (mtd->writesize - 1);
ops.ooblen = len;
ops.oobbuf = buf;
Expand All @@ -172,7 +172,7 @@ int inftl_write_oob(struct mtd_info *mtd, loff_t offs, size_t len,
struct mtd_oob_ops ops;
int res;

ops.mode = MTD_OOB_PLACE;
ops.mode = MTD_OPS_PLACE_OOB;
ops.ooboffs = offs & (mtd->writesize - 1);
ops.ooblen = len;
ops.oobbuf = buf;
Expand All @@ -192,7 +192,7 @@ static int inftl_write(struct mtd_info *mtd, loff_t offs, size_t len,
struct mtd_oob_ops ops;
int res;

ops.mode = MTD_OOB_PLACE;
ops.mode = MTD_OPS_PLACE_OOB;
ops.ooboffs = offs;
ops.ooblen = mtd->oobsize;
ops.oobbuf = oob;
Expand Down
10 changes: 6 additions & 4 deletions drivers/mtd/mtdchar.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ static ssize_t mtd_read(struct file *file, char __user *buf, size_t count,loff_t
{
struct mtd_oob_ops ops;

ops.mode = MTD_OOB_RAW;
ops.mode = MTD_OPS_RAW;
ops.datbuf = kbuf;
ops.oobbuf = NULL;
ops.len = len;
Expand Down Expand Up @@ -317,7 +317,7 @@ static ssize_t mtd_write(struct file *file, const char __user *buf, size_t count
{
struct mtd_oob_ops ops;

ops.mode = MTD_OOB_RAW;
ops.mode = MTD_OPS_RAW;
ops.datbuf = kbuf;
ops.oobbuf = NULL;
ops.ooboffs = 0;
Expand Down Expand Up @@ -413,7 +413,8 @@ static int mtd_do_writeoob(struct file *file, struct mtd_info *mtd,
ops.ooblen = length;
ops.ooboffs = start & (mtd->writesize - 1);
ops.datbuf = NULL;
ops.mode = (mfi->mode == MTD_MODE_RAW) ? MTD_OOB_RAW : MTD_OOB_PLACE;
ops.mode = (mfi->mode == MTD_MODE_RAW) ? MTD_OPS_RAW :
MTD_OPS_PLACE_OOB;

if (ops.ooboffs && ops.ooblen > (mtd->oobsize - ops.ooboffs))
return -EINVAL;
Expand Down Expand Up @@ -457,7 +458,8 @@ static int mtd_do_readoob(struct file *file, struct mtd_info *mtd,
ops.ooblen = length;
ops.ooboffs = start & (mtd->writesize - 1);
ops.datbuf = NULL;
ops.mode = (mfi->mode == MTD_MODE_RAW) ? MTD_OOB_RAW : MTD_OOB_PLACE;
ops.mode = (mfi->mode == MTD_MODE_RAW) ? MTD_OPS_RAW :
MTD_OPS_PLACE_OOB;

if (ops.ooboffs && ops.ooblen > (mtd->oobsize - ops.ooboffs))
return -EINVAL;
Expand Down
2 changes: 1 addition & 1 deletion drivers/mtd/mtdpart.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ static int part_read_oob(struct mtd_info *mtd, loff_t from,
if (ops->oobbuf) {
size_t len, pages;

if (ops->mode == MTD_OOB_AUTO)
if (ops->mode == MTD_OPS_AUTO_OOB)
len = mtd->oobavail;
else
len = mtd->oobsize;
Expand Down
6 changes: 3 additions & 3 deletions drivers/mtd/mtdswap.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ static int mtdswap_read_markers(struct mtdswap_dev *d, struct swap_eb *eb)
ops.oobbuf = d->oob_buf;
ops.ooboffs = 0;
ops.datbuf = NULL;
ops.mode = MTD_OOB_AUTO;
ops.mode = MTD_OPS_AUTO_OOB;

ret = mtdswap_read_oob(d, offset, &ops);

Expand Down Expand Up @@ -389,7 +389,7 @@ static int mtdswap_write_marker(struct mtdswap_dev *d, struct swap_eb *eb,

ops.ooboffs = 0;
ops.oobbuf = (uint8_t *)&n;
ops.mode = MTD_OOB_AUTO;
ops.mode = MTD_OPS_AUTO_OOB;
ops.datbuf = NULL;

if (marker == MTDSWAP_TYPE_CLEAN) {
Expand Down Expand Up @@ -931,7 +931,7 @@ static unsigned int mtdswap_eblk_passes(struct mtdswap_dev *d,
struct mtd_oob_ops ops;
int ret;

ops.mode = MTD_OOB_AUTO;
ops.mode = MTD_OPS_AUTO_OOB;
ops.len = mtd->writesize;
ops.ooblen = mtd->ecclayout->oobavail;
ops.ooboffs = 0;
Expand Down
2 changes: 1 addition & 1 deletion drivers/mtd/nand/gpmi-nand/gpmi-nand.c
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,7 @@ gpmi_ecc_write_oob(struct mtd_info *mtd, struct nand_chip *chip, int page)
* The BCH will use all the (page + oob).
* Our gpmi_hw_ecclayout can only prohibit the JFFS2 to write the oob.
* But it can not stop some ioctls such MEMWRITEOOB which uses
* MTD_OOB_PLACE. So We have to implement this function to prohibit
* MTD_OPS_PLACE_OOB. So We have to implement this function to prohibit
* these ioctls too.
*/
return -EPERM;
Expand Down
40 changes: 20 additions & 20 deletions drivers/mtd/nand/nand_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -1382,12 +1382,12 @@ static uint8_t *nand_transfer_oob(struct nand_chip *chip, uint8_t *oob,
{
switch (ops->mode) {

case MTD_OOB_PLACE:
case MTD_OOB_RAW:
case MTD_OPS_PLACE_OOB:
case MTD_OPS_RAW:
memcpy(oob, chip->oob_poi + ops->ooboffs, len);
return oob + len;

case MTD_OOB_AUTO: {
case MTD_OPS_AUTO_OOB: {
struct nand_oobfree *free = chip->ecc.layout->oobfree;
uint32_t boffs = 0, roffs = ops->ooboffs;
size_t bytes = 0;
Expand Down Expand Up @@ -1437,7 +1437,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
int ret = 0;
uint32_t readlen = ops->len;
uint32_t oobreadlen = ops->ooblen;
uint32_t max_oobsize = ops->mode == MTD_OOB_AUTO ?
uint32_t max_oobsize = ops->mode == MTD_OPS_AUTO_OOB ?
mtd->oobavail : mtd->oobsize;

uint8_t *bufpoi, *oob, *buf;
Expand Down Expand Up @@ -1469,7 +1469,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
}

/* Now read the page into the buffer */
if (unlikely(ops->mode == MTD_OOB_RAW))
if (unlikely(ops->mode == MTD_OPS_RAW))
ret = chip->ecc.read_page_raw(mtd, chip,
bufpoi, page);
else if (!aligned && NAND_SUBPAGE_READ(chip) && !oob)
Expand Down Expand Up @@ -1759,7 +1759,7 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from,

stats = mtd->ecc_stats;

if (ops->mode == MTD_OOB_AUTO)
if (ops->mode == MTD_OPS_AUTO_OOB)
len = chip->ecc.layout->oobavail;
else
len = mtd->oobsize;
Expand Down Expand Up @@ -1787,7 +1787,7 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from,
page = realpage & chip->pagemask;

while (1) {
if (ops->mode == MTD_OOB_RAW)
if (ops->mode == MTD_OPS_RAW)
sndcmd = chip->ecc.read_oob_raw(mtd, chip, page, sndcmd);
else
sndcmd = chip->ecc.read_oob(mtd, chip, page, sndcmd);
Expand Down Expand Up @@ -1865,9 +1865,9 @@ static int nand_read_oob(struct mtd_info *mtd, loff_t from,
nand_get_device(chip, mtd, FL_READING);

switch (ops->mode) {
case MTD_OOB_PLACE:
case MTD_OOB_AUTO:
case MTD_OOB_RAW:
case MTD_OPS_PLACE_OOB:
case MTD_OPS_AUTO_OOB:
case MTD_OPS_RAW:
break;

default:
Expand Down Expand Up @@ -2113,12 +2113,12 @@ static uint8_t *nand_fill_oob(struct mtd_info *mtd, uint8_t *oob, size_t len,

switch (ops->mode) {

case MTD_OOB_PLACE:
case MTD_OOB_RAW:
case MTD_OPS_PLACE_OOB:
case MTD_OPS_RAW:
memcpy(chip->oob_poi + ops->ooboffs, oob, len);
return oob + len;

case MTD_OOB_AUTO: {
case MTD_OPS_AUTO_OOB: {
struct nand_oobfree *free = chip->ecc.layout->oobfree;
uint32_t boffs = 0, woffs = ops->ooboffs;
size_t bytes = 0;
Expand Down Expand Up @@ -2167,7 +2167,7 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
uint32_t writelen = ops->len;

uint32_t oobwritelen = ops->ooblen;
uint32_t oobmaxlen = ops->mode == MTD_OOB_AUTO ?
uint32_t oobmaxlen = ops->mode == MTD_OPS_AUTO_OOB ?
mtd->oobavail : mtd->oobsize;

uint8_t *oob = ops->oobbuf;
Expand Down Expand Up @@ -2236,7 +2236,7 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
}

ret = chip->write_page(mtd, chip, wbuf, page, cached,
(ops->mode == MTD_OOB_RAW));
(ops->mode == MTD_OPS_RAW));
if (ret)
break;

Expand Down Expand Up @@ -2356,7 +2356,7 @@ static int nand_do_write_oob(struct mtd_info *mtd, loff_t to,
pr_debug("%s: to = 0x%08x, len = %i\n",
__func__, (unsigned int)to, (int)ops->ooblen);

if (ops->mode == MTD_OOB_AUTO)
if (ops->mode == MTD_OPS_AUTO_OOB)
len = chip->ecc.layout->oobavail;
else
len = mtd->oobsize;
Expand Down Expand Up @@ -2408,7 +2408,7 @@ static int nand_do_write_oob(struct mtd_info *mtd, loff_t to,

nand_fill_oob(mtd, ops->oobbuf, ops->ooblen, ops);

if (ops->mode == MTD_OOB_RAW)
if (ops->mode == MTD_OPS_RAW)
status = chip->ecc.write_oob_raw(mtd, chip, page & chip->pagemask);
else
status = chip->ecc.write_oob(mtd, chip, page & chip->pagemask);
Expand Down Expand Up @@ -2445,9 +2445,9 @@ static int nand_write_oob(struct mtd_info *mtd, loff_t to,
nand_get_device(chip, mtd, FL_WRITING);

switch (ops->mode) {
case MTD_OOB_PLACE:
case MTD_OOB_AUTO:
case MTD_OOB_RAW:
case MTD_OPS_PLACE_OOB:
case MTD_OPS_AUTO_OOB:
case MTD_OPS_RAW:
break;

default:
Expand Down
8 changes: 4 additions & 4 deletions drivers/mtd/nand/nand_bbt.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ static int scan_read_raw_oob(struct mtd_info *mtd, uint8_t *buf, loff_t offs,
struct mtd_oob_ops ops;
int res;

ops.mode = MTD_OOB_RAW;
ops.mode = MTD_OPS_RAW;
ops.ooboffs = 0;
ops.ooblen = mtd->oobsize;

Expand Down Expand Up @@ -350,7 +350,7 @@ static int scan_write_bbt(struct mtd_info *mtd, loff_t offs, size_t len,
{
struct mtd_oob_ops ops;

ops.mode = MTD_OOB_PLACE;
ops.mode = MTD_OPS_PLACE_OOB;
ops.ooboffs = 0;
ops.ooblen = mtd->oobsize;
ops.datbuf = buf;
Expand Down Expand Up @@ -433,7 +433,7 @@ static int scan_block_fast(struct mtd_info *mtd, struct nand_bbt_descr *bd,
ops.oobbuf = buf;
ops.ooboffs = 0;
ops.datbuf = NULL;
ops.mode = MTD_OOB_PLACE;
ops.mode = MTD_OPS_PLACE_OOB;

for (j = 0; j < len; j++) {
/*
Expand Down Expand Up @@ -672,7 +672,7 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf,
ops.ooblen = mtd->oobsize;
ops.ooboffs = 0;
ops.datbuf = NULL;
ops.mode = MTD_OOB_PLACE;
ops.mode = MTD_OPS_PLACE_OOB;

if (!rcode)
rcode = 0xff;
Expand Down
2 changes: 1 addition & 1 deletion drivers/mtd/nand/sm_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static int sm_block_markbad(struct mtd_info *mtd, loff_t ofs)

/* As long as this function is called on erase block boundaries
it will work correctly for 256 byte nand */
ops.mode = MTD_OOB_PLACE;
ops.mode = MTD_OPS_PLACE_OOB;
ops.ooboffs = 0;
ops.ooblen = mtd->oobsize;
ops.oobbuf = (void *)&oob;
Expand Down
6 changes: 3 additions & 3 deletions drivers/mtd/nftlcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ int nftl_read_oob(struct mtd_info *mtd, loff_t offs, size_t len,
struct mtd_oob_ops ops;
int res;

ops.mode = MTD_OOB_PLACE;
ops.mode = MTD_OPS_PLACE_OOB;
ops.ooboffs = offs & mask;
ops.ooblen = len;
ops.oobbuf = buf;
Expand All @@ -168,7 +168,7 @@ int nftl_write_oob(struct mtd_info *mtd, loff_t offs, size_t len,
struct mtd_oob_ops ops;
int res;

ops.mode = MTD_OOB_PLACE;
ops.mode = MTD_OPS_PLACE_OOB;
ops.ooboffs = offs & mask;
ops.ooblen = len;
ops.oobbuf = buf;
Expand All @@ -191,7 +191,7 @@ static int nftl_write(struct mtd_info *mtd, loff_t offs, size_t len,
struct mtd_oob_ops ops;
int res;

ops.mode = MTD_OOB_PLACE;
ops.mode = MTD_OPS_PLACE_OOB;
ops.ooboffs = offs & mask;
ops.ooblen = mtd->oobsize;
ops.oobbuf = oob;
Expand Down
Loading

0 comments on commit 0612b9d

Please sign in to comment.