Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 315697
b: refs/heads/master
c: c826ed0
h: refs/heads/master
i:
  315695: c3d259f
v: v3
  • Loading branch information
Johan Hedberg authored and Gustavo Padovan committed Jul 17, 2012
1 parent bceefde commit 85b0631
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 27 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 95c5c22097433711de93bc377af89918c6140f77
refs/heads/master: c826ed095d431c91f1d18f9b83b365569fcd977b
49 changes: 23 additions & 26 deletions trunk/drivers/bluetooth/hci_h5.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,14 +559,33 @@ static void h5_slip_one_byte(struct sk_buff *skb, u8 c)
}
}

static struct sk_buff *h5_build_pkt(struct hci_uart *hu, bool rel, u8 pkt_type,
const u8 *data, size_t len)
static bool valid_packet_type(u8 type)
{
switch (type) {
case HCI_ACLDATA_PKT:
case HCI_COMMAND_PKT:
case HCI_SCODATA_PKT:
case HCI_3WIRE_LINK_PKT:
case HCI_3WIRE_ACK_PKT:
return true;
default:
return false;
}
}

static struct sk_buff *h5_prepare_pkt(struct hci_uart *hu, u8 pkt_type,
const u8 *data, size_t len)
{
struct h5 *h5 = hu->priv;
struct sk_buff *nskb;
u8 hdr[4];
int i;

if (!valid_packet_type(pkt_type)) {
BT_ERR("Unknown packet type %u", pkt_type);
return NULL;
}

/*
* Max len of packet: (original len + 4 (H5 hdr) + 2 (crc)) * 2
* (because bytes 0xc0 and 0xdb are escaped, worst case is when
Expand All @@ -584,7 +603,8 @@ static struct sk_buff *h5_build_pkt(struct hci_uart *hu, bool rel, u8 pkt_type,
hdr[0] = h5->tx_ack << 3;
h5->tx_ack_req = false;

if (rel) {
/* Reliable packet? */
if (pkt_type == HCI_ACLDATA_PKT || pkt_type == HCI_COMMAND_PKT) {
hdr[0] |= 1 << 7;
hdr[0] |= h5->tx_seq;
h5->tx_seq = (h5->tx_seq + 1) % 8;
Expand All @@ -610,29 +630,6 @@ static struct sk_buff *h5_build_pkt(struct hci_uart *hu, bool rel, u8 pkt_type,
return nskb;
}

static struct sk_buff *h5_prepare_pkt(struct hci_uart *hu, u8 pkt_type,
const u8 *data, size_t len)
{
bool rel;

switch (pkt_type) {
case HCI_ACLDATA_PKT:
case HCI_COMMAND_PKT:
rel = true;
break;
case HCI_SCODATA_PKT:
case HCI_3WIRE_LINK_PKT:
case HCI_3WIRE_ACK_PKT:
rel = false;
break;
default:
BT_ERR("Unknown packet type %u", pkt_type);
return NULL;
}

return h5_build_pkt(hu, rel, pkt_type, data, len);
}

static struct sk_buff *h5_dequeue(struct hci_uart *hu)
{
struct h5 *h5 = hu->priv;
Expand Down

0 comments on commit 85b0631

Please sign in to comment.