summaryrefslogtreecommitdiff
path: root/extmod/vfs_fat.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2019-09-08 22:01:09 +1000
committerDamien George <damien.p.george@gmail.com>2019-10-29 12:55:17 +1100
commite1c7b1cb431f17bc00a76e7d411f5106b1a967cc (patch)
tree2cde0da249c0863ae586e2f007f55aa84486951d /extmod/vfs_fat.c
parent9aabb6c01ba4166bb389e28b55f21614fca5aa7f (diff)
extmod/vfs_blockdev: Factor out block device interface code.
Diffstat (limited to 'extmod/vfs_fat.c')
-rw-r--r--extmod/vfs_fat.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/extmod/vfs_fat.c b/extmod/vfs_fat.c
index dcfb677b1..129b6cc66 100644
--- a/extmod/vfs_fat.c
+++ b/extmod/vfs_fat.c
@@ -68,21 +68,12 @@ STATIC mp_obj_t fat_vfs_make_new(const mp_obj_type_t *type, size_t n_args, size_
// create new object
fs_user_mount_t *vfs = m_new_obj(fs_user_mount_t);
vfs->base.type = type;
- vfs->blockdev.flags = MP_BLOCKDEV_FLAG_FREE_OBJ;
vfs->fatfs.drv = vfs;
- // load block protocol methods
- mp_load_method(args[0], MP_QSTR_readblocks, vfs->blockdev.readblocks);
- mp_load_method_maybe(args[0], MP_QSTR_writeblocks, vfs->blockdev.writeblocks);
- mp_load_method_maybe(args[0], MP_QSTR_ioctl, vfs->blockdev.u.ioctl);
- if (vfs->blockdev.u.ioctl[0] != MP_OBJ_NULL) {
- // device supports new block protocol, so indicate it
- vfs->blockdev.flags |= MP_BLOCKDEV_FLAG_HAVE_IOCTL;
- } else {
- // no ioctl method, so assume the device uses the old block protocol
- mp_load_method_maybe(args[0], MP_QSTR_sync, vfs->blockdev.u.old.sync);
- mp_load_method(args[0], MP_QSTR_count, vfs->blockdev.u.old.count);
- }
+ // Initialise underlying block device
+ vfs->blockdev.flags = MP_BLOCKDEV_FLAG_FREE_OBJ;
+ vfs->blockdev.block_size = FF_MIN_SS; // default, will be populated by call to BP_IOCTL_SEC_SIZE
+ mp_vfs_blockdev_init(&vfs->blockdev, args[0]);
// mount the block device so the VFS methods can be used
FRESULT res = f_mount(&vfs->fatfs);