Skip to content

Commit 96af739

Browse files
David HerrmannGustavo F. Padovan
authored andcommitted
Bluetooth: Replace rfcomm tty tasklet by workqueue
Remove old tasklets and replace by workqueue. To avoid reentrancy (which tasklets always avoid) we use the system_nrt_wq. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
1 parent 5ada991 commit 96af739

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

  • net/bluetooth/rfcomm

‎net/bluetooth/rfcomm/tty.c‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <linux/capability.h>
3535
#include <linux/slab.h>
3636
#include <linux/skbuff.h>
37+
#include <linux/workqueue.h>
3738

3839
#include <net/bluetooth/bluetooth.h>
3940
#include <net/bluetooth/hci_core.h>
@@ -65,7 +66,7 @@ struct rfcomm_dev {
6566
struct rfcomm_dlc *dlc;
6667
struct tty_struct *tty;
6768
wait_queue_head_t wait;
68-
struct tasklet_struct wakeup_task;
69+
struct work_struct wakeup_task;
6970

7071
struct device *tty_dev;
7172

@@ -81,7 +82,7 @@ static void rfcomm_dev_data_ready(struct rfcomm_dlc *dlc, struct sk_buff *skb);
8182
static void rfcomm_dev_state_change(struct rfcomm_dlc *dlc, int err);
8283
static void rfcomm_dev_modem_status(struct rfcomm_dlc *dlc, u8 v24_sig);
8384

84-
static void rfcomm_tty_wakeup(unsigned long arg);
85+
static void rfcomm_tty_wakeup(struct work_struct *work);
8586

8687
/* ---- Device functions ---- */
8788
static void rfcomm_dev_destruct(struct rfcomm_dev *dev)
@@ -257,7 +258,7 @@ static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc)
257258
atomic_set(&dev->opened, 0);
258259

259260
init_waitqueue_head(&dev->wait);
260-
tasklet_init(&dev->wakeup_task, rfcomm_tty_wakeup, (unsigned long) dev);
261+
INIT_WORK(&dev->wakeup_task, rfcomm_tty_wakeup);
261262

262263
skb_queue_head_init(&dev->pending);
263264

@@ -351,7 +352,7 @@ static void rfcomm_wfree(struct sk_buff *skb)
351352
struct rfcomm_dev *dev = (void *) skb->sk;
352353
atomic_sub(skb->truesize, &dev->wmem_alloc);
353354
if (test_bit(RFCOMM_TTY_ATTACHED, &dev->flags))
354-
tasklet_schedule(&dev->wakeup_task);
355+
queue_work(system_nrt_wq, &dev->wakeup_task);
355356
rfcomm_dev_put(dev);
356357
}
357358

@@ -635,9 +636,10 @@ static void rfcomm_dev_modem_status(struct rfcomm_dlc *dlc, u8 v24_sig)
635636
}
636637

637638
/* ---- TTY functions ---- */
638-
static void rfcomm_tty_wakeup(unsigned long arg)
639+
static void rfcomm_tty_wakeup(struct work_struct *work)
639640
{
640-
struct rfcomm_dev *dev = (void *) arg;
641+
struct rfcomm_dev *dev = container_of(work, struct rfcomm_dev,
642+
wakeup_task);
641643
struct tty_struct *tty = dev->tty;
642644
if (!tty)
643645
return;
@@ -762,7 +764,7 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
762764
rfcomm_dlc_close(dev->dlc, 0);
763765

764766
clear_bit(RFCOMM_TTY_ATTACHED, &dev->flags);
765-
tasklet_kill(&dev->wakeup_task);
767+
cancel_work_sync(&dev->wakeup_task);
766768

767769
rfcomm_dlc_lock(dev->dlc);
768770
tty->driver_data = NULL;

0 commit comments

Comments
 (0)