You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/12/11 16:02:02 UTC
[incubator-nuttx] 02/02: bch: specify the alignment of bch buffer by CONFIG_BCH_BUFFER_ALIGNMENT
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit befad07fd4331e33f817a6f80ad2be7722e94545
Author: Jiuzhu Dong <do...@xiaomi.com>
AuthorDate: Mon Dec 6 22:53:21 2021 +0800
bch: specify the alignment of bch buffer by CONFIG_BCH_BUFFER_ALIGNMENT
Signed-off-by: Jiuzhu Dong <do...@xiaomi.com>
---
drivers/bch/Kconfig | 4 ++++
drivers/bch/bchlib_setup.c | 6 +++++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/bch/Kconfig b/drivers/bch/Kconfig
index 38a36e5..cdf70d5 100644
--- a/drivers/bch/Kconfig
+++ b/drivers/bch/Kconfig
@@ -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
diff --git a/drivers/bch/bchlib_setup.c b/drivers/bch/bchlib_setup.c
index d51dfeb..9c57c20 100644
--- a/drivers/bch/bchlib_setup.c
+++ b/drivers/bch/bchlib_setup.c
@@ -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");