diff options
author | Szymon Janc <szymon.janc@tieto.com> | 2011-03-21 09:20:06 -0400 |
---|---|---|
committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-04-05 11:40:47 -0400 |
commit | fada4ac33992b1f953d95584e36f6ca7860aea40 (patch) | |
tree | 2e5f23109278c91c8b90433c87556c5f996499ab /net/bluetooth | |
parent | f4d7cd4a4c25cb4a5c30a675d4cc0052c93b925a (diff) |
Bluetooth: Use kthread API in cmtp
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')
-rw-r--r-- | net/bluetooth/cmtp/capi.c | 6 | ||||
-rw-r--r-- | net/bluetooth/cmtp/cmtp.h | 9 | ||||
-rw-r--r-- | net/bluetooth/cmtp/core.c | 16 |
3 files changed, 13 insertions, 18 deletions
diff --git a/net/bluetooth/cmtp/capi.c b/net/bluetooth/cmtp/capi.c index 67cff810c77d..744233cba244 100644 --- a/net/bluetooth/cmtp/capi.c +++ b/net/bluetooth/cmtp/capi.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/ioctl.h> | 35 | #include <linux/ioctl.h> |
36 | #include <linux/file.h> | 36 | #include <linux/file.h> |
37 | #include <linux/wait.h> | 37 | #include <linux/wait.h> |
38 | #include <linux/kthread.h> | ||
38 | #include <net/sock.h> | 39 | #include <net/sock.h> |
39 | 40 | ||
40 | #include <linux/isdn/capilli.h> | 41 | #include <linux/isdn/capilli.h> |
@@ -143,7 +144,7 @@ static void cmtp_send_capimsg(struct cmtp_session *session, struct sk_buff *skb) | |||
143 | 144 | ||
144 | skb_queue_tail(&session->transmit, skb); | 145 | skb_queue_tail(&session->transmit, skb); |
145 | 146 | ||
146 | cmtp_schedule(session); | 147 | wake_up_interruptible(sk_sleep(session->sock->sk)); |
147 | } | 148 | } |
148 | 149 | ||
149 | static void cmtp_send_interopmsg(struct cmtp_session *session, | 150 | static void cmtp_send_interopmsg(struct cmtp_session *session, |
@@ -386,8 +387,7 @@ static void cmtp_reset_ctr(struct capi_ctr *ctrl) | |||
386 | 387 | ||
387 | capi_ctr_down(ctrl); | 388 | capi_ctr_down(ctrl); |
388 | 389 | ||
389 | atomic_inc(&session->terminate); | 390 | kthread_stop(session->task); |
390 | cmtp_schedule(session); | ||
391 | } | 391 | } |
392 | 392 | ||
393 | static void cmtp_register_appl(struct capi_ctr *ctrl, __u16 appl, capi_register_params *rp) | 393 | static void cmtp_register_appl(struct capi_ctr *ctrl, __u16 appl, capi_register_params *rp) |
diff --git a/net/bluetooth/cmtp/cmtp.h b/net/bluetooth/cmtp/cmtp.h index c6f78f89415c..db43b54ac9af 100644 --- a/net/bluetooth/cmtp/cmtp.h +++ b/net/bluetooth/cmtp/cmtp.h | |||
@@ -81,7 +81,7 @@ struct cmtp_session { | |||
81 | 81 | ||
82 | char name[BTNAMSIZ]; | 82 | char name[BTNAMSIZ]; |
83 | 83 | ||
84 | atomic_t terminate; | 84 | struct task_struct *task; |
85 | 85 | ||
86 | wait_queue_head_t wait; | 86 | wait_queue_head_t wait; |
87 | 87 | ||
@@ -121,13 +121,6 @@ void cmtp_detach_device(struct cmtp_session *session); | |||
121 | 121 | ||
122 | void cmtp_recv_capimsg(struct cmtp_session *session, struct sk_buff *skb); | 122 | void cmtp_recv_capimsg(struct cmtp_session *session, struct sk_buff *skb); |
123 | 123 | ||
124 | static inline void cmtp_schedule(struct cmtp_session *session) | ||
125 | { | ||
126 | struct sock *sk = session->sock->sk; | ||
127 | |||
128 | wake_up_interruptible(sk_sleep(sk)); | ||
129 | } | ||
130 | |||
131 | /* CMTP init defines */ | 124 | /* CMTP init defines */ |
132 | int cmtp_init_sockets(void); | 125 | int cmtp_init_sockets(void); |
133 | void cmtp_cleanup_sockets(void); | 126 | void cmtp_cleanup_sockets(void); |
diff --git a/net/bluetooth/cmtp/core.c b/net/bluetooth/cmtp/core.c index 16aa6bd039ba..cce99b0919f5 100644 --- a/net/bluetooth/cmtp/core.c +++ b/net/bluetooth/cmtp/core.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/ioctl.h> | 35 | #include <linux/ioctl.h> |
36 | #include <linux/file.h> | 36 | #include <linux/file.h> |
37 | #include <linux/init.h> | 37 | #include <linux/init.h> |
38 | #include <linux/kthread.h> | ||
38 | #include <net/sock.h> | 39 | #include <net/sock.h> |
39 | 40 | ||
40 | #include <linux/isdn/capilli.h> | 41 | #include <linux/isdn/capilli.h> |
@@ -287,12 +288,11 @@ static int cmtp_session(void *arg) | |||
287 | 288 | ||
288 | BT_DBG("session %p", session); | 289 | BT_DBG("session %p", session); |
289 | 290 | ||
290 | daemonize("kcmtpd_ctr_%d", session->num); | ||
291 | set_user_nice(current, -15); | 291 | set_user_nice(current, -15); |
292 | 292 | ||
293 | init_waitqueue_entry(&wait, current); | 293 | init_waitqueue_entry(&wait, current); |
294 | add_wait_queue(sk_sleep(sk), &wait); | 294 | add_wait_queue(sk_sleep(sk), &wait); |
295 | while (!atomic_read(&session->terminate)) { | 295 | while (!kthread_should_stop()) { |
296 | set_current_state(TASK_INTERRUPTIBLE); | 296 | set_current_state(TASK_INTERRUPTIBLE); |
297 | 297 | ||
298 | if (sk->sk_state != BT_CONNECTED) | 298 | if (sk->sk_state != BT_CONNECTED) |
@@ -370,9 +370,12 @@ int cmtp_add_connection(struct cmtp_connadd_req *req, struct socket *sock) | |||
370 | 370 | ||
371 | __cmtp_link_session(session); | 371 | __cmtp_link_session(session); |
372 | 372 | ||
373 | err = kernel_thread(cmtp_session, session, CLONE_KERNEL); | 373 | session->task = kthread_run(cmtp_session, session, "kcmtpd_ctr_%d", |
374 | if (err < 0) | 374 | session->num); |
375 | if (IS_ERR(session->task)) { | ||
376 | err = PTR_ERR(session->task); | ||
375 | goto unlink; | 377 | goto unlink; |
378 | } | ||
376 | 379 | ||
377 | if (!(session->flags & (1 << CMTP_LOOPBACK))) { | 380 | if (!(session->flags & (1 << CMTP_LOOPBACK))) { |
378 | err = cmtp_attach_device(session); | 381 | err = cmtp_attach_device(session); |
@@ -409,9 +412,8 @@ int cmtp_del_connection(struct cmtp_conndel_req *req) | |||
409 | /* Flush the transmit queue */ | 412 | /* Flush the transmit queue */ |
410 | skb_queue_purge(&session->transmit); | 413 | skb_queue_purge(&session->transmit); |
411 | 414 | ||
412 | /* Kill session thread */ | 415 | /* Stop session thread */ |
413 | atomic_inc(&session->terminate); | 416 | kthread_stop(session->task); |
414 | cmtp_schedule(session); | ||
415 | } else | 417 | } else |
416 | err = -ENOENT; | 418 | err = -ENOENT; |
417 | 419 | ||