From 1ddc3edcaaa90884131b8cffd7656c41a22b51fe Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 28 Oct 2015 14:59:43 +0200 Subject: [PATCH] Bluetooth: Introduce HCI-driver specific buffer functions This way we avoid dealing with the specific buffer type value and to make it clear that these are for drivers onle. Change-Id: I8aef7ec6a767b2fa68cbe374eb371e2a6192f675 Signed-off-by: Johan Hedberg --- drivers/bluetooth/uart.c | 4 ++-- include/bluetooth/driver.h | 8 +++++++- net/bluetooth/hci_core.c | 10 ++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/drivers/bluetooth/uart.c b/drivers/bluetooth/uart.c index 5c3044855c2..425e10732dd 100644 --- a/drivers/bluetooth/uart.c +++ b/drivers/bluetooth/uart.c @@ -91,7 +91,7 @@ static struct net_buf *bt_uart_evt_recv(int *remaining) *remaining = hdr.len; - buf = bt_buf_get(BT_EVT, 0); + buf = bt_buf_get_evt(); if (buf) { memcpy(net_buf_add(buf, sizeof(hdr)), &hdr, sizeof(hdr)); } else { @@ -111,7 +111,7 @@ static struct net_buf *bt_uart_acl_recv(int *remaining) /* We can ignore the return value since we pass len == min */ bt_uart_read(BT_UART_DEV, (void *)&hdr, sizeof(hdr), sizeof(hdr)); - buf = bt_buf_get(BT_ACL_IN, 0); + buf = bt_buf_get_acl(); if (buf) { memcpy(net_buf_add(buf, sizeof(hdr)), &hdr, sizeof(hdr)); } else { diff --git a/include/bluetooth/driver.h b/include/bluetooth/driver.h index e4443e2adaf..8143a0a764e 100644 --- a/include/bluetooth/driver.h +++ b/include/bluetooth/driver.h @@ -20,7 +20,13 @@ #ifndef __BT_DRIVER_H #define __BT_DRIVER_H -#include +#include + +/* Allocate a buffer for an HCI event */ +struct net_buf *bt_buf_get_evt(void); + +/* Allocate a buffer for incoming ACL data */ +struct net_buf *bt_buf_get_acl(void); /* Receive data from the controller/HCI driver */ void bt_recv(struct net_buf *buf); diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index efa4f3b00f6..70745791acc 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -1706,3 +1706,13 @@ int bt_stop_scanning(void) return bt_le_scan_update(); } + +struct net_buf *bt_buf_get_evt(void) +{ + return bt_buf_get(BT_EVT, 0); +} + +struct net_buf *bt_buf_get_acl(void) +{ + return bt_buf_get(BT_ACL_IN, 0); +}