aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2012-04-02 07:54:50 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-04-09 15:04:30 -0400
commitf60db8c4246ac7c33448fad173bed85354b7d75e (patch)
tree2f6ad4b9625bea393efb61a126a859f43ad476eb /net/bluetooth
parent3d5ea59d35b21d3bc582ce06bf22b522c8764003 (diff)
TTY: rfcomm/tty, add tty_port
And use tty from there. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net/bluetooth')
-rw-r--r--net/bluetooth/rfcomm/tty.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
index 4bf54b377255..97c2a087a9f1 100644
--- a/net/bluetooth/rfcomm/tty.c
+++ b/net/bluetooth/rfcomm/tty.c
@@ -48,6 +48,7 @@
48static struct tty_driver *rfcomm_tty_driver; 48static struct tty_driver *rfcomm_tty_driver;
49 49
50struct rfcomm_dev { 50struct rfcomm_dev {
51 struct tty_port port;
51 struct list_head list; 52 struct list_head list;
52 atomic_t refcnt; 53 atomic_t refcnt;
53 54
@@ -64,7 +65,6 @@ struct rfcomm_dev {
64 uint modem_status; 65 uint modem_status;
65 66
66 struct rfcomm_dlc *dlc; 67 struct rfcomm_dlc *dlc;
67 struct tty_struct *tty;
68 wait_queue_head_t wait; 68 wait_queue_head_t wait;
69 struct work_struct wakeup_task; 69 struct work_struct wakeup_task;
70 70
@@ -252,6 +252,7 @@ static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc)
252 252
253 atomic_set(&dev->opened, 0); 253 atomic_set(&dev->opened, 0);
254 254
255 tty_port_init(&dev->port);
255 init_waitqueue_head(&dev->wait); 256 init_waitqueue_head(&dev->wait);
256 INIT_WORK(&dev->wakeup_task, rfcomm_tty_wakeup); 257 INIT_WORK(&dev->wakeup_task, rfcomm_tty_wakeup);
257 258
@@ -440,8 +441,8 @@ static int rfcomm_release_dev(void __user *arg)
440 rfcomm_dlc_close(dev->dlc, 0); 441 rfcomm_dlc_close(dev->dlc, 0);
441 442
442 /* Shut down TTY synchronously before freeing rfcomm_dev */ 443 /* Shut down TTY synchronously before freeing rfcomm_dev */
443 if (dev->tty) 444 if (dev->port.tty)
444 tty_vhangup(dev->tty); 445 tty_vhangup(dev->port.tty);
445 446
446 if (!test_bit(RFCOMM_RELEASE_ONHUP, &dev->flags)) 447 if (!test_bit(RFCOMM_RELEASE_ONHUP, &dev->flags))
447 rfcomm_dev_del(dev); 448 rfcomm_dev_del(dev);
@@ -559,7 +560,7 @@ static void rfcomm_dev_data_ready(struct rfcomm_dlc *dlc, struct sk_buff *skb)
559 return; 560 return;
560 } 561 }
561 562
562 tty = dev->tty; 563 tty = dev->port.tty;
563 if (!tty || !skb_queue_empty(&dev->pending)) { 564 if (!tty || !skb_queue_empty(&dev->pending)) {
564 skb_queue_tail(&dev->pending, skb); 565 skb_queue_tail(&dev->pending, skb);
565 return; 566 return;
@@ -585,7 +586,7 @@ static void rfcomm_dev_state_change(struct rfcomm_dlc *dlc, int err)
585 wake_up_interruptible(&dev->wait); 586 wake_up_interruptible(&dev->wait);
586 587
587 if (dlc->state == BT_CLOSED) { 588 if (dlc->state == BT_CLOSED) {
588 if (!dev->tty) { 589 if (!dev->port.tty) {
589 if (test_bit(RFCOMM_RELEASE_ONHUP, &dev->flags)) { 590 if (test_bit(RFCOMM_RELEASE_ONHUP, &dev->flags)) {
590 /* Drop DLC lock here to avoid deadlock 591 /* Drop DLC lock here to avoid deadlock
591 * 1. rfcomm_dev_get will take rfcomm_dev_lock 592 * 1. rfcomm_dev_get will take rfcomm_dev_lock
@@ -605,7 +606,7 @@ static void rfcomm_dev_state_change(struct rfcomm_dlc *dlc, int err)
605 rfcomm_dlc_lock(dlc); 606 rfcomm_dlc_lock(dlc);
606 } 607 }
607 } else 608 } else
608 tty_hangup(dev->tty); 609 tty_hangup(dev->port.tty);
609 } 610 }
610} 611}
611 612
@@ -618,8 +619,8 @@ static void rfcomm_dev_modem_status(struct rfcomm_dlc *dlc, u8 v24_sig)
618 BT_DBG("dlc %p dev %p v24_sig 0x%02x", dlc, dev, v24_sig); 619 BT_DBG("dlc %p dev %p v24_sig 0x%02x", dlc, dev, v24_sig);
619 620
620 if ((dev->modem_status & TIOCM_CD) && !(v24_sig & RFCOMM_V24_DV)) { 621 if ((dev->modem_status & TIOCM_CD) && !(v24_sig & RFCOMM_V24_DV)) {
621 if (dev->tty && !C_CLOCAL(dev->tty)) 622 if (dev->port.tty && !C_CLOCAL(dev->port.tty))
622 tty_hangup(dev->tty); 623 tty_hangup(dev->port.tty);
623 } 624 }
624 625
625 dev->modem_status = 626 dev->modem_status =
@@ -634,7 +635,7 @@ static void rfcomm_tty_wakeup(struct work_struct *work)
634{ 635{
635 struct rfcomm_dev *dev = container_of(work, struct rfcomm_dev, 636 struct rfcomm_dev *dev = container_of(work, struct rfcomm_dev,
636 wakeup_task); 637 wakeup_task);
637 struct tty_struct *tty = dev->tty; 638 struct tty_struct *tty = dev->port.tty;
638 if (!tty) 639 if (!tty)
639 return; 640 return;
640 641
@@ -644,7 +645,7 @@ static void rfcomm_tty_wakeup(struct work_struct *work)
644 645
645static void rfcomm_tty_copy_pending(struct rfcomm_dev *dev) 646static void rfcomm_tty_copy_pending(struct rfcomm_dev *dev)
646{ 647{
647 struct tty_struct *tty = dev->tty; 648 struct tty_struct *tty = dev->port.tty;
648 struct sk_buff *skb; 649 struct sk_buff *skb;
649 int inserted = 0; 650 int inserted = 0;
650 651
@@ -697,7 +698,7 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
697 698
698 rfcomm_dlc_lock(dlc); 699 rfcomm_dlc_lock(dlc);
699 tty->driver_data = dev; 700 tty->driver_data = dev;
700 dev->tty = tty; 701 dev->port.tty = tty;
701 rfcomm_dlc_unlock(dlc); 702 rfcomm_dlc_unlock(dlc);
702 set_bit(RFCOMM_TTY_ATTACHED, &dev->flags); 703 set_bit(RFCOMM_TTY_ATTACHED, &dev->flags);
703 704
@@ -762,7 +763,7 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
762 763
763 rfcomm_dlc_lock(dev->dlc); 764 rfcomm_dlc_lock(dev->dlc);
764 tty->driver_data = NULL; 765 tty->driver_data = NULL;
765 dev->tty = NULL; 766 dev->port.tty = NULL;
766 rfcomm_dlc_unlock(dev->dlc); 767 rfcomm_dlc_unlock(dev->dlc);
767 768
768 if (test_bit(RFCOMM_TTY_RELEASED, &dev->flags)) { 769 if (test_bit(RFCOMM_TTY_RELEASED, &dev->flags)) {