aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2006-05-25 19:20:19 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2006-06-18 00:26:20 -0400
commitbc1d6937e6cf4e81a5afeae2c9cf35ffb0905ba5 (patch)
treeb8cbfa60a9f296d24c0ca558906cd7457062bf97 /drivers
parentc6ae522e3a50fc1ec483d7f03ece9c7a25e6de95 (diff)
[IRDA]: stir4200, switching to the kthread API
stir4200 uses a kernel thread for its TX/RX operations, and it is now converted to the kernel kthread API. Tested on an STIR4200 based dongle. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Samuel Ortiz <samuel@sortiz.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/irda/stir4200.c38
1 files changed, 14 insertions, 24 deletions
diff --git a/drivers/net/irda/stir4200.c b/drivers/net/irda/stir4200.c
index 31867e4b891b..d61b208b52a2 100644
--- a/drivers/net/irda/stir4200.c
+++ b/drivers/net/irda/stir4200.c
@@ -50,6 +50,7 @@
50#include <linux/delay.h> 50#include <linux/delay.h>
51#include <linux/usb.h> 51#include <linux/usb.h>
52#include <linux/crc32.h> 52#include <linux/crc32.h>
53#include <linux/kthread.h>
53#include <net/irda/irda.h> 54#include <net/irda/irda.h>
54#include <net/irda/irlap.h> 55#include <net/irda/irlap.h>
55#include <net/irda/irda_device.h> 56#include <net/irda/irda_device.h>
@@ -173,9 +174,7 @@ struct stir_cb {
173 struct qos_info qos; 174 struct qos_info qos;
174 unsigned speed; /* Current speed */ 175 unsigned speed; /* Current speed */
175 176
176 wait_queue_head_t thr_wait; /* transmit thread wakeup */ 177 struct task_struct *thread; /* transmit thread */
177 struct completion thr_exited;
178 pid_t thr_pid;
179 178
180 struct sk_buff *tx_pending; 179 struct sk_buff *tx_pending;
181 void *io_buf; /* transmit/receive buffer */ 180 void *io_buf; /* transmit/receive buffer */
@@ -577,7 +576,7 @@ static int stir_hard_xmit(struct sk_buff *skb, struct net_device *netdev)
577 SKB_LINEAR_ASSERT(skb); 576 SKB_LINEAR_ASSERT(skb);
578 577
579 skb = xchg(&stir->tx_pending, skb); 578 skb = xchg(&stir->tx_pending, skb);
580 wake_up(&stir->thr_wait); 579 wake_up_process(stir->thread);
581 580
582 /* this should never happen unless stop/wakeup problem */ 581 /* this should never happen unless stop/wakeup problem */
583 if (unlikely(skb)) { 582 if (unlikely(skb)) {
@@ -753,13 +752,7 @@ static int stir_transmit_thread(void *arg)
753 struct net_device *dev = stir->netdev; 752 struct net_device *dev = stir->netdev;
754 struct sk_buff *skb; 753 struct sk_buff *skb;
755 754
756 daemonize("%s", dev->name); 755 while (!kthread_should_stop()) {
757 allow_signal(SIGTERM);
758
759 while (netif_running(dev)
760 && netif_device_present(dev)
761 && !signal_pending(current))
762 {
763#ifdef CONFIG_PM 756#ifdef CONFIG_PM
764 /* if suspending, then power off and wait */ 757 /* if suspending, then power off and wait */
765 if (unlikely(freezing(current))) { 758 if (unlikely(freezing(current))) {
@@ -813,10 +806,11 @@ static int stir_transmit_thread(void *arg)
813 } 806 }
814 807
815 /* sleep if nothing to send */ 808 /* sleep if nothing to send */
816 wait_event_interruptible(stir->thr_wait, stir->tx_pending); 809 set_current_state(TASK_INTERRUPTIBLE);
817 } 810 schedule();
818 811
819 complete_and_exit (&stir->thr_exited, 0); 812 }
813 return 0;
820} 814}
821 815
822 816
@@ -859,7 +853,7 @@ static void stir_rcv_irq(struct urb *urb, struct pt_regs *regs)
859 warn("%s: usb receive submit error: %d", 853 warn("%s: usb receive submit error: %d",
860 stir->netdev->name, err); 854 stir->netdev->name, err);
861 stir->receiving = 0; 855 stir->receiving = 0;
862 wake_up(&stir->thr_wait); 856 wake_up_process(stir->thread);
863 } 857 }
864} 858}
865 859
@@ -928,10 +922,10 @@ static int stir_net_open(struct net_device *netdev)
928 } 922 }
929 923
930 /** Start kernel thread for transmit. */ 924 /** Start kernel thread for transmit. */
931 stir->thr_pid = kernel_thread(stir_transmit_thread, stir, 925 stir->thread = kthread_run(stir_transmit_thread, stir,
932 CLONE_FS|CLONE_FILES); 926 "%s", stir->netdev->name);
933 if (stir->thr_pid < 0) { 927 if (IS_ERR(stir->thread)) {
934 err = stir->thr_pid; 928 err = PTR_ERR(stir->thread);
935 err("stir4200: unable to start kernel thread"); 929 err("stir4200: unable to start kernel thread");
936 goto err_out6; 930 goto err_out6;
937 } 931 }
@@ -968,8 +962,7 @@ static int stir_net_close(struct net_device *netdev)
968 netif_stop_queue(netdev); 962 netif_stop_queue(netdev);
969 963
970 /* Kill transmit thread */ 964 /* Kill transmit thread */
971 kill_proc(stir->thr_pid, SIGTERM, 1); 965 kthread_stop(stir->thread);
972 wait_for_completion(&stir->thr_exited);
973 kfree(stir->fifo_status); 966 kfree(stir->fifo_status);
974 967
975 /* Mop up receive urb's */ 968 /* Mop up receive urb's */
@@ -1084,9 +1077,6 @@ static int stir_probe(struct usb_interface *intf,
1084 stir->qos.min_turn_time.bits &= qos_mtt_bits; 1077 stir->qos.min_turn_time.bits &= qos_mtt_bits;
1085 irda_qos_bits_to_value(&stir->qos); 1078 irda_qos_bits_to_value(&stir->qos);
1086 1079
1087 init_completion (&stir->thr_exited);
1088 init_waitqueue_head (&stir->thr_wait);
1089
1090 /* Override the network functions we need to use */ 1080 /* Override the network functions we need to use */
1091 net->hard_start_xmit = stir_hard_xmit; 1081 net->hard_start_xmit = stir_hard_xmit;
1092 net->open = stir_net_open; 1082 net->open = stir_net_open;