]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - include/linux/mtd/mtd.h
[MTD] NAND Replace oobinfo by ecclayout
[mirror_ubuntu-zesty-kernel.git] / include / linux / mtd / mtd.h
index c50c3f3927d959ceda9e1ad2539e9df785219139..48a9df21ab113841a880527a9af8f42536f1a1be 100644 (file)
@@ -1,5 +1,5 @@
-/* 
- * $Id: mtd.h,v 1.59 2005/04/11 10:19:02 gleixner Exp $
+/*
+ * $Id: mtd.h,v 1.61 2005/11/07 11:14:54 gleixner Exp $
  *
  * Copyright (C) 1999-2003 David Woodhouse <dwmw2@infradead.org> et al.
  *
@@ -14,7 +14,6 @@
 #endif
 
 #include <linux/config.h>
-#include <linux/version.h>
 #include <linux/types.h>
 #include <linux/module.h>
 #include <linux/uio.h>
@@ -57,36 +56,59 @@ struct mtd_erase_region_info {
        u_int32_t numblocks;            /* Number of blocks of erasesize in this region */
 };
 
+/**
+ * struct mtd_ecc_stats - error correction status
+ *
+ * @corrected: number of corrected bits
+ * @failed:    number of uncorrectable errors
+ */
+struct mtd_ecc_stats {
+       unsigned long corrected;
+       unsigned long failed;
+};
+
 struct mtd_info {
        u_char type;
        u_int32_t flags;
        u_int32_t size;  // Total size of the MTD
 
-       /* "Major" erase size for the device. Naïve users may take this
+       /* "Major" erase size for the device. Naïve users may take this
         * to be the only erase size available, or may use the more detailed
         * information below if they desire
         */
        u_int32_t erasesize;
+       /* Smallest availlable size for writing to the device.  For NAND,
+        * this is the page size, for some NOR chips, the size of ECC
+        * covered blocks.
+        */
+       u_int32_t writesize;
 
-       u_int32_t oobblock;  // Size of OOB blocks (e.g. 512)
        u_int32_t oobsize;   // Amount of OOB data per block (e.g. 16)
        u_int32_t ecctype;
        u_int32_t eccsize;
-       
+
+       /*
+        * Reuse some of the above unused fields in the case of NOR flash
+        * with configurable programming regions to avoid modifying the
+        * user visible structure layout/size.  Only valid when the
+        * MTD_PROGRAM_REGIONS flag is set.
+        * (Maybe we should have an union for those?)
+        */
+#define MTD_PROGREGION_CTRLMODE_VALID(mtd)  (mtd)->oobsize
+#define MTD_PROGREGION_CTRLMODE_INVALID(mtd)  (mtd)->ecctype
 
        // Kernel-only stuff starts here.
        char *name;
        int index;
 
-       // oobinfo is a nand_oobinfo structure, which can be set by iotcl (MEMSETOOBINFO)
-       struct nand_oobinfo oobinfo;
-       u_int32_t oobavail;  // Number of bytes in OOB area available for fs 
+       /* ecc layout structure pointer - read only ! */
+       struct nand_ecclayout *ecclayout;
 
        /* Data for variable erase regions. If numeraseregions is zero,
-        * it means that the whole device has erasesize as given above. 
+        * it means that the whole device has erasesize as given above.
         */
        int numeraseregions;
-       struct mtd_erase_region_info *eraseregions; 
+       struct mtd_erase_region_info *eraseregions;
 
        /* This really shouldn't be here. It can go away in 2.5 */
        u_int32_t bank_size;
@@ -103,16 +125,13 @@ struct mtd_info {
        int (*read) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf);
        int (*write) (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf);
 
-       int (*read_ecc) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf, u_char *eccbuf, struct nand_oobinfo *oobsel);
-       int (*write_ecc) (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf, u_char *eccbuf, struct nand_oobinfo *oobsel);
-
        int (*read_oob) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf);
        int (*write_oob) (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf);
 
-       /* 
-        * Methods to access the protection register area, present in some 
+       /*
+        * Methods to access the protection register area, present in some
         * flash devices. The user data is one time programmable but the
-        * factory data is read only. 
+        * factory data is read only.
         */
        int (*get_fact_prot_info) (struct mtd_info *mtd, struct otp_info *buf, size_t len);
        int (*read_fact_prot_reg) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf);
@@ -121,17 +140,11 @@ struct mtd_info {
        int (*write_user_prot_reg) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf);
        int (*lock_user_prot_reg) (struct mtd_info *mtd, loff_t from, size_t len);
 
-       /* kvec-based read/write methods. We need these especially for NAND flash,
-          with its limited number of write cycles per erase.
-          NB: The 'count' parameter is the number of _vectors_, each of 
+       /* kvec-based read/write methods.
+          NB: The 'count' parameter is the number of _vectors_, each of
           which contains an (ofs, len) tuple.
        */
-       int (*readv) (struct mtd_info *mtd, struct kvec *vecs, unsigned long count, loff_t from, size_t *retlen);
-       int (*readv_ecc) (struct mtd_info *mtd, struct kvec *vecs, unsigned long count, loff_t from, 
-               size_t *retlen, u_char *eccbuf, struct nand_oobinfo *oobsel);
        int (*writev) (struct mtd_info *mtd, const struct kvec *vecs, unsigned long count, loff_t to, size_t *retlen);
-       int (*writev_ecc) (struct mtd_info *mtd, const struct kvec *vecs, unsigned long count, loff_t to, 
-               size_t *retlen, u_char *eccbuf, struct nand_oobinfo *oobsel);
 
        /* Sync */
        void (*sync) (struct mtd_info *mtd);
@@ -150,6 +163,9 @@ struct mtd_info {
 
        struct notifier_block reboot_notifier;  /* default mode before reboot */
 
+       /* ECC status information */
+       struct mtd_ecc_stats ecc_stats;
+
        void *priv;
 
        struct module *owner;
@@ -194,7 +210,7 @@ int default_mtd_readv(struct mtd_info *mtd, struct kvec *vecs,
 #define MTD_WRITEECC(mtd, args...) (*(mtd->write_ecc))(mtd, args)
 #define MTD_READOOB(mtd, args...) (*(mtd->read_oob))(mtd, args)
 #define MTD_WRITEOOB(mtd, args...) (*(mtd->write_oob))(mtd, args)
-#define MTD_SYNC(mtd) do { if (mtd->sync) (*(mtd->sync))(mtd);  } while (0) 
+#define MTD_SYNC(mtd) do { if (mtd->sync) (*(mtd->sync))(mtd);  } while (0)
 
 
 #ifdef CONFIG_MTD_PARTITIONS