mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-15 01:44:52 +00:00
[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>
This commit is contained in:
parent
c6ae522e3a
commit
bc1d6937e6
@ -50,6 +50,7 @@
|
|||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
#include <linux/usb.h>
|
#include <linux/usb.h>
|
||||||
#include <linux/crc32.h>
|
#include <linux/crc32.h>
|
||||||
|
#include <linux/kthread.h>
|
||||||
#include <net/irda/irda.h>
|
#include <net/irda/irda.h>
|
||||||
#include <net/irda/irlap.h>
|
#include <net/irda/irlap.h>
|
||||||
#include <net/irda/irda_device.h>
|
#include <net/irda/irda_device.h>
|
||||||
@ -173,9 +174,7 @@ struct stir_cb {
|
|||||||
struct qos_info qos;
|
struct qos_info qos;
|
||||||
unsigned speed; /* Current speed */
|
unsigned speed; /* Current speed */
|
||||||
|
|
||||||
wait_queue_head_t thr_wait; /* transmit thread wakeup */
|
struct task_struct *thread; /* transmit thread */
|
||||||
struct completion thr_exited;
|
|
||||||
pid_t thr_pid;
|
|
||||||
|
|
||||||
struct sk_buff *tx_pending;
|
struct sk_buff *tx_pending;
|
||||||
void *io_buf; /* transmit/receive buffer */
|
void *io_buf; /* transmit/receive buffer */
|
||||||
@ -577,7 +576,7 @@ static int stir_hard_xmit(struct sk_buff *skb, struct net_device *netdev)
|
|||||||
SKB_LINEAR_ASSERT(skb);
|
SKB_LINEAR_ASSERT(skb);
|
||||||
|
|
||||||
skb = xchg(&stir->tx_pending, skb);
|
skb = xchg(&stir->tx_pending, skb);
|
||||||
wake_up(&stir->thr_wait);
|
wake_up_process(stir->thread);
|
||||||
|
|
||||||
/* this should never happen unless stop/wakeup problem */
|
/* this should never happen unless stop/wakeup problem */
|
||||||
if (unlikely(skb)) {
|
if (unlikely(skb)) {
|
||||||
@ -753,13 +752,7 @@ static int stir_transmit_thread(void *arg)
|
|||||||
struct net_device *dev = stir->netdev;
|
struct net_device *dev = stir->netdev;
|
||||||
struct sk_buff *skb;
|
struct sk_buff *skb;
|
||||||
|
|
||||||
daemonize("%s", dev->name);
|
while (!kthread_should_stop()) {
|
||||||
allow_signal(SIGTERM);
|
|
||||||
|
|
||||||
while (netif_running(dev)
|
|
||||||
&& netif_device_present(dev)
|
|
||||||
&& !signal_pending(current))
|
|
||||||
{
|
|
||||||
#ifdef CONFIG_PM
|
#ifdef CONFIG_PM
|
||||||
/* if suspending, then power off and wait */
|
/* if suspending, then power off and wait */
|
||||||
if (unlikely(freezing(current))) {
|
if (unlikely(freezing(current))) {
|
||||||
@ -813,10 +806,11 @@ static int stir_transmit_thread(void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* sleep if nothing to send */
|
/* sleep if nothing to send */
|
||||||
wait_event_interruptible(stir->thr_wait, stir->tx_pending);
|
set_current_state(TASK_INTERRUPTIBLE);
|
||||||
}
|
schedule();
|
||||||
|
|
||||||
complete_and_exit (&stir->thr_exited, 0);
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -859,7 +853,7 @@ static void stir_rcv_irq(struct urb *urb, struct pt_regs *regs)
|
|||||||
warn("%s: usb receive submit error: %d",
|
warn("%s: usb receive submit error: %d",
|
||||||
stir->netdev->name, err);
|
stir->netdev->name, err);
|
||||||
stir->receiving = 0;
|
stir->receiving = 0;
|
||||||
wake_up(&stir->thr_wait);
|
wake_up_process(stir->thread);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -928,10 +922,10 @@ static int stir_net_open(struct net_device *netdev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Start kernel thread for transmit. */
|
/** Start kernel thread for transmit. */
|
||||||
stir->thr_pid = kernel_thread(stir_transmit_thread, stir,
|
stir->thread = kthread_run(stir_transmit_thread, stir,
|
||||||
CLONE_FS|CLONE_FILES);
|
"%s", stir->netdev->name);
|
||||||
if (stir->thr_pid < 0) {
|
if (IS_ERR(stir->thread)) {
|
||||||
err = stir->thr_pid;
|
err = PTR_ERR(stir->thread);
|
||||||
err("stir4200: unable to start kernel thread");
|
err("stir4200: unable to start kernel thread");
|
||||||
goto err_out6;
|
goto err_out6;
|
||||||
}
|
}
|
||||||
@ -968,8 +962,7 @@ static int stir_net_close(struct net_device *netdev)
|
|||||||
netif_stop_queue(netdev);
|
netif_stop_queue(netdev);
|
||||||
|
|
||||||
/* Kill transmit thread */
|
/* Kill transmit thread */
|
||||||
kill_proc(stir->thr_pid, SIGTERM, 1);
|
kthread_stop(stir->thread);
|
||||||
wait_for_completion(&stir->thr_exited);
|
|
||||||
kfree(stir->fifo_status);
|
kfree(stir->fifo_status);
|
||||||
|
|
||||||
/* Mop up receive urb's */
|
/* Mop up receive urb's */
|
||||||
@ -1084,9 +1077,6 @@ static int stir_probe(struct usb_interface *intf,
|
|||||||
stir->qos.min_turn_time.bits &= qos_mtt_bits;
|
stir->qos.min_turn_time.bits &= qos_mtt_bits;
|
||||||
irda_qos_bits_to_value(&stir->qos);
|
irda_qos_bits_to_value(&stir->qos);
|
||||||
|
|
||||||
init_completion (&stir->thr_exited);
|
|
||||||
init_waitqueue_head (&stir->thr_wait);
|
|
||||||
|
|
||||||
/* Override the network functions we need to use */
|
/* Override the network functions we need to use */
|
||||||
net->hard_start_xmit = stir_hard_xmit;
|
net->hard_start_xmit = stir_hard_xmit;
|
||||||
net->open = stir_net_open;
|
net->open = stir_net_open;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user