[openib-general] [PATCH] amso1100/c2_vq.c : Corrected vq_wait_for_reply function

Pradipta Kumar Banerjee bpradip at in.ibm.com
Tue Apr 18 00:14:54 PDT 2006


Hi

This patch corrects the vq_wait_for_reply function so that it actually waits
for the reply till the timeout occurs.

Signed-off-by: Pradipta Kumar B <bpradip at in.ibm.com>
Signed-off-by: Krishna Kumar <krkumar2 at in.ibm.com>

---

Index: c2_vq.c
=====================================================================
--- c2_vq.c.org	2006-04-18 11:52:01.000000000 +0530
+++ c2_vq.c	2006-04-18 12:20:42.000000000 +0530
@@ -240,27 +240,12 @@ int vq_send_wr(struct c2_dev *c2dev, uni
  */
 int vq_wait_for_reply(struct c2_dev *c2dev, struct c2_vq_req *req)
 {
-	wait_queue_t __wait;
-	int rc = 0;
-
-	/*
-	 * Add this request to the wait queue.
-	 */
-	init_waitqueue_entry(&__wait, current);
-	add_wait_queue(&req->wait_object, &__wait);
-	for (;;) {
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		if (atomic_read(&req->reply_ready)) {
-			break;
-		}
-		if (schedule_timeout(60 * HZ) == 0) {
-			rc = -ETIMEDOUT;
-			break;
-		}
+	if (wait_event_timeout(req->wait_object,
+		(atomic_read(&req->reply_ready) == 1), 60*HZ) == 0) {
+		printk(KERN_ERR "Device timeout\n");
+		return -ETIMEDOUT;
 	}
-	set_current_state(TASK_RUNNING);
-	remove_wait_queue(&req->wait_object, &__wait);
-	return rc;
+	return 0;
 }
 
 /*



More information about the general mailing list