drivers: bluetooth: Fix direct references to HZ
* Make the various timeout values HZ agnostic by using the proper
macros and values instead.
Change-Id: Id71e1847e5a3ae5444394f69bd28925a94436407
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c
index 4104b7f..1e2b7cd 100644
--- a/drivers/bluetooth/bluecard_cs.c
+++ b/drivers/bluetooth/bluecard_cs.c
@@ -39,6 +39,8 @@
#include <linux/skbuff.h>
#include <linux/io.h>
+#include <linux/jiffies.h>
+
#include <pcmcia/cistpl.h>
#include <pcmcia/ciscode.h>
#include <pcmcia/ds.h>
@@ -47,8 +49,6 @@
#include <net/bluetooth/bluetooth.h>
#include <net/bluetooth/hci_core.h>
-
-
/* ======================== Module parameters ======================== */
@@ -184,14 +184,14 @@
/* Enable activity LED */
outb(0x10 | 0x40, iobase + 0x30);
- /* Stop the LED after HZ/4 */
- mod_timer(&(info->timer), jiffies + HZ / 4);
+ /* Stop the LED after 250 ms */
+ mod_timer(&(info->timer), jiffies + msecs_to_jiffies(250));
} else {
/* Enable power LED */
outb(0x08 | 0x20, iobase + 0x30);
- /* Stop the LED after HZ/2 */
- mod_timer(&(info->timer), jiffies + HZ / 2);
+ /* Stop the LED after 500 ms */
+ mod_timer(&(info->timer), jiffies + msecs_to_jiffies(500));
}
}
@@ -303,7 +303,7 @@
/* Wait until the command reaches the baseband */
prepare_to_wait(&wq, &wait, TASK_INTERRUPTIBLE);
- schedule_timeout(HZ/10);
+ schedule_timeout(msecs_to_jiffies(100));
finish_wait(&wq, &wait);
/* Set baud on baseband */
@@ -317,7 +317,7 @@
/* Wait before the next HCI packet can be send */
prepare_to_wait(&wq, &wait, TASK_INTERRUPTIBLE);
- schedule_timeout(HZ);
+ schedule_timeout(msecs_to_jiffies(1000));
finish_wait(&wq, &wait);
}
diff --git a/drivers/bluetooth/bluesleep.c b/drivers/bluetooth/bluesleep.c
index 6dc9862..93c96ad 100644
--- a/drivers/bluetooth/bluesleep.c
+++ b/drivers/bluetooth/bluesleep.c
@@ -50,6 +50,7 @@
#include <net/bluetooth/bluetooth.h>
#include <net/bluetooth/hci_core.h> /* event notifications */
#include "hci_uart.h"
+#include <linux/jiffies.h>
#define BT_SLEEP_DBG
#ifndef BT_SLEEP_DBG
@@ -159,7 +160,8 @@
if (test_bit(BT_ASLEEP, &flags)) {
BT_DBG("waking up...");
/* Start the timer */
- mod_timer(&tx_timer, jiffies + (TX_TIMER_INTERVAL * HZ));
+ mod_timer(&tx_timer,
+ jiffies + msecs_to_jiffies(TX_TIMER_INTERVAL * 1000));
gpio_set_value(bsi->ext_wake, 0);
clear_bit(BT_ASLEEP, &flags);
/*Activating UART */
@@ -187,7 +189,8 @@
hsuart_power(0);
} else {
- mod_timer(&tx_timer, jiffies + (TX_TIMER_INTERVAL * HZ));
+ mod_timer(&tx_timer,
+ jiffies + msecs_to_jiffies(TX_TIMER_INTERVAL * 1000));
return;
}
} else {
@@ -294,7 +297,8 @@
bluesleep_tx_idle();
} else {
BT_DBG("Tx data during last period");
- mod_timer(&tx_timer, jiffies + (TX_TIMER_INTERVAL*HZ));
+ mod_timer(&tx_timer,
+ jiffies + msecs_to_jiffies(TX_TIMER_INTERVAL * 1000));
}
/* clear the incoming data flag */
@@ -342,7 +346,8 @@
/* start the timer */
- mod_timer(&tx_timer, jiffies + (TX_TIMER_INTERVAL*HZ));
+ mod_timer(&tx_timer,
+ jiffies + msecs_to_jiffies(TX_TIMER_INTERVAL * 1000));
/* assert BT_WAKE */
gpio_set_value(bsi->ext_wake, 0);
diff --git a/drivers/bluetooth/hci_ath.c b/drivers/bluetooth/hci_ath.c
index 8272528..487883a 100644
--- a/drivers/bluetooth/hci_ath.c
+++ b/drivers/bluetooth/hci_ath.c
@@ -41,6 +41,8 @@
#include <linux/of_gpio.h>
#include <linux/proc_fs.h>
+#include <linux/jiffies.h>
+
#include <net/bluetooth/bluetooth.h>
#include <net/bluetooth/hci_core.h>
@@ -134,7 +136,7 @@
static void modify_timer_task(void)
{
spin_lock(&rw_lock);
- mod_timer(&tx_timer, jiffies + (TX_TIMER_INTERVAL * HZ));
+ mod_timer(&tx_timer, jiffies + msecs_to_jiffies(TX_TIMER_INTERVAL * 1000));
clear_bit(BT_TXEXPIRED, &flags);
spin_unlock(&rw_lock);
diff --git a/drivers/bluetooth/hci_bcsp.c b/drivers/bluetooth/hci_bcsp.c
index 9c5b2dc..106bc3d 100644
--- a/drivers/bluetooth/hci_bcsp.c
+++ b/drivers/bluetooth/hci_bcsp.c
@@ -42,6 +42,8 @@
#include <linux/bitrev.h>
#include <asm/unaligned.h>
+#include <linux/jiffies.h>
+
#include <net/bluetooth/bluetooth.h>
#include <net/bluetooth/hci_core.h>
@@ -312,7 +314,7 @@
struct sk_buff *nskb = bcsp_prepare_pkt(bcsp, skb->data, skb->len, bt_cb(skb)->pkt_type);
if (nskb) {
__skb_queue_tail(&bcsp->unack, skb);
- mod_timer(&bcsp->tbcsp, jiffies + HZ / 4);
+ mod_timer(&bcsp->tbcsp, jiffies + msecs_to_jiffies(250));
spin_unlock_irqrestore(&bcsp->unack.lock, flags);
return nskb;
} else {
diff --git a/drivers/bluetooth/hci_ibs.c b/drivers/bluetooth/hci_ibs.c
index 84b253b..deb5741 100644
--- a/drivers/bluetooth/hci_ibs.c
+++ b/drivers/bluetooth/hci_ibs.c
@@ -49,6 +49,8 @@
#include <linux/skbuff.h>
#include <linux/serial_core.h>
+#include <linux/jiffies.h>
+
#ifdef CONFIG_SERIAL_MSM_HS
#include <mach/msm_serial_hs.h>
#endif
@@ -93,7 +95,7 @@
};
static unsigned long wake_retrans = 1;
-static unsigned long tx_idle_delay = (HZ * 2);
+static unsigned long tx_idle_delay = msecs_to_jiffies(2000);
struct hci_ibs_cmd {
u8 cmd;
@@ -270,7 +272,7 @@
ibs->ibs_sent_wakes++; /* debug */
/* start retransmit timer */
- mod_timer(&ibs->wake_retrans_timer, jiffies + wake_retrans);
+ mod_timer(&ibs->wake_retrans_timer, jiffies + msecs_to_jiffies(wake_retrans));
spin_unlock_irqrestore(&ibs->hci_ibs_lock, flags);
@@ -392,7 +394,7 @@
goto out;
}
ibs->ibs_sent_wakes++; /* debug */
- mod_timer(&ibs->wake_retrans_timer, jiffies + wake_retrans);
+ mod_timer(&ibs->wake_retrans_timer, jiffies + msecs_to_jiffies(wake_retrans));
break;
}
out:
@@ -656,7 +658,7 @@
skb_queue_tail(&ibs->txq, skb);
/* switch timers and change state to HCI_IBS_TX_AWAKE */
del_timer(&ibs->wake_retrans_timer);
- mod_timer(&ibs->tx_idle_timer, jiffies + tx_idle_delay);
+ mod_timer(&ibs->tx_idle_timer, jiffies + msecs_to_jiffies(tx_idle_delay));
ibs->tx_ibs_state = HCI_IBS_TX_AWAKE;
}
@@ -686,7 +688,7 @@
case HCI_IBS_TX_AWAKE:
BT_DBG("device awake, sending normally");
skb_queue_tail(&ibs->txq, skb);
- mod_timer(&ibs->tx_idle_timer, jiffies + tx_idle_delay);
+ mod_timer(&ibs->tx_idle_timer, jiffies + msecs_to_jiffies(tx_idle_delay));
break;
case HCI_IBS_TX_ASLEEP:
@@ -902,7 +904,7 @@
}
module_param(wake_retrans, ulong, 0644);
-MODULE_PARM_DESC(wake_retrans, "Delay (1/HZ) to retransmit WAKE_IND");
+MODULE_PARM_DESC(wake_retrans, "Delay (ms) to retransmit WAKE_IND");
module_param(tx_idle_delay, ulong, 0644);
-MODULE_PARM_DESC(tx_idle_delay, "Delay (1/HZ) since last tx for SLEEP_IND");
+MODULE_PARM_DESC(tx_idle_delay, "Delay (ms) since last tx for SLEEP_IND");