aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand/nand_base.c
diff options
context:
space:
mode:
authorDavid Woodhouse <David.Woodhouse@intel.com>2010-02-26 13:32:56 -0500
committerDavid Woodhouse <David.Woodhouse@intel.com>2010-02-26 13:32:56 -0500
commit5e81e88a4c140586d9212999cea683bcd66a15c6 (patch)
tree1d67825bb2cbcb3830fe4584bac04f6d9413d41a /drivers/mtd/nand/nand_base.c
parent9fc51a37a8da84618df7584cad67c078317f6720 (diff)
mtd: nand: Allow caller to pass alternative ID table to nand_scan_ident()
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd/nand/nand_base.c')
-rw-r--r--drivers/mtd/nand/nand_base.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index ba29a29bd743..1c4823696be2 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -2766,10 +2766,10 @@ static void nand_set_defaults(struct nand_chip *chip, int busw)
2766 */ 2766 */
2767static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, 2767static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
2768 struct nand_chip *chip, 2768 struct nand_chip *chip,
2769 int busw, int *maf_id) 2769 int busw, int *maf_id,
2770 struct nand_flash_dev *type)
2770{ 2771{
2771 struct nand_flash_dev *type = NULL; 2772 int dev_id, maf_idx;
2772 int i, dev_id, maf_idx;
2773 int tmp_id, tmp_manf; 2773 int tmp_id, tmp_manf;
2774 2774
2775 /* Select the device */ 2775 /* Select the device */
@@ -2808,15 +2808,14 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
2808 return ERR_PTR(-ENODEV); 2808 return ERR_PTR(-ENODEV);
2809 } 2809 }
2810 2810
2811 /* Lookup the flash id */
2812 for (i = 0; nand_flash_ids[i].name != NULL; i++) {
2813 if (dev_id == nand_flash_ids[i].id) {
2814 type = &nand_flash_ids[i];
2815 break;
2816 }
2817 }
2818
2819 if (!type) 2811 if (!type)
2812 type = nand_flash_ids;
2813
2814 for (; type->name != NULL; type++)
2815 if (dev_id == type->id)
2816 break;
2817
2818 if (!type->name)
2820 return ERR_PTR(-ENODEV); 2819 return ERR_PTR(-ENODEV);
2821 2820
2822 if (!mtd->name) 2821 if (!mtd->name)
@@ -2926,13 +2925,15 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
2926 * nand_scan_ident - [NAND Interface] Scan for the NAND device 2925 * nand_scan_ident - [NAND Interface] Scan for the NAND device
2927 * @mtd: MTD device structure 2926 * @mtd: MTD device structure
2928 * @maxchips: Number of chips to scan for 2927 * @maxchips: Number of chips to scan for
2928 * @table: Alternative NAND ID table
2929 * 2929 *
2930 * This is the first phase of the normal nand_scan() function. It 2930 * This is the first phase of the normal nand_scan() function. It
2931 * reads the flash ID and sets up MTD fields accordingly. 2931 * reads the flash ID and sets up MTD fields accordingly.
2932 * 2932 *
2933 * The mtd->owner field must be set to the module of the caller. 2933 * The mtd->owner field must be set to the module of the caller.
2934 */ 2934 */
2935int nand_scan_ident(struct mtd_info *mtd, int maxchips) 2935int nand_scan_ident(struct mtd_info *mtd, int maxchips,
2936 struct nand_flash_dev *table)
2936{ 2937{
2937 int i, busw, nand_maf_id; 2938 int i, busw, nand_maf_id;
2938 struct nand_chip *chip = mtd->priv; 2939 struct nand_chip *chip = mtd->priv;
@@ -2944,7 +2945,7 @@ int nand_scan_ident(struct mtd_info *mtd, int maxchips)
2944 nand_set_defaults(chip, busw); 2945 nand_set_defaults(chip, busw);
2945 2946
2946 /* Read the flash type */ 2947 /* Read the flash type */
2947 type = nand_get_flash_type(mtd, chip, busw, &nand_maf_id); 2948 type = nand_get_flash_type(mtd, chip, busw, &nand_maf_id, table);
2948 2949
2949 if (IS_ERR(type)) { 2950 if (IS_ERR(type)) {
2950 if (!(chip->options & NAND_SCAN_SILENT_NODEV)) 2951 if (!(chip->options & NAND_SCAN_SILENT_NODEV))
@@ -3235,7 +3236,7 @@ int nand_scan(struct mtd_info *mtd, int maxchips)
3235 BUG(); 3236 BUG();
3236 } 3237 }
3237 3238
3238 ret = nand_scan_ident(mtd, maxchips); 3239 ret = nand_scan_ident(mtd, maxchips, NULL);
3239 if (!ret) 3240 if (!ret)
3240 ret = nand_scan_tail(mtd); 3241 ret = nand_scan_tail(mtd);
3241 return ret; 3242 return ret;