fs: littlefs: sample: Move littlefs_flash_erase() to flash mount
The littlefs_flash_erase() function shall be called from flash specific littlefs_mount function. This allows removal of the stub function when block device support is added. Signed-off-by: Lukasz Majewski <lukma@denx.de>
This commit is contained in:
parent
447ebe34d9
commit
7710f5ef61
1 changed files with 5 additions and 13 deletions
|
@ -259,14 +259,6 @@ static int littlefs_flash_erase(unsigned int id)
|
|||
flash_area_close(pfa);
|
||||
return rc;
|
||||
}
|
||||
#else
|
||||
static int littlefs_flash_erase(unsigned int id)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_APP_LITTLEFS_STORAGE_FLASH */
|
||||
|
||||
#ifdef CONFIG_APP_LITTLEFS_STORAGE_FLASH
|
||||
#define PARTITION_NODE DT_NODELABEL(lfs1)
|
||||
|
||||
#if DT_NODE_EXISTS(PARTITION_NODE)
|
||||
|
@ -293,6 +285,11 @@ static int littlefs_mount(struct fs_mount_t *mp)
|
|||
{
|
||||
int rc;
|
||||
|
||||
rc = littlefs_flash_erase((uintptr_t)mp->storage_dev);
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Do not mount if auto-mount has been enabled */
|
||||
#if !DT_NODE_EXISTS(PARTITION_NODE) || \
|
||||
!(FSTAB_ENTRY_DT_MOUNT_FLAGS(PARTITION_NODE) & FS_MOUNT_FLAG_AUTOMOUNT)
|
||||
|
@ -323,11 +320,6 @@ void main(void)
|
|||
snprintf(fname1, sizeof(fname1), "%s/boot_count", mp->mnt_point);
|
||||
snprintf(fname2, sizeof(fname2), "%s/pattern.bin", mp->mnt_point);
|
||||
|
||||
rc = littlefs_flash_erase((uintptr_t)mp->storage_dev);
|
||||
if (rc < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
rc = littlefs_mount(mp);
|
||||
if (rc < 0) {
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue