mtd: rawnand: Get rid of chip->chipsize
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@kernel.org> Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
This commit is contained in:

committed by
Miquel Raynal

parent
298151689b
commit
6c836d515f
@@ -4542,7 +4542,6 @@ 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 *
|
||||
@@ -4633,6 +4632,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
|
||||
@@ -4737,8 +4737,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
|
||||
@@ -4780,14 +4778,15 @@ ident_done:
|
||||
/* 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;
|
||||
}
|
||||
|
||||
@@ -4803,7 +4802,7 @@ ident_done:
|
||||
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;
|
||||
|
||||
@@ -5054,7 +5053,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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user