On 21.02.19 10:15, Miquel Raynal wrote: > From: Boris Brezillon <bbrezillon@xxxxxxxxxx> > > The target size can now be returned by nanddev_get_targetsize(). Get > rid of the chip->chipsize field and use this helper instead. > > Signed-off-by: Boris Brezillon <bbrezillon@xxxxxxxxxx> > Signed-off-by: Miquel Raynal <miquel.raynal@xxxxxxxxxxx> > --- > .../mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c | 2 +- > drivers/mtd/nand/raw/denali.c | 1 - > drivers/mtd/nand/raw/fsl_elbc_nand.c | 2 +- > drivers/mtd/nand/raw/fsl_ifc_nand.c | 2 +- > drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 2 +- > drivers/mtd/nand/raw/jz4740_nand.c | 2 +- > drivers/mtd/nand/raw/nand_base.c | 21 +++++++++------- > drivers/mtd/nand/raw/nand_bbt.c | 25 ++++++++++++------- > drivers/mtd/nand/raw/nand_jedec.c | 2 -- > drivers/mtd/nand/raw/nand_onfi.c | 2 -- > drivers/mtd/nand/raw/nandsim.c | 5 ++-- > drivers/mtd/nand/raw/sh_flctl.c | 9 ++++--- > include/linux/mtd/rawnand.h | 2 -- > 13 files changed, 41 insertions(+), 36 deletions(-) > [...] > diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c > index 00fe124fcb44..674505a0021c 100644 > --- a/drivers/mtd/nand/raw/nand_base.c > +++ b/drivers/mtd/nand/raw/nand_base.c > @@ -4587,7 +4587,10 @@ static bool find_full_id_nand(struct nand_chip *chip, > mtd->oobsize = memorg->oobsize; > > memorg->bits_per_cell = nand_get_bits_per_cell(id_data[2]); > - chip->chipsize = (uint64_t)type->chipsize << 20; > + memorg->eraseblocks_per_lun = > + DIV_ROUND_DOWN_ULL((u64)type->chipsize << 20, > + memorg->pagesize * > + memorg->pages_per_eraseblock); Shouldn't the assignment of memorg->eraseblocks_per_lun here already be part of patch 7? > chip->options |= type->options; > chip->ecc_strength_ds = NAND_ECC_STRENGTH(type); > chip->ecc_step_ds = NAND_ECC_STEP(type); > @@ -4674,6 +4677,7 @@ static int nand_detect(struct nand_chip *chip, struct nand_flash_dev *type) > int busw, ret; > u8 *id_data = chip->id.data; > u8 maf_id, dev_id; > + u64 targetsize; > > /* > * Let's start by initializing memorg fields that might be left > @@ -4778,8 +4782,6 @@ static int nand_detect(struct nand_chip *chip, struct nand_flash_dev *type) > if (!chip->parameters.model) > return -ENOMEM; > > - chip->chipsize = (uint64_t)type->chipsize << 20; > - > if (!type->pagesize) > nand_manufacturer_detect(chip); > else > @@ -4821,14 +4823,15 @@ static int nand_detect(struct nand_chip *chip, struct nand_flash_dev *type) > /* Calculate the address shift from the page size */ > chip->page_shift = ffs(mtd->writesize) - 1; > /* Convert chipsize to number of pages per chip -1 */ > - chip->pagemask = (chip->chipsize >> chip->page_shift) - 1; > + targetsize = nanddev_target_size(&chip->base); > + chip->pagemask = (targetsize >> chip->page_shift) - 1; > > chip->bbt_erase_shift = chip->phys_erase_shift = > ffs(mtd->erasesize) - 1; > - if (chip->chipsize & 0xffffffff) > - chip->chip_shift = ffs((unsigned)chip->chipsize) - 1; > + if (targetsize & 0xffffffff) > + chip->chip_shift = ffs((unsigned)targetsize) - 1; > else { > - chip->chip_shift = ffs((unsigned)(chip->chipsize >> 32)); > + chip->chip_shift = ffs((unsigned)(targetsize >> 32)); > chip->chip_shift += 32 - 1; > } > > @@ -4844,7 +4847,7 @@ static int nand_detect(struct nand_chip *chip, struct nand_flash_dev *type) > pr_info("%s %s\n", nand_manufacturer_name(manufacturer), > chip->parameters.model); > pr_info("%d MiB, %s, erase size: %d KiB, page size: %d, OOB size: %d\n", > - (int)(chip->chipsize >> 20), nand_is_slc(chip) ? "SLC" : "MLC", > + (int)(targetsize >> 20), nand_is_slc(chip) ? "SLC" : "MLC", > mtd->erasesize >> 10, mtd->writesize, mtd->oobsize); > return 0; > > @@ -5089,7 +5092,7 @@ static int nand_scan_ident(struct nand_chip *chip, unsigned int maxchips, > /* Store the number of chips and calc total size for mtd */ > memorg->ntargets = i; > chip->numchips = i; > - mtd->size = i * chip->chipsize; > + mtd->size = i * nanddev_target_size(&chip->base); > > return 0; > } [...] ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/