From a71bb8b2e2e90d80efda5eb7a71d132f7d4161e3 Mon Sep 17 00:00:00 2001 From: Vincent Dupont Date: Wed, 27 Jul 2016 09:45:34 +0200 Subject: [PATCH] squash spiffs: update read/write functions with new mtd interface --- pkg/spiffs/fs/spiffs_fs.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/pkg/spiffs/fs/spiffs_fs.c b/pkg/spiffs/fs/spiffs_fs.c index 33f37fb49f68..17244bd2a6c8 100644 --- a/pkg/spiffs/fs/spiffs_fs.c +++ b/pkg/spiffs/fs/spiffs_fs.c @@ -14,7 +14,7 @@ #include "kernel_defines.h" -#define ENABLE_DEBUG (0) +#define ENABLE_DEBUG (1) #include 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) //DEBUG("spiffs: read: from addr 0x%" PRIx32 " size 0x%" PRIx32 "\n", addr, size); - return mtd_read(dev, dst, addr, size); + if (mtd_read(dev, dst, addr, size) > 0) { + return 0; + } + else { + return -EIO; + } } 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 DEBUG("spiffs: write: from addr 0x%" PRIx32 " size 0x%" PRIx32 "\n", addr, size); - return mtd_write(dev, src, addr, size); + if (mtd_write(dev, src, addr, size) > 0) { + return 0; + } + else { + return -EIO; + } } static int32_t _dev_erase(struct spiffs_t *fs, u32_t addr, u32_t size)