Merge git://git.denx.de/u-boot-fsl-qoriq
[oweals/u-boot.git] / include / linux / mtd / mtd.h
index e3d3fc73fd62cbf2900086ec18114e59c1dc0d28..3e1694b3a5d33802fcecd32ad0b38556571a8e0d 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright © 1999-2010 David Woodhouse <dwmw2@infradead.org> et al.
  *
- * Released under GPL
+ * SPDX-License-Identifier:    GPL-2.0+
  *
  */
 
@@ -20,7 +20,7 @@
 #else
 #include <linux/compat.h>
 #include <mtd/mtd-abi.h>
-#include <asm/errno.h>
+#include <linux/errno.h>
 #include <div64.h>
 
 #define MAX_MTD_DEVICES 32
@@ -272,10 +272,17 @@ struct mtd_info {
        struct module *owner;
 #ifndef __UBOOT__
        struct device dev;
+#else
+       struct udevice *dev;
 #endif
        int usecount;
 };
 
+static inline int mtd_oobavail(struct mtd_info *mtd, struct mtd_oob_ops *ops)
+{
+       return ops->mode == MTD_OPS_AUTO_OOB ? mtd->oobavail : mtd->oobsize;
+}
+
 int mtd_erase(struct mtd_info *mtd, struct erase_info *instr);
 #ifndef __UBOOT__
 int mtd_point(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
@@ -445,28 +452,20 @@ static inline void mtd_erase_callback(struct erase_info *instr)
 #define MTD_DEBUG_LEVEL3       (3)     /* Noisy   */
 
 #ifdef CONFIG_MTD_DEBUG
-#define pr_debug(args...)      MTDDEBUG(MTD_DEBUG_LEVEL0, args)
 #define MTDDEBUG(n, args...)                           \
        do {                                            \
                if (n <= CONFIG_MTD_DEBUG_VERBOSE)      \
                        printk(KERN_INFO args);         \
        } while(0)
 #else /* CONFIG_MTD_DEBUG */
-#define pr_debug(args...)
 #define MTDDEBUG(n, args...)                           \
        do {                                            \
                if (0)                                  \
                        printk(KERN_INFO args);         \
        } while(0)
 #endif /* CONFIG_MTD_DEBUG */
-#define pr_info(args...)       MTDDEBUG(MTD_DEBUG_LEVEL0, args)
-#define pr_warn(args...)       MTDDEBUG(MTD_DEBUG_LEVEL0, args)
-#define pr_err(args...)                MTDDEBUG(MTD_DEBUG_LEVEL0, args)
-#define pr_crit(args...)       MTDDEBUG(MTD_DEBUG_LEVEL0, args)
-#define pr_cont(args...)       MTDDEBUG(MTD_DEBUG_LEVEL0, args)
-#define pr_notice(args...)     MTDDEBUG(MTD_DEBUG_LEVEL0, args)
 #endif
+
 static inline int mtd_is_bitflip(int err) {
        return err == -EUCLEAN;
 }
@@ -493,5 +492,10 @@ int mtd_arg_off(const char *arg, int *idx, loff_t *off, loff_t *size,
 int mtd_arg_off_size(int argc, char *const argv[], int *idx, loff_t *off,
                     loff_t *size, loff_t *maxsize, int devtype,
                     uint64_t chipsize);
+
+/* drivers/mtd/mtdcore.c */
+void mtd_get_len_incl_bad(struct mtd_info *mtd, uint64_t offset,
+                         const uint64_t length, uint64_t *len_incl_bad,
+                         int *truncated);
 #endif
 #endif /* __MTD_MTD_H__ */