[PATCH 07/10] remove DEBUG for open source release

From: Mark P . Mendelsohn
Date: Fri Sep 23 2011 - 16:01:30 EST


---
drivers/bluetooth/hci_h5.c | 49 +++++++++++++++++++++++++++++++++++---------
1 files changed, 39 insertions(+), 10 deletions(-)

diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c
index a661ff3..7a40565 100644
--- a/drivers/bluetooth/hci_h5.c
+++ b/drivers/bluetooth/hci_h5.c
@@ -77,7 +77,6 @@ struct h5_struct {
H5_W4_PKT_START,
H5_W4_H5_HDR,
H5_W4_DATA,
- H5_W4_CRC1,
H5_W4_CRC
} rx_state;

@@ -197,8 +196,10 @@ static struct sk_buff *h5_prepare_pkt(struct h5_struct *h5, u8 *data,
u16 H5_CRC_INIT(h5_txmsg_crc);
int rel, i;

+#ifdef DEBUG
printk("%s pkt_type %d\n", __func__, pkt_type);
print_hex_dump_bytes("h5_prepare_pkt ", DUMP_PREFIX_NONE, data, len);
+#endif

switch (pkt_type) {
case HCI_ACLDATA_PKT:
@@ -376,12 +377,16 @@ static void h5_pkt_cull(struct h5_struct *h5)

pkts_to_be_removed = skb_queue_len(&h5->unack);

+#ifdef DEBUG
printk("%s: unack len %d\n", pkts_to_be_removed);
+#endif

seqno = h5->msgq_txseq;

while (pkts_to_be_removed) {
+#ifdef DEBUG
printk("ack %d seq %d\n", h5->rxack, seqno);
+#endif
if (h5->rxack == seqno)
break;

@@ -389,7 +394,9 @@ static void h5_pkt_cull(struct h5_struct *h5)
seqno = (seqno - 1) & 0x07;
}

+#ifdef DEBUG
printk("seqno now %d\n", seqno);
+#endif

if (h5->rxack != seqno)
BT_ERR("Peer acked invalid packet");
@@ -529,7 +536,7 @@ static void h5_complete_rx_pkt(struct hci_uart *hu)
h5->txack_req = 1;

/* If needed, transmit an ack pkt */
- hci_uart_tx_wakeup(hu);
+ // hci_uart_tx_wakeup(hu); // wait till end of buffer
}

h5->rxack = (h5->rx_skb->data[0] >> 3) & 0x07;
@@ -611,11 +618,17 @@ static int h5_recv(struct hci_uart *hu, void *data, int count)
ptr = data;

while (count) {
- // printk("while count %d rx_count %d\n", count, h5->rx_count);
+#ifdef DEBUG
+ printk("while count %d rx_count %d\n", count, h5->rx_count);
+#endif

if (h5->rx_count) {
if (*ptr == 0xc0) {
BT_ERR("Short H5 packet");
+#ifdef DEBUG
+ printk("Short H5 %02x count %d rx_count %d state %d\n",
+ *ptr, count, h5->rx_count, h5->rx_state);
+#endif
kfree_skb(h5->rx_skb);
h5->rx_state = H5_W4_PKT_START;
h5->rx_count = 0;
@@ -626,7 +639,9 @@ static int h5_recv(struct hci_uart *hu, void *data, int count)
continue;
}

- // printk("switch state %d\n", h5->rx_state);
+#ifdef DEBUG
+ printk("switch state %d\n", h5->rx_state);
+#endif

switch (h5->rx_state) {
case H5_W4_H5_HDR:
@@ -641,9 +656,11 @@ static int h5_recv(struct hci_uart *hu, void *data, int count)


if (h5->rx_skb->data[0] & 0x80) { /* reliable pkt */
+#ifdef DEBUG
printk("%0x != %0x ? %d\n", h5->rx_skb->data[0] & 0x07,
h5->rxseq_txack,
(h5->rx_skb->data[0] & 0x07) != h5->rxseq_txack);
+#endif

if ((h5->rx_skb->data[0] & 0x07) != h5->rxseq_txack) {
BT_ERR ("Out-of-order packet arrived, got %u expected %u",
@@ -672,11 +689,6 @@ static int h5_recv(struct hci_uart *hu, void *data, int count)

continue;

- case H5_W4_CRC1:
- h5->rx_state = H5_W4_CRC;
- count--;
- continue;
-
case H5_W4_CRC:
if (bitrev16(h5->message_crc) != h5_get_crc(h5)) {
BT_ERR ("Checksum failed: computed %04x received %04x",
@@ -689,6 +701,7 @@ static int h5_recv(struct hci_uart *hu, void *data, int count)
continue;
}
skb_trim(h5->rx_skb, h5->rx_skb->len - 2);
+
h5_complete_rx_pkt(hu);
h5->rx_state = H5_W4_PKT_DELIMITER;
count--;
@@ -699,8 +712,13 @@ static int h5_recv(struct hci_uart *hu, void *data, int count)
case 0xc0:
h5->rx_state = H5_W4_PKT_START;
break;
+
+ case 0x11:
+ // hci_uart_tx_wakeup(hu);
+ break;
+
default:
- /*BT_ERR("Ignoring byte %02x", *ptr);*/
+ BT_ERR("Ignoring byte %02x", *ptr);
break;
}
ptr++; count--;
@@ -712,6 +730,11 @@ static int h5_recv(struct hci_uart *hu, void *data, int count)
ptr++; count--;
break;

+ case 0x11:
+ // hci_uart_tx_wakeup(hu);
+ ptr++; count--;
+ break;
+
default:
h5->rx_state = H5_W4_H5_HDR;
h5->rx_count = 4;
@@ -735,6 +758,12 @@ static int h5_recv(struct hci_uart *hu, void *data, int count)
break;
}
}
+
+ if (h5->txack_req) {
+ /* If needed, transmit an ack pkt */
+ hci_uart_tx_wakeup(hu);
+ }
+
return count;
}

--
1.7.1