Skip to content

Commit 443b701

Browse files
swift-tkkartben
authored andcommitted
soc: ambiq: fix potential issues
1. fix compile issue when CONFIG_DCACHE=n 2. check null in buf_in_nocache Signed-off-by: Swift Tian <swift.tian@ambiq.com>
1 parent 465f6ba commit 443b701

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

soc/ambiq/apollo5x/soc.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
#include <zephyr/cache.h>
99
#include <zephyr/logging/log.h>
1010
#include <zephyr/mem_mgmt/mem_attr.h>
11-
#ifdef CONFIG_DCACHE
11+
#ifdef CONFIG_CACHE_MANAGEMENT
1212
#include <zephyr/dt-bindings/memory-attr/memory-attr-arm.h>
13-
#endif /* CONFIG_DCACHE */
13+
#endif /* CONFIG_CACHE_MANAGEMENT */
1414

1515
#ifdef CONFIG_NOCACHE_MEMORY
1616
#include <zephyr/linker/linker-defs.h>
@@ -48,8 +48,9 @@ void soc_early_init_hook(void)
4848
/*
4949
* Set default temperature for spotmgr to room temperature
5050
*/
51-
am_hal_pwrctrl_temp_thresh_t dummy[32];
52-
am_hal_pwrctrl_temp_update(25.0f, dummy);
51+
am_hal_pwrctrl_temp_thresh_t dummy;
52+
53+
am_hal_pwrctrl_temp_update(25.0f, &dummy);
5354

5455
/* Enable Icache*/
5556
sys_cache_instr_enable();
@@ -63,6 +64,10 @@ bool buf_in_nocache(uintptr_t buf, size_t len_bytes)
6364
{
6465
bool buf_within_nocache = false;
6566

67+
if (buf == 0 || len_bytes == 0) {
68+
return buf_within_nocache;
69+
}
70+
6671
#if CONFIG_NOCACHE_MEMORY
6772
/* Check if buffer is in nocache region defined by the linker */
6873
buf_within_nocache = (buf >= ((uintptr_t)_nocache_ram_start)) &&

0 commit comments

Comments
 (0)