aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/hci_core.c
diff options
context:
space:
mode:
authorAndrei Emeltchenko <andrei.emeltchenko@intel.com>2012-02-03 09:27:55 -0500
committerJohan Hedberg <johan.hedberg@intel.com>2012-02-13 10:01:33 -0500
commit63d2bc1b9a4d77f90b9719c3ff2570a274a7a22f (patch)
treef5dc74ff50c858b3177ed5613dd545fe4a9761f4 /net/bluetooth/hci_core.c
parentb71d385a18cd4516c62d0198c9ec37e658112f75 (diff)
Bluetooth: Helper removes duplicated code
Use __check_timout helper to remove duplicated code Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com> Reviewed-by: Ulisses Furquim <ulisses@profusion.mobi> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Diffstat (limited to 'net/bluetooth/hci_core.c')
-rw-r--r--net/bluetooth/hci_core.c31
1 files changed, 13 insertions, 18 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 9a56a4084482..95eeae59812d 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2390,22 +2390,25 @@ static inline int __get_blocks(struct hci_dev *hdev, struct sk_buff *skb)
2390 return DIV_ROUND_UP(skb->len - HCI_ACL_HDR_SIZE, hdev->block_len); 2390 return DIV_ROUND_UP(skb->len - HCI_ACL_HDR_SIZE, hdev->block_len);
2391} 2391}
2392 2392
2393static inline void hci_sched_acl_pkt(struct hci_dev *hdev) 2393static inline void __check_timeout(struct hci_dev *hdev, unsigned int cnt)
2394{ 2394{
2395 struct hci_chan *chan;
2396 struct sk_buff *skb;
2397 int quote;
2398 unsigned int cnt;
2399
2400 if (!test_bit(HCI_RAW, &hdev->flags)) { 2395 if (!test_bit(HCI_RAW, &hdev->flags)) {
2401 /* ACL tx timeout must be longer than maximum 2396 /* ACL tx timeout must be longer than maximum
2402 * link supervision timeout (40.9 seconds) */ 2397 * link supervision timeout (40.9 seconds) */
2403 if (!hdev->acl_cnt && time_after(jiffies, hdev->acl_last_tx + 2398 if (!cnt && time_after(jiffies, hdev->acl_last_tx +
2404 msecs_to_jiffies(HCI_ACL_TX_TIMEOUT))) 2399 msecs_to_jiffies(HCI_ACL_TX_TIMEOUT)))
2405 hci_link_tx_to(hdev, ACL_LINK); 2400 hci_link_tx_to(hdev, ACL_LINK);
2406 } 2401 }
2402}
2407 2403
2408 cnt = hdev->acl_cnt; 2404static inline void hci_sched_acl_pkt(struct hci_dev *hdev)
2405{
2406 unsigned int cnt = hdev->acl_cnt;
2407 struct hci_chan *chan;
2408 struct sk_buff *skb;
2409 int quote;
2410
2411 __check_timeout(hdev, cnt);
2409 2412
2410 while (hdev->acl_cnt && 2413 while (hdev->acl_cnt &&
2411 (chan = hci_chan_sent(hdev, ACL_LINK, &quote))) { 2414 (chan = hci_chan_sent(hdev, ACL_LINK, &quote))) {
@@ -2438,20 +2441,12 @@ static inline void hci_sched_acl_pkt(struct hci_dev *hdev)
2438 2441
2439static inline void hci_sched_acl_blk(struct hci_dev *hdev) 2442static inline void hci_sched_acl_blk(struct hci_dev *hdev)
2440{ 2443{
2444 unsigned int cnt = hdev->block_cnt;
2441 struct hci_chan *chan; 2445 struct hci_chan *chan;
2442 struct sk_buff *skb; 2446 struct sk_buff *skb;
2443 int quote; 2447 int quote;
2444 unsigned int cnt;
2445
2446 if (!test_bit(HCI_RAW, &hdev->flags)) {
2447 /* ACL tx timeout must be longer than maximum
2448 * link supervision timeout (40.9 seconds) */
2449 if (!hdev->block_cnt && time_after(jiffies, hdev->acl_last_tx +
2450 msecs_to_jiffies(HCI_ACL_TX_TIMEOUT)))
2451 hci_link_tx_to(hdev, ACL_LINK);
2452 }
2453 2448
2454 cnt = hdev->block_cnt; 2449 __check_timeout(hdev, cnt);
2455 2450
2456 while (hdev->block_cnt > 0 && 2451 while (hdev->block_cnt > 0 &&
2457 (chan = hci_chan_sent(hdev, ACL_LINK, &quote))) { 2452 (chan = hci_chan_sent(hdev, ACL_LINK, &quote))) {