Commit 07300164 authored by Huang Shijie's avatar Huang Shijie Committed by Artem Bityutskiy

mtd: de-select the chip when it is not used

When we scan several nand chips with nand_scan(), such as
     .......................
      nand_scan(*, 2);
     .......................

In nand_scan_ident(), the maxchips will become 2, so the current code
will select chip 1 to read the device ID. But the chip 0 is still
selected in this case.

To make the logic clear, we'd better de-select the chip when it is not used.

This patch de-select the nand chip if it is not used any more.
Signed-off-by: default avatarHuang Shijie <b32955@freescale.com>
Signed-off-by: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
parent ded4c55d
...@@ -3329,6 +3329,8 @@ int nand_scan_ident(struct mtd_info *mtd, int maxchips, ...@@ -3329,6 +3329,8 @@ int nand_scan_ident(struct mtd_info *mtd, int maxchips,
return PTR_ERR(type); return PTR_ERR(type);
} }
chip->select_chip(mtd, -1);
/* Check for a chip array */ /* Check for a chip array */
for (i = 1; i < maxchips; i++) { for (i = 1; i < maxchips; i++) {
chip->select_chip(mtd, i); chip->select_chip(mtd, i);
...@@ -3338,8 +3340,11 @@ int nand_scan_ident(struct mtd_info *mtd, int maxchips, ...@@ -3338,8 +3340,11 @@ int nand_scan_ident(struct mtd_info *mtd, int maxchips,
chip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1); chip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1);
/* Read manufacturer and device IDs */ /* Read manufacturer and device IDs */
if (nand_maf_id != chip->read_byte(mtd) || if (nand_maf_id != chip->read_byte(mtd) ||
nand_dev_id != chip->read_byte(mtd)) nand_dev_id != chip->read_byte(mtd)) {
chip->select_chip(mtd, -1);
break; break;
}
chip->select_chip(mtd, -1);
} }
if (i > 1) if (i > 1)
pr_info("%d NAND chips detected\n", i); pr_info("%d NAND chips detected\n", i);
...@@ -3598,9 +3603,6 @@ int nand_scan_tail(struct mtd_info *mtd) ...@@ -3598,9 +3603,6 @@ int nand_scan_tail(struct mtd_info *mtd)
/* Initialize state */ /* Initialize state */
chip->state = FL_READY; chip->state = FL_READY;
/* De-select the device */
chip->select_chip(mtd, -1);
/* Invalidate the pagebuffer reference */ /* Invalidate the pagebuffer reference */
chip->pagebuf = -1; chip->pagebuf = -1;
......
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