aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/rfcomm/tty.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/bluetooth/rfcomm/tty.c')
-rw-r--r--net/bluetooth/rfcomm/tty.c36
1 files changed, 24 insertions, 12 deletions
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
index 74368f79ee5d..26f322737db0 100644
--- a/net/bluetooth/rfcomm/tty.c
+++ b/net/bluetooth/rfcomm/tty.c
@@ -27,7 +27,6 @@
27 * $Id: tty.c,v 1.24 2002/10/03 01:54:38 holtmann Exp $ 27 * $Id: tty.c,v 1.24 2002/10/03 01:54:38 holtmann Exp $
28 */ 28 */
29 29
30#include <linux/config.h>
31#include <linux/module.h> 30#include <linux/module.h>
32 31
33#include <linux/tty.h> 32#include <linux/tty.h>
@@ -39,6 +38,7 @@
39#include <linux/skbuff.h> 38#include <linux/skbuff.h>
40 39
41#include <net/bluetooth/bluetooth.h> 40#include <net/bluetooth/bluetooth.h>
41#include <net/bluetooth/hci_core.h>
42#include <net/bluetooth/rfcomm.h> 42#include <net/bluetooth/rfcomm.h>
43 43
44#ifndef CONFIG_BT_RFCOMM_DEBUG 44#ifndef CONFIG_BT_RFCOMM_DEBUG
@@ -162,6 +162,24 @@ static inline struct rfcomm_dev *rfcomm_dev_get(int id)
162 return dev; 162 return dev;
163} 163}
164 164
165static struct device *rfcomm_get_device(struct rfcomm_dev *dev)
166{
167 struct hci_dev *hdev;
168 struct hci_conn *conn;
169
170 hdev = hci_get_route(&dev->dst, &dev->src);
171 if (!hdev)
172 return NULL;
173
174 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &dev->dst);
175 if (!conn)
176 return NULL;
177
178 hci_dev_put(hdev);
179
180 return &conn->dev;
181}
182
165static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc) 183static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc)
166{ 184{
167 struct rfcomm_dev *dev; 185 struct rfcomm_dev *dev;
@@ -170,10 +188,9 @@ static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc)
170 188
171 BT_DBG("id %d channel %d", req->dev_id, req->channel); 189 BT_DBG("id %d channel %d", req->dev_id, req->channel);
172 190
173 dev = kmalloc(sizeof(struct rfcomm_dev), GFP_KERNEL); 191 dev = kzalloc(sizeof(struct rfcomm_dev), GFP_KERNEL);
174 if (!dev) 192 if (!dev)
175 return -ENOMEM; 193 return -ENOMEM;
176 memset(dev, 0, sizeof(struct rfcomm_dev));
177 194
178 write_lock_bh(&rfcomm_dev_lock); 195 write_lock_bh(&rfcomm_dev_lock);
179 196
@@ -246,7 +263,7 @@ out:
246 return err; 263 return err;
247 } 264 }
248 265
249 tty_register_device(rfcomm_tty_driver, dev->id, NULL); 266 tty_register_device(rfcomm_tty_driver, dev->id, rfcomm_get_device(dev));
250 267
251 return dev->id; 268 return dev->id;
252} 269}
@@ -480,12 +497,8 @@ static void rfcomm_dev_data_ready(struct rfcomm_dlc *dlc, struct sk_buff *skb)
480 497
481 BT_DBG("dlc %p tty %p len %d", dlc, tty, skb->len); 498 BT_DBG("dlc %p tty %p len %d", dlc, tty, skb->len);
482 499
483 if (test_bit(TTY_DONT_FLIP, &tty->flags)) { 500 tty_insert_flip_string(tty, skb->data, skb->len);
484 tty_buffer_request_room(tty, skb->len); 501 tty_flip_buffer_push(tty);
485 tty_insert_flip_string(tty, skb->data, skb->len);
486 tty_flip_buffer_push(tty);
487 } else
488 tty->ldisc.receive_buf(tty, skb->data, NULL, skb->len);
489 502
490 kfree_skb(skb); 503 kfree_skb(skb);
491} 504}
@@ -1025,13 +1038,12 @@ int rfcomm_init_ttys(void)
1025 1038
1026 rfcomm_tty_driver->owner = THIS_MODULE; 1039 rfcomm_tty_driver->owner = THIS_MODULE;
1027 rfcomm_tty_driver->driver_name = "rfcomm"; 1040 rfcomm_tty_driver->driver_name = "rfcomm";
1028 rfcomm_tty_driver->devfs_name = "bluetooth/rfcomm/";
1029 rfcomm_tty_driver->name = "rfcomm"; 1041 rfcomm_tty_driver->name = "rfcomm";
1030 rfcomm_tty_driver->major = RFCOMM_TTY_MAJOR; 1042 rfcomm_tty_driver->major = RFCOMM_TTY_MAJOR;
1031 rfcomm_tty_driver->minor_start = RFCOMM_TTY_MINOR; 1043 rfcomm_tty_driver->minor_start = RFCOMM_TTY_MINOR;
1032 rfcomm_tty_driver->type = TTY_DRIVER_TYPE_SERIAL; 1044 rfcomm_tty_driver->type = TTY_DRIVER_TYPE_SERIAL;
1033 rfcomm_tty_driver->subtype = SERIAL_TYPE_NORMAL; 1045 rfcomm_tty_driver->subtype = SERIAL_TYPE_NORMAL;
1034 rfcomm_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS; 1046 rfcomm_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
1035 rfcomm_tty_driver->init_termios = tty_std_termios; 1047 rfcomm_tty_driver->init_termios = tty_std_termios;
1036 rfcomm_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; 1048 rfcomm_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
1037 tty_set_operations(rfcomm_tty_driver, &rfcomm_ops); 1049 tty_set_operations(rfcomm_tty_driver, &rfcomm_ops);