bch: specify the alignment of bch buffer by CONFIG_BCH_BUFFER_ALIGNMENT

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
This commit is contained in:
Jiuzhu Dong 2021-12-06 22:53:21 +08:00 committed by Xiang Xiao
parent f81ffb51cc
commit befad07fd4
2 changed files with 9 additions and 1 deletions

View File

@ -24,4 +24,8 @@ config BCH_ENCRYPTION_KEY_SIZE
default 16
depends on BCH_ENCRYPTION
config BCH_BUFFER_ALIGNMENT
int "Buffer aligned bytes"
default 0
endif # BCH

View File

@ -112,7 +112,11 @@ int bchlib_setup(const char *blkdev, bool readonly, FAR void **handle)
/* Allocate the sector I/O buffer */
bch->buffer = (FAR uint8_t *)kmm_malloc(bch->sectsize);
#if CONFIG_BCH_BUFFER_ALIGNMENT != 0
bch->buffer = kmm_memalign(CONFIG_BCH_BUFFER_ALIGNMENT, bch->sectsize);
#else
bch->buffer = kmm_malloc(bch->sectsize);
#endif
if (!bch->buffer)
{
ferr("ERROR: Failed to allocate sector buffer\n");