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 <yifeng.zhao@rock-chips.com>
Change-Id: Iecf2af482c1e8af35b9fa3227bcbb597d75f770d
This commit is contained in:
Yifeng Zhao
2024-06-22 10:07:29 +08:00
committed by Tao Huang
parent f4fdb8d83f
commit 63d2f83cdc

View File

@@ -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,