diff --git a/drivers/bluetooth/hci/h4.c b/drivers/bluetooth/hci/h4.c index 0a7293b62b9..b9e46cd6625 100644 --- a/drivers/bluetooth/hci/h4.c +++ b/drivers/bluetooth/hci/h4.c @@ -28,18 +28,14 @@ #include #include -#include +#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLUETOOTH_DEBUG_HCI_DRIVER) #include +#include #include #include #include "../util.h" -#if !defined(CONFIG_BLUETOOTH_DEBUG_HCI_DRIVER) -#undef BT_DBG -#define BT_DBG(fmt, ...) -#endif - #if defined(CONFIG_BLUETOOTH_NRF51_PM) #include "../nrf51_pm.h" #endif diff --git a/drivers/bluetooth/hci/h5.c b/drivers/bluetooth/hci/h5.c index 2b1ef83aa6b..293ff7bc2d9 100644 --- a/drivers/bluetooth/hci/h5.c +++ b/drivers/bluetooth/hci/h5.c @@ -30,18 +30,14 @@ #include #include -#include +#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLUETOOTH_DEBUG_HCI_DRIVER) #include +#include #include #include #include "../util.h" -#if !defined(CONFIG_BLUETOOTH_DEBUG_HCI_DRIVER) -#undef BT_DBG -#define BT_DBG(fmt, ...) -#endif - static BT_STACK_NOINIT(tx_stack, 256); static BT_STACK_NOINIT(rx_stack, 256); diff --git a/drivers/bluetooth/nble/conn.c b/drivers/bluetooth/nble/conn.c index 34a9eb10b74..9084a42ef46 100644 --- a/drivers/bluetooth/nble/conn.c +++ b/drivers/bluetooth/nble/conn.c @@ -19,21 +19,17 @@ #include #include +#define BT_DBG_ENABLED IS_ENABLED(CONFIG_NBLE_DEBUG_CONN) +#include #include #include #include -#include #include "gap_internal.h" #include "gatt_internal.h" #include "conn_internal.h" #include "smp.h" -#if !defined(CONFIG_NBLE_DEBUG_CONN) -#undef BT_DBG -#define BT_DBG(fmt, ...) -#endif - /* Peripheral timeout to initialize Connection Parameter Update procedure */ #define CONN_UPDATE_TIMEOUT K_SECONDS(5) diff --git a/drivers/bluetooth/nble/gap.c b/drivers/bluetooth/nble/gap.c index 9d667e16bbb..d59e8a3d269 100644 --- a/drivers/bluetooth/nble/gap.c +++ b/drivers/bluetooth/nble/gap.c @@ -20,11 +20,12 @@ #include #include +#define BT_DBG_ENABLED IS_ENABLED(CONFIG_NBLE_DEBUG_GAP) +#include #include #include #include #include -#include #include "gap_internal.h" #include "conn_internal.h" @@ -44,11 +45,6 @@ /* Set the firmware compatible with Nordic BLE RPC */ static const uint32_t compatible_firmware = NBLE_VERSION(4, 0, 31); -#if !defined(CONFIG_NBLE_DEBUG_GAP) -#undef BT_DBG -#define BT_DBG(fmt, ...) -#endif - static bt_ready_cb_t bt_ready_cb; static bt_le_scan_cb_t *scan_dev_found_cb; @@ -65,6 +61,11 @@ static const char *bt_addr_le_str(const bt_addr_le_t *addr) return str; } +#else +static inline const char *bt_addr_le_str(const bt_addr_le_t *addr) +{ + return NULL; +} #endif /* CONFIG_BLUETOOTH_DEBUG */ static void clear_bonds(const bt_addr_le_t *addr) diff --git a/drivers/bluetooth/nble/gatt.c b/drivers/bluetooth/nble/gatt.c index f3c8e8226f5..341aa0373e2 100644 --- a/drivers/bluetooth/nble/gatt.c +++ b/drivers/bluetooth/nble/gatt.c @@ -18,20 +18,16 @@ #include #include +#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLUETOOTH_DEBUG_GATT) +#include #include #include #include -#include #include "conn.h" #include "conn_internal.h" #include "gatt_internal.h" -#if !defined(CONFIG_BLUETOOTH_DEBUG_GATT) -#undef BT_DBG -#define BT_DBG(fmt, ...) -#endif - #define NBLE_BUF_SIZE 384 /* TODO: Get this value during negotiation */ diff --git a/drivers/bluetooth/nble/rpc_deserialize.c b/drivers/bluetooth/nble/rpc_deserialize.c index 690158e6228..6036ed53c62 100644 --- a/drivers/bluetooth/nble/rpc_deserialize.c +++ b/drivers/bluetooth/nble/rpc_deserialize.c @@ -18,10 +18,11 @@ #include #include +#define BT_DBG_ENABLED IS_ENABLED(CONFIG_NBLE_DEBUG_RPC) +#include #include /* for bt_security_t */ #include -#include #ifdef CONFIG_PRINTK #include @@ -36,11 +37,6 @@ #include "rpc_functions_to_quark.h" -#if !defined(CONFIG_NBLE_DEBUG_RPC) -#undef BT_DBG -#define BT_DBG(fmt, ...) -#endif - /* Build the list of prototypes and check that list are made only of matching * signatures */ @@ -217,6 +213,9 @@ static char *debug_func_s_p[] = { LIST_FN_SIG_S_P }; static char *debug_func_s_b_p[] = { LIST_FN_SIG_S_B_P }; static char *debug_func_s_b_b_p[] = { LIST_FN_SIG_S_B_B_P}; +#define DBG_FUNC(name) BT_DBG("%s", name) +#else +#define DBG_FUNC(name) #endif #undef FN_SIG_NONE @@ -587,49 +586,49 @@ void rpc_deserialize(struct net_buf *buf) switch (sig_type) { case SIG_TYPE_NONE: if (fn_index < ARRAY_SIZE(m_fct_none)) { - BT_DBG("%s", debug_func_none[fn_index]); + DBG_FUNC(debug_func_none[fn_index]); deserialize_none(fn_index, buf); } break; case SIG_TYPE_S: if (fn_index < ARRAY_SIZE(m_fct_s)) { - BT_DBG("%s", debug_func_s[fn_index]); + DBG_FUNC(debug_func_s[fn_index]); deserialize_s(fn_index, buf); } break; case SIG_TYPE_P: if (fn_index < ARRAY_SIZE(m_fct_p)) { - BT_DBG("%s", debug_func_p[fn_index]); + DBG_FUNC(debug_func_p[fn_index]); deserialize_p(fn_index, buf); } break; case SIG_TYPE_S_B: if (fn_index < ARRAY_SIZE(m_fct_s_b)) { - BT_DBG("%s", debug_func_s_b[fn_index]); + DBG_FUNC(debug_func_s_b[fn_index]); deserialize_s_b(fn_index, buf); } break; case SIG_TYPE_B_B_P: if (fn_index < ARRAY_SIZE(m_fct_b_b_p)) { - BT_DBG("%s", debug_func_b_b_p[fn_index]); + DBG_FUNC(debug_func_b_b_p[fn_index]); deserialize_b_b_p(fn_index, buf); } break; case SIG_TYPE_S_P: if (fn_index < ARRAY_SIZE(m_fct_s_p)) { - BT_DBG("%s", debug_func_s_p[fn_index]); + DBG_FUNC(debug_func_s_p[fn_index]); deserialize_s_p(fn_index, buf); } break; case SIG_TYPE_S_B_P: if (fn_index < ARRAY_SIZE(m_fct_s_b_p)) { - BT_DBG("%s", debug_func_s_b_p[fn_index]); + DBG_FUNC(debug_func_s_b_p[fn_index]); deserialize_s_b_p(fn_index, buf); } break; case SIG_TYPE_S_B_B_P: if (fn_index < ARRAY_SIZE(m_fct_s_b_b_p)) { - BT_DBG("%s", debug_func_s_b_b_p[fn_index]); + DBG_FUNC(debug_func_s_b_b_p[fn_index]); deserialize_s_b_b_p(fn_index, buf); } break; diff --git a/drivers/bluetooth/nble/smp.c b/drivers/bluetooth/nble/smp.c index b5a59676362..e7618d9bdbf 100644 --- a/drivers/bluetooth/nble/smp.c +++ b/drivers/bluetooth/nble/smp.c @@ -20,9 +20,10 @@ #include #include +#define BT_DBG_ENABLED IS_ENABLED(NBLE_DEBUG_GAP) +#include #include #include -#include #include diff --git a/drivers/bluetooth/nble/uart.c b/drivers/bluetooth/nble/uart.c index 291b04f1efd..ea3e8984b74 100644 --- a/drivers/bluetooth/nble/uart.c +++ b/drivers/bluetooth/nble/uart.c @@ -29,6 +29,7 @@ #include +#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLUETOOTH_DEBUG_HCI_DRIVER) #include #include "../util.h" @@ -38,11 +39,6 @@ #include "../nrf51_pm.h" #endif -#if !defined(CONFIG_BLUETOOTH_DEBUG_HCI_DRIVER) -#undef BT_DBG -#define BT_DBG(fmt, ...) -#endif - /** * @note this structure must be self-aligned and self-packed */ diff --git a/drivers/bluetooth/nrf51_pm.c b/drivers/bluetooth/nrf51_pm.c index a466b0ba970..82f3b29b846 100644 --- a/drivers/bluetooth/nrf51_pm.c +++ b/drivers/bluetooth/nrf51_pm.c @@ -20,6 +20,7 @@ #include #include +#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLUETOOTH_DEBUG_HCI_DRIVER) #include #include diff --git a/include/bluetooth/log.h b/include/bluetooth/log.h index 1e7b3fd01f9..3bf7f82b9d1 100644 --- a/include/bluetooth/log.h +++ b/include/bluetooth/log.h @@ -28,6 +28,10 @@ extern "C" { #endif +#if !defined(BT_DBG_ENABLED) +#define BT_DBG_ENABLED 1 +#endif + #if defined(CONFIG_BLUETOOTH_DEBUG_MONITOR) #include @@ -39,8 +43,12 @@ extern "C" { void bt_log(int prio, const char *fmt, ...); -#define BT_DBG(fmt, ...) bt_log(BT_LOG_DBG, "%s (%p): " fmt, \ - __func__, k_current_get(), ##__VA_ARGS__) +#define BT_DBG(fmt, ...) \ + if (BT_DBG_ENABLED) { \ + bt_log(BT_LOG_DBG, "%s (%p): " fmt, \ + __func__, k_current_get(), ##__VA_ARGS__); \ + } + #define BT_ERR(fmt, ...) bt_log(BT_LOG_ERR, "%s: " fmt, \ __func__, ##__VA_ARGS__) #define BT_WARN(fmt, ...) bt_log(BT_LOG_WARN, "%s: " fmt, \ @@ -56,8 +64,12 @@ void bt_log(int prio, const char *fmt, ...); #define SYS_LOG_LEVEL SYS_LOG_LEVEL_DEBUG #include -#define BT_DBG(fmt, ...) SYS_LOG_DBG("(%p) " fmt, k_current_get(), \ - ##__VA_ARGS__) +#define BT_DBG(fmt, ...) \ + if (BT_DBG_ENABLED) { \ + SYS_LOG_DBG("(%p) " fmt, k_current_get(), \ + ##__VA_ARGS__); \ + } + #define BT_ERR(fmt, ...) SYS_LOG_ERR(fmt, ##__VA_ARGS__) #define BT_WARN(fmt, ...) SYS_LOG_WRN(fmt, ##__VA_ARGS__) #define BT_INFO(fmt, ...) SYS_LOG_INF(fmt, ##__VA_ARGS__) @@ -67,10 +79,15 @@ void bt_log(int prio, const char *fmt, ...); #else -#define BT_DBG(fmt, ...) -#define BT_ERR(fmt, ...) -#define BT_WARN(fmt, ...) -#define BT_INFO(fmt, ...) +static inline __printf_like(1, 2) void _bt_log_dummy(const char *fmt, ...) {}; + +#define BT_DBG(fmt, ...) \ + if (0) { \ + _bt_log_dummy(fmt, ##__VA_ARGS__); \ + } +#define BT_ERR BT_DBG +#define BT_WARN BT_DBG +#define BT_INFO BT_DBG #define BT_STACK_DEBUG_EXTRA 0 @@ -88,11 +105,8 @@ void bt_log(int prio, const char *fmt, ...); char __noinit __stack name[(size) + K_THREAD_SIZEOF + \ BT_STACK_DEBUG_EXTRA] -#if defined(CONFIG_BLUETOOTH_DEBUG) +/* This helper is only available when BLUETOOTH_DEBUG is enabled */ const char *bt_hex(const void *buf, size_t len); -#else -#define bt_hex(buf, len) -#endif #ifdef __cplusplus } diff --git a/subsys/bluetooth/controller/hci/hci.c b/subsys/bluetooth/controller/hci/hci.c index 7e5b9c57d91..a268ab10fa3 100644 --- a/subsys/bluetooth/controller/hci/hci.c +++ b/subsys/bluetooth/controller/hci/hci.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "util.h" #include "mem.h" @@ -40,6 +41,7 @@ #include "ll.h" #include "hci_internal.h" +#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLUETOOTH_DEBUG_HCI_DRIVER) #include #include "debug.h" diff --git a/subsys/bluetooth/controller/hci/hci_driver.c b/subsys/bluetooth/controller/hci/hci_driver.c index 08249ffeb11..390fce4560f 100644 --- a/subsys/bluetooth/controller/hci/hci_driver.c +++ b/subsys/bluetooth/controller/hci/hci_driver.c @@ -29,8 +29,9 @@ #include #include -#include +#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLUETOOTH_DEBUG_HCI_DRIVER) #include +#include #include #include @@ -55,11 +56,6 @@ #include "hal/debug.h" -#if !defined(CONFIG_BLUETOOTH_DEBUG_HCI_DRIVER) -#undef BT_DBG -#define BT_DBG(fmt, ...) -#endif - #define HCI_CMD 0x01 #define HCI_ACL 0x02 #define HCI_SCO 0x03 diff --git a/subsys/bluetooth/controller/ll/ctrl.c b/subsys/bluetooth/controller/ll/ctrl.c index ce95a8a9d32..a1e2bcc8344 100644 --- a/subsys/bluetooth/controller/ll/ctrl.c +++ b/subsys/bluetooth/controller/ll/ctrl.c @@ -43,6 +43,7 @@ #include "config.h" +#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLUETOOTH_DEBUG_HCI_DRIVER) #include #include "debug.h" diff --git a/subsys/bluetooth/host/Kconfig b/subsys/bluetooth/host/Kconfig index d1916c15a46..e2cae1f738c 100644 --- a/subsys/bluetooth/host/Kconfig +++ b/subsys/bluetooth/host/Kconfig @@ -338,7 +338,6 @@ config BLUETOOTH_MONITOR_ON_DEV_NAME if BLUETOOTH_DEBUG config BLUETOOTH_DEBUG_HCI_CORE bool "Bluetooth HCI core debug" - depends on BLUETOOTH_HCI_HOST help This option enables debug support for Bluetooth HCI core. diff --git a/subsys/bluetooth/host/a2dp.c b/subsys/bluetooth/host/a2dp.c index 4d7091e983f..d8712179ebc 100644 --- a/subsys/bluetooth/host/a2dp.c +++ b/subsys/bluetooth/host/a2dp.c @@ -25,6 +25,8 @@ #include #include #include + +#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLUETOOTH_DEBUG_A2DP) #include #include #include @@ -35,11 +37,6 @@ #include "avdtp_internal.h" #include "a2dp_internal.h" -#if !defined(CONFIG_BLUETOOTH_DEBUG_A2DP) -#undef BT_DBG -#define BT_DBG(fmt, ...) -#endif - #define A2DP_NO_SPACE (-1) struct bt_a2dp { diff --git a/subsys/bluetooth/host/att.c b/subsys/bluetooth/host/att.c index 76f9bedf714..7d11d022fa6 100644 --- a/subsys/bluetooth/host/att.c +++ b/subsys/bluetooth/host/att.c @@ -24,6 +24,7 @@ #include #include +#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLUETOOTH_DEBUG_ATT) #include #include #include @@ -38,11 +39,6 @@ #include "att_internal.h" #include "gatt_internal.h" -#if !defined(CONFIG_BLUETOOTH_DEBUG_ATT) -#undef BT_DBG -#define BT_DBG(fmt, ...) -#endif - #define ATT_CHAN(_ch) CONTAINER_OF(_ch, struct bt_att, chan.chan) #define ATT_REQ(_node) CONTAINER_OF(_node, struct bt_att_req, node) diff --git a/subsys/bluetooth/host/avdtp.c b/subsys/bluetooth/host/avdtp.c index aea3fb8c849..baba659c15c 100644 --- a/subsys/bluetooth/host/avdtp.c +++ b/subsys/bluetooth/host/avdtp.c @@ -23,6 +23,7 @@ #include #include +#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLUETOOTH_DEBUG_AVDTP) #include #include #include @@ -32,11 +33,6 @@ #include "l2cap_internal.h" #include "avdtp_internal.h" -#if !defined(CONFIG_BLUETOOTH_DEBUG_AVDTP) -#undef BT_DBG -#define BT_DBG(fmt, ...) -#endif - /* TODO add config file*/ #define CONFIG_BLUETOOTH_AVDTP_CONN CONFIG_BLUETOOTH_MAX_CONN diff --git a/subsys/bluetooth/host/conn.c b/subsys/bluetooth/host/conn.c index 720cba456c1..70fc216a5e6 100644 --- a/subsys/bluetooth/host/conn.c +++ b/subsys/bluetooth/host/conn.c @@ -24,6 +24,7 @@ #include #include +#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLUETOOTH_DEBUG_CONN) #include #include #include @@ -38,11 +39,6 @@ #include "smp.h" #include "att_internal.h" -#if !defined(CONFIG_BLUETOOTH_DEBUG_CONN) -#undef BT_DBG -#define BT_DBG(fmt, ...) -#endif - NET_BUF_POOL_DEFINE(acl_tx_pool, CONFIG_BLUETOOTH_L2CAP_TX_BUF_COUNT, BT_L2CAP_BUF_SIZE(CONFIG_BLUETOOTH_L2CAP_TX_MTU), CONFIG_BLUETOOTH_L2CAP_TX_USER_DATA_SIZE, NULL); @@ -75,8 +71,7 @@ static const uint8_t ssp_method[4 /* remote */][4 /* local */] = { }; #endif /* CONFIG_BLUETOOTH_BREDR */ -#if defined(CONFIG_BLUETOOTH_DEBUG_CONN) -static const char *state2str(bt_conn_state_t state) +static inline const char *state2str(bt_conn_state_t state) { switch (state) { case BT_CONN_DISCONNECTED: @@ -93,7 +88,6 @@ static const char *state2str(bt_conn_state_t state) return "(unknown)"; } } -#endif static void notify_connected(struct bt_conn *conn) { diff --git a/subsys/bluetooth/host/gatt.c b/subsys/bluetooth/host/gatt.c index ae091403d4d..8b458136817 100644 --- a/subsys/bluetooth/host/gatt.c +++ b/subsys/bluetooth/host/gatt.c @@ -24,6 +24,7 @@ #include #include +#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLUETOOTH_DEBUG_GATT) #include #include #include @@ -39,11 +40,6 @@ #include "smp.h" #include "gatt_internal.h" -#if !defined(CONFIG_BLUETOOTH_DEBUG_GATT) -#undef BT_DBG -#define BT_DBG(fmt, ...) -#endif - static struct bt_gatt_attr *db; #if defined(CONFIG_BLUETOOTH_GATT_CLIENT) diff --git a/subsys/bluetooth/host/hci_core.c b/subsys/bluetooth/host/hci_core.c index 662bfb60211..db18cc61f1d 100644 --- a/subsys/bluetooth/host/hci_core.c +++ b/subsys/bluetooth/host/hci_core.c @@ -25,6 +25,7 @@ #include #include +#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLUETOOTH_DEBUG_HCI_CORE) #include #include #include @@ -44,11 +45,6 @@ #include "smp.h" #endif /* CONFIG_BLUETOOTH_CONN */ -#if !defined(CONFIG_BLUETOOTH_DEBUG_HCI_CORE) -#undef BT_DBG -#define BT_DBG(fmt, ...) -#endif - /* Peripheral timeout to initialize Connection Parameter Update procedure */ #define CONN_UPDATE_TIMEOUT K_SECONDS(5) #define RPA_TIMEOUT K_SECONDS(CONFIG_BLUETOOTH_RPA_TIMEOUT) diff --git a/subsys/bluetooth/host/hci_core.h b/subsys/bluetooth/host/hci_core.h index 4e54fa78f3d..66335938b91 100644 --- a/subsys/bluetooth/host/hci_core.h +++ b/subsys/bluetooth/host/hci_core.h @@ -152,10 +152,8 @@ int bt_hci_cmd_send_sync(uint16_t opcode, struct net_buf *buf, /* The helper is only safe to be called from internal threads as it's * not multi-threading safe */ -#if defined(CONFIG_BLUETOOTH_DEBUG) const char *bt_addr_str(const bt_addr_t *addr); const char *bt_addr_le_str(const bt_addr_le_t *addr); -#endif int bt_le_scan_update(bool fast_scan); diff --git a/subsys/bluetooth/host/hci_ecc.c b/subsys/bluetooth/host/hci_ecc.c index 6b04accd321..96807f2e7f1 100644 --- a/subsys/bluetooth/host/hci_ecc.c +++ b/subsys/bluetooth/host/hci_ecc.c @@ -27,11 +27,14 @@ #include #include #include + +#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLUETOOTH_DEBUG_HCI_CORE) +#include #include #include -#include #include #include + #include "hci_ecc.h" #ifdef CONFIG_BLUETOOTH_HCI_RAW #include @@ -40,11 +43,6 @@ #include "hci_core.h" #endif -#if !defined(CONFIG_BLUETOOTH_DEBUG_HCI_CORE) -#undef BT_DBG -#define BT_DBG(fmt, ...) -#endif - static BT_STACK_NOINIT(ecc_thread_stack, 1280); /* based on Core Specification 4.2 Vol 3. Part H 2.3.5.6.1 */ diff --git a/subsys/bluetooth/host/hci_raw.c b/subsys/bluetooth/host/hci_raw.c index 8c811739590..77ff0d6fe12 100644 --- a/subsys/bluetooth/host/hci_raw.c +++ b/subsys/bluetooth/host/hci_raw.c @@ -19,9 +19,10 @@ #include #include +#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLUETOOTH_DEBUG_HCI_CORE) +#include #include #include -#include #include "hci_ecc.h" #include "monitor.h" diff --git a/subsys/bluetooth/host/hfp_hf.c b/subsys/bluetooth/host/hfp_hf.c index e6df2311ea4..34fdc7facbb 100644 --- a/subsys/bluetooth/host/hfp_hf.c +++ b/subsys/bluetooth/host/hfp_hf.c @@ -22,6 +22,7 @@ #include #include +#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLUETOOTH_DEBUG_HFP_HF) #include #include #include @@ -32,11 +33,6 @@ #include "at.h" #include "hfp_internal.h" -#if !defined(CONFIG_BLUETOOTH_DEBUG_HFP_HF) -#undef BT_DBG -#define BT_DBG(fmt, ...) -#endif - #define MAX_IND_STR_LEN 17 struct bt_hfp_hf_cb *bt_hf; diff --git a/subsys/bluetooth/host/keys.c b/subsys/bluetooth/host/keys.c index 4de303cc2e5..5efb20e24fa 100644 --- a/subsys/bluetooth/host/keys.c +++ b/subsys/bluetooth/host/keys.c @@ -21,6 +21,7 @@ #include #include +#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLUETOOTH_DEBUG_KEYS) #include #include #include @@ -30,11 +31,6 @@ #include "smp.h" #include "keys.h" -#if !defined(CONFIG_BLUETOOTH_DEBUG_KEYS) -#undef BT_DBG -#define BT_DBG(fmt, ...) -#endif - static struct bt_keys key_pool[CONFIG_BLUETOOTH_MAX_PAIRED]; struct bt_keys *bt_keys_get_addr(const bt_addr_le_t *addr) diff --git a/subsys/bluetooth/host/keys_br.c b/subsys/bluetooth/host/keys_br.c index 45e2f167035..1740795c972 100644 --- a/subsys/bluetooth/host/keys_br.c +++ b/subsys/bluetooth/host/keys_br.c @@ -21,6 +21,7 @@ #include #include +#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLUETOOTH_DEBUG_KEYS) #include #include #include @@ -29,11 +30,6 @@ #include "hci_core.h" #include "keys.h" -#if !defined(CONFIG_BLUETOOTH_DEBUG_KEYS) -#undef BT_DBG -#define BT_DBG(fmt, ...) -#endif - static struct bt_keys_link_key key_pool[CONFIG_BLUETOOTH_MAX_PAIRED]; struct bt_keys_link_key *bt_keys_find_link_key(const bt_addr_t *addr) diff --git a/subsys/bluetooth/host/l2cap.c b/subsys/bluetooth/host/l2cap.c index dffbfbfbe91..080347f5553 100644 --- a/subsys/bluetooth/host/l2cap.c +++ b/subsys/bluetooth/host/l2cap.c @@ -23,6 +23,7 @@ #include #include +#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLUETOOTH_DEBUG_L2CAP) #include #include #include @@ -33,11 +34,6 @@ #include "conn_internal.h" #include "l2cap_internal.h" -#if !defined(CONFIG_BLUETOOTH_DEBUG_L2CAP) -#undef BT_DBG -#define BT_DBG(fmt, ...) -#endif - #define LE_CHAN_RTX(_w) CONTAINER_OF(_w, struct bt_l2cap_le_chan, chan.rtx_work) #define L2CAP_LE_MIN_MTU 23 diff --git a/subsys/bluetooth/host/l2cap_br.c b/subsys/bluetooth/host/l2cap_br.c index b8c311622bb..f1e55d10d4b 100644 --- a/subsys/bluetooth/host/l2cap_br.c +++ b/subsys/bluetooth/host/l2cap_br.c @@ -23,6 +23,7 @@ #include #include +#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLUETOOTH_DEBUG_L2CAP) #include #include #include @@ -39,11 +40,6 @@ #endif #include "sdp_internal.h" -#if !defined(CONFIG_BLUETOOTH_DEBUG_L2CAP) -#undef BT_DBG -#define BT_DBG(fmt, ...) -#endif - #define BR_CHAN(_ch) CONTAINER_OF(_ch, struct bt_l2cap_br_chan, chan) #define BR_CHAN_RTX(_w) CONTAINER_OF(_w, struct bt_l2cap_br_chan, chan.rtx_work) diff --git a/subsys/bluetooth/host/l2cap_internal.h b/subsys/bluetooth/host/l2cap_internal.h index dd7060fb597..25206603245 100644 --- a/subsys/bluetooth/host/l2cap_internal.h +++ b/subsys/bluetooth/host/l2cap_internal.h @@ -233,8 +233,9 @@ void bt_l2cap_chan_add(struct bt_conn *conn, struct bt_l2cap_chan *chan, /* Delete channel */ void bt_l2cap_chan_del(struct bt_l2cap_chan *chan); -#if defined(CONFIG_BLUETOOTH_DEBUG_L2CAP) const char *bt_l2cap_chan_state_str(bt_l2cap_chan_state_t state); + +#if defined(CONFIG_BLUETOOTH_DEBUG_L2CAP) void bt_l2cap_chan_set_state_debug(struct bt_l2cap_chan *chan, bt_l2cap_chan_state_t state, const char *func, int line); diff --git a/subsys/bluetooth/host/log.c b/subsys/bluetooth/host/log.c index 897251ddbf8..98d675ccab5 100644 --- a/subsys/bluetooth/host/log.c +++ b/subsys/bluetooth/host/log.c @@ -26,8 +26,6 @@ #include #include -#include - const char *bt_hex(const void *buf, size_t len) { static const char hex[] = "0123456789abcdef"; diff --git a/subsys/bluetooth/host/monitor.c b/subsys/bluetooth/host/monitor.c index 4b0e9c52899..9cc2adf5cf9 100644 --- a/subsys/bluetooth/host/monitor.c +++ b/subsys/bluetooth/host/monitor.c @@ -30,7 +30,6 @@ #include #include -#include #include "monitor.h" diff --git a/subsys/bluetooth/host/rfcomm.c b/subsys/bluetooth/host/rfcomm.c index c3ab965e46f..d179225c607 100644 --- a/subsys/bluetooth/host/rfcomm.c +++ b/subsys/bluetooth/host/rfcomm.c @@ -24,6 +24,7 @@ #include #include +#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLUETOOTH_DEBUG_RFCOMM) #include #include #include @@ -37,11 +38,6 @@ #include "l2cap_internal.h" #include "rfcomm_internal.h" -#if !defined(CONFIG_BLUETOOTH_DEBUG_RFCOMM) -#undef BT_DBG -#define BT_DBG(fmt, ...) -#endif - #define RFCOMM_CHANNEL_START 0x01 #define RFCOMM_CHANNEL_END 0x1e diff --git a/subsys/bluetooth/host/sdp.c b/subsys/bluetooth/host/sdp.c index 1f49410f272..d103c6aa50e 100644 --- a/subsys/bluetooth/host/sdp.c +++ b/subsys/bluetooth/host/sdp.c @@ -21,17 +21,13 @@ #include #include +#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLUETOOTH_DEBUG_SDP) #include #include #include "l2cap_internal.h" #include "sdp_internal.h" -#if !defined(CONFIG_BLUETOOTH_DEBUG_SDP) -#undef BT_DBG -#define BT_DBG(fmt, ...) -#endif - #define SDP_PSM 0x0001 #define SDP_CHAN(_ch) CONTAINER_OF(_ch, struct bt_sdp, chan.chan) diff --git a/subsys/bluetooth/host/smp.c b/subsys/bluetooth/host/smp.c index a3c73aaf497..01101694ee7 100644 --- a/subsys/bluetooth/host/smp.c +++ b/subsys/bluetooth/host/smp.c @@ -28,8 +28,9 @@ #include #include -#include +#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLUETOOTH_DEBUG_SMP) #include +#include #include #include #include @@ -47,11 +48,6 @@ #include "l2cap_internal.h" #include "smp.h" -#if !defined(CONFIG_BLUETOOTH_DEBUG_SMP) -#undef BT_DBG -#define BT_DBG(fmt, ...) -#endif - #define SMP_TIMEOUT K_SECONDS(30) #if defined(CONFIG_BLUETOOTH_SIGNING) diff --git a/subsys/bluetooth/host/smp_null.c b/subsys/bluetooth/host/smp_null.c index 9a791776bc2..44373b7314b 100644 --- a/subsys/bluetooth/host/smp_null.c +++ b/subsys/bluetooth/host/smp_null.c @@ -24,6 +24,7 @@ #include #include +#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLUETOOTH_DEBUG_HCI_CORE) #include #include #include diff --git a/subsys/bluetooth/host/storage.c b/subsys/bluetooth/host/storage.c index e694b159d60..e7bd7449030 100644 --- a/subsys/bluetooth/host/storage.c +++ b/subsys/bluetooth/host/storage.c @@ -22,6 +22,7 @@ #include #include +#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLUETOOTH_DEBUG_HCI_CORE) #include #include #include