mtd: remove the de-select chip code in nand_release_device()
The nand_get_device() does not select the chip, but nand_release_device() does de-select the chip. It is really strange. With the current code, nand_sync() will de-select the chip, even if the chip has never been selected. To make the balance of select/de-select chip, it's better to remove the de-select chip code in nand_release_device() which makes the code more clear. Signed-off-by: Huang Shijie <b32955@freescale.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
This commit is contained in:
parent
98a9e24506
commit
b0bb6903c8
|
@ -130,15 +130,12 @@ static int check_offs_len(struct mtd_info *mtd,
|
||||||
* nand_release_device - [GENERIC] release chip
|
* nand_release_device - [GENERIC] release chip
|
||||||
* @mtd: MTD device structure
|
* @mtd: MTD device structure
|
||||||
*
|
*
|
||||||
* Deselect, release chip lock and wake up anyone waiting on the device.
|
* Release chip lock and wake up anyone waiting on the device.
|
||||||
*/
|
*/
|
||||||
static void nand_release_device(struct mtd_info *mtd)
|
static void nand_release_device(struct mtd_info *mtd)
|
||||||
{
|
{
|
||||||
struct nand_chip *chip = mtd->priv;
|
struct nand_chip *chip = mtd->priv;
|
||||||
|
|
||||||
/* De-select the NAND device */
|
|
||||||
chip->select_chip(mtd, -1);
|
|
||||||
|
|
||||||
/* Release the controller and the chip */
|
/* Release the controller and the chip */
|
||||||
spin_lock(&chip->controller->lock);
|
spin_lock(&chip->controller->lock);
|
||||||
chip->controller->active = NULL;
|
chip->controller->active = NULL;
|
||||||
|
@ -333,8 +330,10 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)
|
||||||
i++;
|
i++;
|
||||||
} while (!res && i < 2 && (chip->bbt_options & NAND_BBT_SCAN2NDPAGE));
|
} while (!res && i < 2 && (chip->bbt_options & NAND_BBT_SCAN2NDPAGE));
|
||||||
|
|
||||||
if (getchip)
|
if (getchip) {
|
||||||
|
chip->select_chip(mtd, -1);
|
||||||
nand_release_device(mtd);
|
nand_release_device(mtd);
|
||||||
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -952,6 +951,7 @@ int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
|
||||||
ret = __nand_unlock(mtd, ofs, len, 0);
|
ret = __nand_unlock(mtd, ofs, len, 0);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
chip->select_chip(mtd, -1);
|
||||||
nand_release_device(mtd);
|
nand_release_device(mtd);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1016,6 +1016,7 @@ int nand_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
|
||||||
ret = __nand_unlock(mtd, ofs, len, 0x1);
|
ret = __nand_unlock(mtd, ofs, len, 0x1);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
chip->select_chip(mtd, -1);
|
||||||
nand_release_device(mtd);
|
nand_release_device(mtd);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1552,6 +1553,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
|
||||||
chip->select_chip(mtd, chipnr);
|
chip->select_chip(mtd, chipnr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
chip->select_chip(mtd, -1);
|
||||||
|
|
||||||
ops->retlen = ops->len - (size_t) readlen;
|
ops->retlen = ops->len - (size_t) readlen;
|
||||||
if (oob)
|
if (oob)
|
||||||
|
@ -1806,6 +1808,7 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from,
|
||||||
chip->select_chip(mtd, chipnr);
|
chip->select_chip(mtd, chipnr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
chip->select_chip(mtd, -1);
|
||||||
|
|
||||||
ops->oobretlen = ops->ooblen - readlen;
|
ops->oobretlen = ops->ooblen - readlen;
|
||||||
|
|
||||||
|
@ -2188,8 +2191,10 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
|
||||||
chip->select_chip(mtd, chipnr);
|
chip->select_chip(mtd, chipnr);
|
||||||
|
|
||||||
/* Check, if it is write protected */
|
/* Check, if it is write protected */
|
||||||
if (nand_check_wp(mtd))
|
if (nand_check_wp(mtd)) {
|
||||||
return -EIO;
|
ret = -EIO;
|
||||||
|
goto err_out;
|
||||||
|
}
|
||||||
|
|
||||||
realpage = (int)(to >> chip->page_shift);
|
realpage = (int)(to >> chip->page_shift);
|
||||||
page = realpage & chip->pagemask;
|
page = realpage & chip->pagemask;
|
||||||
|
@ -2201,8 +2206,10 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
|
||||||
chip->pagebuf = -1;
|
chip->pagebuf = -1;
|
||||||
|
|
||||||
/* Don't allow multipage oob writes with offset */
|
/* Don't allow multipage oob writes with offset */
|
||||||
if (oob && ops->ooboffs && (ops->ooboffs + ops->ooblen > oobmaxlen))
|
if (oob && ops->ooboffs && (ops->ooboffs + ops->ooblen > oobmaxlen)) {
|
||||||
return -EINVAL;
|
ret = -EINVAL;
|
||||||
|
goto err_out;
|
||||||
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
int bytes = mtd->writesize;
|
int bytes = mtd->writesize;
|
||||||
|
@ -2253,6 +2260,9 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
|
||||||
ops->retlen = ops->len - writelen;
|
ops->retlen = ops->len - writelen;
|
||||||
if (unlikely(oob))
|
if (unlikely(oob))
|
||||||
ops->oobretlen = ops->ooblen;
|
ops->oobretlen = ops->ooblen;
|
||||||
|
|
||||||
|
err_out:
|
||||||
|
chip->select_chip(mtd, -1);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2379,8 +2389,10 @@ static int nand_do_write_oob(struct mtd_info *mtd, loff_t to,
|
||||||
chip->cmdfunc(mtd, NAND_CMD_RESET, -1, -1);
|
chip->cmdfunc(mtd, NAND_CMD_RESET, -1, -1);
|
||||||
|
|
||||||
/* Check, if it is write protected */
|
/* Check, if it is write protected */
|
||||||
if (nand_check_wp(mtd))
|
if (nand_check_wp(mtd)) {
|
||||||
|
chip->select_chip(mtd, -1);
|
||||||
return -EROFS;
|
return -EROFS;
|
||||||
|
}
|
||||||
|
|
||||||
/* Invalidate the page cache, if we write to the cached page */
|
/* Invalidate the page cache, if we write to the cached page */
|
||||||
if (page == chip->pagebuf)
|
if (page == chip->pagebuf)
|
||||||
|
@ -2393,6 +2405,8 @@ static int nand_do_write_oob(struct mtd_info *mtd, loff_t to,
|
||||||
else
|
else
|
||||||
status = chip->ecc.write_oob(mtd, chip, page & chip->pagemask);
|
status = chip->ecc.write_oob(mtd, chip, page & chip->pagemask);
|
||||||
|
|
||||||
|
chip->select_chip(mtd, -1);
|
||||||
|
|
||||||
if (status)
|
if (status)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
|
@ -2625,6 +2639,7 @@ erase_exit:
|
||||||
ret = instr->state == MTD_ERASE_DONE ? 0 : -EIO;
|
ret = instr->state == MTD_ERASE_DONE ? 0 : -EIO;
|
||||||
|
|
||||||
/* Deselect and wake up anyone waiting on the device */
|
/* Deselect and wake up anyone waiting on the device */
|
||||||
|
chip->select_chip(mtd, -1);
|
||||||
nand_release_device(mtd);
|
nand_release_device(mtd);
|
||||||
|
|
||||||
/* Do call back function */
|
/* Do call back function */
|
||||||
|
|
Loading…
Reference in New Issue