From a632efc93f1bf38ed2678bf3c0eec4804792e158 Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Mon, 17 Sep 2018 06:58:09 -0500 Subject: [PATCH 01/43] kernel: move to new logger Use the new logger framework for kernel. Signed-off-by: Anas Nashif --- kernel/Kconfig | 4 ++++ kernel/init.c | 3 +++ kernel/userspace.c | 8 ++++++-- tests/kernel/common/prj.conf | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/kernel/Kconfig b/kernel/Kconfig index 64a890b347b9..302806a6b382 100644 --- a/kernel/Kconfig +++ b/kernel/Kconfig @@ -9,6 +9,10 @@ menu "General Kernel Options" +module = KERNEL +module-str = kernel +source "subsys/logging/Kconfig.template.log_config" + config MULTITHREADING bool "Multi-threading" default y diff --git a/kernel/init.c b/kernel/init.c index e9cdcfa87ce5..8a0531d39488 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -35,6 +35,9 @@ #include #define IDLE_THREAD_NAME "idle" +#define LOG_LEVEL CONFIG_KERNEL_LOG_LEVEL +#include +LOG_MODULE_REGISTER(kernel); /* boot banner items */ #if defined(CONFIG_BOOT_DELAY) && CONFIG_BOOT_DELAY > 0 diff --git a/kernel/userspace.c b/kernel/userspace.c index 54003e27f050..df2c2ab53c4f 100644 --- a/kernel/userspace.c +++ b/kernel/userspace.c @@ -16,7 +16,11 @@ #include #include #include -#include + +#define LOG_LEVEL CONFIG_KERNEL_LOG_LEVEL +#include +LOG_MODULE_DECLARE(kernel); + #if defined(CONFIG_NETWORKING) && defined (CONFIG_DYNAMIC_OBJECTS) /* Used by auto-generated obj_size_get() switch body, as we need to * know the size of struct net_context @@ -221,7 +225,7 @@ void *_impl_k_object_alloc(enum k_objects otype) dyn_obj = z_thread_malloc(sizeof(*dyn_obj) + obj_size_get(otype)); if (dyn_obj == NULL) { - SYS_LOG_WRN("could not allocate kernel object"); + LOG_WRN("could not allocate kernel object"); return NULL; } diff --git a/tests/kernel/common/prj.conf b/tests/kernel/common/prj.conf index be9b038251ea..f978f03e3eb6 100644 --- a/tests/kernel/common/prj.conf +++ b/tests/kernel/common/prj.conf @@ -1,4 +1,4 @@ CONFIG_ZTEST=y CONFIG_PRINTK=y -CONFIG_SYS_LOG=y +CONFIG_LOG=y CONFIG_POLL=y From a8cbcc4401ce59124caa47649db9991477f4a5c2 Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Mon, 17 Sep 2018 09:56:20 -0500 Subject: [PATCH 02/43] arch: setup logging using new logger Use the new logger framework for architecture code. Signed-off-by: Anas Nashif --- arch/Kconfig | 8 +++++ arch/arc/core/mpu/arc_core_mpu.c | 9 ++++-- arch/arc/core/mpu/arc_mpu.c | 22 +++++++------- arch/arm/core/cortex_m/mpu/arm_core_mpu.c | 9 ++++-- arch/arm/core/cortex_m/mpu/arm_mpu.c | 21 ++++++++------ .../core/cortex_m/mpu/arm_mpu_v7_internal.h | 6 +++- .../core/cortex_m/mpu/arm_mpu_v8_internal.h | 4 ++- arch/arm/core/cortex_m/mpu/nxp_mpu.c | 29 ++++++++++--------- samples/mpu/mem_domain_apis_test/prj.conf | 4 +-- .../mpu_stack_guard_test/prj_stack_guard.conf | 2 +- 10 files changed, 71 insertions(+), 43 deletions(-) diff --git a/arch/Kconfig b/arch/Kconfig index 4935dc12fd13..818c9333f69f 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -53,6 +53,14 @@ endchoice menu "General Architecture Options" +module = ARCH +module-str = arch +source "subsys/logging/Kconfig.template.log_config" + +module = MPU +module-str = mpu +source "subsys/logging/Kconfig.template.log_config" + config HW_STACK_PROTECTION bool "Hardware Stack Protection" depends on ARCH_HAS_STACK_PROTECTION diff --git a/arch/arc/core/mpu/arc_core_mpu.c b/arch/arc/core/mpu/arc_core_mpu.c index b7825670a314..3897981de7a7 100644 --- a/arch/arc/core/mpu/arc_core_mpu.c +++ b/arch/arc/core/mpu/arc_core_mpu.c @@ -9,7 +9,10 @@ #include #include #include -#include + +#define LOG_LEVEL CONFIG_MPU_LOG_LEVEL +#include +LOG_MODULE_REGISTER(mpu); /* * @brief Configure MPU for the thread @@ -81,7 +84,7 @@ void configure_mpu_stack_guard(struct k_thread *thread) */ void configure_mpu_user_context(struct k_thread *thread) { - SYS_LOG_DBG("configure user thread %p's context", thread); + LOG_DBG("configure user thread %p's context", thread); arc_core_mpu_configure_user_context(thread); } @@ -96,7 +99,7 @@ void configure_mpu_user_context(struct k_thread *thread) */ void configure_mpu_mem_domain(struct k_thread *thread) { - SYS_LOG_DBG("configure thread %p's domain", thread); + LOG_DBG("configure thread %p's domain", thread); arc_core_mpu_configure_mem_domain(thread->mem_domain_info.mem_domain); } diff --git a/arch/arc/core/mpu/arc_mpu.c b/arch/arc/core/mpu/arc_mpu.c index 1eb0754a3f9b..55ae3659b9c8 100644 --- a/arch/arc/core/mpu/arc_mpu.c +++ b/arch/arc/core/mpu/arc_mpu.c @@ -12,8 +12,10 @@ #include #include #include -#include +#define LOG_LEVEL CONFIG_MPU_LOG_LEVEL +#include +LOG_MODULE_DECLARE(mpu); #define AUX_MPU_RDB_VALID_MASK (0x1) #define AUX_MPU_EN_ENABLE (0x40000000) @@ -330,7 +332,7 @@ void arc_core_mpu_configure(u8_t type, u32_t base, u32_t size) u32_t region_index = _get_region_index_by_type(type); u32_t region_attr = _get_region_attr_by_type(type); - SYS_LOG_DBG("Region info: 0x%x 0x%x", base, size); + LOG_DBG("Region info: 0x%x 0x%x", base, size); if (region_attr == 0) { return; @@ -488,11 +490,11 @@ void arc_core_mpu_configure_mem_domain(struct k_mem_domain *mem_domain) struct k_mem_partition *pparts; if (mem_domain) { - SYS_LOG_DBG("configure domain: %p", mem_domain); + LOG_DBG("configure domain: %p", mem_domain); num_partitions = mem_domain->num_partitions; pparts = mem_domain->partitions; } else { - SYS_LOG_DBG("disable domain partition regions"); + LOG_DBG("disable domain partition regions"); num_partitions = 0; pparts = NULL; } @@ -511,13 +513,13 @@ void arc_core_mpu_configure_mem_domain(struct k_mem_domain *mem_domain) for (; region_index < num_regions; region_index++) { #endif if (num_partitions && pparts->size) { - SYS_LOG_DBG("set region 0x%x 0x%x 0x%x", + LOG_DBG("set region 0x%x 0x%x 0x%x", region_index, pparts->start, pparts->size); _region_init(region_index, pparts->start, pparts->size, pparts->attr); num_partitions--; } else { - SYS_LOG_DBG("disable region 0x%x", region_index); + LOG_DBG("disable region 0x%x", region_index); /* Disable region */ _region_init(region_index, 0, 0, 0); } @@ -537,15 +539,15 @@ void arc_core_mpu_configure_mem_partition(u32_t part_index, u32_t region_index = _get_region_index_by_type(THREAD_DOMAIN_PARTITION_REGION); - SYS_LOG_DBG("configure partition index: %u", part_index); + LOG_DBG("configure partition index: %u", part_index); if (part) { - SYS_LOG_DBG("set region 0x%x 0x%x 0x%x", + LOG_DBG("set region 0x%x 0x%x 0x%x", region_index + part_index, part->start, part->size); _region_init(region_index, part->start, part->size, part->attr); } else { - SYS_LOG_DBG("disable region 0x%x", region_index + part_index); + LOG_DBG("disable region 0x%x", region_index + part_index); /* Disable region */ _region_init(region_index + part_index, 0, 0, 0); } @@ -561,7 +563,7 @@ void arc_core_mpu_mem_partition_remove(u32_t part_index) u32_t region_index = _get_region_index_by_type(THREAD_DOMAIN_PARTITION_REGION); - SYS_LOG_DBG("disable region 0x%x", region_index + part_index); + LOG_DBG("disable region 0x%x", region_index + part_index); /* Disable region */ _region_init(region_index + part_index, 0, 0, 0); } diff --git a/arch/arm/core/cortex_m/mpu/arm_core_mpu.c b/arch/arm/core/cortex_m/mpu/arm_core_mpu.c index 2b3e971e33f2..ab1066271d11 100644 --- a/arch/arm/core/cortex_m/mpu/arm_core_mpu.c +++ b/arch/arm/core/cortex_m/mpu/arm_core_mpu.c @@ -10,7 +10,10 @@ #include #include #include -#include + +#define LOG_LEVEL CONFIG_MPU_LOG_LEVEL +#include +LOG_MODULE_REGISTER(mpu); #if defined(CONFIG_MPU_STACK_GUARD) /* @@ -50,7 +53,7 @@ void configure_mpu_stack_guard(struct k_thread *thread) */ void configure_mpu_user_context(struct k_thread *thread) { - SYS_LOG_DBG("configure user thread %p's context", thread); + LOG_DBG("configure user thread %p's context", thread); arm_core_mpu_disable(); arm_core_mpu_configure_user_context(thread); arm_core_mpu_enable(); @@ -66,7 +69,7 @@ void configure_mpu_user_context(struct k_thread *thread) */ void configure_mpu_mem_domain(struct k_thread *thread) { - SYS_LOG_DBG("configure thread %p's domain", thread); + LOG_DBG("configure thread %p's domain", thread); arm_core_mpu_disable(); arm_core_mpu_configure_mem_domain(thread->mem_domain_info.mem_domain); arm_core_mpu_enable(); diff --git a/arch/arm/core/cortex_m/mpu/arm_mpu.c b/arch/arm/core/cortex_m/mpu/arm_mpu.c index 770a8f15bb3f..58ae89661267 100644 --- a/arch/arm/core/cortex_m/mpu/arm_mpu.c +++ b/arch/arm/core/cortex_m/mpu/arm_mpu.c @@ -11,9 +11,12 @@ #include #include #include -#include #include +#define LOG_LEVEL CONFIG_MPU_LOG_LEVEL +#include +LOG_MODULE_DECLARE(mpu); + #if defined(CONFIG_CPU_CORTEX_M0PLUS) || \ defined(CONFIG_CPU_CORTEX_M3) || \ defined(CONFIG_CPU_CORTEX_M4) || \ @@ -149,7 +152,7 @@ static inline void _disable_region(u32_t r_index) "Index 0x%x out-of-bound (supported regions: 0x%x)\n", r_index, _get_num_regions()); - SYS_LOG_DBG("disable region 0x%x", r_index); + LOG_DBG("disable region 0x%x", r_index); /* Disable region */ ARM_MPU_ClrRegion(r_index); } @@ -165,7 +168,7 @@ void arm_core_mpu_configure(u8_t type, u32_t base, u32_t size) { struct arm_mpu_region region_conf; - SYS_LOG_DBG("Region info: 0x%x 0x%x", base, size); + LOG_DBG("Region info: 0x%x 0x%x", base, size); u32_t region_index = _get_region_index_by_type(type); if (_get_region_attr_by_type(®ion_conf.attr, type, base, size)) { @@ -208,18 +211,18 @@ void arm_core_mpu_configure_mem_domain(struct k_mem_domain *mem_domain) struct arm_mpu_region region_conf; if (mem_domain) { - SYS_LOG_DBG("configure domain: %p", mem_domain); + LOG_DBG("configure domain: %p", mem_domain); num_partitions = mem_domain->num_partitions; pparts = mem_domain->partitions; } else { - SYS_LOG_DBG("disable domain partition regions"); + LOG_DBG("disable domain partition regions"); num_partitions = 0; pparts = NULL; } for (; region_index < _get_num_regions(); region_index++) { if (num_partitions && pparts->size) { - SYS_LOG_DBG("set region 0x%x 0x%x 0x%x", + LOG_DBG("set region 0x%x 0x%x 0x%x", region_index, pparts->start, pparts->size); region_conf.base = pparts->start; _get_ram_region_attr_by_conf(®ion_conf.attr, @@ -246,11 +249,11 @@ void arm_core_mpu_configure_mem_partition(u32_t part_index, _get_region_index_by_type(THREAD_DOMAIN_PARTITION_REGION); struct arm_mpu_region region_conf; - SYS_LOG_DBG("configure partition index: %u", part_index); + LOG_DBG("configure partition index: %u", part_index); if (part && (region_index + part_index < _get_num_regions())) { - SYS_LOG_DBG("set region 0x%x 0x%x 0x%x", + LOG_DBG("set region 0x%x 0x%x 0x%x", region_index + part_index, part->start, part->size); _get_ram_region_attr_by_conf(®ion_conf.attr, part->attr, part->start, part->size); @@ -327,7 +330,7 @@ static int arm_mpu_init(struct device *arg) return -1; } - SYS_LOG_DBG("total region count: %d", _get_num_regions()); + LOG_DBG("total region count: %d", _get_num_regions()); arm_core_mpu_disable(); diff --git a/arch/arm/core/cortex_m/mpu/arm_mpu_v7_internal.h b/arch/arm/core/cortex_m/mpu/arm_mpu_v7_internal.h index de9a6083d79c..71ff8b5c4ecd 100644 --- a/arch/arm/core/cortex_m/mpu/arm_mpu_v7_internal.h +++ b/arch/arm/core/cortex_m/mpu/arm_mpu_v7_internal.h @@ -8,6 +8,10 @@ #ifndef ZEPHYR_ARCH_ARM_CORE_CORTEX_M_MPU_ARM_MPU_V7_INTERNAL_H_ #define ZEPHYR_ARCH_ARM_CORE_CORTEX_M_MPU_ARM_MPU_V7_INTERNAL_H_ + +#define LOG_LEVEL CONFIG_MPU_LOG_LEVEL +#include + /* Global MPU configuration at system initialization. */ static void _mpu_init(void) { @@ -27,7 +31,7 @@ static void _region_init(u32_t index, struct arm_mpu_region *region_conf) MPU->RBAR = (region_conf->base & MPU_RBAR_ADDR_Msk) | MPU_RBAR_VALID_Msk | index; MPU->RASR = region_conf->attr.rasr | MPU_RASR_ENABLE_Msk; - SYS_LOG_DBG("[%d] 0x%08x 0x%08x", + LOG_DBG("[%d] 0x%08x 0x%08x", index, region_conf->base, region_conf->attr.rasr); } diff --git a/arch/arm/core/cortex_m/mpu/arm_mpu_v8_internal.h b/arch/arm/core/cortex_m/mpu/arm_mpu_v8_internal.h index d353ca12dbc3..f24c3e58bffc 100644 --- a/arch/arm/core/cortex_m/mpu/arm_mpu_v8_internal.h +++ b/arch/arm/core/cortex_m/mpu/arm_mpu_v8_internal.h @@ -9,6 +9,8 @@ #define ZEPHYR_ARCH_ARM_CORE_CORTEX_M_MPU_ARM_MPU_V8_INTERNAL_H_ #include +#define LOG_LEVEL CONFIG_MPU_LOG_LEVEL +#include /* Global MPU configuration at system initialization. */ static void _mpu_init(void) @@ -49,7 +51,7 @@ static void _region_init(u32_t index, struct arm_mpu_region *region_conf) | MPU_RLAR_EN_Msk ); - SYS_LOG_DBG("[%d] 0x%08x 0x%08x 0x%08x 0x%08x", + LOG_DBG("[%d] 0x%08x 0x%08x 0x%08x 0x%08x", index, region_conf->base, region_conf->attr.rbar, region_conf->attr.mair_idx, region_conf->attr.r_limit); } diff --git a/arch/arm/core/cortex_m/mpu/nxp_mpu.c b/arch/arm/core/cortex_m/mpu/nxp_mpu.c index 133efea064ce..514ab28405c2 100644 --- a/arch/arm/core/cortex_m/mpu/nxp_mpu.c +++ b/arch/arm/core/cortex_m/mpu/nxp_mpu.c @@ -10,10 +10,13 @@ #include #include #include -#include #include #include +#define LOG_LEVEL CONFIG_MPU_LOG_LEVEL +#include +LOG_MODULE_DECLARE(mpu); + /* NXP MPU Enabled state */ static u8_t nxp_mpu_enabled; @@ -92,7 +95,7 @@ static void _region_init(u32_t index, u32_t region_base, SYSMPU->WORD[index][3] = SYSMPU_WORD_VLD_MASK; } - SYS_LOG_DBG("[%d] 0x%08x 0x%08x 0x%08x 0x%08x", index, + LOG_DBG("[%d] 0x%08x 0x%08x 0x%08x 0x%08x", index, SYSMPU->WORD[index][0], SYSMPU->WORD[index][1], SYSMPU->WORD[index][2], @@ -225,7 +228,7 @@ void arm_core_mpu_disable(void) */ void arm_core_mpu_configure(u8_t type, u32_t base, u32_t size) { - SYS_LOG_DBG("Region info: 0x%x 0x%x", base, size); + LOG_DBG("Region info: 0x%x 0x%x", base, size); u32_t region_index = _get_region_index_by_type(type); u32_t region_attr = _get_region_attr_by_type(type); @@ -265,11 +268,11 @@ void arm_core_mpu_configure_mem_domain(struct k_mem_domain *mem_domain) struct k_mem_partition *pparts; if (mem_domain) { - SYS_LOG_DBG("configure domain: %p", mem_domain); + LOG_DBG("configure domain: %p", mem_domain); num_partitions = mem_domain->num_partitions; pparts = mem_domain->partitions; } else { - SYS_LOG_DBG("disable domain partition regions"); + LOG_DBG("disable domain partition regions"); num_partitions = 0; pparts = NULL; } @@ -280,7 +283,7 @@ void arm_core_mpu_configure_mem_domain(struct k_mem_domain *mem_domain) */ for (; region_index < _get_num_usable_regions(); region_index++) { if (num_partitions && pparts->size) { - SYS_LOG_DBG("set region 0x%x 0x%x 0x%x", + LOG_DBG("set region 0x%x 0x%x 0x%x", region_index, pparts->start, pparts->size); region_attr = pparts->attr; _region_init(region_index, pparts->start, @@ -288,7 +291,7 @@ void arm_core_mpu_configure_mem_domain(struct k_mem_domain *mem_domain) region_attr); num_partitions--; } else { - SYS_LOG_DBG("disable region 0x%x", region_index); + LOG_DBG("disable region 0x%x", region_index); /* Disable region */ SYSMPU->WORD[region_index][0] = 0; SYSMPU->WORD[region_index][1] = 0; @@ -312,17 +315,17 @@ void arm_core_mpu_configure_mem_partition(u32_t part_index, _get_region_index_by_type(THREAD_DOMAIN_PARTITION_REGION); u32_t region_attr; - SYS_LOG_DBG("configure partition index: %u", part_index); + LOG_DBG("configure partition index: %u", part_index); if (part) { - SYS_LOG_DBG("set region 0x%x 0x%x 0x%x", + LOG_DBG("set region 0x%x 0x%x 0x%x", region_index + part_index, part->start, part->size); region_attr = part->attr; _region_init(region_index + part_index, part->start, ENDADDR_ROUND(part->start + part->size), region_attr); } else { - SYS_LOG_DBG("disable region 0x%x", region_index); + LOG_DBG("disable region 0x%x", region_index); /* Disable region */ SYSMPU->WORD[region_index + part_index][0] = 0; SYSMPU->WORD[region_index + part_index][1] = 0; @@ -341,7 +344,7 @@ void arm_core_mpu_mem_partition_remove(u32_t part_index) u32_t region_index = _get_region_index_by_type(THREAD_DOMAIN_PARTITION_REGION); - SYS_LOG_DBG("disable region 0x%x", region_index); + LOG_DBG("disable region 0x%x", region_index); /* Disable region */ SYSMPU->WORD[region_index + part_index][0] = 0; SYSMPU->WORD[region_index + part_index][1] = 0; @@ -424,7 +427,7 @@ static void _nxp_mpu_config(void) __ASSERT(mpu_config.num_regions <= _get_num_regions(), "too many static MPU regions defined"); - SYS_LOG_DBG("total region count: %d", _get_num_regions()); + LOG_DBG("total region count: %d", _get_num_regions()); /* Disable MPU */ SYSMPU->CESR &= ~SYSMPU_CESR_VLD_MASK; @@ -491,7 +494,7 @@ static int nxp_mpu_init(struct device *arg) return 0; } -#if defined(CONFIG_SYS_LOG) +#if defined(CONFIG_LOG) /* To have logging the driver needs to be initialized later */ SYS_INIT(nxp_mpu_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT); diff --git a/samples/mpu/mem_domain_apis_test/prj.conf b/samples/mpu/mem_domain_apis_test/prj.conf index ea363c8023ee..95e4771143dd 100644 --- a/samples/mpu/mem_domain_apis_test/prj.conf +++ b/samples/mpu/mem_domain_apis_test/prj.conf @@ -1,6 +1,6 @@ CONFIG_STDOUT_CONSOLE=y -CONFIG_SYS_LOG=y -CONFIG_SYS_LOG_DEFAULT_LEVEL=4 +CONFIG_LOG=y +CONFIG_LOG_DEFAULT_LEVEL=4 CONFIG_HW_STACK_PROTECTION=y CONFIG_USERSPACE=y CONFIG_MAX_DOMAIN_PARTITIONS=16 diff --git a/samples/mpu/mpu_stack_guard_test/prj_stack_guard.conf b/samples/mpu/mpu_stack_guard_test/prj_stack_guard.conf index a22336a027ad..b7eeeffcad00 100644 --- a/samples/mpu/mpu_stack_guard_test/prj_stack_guard.conf +++ b/samples/mpu/mpu_stack_guard_test/prj_stack_guard.conf @@ -1,3 +1,3 @@ CONFIG_STDOUT_CONSOLE=y CONFIG_MPU_STACK_GUARD=y -CONFIG_SYS_LOG=y +CONFIG_LOG=y From 1b0bcbde77d533f75cd39310825e913c71ebe22b Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Mon, 17 Sep 2018 10:39:56 -0500 Subject: [PATCH 03/43] soc: logging: move soc tree to new logger Use the new logger framework for soc related code. Signed-off-by: Anas Nashif --- soc/Kconfig | 5 +++++ soc/arm/nordic_nrf/nrf51/soc.c | 3 +++ soc/arm/nordic_nrf/nrf52/power.c | 16 ++++++++-------- soc/arm/nordic_nrf/nrf52/soc.c | 4 ++++ soc/x86/intel_quark/quark_se/Kconfig | 20 -------------------- soc/x86/intel_quark/quark_se/soc.c | 14 +++++++------- soc/xtensa/intel_s1000/soc.c | 18 +++++++++--------- 7 files changed, 36 insertions(+), 44 deletions(-) diff --git a/soc/Kconfig b/soc/Kconfig index cc6a7ee1473e..ab0c3810f746 100644 --- a/soc/Kconfig +++ b/soc/Kconfig @@ -10,4 +10,9 @@ menu "Hardware Configuration" osource "$(SOC_DIR)/$(ARCH)/Kconfig" osource "$(SOC_DIR)/$(ARCH)/*/Kconfig" + +module = SOC +module-str = SOC +source "subsys/logging/Kconfig.template.log_config" + endmenu diff --git a/soc/arm/nordic_nrf/nrf51/soc.c b/soc/arm/nordic_nrf/nrf51/soc.c index 36ed1404126e..d37d22cc0501 100644 --- a/soc/arm/nordic_nrf/nrf51/soc.c +++ b/soc/arm/nordic_nrf/nrf51/soc.c @@ -24,6 +24,9 @@ extern void _NmiInit(void); #endif #include +#define LOG_LEVEL CONFIG_SOC_LOG_LEVEL +#include +LOG_MODULE_REGISTER(soc); static int nordicsemi_nrf51_init(struct device *arg) { diff --git a/soc/arm/nordic_nrf/nrf52/power.c b/soc/arm/nordic_nrf/nrf52/power.c index aedfde933fd5..d8641c4bf5ef 100644 --- a/soc/arm/nordic_nrf/nrf52/power.c +++ b/soc/arm/nordic_nrf/nrf52/power.c @@ -3,14 +3,14 @@ * * SPDX-License-Identifier: Apache-2.0 */ - -#define SYS_LOG_LEVEL SYS_LOG_LEVEL_DEBUG -#include - #include #include #include +#define LOG_LEVEL CONFIG_SOC_LOG_LEVEL +#include +LOG_MODULE_DECLARE(soc); + #if defined(CONFIG_SYS_POWER_DEEP_SLEEP) /* System_OFF is deepest Power state available, On exiting from this * state CPU including all peripherals reset @@ -48,7 +48,7 @@ static void _low_power_mode(enum power_states state) default: /* Unsupported State */ - SYS_LOG_ERR("Unsupported State\n"); + LOG_ERR("Unsupported State"); break; } @@ -73,7 +73,7 @@ void _sys_soc_set_power_state(enum power_states state) #endif default: /* Unsupported State */ - SYS_LOG_ERR("Unsupported State\n"); + LOG_ERR("Unsupported State"); break; } } @@ -93,7 +93,7 @@ void _sys_soc_power_state_post_ops(enum power_states state) #endif default: /* Unsupported State */ - SYS_LOG_ERR("Unsupported State\n"); + LOG_ERR("Unsupported State"); break; } } @@ -109,7 +109,7 @@ bool _sys_soc_is_valid_power_state(enum power_states state) return true; break; default: - SYS_LOG_DBG("Unsupported State\n"); + LOG_DBG("Unsupported State"); break; } diff --git a/soc/arm/nordic_nrf/nrf52/soc.c b/soc/arm/nordic_nrf/nrf52/soc.c index 369dbaa496b8..ffffd1fc5a60 100644 --- a/soc/arm/nordic_nrf/nrf52/soc.c +++ b/soc/arm/nordic_nrf/nrf52/soc.c @@ -36,6 +36,10 @@ extern void _NmiInit(void); #include #include +#define LOG_LEVEL CONFIG_SOC_LOG_LEVEL +#include +LOG_MODULE_REGISTER(soc); + static int nordicsemi_nrf52_init(struct device *arg) { u32_t key; diff --git a/soc/x86/intel_quark/quark_se/Kconfig b/soc/x86/intel_quark/quark_se/Kconfig index c5968b3950dd..9ac5a67102f6 100644 --- a/soc/x86/intel_quark/quark_se/Kconfig +++ b/soc/x86/intel_quark/quark_se/Kconfig @@ -27,26 +27,6 @@ config ARC_INIT help Allows x86 processor to kickoff the ARC slave processor. -config SYS_LOG_ARC_INIT_LEVEL - int "Quark SE Sensor Subsystem log level" - depends on SYS_LOG - default 0 - help - Sets log level for the boot initialization and boot process of the sensor - sub-system. - - Levels are: - - - 0 OFF, do not write - - - 1 ERROR, only write SYS_LOG_ERR - - - 2 WARNING, write SYS_LOG_WRN in addition to previous level - - - 3 INFO, write SYS_LOG_INF in addition to previous levels - - - 4 DEBUG, write SYS_LOG_DBG in addition to previous levels - config ARC_GDB_ENABLE bool "Allows the usage of GDB with the ARC processor." depends on ARC_INIT diff --git a/soc/x86/intel_quark/quark_se/soc.c b/soc/x86/intel_quark/quark_se/soc.c index 17783647518f..a6f591819306 100644 --- a/soc/x86/intel_quark/quark_se/soc.c +++ b/soc/x86/intel_quark/quark_se/soc.c @@ -23,6 +23,9 @@ #include "shared_mem.h" #include +#define LOG_LEVEL CONFIG_SOC_LOG_LEVEL +#include +LOG_MODULE_REGISTER(soc); #ifdef CONFIG_X86_MMU /* loapic */ @@ -50,9 +53,6 @@ MMU_BOOT_REGION(0xB0500000, 256*1024, MMU_ENTRY_WRITE); #define SCSS_REG_VAL(offset) \ (*((volatile u32_t *)(SCSS_REGISTER_BASE+offset))) -#define SYS_LOG_LEVEL CONFIG_SYS_LOG_ARC_INIT_LEVEL -#include - /** * * @brief ARC Init @@ -78,12 +78,12 @@ int _arc_init(struct device *arg) * we read the value and stick it in shared_mem->arc_start which is * the beginning of the address space at 0xA8000000 */ reset_vector = (u32_t *)RESET_VECTOR; - SYS_LOG_DBG("Reset vector address: %x", *reset_vector); + LOG_DBG("Reset vector address: %x", *reset_vector); shared_data->arc_start = *reset_vector; shared_data->flags = 0; if (!shared_data->arc_start) { /* Reset vector points to NULL => skip ARC init. */ - SYS_LOG_DBG("Reset vector is NULL, skipping ARC init."); + LOG_DBG("Reset vector is NULL, skipping ARC init."); goto skip_arc_init; } @@ -92,14 +92,14 @@ int _arc_init(struct device *arg) SCSS_REG_VAL(SCSS_SS_CFG) |= ARC_RUN_REQ_A; #endif - SYS_LOG_DBG("Waiting for arc to start..."); + LOG_DBG("Waiting for arc to start..."); /* Block until the ARC core actually starts up */ while (SCSS_REG_VAL(SCSS_SS_STS) & 0x4000) { } /* Block until ARC's quark_se_init() sets a flag indicating it is ready, * if we get stuck here ARC has run but has exploded very early */ - SYS_LOG_DBG("Waiting for arc to init..."); + LOG_DBG("Waiting for arc to init..."); while (!(shared_data->flags & ARC_READY)) { } diff --git a/soc/xtensa/intel_s1000/soc.c b/soc/xtensa/intel_s1000/soc.c index 8937a2c573cb..cebfa58d74c5 100644 --- a/soc/xtensa/intel_s1000/soc.c +++ b/soc/xtensa/intel_s1000/soc.c @@ -4,18 +4,18 @@ * SPDX-License-Identifier: Apache-2.0 */ -#define SYS_LOG_LEVEL SYS_LOG_LEVEL_INFO -#define SYS_LOG_DOMAIN "soc/s1000" - #include #include #include -#include #include #include #include #include +#define LOG_LEVEL CONFIG_SOC_LOG_LEVEL +#include +LOG_MODULE_REGISTER(soc); + static u32_t ref_clk_freq; void _soc_irq_enable(u32_t irq) @@ -42,7 +42,7 @@ void _soc_irq_enable(u32_t irq) } if (!dev_cavs) { - SYS_LOG_DBG("board: CAVS device binding failed\n"); + LOG_DBG("board: CAVS device binding failed"); return; } @@ -62,7 +62,7 @@ void _soc_irq_enable(u32_t irq) } if (!dev_ictl) { - SYS_LOG_DBG("board: DW intr_control device binding failed\n"); + LOG_DBG("board: DW intr_control device binding failed"); return; } @@ -101,7 +101,7 @@ void _soc_irq_disable(u32_t irq) } if (!dev_cavs) { - SYS_LOG_DBG("board: CAVS device binding failed\n"); + LOG_DBG("board: CAVS device binding failed"); return; } @@ -125,7 +125,7 @@ void _soc_irq_disable(u32_t irq) } if (!dev_ictl) { - SYS_LOG_DBG("board: DW intr_control device binding failed\n"); + LOG_DBG("board: DW intr_control device binding failed"); return; } @@ -221,7 +221,7 @@ static int soc_init(struct device *dev) soc_read_bootstraps(); ref_clk_freq = soc_get_ref_clk_freq(); - SYS_LOG_INF("Reference clock frequency: %u Hz", ref_clk_freq); + LOG_INF("Reference clock frequency: %u Hz", ref_clk_freq); soc_set_resource_ownership(); soc_set_power_and_clock(); From 5212e46b1f5076d80f01e2364564bdd6a4cfee35 Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Mon, 17 Sep 2018 11:50:51 -0500 Subject: [PATCH 04/43] kernel: move malloc handling to new logger Make this part of the kernel log domain, it is used by the kernel. Signed-off-by: Anas Nashif --- lib/libc/minimal/source/stdlib/malloc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/libc/minimal/source/stdlib/malloc.c b/lib/libc/minimal/source/stdlib/malloc.c index a8d63b71980f..da7412b83a54 100644 --- a/lib/libc/minimal/source/stdlib/malloc.c +++ b/lib/libc/minimal/source/stdlib/malloc.c @@ -10,7 +10,10 @@ #include #include #include -#include + +#define LOG_LEVEL CONFIG_KERNEL_LOG_LEVEL +#include +LOG_MODULE_DECLARE(os); #if (CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE > 0) K_MUTEX_DEFINE(malloc_mutex); @@ -47,7 +50,7 @@ void *malloc(size_t size) { ARG_UNUSED(size); - SYS_LOG_DBG("CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE is 0\n"); + LOG_DBG("CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE is 0"); errno = ENOMEM; return NULL; From 7cf7e873108d24c09848e357c18e3b7bf238579a Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Mon, 17 Sep 2018 11:52:05 -0500 Subject: [PATCH 05/43] drivers: entropy: remove unused logger kconfig This is not being used by any drivers, so removing until we need it. Signed-off-by: Anas Nashif --- drivers/entropy/Kconfig | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/drivers/entropy/Kconfig b/drivers/entropy/Kconfig index 4ea5b387dc03..36aa00b8f1ee 100644 --- a/drivers/entropy/Kconfig +++ b/drivers/entropy/Kconfig @@ -31,18 +31,4 @@ config ENTROPY_NAME help Specify the device name to be used for the ENTROPY driver. -config SYS_LOG_ENTROPY_LEVEL - int "Random Log level" - depends on SYS_LOG - default 0 - range 0 4 - help - Sets log level for entropy driver. - Levels are: - - 0 OFF: do not write - - 1 ERROR: only write SYS_LOG_ERR - - 2 WARNING: write SYS_LOG_WRN in addition to previous level - - 3 INFO: write SYS_LOG_INF in addition to previous levels - - 4 DEBUG: write SYS_LOG_DBG in addition to previous levels - endif From 54fc9299bca15a4fc9b17a9f65a4729536a96b11 Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Mon, 17 Sep 2018 12:00:47 -0500 Subject: [PATCH 06/43] drivers: adc: move to new logger Move to new logger subsystem. Signed-off-by: Anas Nashif --- drivers/adc/Kconfig | 23 +++-------------------- drivers/adc/adc_dw.c | 15 +++++++++------ drivers/adc/adc_intel_quark_d2000.c | 16 ++++++++-------- drivers/adc/adc_mcux_adc16.c | 23 ++++++++++++----------- drivers/adc/adc_nrfx_adc.c | 24 ++++++++++++------------ drivers/adc/adc_nrfx_saadc.c | 24 ++++++++++++------------ drivers/adc/adc_sam_afec.c | 24 ++++++++++++------------ drivers/adc/adc_ti_adc108s102.c | 15 ++++++++------- tests/drivers/adc/adc_api/prj_base.conf | 4 ++-- 9 files changed, 78 insertions(+), 90 deletions(-) diff --git a/drivers/adc/Kconfig b/drivers/adc/Kconfig index 241bc05b0d9c..98de617a19ac 100644 --- a/drivers/adc/Kconfig +++ b/drivers/adc/Kconfig @@ -31,26 +31,9 @@ config ADC_ASYNC help This option enables the asynchronous API calls. -config SYS_LOG_ADC_LEVEL - int "ADC drivers log level" - depends on SYS_LOG - default 0 - range 0 4 - help - - Sets log level for ADC driver. - - Levels are: - - - 0 OFF, do not write - - - 1 ERROR, only write SYS_LOG_ERR - - - 2 WARNING, write SYS_LOG_WRN in addition to previous level - - - 3 INFO, write SYS_LOG_INF in addition to previous levels - - - 4 DEBUG, write SYS_LOG_DBG in addition to previous levels +module = ADC +module-str = ADC +source "subsys/logging/Kconfig.template.log_config" config ADC_INIT_PRIORITY int "Init priority" diff --git a/drivers/adc/adc_dw.c b/drivers/adc/adc_dw.c index f2e321242846..99b2ce3f9fea 100644 --- a/drivers/adc/adc_dw.c +++ b/drivers/adc/adc_dw.c @@ -19,7 +19,10 @@ #define ADC_CONTEXT_USES_KERNEL_TIMER #include "adc_context.h" #include "adc_dw.h" -#include + +#define LOG_LEVEL CONFIG_ADC_LOG_LEVEL +#include +LOG_MODULE_REGISTER(adc_dw); #define ADC_CLOCK_GATE (1 << 31) #define ADC_DEEP_POWER_DOWN 0x01 @@ -231,27 +234,27 @@ static int adc_dw_channel_setup(struct device *dev, struct adc_info *info = dev->driver_data; if (channel_id >= DW_CHANNEL_COUNT) { - SYS_LOG_ERR("Invalid channel id"); + LOG_ERR("Invalid channel id"); return -EINVAL; } if (channel_cfg->gain != ADC_GAIN_1) { - SYS_LOG_ERR("Invalid channel gain"); + LOG_ERR("Invalid channel gain"); return -EINVAL; } if (channel_cfg->reference != ADC_REF_INTERNAL) { - SYS_LOG_ERR("Invalid channel reference"); + LOG_ERR("Invalid channel reference"); return -EINVAL; } if (channel_cfg->acquisition_time != ADC_ACQ_TIME_DEFAULT) { - SYS_LOG_ERR("Invalid channel acquisition time"); + LOG_ERR("Invalid channel acquisition time"); return -EINVAL; } if (info->state != ADC_STATE_IDLE) { - SYS_LOG_ERR("ADC is busy or in error state"); + LOG_ERR("ADC is busy or in error state"); return -EAGAIN; } diff --git a/drivers/adc/adc_intel_quark_d2000.c b/drivers/adc/adc_intel_quark_d2000.c index 88b2b31eb889..35e8b07414f7 100644 --- a/drivers/adc/adc_intel_quark_d2000.c +++ b/drivers/adc/adc_intel_quark_d2000.c @@ -14,9 +14,9 @@ #include #include -#define SYS_LOG_DOMAIN "dev/adc_quark_d2000" -#define SYS_LOG_LEVEL CONFIG_SYS_LOG_ADC_LEVEL -#include +#define LOG_LEVEL CONFIG_ADC_LOG_LEVEL +#include +LOG_MODULE_REGISTER(adc_intel_quark_d2000); #define ADC_CONTEXT_USES_KERNEL_TIMER #include "adc_context.h" @@ -201,27 +201,27 @@ static int adc_quark_d2000_channel_setup(struct device *dev, u8_t channel_id = channel_cfg->channel_id; if (channel_id > MAX_CHANNELS) { - SYS_LOG_ERR("Channel %d is not valid", channel_id); + LOG_ERR("Channel %d is not valid", channel_id); return -EINVAL; } if (channel_cfg->acquisition_time != ADC_ACQ_TIME_DEFAULT) { - SYS_LOG_ERR("Invalid channel acquisition time"); + LOG_ERR("Invalid channel acquisition time"); return -EINVAL; } if (channel_cfg->differential) { - SYS_LOG_ERR("Differential channels are not supported"); + LOG_ERR("Differential channels are not supported"); return -EINVAL; } if (channel_cfg->gain != ADC_GAIN_1) { - SYS_LOG_ERR("Invalid channel gain"); + LOG_ERR("Invalid channel gain"); return -EINVAL; } if (channel_cfg->reference != ADC_REF_INTERNAL) { - SYS_LOG_ERR("Invalid channel reference"); + LOG_ERR("Invalid channel reference"); return -EINVAL; } diff --git a/drivers/adc/adc_mcux_adc16.c b/drivers/adc/adc_mcux_adc16.c index 0d62499ef87b..77ec65ad660c 100644 --- a/drivers/adc/adc_mcux_adc16.c +++ b/drivers/adc/adc_mcux_adc16.c @@ -8,8 +8,9 @@ #include #include -#define SYS_LOG_LEVEL CONFIG_SYS_LOG_ADC_LEVEL -#include +#define LOG_LEVEL CONFIG_ADC_LOG_LEVEL +#include +LOG_MODULE_REGISTER(adc_mcux_adc16); #define ADC_CONTEXT_USES_KERNEL_TIMER #include "adc_context.h" @@ -34,27 +35,27 @@ static int mcux_adc16_channel_setup(struct device *dev, u8_t channel_id = channel_cfg->channel_id; if (channel_id > (ADC_SC1_ADCH_MASK >> ADC_SC1_ADCH_SHIFT)) { - SYS_LOG_ERR("Channel %d is not valid", channel_id); + LOG_ERR("Channel %d is not valid", channel_id); return -EINVAL; } if (channel_cfg->acquisition_time != ADC_ACQ_TIME_DEFAULT) { - SYS_LOG_ERR("Invalid channel acquisition time"); + LOG_ERR("Invalid channel acquisition time"); return -EINVAL; } if (channel_cfg->differential) { - SYS_LOG_ERR("Differential channels are not supported"); + LOG_ERR("Differential channels are not supported"); return -EINVAL; } if (channel_cfg->gain != ADC_GAIN_1) { - SYS_LOG_ERR("Invalid channel gain"); + LOG_ERR("Invalid channel gain"); return -EINVAL; } if (channel_cfg->reference != ADC_REF_INTERNAL) { - SYS_LOG_ERR("Invalid channel reference"); + LOG_ERR("Invalid channel reference"); return -EINVAL; } @@ -69,7 +70,7 @@ static int start_read(struct device *dev, const struct adc_sequence *sequence) int error; if (sequence->resolution != 12) { - SYS_LOG_ERR("Invalid resolution"); + LOG_ERR("Invalid resolution"); return -EINVAL; } @@ -90,7 +91,7 @@ static int start_read(struct device *dev, const struct adc_sequence *sequence) mode = kADC16_HardwareAverageCount32; break; default: - SYS_LOG_ERR("Invalid oversampling"); + LOG_ERR("Invalid oversampling"); return -EINVAL; } ADC16_SetHardwareAverage(config->base, mode); @@ -136,7 +137,7 @@ static void mcux_adc16_start_channel(struct device *dev) data->channel_id = find_lsb_set(data->channels) - 1; - SYS_LOG_DBG("Starting channel %d", data->channel_id); + LOG_DBG("Starting channel %d", data->channel_id); #if defined(FSL_FEATURE_ADC16_HAS_DIFF_MODE) && FSL_FEATURE_ADC16_HAS_DIFF_MODE channel_config.enableDifferentialConversion = false; @@ -177,7 +178,7 @@ static void mcux_adc16_isr(void *arg) u16_t result; result = ADC16_GetChannelConversionValue(base, channel_group); - SYS_LOG_DBG("Finished channel %d. Result is 0x%04x", + LOG_DBG("Finished channel %d. Result is 0x%04x", data->channel_id, result); *data->buffer++ = result; diff --git a/drivers/adc/adc_nrfx_adc.c b/drivers/adc/adc_nrfx_adc.c index 5fe4a19e5910..4224f42e1662 100644 --- a/drivers/adc/adc_nrfx_adc.c +++ b/drivers/adc/adc_nrfx_adc.c @@ -8,9 +8,9 @@ #include "adc_context.h" #include -#define SYS_LOG_DOMAIN "adc_nrfx_adc" -#define SYS_LOG_LEVEL CONFIG_SYS_LOG_ADC_LEVEL -#include +#define LOG_LEVEL CONFIG_ADC_LOG_LEVEL +#include +LOG_MODULE_REGISTER(adc_mcux_adc16); struct driver_data { struct adc_context ctx; @@ -40,12 +40,12 @@ static int adc_nrfx_channel_setup(struct device *dev, } if (channel_cfg->acquisition_time != ADC_ACQ_TIME_DEFAULT) { - SYS_LOG_ERR("Selected ADC acquisition time is not valid"); + LOG_ERR("Selected ADC acquisition time is not valid"); return -EINVAL; } if (channel_cfg->differential) { - SYS_LOG_ERR("Differential channels are not supported"); + LOG_ERR("Differential channels are not supported"); return -EINVAL; } @@ -60,7 +60,7 @@ static int adc_nrfx_channel_setup(struct device *dev, config->scaling = NRF_ADC_CONFIG_SCALING_INPUT_FULL_SCALE; break; default: - SYS_LOG_ERR("Selected ADC gain is not valid"); + LOG_ERR("Selected ADC gain is not valid"); return -EINVAL; } @@ -86,7 +86,7 @@ static int adc_nrfx_channel_setup(struct device *dev, config->extref = NRF_ADC_CONFIG_EXTREFSEL_AREF1; break; default: - SYS_LOG_ERR("Selected ADC reference is not valid"); + LOG_ERR("Selected ADC reference is not valid"); return -EINVAL; } @@ -126,7 +126,7 @@ static int check_buffer_size(const struct adc_sequence *sequence, } if (sequence->buffer_size < needed_buffer_size) { - SYS_LOG_ERR("Provided buffer is too small (%u/%u)", + LOG_ERR("Provided buffer is too small (%u/%u)", sequence->buffer_size, needed_buffer_size); return -ENOMEM; } @@ -148,12 +148,12 @@ static int start_read(struct device *dev, const struct adc_sequence *sequence) if (!selected_channels || (selected_channels & ~BIT_MASK(CONFIG_ADC_NRFX_ADC_CHANNEL_COUNT))) { - SYS_LOG_ERR("Invalid selection of channels"); + LOG_ERR("Invalid selection of channels"); return -EINVAL; } if (sequence->oversampling != 0) { - SYS_LOG_ERR("Oversampling is not supported"); + LOG_ERR("Oversampling is not supported"); return -EINVAL; } @@ -168,7 +168,7 @@ static int start_read(struct device *dev, const struct adc_sequence *sequence) nrf_resolution = NRF_ADC_CONFIG_RES_10BIT; break; default: - SYS_LOG_ERR("ADC resolution value %d is not valid", + LOG_ERR("ADC resolution value %d is not valid", sequence->resolution); return -EINVAL; } @@ -248,7 +248,7 @@ static int init_adc(struct device *dev) nrfx_err_t result = nrfx_adc_init(&config, event_handler); if (result != NRFX_SUCCESS) { - SYS_LOG_ERR("Failed to initialize device: %s", + LOG_ERR("Failed to initialize device: %s", dev->config->name); return -EBUSY; } diff --git a/drivers/adc/adc_nrfx_saadc.c b/drivers/adc/adc_nrfx_saadc.c index d751e96f7ffe..4f8db7b6b3b2 100644 --- a/drivers/adc/adc_nrfx_saadc.c +++ b/drivers/adc/adc_nrfx_saadc.c @@ -8,9 +8,9 @@ #include "adc_context.h" #include -#define SYS_LOG_DOMAIN "adc_nrfx_saadc" -#define SYS_LOG_LEVEL CONFIG_SYS_LOG_ADC_LEVEL -#include +#define LOG_LEVEL CONFIG_ADC_LOG_LEVEL +#include +LOG_MODULE_REGISTER(adc_nrfx_saadc); struct driver_data { struct adc_context ctx; @@ -66,7 +66,7 @@ static int adc_nrfx_channel_setup(struct device *dev, config.gain = NRF_SAADC_GAIN4; break; default: - SYS_LOG_ERR("Selected ADC gain is not valid"); + LOG_ERR("Selected ADC gain is not valid"); return -EINVAL; } @@ -78,7 +78,7 @@ static int adc_nrfx_channel_setup(struct device *dev, config.reference = NRF_SAADC_REFERENCE_VDD4; break; default: - SYS_LOG_ERR("Selected ADC reference is not valid"); + LOG_ERR("Selected ADC reference is not valid"); return -EINVAL; } @@ -103,7 +103,7 @@ static int adc_nrfx_channel_setup(struct device *dev, config.acq_time = NRF_SAADC_ACQTIME_40US; break; default: - SYS_LOG_ERR("Selected ADC acquisition time is not valid"); + LOG_ERR("Selected ADC acquisition time is not valid"); return -EINVAL; } @@ -168,7 +168,7 @@ static int set_resolution(const struct adc_sequence *sequence) nrf_resolution = NRF_SAADC_RESOLUTION_14BIT; break; default: - SYS_LOG_ERR("ADC resolution value %d is not valid", + LOG_ERR("ADC resolution value %d is not valid", sequence->resolution); return -EINVAL; } @@ -183,7 +183,7 @@ static int set_oversampling(const struct adc_sequence *sequence, nrf_saadc_oversample_t nrf_oversampling; if ((active_channels > 1) && (sequence->oversampling > 0)) { - SYS_LOG_ERR( + LOG_ERR( "Oversampling is supported for single channel only"); return -EINVAL; } @@ -217,7 +217,7 @@ static int set_oversampling(const struct adc_sequence *sequence, nrf_oversampling = NRF_SAADC_OVERSAMPLE_256X; break; default: - SYS_LOG_ERR("Oversampling value %d is not valid", + LOG_ERR("Oversampling value %d is not valid", sequence->oversampling); return -EINVAL; } @@ -237,7 +237,7 @@ static int check_buffer_size(const struct adc_sequence *sequence, } if (sequence->buffer_size < needed_buffer_size) { - SYS_LOG_ERR("Provided buffer is too small (%u/%u)", + LOG_ERR("Provided buffer is too small (%u/%u)", sequence->buffer_size, needed_buffer_size); return -ENOMEM; } @@ -257,7 +257,7 @@ static int start_read(struct device *dev, const struct adc_sequence *sequence) */ if (!selected_channels || (selected_channels & ~BIT_MASK(NRF_SAADC_CHANNEL_COUNT))) { - SYS_LOG_ERR("Invalid selection of channels"); + LOG_ERR("Invalid selection of channels"); return -EINVAL; } @@ -273,7 +273,7 @@ static int start_read(struct device *dev, const struct adc_sequence *sequence) * configured yet. */ if (m_data.positive_inputs[channel_id] == 0) { - SYS_LOG_ERR("Channel %u not configured", + LOG_ERR("Channel %u not configured", channel_id); return -EINVAL; } diff --git a/drivers/adc/adc_sam_afec.c b/drivers/adc/adc_sam_afec.c index d964b26eb5f1..89e812667005 100644 --- a/drivers/adc/adc_sam_afec.c +++ b/drivers/adc/adc_sam_afec.c @@ -23,9 +23,9 @@ #define ADC_CONTEXT_USES_KERNEL_TIMER #include "adc_context.h" -#define SYS_LOG_DOMAIN "dev/adc_sam_afec" -#define SYS_LOG_LEVEL CONFIG_SYS_LOG_ADC_LEVEL -#include +#define LOG_LEVEL CONFIG_ADC_LOG_LEVEL +#include +LOG_MODULE_REGISTER(adc_sam_afec); #define NUM_CHANNELS 12 @@ -88,22 +88,22 @@ static int adc_sam_channel_setup(struct device *dev, afec->AFEC_CGR |= (2 << (channel_id * 2)); break; default: - SYS_LOG_ERR("Selected ADC gain is not valid"); + LOG_ERR("Selected ADC gain is not valid"); return -EINVAL; } if (channel_cfg->acquisition_time != ADC_ACQ_TIME_DEFAULT) { - SYS_LOG_ERR("Selected ADC acquisition time is not valid"); + LOG_ERR("Selected ADC acquisition time is not valid"); return -EINVAL; } if (channel_cfg->reference != ADC_REF_EXTERNAL0) { - SYS_LOG_ERR("Selected reference is not valid"); + LOG_ERR("Selected reference is not valid"); return -EINVAL; } if (channel_cfg->differential) { - SYS_LOG_ERR("Differential input is not supported"); + LOG_ERR("Differential input is not supported"); return -EINVAL; } @@ -124,7 +124,7 @@ static void adc_sam_start_conversion(struct device *dev) data->channel_id = find_lsb_set(data->channels) - 1; - SYS_LOG_DBG("Starting channel %d", data->channel_id); + LOG_DBG("Starting channel %d", data->channel_id); /* Disable all channels. */ afec->AFEC_CHDR = 0xfff; @@ -174,7 +174,7 @@ static int check_buffer_size(const struct adc_sequence *sequence, needed_buffer_size *= (1 + sequence->options->extra_samplings); } if (sequence->buffer_size < needed_buffer_size) { - SYS_LOG_ERR("Provided buffer is too small (%u/%u)", + LOG_ERR("Provided buffer is too small (%u/%u)", sequence->buffer_size, needed_buffer_size); return -ENOMEM; } @@ -194,12 +194,12 @@ static int start_read(struct device *dev, const struct adc_sequence *sequence) */ if (channels == 0 || (channels & (~0UL << NUM_CHANNELS))) { - SYS_LOG_ERR("Invalid selection of channels"); + LOG_ERR("Invalid selection of channels"); return -EINVAL; } if (sequence->oversampling != 0) { - SYS_LOG_ERR("Oversampling is not supported"); + LOG_ERR("Oversampling is not supported"); return -EINVAL; } @@ -207,7 +207,7 @@ static int start_read(struct device *dev, const struct adc_sequence *sequence) /* TODO JKW: Support the Enhanced Resolution Mode 50.6.3 page * 1544. */ - SYS_LOG_ERR("ADC resolution value %d is not valid", + LOG_ERR("ADC resolution value %d is not valid", sequence->resolution); return -EINVAL; } diff --git a/drivers/adc/adc_ti_adc108s102.c b/drivers/adc/adc_ti_adc108s102.c index 4d483a1c0d3d..a0d857ff2002 100644 --- a/drivers/adc/adc_ti_adc108s102.c +++ b/drivers/adc/adc_ti_adc108s102.c @@ -10,12 +10,13 @@ #include #include -#define SYS_LOG_LEVEL CONFIG_SYS_LOG_ADC_LEVEL -#include #include #include #include "adc_ti_adc108s102.h" +#define LOG_LEVEL CONFIG_ADC_LOG_LEVEL +#include +LOG_MODULE_REGISTER(adc_ti_adc108s102); static inline int _ti_adc108s102_sampling(struct device *dev) { @@ -37,7 +38,7 @@ static inline int _ti_adc108s102_sampling(struct device *dev) .count = 1 }; - SYS_LOG_DBG("Sampling!"); + LOG_DBG("Sampling!"); return spi_transceive(adc->spi, &adc->spi_cfg, &tx, &rx); } @@ -50,7 +51,7 @@ static inline void _ti_adc108s102_handle_result(struct device *dev) struct adc_seq_entry *entry; u32_t s_i, i; - SYS_LOG_DBG("_ti_adc108s102_handle_result()"); + LOG_DBG("_ti_adc108s102_handle_result()"); for (i = 0, s_i = 1; i < seq_table->num_entries; i++, s_i++) { entry = &seq_table->entries[i]; @@ -87,7 +88,7 @@ static inline s32_t _ti_adc108s102_prepare(struct device *dev) continue; } - SYS_LOG_DBG("Requesting channel %d", entry->channel_id); + LOG_DBG("Requesting channel %d", entry->channel_id); adc->cmd_buffer[adc->cmd_buf_len] = ADC108S102_CHANNEL_CMD(entry->channel_id); @@ -105,7 +106,7 @@ static inline s32_t _ti_adc108s102_prepare(struct device *dev) adc->cmd_buffer[adc->cmd_buf_len] = 0; adc->cmd_buf_len++; - SYS_LOG_DBG("ADC108S102 is prepared..."); + LOG_DBG("ADC108S102 is prepared..."); return sampling_delay; } @@ -221,7 +222,7 @@ static int ti_adc108s102_init(struct device *dev) adc->spi_cfg.slave = CONFIG_ADC_TI_ADC108S102_SPI_SLAVE; - SYS_LOG_DBG("ADC108s102 initialized"); + LOG_DBG("ADC108s102 initialized"); dev->driver_api = &ti_adc108s102_api; diff --git a/tests/drivers/adc/adc_api/prj_base.conf b/tests/drivers/adc/adc_api/prj_base.conf index 17f655ec2edd..5ec8bec1945b 100644 --- a/tests/drivers/adc/adc_api/prj_base.conf +++ b/tests/drivers/adc/adc_api/prj_base.conf @@ -4,5 +4,5 @@ CONFIG_ADC=y CONFIG_ADC_ASYNC=y CONFIG_ADC_0=y -CONFIG_SYS_LOG=y -CONFIG_SYS_LOG_ADC_LEVEL=1 +CONFIG_LOG=y +CONFIG_ADC_LOG_LEVEL_INF=y From f63787aed93f73a526aa8e8ace3d7fb38f24c1ab Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Mon, 17 Sep 2018 12:06:26 -0500 Subject: [PATCH 07/43] drivers: audio: move to new logger Move to new logger subsystem. Signed-off-by: Anas Nashif --- drivers/audio/Kconfig | 15 +++-------- drivers/audio/tlv320dac310x.c | 48 +++++++++++++++++------------------ 2 files changed, 27 insertions(+), 36 deletions(-) diff --git a/drivers/audio/Kconfig b/drivers/audio/Kconfig index 46c7f33b6d4b..5de26185e420 100644 --- a/drivers/audio/Kconfig +++ b/drivers/audio/Kconfig @@ -28,18 +28,9 @@ config AUDIO_CODEC_INIT_PRIORITY help Audio codec device driver initialization priority. -config SYS_LOG_AUDIO_CODEC_LEVEL - int "Audio codec driver log level" - depends on SYS_LOG - default 0 - help - Sets log level for Audio codec drivers. - Levels are: - - 0 OFF, do not write - - 1 ERROR, only write SYS_LOG_ERR - - 2 WARNING, write SYS_LOG_WRN in addition to previous level - - 3 INFO, write SYS_LOG_INF in addition to previous levels - - 4 DEBUG, write SYS_LOG_DBG in addition to previous levels +module = AUDIO_CODEC +module-str = audio codec +source "subsys/logging/Kconfig.template.log_config" source "drivers/audio/Kconfig.tlv320dac" diff --git a/drivers/audio/tlv320dac310x.c b/drivers/audio/tlv320dac310x.c index eca4b23952b8..be62b93ffc19 100644 --- a/drivers/audio/tlv320dac310x.c +++ b/drivers/audio/tlv320dac310x.c @@ -6,10 +6,6 @@ #include -#define SYS_LOG_DOMAIN "dev/codec" -#define SYS_LOG_LEVEL CONFIG_SYS_LOG_AUDIO_CODEC_LEVEL -#include - #include #include @@ -18,6 +14,10 @@ #include