NFC: Update the LLCP poll mask
authorSamuel Ortiz <sameo@linux.intel.com>
Mon, 7 May 2012 10:31:20 +0000 (12:31 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Tue, 15 May 2012 21:28:02 +0000 (17:28 -0400)
Fix the poll mask depending on the socket state. POLLOUT was missing
for example.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
net/nfc/llcp/sock.c

index 99196d3b84ebb3bc115edc9603d2eac4094f7792..3f339b19d140d666328b5dfd462f5d27bafb94d5 100644 (file)
@@ -340,11 +340,24 @@ static unsigned int llcp_sock_poll(struct file *file, struct socket *sock,
                mask |= POLLERR;
 
        if (!skb_queue_empty(&sk->sk_receive_queue))
-               mask |= POLLIN;
+               mask |= POLLIN | POLLRDNORM;
 
        if (sk->sk_state == LLCP_CLOSED)
                mask |= POLLHUP;
 
+       if (sk->sk_shutdown & RCV_SHUTDOWN)
+               mask |= POLLRDHUP | POLLIN | POLLRDNORM;
+
+       if (sk->sk_shutdown == SHUTDOWN_MASK)
+               mask |= POLLHUP;
+
+       if (sock_writeable(sk))
+               mask |= POLLOUT | POLLWRNORM | POLLWRBAND;
+       else
+               set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags);
+
+       pr_debug("mask 0x%x\n", mask);
+
        return mask;
 }