From 043cea12e5798c15fa34eb0ebdef2d7d79013876 Mon Sep 17 00:00:00 2001 From: Dominik Ermel Date: Thu, 24 Nov 2022 13:15:10 +0000 Subject: [PATCH] fs/fatfs: Add CONFIG_FS_FATFS_MIN_SS The Kconfig option allows to set minimum expected sector size to be supported by FAT fs driver. When this value differs from CONFIG_FS_FATFS_MAX_SS the driver will query device for actual sector size, expecting different sector sizes for different device. When CONFIG_FS_FATFS_MIN_SS and CONFIG_FS_FATFS_MAX_SS are the same, then there is slight reduction if FAT driver size, as the query logic is removed and CONFIG_FS_FATFS_MAX_SS is used for all devices. Signed-off-by: Dominik Ermel --- modules/fatfs/zephyr_fatfs_config.h | 5 +++++ subsys/fs/Kconfig.fatfs | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/modules/fatfs/zephyr_fatfs_config.h b/modules/fatfs/zephyr_fatfs_config.h index fb633d24851..78f82a17cab 100644 --- a/modules/fatfs/zephyr_fatfs_config.h +++ b/modules/fatfs/zephyr_fatfs_config.h @@ -51,6 +51,11 @@ #define FF_MAX_LFN CONFIG_FS_FATFS_MAX_LFN #endif /* defined(CONFIG_FS_FATFS_MAX_LFN) */ +#if defined(CONFIG_FS_FATFS_MIN_SS) +#undef FF_MIN_SS +#define FF_MIN_SS CONFIG_FS_FATFS_MIN_SS +#endif /* defined(CONFIG_FS_FATFS_MIN_SS) */ + #if defined(CONFIG_FS_FATFS_MAX_SS) #undef FF_MAX_SS #define FF_MAX_SS CONFIG_FS_FATFS_MAX_SS diff --git a/subsys/fs/Kconfig.fatfs b/subsys/fs/Kconfig.fatfs index 849882f47c7..de9cfbe1001 100644 --- a/subsys/fs/Kconfig.fatfs +++ b/subsys/fs/Kconfig.fatfs @@ -142,6 +142,20 @@ config FS_FATFS_MAX_SS range 512 4096 default 512 +config FS_FATFS_MIN_SS + int "Minimum expected sector size" + range 512 FS_FATFS_MAX_SS + default 512 + help + Specifies minimum sector size the FAT FS driver is expected to + support. Set this to FS_FATFS_MAX_FS when you have single + device with FAT FS or all connected devices use the same + sector size, to have slight reduction in code in FAT FS driver. + The reduction comes from the fact that FAT FS does not have to + query every connected device for sector size. + This option affects FF_MAX_SS defined in ffconf.h, inside + ELM FAT module + config FS_FATFS_WINDOW_ALIGNMENT int "Memory alignment for the member \"win\" in FATFS" default 1