Skip to content

Commit

Permalink
mtd: nand: kill member ops' of struct nand_chip'
Browse files Browse the repository at this point in the history
The nand_chip.ops field is a struct that is passed around globally with
no particular reason. Every time it is used, it could just as easily be
replaced with a local struct that is updated on each operation. So make
it local.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
  • Loading branch information
Brian Norris authored and Artem Bityutskiy committed Sep 11, 2011
1 parent 4180f24 commit 4a89ff8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 24 deletions.
46 changes: 25 additions & 21 deletions drivers/mtd/nand/nand_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,8 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs)
if (chip->bbt_options & NAND_BBT_USE_FLASH)
ret = nand_update_bbt(mtd, ofs);
else {
struct mtd_oob_ops ops;

nand_get_device(chip, mtd, FL_WRITING);

/*
Expand All @@ -414,13 +416,12 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs)
* procedure. We write two bytes per location, so we dont have
* to mess with 16 bit access.
*/
ops.len = ops.ooblen = 2;
ops.datbuf = NULL;
ops.oobbuf = buf;
ops.ooboffs = chip->badblockpos & ~0x01;
do {
chip->ops.len = chip->ops.ooblen = 2;
chip->ops.datbuf = NULL;
chip->ops.oobbuf = buf;
chip->ops.ooboffs = chip->badblockpos & ~0x01;

ret = nand_do_write_oob(mtd, ofs, &chip->ops);
ret = nand_do_write_oob(mtd, ofs, &ops);

i++;
ofs += mtd->writesize;
Expand Down Expand Up @@ -1573,6 +1574,7 @@ static int nand_read(struct mtd_info *mtd, loff_t from, size_t len,
size_t *retlen, uint8_t *buf)
{
struct nand_chip *chip = mtd->priv;
struct mtd_oob_ops ops;
int ret;

/* Do not allow reads past end of device */
Expand All @@ -1583,13 +1585,13 @@ static int nand_read(struct mtd_info *mtd, loff_t from, size_t len,

nand_get_device(chip, mtd, FL_READING);

chip->ops.len = len;
chip->ops.datbuf = buf;
chip->ops.oobbuf = NULL;
ops.len = len;
ops.datbuf = buf;
ops.oobbuf = NULL;

ret = nand_do_read_ops(mtd, from, &chip->ops);
ret = nand_do_read_ops(mtd, from, &ops);

*retlen = chip->ops.retlen;
*retlen = ops.retlen;

nand_release_device(mtd);

Expand Down Expand Up @@ -2278,6 +2280,7 @@ static int panic_nand_write(struct mtd_info *mtd, loff_t to, size_t len,
size_t *retlen, const uint8_t *buf)
{
struct nand_chip *chip = mtd->priv;
struct mtd_oob_ops ops;
int ret;

/* Do not allow reads past end of device */
Expand All @@ -2292,13 +2295,13 @@ static int panic_nand_write(struct mtd_info *mtd, loff_t to, size_t len,
/* Grab the device */
panic_nand_get_device(chip, mtd, FL_WRITING);

chip->ops.len = len;
chip->ops.datbuf = (uint8_t *)buf;
chip->ops.oobbuf = NULL;
ops.len = len;
ops.datbuf = (uint8_t *)buf;
ops.oobbuf = NULL;

ret = nand_do_write_ops(mtd, to, &chip->ops);
ret = nand_do_write_ops(mtd, to, &ops);

*retlen = chip->ops.retlen;
*retlen = ops.retlen;
return ret;
}

Expand All @@ -2316,6 +2319,7 @@ static int nand_write(struct mtd_info *mtd, loff_t to, size_t len,
size_t *retlen, const uint8_t *buf)
{
struct nand_chip *chip = mtd->priv;
struct mtd_oob_ops ops;
int ret;

/* Do not allow reads past end of device */
Expand All @@ -2326,13 +2330,13 @@ static int nand_write(struct mtd_info *mtd, loff_t to, size_t len,

nand_get_device(chip, mtd, FL_WRITING);

chip->ops.len = len;
chip->ops.datbuf = (uint8_t *)buf;
chip->ops.oobbuf = NULL;
ops.len = len;
ops.datbuf = (uint8_t *)buf;
ops.oobbuf = NULL;

ret = nand_do_write_ops(mtd, to, &chip->ops);
ret = nand_do_write_ops(mtd, to, &ops);

*retlen = chip->ops.retlen;
*retlen = ops.retlen;

nand_release_device(mtd);

Expand Down
3 changes: 0 additions & 3 deletions include/linux/mtd/nand.h
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,6 @@ struct nand_buffers {
* @ecc: [BOARDSPECIFIC] ECC control structure
* @buffers: buffer structure for read/write
* @hwcontrol: platform-specific hardware control structure
* @ops: oob operation operands
* @erase_cmd: [INTERN] erase command write function, selectable due
* to AND support.
* @scan_bbt: [REPLACEABLE] function to scan bad block table
Expand Down Expand Up @@ -535,8 +534,6 @@ struct nand_chip {
struct nand_buffers *buffers;
struct nand_hw_control hwcontrol;

struct mtd_oob_ops ops;

uint8_t *bbt;
struct nand_bbt_descr *bbt_td;
struct nand_bbt_descr *bbt_md;
Expand Down

0 comments on commit 4a89ff8

Please sign in to comment.