From 94c8da21216ac077842c413a4339e71285bcf94d Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Wed, 22 Mar 2023 19:12:25 +0100 Subject: lmb: Fix LMB_MEMORY_REGIONS flag usage Remove test on CONFIG_LMB_MEMORY_REGIONS introduced by commit 7c1860fce4e3 ("lmb: Fix lmb property's defination under struct lmb"). This code in lmb_init() is strange, because if CONFIG_LMB_USE_MAX_REGIONS and CONFIG_LMB_MEMORY_REGIONS are not defined, the implicit #else is empty and the required initialization is not done: lmb->memory.max = ? lmb->reserved.max = ? But this setting is not possible: - CONFIG_LMB_USE_MAX_REGIONS not defined - CONFIG_LMB_MEMORY_REGIONS not defined because CONFIG_LMB_MEMORY_REGIONS and CONFIG_LMB_RESERVED_REGIONS are defined as soon as the CONFIG_LMB_USE_MAX_REGIONS is not defined. This patch removes this impossible case #elif and I add some explanation in lmb.h to explain why in the struct lmb {} the lmb property is defined if CONFIG_LMB_MEMORY_REGIONS is NOT defined. This patch also removes CONFIG_LMB_XXX dependency on CONFIG_LMB as these defines are used in API file lmb.h and not only in library file. Fixes: 5e2548c1d6e03 ("lmb: Fix LMB_MEMORY_REGIONS flag usage") Reported-by: Mark Millard Signed-off-by: Patrick Delaunay Acked-by: Michal Simek --- lib/Kconfig | 7 +++---- lib/lmb.c | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/Kconfig b/lib/Kconfig index 202a34ab413..d8dac09ea84 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -1057,7 +1057,6 @@ config LMB config LMB_USE_MAX_REGIONS bool "Use a common number of memory and reserved regions in lmb lib" - depends on LMB default y help Define the number of supported memory regions in the library logical @@ -1067,7 +1066,7 @@ config LMB_USE_MAX_REGIONS config LMB_MAX_REGIONS int "Number of memory and reserved regions in lmb lib" - depends on LMB && LMB_USE_MAX_REGIONS + depends on LMB_USE_MAX_REGIONS default 16 help Define the number of supported regions, memory and reserved, in the @@ -1075,7 +1074,7 @@ config LMB_MAX_REGIONS config LMB_MEMORY_REGIONS int "Number of memory regions in lmb lib" - depends on LMB && !LMB_USE_MAX_REGIONS + depends on !LMB_USE_MAX_REGIONS default 8 help Define the number of supported memory regions in the library logical @@ -1084,7 +1083,7 @@ config LMB_MEMORY_REGIONS config LMB_RESERVED_REGIONS int "Number of reserved regions in lmb lib" - depends on LMB && !LMB_USE_MAX_REGIONS + depends on !LMB_USE_MAX_REGIONS default 8 help Define the number of supported reserved regions in the library logical diff --git a/lib/lmb.c b/lib/lmb.c index 2444b2a6212..8fbe453dfa9 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -110,7 +110,7 @@ void lmb_init(struct lmb *lmb) #if IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS) lmb->memory.max = CONFIG_LMB_MAX_REGIONS; lmb->reserved.max = CONFIG_LMB_MAX_REGIONS; -#elif defined(CONFIG_LMB_MEMORY_REGIONS) +#else lmb->memory.max = CONFIG_LMB_MEMORY_REGIONS; lmb->reserved.max = CONFIG_LMB_RESERVED_REGIONS; lmb->memory.region = lmb->memory_regions; -- cgit v1.3.1 From c9eb37a1e764b43d2cd2a4a5e6f07d247c569ab7 Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Wed, 22 Mar 2023 19:12:26 +0100 Subject: lmb: add max number of region in lmb_dump_region() output Add the max number of region in lmb dump; this patch allows to check the limit for usage of the LMB regions, memory or reserved. Result on STM32MP157C-DK2: STM32MP> bdinfo ..... lmb_dump_all: memory.cnt = 0x1 / max = 0x2 memory[0] [0xc0000000-0xdfffffff], 0x20000000 bytes flags: 0 reserved.cnt = 0x6 / max = 0x10 reserved[0] [0x10000000-0x10045fff], 0x00046000 bytes flags: 4 reserved[1] [0x30000000-0x3003ffff], 0x00040000 bytes flags: 4 reserved[2] [0x38000000-0x3800ffff], 0x00010000 bytes flags: 4 reserved[3] [0xd4000000-0xd7ffffff], 0x04000000 bytes flags: 4 reserved[4] [0xdcae5000-0xdfffffff], 0x0351b000 bytes flags: 0 reserved[5] [0xddafb5b8-0xdfffffff], 0x02504a48 bytes flags: 0 .... Reported-by: Mark Millard Signed-off-by: Patrick Delaunay --- lib/lmb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/lmb.c b/lib/lmb.c index 8fbe453dfa9..b2c233edb64 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -27,7 +27,7 @@ static void lmb_dump_region(struct lmb_region *rgn, char *name) enum lmb_flags flags; int i; - printf(" %s.cnt = 0x%lx\n", name, rgn->cnt); + printf(" %s.cnt = 0x%lx / max = 0x%lx\n", name, rgn->cnt, rgn->max); for (i = 0; i < rgn->cnt; i++) { base = rgn->region[i].base; -- cgit v1.3.1 From 9ee32a7876f4372fd0f5515a27b2c148a8e8a19c Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 1 Apr 2023 08:13:42 +0200 Subject: lib: missing fallthrough comment in vsnprintf_internal() When a case statement intentionally falls through we should add a comment. Cf. -Wimplicit-fallthrough Signed-off-by: Heinrich Schuchardt --- lib/vsprintf.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib') diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 2d13e68b579..e87503e41ad 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -674,6 +674,7 @@ repeat: case 'x': flags |= SMALL; + /* fallthrough */ case 'X': base = 16; break; @@ -681,8 +682,10 @@ repeat: case 'd': if (fmt[1] == 'E') flags |= ERRSTR; + /* fallthrough */ case 'i': flags |= SIGN; + /* fallthrough */ case 'u': break; -- cgit v1.3.1