From 1bc6597d4d2b3bd145a537209fc3b1faa04cc47e Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Fri, 12 Feb 2016 14:57:53 +0200 Subject: [PATCH] Bluetooth: Take advantage of the new net_buf_pull_u8() helper Change-Id: I41ac2bc721b916f6d939f23be293750a83d21523 Signed-off-by: Johan Hedberg --- drivers/bluetooth/h4.c | 3 +-- drivers/bluetooth/h5.c | 6 +----- net/bluetooth/hci_core.c | 5 ++--- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/bluetooth/h4.c b/drivers/bluetooth/h4.c index 6dcd21468f3..6fbf7f2e740 100644 --- a/drivers/bluetooth/h4.c +++ b/drivers/bluetooth/h4.c @@ -209,8 +209,7 @@ static int h4_send(enum bt_buf_type buf_type, struct net_buf *buf) } while (buf->len) { - uart_poll_out(h4_dev, buf->data[0]); - net_buf_pull(buf, 1); + uart_poll_out(h4_dev, net_buf_pull_u8(buf)); } net_buf_unref(buf); diff --git a/drivers/bluetooth/h5.c b/drivers/bluetooth/h5.c index 4db70ea3be3..526e3eb753d 100644 --- a/drivers/bluetooth/h5.c +++ b/drivers/bluetooth/h5.c @@ -584,11 +584,7 @@ void bt_uart_isr(void *unused) static uint8_t h5_get_type(struct net_buf *buf) { - uint8_t type = UNALIGNED_GET((uint8_t *)buf->data); - - net_buf_pull(buf, sizeof(type)); - - return type; + return net_buf_pull_u8(buf); } static int h5_queue(enum bt_buf_type buf_type, struct net_buf *buf) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 3062e78073f..9795cdf8408 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -1390,13 +1390,12 @@ int bt_le_scan_update(bool fast_scan) static void le_adv_report(struct net_buf *buf) { - uint8_t num_reports = buf->data[0]; + uint8_t num_reports = net_buf_pull_u8(buf); struct bt_hci_ev_le_advertising_info *info; BT_DBG("Adv number of reports %u", num_reports); - info = net_buf_pull(buf, sizeof(num_reports)); - + info = (void *)buf->data; while (num_reports--) { int8_t rssi = info->data[info->length]; const bt_addr_le_t *addr;