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>
This commit is contained in:
parent
b71d385a18
commit
63d2bc1b9a
@ -2390,22 +2390,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);
|
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)) {
|
if (!test_bit(HCI_RAW, &hdev->flags)) {
|
||||||
/* ACL tx timeout must be longer than maximum
|
/* ACL tx timeout must be longer than maximum
|
||||||
* link supervision timeout (40.9 seconds) */
|
* 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)))
|
msecs_to_jiffies(HCI_ACL_TX_TIMEOUT)))
|
||||||
hci_link_tx_to(hdev, ACL_LINK);
|
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 &&
|
while (hdev->acl_cnt &&
|
||||||
(chan = hci_chan_sent(hdev, ACL_LINK, "e))) {
|
(chan = hci_chan_sent(hdev, ACL_LINK, "e))) {
|
||||||
@ -2438,20 +2441,12 @@ static inline void hci_sched_acl_pkt(struct hci_dev *hdev)
|
|||||||
|
|
||||||
static inline void hci_sched_acl_blk(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 hci_chan *chan;
|
||||||
struct sk_buff *skb;
|
struct sk_buff *skb;
|
||||||
int quote;
|
int quote;
|
||||||
unsigned int cnt;
|
|
||||||
|
|
||||||
if (!test_bit(HCI_RAW, &hdev->flags)) {
|
__check_timeout(hdev, cnt);
|
||||||
/* 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;
|
|
||||||
|
|
||||||
while (hdev->block_cnt > 0 &&
|
while (hdev->block_cnt > 0 &&
|
||||||
(chan = hci_chan_sent(hdev, ACL_LINK, "e))) {
|
(chan = hci_chan_sent(hdev, ACL_LINK, "e))) {
|
||||||
|
Loading…
Reference in New Issue
Block a user