Commit b2b5921f authored by Sascha Hauer's avatar Sascha Hauer Committed by Miquel Raynal

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: 32813e28 ("mtd: rawnand: Get rid of chip->numchips")
Signed-off-by: default avatarSascha Hauer <s.hauer@pengutronix.de>
Reviewed-by: default avatarBoris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
parent a188339c
...@@ -4666,7 +4666,6 @@ static int nand_detect(struct nand_chip *chip, struct nand_flash_dev *type) ...@@ -4666,7 +4666,6 @@ static int nand_detect(struct nand_chip *chip, struct nand_flash_dev *type)
memorg = nanddev_get_memorg(&chip->base); memorg = nanddev_get_memorg(&chip->base);
memorg->planes_per_lun = 1; memorg->planes_per_lun = 1;
memorg->luns_per_target = 1; memorg->luns_per_target = 1;
memorg->ntargets = 1;
/* /*
* Reset the chip, required by some chips (e.g. Micron MT29FxGxxxxx) * 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, ...@@ -5031,6 +5030,8 @@ static int nand_scan_ident(struct nand_chip *chip, unsigned int maxchips,
if (ret) if (ret)
return ret; return ret;
memorg->ntargets = maxchips;
/* Read the flash type */ /* Read the flash type */
ret = nand_detect(chip, table); ret = nand_detect(chip, table);
if (ret) { if (ret) {
......
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