diff options
author | Szymon Janc <szymon.janc@tieto.com> | 2011-04-05 09:37:45 -0400 |
---|---|---|
committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-04-05 11:40:46 -0400 |
commit | aabf6f897e44bdf3e237ada04aa8f88d77d75cac (patch) | |
tree | 33f3e53a9146b561a6f5e33e01a25c2dfe76c243 /net | |
parent | a88a9652d25a63ce10b6a5fe680d0ad8f33b9c9b (diff) |
Bluetooth: Use kthread API in hidp
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')
-rw-r--r-- | net/bluetooth/hidp/core.c | 53 | ||||
-rw-r--r-- | net/bluetooth/hidp/hidp.h | 2 |
2 files changed, 25 insertions, 30 deletions
diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c index a1472b75d62..ae6ebc6c348 100644 --- a/net/bluetooth/hidp/core.c +++ b/net/bluetooth/hidp/core.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <linux/init.h> | 37 | #include <linux/init.h> |
38 | #include <linux/wait.h> | 38 | #include <linux/wait.h> |
39 | #include <linux/mutex.h> | 39 | #include <linux/mutex.h> |
40 | #include <linux/kthread.h> | ||
40 | #include <net/sock.h> | 41 | #include <net/sock.h> |
41 | 42 | ||
42 | #include <linux/input.h> | 43 | #include <linux/input.h> |
@@ -463,8 +464,7 @@ static void hidp_idle_timeout(unsigned long arg) | |||
463 | { | 464 | { |
464 | struct hidp_session *session = (struct hidp_session *) arg; | 465 | struct hidp_session *session = (struct hidp_session *) arg; |
465 | 466 | ||
466 | atomic_inc(&session->terminate); | 467 | kthread_stop(session->task); |
467 | hidp_schedule(session); | ||
468 | } | 468 | } |
469 | 469 | ||
470 | static void hidp_set_timer(struct hidp_session *session) | 470 | static void hidp_set_timer(struct hidp_session *session) |
@@ -535,9 +535,7 @@ static void hidp_process_hid_control(struct hidp_session *session, | |||
535 | skb_queue_purge(&session->ctrl_transmit); | 535 | skb_queue_purge(&session->ctrl_transmit); |
536 | skb_queue_purge(&session->intr_transmit); | 536 | skb_queue_purge(&session->intr_transmit); |
537 | 537 | ||
538 | /* Kill session thread */ | 538 | kthread_stop(session->task); |
539 | atomic_inc(&session->terminate); | ||
540 | hidp_schedule(session); | ||
541 | } | 539 | } |
542 | } | 540 | } |
543 | 541 | ||
@@ -696,22 +694,10 @@ static int hidp_session(void *arg) | |||
696 | struct sock *ctrl_sk = session->ctrl_sock->sk; | 694 | struct sock *ctrl_sk = session->ctrl_sock->sk; |
697 | struct sock *intr_sk = session->intr_sock->sk; | 695 | struct sock *intr_sk = session->intr_sock->sk; |
698 | struct sk_buff *skb; | 696 | struct sk_buff *skb; |
699 | int vendor = 0x0000, product = 0x0000; | ||
700 | wait_queue_t ctrl_wait, intr_wait; | 697 | wait_queue_t ctrl_wait, intr_wait; |
701 | 698 | ||
702 | BT_DBG("session %p", session); | 699 | BT_DBG("session %p", session); |
703 | 700 | ||
704 | if (session->input) { | ||
705 | vendor = session->input->id.vendor; | ||
706 | product = session->input->id.product; | ||
707 | } | ||
708 | |||
709 | if (session->hid) { | ||
710 | vendor = session->hid->vendor; | ||
711 | product = session->hid->product; | ||
712 | } | ||
713 | |||
714 | daemonize("khidpd_%04x%04x", vendor, product); | ||
715 | set_user_nice(current, -15); | 701 | set_user_nice(current, -15); |
716 | 702 | ||
717 | init_waitqueue_entry(&ctrl_wait, current); | 703 | init_waitqueue_entry(&ctrl_wait, current); |
@@ -720,7 +706,7 @@ static int hidp_session(void *arg) | |||
720 | add_wait_queue(sk_sleep(intr_sk), &intr_wait); | 706 | add_wait_queue(sk_sleep(intr_sk), &intr_wait); |
721 | session->waiting_for_startup = 0; | 707 | session->waiting_for_startup = 0; |
722 | wake_up_interruptible(&session->startup_queue); | 708 | wake_up_interruptible(&session->startup_queue); |
723 | while (!atomic_read(&session->terminate)) { | 709 | while (!kthread_should_stop()) { |
724 | set_current_state(TASK_INTERRUPTIBLE); | 710 | set_current_state(TASK_INTERRUPTIBLE); |
725 | 711 | ||
726 | if (ctrl_sk->sk_state != BT_CONNECTED || | 712 | if (ctrl_sk->sk_state != BT_CONNECTED || |
@@ -968,6 +954,7 @@ fault: | |||
968 | int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock, struct socket *intr_sock) | 954 | int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock, struct socket *intr_sock) |
969 | { | 955 | { |
970 | struct hidp_session *session, *s; | 956 | struct hidp_session *session, *s; |
957 | int vendor, product; | ||
971 | int err; | 958 | int err; |
972 | 959 | ||
973 | BT_DBG(""); | 960 | BT_DBG(""); |
@@ -1029,9 +1016,24 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock, | |||
1029 | 1016 | ||
1030 | hidp_set_timer(session); | 1017 | hidp_set_timer(session); |
1031 | 1018 | ||
1032 | err = kernel_thread(hidp_session, session, CLONE_KERNEL); | 1019 | if (session->hid) { |
1033 | if (err < 0) | 1020 | vendor = session->hid->vendor; |
1021 | product = session->hid->product; | ||
1022 | } else if (session->input) { | ||
1023 | vendor = session->input->id.vendor; | ||
1024 | product = session->input->id.product; | ||
1025 | } else { | ||
1026 | vendor = 0x0000; | ||
1027 | product = 0x0000; | ||
1028 | } | ||
1029 | |||
1030 | session->task = kthread_run(hidp_session, session, "khidpd_%04x%04x", | ||
1031 | vendor, product); | ||
1032 | if (IS_ERR(session->task)) { | ||
1033 | err = PTR_ERR(session->task); | ||
1034 | goto unlink; | 1034 | goto unlink; |
1035 | } | ||
1036 | |||
1035 | while (session->waiting_for_startup) { | 1037 | while (session->waiting_for_startup) { |
1036 | wait_event_interruptible(session->startup_queue, | 1038 | wait_event_interruptible(session->startup_queue, |
1037 | !session->waiting_for_startup); | 1039 | !session->waiting_for_startup); |
@@ -1056,8 +1058,7 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock, | |||
1056 | err_add_device: | 1058 | err_add_device: |
1057 | hid_destroy_device(session->hid); | 1059 | hid_destroy_device(session->hid); |
1058 | session->hid = NULL; | 1060 | session->hid = NULL; |
1059 | atomic_inc(&session->terminate); | 1061 | kthread_stop(session->task); |
1060 | hidp_schedule(session); | ||
1061 | 1062 | ||
1062 | unlink: | 1063 | unlink: |
1063 | hidp_del_timer(session); | 1064 | hidp_del_timer(session); |
@@ -1108,13 +1109,7 @@ int hidp_del_connection(struct hidp_conndel_req *req) | |||
1108 | skb_queue_purge(&session->ctrl_transmit); | 1109 | skb_queue_purge(&session->ctrl_transmit); |
1109 | skb_queue_purge(&session->intr_transmit); | 1110 | skb_queue_purge(&session->intr_transmit); |
1110 | 1111 | ||
1111 | /* Wakeup user-space polling for socket errors */ | 1112 | kthread_stop(session->task); |
1112 | session->intr_sock->sk->sk_err = EUNATCH; | ||
1113 | session->ctrl_sock->sk->sk_err = EUNATCH; | ||
1114 | |||
1115 | /* Kill session thread */ | ||
1116 | atomic_inc(&session->terminate); | ||
1117 | hidp_schedule(session); | ||
1118 | } | 1113 | } |
1119 | } else | 1114 | } else |
1120 | err = -ENOENT; | 1115 | err = -ENOENT; |
diff --git a/net/bluetooth/hidp/hidp.h b/net/bluetooth/hidp/hidp.h index b412e7152ee..12822cde4b4 100644 --- a/net/bluetooth/hidp/hidp.h +++ b/net/bluetooth/hidp/hidp.h | |||
@@ -142,7 +142,7 @@ struct hidp_session { | |||
142 | uint ctrl_mtu; | 142 | uint ctrl_mtu; |
143 | uint intr_mtu; | 143 | uint intr_mtu; |
144 | 144 | ||
145 | atomic_t terminate; | 145 | struct task_struct *task; |
146 | 146 | ||
147 | unsigned char keys[8]; | 147 | unsigned char keys[8]; |
148 | unsigned char leds; | 148 | unsigned char leds; |