From 07094783e7898a7bc204ff4d8236e8d2bf5e012a Mon Sep 17 00:00:00 2001 From: Petri Pitkanen Date: Fri, 13 Dec 2024 10:02:03 +0200 Subject: [PATCH] silabs: drivers: bluetooth: Conditional compiling of optional components Conditionally compile in controller features based on what features have been enabled in Kconfig This commit allow saving in flash size. Over 10k in peripheral_hr and central_hr. In observer and broadcaster about 20k Signed-off-by: Petri Pitkanen --- drivers/bluetooth/hci/hci_silabs_efr32.c | 31 ++++++++++++++++++------ 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/drivers/bluetooth/hci/hci_silabs_efr32.c b/drivers/bluetooth/hci/hci_silabs_efr32.c index 49d69098db32f8..f148c8eadfa370 100644 --- a/drivers/bluetooth/hci/hci_silabs_efr32.c +++ b/drivers/bluetooth/hci/hci_silabs_efr32.c @@ -186,12 +186,25 @@ static int slz_bt_open(const struct device *dev, bt_hci_recv_t recv) goto deinit; } - sl_btctrl_init_adv(); - sl_btctrl_init_scan(); - sl_btctrl_init_conn(); + if (IS_ENABLED(CONFIG_BT_BROADCASTER) || IS_ENABLED(CONFIG_BT_PERIPHERAL)) { + sl_btctrl_init_adv(); + } + if (IS_ENABLED(CONFIG_BT_CENTRAL) || IS_ENABLED(CONFIG_BT_OBSERVER)) { + sl_btctrl_init_scan(); + } + if (IS_ENABLED(CONFIG_BT_CONN)) { + sl_btctrl_init_conn(); + } sl_btctrl_init_phy(); - sl_btctrl_init_adv_ext(); - sl_btctrl_init_scan_ext(); + + if (IS_ENABLED(CONFIG_BT_EXT_ADV)) { + if (IS_ENABLED(CONFIG_BT_BROADCASTER) || IS_ENABLED(CONFIG_BT_PERIPHERAL)) { + sl_btctrl_init_adv_ext(); + } + if (IS_ENABLED(CONFIG_BT_CENTRAL) || IS_ENABLED(CONFIG_BT_OBSERVER)) { + sl_btctrl_init_scan_ext(); + } + } ret = sl_btctrl_init_basic(SL_BT_CONFIG_MAX_CONNECTIONS, SL_BT_CONFIG_USER_ADVERTISERS, @@ -207,8 +220,12 @@ static int slz_bt_open(const struct device *dev, bt_hci_recv_t recv) sl_bthci_init_upper(); sl_btctrl_hci_parser_init_default(); - sl_btctrl_hci_parser_init_conn(); - sl_btctrl_hci_parser_init_adv(); + if (IS_ENABLED(CONFIG_BT_CONN)) { + sl_btctrl_hci_parser_init_conn(); + } + if (IS_ENABLED(CONFIG_BT_BROADCASTER) || IS_ENABLED(CONFIG_BT_PERIPHERAL)) { + sl_btctrl_hci_parser_init_adv(); + } sl_btctrl_hci_parser_init_phy(); #ifdef CONFIG_PM