Thread (3 messages) 3 messages, 1 author, 2012-01-25

[RFCv1 2/2] Bluetooth: Helper removes duplicated code

From: Emeltchenko Andrei <hidden>
Date: 2012-01-09 08:59:54
Subsystem: bluetooth subsystem, the rest · Maintainers: Marcel Holtmann, Luiz Augusto von Dentz, Linus Torvalds

From: Andrei Emeltchenko <redacted>

Use __check_timout helper to remove duplicated code

Signed-off-by: Andrei Emeltchenko <redacted>
---
 net/bluetooth/hci_core.c |   31 +++++++++++++------------------
 1 files changed, 13 insertions(+), 18 deletions(-)
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index de10e86..aeed666 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2341,22 +2341,25 @@ static inline int __get_blocks(struct hci_dev *hdev, struct sk_buff *skb)
 	return DIV_ROUND_UP(skb->len - HCI_ACL_HDR_SIZE, hdev->block_len);
 }
 
-static inline void hci_sched_acl_pkt(struct hci_dev *hdev)
+static inline void __check_timeout(struct hci_dev *hdev, unsigned int cnt)
 {
-	struct hci_chan *chan;
-	struct sk_buff *skb;
-	int quote;
-	unsigned int cnt;
-
 	if (!test_bit(HCI_RAW, &hdev->flags)) {
 		/* ACL tx timeout must be longer than maximum
 		 * link supervision timeout (40.9 seconds) */
-		if (!hdev->acl_cnt && time_after(jiffies, hdev->acl_last_tx +
+		if (!cnt && time_after(jiffies, hdev->acl_last_tx +
 					msecs_to_jiffies(HCI_ACL_TX_TIMEOUT)))
 			hci_link_tx_to(hdev, ACL_LINK);
 	}
+}
 
-	cnt = hdev->acl_cnt;
+static inline void hci_sched_acl_pkt(struct hci_dev *hdev)
+{
+	unsigned int cnt = hdev->acl_cnt;
+	struct hci_chan *chan;
+	struct sk_buff *skb;
+	int quote;
+
+	__check_timeout(hdev, cnt);
 
 	while (hdev->acl_cnt &&
 			(chan = hci_chan_sent(hdev, ACL_LINK, &quote))) {
@@ -2389,20 +2392,12 @@ static inline void hci_sched_acl_pkt(struct hci_dev *hdev)
 
 static inline void hci_sched_acl_blk(struct hci_dev *hdev)
 {
+	unsigned int cnt = hdev->block_cnt;
 	struct hci_chan *chan;
 	struct sk_buff *skb;
 	int quote;
-	unsigned int cnt;
-
-	if (!test_bit(HCI_RAW, &hdev->flags)) {
-		/* ACL tx timeout must be longer than maximum
-		 * link supervision timeout (40.9 seconds) */
-		if (!hdev->block_cnt && time_after(jiffies, hdev->acl_last_tx +
-					msecs_to_jiffies(HCI_ACL_TX_TIMEOUT)))
-			hci_link_tx_to(hdev, ACL_LINK);
-	}
 
-	cnt = hdev->block_cnt;
+	__check_timeout(hdev, cnt);
 
 	while (hdev->block_cnt > 0 &&
 			(chan = hci_chan_sent(hdev, ACL_LINK, &quote))) {
-- 
1.7.4.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help