aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand/nand_base.c
diff options
context:
space:
mode:
authorHuang Shijie <b32955@freescale.com>2012-11-19 01:43:30 -0500
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2012-12-03 09:36:51 -0500
commit6a8214aa3d323d2e185523ea112116759bc3c5ce (patch)
tree6b5ea204d2c477d328c7f81168ed3fbb02e9bb3e /drivers/mtd/nand/nand_base.c
parentb0bb6903c8fca2d5ebef1f8ae63d420eb931bb1e (diff)
mtd: remove the "chip" parameter in nand_get_device()
There are two reasons to remove the "chip" parameter in nand_get_device(): [1] The nand_release_device() does not have the "chip" parameter. [2] We can get the nand_chip by the mtd->priv field. This patch removes the "chip" parameter in nand_get_device(). Signed-off-by: Huang Shijie <b32955@freescale.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Diffstat (limited to 'drivers/mtd/nand/nand_base.c')
-rw-r--r--drivers/mtd/nand/nand_base.c37
1 files changed, 14 insertions, 23 deletions
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 861a87d4d16b..55c2883af406 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -93,8 +93,7 @@ static struct nand_ecclayout nand_oob_128 = {
93 .length = 78} } 93 .length = 78} }
94}; 94};
95 95
96static int nand_get_device(struct nand_chip *chip, struct mtd_info *mtd, 96static int nand_get_device(struct mtd_info *mtd, int new_state);
97 int new_state);
98 97
99static int nand_do_write_oob(struct mtd_info *mtd, loff_t to, 98static int nand_do_write_oob(struct mtd_info *mtd, loff_t to,
100 struct mtd_oob_ops *ops); 99 struct mtd_oob_ops *ops);
@@ -300,7 +299,7 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)
300 if (getchip) { 299 if (getchip) {
301 chipnr = (int)(ofs >> chip->chip_shift); 300 chipnr = (int)(ofs >> chip->chip_shift);
302 301
303 nand_get_device(chip, mtd, FL_READING); 302 nand_get_device(mtd, FL_READING);
304 303
305 /* Select the NAND device */ 304 /* Select the NAND device */
306 chip->select_chip(mtd, chipnr); 305 chip->select_chip(mtd, chipnr);
@@ -382,7 +381,7 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs)
382 struct mtd_oob_ops ops; 381 struct mtd_oob_ops ops;
383 loff_t wr_ofs = ofs; 382 loff_t wr_ofs = ofs;
384 383
385 nand_get_device(chip, mtd, FL_WRITING); 384 nand_get_device(mtd, FL_WRITING);
386 385
387 ops.datbuf = NULL; 386 ops.datbuf = NULL;
388 ops.oobbuf = buf; 387 ops.oobbuf = buf;
@@ -749,15 +748,15 @@ static void panic_nand_get_device(struct nand_chip *chip,
749 748
750/** 749/**
751 * nand_get_device - [GENERIC] Get chip for selected access 750 * nand_get_device - [GENERIC] Get chip for selected access
752 * @chip: the nand chip descriptor
753 * @mtd: MTD device structure 751 * @mtd: MTD device structure
754 * @new_state: the state which is requested 752 * @new_state: the state which is requested
755 * 753 *
756 * Get the device and lock it for exclusive access 754 * Get the device and lock it for exclusive access
757 */ 755 */
758static int 756static int
759nand_get_device(struct nand_chip *chip, struct mtd_info *mtd, int new_state) 757nand_get_device(struct mtd_info *mtd, int new_state)
760{ 758{
759 struct nand_chip *chip = mtd->priv;
761 spinlock_t *lock = &chip->controller->lock; 760 spinlock_t *lock = &chip->controller->lock;
762 wait_queue_head_t *wq = &chip->controller->wq; 761 wait_queue_head_t *wq = &chip->controller->wq;
763 DECLARE_WAITQUEUE(wait, current); 762 DECLARE_WAITQUEUE(wait, current);
@@ -933,7 +932,7 @@ int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
933 if (ofs + len == mtd->size) 932 if (ofs + len == mtd->size)
934 len -= mtd->erasesize; 933 len -= mtd->erasesize;
935 934
936 nand_get_device(chip, mtd, FL_UNLOCKING); 935 nand_get_device(mtd, FL_UNLOCKING);
937 936
938 /* Shift to get chip number */ 937 /* Shift to get chip number */
939 chipnr = ofs >> chip->chip_shift; 938 chipnr = ofs >> chip->chip_shift;
@@ -983,7 +982,7 @@ int nand_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
983 if (check_offs_len(mtd, ofs, len)) 982 if (check_offs_len(mtd, ofs, len))
984 ret = -EINVAL; 983 ret = -EINVAL;
985 984
986 nand_get_device(chip, mtd, FL_LOCKING); 985 nand_get_device(mtd, FL_LOCKING);
987 986
988 /* Shift to get chip number */ 987 /* Shift to get chip number */
989 chipnr = ofs >> chip->chip_shift; 988 chipnr = ofs >> chip->chip_shift;
@@ -1581,11 +1580,10 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
1581static int nand_read(struct mtd_info *mtd, loff_t from, size_t len, 1580static int nand_read(struct mtd_info *mtd, loff_t from, size_t len,
1582 size_t *retlen, uint8_t *buf) 1581 size_t *retlen, uint8_t *buf)
1583{ 1582{
1584 struct nand_chip *chip = mtd->priv;
1585 struct mtd_oob_ops ops; 1583 struct mtd_oob_ops ops;
1586 int ret; 1584 int ret;
1587 1585
1588 nand_get_device(chip, mtd, FL_READING); 1586 nand_get_device(mtd, FL_READING);
1589 ops.len = len; 1587 ops.len = len;
1590 ops.datbuf = buf; 1588 ops.datbuf = buf;
1591 ops.oobbuf = NULL; 1589 ops.oobbuf = NULL;
@@ -1832,7 +1830,6 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from,
1832static int nand_read_oob(struct mtd_info *mtd, loff_t from, 1830static int nand_read_oob(struct mtd_info *mtd, loff_t from,
1833 struct mtd_oob_ops *ops) 1831 struct mtd_oob_ops *ops)
1834{ 1832{
1835 struct nand_chip *chip = mtd->priv;
1836 int ret = -ENOTSUPP; 1833 int ret = -ENOTSUPP;
1837 1834
1838 ops->retlen = 0; 1835 ops->retlen = 0;
@@ -1844,7 +1841,7 @@ static int nand_read_oob(struct mtd_info *mtd, loff_t from,
1844 return -EINVAL; 1841 return -EINVAL;
1845 } 1842 }
1846 1843
1847 nand_get_device(chip, mtd, FL_READING); 1844 nand_get_device(mtd, FL_READING);
1848 1845
1849 switch (ops->mode) { 1846 switch (ops->mode) {
1850 case MTD_OPS_PLACE_OOB: 1847 case MTD_OPS_PLACE_OOB:
@@ -2314,11 +2311,10 @@ static int panic_nand_write(struct mtd_info *mtd, loff_t to, size_t len,
2314static int nand_write(struct mtd_info *mtd, loff_t to, size_t len, 2311static int nand_write(struct mtd_info *mtd, loff_t to, size_t len,
2315 size_t *retlen, const uint8_t *buf) 2312 size_t *retlen, const uint8_t *buf)
2316{ 2313{
2317 struct nand_chip *chip = mtd->priv;
2318 struct mtd_oob_ops ops; 2314 struct mtd_oob_ops ops;
2319 int ret; 2315 int ret;
2320 2316
2321 nand_get_device(chip, mtd, FL_WRITING); 2317 nand_get_device(mtd, FL_WRITING);
2322 ops.len = len; 2318 ops.len = len;
2323 ops.datbuf = (uint8_t *)buf; 2319 ops.datbuf = (uint8_t *)buf;
2324 ops.oobbuf = NULL; 2320 ops.oobbuf = NULL;
@@ -2424,7 +2420,6 @@ static int nand_do_write_oob(struct mtd_info *mtd, loff_t to,
2424static int nand_write_oob(struct mtd_info *mtd, loff_t to, 2420static int nand_write_oob(struct mtd_info *mtd, loff_t to,
2425 struct mtd_oob_ops *ops) 2421 struct mtd_oob_ops *ops)
2426{ 2422{
2427 struct nand_chip *chip = mtd->priv;
2428 int ret = -ENOTSUPP; 2423 int ret = -ENOTSUPP;
2429 2424
2430 ops->retlen = 0; 2425 ops->retlen = 0;
@@ -2436,7 +2431,7 @@ static int nand_write_oob(struct mtd_info *mtd, loff_t to,
2436 return -EINVAL; 2431 return -EINVAL;
2437 } 2432 }
2438 2433
2439 nand_get_device(chip, mtd, FL_WRITING); 2434 nand_get_device(mtd, FL_WRITING);
2440 2435
2441 switch (ops->mode) { 2436 switch (ops->mode) {
2442 case MTD_OPS_PLACE_OOB: 2437 case MTD_OPS_PLACE_OOB:
@@ -2529,7 +2524,7 @@ int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr,
2529 return -EINVAL; 2524 return -EINVAL;
2530 2525
2531 /* Grab the lock and see if the device is available */ 2526 /* Grab the lock and see if the device is available */
2532 nand_get_device(chip, mtd, FL_ERASING); 2527 nand_get_device(mtd, FL_ERASING);
2533 2528
2534 /* Shift to get first page */ 2529 /* Shift to get first page */
2535 page = (int)(instr->addr >> chip->page_shift); 2530 page = (int)(instr->addr >> chip->page_shift);
@@ -2675,12 +2670,10 @@ erase_exit:
2675 */ 2670 */
2676static void nand_sync(struct mtd_info *mtd) 2671static void nand_sync(struct mtd_info *mtd)
2677{ 2672{
2678 struct nand_chip *chip = mtd->priv;
2679
2680 pr_debug("%s: called\n", __func__); 2673 pr_debug("%s: called\n", __func__);
2681 2674
2682 /* Grab the lock and see if the device is available */ 2675 /* Grab the lock and see if the device is available */
2683 nand_get_device(chip, mtd, FL_SYNCING); 2676 nand_get_device(mtd, FL_SYNCING);
2684 /* Release it and go back */ 2677 /* Release it and go back */
2685 nand_release_device(mtd); 2678 nand_release_device(mtd);
2686} 2679}
@@ -2766,9 +2759,7 @@ static int nand_onfi_get_features(struct mtd_info *mtd, struct nand_chip *chip,
2766 */ 2759 */
2767static int nand_suspend(struct mtd_info *mtd) 2760static int nand_suspend(struct mtd_info *mtd)
2768{ 2761{
2769 struct nand_chip *chip = mtd->priv; 2762 return nand_get_device(mtd, FL_PM_SUSPENDED);
2770
2771 return nand_get_device(chip, mtd, FL_PM_SUSPENDED);
2772} 2763}
2773 2764
2774/** 2765/**