diff options
author | Brian Norris <computersforpeace@gmail.com> | 2011-08-30 21:45:45 -0400 |
---|---|---|
committer | Artem Bityutskiy <artem.bityutskiy@intel.com> | 2011-09-11 08:57:44 -0400 |
commit | 4a89ff885ff9f64ea62669100766e10e4e257c6e (patch) | |
tree | 66d7251fbfcc208e883271e7defd215b71d69af7 /drivers/mtd | |
parent | 4180f24a7bff3aa7978e3785d0edd5dcc4af9049 (diff) |
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>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/nand/nand_base.c | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 686b55770113..c9767b511dfe 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c | |||
@@ -406,6 +406,8 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs) | |||
406 | if (chip->bbt_options & NAND_BBT_USE_FLASH) | 406 | if (chip->bbt_options & NAND_BBT_USE_FLASH) |
407 | ret = nand_update_bbt(mtd, ofs); | 407 | ret = nand_update_bbt(mtd, ofs); |
408 | else { | 408 | else { |
409 | struct mtd_oob_ops ops; | ||
410 | |||
409 | nand_get_device(chip, mtd, FL_WRITING); | 411 | nand_get_device(chip, mtd, FL_WRITING); |
410 | 412 | ||
411 | /* | 413 | /* |
@@ -414,13 +416,12 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs) | |||
414 | * procedure. We write two bytes per location, so we dont have | 416 | * procedure. We write two bytes per location, so we dont have |
415 | * to mess with 16 bit access. | 417 | * to mess with 16 bit access. |
416 | */ | 418 | */ |
419 | ops.len = ops.ooblen = 2; | ||
420 | ops.datbuf = NULL; | ||
421 | ops.oobbuf = buf; | ||
422 | ops.ooboffs = chip->badblockpos & ~0x01; | ||
417 | do { | 423 | do { |
418 | chip->ops.len = chip->ops.ooblen = 2; | 424 | ret = nand_do_write_oob(mtd, ofs, &ops); |
419 | chip->ops.datbuf = NULL; | ||
420 | chip->ops.oobbuf = buf; | ||
421 | chip->ops.ooboffs = chip->badblockpos & ~0x01; | ||
422 | |||
423 | ret = nand_do_write_oob(mtd, ofs, &chip->ops); | ||
424 | 425 | ||
425 | i++; | 426 | i++; |
426 | ofs += mtd->writesize; | 427 | ofs += mtd->writesize; |
@@ -1573,6 +1574,7 @@ static int nand_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
1573 | size_t *retlen, uint8_t *buf) | 1574 | size_t *retlen, uint8_t *buf) |
1574 | { | 1575 | { |
1575 | struct nand_chip *chip = mtd->priv; | 1576 | struct nand_chip *chip = mtd->priv; |
1577 | struct mtd_oob_ops ops; | ||
1576 | int ret; | 1578 | int ret; |
1577 | 1579 | ||
1578 | /* Do not allow reads past end of device */ | 1580 | /* 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, | |||
1583 | 1585 | ||
1584 | nand_get_device(chip, mtd, FL_READING); | 1586 | nand_get_device(chip, mtd, FL_READING); |
1585 | 1587 | ||
1586 | chip->ops.len = len; | 1588 | ops.len = len; |
1587 | chip->ops.datbuf = buf; | 1589 | ops.datbuf = buf; |
1588 | chip->ops.oobbuf = NULL; | 1590 | ops.oobbuf = NULL; |
1589 | 1591 | ||
1590 | ret = nand_do_read_ops(mtd, from, &chip->ops); | 1592 | ret = nand_do_read_ops(mtd, from, &ops); |
1591 | 1593 | ||
1592 | *retlen = chip->ops.retlen; | 1594 | *retlen = ops.retlen; |
1593 | 1595 | ||
1594 | nand_release_device(mtd); | 1596 | nand_release_device(mtd); |
1595 | 1597 | ||
@@ -2278,6 +2280,7 @@ static int panic_nand_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
2278 | size_t *retlen, const uint8_t *buf) | 2280 | size_t *retlen, const uint8_t *buf) |
2279 | { | 2281 | { |
2280 | struct nand_chip *chip = mtd->priv; | 2282 | struct nand_chip *chip = mtd->priv; |
2283 | struct mtd_oob_ops ops; | ||
2281 | int ret; | 2284 | int ret; |
2282 | 2285 | ||
2283 | /* Do not allow reads past end of device */ | 2286 | /* 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, | |||
2292 | /* Grab the device */ | 2295 | /* Grab the device */ |
2293 | panic_nand_get_device(chip, mtd, FL_WRITING); | 2296 | panic_nand_get_device(chip, mtd, FL_WRITING); |
2294 | 2297 | ||
2295 | chip->ops.len = len; | 2298 | ops.len = len; |
2296 | chip->ops.datbuf = (uint8_t *)buf; | 2299 | ops.datbuf = (uint8_t *)buf; |
2297 | chip->ops.oobbuf = NULL; | 2300 | ops.oobbuf = NULL; |
2298 | 2301 | ||
2299 | ret = nand_do_write_ops(mtd, to, &chip->ops); | 2302 | ret = nand_do_write_ops(mtd, to, &ops); |
2300 | 2303 | ||
2301 | *retlen = chip->ops.retlen; | 2304 | *retlen = ops.retlen; |
2302 | return ret; | 2305 | return ret; |
2303 | } | 2306 | } |
2304 | 2307 | ||
@@ -2316,6 +2319,7 @@ static int nand_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
2316 | size_t *retlen, const uint8_t *buf) | 2319 | size_t *retlen, const uint8_t *buf) |
2317 | { | 2320 | { |
2318 | struct nand_chip *chip = mtd->priv; | 2321 | struct nand_chip *chip = mtd->priv; |
2322 | struct mtd_oob_ops ops; | ||
2319 | int ret; | 2323 | int ret; |
2320 | 2324 | ||
2321 | /* Do not allow reads past end of device */ | 2325 | /* 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, | |||
2326 | 2330 | ||
2327 | nand_get_device(chip, mtd, FL_WRITING); | 2331 | nand_get_device(chip, mtd, FL_WRITING); |
2328 | 2332 | ||
2329 | chip->ops.len = len; | 2333 | ops.len = len; |
2330 | chip->ops.datbuf = (uint8_t *)buf; | 2334 | ops.datbuf = (uint8_t *)buf; |
2331 | chip->ops.oobbuf = NULL; | 2335 | ops.oobbuf = NULL; |
2332 | 2336 | ||
2333 | ret = nand_do_write_ops(mtd, to, &chip->ops); | 2337 | ret = nand_do_write_ops(mtd, to, &ops); |
2334 | 2338 | ||
2335 | *retlen = chip->ops.retlen; | 2339 | *retlen = ops.retlen; |
2336 | 2340 | ||
2337 | nand_release_device(mtd); | 2341 | nand_release_device(mtd); |
2338 | 2342 | ||