aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/sco.c
diff options
context:
space:
mode:
authorFrédéric Dalleau <frederic.dalleau@linux.intel.com>2012-11-21 04:51:11 -0500
committerGustavo Padovan <gustavo.padovan@collabora.co.uk>2012-12-03 12:59:58 -0500
commitb96e9c671b05f95126753a22145d4509d45ca197 (patch)
tree2ce5551f3d17330228db1af7aa00d5db0efb9ab7 /net/bluetooth/sco.c
parentb9b5ef188e5a2222cfc16ef62a4703080750b451 (diff)
Bluetooth: Add BT_DEFER_SETUP option to sco socket
This option will set the BT_SK_DEFER_SETUP bit in socket flags. Signed-off-by: Frédéric Dalleau <frederic.dalleau@linux.intel.com> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Diffstat (limited to 'net/bluetooth/sco.c')
-rw-r--r--net/bluetooth/sco.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index 450cdcd88e5c..c6678f2bffc9 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -666,12 +666,31 @@ static int sco_sock_setsockopt(struct socket *sock, int level, int optname, char
666{ 666{
667 struct sock *sk = sock->sk; 667 struct sock *sk = sock->sk;
668 int err = 0; 668 int err = 0;
669 u32 opt;
669 670
670 BT_DBG("sk %p", sk); 671 BT_DBG("sk %p", sk);
671 672
672 lock_sock(sk); 673 lock_sock(sk);
673 674
674 switch (optname) { 675 switch (optname) {
676
677 case BT_DEFER_SETUP:
678 if (sk->sk_state != BT_BOUND && sk->sk_state != BT_LISTEN) {
679 err = -EINVAL;
680 break;
681 }
682
683 if (get_user(opt, (u32 __user *) optval)) {
684 err = -EFAULT;
685 break;
686 }
687
688 if (opt)
689 set_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags);
690 else
691 clear_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags);
692 break;
693
675 default: 694 default:
676 err = -ENOPROTOOPT; 695 err = -ENOPROTOOPT;
677 break; 696 break;
@@ -753,6 +772,19 @@ static int sco_sock_getsockopt(struct socket *sock, int level, int optname, char
753 lock_sock(sk); 772 lock_sock(sk);
754 773
755 switch (optname) { 774 switch (optname) {
775
776 case BT_DEFER_SETUP:
777 if (sk->sk_state != BT_BOUND && sk->sk_state != BT_LISTEN) {
778 err = -EINVAL;
779 break;
780 }
781
782 if (put_user(test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags),
783 (u32 __user *) optval))
784 err = -EFAULT;
785
786 break;
787
756 default: 788 default:
757 err = -ENOPROTOOPT; 789 err = -ENOPROTOOPT;
758 break; 790 break;