mt29f nand: export formatting function and, if DEBUG active, function
[bertos.git] / bertos / cpu / cortex-m3 / drv / mt29f_sam3.c
index 73faca1d1d418f13ef4c1db86317d99341f2231f..a8a3dcb5d1db5c6bac9df7eaecde3d5b991007b3 100644 (file)
@@ -624,14 +624,13 @@ static void initBlockMap(Mt29f *chip)
 }
 
 
-#ifdef _DEBUG
-
-/*
+/**
  * Reset bad blocks map and erase all blocks.
- * DON'T USE on production chips: this function will try to erase
- * factory marked bad blocks too.
+ *
+ * \note DON'T USE on production chips: this function will try to erase
+ *       factory marked bad blocks too.
  */
-static void mt29f_wipe(Mt29f *chip)
+void mt29f_format(Mt29f *chip)
 {
        int b;
 
@@ -644,10 +643,12 @@ static void mt29f_wipe(Mt29f *chip)
        chip->remap_start = MT29F_NUM_USER_BLOCKS;
 }
 
+#ifdef _DEBUG
+
 /*
  * Create some bad blocks, erasing them and writing the bad block mark.
  */
-static void mt29f_ruinSomeBlocks(Mt29f *chip)
+void mt29f_ruinSomeBlocks(Mt29f *chip)
 {
        int bads[] = { 7, 99, 555, 1003, 1004, 1432 };
        unsigned i;
@@ -877,8 +878,11 @@ bool mt29f_init(Mt29f *chip, struct Heap *heap, unsigned chip_select)
 
 bool mt29f_initUnbuffered(Mt29f *chip, struct Heap *heap, unsigned chip_select)
 {
+       if (!commonInit(chip, heap, chip_select))
+               return false;
+
        chip->fd.priv.vt = &mt29f_unbuffered_vt;
-       return commonInit(chip, heap, chip_select);
+       return true;
 }