From 32ca01c5dbed397bddf683c456b3e16749d536ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E8=87=B4=E9=82=A6=20=28XIE=20Zhibang=29?= Date: Mon, 18 Nov 2024 11:24:58 +0800 Subject: [PATCH] esp_hosted_ng: Adapt CONFIG_BT MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 谢致邦 (XIE Zhibang) --- esp_hosted_ng/host/Makefile | 7 ++++++- esp_hosted_ng/host/main.c | 10 ++++++++++ esp_hosted_ng/host/sdio/esp_sdio.c | 4 ++++ esp_hosted_ng/host/spi/esp_spi.c | 6 ++++++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/esp_hosted_ng/host/Makefile b/esp_hosted_ng/host/Makefile index f171edecbd..90bcbe3d3a 100644 --- a/esp_hosted_ng/host/Makefile +++ b/esp_hosted_ng/host/Makefile @@ -53,7 +53,12 @@ ifeq ($(MODULE_NAME), esp32_spi) module_objects += spi/esp_spi.o endif -module_objects += esp_bt.o main.o esp_cmd.o esp_utils.o esp_cfg80211.o esp_stats.o esp_debugfs.o esp_log.o +ifneq ($(filter $(CONFIG_BT), y m), ) + EXTRA_CFLAGS += -DCONFIG_BT + module_objects += esp_bt.o +endif + +module_objects += main.o esp_cmd.o esp_utils.o esp_cfg80211.o esp_stats.o esp_debugfs.o esp_log.o #$(foreach obj,$(module_objects),$(eval CFLAGS_$(obj:.o=).o := $(debug_flags))) CFLAGS_esp_log.o = -DDEBUG diff --git a/esp_hosted_ng/host/main.c b/esp_hosted_ng/host/main.c index 82bbc7fac0..3827bef2d6 100644 --- a/esp_hosted_ng/host/main.c +++ b/esp_hosted_ng/host/main.c @@ -223,6 +223,7 @@ void print_capabilities(u32 cap) } } +#ifdef CONFIG_BT static void init_bt(struct esp_adapter *adapter) { @@ -233,6 +234,7 @@ static void init_bt(struct esp_adapter *adapter) esp_init_bt(adapter); } } +#endif static int check_esp_version(struct fw_version *ver) { @@ -349,7 +351,9 @@ static int process_event_esp_bootup(struct esp_adapter *adapter, u8 *evt_buf, u8 esp_err("network interface init failed\n"); return -1; } +#ifdef CONFIG_BT init_bt(adapter); +#endif if (raw_tp_mode !=0) { #if TEST_RAW_TP @@ -594,8 +598,10 @@ int esp_remove_card(struct esp_adapter *adapter) esp_stop_network_ifaces(adapter); esp_cfg_cleanup(adapter); +#ifdef CONFIG_BT /* BT may have been initialized after fw bootup event, deinit it */ esp_deinit_bt(adapter); +#endif if (adapter->if_rx_workqueue) { flush_workqueue(adapter->if_rx_workqueue); @@ -687,8 +693,10 @@ static void process_rx_packet(struct esp_adapter *adapter, struct sk_buff *skb) struct esp_payload_header *payload_header = NULL; u16 len = 0, offset = 0; u16 rx_checksum = 0, checksum = 0; +#ifdef CONFIG_BT struct hci_dev *hdev = adapter->hcidev; u8 *type = NULL; +#endif if (!skb) return; @@ -752,6 +760,7 @@ static void process_rx_packet(struct esp_adapter *adapter, struct sk_buff *skb) dev_kfree_skb_any(skb); } +#ifdef CONFIG_BT } else if (payload_header->if_type == ESP_HCI_IF) { if (hdev) { @@ -769,6 +778,7 @@ static void process_rx_packet(struct esp_adapter *adapter, struct sk_buff *skb) esp_hci_update_rx_counter(hdev, *type, skb->len); } } +#endif } else if (payload_header->if_type == ESP_INTERNAL_IF) { /* Queue event skb for processing in events workqueue */ diff --git a/esp_hosted_ng/host/sdio/esp_sdio.c b/esp_hosted_ng/host/sdio/esp_sdio.c index 4f9f49f8fc..bd8e8870a1 100644 --- a/esp_hosted_ng/host/sdio/esp_sdio.c +++ b/esp_hosted_ng/host/sdio/esp_sdio.c @@ -274,9 +274,11 @@ static void esp_remove(struct sdio_func *func) if (context->adapter) { esp_remove_card(context->adapter); +#ifdef CONFIG_BT if (context->adapter->hcidev) { esp_deinit_bt(context->adapter); } +#endif } @@ -502,8 +504,10 @@ static int write_packet(struct esp_adapter *adapter, struct sk_buff *skb) /* Notify to process queue */ if (payload_header->if_type == ESP_INTERNAL_IF) prio = PRIO_Q_HIGH; +#ifdef CONFIG_BT else if (payload_header->if_type == ESP_HCI_IF) prio = PRIO_Q_MID; +#endif else prio = PRIO_Q_LOW; diff --git a/esp_hosted_ng/host/spi/esp_spi.c b/esp_hosted_ng/host/spi/esp_spi.c index 1519788915..db0aaf2d57 100644 --- a/esp_hosted_ng/host/spi/esp_spi.c +++ b/esp_hosted_ng/host/spi/esp_spi.c @@ -146,8 +146,10 @@ static int write_packet(struct esp_adapter *adapter, struct sk_buff *skb) /* Enqueue SKB in tx_q */ if (payload_header->if_type == ESP_INTERNAL_IF) { skb_queue_tail(&spi_context.tx_q[PRIO_Q_HIGH], skb); +#ifdef CONFIG_BT } else if (payload_header->if_type == ESP_HCI_IF) { skb_queue_tail(&spi_context.tx_q[PRIO_Q_MID], skb); +#endif } else { skb_queue_tail(&spi_context.tx_q[PRIO_Q_LOW], skb); atomic_inc(&tx_pending); @@ -257,8 +259,10 @@ static int process_rx_buf(struct sk_buff *skb) /* enqueue skb for read_packet to pick it */ if (header->if_type == ESP_INTERNAL_IF) skb_queue_tail(&spi_context.rx_q[PRIO_Q_HIGH], skb); +#ifdef CONFIG_BT else if (header->if_type == ESP_HCI_IF) skb_queue_tail(&spi_context.rx_q[PRIO_Q_MID], skb); +#endif else skb_queue_tail(&spi_context.rx_q[PRIO_Q_LOW], skb); @@ -612,8 +616,10 @@ static void spi_exit(void) cleanup_spi_gpio(); +#ifdef CONFIG_BT if (spi_context.adapter && spi_context.adapter->hcidev) esp_deinit_bt(spi_context.adapter); +#endif spi_context.adapter->dev = NULL;