1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2026-01-01 01:41:18 +01:00

Merge pull request #21169 from fabian18/pr/mtd_sdmmc_remove_MTD_DRIVER_FLAG_DIRECT_WRITE

{cpu/sam0_common/sam0_sdhc,drivers/mtd}: do not allocate `work_area` twice
This commit is contained in:
fabian18 2025-02-19 17:02:42 +00:00 committed by GitHub
commit 8bbeba10cb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 6 deletions

View File

@ -46,9 +46,11 @@ static int _init(mtd_dev_t *dev)
#if IS_USED(MODULE_MTD_WRITE_PAGE)
/* TODO: move to MTD layer */
dev->work_area = malloc(SD_MMC_BLOCK_SIZE);
if (dev->work_area == NULL) {
return -ENOMEM;
if (!dev->work_area) {
dev->work_area = malloc(SD_MMC_BLOCK_SIZE);
if (dev->work_area == NULL) {
return -ENOMEM;
}
}
dev->write_size = 1;
#endif

View File

@ -76,9 +76,11 @@ int mtd_init(mtd_dev_t *mtd)
#ifdef MODULE_MTD_WRITE_PAGE
if ((mtd->driver->flags & MTD_DRIVER_FLAG_DIRECT_WRITE) == 0) {
mtd->work_area = malloc(mtd->pages_per_sector * mtd->page_size);
if (mtd->work_area == NULL) {
res = -ENOMEM;
if (!mtd->work_area) {
mtd->work_area = malloc(mtd->pages_per_sector * mtd->page_size);
if (mtd->work_area == NULL) {
res = -ENOMEM;
}
}
}
#endif