Skip to contentSkip to conversation

Staging: hv: Driver cleanup

PATCH In review K. Y. Srinivasan 3 participants 79 messages Aug 25, 2011 – Aug 30, 2011

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover Staging: hv: Driver cleanup

Further cleanup of the hv drivers.

1) Implement code for autoloading the vmbus drivers without using PCI or DMI signatures. I have implemented this based on Greg's feedback on my earlier implementation.

2) Cleanup error handling across the board and use standard Linux error codes.

3) General cleanup

Regards,

K. Y

#1 lore raw

PATCH 1/59 Staging: hv: vmbus: VMBUS is an ACPI enumerated device, get rid of the PCI signature

VMBUS is an ACPI enumerated device, get rid of the PCI signature.

---
 drivers/staging/hv/vmbus_drv.c |   13 -------------
 1 files changed, 0 insertions(+), 13 deletions(-)
drivers/staging/hv/vmbus_drv.c +0 -13
index 67a4f33..8f1d6eb 100644
@@ -28,7 +28,6 @@
 #include <linux/irq.h>
 #include <linux/interrupt.h>
 #include <linux/sysctl.h>
-#include <linux/pci.h>
 #include <linux/dmi.h>
 #include <linux/slab.h>
 #include <linux/acpi.h>
@@ -754,18 +753,6 @@ static struct acpi_driver vmbus_acpi_driver = {
 	},
 };
 
-/*
- * 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);
-
 static int __init hv_acpi_init(void)
 {
 	int ret, t;
Signature · 1 line
1.7.4.1
#2 lore raw

PATCH 2/59 Staging: hv: Replace struct hv_guid with the uuid type already defined in Linux

Replace struct hv_guid with the uuid type already defined in Linux.

---
 drivers/staging/hv/blkvsc_drv.c   |   18 +++---
 drivers/staging/hv/channel.c      |    4 +-
 drivers/staging/hv/channel_mgmt.c |   50 ++++++-------
 drivers/staging/hv/hv_mouse.c     |    6 +-
 drivers/staging/hv/hyperv.h       |   24 +++----
 drivers/staging/hv/hyperv_vmbus.h |    8 +-
 drivers/staging/hv/netvsc.c       |    6 +-
 drivers/staging/hv/storvsc_drv.c  |    6 +-
 drivers/staging/hv/vmbus_drv.c    |  142 ++++++++++++++++++------------------
 9 files changed, 129 insertions(+), 135 deletions(-)
drivers/staging/hv/blkvsc_drv.c +9 -9
index d286b22..018b293 100644
@@ -112,8 +112,8 @@ struct block_device_context {
 static const char *drv_name = "blkvsc";
 
 /* {32412632-86cb-44a2-9b5c-50d1417354f5} */
-static const struct hv_guid dev_type = {
-	.data = {
+static const uuid_le dev_type = {
+	.b = {
 		0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
 		0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5
 	}
@@ -155,13 +155,13 @@ static int blkvsc_device_add(struct hv_device *device,
 	 * id. For IDE devices, the device instance id is formatted as
 	 * <bus id> * - <device id> - 8899 - 000000000000.
 	 */
-	device_info->path_id = device->dev_instance.data[3] << 24 |
-			     device->dev_instance.data[2] << 16 |
-			     device->dev_instance.data[1] << 8  |
-			     device->dev_instance.data[0];
+	device_info->path_id = device->dev_instance.b[3] << 24 |
+			     device->dev_instance.b[2] << 16 |
+			     device->dev_instance.b[1] << 8  |
+			     device->dev_instance.b[0];
 
-	device_info->target_id = device->dev_instance.data[5] << 8 |
-			       device->dev_instance.data[4];
+	device_info->target_id = device->dev_instance.b[5] << 8 |
+			       device->dev_instance.b[4];
 
 	return ret;
 }
@@ -829,7 +829,7 @@ static int blkvsc_drv_init(void)
 
 	BUILD_BUG_ON(sizeof(sector_t) != 8);
 
-	memcpy(&drv->dev_type, &dev_type, sizeof(struct hv_guid));
+	memcpy(&drv->dev_type, &dev_type, sizeof(uuid_le));
 	drv->driver.name = drv_name;
 
 	/* The driver belongs to vmbus */
drivers/staging/hv/channel.c +2 -2
index 455f47a..222adcc 100644
@@ -81,10 +81,10 @@ void vmbus_get_debug_info(struct vmbus_channel *channel,
 	debuginfo->relid = channel->offermsg.child_relid;
 	debuginfo->state = channel->state;
 	memcpy(&debuginfo->interfacetype,
-	       &channel->offermsg.offer.if_type, sizeof(struct hv_guid));
+	       &channel->offermsg.offer.if_type, sizeof(uuid_le));
 	memcpy(&debuginfo->interface_instance,
 	       &channel->offermsg.offer.if_instance,
-	       sizeof(struct hv_guid));
+	       sizeof(uuid_le));
 
 	monitorpage = (struct hv_monitor_page *)vmbus_connection.monitor_pages;
 
drivers/staging/hv/channel_mgmt.c +23 -27

149 lines not on this page · raw message

drivers/staging/hv/hv_mouse.c +3 -3
index 9f3fbee..950f4b4 100644
@@ -179,8 +179,8 @@ struct mousevsc_dev {
 static const char *driver_name = "mousevsc";
 
 /* {CFA8B69E-5B4A-4cc0-B98B-8BA1A1F3F95A} */
-static const struct hv_guid mouse_guid = {
-	.data = {0x9E, 0xB6, 0xA8, 0xCF, 0x4A, 0x5B, 0xc0, 0x4c,
+static const uuid_le mouse_guid = {
+	.b = {0x9E, 0xB6, 0xA8, 0xCF, 0x4A, 0x5B, 0xc0, 0x4c,
 		 0xB9, 0x8B, 0x8B, 0xA1, 0xA1, 0xF3, 0xF9, 0x5A}
 };
 
@@ -932,7 +932,7 @@ static int __init mousevsc_init(void)
 	DPRINT_INFO(INPUTVSC_DRV, "Hyper-V Mouse driver initializing.");
 
 	memcpy(&drv->dev_type, &mouse_guid,
-	       sizeof(struct hv_guid));
+	       sizeof(uuid_le));
 
 	drv->driver.name = driver_name;
 
drivers/staging/hv/hyperv.h +11 -13
index 1747a24..399d9fe 100644
@@ -27,6 +27,7 @@
 
 #include <linux/scatterlist.h>
 #include <linux/list.h>
+#include <linux/uuid.h>
 #include <linux/timer.h>
 #include <linux/workqueue.h>
 #include <linux/completion.h>
@@ -35,9 +36,6 @@
 
 #include <asm/hyperv.h>
 
-struct hv_guid {
-	unsigned char data[16];
-};
 
 #define MAX_PAGE_BUFFER_COUNT				16
 #define MAX_MULTIPAGE_BUFFER_COUNT			32 /* 128K */
@@ -156,8 +154,8 @@ struct hv_ring_buffer_debug_info {
  * struct contains the fundamental information about an offer.
  */
 struct vmbus_channel_offer {
-	struct hv_guid if_type;
-	struct hv_guid if_instance;
+	uuid_le if_type;
+	uuid_le if_instance;
 	u64 int_latency; /* in 100ns units */
 	u32 if_revision;
 	u32 server_ctx_size;	/* in bytes */
@@ -526,8 +524,8 @@ enum vmbus_channel_state {
 struct vmbus_channel_debug_info {
 	u32 relid;
 	enum vmbus_channel_state state;
-	struct hv_guid interfacetype;
-	struct hv_guid interface_instance;
+	uuid_le interfacetype;
+	uuid_le interface_instance;
 	u32 monitorid;
 	u32 servermonitor_pending;
 	u32 servermonitor_latency;
@@ -786,8 +784,8 @@ struct hv_dev_port_info {
 struct hv_device_info {
 	u32 chn_id;
 	u32 chn_state;
-	struct hv_guid chn_type;
-	struct hv_guid chn_instance;
+	uuid_le chn_type;
+	uuid_le chn_instance;
 
 	u32 monitor_id;
 	u32 server_monitor_pending;
@@ -806,7 +804,7 @@ struct hv_driver {
 	const char *name;
 
 	/* the device type supported by this driver */
-	struct hv_guid dev_type;
+	uuid_le dev_type;
 
 	struct device_driver driver;
 
@@ -819,10 +817,10 @@ struct hv_driver {
 /* Base device object */
 struct hv_device {
 	/* the device type id of this device */
-	struct hv_guid dev_type;
+	uuid_le dev_type;
 
 	/* the device instance id of this device */
-	struct hv_guid dev_instance;
+	uuid_le dev_instance;
 
 	struct device device;
 
@@ -935,7 +933,7 @@ struct ictimesync_data {
 struct hyperv_service_callback {
 	u8 msg_type;
 	char *log_msg;
-	unsigned char data[16];
+	uuid_le data;
 	struct vmbus_channel *channel;
 	void (*callback) (void *context);
 };
drivers/staging/hv/hyperv_vmbus.h +4 -4
index 349ad80..16ca90d 100644
@@ -451,8 +451,8 @@ enum {
 /* #define VMBUS_PORT_ID		11 */
 
 /* 628180B8-308D-4c5e-B7DB-1BEB62E62EF4 */
-static const struct hv_guid VMBUS_SERVICE_ID = {
-	.data = {
+static const uuid_le VMBUS_SERVICE_ID = {
+	.b = {
 		0xb8, 0x80, 0x81, 0x62, 0x8d, 0x30, 0x5e, 0x4c,
 		0xb7, 0xdb, 0x1b, 0xeb, 0x62, 0xe6, 0x2e, 0xf4
 	},
@@ -601,8 +601,8 @@ extern struct vmbus_connection vmbus_connection;
 
 /* General vmbus interface */
 
-struct hv_device *vmbus_child_device_create(struct hv_guid *type,
-					 struct hv_guid *instance,
+struct hv_device *vmbus_child_device_create(uuid_le *type,
+					 uuid_le *instance,
 					 struct vmbus_channel *channel);
 
 int vmbus_child_device_register(struct hv_device *child_device_obj);
drivers/staging/hv/netvsc.c +3 -3
index dc5e5c4..1506b53 100644
@@ -36,8 +36,8 @@
 static const char *driver_name = "netvsc";
 
 /* {F8615163-DF3E-46c5-913F-F2D2F965ED0E} */
-static const struct hv_guid netvsc_device_type = {
-	.data = {
+static const uuid_le netvsc_device_type = {
+	.b = {
 		0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46,
 		0x91, 0x3F, 0xF2, 0xD2, 0xF9, 0x65, 0xED, 0x0E
 	}
@@ -1009,7 +1009,7 @@ int netvsc_initialize(struct hv_driver *drv)
 {
 
 	drv->name = driver_name;
-	memcpy(&drv->dev_type, &netvsc_device_type, sizeof(struct hv_guid));
+	memcpy(&drv->dev_type, &netvsc_device_type, sizeof(uuid_le));
 
 	return 0;
 }
drivers/staging/hv/storvsc_drv.c +3 -3
index 7effaf3..e4cdbc5 100644
@@ -45,8 +45,8 @@ MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer size (bytes)");
 static const char *driver_name = "storvsc";
 
 /* {ba6163d9-04a1-4d29-b605-72e2ffb1dc7f} */
-static const struct hv_guid stor_vsci_device_type = {
-	.data = {
+static const uuid_le stor_vsci_device_type = {
+	.b = {
 		0xd9, 0x63, 0x61, 0xba, 0xa1, 0x04, 0x29, 0x4d,
 		0xb6, 0x05, 0x72, 0xe2, 0xff, 0xb1, 0xdc, 0x7f
 	}
@@ -765,7 +765,7 @@ static int __init storvsc_drv_init(void)
 	sizeof(u64)));
 
 	memcpy(&drv->dev_type, &stor_vsci_device_type,
-	       sizeof(struct hv_guid));
+	       sizeof(uuid_le));
 
 	if (max_outstanding_req_per_channel <
 	    STORVSC_MAX_IO_REQUESTS)
drivers/staging/hv/vmbus_drv.c +71 -71

189 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#3 lore raw

PATCH 3/59 Staging: hv: Add struct hv_vmbus_device_id to mod_devicetable.h

In reply to K. Y. Srinivasan

In preparation for implementing vmbus aliases for auto-loading Hyper-V drivers, define vmbus specific device ID.

---
 include/linux/mod_devicetable.h |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
include/linux/mod_devicetable.h +7 -0
index ae28e93..5a12377 100644
@@ -405,6 +405,13 @@ struct virtio_device_id {
 };
 #define VIRTIO_DEV_ANY_ID	0xffffffff
 
+/*
+ * For Hyper-V devices we use the device guid as the id.
+ */
+struct hv_vmbus_device_id {
+	__u8 guid[16];
+};
+
 /* i2c */
 
 #define I2C_NAME_SIZE	20
Signature · 1 line
1.7.4.1
#4 lore raw

PATCH 4/59 Staging: hv: Add code to parse struct hv_vmbus_device_id table

In reply to K. Y. Srinivasan

Add code to parse struct hv_vmbus_device_id table.

---
 scripts/mod/file2alias.c |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)
scripts/mod/file2alias.c +25 -0
index e26e2fb..b74d21a 100644
@@ -735,6 +735,27 @@ static int do_virtio_entry(const char *filename, struct virtio_device_id *id,
 	return 1;
 }
 
+/*
+ * Looks like: vmbus:guid
+ * Each byte of the guid will be represented by two hex characters
+ * in the name.
+ */
+
+static int do_vmbus_entry(const char *filename, struct hv_vmbus_device_id *id,
+			  char *alias)
+{
+	int i;
+	char guid_name[((sizeof(struct hv_vmbus_device_id) + 1)) * 2];
+
+	for (i = 0; i < (sizeof(struct hv_vmbus_device_id) * 2); i += 2)
+		sprintf(&guid_name[i], "%02x", id->guid[i/2]);
+
+	strcpy(alias, "vmbus:");
+	strcat(alias, guid_name);
+
+	return 1;
+}
+
 /* Looks like: i2c:S */
 static int do_i2c_entry(const char *filename, struct i2c_device_id *id,
 			char *alias)
@@ -994,6 +1015,10 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
 		do_table(symval, sym->st_size,
 			 sizeof(struct virtio_device_id), "virtio",
 			 do_virtio_entry, mod);
+	else if (sym_is(symname, "__mod_vmbus_device_table"))
+		do_table(symval, sym->st_size,
+			 sizeof(struct hv_vmbus_device_id), "vmbus",
+			 do_vmbus_entry, mod);
 	else if (sym_is(symname, "__mod_i2c_device_table"))
 		do_table(symval, sym->st_size,
 			 sizeof(struct i2c_device_id), "i2c",
Signature · 1 line
1.7.4.1
#5 lore raw

PATCH 5/59 Staging: hv: vmbus: Introduce vmbus ID space in struct hv_driver

In reply to K. Y. Srinivasan

In preparation for supporting auto-loading Hyper-V drivers using vmbus specific aliases, introduce vmbus ID space in struct hv_driver.

---
 drivers/staging/hv/hyperv.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/staging/hv/hyperv.h +2 -0
index 399d9fe..b8199f4 100644
@@ -32,6 +32,7 @@
 #include <linux/workqueue.h>
 #include <linux/completion.h>
 #include <linux/device.h>
+#include <linux/mod_devicetable.h>
 
 
 #include <asm/hyperv.h>
@@ -805,6 +806,7 @@ struct hv_driver {
 
 	/* the device type supported by this driver */
 	uuid_le dev_type;
+	const struct hv_vmbus_device_id *id_table;
 
 	struct device_driver driver;
 
Signature · 1 line
1.7.4.1
#6 lore raw

PATCH 6/59 Staging: hv: blkvsc: Use the newly introduced vmbus ID in the blockvsc driver

In reply to K. Y. Srinivasan

Use the newly introduced vmbus ID in the blockvsc driver. Also, do the associated cleanup.

---
 drivers/staging/hv/blkvsc_drv.c |   23 ++++++++++++++---------
 1 files changed, 14 insertions(+), 9 deletions(-)
drivers/staging/hv/blkvsc_drv.c +14 -9
index 018b293..9b99387 100644
@@ -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));
 	drv->driver.name = drv_name;
 
 	/* The driver belongs to vmbus */
Signature · 1 line
1.7.4.1
#7 lore raw

Re: [PATCH 06/59] Staging: hv: blkvsc: Use the newly introduced vmbus ID in the blockvsc driver

Quoted 34 lines · K. Y. Srinivasan

Use the newly introduced vmbus ID in the blockvsc driver. Also, do the associated cleanup.

---
 drivers/staging/hv/blkvsc_drv.c |   23 ++++++++++++++---------
 1 files changed, 14 insertions(+), 9 deletions(-)
drivers/staging/hv/blkvsc_drv.c +2 -8
index 018b293..9b99387 100644
@@ -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[] = {
+	{

drivers/staging/hv/blkvsc_drv.c static void blkvsc_request(struct request_queue *queue) · line 808

Quoted 10 lines
drivers/staging/hv/blkvsc_drv.c +10 -0
+		/* 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

#8 lore raw

RE: [PATCH 06/59] Staging: hv: blkvsc: Use the newly introduced vmbus ID in the blockvsc driver

Quoted 85 lines

-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Thursday, August 25, 2011 1:36 PM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Haiyang Zhang
Subject: Re: [PATCH 06/59] Staging: hv: blkvsc: Use the newly introduced vmbus ID in the blockvsc driver

drivers/staging/hv/blkvsc_drv.c static void blkvsc_request(struct request_queue

Quoted 29 lines · K. Y. Srinivasan

Use the newly introduced vmbus ID in the blockvsc driver. Also, do the associated cleanup.

---
 drivers/staging/hv/blkvsc_drv.c |   23 ++++++++++++++---------
 1 files changed, 14 insertions(+), 9 deletions(-)
drivers/staging/hv/blkvsc_drv.c +0 -8
index 018b293..9b99387 100644
@@ -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)

Quoted 5 lines
drivers/staging/hv/blkvsc_drv.c +2 -0
 	}
 }
 
+static const struct hv_vmbus_device_id id_table[] = {
+	{

drivers/staging/hv/blkvsc_drv.c static void blkvsc_request(struct request_queue *queue) · line 808

Quoted 10 lines
drivers/staging/hv/blkvsc_drv.c +10 -0
+		/* 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) },
	{ },
};
Quoted 4 lines

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

#9 lore raw

Re: [PATCH 06/59] Staging: hv: blkvsc: Use the newly introduced vmbus ID in the blockvsc driver

Quoted 12 lines · KY Srinivasan
Quoted 12 lines

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) },
	{ },
};
Quoted 6 lines
Quoted 4 lines

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

#10 lore raw

RE: [PATCH 06/59] Staging: hv: blkvsc: Use the newly introduced vmbus ID in the blockvsc driver

Quoted 29 lines

-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Thursday, August 25, 2011 2:46 PM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Haiyang Zhang
Subject: Re: [PATCH 06/59] Staging: hv: blkvsc: Use the newly introduced vmbus ID in the blockvsc driver

Quoted 17 lines · KY Srinivasan
Quoted 16 lines

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.

Quoted 7 lines
Quoted 1 line

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

#11 lore raw

Re: [PATCH 06/59] Staging: hv: blkvsc: Use the newly introduced vmbus ID in the blockvsc driver

In reply to K. Y. Srinivasan
Quoted 54 lines · K. Y. Srinivasan

Use the newly introduced vmbus ID in the blockvsc driver. Also, do the associated cleanup.

---
 drivers/staging/hv/blkvsc_drv.c |   23 ++++++++++++++---------
 1 files changed, 14 insertions(+), 9 deletions(-)
drivers/staging/hv/blkvsc_drv.c +14 -8
index 018b293..9b99387 100644
@@ -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,

drivers/staging/hv/blkvsc_drv.c static int blkvsc_drv_init(void) · line 832

Quoted 4 lines
drivers/staging/hv/blkvsc_drv.c +0 -1
@@ -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

#12 lore raw

PATCH 7/59 Staging: hv: storvsc: Use the newly introduced vmbus ID in storvsc driver

In reply to K. Y. Srinivasan

Use the newly introduced vmbus ID in storvsc driver. Also, do the assciated cleanup.

---
 drivers/staging/hv/storvsc_drv.c |   25 ++++++++++++++-----------
 1 files changed, 14 insertions(+), 11 deletions(-)
drivers/staging/hv/storvsc_drv.c +14 -11
index e4cdbc5..ed2140c 100644
@@ -44,14 +44,6 @@ MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer size (bytes)");
 
 static const char *driver_name = "storvsc";
 
-/* {ba6163d9-04a1-4d29-b605-72e2ffb1dc7f} */
-static const uuid_le stor_vsci_device_type = {
-	.b = {
-		0xd9, 0x63, 0x61, 0xba, 0xa1, 0x04, 0x29, 0x4d,
-		0xb6, 0x05, 0x72, 0xe2, 0xff, 0xb1, 0xdc, 0x7f
-	}
-};
-
 struct hv_host_device {
 	struct hv_device *dev;
 	struct kmem_cache *request_pool;
@@ -646,7 +638,20 @@ static struct scsi_host_template scsi_driver = {
 	.dma_boundary =		PAGE_SIZE-1,
 };
 
+static const struct hv_vmbus_device_id id_table[] = {
+	{
+		/* SCSI guid */
+		.guid = {
+			0xd9, 0x63, 0x61, 0xba, 0xa1, 0x04, 0x29, 0x4d,
+			0xb6, 0x05, 0x72, 0xe2, 0xff, 0xb1, 0xdc, 0x7f
+		}
+	},
+	{
+		.guid = { }
+	},
+};
 
+MODULE_DEVICE_TABLE(vmbus, id_table);
 /*
  * storvsc_probe - Add a new device for this driver
  */
@@ -720,6 +725,7 @@ static int storvsc_probe(struct hv_device *device)
 /* The one and only one */
 
 static struct hv_driver storvsc_drv = {
+	.id_table = id_table,
 	.probe = storvsc_probe,
 	.remove = storvsc_remove,
 };
@@ -764,9 +770,6 @@ static int __init storvsc_drv_init(void)
 	sizeof(struct vstor_packet) + sizeof(u64),
 	sizeof(u64)));
 
-	memcpy(&drv->dev_type, &stor_vsci_device_type,
-	       sizeof(uuid_le));
-
 	if (max_outstanding_req_per_channel <
 	    STORVSC_MAX_IO_REQUESTS)
 		return -1;
Signature · 1 line
1.7.4.1
#13 lore raw

PATCH 8/59 Staging: hv: netvsc: Use the newly introduced vmbus ID in netvsc driver

In reply to K. Y. Srinivasan

Use the newly introduced vmbus ID in netvsc driver. Also, do the associated cleanup.

---
 drivers/staging/hv/netvsc.c     |   10 ----------
 drivers/staging/hv/netvsc_drv.c |   16 ++++++++++++++++
 2 files changed, 16 insertions(+), 10 deletions(-)
drivers/staging/hv/netvsc.c +0 -10
index 1506b53..6f4541b 100644
@@ -35,15 +35,6 @@
 /* Globals */
 static const char *driver_name = "netvsc";
 
-/* {F8615163-DF3E-46c5-913F-F2D2F965ED0E} */
-static const uuid_le netvsc_device_type = {
-	.b = {
-		0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46,
-		0x91, 0x3F, 0xF2, 0xD2, 0xF9, 0x65, 0xED, 0x0E
-	}
-};
-
-
 static struct netvsc_device *alloc_net_device(struct hv_device *device)
 {
 	struct netvsc_device *net_device;
@@ -1009,7 +1000,6 @@ int netvsc_initialize(struct hv_driver *drv)
 {
 
 	drv->name = driver_name;
-	memcpy(&drv->dev_type, &netvsc_device_type, sizeof(uuid_le));
 
 	return 0;
 }
drivers/staging/hv/netvsc_drv.c +16 -0
index 61989f0..2e25c95 100644
@@ -413,8 +413,24 @@ static int netvsc_remove(struct hv_device *dev)
 	return 0;
 }
 
+static const struct hv_vmbus_device_id id_table[] = {
+	{
+		/* Network guid */
+		.guid = {
+			0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46,
+			0x91, 0x3F, 0xF2, 0xD2, 0xF9, 0x65, 0xED, 0x0E
+		}
+	},
+	{
+		.guid = { }
+	},
+};
+
+MODULE_DEVICE_TABLE(vmbus, id_table);
+
 /* The one and only one */
 static struct  hv_driver netvsc_drv = {
+	.id_table = id_table,
 	.probe = netvsc_probe,
 	.remove = netvsc_remove,
 };
Signature · 1 line
1.7.4.1
#14 lore raw

PATCH 9/59 Staging: hv: mousevsc: Use the newly introduced vmbus ID in mouse driver

In reply to K. Y. Srinivasan

Use the newly introduced vmbus ID in mouse driver. Also, do the associated cleanup. Since the mouse driver is not functional, we disable the autoloading of this driver.

---
 drivers/staging/hv/hv_mouse.c |   27 ++++++++++++++++++---------
 1 files changed, 18 insertions(+), 9 deletions(-)
drivers/staging/hv/hv_mouse.c +18 -9
index 950f4b4..dd8a114 100644
@@ -178,12 +178,6 @@ struct mousevsc_dev {
 
 static const char *driver_name = "mousevsc";
 
-/* {CFA8B69E-5B4A-4cc0-B98B-8BA1A1F3F95A} */
-static const uuid_le mouse_guid = {
-	.b = {0x9E, 0xB6, 0xA8, 0xCF, 0x4A, 0x5B, 0xc0, 0x4c,
-		 0xB9, 0x8B, 0x8B, 0xA1, 0xA1, 0xF3, 0xF9, 0x5A}
-};
-
 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);
@@ -914,8 +908,26 @@ static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len)
 	kfree(hid_dev);
 }
 
+static const struct hv_vmbus_device_id id_table[] = {
+	{
+		/* Mouse guid */
+		.guid = {
+			0x9E, 0xB6, 0xA8, 0xCF, 0x4A, 0x5B, 0xc0, 0x4c,
+			0xB9, 0x8B, 0x8B, 0xA1, 0xA1, 0xF3, 0xF9, 0x5A
+		}
+	},
+	{
+		.guid = { }
+	},
+};
+
+/*
+ * The mouse driver is not functional; do not auto-load it.
+ */
+/* MODULE_DEVICE_TABLE(vmbus, id_table); */
 
 static struct  hv_driver mousevsc_drv = {
+	.id_table = id_table,
 	.probe = mousevsc_probe,
 	.remove = mousevsc_remove,
 };
@@ -931,9 +943,6 @@ static int __init mousevsc_init(void)
 
 	DPRINT_INFO(INPUTVSC_DRV, "Hyper-V Mouse driver initializing.");
 
-	memcpy(&drv->dev_type, &mouse_guid,
-	       sizeof(uuid_le));
-
 	drv->driver.name = driver_name;
 
 	/* The driver belongs to vmbus */
Signature · 1 line
1.7.4.1
#15 lore raw

PATCH 10/59 Staging: hv: util: Make hv_utils a vmbus device driver

In reply to K. Y. Srinivasan

In preperation for supporting auto-loading the util driver, make the util driver a vmbus driver.

---
 drivers/staging/hv/hv_util.c |   64 +++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 63 insertions(+), 1 deletions(-)
drivers/staging/hv/hv_util.c +63 -1
index c164b54..a620f4d 100644
@@ -36,6 +36,8 @@ 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;
@@ -210,6 +212,63 @@ static void heartbeat_onchannelcallback(void *context)
 	}
 }
 
+/*
+ * The devices managed by the util driver don't need any additional
+ * setup.
+ */
+static int util_probe(struct hv_device *dev)
+{
+	return 0;
+}
+
+static int util_remove(struct hv_device *dev)
+{
+	return 0;
+}
+
+static const struct hv_vmbus_device_id id_table[] = {
+	{
+		/* Shutdown guid */
+		.guid = {
+			0x31, 0x60, 0x0B, 0X0E, 0x13, 0x52, 0x34, 0x49,
+			0x81, 0x8B, 0x38, 0XD9, 0x0C, 0xED, 0x39, 0xDB
+		}
+	},
+	{
+		/* Time synch guid */
+		.guid = {
+			0x30, 0xe6, 0x27, 0x95, 0xae, 0xd0, 0x7b, 0x49,
+			0xad, 0xce, 0xe8, 0x0a, 0xb0, 0x17, 0x5c, 0xaf
+		}
+	},
+	{
+		/* Heartbeat guid */
+		.guid = {
+			0x39, 0x4f, 0x16, 0x57, 0x15, 0x91, 0x78, 0x4e,
+			0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d
+		}
+	},
+	{
+		/* KVP guid */
+		.guid = {
+			0xe7, 0xf4, 0xa0, 0xa9, 0x45, 0x5a, 0x96, 0x4d,
+			0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3,  0xe6
+		}
+	},
+	{
+		.guid = { }
+	},
+};
+
+MODULE_DEVICE_TABLE(vmbus, id_table);
+
+/* The one and only one */
+static  struct hv_driver util_drv = {
+	.id_table = id_table,
+	.probe =  util_probe,
+	.remove =  util_remove,
+};
+
 static const struct pci_device_id __initconst
 hv_utils_pci_table[] __maybe_unused = {
 	{ PCI_DEVICE(0x1414, 0x5353) }, /* Hyper-V emulated VGA controller */
@@ -264,7 +323,9 @@ static int __init init_hyperv_utils(void)
 
 	hv_cb_utils[HV_KVP_MSG].callback = &hv_kvp_onchannelcallback;
 
-	return 0;
+	util_drv.driver.name = driver_name;
+
+	return vmbus_child_driver_register(&util_drv.driver);
 }
 
 static void exit_hyperv_utils(void)
@@ -296,6 +357,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);
 }
 
 module_init(init_hyperv_utils);
Signature · 1 line
1.7.4.1
#16 lore raw

Re: [PATCH 10/59] Staging: hv: util: Make hv_utils a vmbus device driver

drivers/staging/hv/hv_util.c static int __init init_hyperv_utils(void) · line 328

Quoted 3 lines · K. Y. Srinivasan
drivers/staging/hv/hv_util.c +3 -0
+	util_drv.driver.name = driver_name;
+
+	return vmbus_child_driver_register(&util_drv.driver);

We should free the allocations if vmbus_child_driver_register() fails.

regards,
dan carpenter

#17 lore raw

RE: [PATCH 10/59] Staging: hv: util: Make hv_utils a vmbus device driver

Quoted 10 lines

-----Original Message-----
From: Dan Carpenter [mailto:[email protected]]
Sent: Tuesday, August 30, 2011 11:53 AM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Haiyang Zhang
Subject: Re: [PATCH 10/59] Staging: hv: util: Make hv_utils a vmbus device driver

Quoted 6 lines

drivers/staging/hv/hv_util.c static int __init init_hyperv_utils(void) · line 328

Quoted 3 lines · K. Y. Srinivasan
drivers/staging/hv/hv_util.c +3 -0
+	util_drv.driver.name = driver_name;
+
+	return vmbus_child_driver_register(&util_drv.driver);

We should free the allocations if vmbus_child_driver_register() fails.

Thanks Dan. I will take care of this.

Regards,

K. Y

#18 lore raw

PATCH 11/59 Staging: hv: vmbus: Cleanup vmbus_match()

In reply to K. Y. Srinivasan

Use the preferred mechanism to compare guids in vmbus_match().

---
 drivers/staging/hv/vmbus_drv.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/staging/hv/vmbus_drv.c +1 -2
index c88a183..b651968 100644
@@ -302,8 +302,7 @@ static int vmbus_match(struct device *device, struct device_driver *driver)
 	struct hv_device *hv_dev = device_to_hv_device(device);
 
 	/* We found our driver ? */
-	if (memcmp(&hv_dev->dev_type, &drv->dev_type,
-		   sizeof(uuid_le)) == 0)
+	if (!uuid_le_cmp(hv_dev->dev_type, drv->dev_type))
 		match = 1;
 
 	return match;
Signature · 1 line
1.7.4.1
#19 lore raw

PATCH 12/59 Staging: hv: vmbus: Cleanup vmbus_uevent() code

In reply to K. Y. Srinivasan

Now generate appropriate uevent based on the modalias string. As part of this, cleanup the existing uevent code.

---
 drivers/staging/hv/vmbus_drv.c |   60 ++++++++--------------------------------
 1 files changed, 12 insertions(+), 48 deletions(-)
drivers/staging/hv/vmbus_drv.c +10 -46
index b651968..a6e7dc5 100644
@@ -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]);
 
-	return 0;
+	ret = add_uevent_var(env, "MODALIAS=vmbus:%s", alias_name);
+	return ret;
 }
 
 
Signature · 1 line
1.7.4.1
#20 lore raw

Re: [PATCH 12/59] Staging: hv: vmbus: Cleanup vmbus_uevent() code

Quoted 65 lines · K. Y. Srinivasan

Now generate appropriate uevent based on the modalias string. As part of this, cleanup the existing uevent code.

---
 drivers/staging/hv/vmbus_drv.c |   60 ++++++++--------------------------------
 1 files changed, 12 insertions(+), 48 deletions(-)
drivers/staging/hv/vmbus_drv.c +6 -37
index b651968..a6e7dc5 100644
@@ -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],

drivers/staging/hv/vmbus_drv.c static struct device_attribute vmbus_device_attrs[] = { · line 252

Quoted 10 lines
drivers/staging/hv/vmbus_drv.c +2 -8
-			     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

#21 lore raw

Re: [PATCH 12/59] Staging: hv: vmbus: Cleanup vmbus_uevent() code

Quoted 71 lines · Greg KH
Quoted 70 lines · K. Y. Srinivasan

Now generate appropriate uevent based on the modalias string. As part of this, cleanup the existing uevent code.

---
 drivers/staging/hv/vmbus_drv.c |   60 ++++++++--------------------------------
 1 files changed, 12 insertions(+), 48 deletions(-)
drivers/staging/hv/vmbus_drv.c +6 -42
index b651968..a6e7dc5 100644
@@ -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],
Quoted 8 lines

drivers/staging/hv/vmbus_drv.c static struct device_attribute vmbus_device_attrs[] = { · line 252

Quoted 5 lines
drivers/staging/hv/vmbus_drv.c +2 -3
-			     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

#22 lore raw

RE: [PATCH 12/59] Staging: hv: vmbus: Cleanup vmbus_uevent() code

Quoted 96 lines

-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Thursday, August 25, 2011 5:15 PM
To: KY Srinivasan
Cc: [email protected]; Haiyang Zhang; [email protected]; linux- [email protected]; [email protected]
Subject: Re: [PATCH 12/59] Staging: hv: vmbus: Cleanup vmbus_uevent() code

Quoted 2 lines · Greg KH
Quoted 1 line · K. Y. Srinivasan

Now generate appropriate uevent based on the modalias string. As part of

this,

Quoted 9 lines

Review

Quoted 9 lines

cleanup the existing uevent code.

---
 drivers/staging/hv/vmbus_drv.c |   60 ++++++++--------------------------------
 1 files changed, 12 insertions(+), 48 deletions(-)
(quoted diff) +0 -0

b/drivers/staging/hv/vmbus_drv.c

Quoted 4 lines

drivers/staging/hv/vmbus_drv.c static struct device_attribute vmbus_device_attrs[]

Quoted 4 lines

index b651968..a6e7dc5 100644

drivers/staging/hv/vmbus_drv.c +0 -0
@@ -237,58 +237,22 @@ static struct device_attribute vmbus_device_attrs[]

= {

Quoted 1 line

drivers/staging/hv/vmbus_drv.c static struct device_attribute vmbus_device_attrs[] · line 237

Quoted 1 line
drivers/staging/hv/vmbus_drv.c +0 -0
  * This routine is invoked when a device is added or removed on the vmbus

to

Quoted 8 lines

drivers/staging/hv/vmbus_drv.c static struct device_attribute vmbus_device_attrs[] = {

Quoted 8 lines
drivers/staging/hv/vmbus_drv.c +4 -0
  * 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)

Quoted 47 lines
Quoted 47 lines
drivers/staging/hv/vmbus_drv.c +2 -42
 {
 	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],
Quoted 8 lines

drivers/staging/hv/vmbus_drv.c static struct device_attribute vmbus_device_attrs[] = { · line 252

Quoted 5 lines
drivers/staging/hv/vmbus_drv.c +2 -3
-			     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.

Quoted 2 lines

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

Greg,

I don't think I got this mail. Could you resend the mail.

Regards,

K. Y

#23 lore raw

Re: [PATCH 12/59] Staging: hv: vmbus: Cleanup vmbus_uevent() code

Quoted 9 lines · KY Srinivasan
Quoted 5 lines
Quoted 2 lines

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?

Greg,

I don't think I got this mail. Could you resend the mail.

Sure, here it is:

From: "K. Y. Srinivasan" <[email protected]>
Date: Thu, 25 Aug 2011 09:48:38 -0700
Subject: [PATCH] Staging: hv: vmbus: Cleanup vmbus_uevent() code
Status: RO
Content-Length: 2871
Lines: 82

Now generate appropriate uevent based on the modalias string. As part of this, cleanup the existing uevent code.

[gregkh - fixed code to handle driver_data portion of struct hv_vmbus_device_id]

drivers/staging/hv/vmbus_drv.c +10 -46
index b651968..afb16704 100644
@@ -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 *)0)->guid) + 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 *)0)->guid) * 2); i += 2)
+		sprintf(&alias_name[i], "%02x", dev->dev_type.b[i/2]);
 
-	return 0;
+	ret = add_uevent_var(env, "MODALIAS=vmbus:%s", alias_name);
+	return ret;
 }
 
 
#24 lore raw

RE: [PATCH 12/59] Staging: hv: vmbus: Cleanup vmbus_uevent() code

Quoted 105 lines

-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Thursday, August 25, 2011 6:28 PM
To: KY Srinivasan
Cc: [email protected]; Haiyang Zhang; [email protected]; linux- [email protected]; [email protected]
Subject: Re: [PATCH 12/59] Staging: hv: vmbus: Cleanup vmbus_uevent() code

Quoted 9 lines · KY Srinivasan
Quoted 5 lines
Quoted 2 lines

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?

Greg,

I don't think I got this mail. Could you resend the mail.

Sure, here it is:

From: "K. Y. Srinivasan" <[email protected]>
Date: Thu, 25 Aug 2011 09:48:38 -0700
Subject: [PATCH] Staging: hv: vmbus: Cleanup vmbus_uevent() code
Status: RO
Content-Length: 2871
Lines: 82

Now generate appropriate uevent based on the modalias string. As part of this, cleanup the existing uevent code.

[gregkh - fixed code to handle driver_data portion of struct hv_vmbus_device_id]

drivers/staging/hv/vmbus_drv.c +6 -43
index b651968..afb16704 100644
@@ -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 *)0)->guid) + 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]);

drivers/staging/hv/vmbus_drv.c static struct device_attribute vmbus_device_attrs[] = { · line 258

Quoted 10 lines
drivers/staging/hv/vmbus_drv.c +4 -3
-	if (ret)
-		return ret;
+	for (i = 0; i < ((sizeof((struct hv_vmbus_device_id *)0)->guid) * 2); i += 2)
+		sprintf(&alias_name[i], "%02x", dev->dev_type.b[i/2]);
 
-	return 0;
+	ret = add_uevent_var(env, "MODALIAS=vmbus:%s", alias_name);
+	return ret;
 }
 

Looks good.

Thank you.

K. Y

#25 lore raw

RE: [PATCH 12/59] Staging: hv: vmbus: Cleanup vmbus_uevent() code

In reply to Greg KH
Quoted 91 lines

-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Thursday, August 25, 2011 5:00 PM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Haiyang Zhang
Subject: Re: [PATCH 12/59] Staging: hv: vmbus: Cleanup vmbus_uevent() code

drivers/staging/hv/vmbus_drv.c static struct device_attribute vmbus_device_attrs[] =

Quoted 14 lines · K. Y. Srinivasan

Now generate appropriate uevent based on the modalias string. As part of this, cleanup the existing uevent code.

---
 drivers/staging/hv/vmbus_drv.c |   60 ++++++++--------------------------------
 1 files changed, 12 insertions(+), 48 deletions(-)
drivers/staging/hv/vmbus_drv.c +0 -0
index b651968..a6e7dc5 100644
@@ -237,58 +237,22 @@ static struct device_attribute vmbus_device_attrs[] =

{

Quoted 51 lines
drivers/staging/hv/vmbus_drv.c +6 -37
  * 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],

drivers/staging/hv/vmbus_drv.c static struct device_attribute vmbus_device_attrs[] = { · line 252

Quoted 10 lines
drivers/staging/hv/vmbus_drv.c +2 -8
-			     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.

Quoted 4 lines

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

#26 lore raw

Re: [PATCH 12/59] Staging: hv: vmbus: Cleanup vmbus_uevent() code

Quoted 91 lines · KY Srinivasan
Quoted 91 lines

-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Thursday, August 25, 2011 5:00 PM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Haiyang Zhang
Subject: Re: [PATCH 12/59] Staging: hv: vmbus: Cleanup vmbus_uevent() code

drivers/staging/hv/vmbus_drv.c static struct device_attribute vmbus_device_attrs[] =

Quoted 14 lines · K. Y. Srinivasan

Now generate appropriate uevent based on the modalias string. As part of this, cleanup the existing uevent code.

---
 drivers/staging/hv/vmbus_drv.c |   60 ++++++++--------------------------------
 1 files changed, 12 insertions(+), 48 deletions(-)
drivers/staging/hv/vmbus_drv.c +0 -0
index b651968..a6e7dc5 100644
@@ -237,58 +237,22 @@ static struct device_attribute vmbus_device_attrs[] =

{

Quoted 51 lines
drivers/staging/hv/vmbus_drv.c +6 -37
  * 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],

drivers/staging/hv/vmbus_drv.c static struct device_attribute vmbus_device_attrs[] = { · line 252

Quoted 10 lines
drivers/staging/hv/vmbus_drv.c +2 -8
-			     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.

Quoted 7 lines
Quoted 4 lines

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.

That's what I ended up doing :)

greg k-h

#27 lore raw

PATCH 13/59 Staging: hv: vmbus: Support the notion of id tables in vmbus_match()

In reply to K. Y. Srinivasan

Introduce code to handle driver specific id tables to the vmbus core (vmbus_match). This would allow us to handle more than one device type with a given driver.

---
 drivers/staging/hv/vmbus_drv.c |   20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 deletions(-)
drivers/staging/hv/vmbus_drv.c +15 -5
index a6e7dc5..abcd592 100644
@@ -255,21 +255,31 @@ static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env)
 	return ret;
 }
 
+static uuid_le null_guid;
+
+static inline  bool is_null_guid(const __u8 *guid)
+{
+	if (memcmp(guid, &null_guid, sizeof(uuid_le)))
+		return false;
+	return true;
+}
+
 
 /*
  * vmbus_match - Attempt to match the specified device to the specified driver
  */
 static int vmbus_match(struct device *device, struct device_driver *driver)
 {
-	int match = 0;
 	struct hv_driver *drv = drv_to_hv_drv(driver);
 	struct hv_device *hv_dev = device_to_hv_device(device);
+	const struct hv_vmbus_device_id *id_array = drv->id_table;
 
-	/* We found our driver ? */
-	if (!uuid_le_cmp(hv_dev->dev_type, drv->dev_type))
-		match = 1;
+	for (; !is_null_guid(id_array->guid); id_array++)
+		if (!memcmp(&id_array->guid, &hv_dev->dev_type.b,
+				sizeof(struct hv_vmbus_device_id)))
+			return 1;
 
-	return match;
+	return 0;
 }
 
 /*
Signature · 1 line
1.7.4.1
#28 lore raw

PATCH 14/59 Staging: hv: vmbus: Get rid of an unnecessary include line in vmbus_drv.c

In reply to K. Y. Srinivasan

Get rid of an unnecessary include line in vmbus_drv.c.

---
 drivers/staging/hv/vmbus_drv.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
drivers/staging/hv/vmbus_drv.c +0 -1
index abcd592..dbb51b0 100644
@@ -28,7 +28,6 @@
 #include <linux/irq.h>
 #include <linux/interrupt.h>
 #include <linux/sysctl.h>
-#include <linux/dmi.h>
 #include <linux/slab.h>
 #include <linux/acpi.h>
 #include <acpi/acpi_bus.h>
Signature · 1 line
1.7.4.1
#29 lore raw

PATCH 15/59 Staging: hv: storvsc: Get rid of the DMI signature

In reply to K. Y. Srinivasan

Now that we have implemented a vmbus specific mechanism for auto-loading, get rid of the DMI signature.

---
 drivers/staging/hv/storvsc_drv.c |   22 ----------------------
 1 files changed, 0 insertions(+), 22 deletions(-)
drivers/staging/hv/storvsc_drv.c +0 -22
index ed2140c..4dc6d2f 100644
@@ -24,7 +24,6 @@
 #include <linux/module.h>
 #include <linux/device.h>
 #include <linux/blkdev.h>
-#include <linux/dmi.h>
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_host.h>
@@ -730,27 +729,6 @@ static struct hv_driver storvsc_drv = {
 	.remove = storvsc_remove,
 };
 
-/*
- * We use a DMI 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 dmi_system_id __initconst
-hv_stor_dmi_table[] __maybe_unused  = {
-	{
-		.ident = "Hyper-V",
-		.matches = {
-			DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
-			DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"),
-			DMI_MATCH(DMI_BOARD_NAME, "Virtual Machine"),
-		},
-	},
-	{ },
-};
-MODULE_DEVICE_TABLE(dmi, hv_stor_dmi_table);
-
 static int __init storvsc_drv_init(void)
 {
 	int ret;
Signature · 1 line
1.7.4.1
#30 lore raw

PATCH 16/59 Staging: hv: netvsc: Get rid of the PCI signature

In reply to K. Y. Srinivasan

Now that we have implemented a vmbus specific mechanism for auto-loading, get rid of the PCI signature.

---
 drivers/staging/hv/netvsc_drv.c |    8 --------
 1 files changed, 0 insertions(+), 8 deletions(-)
drivers/staging/hv/netvsc_drv.c +0 -8
index 2e25c95..ea5c289 100644
@@ -34,7 +34,6 @@
 #include <linux/in.h>
 #include <linux/slab.h>
 #include <linux/dmi.h>
-#include <linux/pci.h>
 #include <net/arp.h>
 #include <net/route.h>
 #include <net/sock.h>
@@ -477,13 +476,6 @@ static int __init netvsc_drv_init(void)
 	return ret;
 }
 
-static const struct pci_device_id __initconst
-hv_netvsc_pci_table[] __maybe_unused = {
-	{ PCI_DEVICE(0x1414, 0x5353) }, /* VGA compatible controller */
-	{ 0 }
-};
-MODULE_DEVICE_TABLE(pci, hv_netvsc_pci_table);
-
 MODULE_LICENSE("GPL");
 MODULE_VERSION(HV_DRV_VERSION);
 MODULE_DESCRIPTION("Microsoft Hyper-V network driver");
Signature · 1 line
1.7.4.1
#31 lore raw

PATCH 17/59 Staging: hv: netvsc: Get rid of the DMI signature in netvsc_drv.c

In reply to K. Y. Srinivasan

Now that we have implemented a vmbus specific mechanism for auto-loading, get rid of the DMI signature.

---
 drivers/staging/hv/netvsc_drv.c |   19 -------------------
 1 files changed, 0 insertions(+), 19 deletions(-)
drivers/staging/hv/netvsc_drv.c +0 -19
index ea5c289..d6c6180 100644
@@ -33,7 +33,6 @@
 #include <linux/skbuff.h>
 #include <linux/in.h>
 #include <linux/slab.h>
-#include <linux/dmi.h>
 #include <net/arp.h>
 #include <net/route.h>
 #include <net/sock.h>
@@ -440,20 +439,6 @@ static void __exit netvsc_drv_exit(void)
 }
 
 
-static const struct dmi_system_id __initconst
-hv_netvsc_dmi_table[] __maybe_unused  = {
-	{
-		.ident = "Hyper-V",
-		.matches = {
-			DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
-			DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"),
-			DMI_MATCH(DMI_BOARD_NAME, "Virtual Machine"),
-		},
-	},
-	{ },
-};
-MODULE_DEVICE_TABLE(dmi, hv_netvsc_dmi_table);
-
 static int __init netvsc_drv_init(void)
 {
 	struct hv_driver *drv = &netvsc_drv;
@@ -461,10 +446,6 @@ static int __init netvsc_drv_init(void)
 
 	pr_info("initializing....");
 
-	if (!dmi_check_system(hv_netvsc_dmi_table))
-		return -ENODEV;
-
-
 	/* Callback to client driver to complete the initialization */
 	netvsc_initialize(drv);
 
Signature · 1 line
1.7.4.1
#32 lore raw

PATCH 18/59 Staging: hv: util: Get rid of the DMI signature in hv_util.c

In reply to K. Y. Srinivasan

Now that we have implemented a vmbus specific mechanism for auto-loading, get rid of the DMI signature.

---
 drivers/staging/hv/hv_util.c |   20 --------------------
 1 files changed, 0 insertions(+), 20 deletions(-)
drivers/staging/hv/hv_util.c +0 -20
index a620f4d..aed9187 100644
@@ -26,7 +26,6 @@
 #include <linux/slab.h>
 #include <linux/sysctl.h>
 #include <linux/reboot.h>
-#include <linux/dmi.h>
 #include <linux/pci.h>
 
 #include "hyperv.h"
@@ -276,22 +275,6 @@ hv_utils_pci_table[] __maybe_unused = {
 };
 MODULE_DEVICE_TABLE(pci, hv_utils_pci_table);
 
-
-static const struct dmi_system_id __initconst
-hv_utils_dmi_table[] __maybe_unused  = {
-	{
-		.ident = "Hyper-V",
-		.matches = {
-			DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
-			DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"),
-			DMI_MATCH(DMI_BOARD_NAME, "Virtual Machine"),
-		},
-	},
-	{ },
-};
-MODULE_DEVICE_TABLE(dmi, hv_utils_dmi_table);
-
-
 static int __init init_hyperv_utils(void)
 {
 	pr_info("Registering HyperV Utility Driver\n");
@@ -300,9 +283,6 @@ static int __init init_hyperv_utils(void)
 		return -ENODEV;
 
 
-	if (!dmi_check_system(hv_utils_dmi_table))
-		return -ENODEV;
-
 	shut_txf_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
 	time_txf_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
 	hbeat_txf_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
Signature · 1 line
1.7.4.1
#33 lore raw

PATCH 19/59 Staging: hv: util: Get rid of the PCI signature in hv_util.c

In reply to K. Y. Srinivasan

Now that we have implemented a vmbus specific mechanism for auto-loading, get rid of the PCI signature.

---
 drivers/staging/hv/hv_util.c |    8 --------
 1 files changed, 0 insertions(+), 8 deletions(-)
drivers/staging/hv/hv_util.c +0 -8
index aed9187..1b0ec0e 100644
@@ -26,7 +26,6 @@
 #include <linux/slab.h>
 #include <linux/sysctl.h>
 #include <linux/reboot.h>
-#include <linux/pci.h>
 
 #include "hyperv.h"
 #include "hv_kvp.h"
@@ -268,13 +267,6 @@ static  struct hv_driver util_drv = {
 	.remove =  util_remove,
 };
 
-static const struct pci_device_id __initconst
-hv_utils_pci_table[] __maybe_unused = {
-	{ PCI_DEVICE(0x1414, 0x5353) }, /* Hyper-V emulated VGA controller */
-	{ 0 }
-};
-MODULE_DEVICE_TABLE(pci, hv_utils_pci_table);
-
 static int __init init_hyperv_utils(void)
 {
 	pr_info("Registering HyperV Utility Driver\n");
Signature · 1 line
1.7.4.1
#34 lore raw

PATCH 20/59 Staging: hv: netvsc: Initialize the driver name directly

In reply to K. Y. Srinivasan

Initialize the driver name directly in netvsc_drv.c and do the necessary adjustments.

---
 drivers/staging/hv/netvsc.c     |    5 -----
 drivers/staging/hv/netvsc_drv.c |    4 +++-
 2 files changed, 3 insertions(+), 6 deletions(-)
drivers/staging/hv/netvsc.c +0 -5
index 6f4541b..d085018 100644
@@ -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;
@@ -999,7 +996,5 @@ cleanup:
 int netvsc_initialize(struct hv_driver *drv)
 {
 
-	drv->name = driver_name;
-
 	return 0;
 }
drivers/staging/hv/netvsc_drv.c +3 -1
index d6c6180..61de6f2 100644
@@ -41,6 +41,8 @@
 #include "hyperv.h"
 #include "hyperv_net.h"
 
+static const char *driver_name = "netvsc";
+
 struct net_device_context {
 	/* point back to our device context */
 	struct hv_device *device_ctx;
@@ -449,7 +451,7 @@ static int __init netvsc_drv_init(void)
 	/* Callback to client driver to complete the initialization */
 	netvsc_initialize(drv);
 
-	drv->driver.name = drv->name;
+	drv->driver.name = driver_name;
 
 	/* The driver belongs to vmbus */
 	ret = vmbus_child_driver_register(&drv->driver);
Signature · 1 line
1.7.4.1
#35 lore raw

PATCH 21/59 Staging: hv: netvsc: Get rid of the empty function netvsc_initialize()

In reply to K. Y. Srinivasan

Now, get rid of the empty function netvsc_initialize().

---
 drivers/staging/hv/hyperv_net.h |    1 -
 drivers/staging/hv/netvsc.c     |    9 ---------
 drivers/staging/hv/netvsc_drv.c |    3 ---
 3 files changed, 0 insertions(+), 13 deletions(-)
drivers/staging/hv/hyperv_net.h +0 -1
index 27f987b..5782fea 100644
@@ -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,
drivers/staging/hv/netvsc.c +0 -9
index d085018..cb02eed 100644
@@ -989,12 +989,3 @@ cleanup:
 
 	return ret;
 }
-
-/*
- * netvsc_initialize - Main entry point
- */
-int netvsc_initialize(struct hv_driver *drv)
-{
-
-	return 0;
-}
drivers/staging/hv/netvsc_drv.c +0 -3
index 61de6f2..bb46216 100644
@@ -448,9 +448,6 @@ static int __init netvsc_drv_init(void)
 
 	pr_info("initializing....");
 
-	/* Callback to client driver to complete the initialization */
-	netvsc_initialize(drv);
-
 	drv->driver.name = driver_name;
 
 	/* The driver belongs to vmbus */
Signature · 1 line
1.7.4.1
#36 lore raw

PATCH 22/59 Staging: hv: vmbus: Get rid of the unused name field in struct hv_driver

In reply to K. Y. Srinivasan

Get rid of the unused "name" field in struct hv_driver.

---
 drivers/staging/hv/hyperv.h |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
drivers/staging/hv/hyperv.h +0 -2
index b8199f4..60ead66 100644
@@ -802,8 +802,6 @@ struct hv_device_info {
 
 /* Base driver object */
 struct hv_driver {
-	const char *name;
-
 	/* the device type supported by this driver */
 	uuid_le dev_type;
 	const struct hv_vmbus_device_id *id_table;
Signature · 1 line
1.7.4.1
#37 lore raw

Re: [PATCH 22/59] Staging: hv: vmbus: Get rid of the unused name field in struct hv_driver

Quoted 13 lines · K. Y. Srinivasan

Get rid of the unused "name" field in struct hv_driver.

---
 drivers/staging/hv/hyperv.h |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
drivers/staging/hv/hyperv.h +0 -0
index b8199f4..60ead66 100644

drivers/staging/hv/hyperv.h struct hv_device_info { · line 805

Quoted 4 lines
drivers/staging/hv/hyperv.h +0 -1
@@ -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

#38 lore raw

Re: [PATCH 22/59] Staging: hv: vmbus: Get rid of the unused name field in struct hv_driver

Quoted 34 lines · Greg KH
Quoted 13 lines · K. Y. Srinivasan

Get rid of the unused "name" field in struct hv_driver.

---
 drivers/staging/hv/hyperv.h |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
drivers/staging/hv/hyperv.h +0 -0
index b8199f4..60ead66 100644

drivers/staging/hv/hyperv.h struct hv_device_info { · line 805

Quoted 4 lines
drivers/staging/hv/hyperv.h +0 -1
@@ -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.

Quoted 7 lines

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

#39 lore raw

Re: [PATCH 22/59] Staging: hv: vmbus: Get rid of the unused name field in struct hv_driver

Quoted 9 lines · Greg KH
Quoted 3 lines

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 <[email protected]>
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 <[email protected]>
Cc Haiyang Zhang <[email protected]>
Cc Hank Janssen <[email protected]>
---
 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(-)
drivers/staging/hv/blkvsc_drv.c +3 -14
index d170f24..07dc9ed 100644
@@ -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);
 }
 
 /*
drivers/staging/hv/hv_mouse.c +3 -18
index ebd1715..5727173 100644
@@ -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);
 }
 
 /*
drivers/staging/hv/hv_util.c +3 -6
index b0d89de..f2f456f 100644
@@ -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);
drivers/staging/hv/hyperv.h +6 -2
index d96de66..c249811 100644
@@ -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
drivers/staging/hv/hyperv_net.h +0 -1
index 27f987b..5782fea 100644
@@ -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,
drivers/staging/hv/netvsc.c +0 -14
index 6f4541b..cb02eed 100644
@@ -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;
-}
drivers/staging/hv/netvsc_drv.c +3 -16
index 2d2955c..ad1ef03 100644
@@ -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");
drivers/staging/hv/storvsc_drv.c +7 -17
index 6f67e9b..0297418 100644
@@ -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");
drivers/staging/hv/vmbus_drv.c +21 -22

72 lines not on this page · raw message

Signature · 1 line
1.7.6
#40 lore raw

RE: [PATCH 22/59] Staging: hv: vmbus: Get rid of the unused name field in struct hv_driver

In reply to Greg KH
Quoted 54 lines

-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Thursday, August 25, 2011 5:28 PM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Haiyang Zhang
Subject: Re: [PATCH 22/59] Staging: hv: vmbus: Get rid of the unused name field in struct hv_driver

Quoted 34 lines · Greg KH
Quoted 13 lines · K. Y. Srinivasan

Get rid of the unused "name" field in struct hv_driver.

---
 drivers/staging/hv/hyperv.h |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
drivers/staging/hv/hyperv.h +0 -0
index b8199f4..60ead66 100644

drivers/staging/hv/hyperv.h struct hv_device_info { · line 805

Quoted 4 lines
drivers/staging/hv/hyperv.h +0 -1
@@ -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.

Quoted 7 lines

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...

Quoted 5 lines

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,

This was existing code and I realized it did not conform to the Linux Driver Model. I fixed it in the patch set I had sent earlier (110/117). Yesterday I only got up to 74 of the 117 patches that you commented on.
I was planning to send the rest today. If it is ok with you, please don't fix it here As it would break everything else. This is existing code that I am fixing in the patch set I will send you shortly.

Regards,

K. Y

Quoted 2 lines

greg k-h

#41 lore raw

Re: [PATCH 22/59] Staging: hv: vmbus: Get rid of the unused name field in struct hv_driver

Quoted 6 lines · KY Srinivasan

This was existing code and I realized it did not conform to the Linux Driver Model. I fixed it in the patch set I had sent earlier (110/117). Yesterday I only got up to 74 of the 117 patches that you commented on.
I was planning to send the rest today. If it is ok with you, please don't fix it here As it would break everything else. This is existing code that I am fixing in the patch set I will send you shortly.

Oops, as you see, I applied it :)

And I applied the rest of your series, so you might want to re-test and resync your next series of patches based on what I have in the staging-next tree now.

thanks,

greg k-h

#42 lore raw

PATCH 23/59 Staging: hv: vmbus: Get rid of some unnecessary comments

In reply to K. Y. Srinivasan

Get rid of some unnecessary comments.

---
 drivers/staging/hv/vmbus_drv.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
drivers/staging/hv/vmbus_drv.c +0 -2
index dbb51b0..e467c56 100644
@@ -44,8 +44,6 @@ static struct tasklet_struct event_dpc;
 
 unsigned int vmbus_loglevel = (ALL_MODULES << 16 | INFO_LVL);
 EXPORT_SYMBOL(vmbus_loglevel);
-	/* (ALL_MODULES << 16 | DEBUG_LVL_ENTEREXIT); */
-	/* (((VMBUS | VMBUS_DRV)<<16) | DEBUG_LVL_ENTEREXIT); */
 
 static struct completion probe_event;
 static int irq;
Signature · 1 line
1.7.4.1
#43 lore raw

PATCH 24/59 Staging: hv: vmbus: Cleanup unnecessary comments in hv.c

In reply to K. Y. Srinivasan

Cleanup unnecessary comments in hv.c.

---
 drivers/staging/hv/hv.c |    8 --------
 1 files changed, 0 insertions(+), 8 deletions(-)
drivers/staging/hv/hv.c +0 -8
index 2192d78..d2b921b 100644
@@ -164,11 +164,7 @@ int hv_init(void)
 		goto cleanup;
 
 	max_leaf = query_hypervisor_info();
-	/* HvQueryHypervisorFeatures(maxLeaf); */
 
-	/*
-	 * We only support running on top of Hyper-V
-	 */
 	rdmsrl(HV_X64_MSR_GUEST_OS_ID, hv_context.guestid);
 
 	if (hv_context.guestid != 0)
@@ -181,10 +177,6 @@ int hv_init(void)
 	/* See if the hypercall page is already set */
 	rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
 
-	/*
-	* Allocate the hypercall page memory
-	* virtaddr = osd_page_alloc(1);
-	*/
 	virtaddr = __vmalloc(PAGE_SIZE, GFP_KERNEL, PAGE_KERNEL_EXEC);
 
 	if (!virtaddr)
Signature · 1 line
1.7.4.1
#44 lore raw

PATCH 25/59 Staging: hv: vmbus: Cleanup error handling in hv_init()

In reply to K. Y. Srinivasan

Use standard Linux error codes.

---
 drivers/staging/hv/hv.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
drivers/staging/hv/hv.c +3 -4
index d2b921b..736794e 100644
@@ -151,7 +151,6 @@ static u64 do_hypercall(u64 control, void *input, void *output)
  */
 int hv_init(void)
 {
-	int ret = 0;
 	int max_leaf;
 	union hv_x64_msr_hypercall_contents hypercall_msr;
 	void *virtaddr = NULL;
@@ -214,7 +213,7 @@ int hv_init(void)
 	hv_context.signal_event_param->flag_number = 0;
 	hv_context.signal_event_param->rsvdz = 0;
 
-	return ret;
+	return 0;
 
 cleanup:
 	if (virtaddr) {
@@ -225,8 +224,8 @@ cleanup:
 
 		vfree(virtaddr);
 	}
-	ret = -1;
-	return ret;
+
+	return -ENOTSUPP;
 }
 
 /*
Signature · 1 line
1.7.4.1
#45 lore raw

PATCH 26/59 Staging: hv: vmbus: Get rid of unnecessay comments in connection.c

In reply to K. Y. Srinivasan

Get rid of unnecessay comments in connection.c.

---
 drivers/staging/hv/connection.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
drivers/staging/hv/connection.c +0 -2
index e6b4039..0e7efce 100644
@@ -215,8 +215,6 @@ static void process_chn_event(u32 relid)
 {
 	struct vmbus_channel *channel;
 
-	/* ASSERT(relId > 0); */
-
 	/*
 	 * Find the channel based on this relid and invokes the
 	 * channel callback to process the event
Signature · 1 line
1.7.4.1
#46 lore raw

PATCH 27/59 Staging: hv: vmbus: Get rid of the function dump_gpadl_body()

In reply to K. Y. Srinivasan

Get rid of the function dump_gpadl_body() since it adds no value and actually is in the data path.

---
 drivers/staging/hv/channel.c |   20 --------------------
 1 files changed, 0 insertions(+), 20 deletions(-)
drivers/staging/hv/channel.c +0 -20
index 222adcc..2d5bfac 100644
@@ -239,24 +239,6 @@ errorout:
 }
 EXPORT_SYMBOL_GPL(vmbus_open);
 
-/*
- * dump_gpadl_body - Dump the gpadl body message to the console for
- * debugging purposes.
- */
-static void dump_gpadl_body(struct vmbus_channel_gpadl_body *gpadl, u32 len)
-{
-	int i;
-	int pfncount;
-
-	pfncount = (len - sizeof(struct vmbus_channel_gpadl_body)) /
-		   sizeof(u64);
-
-	DPRINT_DBG(VMBUS, "gpadl body - len %d pfn count %d", len, pfncount);
-
-	for (i = 0; i < pfncount; i++)
-		DPRINT_DBG(VMBUS, "gpadl body  - %d) pfn %llu",
-			   i, gpadl->pfn[i]);
-}
 
 /*
  * dump_gpadl_header - Dump the gpadl header message to the console for
@@ -485,8 +467,6 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
 				CHANNELMSG_GPADL_BODY;
 			gpadl_body->gpadl = next_gpadl_handle;
 
-			dump_gpadl_body(gpadl_body, submsginfo->msgsize -
-				      sizeof(*submsginfo));
 			ret = vmbus_post_msg(gpadl_body,
 					       submsginfo->msgsize -
 					       sizeof(*submsginfo));
Signature · 1 line
1.7.4.1
#47 lore raw

PATCH 28/59 Staging: hv: vmbus: Get rid of the function dump_gpadl_header()

In reply to K. Y. Srinivasan

Get rid of the function dump_gpadl_header() as this adds no value.

---
 drivers/staging/hv/channel.c |   28 ----------------------------
 1 files changed, 0 insertions(+), 28 deletions(-)
drivers/staging/hv/channel.c +0 -28
index 2d5bfac..aa0a150 100644
@@ -239,33 +239,6 @@ errorout:
 }
 EXPORT_SYMBOL_GPL(vmbus_open);
 
-
-/*
- * dump_gpadl_header - Dump the gpadl header message to the console for
- * debugging purposes.
- */
-static void dump_gpadl_header(struct vmbus_channel_gpadl_header *gpadl)
-{
-	int i, j;
-	int pagecount;
-
-	DPRINT_DBG(VMBUS,
-		   "gpadl header - relid %d, range count %d, range buflen %d",
-		   gpadl->child_relid, gpadl->rangecount, gpadl->range_buflen);
-	for (i = 0; i < gpadl->rangecount; i++) {
-		pagecount = gpadl->range[i].byte_count >> PAGE_SHIFT;
-		pagecount = (pagecount > 26) ? 26 : pagecount;
-
-		DPRINT_DBG(VMBUS, "gpadl range %d - len %d offset %d "
-			   "page count %d", i, gpadl->range[i].byte_count,
-			   gpadl->range[i].byte_offset, pagecount);
-
-		for (j = 0; j < pagecount; j++)
-			DPRINT_DBG(VMBUS, "%d) pfn %llu", j,
-				   gpadl->range[i].pfn_array[j]);
-	}
-}
-
 /*
  * create_gpadl_header - Creates a gpadl for the specified buffer
  */
@@ -443,7 +416,6 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
 	gpadlmsg->child_relid = channel->offermsg.child_relid;
 	gpadlmsg->gpadl = next_gpadl_handle;
 
-	dump_gpadl_header(gpadlmsg);
 
 	spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
 	list_add_tail(&msginfo->msglistentry,
Signature · 1 line
1.7.4.1
#48 lore raw

PATCH 29/59 Staging: hv: vmbus: Rename openMsg to open_msg in channel.c

In reply to K. Y. Srinivasan

Rename openMsg to open_msg in channel.c.

---
 drivers/staging/hv/channel.c |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)
drivers/staging/hv/channel.c +10 -10
index aa0a150..ebd7552 100644
@@ -119,7 +119,7 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
 		     u32 recv_ringbuffer_size, void *userdata, u32 userdatalen,
 		     void (*onchannelcallback)(void *context), void *context)
 {
-	struct vmbus_channel_open_channel *openMsg;
+	struct vmbus_channel_open_channel *open_msg;
 	struct vmbus_channel_msginfo *openInfo = NULL;
 	void *in, *out;
 	unsigned long flags;
@@ -183,14 +183,14 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
 
 	init_completion(&openInfo->waitevent);
 
-	openMsg = (struct vmbus_channel_open_channel *)openInfo->msg;
-	openMsg->header.msgtype = CHANNELMSG_OPENCHANNEL;
-	openMsg->openid = newchannel->offermsg.child_relid;
-	openMsg->child_relid = newchannel->offermsg.child_relid;
-	openMsg->ringbuffer_gpadlhandle = newchannel->ringbuffer_gpadlhandle;
-	openMsg->downstream_ringbuffer_pageoffset = send_ringbuffer_size >>
+	open_msg = (struct vmbus_channel_open_channel *)openInfo->msg;
+	open_msg->header.msgtype = CHANNELMSG_OPENCHANNEL;
+	open_msg->openid = newchannel->offermsg.child_relid;
+	open_msg->child_relid = newchannel->offermsg.child_relid;
+	open_msg->ringbuffer_gpadlhandle = newchannel->ringbuffer_gpadlhandle;
+	open_msg->downstream_ringbuffer_pageoffset = send_ringbuffer_size >>
 						  PAGE_SHIFT;
-	openMsg->server_contextarea_gpadlhandle = 0;
+	open_msg->server_contextarea_gpadlhandle = 0;
 
 	if (userdatalen > MAX_USER_DEFINED_BYTES) {
 		err = -EINVAL;
@@ -198,14 +198,14 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
 	}
 
 	if (userdatalen)
-		memcpy(openMsg->userdata, userdata, userdatalen);
+		memcpy(open_msg->userdata, userdata, userdatalen);
 
 	spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
 	list_add_tail(&openInfo->msglistentry,
 		      &vmbus_connection.chn_msg_list);
 	spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
 
-	ret = vmbus_post_msg(openMsg,
+	ret = vmbus_post_msg(open_msg,
 			       sizeof(struct vmbus_channel_open_channel));
 
 	if (ret != 0)
Signature · 1 line
1.7.4.1
#49 lore raw

PATCH 30/59 Staging: hv: vmbus: Get rid of unnecessary comments in channel.c

In reply to K. Y. Srinivasan

Get rid of unnecessary comments in channel.c.

---
 drivers/staging/hv/channel.c |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)
drivers/staging/hv/channel.c +0 -4
index ebd7552..e02060e 100644
@@ -76,7 +76,6 @@ void vmbus_get_debug_info(struct vmbus_channel *channel,
 	struct hv_monitor_page *monitorpage;
 	u8 monitor_group = (u8)channel->offermsg.monitorid / 32;
 	u8 monitor_offset = (u8)channel->offermsg.monitorid % 32;
-	/* u32 monitorBit	= 1 << monitorOffset; */
 
 	debuginfo->relid = channel->offermsg.child_relid;
 	debuginfo->state = channel->state;
@@ -392,7 +391,6 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
 {
 	struct vmbus_channel_gpadl_header *gpadlmsg;
 	struct vmbus_channel_gpadl_body *gpadl_body;
-	/* struct vmbus_channel_gpadl_created *gpadlCreated; */
 	struct vmbus_channel_msginfo *msginfo = NULL;
 	struct vmbus_channel_msginfo *submsginfo;
 	u32 msgcount;
@@ -474,8 +472,6 @@ int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle)
 	unsigned long flags;
 	int ret, t;
 
-	/* ASSERT(gpadl_handle != 0); */
-
 	info = kmalloc(sizeof(*info) +
 		       sizeof(struct vmbus_channel_gpadl_teardown), GFP_KERNEL);
 	if (!info)
Signature · 1 line
1.7.4.1
#50 lore raw

PATCH 31/59 Staging: hv: vmbus: Change the variable name openInfo to open_info in channel.c

In reply to K. Y. Srinivasan

Change the variable name openInfo to open_info in channel.c.

---
 drivers/staging/hv/channel.c |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)
drivers/staging/hv/channel.c +12 -12
index e02060e..9eb8def 100644
@@ -119,7 +119,7 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
 		     void (*onchannelcallback)(void *context), void *context)
 {
 	struct vmbus_channel_open_channel *open_msg;
-	struct vmbus_channel_msginfo *openInfo = NULL;
+	struct vmbus_channel_msginfo *open_info = NULL;
 	void *in, *out;
 	unsigned long flags;
 	int ret, t, err = 0;
@@ -172,17 +172,17 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
 	}
 
 	/* Create and init the channel open message */
-	openInfo = kmalloc(sizeof(*openInfo) +
+	open_info = kmalloc(sizeof(*open_info) +
 			   sizeof(struct vmbus_channel_open_channel),
 			   GFP_KERNEL);
-	if (!openInfo) {
+	if (!open_info) {
 		err = -ENOMEM;
 		goto errorout;
 	}
 
-	init_completion(&openInfo->waitevent);
+	init_completion(&open_info->waitevent);
 
-	open_msg = (struct vmbus_channel_open_channel *)openInfo->msg;
+	open_msg = (struct vmbus_channel_open_channel *)open_info->msg;
 	open_msg->header.msgtype = CHANNELMSG_OPENCHANNEL;
 	open_msg->openid = newchannel->offermsg.child_relid;
 	open_msg->child_relid = newchannel->offermsg.child_relid;
@@ -200,7 +200,7 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
 		memcpy(open_msg->userdata, userdata, userdatalen);
 
 	spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
-	list_add_tail(&openInfo->msglistentry,
+	list_add_tail(&open_info->msglistentry,
 		      &vmbus_connection.chn_msg_list);
 	spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
 
@@ -210,22 +210,22 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
 	if (ret != 0)
 		goto cleanup;
 
-	t = wait_for_completion_timeout(&openInfo->waitevent, 5*HZ);
+	t = wait_for_completion_timeout(&open_info->waitevent, 5*HZ);
 	if (t == 0) {
 		err = -ETIMEDOUT;
 		goto errorout;
 	}
 
 
-	if (openInfo->response.open_result.status)
-		err = openInfo->response.open_result.status;
+	if (open_info->response.open_result.status)
+		err = open_info->response.open_result.status;
 
 cleanup:
 	spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
-	list_del(&openInfo->msglistentry);
+	list_del(&open_info->msglistentry);
 	spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
 
-	kfree(openInfo);
+	kfree(open_info);
 	return err;
 
 errorout:
@@ -233,7 +233,7 @@ errorout:
 	hv_ringbuffer_cleanup(&newchannel->inbound);
 	free_pages((unsigned long)out,
 		get_order(send_ringbuffer_size + recv_ringbuffer_size));
-	kfree(openInfo);
+	kfree(open_info);
 	return err;
 }
 EXPORT_SYMBOL_GPL(vmbus_open);
Signature · 1 line
1.7.4.1
#51 lore raw

PATCH 32/59 Staging: hv: vmbus: Cleanup error values in ringbuffer.c

In reply to K. Y. Srinivasan

Use standard Linux errno values in ringbuffer.c and do the associated cleanup in the clients.

---
 drivers/staging/hv/blkvsc_drv.c  |    2 +-
 drivers/staging/hv/netvsc.c      |    2 +-
 drivers/staging/hv/ring_buffer.c |    6 +++---
 drivers/staging/hv/storvsc_drv.c |    2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)
drivers/staging/hv/blkvsc_drv.c +1 -1
index 9b99387..d3f4f1d 100644
@@ -726,7 +726,7 @@ static int blkvsc_do_request(struct block_device_context *blkdev,
 		} else {
 			ret = blkvsc_submit_request(blkvsc_req,
 						    blkvsc_request_completion);
-			if (ret == -1) {
+			if (ret == -EAGAIN) {
 				pending = 1;
 				list_add_tail(&blkvsc_req->pend_entry,
 					      &blkdev->pending_list);
drivers/staging/hv/netvsc.c +1 -1
index cb02eed..d547ff6 100644
@@ -565,7 +565,7 @@ retry_send_cmplt:
 	if (ret == 0) {
 		/* success */
 		/* no-op */
-	} else if (ret == -1) {
+	} else if (ret == -EAGAIN) {
 		/* no more room...wait a bit and attempt to retry 3 times */
 		retries++;
 		dev_err(&device->device, "unable to send receive completion pkt"
drivers/staging/hv/ring_buffer.c +3 -3
index 42f7672..9212699 100644
@@ -390,7 +390,7 @@ int hv_ringbuffer_write(struct hv_ring_buffer_info *outring_info,
 	/* is empty since the read index == write index */
 	if (bytes_avail_towrite <= totalbytes_towrite) {
 		spin_unlock_irqrestore(&outring_info->ring_lock, flags);
-		return -1;
+		return -EAGAIN;
 	}
 
 	/* Write to the ring buffer */
@@ -450,7 +450,7 @@ int hv_ringbuffer_peek(struct hv_ring_buffer_info *Inring_info,
 
 		spin_unlock_irqrestore(&Inring_info->ring_lock, flags);
 
-		return -1;
+		return -EAGAIN;
 	}
 
 	/* Convert to byte offset */
@@ -496,7 +496,7 @@ int hv_ringbuffer_read(struct hv_ring_buffer_info *inring_info, void *buffer,
 	if (bytes_avail_toread < buflen) {
 		spin_unlock_irqrestore(&inring_info->ring_lock, flags);
 
-		return -1;
+		return -EAGAIN;
 	}
 
 	next_read_location =
drivers/staging/hv/storvsc_drv.c +1 -1
index 4dc6d2f..1e49879 100644
@@ -580,7 +580,7 @@ retry_request:
 	/* Invokes the vsc to start an IO */
 	ret = storvsc_do_io(dev, &cmd_request->request);
 
-	if (ret == -1) {
+	if (ret == -EAGAIN) {
 		/* no more space */
 
 		if (cmd_request->bounce_sgl_count) {
Signature · 1 line
1.7.4.1
#52 lore raw

PATCH 33/59 Staging: hv: vmbus: Cleanup the error return value in vmbus_recvpacket_raw()

In reply to K. Y. Srinivasan

Use standard Linux errno values.

---
 drivers/staging/hv/channel.c  |    2 +-
 drivers/staging/hv/hv_mouse.c |    2 +-
 drivers/staging/hv/netvsc.c   |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/staging/hv/channel.c +1 -1
index 9eb8def..ac92c1f 100644
@@ -811,7 +811,7 @@ int vmbus_recvpacket_raw(struct vmbus_channel *channel, void *buffer,
 		pr_err("Buffer too small - needed %d bytes but "
 			"got space for only %d bytes\n",
 			packetlen, bufferlen);
-		return -2;
+		return -ENOBUFS;
 	}
 
 	*requestid = desc.trans_id;
drivers/staging/hv/hv_mouse.c +1 -1
index dd8a114..2e04948 100644
@@ -541,7 +541,7 @@ static void mousevsc_on_channel_callback(void *context)
 				}
 				break;
 			}
-		} else if (ret == -2) {
+		} else if (ret == -ENOBUFS) {
 			/* Handle large packet */
 			bufferlen = bytes_recvd;
 			buffer = kzalloc(bytes_recvd, GFP_KERNEL);
drivers/staging/hv/netvsc.c +1 -1
index d547ff6..b89ac7e 100644
@@ -884,7 +884,7 @@ static void netvsc_channel_cb(void *context)
 
 				break;
 			}
-		} else if (ret == -2) {
+		} else if (ret == -ENOBUFS) {
 			/* Handle large packet */
 			buffer = kmalloc(bytes_recvd, GFP_ATOMIC);
 			if (buffer == NULL) {
Signature · 1 line
1.7.4.1
#53 lore raw

PATCH 34/59 Staging: hv: netvsc: Get rid of an unnecessary print statement in netvsc_probe()

In reply to K. Y. Srinivasan

Get rid of an unnecessary print statement in netvsc_probe(). Furthermore, this fixes a bug since netdev_err is being invoked after the device has been freed.

---
 drivers/staging/hv/netvsc_drv.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
drivers/staging/hv/netvsc_drv.c +0 -2
index bb46216..77f9236 100644
@@ -357,8 +357,6 @@ static int netvsc_probe(struct hv_device *dev)
 	if (ret != 0) {
 		free_netdev(net);
 		dev_set_drvdata(&dev->device, NULL);
-
-		netdev_err(net, "unable to add netvsc device (ret %d)\n", ret);
 		return ret;
 	}
 
Signature · 1 line
1.7.4.1
#54 lore raw

PATCH 35/59 Staging: hv: vmbus: Retry vmbus_post_msg() before giving up

In reply to K. Y. Srinivasan

The function hv_post_msg() can fail because of transient resource conditions. It may be useful to retry the operation.

---
 arch/x86/include/asm/hyperv.h   |    1 +
 drivers/staging/hv/connection.c |   18 +++++++++++++++++-
 2 files changed, 18 insertions(+), 1 deletions(-)
arch/x86/include/asm/hyperv.h +1 -0
index 5df477a..b80420b 100644
@@ -189,5 +189,6 @@
 #define HV_STATUS_INVALID_HYPERCALL_CODE	2
 #define HV_STATUS_INVALID_HYPERCALL_INPUT	3
 #define HV_STATUS_INVALID_ALIGNMENT		4
+#define HV_STATUS_INSUFFICIENT_BUFFERS		19
 
 #endif
drivers/staging/hv/connection.c +17 -1
index 0e7efce..a88ad70 100644
@@ -25,6 +25,7 @@
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/wait.h>
+#include <linux/delay.h>
 #include <linux/mm.h>
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
@@ -268,10 +269,25 @@ void vmbus_on_event(unsigned long data)
 int vmbus_post_msg(void *buffer, size_t buflen)
 {
 	union hv_connection_id conn_id;
+	int ret = 0;
+	int retries = 0;
 
 	conn_id.asu32 = 0;
 	conn_id.u.id = VMBUS_MESSAGE_CONNECTION_ID;
-	return hv_post_message(conn_id, 1, buffer, buflen);
+
+	/*
+	 * hv_post_message() can have transient failures because of
+	 * insufficient resources. Retry the operation a couple of
+	 * times before giving up.
+	 */
+	while (retries < 3) {
+		ret =  hv_post_message(conn_id, 1, buffer, buflen);
+		if (ret != HV_STATUS_INSUFFICIENT_BUFFERS)
+			return ret;
+		retries++;
+		msleep(100);
+	}
+	return ret;
 }
 
 /*
Signature · 1 line
1.7.4.1
#55 lore raw

PATCH 36/59 Staging: hv: storvsc: Cleanup error handling in storvsc_dev_add()

In reply to K. Y. Srinivasan

Use standard Linux error values and cleanup error handling. I would like to acknowledge Andre Bartke ([email protected]) for highlighting this problem.

---
 drivers/staging/hv/storvsc.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
drivers/staging/hv/storvsc.c +6 -6
index 3029786..915aeee 100644
@@ -392,10 +392,8 @@ int storvsc_dev_add(struct hv_device *device,
 
 	device_info = (struct storvsc_device_info *)additional_info;
 	stor_device = alloc_stor_device(device);
-	if (!stor_device) {
-		ret = -1;
-		goto cleanup;
-	}
+	if (!stor_device)
+		return -ENOMEM;
 
 	/* Save the channel properties to our storvsc channel */
 
@@ -409,11 +407,13 @@ int storvsc_dev_add(struct hv_device *device,
 	stor_device->port_number = device_info->port_number;
 	/* Send it back up */
 	ret = storvsc_connect_to_vsp(device, device_info->ring_buffer_size);
-
+	if (ret) {
+		free_stor_device(stor_device);
+		return ret;
+	}
 	device_info->path_id = stor_device->path_id;
 	device_info->target_id = stor_device->target_id;
 
-cleanup:
 	return ret;
 }
 
Signature · 1 line
1.7.4.1
#56 lore raw

PATCH 37/59 Staging: hv: storvsc: Cleanup error handling in storvsc_channel_init()

In reply to K. Y. Srinivasan

Use standard Linux error codes.

---
 drivers/staging/hv/storvsc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/hv/storvsc.c +1 -1
index 915aeee..22ac6f2 100644
@@ -111,7 +111,7 @@ static int storvsc_channel_init(struct hv_device *device)
 
 	stor_device = get_stor_device(device);
 	if (!stor_device)
-		return -1;
+		return -ENODEV;
 
 	request = &stor_device->init_request;
 	vstor_packet = &request->vstor_packet;
Signature · 1 line
1.7.4.1
#57 lore raw

PATCH 38/59 Staging: hv: storvsc: Cleanup error handling in storvsc_connect_to_vsp()

In reply to K. Y. Srinivasan

Cleanup error handling in storvsc_connect_to_vsp().

---
 drivers/staging/hv/storvsc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/hv/storvsc.c +1 -1
index 22ac6f2..2b73f72 100644
@@ -376,7 +376,7 @@ static int storvsc_connect_to_vsp(struct hv_device *device, u32 ring_size)
 			 storvsc_on_channel_callback, device);
 
 	if (ret != 0)
-		return -1;
+		return ret;
 
 	ret = storvsc_channel_init(device);
 
Signature · 1 line
1.7.4.1
#58 lore raw

PATCH 39/59 Staging: hv: storvsc: Cleanup error handling in storvsc_do_io()

In reply to K. Y. Srinivasan

Use standard Linux error codes.

---
 drivers/staging/hv/storvsc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/hv/storvsc.c +1 -1
index 2b73f72..2b914e4 100644
@@ -454,7 +454,7 @@ int storvsc_do_io(struct hv_device *device,
 	stor_device = get_stor_device(device);
 
 	if (!stor_device)
-		return -2;
+		return -ENODEV;
 
 
 	request->device  = device;
Signature · 1 line
1.7.4.1
#59 lore raw

PATCH 40/59 Storage: hv: storvsc: Get rid of some unnecessary DPRINTs from storvsc.c

In reply to K. Y. Srinivasan

Get rid of some unnecessary DPRINTs from storvsc.c.

---
 drivers/staging/hv/storvsc.c |   16 ----------------
 1 files changed, 0 insertions(+), 16 deletions(-)
drivers/staging/hv/storvsc.c +0 -16
index 2b914e4..3730f3f 100644
@@ -125,8 +125,6 @@ static int storvsc_channel_init(struct hv_device *device)
 	vstor_packet->operation = VSTOR_OPERATION_BEGIN_INITIALIZATION;
 	vstor_packet->flags = REQUEST_COMPLETION_FLAG;
 
-	DPRINT_INFO(STORVSC, "BEGIN_INITIALIZATION_OPERATION...");
-
 	ret = vmbus_sendpacket(device->channel, vstor_packet,
 			       sizeof(struct vstor_packet),
 			       (unsigned long)request,
@@ -145,7 +143,6 @@ static int storvsc_channel_init(struct hv_device *device)
 	    vstor_packet->status != 0)
 		goto cleanup;
 
-	DPRINT_INFO(STORVSC, "QUERY_PROTOCOL_VERSION_OPERATION...");
 
 	/* reuse the packet for version range supported */
 	memset(vstor_packet, 0, sizeof(struct vstor_packet));
@@ -174,8 +171,6 @@ static int storvsc_channel_init(struct hv_device *device)
 	    vstor_packet->status != 0)
 		goto cleanup;
 
-	/* Query channel properties */
-	DPRINT_INFO(STORVSC, "QUERY_PROPERTIES_OPERATION...");
 
 	memset(vstor_packet, 0, sizeof(struct vstor_packet));
 	vstor_packet->operation = VSTOR_OPERATION_QUERY_PROPERTIES;
@@ -207,8 +202,6 @@ static int storvsc_channel_init(struct hv_device *device)
 	stor_device->target_id
 		= vstor_packet->storage_channel_properties.target_id;
 
-	DPRINT_INFO(STORVSC, "END_INITIALIZATION_OPERATION...");
-
 	memset(vstor_packet, 0, sizeof(struct vstor_packet));
 	vstor_packet->operation = VSTOR_OPERATION_END_INITIALIZATION;
 	vstor_packet->flags = REQUEST_COMPLETION_FLAG;
@@ -232,7 +225,6 @@ static int storvsc_channel_init(struct hv_device *device)
 	    vstor_packet->status != 0)
 		goto cleanup;
 
-	DPRINT_INFO(STORVSC, "**** storage channel up and running!! ****");
 
 cleanup:
 	put_stor_device(device);
@@ -305,13 +297,8 @@ static void storvsc_on_receive(struct hv_device *device,
 		storvsc_on_io_completion(device, vstor_packet, request);
 		break;
 	case VSTOR_OPERATION_REMOVE_DEVICE:
-		DPRINT_INFO(STORVSC, "REMOVE_DEVICE_OPERATION");
-		/* TODO: */
-		break;
 
 	default:
-		DPRINT_INFO(STORVSC, "Unknown operation received - %d",
-			    vstor_packet->operation);
 		break;
 	}
 }
@@ -421,9 +408,6 @@ int storvsc_dev_remove(struct hv_device *device)
 {
 	struct storvsc_device *stor_device;
 
-	DPRINT_INFO(STORVSC, "disabling storage device (%p)...",
-		    device->ext);
-
 	stor_device = release_stor_device(device);
 
 	/*
Signature · 1 line
1.7.4.1
#60 lore raw

PATCH 41/59 Staging: hv: storvsc: Fix/cleanup some dated comments in storvsc.c

In reply to K. Y. Srinivasan

Fix/cleanup some dated comments in storvsc.c.

---
 drivers/staging/hv/storvsc.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)
drivers/staging/hv/storvsc.c +3 -5
index 3730f3f..827b6a3 100644
@@ -166,7 +166,6 @@ static int storvsc_channel_init(struct hv_device *device)
 		goto cleanup;
 	}
 
-	/* TODO: Check returned version */
 	if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
 	    vstor_packet->status != 0)
 		goto cleanup;
@@ -193,7 +192,6 @@ static int storvsc_channel_init(struct hv_device *device)
 		goto cleanup;
 	}
 
-	/* TODO: Check returned version */
 	if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
 	    vstor_packet->status != 0)
 		goto cleanup;
@@ -384,11 +382,12 @@ int storvsc_dev_add(struct hv_device *device,
 
 	/* Save the channel properties to our storvsc channel */
 
-	/* FIXME: */
 	/*
 	 * If we support more than 1 scsi channel, we need to set the
 	 * port number here to the scsi channel but how do we get the
-	 * scsi channel prior to the bus scan
+	 * scsi channel prior to the bus scan.
+	 *
+	 * The host does not support this.
 	 */
 
 	stor_device->port_number = device_info->port_number;
@@ -545,4 +544,3 @@ int storvsc_get_major_info(struct storvsc_device_info *device_info,
 
 	return -ENODEV;
 }
-
Signature · 1 line
1.7.4.1
#61 lore raw

PATCH 42/59 Staging: hv: storvsc: Cleanup returned error code in storvsc_host_reset()

In reply to K. Y. Srinivasan

Use standard Linux error codes.

---
 drivers/staging/hv/storvsc_drv.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/hv/storvsc_drv.c +1 -1
index 1e49879..c245698 100644
@@ -348,7 +348,7 @@ static int storvsc_host_reset(struct hv_device *device)
 
 	stor_device = get_stor_device(device);
 	if (!stor_device)
-		return -1;
+		return -ENODEV;
 
 	request = &stor_device->reset_request;
 	vstor_packet = &request->vstor_packet;
Signature · 1 line
1.7.4.1
#62 lore raw

PATCH 43/59 Staging: hv: storvsc: Cleanup error code returned in storvsc_probe()

In reply to K. Y. Srinivasan

Use standard Linux error codes.

---
 drivers/staging/hv/storvsc_drv.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/hv/storvsc_drv.c +2 -2
index c245698..956f010 100644
@@ -693,7 +693,7 @@ static int storvsc_probe(struct hv_device *device)
 	if (ret != 0) {
 		kmem_cache_destroy(host_dev->request_pool);
 		scsi_host_put(host);
-		return -1;
+		return -ENODEV;
 	}
 
 	host_dev->path = device_info.path_id;
@@ -714,7 +714,7 @@ static int storvsc_probe(struct hv_device *device)
 
 		kmem_cache_destroy(host_dev->request_pool);
 		scsi_host_put(host);
-		return -1;
+		return -ENODEV;
 	}
 
 	scsi_scan_host(host);
Signature · 1 line
1.7.4.1
#63 lore raw

PATCH 44/59 Staging: hv: storvsc: Cleanup returned error code in storvsc_drv_init()

In reply to K. Y. Srinivasan

Use standard Linux error codes.

---
 drivers/staging/hv/storvsc_drv.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/hv/storvsc_drv.c +1 -1
index 956f010..94f40fc 100644
@@ -750,7 +750,7 @@ static int __init storvsc_drv_init(void)
 
 	if (max_outstanding_req_per_channel <
 	    STORVSC_MAX_IO_REQUESTS)
-		return -1;
+		return -EINVAL;
 
 	drv->driver.name = driver_name;
 
Signature · 1 line
1.7.4.1
#64 lore raw

PATCH 45/59 Staging: hv: netvsc: Cleanup the returned error code in netvsc_probe()

In reply to K. Y. Srinivasan

Use standard Linux error codes.

---
 drivers/staging/hv/netvsc_drv.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/hv/netvsc_drv.c +1 -1
index 77f9236..e7c61d6 100644
@@ -340,7 +340,7 @@ static int netvsc_probe(struct hv_device *dev)
 
 	net = alloc_etherdev(sizeof(struct net_device_context));
 	if (!net)
-		return -1;
+		return -ENOMEM;
 
 	/* Set initial state */
 	netif_carrier_off(net);
Signature · 1 line
1.7.4.1
#65 lore raw

PATCH 46/59 Staging: hv: netvsc: Cleanup error return codes in netvsc_destroy_recv_buf()

In reply to K. Y. Srinivasan

Cleanup error return codes in netvsc_destroy_recv_buf().

---
 drivers/staging/hv/netvsc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/hv/netvsc.c +2 -2
index b89ac7e..baa0c8d 100644
@@ -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;
 	}
Signature · 1 line
1.7.4.1
#66 lore raw

PATCH 47/59 Staging: hv: netvsc: Cleanup error return values in netvsc_init_recv_buf()

In reply to K. Y. Srinivasan

Use standard Linux error codes.

---
 drivers/staging/hv/netvsc.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
drivers/staging/hv/netvsc.c +5 -5
index baa0c8d..5703fd7 100644
@@ -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;
 	}
 
Signature · 1 line
1.7.4.1
#67 lore raw

PATCH 48/59 Staging: hv: netvsc: Cleanup error returns in netvsc_connect_vsp()

In reply to K. Y. Srinivasan

Use standard Linux error codes.

---
 drivers/staging/hv/netvsc.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)
drivers/staging/hv/netvsc.c +4 -6
index 5703fd7..9cc126b 100644
@@ -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);
Signature · 1 line
1.7.4.1
#68 lore raw

PATCH 49/59 Staging: hv: netvsc: Cleanup error return values in netvsc_send()

In reply to K. Y. Srinivasan

Use standard Linux error codes.

---
 drivers/staging/hv/netvsc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/hv/netvsc.c +2 -2
index 9cc126b..f7f4957 100644
@@ -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;
Signature · 1 line
1.7.4.1
#69 lore raw

PATCH 50/59 Staging: hv: netvsc: Cleanup error return codes in netvsc_device_add()

In reply to K. Y. Srinivasan

Use standard Linux error codes.

---
 drivers/staging/hv/netvsc.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
drivers/staging/hv/netvsc.c +1 -3
index f7f4957..b6e1fb9 100644
@@ -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;
 	}
 
Signature · 1 line
1.7.4.1
#70 lore raw

PATCH 51/59 Staging: hv: netvsc: Cleanup error codes in rndis_filter_receive()

In reply to K. Y. Srinivasan

Use standard Linux error codes.

---
 drivers/staging/hv/rndis_filter.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/hv/rndis_filter.c +2 -2
index dbb5201..8e1ef00 100644
@@ -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(
Signature · 1 line
1.7.4.1
#71 lore raw

PATCH 52/59 Staging: hv: netvsc: Cleanup error code in rndis_filter_query_device()

In reply to K. Y. Srinivasan

Use standard Linux error codes.

---
 drivers/staging/hv/rndis_filter.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/hv/rndis_filter.c +1 -1
index 8e1ef00..f26886d 100644
@@ -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;
 	}
 
Signature · 1 line
1.7.4.1
#72 lore raw

PATCH 53/59 Staging: hv: netvsc: Cleanup error return values in rndis_filter_set_packet_filter()

In reply to K. Y. Srinivasan

Use standard Linux error codes and cleanup some error paths.

---
 drivers/staging/hv/rndis_filter.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)
drivers/staging/hv/rndis_filter.c +1 -4
index f26886d..f5f3052 100644
@@ -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;
 	}
Signature · 1 line
1.7.4.1
#73 lore raw

PATCH 54/59 Staging: hv: netvsc: Cleanup error returns in rndis_filter_init_device()

In reply to K. Y. Srinivasan

Use standard Linux error codes.

---
 drivers/staging/hv/rndis_filter.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/hv/rndis_filter.c +2 -2
index f5f3052..a71f29d 100644
@@ -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:
Signature · 1 line
1.7.4.1
#74 lore raw

PATCH 55/59 Staging: hv: netvsc: Cleanup error code in rndis_filter_device_add()

In reply to K. Y. Srinivasan

Use standard Linux error codes.

---
 drivers/staging/hv/rndis_filter.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/hv/rndis_filter.c +1 -1
index a71f29d..f0d1362 100644
@@ -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
Signature · 1 line
1.7.4.1
#75 lore raw

PATCH 56/59 Staging: hv: mouse: Change the jump label Cleanup to cleanup

In reply to K. Y. Srinivasan

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

---
 drivers/staging/hv/hv_mouse.c |   22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)
drivers/staging/hv/hv_mouse.c +11 -11
index 2e04948..cbb837b 100644
@@ -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;
 }
 
Signature · 1 line
1.7.4.1
#76 lore raw

PATCH 57/59 Staging: hv: mouse: Get rid of the unused PCI signature

In reply to K. Y. Srinivasan

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

---
 drivers/staging/hv/hv_mouse.c |   22 ----------------------
 1 files changed, 0 insertions(+), 22 deletions(-)
drivers/staging/hv/hv_mouse.c +0 -22
index cbb837b..a29a050 100644
@@ -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);
Signature · 1 line
1.7.4.1
#77 lore raw

PATCH 58/59 Staging: hv: netvsc: Change the jump label Cleanup to cleanup

In reply to K. Y. Srinivasan

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

---
 drivers/staging/hv/rndis_filter.c |   28 ++++++++++++++--------------
 1 files changed, 14 insertions(+), 14 deletions(-)
drivers/staging/hv/rndis_filter.c +14 -14
index f0d1362..79dfe78 100644
@@ -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;
Signature · 1 line
1.7.4.1
#78 lore raw

PATCH 59/59 Staging: hv: netvsc: Change the jump label Exit to exit

In reply to K. Y. Srinivasan

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

---
 drivers/staging/hv/rndis_filter.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/hv/rndis_filter.c +2 -2
index 79dfe78..6db48b9 100644
@@ -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;
 }
 
Signature · 1 line
1.7.4.1