From 63d2f83cdc8ada38440d3ac7e2088e499b76a3aa Mon Sep 17 00:00:00 2001 From: Yifeng Zhao Date: Sat, 22 Jun 2024 10:07:29 +0800 Subject: [PATCH] soc: rockchip: sdmmc_vendor_storage: fix the issue of inaccurate calculation of free size When the amount of data written increases, more space is allocated, but when the amount of data written decreases, the allocated space is reclaimed without updating the value of free_size. Signed-off-by: Yifeng Zhao Change-Id: Iecf2af482c1e8af35b9fa3227bcbb597d75f770d --- drivers/soc/rockchip/sdmmc_vendor_storage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/soc/rockchip/sdmmc_vendor_storage.c b/drivers/soc/rockchip/sdmmc_vendor_storage.c index ea1d9410b8eb..5c14c484cd6a 100644 --- a/drivers/soc/rockchip/sdmmc_vendor_storage.c +++ b/drivers/soc/rockchip/sdmmc_vendor_storage.c @@ -85,6 +85,7 @@ static int emmc_vendor_storage_init(void) EMMC_VENDOR_PART_SIZE * max_index, EMMC_VENDOR_PART_SIZE, 0)) goto error_exit; + g_vendor->free_size = sizeof(g_vendor->data) - g_vendor->free_offset; } else { memset((void *)g_vendor, 0, sizeof(*g_vendor)); g_vendor->version = 1; @@ -160,8 +161,7 @@ static int emmc_vendor_write(u32 id, void *pbuf, u32 size) item->size = size; memcpy(&p_data[item->offset], pbuf, size); g_vendor->free_offset = offset + align_size; - g_vendor->free_size -= (align_size - - alloc_size); + g_vendor->free_size = sizeof(g_vendor->data) - g_vendor->free_offset; } else { memcpy(&p_data[item->offset], pbuf,