]> 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 b6f2fdae65c6c284b9f511d35301af420a049303..48a9df21ab113841a880527a9af8f42536f1a1be 100644 (file)
@@ -56,18 +56,33 @@ 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;
@@ -79,7 +94,6 @@ struct mtd_info {
         * MTD_PROGRAM_REGIONS flag is set.
         * (Maybe we should have an union for those?)
         */
-#define MTD_PROGREGION_SIZE(mtd)  (mtd)->oobblock
 #define MTD_PROGREGION_CTRLMODE_VALID(mtd)  (mtd)->oobsize
 #define MTD_PROGREGION_CTRLMODE_INVALID(mtd)  (mtd)->ecctype
 
@@ -87,9 +101,8 @@ struct mtd_info {
        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.
@@ -112,9 +125,6 @@ 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);
 
@@ -130,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.
+       /* 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);
@@ -159,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;