summaryrefslogtreecommitdiffstats
path: root/net/bluetooth/cmtp/core.c
diff options
context:
space:
mode:
authorJohn W. Linville <linville@tuxdriver.com>2011-08-26 10:33:51 -0400
committerJohn W. Linville <linville@tuxdriver.com>2011-08-26 10:33:51 -0400
commite2e6be56df37c371f564e127c154036b0c2211a1 (patch)
tree6687fc0340c20a76972bcaf5c665364c1074aee8 /net/bluetooth/cmtp/core.c
parentbc909d9ddbf7778371e36a651d6e4194b1cc7d4c (diff)
parent8b2a3827bb12430d932cd479b22d906baf08c212 (diff)
downloadlinux-e2e6be56df37c371f564e127c154036b0c2211a1.tar.bz2
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless into for-davem
Diffstat (limited to 'net/bluetooth/cmtp/core.c')
-rw-r--r--net/bluetooth/cmtp/core.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/net/bluetooth/cmtp/core.c b/net/bluetooth/cmtp/core.c
index c5b11af908be..521baa4fe835 100644
--- a/net/bluetooth/cmtp/core.c
+++ b/net/bluetooth/cmtp/core.c
@@ -292,9 +292,11 @@ static int cmtp_session(void *arg)
init_waitqueue_entry(&wait, current);
add_wait_queue(sk_sleep(sk), &wait);
- while (!kthread_should_stop()) {
+ while (1) {
set_current_state(TASK_INTERRUPTIBLE);
+ if (atomic_read(&session->terminate))
+ break;
if (sk->sk_state != BT_CONNECTED)
break;
@@ -307,7 +309,7 @@ static int cmtp_session(void *arg)
schedule();
}
- set_current_state(TASK_RUNNING);
+ __set_current_state(TASK_RUNNING);
remove_wait_queue(sk_sleep(sk), &wait);
down_write(&cmtp_session_sem);
@@ -380,16 +382,17 @@ int cmtp_add_connection(struct cmtp_connadd_req *req, struct socket *sock)
if (!(session->flags & (1 << CMTP_LOOPBACK))) {
err = cmtp_attach_device(session);
- if (err < 0)
- goto detach;
+ if (err < 0) {
+ atomic_inc(&session->terminate);
+ wake_up_process(session->task);
+ up_write(&cmtp_session_sem);
+ return err;
+ }
}
up_write(&cmtp_session_sem);
return 0;
-detach:
- cmtp_detach_device(session);
-
unlink:
__cmtp_unlink_session(session);
@@ -414,7 +417,8 @@ int cmtp_del_connection(struct cmtp_conndel_req *req)
skb_queue_purge(&session->transmit);
/* Stop session thread */
- kthread_stop(session->task);
+ atomic_inc(&session->terminate);
+ wake_up_process(session->task);
} else
err = -ENOENT;