From 6352d6e1dac9df364e4d930adc3ccf9198f59e46 Mon Sep 17 00:00:00 2001 From: lzl Date: Tue, 8 Jun 2021 09:07:04 +0000 Subject: [PATCH] kernel adapter Signed-off-by: lzl --- fs/vfs/disk/disk.c | 12 +++++------- kernel/common/los_rootfs.c | 13 ++++++++----- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/fs/vfs/disk/disk.c b/fs/vfs/disk/disk.c index c131ffc3..d03ce62d 100644 --- a/fs/vfs/disk/disk.c +++ b/fs/vfs/disk/disk.c @@ -35,14 +35,8 @@ #include "unistd.h" #include "sys/mount.h" #include "linux/spinlock.h" - #include "fs/path_cache.h" -#ifdef LOSCFG_DRIVERS_MMC -#include "mmc/block.h" -#endif - - los_disk g_sysDisk[SYS_MAX_DISK]; los_part g_sysPart[SYS_MAX_PART]; @@ -1685,13 +1679,17 @@ VOID show_part(los_part *part) PRINTK("part sec count : %llu\n", part->sector_count); } +#ifdef LOSCFG_DRIVERS_MMC +ssize_t StorageBlockMmcErase(uint32_t blockId, size_t secStart, size_t secNr); +#endif + INT32 EraseDiskByID(UINT32 diskID, size_t startSector, UINT32 sectors) { INT32 ret = VFS_ERROR; #ifdef LOSCFG_DRIVERS_MMC los_disk *disk = get_disk((INT32)diskID); if (disk != NULL) { - ret = do_mmc_erase(diskID, startSector, sectors); + ret = StorageBlockMmcErase(diskID, startSector, sectors); } #endif diff --git a/kernel/common/los_rootfs.c b/kernel/common/los_rootfs.c index 9db34881..dd4ef1b9 100644 --- a/kernel/common/los_rootfs.c +++ b/kernel/common/los_rootfs.c @@ -35,7 +35,6 @@ #include "mtd_partition.h" #endif #ifdef LOSCFG_DRIVERS_MMC -#include "mmc/block.h" #include "disk.h" #endif #include "sys/mount.h" @@ -103,18 +102,22 @@ los_disk *GetMmcDisk(UINT8 type) #endif #ifdef LOSCFG_STORAGE_EMMC +struct disk_divide_info *StorageBlockGetEmmc(void); +struct block_operations *StorageBlockGetMmcOps(void); +char *StorageBlockGetEmmcNodeName(void *block); + STATIC const CHAR *AddEmmcRootfsPart(INT32 rootAddr, INT32 rootSize) { INT32 ret; - struct mmc_block *block = (struct mmc_block *)((struct drv_data *)g_emmcDisk->dev->data)->priv; - const char *node_name = mmc_block_get_node_name(block); + void *block = ((struct drv_data *)g_emmcDisk->dev->data)->priv; + const char *node_name = StorageBlockGetEmmcNodeName(block); if (los_disk_deinit(g_emmcDisk->disk_id) != ENOERR) { PRINT_ERR("Failed to deinit emmc disk!\n"); return NULL; } - struct disk_divide_info *emmc = get_emmc(); + struct disk_divide_info *emmc = StorageBlockGetEmmc(); ret = add_mmc_partition(emmc, rootAddr / EMMC_SEC_SIZE, rootSize / EMMC_SEC_SIZE); if (ret != LOS_OK) { PRINT_ERR("Failed to add mmc root partition!\n"); @@ -138,7 +141,7 @@ STATIC const CHAR *AddEmmcRootfsPart(INT32 rootAddr, INT32 rootSize) PRINT_ERR("Failed to alloc disk %s!\n", node_name); return NULL; } - if (los_disk_init(node_name, mmc_block_get_bops(block), (void *)block, diskId, emmc) != ENOERR) { + if (los_disk_init(node_name, StorageBlockGetMmcOps(), block, diskId, emmc) != ENOERR) { PRINT_ERR("Failed to init emmc disk!\n"); return NULL; } -- GitLab