diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2008-07-14 14:13:51 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2008-07-14 14:13:51 -0400 |
commit | 43cbeee9f9b26300275e4e2d55ed1607f8c5f760 (patch) | |
tree | 42ca68acb1043291df2015be01b81c09eeb5fb80 /net/bluetooth/af_bluetooth.c | |
parent | 3241ad820dbb172021e0268b5611031991431626 (diff) |
[Bluetooth] Add support for TIOCOUTQ and TIOCINQ ioctls
Almost every protocol family supports the TIOCOUTQ and TIOCINQ ioctls
and even Bluetooth could make use of them. When implementing audio
streaming and integration with GStreamer or PulseAudio they will allow
a better timing and synchronization.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/af_bluetooth.c')
-rw-r--r-- | net/bluetooth/af_bluetooth.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c index 88afe25003d8..77fe9b868fee 100644 --- a/net/bluetooth/af_bluetooth.c +++ b/net/bluetooth/af_bluetooth.c | |||
@@ -335,11 +335,34 @@ EXPORT_SYMBOL(bt_sock_poll); | |||
335 | int bt_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | 335 | int bt_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) |
336 | { | 336 | { |
337 | struct sock *sk = sock->sk; | 337 | struct sock *sk = sock->sk; |
338 | struct sk_buff *skb; | ||
339 | long amount; | ||
338 | int err; | 340 | int err; |
339 | 341 | ||
340 | BT_DBG("sk %p cmd %x arg %lx", sk, cmd, arg); | 342 | BT_DBG("sk %p cmd %x arg %lx", sk, cmd, arg); |
341 | 343 | ||
342 | switch (cmd) { | 344 | switch (cmd) { |
345 | case TIOCOUTQ: | ||
346 | if (sk->sk_state == BT_LISTEN) | ||
347 | return -EINVAL; | ||
348 | |||
349 | amount = sk->sk_sndbuf - atomic_read(&sk->sk_wmem_alloc); | ||
350 | if (amount < 0) | ||
351 | amount = 0; | ||
352 | err = put_user(amount, (int __user *) arg); | ||
353 | break; | ||
354 | |||
355 | case TIOCINQ: | ||
356 | if (sk->sk_state == BT_LISTEN) | ||
357 | return -EINVAL; | ||
358 | |||
359 | lock_sock(sk); | ||
360 | skb = skb_peek(&sk->sk_receive_queue); | ||
361 | amount = skb ? skb->len : 0; | ||
362 | release_sock(sk); | ||
363 | err = put_user(amount, (int __user *) arg); | ||
364 | break; | ||
365 | |||
343 | case SIOCGSTAMP: | 366 | case SIOCGSTAMP: |
344 | err = sock_get_timestamp(sk, (struct timeval __user *) arg); | 367 | err = sock_get_timestamp(sk, (struct timeval __user *) arg); |
345 | break; | 368 | break; |