zlogger: correct calculation of buffer map/offset 36/281236/2
authorMarek Szyprowski <m.szyprowski@samsung.com>
Wed, 14 Sep 2022 15:24:53 +0000 (17:24 +0200)
committerMarek Szyprowski <m.szyprowski@samsung.com>
Thu, 15 Sep 2022 11:28:40 +0000 (13:28 +0200)
Fix calculation of buffer map & offset for the non-2KB buffer case.

Change-Id: Icb53076c5c23493ac8489d5393a53a9d7fe01c0a
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
include/uapi/linux/zlogger.h
kernel/zlogger/zlogger.c

index 8fb32ce22bf5da27d112362a12bb4c81a9e6a5ed..1cad482612305d6cb1481c84d76e6f7b51bec385 100644 (file)
@@ -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))
 
index 003e032c40c3099ca7384f98560b1e2bbb8b726e..09ed37543c12758338fcab84ed02b1e84f376669 100644 (file)
@@ -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;