Fix calculation of buffer map & offset for the non-2KB buffer case.
Change-Id: Icb53076c5c23493ac8489d5393a53a9d7fe01c0a
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
#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))
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;