diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2007-02-17 23:58:57 +0100 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-02-26 20:42:41 +0100 |
commit | c1a3313698895d8ad4760f98642007bf236af2e8 (patch) | |
tree | 337a876f727061362b6a169f8759849c105b8f7a /net/bluetooth | |
parent | [Bluetooth] Add open and close callbacks for HID device (diff) | |
download | linux-c1a3313698895d8ad4760f98642007bf236af2e8.tar.xz linux-c1a3313698895d8ad4760f98642007bf236af2e8.zip |
[Bluetooth] Make use of device_move() for RFCOMM TTY devices
In the case of bound RFCOMM TTY devices the parent is not available
before its usage. So when opening a RFCOMM TTY device, move it to
the corresponding ACL device as a child. When closing the device,
move it back to the virtual device tree.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth')
-rw-r--r-- | net/bluetooth/rfcomm/tty.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c index 8cd82dce5008..9a7a44fc721f 100644 --- a/net/bluetooth/rfcomm/tty.c +++ b/net/bluetooth/rfcomm/tty.c @@ -74,6 +74,8 @@ struct rfcomm_dev { wait_queue_head_t wait; struct tasklet_struct wakeup_task; + struct device *tty_dev; + atomic_t wmem_alloc; }; @@ -261,7 +263,7 @@ out: return err; } - tty_register_device(rfcomm_tty_driver, dev->id, rfcomm_get_device(dev)); + dev->tty_dev = tty_register_device(rfcomm_tty_driver, dev->id, NULL); return dev->id; } @@ -630,6 +632,9 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp) set_current_state(TASK_RUNNING); remove_wait_queue(&dev->wait, &wait); + if (err == 0) + device_move(dev->tty_dev, rfcomm_get_device(dev)); + return err; } @@ -642,6 +647,8 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp) BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc, dev->opened); if (--dev->opened == 0) { + device_move(dev->tty_dev, NULL); + /* Close DLC and dettach TTY */ rfcomm_dlc_close(dev->dlc, 0); |