Skip to content

Commit a71bb8b

Browse files
author
Vincent Dupont
committed
squash spiffs: update read/write functions with new mtd interface
1 parent 9f41abd commit a71bb8b

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

pkg/spiffs/fs/spiffs_fs.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#include "kernel_defines.h"
1616

17-
#define ENABLE_DEBUG (0)
17+
#define ENABLE_DEBUG (1)
1818
#include <debug.h>
1919

2020
static int spiffs_err_to_errno(s32_t err);
@@ -26,7 +26,12 @@ static int32_t _dev_read(struct spiffs_t *fs, u32_t addr, u32_t size, u8_t *dst)
2626

2727
//DEBUG("spiffs: read: from addr 0x%" PRIx32 " size 0x%" PRIx32 "\n", addr, size);
2828

29-
return mtd_read(dev, dst, addr, size);
29+
if (mtd_read(dev, dst, addr, size) > 0) {
30+
return 0;
31+
}
32+
else {
33+
return -EIO;
34+
}
3035
}
3136

3237
static int32_t _dev_write(struct spiffs_t *fs, u32_t addr, u32_t size, u8_t *src)
@@ -35,7 +40,12 @@ static int32_t _dev_write(struct spiffs_t *fs, u32_t addr, u32_t size, u8_t *src
3540

3641
DEBUG("spiffs: write: from addr 0x%" PRIx32 " size 0x%" PRIx32 "\n", addr, size);
3742

38-
return mtd_write(dev, src, addr, size);
43+
if (mtd_write(dev, src, addr, size) > 0) {
44+
return 0;
45+
}
46+
else {
47+
return -EIO;
48+
}
3949
}
4050

4151
static int32_t _dev_erase(struct spiffs_t *fs, u32_t addr, u32_t size)

0 commit comments

Comments
 (0)