sync
This commit is contained in:
@@ -17,7 +17,7 @@ LOG_MODULE_REGISTER(fs_mgmt, CONFIG_FS_MGMT_LOG_LEVEL);
|
||||
* Without PM, we fall back to the DTS node label.
|
||||
*/
|
||||
#if defined(PM_littlefs_storage_ID)
|
||||
#define FokITION_ID(littlefs_storage)
|
||||
#define FS_PARTITION_ID PM_littlefs_storage_ID
|
||||
#elif DT_NODE_EXISTS(DT_NODELABEL(ext_flash_lfs))
|
||||
#define FS_PARTITION_ID FIXED_PARTITION_ID(ext_flash_lfs)
|
||||
#else
|
||||
@@ -38,8 +38,10 @@ static struct fs_mount_t fs_storage_mnt = {
|
||||
.mnt_point = CONFIG_FS_MGMT_MOUNT_POINT,
|
||||
};
|
||||
|
||||
#if defined(CONFIG_PM_DEVICE) && !defined(CONFIG_FILE_SYSTEM_SHELL)
|
||||
static int open_count = 0;
|
||||
static struct k_mutex flash_pm_lock;
|
||||
#endif
|
||||
|
||||
// #define ACK_WATERMARK (CONFIG_BUZZ_PROTO_SLAB_COUNT / 4)
|
||||
#define INITIAL_CREDITS CONFIG_BUZZ_PROTO_SLAB_COUNT
|
||||
@@ -79,7 +81,9 @@ static struct
|
||||
*/
|
||||
static int fs_mgmt_pm_flash_suspend(void)
|
||||
{
|
||||
#if IS_ENABLED(CONFIG_PM_DEVICE)
|
||||
#if defined(CONFIG_FILE_SYSTEM_SHELL)
|
||||
return 0;
|
||||
#elif defined(CONFIG_PM_DEVICE)
|
||||
if (!device_is_ready(flash_dev))
|
||||
{
|
||||
return -ENODEV;
|
||||
@@ -105,7 +109,7 @@ static int fs_mgmt_pm_flash_suspend(void)
|
||||
}
|
||||
|
||||
k_mutex_unlock(&flash_pm_lock);
|
||||
#endif /* CONFIG_PM_DEVICE */
|
||||
#endif /* CONFIG_FILE_SYSTEM_SHELL / CONFIG_PM_DEVICE */
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -116,7 +120,9 @@ static int fs_mgmt_pm_flash_suspend(void)
|
||||
*/
|
||||
static int fs_mgmt_pm_flash_resume(void)
|
||||
{
|
||||
#if IS_ENABLED(CONFIG_PM_DEVICE)
|
||||
#if defined(CONFIG_FILE_SYSTEM_SHELL)
|
||||
return 0;
|
||||
#elif defined(CONFIG_PM_DEVICE)
|
||||
if (!device_is_ready(flash_dev))
|
||||
return -ENODEV;
|
||||
|
||||
@@ -134,7 +140,7 @@ static int fs_mgmt_pm_flash_resume(void)
|
||||
open_count++;
|
||||
|
||||
k_mutex_unlock(&flash_pm_lock);
|
||||
#endif /* CONFIG_PM_DEVICE */
|
||||
#endif /* CONFIG_FILE_SYSTEM_SHELL / CONFIG_PM_DEVICE */
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -182,6 +188,20 @@ int fs_mgmt_pm_unlink(const char *path)
|
||||
{
|
||||
LOG_DBG("PM Unlinking file '%s'", path);
|
||||
fs_mgmt_pm_flash_resume();
|
||||
|
||||
struct fs_dirent entry;
|
||||
int stat_rc = fs_stat(path, &entry);
|
||||
if (stat_rc == -ENOENT)
|
||||
{
|
||||
fs_mgmt_pm_flash_suspend();
|
||||
return 0;
|
||||
}
|
||||
if (stat_rc < 0)
|
||||
{
|
||||
fs_mgmt_pm_flash_suspend();
|
||||
return stat_rc;
|
||||
}
|
||||
|
||||
int rc = fs_unlink(path);
|
||||
fs_mgmt_pm_flash_suspend();
|
||||
return rc;
|
||||
@@ -400,7 +420,9 @@ int fs_mgmt_pm_mkdir_recursive(char *path)
|
||||
|
||||
static int fs_mgmt_init(void)
|
||||
{
|
||||
#if defined(CONFIG_PM_DEVICE) && !defined(CONFIG_FILE_SYSTEM_SHELL)
|
||||
k_mutex_init(&flash_pm_lock);
|
||||
#endif
|
||||
|
||||
if (!device_is_ready(flash_dev))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user