aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth
diff options
context:
space:
mode:
authorGustavo F. Padovan <padovan@profusion.mobi>2011-02-03 23:42:23 -0500
committerGustavo F. Padovan <padovan@profusion.mobi>2011-02-07 22:43:30 -0500
commitc47b7c724bc7106acf602b2ce99922a2d14ea62b (patch)
tree28dc23a5a4e3641fa4d55b70bc5d6c8adec30be8 /net/bluetooth
parentaf6bcd8205ac06fa1de98b2b28303157fb9c3dfc (diff)
Bluetooth: move l2cap_sock_accept() to l2cap_sock.c
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net/bluetooth')
-rw-r--r--net/bluetooth/l2cap_core.c56
-rw-r--r--net/bluetooth/l2cap_sock.c56
2 files changed, 56 insertions, 56 deletions
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 6af38722d5cb..ff6a54ffed89 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -993,62 +993,6 @@ done:
993 return err; 993 return err;
994} 994}
995 995
996int l2cap_sock_accept(struct socket *sock, struct socket *newsock, int flags)
997{
998 DECLARE_WAITQUEUE(wait, current);
999 struct sock *sk = sock->sk, *nsk;
1000 long timeo;
1001 int err = 0;
1002
1003 lock_sock_nested(sk, SINGLE_DEPTH_NESTING);
1004
1005 if (sk->sk_state != BT_LISTEN) {
1006 err = -EBADFD;
1007 goto done;
1008 }
1009
1010 timeo = sock_rcvtimeo(sk, flags & O_NONBLOCK);
1011
1012 BT_DBG("sk %p timeo %ld", sk, timeo);
1013
1014 /* Wait for an incoming connection. (wake-one). */
1015 add_wait_queue_exclusive(sk_sleep(sk), &wait);
1016 while (!(nsk = bt_accept_dequeue(sk, newsock))) {
1017 set_current_state(TASK_INTERRUPTIBLE);
1018 if (!timeo) {
1019 err = -EAGAIN;
1020 break;
1021 }
1022
1023 release_sock(sk);
1024 timeo = schedule_timeout(timeo);
1025 lock_sock_nested(sk, SINGLE_DEPTH_NESTING);
1026
1027 if (sk->sk_state != BT_LISTEN) {
1028 err = -EBADFD;
1029 break;
1030 }
1031
1032 if (signal_pending(current)) {
1033 err = sock_intr_errno(timeo);
1034 break;
1035 }
1036 }
1037 set_current_state(TASK_RUNNING);
1038 remove_wait_queue(sk_sleep(sk), &wait);
1039
1040 if (err)
1041 goto done;
1042
1043 newsock->state = SS_CONNECTED;
1044
1045 BT_DBG("new socket %p", nsk);
1046
1047done:
1048 release_sock(sk);
1049 return err;
1050}
1051
1052int l2cap_sock_getname(struct socket *sock, struct sockaddr *addr, int *len, int peer) 996int l2cap_sock_getname(struct socket *sock, struct sockaddr *addr, int *len, int peer)
1053{ 997{
1054 struct sockaddr_l2 *la = (struct sockaddr_l2 *) addr; 998 struct sockaddr_l2 *la = (struct sockaddr_l2 *) addr;
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index ef9a60fda495..b19a386332fc 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -197,6 +197,62 @@ done:
197 return err; 197 return err;
198} 198}
199 199
200static int l2cap_sock_accept(struct socket *sock, struct socket *newsock, int flags)
201{
202 DECLARE_WAITQUEUE(wait, current);
203 struct sock *sk = sock->sk, *nsk;
204 long timeo;
205 int err = 0;
206
207 lock_sock_nested(sk, SINGLE_DEPTH_NESTING);
208
209 if (sk->sk_state != BT_LISTEN) {
210 err = -EBADFD;
211 goto done;
212 }
213
214 timeo = sock_rcvtimeo(sk, flags & O_NONBLOCK);
215
216 BT_DBG("sk %p timeo %ld", sk, timeo);
217
218 /* Wait for an incoming connection. (wake-one). */
219 add_wait_queue_exclusive(sk_sleep(sk), &wait);
220 while (!(nsk = bt_accept_dequeue(sk, newsock))) {
221 set_current_state(TASK_INTERRUPTIBLE);
222 if (!timeo) {
223 err = -EAGAIN;
224 break;
225 }
226
227 release_sock(sk);
228 timeo = schedule_timeout(timeo);
229 lock_sock_nested(sk, SINGLE_DEPTH_NESTING);
230
231 if (sk->sk_state != BT_LISTEN) {
232 err = -EBADFD;
233 break;
234 }
235
236 if (signal_pending(current)) {
237 err = sock_intr_errno(timeo);
238 break;
239 }
240 }
241 set_current_state(TASK_RUNNING);
242 remove_wait_queue(sk_sleep(sk), &wait);
243
244 if (err)
245 goto done;
246
247 newsock->state = SS_CONNECTED;
248
249 BT_DBG("new socket %p", nsk);
250
251done:
252 release_sock(sk);
253 return err;
254}
255
200static int l2cap_sock_release(struct socket *sock) 256static int l2cap_sock_release(struct socket *sock)
201{ 257{
202 struct sock *sk = sock->sk; 258 struct sock *sk = sock->sk;