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>
This commit is contained in:
Kevin F. Haggerty 2016-06-19 08:05:01 -06:00 committed by Francescodario Cuzzocrea
parent be64d2c0f9
commit 7cf074467e
6 changed files with 61 additions and 44 deletions

View File

@ -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 @@ static void bluecard_enable_activity_led(bluecard_info_t *info)
/* 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 @@ static void bluecard_write_wakeup(bluecard_info_t *info)
/* 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 @@ static void bluecard_write_wakeup(bluecard_info_t *info)
/* 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);
}

View File

@ -55,6 +55,7 @@
#include <linux/barcode_emul.h>
#include <linux/jiffies.h>
#define BT_SLEEP_DBG
#ifndef BT_SLEEP_DBG
@ -107,8 +108,8 @@ DECLARE_DELAYED_WORK(uart_awake_workqueue, bluesleep_uart_awake_work);
#define bluesleep_tx_idle() schedule_delayed_work(&sleep_workqueue, 0)
#define bluesleep_uart_work() schedule_delayed_work(&uart_awake_workqueue, 0)
/* 10 second timeout */
#define TX_TIMER_INTERVAL 1
/* 3 second timeout */
#define TX_TIMER_INTERVAL 3
/* state variable names and bit positions */
#define BT_PROTO 0x01
@ -231,7 +232,8 @@ void bluesleep_sleep_wakeup(void)
hsuart_power(1);
wake_lock(&bsi->wake_lock);
/* Start the timer */
mod_timer(&tx_timer, jiffies + (TX_TIMER_INTERVAL * HZ));
mod_timer(&tx_timer,
jiffies + msecs_to_jiffies(TX_TIMER_INTERVAL * 1000));
if (bsi->has_ext_wake == 1) {
gpio_set_value(bsi->ext_wake, 1);
}
@ -240,7 +242,8 @@ void bluesleep_sleep_wakeup(void)
}
else {
BT_DBG("bluesleep_sleep_wakeup : already wake up, so start timer...");
mod_timer(&tx_timer, jiffies + (TX_TIMER_INTERVAL * HZ));
mod_timer(&tx_timer,
jiffies + msecs_to_jiffies(TX_TIMER_INTERVAL * 1000));
}
}
@ -251,7 +254,8 @@ static void bluesleep_tx_data_wakeup(void)
wake_lock(&bsi->wake_lock);
/* Start the timer */
mod_timer(&tx_timer, jiffies + (TX_TIMER_INTERVAL * HZ));
mod_timer(&tx_timer,
jiffies + msecs_to_jiffies(TX_TIMER_INTERVAL * 1000));
if (bsi->has_ext_wake == 1) {
gpio_set_value(bsi->ext_wake, 1);
}
@ -260,7 +264,8 @@ static void bluesleep_tx_data_wakeup(void)
}
else {
BT_DBG("bluesleep_tx_data_wakeup : already wake up, so start timer...");
mod_timer(&tx_timer, jiffies + (TX_TIMER_INTERVAL * HZ));
mod_timer(&tx_timer,
jiffies + msecs_to_jiffies(TX_TIMER_INTERVAL * 1000));
}
}
@ -305,7 +310,8 @@ static void bluesleep_sleep_work(struct work_struct *work)
if (test_bit(BT_TXDATA, &flags)) {
BT_DBG("TXDATA remained. Wait until timer expires.");
mod_timer(&tx_timer, jiffies + TX_TIMER_INTERVAL * HZ);
mod_timer(&tx_timer,
jiffies + msecs_to_jiffies(TX_TIMER_INTERVAL * 1000));
mutex_unlock(&bluesleep_mutex);
return;
}
@ -325,18 +331,20 @@ static void bluesleep_sleep_work(struct work_struct *work)
/* UART clk is not turned off immediately. Release
* wakelock after 500 ms.
*/
wake_lock_timeout(&bsi->wake_lock, HZ / 2);
wake_lock_timeout(&bsi->wake_lock, msecs_to_jiffies(500));
} else {
BT_DBG("host can enter sleep but some tx remained.");
mod_timer(&tx_timer, jiffies + TX_TIMER_INTERVAL * HZ);
mod_timer(&tx_timer,
jiffies + msecs_to_jiffies(TX_TIMER_INTERVAL * 1000));
mutex_unlock(&bluesleep_mutex);
return;
}
} else if (!test_bit(BT_EXT_WAKE, &flags)
&& !test_bit(BT_ASLEEP, &flags)) {
BT_DBG("host_wake high and BT_EXT_WAKE & BT_ASLEEP already freed.");
mod_timer(&tx_timer, jiffies + (TX_TIMER_INTERVAL * HZ));
mod_timer(&tx_timer,
jiffies + msecs_to_jiffies(TX_TIMER_INTERVAL * 1000));
if (bsi->has_ext_wake == 1) {
gpio_set_value(bsi->ext_wake, 1);
}
@ -406,7 +414,7 @@ static void bluesleep_start(void)
}
/* 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 */
if (bsi->has_ext_wake == 1) {
@ -443,7 +451,7 @@ static void bluesleep_abnormal_stop(void)
if (disable_irq_wake(bsi->host_wake_irq))
BT_ERR("Couldn't disable hostwake IRQ wakeup mode\n");
wake_lock_timeout(&bsi->wake_lock, HZ / 2);
wake_lock_timeout(&bsi->wake_lock, msecs_to_jiffies(500));
clear_bit(BT_TXDATA, &flags);
bsi->uport = NULL;
@ -475,7 +483,7 @@ static void bluesleep_stop(void)
if (disable_irq_wake(bsi->host_wake_irq))
BT_ERR("Couldn't disable hostwake IRQ wakeup mode\n");
wake_lock_timeout(&bsi->wake_lock, HZ / 2);
wake_lock_timeout(&bsi->wake_lock, msecs_to_jiffies(500));
bsi->uport = NULL;
}
@ -573,7 +581,8 @@ static void bluesleep_tx_timer_expire(unsigned long data)
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 */

View File

@ -56,6 +56,7 @@
#include <linux/barcode_emul.h>
#include <linux/delay.h>
#include <linux/jiffies.h>
#define BT_SLEEP_DBG
#ifndef BT_SLEEP_DBG
@ -112,7 +113,7 @@ DECLARE_DELAYED_WORK(tx_timer_expired_workqueue, bluesleep_ext_wake_set_wq);
#define bluesleep_tx_timer_expired() schedule_delayed_work(&tx_timer_expired_workqueue, 0)
/* 10 second timeout */
/* 3 second timeout */
#define TX_TIMER_INTERVAL 3
/* state variable names and bit positions */
@ -235,7 +236,7 @@ void bluesleep_sleep_wakeup(void)
hsuart_power(1);
wake_lock(&bsi->wake_lock);
/* Start the timer */
mod_timer(&tx_timer, jiffies + (TX_TIMER_INTERVAL * HZ));
mod_timer(&tx_timer, jiffies + (msecs_to_jiffies(TX_TIMER_INTERVAL * 1000)));
if (bsi->has_ext_wake == 1) {
int ret;
ret = ice_gpiox_set(bsi->ext_wake, 1);
@ -251,7 +252,7 @@ void bluesleep_sleep_wakeup(void)
}
else {
BT_DBG("bluesleep_sleep_wakeup : already wake up, so start timer...");
mod_timer(&tx_timer, jiffies + (TX_TIMER_INTERVAL * HZ));
mod_timer(&tx_timer, jiffies + (msecs_to_jiffies(TX_TIMER_INTERVAL * 1000)));
}
}
@ -270,7 +271,7 @@ static void bluesleep_tx_data_wakeup(void)
wake_lock(&bsi->wake_lock);
/* Start the timer */
mod_timer(&tx_timer, jiffies + (TX_TIMER_INTERVAL * HZ));
mod_timer(&tx_timer, jiffies + (msecs_to_jiffies(TX_TIMER_INTERVAL * 1000)));
if (bsi->has_ext_wake == 1) {
int ret;
ret = ice_gpiox_set(bsi->ext_wake, 1);
@ -292,7 +293,7 @@ static void bluesleep_tx_data_wakeup(void)
}
else {
BT_DBG("bluesleep_tx_data_wakeup : already wake up, so start timer...");
mod_timer(&tx_timer, jiffies + (TX_TIMER_INTERVAL * HZ));
mod_timer(&tx_timer, jiffies + (msecs_to_jiffies(TX_TIMER_INTERVAL * 1000)));
}
}
@ -322,7 +323,7 @@ static void bluesleep_sleep_work(struct work_struct *work)
if (test_bit(BT_TXDATA, &flags)) {
BT_DBG("TXDATA remained. Wait until timer expires.");
mod_timer(&tx_timer, jiffies + TX_TIMER_INTERVAL * HZ);
mod_timer(&tx_timer, jiffies + msecs_to_jiffies(TX_TIMER_INTERVAL * 1000));
mutex_unlock(&bluesleep_mutex);
return;
}
@ -346,18 +347,18 @@ static void bluesleep_sleep_work(struct work_struct *work)
/* UART clk is not turned off immediately. Release
* wakelock after 500 ms.
*/
wake_lock_timeout(&bsi->wake_lock, HZ / 2);
wake_lock_timeout(&bsi->wake_lock, msecs_to_jiffies(500));
} else {
BT_DBG("host can enter sleep but some tx remained.");
mod_timer(&tx_timer, jiffies + TX_TIMER_INTERVAL * HZ);
mod_timer(&tx_timer, jiffies + msecs_to_jiffies(TX_TIMER_INTERVAL * 1000));
mutex_unlock(&bluesleep_mutex);
return;
}
} else if (!test_bit(BT_EXT_WAKE, &flags)
&& !test_bit(BT_ASLEEP, &flags)) {
BT_DBG("host_wake high and BT_EXT_WAKE & BT_ASLEEP already freed.");
mod_timer(&tx_timer, jiffies + (TX_TIMER_INTERVAL * HZ));
mod_timer(&tx_timer, jiffies + (msecs_to_jiffies(TX_TIMER_INTERVAL * 1000)));
if (bsi->has_ext_wake == 1) {
int ret;
ret = ice_gpiox_set(bsi->ext_wake, 1);
@ -441,7 +442,7 @@ static void bluesleep_start(void)
}
/* 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 */
if (bsi->has_ext_wake == 1) {
@ -480,7 +481,7 @@ static void bluesleep_abnormal_stop(void)
if (disable_irq_wake(bsi->host_wake_irq))
BT_ERR("Couldn't disable hostwake IRQ wakeup mode\n");
wake_lock_timeout(&bsi->wake_lock, HZ / 2);
wake_lock_timeout(&bsi->wake_lock, msecs_to_jiffies(500));
clear_bit(BT_TXDATA, &flags);
bsi->uport = NULL;
@ -514,7 +515,7 @@ static void bluesleep_stop(void)
if (disable_irq_wake(bsi->host_wake_irq))
BT_ERR("Couldn't disable hostwake IRQ wakeup mode\n");
wake_lock_timeout(&bsi->wake_lock, HZ / 2);
wake_lock_timeout(&bsi->wake_lock, msecs_to_jiffies(500));
bsi->uport = NULL;
}
@ -612,7 +613,8 @@ static void bluesleep_tx_timer_expire(unsigned long data)
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 */

View File

@ -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 hsuart_serial_clock_off(struct uart_port *port)
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);

View File

@ -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 @@ static struct sk_buff *bcsp_dequeue(struct hci_uart *hu)
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 {

View File

@ -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 @@ enum hci_ibs_clock_state_vote_e {
};
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 @@ static void ibs_wq_awake_device(struct work_struct *work)
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 @@ static void hci_ibs_wake_retrans_timeout(unsigned long arg)
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 @@ static void ibs_device_woke_up(struct hci_uart *hu)
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 @@ static int ibs_enqueue(struct hci_uart *hu, struct sk_buff *skb)
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 @@ int ibs_deinit(void)
}
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");