diff --git a/fs/fat/fs_mkfatfs.c b/fs/fat/fs_mkfatfs.c index 88d1859118..e4fd147549 100644 --- a/fs/fat/fs_mkfatfs.c +++ b/fs/fat/fs_mkfatfs.c @@ -298,7 +298,12 @@ int mkfatfs(FAR const char *pathname, FAR struct fat_format_s *fmt) /* Allocate a buffer that will be working sector memory */ +#ifdef CONFIG_FAT_DMAMEMORY + var.fv_sect = (uint8_t*)fat_dma_alloc(var.fv_sectorsize); ++#else var.fv_sect = (uint8_t*)kmm_malloc(var.fv_sectorsize); +#endif + if (!var.fv_sect) { fdbg("ERROR: Failed to allocate working buffers\n"); @@ -319,7 +324,11 @@ errout: if (var.fv_sect) { +#ifdef CONFIG_FAT_DMAMEMORY + fat_dma_free(var.fv_sect, var.fv_sectorsize); +#else kmm_free(var.fv_sect); +#endif } /* Return any reported errors */