Linux virtualization list
 help / color / mirror / Atom feed
* [PATCH 46/59] Staging: hv: netvsc: Cleanup error return codes in netvsc_destroy_recv_buf()
From: K. Y. Srinivasan @ 2011-08-25 16:49 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang
In-Reply-To: <1314290965-2698-1-git-send-email-kys@microsoft.com>

Cleanup error return codes in netvsc_destroy_recv_buf().

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index b89ac7e..baa0c8d 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -160,7 +160,7 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device)
 		if (ret != 0) {
 			dev_err(&net_device->dev->device, "unable to send "
 				"revoke receive buffer to netvsp");
-			return -1;
+			return ret;
 		}
 	}
 
@@ -175,7 +175,7 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device)
 		if (ret != 0) {
 			dev_err(&net_device->dev->device,
 				   "unable to teardown receive buffer's gpadl");
-			return -1;
+			return -ret;
 		}
 		net_device->recv_buf_gpadl_handle = 0;
 	}
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 47/59] Staging: hv: netvsc: Cleanup error return values in netvsc_init_recv_buf()
From: K. Y. Srinivasan @ 2011-08-25 16:49 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang
In-Reply-To: <1314290965-2698-1-git-send-email-kys@microsoft.com>

Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index baa0c8d..5703fd7 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -207,7 +207,7 @@ static int netvsc_init_recv_buf(struct hv_device *device)
 	if (!net_device) {
 		dev_err(&device->device, "unable to get net device..."
 			   "device being destroyed?");
-		return -1;
+		return -ENODEV;
 	}
 
 	net_device->recv_buf =
@@ -216,7 +216,7 @@ static int netvsc_init_recv_buf(struct hv_device *device)
 	if (!net_device->recv_buf) {
 		dev_err(&device->device, "unable to allocate receive "
 			"buffer of size %d", net_device->recv_buf_size);
-		ret = -1;
+		ret = -ENOMEM;
 		goto cleanup;
 	}
 
@@ -269,7 +269,7 @@ static int netvsc_init_recv_buf(struct hv_device *device)
 			   "initialzation with NetVsp - status %d",
 			   init_packet->msg.v1_msg.
 			   send_recv_buf_complete.status);
-		ret = -1;
+		ret = -EINVAL;
 		goto cleanup;
 	}
 
@@ -281,7 +281,7 @@ static int netvsc_init_recv_buf(struct hv_device *device)
 	net_device->recv_section = kmalloc(net_device->recv_section_cnt
 		* sizeof(struct nvsp_1_receive_buffer_section), GFP_KERNEL);
 	if (net_device->recv_section == NULL) {
-		ret = -1;
+		ret = -EINVAL;
 		goto cleanup;
 	}
 
@@ -297,7 +297,7 @@ static int netvsc_init_recv_buf(struct hv_device *device)
 	 */
 	if (net_device->recv_section_cnt != 1 ||
 	    net_device->recv_section->offset != 0) {
-		ret = -1;
+		ret = -EINVAL;
 		goto cleanup;
 	}
 
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 48/59] Staging: hv: netvsc: Cleanup error returns in netvsc_connect_vsp()
From: K. Y. Srinivasan @ 2011-08-25 16:49 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang
In-Reply-To: <1314290965-2698-1-git-send-email-kys@microsoft.com>

Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 5703fd7..9cc126b 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -323,7 +323,7 @@ static int netvsc_connect_vsp(struct hv_device *device)
 	if (!net_device) {
 		dev_err(&device->device, "unable to get net device..."
 			   "device being destroyed?");
-		return -1;
+		return -ENODEV;
 	}
 
 	init_packet = &net_device->channel_init_pkt;
@@ -354,13 +354,13 @@ static int netvsc_connect_vsp(struct hv_device *device)
 
 	if (init_packet->msg.init_msg.init_complete.status !=
 	    NVSP_STAT_SUCCESS) {
-		ret = -1;
+		ret = -EINVAL;
 		goto cleanup;
 	}
 
 	if (init_packet->msg.init_msg.init_complete.
 	    negotiated_protocol_ver != NVSP_PROTOCOL_VERSION_1) {
-		ret = -1;
+		ret = -EPROTO;
 		goto cleanup;
 	}
 	/* Send the ndis version */
@@ -381,10 +381,8 @@ static int netvsc_connect_vsp(struct hv_device *device)
 				sizeof(struct nvsp_message),
 				(unsigned long)init_packet,
 				VM_PKT_DATA_INBAND, 0);
-	if (ret != 0) {
-		ret = -1;
+	if (ret != 0)
 		goto cleanup;
-	}
 
 	/* Post the big receive buffer to NetVSP */
 	ret = netvsc_init_recv_buf(device);
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 49/59] Staging: hv: netvsc: Cleanup error return values in netvsc_send()
From: K. Y. Srinivasan @ 2011-08-25 16:49 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang
In-Reply-To: <1314290965-2698-1-git-send-email-kys@microsoft.com>

Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 9cc126b..f7f4957 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -409,7 +409,7 @@ int netvsc_device_remove(struct hv_device *device)
 	net_device = release_outbound_net_device(device);
 	if (!net_device) {
 		dev_err(&device->device, "No net device present!!");
-		return -1;
+		return -ENODEV;
 	}
 
 	/* Wait for all send completions */
@@ -499,7 +499,7 @@ int netvsc_send(struct hv_device *device,
 	if (!net_device) {
 		dev_err(&device->device, "net device (%p) shutting down..."
 			   "ignoring outbound packets", net_device);
-		return -2;
+		return -ENODEV;
 	}
 
 	sendMessage.hdr.msg_type = NVSP_MSG1_TYPE_SEND_RNDIS_PKT;
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 50/59] Staging: hv: netvsc: Cleanup error return codes in netvsc_device_add()
From: K. Y. Srinivasan @ 2011-08-25 16:49 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang
In-Reply-To: <1314290965-2698-1-git-send-email-kys@microsoft.com>

Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/netvsc.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index f7f4957..b6e1fb9 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -918,7 +918,7 @@ int netvsc_device_add(struct hv_device *device, void *additional_info)
 
 	net_device = alloc_net_device(device);
 	if (!net_device) {
-		ret = -1;
+		ret = -ENOMEM;
 		goto cleanup;
 	}
 
@@ -947,7 +947,6 @@ int netvsc_device_add(struct hv_device *device, void *additional_info)
 
 	if (ret != 0) {
 		dev_err(&device->device, "unable to open channel: %d", ret);
-		ret = -1;
 		goto cleanup;
 	}
 
@@ -959,7 +958,6 @@ int netvsc_device_add(struct hv_device *device, void *additional_info)
 	if (ret != 0) {
 		dev_err(&device->device,
 			"unable to connect to NetVSP - %d", ret);
-		ret = -1;
 		goto close;
 	}
 
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 51/59] Staging: hv: netvsc: Cleanup error codes in rndis_filter_receive()
From: K. Y. Srinivasan @ 2011-08-25 16:49 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang
In-Reply-To: <1314290965-2698-1-git-send-email-kys@microsoft.com>

Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/rndis_filter.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index dbb5201..8e1ef00 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -358,14 +358,14 @@ int rndis_filter_receive(struct hv_device *dev,
 	if (!net_dev->extension) {
 		dev_err(&dev->device, "got rndis message but no rndis device - "
 			  "dropping this message!\n");
-		return -1;
+		return -ENODEV;
 	}
 
 	rndis_dev = (struct rndis_device *)net_dev->extension;
 	if (rndis_dev->state == RNDIS_DEV_UNINITIALIZED) {
 		dev_err(&dev->device, "got rndis message but rndis device "
 			   "uninitialized...dropping this message!\n");
-		return -1;
+		return -ENODEV;
 	}
 
 	rndis_hdr = (struct rndis_message *)kmap_atomic(
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 52/59] Staging: hv: netvsc: Cleanup error code in rndis_filter_query_device()
From: K. Y. Srinivasan @ 2011-08-25 16:49 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang
In-Reply-To: <1314290965-2698-1-git-send-email-kys@microsoft.com>

Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/rndis_filter.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index 8e1ef00..f26886d 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -437,7 +437,7 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid,
 	request = get_rndis_request(dev, REMOTE_NDIS_QUERY_MSG,
 			RNDIS_MESSAGE_SIZE(struct rndis_query_request));
 	if (!request) {
-		ret = -1;
+		ret = -ENOMEM;
 		goto Cleanup;
 	}
 
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 53/59] Staging: hv: netvsc: Cleanup error return values in rndis_filter_set_packet_filter()
From: K. Y. Srinivasan @ 2011-08-25 16:49 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang
In-Reply-To: <1314290965-2698-1-git-send-email-kys@microsoft.com>

Use standard Linux error codes and cleanup some error paths.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/rndis_filter.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index f26886d..f5f3052 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -511,7 +511,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
 			RNDIS_MESSAGE_SIZE(struct rndis_set_request) +
 			sizeof(u32));
 	if (!request) {
-		ret = -1;
+		ret = -ENOMEM;
 		goto Cleanup;
 	}
 
@@ -531,7 +531,6 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
 	t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
 
 	if (t == 0) {
-		ret = -1;
 		dev_err(&dev->net_dev->dev->device,
 			"timeout before we got a set response...\n");
 		/*
@@ -540,8 +539,6 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
 		 */
 		goto Exit;
 	} else {
-		if (ret > 0)
-			ret = 0;
 		set_complete = &request->response_msg.msg.set_complete;
 		status = set_complete->status;
 	}
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 54/59] Staging: hv: netvsc: Cleanup error returns in rndis_filter_init_device()
From: K. Y. Srinivasan @ 2011-08-25 16:49 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang
In-Reply-To: <1314290965-2698-1-git-send-email-kys@microsoft.com>

Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/rndis_filter.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index f5f3052..a71f29d 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -562,7 +562,7 @@ static int rndis_filter_init_device(struct rndis_device *dev)
 	request = get_rndis_request(dev, REMOTE_NDIS_INITIALIZE_MSG,
 			RNDIS_MESSAGE_SIZE(struct rndis_initialize_request));
 	if (!request) {
-		ret = -1;
+		ret = -ENOMEM;
 		goto Cleanup;
 	}
 
@@ -596,7 +596,7 @@ static int rndis_filter_init_device(struct rndis_device *dev)
 		ret = 0;
 	} else {
 		dev->state = RNDIS_DEV_UNINITIALIZED;
-		ret = -1;
+		ret = -EINVAL;
 	}
 
 Cleanup:
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 55/59] Staging: hv: netvsc: Cleanup error code in rndis_filter_device_add()
From: K. Y. Srinivasan @ 2011-08-25 16:49 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang
In-Reply-To: <1314290965-2698-1-git-send-email-kys@microsoft.com>

Use standard Linux error codes.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/rndis_filter.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index a71f29d..f0d1362 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -673,7 +673,7 @@ int rndis_filter_device_add(struct hv_device *dev,
 
 	rndisDevice = get_rndis_device();
 	if (!rndisDevice)
-		return -1;
+		return -ENODEV;
 
 	/*
 	 * Let the inner driver handle this first to create the netvsc channel
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 56/59] Staging: hv: mouse: Change the jump label Cleanup to cleanup
From: K. Y. Srinivasan @ 2011-08-25 16:49 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang
In-Reply-To: <1314290965-2698-1-git-send-email-kys@microsoft.com>

Change the jump label "Cleanup" to "cleanup".

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_mouse.c |   22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 2e04948..cbb837b 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -338,7 +338,7 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
 
 	if (!input_device->hid_desc) {
 		pr_err("unable to allocate hid descriptor - size %d", desc->bLength);
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	memcpy(input_device->hid_desc, desc, desc->bLength);
@@ -351,7 +351,7 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
 	if (!input_device->report_desc) {
 		pr_err("unable to allocate report descriptor - size %d",
 			   input_device->report_desc_size);
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	memcpy(input_device->report_desc,
@@ -378,7 +378,7 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
 	if (ret != 0) {
 		pr_err("unable to send synthhid device info ack - ret %d",
 			   ret);
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	input_device->device_wait_condition = 1;
@@ -386,7 +386,7 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
 
 	return;
 
-Cleanup:
+cleanup:
 	kfree(input_device->hid_desc);
 	input_device->hid_desc = NULL;
 
@@ -605,7 +605,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 					VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
 	if (ret != 0) {
 		pr_err("unable to send synthhid protocol request.");
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	input_dev->protocol_wait_condition = 0;
@@ -613,7 +613,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 		input_dev->protocol_wait_condition, msecs_to_jiffies(1000));
 	if (input_dev->protocol_wait_condition == 0) {
 		ret = -ETIMEDOUT;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	response = &input_dev->protocol_resp;
@@ -622,7 +622,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 		pr_err("synthhid protocol request failed (version %d)",
 		       SYNTHHID_INPUT_VERSION);
 		ret = -1;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	input_dev->device_wait_condition = 0;
@@ -630,7 +630,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 		input_dev->device_wait_condition, msecs_to_jiffies(1000));
 	if (input_dev->device_wait_condition == 0) {
 		ret = -ETIMEDOUT;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	/*
@@ -642,7 +642,7 @@ static int mousevsc_connect_to_vsp(struct hv_device *device)
 	else
 		ret = -1;
 
-Cleanup:
+cleanup:
 	put_input_device(device);
 
 	return ret;
@@ -660,7 +660,7 @@ static int mousevsc_on_device_add(struct hv_device *device,
 
 	if (!input_dev) {
 		ret = -1;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	input_dev->init_complete = false;
@@ -713,7 +713,7 @@ static int mousevsc_on_device_add(struct hv_device *device,
 
 	input_dev->init_complete = true;
 
-Cleanup:
+cleanup:
 	return ret;
 }
 
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 57/59] Staging: hv: mouse: Get rid of  the unused  PCI signature
From: K. Y. Srinivasan @ 2011-08-25 16:49 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang
In-Reply-To: <1314290965-2698-1-git-send-email-kys@microsoft.com>

Get rid of  the unused  PCI signature in the mouse driver.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/hv_mouse.c |   22 ----------------------
 1 files changed, 0 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index cbb837b..a29a050 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -22,8 +22,6 @@
 #include <linux/input.h>
 #include <linux/hid.h>
 #include <linux/hiddev.h>
-#include <linux/pci.h>
-#include <linux/dmi.h>
 
 #include "hyperv.h"
 
@@ -956,26 +954,6 @@ static void __exit mousevsc_exit(void)
 	mousevsc_drv_exit();
 }
 
-/*
- * We don't want to automatically load this driver just yet, it's quite
- * broken.  It's safe if you want to load it yourself manually, but
- * don't inflict it on unsuspecting users, that's just mean.
- */
-#if 0
-
-/*
- * We use a PCI table to determine if we should autoload this driver  This is
- * needed by distro tools to determine if the hyperv drivers should be
- * installed and/or configured.  We don't do anything else with the table, but
- * it needs to be present.
- */
-static const struct pci_device_id microsoft_hv_pci_table[] = {
-	{ PCI_DEVICE(0x1414, 0x5353) },	/* VGA compatible controller */
-	{ 0 }
-};
-MODULE_DEVICE_TABLE(pci, microsoft_hv_pci_table);
-#endif
-
 MODULE_LICENSE("GPL");
 MODULE_VERSION(HV_DRV_VERSION);
 module_init(mousevsc_init);
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 58/59] Staging: hv: netvsc: Change the jump label Cleanup to cleanup
From: K. Y. Srinivasan @ 2011-08-25 16:49 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization; +Cc: Haiyang Zhang
In-Reply-To: <1314290965-2698-1-git-send-email-kys@microsoft.com>

Change the jump label "Cleanup" to "cleanup".

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/rndis_filter.c |   28 ++++++++++++++--------------
 1 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index f0d1362..79dfe78 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -438,7 +438,7 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid,
 			RNDIS_MESSAGE_SIZE(struct rndis_query_request));
 	if (!request) {
 		ret = -ENOMEM;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	/* Setup the rndis query */
@@ -450,12 +450,12 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid,
 
 	ret = rndis_filter_send_request(dev, request);
 	if (ret != 0)
-		goto Cleanup;
+		goto cleanup;
 
 	t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
 	if (t == 0) {
 		ret = -ETIMEDOUT;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	/* Copy the response back */
@@ -463,7 +463,7 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid,
 
 	if (query_complete->info_buflen > inresult_size) {
 		ret = -1;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	memcpy(result,
@@ -473,7 +473,7 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid,
 
 	*result_size = query_complete->info_buflen;
 
-Cleanup:
+cleanup:
 	if (request)
 		put_rndis_request(dev, request);
 
@@ -512,7 +512,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
 			sizeof(u32));
 	if (!request) {
 		ret = -ENOMEM;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	/* Setup the rndis set */
@@ -526,7 +526,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
 
 	ret = rndis_filter_send_request(dev, request);
 	if (ret != 0)
-		goto Cleanup;
+		goto cleanup;
 
 	t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
 
@@ -543,7 +543,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
 		status = set_complete->status;
 	}
 
-Cleanup:
+cleanup:
 	if (request)
 		put_rndis_request(dev, request);
 Exit:
@@ -563,7 +563,7 @@ static int rndis_filter_init_device(struct rndis_device *dev)
 			RNDIS_MESSAGE_SIZE(struct rndis_initialize_request));
 	if (!request) {
 		ret = -ENOMEM;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	/* Setup the rndis set */
@@ -578,7 +578,7 @@ static int rndis_filter_init_device(struct rndis_device *dev)
 	ret = rndis_filter_send_request(dev, request);
 	if (ret != 0) {
 		dev->state = RNDIS_DEV_UNINITIALIZED;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 
@@ -586,7 +586,7 @@ static int rndis_filter_init_device(struct rndis_device *dev)
 
 	if (t == 0) {
 		ret = -ETIMEDOUT;
-		goto Cleanup;
+		goto cleanup;
 	}
 
 	init_complete = &request->response_msg.msg.init_complete;
@@ -599,7 +599,7 @@ static int rndis_filter_init_device(struct rndis_device *dev)
 		ret = -EINVAL;
 	}
 
-Cleanup:
+cleanup:
 	if (request)
 		put_rndis_request(dev, request);
 
@@ -615,7 +615,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
 	request = get_rndis_request(dev, REMOTE_NDIS_HALT_MSG,
 				RNDIS_MESSAGE_SIZE(struct rndis_halt_request));
 	if (!request)
-		goto Cleanup;
+		goto cleanup;
 
 	/* Setup the rndis set */
 	halt = &request->request_msg.msg.halt_req;
@@ -626,7 +626,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
 
 	dev->state = RNDIS_DEV_UNINITIALIZED;
 
-Cleanup:
+cleanup:
 	if (request)
 		put_rndis_request(dev, request);
 	return;
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 59/59] Staging: hv: netvsc: Change the jump label Exit to exit
From: K. Y. Srinivasan @ 2011-08-25 16:49 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization
  Cc: K. Y. Srinivasan, Haiyang Zhang
In-Reply-To: <1314290965-2698-1-git-send-email-kys@microsoft.com>

Change the jump lable "Exit" to "exit".

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/rndis_filter.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index 79dfe78..6db48b9 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -537,7 +537,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
 		 * We can't deallocate the request since we may still receive a
 		 * send completion for it.
 		 */
-		goto Exit;
+		goto exit;
 	} else {
 		set_complete = &request->response_msg.msg.set_complete;
 		status = set_complete->status;
@@ -546,7 +546,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
 cleanup:
 	if (request)
 		put_rndis_request(dev, request);
-Exit:
+exit:
 	return ret;
 }
 
-- 
1.7.4.1

^ permalink raw reply related

* Re: [PATCH 06/59] Staging: hv: blkvsc: Use the newly introduced vmbus ID in the blockvsc driver
From: Greg KH @ 2011-08-25 17:36 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang
In-Reply-To: <1314290965-2698-6-git-send-email-kys@microsoft.com>

On Thu, Aug 25, 2011 at 09:48:32AM -0700, K. Y. Srinivasan wrote:
> Use the newly introduced vmbus ID in the blockvsc driver. Also, do
> the associated cleanup.
> 
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> ---
>  drivers/staging/hv/blkvsc_drv.c |   23 ++++++++++++++---------
>  1 files changed, 14 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
> index 018b293..9b99387 100644
> --- a/drivers/staging/hv/blkvsc_drv.c
> +++ b/drivers/staging/hv/blkvsc_drv.c
> @@ -111,14 +111,6 @@ struct block_device_context {
>  
>  static const char *drv_name = "blkvsc";
>  
> -/* {32412632-86cb-44a2-9b5c-50d1417354f5} */
> -static const uuid_le dev_type = {
> -	.b = {
> -		0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
> -		0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5
> -	}
> -};
> -
>  /*
>   * There is a circular dependency involving blkvsc_request_completion()
>   * and blkvsc_do_request().
> @@ -802,10 +794,24 @@ static void blkvsc_request(struct request_queue *queue)
>  	}
>  }
>  
> +static const struct hv_vmbus_device_id id_table[] = {
> +	{
> +		/* IDE guid */
> +		.guid = {
> +			0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
> +			0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5
> +		}
> +	},
> +	{
> +		.guid = { }
> +	},
> +};

Ah, so close, and yet, not quite :(

This should look like:

static const struct hv_vmbus_device_id id_table[] = {
	{
		/* IDE guid */
		.guid = {
			0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
			0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5
		}
	},
	{ },
};

No need to set the field name to nothing.

Hm, this could all be made even smaller with something like the
USB_DEVICE() macro.  How about this instead:

/* IDE guid */
static const struct hv_vmbus_device_id id_table[] = {
	{ VMBUS_DEVICE(0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
		       0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5) },
	{ },
};

That would be easier to read and understand, right?  Half the number of
lines as well, which is always nice.

If so, I'll go make that change here so you don't have to respin these.

thanks,

greg k-h

^ permalink raw reply

* RE: [PATCH 06/59] Staging: hv: blkvsc: Use the newly introduced vmbus ID in the blockvsc driver
From: KY Srinivasan @ 2011-08-25 17:52 UTC (permalink / raw)
  To: Greg KH
  Cc: gregkh@suse.de, linux-kernel@vger.kernel.org,
	devel@linuxdriverproject.org, virtualization@lists.osdl.org,
	Haiyang Zhang
In-Reply-To: <20110825173624.GA21334@kroah.com>



> -----Original Message-----
> From: Greg KH [mailto:greg@kroah.com]
> Sent: Thursday, August 25, 2011 1:36 PM
> To: KY Srinivasan
> Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> Subject: Re: [PATCH 06/59] Staging: hv: blkvsc: Use the newly introduced vmbus
> ID in the blockvsc driver
> 
> On Thu, Aug 25, 2011 at 09:48:32AM -0700, K. Y. Srinivasan wrote:
> > Use the newly introduced vmbus ID in the blockvsc driver. Also, do
> > the associated cleanup.
> >
> > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> > Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> > ---
> >  drivers/staging/hv/blkvsc_drv.c |   23 ++++++++++++++---------
> >  1 files changed, 14 insertions(+), 9 deletions(-)
> >
> > diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
> > index 018b293..9b99387 100644
> > --- a/drivers/staging/hv/blkvsc_drv.c
> > +++ b/drivers/staging/hv/blkvsc_drv.c
> > @@ -111,14 +111,6 @@ struct block_device_context {
> >
> >  static const char *drv_name = "blkvsc";
> >
> > -/* {32412632-86cb-44a2-9b5c-50d1417354f5} */
> > -static const uuid_le dev_type = {
> > -	.b = {
> > -		0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
> > -		0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5
> > -	}
> > -};
> > -
> >  /*
> >   * There is a circular dependency involving blkvsc_request_completion()
> >   * and blkvsc_do_request().
> > @@ -802,10 +794,24 @@ static void blkvsc_request(struct request_queue
> *queue)
> >  	}
> >  }
> >
> > +static const struct hv_vmbus_device_id id_table[] = {
> > +	{
> > +		/* IDE guid */
> > +		.guid = {
> > +			0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
> > +			0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5
> > +		}
> > +	},
> > +	{
> > +		.guid = { }
> > +	},
> > +};
> 
> Ah, so close, and yet, not quite :(
> 
> This should look like:
> 
> static const struct hv_vmbus_device_id id_table[] = {
> 	{
> 		/* IDE guid */
> 		.guid = {
> 			0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
> 			0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5
> 		}
> 	},
> 	{ },
> };
> 
> No need to set the field name to nothing.
> 
> Hm, this could all be made even smaller with something like the
> USB_DEVICE() macro.  How about this instead:
> 
> /* IDE guid */
> static const struct hv_vmbus_device_id id_table[] = {
> 	{ VMBUS_DEVICE(0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
> 		       0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5) },
> 	{ },
> };
> 
> That would be easier to read and understand, right?  Half the number of
> lines as well, which is always nice.
> 
> If so, I'll go make that change here so you don't have to respin these.

Looks great Greg. So you are going to add the VMBUS_DEVICE() macro?
Thanks for doing this.

Regards,

K. Y

^ permalink raw reply

* Re: [PATCH 06/59] Staging: hv: blkvsc: Use the newly introduced vmbus ID in the blockvsc driver
From: Greg KH @ 2011-08-25 18:46 UTC (permalink / raw)
  To: KY Srinivasan
  Cc: gregkh@suse.de, linux-kernel@vger.kernel.org,
	devel@linuxdriverproject.org, virtualization@lists.osdl.org,
	Haiyang Zhang
In-Reply-To: <6E21E5352C11B742B20C142EB499E048081B339F@TK5EX14MBXC126.redmond.corp.microsoft.com>

On Thu, Aug 25, 2011 at 05:52:10PM +0000, KY Srinivasan wrote:
> > No need to set the field name to nothing.
> > 
> > Hm, this could all be made even smaller with something like the
> > USB_DEVICE() macro.  How about this instead:
> > 
> > /* IDE guid */
> > static const struct hv_vmbus_device_id id_table[] = {
> > 	{ VMBUS_DEVICE(0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
> > 		       0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5) },
> > 	{ },
> > };
> > 
> > That would be easier to read and understand, right?  Half the number of
> > lines as well, which is always nice.
> > 
> > If so, I'll go make that change here so you don't have to respin these.
> 
> Looks great Greg. So you are going to add the VMBUS_DEVICE() macro?

Yes, I've now done so and pushed out the changes, which you have been
copied on, including a bug fix that I needed to make when I added the
driver_data field to the hv_vmbus_device_id structure.

I'll review the rest of the series after lunch.

thanks,

greg k-h

^ permalink raw reply

* RE: [PATCH 06/59] Staging: hv: blkvsc: Use the newly introduced vmbus ID in the blockvsc driver
From: KY Srinivasan @ 2011-08-25 18:50 UTC (permalink / raw)
  To: Greg KH
  Cc: devel@linuxdriverproject.org, Haiyang Zhang, gregkh@suse.de,
	linux-kernel@vger.kernel.org, virtualization@lists.osdl.org
In-Reply-To: <20110825184612.GA1891@kroah.com>



> -----Original Message-----
> From: Greg KH [mailto:greg@kroah.com]
> Sent: Thursday, August 25, 2011 2:46 PM
> To: KY Srinivasan
> Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> Subject: Re: [PATCH 06/59] Staging: hv: blkvsc: Use the newly introduced vmbus
> ID in the blockvsc driver
> 
> On Thu, Aug 25, 2011 at 05:52:10PM +0000, KY Srinivasan wrote:
> > > No need to set the field name to nothing.
> > >
> > > Hm, this could all be made even smaller with something like the
> > > USB_DEVICE() macro.  How about this instead:
> > >
> > > /* IDE guid */
> > > static const struct hv_vmbus_device_id id_table[] = {
> > > 	{ VMBUS_DEVICE(0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
> > > 		       0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5) },
> > > 	{ },
> > > };
> > >
> > > That would be easier to read and understand, right?  Half the number of
> > > lines as well, which is always nice.
> > >
> > > If so, I'll go make that change here so you don't have to respin these.
> >
> > Looks great Greg. So you are going to add the VMBUS_DEVICE() macro?
> 
> Yes, I've now done so and pushed out the changes, which you have been
> copied on, including a bug fix that I needed to make when I added the
> driver_data field to the hv_vmbus_device_id structure.
> 
> I'll review the rest of the series after lunch.

Thanks Greg.

K. Y

^ permalink raw reply

* Re: [PATCH 06/59] Staging: hv: blkvsc: Use the newly introduced vmbus ID in the blockvsc driver
From: Greg KH @ 2011-08-25 20:43 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang
In-Reply-To: <1314290965-2698-6-git-send-email-kys@microsoft.com>

On Thu, Aug 25, 2011 at 09:48:32AM -0700, K. Y. Srinivasan wrote:
> Use the newly introduced vmbus ID in the blockvsc driver. Also, do
> the associated cleanup.
> 
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> ---
>  drivers/staging/hv/blkvsc_drv.c |   23 ++++++++++++++---------
>  1 files changed, 14 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
> index 018b293..9b99387 100644
> --- a/drivers/staging/hv/blkvsc_drv.c
> +++ b/drivers/staging/hv/blkvsc_drv.c
> @@ -111,14 +111,6 @@ struct block_device_context {
>  
>  static const char *drv_name = "blkvsc";
>  
> -/* {32412632-86cb-44a2-9b5c-50d1417354f5} */
> -static const uuid_le dev_type = {
> -	.b = {
> -		0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
> -		0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5
> -	}
> -};
> -
>  /*
>   * There is a circular dependency involving blkvsc_request_completion()
>   * and blkvsc_do_request().
> @@ -802,10 +794,24 @@ static void blkvsc_request(struct request_queue *queue)
>  	}
>  }
>  
> +static const struct hv_vmbus_device_id id_table[] = {
> +	{
> +		/* IDE guid */
> +		.guid = {
> +			0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
> +			0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5
> +		}
> +	},
> +	{
> +		.guid = { }
> +	},
> +};
>  
> +MODULE_DEVICE_TABLE(vmbus, id_table);
>  
>  /* The one and only one */
>  static  struct hv_driver blkvsc_drv = {
> +	.id_table = id_table,
>  	.probe =  blkvsc_probe,
>  	.remove =  blkvsc_remove,
>  	.shutdown = blkvsc_shutdown,
> @@ -829,7 +835,6 @@ static int blkvsc_drv_init(void)
>  
>  	BUILD_BUG_ON(sizeof(sector_t) != 8);
>  
> -	memcpy(&drv->dev_type, &dev_type, sizeof(uuid_le));

If I'm not mistaken, the driver just broke now and will not bind
properly to this device, right?

Ick, oh well, I'll plod on and hope that you fix this issue up in a
later patch, but note that this might make 'git bisect' cause problems
if someone lands in the middle of this series with things broken
(run-time, not build time).

Sorry, I should have caught that first time through this series, I
didn't realize it until right now when I tried it.

greg k-h

^ permalink raw reply

* Re: [PATCH 12/59] Staging: hv: vmbus: Cleanup vmbus_uevent() code
From: Greg KH @ 2011-08-25 20:59 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: devel, Haiyang Zhang, gregkh, linux-kernel, virtualization
In-Reply-To: <1314290965-2698-12-git-send-email-kys@microsoft.com>

On Thu, Aug 25, 2011 at 09:48:38AM -0700, K. Y. Srinivasan wrote:
> Now generate appropriate uevent based on the modalias string. As part of this,
> cleanup the existing uevent code.
> 
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> ---
>  drivers/staging/hv/vmbus_drv.c |   60 ++++++++--------------------------------
>  1 files changed, 12 insertions(+), 48 deletions(-)
> 
> diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
> index b651968..a6e7dc5 100644
> --- a/drivers/staging/hv/vmbus_drv.c
> +++ b/drivers/staging/hv/vmbus_drv.c
> @@ -237,58 +237,22 @@ static struct device_attribute vmbus_device_attrs[] = {
>   * This routine is invoked when a device is added or removed on the vmbus to
>   * generate a uevent to udev in the userspace. The udev will then look at its
>   * rule and the uevent generated here to load the appropriate driver
> + *
> + * The alias string will be of the form vmbus:guid where guid is the string
> + * representation of the device guid (each byte of the guid will be
> + * represented with two hex characters.
>   */
>  static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env)
>  {
>  	struct hv_device *dev = device_to_hv_device(device);
> -	int ret;
> -
> -	ret = add_uevent_var(env, "VMBUS_DEVICE_CLASS_GUID={"
> -			     "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
> -			     "%02x%02x%02x%02x%02x%02x%02x%02x}",
> -			     dev->dev_type.b[3],
> -			     dev->dev_type.b[2],
> -			     dev->dev_type.b[1],
> -			     dev->dev_type.b[0],
> -			     dev->dev_type.b[5],
> -			     dev->dev_type.b[4],
> -			     dev->dev_type.b[7],
> -			     dev->dev_type.b[6],
> -			     dev->dev_type.b[8],
> -			     dev->dev_type.b[9],
> -			     dev->dev_type.b[10],
> -			     dev->dev_type.b[11],
> -			     dev->dev_type.b[12],
> -			     dev->dev_type.b[13],
> -			     dev->dev_type.b[14],
> -			     dev->dev_type.b[15]);
> -
> -	if (ret)
> -		return ret;
> +	int i, ret;
> +	char alias_name[((sizeof(struct hv_vmbus_device_id) + 1)) * 2];
>  
> -	ret = add_uevent_var(env, "VMBUS_DEVICE_DEVICE_GUID={"
> -			     "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
> -			     "%02x%02x%02x%02x%02x%02x%02x%02x}",
> -			     dev->dev_instance.b[3],
> -			     dev->dev_instance.b[2],
> -			     dev->dev_instance.b[1],
> -			     dev->dev_instance.b[0],
> -			     dev->dev_instance.b[5],
> -			     dev->dev_instance.b[4],
> -			     dev->dev_instance.b[7],
> -			     dev->dev_instance.b[6],
> -			     dev->dev_instance.b[8],
> -			     dev->dev_instance.b[9],
> -			     dev->dev_instance.b[10],
> -			     dev->dev_instance.b[11],
> -			     dev->dev_instance.b[12],
> -			     dev->dev_instance.b[13],
> -			     dev->dev_instance.b[14],
> -			     dev->dev_instance.b[15]);
> -	if (ret)
> -		return ret;
> +	for (i = 0; i < (sizeof(struct hv_vmbus_device_id) * 2); i += 2)
> +		sprintf(&alias_name[i], "%02x", dev->dev_type.b[i/2]);

I have to edit this to get it to work properly with the fact that I
added the driver_data field to hv_vmbus_device_id.

Arguably, one could say that this patch was always broken as you were
assuming the size of an individual field was the same size as the whole
structure, which I don't think is always the case, or at least it's not
a safe thing to assume :)

thanks,

greg k-h

^ permalink raw reply

* Re: [PATCH 12/59] Staging: hv: vmbus: Cleanup vmbus_uevent() code
From: Greg KH @ 2011-08-25 21:15 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: devel, Haiyang Zhang, gregkh, linux-kernel, virtualization
In-Reply-To: <20110825205930.GA10883@kroah.com>

On Thu, Aug 25, 2011 at 01:59:30PM -0700, Greg KH wrote:
> On Thu, Aug 25, 2011 at 09:48:38AM -0700, K. Y. Srinivasan wrote:
> > Now generate appropriate uevent based on the modalias string. As part of this,
> > cleanup the existing uevent code.
> > 
> > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> > Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> > ---
> >  drivers/staging/hv/vmbus_drv.c |   60 ++++++++--------------------------------
> >  1 files changed, 12 insertions(+), 48 deletions(-)
> > 
> > diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
> > index b651968..a6e7dc5 100644
> > --- a/drivers/staging/hv/vmbus_drv.c
> > +++ b/drivers/staging/hv/vmbus_drv.c
> > @@ -237,58 +237,22 @@ static struct device_attribute vmbus_device_attrs[] = {
> >   * This routine is invoked when a device is added or removed on the vmbus to
> >   * generate a uevent to udev in the userspace. The udev will then look at its
> >   * rule and the uevent generated here to load the appropriate driver
> > + *
> > + * The alias string will be of the form vmbus:guid where guid is the string
> > + * representation of the device guid (each byte of the guid will be
> > + * represented with two hex characters.
> >   */
> >  static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env)
> >  {
> >  	struct hv_device *dev = device_to_hv_device(device);
> > -	int ret;
> > -
> > -	ret = add_uevent_var(env, "VMBUS_DEVICE_CLASS_GUID={"
> > -			     "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
> > -			     "%02x%02x%02x%02x%02x%02x%02x%02x}",
> > -			     dev->dev_type.b[3],
> > -			     dev->dev_type.b[2],
> > -			     dev->dev_type.b[1],
> > -			     dev->dev_type.b[0],
> > -			     dev->dev_type.b[5],
> > -			     dev->dev_type.b[4],
> > -			     dev->dev_type.b[7],
> > -			     dev->dev_type.b[6],
> > -			     dev->dev_type.b[8],
> > -			     dev->dev_type.b[9],
> > -			     dev->dev_type.b[10],
> > -			     dev->dev_type.b[11],
> > -			     dev->dev_type.b[12],
> > -			     dev->dev_type.b[13],
> > -			     dev->dev_type.b[14],
> > -			     dev->dev_type.b[15]);
> > -
> > -	if (ret)
> > -		return ret;
> > +	int i, ret;
> > +	char alias_name[((sizeof(struct hv_vmbus_device_id) + 1)) * 2];
> >  
> > -	ret = add_uevent_var(env, "VMBUS_DEVICE_DEVICE_GUID={"
> > -			     "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
> > -			     "%02x%02x%02x%02x%02x%02x%02x%02x}",
> > -			     dev->dev_instance.b[3],
> > -			     dev->dev_instance.b[2],
> > -			     dev->dev_instance.b[1],
> > -			     dev->dev_instance.b[0],
> > -			     dev->dev_instance.b[5],
> > -			     dev->dev_instance.b[4],
> > -			     dev->dev_instance.b[7],
> > -			     dev->dev_instance.b[6],
> > -			     dev->dev_instance.b[8],
> > -			     dev->dev_instance.b[9],
> > -			     dev->dev_instance.b[10],
> > -			     dev->dev_instance.b[11],
> > -			     dev->dev_instance.b[12],
> > -			     dev->dev_instance.b[13],
> > -			     dev->dev_instance.b[14],
> > -			     dev->dev_instance.b[15]);
> > -	if (ret)
> > -		return ret;
> > +	for (i = 0; i < (sizeof(struct hv_vmbus_device_id) * 2); i += 2)
> > +		sprintf(&alias_name[i], "%02x", dev->dev_type.b[i/2]);
> 
> I have to edit this to get it to work properly with the fact that I
> added the driver_data field to hv_vmbus_device_id.

You should have a copy of the patch I applied in your inbox now, can you
verify I didn't mess it up?

thanks,

greg k-h

^ permalink raw reply

* Re: [PATCH 22/59] Staging: hv: vmbus: Get rid of the unused name field in struct hv_driver
From: Greg KH @ 2011-08-25 21:24 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang
In-Reply-To: <1314290965-2698-22-git-send-email-kys@microsoft.com>

On Thu, Aug 25, 2011 at 09:48:48AM -0700, K. Y. Srinivasan wrote:
> Get rid of the unused "name" field in struct hv_driver.
> 
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> ---
>  drivers/staging/hv/hyperv.h |    2 --
>  1 files changed, 0 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/hv/hyperv.h b/drivers/staging/hv/hyperv.h
> index b8199f4..60ead66 100644
> --- a/drivers/staging/hv/hyperv.h
> +++ b/drivers/staging/hv/hyperv.h
> @@ -802,8 +802,6 @@ struct hv_device_info {
>  
>  /* Base driver object */
>  struct hv_driver {
> -	const char *name;

Wait, why is this unused?  What are you going to use as your name for
the driver in sysfs then?  The module name?

As much as I love seeing things deleted, I really think you need this
field.

Ah, yeah, I see why you think it's unneeded, crud like this in the
drivers:

	drv->driver.name = driver_name;

No vmbus driver should ever have to touch the base struct driver on it's
own at all.  Your vmbus core should properly handle telling the driver
core what the name of the driver is.

As an example, see the __pci_register_driver() function, the first thing
that code does is set the name based on the name of the larger
pci_driver structure passed to it.

Man, if you want something done right, you have to do it yourself, let
me go make these changes so you don't have to do any new work at this
point in time, hopefully your other patches will apply...

greg k-h

^ permalink raw reply

* Re: [PATCH 22/59] Staging: hv: vmbus: Get rid of the unused name field in struct hv_driver
From: Greg KH @ 2011-08-25 21:28 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang
In-Reply-To: <20110825212428.GA1617@kroah.com>

On Thu, Aug 25, 2011 at 02:24:28PM -0700, Greg KH wrote:
> On Thu, Aug 25, 2011 at 09:48:48AM -0700, K. Y. Srinivasan wrote:
> > Get rid of the unused "name" field in struct hv_driver.
> > 
> > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> > Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> > ---
> >  drivers/staging/hv/hyperv.h |    2 --
> >  1 files changed, 0 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/staging/hv/hyperv.h b/drivers/staging/hv/hyperv.h
> > index b8199f4..60ead66 100644
> > --- a/drivers/staging/hv/hyperv.h
> > +++ b/drivers/staging/hv/hyperv.h
> > @@ -802,8 +802,6 @@ struct hv_device_info {
> >  
> >  /* Base driver object */
> >  struct hv_driver {
> > -	const char *name;
> 
> Wait, why is this unused?  What are you going to use as your name for
> the driver in sysfs then?  The module name?
> 
> As much as I love seeing things deleted, I really think you need this
> field.
> 
> Ah, yeah, I see why you think it's unneeded, crud like this in the
> drivers:
> 
> 	drv->driver.name = driver_name;
> 
> No vmbus driver should ever have to touch the base struct driver on it's
> own at all.  Your vmbus core should properly handle telling the driver
> core what the name of the driver is.
> 
> As an example, see the __pci_register_driver() function, the first thing
> that code does is set the name based on the name of the larger
> pci_driver structure passed to it.
> 
> Man, if you want something done right, you have to do it yourself, let
> me go make these changes so you don't have to do any new work at this
> point in time, hopefully your other patches will apply...

What, vmbus_child_driver_register() takes a struct driver *?

No wonder things are so messed up here, and why you got confused.  Let
me pound on this for a bit to see if I can get it cleaned up to be more
"sane"...

greg k-h

^ permalink raw reply

* Re: [PATCH 22/59] Staging: hv: vmbus: Get rid of the unused name field in struct hv_driver
From: Greg KH @ 2011-08-25 22:11 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: Hank Janssen, devel, Haiyang Zhang, gregkh, linux-kernel,
	virtualization
In-Reply-To: <20110825212820.GA6770@kroah.com>

On Thu, Aug 25, 2011 at 02:28:20PM -0700, Greg KH wrote:
> > Man, if you want something done right, you have to do it yourself, let
> > me go make these changes so you don't have to do any new work at this
> > point in time, hopefully your other patches will apply...
> 
> What, vmbus_child_driver_register() takes a struct driver *?
> 
> No wonder things are so messed up here, and why you got confused.  Let
> me pound on this for a bit to see if I can get it cleaned up to be more
> "sane"...

Ok, here's what I'm talking about.  It properly hooks up the module
reference counting issues that you had yet to take care of as well (see,
you got that for free just by getting the logic correct, and the code is
even smaller than before overall, it's a win-win all around...)

The patch below works for me, I've committed it and will work out how to
apply the rest of your patch series now.

-----------------

From: Greg Kroah-Hartman <gregkh@suse.de>
Date: Thu, 25 Aug 2011 15:07:32 -0700
Subject: Staging: hv: fix up driver registering mess

Individual drivers should never be touching the 'struct device' field,
so if that is a requirement to pass to the vmbus core, you know
something is wrong.

This patch fixes that all up, and resolves the problem where the module
reference counting was not happening properly for the individual drivers
as well.  Overall, it reduces the lines of code the individual drivers
have to have, which tells you that this is the correct thing to do.

Also, somehow the _GPL marking for the functions got removed on an older
patch.  As the name of the function was changing, properly change the
_GPL marking as well at the same time.

Cc: K. Y. Srinivasan <kys@microsoft.com>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Cc: Hank Janssen <hjanssen@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
 drivers/staging/hv/blkvsc_drv.c  |   17 ++------------
 drivers/staging/hv/hv_mouse.c    |   21 ++---------------
 drivers/staging/hv/hv_util.c     |    9 ++-----
 drivers/staging/hv/hyperv.h      |    8 +++++-
 drivers/staging/hv/hyperv_net.h  |    1 -
 drivers/staging/hv/netvsc.c      |   14 ------------
 drivers/staging/hv/netvsc_drv.c  |   19 ++--------------
 drivers/staging/hv/storvsc_drv.c |   24 ++++++---------------
 drivers/staging/hv/vmbus_drv.c   |   43 ++++++++++++++++++-------------------
 9 files changed, 46 insertions(+), 110 deletions(-)

diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index d170f24..07dc9ed 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -109,7 +109,6 @@ struct block_device_context {
 	int users;
 };
 
-static const char *drv_name = "blkvsc";
 
 /*
  * There is a circular dependency involving blkvsc_request_completion()
@@ -805,6 +804,7 @@ MODULE_DEVICE_TABLE(vmbus, id_table);
 
 /* The one and only one */
 static  struct hv_driver blkvsc_drv = {
+	.name = "blkvsc",
 	.id_table = id_table,
 	.probe =  blkvsc_probe,
 	.remove =  blkvsc_remove,
@@ -824,24 +824,13 @@ static const struct block_device_operations block_ops = {
  */
 static int blkvsc_drv_init(void)
 {
-	struct hv_driver *drv = &blkvsc_drv;
-	int ret;
-
 	BUILD_BUG_ON(sizeof(sector_t) != 8);
-
-	drv->driver.name = drv_name;
-
-	/* The driver belongs to vmbus */
-	ret = vmbus_child_driver_register(&drv->driver);
-
-	return ret;
+	return vmbus_driver_register(&blkvsc_drv);
 }
 
-
 static void blkvsc_drv_exit(void)
 {
-
-	vmbus_child_driver_unregister(&blkvsc_drv.driver);
+	vmbus_driver_unregister(&blkvsc_drv);
 }
 
 /*
diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index ebd1715..5727173 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -176,8 +176,6 @@ struct mousevsc_dev {
 };
 
 
-static const char *driver_name = "mousevsc";
-
 static void deviceinfo_callback(struct hv_device *dev, struct hv_input_dev_info *info);
 static void inputreport_callback(struct hv_device *dev, void *packet, u32 len);
 static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len);
@@ -921,33 +919,20 @@ static const struct hv_vmbus_device_id id_table[] = {
 /* MODULE_DEVICE_TABLE(vmbus, id_table); */
 
 static struct  hv_driver mousevsc_drv = {
+	.name = "mousevsc",
 	.id_table = id_table,
 	.probe = mousevsc_probe,
 	.remove = mousevsc_remove,
 };
 
-static void mousevsc_drv_exit(void)
-{
-	vmbus_child_driver_unregister(&mousevsc_drv.driver);
-}
-
 static int __init mousevsc_init(void)
 {
-	struct hv_driver *drv = &mousevsc_drv;
-
-	DPRINT_INFO(INPUTVSC_DRV, "Hyper-V Mouse driver initializing.");
-
-	drv->driver.name = driver_name;
-
-	/* The driver belongs to vmbus */
-	vmbus_child_driver_register(&drv->driver);
-
-	return 0;
+	return vmbus_driver_register(&mousevsc_drv);
 }
 
 static void __exit mousevsc_exit(void)
 {
-	mousevsc_drv_exit();
+	vmbus_driver_unregister(&mousevsc_drv);
 }
 
 /*
diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c
index b0d89de..f2f456f 100644
--- a/drivers/staging/hv/hv_util.c
+++ b/drivers/staging/hv/hv_util.c
@@ -34,8 +34,6 @@ static u8 *shut_txf_buf;
 static u8 *time_txf_buf;
 static u8 *hbeat_txf_buf;
 
-static const char *driver_name = "hv_util";
-
 static void shutdown_onchannelcallback(void *context)
 {
 	struct vmbus_channel *channel = context;
@@ -244,6 +242,7 @@ MODULE_DEVICE_TABLE(vmbus, id_table);
 
 /* The one and only one */
 static  struct hv_driver util_drv = {
+	.name = "hv_util",
 	.id_table = id_table,
 	.probe =  util_probe,
 	.remove =  util_remove,
@@ -277,9 +276,7 @@ static int __init init_hyperv_utils(void)
 
 	hv_cb_utils[HV_KVP_MSG].callback = &hv_kvp_onchannelcallback;
 
-	util_drv.driver.name = driver_name;
-
-	return vmbus_child_driver_register(&util_drv.driver);
+	return vmbus_driver_register(&util_drv);
 }
 
 static void exit_hyperv_utils(void)
@@ -311,7 +308,7 @@ static void exit_hyperv_utils(void)
 	kfree(shut_txf_buf);
 	kfree(time_txf_buf);
 	kfree(hbeat_txf_buf);
-	vmbus_child_driver_unregister(&util_drv.driver);
+	vmbus_driver_unregister(&util_drv);
 }
 
 module_init(init_hyperv_utils);
diff --git a/drivers/staging/hv/hyperv.h b/drivers/staging/hv/hyperv.h
index d96de66..c249811 100644
--- a/drivers/staging/hv/hyperv.h
+++ b/drivers/staging/hv/hyperv.h
@@ -845,8 +845,12 @@ static inline struct hv_driver *drv_to_hv_drv(struct device_driver *d)
 
 
 /* Vmbus interface */
-int vmbus_child_driver_register(struct device_driver *drv);
-void vmbus_child_driver_unregister(struct device_driver *drv);
+#define vmbus_driver_register(driver)	\
+	__vmbus_driver_register(driver, THIS_MODULE, KBUILD_MODNAME)
+int __must_check __vmbus_driver_register(struct hv_driver *hv_driver,
+					 struct module *owner,
+					 const char *mod_name);
+void vmbus_driver_unregister(struct hv_driver *hv_driver);
 
 /**
  * VMBUS_DEVICE - macro used to describe a specific hyperv vmbus device
diff --git a/drivers/staging/hv/hyperv_net.h b/drivers/staging/hv/hyperv_net.h
index 27f987b..5782fea 100644
--- a/drivers/staging/hv/hyperv_net.h
+++ b/drivers/staging/hv/hyperv_net.h
@@ -96,7 +96,6 @@ void netvsc_linkstatus_callback(struct hv_device *device_obj,
 				unsigned int status);
 int netvsc_recv_callback(struct hv_device *device_obj,
 			struct hv_netvsc_packet *packet);
-int netvsc_initialize(struct hv_driver *drv);
 int rndis_filter_open(struct hv_device *dev);
 int rndis_filter_close(struct hv_device *dev);
 int rndis_filter_device_add(struct hv_device *dev,
diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 6f4541b..cb02eed 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -32,9 +32,6 @@
 #include "hyperv_net.h"
 
 
-/* Globals */
-static const char *driver_name = "netvsc";
-
 static struct netvsc_device *alloc_net_device(struct hv_device *device)
 {
 	struct netvsc_device *net_device;
@@ -992,14 +989,3 @@ cleanup:
 
 	return ret;
 }
-
-/*
- * netvsc_initialize - Main entry point
- */
-int netvsc_initialize(struct hv_driver *drv)
-{
-
-	drv->name = driver_name;
-
-	return 0;
-}
diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index 2d2955c..ad1ef03 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -422,6 +422,7 @@ MODULE_DEVICE_TABLE(vmbus, id_table);
 
 /* The one and only one */
 static struct  hv_driver netvsc_drv = {
+	.name = "netvsc",
 	.id_table = id_table,
 	.probe = netvsc_probe,
 	.remove = netvsc_remove,
@@ -429,26 +430,12 @@ static struct  hv_driver netvsc_drv = {
 
 static void __exit netvsc_drv_exit(void)
 {
-	vmbus_child_driver_unregister(&netvsc_drv.driver);
+	vmbus_driver_unregister(&netvsc_drv);
 }
 
-
 static int __init netvsc_drv_init(void)
 {
-	struct hv_driver *drv = &netvsc_drv;
-	int ret;
-
-	pr_info("initializing....");
-
-	/* Callback to client driver to complete the initialization */
-	netvsc_initialize(drv);
-
-	drv->driver.name = drv->name;
-
-	/* The driver belongs to vmbus */
-	ret = vmbus_child_driver_register(&drv->driver);
-
-	return ret;
+	return vmbus_driver_register(&netvsc_drv);
 }
 
 MODULE_LICENSE("GPL");
diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 6f67e9b..0297418 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -41,8 +41,6 @@ static int storvsc_ringbuffer_size = STORVSC_RING_BUFFER_SIZE;
 module_param(storvsc_ringbuffer_size, int, S_IRUGO);
 MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer size (bytes)");
 
-static const char *driver_name = "storvsc";
-
 struct hv_host_device {
 	struct hv_device *dev;
 	struct kmem_cache *request_pool;
@@ -718,6 +716,7 @@ static int storvsc_probe(struct hv_device *device)
 /* The one and only one */
 
 static struct hv_driver storvsc_drv = {
+	.name = "storvsc",
 	.id_table = id_table,
 	.probe = storvsc_probe,
 	.remove = storvsc_remove,
@@ -725,8 +724,6 @@ static struct hv_driver storvsc_drv = {
 
 static int __init storvsc_drv_init(void)
 {
-	int ret;
-	struct hv_driver *drv = &storvsc_drv;
 	u32 max_outstanding_req_per_channel;
 
 	/*
@@ -735,29 +732,22 @@ static int __init storvsc_drv_init(void)
 	 * the ring buffer indices) by the max request size (which is
 	 * vmbus_channel_packet_multipage_buffer + struct vstor_packet + u64)
 	 */
-
 	max_outstanding_req_per_channel =
-	((storvsc_ringbuffer_size - PAGE_SIZE) /
-	ALIGN(MAX_MULTIPAGE_BUFFER_PACKET +
-	sizeof(struct vstor_packet) + sizeof(u64),
-	sizeof(u64)));
+		((storvsc_ringbuffer_size - PAGE_SIZE) /
+		ALIGN(MAX_MULTIPAGE_BUFFER_PACKET +
+		sizeof(struct vstor_packet) + sizeof(u64),
+		sizeof(u64)));
 
 	if (max_outstanding_req_per_channel <
 	    STORVSC_MAX_IO_REQUESTS)
 		return -1;
 
-	drv->driver.name = driver_name;
-
-
-	/* The driver belongs to vmbus */
-	ret = vmbus_child_driver_register(&drv->driver);
-
-	return ret;
+	return vmbus_driver_register(&storvsc_drv);
 }
 
 static void __exit storvsc_drv_exit(void)
 {
-	vmbus_child_driver_unregister(&storvsc_drv.driver);
+	vmbus_driver_unregister(&storvsc_drv);
 }
 
 MODULE_LICENSE("GPL");
diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 0114b04..26f4901 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -552,51 +552,50 @@ static int vmbus_bus_init(int irq)
 }
 
 /**
- * vmbus_child_driver_register() - Register a vmbus's child driver
- * @drv:        Pointer to driver structure you want to register
- *
+ * __vmbus_child_driver_register - Register a vmbus's driver
+ * @drv: Pointer to driver structure you want to register
+ * @owner: owner module of the drv
+ * @mod_name: module name string
  *
  * Registers the given driver with Linux through the 'driver_register()' call
- * And sets up the hyper-v vmbus handling for this driver.
+ * and sets up the hyper-v vmbus handling for this driver.
  * It will return the state of the 'driver_register()' call.
  *
- * Mainly used by Hyper-V drivers.
  */
-int vmbus_child_driver_register(struct device_driver *drv)
+int __vmbus_driver_register(struct hv_driver *hv_driver, struct module *owner, const char *mod_name)
 {
 	int ret;
 
-	pr_info("child driver registering - name %s\n", drv->name);
+	pr_info("registering driver %s\n", hv_driver->name);
 
-	/* The child driver on this vmbus */
-	drv->bus = &hv_bus;
+	hv_driver->driver.name = hv_driver->name;
+	hv_driver->driver.owner = owner;
+	hv_driver->driver.mod_name = mod_name;
+	hv_driver->driver.bus = &hv_bus;
 
-	ret = driver_register(drv);
+	ret = driver_register(&hv_driver->driver);
 
 	vmbus_request_offers();
 
 	return ret;
 }
-EXPORT_SYMBOL(vmbus_child_driver_register);
+EXPORT_SYMBOL_GPL(__vmbus_driver_register);
 
 /**
- * vmbus_child_driver_unregister() - Unregister a vmbus's child driver
- * @drv:        Pointer to driver structure you want to un-register
- *
- *
- * Un-register the given driver with Linux through the 'driver_unregister()'
- * call. And ungegisters the driver from the Hyper-V vmbus handler.
+ * vmbus_driver_unregister() - Unregister a vmbus's driver
+ * @drv: Pointer to driver structure you want to un-register
  *
- * Mainly used by Hyper-V drivers.
+ * Un-register the given driver that was previous registered with a call to
+ * vmbus_driver_register()
  */
-void vmbus_child_driver_unregister(struct device_driver *drv)
+void vmbus_driver_unregister(struct hv_driver *hv_driver)
 {
-	pr_info("child driver unregistering - name %s\n", drv->name);
+	pr_info("unregistering driver %s\n", hv_driver->name);
 
-	driver_unregister(drv);
+	driver_unregister(&hv_driver->driver);
 
 }
-EXPORT_SYMBOL(vmbus_child_driver_unregister);
+EXPORT_SYMBOL_GPL(vmbus_driver_unregister);
 
 /*
  * vmbus_child_device_create - Creates and registers a new child device
-- 
1.7.6

^ permalink raw reply related

* RE: [PATCH 12/59] Staging: hv: vmbus: Cleanup vmbus_uevent() code
From: KY Srinivasan @ 2011-08-25 22:14 UTC (permalink / raw)
  To: Greg KH
  Cc: gregkh@suse.de, linux-kernel@vger.kernel.org,
	devel@linuxdriverproject.org, virtualization@lists.osdl.org,
	Haiyang Zhang
In-Reply-To: <20110825205930.GA10883@kroah.com>



> -----Original Message-----
> From: Greg KH [mailto:greg@kroah.com]
> Sent: Thursday, August 25, 2011 5:00 PM
> To: KY Srinivasan
> Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> Subject: Re: [PATCH 12/59] Staging: hv: vmbus: Cleanup vmbus_uevent() code
> 
> On Thu, Aug 25, 2011 at 09:48:38AM -0700, K. Y. Srinivasan wrote:
> > Now generate appropriate uevent based on the modalias string. As part of this,
> > cleanup the existing uevent code.
> >
> > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> > Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> > ---
> >  drivers/staging/hv/vmbus_drv.c |   60 ++++++++--------------------------------
> >  1 files changed, 12 insertions(+), 48 deletions(-)
> >
> > diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
> > index b651968..a6e7dc5 100644
> > --- a/drivers/staging/hv/vmbus_drv.c
> > +++ b/drivers/staging/hv/vmbus_drv.c
> > @@ -237,58 +237,22 @@ static struct device_attribute vmbus_device_attrs[] =
> {
> >   * This routine is invoked when a device is added or removed on the vmbus to
> >   * generate a uevent to udev in the userspace. The udev will then look at its
> >   * rule and the uevent generated here to load the appropriate driver
> > + *
> > + * The alias string will be of the form vmbus:guid where guid is the string
> > + * representation of the device guid (each byte of the guid will be
> > + * represented with two hex characters.
> >   */
> >  static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env)
> >  {
> >  	struct hv_device *dev = device_to_hv_device(device);
> > -	int ret;
> > -
> > -	ret = add_uevent_var(env, "VMBUS_DEVICE_CLASS_GUID={"
> > -			     "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
> > -			     "%02x%02x%02x%02x%02x%02x%02x%02x}",
> > -			     dev->dev_type.b[3],
> > -			     dev->dev_type.b[2],
> > -			     dev->dev_type.b[1],
> > -			     dev->dev_type.b[0],
> > -			     dev->dev_type.b[5],
> > -			     dev->dev_type.b[4],
> > -			     dev->dev_type.b[7],
> > -			     dev->dev_type.b[6],
> > -			     dev->dev_type.b[8],
> > -			     dev->dev_type.b[9],
> > -			     dev->dev_type.b[10],
> > -			     dev->dev_type.b[11],
> > -			     dev->dev_type.b[12],
> > -			     dev->dev_type.b[13],
> > -			     dev->dev_type.b[14],
> > -			     dev->dev_type.b[15]);
> > -
> > -	if (ret)
> > -		return ret;
> > +	int i, ret;
> > +	char alias_name[((sizeof(struct hv_vmbus_device_id) + 1)) * 2];
> >
> > -	ret = add_uevent_var(env, "VMBUS_DEVICE_DEVICE_GUID={"
> > -			     "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
> > -			     "%02x%02x%02x%02x%02x%02x%02x%02x}",
> > -			     dev->dev_instance.b[3],
> > -			     dev->dev_instance.b[2],
> > -			     dev->dev_instance.b[1],
> > -			     dev->dev_instance.b[0],
> > -			     dev->dev_instance.b[5],
> > -			     dev->dev_instance.b[4],
> > -			     dev->dev_instance.b[7],
> > -			     dev->dev_instance.b[6],
> > -			     dev->dev_instance.b[8],
> > -			     dev->dev_instance.b[9],
> > -			     dev->dev_instance.b[10],
> > -			     dev->dev_instance.b[11],
> > -			     dev->dev_instance.b[12],
> > -			     dev->dev_instance.b[13],
> > -			     dev->dev_instance.b[14],
> > -			     dev->dev_instance.b[15]);
> > -	if (ret)
> > -		return ret;
> > +	for (i = 0; i < (sizeof(struct hv_vmbus_device_id) * 2); i += 2)
> > +		sprintf(&alias_name[i], "%02x", dev->dev_type.b[i/2]);
> 
> I have to edit this to get it to work properly with the fact that I
> added the driver_data field to hv_vmbus_device_id.
> 
> Arguably, one could say that this patch was always broken as you were
> assuming the size of an individual field was the same size as the whole
> structure, which I don't think is always the case, or at least it's not
> a safe thing to assume :)

Perhaps I could have sized it based on guid size since that is what is going
to be the alias. 

Regards,

K. Y

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox