2 RFCOMM implementation for Linux Bluetooth stack (BlueZ).
3 Copyright (C) 2002 Maxim Krasnyansky <maxk@qualcomm.com>
4 Copyright (C) 2002 Marcel Holtmann <marcel@holtmann.org>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License version 2 as
8 published by the Free Software Foundation;
10 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
11 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
13 IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
14 CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
15 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
20 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
21 SOFTWARE IS DISCLAIMED.
27 * $Id: tty.c,v 1.1.1.1 2005/04/11 02:51:12 jack Exp $
30 #include <linux/config.h>
31 #include <linux/module.h>
33 #include <linux/tty.h>
34 #include <linux/tty_driver.h>
35 #include <linux/tty_flip.h>
37 #include <linux/slab.h>
38 #include <linux/skbuff.h>
40 #include <net/bluetooth/bluetooth.h>
41 #include <net/bluetooth/rfcomm.h>
43 #ifndef CONFIG_BLUEZ_RFCOMM_DEBUG
48 #define RFCOMM_TTY_MAGIC 0x6d02 /* magic number for rfcomm struct */
49 #define RFCOMM_TTY_PORTS RFCOMM_MAX_DEV /* whole lotta rfcomm devices */
50 #define RFCOMM_TTY_MAJOR 216 /* device node major id of the usb/bluetooth.c driver */
51 #define RFCOMM_TTY_MINOR 0
54 struct list_head list;
69 struct rfcomm_dlc *dlc;
70 struct tty_struct *tty;
71 wait_queue_head_t wait;
72 struct tasklet_struct wakeup_task;
78 static LIST_HEAD(rfcomm_dev_list);
79 static rwlock_t rfcomm_dev_lock = RW_LOCK_UNLOCKED;
81 static void rfcomm_dev_data_ready(struct rfcomm_dlc *dlc, struct sk_buff *skb);
82 static void rfcomm_dev_state_change(struct rfcomm_dlc *dlc, int err);
83 static void rfcomm_dev_modem_status(struct rfcomm_dlc *dlc, u8 v24_sig);
85 static void rfcomm_tty_wakeup(unsigned long arg);
87 /* ---- Device functions ---- */
88 static void rfcomm_dev_destruct(struct rfcomm_dev *dev)
90 struct rfcomm_dlc *dlc = dev->dlc;
92 BT_DBG("dev %p dlc %p", dev, dlc);
95 /* Detach DLC if it's owned by this dev */
96 if (dlc->owner == dev)
98 rfcomm_dlc_unlock(dlc);
106 static inline void rfcomm_dev_hold(struct rfcomm_dev *dev)
108 atomic_inc(&dev->refcnt);
111 static inline void rfcomm_dev_put(struct rfcomm_dev *dev)
113 if (atomic_dec_and_test(&dev->refcnt))
114 rfcomm_dev_destruct(dev);
117 static struct rfcomm_dev *__rfcomm_dev_get(int id)
119 struct rfcomm_dev *dev;
122 list_for_each(p, &rfcomm_dev_list) {
123 dev = list_entry(p, struct rfcomm_dev, list);
131 static inline struct rfcomm_dev *rfcomm_dev_get(int id)
133 struct rfcomm_dev *dev;
135 read_lock(&rfcomm_dev_lock);
136 dev = __rfcomm_dev_get(id);
137 read_unlock(&rfcomm_dev_lock);
139 if (dev) rfcomm_dev_hold(dev);
143 static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc)
145 struct rfcomm_dev *dev;
146 struct list_head *head = &rfcomm_dev_list, *p;
149 BT_DBG("id %d channel %d", req->dev_id, req->channel);
151 dev = kmalloc(sizeof(struct rfcomm_dev), GFP_KERNEL);
154 memset(dev, 0, sizeof(struct rfcomm_dev));
156 write_lock_bh(&rfcomm_dev_lock);
158 if (req->dev_id < 0) {
161 list_for_each(p, &rfcomm_dev_list) {
162 if (list_entry(p, struct rfcomm_dev, list)->id != dev->id)
169 dev->id = req->dev_id;
171 list_for_each(p, &rfcomm_dev_list) {
172 struct rfcomm_dev *entry = list_entry(p, struct rfcomm_dev, list);
174 if (entry->id == dev->id) {
179 if (entry->id > dev->id - 1)
186 if ((dev->id < 0) || (dev->id > RFCOMM_MAX_DEV - 1)) {
191 sprintf(dev->name, "rfcomm%d", dev->id);
193 list_add(&dev->list, head);
194 atomic_set(&dev->refcnt, 1);
196 bacpy(&dev->src, &req->src);
197 bacpy(&dev->dst, &req->dst);
198 dev->channel = req->channel;
200 dev->flags = req->flags &
201 ((1 << RFCOMM_RELEASE_ONHUP) | (1 << RFCOMM_REUSE_DLC));
203 dev->sndbuf = RFCOMM_MAX_CREDITS * RFCOMM_DEFAULT_MTU * 10;
205 init_waitqueue_head(&dev->wait);
206 tasklet_init(&dev->wakeup_task, rfcomm_tty_wakeup, (unsigned long) dev);
208 rfcomm_dlc_lock(dlc);
209 dlc->data_ready = rfcomm_dev_data_ready;
210 dlc->state_change = rfcomm_dev_state_change;
211 dlc->modem_status = rfcomm_dev_modem_status;
215 rfcomm_dlc_unlock(dlc);
220 write_unlock_bh(&rfcomm_dev_lock);
229 static void rfcomm_dev_del(struct rfcomm_dev *dev)
231 BT_DBG("dev %p", dev);
233 write_lock_bh(&rfcomm_dev_lock);
234 list_del_init(&dev->list);
235 write_unlock_bh(&rfcomm_dev_lock);
240 /* ---- Send buffer ---- */
241 static void rfcomm_wfree(struct sk_buff *skb)
243 struct rfcomm_dev *dev = (void *) skb->sk;
244 atomic_sub(skb->truesize, &dev->wmem_alloc);
245 if (test_bit(RFCOMM_TTY_ATTACHED, &dev->flags))
246 tasklet_schedule(&dev->wakeup_task);
250 static inline void rfcomm_set_owner_w(struct sk_buff *skb, struct rfcomm_dev *dev)
252 rfcomm_dev_hold(dev);
253 atomic_add(skb->truesize, &dev->wmem_alloc);
254 skb->sk = (void *) dev;
255 skb->destructor = rfcomm_wfree;
258 static struct sk_buff *rfcomm_wmalloc(struct rfcomm_dev *dev, unsigned long size, int priority)
260 if (atomic_read(&dev->wmem_alloc) < dev->sndbuf) {
261 struct sk_buff *skb = alloc_skb(size, priority);
263 rfcomm_set_owner_w(skb, dev);
270 /* ---- Device IOCTLs ---- */
272 #define NOCAP_FLAGS ((1 << RFCOMM_REUSE_DLC) | (1 << RFCOMM_RELEASE_ONHUP))
274 static int rfcomm_create_dev(struct sock *sk, unsigned long arg)
276 struct rfcomm_dev_req req;
277 struct rfcomm_dlc *dlc;
280 if (copy_from_user(&req, (void *) arg, sizeof(req)))
283 BT_DBG("sk %p dev_id %id flags 0x%x", sk, req.dev_id, req.flags);
285 if (req.flags != NOCAP_FLAGS && !capable(CAP_NET_ADMIN))
288 if (req.flags & (1 << RFCOMM_REUSE_DLC)) {
289 /* Socket must be connected */
290 if (sk->state != BT_CONNECTED)
293 dlc = rfcomm_pi(sk)->dlc;
294 rfcomm_dlc_hold(dlc);
296 dlc = rfcomm_dlc_alloc(GFP_KERNEL);
301 id = rfcomm_dev_add(&req, dlc);
307 if (req.flags & (1 << RFCOMM_REUSE_DLC)) {
308 /* DLC is now used by device.
309 * Socket must be disconnected */
310 sk->state = BT_CLOSED;
316 static int rfcomm_release_dev(unsigned long arg)
318 struct rfcomm_dev_req req;
319 struct rfcomm_dev *dev;
321 if (copy_from_user(&req, (void *) arg, sizeof(req)))
324 BT_DBG("dev_id %id flags 0x%x", req.dev_id, req.flags);
326 if (!capable(CAP_NET_ADMIN))
329 if (!(dev = rfcomm_dev_get(req.dev_id)))
332 if (req.flags & (1 << RFCOMM_HANGUP_NOW))
333 rfcomm_dlc_close(dev->dlc, 0);
340 static int rfcomm_get_dev_list(unsigned long arg)
342 struct rfcomm_dev_list_req *dl;
343 struct rfcomm_dev_info *di;
350 if (get_user(dev_num, (u16 *) arg))
356 size = sizeof(*dl) + dev_num * sizeof(*di);
358 if (verify_area(VERIFY_WRITE, (void *)arg, size))
361 if (!(dl = kmalloc(size, GFP_KERNEL)))
366 read_lock_bh(&rfcomm_dev_lock);
368 list_for_each(p, &rfcomm_dev_list) {
369 struct rfcomm_dev *dev = list_entry(p, struct rfcomm_dev, list);
370 (di + n)->id = dev->id;
371 (di + n)->flags = dev->flags;
372 (di + n)->state = dev->dlc->state;
373 (di + n)->channel = dev->channel;
374 bacpy(&(di + n)->src, &dev->src);
375 bacpy(&(di + n)->dst, &dev->dst);
380 read_unlock_bh(&rfcomm_dev_lock);
383 size = sizeof(*dl) + n * sizeof(*di);
385 copy_to_user((void *) arg, dl, size);
390 static int rfcomm_get_dev_info(unsigned long arg)
392 struct rfcomm_dev *dev;
393 struct rfcomm_dev_info di;
398 if (copy_from_user(&di, (void *)arg, sizeof(di)))
401 if (!(dev = rfcomm_dev_get(di.id)))
404 di.flags = dev->flags;
405 di.channel = dev->channel;
406 di.state = dev->dlc->state;
407 bacpy(&di.src, &dev->src);
408 bacpy(&di.dst, &dev->dst);
410 if (copy_to_user((void *)arg, &di, sizeof(di)))
417 int rfcomm_dev_ioctl(struct sock *sk, unsigned int cmd, unsigned long arg)
419 BT_DBG("cmd %d arg %ld", cmd, arg);
422 case RFCOMMCREATEDEV:
423 return rfcomm_create_dev(sk, arg);
425 case RFCOMMRELEASEDEV:
426 return rfcomm_release_dev(arg);
428 case RFCOMMGETDEVLIST:
429 return rfcomm_get_dev_list(arg);
431 case RFCOMMGETDEVINFO:
432 return rfcomm_get_dev_info(arg);
438 /* ---- DLC callbacks ---- */
439 static void rfcomm_dev_data_ready(struct rfcomm_dlc *dlc, struct sk_buff *skb)
441 struct rfcomm_dev *dev = dlc->owner;
442 struct tty_struct *tty;
444 if (!dev || !(tty = dev->tty)) {
449 BT_DBG("dlc %p tty %p len %d", dlc, tty, skb->len);
451 if (test_bit(TTY_DONT_FLIP, &tty->flags)) {
453 for (i = 0; i < skb->len; i++) {
454 if (tty->flip.count >= TTY_FLIPBUF_SIZE)
455 tty_flip_buffer_push(tty);
457 tty_insert_flip_char(tty, skb->data[i], 0);
459 tty_flip_buffer_push(tty);
461 tty->ldisc.receive_buf(tty, skb->data, NULL, skb->len);
466 static void rfcomm_dev_state_change(struct rfcomm_dlc *dlc, int err)
468 struct rfcomm_dev *dev = dlc->owner;
472 BT_DBG("dlc %p dev %p err %d", dlc, dev, err);
475 wake_up_interruptible(&dev->wait);
477 if (dlc->state == BT_CLOSED) {
479 if (test_bit(RFCOMM_RELEASE_ONHUP, &dev->flags)) {
480 rfcomm_dev_hold(dev);
483 /* We have to drop DLC lock here, otherwise
484 * rfcomm_dev_put() will dead lock if it's the last refference */
485 rfcomm_dlc_unlock(dlc);
487 rfcomm_dlc_lock(dlc);
490 tty_hangup(dev->tty);
494 static void rfcomm_dev_modem_status(struct rfcomm_dlc *dlc, u8 v24_sig)
496 struct rfcomm_dev *dev = dlc->owner;
500 BT_DBG("dlc %p dev %p v24_sig 0x%02x", dlc, dev, v24_sig);
503 ((v24_sig & RFCOMM_V24_RTC) ? (TIOCM_DSR | TIOCM_DTR) : 0) |
504 ((v24_sig & RFCOMM_V24_RTR) ? (TIOCM_RTS | TIOCM_CTS) : 0) |
505 ((v24_sig & RFCOMM_V24_IC) ? TIOCM_RI : 0) |
506 ((v24_sig & RFCOMM_V24_DV) ? TIOCM_CD : 0);
509 /* ---- TTY functions ---- */
510 static void rfcomm_tty_wakeup(unsigned long arg)
512 struct rfcomm_dev *dev = (void *) arg;
513 struct tty_struct *tty = dev->tty;
517 BT_DBG("dev %p tty %p", dev, tty);
519 if (test_bit(TTY_DO_WRITE_WAKEUP, &tty->flags) && tty->ldisc.write_wakeup)
520 (tty->ldisc.write_wakeup)(tty);
522 wake_up_interruptible(&tty->write_wait);
523 #ifdef SERIAL_HAVE_POLL_WAIT
524 wake_up_interruptible(&tty->poll_wait);
528 static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
530 DECLARE_WAITQUEUE(wait, current);
531 struct rfcomm_dev *dev;
532 struct rfcomm_dlc *dlc;
535 id = MINOR(tty->device) - tty->driver.minor_start;
537 BT_DBG("tty %p id %d", tty, id);
539 dev = rfcomm_dev_get(id);
543 BT_DBG("dev %p dst %s channel %d opened %d", dev, batostr(&dev->dst), dev->channel, dev->opened);
545 if (dev->opened++ != 0)
550 /* Attach TTY and open DLC */
552 rfcomm_dlc_lock(dlc);
553 tty->driver_data = dev;
555 rfcomm_dlc_unlock(dlc);
556 set_bit(RFCOMM_TTY_ATTACHED, &dev->flags);
558 err = rfcomm_dlc_open(dlc, &dev->src, &dev->dst, dev->channel);
562 /* Wait for DLC to connect */
563 add_wait_queue(&dev->wait, &wait);
565 set_current_state(TASK_INTERRUPTIBLE);
567 if (dlc->state == BT_CLOSED) {
572 if (dlc->state == BT_CONNECTED)
575 if (signal_pending(current)) {
582 set_current_state(TASK_RUNNING);
583 remove_wait_queue(&dev->wait, &wait);
588 static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
590 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
594 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc, dev->opened);
596 if (--dev->opened == 0) {
597 /* Close DLC and dettach TTY */
598 rfcomm_dlc_close(dev->dlc, 0);
600 clear_bit(RFCOMM_TTY_ATTACHED, &dev->flags);
601 tasklet_kill(&dev->wakeup_task);
603 rfcomm_dlc_lock(dev->dlc);
604 tty->driver_data = NULL;
606 rfcomm_dlc_unlock(dev->dlc);
612 static int rfcomm_tty_write(struct tty_struct *tty, int from_user, const unsigned char *buf, int count)
614 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
615 struct rfcomm_dlc *dlc = dev->dlc;
617 int err = 0, sent = 0, size;
619 BT_DBG("tty %p from_user %d count %d", tty, from_user, count);
622 size = min_t(uint, count, dlc->mtu);
625 skb = rfcomm_wmalloc(dev, size + RFCOMM_SKB_RESERVE, GFP_KERNEL);
627 skb = rfcomm_wmalloc(dev, size + RFCOMM_SKB_RESERVE, GFP_ATOMIC);
632 skb_reserve(skb, RFCOMM_SKB_HEAD_RESERVE);
635 copy_from_user(skb_put(skb, size), buf + sent, size);
637 memcpy(skb_put(skb, size), buf + sent, size);
639 if ((err = rfcomm_dlc_send(dlc, skb)) < 0) {
648 return sent ? sent : err;
651 static int rfcomm_tty_write_room(struct tty_struct *tty)
653 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
654 struct rfcomm_dlc *dlc = dev->dlc;
656 BT_DBG("tty %p", tty);
658 return dlc->mtu * (dlc->tx_credits ? : 10);
661 static int rfcomm_tty_set_modem_status(uint cmd, struct rfcomm_dlc *dlc, uint status)
665 BT_DBG("dlc %p cmd 0x%02x", dlc, cmd);
670 rfcomm_dlc_get_modem_status(dlc, &v24_sig);
672 mask = ((status & TIOCM_DSR) ? RFCOMM_V24_RTC : 0) |
673 ((status & TIOCM_DTR) ? RFCOMM_V24_RTC : 0) |
674 ((status & TIOCM_RTS) ? RFCOMM_V24_RTR : 0) |
675 ((status & TIOCM_CTS) ? RFCOMM_V24_RTR : 0) |
676 ((status & TIOCM_RI) ? RFCOMM_V24_IC : 0) |
677 ((status & TIOCM_CD) ? RFCOMM_V24_DV : 0);
684 rfcomm_dlc_set_modem_status(dlc, v24_sig);
688 static int rfcomm_tty_ioctl(struct tty_struct *tty, struct file *filp, unsigned int cmd, unsigned long arg)
690 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
691 struct rfcomm_dlc *dlc = dev->dlc;
695 BT_DBG("tty %p cmd 0x%02x", tty, cmd);
699 BT_DBG("TCGETS is not supported");
703 BT_DBG("TCSETS is not supported");
709 return put_user(dev->modem_status, (unsigned int *)arg);
711 case TIOCMSET: /* Turns on and off the lines as specified by the mask */
712 case TIOCMBIS: /* Turns on the lines as specified by the mask */
713 case TIOCMBIC: /* Turns off the lines as specified by the mask */
714 if ((err = get_user(status, (unsigned int *)arg)))
716 return rfcomm_tty_set_modem_status(cmd, dlc, status);
719 BT_DBG("TIOCMIWAIT");
723 BT_DBG("TIOCGICOUNT");
727 BT_ERR("TIOCGSERIAL is not supported");
731 BT_ERR("TIOCSSERIAL is not supported");
735 BT_ERR("TIOCSERGSTRUCT is not supported");
739 BT_ERR("TIOCSERGETLSR is not supported");
743 BT_ERR("TIOCSERCONFIG is not supported");
747 return -ENOIOCTLCMD; /* ioctls which we must ignore */
754 #define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK))
756 static void rfcomm_tty_set_termios(struct tty_struct *tty, struct termios *old)
758 BT_DBG("tty %p", tty);
760 if ((tty->termios->c_cflag == old->c_cflag) &&
761 (RELEVANT_IFLAG(tty->termios->c_iflag) == RELEVANT_IFLAG(old->c_iflag)))
764 /* handle turning off CRTSCTS */
765 if ((old->c_cflag & CRTSCTS) && !(tty->termios->c_cflag & CRTSCTS)) {
766 BT_DBG("turning off CRTSCTS");
770 static void rfcomm_tty_throttle(struct tty_struct *tty)
772 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
774 BT_DBG("tty %p dev %p", tty, dev);
776 rfcomm_dlc_throttle(dev->dlc);
779 static void rfcomm_tty_unthrottle(struct tty_struct *tty)
781 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
783 BT_DBG("tty %p dev %p", tty, dev);
785 rfcomm_dlc_unthrottle(dev->dlc);
788 static int rfcomm_tty_chars_in_buffer(struct tty_struct *tty)
790 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
791 struct rfcomm_dlc *dlc = dev->dlc;
793 BT_DBG("tty %p dev %p", tty, dev);
795 if (skb_queue_len(&dlc->tx_queue))
801 static void rfcomm_tty_flush_buffer(struct tty_struct *tty)
803 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
807 BT_DBG("tty %p dev %p", tty, dev);
809 skb_queue_purge(&dev->dlc->tx_queue);
811 if (test_bit(TTY_DO_WRITE_WAKEUP, &tty->flags) && tty->ldisc.write_wakeup)
812 tty->ldisc.write_wakeup(tty);
815 static void rfcomm_tty_send_xchar(struct tty_struct *tty, char ch)
817 BT_DBG("tty %p ch %c", tty, ch);
820 static void rfcomm_tty_wait_until_sent(struct tty_struct *tty, int timeout)
822 BT_DBG("tty %p timeout %d", tty, timeout);
825 static void rfcomm_tty_hangup(struct tty_struct *tty)
827 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
831 BT_DBG("tty %p dev %p", tty, dev);
833 rfcomm_tty_flush_buffer(tty);
835 if (test_bit(RFCOMM_RELEASE_ONHUP, &dev->flags))
839 static int rfcomm_tty_read_proc(char *buf, char **start, off_t offset, int len, int *eof, void *unused)
844 /* ---- TTY structure ---- */
845 static int rfcomm_tty_refcount; /* If we manage several devices */
847 static struct tty_struct *rfcomm_tty_table[RFCOMM_TTY_PORTS];
848 static struct termios *rfcomm_tty_termios[RFCOMM_TTY_PORTS];
849 static struct termios *rfcomm_tty_termios_locked[RFCOMM_TTY_PORTS];
851 static struct tty_driver rfcomm_tty_driver = {
852 magic: TTY_DRIVER_MAGIC,
853 driver_name: "rfcomm",
854 #ifdef CONFIG_DEVFS_FS
855 name: "bluetooth/rfcomm/%d",
859 major: RFCOMM_TTY_MAJOR,
860 minor_start: RFCOMM_TTY_MINOR,
861 num: RFCOMM_TTY_PORTS,
862 type: TTY_DRIVER_TYPE_SERIAL,
863 subtype: SERIAL_TYPE_NORMAL,
864 flags: TTY_DRIVER_REAL_RAW,
866 refcount: &rfcomm_tty_refcount,
867 table: rfcomm_tty_table,
868 termios: rfcomm_tty_termios,
869 termios_locked: rfcomm_tty_termios_locked,
871 open: rfcomm_tty_open,
872 close: rfcomm_tty_close,
873 write: rfcomm_tty_write,
874 write_room: rfcomm_tty_write_room,
875 chars_in_buffer: rfcomm_tty_chars_in_buffer,
876 flush_buffer: rfcomm_tty_flush_buffer,
877 ioctl: rfcomm_tty_ioctl,
878 throttle: rfcomm_tty_throttle,
879 unthrottle: rfcomm_tty_unthrottle,
880 set_termios: rfcomm_tty_set_termios,
881 send_xchar: rfcomm_tty_send_xchar,
884 hangup: rfcomm_tty_hangup,
885 wait_until_sent: rfcomm_tty_wait_until_sent,
886 read_proc: rfcomm_tty_read_proc,
889 int rfcomm_init_ttys(void)
893 /* Initalize our global data */
894 for (i = 0; i < RFCOMM_TTY_PORTS; i++)
895 rfcomm_tty_table[i] = NULL;
897 /* Register the TTY driver */
898 rfcomm_tty_driver.init_termios = tty_std_termios;
899 rfcomm_tty_driver.init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
900 rfcomm_tty_driver.flags = TTY_DRIVER_REAL_RAW;
902 if (tty_register_driver(&rfcomm_tty_driver)) {
903 BT_ERR("Can't register RFCOMM TTY driver");
910 void rfcomm_cleanup_ttys(void)
912 tty_unregister_driver(&rfcomm_tty_driver);