Skip to content

Commit bec3a6f

Browse files
etienne-lmskartben
authored andcommitted
drivers: adc: stm32: support DMA when CONFIG_MEM_ATTR=n
Allow STM32 ADC driver to operate with DMA support even when CONFIG_MEM_ATTR is disabled which happen when CONFIG_ARM_MPU is intentionally disabled despite the CPU supports MPU. By the way, remove some #ifdef directive on header files inclusion that add noise in the header file inclusion section without any benefit. Also remove inclusion of zephyr/arch/cache.h that is not needed at all. Signed-off-by: Etienne Carriere <[email protected]>
1 parent bd92d69 commit bec3a6f

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

drivers/adc/adc_stm32.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <zephyr/device.h>
1919
#include <zephyr/kernel.h>
2020
#include <zephyr/init.h>
21+
#include <zephyr/toolchain.h>
2122
#include <soc.h>
2223
#include <zephyr/pm/device.h>
2324
#include <zephyr/pm/policy.h>
@@ -53,12 +54,7 @@ LOG_MODULE_REGISTER(adc_stm32);
5354
#include <stm32_ll_system.h>
5455
#endif
5556

56-
#ifdef CONFIG_NOCACHE_MEMORY
5757
#include <zephyr/linker/linker-defs.h>
58-
#elif defined(CONFIG_CACHE_MANAGEMENT)
59-
#include <zephyr/arch/cache.h>
60-
#endif /* CONFIG_NOCACHE_MEMORY */
61-
6258

6359
/* Here are some redefinitions of ADC versions for better readability */
6460
#if defined(CONFIG_SOC_SERIES_STM32F3X)
@@ -281,7 +277,7 @@ static int adc_stm32_dma_start(const struct device *dev,
281277
* zephyr,memory-attr = <( DT_MEM_ARM(ATTR_MPU_RAM_NOCACHE) | ... )>;
282278
* };
283279
*/
284-
static bool buf_in_nocache(uintptr_t buf, size_t len_bytes)
280+
static bool buf_in_nocache(uintptr_t buf __maybe_unused, size_t len_bytes __maybe_unused)
285281
{
286282
bool buf_within_nocache = false;
287283

@@ -293,8 +289,10 @@ static bool buf_in_nocache(uintptr_t buf, size_t len_bytes)
293289
}
294290
#endif /* CONFIG_NOCACHE_MEMORY */
295291

292+
#ifdef CONFIG_MEM_ATTR
296293
buf_within_nocache = mem_attr_check_buf(
297294
(void *)buf, len_bytes, DT_MEM_ARM(ATTR_MPU_RAM_NOCACHE)) == 0;
295+
#endif /* CONFIG_MEM_ATTR */
298296

299297
return buf_within_nocache;
300298
}

0 commit comments

Comments
 (0)