aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/bnep
diff options
context:
space:
mode:
authorSzymon Janc <szymon.janc@tieto.com>2011-03-21 09:20:00 -0400
committerGustavo F. Padovan <padovan@profusion.mobi>2011-04-05 11:40:47 -0400
commitf4d7cd4a4c25cb4a5c30a675d4cc0052c93b925a (patch)
treedfefefd66cf0383a438dce4bf12520611cb488f1 /net/bluetooth/bnep
parentaabf6f897e44bdf3e237ada04aa8f88d77d75cac (diff)
Bluetooth: Use kthread API in bnep
kernel_thread() is a low-level implementation detail and EXPORT_SYMBOL(kernel_thread) is scheduled for removal. Use the <linux/kthread.h> API instead. Signed-off-by: Szymon Janc <szymon.janc@tieto.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net/bluetooth/bnep')
-rw-r--r--net/bluetooth/bnep/bnep.h2
-rw-r--r--net/bluetooth/bnep/core.c21
2 files changed, 9 insertions, 14 deletions
diff --git a/net/bluetooth/bnep/bnep.h b/net/bluetooth/bnep/bnep.h
index d768e0434ed..8e6c06158f8 100644
--- a/net/bluetooth/bnep/bnep.h
+++ b/net/bluetooth/bnep/bnep.h
@@ -155,7 +155,7 @@ struct bnep_session {
155 unsigned int role; 155 unsigned int role;
156 unsigned long state; 156 unsigned long state;
157 unsigned long flags; 157 unsigned long flags;
158 atomic_t killed; 158 struct task_struct *task;
159 159
160 struct ethhdr eh; 160 struct ethhdr eh;
161 struct msghdr msg; 161 struct msghdr msg;
diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c
index 0a2e76bde54..ca39fcf010c 100644
--- a/net/bluetooth/bnep/core.c
+++ b/net/bluetooth/bnep/core.c
@@ -36,6 +36,7 @@
36#include <linux/errno.h> 36#include <linux/errno.h>
37#include <linux/net.h> 37#include <linux/net.h>
38#include <linux/slab.h> 38#include <linux/slab.h>
39#include <linux/kthread.h>
39#include <net/sock.h> 40#include <net/sock.h>
40 41
41#include <linux/socket.h> 42#include <linux/socket.h>
@@ -479,12 +480,11 @@ static int bnep_session(void *arg)
479 480
480 BT_DBG(""); 481 BT_DBG("");
481 482
482 daemonize("kbnepd %s", dev->name);
483 set_user_nice(current, -15); 483 set_user_nice(current, -15);
484 484
485 init_waitqueue_entry(&wait, current); 485 init_waitqueue_entry(&wait, current);
486 add_wait_queue(sk_sleep(sk), &wait); 486 add_wait_queue(sk_sleep(sk), &wait);
487 while (!atomic_read(&s->killed)) { 487 while (!kthread_should_stop()) {
488 set_current_state(TASK_INTERRUPTIBLE); 488 set_current_state(TASK_INTERRUPTIBLE);
489 489
490 /* RX */ 490 /* RX */
@@ -611,11 +611,12 @@ int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock)
611 611
612 __bnep_link_session(s); 612 __bnep_link_session(s);
613 613
614 err = kernel_thread(bnep_session, s, CLONE_KERNEL); 614 s->task = kthread_run(bnep_session, s, "kbnepd %s", dev->name);
615 if (err < 0) { 615 if (IS_ERR(s->task)) {
616 /* Session thread start failed, gotta cleanup. */ 616 /* Session thread start failed, gotta cleanup. */
617 unregister_netdev(dev); 617 unregister_netdev(dev);
618 __bnep_unlink_session(s); 618 __bnep_unlink_session(s);
619 err = PTR_ERR(s->task);
619 goto failed; 620 goto failed;
620 } 621 }
621 622
@@ -639,15 +640,9 @@ int bnep_del_connection(struct bnep_conndel_req *req)
639 down_read(&bnep_session_sem); 640 down_read(&bnep_session_sem);
640 641
641 s = __bnep_get_session(req->dst); 642 s = __bnep_get_session(req->dst);
642 if (s) { 643 if (s)
643 /* Wakeup user-space which is polling for socket errors. 644 kthread_stop(s->task);
644 * This is temporary hack until we have shutdown in L2CAP */ 645 else
645 s->sock->sk->sk_err = EUNATCH;
646
647 /* Kill session thread */
648 atomic_inc(&s->killed);
649 wake_up_interruptible(sk_sleep(s->sock->sk));
650 } else
651 err = -ENOENT; 646 err = -ENOENT;
652 647
653 up_read(&bnep_session_sem); 648 up_read(&bnep_session_sem);