Skip to content

Commit b2b5921

Browse files
saschahauermiquelraynal
authored andcommitted
mtd: rawnand: initialize ntargets with maxchips
memorg->ntargets is initialized with '1'. It should be initialized with the maxchips argument from nand_scan() instead. Otherwise multi chip support errors out on the secondary chip selects when trying to call nand_reset() on them: WARNING: CPU: 0 PID: 1 at drivers/mtd/nand/raw/internals.h:114 nand_reset_op+0x194/0x1c4 With this memorg->ntargets is initialized with the maximum number of chip selects supported by the driver. After having detected the number of actually connected chips memory->ntargets is updated with that number. Fixes: 32813e2 ("mtd: rawnand: Get rid of chip->numchips") Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
1 parent a188339 commit b2b5921

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/mtd/nand/raw/nand_base.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4666,7 +4666,6 @@ static int nand_detect(struct nand_chip *chip, struct nand_flash_dev *type)
46664666
memorg = nanddev_get_memorg(&chip->base);
46674667
memorg->planes_per_lun = 1;
46684668
memorg->luns_per_target = 1;
4669-
memorg->ntargets = 1;
46704669

46714670
/*
46724671
* Reset the chip, required by some chips (e.g. Micron MT29FxGxxxxx)
@@ -5031,6 +5030,8 @@ static int nand_scan_ident(struct nand_chip *chip, unsigned int maxchips,
50315030
if (ret)
50325031
return ret;
50335032

5033+
memorg->ntargets = maxchips;
5034+
50345035
/* Read the flash type */
50355036
ret = nand_detect(chip, table);
50365037
if (ret) {

0 commit comments

Comments
 (0)