Skip to content

Commit

Permalink
mtd: remove the "chip" parameter in nand_get_device()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Huang Shijie authored and Artem Bityutskiy committed Dec 3, 2012
1 parent b0bb690 commit 6a8214a
Showing 1 changed file with 14 additions and 23 deletions.
37 changes: 14 additions & 23 deletions drivers/mtd/nand/nand_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ static struct nand_ecclayout nand_oob_128 = {
.length = 78} }
};

static int nand_get_device(struct nand_chip *chip, struct mtd_info *mtd,
int new_state);
static int nand_get_device(struct mtd_info *mtd, int new_state);

static int nand_do_write_oob(struct mtd_info *mtd, loff_t to,
struct mtd_oob_ops *ops);
Expand Down Expand Up @@ -300,7 +299,7 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)
if (getchip) {
chipnr = (int)(ofs >> chip->chip_shift);

nand_get_device(chip, mtd, FL_READING);
nand_get_device(mtd, FL_READING);

/* Select the NAND device */
chip->select_chip(mtd, chipnr);
Expand Down Expand Up @@ -382,7 +381,7 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs)
struct mtd_oob_ops ops;
loff_t wr_ofs = ofs;

nand_get_device(chip, mtd, FL_WRITING);
nand_get_device(mtd, FL_WRITING);

ops.datbuf = NULL;
ops.oobbuf = buf;
Expand Down Expand Up @@ -749,15 +748,15 @@ static void panic_nand_get_device(struct nand_chip *chip,

/**
* nand_get_device - [GENERIC] Get chip for selected access
* @chip: the nand chip descriptor
* @mtd: MTD device structure
* @new_state: the state which is requested
*
* Get the device and lock it for exclusive access
*/
static int
nand_get_device(struct nand_chip *chip, struct mtd_info *mtd, int new_state)
nand_get_device(struct mtd_info *mtd, int new_state)
{
struct nand_chip *chip = mtd->priv;
spinlock_t *lock = &chip->controller->lock;
wait_queue_head_t *wq = &chip->controller->wq;
DECLARE_WAITQUEUE(wait, current);
Expand Down Expand Up @@ -933,7 +932,7 @@ int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
if (ofs + len == mtd->size)
len -= mtd->erasesize;

nand_get_device(chip, mtd, FL_UNLOCKING);
nand_get_device(mtd, FL_UNLOCKING);

/* Shift to get chip number */
chipnr = ofs >> chip->chip_shift;
Expand Down Expand Up @@ -983,7 +982,7 @@ int nand_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
if (check_offs_len(mtd, ofs, len))
ret = -EINVAL;

nand_get_device(chip, mtd, FL_LOCKING);
nand_get_device(mtd, FL_LOCKING);

/* Shift to get chip number */
chipnr = ofs >> chip->chip_shift;
Expand Down Expand Up @@ -1581,11 +1580,10 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
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;

nand_get_device(chip, mtd, FL_READING);
nand_get_device(mtd, FL_READING);
ops.len = len;
ops.datbuf = buf;
ops.oobbuf = NULL;
Expand Down Expand Up @@ -1832,7 +1830,6 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from,
static int nand_read_oob(struct mtd_info *mtd, loff_t from,
struct mtd_oob_ops *ops)
{
struct nand_chip *chip = mtd->priv;
int ret = -ENOTSUPP;

ops->retlen = 0;
Expand All @@ -1844,7 +1841,7 @@ static int nand_read_oob(struct mtd_info *mtd, loff_t from,
return -EINVAL;
}

nand_get_device(chip, mtd, FL_READING);
nand_get_device(mtd, FL_READING);

switch (ops->mode) {
case MTD_OPS_PLACE_OOB:
Expand Down Expand Up @@ -2314,11 +2311,10 @@ static int panic_nand_write(struct mtd_info *mtd, loff_t to, size_t len,
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;

nand_get_device(chip, mtd, FL_WRITING);
nand_get_device(mtd, FL_WRITING);
ops.len = len;
ops.datbuf = (uint8_t *)buf;
ops.oobbuf = NULL;
Expand Down Expand Up @@ -2424,7 +2420,6 @@ static int nand_do_write_oob(struct mtd_info *mtd, loff_t to,
static int nand_write_oob(struct mtd_info *mtd, loff_t to,
struct mtd_oob_ops *ops)
{
struct nand_chip *chip = mtd->priv;
int ret = -ENOTSUPP;

ops->retlen = 0;
Expand All @@ -2436,7 +2431,7 @@ static int nand_write_oob(struct mtd_info *mtd, loff_t to,
return -EINVAL;
}

nand_get_device(chip, mtd, FL_WRITING);
nand_get_device(mtd, FL_WRITING);

switch (ops->mode) {
case MTD_OPS_PLACE_OOB:
Expand Down Expand Up @@ -2529,7 +2524,7 @@ int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr,
return -EINVAL;

/* Grab the lock and see if the device is available */
nand_get_device(chip, mtd, FL_ERASING);
nand_get_device(mtd, FL_ERASING);

/* Shift to get first page */
page = (int)(instr->addr >> chip->page_shift);
Expand Down Expand Up @@ -2675,12 +2670,10 @@ int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr,
*/
static void nand_sync(struct mtd_info *mtd)
{
struct nand_chip *chip = mtd->priv;

pr_debug("%s: called\n", __func__);

/* Grab the lock and see if the device is available */
nand_get_device(chip, mtd, FL_SYNCING);
nand_get_device(mtd, FL_SYNCING);
/* Release it and go back */
nand_release_device(mtd);
}
Expand Down Expand Up @@ -2766,9 +2759,7 @@ static int nand_onfi_get_features(struct mtd_info *mtd, struct nand_chip *chip,
*/
static int nand_suspend(struct mtd_info *mtd)
{
struct nand_chip *chip = mtd->priv;

return nand_get_device(chip, mtd, FL_PM_SUSPENDED);
return nand_get_device(mtd, FL_PM_SUSPENDED);
}

/**
Expand Down

0 comments on commit 6a8214a

Please sign in to comment.