Commit fc8c3e4b authored by Marcel Holtmann's avatar Marcel Holtmann

[Bluetooth] Dynamic allocation of the RFCOMM TTY devices

Only allocate the RFCOMM TTY devices when they are really in use. This
prevents the system from calling hotplug and udev 256 times to create or
remove every device node. In fact this makes the loading and unloading
of the RFCOMM module much faster.
parent d1c5ea97
......@@ -52,7 +52,7 @@
#include <net/bluetooth/l2cap.h>
#include <net/bluetooth/rfcomm.h>
#define VERSION "1.1"
#define VERSION "1.2"
#ifndef CONFIG_BT_RFCOMM_DEBUG
#undef BT_DBG
......
......@@ -50,6 +50,8 @@
#define RFCOMM_TTY_MAJOR 216 /* device node major id of the usb/bluetooth.c driver */
#define RFCOMM_TTY_MINOR 0
static struct tty_driver *rfcomm_tty_driver;
struct rfcomm_dev {
struct list_head list;
atomic_t refcnt;
......@@ -98,6 +100,8 @@ static void rfcomm_dev_destruct(struct rfcomm_dev *dev)
rfcomm_dlc_put(dlc);
tty_unregister_device(rfcomm_tty_driver, dev->id);
/* Refcount should only hit zero when called from rfcomm_dev_del()
which will have taken us off the list. Everything else are
refcounting bugs. */
......@@ -239,8 +243,11 @@ static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc)
if (err) {
kfree(dev);
return err;
} else
return dev->id;
}
tty_register_device(rfcomm_tty_driver, dev->id, NULL);
return dev->id;
}
static void rfcomm_dev_del(struct rfcomm_dev *dev)
......@@ -871,8 +878,6 @@ static int rfcomm_tty_tiocmset(struct tty_struct *tty, struct file *filp, unsign
/* ---- TTY structure ---- */
static struct tty_driver *rfcomm_tty_driver;
static struct tty_operations rfcomm_ops = {
.open = rfcomm_tty_open,
.close = rfcomm_tty_close,
......@@ -906,7 +911,7 @@ int rfcomm_init_ttys(void)
rfcomm_tty_driver->minor_start = RFCOMM_TTY_MINOR;
rfcomm_tty_driver->type = TTY_DRIVER_TYPE_SERIAL;
rfcomm_tty_driver->subtype = SERIAL_TYPE_NORMAL;
rfcomm_tty_driver->flags = TTY_DRIVER_REAL_RAW;
rfcomm_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS;
rfcomm_tty_driver->init_termios = tty_std_termios;
rfcomm_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
tty_set_operations(rfcomm_tty_driver, &rfcomm_ops);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment