mtd: add ECC info for nand_flash_dev{}

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Fri Aug 30 16:59:03 EDT 2013


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=2dc0bdd91bb63f7d5755137177315c49637f6a96
Commit:     2dc0bdd91bb63f7d5755137177315c49637f6a96
Parent:     e2985fc1d684927ce1dd5e5e6d35db8b52302685
Author:     Huang Shijie <b32955 at freescale.com>
AuthorDate: Fri May 17 11:17:31 2013 +0800
Committer:  David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Fri Aug 30 21:34:45 2013 +0100

    mtd: add ECC info for nand_flash_dev{}
    
    Add an instance of an anonymous struct to store the ECC info for full id
    nand chips.
    	@ecc.strength_ds: ECC correctability from the datasheet.
    	@ecc.step_ds: ECC size required by the @ecc.strength_ds,
    
    These two fields are all from the datasheet.
    
    Also add the necessary macros to make the code simple and clean.
    
    Signed-off-by: Huang Shijie <b32955 at freescale.com>
    Signed-off-by: Brian Norris <computersforpeace at gmail.com>
    Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
 include/linux/mtd/nand.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index bf4c566..ac8e89d 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -628,6 +628,11 @@ struct nand_chip {
 	{ .name = (nm), {{ .dev_id = (devid) }}, .chipsize = (chipsz), \
 	  .options = (opts) }
 
+#define NAND_ECC_INFO(_strength, _step)	\
+			{ .strength_ds = (_strength), .step_ds = (_step) }
+#define NAND_ECC_STRENGTH(type)		((type)->ecc.strength_ds)
+#define NAND_ECC_STEP(type)		((type)->ecc.step_ds)
+
 /**
  * struct nand_flash_dev - NAND Flash Device ID Structure
  * @name: a human-readable name of the NAND chip
@@ -645,6 +650,12 @@ struct nand_chip {
  * @options: stores various chip bit options
  * @id_len: The valid length of the @id.
  * @oobsize: OOB size
+ * @ecc.strength_ds: The ECC correctability from the datasheet, same as the
+ *                   @ecc_strength_ds in nand_chip{}.
+ * @ecc.step_ds: The ECC step required by the @ecc.strength_ds, same as the
+ *               @ecc_step_ds in nand_chip{}, also from the datasheet.
+ *               For example, the "4bit ECC for each 512Byte" can be set with
+ *               NAND_ECC_INFO(4, 512).
  */
 struct nand_flash_dev {
 	char *name;
@@ -661,6 +672,10 @@ struct nand_flash_dev {
 	unsigned int options;
 	uint16_t id_len;
 	uint16_t oobsize;
+	struct {
+		uint16_t strength_ds;
+		uint16_t step_ds;
+	} ecc;
 };
 
 /**



More information about the linux-mtd-cvs mailing list