mtd: nand: kill member `ops' of `struct nand_chip'
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>
This commit is contained in:
parent
4180f24a7b
commit
4a89ff885f
|
@ -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)
|
if (chip->bbt_options & NAND_BBT_USE_FLASH)
|
||||||
ret = nand_update_bbt(mtd, ofs);
|
ret = nand_update_bbt(mtd, ofs);
|
||||||
else {
|
else {
|
||||||
|
struct mtd_oob_ops ops;
|
||||||
|
|
||||||
nand_get_device(chip, mtd, FL_WRITING);
|
nand_get_device(chip, mtd, FL_WRITING);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -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
|
* procedure. We write two bytes per location, so we dont have
|
||||||
* to mess with 16 bit access.
|
* to mess with 16 bit access.
|
||||||
*/
|
*/
|
||||||
|
ops.len = ops.ooblen = 2;
|
||||||
|
ops.datbuf = NULL;
|
||||||
|
ops.oobbuf = buf;
|
||||||
|
ops.ooboffs = chip->badblockpos & ~0x01;
|
||||||
do {
|
do {
|
||||||
chip->ops.len = chip->ops.ooblen = 2;
|
ret = nand_do_write_oob(mtd, ofs, &ops);
|
||||||
chip->ops.datbuf = NULL;
|
|
||||||
chip->ops.oobbuf = buf;
|
|
||||||
chip->ops.ooboffs = chip->badblockpos & ~0x01;
|
|
||||||
|
|
||||||
ret = nand_do_write_oob(mtd, ofs, &chip->ops);
|
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
ofs += mtd->writesize;
|
ofs += mtd->writesize;
|
||||||
|
@ -1573,6 +1574,7 @@ static int nand_read(struct mtd_info *mtd, loff_t from, size_t len,
|
||||||
size_t *retlen, uint8_t *buf)
|
size_t *retlen, uint8_t *buf)
|
||||||
{
|
{
|
||||||
struct nand_chip *chip = mtd->priv;
|
struct nand_chip *chip = mtd->priv;
|
||||||
|
struct mtd_oob_ops ops;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Do not allow reads past end of device */
|
/* Do not allow reads past end of device */
|
||||||
|
@ -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);
|
nand_get_device(chip, mtd, FL_READING);
|
||||||
|
|
||||||
chip->ops.len = len;
|
ops.len = len;
|
||||||
chip->ops.datbuf = buf;
|
ops.datbuf = buf;
|
||||||
chip->ops.oobbuf = NULL;
|
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);
|
nand_release_device(mtd);
|
||||||
|
|
||||||
|
@ -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)
|
size_t *retlen, const uint8_t *buf)
|
||||||
{
|
{
|
||||||
struct nand_chip *chip = mtd->priv;
|
struct nand_chip *chip = mtd->priv;
|
||||||
|
struct mtd_oob_ops ops;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Do not allow reads past end of device */
|
/* Do not allow reads past end of device */
|
||||||
|
@ -2292,13 +2295,13 @@ static int panic_nand_write(struct mtd_info *mtd, loff_t to, size_t len,
|
||||||
/* Grab the device */
|
/* Grab the device */
|
||||||
panic_nand_get_device(chip, mtd, FL_WRITING);
|
panic_nand_get_device(chip, mtd, FL_WRITING);
|
||||||
|
|
||||||
chip->ops.len = len;
|
ops.len = len;
|
||||||
chip->ops.datbuf = (uint8_t *)buf;
|
ops.datbuf = (uint8_t *)buf;
|
||||||
chip->ops.oobbuf = NULL;
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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)
|
size_t *retlen, const uint8_t *buf)
|
||||||
{
|
{
|
||||||
struct nand_chip *chip = mtd->priv;
|
struct nand_chip *chip = mtd->priv;
|
||||||
|
struct mtd_oob_ops ops;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Do not allow reads past end of device */
|
/* Do not allow reads past end of device */
|
||||||
|
@ -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);
|
nand_get_device(chip, mtd, FL_WRITING);
|
||||||
|
|
||||||
chip->ops.len = len;
|
ops.len = len;
|
||||||
chip->ops.datbuf = (uint8_t *)buf;
|
ops.datbuf = (uint8_t *)buf;
|
||||||
chip->ops.oobbuf = NULL;
|
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);
|
nand_release_device(mtd);
|
||||||
|
|
||||||
|
|
|
@ -427,7 +427,6 @@ struct nand_buffers {
|
||||||
* @ecc: [BOARDSPECIFIC] ECC control structure
|
* @ecc: [BOARDSPECIFIC] ECC control structure
|
||||||
* @buffers: buffer structure for read/write
|
* @buffers: buffer structure for read/write
|
||||||
* @hwcontrol: platform-specific hardware control structure
|
* @hwcontrol: platform-specific hardware control structure
|
||||||
* @ops: oob operation operands
|
|
||||||
* @erase_cmd: [INTERN] erase command write function, selectable due
|
* @erase_cmd: [INTERN] erase command write function, selectable due
|
||||||
* to AND support.
|
* to AND support.
|
||||||
* @scan_bbt: [REPLACEABLE] function to scan bad block table
|
* @scan_bbt: [REPLACEABLE] function to scan bad block table
|
||||||
|
@ -535,8 +534,6 @@ struct nand_chip {
|
||||||
struct nand_buffers *buffers;
|
struct nand_buffers *buffers;
|
||||||
struct nand_hw_control hwcontrol;
|
struct nand_hw_control hwcontrol;
|
||||||
|
|
||||||
struct mtd_oob_ops ops;
|
|
||||||
|
|
||||||
uint8_t *bbt;
|
uint8_t *bbt;
|
||||||
struct nand_bbt_descr *bbt_td;
|
struct nand_bbt_descr *bbt_td;
|
||||||
struct nand_bbt_descr *bbt_md;
|
struct nand_bbt_descr *bbt_md;
|
||||||
|
|
Loading…
Reference in New Issue