aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/bluetooth
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2012-07-16 09:12:19 -0400
committerGustavo Padovan <gustavo.padovan@collabora.co.uk>2012-07-17 13:49:24 -0400
commite0482103c22957b413db4c4ba35eca3b1e99751d (patch)
treeb94980ec5c9abcbdddfe09d187a935528da65991 /drivers/bluetooth
parentafdc944c1b9604fd0399d490e5bec5e632f731d0 (diff)
Bluetooth: Introduce a flags variable to Three-wire UART state
This patch introduces a flags variable to the Three-wire UART state struct and converts the two existing bools in the struct into flags. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Diffstat (limited to 'drivers/bluetooth')
-rw-r--r--drivers/bluetooth/hci_h5.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c
index 831ccfecc8a9..b6154d5a07a5 100644
--- a/drivers/bluetooth/hci_h5.c
+++ b/drivers/bluetooth/hci_h5.c
@@ -58,21 +58,27 @@
58#define SLIP_ESC_DELIM 0xdc 58#define SLIP_ESC_DELIM 0xdc
59#define SLIP_ESC_ESC 0xdd 59#define SLIP_ESC_ESC 0xdd
60 60
61/* H5 state flags */
62enum {
63 H5_RX_ESC, /* SLIP escape mode */
64 H5_TX_ACK_REQ, /* Pending ack to send */
65};
66
61struct h5 { 67struct h5 {
62 struct sk_buff_head unack; /* Unack'ed packets queue */ 68 struct sk_buff_head unack; /* Unack'ed packets queue */
63 struct sk_buff_head rel; /* Reliable packets queue */ 69 struct sk_buff_head rel; /* Reliable packets queue */
64 struct sk_buff_head unrel; /* Unreliable packets queue */ 70 struct sk_buff_head unrel; /* Unreliable packets queue */
65 71
72 unsigned long flags;
73
66 struct sk_buff *rx_skb; /* Receive buffer */ 74 struct sk_buff *rx_skb; /* Receive buffer */
67 size_t rx_pending; /* Expecting more bytes */ 75 size_t rx_pending; /* Expecting more bytes */
68 bool rx_esc; /* SLIP escape mode */
69 u8 rx_ack; /* Last ack number received */ 76 u8 rx_ack; /* Last ack number received */
70 77
71 int (*rx_func) (struct hci_uart *hu, u8 c); 78 int (*rx_func) (struct hci_uart *hu, u8 c);
72 79
73 struct timer_list timer; /* Retransmission timer */ 80 struct timer_list timer; /* Retransmission timer */
74 81
75 bool tx_ack_req; /* Pending ack to send */
76 u8 tx_seq; /* Next seq number to send */ 82 u8 tx_seq; /* Next seq number to send */
77 u8 tx_ack; /* Next ack number to send */ 83 u8 tx_ack; /* Next ack number to send */
78 u8 tx_win; /* Sliding window size */ 84 u8 tx_win; /* Sliding window size */
@@ -317,7 +323,7 @@ static void h5_complete_rx_pkt(struct hci_uart *hu)
317 323
318 if (H5_HDR_RELIABLE(hdr)) { 324 if (H5_HDR_RELIABLE(hdr)) {
319 h5->tx_ack = (h5->tx_ack + 1) % 8; 325 h5->tx_ack = (h5->tx_ack + 1) % 8;
320 h5->tx_ack_req = true; 326 set_bit(H5_TX_ACK_REQ, &h5->flags);
321 hci_uart_tx_wakeup(hu); 327 hci_uart_tx_wakeup(hu);
322 } 328 }
323 329
@@ -445,12 +451,12 @@ static void h5_unslip_one_byte(struct h5 *h5, unsigned char c)
445 const u8 delim = SLIP_DELIMITER, esc = SLIP_ESC; 451 const u8 delim = SLIP_DELIMITER, esc = SLIP_ESC;
446 const u8 *byte = &c; 452 const u8 *byte = &c;
447 453
448 if (!h5->rx_esc && c == SLIP_ESC) { 454 if (!test_bit(H5_RX_ESC, &h5->flags) && c == SLIP_ESC) {
449 h5->rx_esc = true; 455 set_bit(H5_RX_ESC, &h5->flags);
450 return; 456 return;
451 } 457 }
452 458
453 if (h5->rx_esc) { 459 if (test_and_clear_bit(H5_RX_ESC, &h5->flags)) {
454 switch (c) { 460 switch (c) {
455 case SLIP_ESC_DELIM: 461 case SLIP_ESC_DELIM:
456 byte = &delim; 462 byte = &delim;
@@ -463,8 +469,6 @@ static void h5_unslip_one_byte(struct h5 *h5, unsigned char c)
463 h5_reset_rx(h5); 469 h5_reset_rx(h5);
464 return; 470 return;
465 } 471 }
466
467 h5->rx_esc = false;
468 } 472 }
469 473
470 memcpy(skb_put(h5->rx_skb, 1), byte, 1); 474 memcpy(skb_put(h5->rx_skb, 1), byte, 1);
@@ -482,7 +486,7 @@ static void h5_reset_rx(struct h5 *h5)
482 486
483 h5->rx_func = h5_rx_delimiter; 487 h5->rx_func = h5_rx_delimiter;
484 h5->rx_pending = 0; 488 h5->rx_pending = 0;
485 h5->rx_esc = false; 489 clear_bit(H5_RX_ESC, &h5->flags);
486} 490}
487 491
488static int h5_recv(struct hci_uart *hu, void *data, int count) 492static int h5_recv(struct hci_uart *hu, void *data, int count)
@@ -621,7 +625,7 @@ static struct sk_buff *h5_prepare_pkt(struct hci_uart *hu, u8 pkt_type,
621 h5_slip_delim(nskb); 625 h5_slip_delim(nskb);
622 626
623 hdr[0] = h5->tx_ack << 3; 627 hdr[0] = h5->tx_ack << 3;
624 h5->tx_ack_req = false; 628 clear_bit(H5_TX_ACK_REQ, &h5->flags);
625 629
626 /* Reliable packet? */ 630 /* Reliable packet? */
627 if (pkt_type == HCI_ACLDATA_PKT || pkt_type == HCI_COMMAND_PKT) { 631 if (pkt_type == HCI_ACLDATA_PKT || pkt_type == HCI_COMMAND_PKT) {
@@ -703,7 +707,7 @@ static struct sk_buff *h5_dequeue(struct hci_uart *hu)
703unlock: 707unlock:
704 spin_unlock_irqrestore(&h5->unack.lock, flags); 708 spin_unlock_irqrestore(&h5->unack.lock, flags);
705 709
706 if (h5->tx_ack_req) 710 if (test_bit(H5_TX_ACK_REQ, &h5->flags))
707 return h5_prepare_pkt(hu, HCI_3WIRE_ACK_PKT, NULL, 0); 711 return h5_prepare_pkt(hu, HCI_3WIRE_ACK_PKT, NULL, 0);
708 712
709 return NULL; 713 return NULL;