Bluetooth: Refactor buffer HCI user data
To accommodate for ACL user data move the HCI command/event data into its own struct and put it inside a union in bt_buf. Change-Id: I680500b15709d14b1e9f70ced88664d607a6568c Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
0c397c6ca2
commit
5626788eb7
3 changed files with 19 additions and 10 deletions
|
@ -48,13 +48,19 @@ enum bt_buf_type {
|
|||
BT_ACL_IN, /* Incoming ACL data */
|
||||
};
|
||||
|
||||
/* HCI command specific info */
|
||||
struct bt_buf_hci_data {
|
||||
struct nano_sem *sync;
|
||||
uint16_t opcode;
|
||||
};
|
||||
|
||||
struct bt_buf {
|
||||
/* FIFO uses first 4 bytes itself, reserve space */
|
||||
int __unused;
|
||||
|
||||
/* HCI command specific info */
|
||||
struct nano_sem *sync;
|
||||
uint16_t opcode;
|
||||
union {
|
||||
struct bt_buf_hci_data hci;
|
||||
};
|
||||
|
||||
/* Type of data contained in the buffer */
|
||||
uint8_t type;
|
||||
|
|
|
@ -79,7 +79,7 @@ struct bt_buf *bt_buf_get(enum bt_buf_type type, size_t reserve_head)
|
|||
buf->type = type;
|
||||
buf->data = buf->buf + reserve_head;
|
||||
buf->len = 0;
|
||||
buf->sync = NULL;
|
||||
buf->hci.sync = NULL;
|
||||
|
||||
BT_DBG("buf %p reserve %u\n", buf, reserve_head);
|
||||
|
||||
|
|
|
@ -69,8 +69,8 @@ struct bt_buf *bt_hci_cmd_create(uint16_t opcode, uint8_t param_len)
|
|||
|
||||
BT_DBG("buf %p\n", buf);
|
||||
|
||||
buf->opcode = opcode;
|
||||
buf->sync = NULL;
|
||||
buf->hci.opcode = opcode;
|
||||
buf->hci.sync = NULL;
|
||||
|
||||
hdr = (void *)bt_buf_add(buf, sizeof(*hdr));
|
||||
hdr->opcode = sys_cpu_to_le16(opcode);
|
||||
|
@ -107,7 +107,7 @@ static int bt_hci_cmd_send_sync(uint16_t opcode, struct bt_buf *buf)
|
|||
BT_DBG("opcode %x len %u\n", opcode, buf->len);
|
||||
|
||||
nano_sem_init(&sync_sem);
|
||||
buf->sync = &sync_sem;
|
||||
buf->hci.sync = &sync_sem;
|
||||
|
||||
nano_fifo_put(&dev.cmd_queue, buf);
|
||||
|
||||
|
@ -265,7 +265,10 @@ static void hci_cmd_done(uint16_t opcode)
|
|||
{
|
||||
struct bt_buf *sent = dev.sent_cmd;
|
||||
|
||||
if (dev.sent_cmd->opcode != opcode) {
|
||||
if (!sent)
|
||||
return;
|
||||
|
||||
if (dev.sent_cmd->hci.opcode != opcode) {
|
||||
BT_ERR("Unexpected completion of opcode %x\n", opcode);
|
||||
return;
|
||||
}
|
||||
|
@ -273,8 +276,8 @@ static void hci_cmd_done(uint16_t opcode)
|
|||
dev.sent_cmd = NULL;
|
||||
|
||||
/* If the command was synchronous wake up bt_hci_cmd_send_sync() */
|
||||
if (sent->sync)
|
||||
nano_fiber_sem_give(sent->sync);
|
||||
if (sent->hci.sync)
|
||||
nano_fiber_sem_give(sent->hci.sync);
|
||||
|
||||
bt_buf_put(sent);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue