aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2012-07-16 09:12:17 -0400
committerGustavo Padovan <gustavo.padovan@collabora.co.uk>2012-07-17 13:48:38 -0400
commitc826ed095d431c91f1d18f9b83b365569fcd977b (patch)
tree5bc202ccdb9efc042626ea262a443249477c8ed4
parent95c5c22097433711de93bc377af89918c6140f77 (diff)
Bluetooth: Remove unnecessary h5_build_pkt function
The implementation of h5_build_packet can be moved into h5_prepare_pkt since all h5_prepare_pkt does is determine whether the packet is reliable and then call h5_build_packet. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
-rw-r--r--drivers/bluetooth/hci_h5.c49
1 files changed, 23 insertions, 26 deletions
diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c
index 8819ce81ca56..f9067ce25568 100644
--- a/drivers/bluetooth/hci_h5.c
+++ b/drivers/bluetooth/hci_h5.c
@@ -559,14 +559,33 @@ static void h5_slip_one_byte(struct sk_buff *skb, u8 c)
559 } 559 }
560} 560}
561 561
562static struct sk_buff *h5_build_pkt(struct hci_uart *hu, bool rel, u8 pkt_type, 562static bool valid_packet_type(u8 type)
563 const u8 *data, size_t len) 563{
564 switch (type) {
565 case HCI_ACLDATA_PKT:
566 case HCI_COMMAND_PKT:
567 case HCI_SCODATA_PKT:
568 case HCI_3WIRE_LINK_PKT:
569 case HCI_3WIRE_ACK_PKT:
570 return true;
571 default:
572 return false;
573 }
574}
575
576static struct sk_buff *h5_prepare_pkt(struct hci_uart *hu, u8 pkt_type,
577 const u8 *data, size_t len)
564{ 578{
565 struct h5 *h5 = hu->priv; 579 struct h5 *h5 = hu->priv;
566 struct sk_buff *nskb; 580 struct sk_buff *nskb;
567 u8 hdr[4]; 581 u8 hdr[4];
568 int i; 582 int i;
569 583
584 if (!valid_packet_type(pkt_type)) {
585 BT_ERR("Unknown packet type %u", pkt_type);
586 return NULL;
587 }
588
570 /* 589 /*
571 * Max len of packet: (original len + 4 (H5 hdr) + 2 (crc)) * 2 590 * Max len of packet: (original len + 4 (H5 hdr) + 2 (crc)) * 2
572 * (because bytes 0xc0 and 0xdb are escaped, worst case is when 591 * (because bytes 0xc0 and 0xdb are escaped, worst case is when
@@ -584,7 +603,8 @@ static struct sk_buff *h5_build_pkt(struct hci_uart *hu, bool rel, u8 pkt_type,
584 hdr[0] = h5->tx_ack << 3; 603 hdr[0] = h5->tx_ack << 3;
585 h5->tx_ack_req = false; 604 h5->tx_ack_req = false;
586 605
587 if (rel) { 606 /* Reliable packet? */
607 if (pkt_type == HCI_ACLDATA_PKT || pkt_type == HCI_COMMAND_PKT) {
588 hdr[0] |= 1 << 7; 608 hdr[0] |= 1 << 7;
589 hdr[0] |= h5->tx_seq; 609 hdr[0] |= h5->tx_seq;
590 h5->tx_seq = (h5->tx_seq + 1) % 8; 610 h5->tx_seq = (h5->tx_seq + 1) % 8;
@@ -610,29 +630,6 @@ static struct sk_buff *h5_build_pkt(struct hci_uart *hu, bool rel, u8 pkt_type,
610 return nskb; 630 return nskb;
611} 631}
612 632
613static struct sk_buff *h5_prepare_pkt(struct hci_uart *hu, u8 pkt_type,
614 const u8 *data, size_t len)
615{
616 bool rel;
617
618 switch (pkt_type) {
619 case HCI_ACLDATA_PKT:
620 case HCI_COMMAND_PKT:
621 rel = true;
622 break;
623 case HCI_SCODATA_PKT:
624 case HCI_3WIRE_LINK_PKT:
625 case HCI_3WIRE_ACK_PKT:
626 rel = false;
627 break;
628 default:
629 BT_ERR("Unknown packet type %u", pkt_type);
630 return NULL;
631 }
632
633 return h5_build_pkt(hu, rel, pkt_type, data, len);
634}
635
636static struct sk_buff *h5_dequeue(struct hci_uart *hu) 633static struct sk_buff *h5_dequeue(struct hci_uart *hu)
637{ 634{
638 struct h5 *h5 = hu->priv; 635 struct h5 *h5 = hu->priv;