Commit 32813e28 authored by Boris Brezillon's avatar Boris Brezillon Committed by Miquel Raynal

mtd: rawnand: Get rid of chip->numchips

The same information is provided by nanddev_ntargets().
Signed-off-by: default avatarBoris Brezillon <bbrezillon@kernel.org>
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: default avatarFrieder Schrempf <frieder.schrempf@kontron.de>
parent 6c836d51
...@@ -1291,7 +1291,7 @@ static int __init inftl_scan_bbt(struct mtd_info *mtd) ...@@ -1291,7 +1291,7 @@ static int __init inftl_scan_bbt(struct mtd_info *mtd)
struct doc_priv *doc = nand_get_controller_data(this); struct doc_priv *doc = nand_get_controller_data(this);
struct mtd_partition parts[5]; struct mtd_partition parts[5];
if (this->numchips > doc->chips_per_floor) { if (nanddev_ntargets(&this->base) > doc->chips_per_floor) {
pr_err("Multi-floor INFTL devices not yet supported.\n"); pr_err("Multi-floor INFTL devices not yet supported.\n");
return -EIO; return -EIO;
} }
......
...@@ -653,7 +653,7 @@ static int fsl_elbc_attach_chip(struct nand_chip *chip) ...@@ -653,7 +653,7 @@ static int fsl_elbc_attach_chip(struct nand_chip *chip)
priv->fmr |= al << FMR_AL_SHIFT; priv->fmr |= al << FMR_AL_SHIFT;
dev_dbg(priv->dev, "fsl_elbc_init: nand->numchips = %d\n", dev_dbg(priv->dev, "fsl_elbc_init: nand->numchips = %d\n",
chip->numchips); nanddev_ntargets(&chip->base));
dev_dbg(priv->dev, "fsl_elbc_init: nand->chipsize = %lld\n", dev_dbg(priv->dev, "fsl_elbc_init: nand->chipsize = %lld\n",
nanddev_target_size(&chip->base)); nanddev_target_size(&chip->base));
dev_dbg(priv->dev, "fsl_elbc_init: nand->pagemask = %8x\n", dev_dbg(priv->dev, "fsl_elbc_init: nand->pagemask = %8x\n",
......
...@@ -722,7 +722,7 @@ static int fsl_ifc_attach_chip(struct nand_chip *chip) ...@@ -722,7 +722,7 @@ static int fsl_ifc_attach_chip(struct nand_chip *chip)
struct fsl_ifc_mtd *priv = nand_get_controller_data(chip); struct fsl_ifc_mtd *priv = nand_get_controller_data(chip);
dev_dbg(priv->dev, "%s: nand->numchips = %d\n", __func__, dev_dbg(priv->dev, "%s: nand->numchips = %d\n", __func__,
chip->numchips); nanddev_ntargets(&chip->base));
dev_dbg(priv->dev, "%s: nand->chipsize = %lld\n", __func__, dev_dbg(priv->dev, "%s: nand->chipsize = %lld\n", __func__,
nanddev_target_size(&chip->base)); nanddev_target_size(&chip->base));
dev_dbg(priv->dev, "%s: nand->pagemask = %8x\n", __func__, dev_dbg(priv->dev, "%s: nand->pagemask = %8x\n", __func__,
......
...@@ -849,7 +849,7 @@ static int hisi_nfc_resume(struct device *dev) ...@@ -849,7 +849,7 @@ static int hisi_nfc_resume(struct device *dev)
struct hinfc_host *host = dev_get_drvdata(dev); struct hinfc_host *host = dev_get_drvdata(dev);
struct nand_chip *chip = &host->chip; struct nand_chip *chip = &host->chip;
for (cs = 0; cs < chip->numchips; cs++) for (cs = 0; cs < nanddev_ntargets(&chip->base); cs++)
hisi_nfc_send_cmd_reset(host, cs); hisi_nfc_send_cmd_reset(host, cs);
hinfc_write(host, SET_HINFC504_PWIDTH(HINFC504_W_LATCH, hinfc_write(host, SET_HINFC504_PWIDTH(HINFC504_W_LATCH,
HINFC504_R_LATCH, HINFC504_RW_LATCH), HINFC504_PWIDTH); HINFC504_R_LATCH, HINFC504_RW_LATCH), HINFC504_PWIDTH);
......
...@@ -354,7 +354,6 @@ static int jz_nand_detect_bank(struct platform_device *pdev, ...@@ -354,7 +354,6 @@ static int jz_nand_detect_bank(struct platform_device *pdev,
} }
/* Update size of the MTD. */ /* Update size of the MTD. */
chip->numchips++;
memorg->ntargets++; memorg->ntargets++;
mtd->size += nanddev_target_size(&chip->base); mtd->size += nanddev_target_size(&chip->base);
} }
......
...@@ -110,7 +110,7 @@ static inline int nand_exec_op(struct nand_chip *chip, ...@@ -110,7 +110,7 @@ static inline int nand_exec_op(struct nand_chip *chip,
if (!nand_has_exec_op(chip)) if (!nand_has_exec_op(chip))
return -ENOTSUPP; return -ENOTSUPP;
if (WARN_ON(op->cs >= chip->numchips)) if (WARN_ON(op->cs >= nanddev_ntargets(&chip->base)))
return -EINVAL; return -EINVAL;
return chip->controller->ops->exec_op(chip, op, false); return chip->controller->ops->exec_op(chip, op, false);
......
...@@ -240,10 +240,10 @@ static int check_offs_len(struct nand_chip *chip, loff_t ofs, uint64_t len) ...@@ -240,10 +240,10 @@ static int check_offs_len(struct nand_chip *chip, loff_t ofs, uint64_t len)
void nand_select_target(struct nand_chip *chip, unsigned int cs) void nand_select_target(struct nand_chip *chip, unsigned int cs)
{ {
/* /*
* cs should always lie between 0 and chip->numchips, when that's not * cs should always lie between 0 and nanddev_ntargets(), when that's
* the case it's a bug and the caller should be fixed. * not the case it's a bug and the caller should be fixed.
*/ */
if (WARN_ON(cs > chip->numchips)) if (WARN_ON(cs > nanddev_ntargets(&chip->base)))
return; return;
chip->cur_cs = cs; chip->cur_cs = cs;
...@@ -4999,12 +4999,6 @@ static int nand_scan_ident(struct nand_chip *chip, unsigned int maxchips, ...@@ -4999,12 +4999,6 @@ static int nand_scan_ident(struct nand_chip *chip, unsigned int maxchips,
if (!mtd->name && mtd->dev.parent) if (!mtd->name && mtd->dev.parent)
mtd->name = dev_name(mtd->dev.parent); mtd->name = dev_name(mtd->dev.parent);
/*
* Start with chips->numchips = maxchips to let nand_select_target() do
* its job. chip->numchips will be adjusted after.
*/
chip->numchips = maxchips;
/* Set the default functions */ /* Set the default functions */
nand_set_defaults(chip); nand_set_defaults(chip);
...@@ -5052,7 +5046,6 @@ static int nand_scan_ident(struct nand_chip *chip, unsigned int maxchips, ...@@ -5052,7 +5046,6 @@ static int nand_scan_ident(struct nand_chip *chip, unsigned int maxchips,
/* Store the number of chips and calc total size for mtd */ /* Store the number of chips and calc total size for mtd */
memorg->ntargets = i; memorg->ntargets = i;
chip->numchips = i;
mtd->size = i * nanddev_target_size(&chip->base); mtd->size = i * nanddev_target_size(&chip->base);
return 0; return 0;
...@@ -5794,7 +5787,7 @@ static int nand_scan_tail(struct nand_chip *chip) ...@@ -5794,7 +5787,7 @@ static int nand_scan_tail(struct nand_chip *chip)
goto err_nanddev_cleanup; goto err_nanddev_cleanup;
/* Enter fastest possible mode on all dies. */ /* Enter fastest possible mode on all dies. */
for (i = 0; i < chip->numchips; i++) { for (i = 0; i < nanddev_ntargets(&chip->base); i++) {
ret = nand_setup_data_interface(chip, i); ret = nand_setup_data_interface(chip, i);
if (ret) if (ret)
goto err_nanddev_cleanup; goto err_nanddev_cleanup;
......
...@@ -269,7 +269,7 @@ static int read_abs_bbt(struct nand_chip *this, uint8_t *buf, ...@@ -269,7 +269,7 @@ static int read_abs_bbt(struct nand_chip *this, uint8_t *buf,
if (td->options & NAND_BBT_PERCHIP) { if (td->options & NAND_BBT_PERCHIP) {
int offs = 0; int offs = 0;
for (i = 0; i < this->numchips; i++) { for (i = 0; i < nanddev_ntargets(&this->base); i++) {
if (chip == -1 || chip == i) if (chip == -1 || chip == i)
res = read_bbt(this, buf, td->pages[i], res = read_bbt(this, buf, td->pages[i],
targetsize >> this->bbt_erase_shift, targetsize >> this->bbt_erase_shift,
...@@ -478,9 +478,9 @@ static int create_bbt(struct nand_chip *this, uint8_t *buf, ...@@ -478,9 +478,9 @@ static int create_bbt(struct nand_chip *this, uint8_t *buf,
startblock = 0; startblock = 0;
from = 0; from = 0;
} else { } else {
if (chip >= this->numchips) { if (chip >= nanddev_ntargets(&this->base)) {
pr_warn("create_bbt(): chipnr (%d) > available chips (%d)\n", pr_warn("create_bbt(): chipnr (%d) > available chips (%d)\n",
chip + 1, this->numchips); chip + 1, nanddev_ntargets(&this->base));
return -EINVAL; return -EINVAL;
} }
numblocks = targetsize >> this->bbt_erase_shift; numblocks = targetsize >> this->bbt_erase_shift;
...@@ -550,7 +550,7 @@ static int search_bbt(struct nand_chip *this, uint8_t *buf, ...@@ -550,7 +550,7 @@ static int search_bbt(struct nand_chip *this, uint8_t *buf,
/* Do we have a bbt per chip? */ /* Do we have a bbt per chip? */
if (td->options & NAND_BBT_PERCHIP) { if (td->options & NAND_BBT_PERCHIP) {
chips = this->numchips; chips = nanddev_ntargets(&this->base);
bbtblocks = targetsize >> this->bbt_erase_shift; bbtblocks = targetsize >> this->bbt_erase_shift;
startblock &= bbtblocks - 1; startblock &= bbtblocks - 1;
} else { } else {
...@@ -643,7 +643,7 @@ static int get_bbt_block(struct nand_chip *this, struct nand_bbt_descr *td, ...@@ -643,7 +643,7 @@ static int get_bbt_block(struct nand_chip *this, struct nand_bbt_descr *td,
numblocks = (int)(targetsize >> this->bbt_erase_shift); numblocks = (int)(targetsize >> this->bbt_erase_shift);
if (!(td->options & NAND_BBT_PERCHIP)) if (!(td->options & NAND_BBT_PERCHIP))
numblocks *= this->numchips; numblocks *= nanddev_ntargets(&this->base);
/* /*
* Automatic placement of the bad block table. Search direction * Automatic placement of the bad block table. Search direction
...@@ -745,7 +745,7 @@ static int write_bbt(struct nand_chip *this, uint8_t *buf, ...@@ -745,7 +745,7 @@ static int write_bbt(struct nand_chip *this, uint8_t *buf,
numblocks = (int)(targetsize >> this->bbt_erase_shift); numblocks = (int)(targetsize >> this->bbt_erase_shift);
/* Full device write or specific chip? */ /* Full device write or specific chip? */
if (chipsel == -1) { if (chipsel == -1) {
nrchips = this->numchips; nrchips = nanddev_ntargets(&this->base);
} else { } else {
nrchips = chipsel + 1; nrchips = chipsel + 1;
chip = chipsel; chip = chipsel;
...@@ -932,7 +932,7 @@ static int check_create(struct nand_chip *this, uint8_t *buf, ...@@ -932,7 +932,7 @@ static int check_create(struct nand_chip *this, uint8_t *buf,
/* Do we have a bbt per chip? */ /* Do we have a bbt per chip? */
if (td->options & NAND_BBT_PERCHIP) if (td->options & NAND_BBT_PERCHIP)
chips = this->numchips; chips = nanddev_ntargets(&this->base);
else else
chips = 1; chips = 1;
...@@ -1111,7 +1111,7 @@ static void mark_bbt_region(struct nand_chip *this, struct nand_bbt_descr *td) ...@@ -1111,7 +1111,7 @@ static void mark_bbt_region(struct nand_chip *this, struct nand_bbt_descr *td)
/* Do we have a bbt per chip? */ /* Do we have a bbt per chip? */
if (td->options & NAND_BBT_PERCHIP) { if (td->options & NAND_BBT_PERCHIP) {
chips = this->numchips; chips = nanddev_ntargets(&this->base);
nrblocks = (int)(targetsize >> this->bbt_erase_shift); nrblocks = (int)(targetsize >> this->bbt_erase_shift);
} else { } else {
chips = 1; chips = 1;
......
...@@ -1002,7 +1002,6 @@ struct nand_legacy { ...@@ -1002,7 +1002,6 @@ struct nand_legacy {
* set to the actually used ONFI mode if the chip is * set to the actually used ONFI mode if the chip is
* ONFI compliant or deduced from the datasheet if * ONFI compliant or deduced from the datasheet if
* the NAND chip is not ONFI compliant. * the NAND chip is not ONFI compliant.
* @numchips: [INTERN] number of physical chips
* @pagemask: [INTERN] page number mask = number of (pages / chip) - 1 * @pagemask: [INTERN] page number mask = number of (pages / chip) - 1
* @data_buf: [INTERN] buffer for data, size is (page size + oobsize). * @data_buf: [INTERN] buffer for data, size is (page size + oobsize).
* @pagecache: Structure containing page cache related fields * @pagecache: Structure containing page cache related fields
...@@ -1016,8 +1015,9 @@ struct nand_legacy { ...@@ -1016,8 +1015,9 @@ struct nand_legacy {
* @data_interface: [INTERN] NAND interface timing information * @data_interface: [INTERN] NAND interface timing information
* @cur_cs: currently selected target. -1 means no target selected, * @cur_cs: currently selected target. -1 means no target selected,
* otherwise we should always have cur_cs >= 0 && * otherwise we should always have cur_cs >= 0 &&
* cur_cs < numchips. NAND Controller drivers should not * cur_cs < nanddev_ntargets(). NAND Controller drivers
* modify this value, but they're allowed to read it. * should not modify this value, but they're allowed to
* read it.
* @read_retries: [INTERN] the number of read retry modes supported * @read_retries: [INTERN] the number of read retry modes supported
* @lock: lock protecting the suspended field. Also used to * @lock: lock protecting the suspended field. Also used to
* serialize accesses to the NAND device. * serialize accesses to the NAND device.
...@@ -1051,7 +1051,6 @@ struct nand_chip { ...@@ -1051,7 +1051,6 @@ struct nand_chip {
int phys_erase_shift; int phys_erase_shift;
int bbt_erase_shift; int bbt_erase_shift;
int chip_shift; int chip_shift;
int numchips;
int pagemask; int pagemask;
u8 *data_buf; u8 *data_buf;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment