summaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2019-01-21 09:24:24 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2019-01-21 09:24:24 +0100
commit25082eff77300372316fe85265730d1d3e653287 (patch)
treedbf5c375fdb169dea245b62c39469d62d7ca6f66 /drivers/mtd
parente059f9a0dd10241b58bd4a8c0e07bbc4390b3a86 (diff)
downloadbarebox-25082eff77300372316fe85265730d1d3e653287.tar.gz
barebox-25082eff77300372316fe85265730d1d3e653287.tar.xz
Revert "mtd: nand: Kill the chip->scan_bbt() hook"
This reverts commit 95ce69795506293eae28d6e64055d2c7ae27f164.
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/nand/nand_base.c6
-rw-r--r--drivers/mtd/nand/nand_bbt.c10
-rw-r--r--drivers/mtd/nand/nand_imx_bbm.c2
-rw-r--r--drivers/mtd/nand/nand_mxs.c27
4 files changed, 29 insertions, 16 deletions
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 8ae6f34468..bf15e6ccee 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -2956,6 +2956,10 @@ static void nand_set_defaults(struct nand_chip *chip, int busw)
#endif
if (!chip->read_buf)
chip->read_buf = busw ? nand_read_buf16 : nand_read_buf;
+#ifdef CONFIG_NAND_BBT
+ if (!chip->scan_bbt)
+ chip->scan_bbt = nand_default_bbt;
+#endif
if (!chip->controller) {
chip->controller = &chip->hwcontrol;
}
@@ -3846,7 +3850,7 @@ int nand_scan_tail(struct mtd_info *mtd)
return 0;
/* Build bad block table */
- return nand_create_bbt(mtd);
+ return chip->scan_bbt(mtd);
}
EXPORT_SYMBOL(nand_scan_tail);
diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c
index 90c10862c5..a908a36544 100644
--- a/drivers/mtd/nand/nand_bbt.c
+++ b/drivers/mtd/nand/nand_bbt.c
@@ -77,8 +77,6 @@
#define BBT_ENTRY_MASK 0x03
#define BBT_ENTRY_SHIFT 2
-static int nand_update_bbt(struct mtd_info *mtd, loff_t offs);
-
static inline uint8_t bbt_get_entry(struct nand_chip *chip, int block)
{
uint8_t entry = chip->bbt[block >> BBT_ENTRY_SHIFT];
@@ -1225,7 +1223,7 @@ err:
*
* The function updates the bad block table(s).
*/
-static int nand_update_bbt(struct mtd_info *mtd, loff_t offs)
+int nand_update_bbt(struct mtd_info *mtd, loff_t offs)
{
struct nand_chip *this = mtd->priv;
int len, res = 0;
@@ -1353,13 +1351,13 @@ static int nand_create_badblock_pattern(struct nand_chip *this)
}
/**
- * nand_create_bbt - [NAND Interface] Select a default bad block table for the device
+ * nand_default_bbt - [NAND Interface] Select a default bad block table for the device
* @mtd: MTD device structure
*
* This function selects the default bad block table support for the device and
* calls the nand_scan_bbt function.
*/
-int nand_create_bbt(struct mtd_info *mtd)
+int nand_default_bbt(struct mtd_info *mtd)
{
struct nand_chip *this = mtd->priv;
int ret;
@@ -1457,3 +1455,5 @@ int nand_markgood_bbt(struct mtd_info *mtd, loff_t offs)
}
EXPORT_SYMBOL(nand_scan_bbt);
+EXPORT_SYMBOL(nand_default_bbt);
+EXPORT_SYMBOL_GPL(nand_update_bbt);
diff --git a/drivers/mtd/nand/nand_imx_bbm.c b/drivers/mtd/nand/nand_imx_bbm.c
index 4fd5487aa2..23722a9064 100644
--- a/drivers/mtd/nand/nand_imx_bbm.c
+++ b/drivers/mtd/nand/nand_imx_bbm.c
@@ -129,7 +129,7 @@ static int attach_bbt(struct mtd_info *mtd, void *bbt)
free(chip->bbt);
chip->bbt = bbt;
- return nand_create_bbt(mtd);
+ return nand_update_bbt(mtd, 0);
}
static int do_imx_nand_bbm(int argc, char *argv[])
diff --git a/drivers/mtd/nand/nand_mxs.c b/drivers/mtd/nand/nand_mxs.c
index f69453aba5..28a07d4cba 100644
--- a/drivers/mtd/nand/nand_mxs.c
+++ b/drivers/mtd/nand/nand_mxs.c
@@ -1201,7 +1201,21 @@ static int mxs_nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)
return 0;
}
-static int mxs_nand_init_bch(struct mtd_info *mtd)
+/*
+ * Nominally, the purpose of this function is to look for or create the bad
+ * block table. In fact, since the we call this function at the very end of
+ * the initialization process started by nand_scan(), and we doesn't have a
+ * more formal mechanism, we "hook" this function to continue init process.
+ *
+ * At this point, the physical NAND Flash chips have been identified and
+ * counted, so we know the physical geometry. This enables us to make some
+ * important configuration decisions.
+ *
+ * The return value of this function propogates directly back to this driver's
+ * call to nand_scan(). Anything other than zero will cause this driver to
+ * tear everything down and declare failure.
+ */
+static int mxs_nand_scan_bbt(struct mtd_info *mtd)
{
struct nand_chip *nand = mtd->priv;
struct mxs_nand_info *nand_info = nand->priv;
@@ -1238,7 +1252,8 @@ static int mxs_nand_init_bch(struct mtd_info *mtd)
mtd->block_markbad = mxs_nand_hook_block_markbad;
}
- return 0;
+ /* We use the reference implementation for bad block management. */
+ return nand_default_bbt(mtd);
}
/*
@@ -2168,6 +2183,7 @@ static int mxs_nand_probe(struct device_d *dev)
nand->dev_ready = mxs_nand_device_ready;
nand->select_chip = mxs_nand_select_chip;
nand->block_bad = mxs_nand_block_bad;
+ nand->scan_bbt = mxs_nand_scan_bbt;
nand->read_byte = mxs_nand_read_byte;
@@ -2199,13 +2215,6 @@ static int mxs_nand_probe(struct device_d *dev)
mxs_nand_setup_timing(nand_info);
- err = mxs_nand_init_bch(mtd);
- if (err)
- goto err2;
- err = nand_create_bbt(mtd);
- if (err)
- goto err2;
-
/* second phase scan */
err = nand_scan_tail(mtd);
if (err)