Commit 87a9404e authored by Neil Horman's avatar Neil Horman Committed by Greg Kroah-Hartman

staging: unisys: Clean up kthread usage

Remove the has_stopped completion as theres already one available
internally.

Correct the while loops

Remove the while loop in drain_queue as it already exists in the top level
loop
Signed-off-by: default avatarNeil Horman <nhorman@redhat.com>
Signed-off-by: default avatarBenjamin Romer <benjamin.romer@unisys.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 513e1cbd
...@@ -91,7 +91,6 @@ static struct visor_driver visornic_driver = { ...@@ -91,7 +91,6 @@ static struct visor_driver visornic_driver = {
struct visor_thread_info { struct visor_thread_info {
struct task_struct *task; struct task_struct *task;
struct completion has_stopped;
int id; int id;
}; };
...@@ -317,7 +316,6 @@ static int visor_thread_start(struct visor_thread_info *thrinfo, ...@@ -317,7 +316,6 @@ static int visor_thread_start(struct visor_thread_info *thrinfo,
void *thrcontext, char *name) void *thrcontext, char *name)
{ {
/* used to stop the thread */ /* used to stop the thread */
init_completion(&thrinfo->has_stopped);
thrinfo->task = kthread_run(threadfn, thrcontext, name); thrinfo->task = kthread_run(threadfn, thrcontext, name);
if (IS_ERR(thrinfo->task)) { if (IS_ERR(thrinfo->task)) {
pr_debug("%s failed (%ld)\n", pr_debug("%s failed (%ld)\n",
...@@ -341,9 +339,7 @@ static void visor_thread_stop(struct visor_thread_info *thrinfo) ...@@ -341,9 +339,7 @@ static void visor_thread_stop(struct visor_thread_info *thrinfo)
if (!thrinfo->id) if (!thrinfo->id)
return; /* thread not running */ return; /* thread not running */
kthread_stop(thrinfo->task); BUG_ON(kthread_stop(thrinfo->task));
/* give up if the thread has NOT died in 1 minute */
if (wait_for_completion_timeout(&thrinfo->has_stopped, 60 * HZ))
thrinfo->id = 0; thrinfo->id = 0;
} }
...@@ -1691,14 +1687,12 @@ drain_queue(struct uiscmdrsp *cmdrsp, struct visornic_devdata *devdata) ...@@ -1691,14 +1687,12 @@ drain_queue(struct uiscmdrsp *cmdrsp, struct visornic_devdata *devdata)
unsigned long flags; unsigned long flags;
struct net_device *netdev; struct net_device *netdev;
/* drain queue */
while (1) {
/* TODO: CLIENT ACQUIRE -- Don't really need this at the /* TODO: CLIENT ACQUIRE -- Don't really need this at the
* moment */ * moment */
if (!visorchannel_signalremove(devdata->dev->visorchannel, if (!visorchannel_signalremove(devdata->dev->visorchannel,
IOCHAN_FROM_IOPART, IOCHAN_FROM_IOPART,
cmdrsp)) cmdrsp))
break; /* queue empty */ return; /* queue empty */
switch (cmdrsp->net.type) { switch (cmdrsp->net.type) {
case NET_RCV: case NET_RCV:
...@@ -1749,6 +1743,8 @@ drain_queue(struct uiscmdrsp *cmdrsp, struct visornic_devdata *devdata) ...@@ -1749,6 +1743,8 @@ drain_queue(struct uiscmdrsp *cmdrsp, struct visornic_devdata *devdata)
devdata->enab_dis_acked = 1; devdata->enab_dis_acked = 1;
spin_unlock_irqrestore(&devdata->priv_lock, flags); spin_unlock_irqrestore(&devdata->priv_lock, flags);
if (kthread_should_stop())
break;
if (devdata->server_down && if (devdata->server_down &&
devdata->server_change_state) { devdata->server_change_state) {
/* Inform Linux that the link is up */ /* Inform Linux that the link is up */
...@@ -1780,10 +1776,6 @@ drain_queue(struct uiscmdrsp *cmdrsp, struct visornic_devdata *devdata) ...@@ -1780,10 +1776,6 @@ drain_queue(struct uiscmdrsp *cmdrsp, struct visornic_devdata *devdata)
break; break;
} }
/* cmdrsp is now available for reuse */ /* cmdrsp is now available for reuse */
if (kthread_should_stop())
break;
}
} }
/** /**
...@@ -1803,9 +1795,9 @@ process_incoming_rsps(void *v) ...@@ -1803,9 +1795,9 @@ process_incoming_rsps(void *v)
cmdrsp = kmalloc(SZ, GFP_ATOMIC); cmdrsp = kmalloc(SZ, GFP_ATOMIC);
if (!cmdrsp) if (!cmdrsp)
complete_and_exit(&devdata->threadinfo.has_stopped, 0); return 0;
while (1) { while (!kthread_should_stop()) {
wait_event_interruptible_timeout( wait_event_interruptible_timeout(
devdata->rsp_queue, (atomic_read( devdata->rsp_queue, (atomic_read(
&devdata->interrupt_rcvd) == 1), &devdata->interrupt_rcvd) == 1),
...@@ -1818,12 +1810,10 @@ process_incoming_rsps(void *v) ...@@ -1818,12 +1810,10 @@ process_incoming_rsps(void *v)
atomic_set(&devdata->interrupt_rcvd, 0); atomic_set(&devdata->interrupt_rcvd, 0);
send_rcv_posts_if_needed(devdata); send_rcv_posts_if_needed(devdata);
drain_queue(cmdrsp, devdata); drain_queue(cmdrsp, devdata);
if (kthread_should_stop())
break;
} }
kfree(cmdrsp); kfree(cmdrsp);
complete_and_exit(&devdata->threadinfo.has_stopped, 0); return 0;
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment