summaryrefslogtreecommitdiffstatshomepage
path: root/extmod
diff options
context:
space:
mode:
Diffstat (limited to 'extmod')
-rw-r--r--extmod/vfs_fat.c4
-rw-r--r--extmod/vfs_fat_diskio.c32
-rw-r--r--extmod/vfs_fat_file.c13
-rw-r--r--extmod/vfs_fat_misc.c29
4 files changed, 2 insertions, 76 deletions
diff --git a/extmod/vfs_fat.c b/extmod/vfs_fat.c
index a6f2ae806a..ecbbdb59ab 100644
--- a/extmod/vfs_fat.c
+++ b/extmod/vfs_fat.c
@@ -32,10 +32,6 @@
#error "with MICROPY_VFS_FAT enabled, must also enable MICROPY_VFS"
#endif
-#if !MICROPY_FATFS_OO
-#error "with MICROPY_VFS_FAT enabled, must also enable MICROPY_FATFS_OO"
-#endif
-
#include <string.h>
#include "py/nlr.h"
#include "py/runtime.h"
diff --git a/extmod/vfs_fat_diskio.c b/extmod/vfs_fat_diskio.c
index c8a6e15335..e12c4597e4 100644
--- a/extmod/vfs_fat_diskio.c
+++ b/extmod/vfs_fat_diskio.c
@@ -36,13 +36,8 @@
#include "py/mphal.h"
#include "py/runtime.h"
-#if MICROPY_FATFS_OO
#include "lib/oofatfs/ff.h"
#include "lib/oofatfs/diskio.h"
-#else
-#include "lib/fatfs/ff.h" /* FatFs lower layer API */
-#include "lib/fatfs/diskio.h" /* FatFs lower layer API */
-#endif
#include "extmod/fsusermount.h"
#if _MAX_SS == _MIN_SS
@@ -51,29 +46,16 @@
#define SECSIZE(fs) ((fs)->ssize)
#endif
-#if MICROPY_FATFS_OO
typedef void *bdev_t;
STATIC fs_user_mount_t *disk_get_device(void *bdev) {
return (fs_user_mount_t*)bdev;
}
-#else
-typedef BYTE bdev_t;
-STATIC fs_user_mount_t *disk_get_device(uint id) {
- if (id < MP_ARRAY_SIZE(MP_STATE_PORT(fs_user_mount))) {
- return MP_STATE_PORT(fs_user_mount)[id];
- } else {
- return NULL;
- }
-}
-#endif
/*-----------------------------------------------------------------------*/
/* Initialize a Drive */
/*-----------------------------------------------------------------------*/
-#if MICROPY_FATFS_OO
STATIC
-#endif
DSTATUS disk_initialize (
bdev_t pdrv /* Physical drive nmuber (0..) */
)
@@ -105,9 +87,7 @@ DSTATUS disk_initialize (
/* Get Disk Status */
/*-----------------------------------------------------------------------*/
-#if MICROPY_FATFS_OO
STATIC
-#endif
DSTATUS disk_status (
bdev_t pdrv /* Physical drive nmuber (0..) */
)
@@ -159,7 +139,6 @@ DRESULT disk_read (
/* Write Sector(s) */
/*-----------------------------------------------------------------------*/
-#if MICROPY_FATFS_OO || _USE_WRITE
DRESULT disk_write (
bdev_t pdrv, /* Physical drive nmuber (0..) */
const BYTE *buff, /* Data to be written */
@@ -191,14 +170,12 @@ DRESULT disk_write (
return RES_OK;
}
-#endif
/*-----------------------------------------------------------------------*/
/* Miscellaneous Functions */
/*-----------------------------------------------------------------------*/
-#if MICROPY_FATFS_OO || _USE_IOCTL
DRESULT disk_ioctl (
bdev_t pdrv, /* Physical drive nmuber (0..) */
BYTE cmd, /* Control code */
@@ -237,7 +214,7 @@ DRESULT disk_ioctl (
} else {
*((WORD*)buff) = mp_obj_get_int(ret);
}
- #if MICROPY_FATFS_OO && _MAX_SS != _MIN_SS
+ #if _MAX_SS != _MIN_SS
// need to store ssize because we use it in disk_read/disk_write
vfs->fatfs.ssize = *((WORD*)buff);
#endif
@@ -248,7 +225,6 @@ DRESULT disk_ioctl (
*((DWORD*)buff) = 1; // erase block size in units of sector size
return RES_OK;
- #if MICROPY_FATFS_OO
case IOCTL_INIT:
*((DSTATUS*)buff) = disk_initialize(pdrv);
return RES_OK;
@@ -256,7 +232,6 @@ DRESULT disk_ioctl (
case IOCTL_STATUS:
*((DSTATUS*)buff) = disk_status(pdrv);
return RES_OK;
- #endif
default:
return RES_PARERR;
@@ -278,7 +253,7 @@ DRESULT disk_ioctl (
case GET_SECTOR_SIZE:
*((WORD*)buff) = 512; // old protocol had fixed sector size
- #if MICROPY_FATFS_OO && _MAX_SS != _MIN_SS
+ #if _MAX_SS != _MIN_SS
// need to store ssize because we use it in disk_read/disk_write
vfs->fatfs.ssize = 512;
#endif
@@ -288,7 +263,6 @@ DRESULT disk_ioctl (
*((DWORD*)buff) = 1; // erase block size in units of sector size
return RES_OK;
- #if MICROPY_FATFS_OO
case IOCTL_INIT:
*((DSTATUS*)buff) = disk_initialize(pdrv);
return RES_OK;
@@ -296,13 +270,11 @@ DRESULT disk_ioctl (
case IOCTL_STATUS:
*((DSTATUS*)buff) = disk_status(pdrv);
return RES_OK;
- #endif
default:
return RES_PARERR;
}
}
}
-#endif
#endif // MICROPY_VFS
diff --git a/extmod/vfs_fat_file.c b/extmod/vfs_fat_file.c
index dccd12035f..bb5903575d 100644
--- a/extmod/vfs_fat_file.c
+++ b/extmod/vfs_fat_file.c
@@ -34,11 +34,7 @@
#include "py/runtime.h"
#include "py/stream.h"
#include "py/mperrno.h"
-#if MICROPY_FATFS_OO
#include "lib/oofatfs/ff.h"
-#else
-#include "lib/fatfs/ff.h"
-#endif
#include "extmod/fsusermount.h"
#include "extmod/vfs_fat.h"
@@ -115,11 +111,7 @@ STATIC mp_uint_t file_obj_write(mp_obj_t self_in, const void *buf, mp_uint_t siz
STATIC mp_obj_t file_obj_close(mp_obj_t self_in) {
pyb_file_obj_t *self = MP_OBJ_TO_PTR(self_in);
// if fs==NULL then the file is closed and in that case this method is a no-op
- #if MICROPY_FATFS_OO
if (self->fp.obj.fs != NULL) {
- #else
- if (self->fp.fs != NULL) {
- #endif
FRESULT res = f_close(&self->fp);
if (res != FR_OK) {
mp_raise_OSError(fresult_to_errno_table[res]);
@@ -221,13 +213,8 @@ STATIC mp_obj_t file_open(fs_user_mount_t *vfs, const mp_obj_type_t *type, mp_ar
o->base.type = type;
const char *fname = mp_obj_str_get_str(args[0].u_obj);
- #if MICROPY_FATFS_OO
assert(vfs != NULL);
FRESULT res = f_open(&vfs->fatfs, &o->fp, fname, mode);
- #else
- (void)vfs;
- FRESULT res = f_open(&o->fp, fname, mode);
- #endif
if (res != FR_OK) {
m_del_obj(pyb_file_obj_t, o);
mp_raise_OSError(fresult_to_errno_table[res]);
diff --git a/extmod/vfs_fat_misc.c b/extmod/vfs_fat_misc.c
index 82ef91a1fb..ba513ef923 100644
--- a/extmod/vfs_fat_misc.c
+++ b/extmod/vfs_fat_misc.c
@@ -30,19 +30,11 @@
#include <string.h>
#include "py/nlr.h"
#include "py/runtime.h"
-#if MICROPY_FATFS_OO
#include "lib/oofatfs/ff.h"
-#else
-#include "lib/fatfs/ff.h"
-#endif
#include "extmod/vfs_fat.h"
#include "extmod/fsusermount.h"
#include "py/lexer.h"
-#if !MICROPY_FATFS_OO && _USE_LFN
-STATIC char lfn[_MAX_LFN + 1]; /* Buffer to store the LFN */
-#endif
-
// TODO: actually, the core function should be ilistdir()
mp_obj_t fat_vfs_listdir(const char *path, bool is_str_type) {
@@ -53,16 +45,8 @@ mp_obj_t fat_vfs_listdir2(fs_user_mount_t *vfs, const char *path, bool is_str_ty
FRESULT res;
FILINFO fno;
FF_DIR dir;
-#if !MICROPY_FATFS_OO && _USE_LFN
- fno.lfname = lfn;
- fno.lfsize = sizeof lfn;
-#endif
- #if MICROPY_FATFS_OO
res = f_opendir(&vfs->fatfs, &dir, path);
- #else
- res = f_opendir(&dir, path); /* Open the directory */
- #endif
if (res != FR_OK) {
mp_raise_OSError(fresult_to_errno_table[res]);
}
@@ -75,11 +59,7 @@ mp_obj_t fat_vfs_listdir2(fs_user_mount_t *vfs, const char *path, bool is_str_ty
if (fno.fname[0] == '.' && fno.fname[1] == 0) continue; /* Ignore . entry */
if (fno.fname[0] == '.' && fno.fname[1] == '.' && fno.fname[2] == 0) continue; /* Ignore .. entry */
-#if !MICROPY_FATFS_OO && _USE_LFN
- char *fn = *fno.lfname ? fno.lfname : fno.fname;
-#else
char *fn = fno.fname;
-#endif
/*
if (fno.fattrib & AM_DIR) {
@@ -108,17 +88,8 @@ mp_obj_t fat_vfs_listdir2(fs_user_mount_t *vfs, const char *path, bool is_str_ty
mp_import_stat_t fat_vfs_import_stat(fs_user_mount_t *vfs, const char *path) {
FILINFO fno;
-#if !MICROPY_FATFS_OO && _USE_LFN
- fno.lfname = NULL;
- fno.lfsize = 0;
-#endif
- #if MICROPY_FATFS_OO
assert(vfs != NULL);
FRESULT res = f_stat(&vfs->fatfs, path, &fno);
- #else
- (void)vfs;
- FRESULT res = f_stat(path, &fno);
- #endif
if (res == FR_OK) {
if ((fno.fattrib & AM_DIR) != 0) {
return MP_IMPORT_STAT_DIR;