summaryrefslogtreecommitdiffstats
path: root/net/bluetooth/cmtp/core.c
diff options
context:
space:
mode:
authorJohn W. Linville <linville@tuxdriver.com>2011-08-22 14:20:09 -0400
committerJohn W. Linville <linville@tuxdriver.com>2011-08-22 14:20:09 -0400
commit4475a0a93f368e57d5306d4cbe9318e8c1c90c41 (patch)
treeb4b7b23d8939d3e764bf54026ae42205dc6850be /net/bluetooth/cmtp/core.c
parent16a9d06c753abc44f66f88e03bbecb3f1e45d71b (diff)
parent687beaa0d1d937c327e2f97b4b4fa6c23ca70624 (diff)
downloadop-kernel-dev-4475a0a93f368e57d5306d4cbe9318e8c1c90c41.zip
op-kernel-dev-4475a0a93f368e57d5306d4cbe9318e8c1c90c41.tar.gz
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/padovan/bluetooth
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 c5b11af..521baa4 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;
OpenPOWER on IntegriCloud