Merge branch 'for-3.20' of git://linux-nfs.org/~bfields/linux
[firefly-linux-kernel-4.4.55.git] / net / bluetooth / l2cap_sock.c
index f65caf41953f866fdea55b8eb342fafc9dc8a1c7..60694f0f4c73768dee1db1a4926ced43522dbe83 100644 (file)
@@ -302,7 +302,7 @@ done:
 static int l2cap_sock_accept(struct socket *sock, struct socket *newsock,
                             int flags)
 {
-       DECLARE_WAITQUEUE(wait, current);
+       DEFINE_WAIT_FUNC(wait, woken_wake_function);
        struct sock *sk = sock->sk, *nsk;
        long timeo;
        int err = 0;
@@ -316,8 +316,6 @@ static int l2cap_sock_accept(struct socket *sock, struct socket *newsock,
        /* Wait for an incoming connection. (wake-one). */
        add_wait_queue_exclusive(sk_sleep(sk), &wait);
        while (1) {
-               set_current_state(TASK_INTERRUPTIBLE);
-
                if (sk->sk_state != BT_LISTEN) {
                        err = -EBADFD;
                        break;
@@ -338,10 +336,11 @@ static int l2cap_sock_accept(struct socket *sock, struct socket *newsock,
                }
 
                release_sock(sk);
-               timeo = schedule_timeout(timeo);
+
+               timeo = wait_woken(&wait, TASK_INTERRUPTIBLE, timeo);
+
                lock_sock_nested(sk, L2CAP_NESTING_PARENT);
        }
-       __set_current_state(TASK_RUNNING);
        remove_wait_queue(sk_sleep(sk), &wait);
 
        if (err)
@@ -1614,6 +1613,8 @@ int __init l2cap_init_sockets(void)
 {
        int err;
 
+       BUILD_BUG_ON(sizeof(struct sockaddr_l2) > sizeof(struct sockaddr));
+
        err = proto_register(&l2cap_proto, 0);
        if (err < 0)
                return err;