From: Marek Szyprowski Date: Wed, 14 Sep 2022 15:24:53 +0000 (+0200) Subject: zlogger: correct calculation of buffer map/offset X-Git-Tag: accepted/tizen/unified/20220921.022911~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=03e2fc78ff607a8d99f3ba89c4b35c0b238722d3;p=platform%2Fkernel%2Flinux-tizen-modules-source.git zlogger: correct calculation of buffer map/offset Fix calculation of buffer map & offset for the non-2KB buffer case. Change-Id: Icb53076c5c23493ac8489d5393a53a9d7fe01c0a Signed-off-by: Marek Szyprowski --- diff --git a/include/uapi/linux/zlogger.h b/include/uapi/linux/zlogger.h index 8fb32ce..1cad482 100644 --- a/include/uapi/linux/zlogger.h +++ b/include/uapi/linux/zlogger.h @@ -28,6 +28,7 @@ #define ZLOGGER_MAP_SIZE (4 * ZLOGGER_MB) #define ZLOGGER_BUFFER_SIZE (ZLOGGER_DEVICE_COUNT * ZLOGGER_MAP_SIZE) #define ZLOGGER_BLOCK_SIZE (2 * ZLOGGER_KB) +#define ZLOGGER_BLOCK_MAP_COUNT (ZLOGGER_MAP_SIZE / ZLOGGER_BLOCK_SIZE) #define ZLOGGER_BLOCK_COUNT (ZLOGGER_BUFFER_SIZE / ZLOGGER_BLOCK_SIZE) #define ZLOGGER_DATA_MAX (ZLOGGER_BLOCK_SIZE - sizeof(struct zlogger_header)) diff --git a/kernel/zlogger/zlogger.c b/kernel/zlogger/zlogger.c index 003e032..09ed375 100644 --- a/kernel/zlogger/zlogger.c +++ b/kernel/zlogger/zlogger.c @@ -182,8 +182,8 @@ static inline char *get_shared_memory(int dev_index) static inline struct zlogger_block *get_block(uint16_t block_index) { uint16_t index = block_index - 1; - int offset = index & (ZLOGGER_BLOCK_SIZE - 1); - char *p = get_shared_memory(index / ZLOGGER_BLOCK_SIZE); + int offset = index & (ZLOGGER_BLOCK_MAP_COUNT - 1); + char *p = get_shared_memory(index / ZLOGGER_BLOCK_MAP_COUNT); if (!p) return NULL;