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

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
Loading
Loading
Loading
Loading
+86 −96
Original line number Diff line number Diff line
@@ -91,7 +91,6 @@ static struct visor_driver visornic_driver = {

struct visor_thread_info {
	struct task_struct *task;
	struct completion has_stopped;
	int id;
};

@@ -317,7 +316,6 @@ static int visor_thread_start(struct visor_thread_info *thrinfo,
			      void *thrcontext, char *name)
{
	/* used to stop the thread */
	init_completion(&thrinfo->has_stopped);
	thrinfo->task = kthread_run(threadfn, thrcontext, name);
	if (IS_ERR(thrinfo->task)) {
		pr_debug("%s failed (%ld)\n",
@@ -341,9 +339,7 @@ static void visor_thread_stop(struct visor_thread_info *thrinfo)
	if (!thrinfo->id)
		return;	/* thread not running */

	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))
	BUG_ON(kthread_stop(thrinfo->task));
	thrinfo->id = 0;
}

@@ -1691,14 +1687,12 @@ drain_queue(struct uiscmdrsp *cmdrsp, struct visornic_devdata *devdata)
	unsigned long flags;
	struct net_device *netdev;

	/* drain queue */
	while (1) {
	/* TODO: CLIENT ACQUIRE -- Don't really need this at the
	 * moment */
	if (!visorchannel_signalremove(devdata->dev->visorchannel,
				       IOCHAN_FROM_IOPART,
				       cmdrsp))
			break; /* queue empty */
		return; /* queue empty */

	switch (cmdrsp->net.type) {
	case NET_RCV:
@@ -1749,6 +1743,8 @@ drain_queue(struct uiscmdrsp *cmdrsp, struct visornic_devdata *devdata)
		devdata->enab_dis_acked = 1;
		spin_unlock_irqrestore(&devdata->priv_lock, flags);

		if (kthread_should_stop())
			break;
		if (devdata->server_down &&
		    devdata->server_change_state) {
			/* Inform Linux that the link is up */
@@ -1780,10 +1776,6 @@ drain_queue(struct uiscmdrsp *cmdrsp, struct visornic_devdata *devdata)
		break;
	}
	/* cmdrsp is now available for reuse  */

		if (kthread_should_stop())
			break;
	}
}

/**
@@ -1803,9 +1795,9 @@ process_incoming_rsps(void *v)

	cmdrsp = kmalloc(SZ, GFP_ATOMIC);
	if (!cmdrsp)
		complete_and_exit(&devdata->threadinfo.has_stopped, 0);
		return 0;

	while (1) {
	while (!kthread_should_stop()) {
		wait_event_interruptible_timeout(
			devdata->rsp_queue, (atomic_read(
					     &devdata->interrupt_rcvd) == 1),
@@ -1818,12 +1810,10 @@ process_incoming_rsps(void *v)
		atomic_set(&devdata->interrupt_rcvd, 0);
		send_rcv_posts_if_needed(devdata);
		drain_queue(cmdrsp, devdata);
		if (kthread_should_stop())
			break;
	}

	kfree(cmdrsp);
	complete_and_exit(&devdata->threadinfo.has_stopped, 0);
	return 0;
}

/**