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 <johan.hedberg@intel.com>
This commit is contained in:
Johan Hedberg 2015-10-28 14:59:43 +02:00 committed by Anas Nashif
parent 7ff1cbd976
commit 1ddc3edcaa
3 changed files with 19 additions and 3 deletions

View file

@ -91,7 +91,7 @@ static struct net_buf *bt_uart_evt_recv(int *remaining)
*remaining = hdr.len; *remaining = hdr.len;
buf = bt_buf_get(BT_EVT, 0); buf = bt_buf_get_evt();
if (buf) { if (buf) {
memcpy(net_buf_add(buf, sizeof(hdr)), &hdr, sizeof(hdr)); memcpy(net_buf_add(buf, sizeof(hdr)), &hdr, sizeof(hdr));
} else { } 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 */ /* We can ignore the return value since we pass len == min */
bt_uart_read(BT_UART_DEV, (void *)&hdr, sizeof(hdr), sizeof(hdr)); 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) { if (buf) {
memcpy(net_buf_add(buf, sizeof(hdr)), &hdr, sizeof(hdr)); memcpy(net_buf_add(buf, sizeof(hdr)), &hdr, sizeof(hdr));
} else { } else {

View file

@ -20,7 +20,13 @@
#ifndef __BT_DRIVER_H #ifndef __BT_DRIVER_H
#define __BT_DRIVER_H #define __BT_DRIVER_H
#include <bluetooth/buf.h> #include <net/buf.h>
/* 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 */ /* Receive data from the controller/HCI driver */
void bt_recv(struct net_buf *buf); void bt_recv(struct net_buf *buf);

View file

@ -1706,3 +1706,13 @@ int bt_stop_scanning(void)
return bt_le_scan_update(); 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);
}