From 496b02b54ac9afe89ece74a1da656ab9b08b5bd9 Mon Sep 17 00:00:00 2001 From: Carles Cufi Date: Thu, 15 Sep 2016 10:07:56 +0200 Subject: [PATCH] Bluetooth: Controller: Refactor HCI files As part of the effort to consolidate the BLE Controller's HCI layer, the following files have been renamed: * hci.h -> hci_internal.h: contains the HCI API to be used by the driver * main.c -> hci_driver.c: Implement bt_driver and includes initialization and glue code Jira: ZEP-726 Change-Id: Ica8b3e114da42a766a1b14ce59558cacd899a1a7 Signed-off-by: Carles Cufi --- drivers/bluetooth/controller/Makefile | 2 +- drivers/bluetooth/controller/hci/hci.c | 13 ++++++------- .../controller/{main.c => hci/hci_driver.c} | 17 ++++++++--------- .../controller/hci/{hci.h => hci_internal.h} | 14 +++++++------- 4 files changed, 22 insertions(+), 24 deletions(-) rename drivers/bluetooth/controller/{main.c => hci/hci_driver.c} (94%) rename drivers/bluetooth/controller/hci/{hci.h => hci_internal.h} (68%) diff --git a/drivers/bluetooth/controller/Makefile b/drivers/bluetooth/controller/Makefile index ee2570e7ee5..c422b3073d0 100644 --- a/drivers/bluetooth/controller/Makefile +++ b/drivers/bluetooth/controller/Makefile @@ -14,5 +14,5 @@ obj-$(CONFIG_BLUETOOTH_CONTROLLER) += hal/radio.o obj-$(CONFIG_BLUETOOTH_CONTROLLER) += ll/ticker.o obj-$(CONFIG_BLUETOOTH_CONTROLLER) += ll/ctrl.o obj-$(CONFIG_BLUETOOTH_CONTROLLER) += ll/ll.o +obj-$(CONFIG_BLUETOOTH_CONTROLLER) += hci/hci_driver.o obj-$(CONFIG_BLUETOOTH_CONTROLLER) += hci/hci.o -obj-$(CONFIG_BLUETOOTH_CONTROLLER) += main.o diff --git a/drivers/bluetooth/controller/hci/hci.c b/drivers/bluetooth/controller/hci/hci.c index 5c489c25d3a..1b34b3ab6db 100644 --- a/drivers/bluetooth/controller/hci/hci.c +++ b/drivers/bluetooth/controller/hci/hci.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "defines.h" #include "ticker.h" @@ -33,9 +34,7 @@ #include "pdu.h" #include "ctrl.h" #include "ll.h" - -#include -#include "hci.h" +#include "hci_internal.h" #include "debug.h" @@ -959,7 +958,7 @@ static void hci_data_handle(void) hci_context.rx_len = 0; } -void hci_handle(uint8_t x, uint8_t *len, uint8_t **out) +void hcic_handle(uint8_t x, uint8_t *len, uint8_t **out) { struct bt_hci_cmd_hdr *cmd; @@ -1378,7 +1377,7 @@ static void encode_data(uint8_t *buf, uint8_t *len, uint8_t **out) } -void hci_encode(uint8_t *buf, uint8_t *len, uint8_t **out) +void hcic_encode(uint8_t *buf, uint8_t *len, uint8_t **out) { struct radio_pdu_node_rx *radio_pdu_node_rx; struct pdu_data *pdu_data; @@ -1408,8 +1407,8 @@ void hci_encode(uint8_t *buf, uint8_t *len, uint8_t **out) } } -void hci_encode_num_cmplt(uint16_t handle, uint8_t num, uint8_t *len, - uint8_t **out) +void hcic_encode_num_cmplt(uint16_t handle, uint8_t num, uint8_t *len, + uint8_t **out) { struct bt_hci_evt_num_completed_packets *ep; struct bt_hci_handle_count *hc; diff --git a/drivers/bluetooth/controller/main.c b/drivers/bluetooth/controller/hci/hci_driver.c similarity index 94% rename from drivers/bluetooth/controller/main.c rename to drivers/bluetooth/controller/hci/hci_driver.c index ce02f8a6c1c..8d461f241e6 100644 --- a/drivers/bluetooth/controller/main.c +++ b/drivers/bluetooth/controller/hci/hci_driver.c @@ -42,7 +42,7 @@ #include "hal/radio.h" #include "ll/ticker.h" #include "ll/ctrl_internal.h" -#include "hci/hci.h" +#include "hci_internal.h" #include "hal/debug.h" @@ -224,7 +224,7 @@ static void native_recv_fiber(int unused0, int unused1) uint8_t *buf; int retval; - hci_encode_num_cmplt(handle, num_cmplt, &len, &buf); + hcic_encode_num_cmplt(handle, num_cmplt, &len, &buf); BT_ASSERT(len); retval = native_recv(len, buf); @@ -238,7 +238,7 @@ static void native_recv_fiber(int unused0, int unused1) uint8_t *buf; int retval; - hci_encode((uint8_t *)radio_pdu_node_rx, &len, &buf); + hcic_encode((uint8_t *)radio_pdu_node_rx, &len, &buf); /* Not all radio_rx_get are translated to HCI!, * hence just dequeue. @@ -267,7 +267,6 @@ static void native_recv_fiber(int unused0, int unused1) static int native_send(struct net_buf *buf) { - extern void hci_handle(uint8_t x, uint8_t *len, uint8_t **out); uint8_t type; uint8_t remaining; uint8_t *in; @@ -279,10 +278,10 @@ static int native_send(struct net_buf *buf) type = bt_buf_get_type(buf); switch (type) { case BT_BUF_ACL_OUT: - hci_handle(HCI_ACL, &remaining, &in); + hcic_handle(HCI_ACL, &remaining, &in); break; case BT_BUF_CMD: - hci_handle(HCI_CMD, &remaining, &in); + hcic_handle(HCI_CMD, &remaining, &in); break; default: BT_ERR("Unknown HCI type %u", type); @@ -296,7 +295,7 @@ static int native_send(struct net_buf *buf) if (buf->len) { while (buf->len - 1) { - hci_handle(net_buf_pull_u8(buf), &remaining, &in); + hcic_handle(net_buf_pull_u8(buf), &remaining, &in); } if (remaining) { @@ -304,9 +303,9 @@ static int native_send(struct net_buf *buf) return -EINVAL; } - hci_handle(net_buf_pull_u8(buf), &remaining, &in); + hcic_handle(net_buf_pull_u8(buf), &remaining, &in); - BT_DBG("hci_handle returned %u bytes", remaining); + BT_DBG("hcic_handle returned %u bytes", remaining); if (remaining) { int retval; diff --git a/drivers/bluetooth/controller/hci/hci.h b/drivers/bluetooth/controller/hci/hci_internal.h similarity index 68% rename from drivers/bluetooth/controller/hci/hci.h rename to drivers/bluetooth/controller/hci/hci_internal.h index e290085dab1..31d15e884e2 100644 --- a/drivers/bluetooth/controller/hci/hci.h +++ b/drivers/bluetooth/controller/hci/hci_internal.h @@ -15,12 +15,12 @@ * limitations under the License. */ -#ifndef _HCI_H_ -#define _HCI_H_ +#ifndef _HCI_CONTROLLER_H_ +#define _HCI_CONTROLLER_H_ -void hci_handle(uint8_t x, uint8_t *len, uint8_t **out); -void hci_encode(uint8_t *buf, uint8_t *len, uint8_t **out); -void hci_encode_num_cmplt(uint16_t instance, uint8_t num, uint8_t *len, - uint8_t **out); +void hcic_handle(uint8_t x, uint8_t *len, uint8_t **out); +void hcic_encode(uint8_t *buf, uint8_t *len, uint8_t **out); +void hcic_encode_num_cmplt(uint16_t instance, uint8_t num, uint8_t *len, + uint8_t **out); -#endif /* _HCI_H_ */ +#endif /* _HCI_CONTROLLER_H_ */