From 6013591cb1097c2b3520317c365dd5517b0e5f83 Mon Sep 17 00:00:00 2001 From: wangjianyu3 Date: Wed, 24 Jul 2024 20:39:45 +0800 Subject: [PATCH] dev_mem: Fix config judgment Signed-off-by: wangjianyu3 --- drivers/misc/dev_mem.c | 55 ++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/drivers/misc/dev_mem.c b/drivers/misc/dev_mem.c index 655c3a7772..894b6d6907 100644 --- a/drivers/misc/dev_mem.c +++ b/drivers/misc/dev_mem.c @@ -218,38 +218,41 @@ int devmem_register(void) return -ENOMEM; } -#ifdef CONFIG_BOARD_MEMORY_RANGE - len = parse_memory_region(CONFIG_BOARD_MEMORY_RANGE, region, - DEVMEM_REGION - 1); - if (len < 0) + if (CONFIG_BOARD_MEMORY_RANGE[0] != '\0') { - kmm_free(region); - return len; - } -#else - if (len + (4 - merge) > DEVMEM_REGION) - { - len = DEVMEM_REGION - (4 - merge); - } - - region[len].flags = PROT_EXEC | PROT_READ; - region[len].start = (uintptr_t)_stext; - region[len++].end = (uintptr_t)_etext; - region[len].flags = PROT_WRITE | PROT_READ; - region[len].start = (uintptr_t)_sdata; - region[len++].end = (uintptr_t)_edata; - - if (merge) - { - region[len - 1].end = (uintptr_t)_ebss; + len = parse_memory_region(CONFIG_BOARD_MEMORY_RANGE, region, + DEVMEM_REGION - 1); + if (len < 0) + { + kmm_free(region); + return len; + } } else { + if (len + (4 - merge) > DEVMEM_REGION) + { + len = DEVMEM_REGION - (4 - merge); + } + + region[len].flags = PROT_EXEC | PROT_READ; + region[len].start = (uintptr_t)_stext; + region[len++].end = (uintptr_t)_etext; region[len].flags = PROT_WRITE | PROT_READ; - region[len].start = (uintptr_t)_sbss; - region[len++].end = (uintptr_t)_ebss; + region[len].start = (uintptr_t)_sdata; + region[len++].end = (uintptr_t)_edata; + + if (merge) + { + region[len - 1].end = (uintptr_t)_ebss; + } + else + { + region[len].flags = PROT_WRITE | PROT_READ; + region[len].start = (uintptr_t)_sbss; + region[len++].end = (uintptr_t)_ebss; + } } -#endif /* register the new MEM driver */