]> git.sur5r.net Git - u-boot/blobdiff - drivers/mtd/mtdcore.c
Merge branch 'master' of git://git.denx.de/u-boot-atmel
[u-boot] / drivers / mtd / mtdcore.c
index 796ac0729e3a3f84545736f09f849ae18f7d0984..cb27ff22be0c6113d3c7fa3b8171a198aa949f74 100644 (file)
@@ -9,7 +9,6 @@
  *
  */
 
-#define __UBOOT__
 #ifndef __UBOOT__
 #include <linux/module.h>
 #include <linux/kernel.h>
@@ -476,6 +475,8 @@ int add_mtd_device(struct mtd_info *mtd)
           the notifier, since we hold the mtd_table_mutex */
        list_for_each_entry(not, &mtd_notifiers, list)
                not->add(mtd);
+#else
+       pr_debug("mtd: Giving out device %d to %s\n", i, mtd->name);
 #endif
 
        mutex_unlock(&mtd_table_mutex);
@@ -802,7 +803,7 @@ void mtd_get_len_incl_bad(struct mtd_info *mtd, uint64_t offset,
        *truncated = 0;
        *len_incl_bad = 0;
 
-       if (!mtd->block_isbad) {
+       if (!mtd->_block_isbad) {
                *len_incl_bad = length;
                return;
        }
@@ -818,7 +819,7 @@ void mtd_get_len_incl_bad(struct mtd_info *mtd, uint64_t offset,
 
                block_len = mtd->erasesize - (offset & (mtd->erasesize - 1));
 
-               if (!mtd->block_isbad(mtd, offset & ~(mtd->erasesize - 1)))
+               if (!mtd->_block_isbad(mtd, offset & ~(mtd->erasesize - 1)))
                        len_excl_bad += block_len;
 
                *len_incl_bad += block_len;
@@ -1009,14 +1010,14 @@ EXPORT_SYMBOL_GPL(mtd_read_oob);
  * devices. The user data is one time programmable but the factory data is read
  * only.
  */
-int mtd_get_fact_prot_info(struct mtd_info *mtd, struct otp_info *buf,
-                          size_t len)
+int mtd_get_fact_prot_info(struct mtd_info *mtd, size_t len, size_t *retlen,
+                          struct otp_info *buf)
 {
        if (!mtd->_get_fact_prot_info)
                return -EOPNOTSUPP;
        if (!len)
                return 0;
-       return mtd->_get_fact_prot_info(mtd, buf, len);
+       return mtd->_get_fact_prot_info(mtd, len, retlen, buf);
 }
 EXPORT_SYMBOL_GPL(mtd_get_fact_prot_info);
 
@@ -1032,14 +1033,14 @@ int mtd_read_fact_prot_reg(struct mtd_info *mtd, loff_t from, size_t len,
 }
 EXPORT_SYMBOL_GPL(mtd_read_fact_prot_reg);
 
-int mtd_get_user_prot_info(struct mtd_info *mtd, struct otp_info *buf,
-                          size_t len)
+int mtd_get_user_prot_info(struct mtd_info *mtd, size_t len, size_t *retlen,
+                          struct otp_info *buf)
 {
        if (!mtd->_get_user_prot_info)
                return -EOPNOTSUPP;
        if (!len)
                return 0;
-       return mtd->_get_user_prot_info(mtd, buf, len);
+       return mtd->_get_user_prot_info(mtd, len, retlen, buf);
 }
 EXPORT_SYMBOL_GPL(mtd_get_user_prot_info);
 
@@ -1058,12 +1059,22 @@ EXPORT_SYMBOL_GPL(mtd_read_user_prot_reg);
 int mtd_write_user_prot_reg(struct mtd_info *mtd, loff_t to, size_t len,
                            size_t *retlen, u_char *buf)
 {
+       int ret;
+
        *retlen = 0;
        if (!mtd->_write_user_prot_reg)
                return -EOPNOTSUPP;
        if (!len)
                return 0;
-       return mtd->_write_user_prot_reg(mtd, to, len, retlen, buf);
+       ret = mtd->_write_user_prot_reg(mtd, to, len, retlen, buf);
+       if (ret)
+               return ret;
+
+       /*
+        * If no data could be written at all, we are out of memory and
+        * must return -ENOSPC.
+        */
+       return (*retlen) ? 0 : -ENOSPC;
 }
 EXPORT_SYMBOL_GPL(mtd_write_user_prot_reg);