]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
Bluetooth: Convert timers to use timer_setup()
authorKees Cook <keescook@chromium.org>
Thu, 5 Oct 2017 00:54:29 +0000 (17:54 -0700)
committerMarcel Holtmann <marcel@holtmann.org>
Fri, 6 Oct 2017 18:37:11 +0000 (20:37 +0200)
In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
to pass the timer pointer explicitly. As already done in hci_qca, add
struct hci_uart pointer to priv structure.

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
drivers/bluetooth/bluecard_cs.c
drivers/bluetooth/hci_bcsp.c
drivers/bluetooth/hci_h5.c
drivers/bluetooth/hci_qca.c

index b07ca9565291fb504ad8b9ea8955ac176cf2f913..d513ef4743dce272634e8012a48305a0e83de3e6 100644 (file)
@@ -156,9 +156,9 @@ static void bluecard_detach(struct pcmcia_device *p_dev);
 /* ======================== LED handling routines ======================== */
 
 
-static void bluecard_activity_led_timeout(u_long arg)
+static void bluecard_activity_led_timeout(struct timer_list *t)
 {
-       struct bluecard_info *info = (struct bluecard_info *)arg;
+       struct bluecard_info *info = from_timer(info, t, timer);
        unsigned int iobase = info->p_dev->resource[0]->start;
 
        if (test_bit(CARD_ACTIVITY, &(info->hw_state))) {
@@ -691,8 +691,7 @@ static int bluecard_open(struct bluecard_info *info)
 
        spin_lock_init(&(info->lock));
 
-       setup_timer(&(info->timer), &bluecard_activity_led_timeout,
-                   (u_long)info);
+       timer_setup(&info->timer, bluecard_activity_led_timeout, 0);
 
        skb_queue_head_init(&(info->txq));
 
index d880f4e33c755deae65c23947be368eece5b768f..1a7f0c82fb362ec2e200c2b6428b923fb24aa3ab 100644 (file)
@@ -65,6 +65,7 @@ struct bcsp_struct {
        u8      rxseq_txack;            /* rxseq == txack. */
        u8      rxack;                  /* Last packet sent by us that the peer ack'ed */
        struct  timer_list tbcsp;
+       struct  hci_uart *hu;
 
        enum {
                BCSP_W4_PKT_DELIMITER,
@@ -697,10 +698,10 @@ static int bcsp_recv(struct hci_uart *hu, const void *data, int count)
 }
 
        /* Arrange to retransmit all messages in the relq. */
-static void bcsp_timed_event(unsigned long arg)
+static void bcsp_timed_event(struct timer_list *t)
 {
-       struct hci_uart *hu = (struct hci_uart *)arg;
-       struct bcsp_struct *bcsp = hu->priv;
+       struct bcsp_struct *bcsp = from_timer(bcsp, t, tbcsp);
+       struct hci_uart *hu = bcsp->hu;
        struct sk_buff *skb;
        unsigned long flags;
 
@@ -729,11 +730,12 @@ static int bcsp_open(struct hci_uart *hu)
                return -ENOMEM;
 
        hu->priv = bcsp;
+       bcsp->hu = hu;
        skb_queue_head_init(&bcsp->unack);
        skb_queue_head_init(&bcsp->rel);
        skb_queue_head_init(&bcsp->unrel);
 
-       setup_timer(&bcsp->tbcsp, bcsp_timed_event, (u_long)hu);
+       timer_setup(&bcsp->tbcsp, bcsp_timed_event, 0);
 
        bcsp->rx_state = BCSP_W4_PKT_DELIMITER;
 
index c0e4e26dc30d7c3c6a771b7b86df88c8cf763646..6a8d0d06aba7a6bbaf5bf1d8dd494826469fe2f1 100644 (file)
@@ -78,6 +78,7 @@ struct h5 {
        int                     (*rx_func)(struct hci_uart *hu, u8 c);
 
        struct timer_list       timer;          /* Retransmission timer */
+       struct hci_uart         *hu;            /* Parent HCI UART */
 
        u8                      tx_seq;         /* Next seq number to send */
        u8                      tx_ack;         /* Next ack number to send */
@@ -120,12 +121,12 @@ static u8 h5_cfg_field(struct h5 *h5)
        return h5->tx_win & 0x07;
 }
 
-static void h5_timed_event(unsigned long arg)
+static void h5_timed_event(struct timer_list *t)
 {
        const unsigned char sync_req[] = { 0x01, 0x7e };
        unsigned char conf_req[3] = { 0x03, 0xfc };
-       struct hci_uart *hu = (struct hci_uart *)arg;
-       struct h5 *h5 = hu->priv;
+       struct h5 *h5 = from_timer(h5, t, timer);
+       struct hci_uart *hu = h5->hu;
        struct sk_buff *skb;
        unsigned long flags;
 
@@ -197,6 +198,7 @@ static int h5_open(struct hci_uart *hu)
                return -ENOMEM;
 
        hu->priv = h5;
+       h5->hu = hu;
 
        skb_queue_head_init(&h5->unack);
        skb_queue_head_init(&h5->rel);
@@ -204,7 +206,7 @@ static int h5_open(struct hci_uart *hu)
 
        h5_reset_rx(h5);
 
-       setup_timer(&h5->timer, h5_timed_event, (unsigned long)hu);
+       timer_setup(&h5->timer, h5_timed_event, 0);
 
        h5->tx_win = H5_TX_WIN_MAX;
 
index 392f412b4575162bc2897ba12b30e1d5b62dc60b..4a949bb60394db6f316d37e39fd160c9bba02631 100644 (file)
@@ -307,10 +307,10 @@ static void qca_wq_serial_tx_clock_vote_off(struct work_struct *work)
        serial_clock_vote(HCI_IBS_TX_VOTE_CLOCK_OFF, hu);
 }
 
-static void hci_ibs_tx_idle_timeout(unsigned long arg)
+static void hci_ibs_tx_idle_timeout(struct timer_list *t)
 {
-       struct hci_uart *hu = (struct hci_uart *)arg;
-       struct qca_data *qca = hu->priv;
+       struct qca_data *qca = from_timer(qca, t, tx_idle_timer);
+       struct hci_uart *hu = qca->hu;
        unsigned long flags;
 
        BT_DBG("hu %p idle timeout in %d state", hu, qca->tx_ibs_state);
@@ -342,10 +342,10 @@ static void hci_ibs_tx_idle_timeout(unsigned long arg)
        spin_unlock_irqrestore(&qca->hci_ibs_lock, flags);
 }
 
-static void hci_ibs_wake_retrans_timeout(unsigned long arg)
+static void hci_ibs_wake_retrans_timeout(struct timer_list *t)
 {
-       struct hci_uart *hu = (struct hci_uart *)arg;
-       struct qca_data *qca = hu->priv;
+       struct qca_data *qca = from_timer(qca, t, wake_retrans_timer);
+       struct hci_uart *hu = qca->hu;
        unsigned long flags, retrans_delay;
        bool retransmit = false;
 
@@ -438,11 +438,10 @@ static int qca_open(struct hci_uart *hu)
 
        hu->priv = qca;
 
-       setup_timer(&qca->wake_retrans_timer, hci_ibs_wake_retrans_timeout,
-                   (u_long)hu);
+       timer_setup(&qca->wake_retrans_timer, hci_ibs_wake_retrans_timeout, 0);
        qca->wake_retrans = IBS_WAKE_RETRANS_TIMEOUT_MS;
 
-       setup_timer(&qca->tx_idle_timer, hci_ibs_tx_idle_timeout, (u_long)hu);
+       timer_setup(&qca->tx_idle_timer, hci_ibs_tx_idle_timeout, 0);
        qca->tx_idle_delay = IBS_TX_IDLE_TIMEOUT_MS;
 
        BT_DBG("HCI_UART_QCA open, tx_idle_delay=%u, wake_retrans=%u",