Skip to content

Commit e372e83

Browse files
committed
extmod/fsusermount: Move BP_IOCTL_xxx constants to fsusermount.h.
1 parent b33a770 commit e372e83

4 files changed

Lines changed: 17 additions & 17 deletions

File tree

extmod/fsusermount.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@
2929
#define FSUSER_FREE_OBJ (0x0002) // fs_user_mount_t obj should be freed on umount
3030
#define FSUSER_HAVE_IOCTL (0x0004) // new protocol with ioctl
3131

32+
// constants for block protocol ioctl
33+
#define BP_IOCTL_INIT (1)
34+
#define BP_IOCTL_DEINIT (2)
35+
#define BP_IOCTL_SYNC (3)
36+
#define BP_IOCTL_SEC_COUNT (4)
37+
#define BP_IOCTL_SEC_SIZE (5)
38+
3239
typedef struct _fs_user_mount_t {
3340
const char *str;
3441
uint16_t len; // length of str

stmhal/diskio.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,6 @@
3737
#include "lib/fatfs/diskio.h" /* FatFs lower layer API */
3838
#include "extmod/fsusermount.h"
3939

40-
// constants for block protocol ioctl
41-
#define BP_IOCTL_INIT (1)
42-
//#define BP_IOCTL_DEINIT (2) // unused
43-
#define BP_IOCTL_SYNC (3)
44-
#define BP_IOCTL_SEC_COUNT (4)
45-
#define BP_IOCTL_SEC_SIZE (5)
46-
4740
STATIC fs_user_mount_t *disk_get_device(uint id) {
4841
if (id < MP_ARRAY_SIZE(MP_STATE_PORT(fs_user_mount))) {
4942
return MP_STATE_PORT(fs_user_mount)[id];

stmhal/sdcard.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -377,24 +377,24 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(pyb_sdcard_writeblocks_obj, pyb_sdcard_writeblo
377377
STATIC mp_obj_t pyb_sdcard_ioctl(mp_obj_t self, mp_obj_t cmd_in, mp_obj_t arg_in) {
378378
mp_int_t cmd = mp_obj_get_int(cmd_in);
379379
switch (cmd) {
380-
case 1: // INIT
380+
case BP_IOCTL_INIT:
381381
if (!sdcard_power_on()) {
382382
return MP_OBJ_NEW_SMALL_INT(-1); // error
383383
}
384384
return MP_OBJ_NEW_SMALL_INT(0); // success
385385

386-
case 2: // DEINIT
386+
case BP_IOCTL_DEINIT:
387387
sdcard_power_off();
388388
return MP_OBJ_NEW_SMALL_INT(0); // success
389389

390-
case 3: // SYNC
390+
case BP_IOCTL_SYNC:
391391
// nothing to do
392392
return MP_OBJ_NEW_SMALL_INT(0); // success
393393

394-
case 4: // SEC_COUNT
394+
case BP_IOCTL_SEC_COUNT:
395395
return MP_OBJ_NEW_SMALL_INT(0); // TODO
396396

397-
case 5: // SEC_SIZE
397+
case BP_IOCTL_SEC_SIZE:
398398
return MP_OBJ_NEW_SMALL_INT(SDCARD_BLOCK_SIZE);
399399

400400
default: // unknown command

stmhal/storage.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -363,11 +363,11 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(pyb_flash_writeblocks_obj, pyb_flash_writeblock
363363
STATIC mp_obj_t pyb_flash_ioctl(mp_obj_t self, mp_obj_t cmd_in, mp_obj_t arg_in) {
364364
mp_int_t cmd = mp_obj_get_int(cmd_in);
365365
switch (cmd) {
366-
case 1: storage_init(); return MP_OBJ_NEW_SMALL_INT(0); // INIT
367-
case 2: storage_flush(); return MP_OBJ_NEW_SMALL_INT(0); // DEINIT; TODO properly
368-
case 3: storage_flush(); return MP_OBJ_NEW_SMALL_INT(0); // SYNC
369-
case 4: return MP_OBJ_NEW_SMALL_INT(storage_get_block_count()); // SEC_COUNT
370-
case 5: return MP_OBJ_NEW_SMALL_INT(storage_get_block_size()); // SEC_SIZE
366+
case BP_IOCTL_INIT: storage_init(); return MP_OBJ_NEW_SMALL_INT(0);
367+
case BP_IOCTL_DEINIT: storage_flush(); return MP_OBJ_NEW_SMALL_INT(0); // TODO properly
368+
case BP_IOCTL_SYNC: storage_flush(); return MP_OBJ_NEW_SMALL_INT(0);
369+
case BP_IOCTL_SEC_COUNT: return MP_OBJ_NEW_SMALL_INT(storage_get_block_count());
370+
case BP_IOCTL_SEC_SIZE: return MP_OBJ_NEW_SMALL_INT(storage_get_block_size());
371371
default: return mp_const_none;
372372
}
373373
}

0 commit comments

Comments
 (0)