From: K. Y. Srinivasan Date: Tue, 10 May 2011 14:55:41 +0000 (-0700) Subject: Staging: hv: Use completion abstraction in struct netvsc_device X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=35abb21ace3413de6ea8d5c7750cedfd46111f0c;p=linux-beck.git Staging: hv: Use completion abstraction in struct netvsc_device Use completion abstraction in struct netvsc_device instead of struct wait_queue_head_t to synchronize. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Abhishek Kane Signed-off-by: Hank Janssen Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c index 832f62e70f5b..4eb448226ef1 100644 --- a/drivers/staging/hv/netvsc.c +++ b/drivers/staging/hv/netvsc.c @@ -213,6 +213,7 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device) static int netvsc_init_recv_buf(struct hv_device *device) { int ret = 0; + int t; struct netvsc_device *net_device; struct nvsp_message *init_packet; @@ -260,7 +261,6 @@ static int netvsc_init_recv_buf(struct hv_device *device) send_recv_buf.id = NETVSC_RECEIVE_BUFFER_ID; /* Send the gpadl notification request */ - net_device->wait_condition = 0; ret = vmbus_sendpacket(device->channel, init_packet, sizeof(struct nvsp_message), (unsigned long)init_packet, @@ -272,10 +272,8 @@ static int netvsc_init_recv_buf(struct hv_device *device) goto cleanup; } - wait_event_timeout(net_device->channel_init_wait, - net_device->wait_condition, - msecs_to_jiffies(1000)); - BUG_ON(net_device->wait_condition == 0); + t = wait_for_completion_timeout(&net_device->channel_init_wait, HZ); + BUG_ON(t == 0); /* Check the response */ @@ -394,6 +392,7 @@ static int netvsc_destroy_send_buf(struct netvsc_device *net_device) static int netvsc_init_send_buf(struct hv_device *device) { int ret = 0; + int t; struct netvsc_device *net_device; struct nvsp_message *init_packet; @@ -443,7 +442,6 @@ static int netvsc_init_send_buf(struct hv_device *device) NETVSC_SEND_BUFFER_ID; /* Send the gpadl notification request */ - net_device->wait_condition = 0; ret = vmbus_sendpacket(device->channel, init_packet, sizeof(struct nvsp_message), (unsigned long)init_packet, @@ -455,10 +453,9 @@ static int netvsc_init_send_buf(struct hv_device *device) goto cleanup; } - wait_event_timeout(net_device->channel_init_wait, - net_device->wait_condition, - msecs_to_jiffies(1000)); - BUG_ON(net_device->wait_condition == 0); + t = wait_for_completion_timeout(&net_device->channel_init_wait, HZ); + + BUG_ON(t == 0); /* Check the response */ if (init_packet->msg.v1_msg. @@ -487,7 +484,7 @@ exit: static int netvsc_connect_vsp(struct hv_device *device) { - int ret; + int ret, t; struct netvsc_device *net_device; struct nvsp_message *init_packet; int ndis_version; @@ -509,7 +506,6 @@ static int netvsc_connect_vsp(struct hv_device *device) NVSP_MAX_PROTOCOL_VERSION; /* Send the init request */ - net_device->wait_condition = 0; ret = vmbus_sendpacket(device->channel, init_packet, sizeof(struct nvsp_message), (unsigned long)init_packet, @@ -519,10 +515,9 @@ static int netvsc_connect_vsp(struct hv_device *device) if (ret != 0) goto cleanup; - wait_event_timeout(net_device->channel_init_wait, - net_device->wait_condition, - msecs_to_jiffies(1000)); - if (net_device->wait_condition == 0) { + t = wait_for_completion_timeout(&net_device->channel_init_wait, HZ); + + if (t == 0) { ret = -ETIMEDOUT; goto cleanup; } @@ -647,8 +642,7 @@ static void netvsc_send_completion(struct hv_device *device, /* Copy the response back */ memcpy(&net_device->channel_init_pkt, nvsp_packet, sizeof(struct nvsp_message)); - net_device->wait_condition = 1; - wake_up(&net_device->channel_init_wait); + complete(&net_device->channel_init_wait); } else if (nvsp_packet->hdr.msg_type == NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE) { /* Get the send context */ @@ -1123,7 +1117,7 @@ int netvsc_device_add(struct hv_device *device, void *additional_info) list_add_tail(&packet->list_ent, &net_device->recv_pkt_list); } - init_waitqueue_head(&net_device->channel_init_wait); + init_completion(&net_device->channel_init_wait); /* Open the channel */ ret = vmbus_open(device->channel, net_driver->ring_buf_size, diff --git a/drivers/staging/hv/netvsc.h b/drivers/staging/hv/netvsc.h index 45d24b9d91a1..9ebea3b802c1 100644 --- a/drivers/staging/hv/netvsc.h +++ b/drivers/staging/hv/netvsc.h @@ -318,8 +318,7 @@ struct netvsc_device { struct nvsp_1_receive_buffer_section *recv_section; /* Used for NetVSP initialization protocol */ - int wait_condition; - wait_queue_head_t channel_init_wait; + struct completion channel_init_wait; struct nvsp_message channel_init_pkt; struct nvsp_message revoke_packet;