aboutsummaryrefslogtreecommitdiffstats
diff options
-rw-r--r--f3.patch283
-rw-r--r--series11
-rw-r--r--staging/staging-hv-coding-style-cleanup-for-netvsc.c.patch1925
-rw-r--r--staging/staging-hv-coding-style-cleanup-for-rndisfilter.c.patch1269
-rw-r--r--staging/staging-hv-coding-style-cleanup-for-storvsc_drv.c.patch1567
-rw-r--r--staging/staging-hv-coding-style-cleanups-for-vmbus_drv.c.patch1440
-rw-r--r--staging/staging-hv-remove-function-pointer-typedefs-from-netvscapi.h.patch90
-rw-r--r--staging/staging-hv-remove-function-pointer-typedefs-from-storvscapi.h.patch59
-rw-r--r--staging/staging-hv-remove-function-pointer-typedefs-from-vmbus.h.patch117
-rw-r--r--staging/staging-hv-remove-function-pointer-typedefs-from-vmbusapi.h.patch205
-rw-r--r--staging/staging-hv-remove-pfn_channel_callback.patch70
-rw-r--r--staging/staging-hv-rename-struct-netvsc_device.patch301
12 files changed, 7053 insertions, 284 deletions
diff --git a/f3.patch b/f3.patch
deleted file mode 100644
index f7c6d7c77ff741..00000000000000
--- a/f3.patch
+++ /dev/null
@@ -1,283 +0,0 @@
----
- drivers/staging/hv/vmbus_drv.c | 139 +++++++++++------------------------------
- 1 file changed, 38 insertions(+), 101 deletions(-)
-
---- a/drivers/staging/hv/vmbus_drv.c
-+++ b/drivers/staging/hv/vmbus_drv.c
-@@ -1,5 +1,4 @@
- /*
-- *
- * Copyright (c) 2009, Microsoft Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
-@@ -18,10 +17,7 @@
- * Authors:
- * Haiyang Zhang <haiyangz@microsoft.com>
- * Hank Janssen <hjanssen@microsoft.com>
-- *
- */
--
--
- #include <linux/init.h>
- #include <linux/module.h>
- #include <linux/device.h>
-@@ -33,35 +29,27 @@
- #include "vmbus.h"
-
-
--/* Defines */
--
--
- /* FIXME! We need to do this dynamically for PIC and APIC system */
--#define VMBUS_IRQ 0x5
--#define VMBUS_IRQ_VECTOR IRQ5_VECTOR
--
--/* Data types */
--
-+#define VMBUS_IRQ 0x5
-+#define VMBUS_IRQ_VECTOR IRQ5_VECTOR
-
- /* Main vmbus driver data structure */
- struct vmbus_driver_context {
- /* !! These must be the first 2 fields !! */
-+ /* FIXME, this is a bug */
- /* The driver field is not used in here. Instead, the bus field is */
- /* used to represent the driver */
-- struct driver_context drv_ctx;
-+ struct driver_context drv_ctx;
- struct vmbus_driver drv_obj;
-
-- struct bus_type bus;
-- struct tasklet_struct msg_dpc;
-- struct tasklet_struct event_dpc;
-+ struct bus_type bus;
-+ struct tasklet_struct msg_dpc;
-+ struct tasklet_struct event_dpc;
-
- /* The bus root device */
-- struct device_context device_ctx;
-+ struct device_context device_ctx;
- };
-
--
--/* Static decl */
--
- static int vmbus_match(struct device *device, struct device_driver *driver);
- static int vmbus_probe(struct device *device);
- static int vmbus_remove(struct device *device);
-@@ -914,9 +902,8 @@ static int vmbus_remove(struct device *c
- return 0;
- }
-
--/*++
--
--Name: vmbus_shutdown()
-+/**
-+ * vmbus_shutdown
-
- Desc: Shutdown a vmbus device
-
-@@ -928,16 +915,17 @@ static void vmbus_shutdown(struct device
- DPRINT_ENTER(VMBUS_DRV);
-
- /* Special case root bus device */
-- if (child_device->parent == NULL)
-- {
-- /* No-op since it is statically defined and handle in vmbus_bus_exit() */
-+ if (child_device->parent == NULL) {
-+ /*
-+ * No-op since it is statically defined and handle in
-+ * vmbus_bus_exit()
-+ */
- DPRINT_EXIT(VMBUS_DRV);
- return;
- }
-
- /* The device may not be attached yet */
-- if (!child_device->driver)
-- {
-+ if (!child_device->driver) {
- DPRINT_EXIT(VMBUS_DRV);
- return;
- }
-@@ -955,13 +943,9 @@ static void vmbus_shutdown(struct device
- return;
- }
-
--/*++
--
--Name: vmbus_bus_release()
--
--Desc: Final callback release of the vmbus root device
--
----*/
-+/**
-+ * vmbus_bus_release - Final callback release of the vmbus root device
-+ */
- static void vmbus_bus_release(struct device *device)
- {
- DPRINT_ENTER(VMBUS_DRV);
-@@ -973,13 +957,9 @@ static void vmbus_bus_release(struct dev
- DPRINT_EXIT(VMBUS_DRV);
- }
-
--/*++
--
--Name: vmbus_device_release()
--
--Desc: Final callback release of the vmbus child device
--
----*/
-+/**
-+ * vmbus_device_release - Final callback release of the vmbus child device
-+ */
- static void vmbus_device_release(struct device *device)
- {
- struct device_context *device_ctx = device_to_device_context(device);
-@@ -990,19 +970,14 @@ static void vmbus_device_release(struct
- kfree(device_ctx);
-
- /* !!DO NOT REFERENCE device_ctx anymore at this point!! */
--
- DPRINT_EXIT(VMBUS_DRV);
-
- return;
- }
-
--/*++
--
--Name: vmbus_msg_dpc()
--
--Desc: Tasklet routine to handle hypervisor messages
--
----*/
-+/**
-+ * vmbus_msg_dpc - Tasklet routine to handle hypervisor messages
-+ */
- static void vmbus_msg_dpc(unsigned long data)
- {
- struct vmbus_driver *vmbus_drv_obj = (struct vmbus_driver *)data;
-@@ -1017,13 +992,9 @@ static void vmbus_msg_dpc(unsigned long
- DPRINT_EXIT(VMBUS_DRV);
- }
-
--/*++
--
--Name: vmbus_msg_dpc()
--
--Desc: Tasklet routine to handle hypervisor events
--
----*/
-+/**
-+ * vmbus_msg_dpc - Tasklet routine to handle hypervisor events
-+ */
- static void vmbus_event_dpc(unsigned long data)
- {
- struct vmbus_driver *vmbus_drv_obj = (struct vmbus_driver *)data;
-@@ -1038,17 +1009,10 @@ static void vmbus_event_dpc(unsigned lon
- DPRINT_EXIT(VMBUS_DRV);
- }
-
--/*++
--
--Name: vmbus_msg_dpc()
--
--Desc: ISR routine
--
----*/
--static irqreturn_t vmbus_isr(int irq, void* dev_id)
-+static irqreturn_t vmbus_isr(int irq, void *dev_id)
- {
-- int ret=0;
- struct vmbus_driver *vmbus_driver_obj = &g_vmbus_drv.drv_obj;
-+ int ret;
-
- DPRINT_ENTER(VMBUS_DRV);
-
-@@ -1058,48 +1022,31 @@ static irqreturn_t vmbus_isr(int irq, vo
- ret = vmbus_driver_obj->OnIsr(&vmbus_driver_obj->Base);
-
- /* Schedules a dpc if necessary */
-- if (ret > 0)
-- {
-- if (test_bit(0, (unsigned long*)&ret))
-- {
-+ if (ret > 0) {
-+ if (test_bit(0, (unsigned long *)&ret))
- tasklet_schedule(&g_vmbus_drv.msg_dpc);
-- }
-
-- if (test_bit(1, (unsigned long*)&ret))
-- {
-+ if (test_bit(1, (unsigned long *)&ret))
- tasklet_schedule(&g_vmbus_drv.event_dpc);
-- }
-
- DPRINT_EXIT(VMBUS_DRV);
- return IRQ_HANDLED;
-- }
-- else
-- {
-+ } else {
- DPRINT_EXIT(VMBUS_DRV);
- return IRQ_NONE;
- }
- }
-
--MODULE_LICENSE("GPL");
--
--
--/*++
--
--Name: vmbus_init()
--
--Desc: Main vmbus driver entry routine
--
----*/
- static int __init vmbus_init(void)
- {
-- int ret=0;
-+ int ret = 0;
-
- DPRINT_ENTER(VMBUS_DRV);
-
- DPRINT_INFO(VMBUS_DRV,
- "Vmbus initializing.... current log level 0x%x (%x,%x)",
- vmbus_loglevel, HIWORD(vmbus_loglevel), LOWORD(vmbus_loglevel));
--/* Todo: it is used for loglevel, to be ported to new kernel. */
-+ /* Todo: it is used for loglevel, to be ported to new kernel. */
-
- ret = vmbus_bus_init(VmbusInitialize);
-
-@@ -1107,29 +1054,19 @@ static int __init vmbus_init(void)
- return ret;
- }
-
--
--
--/*++
--
--Name: vmbus_init()
--
--Desc: Main vmbus driver exit routine
--
----*/
- static void __exit vmbus_exit(void)
- {
- DPRINT_ENTER(VMBUS_DRV);
-
- vmbus_bus_exit();
--/* Todo: it is used for loglevel, to be ported to new kernel. */
-+ /* Todo: it is used for loglevel, to be ported to new kernel. */
- DPRINT_EXIT(VMBUS_DRV);
--
- return;
- }
-
-+MODULE_LICENSE("GPL");
- module_param(vmbus_irq, int, S_IRUGO);
- module_param(vmbus_loglevel, int, S_IRUGO);
-
- module_init(vmbus_init);
- module_exit(vmbus_exit);
--/* eof */
diff --git a/series b/series
index ecdf08c28f78a5..f9a3769498ddd1 100644
--- a/series
+++ b/series
@@ -604,6 +604,16 @@ staging/staging-hv-reorg-storvsc.c.patch
staging/staging-hv-coding-style-fixes-for-blkvsc_drv.c.patch
staging/staging-hv-coding-style-cleanup-for-channel.c.patch
staging/staging-hv-warn-the-world-of-a-bug-in-the-release-function.patch
+staging/staging-hv-coding-style-cleanups-for-vmbus_drv.c.patch
+staging/staging-hv-coding-style-cleanup-for-storvsc_drv.c.patch
+staging/staging-hv-coding-style-cleanup-for-rndisfilter.c.patch
+staging/staging-hv-coding-style-cleanup-for-netvsc.c.patch
+staging/staging-hv-rename-struct-netvsc_device.patch
+staging/staging-hv-remove-function-pointer-typedefs-from-vmbusapi.h.patch
+staging/staging-hv-remove-function-pointer-typedefs-from-netvscapi.h.patch
+staging/staging-hv-remove-function-pointer-typedefs-from-storvscapi.h.patch
+staging/staging-hv-remove-pfn_channel_callback.patch
+staging/staging-hv-remove-function-pointer-typedefs-from-vmbus.h.patch
staging/staging-htc-dream-limit-kconfig-for-only-msm-platforms.patch
staging/staging-htc-dream-touchscreen-driver-for-staging.patch
@@ -897,4 +907,3 @@ led_classdev.sysfs-name.patch
#tty.work/serial-f81216-helper
-f3.patch
diff --git a/staging/staging-hv-coding-style-cleanup-for-netvsc.c.patch b/staging/staging-hv-coding-style-cleanup-for-netvsc.c.patch
new file mode 100644
index 00000000000000..66f5f15ffc7b36
--- /dev/null
+++ b/staging/staging-hv-coding-style-cleanup-for-netvsc.c.patch
@@ -0,0 +1,1925 @@
+From foo@baz Wed Sep 2 10:33:05 PDT 2009
+Date: Wed, 02 Sep 2009 10:33:05 -0700
+To: Greg KH <greg@kroah.com>
+From: Greg Kroah-Hartman <gregkh@suse.de>
+Subject: Staging: hv: coding style cleanup for NetVsc.c
+
+Still a lot of long lines, but that's nothing I can fix up at this time
+
+Cc: Hank Janssen <hjanssen@microsoft.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+---
+ drivers/staging/hv/NetVsc.c | 1188 +++++++++++++++++++-------------------------
+ 1 file changed, 536 insertions(+), 652 deletions(-)
+
+--- a/drivers/staging/hv/NetVsc.c
++++ b/drivers/staging/hv/NetVsc.c
+@@ -1,5 +1,4 @@
+ /*
+- *
+ * Copyright (c) 2009, Microsoft Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+@@ -17,13 +16,11 @@
+ *
+ * Authors:
+ * Hank Janssen <hjanssen@microsoft.com>
+- *
+ */
+-
+ #include <linux/kernel.h>
+ #include <linux/mm.h>
+ #include <linux/delay.h>
+-#include <asm/io.h>
++#include <linux/io.h>
+ #include "osd.h"
+ #include "logging.h"
+ #include "NetVsc.h"
+@@ -31,7 +28,7 @@
+
+
+ /* Globals */
+-static const char* gDriverName="netvsc";
++static const char *gDriverName = "netvsc";
+
+ /* {F8615163-DF3E-46c5-913F-F2D2F965ED0E} */
+ static const struct hv_guid gNetVscDeviceType = {
+@@ -41,84 +38,40 @@ static const struct hv_guid gNetVscDevic
+ }
+ };
+
++static int NetVscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo);
++
++static int NetVscOnDeviceRemove(struct hv_device *Device);
++
++static void NetVscOnCleanup(struct hv_driver *Driver);
++
++static void NetVscOnChannelCallback(void *context);
++
++static int NetVscInitializeSendBufferWithNetVsp(struct hv_device *Device);
++
++static int NetVscInitializeReceiveBufferWithNetVsp(struct hv_device *Device);
++
++static int NetVscDestroySendBuffer(struct NETVSC_DEVICE *NetDevice);
+
+-/* Internal routines */
+-static int
+-NetVscOnDeviceAdd(
+- struct hv_device *Device,
+- void *AdditionalInfo
+- );
+-
+-static int
+-NetVscOnDeviceRemove(
+- struct hv_device *Device
+- );
+-
+-static void
+-NetVscOnCleanup(
+- struct hv_driver *Driver
+- );
+-
+-static void
+-NetVscOnChannelCallback(
+- void * context
+- );
+-
+-static int
+-NetVscInitializeSendBufferWithNetVsp(
+- struct hv_device *Device
+- );
+-
+-static int
+-NetVscInitializeReceiveBufferWithNetVsp(
+- struct hv_device *Device
+- );
+-
+-static int
+-NetVscDestroySendBuffer(
+- struct NETVSC_DEVICE *NetDevice
+- );
+-
+-static int
+-NetVscDestroyReceiveBuffer(
+- struct NETVSC_DEVICE *NetDevice
+- );
+-
+-static int
+-NetVscConnectToVsp(
+- struct hv_device *Device
+- );
+-
+-static void
+-NetVscOnSendCompletion(
+- struct hv_device *Device,
+- struct vmpacket_descriptor *Packet
+- );
+-
+-static int
+-NetVscOnSend(
+- struct hv_device *Device,
+- struct hv_netvsc_packet *Packet
+- );
+-
+-static void
+-NetVscOnReceive(
+- struct hv_device *Device,
+- struct vmpacket_descriptor *Packet
+- );
+-
+-static void
+-NetVscOnReceiveCompletion(
+- void * Context
+- );
+-
+-static void
+-NetVscSendReceiveCompletion(
+- struct hv_device *Device,
+- u64 TransactionId
+- );
++static int NetVscDestroyReceiveBuffer(struct NETVSC_DEVICE *NetDevice);
+
+-static inline struct NETVSC_DEVICE *AllocNetDevice(struct hv_device *Device)
++static int NetVscConnectToVsp(struct hv_device *Device);
++
++static void NetVscOnSendCompletion(struct hv_device *Device,
++ struct vmpacket_descriptor *Packet);
++
++static int NetVscOnSend(struct hv_device *Device,
++ struct hv_netvsc_packet *Packet);
++
++static void NetVscOnReceive(struct hv_device *Device,
++ struct vmpacket_descriptor *Packet);
++
++static void NetVscOnReceiveCompletion(void *Context);
++
++static void NetVscSendReceiveCompletion(struct hv_device *Device,
++ u64 TransactionId);
++
++
++static struct NETVSC_DEVICE *AllocNetDevice(struct hv_device *Device)
+ {
+ struct NETVSC_DEVICE *netDevice;
+
+@@ -135,7 +88,7 @@ static inline struct NETVSC_DEVICE *Allo
+ return netDevice;
+ }
+
+-static inline void FreeNetDevice(struct NETVSC_DEVICE *Device)
++static void FreeNetDevice(struct NETVSC_DEVICE *Device)
+ {
+ ASSERT(atomic_read(&Device->RefCount) == 0);
+ Device->Device->Extension = NULL;
+@@ -144,11 +97,11 @@ static inline void FreeNetDevice(struct
+
+
+ /* Get the net device object iff exists and its refcount > 1 */
+-static inline struct NETVSC_DEVICE *GetOutboundNetDevice(struct hv_device *Device)
++static struct NETVSC_DEVICE *GetOutboundNetDevice(struct hv_device *Device)
+ {
+ struct NETVSC_DEVICE *netDevice;
+
+- netDevice = (struct NETVSC_DEVICE*)Device->Extension;
++ netDevice = Device->Extension;
+ if (netDevice && atomic_read(&netDevice->RefCount) > 1)
+ atomic_inc(&netDevice->RefCount);
+ else
+@@ -158,11 +111,11 @@ static inline struct NETVSC_DEVICE *GetO
+ }
+
+ /* Get the net device object iff exists and its refcount > 0 */
+-static inline struct NETVSC_DEVICE *GetInboundNetDevice(struct hv_device *Device)
++static struct NETVSC_DEVICE *GetInboundNetDevice(struct hv_device *Device)
+ {
+ struct NETVSC_DEVICE *netDevice;
+
+- netDevice = (struct NETVSC_DEVICE*)Device->Extension;
++ netDevice = Device->Extension;
+ if (netDevice && atomic_read(&netDevice->RefCount))
+ atomic_inc(&netDevice->RefCount);
+ else
+@@ -171,73 +124,62 @@ static inline struct NETVSC_DEVICE *GetI
+ return netDevice;
+ }
+
+-static inline void PutNetDevice(struct hv_device *Device)
++static void PutNetDevice(struct hv_device *Device)
+ {
+ struct NETVSC_DEVICE *netDevice;
+
+- netDevice = (struct NETVSC_DEVICE*)Device->Extension;
++ netDevice = Device->Extension;
+ ASSERT(netDevice);
+
+ atomic_dec(&netDevice->RefCount);
+ }
+
+-static inline struct NETVSC_DEVICE *ReleaseOutboundNetDevice(struct hv_device *Device)
++static struct NETVSC_DEVICE *ReleaseOutboundNetDevice(struct hv_device *Device)
+ {
+ struct NETVSC_DEVICE *netDevice;
+
+- netDevice = (struct NETVSC_DEVICE*)Device->Extension;
++ netDevice = Device->Extension;
+ if (netDevice == NULL)
+ return NULL;
+
+ /* Busy wait until the ref drop to 2, then set it to 1 */
+ while (atomic_cmpxchg(&netDevice->RefCount, 2, 1) != 2)
+- {
+ udelay(100);
+- }
+
+ return netDevice;
+ }
+
+-static inline struct NETVSC_DEVICE *ReleaseInboundNetDevice(struct hv_device *Device)
++static struct NETVSC_DEVICE *ReleaseInboundNetDevice(struct hv_device *Device)
+ {
+ struct NETVSC_DEVICE *netDevice;
+
+- netDevice = (struct NETVSC_DEVICE*)Device->Extension;
++ netDevice = Device->Extension;
+ if (netDevice == NULL)
+ return NULL;
+
+ /* Busy wait until the ref drop to 1, then set it to 0 */
+ while (atomic_cmpxchg(&netDevice->RefCount, 1, 0) != 1)
+- {
+ udelay(100);
+- }
+
+ Device->Extension = NULL;
+ return netDevice;
+ }
+
+-/*++;
+-
+-
+-Name:
+- NetVscInitialize()
+-
+-Description:
+- Main entry point
+-
+---*/
+-int
+-NetVscInitialize(
+- struct hv_driver *drv
+- )
++/**
++ * NetVscInitialize - Main entry point
++ */
++int NetVscInitialize(struct hv_driver *drv)
+ {
+ struct netvsc_driver *driver = (struct netvsc_driver *)drv;
+- int ret=0;
+
+ DPRINT_ENTER(NETVSC);
+
+- DPRINT_DBG(NETVSC, "sizeof(struct hv_netvsc_packet)=%zd, sizeof(struct nvsp_message)=%zd, sizeof(struct vmtransfer_page_packet_header)=%zd",
+- sizeof(struct hv_netvsc_packet), sizeof(struct nvsp_message), sizeof(struct vmtransfer_page_packet_header));
++ DPRINT_DBG(NETVSC, "sizeof(struct hv_netvsc_packet)=%zd, "
++ "sizeof(struct nvsp_message)=%zd, "
++ "sizeof(struct vmtransfer_page_packet_header)=%zd",
++ sizeof(struct hv_netvsc_packet),
++ sizeof(struct nvsp_message),
++ sizeof(struct vmtransfer_page_packet_header));
+
+ /* Make sure we are at least 2 pages since 1 page is used for control */
+ ASSERT(driver->RingBufferSize >= (PAGE_SIZE << 1));
+@@ -250,48 +192,50 @@ NetVscInitialize(
+ ASSERT(driver->OnLinkStatusChanged);
+
+ /* Setup the dispatch table */
+- driver->Base.OnDeviceAdd = NetVscOnDeviceAdd;
+- driver->Base.OnDeviceRemove = NetVscOnDeviceRemove;
+- driver->Base.OnCleanup = NetVscOnCleanup;
++ driver->Base.OnDeviceAdd = NetVscOnDeviceAdd;
++ driver->Base.OnDeviceRemove = NetVscOnDeviceRemove;
++ driver->Base.OnCleanup = NetVscOnCleanup;
+
+- driver->OnSend = NetVscOnSend;
++ driver->OnSend = NetVscOnSend;
+
+ RndisFilterInit(driver);
+
+ DPRINT_EXIT(NETVSC);
+
+- return ret;
++ return 0;
+ }
+
+-static int
+-NetVscInitializeReceiveBufferWithNetVsp(
+- struct hv_device *Device
+- )
++static int NetVscInitializeReceiveBufferWithNetVsp(struct hv_device *Device)
+ {
+- int ret=0;
++ int ret = 0;
+ struct NETVSC_DEVICE *netDevice;
+ struct nvsp_message *initPacket;
+
+ DPRINT_ENTER(NETVSC);
+
+ netDevice = GetOutboundNetDevice(Device);
+- if (!netDevice)
+- {
+- DPRINT_ERR(NETVSC, "unable to get net device...device being destroyed?");
++ if (!netDevice) {
++ DPRINT_ERR(NETVSC, "unable to get net device..."
++ "device being destroyed?");
+ DPRINT_EXIT(NETVSC);
+ return -1;
+ }
+ ASSERT(netDevice->ReceiveBufferSize > 0);
+- ASSERT((netDevice->ReceiveBufferSize & (PAGE_SIZE-1)) == 0); /* page-size grandularity */
++ /* page-size grandularity */
++ ASSERT((netDevice->ReceiveBufferSize & (PAGE_SIZE - 1)) == 0);
+
+- netDevice->ReceiveBuffer = osd_PageAlloc(netDevice->ReceiveBufferSize >> PAGE_SHIFT);
+- if (!netDevice->ReceiveBuffer)
+- {
+- DPRINT_ERR(NETVSC, "unable to allocate receive buffer of size %d", netDevice->ReceiveBufferSize);
++ netDevice->ReceiveBuffer =
++ osd_PageAlloc(netDevice->ReceiveBufferSize >> PAGE_SHIFT);
++ if (!netDevice->ReceiveBuffer) {
++ DPRINT_ERR(NETVSC,
++ "unable to allocate receive buffer of size %d",
++ netDevice->ReceiveBufferSize);
+ ret = -1;
+ goto Cleanup;
+ }
+- ASSERT(((unsigned long)netDevice->ReceiveBuffer & (PAGE_SIZE-1)) == 0); /* page-aligned buffer */
++ /* page-aligned buffer */
++ ASSERT(((unsigned long)netDevice->ReceiveBuffer & (PAGE_SIZE - 1)) ==
++ 0);
+
+ DPRINT_INFO(NETVSC, "Establishing receive buffer's GPADL...");
+
+@@ -301,13 +245,12 @@ NetVscInitializeReceiveBufferWithNetVsp(
+ * than the channel to establish the gpadl handle.
+ */
+ ret = Device->Driver->VmbusChannelInterface.EstablishGpadl(Device,
+- netDevice->ReceiveBuffer,
+- netDevice->ReceiveBufferSize,
+- &netDevice->ReceiveBufferGpadlHandle);
+-
+- if (ret != 0)
+- {
+- DPRINT_ERR(NETVSC, "unable to establish receive buffer's gpadl");
++ netDevice->ReceiveBuffer,
++ netDevice->ReceiveBufferSize,
++ &netDevice->ReceiveBufferGpadlHandle);
++ if (ret != 0) {
++ DPRINT_ERR(NETVSC,
++ "unable to establish receive buffer's gpadl");
+ goto Cleanup;
+ }
+
+@@ -320,31 +263,30 @@ NetVscInitializeReceiveBufferWithNetVsp(
+
+ memset(initPacket, 0, sizeof(struct nvsp_message));
+
+- initPacket->Header.MessageType = NvspMessage1TypeSendReceiveBuffer;
+- initPacket->Messages.Version1Messages.SendReceiveBuffer.GpadlHandle = netDevice->ReceiveBufferGpadlHandle;
+- initPacket->Messages.Version1Messages.SendReceiveBuffer.Id = NETVSC_RECEIVE_BUFFER_ID;
++ initPacket->Header.MessageType = NvspMessage1TypeSendReceiveBuffer;
++ initPacket->Messages.Version1Messages.SendReceiveBuffer.GpadlHandle = netDevice->ReceiveBufferGpadlHandle;
++ initPacket->Messages.Version1Messages.SendReceiveBuffer.Id = NETVSC_RECEIVE_BUFFER_ID;
+
+ /* Send the gpadl notification request */
+ ret = Device->Driver->VmbusChannelInterface.SendPacket(Device,
+- initPacket,
+- sizeof(struct nvsp_message),
+- (unsigned long)initPacket,
+- VmbusPacketTypeDataInBand,
+- VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
+- if (ret != 0)
+- {
+- DPRINT_ERR(NETVSC, "unable to send receive buffer's gpadl to netvsp");
++ initPacket,
++ sizeof(struct nvsp_message),
++ (unsigned long)initPacket,
++ VmbusPacketTypeDataInBand,
++ VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
++ if (ret != 0) {
++ DPRINT_ERR(NETVSC,
++ "unable to send receive buffer's gpadl to netvsp");
+ goto Cleanup;
+ }
+
+ osd_WaitEventWait(netDevice->ChannelInitEvent);
+
+ /* Check the response */
+- if (initPacket->Messages.Version1Messages.SendReceiveBufferComplete.Status != NvspStatusSuccess)
+- {
+- DPRINT_ERR(NETVSC,
+- "Unable to complete receive buffer initialzation with NetVsp - status %d",
+- initPacket->Messages.Version1Messages.SendReceiveBufferComplete.Status);
++ if (initPacket->Messages.Version1Messages.SendReceiveBufferComplete.Status != NvspStatusSuccess) {
++ DPRINT_ERR(NETVSC, "Unable to complete receive buffer "
++ "initialzation with NetVsp - status %d",
++ initPacket->Messages.Version1Messages.SendReceiveBufferComplete.Status);
+ ret = -1;
+ goto Cleanup;
+ }
+@@ -356,8 +298,7 @@ NetVscInitializeReceiveBufferWithNetVsp(
+ netDevice->ReceiveSectionCount = initPacket->Messages.Version1Messages.SendReceiveBufferComplete.NumSections;
+
+ netDevice->ReceiveSections = kmalloc(netDevice->ReceiveSectionCount * sizeof(struct nvsp_1_receive_buffer_section), GFP_KERNEL);
+- if (netDevice->ReceiveSections == NULL)
+- {
++ if (netDevice->ReceiveSections == NULL) {
+ ret = -1;
+ goto Cleanup;
+ }
+@@ -366,16 +307,20 @@ NetVscInitializeReceiveBufferWithNetVsp(
+ initPacket->Messages.Version1Messages.SendReceiveBufferComplete.Sections,
+ netDevice->ReceiveSectionCount * sizeof(struct nvsp_1_receive_buffer_section));
+
+- DPRINT_INFO(NETVSC,
+- "Receive sections info (count %d, offset %d, endoffset %d, suballoc size %d, num suballocs %d)",
+- netDevice->ReceiveSectionCount, netDevice->ReceiveSections[0].Offset, netDevice->ReceiveSections[0].EndOffset,
+- netDevice->ReceiveSections[0].SubAllocationSize, netDevice->ReceiveSections[0].NumSubAllocations);
+-
++ DPRINT_INFO(NETVSC, "Receive sections info (count %d, offset %d, "
++ "endoffset %d, suballoc size %d, num suballocs %d)",
++ netDevice->ReceiveSectionCount,
++ netDevice->ReceiveSections[0].Offset,
++ netDevice->ReceiveSections[0].EndOffset,
++ netDevice->ReceiveSections[0].SubAllocationSize,
++ netDevice->ReceiveSections[0].NumSubAllocations);
+
+- /* For 1st release, there should only be 1 section that represents the entire receive buffer */
++ /*
++ * For 1st release, there should only be 1 section that represents the
++ * entire receive buffer
++ */
+ if (netDevice->ReceiveSectionCount != 1 ||
+- netDevice->ReceiveSections->Offset != 0 )
+- {
++ netDevice->ReceiveSections->Offset != 0) {
+ ret = -1;
+ goto Cleanup;
+ }
+@@ -391,36 +336,35 @@ Exit:
+ return ret;
+ }
+
+-
+-static int
+-NetVscInitializeSendBufferWithNetVsp(
+- struct hv_device *Device
+- )
++static int NetVscInitializeSendBufferWithNetVsp(struct hv_device *Device)
+ {
+- int ret=0;
++ int ret = 0;
+ struct NETVSC_DEVICE *netDevice;
+ struct nvsp_message *initPacket;
+
+ DPRINT_ENTER(NETVSC);
+
+ netDevice = GetOutboundNetDevice(Device);
+- if (!netDevice)
+- {
+- DPRINT_ERR(NETVSC, "unable to get net device...device being destroyed?");
++ if (!netDevice) {
++ DPRINT_ERR(NETVSC, "unable to get net device..."
++ "device being destroyed?");
+ DPRINT_EXIT(NETVSC);
+ return -1;
+ }
+ ASSERT(netDevice->SendBufferSize > 0);
+- ASSERT((netDevice->SendBufferSize & (PAGE_SIZE-1)) == 0); /* page-size grandularity */
++ /* page-size grandularity */
++ ASSERT((netDevice->SendBufferSize & (PAGE_SIZE - 1)) == 0);
+
+- netDevice->SendBuffer = osd_PageAlloc(netDevice->SendBufferSize >> PAGE_SHIFT);
+- if (!netDevice->SendBuffer)
+- {
+- DPRINT_ERR(NETVSC, "unable to allocate send buffer of size %d", netDevice->SendBufferSize);
++ netDevice->SendBuffer =
++ osd_PageAlloc(netDevice->SendBufferSize >> PAGE_SHIFT);
++ if (!netDevice->SendBuffer) {
++ DPRINT_ERR(NETVSC, "unable to allocate send buffer of size %d",
++ netDevice->SendBufferSize);
+ ret = -1;
+ goto Cleanup;
+ }
+- ASSERT(((unsigned long)netDevice->SendBuffer & (PAGE_SIZE-1)) == 0); /* page-aligned buffer */
++ /* page-aligned buffer */
++ ASSERT(((unsigned long)netDevice->SendBuffer & (PAGE_SIZE - 1)) == 0);
+
+ DPRINT_INFO(NETVSC, "Establishing send buffer's GPADL...");
+
+@@ -430,12 +374,10 @@ NetVscInitializeSendBufferWithNetVsp(
+ * than the channel to establish the gpadl handle.
+ */
+ ret = Device->Driver->VmbusChannelInterface.EstablishGpadl(Device,
+- netDevice->SendBuffer,
+- netDevice->SendBufferSize,
+- &netDevice->SendBufferGpadlHandle);
+-
+- if (ret != 0)
+- {
++ netDevice->SendBuffer,
++ netDevice->SendBufferSize,
++ &netDevice->SendBufferGpadlHandle);
++ if (ret != 0) {
+ DPRINT_ERR(NETVSC, "unable to establish send buffer's gpadl");
+ goto Cleanup;
+ }
+@@ -449,31 +391,29 @@ NetVscInitializeSendBufferWithNetVsp(
+
+ memset(initPacket, 0, sizeof(struct nvsp_message));
+
+- initPacket->Header.MessageType = NvspMessage1TypeSendSendBuffer;
+- initPacket->Messages.Version1Messages.SendReceiveBuffer.GpadlHandle = netDevice->SendBufferGpadlHandle;
+- initPacket->Messages.Version1Messages.SendReceiveBuffer.Id = NETVSC_SEND_BUFFER_ID;
++ initPacket->Header.MessageType = NvspMessage1TypeSendSendBuffer;
++ initPacket->Messages.Version1Messages.SendReceiveBuffer.GpadlHandle = netDevice->SendBufferGpadlHandle;
++ initPacket->Messages.Version1Messages.SendReceiveBuffer.Id = NETVSC_SEND_BUFFER_ID;
+
+ /* Send the gpadl notification request */
+ ret = Device->Driver->VmbusChannelInterface.SendPacket(Device,
+- initPacket,
+- sizeof(struct nvsp_message),
+- (unsigned long)initPacket,
+- VmbusPacketTypeDataInBand,
+- VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
+- if (ret != 0)
+- {
+- DPRINT_ERR(NETVSC, "unable to send receive buffer's gpadl to netvsp");
++ initPacket, sizeof(struct nvsp_message),
++ (unsigned long)initPacket,
++ VmbusPacketTypeDataInBand,
++ VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
++ if (ret != 0) {
++ DPRINT_ERR(NETVSC,
++ "unable to send receive buffer's gpadl to netvsp");
+ goto Cleanup;
+ }
+
+ osd_WaitEventWait(netDevice->ChannelInitEvent);
+
+ /* Check the response */
+- if (initPacket->Messages.Version1Messages.SendSendBufferComplete.Status != NvspStatusSuccess)
+- {
+- DPRINT_ERR(NETVSC,
+- "Unable to complete send buffer initialzation with NetVsp - status %d",
+- initPacket->Messages.Version1Messages.SendSendBufferComplete.Status);
++ if (initPacket->Messages.Version1Messages.SendSendBufferComplete.Status != NvspStatusSuccess) {
++ DPRINT_ERR(NETVSC, "Unable to complete send buffer "
++ "initialzation with NetVsp - status %d",
++ initPacket->Messages.Version1Messages.SendSendBufferComplete.Status);
+ ret = -1;
+ goto Cleanup;
+ }
+@@ -491,14 +431,10 @@ Exit:
+ return ret;
+ }
+
+-static int
+-NetVscDestroyReceiveBuffer(
+- struct NETVSC_DEVICE *NetDevice
+- )
++static int NetVscDestroyReceiveBuffer(struct NETVSC_DEVICE *NetDevice)
+ {
+ struct nvsp_message *revokePacket;
+- int ret=0;
+-
++ int ret = 0;
+
+ DPRINT_ENTER(NETVSC);
+
+@@ -508,9 +444,9 @@ NetVscDestroyReceiveBuffer(
+ * NvspMessage1TypeSendReceiveBuffer msg) therefore, we need
+ * to send a revoke msg here
+ */
+- if (NetDevice->ReceiveSectionCount)
+- {
+- DPRINT_INFO(NETVSC, "Sending NvspMessage1TypeRevokeReceiveBuffer...");
++ if (NetDevice->ReceiveSectionCount) {
++ DPRINT_INFO(NETVSC,
++ "Sending NvspMessage1TypeRevokeReceiveBuffer...");
+
+ /* Send the revoke receive buffer */
+ revokePacket = &NetDevice->RevokePacket;
+@@ -519,56 +455,55 @@ NetVscDestroyReceiveBuffer(
+ revokePacket->Header.MessageType = NvspMessage1TypeRevokeReceiveBuffer;
+ revokePacket->Messages.Version1Messages.RevokeReceiveBuffer.Id = NETVSC_RECEIVE_BUFFER_ID;
+
+- ret = NetDevice->Device->Driver->VmbusChannelInterface.SendPacket(NetDevice->Device,
+- revokePacket,
+- sizeof(struct nvsp_message),
+- (unsigned long)revokePacket,
+- VmbusPacketTypeDataInBand,
+- 0);
++ ret = NetDevice->Device->Driver->VmbusChannelInterface.SendPacket(
++ NetDevice->Device,
++ revokePacket,
++ sizeof(struct nvsp_message),
++ (unsigned long)revokePacket,
++ VmbusPacketTypeDataInBand, 0);
+ /*
+ * If we failed here, we might as well return and
+ * have a leak rather than continue and a bugchk
+ */
+- if (ret != 0)
+- {
+- DPRINT_ERR(NETVSC, "unable to send revoke receive buffer to netvsp");
++ if (ret != 0) {
++ DPRINT_ERR(NETVSC, "unable to send revoke receive "
++ "buffer to netvsp");
+ DPRINT_EXIT(NETVSC);
+ return -1;
+ }
+ }
+
+ /* Teardown the gpadl on the vsp end */
+- if (NetDevice->ReceiveBufferGpadlHandle)
+- {
++ if (NetDevice->ReceiveBufferGpadlHandle) {
+ DPRINT_INFO(NETVSC, "Tearing down receive buffer's GPADL...");
+
+- ret = NetDevice->Device->Driver->VmbusChannelInterface.TeardownGpadl(NetDevice->Device,
+- NetDevice->ReceiveBufferGpadlHandle);
++ ret = NetDevice->Device->Driver->VmbusChannelInterface.TeardownGpadl(
++ NetDevice->Device,
++ NetDevice->ReceiveBufferGpadlHandle);
+
+ /* If we failed here, we might as well return and have a leak rather than continue and a bugchk */
+- if (ret != 0)
+- {
+- DPRINT_ERR(NETVSC, "unable to teardown receive buffer's gpadl");
++ if (ret != 0) {
++ DPRINT_ERR(NETVSC,
++ "unable to teardown receive buffer's gpadl");
+ DPRINT_EXIT(NETVSC);
+ return -1;
+ }
+ NetDevice->ReceiveBufferGpadlHandle = 0;
+ }
+
+- if (NetDevice->ReceiveBuffer)
+- {
++ if (NetDevice->ReceiveBuffer) {
+ DPRINT_INFO(NETVSC, "Freeing up receive buffer...");
+
+ /* Free up the receive buffer */
+- osd_PageFree(NetDevice->ReceiveBuffer, NetDevice->ReceiveBufferSize >> PAGE_SHIFT);
++ osd_PageFree(NetDevice->ReceiveBuffer,
++ NetDevice->ReceiveBufferSize >> PAGE_SHIFT);
+ NetDevice->ReceiveBuffer = NULL;
+ }
+
+- if (NetDevice->ReceiveSections)
+- {
++ if (NetDevice->ReceiveSections) {
++ NetDevice->ReceiveSectionCount = 0;
+ kfree(NetDevice->ReceiveSections);
+ NetDevice->ReceiveSections = NULL;
+- NetDevice->ReceiveSectionCount = 0;
+ }
+
+ DPRINT_EXIT(NETVSC);
+@@ -576,17 +511,10 @@ NetVscDestroyReceiveBuffer(
+ return ret;
+ }
+
+-
+-
+-
+-static int
+-NetVscDestroySendBuffer(
+- struct NETVSC_DEVICE *NetDevice
+- )
++static int NetVscDestroySendBuffer(struct NETVSC_DEVICE *NetDevice)
+ {
+ struct nvsp_message *revokePacket;
+- int ret=0;
+-
++ int ret = 0;
+
+ DPRINT_ENTER(NETVSC);
+
+@@ -596,9 +524,9 @@ NetVscDestroySendBuffer(
+ * NvspMessage1TypeSendReceiveBuffer msg) therefore, we need
+ * to send a revoke msg here
+ */
+- if (NetDevice->SendSectionSize)
+- {
+- DPRINT_INFO(NETVSC, "Sending NvspMessage1TypeRevokeSendBuffer...");
++ if (NetDevice->SendSectionSize) {
++ DPRINT_INFO(NETVSC,
++ "Sending NvspMessage1TypeRevokeSendBuffer...");
+
+ /* Send the revoke send buffer */
+ revokePacket = &NetDevice->RevokePacket;
+@@ -608,44 +536,47 @@ NetVscDestroySendBuffer(
+ revokePacket->Messages.Version1Messages.RevokeSendBuffer.Id = NETVSC_SEND_BUFFER_ID;
+
+ ret = NetDevice->Device->Driver->VmbusChannelInterface.SendPacket(NetDevice->Device,
+- revokePacket,
+- sizeof(struct nvsp_message),
+- (unsigned long)revokePacket,
+- VmbusPacketTypeDataInBand,
+- 0);
+- /* If we failed here, we might as well return and have a leak rather than continue and a bugchk */
+- if (ret != 0)
+- {
+- DPRINT_ERR(NETVSC, "unable to send revoke send buffer to netvsp");
++ revokePacket,
++ sizeof(struct nvsp_message),
++ (unsigned long)revokePacket,
++ VmbusPacketTypeDataInBand, 0);
++ /*
++ * If we failed here, we might as well return and have a leak
++ * rather than continue and a bugchk
++ */
++ if (ret != 0) {
++ DPRINT_ERR(NETVSC, "unable to send revoke send buffer "
++ "to netvsp");
+ DPRINT_EXIT(NETVSC);
+ return -1;
+ }
+ }
+
+ /* Teardown the gpadl on the vsp end */
+- if (NetDevice->SendBufferGpadlHandle)
+- {
++ if (NetDevice->SendBufferGpadlHandle) {
+ DPRINT_INFO(NETVSC, "Tearing down send buffer's GPADL...");
+
+- ret = NetDevice->Device->Driver->VmbusChannelInterface.TeardownGpadl(NetDevice->Device,
+- NetDevice->SendBufferGpadlHandle);
++ ret = NetDevice->Device->Driver->VmbusChannelInterface.TeardownGpadl(NetDevice->Device, NetDevice->SendBufferGpadlHandle);
+
+- /* If we failed here, we might as well return and have a leak rather than continue and a bugchk */
+- if (ret != 0)
+- {
+- DPRINT_ERR(NETVSC, "unable to teardown send buffer's gpadl");
++ /*
++ * If we failed here, we might as well return and have a leak
++ * rather than continue and a bugchk
++ */
++ if (ret != 0) {
++ DPRINT_ERR(NETVSC, "unable to teardown send buffer's "
++ "gpadl");
+ DPRINT_EXIT(NETVSC);
+ return -1;
+ }
+ NetDevice->SendBufferGpadlHandle = 0;
+ }
+
+- if (NetDevice->SendBuffer)
+- {
++ if (NetDevice->SendBuffer) {
+ DPRINT_INFO(NETVSC, "Freeing up send buffer...");
+
+ /* Free up the receive buffer */
+- osd_PageFree(NetDevice->SendBuffer, NetDevice->SendBufferSize >> PAGE_SHIFT);
++ osd_PageFree(NetDevice->SendBuffer,
++ NetDevice->SendBufferSize >> PAGE_SHIFT);
+ NetDevice->SendBuffer = NULL;
+ }
+
+@@ -655,13 +586,9 @@ NetVscDestroySendBuffer(
+ }
+
+
+-
+-static int
+-NetVscConnectToVsp(
+- struct hv_device *Device
+- )
++static int NetVscConnectToVsp(struct hv_device *Device)
+ {
+- int ret=0;
++ int ret;
+ struct NETVSC_DEVICE *netDevice;
+ struct nvsp_message *initPacket;
+ int ndisVersion;
+@@ -669,9 +596,9 @@ NetVscConnectToVsp(
+ DPRINT_ENTER(NETVSC);
+
+ netDevice = GetOutboundNetDevice(Device);
+- if (!netDevice)
+- {
+- DPRINT_ERR(NETVSC, "unable to get net device...device being destroyed?");
++ if (!netDevice) {
++ DPRINT_ERR(NETVSC, "unable to get net device..."
++ "device being destroyed?");
+ DPRINT_EXIT(NETVSC);
+ return -1;
+ }
+@@ -680,21 +607,20 @@ NetVscConnectToVsp(
+
+ memset(initPacket, 0, sizeof(struct nvsp_message));
+ initPacket->Header.MessageType = NvspMessageTypeInit;
+- initPacket->Messages.InitMessages.Init.MinProtocolVersion = NVSP_MIN_PROTOCOL_VERSION;
+- initPacket->Messages.InitMessages.Init.MaxProtocolVersion = NVSP_MAX_PROTOCOL_VERSION;
++ initPacket->Messages.InitMessages.Init.MinProtocolVersion = NVSP_MIN_PROTOCOL_VERSION;
++ initPacket->Messages.InitMessages.Init.MaxProtocolVersion = NVSP_MAX_PROTOCOL_VERSION;
+
+ DPRINT_INFO(NETVSC, "Sending NvspMessageTypeInit...");
+
+ /* Send the init request */
+ ret = Device->Driver->VmbusChannelInterface.SendPacket(Device,
+- initPacket,
+- sizeof(struct nvsp_message),
+- (unsigned long)initPacket,
+- VmbusPacketTypeDataInBand,
+- VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
++ initPacket,
++ sizeof(struct nvsp_message),
++ (unsigned long)initPacket,
++ VmbusPacketTypeDataInBand,
++ VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
+
+- if( ret != 0)
+- {
++ if (ret != 0) {
+ DPRINT_ERR(NETVSC, "unable to send NvspMessageTypeInit");
+ goto Cleanup;
+ }
+@@ -707,17 +633,19 @@ NetVscConnectToVsp(
+ initPacket->Messages.InitMessages.InitComplete.Status,
+ initPacket->Messages.InitMessages.InitComplete.MaximumMdlChainLength);
+
+- if (initPacket->Messages.InitMessages.InitComplete.Status != NvspStatusSuccess)
+- {
+- DPRINT_ERR(NETVSC, "unable to initialize with netvsp (status 0x%x)", initPacket->Messages.InitMessages.InitComplete.Status);
++ if (initPacket->Messages.InitMessages.InitComplete.Status !=
++ NvspStatusSuccess) {
++ DPRINT_ERR(NETVSC,
++ "unable to initialize with netvsp (status 0x%x)",
++ initPacket->Messages.InitMessages.InitComplete.Status);
+ ret = -1;
+ goto Cleanup;
+ }
+
+- if (initPacket->Messages.InitMessages.InitComplete.NegotiatedProtocolVersion != NVSP_PROTOCOL_VERSION_1)
+- {
+- DPRINT_ERR(NETVSC, "unable to initialize with netvsp (version expected 1 got %d)",
+- initPacket->Messages.InitMessages.InitComplete.NegotiatedProtocolVersion);
++ if (initPacket->Messages.InitMessages.InitComplete.NegotiatedProtocolVersion != NVSP_PROTOCOL_VERSION_1) {
++ DPRINT_ERR(NETVSC, "unable to initialize with netvsp "
++ "(version expected 1 got %d)",
++ initPacket->Messages.InitMessages.InitComplete.NegotiatedProtocolVersion);
+ ret = -1;
+ goto Cleanup;
+ }
+@@ -726,22 +654,23 @@ NetVscConnectToVsp(
+ /* Send the ndis version */
+ memset(initPacket, 0, sizeof(struct nvsp_message));
+
+- ndisVersion = 0x00050000;
++ ndisVersion = 0x00050000;
+
+- initPacket->Header.MessageType = NvspMessage1TypeSendNdisVersion;
+- initPacket->Messages.Version1Messages.SendNdisVersion.NdisMajorVersion = (ndisVersion & 0xFFFF0000) >> 16;
+- initPacket->Messages.Version1Messages.SendNdisVersion.NdisMinorVersion = ndisVersion & 0xFFFF;
++ initPacket->Header.MessageType = NvspMessage1TypeSendNdisVersion;
++ initPacket->Messages.Version1Messages.SendNdisVersion.NdisMajorVersion =
++ (ndisVersion & 0xFFFF0000) >> 16;
++ initPacket->Messages.Version1Messages.SendNdisVersion.NdisMinorVersion =
++ ndisVersion & 0xFFFF;
+
+ /* Send the init request */
+ ret = Device->Driver->VmbusChannelInterface.SendPacket(Device,
+- initPacket,
+- sizeof(struct nvsp_message),
+- (unsigned long)initPacket,
+- VmbusPacketTypeDataInBand,
+- 0);
+- if (ret != 0)
+- {
+- DPRINT_ERR(NETVSC, "unable to send NvspMessage1TypeSendNdisVersion");
++ initPacket,
++ sizeof(struct nvsp_message),
++ (unsigned long)initPacket,
++ VmbusPacketTypeDataInBand, 0);
++ if (ret != 0) {
++ DPRINT_ERR(NETVSC,
++ "unable to send NvspMessage1TypeSendNdisVersion");
+ ret = -1;
+ goto Cleanup;
+ }
+@@ -756,9 +685,7 @@ NetVscConnectToVsp(
+ /* Post the big receive buffer to NetVSP */
+ ret = NetVscInitializeReceiveBufferWithNetVsp(Device);
+ if (ret == 0)
+- {
+ ret = NetVscInitializeSendBufferWithNetVsp(Device);
+- }
+
+ Cleanup:
+ PutNetDevice(Device);
+@@ -766,10 +693,7 @@ Cleanup:
+ return ret;
+ }
+
+-static void
+-NetVscDisconnectFromVsp(
+- struct NETVSC_DEVICE *NetDevice
+- )
++static void NetVscDisconnectFromVsp(struct NETVSC_DEVICE *NetDevice)
+ {
+ DPRINT_ENTER(NETVSC);
+
+@@ -779,36 +703,23 @@ NetVscDisconnectFromVsp(
+ DPRINT_EXIT(NETVSC);
+ }
+
+-
+-/*++
+-
+-Name:
+- NetVscOnDeviceAdd()
+-
+-Description:
+- Callback when the device belonging to this driver is added
+-
+---*/
+-static int
+-NetVscOnDeviceAdd(
+- struct hv_device *Device,
+- void *AdditionalInfo
+- )
++/**
++ * NetVscOnDeviceAdd - Callback when the device belonging to this driver is added
++ */
++static int NetVscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo)
+ {
+- int ret=0;
++ int ret = 0;
+ int i;
+-
+ struct NETVSC_DEVICE *netDevice;
+ struct hv_netvsc_packet *packet;
+ LIST_ENTRY *entry;
+-
+- struct netvsc_driver *netDriver = (struct netvsc_driver *)Device->Driver;
++ struct netvsc_driver *netDriver =
++ (struct netvsc_driver *)Device->Driver;
+
+ DPRINT_ENTER(NETVSC);
+
+ netDevice = AllocNetDevice(Device);
+- if (!netDevice)
+- {
++ if (!netDevice) {
+ ret = -1;
+ goto Cleanup;
+ }
+@@ -823,30 +734,31 @@ NetVscOnDeviceAdd(
+
+ INITIALIZE_LIST_HEAD(&netDevice->ReceivePacketList);
+
+- for (i=0; i < NETVSC_RECEIVE_PACKETLIST_COUNT; i++)
+- {
+- packet = kzalloc(sizeof(struct hv_netvsc_packet) + (NETVSC_RECEIVE_SG_COUNT* sizeof(struct hv_page_buffer)), GFP_KERNEL);
+- if (!packet)
+- {
+- DPRINT_DBG(NETVSC, "unable to allocate netvsc pkts for receive pool (wanted %d got %d)", NETVSC_RECEIVE_PACKETLIST_COUNT, i);
++ for (i = 0; i < NETVSC_RECEIVE_PACKETLIST_COUNT; i++) {
++ packet = kzalloc(sizeof(struct hv_netvsc_packet) +
++ (NETVSC_RECEIVE_SG_COUNT *
++ sizeof(struct hv_page_buffer)), GFP_KERNEL);
++ if (!packet) {
++ DPRINT_DBG(NETVSC, "unable to allocate netvsc pkts "
++ "for receive pool (wanted %d got %d)",
++ NETVSC_RECEIVE_PACKETLIST_COUNT, i);
+ break;
+ }
+
+- INSERT_TAIL_LIST(&netDevice->ReceivePacketList, &packet->ListEntry);
++ INSERT_TAIL_LIST(&netDevice->ReceivePacketList,
++ &packet->ListEntry);
+ }
+ netDevice->ChannelInitEvent = osd_WaitEventCreate();
+
+ /* Open the channel */
+ ret = Device->Driver->VmbusChannelInterface.Open(Device,
+- netDriver->RingBufferSize,
+- netDriver->RingBufferSize,
+- NULL, 0,
+- NetVscOnChannelCallback,
+- Device
+- );
++ netDriver->RingBufferSize,
++ netDriver->RingBufferSize,
++ NULL, 0,
++ NetVscOnChannelCallback,
++ Device);
+
+- if (ret != 0)
+- {
++ if (ret != 0) {
+ DPRINT_ERR(NETVSC, "unable to open channel: %d", ret);
+ ret = -1;
+ goto Cleanup;
+@@ -857,14 +769,14 @@ NetVscOnDeviceAdd(
+
+ /* Connect with the NetVsp */
+ ret = NetVscConnectToVsp(Device);
+- if (ret != 0)
+- {
++ if (ret != 0) {
+ DPRINT_ERR(NETVSC, "unable to connect to NetVSP - %d", ret);
+ ret = -1;
+ goto Close;
+ }
+
+- DPRINT_INFO(NETVSC, "*** NetVSC channel handshake result - %d ***", ret);
++ DPRINT_INFO(NETVSC, "*** NetVSC channel handshake result - %d ***",
++ ret);
+
+ DPRINT_EXIT(NETVSC);
+ return ret;
+@@ -875,14 +787,14 @@ Close:
+
+ Cleanup:
+
+- if (netDevice)
+- {
++ if (netDevice) {
+ kfree(netDevice->ChannelInitEvent);
+
+- while (!IsListEmpty(&netDevice->ReceivePacketList))
+- {
++ while (!IsListEmpty(&netDevice->ReceivePacketList)) {
+ entry = REMOVE_HEAD_LIST(&netDevice->ReceivePacketList);
+- packet = CONTAINING_RECORD(entry, struct hv_netvsc_packet, ListEntry);
++ packet = CONTAINING_RECORD(entry,
++ struct hv_netvsc_packet,
++ ListEntry);
+ kfree(packet);
+ }
+
+@@ -896,43 +808,31 @@ Cleanup:
+ return ret;
+ }
+
+-
+-/*++
+-
+-Name:
+- NetVscOnDeviceRemove()
+-
+-Description:
+- Callback when the root bus device is removed
+-
+---*/
+-static int
+-NetVscOnDeviceRemove(
+- struct hv_device *Device
+- )
++/**
++ * NetVscOnDeviceRemove - Callback when the root bus device is removed
++ */
++static int NetVscOnDeviceRemove(struct hv_device *Device)
+ {
+ struct NETVSC_DEVICE *netDevice;
+ struct hv_netvsc_packet *netvscPacket;
+- int ret=0;
+ LIST_ENTRY *entry;
+
+ DPRINT_ENTER(NETVSC);
+
+- DPRINT_INFO(NETVSC, "Disabling outbound traffic on net device (%p)...", Device->Extension);
++ DPRINT_INFO(NETVSC, "Disabling outbound traffic on net device (%p)...",
++ Device->Extension);
+
+ /* Stop outbound traffic ie sends and receives completions */
+ netDevice = ReleaseOutboundNetDevice(Device);
+- if (!netDevice)
+- {
++ if (!netDevice) {
+ DPRINT_ERR(NETVSC, "No net device present!!");
+ return -1;
+ }
+
+ /* Wait for all send completions */
+- while (atomic_read(&netDevice->NumOutstandingSends))
+- {
+- DPRINT_INFO(NETVSC, "waiting for %d requests to complete...", atomic_read(&netDevice->NumOutstandingSends));
+-
++ while (atomic_read(&netDevice->NumOutstandingSends)) {
++ DPRINT_INFO(NETVSC, "waiting for %d requests to complete...",
++ atomic_read(&netDevice->NumOutstandingSends));
+ udelay(100);
+ }
+
+@@ -940,7 +840,8 @@ NetVscOnDeviceRemove(
+
+ NetVscDisconnectFromVsp(netDevice);
+
+- DPRINT_INFO(NETVSC, "Disabling inbound traffic on net device (%p)...", Device->Extension);
++ DPRINT_INFO(NETVSC, "Disabling inbound traffic on net device (%p)...",
++ Device->Extension);
+
+ /* Stop inbound traffic ie receives and sends completions */
+ netDevice = ReleaseInboundNetDevice(Device);
+@@ -952,10 +853,11 @@ NetVscOnDeviceRemove(
+ Device->Driver->VmbusChannelInterface.Close(Device);
+
+ /* Release all resources */
+- while (!IsListEmpty(&netDevice->ReceivePacketList))
+- {
++ while (!IsListEmpty(&netDevice->ReceivePacketList)) {
+ entry = REMOVE_HEAD_LIST(&netDevice->ReceivePacketList);
+- netvscPacket = CONTAINING_RECORD(entry, struct hv_netvsc_packet, ListEntry);
++ netvscPacket = CONTAINING_RECORD(entry,
++ struct hv_netvsc_packet,
++ ListEntry);
+
+ kfree(netvscPacket);
+ }
+@@ -964,35 +866,20 @@ NetVscOnDeviceRemove(
+ FreeNetDevice(netDevice);
+
+ DPRINT_EXIT(NETVSC);
+- return ret;
++ return 0;
+ }
+
+-
+-
+-/*++
+-
+-Name:
+- NetVscOnCleanup()
+-
+-Description:
+- Perform any cleanup when the driver is removed
+-
+---*/
+-static void
+-NetVscOnCleanup(
+- struct hv_driver *drv
+- )
++/**
++ * NetVscOnCleanup - Perform any cleanup when the driver is removed
++ */
++static void NetVscOnCleanup(struct hv_driver *drv)
+ {
+ DPRINT_ENTER(NETVSC);
+-
+ DPRINT_EXIT(NETVSC);
+ }
+
+-static void
+-NetVscOnSendCompletion(
+- struct hv_device *Device,
+- struct vmpacket_descriptor *Packet
+- )
++static void NetVscOnSendCompletion(struct hv_device *Device,
++ struct vmpacket_descriptor *Packet)
+ {
+ struct NETVSC_DEVICE *netDevice;
+ struct nvsp_message *nvspPacket;
+@@ -1001,27 +888,29 @@ NetVscOnSendCompletion(
+ DPRINT_ENTER(NETVSC);
+
+ netDevice = GetInboundNetDevice(Device);
+- if (!netDevice)
+- {
+- DPRINT_ERR(NETVSC, "unable to get net device...device being destroyed?");
++ if (!netDevice) {
++ DPRINT_ERR(NETVSC, "unable to get net device..."
++ "device being destroyed?");
+ DPRINT_EXIT(NETVSC);
+ return;
+ }
+
+ nvspPacket = (struct nvsp_message *)((unsigned long)Packet + (Packet->DataOffset8 << 3));
+
+- DPRINT_DBG(NETVSC, "send completion packet - type %d", nvspPacket->Header.MessageType);
++ DPRINT_DBG(NETVSC, "send completion packet - type %d",
++ nvspPacket->Header.MessageType);
+
+- if (nvspPacket->Header.MessageType == NvspMessageTypeInitComplete ||
+- nvspPacket->Header.MessageType == NvspMessage1TypeSendReceiveBufferComplete ||
+- nvspPacket->Header.MessageType == NvspMessage1TypeSendSendBufferComplete)
+- {
++ if ((nvspPacket->Header.MessageType == NvspMessageTypeInitComplete) ||
++ (nvspPacket->Header.MessageType ==
++ NvspMessage1TypeSendReceiveBufferComplete) ||
++ (nvspPacket->Header.MessageType ==
++ NvspMessage1TypeSendSendBufferComplete)) {
+ /* Copy the response back */
+- memcpy(&netDevice->ChannelInitPacket, nvspPacket, sizeof(struct nvsp_message));
++ memcpy(&netDevice->ChannelInitPacket, nvspPacket,
++ sizeof(struct nvsp_message));
+ osd_WaitEventSet(netDevice->ChannelInitEvent);
+- }
+- else if (nvspPacket->Header.MessageType == NvspMessage1TypeSendRNDISPacketComplete)
+- {
++ } else if (nvspPacket->Header.MessageType ==
++ NvspMessage1TypeSendRNDISPacketComplete) {
+ /* Get the send context */
+ nvscPacket = (struct hv_netvsc_packet *)(unsigned long)Packet->TransactionId;
+ ASSERT(nvscPacket);
+@@ -1030,73 +919,66 @@ NetVscOnSendCompletion(
+ nvscPacket->Completion.Send.OnSendCompletion(nvscPacket->Completion.Send.SendCompletionContext);
+
+ atomic_dec(&netDevice->NumOutstandingSends);
+- }
+- else
+- {
+- DPRINT_ERR(NETVSC, "Unknown send completion packet type - %d received!!", nvspPacket->Header.MessageType);
++ } else {
++ DPRINT_ERR(NETVSC, "Unknown send completion packet type - "
++ "%d received!!", nvspPacket->Header.MessageType);
+ }
+
+ PutNetDevice(Device);
+ DPRINT_EXIT(NETVSC);
+ }
+
+-
+-
+-static int
+-NetVscOnSend(
+- struct hv_device *Device,
+- struct hv_netvsc_packet *Packet
+- )
++static int NetVscOnSend(struct hv_device *Device,
++ struct hv_netvsc_packet *Packet)
+ {
+ struct NETVSC_DEVICE *netDevice;
+- int ret=0;
++ int ret = 0;
+
+ struct nvsp_message sendMessage;
+
+ DPRINT_ENTER(NETVSC);
+
+ netDevice = GetOutboundNetDevice(Device);
+- if (!netDevice)
+- {
+- DPRINT_ERR(NETVSC, "net device (%p) shutting down...ignoring outbound packets", netDevice);
++ if (!netDevice) {
++ DPRINT_ERR(NETVSC, "net device (%p) shutting down..."
++ "ignoring outbound packets", netDevice);
+ DPRINT_EXIT(NETVSC);
+ return -2;
+ }
+
+ sendMessage.Header.MessageType = NvspMessage1TypeSendRNDISPacket;
+- if (Packet->IsDataPacket)
+- sendMessage.Messages.Version1Messages.SendRNDISPacket.ChannelType = 0;/* 0 is RMC_DATA; */
+- else
+- sendMessage.Messages.Version1Messages.SendRNDISPacket.ChannelType = 1;/* 1 is RMC_CONTROL; */
++ if (Packet->IsDataPacket) {
++ /* 0 is RMC_DATA; */
++ sendMessage.Messages.Version1Messages.SendRNDISPacket.ChannelType = 0;
++ } else {
++ /* 1 is RMC_CONTROL; */
++ sendMessage.Messages.Version1Messages.SendRNDISPacket.ChannelType = 1;
++ }
+
+ /* Not using send buffer section */
+- sendMessage.Messages.Version1Messages.SendRNDISPacket.SendBufferSectionIndex = 0xFFFFFFFF;
+- sendMessage.Messages.Version1Messages.SendRNDISPacket.SendBufferSectionSize = 0;
++ sendMessage.Messages.Version1Messages.SendRNDISPacket.SendBufferSectionIndex = 0xFFFFFFFF;
++ sendMessage.Messages.Version1Messages.SendRNDISPacket.SendBufferSectionSize = 0;
+
+- if (Packet->PageBufferCount)
+- {
+- ret = Device->Driver->VmbusChannelInterface.SendPacketPageBuffer(Device,
+- Packet->PageBuffers,
+- Packet->PageBufferCount,
+- &sendMessage,
+- sizeof(struct nvsp_message),
+- (unsigned long)Packet);
+- }
+- else
+- {
++ if (Packet->PageBufferCount) {
++ ret = Device->Driver->VmbusChannelInterface.SendPacketPageBuffer(
++ Device, Packet->PageBuffers,
++ Packet->PageBufferCount,
++ &sendMessage,
++ sizeof(struct nvsp_message),
++ (unsigned long)Packet);
++ } else {
+ ret = Device->Driver->VmbusChannelInterface.SendPacket(Device,
+- &sendMessage,
+- sizeof(struct nvsp_message),
+- (unsigned long)Packet,
+- VmbusPacketTypeDataInBand,
+- VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
++ &sendMessage,
++ sizeof(struct nvsp_message),
++ (unsigned long)Packet,
++ VmbusPacketTypeDataInBand,
++ VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
+
+ }
+
+ if (ret != 0)
+- {
+- DPRINT_ERR(NETVSC, "Unable to send packet %p ret %d", Packet, ret);
+- }
++ DPRINT_ERR(NETVSC, "Unable to send packet %p ret %d",
++ Packet, ret);
+
+ atomic_inc(&netDevice->NumOutstandingSends);
+ PutNetDevice(Device);
+@@ -1105,68 +987,70 @@ NetVscOnSend(
+ return ret;
+ }
+
+-
+-static void
+-NetVscOnReceive(
+- struct hv_device *Device,
+- struct vmpacket_descriptor *Packet
+- )
++static void NetVscOnReceive(struct hv_device *Device,
++ struct vmpacket_descriptor *Packet)
+ {
+ struct NETVSC_DEVICE *netDevice;
+ struct vmtransfer_page_packet_header *vmxferpagePacket;
+ struct nvsp_message *nvspPacket;
+- struct hv_netvsc_packet *netvscPacket=NULL;
+- LIST_ENTRY* entry;
++ struct hv_netvsc_packet *netvscPacket = NULL;
++ LIST_ENTRY *entry;
+ unsigned long start;
+ unsigned long end, endVirtual;
+ /* struct netvsc_driver *netvscDriver; */
+- struct xferpage_packet *xferpagePacket=NULL;
++ struct xferpage_packet *xferpagePacket = NULL;
+ LIST_ENTRY listHead;
+-
+- int i=0, j=0;
+- int count=0, bytesRemain=0;
++ int i, j;
++ int count = 0, bytesRemain = 0;
+ unsigned long flags;
+
+ DPRINT_ENTER(NETVSC);
+
+ netDevice = GetInboundNetDevice(Device);
+- if (!netDevice)
+- {
+- DPRINT_ERR(NETVSC, "unable to get net device...device being destroyed?");
++ if (!netDevice) {
++ DPRINT_ERR(NETVSC, "unable to get net device..."
++ "device being destroyed?");
+ DPRINT_EXIT(NETVSC);
+ return;
+ }
+
+- /* All inbound packets other than send completion should be xfer page packet */
+- if (Packet->Type != VmbusPacketTypeDataUsingTransferPages)
+- {
+- DPRINT_ERR(NETVSC, "Unknown packet type received - %d", Packet->Type);
++ /*
++ * All inbound packets other than send completion should be xfer page
++ * packet
++ */
++ if (Packet->Type != VmbusPacketTypeDataUsingTransferPages) {
++ DPRINT_ERR(NETVSC, "Unknown packet type received - %d",
++ Packet->Type);
+ PutNetDevice(Device);
+ return;
+ }
+
+- nvspPacket = (struct nvsp_message*)((unsigned long)Packet + (Packet->DataOffset8 << 3));
++ nvspPacket = (struct nvsp_message *)((unsigned long)Packet +
++ (Packet->DataOffset8 << 3));
+
+ /* Make sure this is a valid nvsp packet */
+- if (nvspPacket->Header.MessageType != NvspMessage1TypeSendRNDISPacket )
+- {
+- DPRINT_ERR(NETVSC, "Unknown nvsp packet type received - %d", nvspPacket->Header.MessageType);
++ if (nvspPacket->Header.MessageType != NvspMessage1TypeSendRNDISPacket) {
++ DPRINT_ERR(NETVSC, "Unknown nvsp packet type received - %d",
++ nvspPacket->Header.MessageType);
+ PutNetDevice(Device);
+ return;
+ }
+
+- DPRINT_DBG(NETVSC, "NVSP packet received - type %d", nvspPacket->Header.MessageType);
++ DPRINT_DBG(NETVSC, "NVSP packet received - type %d",
++ nvspPacket->Header.MessageType);
+
+ vmxferpagePacket = (struct vmtransfer_page_packet_header *)Packet;
+
+- if (vmxferpagePacket->TransferPageSetId != NETVSC_RECEIVE_BUFFER_ID)
+- {
+- DPRINT_ERR(NETVSC, "Invalid xfer page set id - expecting %x got %x", NETVSC_RECEIVE_BUFFER_ID, vmxferpagePacket->TransferPageSetId);
++ if (vmxferpagePacket->TransferPageSetId != NETVSC_RECEIVE_BUFFER_ID) {
++ DPRINT_ERR(NETVSC, "Invalid xfer page set id - "
++ "expecting %x got %x", NETVSC_RECEIVE_BUFFER_ID,
++ vmxferpagePacket->TransferPageSetId);
+ PutNetDevice(Device);
+ return;
+ }
+
+- DPRINT_DBG(NETVSC, "xfer page - range count %d", vmxferpagePacket->RangeCount);
++ DPRINT_DBG(NETVSC, "xfer page - range count %d",
++ vmxferpagePacket->RangeCount);
+
+ INITIALIZE_LIST_HEAD(&listHead);
+
+@@ -1177,10 +1061,11 @@ NetVscOnReceive(
+ * fulfil
+ */
+ spin_lock_irqsave(&netDevice->receive_packet_list_lock, flags);
+- while (!IsListEmpty(&netDevice->ReceivePacketList))
+- {
++ while (!IsListEmpty(&netDevice->ReceivePacketList)) {
+ entry = REMOVE_HEAD_LIST(&netDevice->ReceivePacketList);
+- netvscPacket = CONTAINING_RECORD(entry, struct hv_netvsc_packet, ListEntry);
++ netvscPacket = CONTAINING_RECORD(entry,
++ struct hv_netvsc_packet,
++ ListEntry);
+
+ INSERT_TAIL_LIST(&listHead, &netvscPacket->ListEntry);
+
+@@ -1194,22 +1079,27 @@ NetVscOnReceive(
+ * page and at least 1 for the range) i.e. we can handled
+ * some of the xfer page packet ranges...
+ */
+- if (count < 2)
+- {
+- DPRINT_ERR(NETVSC, "Got only %d netvsc pkt...needed %d pkts. Dropping this xfer page packet completely!", count, vmxferpagePacket->RangeCount+1);
++ if (count < 2) {
++ DPRINT_ERR(NETVSC, "Got only %d netvsc pkt...needed %d pkts. "
++ "Dropping this xfer page packet completely!",
++ count, vmxferpagePacket->RangeCount + 1);
+
+ /* Return it to the freelist */
+ spin_lock_irqsave(&netDevice->receive_packet_list_lock, flags);
+- for (i=count; i != 0; i--)
+- {
++ for (i = count; i != 0; i--) {
+ entry = REMOVE_HEAD_LIST(&listHead);
+- netvscPacket = CONTAINING_RECORD(entry, struct hv_netvsc_packet, ListEntry);
++ netvscPacket = CONTAINING_RECORD(entry,
++ struct hv_netvsc_packet,
++ ListEntry);
+
+- INSERT_TAIL_LIST(&netDevice->ReceivePacketList, &netvscPacket->ListEntry);
++ INSERT_TAIL_LIST(&netDevice->ReceivePacketList,
++ &netvscPacket->ListEntry);
+ }
+- spin_unlock_irqrestore(&netDevice->receive_packet_list_lock, flags);
++ spin_unlock_irqrestore(&netDevice->receive_packet_list_lock,
++ flags);
+
+- NetVscSendReceiveCompletion(Device, vmxferpagePacket->d.TransactionId);
++ NetVscSendReceiveCompletion(Device,
++ vmxferpagePacket->d.TransactionId);
+
+ PutNetDevice(Device);
+ return;
+@@ -1217,74 +1107,90 @@ NetVscOnReceive(
+
+ /* Remove the 1st packet to represent the xfer page packet itself */
+ entry = REMOVE_HEAD_LIST(&listHead);
+- xferpagePacket = CONTAINING_RECORD(entry, struct xferpage_packet, ListEntry);
+- xferpagePacket->Count = count - 1; /* This is how much we can satisfy */
+- ASSERT(xferpagePacket->Count > 0 && xferpagePacket->Count <= vmxferpagePacket->RangeCount);
+-
+- if (xferpagePacket->Count != vmxferpagePacket->RangeCount)
+- {
+- DPRINT_INFO(NETVSC, "Needed %d netvsc pkts to satisy this xfer page...got %d", vmxferpagePacket->RangeCount, xferpagePacket->Count);
++ xferpagePacket = CONTAINING_RECORD(entry, struct xferpage_packet,
++ ListEntry);
++ /* This is how much we can satisfy */
++ xferpagePacket->Count = count - 1;
++ ASSERT(xferpagePacket->Count > 0 && xferpagePacket->Count <=
++ vmxferpagePacket->RangeCount);
++
++ if (xferpagePacket->Count != vmxferpagePacket->RangeCount) {
++ DPRINT_INFO(NETVSC, "Needed %d netvsc pkts to satisy this xfer "
++ "page...got %d", vmxferpagePacket->RangeCount,
++ xferpagePacket->Count);
+ }
+
+ /* Each range represents 1 RNDIS pkt that contains 1 ethernet frame */
+- for (i=0; i < (count - 1); i++)
+- {
++ for (i = 0; i < (count - 1); i++) {
+ entry = REMOVE_HEAD_LIST(&listHead);
+- netvscPacket = CONTAINING_RECORD(entry, struct hv_netvsc_packet, ListEntry);
++ netvscPacket = CONTAINING_RECORD(entry,
++ struct hv_netvsc_packet,
++ ListEntry);
+
+ /* Initialize the netvsc packet */
+ netvscPacket->XferPagePacket = xferpagePacket;
+- netvscPacket->Completion.Recv.OnReceiveCompletion = NetVscOnReceiveCompletion;
+- netvscPacket->Completion.Recv.ReceiveCompletionContext = netvscPacket;
++ netvscPacket->Completion.Recv.OnReceiveCompletion =
++ NetVscOnReceiveCompletion;
++ netvscPacket->Completion.Recv.ReceiveCompletionContext =
++ netvscPacket;
+ netvscPacket->Device = Device;
+- netvscPacket->Completion.Recv.ReceiveCompletionTid = vmxferpagePacket->d.TransactionId; /* Save this so that we can send it back */
++ /* Save this so that we can send it back */
++ netvscPacket->Completion.Recv.ReceiveCompletionTid =
++ vmxferpagePacket->d.TransactionId;
+
+- netvscPacket->TotalDataBufferLength = vmxferpagePacket->Ranges[i].ByteCount;
++ netvscPacket->TotalDataBufferLength =
++ vmxferpagePacket->Ranges[i].ByteCount;
+ netvscPacket->PageBufferCount = 1;
+
+- ASSERT(vmxferpagePacket->Ranges[i].ByteOffset + vmxferpagePacket->Ranges[i].ByteCount < netDevice->ReceiveBufferSize);
++ ASSERT(vmxferpagePacket->Ranges[i].ByteOffset +
++ vmxferpagePacket->Ranges[i].ByteCount <
++ netDevice->ReceiveBufferSize);
+
+- netvscPacket->PageBuffers[0].Length = vmxferpagePacket->Ranges[i].ByteCount;
++ netvscPacket->PageBuffers[0].Length =
++ vmxferpagePacket->Ranges[i].ByteCount;
+
+- start = virt_to_phys((void*)((unsigned long)netDevice->ReceiveBuffer + vmxferpagePacket->Ranges[i].ByteOffset));
++ start = virt_to_phys((void *)((unsigned long)netDevice->ReceiveBuffer + vmxferpagePacket->Ranges[i].ByteOffset));
+
+ netvscPacket->PageBuffers[0].Pfn = start >> PAGE_SHIFT;
+ endVirtual = (unsigned long)netDevice->ReceiveBuffer
+ + vmxferpagePacket->Ranges[i].ByteOffset
+- + vmxferpagePacket->Ranges[i].ByteCount -1;
+- end = virt_to_phys((void*)endVirtual);
++ + vmxferpagePacket->Ranges[i].ByteCount - 1;
++ end = virt_to_phys((void *)endVirtual);
+
+ /* Calculate the page relative offset */
+- netvscPacket->PageBuffers[0].Offset = vmxferpagePacket->Ranges[i].ByteOffset & (PAGE_SIZE -1);
+- if ((end >> PAGE_SHIFT) != (start>>PAGE_SHIFT)) {
+- /* Handle frame across multiple pages: */
+- netvscPacket->PageBuffers[0].Length =
+- (netvscPacket->PageBuffers[0].Pfn <<PAGE_SHIFT) + PAGE_SIZE - start;
+- bytesRemain = netvscPacket->TotalDataBufferLength - netvscPacket->PageBuffers[0].Length;
+- for (j=1; j<NETVSC_PACKET_MAXPAGE; j++) {
+- netvscPacket->PageBuffers[j].Offset = 0;
+- if (bytesRemain <= PAGE_SIZE) {
+- netvscPacket->PageBuffers[j].Length = bytesRemain;
+- bytesRemain = 0;
+- } else {
+- netvscPacket->PageBuffers[j].Length = PAGE_SIZE;
+- bytesRemain -= PAGE_SIZE;
++ netvscPacket->PageBuffers[0].Offset =
++ vmxferpagePacket->Ranges[i].ByteOffset & (PAGE_SIZE - 1);
++ if ((end >> PAGE_SHIFT) != (start >> PAGE_SHIFT)) {
++ /* Handle frame across multiple pages: */
++ netvscPacket->PageBuffers[0].Length =
++ (netvscPacket->PageBuffers[0].Pfn << PAGE_SHIFT)
++ + PAGE_SIZE - start;
++ bytesRemain = netvscPacket->TotalDataBufferLength -
++ netvscPacket->PageBuffers[0].Length;
++ for (j = 1; j < NETVSC_PACKET_MAXPAGE; j++) {
++ netvscPacket->PageBuffers[j].Offset = 0;
++ if (bytesRemain <= PAGE_SIZE) {
++ netvscPacket->PageBuffers[j].Length = bytesRemain;
++ bytesRemain = 0;
++ } else {
++ netvscPacket->PageBuffers[j].Length = PAGE_SIZE;
++ bytesRemain -= PAGE_SIZE;
++ }
++ netvscPacket->PageBuffers[j].Pfn =
++ virt_to_phys((void *)(endVirtual - bytesRemain)) >> PAGE_SHIFT;
++ netvscPacket->PageBufferCount++;
++ if (bytesRemain == 0)
++ break;
+ }
+- netvscPacket->PageBuffers[j].Pfn =
+- virt_to_phys((void*)(endVirtual - bytesRemain)) >> PAGE_SHIFT;
+- netvscPacket->PageBufferCount++;
+- if (bytesRemain == 0)
+- break;
+- }
+- ASSERT(bytesRemain == 0);
++ ASSERT(bytesRemain == 0);
+ }
+- DPRINT_DBG(NETVSC, "[%d] - (abs offset %u len %u) => (pfn %llx, offset %u, len %u)",
+- i,
+- vmxferpagePacket->Ranges[i].ByteOffset,
+- vmxferpagePacket->Ranges[i].ByteCount,
+- netvscPacket->PageBuffers[0].Pfn,
+- netvscPacket->PageBuffers[0].Offset,
+- netvscPacket->PageBuffers[0].Length);
++ DPRINT_DBG(NETVSC, "[%d] - (abs offset %u len %u) => "
++ "(pfn %llx, offset %u, len %u)", i,
++ vmxferpagePacket->Ranges[i].ByteOffset,
++ vmxferpagePacket->Ranges[i].ByteCount,
++ netvscPacket->PageBuffers[0].Pfn,
++ netvscPacket->PageBuffers[0].Offset,
++ netvscPacket->PageBuffers[0].Length);
+
+ /* Pass it to the upper layer */
+ ((struct netvsc_driver *)Device->Driver)->OnReceiveCallback(Device, netvscPacket);
+@@ -1298,20 +1204,18 @@ NetVscOnReceive(
+ DPRINT_EXIT(NETVSC);
+ }
+
+-
+-static void
+-NetVscSendReceiveCompletion(
+- struct hv_device *Device,
+- u64 TransactionId
+- )
++static void NetVscSendReceiveCompletion(struct hv_device *Device,
++ u64 TransactionId)
+ {
+ struct nvsp_message recvcompMessage;
+- int retries=0;
+- int ret=0;
++ int retries = 0;
++ int ret;
+
+- DPRINT_DBG(NETVSC, "Sending receive completion pkt - %llx", TransactionId);
++ DPRINT_DBG(NETVSC, "Sending receive completion pkt - %llx",
++ TransactionId);
+
+- recvcompMessage.Header.MessageType = NvspMessage1TypeSendRNDISPacketComplete;
++ recvcompMessage.Header.MessageType =
++ NvspMessage1TypeSendRNDISPacketComplete;
+
+ /* FIXME: Pass in the status */
+ recvcompMessage.Messages.Version1Messages.SendRNDISPacketComplete.Status = NvspStatusSuccess;
+@@ -1319,45 +1223,40 @@ NetVscSendReceiveCompletion(
+ retry_send_cmplt:
+ /* Send the completion */
+ ret = Device->Driver->VmbusChannelInterface.SendPacket(Device,
+- &recvcompMessage,
+- sizeof(struct nvsp_message),
+- TransactionId,
+- VmbusPacketTypeCompletion,
+- 0);
+- if (ret == 0) /* success */
+- {
++ &recvcompMessage,
++ sizeof(struct nvsp_message),
++ TransactionId,
++ VmbusPacketTypeCompletion, 0);
++ if (ret == 0) {
++ /* success */
+ /* no-op */
+- }
+- else if (ret == -1) /* no more room...wait a bit and attempt to retry 3 times */
+- {
++ } else if (ret == -1) {
++ /* no more room...wait a bit and attempt to retry 3 times */
+ retries++;
+- DPRINT_ERR(NETVSC, "unable to send receive completion pkt (tid %llx)...retrying %d", TransactionId, retries);
++ DPRINT_ERR(NETVSC, "unable to send receive completion pkt "
++ "(tid %llx)...retrying %d", TransactionId, retries);
+
+- if (retries < 4)
+- {
++ if (retries < 4) {
+ udelay(100);
+ goto retry_send_cmplt;
++ } else {
++ DPRINT_ERR(NETVSC, "unable to send receive completion "
++ "pkt (tid %llx)...give up retrying",
++ TransactionId);
+ }
+- else
+- {
+- DPRINT_ERR(NETVSC, "unable to send receive completion pkt (tid %llx)...give up retrying", TransactionId);
+- }
+- }
+- else
+- {
+- DPRINT_ERR(NETVSC, "unable to send receive completion pkt - %llx", TransactionId);
++ } else {
++ DPRINT_ERR(NETVSC, "unable to send receive completion pkt - "
++ "%llx", TransactionId);
+ }
+ }
+
+ /* Send a receive completion packet to RNDIS device (ie NetVsp) */
+-static void
+-NetVscOnReceiveCompletion(
+- void * Context)
++static void NetVscOnReceiveCompletion(void *Context)
+ {
+- struct hv_netvsc_packet *packet = (struct hv_netvsc_packet*)Context;
+- struct hv_device *device = (struct hv_device*)packet->Device;
++ struct hv_netvsc_packet *packet = Context;
++ struct hv_device *device = (struct hv_device *)packet->Device;
+ struct NETVSC_DEVICE *netDevice;
+- u64 transactionId=0;
++ u64 transactionId = 0;
+ bool fSendReceiveComp = false;
+ unsigned long flags;
+
+@@ -1365,12 +1264,15 @@ NetVscOnReceiveCompletion(
+
+ ASSERT(packet->XferPagePacket);
+
+- /* Even though it seems logical to do a GetOutboundNetDevice() here to send out receive completion, */
+- /* we are using GetInboundNetDevice() since we may have disable outbound traffic already. */
++ /*
++ * Even though it seems logical to do a GetOutboundNetDevice() here to
++ * send out receive completion, we are using GetInboundNetDevice()
++ * since we may have disable outbound traffic already.
++ */
+ netDevice = GetInboundNetDevice(device);
+- if (!netDevice)
+- {
+- DPRINT_ERR(NETVSC, "unable to get net device...device being destroyed?");
++ if (!netDevice) {
++ DPRINT_ERR(NETVSC, "unable to get net device..."
++ "device being destroyed?");
+ DPRINT_EXIT(NETVSC);
+ return;
+ }
+@@ -1381,14 +1283,16 @@ NetVscOnReceiveCompletion(
+ ASSERT(packet->XferPagePacket->Count > 0);
+ packet->XferPagePacket->Count--;
+
+- /* Last one in the line that represent 1 xfer page packet. */
+- /* Return the xfer page packet itself to the freelist */
+- if (packet->XferPagePacket->Count == 0)
+- {
++ /*
++ * Last one in the line that represent 1 xfer page packet.
++ * Return the xfer page packet itself to the freelist
++ */
++ if (packet->XferPagePacket->Count == 0) {
+ fSendReceiveComp = true;
+ transactionId = packet->Completion.Recv.ReceiveCompletionTid;
+
+- INSERT_TAIL_LIST(&netDevice->ReceivePacketList, &packet->XferPagePacket->ListEntry);
++ INSERT_TAIL_LIST(&netDevice->ReceivePacketList,
++ &packet->XferPagePacket->ListEntry);
+ }
+
+ /* Put the packet back */
+@@ -1397,32 +1301,24 @@ NetVscOnReceiveCompletion(
+
+ /* Send a receive completion for the xfer page packet */
+ if (fSendReceiveComp)
+- {
+ NetVscSendReceiveCompletion(device, transactionId);
+- }
+
+ PutNetDevice(device);
+ DPRINT_EXIT(NETVSC);
+ }
+
+-
+-
+-void
+-NetVscOnChannelCallback(
+- void * Context
+- )
+-{
+- const int netPacketSize=2048;
+- int ret=0;
+- struct hv_device *device=(struct hv_device*)Context;
++void NetVscOnChannelCallback(void *Context)
++{
++ const int netPacketSize = 2048;
++ int ret;
++ struct hv_device *device = Context;
+ struct NETVSC_DEVICE *netDevice;
+-
+ u32 bytesRecvd;
+ u64 requestId;
+ unsigned char packet[netPacketSize];
+ struct vmpacket_descriptor *desc;
+- unsigned char *buffer=packet;
+- int bufferlen=netPacketSize;
++ unsigned char *buffer = packet;
++ int bufferlen = netPacketSize;
+
+
+ DPRINT_ENTER(NETVSC);
+@@ -1430,82 +1326,70 @@ NetVscOnChannelCallback(
+ ASSERT(device);
+
+ netDevice = GetInboundNetDevice(device);
+- if (!netDevice)
+- {
+- DPRINT_ERR(NETVSC, "net device (%p) shutting down...ignoring inbound packets", netDevice);
++ if (!netDevice) {
++ DPRINT_ERR(NETVSC, "net device (%p) shutting down..."
++ "ignoring inbound packets", netDevice);
+ DPRINT_EXIT(NETVSC);
+ return;
+ }
+
+- do
+- {
+- ret = device->Driver->VmbusChannelInterface.RecvPacketRaw(device,
+- buffer,
+- bufferlen,
+- &bytesRecvd,
+- &requestId);
+-
+- if (ret == 0)
+- {
+- if (bytesRecvd > 0)
+- {
+- DPRINT_DBG(NETVSC, "receive %d bytes, tid %llx", bytesRecvd, requestId);
+-
+- desc = (struct vmpacket_descriptor*)buffer;
+- switch (desc->Type)
+- {
+- case VmbusPacketTypeCompletion:
+- NetVscOnSendCompletion(device, desc);
+- break;
+-
+- case VmbusPacketTypeDataUsingTransferPages:
+- NetVscOnReceive(device, desc);
+- break;
+-
+- default:
+- DPRINT_ERR(NETVSC, "unhandled packet type %d, tid %llx len %d\n", desc->Type, requestId, bytesRecvd);
+- break;
++ do {
++ ret = device->Driver->VmbusChannelInterface.RecvPacketRaw(
++ device, buffer, bufferlen,
++ &bytesRecvd, &requestId);
++ if (ret == 0) {
++ if (bytesRecvd > 0) {
++ DPRINT_DBG(NETVSC, "receive %d bytes, tid %llx",
++ bytesRecvd, requestId);
++
++ desc = (struct vmpacket_descriptor *)buffer;
++ switch (desc->Type) {
++ case VmbusPacketTypeCompletion:
++ NetVscOnSendCompletion(device, desc);
++ break;
++
++ case VmbusPacketTypeDataUsingTransferPages:
++ NetVscOnReceive(device, desc);
++ break;
++
++ default:
++ DPRINT_ERR(NETVSC,
++ "unhandled packet type %d, "
++ "tid %llx len %d\n",
++ desc->Type, requestId,
++ bytesRecvd);
++ break;
+ }
+
+ /* reset */
+- if (bufferlen > netPacketSize)
+- {
++ if (bufferlen > netPacketSize) {
+ kfree(buffer);
+-
+ buffer = packet;
+ bufferlen = netPacketSize;
+ }
+- }
+- else
+- {
+- /* DPRINT_DBG(NETVSC, "nothing else to read..."); */
+-
++ } else {
+ /* reset */
+- if (bufferlen > netPacketSize)
+- {
++ if (bufferlen > netPacketSize) {
+ kfree(buffer);
+-
+ buffer = packet;
+ bufferlen = netPacketSize;
+ }
+
+ break;
+ }
+- }
+- else if (ret == -2) /* Handle large packet */
+- {
++ } else if (ret == -2) {
++ /* Handle large packet */
+ buffer = kmalloc(bytesRecvd, GFP_ATOMIC);
+- if (buffer == NULL)
+- {
++ if (buffer == NULL) {
+ /* Try again next time around */
+- DPRINT_ERR(NETVSC, "unable to allocate buffer of size (%d)!!", bytesRecvd);
++ DPRINT_ERR(NETVSC,
++ "unable to allocate buffer of size "
++ "(%d)!!", bytesRecvd);
+ break;
+ }
+
+ bufferlen = bytesRecvd;
+- }
+- else
+- {
++ } else {
+ ASSERT(0);
+ }
+ } while (1);
diff --git a/staging/staging-hv-coding-style-cleanup-for-rndisfilter.c.patch b/staging/staging-hv-coding-style-cleanup-for-rndisfilter.c.patch
new file mode 100644
index 00000000000000..5ea54e65c52228
--- /dev/null
+++ b/staging/staging-hv-coding-style-cleanup-for-rndisfilter.c.patch
@@ -0,0 +1,1269 @@
+From foo@baz Wed Sep 2 09:17:52 PDT 2009
+Date: Wed, 02 Sep 2009 09:17:52 -0700
+To: Greg KH <greg@kroah.com>
+From: Greg Kroah-Hartman <gregkh@suse.de>
+Subject: Staging: hv: coding style cleanup for RndisFilter.c
+
+It's much better now.
+
+Cc: Hank Janssen <hjanssen@microsoft.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ drivers/staging/hv/RndisFilter.c | 679 ++++++++++++++++-----------------------
+ 1 file changed, 282 insertions(+), 397 deletions(-)
+
+--- a/drivers/staging/hv/RndisFilter.c
++++ b/drivers/staging/hv/RndisFilter.c
+@@ -1,5 +1,4 @@
+ /*
+- *
+ * Copyright (c) 2009, Microsoft Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+@@ -18,20 +17,15 @@
+ * Authors:
+ * Haiyang Zhang <haiyangz@microsoft.com>
+ * Hank Janssen <hjanssen@microsoft.com>
+- *
+ */
+-
+ #include <linux/kernel.h>
+ #include <linux/highmem.h>
+-#include <asm/kmap_types.h>
+-#include <asm/io.h>
+-
++#include <linux/io.h>
+ #include "osd.h"
+ #include "logging.h"
+ #include "NetVscApi.h"
+ #include "RndisFilter.h"
+
+-
+ /* Data types */
+ struct rndis_filter_driver_object {
+ /* The original driver */
+@@ -46,25 +40,27 @@ enum rndis_device_state {
+ };
+
+ struct rndis_device {
+- struct NETVSC_DEVICE *NetDevice;
++ struct NETVSC_DEVICE *NetDevice;
+
+ enum rndis_device_state State;
+- u32 LinkStatus;
++ u32 LinkStatus;
+ atomic_t NewRequestId;
+
+ spinlock_t request_lock;
+- LIST_ENTRY RequestList;
++ LIST_ENTRY RequestList;
+
+- unsigned char HwMacAddr[HW_MACADDR_LEN];
++ unsigned char HwMacAddr[HW_MACADDR_LEN];
+ };
+
+-
+ struct rndis_request {
+- LIST_ENTRY ListEntry;
++ LIST_ENTRY ListEntry;
+ struct osd_waitevent *WaitEvent;
+
+- /* FIXME: We assumed a fixed size response here. If we do ever need to handle a bigger response, */
+- /* we can either define a max response message or add a response buffer variable above this field */
++ /*
++ * FIXME: We assumed a fixed size response here. If we do ever need to
++ * handle a bigger response, we can either define a max response
++ * message or add a response buffer variable above this field
++ */
+ struct rndis_message ResponseMessage;
+
+ /* Simplify allocation by having a netvsc packet inline */
+@@ -76,133 +72,41 @@ struct rndis_request {
+
+
+ struct rndis_filter_packet {
+- void *CompletionContext;
+- PFN_ON_SENDRECVCOMPLETION OnCompletion;
+-
++ void *CompletionContext;
++ PFN_ON_SENDRECVCOMPLETION OnCompletion;
+ struct rndis_message Message;
+ };
+
+
+-/* Internal routines */
++static int RndisFilterOnDeviceAdd(struct hv_device *Device,
++ void *AdditionalInfo);
+
+-static int
+-RndisFilterSendRequest(
+- struct rndis_device *Device,
+- struct rndis_request *Request
+- );
++static int RndisFilterOnDeviceRemove(struct hv_device *Device);
+
+-static void RndisFilterReceiveResponse(struct rndis_device *Device,
+- struct rndis_message *Response);
++static void RndisFilterOnCleanup(struct hv_driver *Driver);
+
+-static void RndisFilterReceiveIndicateStatus(struct rndis_device *Device,
+- struct rndis_message *Response);
++static int RndisFilterOnOpen(struct hv_device *Device);
+
+-static void RndisFilterReceiveData(struct rndis_device *Device,
+- struct rndis_message *Message,
+- struct hv_netvsc_packet *Packet);
++static int RndisFilterOnClose(struct hv_device *Device);
+
+-static int RndisFilterOnReceive(
+- struct hv_device *Device,
+- struct hv_netvsc_packet *Packet
+- );
+-
+-static int
+-RndisFilterQueryDevice(
+- struct rndis_device *Device,
+- u32 Oid,
+- void *Result,
+- u32 *ResultSize
+- );
+-
+-static inline int
+-RndisFilterQueryDeviceMac(
+- struct rndis_device *Device
+- );
+-
+-static inline int
+-RndisFilterQueryDeviceLinkStatus(
+- struct rndis_device *Device
+- );
+-
+-static int
+-RndisFilterSetPacketFilter(
+- struct rndis_device *Device,
+- u32 NewFilter
+- );
+-
+-static int
+-RndisFilterInitDevice(
+- struct rndis_device *Device
+- );
+-
+-static int
+-RndisFilterOpenDevice(
+- struct rndis_device *Device
+- );
+-
+-static int
+-RndisFilterCloseDevice(
+- struct rndis_device *Device
+- );
+-
+-static int
+-RndisFilterOnDeviceAdd(
+- struct hv_device *Device,
+- void *AdditionalInfo
+- );
+-
+-static int
+-RndisFilterOnDeviceRemove(
+- struct hv_device *Device
+- );
+-
+-static void
+-RndisFilterOnCleanup(
+- struct hv_driver *Driver
+- );
+-
+-static int
+-RndisFilterOnOpen(
+- struct hv_device *Device
+- );
+-
+-static int
+-RndisFilterOnClose(
+- struct hv_device *Device
+- );
+-
+-static int
+-RndisFilterOnSend(
+- struct hv_device *Device,
+- struct hv_netvsc_packet *Packet
+- );
+-
+-static void
+-RndisFilterOnSendCompletion(
+- void *Context
+- );
+-
+-static void
+-RndisFilterOnSendRequestCompletion(
+- void *Context
+- );
++static int RndisFilterOnSend(struct hv_device *Device,
++ struct hv_netvsc_packet *Packet);
+
++static void RndisFilterOnSendCompletion(void *Context);
+
+-/* Global var */
++static void RndisFilterOnSendRequestCompletion(void *Context);
+
+
+ /* The one and only */
+ static struct rndis_filter_driver_object gRndisFilter;
+
+-static inline struct rndis_device *GetRndisDevice(void)
++static struct rndis_device *GetRndisDevice(void)
+ {
+ struct rndis_device *device;
+
+ device = kzalloc(sizeof(struct rndis_device), GFP_KERNEL);
+ if (!device)
+- {
+ return NULL;
+- }
+
+ spin_lock_init(&device->request_lock);
+
+@@ -213,12 +117,9 @@ static inline struct rndis_device *GetRn
+ return device;
+ }
+
+-static inline void PutRndisDevice(struct rndis_device *Device)
+-{
+- kfree(Device);
+-}
+-
+-static inline struct rndis_request *GetRndisRequest(struct rndis_device *Device, u32 MessageType, u32 MessageLength)
++static struct rndis_request *GetRndisRequest(struct rndis_device *Device,
++ u32 MessageType,
++ u32 MessageLength)
+ {
+ struct rndis_request *request;
+ struct rndis_message *rndisMessage;
+@@ -227,13 +128,10 @@ static inline struct rndis_request *GetR
+
+ request = kzalloc(sizeof(struct rndis_request), GFP_KERNEL);
+ if (!request)
+- {
+ return NULL;
+- }
+
+ request->WaitEvent = osd_WaitEventCreate();
+- if (!request->WaitEvent)
+- {
++ if (!request->WaitEvent) {
+ kfree(request);
+ return NULL;
+ }
+@@ -242,8 +140,11 @@ static inline struct rndis_request *GetR
+ rndisMessage->NdisMessageType = MessageType;
+ rndisMessage->MessageLength = MessageLength;
+
+- /* Set the request id. This field is always after the rndis header for request/response packet types so */
+- /* we just used the SetRequest as a template */
++ /*
++ * Set the request id. This field is always after the rndis header for
++ * request/response packet types so we just used the SetRequest as a
++ * template
++ */
+ set = &rndisMessage->Message.SetRequest;
+ set->RequestId = atomic_inc_return(&Device->NewRequestId);
+
+@@ -255,7 +156,8 @@ static inline struct rndis_request *GetR
+ return request;
+ }
+
+-static inline void PutRndisRequest(struct rndis_device *Device, struct rndis_request *Request)
++static void PutRndisRequest(struct rndis_device *Device,
++ struct rndis_request *Request)
+ {
+ unsigned long flags;
+
+@@ -267,24 +169,29 @@ static inline void PutRndisRequest(struc
+ kfree(Request);
+ }
+
+-static inline void DumpRndisMessage(struct rndis_message *RndisMessage)
++static void DumpRndisMessage(struct rndis_message *RndisMessage)
+ {
+- switch (RndisMessage->NdisMessageType)
+- {
++ switch (RndisMessage->NdisMessageType) {
+ case REMOTE_NDIS_PACKET_MSG:
+- DPRINT_DBG(NETVSC, "REMOTE_NDIS_PACKET_MSG (len %u, data offset %u data len %u, # oob %u, oob offset %u, oob len %u, pkt offset %u, pkt len %u",
+- RndisMessage->MessageLength,
+- RndisMessage->Message.Packet.DataOffset,
+- RndisMessage->Message.Packet.DataLength,
+- RndisMessage->Message.Packet.NumOOBDataElements,
+- RndisMessage->Message.Packet.OOBDataOffset,
+- RndisMessage->Message.Packet.OOBDataLength,
+- RndisMessage->Message.Packet.PerPacketInfoOffset,
+- RndisMessage->Message.Packet.PerPacketInfoLength);
++ DPRINT_DBG(NETVSC, "REMOTE_NDIS_PACKET_MSG (len %u, "
++ "data offset %u data len %u, # oob %u, "
++ "oob offset %u, oob len %u, pkt offset %u, "
++ "pkt len %u",
++ RndisMessage->MessageLength,
++ RndisMessage->Message.Packet.DataOffset,
++ RndisMessage->Message.Packet.DataLength,
++ RndisMessage->Message.Packet.NumOOBDataElements,
++ RndisMessage->Message.Packet.OOBDataOffset,
++ RndisMessage->Message.Packet.OOBDataLength,
++ RndisMessage->Message.Packet.PerPacketInfoOffset,
++ RndisMessage->Message.Packet.PerPacketInfoLength);
+ break;
+
+ case REMOTE_NDIS_INITIALIZE_CMPLT:
+- DPRINT_DBG(NETVSC, "REMOTE_NDIS_INITIALIZE_CMPLT (len %u, id 0x%x, status 0x%x, major %d, minor %d, device flags %d, max xfer size 0x%x, max pkts %u, pkt aligned %u)",
++ DPRINT_DBG(NETVSC, "REMOTE_NDIS_INITIALIZE_CMPLT "
++ "(len %u, id 0x%x, status 0x%x, major %d, minor %d, "
++ "device flags %d, max xfer size 0x%x, max pkts %u, "
++ "pkt aligned %u)",
+ RndisMessage->MessageLength,
+ RndisMessage->Message.InitializeComplete.RequestId,
+ RndisMessage->Message.InitializeComplete.Status,
+@@ -297,7 +204,9 @@ static inline void DumpRndisMessage(stru
+ break;
+
+ case REMOTE_NDIS_QUERY_CMPLT:
+- DPRINT_DBG(NETVSC, "REMOTE_NDIS_QUERY_CMPLT (len %u, id 0x%x, status 0x%x, buf len %u, buf offset %u)",
++ DPRINT_DBG(NETVSC, "REMOTE_NDIS_QUERY_CMPLT "
++ "(len %u, id 0x%x, status 0x%x, buf len %u, "
++ "buf offset %u)",
+ RndisMessage->MessageLength,
+ RndisMessage->Message.QueryComplete.RequestId,
+ RndisMessage->Message.QueryComplete.Status,
+@@ -306,14 +215,16 @@ static inline void DumpRndisMessage(stru
+ break;
+
+ case REMOTE_NDIS_SET_CMPLT:
+- DPRINT_DBG(NETVSC, "REMOTE_NDIS_SET_CMPLT (len %u, id 0x%x, status 0x%x)",
++ DPRINT_DBG(NETVSC,
++ "REMOTE_NDIS_SET_CMPLT (len %u, id 0x%x, status 0x%x)",
+ RndisMessage->MessageLength,
+ RndisMessage->Message.SetComplete.RequestId,
+ RndisMessage->Message.SetComplete.Status);
+ break;
+
+ case REMOTE_NDIS_INDICATE_STATUS_MSG:
+- DPRINT_DBG(NETVSC, "REMOTE_NDIS_INDICATE_STATUS_MSG (len %u, status 0x%x, buf len %u, buf offset %u)",
++ DPRINT_DBG(NETVSC, "REMOTE_NDIS_INDICATE_STATUS_MSG "
++ "(len %u, status 0x%x, buf len %u, buf offset %u)",
+ RndisMessage->MessageLength,
+ RndisMessage->Message.IndicateStatus.Status,
+ RndisMessage->Message.IndicateStatus.StatusBufferLength,
+@@ -328,13 +239,10 @@ static inline void DumpRndisMessage(stru
+ }
+ }
+
+-static int
+-RndisFilterSendRequest(
+- struct rndis_device *Device,
+- struct rndis_request *Request
+- )
++static int RndisFilterSendRequest(struct rndis_device *Device,
++ struct rndis_request *Request)
+ {
+- int ret=0;
++ int ret;
+ struct hv_netvsc_packet *packet;
+
+ DPRINT_ENTER(NETVSC);
+@@ -346,12 +254,15 @@ RndisFilterSendRequest(
+ packet->TotalDataBufferLength = Request->RequestMessage.MessageLength;
+ packet->PageBufferCount = 1;
+
+- packet->PageBuffers[0].Pfn = virt_to_phys(&Request->RequestMessage) >> PAGE_SHIFT;
++ packet->PageBuffers[0].Pfn = virt_to_phys(&Request->RequestMessage) >>
++ PAGE_SHIFT;
+ packet->PageBuffers[0].Length = Request->RequestMessage.MessageLength;
+- packet->PageBuffers[0].Offset = (unsigned long)&Request->RequestMessage & (PAGE_SIZE -1);
++ packet->PageBuffers[0].Offset =
++ (unsigned long)&Request->RequestMessage & (PAGE_SIZE - 1);
+
+ packet->Completion.Send.SendCompletionContext = Request;/* packet; */
+- packet->Completion.Send.OnSendCompletion = RndisFilterOnSendRequestCompletion;
++ packet->Completion.Send.OnSendCompletion =
++ RndisFilterOnSendRequestCompletion;
+ packet->Completion.Send.SendCompletionTid = (unsigned long)Device;
+
+ ret = gRndisFilter.InnerDriver.OnSend(Device->NetDevice->Device, packet);
+@@ -359,7 +270,6 @@ RndisFilterSendRequest(
+ return ret;
+ }
+
+-
+ static void RndisFilterReceiveResponse(struct rndis_device *Device,
+ struct rndis_message *Response)
+ {
+@@ -372,15 +282,22 @@ static void RndisFilterReceiveResponse(s
+ DPRINT_ENTER(NETVSC);
+
+ spin_lock_irqsave(&Device->request_lock, flags);
+- ITERATE_LIST_ENTRIES(anchor, curr, &Device->RequestList)
+- {
+- request = CONTAINING_RECORD(curr, struct rndis_request, ListEntry);
+-
+- /* All request/response message contains RequestId as the 1st field */
+- if (request->RequestMessage.Message.InitializeRequest.RequestId == Response->Message.InitializeComplete.RequestId)
+- {
+- DPRINT_DBG(NETVSC, "found rndis request for this response (id 0x%x req type 0x%x res type 0x%x)",
+- request->RequestMessage.Message.InitializeRequest.RequestId, request->RequestMessage.NdisMessageType, Response->NdisMessageType);
++ ITERATE_LIST_ENTRIES(anchor, curr, &Device->RequestList) {
++ request = CONTAINING_RECORD(curr, struct rndis_request,
++ ListEntry);
++
++ /*
++ * All request/response message contains RequestId as the 1st
++ * field
++ */
++ if (request->RequestMessage.Message.InitializeRequest.RequestId
++ == Response->Message.InitializeComplete.RequestId) {
++ DPRINT_DBG(NETVSC, "found rndis request for "
++ "this response (id 0x%x req type 0x%x res "
++ "type 0x%x)",
++ request->RequestMessage.Message.InitializeRequest.RequestId,
++ request->RequestMessage.NdisMessageType,
++ Response->NdisMessageType);
+
+ found = true;
+ break;
+@@ -388,32 +305,31 @@ static void RndisFilterReceiveResponse(s
+ }
+ spin_unlock_irqrestore(&Device->request_lock, flags);
+
+- if (found)
+- {
+- if (Response->MessageLength <= sizeof(struct rndis_message))
+- {
+- memcpy(&request->ResponseMessage, Response, Response->MessageLength);
+- }
+- else
+- {
+- DPRINT_ERR(NETVSC, "rndis response buffer overflow detected (size %u max %zu)", Response->MessageLength, sizeof(struct rndis_filter_packet));
+-
+- if (Response->NdisMessageType == REMOTE_NDIS_RESET_CMPLT) /* does not have a request id field */
+- {
++ if (found) {
++ if (Response->MessageLength <= sizeof(struct rndis_message)) {
++ memcpy(&request->ResponseMessage, Response,
++ Response->MessageLength);
++ } else {
++ DPRINT_ERR(NETVSC, "rndis response buffer overflow "
++ "detected (size %u max %zu)",
++ Response->MessageLength,
++ sizeof(struct rndis_filter_packet));
++
++ if (Response->NdisMessageType ==
++ REMOTE_NDIS_RESET_CMPLT) {
++ /* does not have a request id field */
+ request->ResponseMessage.Message.ResetComplete.Status = STATUS_BUFFER_OVERFLOW;
+- }
+- else
+- {
++ } else {
+ request->ResponseMessage.Message.InitializeComplete.Status = STATUS_BUFFER_OVERFLOW;
+ }
+ }
+
+ osd_WaitEventSet(request->WaitEvent);
+- }
+- else
+- {
+- DPRINT_ERR(NETVSC, "no rndis request found for this response (id 0x%x res type 0x%x)",
+- Response->Message.InitializeComplete.RequestId, Response->NdisMessageType);
++ } else {
++ DPRINT_ERR(NETVSC, "no rndis request found for this response "
++ "(id 0x%x res type 0x%x)",
++ Response->Message.InitializeComplete.RequestId,
++ Response->NdisMessageType);
+ }
+
+ DPRINT_EXIT(NETVSC);
+@@ -422,19 +338,17 @@ static void RndisFilterReceiveResponse(s
+ static void RndisFilterReceiveIndicateStatus(struct rndis_device *Device,
+ struct rndis_message *Response)
+ {
+- struct rndis_indicate_status *indicate = &Response->Message.IndicateStatus;
++ struct rndis_indicate_status *indicate =
++ &Response->Message.IndicateStatus;
+
+- if (indicate->Status == RNDIS_STATUS_MEDIA_CONNECT)
+- {
++ if (indicate->Status == RNDIS_STATUS_MEDIA_CONNECT) {
+ gRndisFilter.InnerDriver.OnLinkStatusChanged(Device->NetDevice->Device, 1);
+- }
+- else if (indicate->Status == RNDIS_STATUS_MEDIA_DISCONNECT)
+- {
++ } else if (indicate->Status == RNDIS_STATUS_MEDIA_DISCONNECT) {
+ gRndisFilter.InnerDriver.OnLinkStatusChanged(Device->NetDevice->Device, 0);
+- }
+- else
+- {
+- /* TODO: */
++ } else {
++ /*
++ * TODO:
++ */
+ }
+ }
+
+@@ -448,12 +362,15 @@ static void RndisFilterReceiveData(struc
+ DPRINT_ENTER(NETVSC);
+
+ /* empty ethernet frame ?? */
+- ASSERT(Packet->PageBuffers[0].Length > RNDIS_MESSAGE_SIZE(struct rndis_packet));
++ ASSERT(Packet->PageBuffers[0].Length >
++ RNDIS_MESSAGE_SIZE(struct rndis_packet));
+
+ rndisPacket = &Message->Message.Packet;
+
+- /* FIXME: Handle multiple rndis pkt msgs that maybe enclosed in this */
+- /* netvsc packet (ie TotalDataBufferLength != MessageLength) */
++ /*
++ * FIXME: Handle multiple rndis pkt msgs that maybe enclosed in this
++ * netvsc packet (ie TotalDataBufferLength != MessageLength)
++ */
+
+ /* Remove the rndis header and pass it back up the stack */
+ dataOffset = RNDIS_HEADER_SIZE + rndisPacket->DataOffset;
+@@ -464,18 +381,16 @@ static void RndisFilterReceiveData(struc
+
+ Packet->IsDataPacket = true;
+
+- gRndisFilter.InnerDriver.OnReceiveCallback(Device->NetDevice->Device, Packet);
++ gRndisFilter.InnerDriver.OnReceiveCallback(Device->NetDevice->Device,
++ Packet);
+
+ DPRINT_EXIT(NETVSC);
+ }
+
+-static int
+-RndisFilterOnReceive(
+- struct hv_device *Device,
+- struct hv_netvsc_packet *Packet
+- )
++static int RndisFilterOnReceive(struct hv_device *Device,
++ struct hv_netvsc_packet *Packet)
+ {
+- struct NETVSC_DEVICE *netDevice = (struct NETVSC_DEVICE*)Device->Extension;
++ struct NETVSC_DEVICE *netDevice = Device->Extension;
+ struct rndis_device *rndisDevice;
+ struct rndis_message rndisMessage;
+ struct rndis_message *rndisHeader;
+@@ -484,74 +399,87 @@ RndisFilterOnReceive(
+
+ ASSERT(netDevice);
+ /* Make sure the rndis device state is initialized */
+- if (!netDevice->Extension)
+- {
+- DPRINT_ERR(NETVSC, "got rndis message but no rndis device...dropping this message!");
++ if (!netDevice->Extension) {
++ DPRINT_ERR(NETVSC, "got rndis message but no rndis device..."
++ "dropping this message!");
+ DPRINT_EXIT(NETVSC);
+ return -1;
+ }
+
+- rndisDevice = (struct rndis_device*)netDevice->Extension;
+- if (rndisDevice->State == RNDIS_DEV_UNINITIALIZED)
+- {
+- DPRINT_ERR(NETVSC, "got rndis message but rndis device uninitialized...dropping this message!");
++ rndisDevice = (struct rndis_device *)netDevice->Extension;
++ if (rndisDevice->State == RNDIS_DEV_UNINITIALIZED) {
++ DPRINT_ERR(NETVSC, "got rndis message but rndis device "
++ "uninitialized...dropping this message!");
+ DPRINT_EXIT(NETVSC);
+ return -1;
+ }
+
+- rndisHeader = (struct rndis_message *)kmap_atomic(pfn_to_page(Packet->PageBuffers[0].Pfn), KM_IRQ0);
++ rndisHeader = (struct rndis_message *)kmap_atomic(
++ pfn_to_page(Packet->PageBuffers[0].Pfn), KM_IRQ0);
+
+- rndisHeader = (void*)((unsigned long)rndisHeader + Packet->PageBuffers[0].Offset);
++ rndisHeader = (void *)((unsigned long)rndisHeader +
++ Packet->PageBuffers[0].Offset);
+
+ /* Make sure we got a valid rndis message */
+- /* FIXME: There seems to be a bug in set completion msg where its MessageLength is 16 bytes but */
+- /* the ByteCount field in the xfer page range shows 52 bytes */
++ /*
++ * FIXME: There seems to be a bug in set completion msg where its
++ * MessageLength is 16 bytes but the ByteCount field in the xfer page
++ * range shows 52 bytes
++ * */
+ #if 0
+- if ( Packet->TotalDataBufferLength != rndisHeader->MessageLength )
+- {
+- kunmap_atomic(rndisHeader - Packet->PageBuffers[0].Offset, KM_IRQ0);
+-
+- DPRINT_ERR(NETVSC, "invalid rndis message? (expected %u bytes got %u)...dropping this message!",
+- rndisHeader->MessageLength, Packet->TotalDataBufferLength);
++ if (Packet->TotalDataBufferLength != rndisHeader->MessageLength) {
++ kunmap_atomic(rndisHeader - Packet->PageBuffers[0].Offset,
++ KM_IRQ0);
++
++ DPRINT_ERR(NETVSC, "invalid rndis message? (expected %u "
++ "bytes got %u)...dropping this message!",
++ rndisHeader->MessageLength,
++ Packet->TotalDataBufferLength);
+ DPRINT_EXIT(NETVSC);
+ return -1;
+ }
+ #endif
+
+- if ((rndisHeader->NdisMessageType != REMOTE_NDIS_PACKET_MSG) && (rndisHeader->MessageLength > sizeof(struct rndis_message)))
+- {
+- DPRINT_ERR(NETVSC, "incoming rndis message buffer overflow detected (got %u, max %zu)...marking it an error!",
+- rndisHeader->MessageLength, sizeof(struct rndis_message));
++ if ((rndisHeader->NdisMessageType != REMOTE_NDIS_PACKET_MSG) &&
++ (rndisHeader->MessageLength > sizeof(struct rndis_message))) {
++ DPRINT_ERR(NETVSC, "incoming rndis message buffer overflow "
++ "detected (got %u, max %zu)...marking it an error!",
++ rndisHeader->MessageLength,
++ sizeof(struct rndis_message));
+ }
+
+- memcpy(&rndisMessage, rndisHeader, (rndisHeader->MessageLength > sizeof(struct rndis_message))?sizeof(struct rndis_message):rndisHeader->MessageLength);
++ memcpy(&rndisMessage, rndisHeader,
++ (rndisHeader->MessageLength > sizeof(struct rndis_message)) ?
++ sizeof(struct rndis_message) :
++ rndisHeader->MessageLength);
+
+ kunmap_atomic(rndisHeader - Packet->PageBuffers[0].Offset, KM_IRQ0);
+
+ DumpRndisMessage(&rndisMessage);
+
+- switch (rndisMessage.NdisMessageType)
+- {
+- /* data msg */
++ switch (rndisMessage.NdisMessageType) {
+ case REMOTE_NDIS_PACKET_MSG:
++ /* data msg */
+ RndisFilterReceiveData(rndisDevice, &rndisMessage, Packet);
+ break;
+
+- /* completion msgs */
+ case REMOTE_NDIS_INITIALIZE_CMPLT:
+ case REMOTE_NDIS_QUERY_CMPLT:
+ case REMOTE_NDIS_SET_CMPLT:
+ /* case REMOTE_NDIS_RESET_CMPLT: */
+ /* case REMOTE_NDIS_KEEPALIVE_CMPLT: */
++ /* completion msgs */
+ RndisFilterReceiveResponse(rndisDevice, &rndisMessage);
+ break;
+
+- /* notification msgs */
+ case REMOTE_NDIS_INDICATE_STATUS_MSG:
++ /* notification msgs */
+ RndisFilterReceiveIndicateStatus(rndisDevice, &rndisMessage);
+ break;
+ default:
+- DPRINT_ERR(NETVSC, "unhandled rndis message (type %u len %u)", rndisMessage.NdisMessageType, rndisMessage.MessageLength);
++ DPRINT_ERR(NETVSC, "unhandled rndis message (type %u len %u)",
++ rndisMessage.NdisMessageType,
++ rndisMessage.MessageLength);
+ break;
+ }
+
+@@ -559,29 +487,23 @@ RndisFilterOnReceive(
+ return 0;
+ }
+
+-
+-static int
+-RndisFilterQueryDevice(
+- struct rndis_device *Device,
+- u32 Oid,
+- void *Result,
+- u32 *ResultSize
+- )
++static int RndisFilterQueryDevice(struct rndis_device *Device, u32 Oid,
++ void *Result, u32 *ResultSize)
+ {
+ struct rndis_request *request;
+ u32 inresultSize = *ResultSize;
+ struct rndis_query_request *query;
+ struct rndis_query_complete *queryComplete;
+- int ret=0;
++ int ret = 0;
+
+ DPRINT_ENTER(NETVSC);
+
+ ASSERT(Result);
+
+ *ResultSize = 0;
+- request = GetRndisRequest(Device, REMOTE_NDIS_QUERY_MSG, RNDIS_MESSAGE_SIZE(struct rndis_query_request));
+- if (!request)
+- {
++ request = GetRndisRequest(Device, REMOTE_NDIS_QUERY_MSG,
++ RNDIS_MESSAGE_SIZE(struct rndis_query_request));
++ if (!request) {
+ ret = -1;
+ goto Cleanup;
+ }
+@@ -595,62 +517,53 @@ RndisFilterQueryDevice(
+
+ ret = RndisFilterSendRequest(Device, request);
+ if (ret != 0)
+- {
+ goto Cleanup;
+- }
+
+ osd_WaitEventWait(request->WaitEvent);
+
+ /* Copy the response back */
+ queryComplete = &request->ResponseMessage.Message.QueryComplete;
+
+- if (queryComplete->InformationBufferLength > inresultSize)
+- {
++ if (queryComplete->InformationBufferLength > inresultSize) {
+ ret = -1;
+ goto Cleanup;
+ }
+
+ memcpy(Result,
+- (void*)((unsigned long)queryComplete + queryComplete->InformationBufferOffset),
+- queryComplete->InformationBufferLength);
++ (void *)((unsigned long)queryComplete +
++ queryComplete->InformationBufferOffset),
++ queryComplete->InformationBufferLength);
+
+ *ResultSize = queryComplete->InformationBufferLength;
+
+ Cleanup:
+ if (request)
+- {
+ PutRndisRequest(Device, request);
+- }
+ DPRINT_EXIT(NETVSC);
+
+ return ret;
+ }
+
+-static inline int RndisFilterQueryDeviceMac(struct rndis_device *Device)
++static int RndisFilterQueryDeviceMac(struct rndis_device *Device)
+ {
+- u32 size=HW_MACADDR_LEN;
++ u32 size = HW_MACADDR_LEN;
+
+ return RndisFilterQueryDevice(Device,
+- RNDIS_OID_802_3_PERMANENT_ADDRESS,
+- Device->HwMacAddr,
+- &size);
++ RNDIS_OID_802_3_PERMANENT_ADDRESS,
++ Device->HwMacAddr, &size);
+ }
+
+-static inline int RndisFilterQueryDeviceLinkStatus(struct rndis_device *Device)
++static int RndisFilterQueryDeviceLinkStatus(struct rndis_device *Device)
+ {
+- u32 size=sizeof(u32);
++ u32 size = sizeof(u32);
+
+ return RndisFilterQueryDevice(Device,
+- RNDIS_OID_GEN_MEDIA_CONNECT_STATUS,
+- &Device->LinkStatus,
+- &size);
++ RNDIS_OID_GEN_MEDIA_CONNECT_STATUS,
++ &Device->LinkStatus, &size);
+ }
+
+-static int
+-RndisFilterSetPacketFilter(
+- struct rndis_device *Device,
+- u32 NewFilter
+- )
++static int RndisFilterSetPacketFilter(struct rndis_device *Device,
++ u32 NewFilter)
+ {
+ struct rndis_request *request;
+ struct rndis_set_request *set;
+@@ -660,11 +573,13 @@ RndisFilterSetPacketFilter(
+
+ DPRINT_ENTER(NETVSC);
+
+- ASSERT(RNDIS_MESSAGE_SIZE(struct rndis_set_request) + sizeof(u32) <= sizeof(struct rndis_message));
++ ASSERT(RNDIS_MESSAGE_SIZE(struct rndis_set_request) + sizeof(u32) <=
++ sizeof(struct rndis_message));
+
+- request = GetRndisRequest(Device, REMOTE_NDIS_SET_MSG, RNDIS_MESSAGE_SIZE(struct rndis_set_request) + sizeof(u32));
+- if (!request)
+- {
++ request = GetRndisRequest(Device, REMOTE_NDIS_SET_MSG,
++ RNDIS_MESSAGE_SIZE(struct rndis_set_request) +
++ sizeof(u32));
++ if (!request) {
+ ret = -1;
+ goto Cleanup;
+ }
+@@ -675,37 +590,32 @@ RndisFilterSetPacketFilter(
+ set->InformationBufferLength = sizeof(u32);
+ set->InformationBufferOffset = sizeof(struct rndis_set_request);
+
+- memcpy((void*)(unsigned long)set + sizeof(struct rndis_set_request), &NewFilter, sizeof(u32));
++ memcpy((void *)(unsigned long)set + sizeof(struct rndis_set_request),
++ &NewFilter, sizeof(u32));
+
+ ret = RndisFilterSendRequest(Device, request);
+ if (ret != 0)
+- {
+ goto Cleanup;
+- }
+
+ ret = osd_WaitEventWaitEx(request->WaitEvent, 2000/*2sec*/);
+- if (!ret)
+- {
++ if (!ret) {
+ ret = -1;
+ DPRINT_ERR(NETVSC, "timeout before we got a set response...");
+- /* We cant deallocate the request since we may still receive a send completion for it. */
++ /*
++ * We cant deallocate the request since we may still receive a
++ * send completion for it.
++ */
+ goto Exit;
+- }
+- else
+- {
++ } else {
+ if (ret > 0)
+- {
+ ret = 0;
+- }
+ setComplete = &request->ResponseMessage.Message.SetComplete;
+ status = setComplete->Status;
+ }
+
+ Cleanup:
+ if (request)
+- {
+ PutRndisRequest(Device, request);
+- }
+ Exit:
+ DPRINT_EXIT(NETVSC);
+
+@@ -716,7 +626,8 @@ int RndisFilterInit(struct netvsc_driver
+ {
+ DPRINT_ENTER(NETVSC);
+
+- DPRINT_DBG(NETVSC, "sizeof(struct rndis_filter_packet) == %zd", sizeof(struct rndis_filter_packet));
++ DPRINT_DBG(NETVSC, "sizeof(struct rndis_filter_packet) == %zd",
++ sizeof(struct rndis_filter_packet));
+
+ Driver->RequestExtSize = sizeof(struct rndis_filter_packet);
+ Driver->AdditionalRequestPageBufferCount = 1; /* For rndis header */
+@@ -732,14 +643,16 @@ int RndisFilterInit(struct netvsc_driver
+
+ /* Save the original dispatch handlers before we override it */
+ gRndisFilter.InnerDriver.Base.OnDeviceAdd = Driver->Base.OnDeviceAdd;
+- gRndisFilter.InnerDriver.Base.OnDeviceRemove = Driver->Base.OnDeviceRemove;
++ gRndisFilter.InnerDriver.Base.OnDeviceRemove =
++ Driver->Base.OnDeviceRemove;
+ gRndisFilter.InnerDriver.Base.OnCleanup = Driver->Base.OnCleanup;
+
+ ASSERT(Driver->OnSend);
+ ASSERT(Driver->OnReceiveCallback);
+ gRndisFilter.InnerDriver.OnSend = Driver->OnSend;
+ gRndisFilter.InnerDriver.OnReceiveCallback = Driver->OnReceiveCallback;
+- gRndisFilter.InnerDriver.OnLinkStatusChanged = Driver->OnLinkStatusChanged;
++ gRndisFilter.InnerDriver.OnLinkStatusChanged =
++ Driver->OnLinkStatusChanged;
+
+ /* Override */
+ Driver->Base.OnDeviceAdd = RndisFilterOnDeviceAdd;
+@@ -766,9 +679,9 @@ static int RndisFilterInitDevice(struct
+
+ DPRINT_ENTER(NETVSC);
+
+- request = GetRndisRequest(Device, REMOTE_NDIS_INITIALIZE_MSG, RNDIS_MESSAGE_SIZE(struct rndis_initialize_request));
+- if (!request)
+- {
++ request = GetRndisRequest(Device, REMOTE_NDIS_INITIALIZE_MSG,
++ RNDIS_MESSAGE_SIZE(struct rndis_initialize_request));
++ if (!request) {
+ ret = -1;
+ goto Cleanup;
+ }
+@@ -777,13 +690,13 @@ static int RndisFilterInitDevice(struct
+ init = &request->RequestMessage.Message.InitializeRequest;
+ init->MajorVersion = RNDIS_MAJOR_VERSION;
+ init->MinorVersion = RNDIS_MINOR_VERSION;
+- init->MaxTransferSize = 2048; /* FIXME: Use 1536 - rounded ethernet frame size */
++ /* FIXME: Use 1536 - rounded ethernet frame size */
++ init->MaxTransferSize = 2048;
+
+ Device->State = RNDIS_DEV_INITIALIZING;
+
+ ret = RndisFilterSendRequest(Device, request);
+- if (ret != 0)
+- {
++ if (ret != 0) {
+ Device->State = RNDIS_DEV_UNINITIALIZED;
+ goto Cleanup;
+ }
+@@ -792,22 +705,17 @@ static int RndisFilterInitDevice(struct
+
+ initComplete = &request->ResponseMessage.Message.InitializeComplete;
+ status = initComplete->Status;
+- if (status == RNDIS_STATUS_SUCCESS)
+- {
++ if (status == RNDIS_STATUS_SUCCESS) {
+ Device->State = RNDIS_DEV_INITIALIZED;
+ ret = 0;
+- }
+- else
+- {
++ } else {
+ Device->State = RNDIS_DEV_UNINITIALIZED;
+ ret = -1;
+ }
+
+ Cleanup:
+ if (request)
+- {
+ PutRndisRequest(Device, request);
+- }
+ DPRINT_EXIT(NETVSC);
+
+ return ret;
+@@ -821,11 +729,10 @@ static void RndisFilterHaltDevice(struct
+ DPRINT_ENTER(NETVSC);
+
+ /* Attempt to do a rndis device halt */
+- request = GetRndisRequest(Device, REMOTE_NDIS_HALT_MSG, RNDIS_MESSAGE_SIZE(struct rndis_halt_request));
++ request = GetRndisRequest(Device, REMOTE_NDIS_HALT_MSG,
++ RNDIS_MESSAGE_SIZE(struct rndis_halt_request));
+ if (!request)
+- {
+ goto Cleanup;
+- }
+
+ /* Setup the rndis set */
+ halt = &request->RequestMessage.Message.HaltRequest;
+@@ -838,28 +745,25 @@ static void RndisFilterHaltDevice(struct
+
+ Cleanup:
+ if (request)
+- {
+ PutRndisRequest(Device, request);
+- }
+ DPRINT_EXIT(NETVSC);
+ return;
+ }
+
+-
+ static int RndisFilterOpenDevice(struct rndis_device *Device)
+ {
+- int ret=0;
++ int ret;
+
+ DPRINT_ENTER(NETVSC);
+
+ if (Device->State != RNDIS_DEV_INITIALIZED)
+ return 0;
+
+- ret = RndisFilterSetPacketFilter(Device, NDIS_PACKET_TYPE_BROADCAST|NDIS_PACKET_TYPE_DIRECTED);
++ ret = RndisFilterSetPacketFilter(Device,
++ NDIS_PACKET_TYPE_BROADCAST |
++ NDIS_PACKET_TYPE_DIRECTED);
+ if (ret == 0)
+- {
+ Device->State = RNDIS_DEV_DATAINITIALIZED;
+- }
+
+ DPRINT_EXIT(NETVSC);
+ return ret;
+@@ -876,53 +780,46 @@ static int RndisFilterCloseDevice(struct
+
+ ret = RndisFilterSetPacketFilter(Device, 0);
+ if (ret == 0)
+- {
+ Device->State = RNDIS_DEV_INITIALIZED;
+- }
+
+ DPRINT_EXIT(NETVSC);
+
+ return ret;
+ }
+
+-
+-static int
+-RndisFilterOnDeviceAdd(
+- struct hv_device *Device,
+- void *AdditionalInfo
+- )
++static int RndisFilterOnDeviceAdd(struct hv_device *Device,
++ void *AdditionalInfo)
+ {
+ int ret;
+ struct NETVSC_DEVICE *netDevice;
+ struct rndis_device *rndisDevice;
+- struct netvsc_device_info *deviceInfo = (struct netvsc_device_info *)AdditionalInfo;
++ struct netvsc_device_info *deviceInfo = AdditionalInfo;
+
+ DPRINT_ENTER(NETVSC);
+
+ rndisDevice = GetRndisDevice();
+- if (!rndisDevice)
+- {
++ if (!rndisDevice) {
+ DPRINT_EXIT(NETVSC);
+ return -1;
+ }
+
+ DPRINT_DBG(NETVSC, "rndis device object allocated - %p", rndisDevice);
+
+- /* Let the inner driver handle this first to create the netvsc channel */
+- /* NOTE! Once the channel is created, we may get a receive callback */
+- /* (RndisFilterOnReceive()) before this call is completed */
++ /*
++ * Let the inner driver handle this first to create the netvsc channel
++ * NOTE! Once the channel is created, we may get a receive callback
++ * (RndisFilterOnReceive()) before this call is completed
++ */
+ ret = gRndisFilter.InnerDriver.Base.OnDeviceAdd(Device, AdditionalInfo);
+- if (ret != 0)
+- {
+- PutRndisDevice(rndisDevice);
++ if (ret != 0) {
++ kfree(rndisDevice);
+ DPRINT_EXIT(NETVSC);
+ return ret;
+ }
+
+
+ /* Initialize the rndis device */
+-
+- netDevice = (struct NETVSC_DEVICE*)Device->Extension;
++ netDevice = Device->Extension;
+ ASSERT(netDevice);
+ ASSERT(netDevice->Device);
+
+@@ -931,54 +828,54 @@ RndisFilterOnDeviceAdd(
+
+ /* Send the rndis initialization message */
+ ret = RndisFilterInitDevice(rndisDevice);
+- if (ret != 0)
+- {
+- /* TODO: If rndis init failed, we will need to shut down the channel */
++ if (ret != 0) {
++ /*
++ * TODO: If rndis init failed, we will need to shut down the
++ * channel
++ */
+ }
+
+ /* Get the mac address */
+ ret = RndisFilterQueryDeviceMac(rndisDevice);
+- if (ret != 0)
+- {
+- /* TODO: shutdown rndis device and the channel */
++ if (ret != 0) {
++ /*
++ * TODO: shutdown rndis device and the channel
++ */
+ }
+
+ DPRINT_INFO(NETVSC, "Device 0x%p mac addr %02x%02x%02x%02x%02x%02x",
+- rndisDevice,
+- rndisDevice->HwMacAddr[0],
+- rndisDevice->HwMacAddr[1],
+- rndisDevice->HwMacAddr[2],
+- rndisDevice->HwMacAddr[3],
+- rndisDevice->HwMacAddr[4],
+- rndisDevice->HwMacAddr[5]);
++ rndisDevice,
++ rndisDevice->HwMacAddr[0],
++ rndisDevice->HwMacAddr[1],
++ rndisDevice->HwMacAddr[2],
++ rndisDevice->HwMacAddr[3],
++ rndisDevice->HwMacAddr[4],
++ rndisDevice->HwMacAddr[5]);
+
+ memcpy(deviceInfo->MacAddr, rndisDevice->HwMacAddr, HW_MACADDR_LEN);
+
+ RndisFilterQueryDeviceLinkStatus(rndisDevice);
+
+ deviceInfo->LinkState = rndisDevice->LinkStatus;
+- DPRINT_INFO(NETVSC, "Device 0x%p link state %s", rndisDevice, ((deviceInfo->LinkState)?("down"):("up")));
++ DPRINT_INFO(NETVSC, "Device 0x%p link state %s", rndisDevice,
++ ((deviceInfo->LinkState) ? ("down") : ("up")));
+
+ DPRINT_EXIT(NETVSC);
+
+ return ret;
+ }
+
+-
+-static int
+-RndisFilterOnDeviceRemove(
+- struct hv_device *Device
+- )
++static int RndisFilterOnDeviceRemove(struct hv_device *Device)
+ {
+- struct NETVSC_DEVICE *netDevice = (struct NETVSC_DEVICE*)Device->Extension;
+- struct rndis_device *rndisDevice = (struct rndis_device *)netDevice->Extension;
++ struct NETVSC_DEVICE *netDevice = Device->Extension;
++ struct rndis_device *rndisDevice = netDevice->Extension;
+
+ DPRINT_ENTER(NETVSC);
+
+ /* Halt and release the rndis device */
+ RndisFilterHaltDevice(rndisDevice);
+
+- PutRndisDevice(rndisDevice);
++ kfree(rndisDevice);
+ netDevice->Extension = NULL;
+
+ /* Pass control to inner driver to remove the device */
+@@ -989,61 +886,47 @@ RndisFilterOnDeviceRemove(
+ return 0;
+ }
+
+-
+-static void
+-RndisFilterOnCleanup(
+- struct hv_driver *Driver
+- )
++static void RndisFilterOnCleanup(struct hv_driver *Driver)
+ {
+ DPRINT_ENTER(NETVSC);
+
+ DPRINT_EXIT(NETVSC);
+ }
+
+-static int
+-RndisFilterOnOpen(
+- struct hv_device *Device
+- )
++static int RndisFilterOnOpen(struct hv_device *Device)
+ {
+ int ret;
+- struct NETVSC_DEVICE *netDevice = (struct NETVSC_DEVICE*)Device->Extension;
++ struct NETVSC_DEVICE *netDevice = Device->Extension;
+
+ DPRINT_ENTER(NETVSC);
+
+ ASSERT(netDevice);
+- ret = RndisFilterOpenDevice((struct rndis_device *)netDevice->Extension);
++ ret = RndisFilterOpenDevice(netDevice->Extension);
+
+ DPRINT_EXIT(NETVSC);
+
+ return ret;
+ }
+
+-static int
+-RndisFilterOnClose(
+- struct hv_device *Device
+- )
++static int RndisFilterOnClose(struct hv_device *Device)
+ {
+ int ret;
+- struct NETVSC_DEVICE *netDevice = (struct NETVSC_DEVICE*)Device->Extension;
++ struct NETVSC_DEVICE *netDevice = Device->Extension;
+
+ DPRINT_ENTER(NETVSC);
+
+ ASSERT(netDevice);
+- ret = RndisFilterCloseDevice((struct rndis_device *)netDevice->Extension);
++ ret = RndisFilterCloseDevice(netDevice->Extension);
+
+ DPRINT_EXIT(NETVSC);
+
+ return ret;
+ }
+
+-
+-static int
+-RndisFilterOnSend(
+- struct hv_device *Device,
+- struct hv_netvsc_packet *Packet
+- )
++static int RndisFilterOnSend(struct hv_device *Device,
++ struct hv_netvsc_packet *Packet)
+ {
+- int ret=0;
++ int ret;
+ struct rndis_filter_packet *filterPacket;
+ struct rndis_message *rndisMessage;
+ struct rndis_packet *rndisPacket;
+@@ -1061,31 +944,38 @@ RndisFilterOnSend(
+ rndisMessageSize = RNDIS_MESSAGE_SIZE(struct rndis_packet);
+
+ rndisMessage->NdisMessageType = REMOTE_NDIS_PACKET_MSG;
+- rndisMessage->MessageLength = Packet->TotalDataBufferLength + rndisMessageSize;
++ rndisMessage->MessageLength = Packet->TotalDataBufferLength +
++ rndisMessageSize;
+
+ rndisPacket = &rndisMessage->Message.Packet;
+ rndisPacket->DataOffset = sizeof(struct rndis_packet);
+ rndisPacket->DataLength = Packet->TotalDataBufferLength;
+
+ Packet->IsDataPacket = true;
+- Packet->PageBuffers[0].Pfn = virt_to_phys(rndisMessage) >> PAGE_SHIFT;
+- Packet->PageBuffers[0].Offset = (unsigned long)rndisMessage & (PAGE_SIZE-1);
+- Packet->PageBuffers[0].Length = rndisMessageSize;
++ Packet->PageBuffers[0].Pfn = virt_to_phys(rndisMessage) >> PAGE_SHIFT;
++ Packet->PageBuffers[0].Offset =
++ (unsigned long)rndisMessage & (PAGE_SIZE-1);
++ Packet->PageBuffers[0].Length = rndisMessageSize;
+
+ /* Save the packet send completion and context */
+ filterPacket->OnCompletion = Packet->Completion.Send.OnSendCompletion;
+- filterPacket->CompletionContext = Packet->Completion.Send.SendCompletionContext;
++ filterPacket->CompletionContext =
++ Packet->Completion.Send.SendCompletionContext;
+
+ /* Use ours */
+ Packet->Completion.Send.OnSendCompletion = RndisFilterOnSendCompletion;
+ Packet->Completion.Send.SendCompletionContext = filterPacket;
+
+ ret = gRndisFilter.InnerDriver.OnSend(Device, Packet);
+- if (ret != 0)
+- {
+- /* Reset the completion to originals to allow retries from above */
+- Packet->Completion.Send.OnSendCompletion = filterPacket->OnCompletion;
+- Packet->Completion.Send.SendCompletionContext = filterPacket->CompletionContext;
++ if (ret != 0) {
++ /*
++ * Reset the completion to originals to allow retries from
++ * above
++ */
++ Packet->Completion.Send.OnSendCompletion =
++ filterPacket->OnCompletion;
++ Packet->Completion.Send.SendCompletionContext =
++ filterPacket->CompletionContext;
+ }
+
+ DPRINT_EXIT(NETVSC);
+@@ -1093,11 +983,9 @@ RndisFilterOnSend(
+ return ret;
+ }
+
+-static void
+-RndisFilterOnSendCompletion(
+- void *Context)
++static void RndisFilterOnSendCompletion(void *Context)
+ {
+- struct rndis_filter_packet *filterPacket = (struct rndis_filter_packet *)Context;
++ struct rndis_filter_packet *filterPacket = Context;
+
+ DPRINT_ENTER(NETVSC);
+
+@@ -1108,10 +996,7 @@ RndisFilterOnSendCompletion(
+ }
+
+
+-static void
+-RndisFilterOnSendRequestCompletion(
+- void *Context
+- )
++static void RndisFilterOnSendRequestCompletion(void *Context)
+ {
+ DPRINT_ENTER(NETVSC);
+
diff --git a/staging/staging-hv-coding-style-cleanup-for-storvsc_drv.c.patch b/staging/staging-hv-coding-style-cleanup-for-storvsc_drv.c.patch
new file mode 100644
index 00000000000000..13935baadcb46d
--- /dev/null
+++ b/staging/staging-hv-coding-style-cleanup-for-storvsc_drv.c.patch
@@ -0,0 +1,1567 @@
+From foo@baz Wed Sep 2 08:37:47 PDT 2009
+Date: Wed, 02 Sep 2009 08:37:47 -0700
+To: Greg KH <greg@kroah.com>
+From: Greg Kroah-Hartman <gregkh@suse.de>
+Subject: Staging: hv: coding style cleanup for storvsc_drv.c
+
+Where's the hazard pay for cleaning up this mess...
+
+Cc: Hank Janssen <hjanssen@microsoft.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ drivers/staging/hv/storvsc_drv.c | 944 +++++++++++++++++++--------------------
+ 1 file changed, 475 insertions(+), 469 deletions(-)
+
+--- a/drivers/staging/hv/storvsc_drv.c
++++ b/drivers/staging/hv/storvsc_drv.c
+@@ -1,5 +1,4 @@
+ /*
+- *
+ * Copyright (c) 2009, Microsoft Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+@@ -18,14 +17,11 @@
+ * Authors:
+ * Haiyang Zhang <haiyangz@microsoft.com>
+ * Hank Janssen <hjanssen@microsoft.com>
+- *
+ */
+-
+ #include <linux/init.h>
+ #include <linux/module.h>
+ #include <linux/device.h>
+ #include <linux/blkdev.h>
+-
+ #include <scsi/scsi.h>
+ #include <scsi/scsi_cmnd.h>
+ #include <scsi/scsi_host.h>
+@@ -33,66 +29,75 @@
+ #include <scsi/scsi_tcq.h>
+ #include <scsi/scsi_eh.h>
+ #include <scsi/scsi_devinfo.h>
+-
+ #include <scsi/scsi_dbg.h>
+-
+ #include "osd.h"
+ #include "logging.h"
+ #include "vmbus.h"
+ #include "StorVscApi.h"
+
+
+-/* #defines */
+-
+-
+-
+-/* Data types */
+-
+ struct host_device_context {
+- struct work_struct host_rescan_work; /* must be 1st field */
+- struct device_context *device_ctx; /* point back to our device context */
+- struct kmem_cache *request_pool;
+- unsigned int port;
+- unsigned char path;
+- unsigned char target;
++ /* must be 1st field
++ * FIXME this is a bug */
++ struct work_struct host_rescan_work;
++
++ /* point back to our device context */
++ struct device_context *device_ctx;
++ struct kmem_cache *request_pool;
++ unsigned int port;
++ unsigned char path;
++ unsigned char target;
+ };
+
+ struct storvsc_cmd_request {
+- struct list_head entry;
+- struct scsi_cmnd *cmd;
++ struct list_head entry;
++ struct scsi_cmnd *cmd;
+
+ unsigned int bounce_sgl_count;
+- struct scatterlist *bounce_sgl;
++ struct scatterlist *bounce_sgl;
+
+ struct hv_storvsc_request request;
+ /* !!!DO NOT ADD ANYTHING BELOW HERE!!! */
+- /* The extension buffer falls right here and is pointed to by request.Extension; */
++ /* The extension buffer falls right here and is pointed to by
++ * request.Extension;
++ * Which sounds like a very bad design... */
+ };
+
+ struct storvsc_driver_context {
+ /* !! These must be the first 2 fields !! */
+- struct driver_context drv_ctx;
++ /* FIXME this is a bug... */
++ struct driver_context drv_ctx;
+ struct storvsc_driver_object drv_obj;
+ };
+
+ /* Static decl */
+ static int storvsc_probe(struct device *dev);
+-static int storvsc_queuecommand(struct scsi_cmnd *scmnd, void (*done)(struct scsi_cmnd *));
++static int storvsc_queuecommand(struct scsi_cmnd *scmnd,
++ void (*done)(struct scsi_cmnd *));
+ static int storvsc_device_alloc(struct scsi_device *);
+ static int storvsc_device_configure(struct scsi_device *);
+ static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd);
+ static void storvsc_host_rescan_callback(struct work_struct *work);
+-static void storvsc_host_rescan(struct hv_device* device_obj);
++static void storvsc_host_rescan(struct hv_device *device_obj);
+ static int storvsc_remove(struct device *dev);
+
+-static struct scatterlist *create_bounce_buffer(struct scatterlist *sgl, unsigned int sg_count, unsigned int len);
+-static void destroy_bounce_buffer(struct scatterlist *sgl, unsigned int sg_count);
++static struct scatterlist *create_bounce_buffer(struct scatterlist *sgl,
++ unsigned int sg_count,
++ unsigned int len);
++static void destroy_bounce_buffer(struct scatterlist *sgl,
++ unsigned int sg_count);
+ static int do_bounce_buffer(struct scatterlist *sgl, unsigned int sg_count);
+-static unsigned int copy_from_bounce_buffer(struct scatterlist *orig_sgl, struct scatterlist *bounce_sgl, unsigned int orig_sgl_count);
+-static unsigned int copy_to_bounce_buffer(struct scatterlist *orig_sgl, struct scatterlist *bounce_sgl, unsigned int orig_sgl_count);
+-
+-static int storvsc_report_luns(struct scsi_device *sdev, unsigned int luns[], unsigned int *lun_count);
+-static int storvsc_get_chs(struct scsi_device *sdev, struct block_device * bdev, sector_t capacity, int *info);
++static unsigned int copy_from_bounce_buffer(struct scatterlist *orig_sgl,
++ struct scatterlist *bounce_sgl,
++ unsigned int orig_sgl_count);
++static unsigned int copy_to_bounce_buffer(struct scatterlist *orig_sgl,
++ struct scatterlist *bounce_sgl,
++ unsigned int orig_sgl_count);
++
++static int storvsc_report_luns(struct scsi_device *sdev, unsigned int luns[],
++ unsigned int *lun_count);
++static int storvsc_get_chs(struct scsi_device *sdev, struct block_device *bdev,
++ sector_t capacity, int *info);
+
+
+ static int storvsc_ringbuffer_size = STORVSC_RING_BUFFER_SIZE;
+@@ -102,39 +107,41 @@ static struct storvsc_driver_context g_s
+
+ /* Scsi driver */
+ static struct scsi_host_template scsi_driver = {
+- .module = THIS_MODULE,
+- .name = "storvsc_host_t",
+- .bios_param = storvsc_get_chs,
+- .queuecommand = storvsc_queuecommand,
+- .eh_host_reset_handler = storvsc_host_reset_handler,
+- .slave_alloc = storvsc_device_alloc,
+- .slave_configure = storvsc_device_configure,
+- .cmd_per_lun = 1,
+- .can_queue = STORVSC_MAX_IO_REQUESTS*STORVSC_MAX_TARGETS, /* 64 max_queue * 1 target */
+- .this_id = -1,
++ .module = THIS_MODULE,
++ .name = "storvsc_host_t",
++ .bios_param = storvsc_get_chs,
++ .queuecommand = storvsc_queuecommand,
++ .eh_host_reset_handler = storvsc_host_reset_handler,
++ .slave_alloc = storvsc_device_alloc,
++ .slave_configure = storvsc_device_configure,
++ .cmd_per_lun = 1,
++ /* 64 max_queue * 1 target */
++ .can_queue = STORVSC_MAX_IO_REQUESTS*STORVSC_MAX_TARGETS,
++ .this_id = -1,
+ /* no use setting to 0 since ll_blk_rw reset it to 1 */
+- .sg_tablesize = MAX_MULTIPAGE_BUFFER_COUNT,/* currently 32 */
+- /* ENABLE_CLUSTERING allows mutiple physically contig bio_vecs to merge into 1 sg element. If set, we must */
+- /* limit the max_segment_size to PAGE_SIZE, otherwise we may get 1 sg element that represents multiple */
++ /* currently 32 */
++ .sg_tablesize = MAX_MULTIPAGE_BUFFER_COUNT,
++ /*
++ * ENABLE_CLUSTERING allows mutiple physically contig bio_vecs to merge
++ * into 1 sg element. If set, we must limit the max_segment_size to
++ * PAGE_SIZE, otherwise we may get 1 sg element that represents
++ * multiple
++ */
+ /* physically contig pfns (ie sg[x].length > PAGE_SIZE). */
+- .use_clustering = ENABLE_CLUSTERING,
++ .use_clustering = ENABLE_CLUSTERING,
+ /* Make sure we dont get a sg segment crosses a page boundary */
+- .dma_boundary = PAGE_SIZE-1,
++ .dma_boundary = PAGE_SIZE-1,
+ };
+
+
+-/*++
+-
+-Name: storvsc_drv_init()
+-
+-Desc: StorVsc driver initialization.
+-
+---*/
++/**
++ * storvsc_drv_init - StorVsc driver initialization.
++ */
+ static int storvsc_drv_init(PFN_DRIVERINITIALIZE pfn_drv_init)
+ {
+- int ret=0;
++ int ret;
+ struct storvsc_driver_object *storvsc_drv_obj = &g_storvsc_drv.drv_obj;
+- struct driver_context *drv_ctx=&g_storvsc_drv.drv_ctx;
++ struct driver_context *drv_ctx = &g_storvsc_drv.drv_ctx;
+
+ DPRINT_ENTER(STORVSC_DRV);
+
+@@ -146,17 +153,24 @@ static int storvsc_drv_init(PFN_DRIVERIN
+ /* Callback to client driver to complete the initialization */
+ pfn_drv_init(&storvsc_drv_obj->Base);
+
+- DPRINT_INFO(STORVSC_DRV, "request extension size %u, max outstanding reqs %u", storvsc_drv_obj->RequestExtSize, storvsc_drv_obj->MaxOutstandingRequestsPerChannel);
+-
+- if (storvsc_drv_obj->MaxOutstandingRequestsPerChannel < STORVSC_MAX_IO_REQUESTS)
+- {
+- DPRINT_ERR(STORVSC_DRV, "The number of outstanding io requests (%d) is larger than that supported (%d) internally.",
+- STORVSC_MAX_IO_REQUESTS, storvsc_drv_obj->MaxOutstandingRequestsPerChannel);
++ DPRINT_INFO(STORVSC_DRV,
++ "request extension size %u, max outstanding reqs %u",
++ storvsc_drv_obj->RequestExtSize,
++ storvsc_drv_obj->MaxOutstandingRequestsPerChannel);
++
++ if (storvsc_drv_obj->MaxOutstandingRequestsPerChannel <
++ STORVSC_MAX_IO_REQUESTS) {
++ DPRINT_ERR(STORVSC_DRV,
++ "The number of outstanding io requests (%d) "
++ "is larger than that supported (%d) internally.",
++ STORVSC_MAX_IO_REQUESTS,
++ storvsc_drv_obj->MaxOutstandingRequestsPerChannel);
+ return -1;
+ }
+
+ drv_ctx->driver.name = storvsc_drv_obj->Base.name;
+- memcpy(&drv_ctx->class_id, &storvsc_drv_obj->Base.deviceType, sizeof(struct hv_guid));
++ memcpy(&drv_ctx->class_id, &storvsc_drv_obj->Base.deviceType,
++ sizeof(struct hv_guid));
+
+ drv_ctx->probe = storvsc_probe;
+ drv_ctx->remove = storvsc_remove;
+@@ -169,7 +183,6 @@ static int storvsc_drv_init(PFN_DRIVERIN
+ return ret;
+ }
+
+-
+ static int storvsc_drv_exit_cb(struct device *dev, void *data)
+ {
+ struct device **curr = (struct device **)data;
+@@ -177,24 +190,16 @@ static int storvsc_drv_exit_cb(struct de
+ return 1; /* stop iterating */
+ }
+
+-/*++
+-
+-Name: storvsc_drv_exit()
+-
+-Desc:
+-
+---*/
+ static void storvsc_drv_exit(void)
+ {
+ struct storvsc_driver_object *storvsc_drv_obj = &g_storvsc_drv.drv_obj;
+- struct driver_context *drv_ctx=&g_storvsc_drv.drv_ctx;
+- struct device *current_dev=NULL;
++ struct driver_context *drv_ctx = &g_storvsc_drv.drv_ctx;
++ struct device *current_dev = NULL;
+ int ret;
+
+ DPRINT_ENTER(STORVSC_DRV);
+
+- while (1)
+- {
++ while (1) {
+ current_dev = NULL;
+
+ /* Get the device */
+@@ -223,24 +228,20 @@ static void storvsc_drv_exit(void)
+ return;
+ }
+
+-/*++
+-
+-Name: storvsc_probe()
+-
+-Desc: Add a new device for this driver
+-
+---*/
++/**
++ * storvsc_probe - Add a new device for this driver
++ */
+ static int storvsc_probe(struct device *device)
+ {
+- int ret=0;
+-
+- struct driver_context *driver_ctx = driver_to_driver_context(device->driver);
+- struct storvsc_driver_context *storvsc_drv_ctx = (struct storvsc_driver_context*)driver_ctx;
+- struct storvsc_driver_object *storvsc_drv_obj = &storvsc_drv_ctx->drv_obj;
+-
++ int ret;
++ struct driver_context *driver_ctx =
++ driver_to_driver_context(device->driver);
++ struct storvsc_driver_context *storvsc_drv_ctx =
++ (struct storvsc_driver_context *)driver_ctx;
++ struct storvsc_driver_object *storvsc_drv_obj =
++ &storvsc_drv_ctx->drv_obj;
+ struct device_context *device_ctx = device_to_device_context(device);
+ struct hv_device *device_obj = &device_ctx->device_obj;
+-
+ struct Scsi_Host *host;
+ struct host_device_context *host_device_ctx;
+ struct storvsc_device_info device_info;
+@@ -250,32 +251,31 @@ static int storvsc_probe(struct device *
+ if (!storvsc_drv_obj->Base.OnDeviceAdd)
+ return -1;
+
+- host = scsi_host_alloc(&scsi_driver, sizeof(struct host_device_context));
+- if (!host)
+- {
++ host = scsi_host_alloc(&scsi_driver,
++ sizeof(struct host_device_context));
++ if (!host) {
+ DPRINT_ERR(STORVSC_DRV, "unable to allocate scsi host object");
+ return -ENOMEM;
+ }
+
+ dev_set_drvdata(device, host);
+
+- host_device_ctx = (struct host_device_context*)host->hostdata;
++ host_device_ctx = (struct host_device_context *)host->hostdata;
+ memset(host_device_ctx, 0, sizeof(struct host_device_context));
+
+ host_device_ctx->port = host->host_no;
+ host_device_ctx->device_ctx = device_ctx;
+
+- INIT_WORK(&host_device_ctx->host_rescan_work, storvsc_host_rescan_callback);
++ INIT_WORK(&host_device_ctx->host_rescan_work,
++ storvsc_host_rescan_callback);
+
+ host_device_ctx->request_pool =
+- kmem_cache_create
+- (dev_name(&device_ctx->device),
+- sizeof(struct storvsc_cmd_request) + storvsc_drv_obj->RequestExtSize,
+- 0,
+- SLAB_HWCACHE_ALIGN, NULL);
++ kmem_cache_create(dev_name(&device_ctx->device),
++ sizeof(struct storvsc_cmd_request) +
++ storvsc_drv_obj->RequestExtSize, 0,
++ SLAB_HWCACHE_ALIGN, NULL);
+
+- if (!host_device_ctx->request_pool)
+- {
++ if (!host_device_ctx->request_pool) {
+ scsi_host_put(host);
+ DPRINT_EXIT(STORVSC_DRV);
+
+@@ -284,9 +284,9 @@ static int storvsc_probe(struct device *
+
+ device_info.PortNumber = host->host_no;
+ /* Call to the vsc driver to add the device */
+- ret = storvsc_drv_obj->Base.OnDeviceAdd(device_obj, (void*)&device_info);
+- if (ret != 0)
+- {
++ ret = storvsc_drv_obj->Base.OnDeviceAdd(device_obj,
++ (void *)&device_info);
++ if (ret != 0) {
+ DPRINT_ERR(STORVSC_DRV, "unable to add scsi vsc device");
+ kmem_cache_destroy(host_device_ctx->request_pool);
+ scsi_host_put(host);
+@@ -299,14 +299,16 @@ static int storvsc_probe(struct device *
+ host_device_ctx->path = device_info.PathId;
+ host_device_ctx->target = device_info.TargetId;
+
+- host->max_lun = STORVSC_MAX_LUNS_PER_TARGET; /* max # of devices per target */
+- host->max_id = STORVSC_MAX_TARGETS; /* max # of targets per channel */
+- host->max_channel = STORVSC_MAX_CHANNELS -1; /* max # of channels */
++ /* max # of devices per target */
++ host->max_lun = STORVSC_MAX_LUNS_PER_TARGET;
++ /* max # of targets per channel */
++ host->max_id = STORVSC_MAX_TARGETS;
++ /* max # of channels */
++ host->max_channel = STORVSC_MAX_CHANNELS - 1;
+
+ /* Register the HBA and start the scsi bus scan */
+ ret = scsi_add_host(host, device);
+- if (ret != 0)
+- {
++ if (ret != 0) {
+ DPRINT_ERR(STORVSC_DRV, "unable to add scsi host device");
+
+ storvsc_drv_obj->Base.OnDeviceRemove(device_obj);
+@@ -325,47 +327,44 @@ static int storvsc_probe(struct device *
+ return ret;
+ }
+
+-
+-/*++
+-
+-Name: storvsc_remove()
+-
+-Desc: Callback when our device is removed
+-
+---*/
++/**
++ * storvsc_remove - Callback when our device is removed
++ */
+ static int storvsc_remove(struct device *device)
+ {
+- int ret=0;
+-
+- struct driver_context *driver_ctx = driver_to_driver_context(device->driver);
+- struct storvsc_driver_context *storvsc_drv_ctx = (struct storvsc_driver_context*)driver_ctx;
+- struct storvsc_driver_object *storvsc_drv_obj = &storvsc_drv_ctx->drv_obj;
+-
++ int ret;
++ struct driver_context *driver_ctx =
++ driver_to_driver_context(device->driver);
++ struct storvsc_driver_context *storvsc_drv_ctx =
++ (struct storvsc_driver_context *)driver_ctx;
++ struct storvsc_driver_object *storvsc_drv_obj =
++ &storvsc_drv_ctx->drv_obj;
+ struct device_context *device_ctx = device_to_device_context(device);
+ struct hv_device *device_obj = &device_ctx->device_obj;
+-
+ struct Scsi_Host *host = dev_get_drvdata(device);
+- struct host_device_context *host_device_ctx=(struct host_device_context*)host->hostdata;
++ struct host_device_context *host_device_ctx =
++ (struct host_device_context *)host->hostdata;
+
+
+ DPRINT_ENTER(STORVSC_DRV);
+
+- if (!storvsc_drv_obj->Base.OnDeviceRemove)
+- {
++ if (!storvsc_drv_obj->Base.OnDeviceRemove) {
+ DPRINT_EXIT(STORVSC_DRV);
+ return -1;
+ }
+
+- /* Call to the vsc driver to let it know that the device is being removed */
++ /*
++ * Call to the vsc driver to let it know that the device is being
++ * removed
++ */
+ ret = storvsc_drv_obj->Base.OnDeviceRemove(device_obj);
+- if (ret != 0)
+- {
++ if (ret != 0) {
+ /* TODO: */
+- DPRINT_ERR(STORVSC, "unable to remove vsc device (ret %d)", ret);
++ DPRINT_ERR(STORVSC, "unable to remove vsc device (ret %d)",
++ ret);
+ }
+
+- if (host_device_ctx->request_pool)
+- {
++ if (host_device_ctx->request_pool) {
+ kmem_cache_destroy(host_device_ctx->request_pool);
+ host_device_ctx->request_pool = NULL;
+ }
+@@ -381,45 +380,45 @@ static int storvsc_remove(struct device
+ return ret;
+ }
+
+-/*++
+-
+-Name: storvsc_commmand_completion()
+-
+-Desc: Command completion processing
+-
+---*/
++/**
++ * storvsc_commmand_completion - Command completion processing
++ */
+ static void storvsc_commmand_completion(struct hv_storvsc_request *request)
+ {
+- struct storvsc_cmd_request *cmd_request = (struct storvsc_cmd_request*)request->Context;
++ struct storvsc_cmd_request *cmd_request =
++ (struct storvsc_cmd_request *)request->Context;
+ struct scsi_cmnd *scmnd = cmd_request->cmd;
+- struct host_device_context *host_device_ctx = (struct host_device_context*)scmnd->device->host->hostdata;
++ struct host_device_context *host_device_ctx =
++ (struct host_device_context *)scmnd->device->host->hostdata;
+ void (*scsi_done_fn)(struct scsi_cmnd *);
+ struct scsi_sense_hdr sense_hdr;
+
+ ASSERT(request == &cmd_request->request);
+- ASSERT((unsigned long)scmnd->host_scribble == (unsigned long)cmd_request);
++ ASSERT((unsigned long)scmnd->host_scribble ==
++ (unsigned long)cmd_request);
+ ASSERT(scmnd);
+ ASSERT(scmnd->scsi_done);
+
+ DPRINT_ENTER(STORVSC_DRV);
+
+- if (cmd_request->bounce_sgl_count)/* using bounce buffer */
+- {
++ if (cmd_request->bounce_sgl_count) {
++ /* using bounce buffer */
+ /* printk("copy_from_bounce_buffer\n"); */
+
+ /* FIXME: We can optimize on writes by just skipping this */
+- copy_from_bounce_buffer(scsi_sglist(scmnd), cmd_request->bounce_sgl, scsi_sg_count(scmnd));
+- destroy_bounce_buffer(cmd_request->bounce_sgl, cmd_request->bounce_sgl_count);
++ copy_from_bounce_buffer(scsi_sglist(scmnd),
++ cmd_request->bounce_sgl,
++ scsi_sg_count(scmnd));
++ destroy_bounce_buffer(cmd_request->bounce_sgl,
++ cmd_request->bounce_sgl_count);
+ }
+
+ scmnd->result = request->Status;
+
+- if (scmnd->result)
+- {
+- if (scsi_normalize_sense(scmnd->sense_buffer, request->SenseBufferSize, &sense_hdr))
+- {
++ if (scmnd->result) {
++ if (scsi_normalize_sense(scmnd->sense_buffer,
++ request->SenseBufferSize, &sense_hdr))
+ scsi_print_sense_hdr("storvsc", &sense_hdr);
+- }
+ }
+
+ ASSERT(request->BytesXfer <= request->DataBuffer.Length);
+@@ -440,58 +439,50 @@ static void storvsc_commmand_completion(
+
+ static int do_bounce_buffer(struct scatterlist *sgl, unsigned int sg_count)
+ {
+- int i=0;
++ int i;
+
+ /* No need to check */
+ if (sg_count < 2)
+ return -1;
+
+ /* We have at least 2 sg entries */
+- for ( i=0; i<sg_count; i++ )
+- {
+- if (i == 0) /* make sure 1st one does not have hole */
+- {
++ for (i = 0; i < sg_count; i++) {
++ if (i == 0) {
++ /* make sure 1st one does not have hole */
+ if (sgl[i].offset + sgl[i].length != PAGE_SIZE)
+ return i;
+- }
+- else if (i == sg_count - 1) /* make sure last one does not have hole */
+- {
++ } else if (i == sg_count - 1) {
++ /* make sure last one does not have hole */
+ if (sgl[i].offset != 0)
+ return i;
+- }
+- else /* make sure no hole in the middle */
+- {
++ } else {
++ /* make sure no hole in the middle */
+ if (sgl[i].length != PAGE_SIZE || sgl[i].offset != 0)
+- {
+ return i;
+- }
+ }
+ }
+ return -1;
+ }
+
+-static struct scatterlist *create_bounce_buffer(struct scatterlist *sgl, unsigned int sg_count, unsigned int len)
++static struct scatterlist *create_bounce_buffer(struct scatterlist *sgl,
++ unsigned int sg_count,
++ unsigned int len)
+ {
+ int i;
+- int num_pages=0;
+- struct scatterlist* bounce_sgl;
++ int num_pages;
++ struct scatterlist *bounce_sgl;
+ struct page *page_buf;
+
+ num_pages = ALIGN_UP(len, PAGE_SIZE) >> PAGE_SHIFT;
+
+ bounce_sgl = kcalloc(num_pages, sizeof(struct scatterlist), GFP_ATOMIC);
+ if (!bounce_sgl)
+- {
+ return NULL;
+- }
+
+- for(i=0; i<num_pages; i++)
+- {
++ for (i = 0; i < num_pages; i++) {
+ page_buf = alloc_page(GFP_ATOMIC);
+ if (!page_buf)
+- {
+ goto cleanup;
+- }
+ sg_set_page(&bounce_sgl[i], page_buf, 0, 0);
+ }
+
+@@ -502,84 +493,76 @@ cleanup:
+ return NULL;
+ }
+
+-static void destroy_bounce_buffer(struct scatterlist *sgl, unsigned int sg_count)
++static void destroy_bounce_buffer(struct scatterlist *sgl,
++ unsigned int sg_count)
+ {
+ int i;
+ struct page *page_buf;
+
+- for (i=0; i<sg_count; i++)
+- {
+- if ((page_buf = sg_page((&sgl[i]))) != NULL)
+-
+- {
++ for (i = 0; i < sg_count; i++) {
++ page_buf = sg_page((&sgl[i]));
++ if (page_buf != NULL)
+ __free_page(page_buf);
+- }
+ }
+
+ kfree(sgl);
+ }
+
+ /* Assume the bounce_sgl has enough room ie using the create_bounce_buffer() */
+-static unsigned int copy_to_bounce_buffer(struct scatterlist *orig_sgl, struct scatterlist *bounce_sgl, unsigned int orig_sgl_count)
++static unsigned int copy_to_bounce_buffer(struct scatterlist *orig_sgl,
++ struct scatterlist *bounce_sgl,
++ unsigned int orig_sgl_count)
+ {
+- int i=0,j=0;
++ int i;
++ int j = 0;
+ unsigned long src, dest;
+ unsigned int srclen, destlen, copylen;
+- unsigned int total_copied=0;
+- unsigned long bounce_addr=0;
+- unsigned long src_addr=0;
++ unsigned int total_copied = 0;
++ unsigned long bounce_addr = 0;
++ unsigned long src_addr = 0;
+ unsigned long flags;
+
+ local_irq_save(flags);
+
+- for (i=0; i<orig_sgl_count; i++)
+- {
+- src_addr = (unsigned long)kmap_atomic(sg_page((&orig_sgl[i])), KM_IRQ0) + orig_sgl[i].offset;
++ for (i = 0; i < orig_sgl_count; i++) {
++ src_addr = (unsigned long)kmap_atomic(sg_page((&orig_sgl[i])),
++ KM_IRQ0) + orig_sgl[i].offset;
+ src = src_addr;
+ srclen = orig_sgl[i].length;
+
+- /* if (PageHighMem(orig_sgl[i].page)) */
+- /* printk("HighMem page detected - addr %p", (void*)src); */
+-
+ ASSERT(orig_sgl[i].offset + orig_sgl[i].length <= PAGE_SIZE);
+
+ if (j == 0)
+- {
+ bounce_addr = (unsigned long)kmap_atomic(sg_page((&bounce_sgl[j])), KM_IRQ0);
+- }
+
+- while (srclen)
+- {
++ while (srclen) {
+ /* assume bounce offset always == 0 */
+ dest = bounce_addr + bounce_sgl[j].length;
+ destlen = PAGE_SIZE - bounce_sgl[j].length;
+
+ copylen = min(srclen, destlen);
+- memcpy((void*)dest, (void*)src, copylen);
++ memcpy((void *)dest, (void *)src, copylen);
+
+ total_copied += copylen;
+ bounce_sgl[j].length += copylen;
+ srclen -= copylen;
+ src += copylen;
+
+- if (bounce_sgl[j].length == PAGE_SIZE) /* full..move to next entry */
+- {
+- kunmap_atomic((void*)bounce_addr, KM_IRQ0);
++ if (bounce_sgl[j].length == PAGE_SIZE) {
++ /* full..move to next entry */
++ kunmap_atomic((void *)bounce_addr, KM_IRQ0);
+ j++;
+
+ /* if we need to use another bounce buffer */
+- if (srclen || i != orig_sgl_count -1)
+- {
++ if (srclen || i != orig_sgl_count - 1)
+ bounce_addr = (unsigned long)kmap_atomic(sg_page((&bounce_sgl[j])), KM_IRQ0);
+- }
+- }
+- else if (srclen == 0 && i == orig_sgl_count -1) /* unmap the last bounce that is < PAGE_SIZE */
+- {
+- kunmap_atomic((void*)bounce_addr, KM_IRQ0);
++ } else if (srclen == 0 && i == orig_sgl_count - 1) {
++ /* unmap the last bounce that is < PAGE_SIZE */
++ kunmap_atomic((void *)bounce_addr, KM_IRQ0);
+ }
+ }
+
+- kunmap_atomic((void*)(src_addr - orig_sgl[i].offset), KM_IRQ0);
++ kunmap_atomic((void *)(src_addr - orig_sgl[i].offset), KM_IRQ0);
+ }
+
+ local_irq_restore(flags);
+@@ -588,61 +571,59 @@ static unsigned int copy_to_bounce_buffe
+ }
+
+ /* Assume the original sgl has enough room */
+-static unsigned int copy_from_bounce_buffer(struct scatterlist *orig_sgl, struct scatterlist *bounce_sgl, unsigned int orig_sgl_count)
++static unsigned int copy_from_bounce_buffer(struct scatterlist *orig_sgl,
++ struct scatterlist *bounce_sgl,
++ unsigned int orig_sgl_count)
+ {
+- int i=0,j=0;
++ int i;
++ int j = 0;
+ unsigned long src, dest;
+ unsigned int srclen, destlen, copylen;
+- unsigned int total_copied=0;
+- unsigned long bounce_addr=0;
+- unsigned long dest_addr=0;
++ unsigned int total_copied = 0;
++ unsigned long bounce_addr = 0;
++ unsigned long dest_addr = 0;
+ unsigned long flags;
+
+ local_irq_save(flags);
+
+- for (i=0; i<orig_sgl_count; i++)
+- {
+- dest_addr = (unsigned long)kmap_atomic(sg_page((&orig_sgl[i])), KM_IRQ0) + orig_sgl[i].offset;
++ for (i = 0; i < orig_sgl_count; i++) {
++ dest_addr = (unsigned long)kmap_atomic(sg_page((&orig_sgl[i])),
++ KM_IRQ0) + orig_sgl[i].offset;
+ dest = dest_addr;
+ destlen = orig_sgl[i].length;
+ ASSERT(orig_sgl[i].offset + orig_sgl[i].length <= PAGE_SIZE);
+
+ if (j == 0)
+- {
+ bounce_addr = (unsigned long)kmap_atomic(sg_page((&bounce_sgl[j])), KM_IRQ0);
+- }
+
+- while (destlen)
+- {
++ while (destlen) {
+ src = bounce_addr + bounce_sgl[j].offset;
+ srclen = bounce_sgl[j].length - bounce_sgl[j].offset;
+
+ copylen = min(srclen, destlen);
+- memcpy((void*)dest, (void*)src, copylen);
++ memcpy((void *)dest, (void *)src, copylen);
+
+ total_copied += copylen;
+ bounce_sgl[j].offset += copylen;
+ destlen -= copylen;
+ dest += copylen;
+
+- if (bounce_sgl[j].offset == bounce_sgl[j].length) /* full */
+- {
+- kunmap_atomic((void*)bounce_addr, KM_IRQ0);
++ if (bounce_sgl[j].offset == bounce_sgl[j].length) {
++ /* full */
++ kunmap_atomic((void *)bounce_addr, KM_IRQ0);
+ j++;
+
+ /* if we need to use another bounce buffer */
+- if (destlen || i != orig_sgl_count -1)
+- {
++ if (destlen || i != orig_sgl_count - 1)
+ bounce_addr = (unsigned long)kmap_atomic(sg_page((&bounce_sgl[j])), KM_IRQ0);
+- }
+- }
+- else if (destlen == 0 && i == orig_sgl_count -1) /* unmap the last bounce that is < PAGE_SIZE */
+- {
+- kunmap_atomic((void*)bounce_addr, KM_IRQ0);
++ } else if (destlen == 0 && i == orig_sgl_count - 1) {
++ /* unmap the last bounce that is < PAGE_SIZE */
++ kunmap_atomic((void *)bounce_addr, KM_IRQ0);
+ }
+ }
+
+- kunmap_atomic((void*)(dest_addr - orig_sgl[i].offset), KM_IRQ0);
++ kunmap_atomic((void *)(dest_addr - orig_sgl[i].offset),
++ KM_IRQ0);
+ }
+
+ local_irq_restore(flags);
+@@ -650,47 +631,44 @@ static unsigned int copy_from_bounce_buf
+ return total_copied;
+ }
+
+-
+-/*++
+-
+-Name: storvsc_queuecommand()
+-
+-Desc: Initiate command processing
+-
+---*/
+-static int storvsc_queuecommand(struct scsi_cmnd *scmnd, void (*done)(struct scsi_cmnd *))
++/**
++ * storvsc_queuecommand - Initiate command processing
++ */
++static int storvsc_queuecommand(struct scsi_cmnd *scmnd,
++ void (*done)(struct scsi_cmnd *))
+ {
+- int ret=0;
+- struct host_device_context *host_device_ctx = (struct host_device_context*)scmnd->device->host->hostdata;
+- struct device_context *device_ctx=host_device_ctx->device_ctx;
+- struct driver_context *driver_ctx = driver_to_driver_context(device_ctx->device.driver);
+- struct storvsc_driver_context *storvsc_drv_ctx = (struct storvsc_driver_context*)driver_ctx;
+- struct storvsc_driver_object *storvsc_drv_obj = &storvsc_drv_ctx->drv_obj;
+-
++ int ret;
++ struct host_device_context *host_device_ctx =
++ (struct host_device_context *)scmnd->device->host->hostdata;
++ struct device_context *device_ctx = host_device_ctx->device_ctx;
++ struct driver_context *driver_ctx =
++ driver_to_driver_context(device_ctx->device.driver);
++ struct storvsc_driver_context *storvsc_drv_ctx =
++ (struct storvsc_driver_context *)driver_ctx;
++ struct storvsc_driver_object *storvsc_drv_obj =
++ &storvsc_drv_ctx->drv_obj;
+ struct hv_storvsc_request *request;
+ struct storvsc_cmd_request *cmd_request;
+- unsigned int request_size=0;
++ unsigned int request_size = 0;
+ int i;
+ struct scatterlist *sgl;
+
+ DPRINT_ENTER(STORVSC_DRV);
+
+- DPRINT_DBG(STORVSC_DRV, "scmnd %p dir %d, use_sg %d buf %p len %d queue depth %d tagged %d",
+- scmnd,
+- scmnd->sc_data_direction,
+- scsi_sg_count(scmnd),
+- scsi_sglist(scmnd),
+- scsi_bufflen(scmnd),
+- scmnd->device->queue_depth,
+- scmnd->device->tagged_supported);
++ DPRINT_DBG(STORVSC_DRV, "scmnd %p dir %d, use_sg %d buf %p len %d "
++ "queue depth %d tagged %d", scmnd, scmnd->sc_data_direction,
++ scsi_sg_count(scmnd), scsi_sglist(scmnd),
++ scsi_bufflen(scmnd), scmnd->device->queue_depth,
++ scmnd->device->tagged_supported);
+
+ /* If retrying, no need to prep the cmd */
+- if (scmnd->host_scribble)
+- {
++ if (scmnd->host_scribble) {
+ ASSERT(scmnd->scsi_done != NULL);
+
+- cmd_request = (struct storvsc_cmd_request* )scmnd->host_scribble;
+- DPRINT_INFO(STORVSC_DRV, "retrying scmnd %p cmd_request %p", scmnd, cmd_request);
++ cmd_request =
++ (struct storvsc_cmd_request *)scmnd->host_scribble;
++ DPRINT_INFO(STORVSC_DRV, "retrying scmnd %p cmd_request %p",
++ scmnd, cmd_request);
+
+ goto retry_request;
+ }
+@@ -702,11 +680,11 @@ static int storvsc_queuecommand(struct s
+
+ request_size = sizeof(struct storvsc_cmd_request);
+
+- cmd_request = kmem_cache_alloc(host_device_ctx->request_pool, GFP_ATOMIC);
+- if (!cmd_request)
+- {
+- DPRINT_ERR(STORVSC_DRV, "scmnd (%p) - unable to allocate storvsc_cmd_request...marking queue busy", scmnd);
+-
++ cmd_request = kmem_cache_alloc(host_device_ctx->request_pool,
++ GFP_ATOMIC);
++ if (!cmd_request) {
++ DPRINT_ERR(STORVSC_DRV, "scmnd (%p) - unable to allocate "
++ "storvsc_cmd_request...marking queue busy", scmnd);
+ scmnd->scsi_done = NULL;
+ return SCSI_MLQUEUE_DEVICE_BUSY;
+ }
+@@ -716,16 +694,17 @@ static int storvsc_queuecommand(struct s
+ cmd_request->bounce_sgl = NULL;
+ cmd_request->cmd = scmnd;
+
+- scmnd->host_scribble = (unsigned char*)cmd_request;
++ scmnd->host_scribble = (unsigned char *)cmd_request;
+
+ request = &cmd_request->request;
+
+- request->Extension = (void*)((unsigned long)cmd_request + request_size);
+- DPRINT_DBG(STORVSC_DRV, "req %p size %d ext %d", request, request_size, storvsc_drv_obj->RequestExtSize);
++ request->Extension =
++ (void *)((unsigned long)cmd_request + request_size);
++ DPRINT_DBG(STORVSC_DRV, "req %p size %d ext %d", request, request_size,
++ storvsc_drv_obj->RequestExtSize);
+
+ /* Build the SRB */
+- switch(scmnd->sc_data_direction)
+- {
++ switch (scmnd->sc_data_direction) {
+ case DMA_TO_DEVICE:
+ request->Type = WRITE_TYPE;
+ break;
+@@ -755,69 +734,82 @@ static int storvsc_queuecommand(struct s
+
+
+ request->DataBuffer.Length = scsi_bufflen(scmnd);
+- if (scsi_sg_count(scmnd))
+- {
+- sgl = (struct scatterlist*)scsi_sglist(scmnd);
++ if (scsi_sg_count(scmnd)) {
++ sgl = (struct scatterlist *)scsi_sglist(scmnd);
+
+ /* check if we need to bounce the sgl */
+- if (do_bounce_buffer(sgl, scsi_sg_count(scmnd)) != -1)
+- {
+- DPRINT_INFO(STORVSC_DRV, "need to bounce buffer for this scmnd %p", scmnd);
+- cmd_request->bounce_sgl = create_bounce_buffer(sgl, scsi_sg_count(scmnd), scsi_bufflen(scmnd));
+- if (!cmd_request->bounce_sgl)
+- {
+- DPRINT_ERR(STORVSC_DRV, "unable to create bounce buffer for this scmnd %p", scmnd);
++ if (do_bounce_buffer(sgl, scsi_sg_count(scmnd)) != -1) {
++ DPRINT_INFO(STORVSC_DRV,
++ "need to bounce buffer for this scmnd %p",
++ scmnd);
++ cmd_request->bounce_sgl =
++ create_bounce_buffer(sgl, scsi_sg_count(scmnd),
++ scsi_bufflen(scmnd));
++ if (!cmd_request->bounce_sgl) {
++ DPRINT_ERR(STORVSC_DRV,
++ "unable to create bounce buffer for "
++ "this scmnd %p", scmnd);
+
+ scmnd->scsi_done = NULL;
+ scmnd->host_scribble = NULL;
+- kmem_cache_free(host_device_ctx->request_pool, cmd_request);
++ kmem_cache_free(host_device_ctx->request_pool,
++ cmd_request);
+
+ return SCSI_MLQUEUE_HOST_BUSY;
+ }
+
+- cmd_request->bounce_sgl_count = ALIGN_UP(scsi_bufflen(scmnd), PAGE_SIZE) >> PAGE_SHIFT;
+-
+- /* printk("bouncing buffer allocated %p original buffer %p\n", bounce_sgl, sgl); */
+- /* printk("copy_to_bounce_buffer\n"); */
+- /* FIXME: We can optimize on reads by just skipping this */
+- copy_to_bounce_buffer(sgl, cmd_request->bounce_sgl, scsi_sg_count(scmnd));
++ cmd_request->bounce_sgl_count =
++ ALIGN_UP(scsi_bufflen(scmnd), PAGE_SIZE) >>
++ PAGE_SHIFT;
++
++ /*
++ * FIXME: We can optimize on reads by just skipping
++ * this
++ */
++ copy_to_bounce_buffer(sgl, cmd_request->bounce_sgl,
++ scsi_sg_count(scmnd));
+
+ sgl = cmd_request->bounce_sgl;
+ }
+
+ request->DataBuffer.Offset = sgl[0].offset;
+
+- for (i = 0; i < scsi_sg_count(scmnd); i++ )
+- {
+- DPRINT_DBG(STORVSC_DRV, "sgl[%d] len %d offset %d \n", i, sgl[i].length, sgl[i].offset);
+- request->DataBuffer.PfnArray[i] = page_to_pfn(sg_page((&sgl[i])));
++ for (i = 0; i < scsi_sg_count(scmnd); i++) {
++ DPRINT_DBG(STORVSC_DRV, "sgl[%d] len %d offset %d \n",
++ i, sgl[i].length, sgl[i].offset);
++ request->DataBuffer.PfnArray[i] =
++ page_to_pfn(sg_page((&sgl[i])));
+ }
+- }
+-
+- else if (scsi_sglist(scmnd))
+- {
++ } else if (scsi_sglist(scmnd)) {
+ ASSERT(scsi_bufflen(scmnd) <= PAGE_SIZE);
+- request->DataBuffer.Offset = virt_to_phys(scsi_sglist(scmnd)) & (PAGE_SIZE-1);
+- request->DataBuffer.PfnArray[0] = virt_to_phys(scsi_sglist(scmnd)) >> PAGE_SHIFT;
+- }
+- else
+- {
++ request->DataBuffer.Offset =
++ virt_to_phys(scsi_sglist(scmnd)) & (PAGE_SIZE-1);
++ request->DataBuffer.PfnArray[0] =
++ virt_to_phys(scsi_sglist(scmnd)) >> PAGE_SHIFT;
++ } else {
+ ASSERT(scsi_bufflen(scmnd) == 0);
+ }
+
+ retry_request:
+-
+ /* Invokes the vsc to start an IO */
+- ret = storvsc_drv_obj->OnIORequest(&device_ctx->device_obj, &cmd_request->request);
+- if (ret == -1) /* no more space */
+- {
+- DPRINT_ERR(STORVSC_DRV, "scmnd (%p) - queue FULL...marking queue busy", scmnd);
+-
+- if (cmd_request->bounce_sgl_count)
+- {
+- /* FIXME: We can optimize on writes by just skipping this */
+- copy_from_bounce_buffer(scsi_sglist(scmnd), cmd_request->bounce_sgl, scsi_sg_count(scmnd));
+- destroy_bounce_buffer(cmd_request->bounce_sgl, cmd_request->bounce_sgl_count);
++ ret = storvsc_drv_obj->OnIORequest(&device_ctx->device_obj,
++ &cmd_request->request);
++ if (ret == -1) {
++ /* no more space */
++ DPRINT_ERR(STORVSC_DRV,
++ "scmnd (%p) - queue FULL...marking queue busy",
++ scmnd);
++
++ if (cmd_request->bounce_sgl_count) {
++ /*
++ * FIXME: We can optimize on writes by just skipping
++ * this
++ */
++ copy_from_bounce_buffer(scsi_sglist(scmnd),
++ cmd_request->bounce_sgl,
++ scsi_sg_count(scmnd));
++ destroy_bounce_buffer(cmd_request->bounce_sgl,
++ cmd_request->bounce_sgl_count);
+ }
+
+ kmem_cache_free(host_device_ctx->request_pool, cmd_request);
+@@ -833,37 +825,44 @@ retry_request:
+ return ret;
+ }
+
+-static int storvsc_merge_bvec(struct request_queue *q, struct bvec_merge_data *bmd, struct bio_vec *bvec)
++static int storvsc_merge_bvec(struct request_queue *q,
++ struct bvec_merge_data *bmd, struct bio_vec *bvec)
+ {
+- return bvec->bv_len; /* checking done by caller. */
++ /* checking done by caller. */
++ return bvec->bv_len;
+ }
+
+-/*++
+-
+-Name: storvsc_device_configure()
+-
+-Desc: Configure the specified scsi device
+-
+---*/
++/**
++ * storvsc_device_configure - Configure the specified scsi device
++ */
+ static int storvsc_device_alloc(struct scsi_device *sdevice)
+ {
+- DPRINT_DBG(STORVSC_DRV, "sdev (%p) - setting device flag to %d", sdevice, BLIST_SPARSELUN);
+- /* This enables luns to be located sparsely. Otherwise, we may not discovered them. */
++ DPRINT_DBG(STORVSC_DRV, "sdev (%p) - setting device flag to %d",
++ sdevice, BLIST_SPARSELUN);
++ /*
++ * This enables luns to be located sparsely. Otherwise, we may not
++ * discovered them.
++ */
+ sdevice->sdev_bflags |= BLIST_SPARSELUN | BLIST_LARGELUN;
+ return 0;
+ }
+
+ static int storvsc_device_configure(struct scsi_device *sdevice)
+ {
+- DPRINT_INFO(STORVSC_DRV, "sdev (%p) - curr queue depth %d", sdevice, sdevice->queue_depth);
++ DPRINT_INFO(STORVSC_DRV, "sdev (%p) - curr queue depth %d", sdevice,
++ sdevice->queue_depth);
+
+- DPRINT_INFO(STORVSC_DRV, "sdev (%p) - setting queue depth to %d", sdevice, STORVSC_MAX_IO_REQUESTS);
+- scsi_adjust_queue_depth(sdevice, MSG_SIMPLE_TAG, STORVSC_MAX_IO_REQUESTS);
++ DPRINT_INFO(STORVSC_DRV, "sdev (%p) - setting queue depth to %d",
++ sdevice, STORVSC_MAX_IO_REQUESTS);
++ scsi_adjust_queue_depth(sdevice, MSG_SIMPLE_TAG,
++ STORVSC_MAX_IO_REQUESTS);
+
+- DPRINT_INFO(STORVSC_DRV, "sdev (%p) - setting max segment size to %ld", sdevice, PAGE_SIZE);
++ DPRINT_INFO(STORVSC_DRV, "sdev (%p) - setting max segment size to %ld",
++ sdevice, PAGE_SIZE);
+ blk_queue_max_segment_size(sdevice->request_queue, PAGE_SIZE);
+
+- DPRINT_INFO(STORVSC_DRV, "sdev (%p) - adding merge bio vec routine", sdevice);
++ DPRINT_INFO(STORVSC_DRV, "sdev (%p) - adding merge bio vec routine",
++ sdevice);
+ blk_queue_merge_bvec(sdevice->request_queue, storvsc_merge_bvec);
+
+ blk_queue_bounce_limit(sdevice->request_queue, BLK_BOUNCE_ANY);
+@@ -872,78 +871,75 @@ static int storvsc_device_configure(stru
+ return 0;
+ }
+
+-/*++
+-
+-Name: storvsc_host_reset_handler()
+-
+-Desc: Reset the scsi HBA
+-
+---*/
++/**
++ * storvsc_host_reset_handler - Reset the scsi HBA
++ */
+ static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd)
+ {
+- int ret=SUCCESS;
+- struct host_device_context *host_device_ctx = (struct host_device_context*)scmnd->device->host->hostdata;
++ int ret;
++ struct host_device_context *host_device_ctx =
++ (struct host_device_context *)scmnd->device->host->hostdata;
+ struct device_context *device_ctx = host_device_ctx->device_ctx;
+- struct driver_context *driver_ctx = driver_to_driver_context(device_ctx->device.driver);
+- struct storvsc_driver_context *storvsc_drv_ctx = (struct storvsc_driver_context*)driver_ctx;
++ struct driver_context *driver_ctx =
++ driver_to_driver_context(device_ctx->device.driver);
++ struct storvsc_driver_context *storvsc_drv_ctx =
++ (struct storvsc_driver_context *)driver_ctx;
+
+- struct storvsc_driver_object *storvsc_drv_obj = &storvsc_drv_ctx->drv_obj;
++ struct storvsc_driver_object *storvsc_drv_obj =
++ &storvsc_drv_ctx->drv_obj;
+
+ DPRINT_ENTER(STORVSC_DRV);
+
+- DPRINT_INFO(STORVSC_DRV, "sdev (%p) dev obj (%p) - host resetting...", scmnd->device, &device_ctx->device_obj);
++ DPRINT_INFO(STORVSC_DRV, "sdev (%p) dev obj (%p) - host resetting...",
++ scmnd->device, &device_ctx->device_obj);
+
+ /* Invokes the vsc to reset the host/bus */
+ ASSERT(storvsc_drv_obj->OnHostReset);
+ ret = storvsc_drv_obj->OnHostReset(&device_ctx->device_obj);
+- if (ret != 0)
+- {
++ if (ret != 0) {
+ DPRINT_EXIT(STORVSC_DRV);
+ return ret;
+ }
+
+- DPRINT_INFO(STORVSC_DRV, "sdev (%p) dev obj (%p) - host reseted", scmnd->device, &device_ctx->device_obj);
++ DPRINT_INFO(STORVSC_DRV, "sdev (%p) dev obj (%p) - host reseted",
++ scmnd->device, &device_ctx->device_obj);
+
+ DPRINT_EXIT(STORVSC_DRV);
+
+ return ret;
+ }
+
+-/*++
+-
+-Name: storvsc_host_rescan
+-
+-Desc: Rescan the scsi HBA
+-
+---*/
++/**
++ * storvsc_host_rescan - Rescan the scsi HBA
++ */
+ static void storvsc_host_rescan_callback(struct work_struct *work)
+ {
+ struct hv_device *device_obj =
+- &((struct host_device_context*)work)->device_ctx->device_obj;
+- struct device_context* device_ctx = to_device_context(device_obj);
++ &((struct host_device_context *)work)->device_ctx->device_obj;
++ struct device_context *device_ctx = to_device_context(device_obj);
+ struct Scsi_Host *host = dev_get_drvdata(&device_ctx->device);
+ struct scsi_device *sdev;
+ struct host_device_context *host_device_ctx;
+ struct scsi_device **sdevs_remove_list;
+- unsigned int sdevs_count=0;
++ unsigned int sdevs_count = 0;
+ unsigned int found;
+ unsigned int i;
+- unsigned int lun_count=0;
++ unsigned int lun_count = 0;
+ unsigned int *lun_list;
+
+ DPRINT_ENTER(STORVSC_DRV);
+
+- host_device_ctx = (struct host_device_context*)host->hostdata;
+- lun_list = kcalloc(STORVSC_MAX_LUNS_PER_TARGET, sizeof(unsigned int), GFP_ATOMIC);
+- if (!lun_list)
+- {
++ host_device_ctx = (struct host_device_context *)host->hostdata;
++ lun_list = kcalloc(STORVSC_MAX_LUNS_PER_TARGET, sizeof(unsigned int),
++ GFP_ATOMIC);
++ if (!lun_list) {
+ DPRINT_ERR(STORVSC_DRV, "unable to allocate lun list");
+ return;
+ }
+
+- sdevs_remove_list = kcalloc(STORVSC_MAX_LUNS_PER_TARGET, sizeof(void *), GFP_ATOMIC);
+- if (!sdevs_remove_list)
+- {
++ sdevs_remove_list = kcalloc(STORVSC_MAX_LUNS_PER_TARGET,
++ sizeof(void *), GFP_ATOMIC);
++ if (!sdevs_remove_list) {
+ kfree(lun_list);
+ DPRINT_ERR(STORVSC_DRV, "unable to allocate lun remove list");
+ return;
+@@ -952,65 +948,67 @@ static void storvsc_host_rescan_callback
+ DPRINT_INFO(STORVSC_DRV, "rescanning host for new scsi devices...");
+
+ /* Rescan for new device */
+- scsi_scan_target(&host->shost_gendev, host_device_ctx->path, host_device_ctx->target, SCAN_WILD_CARD, 1);
++ scsi_scan_target(&host->shost_gendev, host_device_ctx->path,
++ host_device_ctx->target, SCAN_WILD_CARD, 1);
+
+ DPRINT_INFO(STORVSC_DRV, "rescanning host for removed scsi device...");
+
+ /* Use the 1st device to send the report luns cmd */
+- shost_for_each_device(sdev, host)
+- {
+- lun_count=STORVSC_MAX_LUNS_PER_TARGET;
++ shost_for_each_device(sdev, host) {
++ lun_count = STORVSC_MAX_LUNS_PER_TARGET;
+ storvsc_report_luns(sdev, lun_list, &lun_count);
+
+- DPRINT_INFO(STORVSC_DRV, "report luns on scsi device (%p) found %u luns ", sdev, lun_count);
+- DPRINT_INFO(STORVSC_DRV, "existing luns on scsi device (%p) host (%d)", sdev, host->host_no);
++ DPRINT_INFO(STORVSC_DRV,
++ "report luns on scsi device (%p) found %u luns ",
++ sdev, lun_count);
++ DPRINT_INFO(STORVSC_DRV,
++ "existing luns on scsi device (%p) host (%d)",
++ sdev, host->host_no);
+
+ scsi_device_put(sdev);
+ break;
+ }
+
+- for (i=0; i<lun_count; i++)
+- {
++ for (i = 0; i < lun_count; i++)
+ DPRINT_INFO(STORVSC_DRV, "%d) lun %u", i, lun_list[i]);
+- }
+
+- /* Rescan for devices that may have been removed. */
+- /* We do not have to worry that new devices may have been added since */
+- /* this callback is serialized by the workqueue ie add/remove are done here. */
+- shost_for_each_device(sdev, host)
+- {
++ /* Rescan for devices that may have been removed.
++ * We do not have to worry that new devices may have been added since
++ * this callback is serialized by the workqueue ie add/remove are done
++ * here.
++ */
++ shost_for_each_device(sdev, host) {
+ /* See if this device is still here */
+ found = 0;
+- for (i=0; i<lun_count; i++)
+- {
+- if (sdev->lun == lun_list[i])
+- {
++ for (i = 0; i < lun_count; i++) {
++ if (sdev->lun == lun_list[i]) {
+ found = 1;
+ break;
+ }
+ }
+- if (!found)
+- {
+- DPRINT_INFO(STORVSC_DRV, "lun (%u) does not exists", sdev->lun);
++ if (!found) {
++ DPRINT_INFO(STORVSC_DRV, "lun (%u) does not exists",
++ sdev->lun);
+ sdevs_remove_list[sdevs_count++] = sdev;
+ }
+ }
+
+ /* Now remove the devices */
+- for (i=0; i< sdevs_count; i++)
+- {
+- DPRINT_INFO(STORVSC_DRV, "removing scsi device (%p) lun (%u)...",
+- sdevs_remove_list[i], sdevs_remove_list[i]->lun);
++ for (i = 0; i < sdevs_count; i++) {
++ DPRINT_INFO(STORVSC_DRV,
++ "removing scsi device (%p) lun (%u)...",
++ sdevs_remove_list[i], sdevs_remove_list[i]->lun);
+
+ /* make sure it is not removed from underneath us */
+- if (!scsi_device_get(sdevs_remove_list[i]))
+- {
++ if (!scsi_device_get(sdevs_remove_list[i])) {
+ scsi_remove_device(sdevs_remove_list[i]);
+ scsi_device_put(sdevs_remove_list[i]);
+ }
+ }
+
+- DPRINT_INFO(STORVSC_DRV, "rescan completed on dev obj (%p) target (%u) bus (%u)", device_obj, host_device_ctx->target, host_device_ctx->path);
++ DPRINT_INFO(STORVSC_DRV, "rescan completed on dev obj (%p) "
++ "target (%u) bus (%u)", device_obj,
++ host_device_ctx->target, host_device_ctx->path);
+
+ kfree(lun_list);
+ kfree(sdevs_remove_list);
+@@ -1018,16 +1016,18 @@ static void storvsc_host_rescan_callback
+ DPRINT_EXIT(STORVSC_DRV);
+ }
+
+-static int storvsc_report_luns(struct scsi_device *sdev, unsigned int luns[], unsigned int *lun_count)
++static int storvsc_report_luns(struct scsi_device *sdev, unsigned int luns[],
++ unsigned int *lun_count)
+ {
+- int i,j;
+- unsigned int lun=0;
++ int i, j;
++ unsigned int lun = 0;
+ unsigned int num_luns;
+ int result;
+ unsigned char *data;
+ struct scsi_sense_hdr sshdr;
+- unsigned char cmd[16]={0};
+- unsigned int report_len = 8*(STORVSC_MAX_LUNS_PER_TARGET+1); /* Add 1 to cover the report_lun header */
++ unsigned char cmd[16] = {0};
++ /* Add 1 to cover the report_lun header */
++ unsigned int report_len = 8 * (STORVSC_MAX_LUNS_PER_TARGET+1);
+ unsigned long long *report_luns;
+ const unsigned int in_lun_count = *lun_count;
+
+@@ -1035,45 +1035,44 @@ static int storvsc_report_luns(struct sc
+
+ report_luns = kzalloc(report_len, GFP_ATOMIC);
+ if (!report_luns)
+- {
+ return -ENOMEM;
+- }
+
+ cmd[0] = REPORT_LUNS;
+
+ /* cmd length */
+- *(unsigned int*)&cmd[6] = cpu_to_be32(report_len);
++ *(unsigned int *)&cmd[6] = cpu_to_be32(report_len);
+
+- result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, (unsigned char*)report_luns, report_len, &sshdr, 30*HZ, 3, NULL);
+- if (result != 0)
+- {
++ result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE,
++ (unsigned char *)report_luns, report_len,
++ &sshdr, 30 * HZ, 3, NULL);
++ if (result != 0) {
+ kfree(report_luns);
+ return -EBUSY;
+ }
+
+ /* get the length from the first four bytes */
+- report_len = be32_to_cpu(*(unsigned int*)&report_luns[0]);
++ report_len = be32_to_cpu(*(unsigned int *)&report_luns[0]);
+
+ num_luns = (report_len / sizeof(unsigned long long));
+- if (num_luns > in_lun_count)
+- {
++ if (num_luns > in_lun_count) {
+ kfree(report_luns);
+ return -EINVAL;
+ }
+
+ *lun_count = num_luns;
+
+- DPRINT_DBG(STORVSC_DRV, "report luns on scsi device (%p) found %u luns ", sdev, num_luns);
++ DPRINT_DBG(STORVSC_DRV,
++ "report luns on scsi device (%p) found %u luns ",
++ sdev, num_luns);
+
+ /* lun id starts at 1 */
+- for (i=1; i< num_luns+1; i++)
+- {
++ for (i = 1; i < num_luns + 1; i++) {
+ lun = 0;
+- data = (unsigned char*)&report_luns[i];
+- for (j = 0; j < sizeof(lun); j += 2)
+- {
+- lun = lun | (((data[j] << 8) | data[j + 1]) << (j * 8));
+- }
++ data = (unsigned char *)&report_luns[i];
++ for (j = 0; j < sizeof(lun); j += 2) {
++ lun = lun | (((data[j] << 8) | data[j + 1]) <<
++ (j * 8));
++ }
+
+ luns[i-1] = lun;
+ }
+@@ -1084,119 +1083,126 @@ static int storvsc_report_luns(struct sc
+
+ static void storvsc_host_rescan(struct hv_device *device_obj)
+ {
+- struct device_context* device_ctx = to_device_context(device_obj);
++ struct device_context *device_ctx = to_device_context(device_obj);
+ struct Scsi_Host *host = dev_get_drvdata(&device_ctx->device);
+ struct host_device_context *host_device_ctx;
+
+ DPRINT_ENTER(STORVSC_DRV);
+
+- host_device_ctx = (struct host_device_context*)host->hostdata;
++ host_device_ctx = (struct host_device_context *)host->hostdata;
+
+- DPRINT_INFO(STORVSC_DRV, "initiating rescan on dev obj (%p) target (%u) bus (%u)...", device_obj, host_device_ctx->target, host_device_ctx->path);
+-
+- /* We need to queue this since the scanning may block and the caller may be in an intr context */
++ DPRINT_INFO(STORVSC_DRV, "initiating rescan on dev obj (%p) "
++ "target (%u) bus (%u)...", device_obj,
++ host_device_ctx->target, host_device_ctx->path);
++
++ /*
++ * We need to queue this since the scanning may block and the caller
++ * may be in an intr context
++ */
+ /* scsi_queue_work(host, &host_device_ctx->host_rescan_work); */
+ schedule_work(&host_device_ctx->host_rescan_work);
+ DPRINT_EXIT(STORVSC_DRV);
+ }
+
+-static int storvsc_get_chs(struct scsi_device *sdev, struct block_device * bdev, sector_t capacity, int *info)
++static int storvsc_get_chs(struct scsi_device *sdev, struct block_device * bdev,
++ sector_t capacity, int *info)
+ {
+ sector_t total_sectors = capacity;
+- sector_t cylinder_times_heads=0;
+- sector_t temp=0;
++ sector_t cylinder_times_heads = 0;
++ sector_t temp = 0;
+
+- int sectors_per_track=0;
+- int heads=0;
+- int cylinders=0;
+- int rem=0;
+-
+- if (total_sectors > (65535 * 16 * 255)) {
+- total_sectors = (65535 * 16 * 255);
+- }
+-
+- if (total_sectors >= (65535 * 16 * 63)) {
+- sectors_per_track = 255;
+- heads = 16;
++ int sectors_per_track = 0;
++ int heads = 0;
++ int cylinders = 0;
++ int rem = 0;
++
++ if (total_sectors > (65535 * 16 * 255))
++ total_sectors = (65535 * 16 * 255);
++
++ if (total_sectors >= (65535 * 16 * 63)) {
++ sectors_per_track = 255;
++ heads = 16;
+
+ cylinder_times_heads = total_sectors;
+- rem = sector_div(cylinder_times_heads, sectors_per_track); /* sector_div stores the quotient in cylinder_times_heads */
+- }
+- else
+- {
+- sectors_per_track = 17;
++ /* sector_div stores the quotient in cylinder_times_heads */
++ rem = sector_div(cylinder_times_heads, sectors_per_track);
++ } else {
++ sectors_per_track = 17;
+
+ cylinder_times_heads = total_sectors;
+- rem = sector_div(cylinder_times_heads, sectors_per_track); /* sector_div stores the quotient in cylinder_times_heads */
++ /* sector_div stores the quotient in cylinder_times_heads */
++ rem = sector_div(cylinder_times_heads, sectors_per_track);
+
+ temp = cylinder_times_heads + 1023;
+- rem = sector_div(temp, 1024); /* sector_div stores the quotient in temp */
++ /* sector_div stores the quotient in temp */
++ rem = sector_div(temp, 1024);
+
+ heads = temp;
+
+- if (heads < 4) {
+- heads = 4;
+- }
+-
+- if (cylinder_times_heads >= (heads * 1024) || (heads > 16)) {
+- sectors_per_track = 31;
+- heads = 16;
++ if (heads < 4)
++ heads = 4;
++
++ if (cylinder_times_heads >= (heads * 1024) || (heads > 16)) {
++ sectors_per_track = 31;
++ heads = 16;
+
+ cylinder_times_heads = total_sectors;
+- rem = sector_div(cylinder_times_heads, sectors_per_track); /* sector_div stores the quotient in cylinder_times_heads */
+- }
++ /*
++ * sector_div stores the quotient in
++ * cylinder_times_heads
++ */
++ rem = sector_div(cylinder_times_heads,
++ sectors_per_track);
++ }
+
+- if (cylinder_times_heads >= (heads * 1024)) {
+- sectors_per_track = 63;
+- heads = 16;
++ if (cylinder_times_heads >= (heads * 1024)) {
++ sectors_per_track = 63;
++ heads = 16;
+
+ cylinder_times_heads = total_sectors;
+- rem = sector_div(cylinder_times_heads, sectors_per_track); /* sector_div stores the quotient in cylinder_times_heads */
+- }
+- }
++ /*
++ * sector_div stores the quotient in
++ * cylinder_times_heads
++ */
++ rem = sector_div(cylinder_times_heads,
++ sectors_per_track);
++ }
++ }
+
+ temp = cylinder_times_heads;
+- rem = sector_div(temp, heads); /* sector_div stores the quotient in temp */
++ /* sector_div stores the quotient in temp */
++ rem = sector_div(temp, heads);
+ cylinders = temp;
+
+ info[0] = heads;
+- info[1] = sectors_per_track;
+- info[2] = cylinders;
++ info[1] = sectors_per_track;
++ info[2] = cylinders;
+
+- DPRINT_INFO(STORVSC_DRV, "CHS (%d, %d, %d)", cylinders, heads, sectors_per_track);
++ DPRINT_INFO(STORVSC_DRV, "CHS (%d, %d, %d)", cylinders, heads,
++ sectors_per_track);
+
+ return 0;
+ }
+
+-MODULE_LICENSE("GPL");
+-
+ static int __init storvsc_init(void)
+ {
+ int ret;
+
+ DPRINT_ENTER(STORVSC_DRV);
+-
+ DPRINT_INFO(STORVSC_DRV, "Storvsc initializing....");
+-
+ ret = storvsc_drv_init(StorVscInitialize);
+-
+ DPRINT_EXIT(STORVSC_DRV);
+-
+ return ret;
+ }
+
+ static void __exit storvsc_exit(void)
+ {
+ DPRINT_ENTER(STORVSC_DRV);
+-
+ storvsc_drv_exit();
+-
+ DPRINT_ENTER(STORVSC_DRV);
+ }
+
++MODULE_LICENSE("GPL");
+ module_param(storvsc_ringbuffer_size, int, S_IRUGO);
+-
+ module_init(storvsc_init);
+ module_exit(storvsc_exit);
+-
+-/* eof */
diff --git a/staging/staging-hv-coding-style-cleanups-for-vmbus_drv.c.patch b/staging/staging-hv-coding-style-cleanups-for-vmbus_drv.c.patch
new file mode 100644
index 00000000000000..68e769e2daf17e
--- /dev/null
+++ b/staging/staging-hv-coding-style-cleanups-for-vmbus_drv.c.patch
@@ -0,0 +1,1440 @@
+From foo@baz Wed Sep 2 07:11:14 PDT 2009
+Date: Wed, 02 Sep 2009 07:11:14 -0700
+To: Greg KH <greg@kroah.com>
+From: Greg Kroah-Hartman <gregkh@suse.de>
+Subject: Staging: hv: coding style cleanups for vmbus_drv.c
+
+Almost clean.
+
+Cc: Hank Janssen <hjanssen@microsoft.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+---
+ drivers/staging/hv/vmbus_drv.c | 946 +++++++++++++++++------------------------
+ 1 file changed, 405 insertions(+), 541 deletions(-)
+
+--- a/drivers/staging/hv/vmbus_drv.c
++++ b/drivers/staging/hv/vmbus_drv.c
+@@ -1,5 +1,4 @@
+ /*
+- *
+ * Copyright (c) 2009, Microsoft Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+@@ -18,10 +17,7 @@
+ * Authors:
+ * Haiyang Zhang <haiyangz@microsoft.com>
+ * Hank Janssen <hjanssen@microsoft.com>
+- *
+ */
+-
+-
+ #include <linux/init.h>
+ #include <linux/module.h>
+ #include <linux/device.h>
+@@ -33,35 +29,27 @@
+ #include "vmbus.h"
+
+
+-/* Defines */
+-
+-
+ /* FIXME! We need to do this dynamically for PIC and APIC system */
+-#define VMBUS_IRQ 0x5
+-#define VMBUS_IRQ_VECTOR IRQ5_VECTOR
+-
+-/* Data types */
+-
++#define VMBUS_IRQ 0x5
++#define VMBUS_IRQ_VECTOR IRQ5_VECTOR
+
+ /* Main vmbus driver data structure */
+ struct vmbus_driver_context {
+ /* !! These must be the first 2 fields !! */
++ /* FIXME, this is a bug */
+ /* The driver field is not used in here. Instead, the bus field is */
+ /* used to represent the driver */
+- struct driver_context drv_ctx;
++ struct driver_context drv_ctx;
+ struct vmbus_driver drv_obj;
+
+- struct bus_type bus;
+- struct tasklet_struct msg_dpc;
+- struct tasklet_struct event_dpc;
++ struct bus_type bus;
++ struct tasklet_struct msg_dpc;
++ struct tasklet_struct event_dpc;
+
+ /* The bus root device */
+- struct device_context device_ctx;
++ struct device_context device_ctx;
+ };
+
+-
+-/* Static decl */
+-
+ static int vmbus_match(struct device *device, struct device_driver *driver);
+ static int vmbus_probe(struct device *device);
+ static int vmbus_remove(struct device *device);
+@@ -70,40 +58,33 @@ static int vmbus_uevent(struct device *d
+ static void vmbus_msg_dpc(unsigned long data);
+ static void vmbus_event_dpc(unsigned long data);
+
+-static irqreturn_t vmbus_isr(int irq, void* dev_id);
++static irqreturn_t vmbus_isr(int irq, void *dev_id);
+
+ static void vmbus_device_release(struct device *device);
+ static void vmbus_bus_release(struct device *device);
+
+-static struct hv_device *vmbus_child_device_create(struct hv_guid *type, struct hv_guid *instance, void *context);
++static struct hv_device *vmbus_child_device_create(struct hv_guid *type,
++ struct hv_guid *instance,
++ void *context);
+ static void vmbus_child_device_destroy(struct hv_device *device_obj);
+-static int vmbus_child_device_register(struct hv_device *root_device_obj, struct hv_device *child_device_obj);
++static int vmbus_child_device_register(struct hv_device *root_device_obj,
++ struct hv_device *child_device_obj);
+ static void vmbus_child_device_unregister(struct hv_device *child_device_obj);
+-static void vmbus_child_device_get_info(struct hv_device *device_obj, struct hv_device_info *device_info);
++static void vmbus_child_device_get_info(struct hv_device *device_obj,
++ struct hv_device_info *device_info);
++static ssize_t vmbus_show_device_attr(struct device *dev,
++ struct device_attribute *dev_attr,
++ char *buf);
+
+-/* static ssize_t vmbus_show_class_id(struct device *dev, struct device_attribute *attr, char *buf); */
+-/* static ssize_t vmbus_show_device_id(struct device *dev, struct device_attribute *attr, char *buf); */
+
+-static ssize_t vmbus_show_device_attr(struct device *dev, struct device_attribute *dev_attr, char *buf);
+-
+-
+-/* Global */
+-
+-
+-/* Global logging setting */
+-
+-/* unsigned int vmbus_loglevel= (((VMBUS | VMBUS_DRV)<<16) | DEBUG_LVL_ENTEREXIT); */
+-/* unsigned int vmbus_loglevel= (ALL_MODULES << 16 | DEBUG_LVL_ENTEREXIT); */
+-unsigned int vmbus_loglevel= (ALL_MODULES << 16 | INFO_LVL);
++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 int vmbus_irq = VMBUS_IRQ;
+
+-/* Setup /proc/sys/bus/vmbus/vmbus_loglevel */
+-/* Allow usage of sysctl cmd to set the logging level */
+-
+ /* Set up per device attributes in /sys/bus/vmbus/devices/<bus device> */
+-
+ static struct device_attribute vmbus_device_attrs[] = {
+ __ATTR(id, S_IRUGO, vmbus_show_device_attr, NULL),
+ __ATTR(state, S_IRUGO, vmbus_show_device_attr, NULL),
+@@ -134,29 +115,25 @@ static struct device_attribute vmbus_dev
+ };
+
+ /* The one and only one */
+-static struct vmbus_driver_context g_vmbus_drv={
+- .bus.name = "vmbus",
+- .bus.match = vmbus_match,
+- .bus.shutdown = vmbus_shutdown,
+- .bus.remove = vmbus_remove,
+- .bus.probe = vmbus_probe,
+- .bus.uevent = vmbus_uevent,
+- .bus.dev_attrs = vmbus_device_attrs,
++static struct vmbus_driver_context g_vmbus_drv = {
++ .bus.name = "vmbus",
++ .bus.match = vmbus_match,
++ .bus.shutdown = vmbus_shutdown,
++ .bus.remove = vmbus_remove,
++ .bus.probe = vmbus_probe,
++ .bus.uevent = vmbus_uevent,
++ .bus.dev_attrs = vmbus_device_attrs,
+ };
+
+-
+-/* Routines */
+-
+-
+-
+-/*++
+-
+-Name: vmbus_show_device_attr()
+-
+-Desc: Show the device attribute in sysfs. This is invoked when user does a "cat /sys/bus/vmbus/devices/<bus device>/<attr name>"
+-
+---*/
+-static ssize_t vmbus_show_device_attr(struct device *dev, struct device_attribute *dev_attr, char *buf)
++/**
++ * vmbus_show_device_attr - Show the device attribute in sysfs.
++ *
++ * This is invoked when user does a
++ * "cat /sys/bus/vmbus/devices/<busdevice>/<attr name>"
++ */
++static ssize_t vmbus_show_device_attr(struct device *dev,
++ struct device_attribute *dev_attr,
++ char *buf)
+ {
+ struct device_context *device_ctx = device_to_device_context(dev);
+ struct hv_device_info device_info;
+@@ -165,173 +142,119 @@ static ssize_t vmbus_show_device_attr(st
+
+ vmbus_child_device_get_info(&device_ctx->device_obj, &device_info);
+
+- if (!strcmp(dev_attr->attr.name, "class_id"))
+- {
+- return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x%02x%02x}\n",
+- device_info.ChannelType.data[3], device_info.ChannelType.data[2],
+- device_info.ChannelType.data[1], device_info.ChannelType.data[0],
+- device_info.ChannelType.data[5], device_info.ChannelType.data[4],
+- device_info.ChannelType.data[7], device_info.ChannelType.data[6],
+- device_info.ChannelType.data[8], device_info.ChannelType.data[9],
+- device_info.ChannelType.data[10], device_info.ChannelType.data[11],
+- device_info.ChannelType.data[12], device_info.ChannelType.data[13],
+- device_info.ChannelType.data[14], device_info.ChannelType.data[15]);
+-
+- }
+- else if (!strcmp(dev_attr->attr.name, "device_id"))
+- {
+- return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x%02x%02x}\n",
+- device_info.ChannelInstance.data[3], device_info.ChannelInstance.data[2],
+- device_info.ChannelInstance.data[1], device_info.ChannelInstance.data[0],
+- device_info.ChannelInstance.data[5], device_info.ChannelInstance.data[4],
+- device_info.ChannelInstance.data[7], device_info.ChannelInstance.data[6],
+- device_info.ChannelInstance.data[8], device_info.ChannelInstance.data[9],
+- device_info.ChannelInstance.data[10], device_info.ChannelInstance.data[11],
+- device_info.ChannelInstance.data[12], device_info.ChannelInstance.data[13],
+- device_info.ChannelInstance.data[14], device_info.ChannelInstance.data[15]);
+- }
+- else if (!strcmp(dev_attr->attr.name, "state"))
+- {
++ if (!strcmp(dev_attr->attr.name, "class_id")) {
++ return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-"
++ "%02x%02x%02x%02x%02x%02x%02x%02x}\n",
++ device_info.ChannelType.data[3],
++ device_info.ChannelType.data[2],
++ device_info.ChannelType.data[1],
++ device_info.ChannelType.data[0],
++ device_info.ChannelType.data[5],
++ device_info.ChannelType.data[4],
++ device_info.ChannelType.data[7],
++ device_info.ChannelType.data[6],
++ device_info.ChannelType.data[8],
++ device_info.ChannelType.data[9],
++ device_info.ChannelType.data[10],
++ device_info.ChannelType.data[11],
++ device_info.ChannelType.data[12],
++ device_info.ChannelType.data[13],
++ device_info.ChannelType.data[14],
++ device_info.ChannelType.data[15]);
++ } else if (!strcmp(dev_attr->attr.name, "device_id")) {
++ return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-"
++ "%02x%02x%02x%02x%02x%02x%02x%02x}\n",
++ device_info.ChannelInstance.data[3],
++ device_info.ChannelInstance.data[2],
++ device_info.ChannelInstance.data[1],
++ device_info.ChannelInstance.data[0],
++ device_info.ChannelInstance.data[5],
++ device_info.ChannelInstance.data[4],
++ device_info.ChannelInstance.data[7],
++ device_info.ChannelInstance.data[6],
++ device_info.ChannelInstance.data[8],
++ device_info.ChannelInstance.data[9],
++ device_info.ChannelInstance.data[10],
++ device_info.ChannelInstance.data[11],
++ device_info.ChannelInstance.data[12],
++ device_info.ChannelInstance.data[13],
++ device_info.ChannelInstance.data[14],
++ device_info.ChannelInstance.data[15]);
++ } else if (!strcmp(dev_attr->attr.name, "state")) {
+ return sprintf(buf, "%d\n", device_info.ChannelState);
+- }
+- else if (!strcmp(dev_attr->attr.name, "id"))
+- {
++ } else if (!strcmp(dev_attr->attr.name, "id")) {
+ return sprintf(buf, "%d\n", device_info.ChannelId);
+- }
+- else if (!strcmp(dev_attr->attr.name, "out_intr_mask"))
+- {
++ } else if (!strcmp(dev_attr->attr.name, "out_intr_mask")) {
+ return sprintf(buf, "%d\n", device_info.Outbound.InterruptMask);
+- }
+- else if (!strcmp(dev_attr->attr.name, "out_read_index"))
+- {
++ } else if (!strcmp(dev_attr->attr.name, "out_read_index")) {
+ return sprintf(buf, "%d\n", device_info.Outbound.ReadIndex);
+- }
+- else if (!strcmp(dev_attr->attr.name, "out_write_index"))
+- {
++ } else if (!strcmp(dev_attr->attr.name, "out_write_index")) {
+ return sprintf(buf, "%d\n", device_info.Outbound.WriteIndex);
+- }
+- else if (!strcmp(dev_attr->attr.name, "out_read_bytes_avail"))
+- {
+- return sprintf(buf, "%d\n", device_info.Outbound.BytesAvailToRead);
+- }
+- else if (!strcmp(dev_attr->attr.name, "out_write_bytes_avail"))
+- {
+- return sprintf(buf, "%d\n", device_info.Outbound.BytesAvailToWrite);
+- }
+- else if (!strcmp(dev_attr->attr.name, "in_intr_mask"))
+- {
++ } else if (!strcmp(dev_attr->attr.name, "out_read_bytes_avail")) {
++ return sprintf(buf, "%d\n",
++ device_info.Outbound.BytesAvailToRead);
++ } else if (!strcmp(dev_attr->attr.name, "out_write_bytes_avail")) {
++ return sprintf(buf, "%d\n",
++ device_info.Outbound.BytesAvailToWrite);
++ } else if (!strcmp(dev_attr->attr.name, "in_intr_mask")) {
+ return sprintf(buf, "%d\n", device_info.Inbound.InterruptMask);
+- }
+- else if (!strcmp(dev_attr->attr.name, "in_read_index"))
+- {
++ } else if (!strcmp(dev_attr->attr.name, "in_read_index")) {
+ return sprintf(buf, "%d\n", device_info.Inbound.ReadIndex);
+- }
+- else if (!strcmp(dev_attr->attr.name, "in_write_index"))
+- {
++ } else if (!strcmp(dev_attr->attr.name, "in_write_index")) {
+ return sprintf(buf, "%d\n", device_info.Inbound.WriteIndex);
+- }
+- else if (!strcmp(dev_attr->attr.name, "in_read_bytes_avail"))
+- {
+- return sprintf(buf, "%d\n", device_info.Inbound.BytesAvailToRead);
+- }
+- else if (!strcmp(dev_attr->attr.name, "in_write_bytes_avail"))
+- {
+- return sprintf(buf, "%d\n", device_info.Inbound.BytesAvailToWrite);
+- }
+- else if (!strcmp(dev_attr->attr.name, "monitor_id"))
+- {
++ } else if (!strcmp(dev_attr->attr.name, "in_read_bytes_avail")) {
++ return sprintf(buf, "%d\n",
++ device_info.Inbound.BytesAvailToRead);
++ } else if (!strcmp(dev_attr->attr.name, "in_write_bytes_avail")) {
++ return sprintf(buf, "%d\n",
++ device_info.Inbound.BytesAvailToWrite);
++ } else if (!strcmp(dev_attr->attr.name, "monitor_id")) {
+ return sprintf(buf, "%d\n", device_info.MonitorId);
+- }
+- else if (!strcmp(dev_attr->attr.name, "server_monitor_pending"))
+- {
++ } else if (!strcmp(dev_attr->attr.name, "server_monitor_pending")) {
+ return sprintf(buf, "%d\n", device_info.ServerMonitorPending);
+- }
+- else if (!strcmp(dev_attr->attr.name, "server_monitor_latency"))
+- {
++ } else if (!strcmp(dev_attr->attr.name, "server_monitor_latency")) {
+ return sprintf(buf, "%d\n", device_info.ServerMonitorLatency);
+- }
+- else if (!strcmp(dev_attr->attr.name, "server_monitor_conn_id"))
+- {
+- return sprintf(buf, "%d\n", device_info.ServerMonitorConnectionId);
+- }
+- else if (!strcmp(dev_attr->attr.name, "client_monitor_pending"))
+- {
++ } else if (!strcmp(dev_attr->attr.name, "server_monitor_conn_id")) {
++ return sprintf(buf, "%d\n",
++ device_info.ServerMonitorConnectionId);
++ } else if (!strcmp(dev_attr->attr.name, "client_monitor_pending")) {
+ return sprintf(buf, "%d\n", device_info.ClientMonitorPending);
+- }
+- else if (!strcmp(dev_attr->attr.name, "client_monitor_latency"))
+- {
++ } else if (!strcmp(dev_attr->attr.name, "client_monitor_latency")) {
+ return sprintf(buf, "%d\n", device_info.ClientMonitorLatency);
+- }
+- else if (!strcmp(dev_attr->attr.name, "client_monitor_conn_id"))
+- {
+- return sprintf(buf, "%d\n", device_info.ClientMonitorConnectionId);
+- }
+- else
+- {
++ } else if (!strcmp(dev_attr->attr.name, "client_monitor_conn_id")) {
++ return sprintf(buf, "%d\n",
++ device_info.ClientMonitorConnectionId);
++ } else {
+ return 0;
+ }
+ }
+
+-/*++
+-
+-Name: vmbus_show_class_id()
+-
+-Desc: Show the device class id in sysfs
+-
+---*/
+-/* static ssize_t vmbus_show_class_id(struct device *dev, struct device_attribute *attr, char *buf) */
+-/* { */
+-/* struct device_context *device_ctx = device_to_device_context(dev); */
+-/* return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x%02x%02x}\n", */
+-/* device_ctx->class_id[3], device_ctx->class_id[2], device_ctx->class_id[1], device_ctx->class_id[0], */
+-/* device_ctx->class_id[5], device_ctx->class_id[4], */
+-/* device_ctx->class_id[7], device_ctx->class_id[6], */
+-/* device_ctx->class_id[8], device_ctx->class_id[9], device_ctx->class_id[10], device_ctx->class_id[11], device_ctx->class_id[12], device_ctx->class_id[13], device_ctx->class_id[14], device_ctx->class_id[15]); */
+-/* } */
+-
+-/*++
+-
+-Name: vmbus_show_device_id()
+-
+-Desc: Show the device instance id in sysfs
+-
+---*/
+-/* static ssize_t vmbus_show_device_id(struct device *dev, struct device_attribute *attr, char *buf) */
+-/* { */
+-/* struct device_context *device_ctx = device_to_device_context(dev); */
+-/* return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x%02x%02x}\n", */
+-/* device_ctx->device_id[3], device_ctx->device_id[2], device_ctx->device_id[1], device_ctx->device_id[0], */
+-/* device_ctx->device_id[5], device_ctx->device_id[4], */
+-/* device_ctx->device_id[7], device_ctx->device_id[6], */
+-/* device_ctx->device_id[8], device_ctx->device_id[9], device_ctx->device_id[10], device_ctx->device_id[11], device_ctx->device_id[12], device_ctx->device_id[13], device_ctx->device_id[14], device_ctx->device_id[15]); */
+-/* } */
+-
+-/*++
+-
+-Name: vmbus_bus_init()
+-
+-Desc: Main vmbus driver initialization routine. Here, we
+- - initialize the vmbus driver context
+- - setup various driver entry points
+- - invoke the vmbus hv main init routine
+- - get the irq resource
+- - invoke the vmbus to add the vmbus root device
+- - setup the vmbus root device
+- - retrieve the channel offers
+---*/
++/**
++ * vmbus_bus_init -Main vmbus driver initialization routine.
++ *
++ * Here, we
++ * - initialize the vmbus driver context
++ * - setup various driver entry points
++ * - invoke the vmbus hv main init routine
++ * - get the irq resource
++ * - invoke the vmbus to add the vmbus root device
++ * - setup the vmbus root device
++ * - retrieve the channel offers
++ */
+ static int vmbus_bus_init(PFN_DRIVERINITIALIZE pfn_drv_init)
+ {
+- int ret=0;
+- unsigned int vector=0;
+-
+- struct vmbus_driver_context *vmbus_drv_ctx=&g_vmbus_drv;
++ struct vmbus_driver_context *vmbus_drv_ctx = &g_vmbus_drv;
+ struct vmbus_driver *vmbus_drv_obj = &g_vmbus_drv.drv_obj;
+-
+- struct device_context *dev_ctx=&g_vmbus_drv.device_ctx;
++ struct device_context *dev_ctx = &g_vmbus_drv.device_ctx;
++ int ret;
++ unsigned int vector;
+
+ DPRINT_ENTER(VMBUS_DRV);
+
+- /* Set this up to allow lower layer to callback to add/remove child devices on the bus */
++ /*
++ * Set this up to allow lower layer to callback to add/remove child
++ * devices on the bus
++ */
+ vmbus_drv_obj->OnChildDeviceCreate = vmbus_child_device_create;
+ vmbus_drv_obj->OnChildDeviceDestroy = vmbus_child_device_destroy;
+ vmbus_drv_obj->OnChildDeviceAdd = vmbus_child_device_register;
+@@ -339,15 +262,13 @@ static int vmbus_bus_init(PFN_DRIVERINIT
+
+ /* Call to bus driver to initialize */
+ ret = pfn_drv_init(&vmbus_drv_obj->Base);
+- if (ret != 0)
+- {
++ if (ret != 0) {
+ DPRINT_ERR(VMBUS_DRV, "Unable to initialize vmbus (%d)", ret);
+ goto cleanup;
+ }
+
+ /* Sanity checks */
+- if (!vmbus_drv_obj->Base.OnDeviceAdd)
+- {
++ if (!vmbus_drv_obj->Base.OnDeviceAdd) {
+ DPRINT_ERR(VMBUS_DRV, "OnDeviceAdd() routine not set");
+ ret = -1;
+ goto cleanup;
+@@ -356,27 +277,25 @@ static int vmbus_bus_init(PFN_DRIVERINIT
+ vmbus_drv_ctx->bus.name = vmbus_drv_obj->Base.name;
+
+ /* Initialize the bus context */
+- tasklet_init(&vmbus_drv_ctx->msg_dpc, vmbus_msg_dpc, (unsigned long)vmbus_drv_obj);
+- tasklet_init(&vmbus_drv_ctx->event_dpc, vmbus_event_dpc, (unsigned long)vmbus_drv_obj);
++ tasklet_init(&vmbus_drv_ctx->msg_dpc, vmbus_msg_dpc,
++ (unsigned long)vmbus_drv_obj);
++ tasklet_init(&vmbus_drv_ctx->event_dpc, vmbus_event_dpc,
++ (unsigned long)vmbus_drv_obj);
+
+ /* Now, register the bus driver with LDM */
+ ret = bus_register(&vmbus_drv_ctx->bus);
+- if (ret)
+- {
++ if (ret) {
+ ret = -1;
+ goto cleanup;
+ }
+
+ /* Get the interrupt resource */
+- ret = request_irq(vmbus_irq,
+- vmbus_isr,
+- IRQF_SAMPLE_RANDOM,
+- vmbus_drv_obj->Base.name,
+- NULL);
+-
+- if (ret != 0)
+- {
+- DPRINT_ERR(VMBUS_DRV, "ERROR - Unable to request IRQ %d", vmbus_irq);
++ ret = request_irq(vmbus_irq, vmbus_isr, IRQF_SAMPLE_RANDOM,
++ vmbus_drv_obj->Base.name, NULL);
++
++ if (ret != 0) {
++ DPRINT_ERR(VMBUS_DRV, "ERROR - Unable to request IRQ %d",
++ vmbus_irq);
+
+ bus_unregister(&vmbus_drv_ctx->bus);
+
+@@ -391,9 +310,9 @@ static int vmbus_bus_init(PFN_DRIVERINIT
+ memset(dev_ctx, 0, sizeof(struct device_context));
+
+ ret = vmbus_drv_obj->Base.OnDeviceAdd(&dev_ctx->device_obj, &vector);
+- if (ret != 0)
+- {
+- DPRINT_ERR(VMBUS_DRV, "ERROR - Unable to add vmbus root device");
++ if (ret != 0) {
++ DPRINT_ERR(VMBUS_DRV,
++ "ERROR - Unable to add vmbus root device");
+
+ free_irq(vmbus_irq, NULL);
+
+@@ -404,21 +323,24 @@ static int vmbus_bus_init(PFN_DRIVERINIT
+ }
+ /* strcpy(dev_ctx->device.bus_id, dev_ctx->device_obj.name); */
+ dev_set_name(&dev_ctx->device, "vmbus_0_0");
+- memcpy(&dev_ctx->class_id, &dev_ctx->device_obj.deviceType, sizeof(struct hv_guid));
+- memcpy(&dev_ctx->device_id, &dev_ctx->device_obj.deviceInstance, sizeof(struct hv_guid));
++ memcpy(&dev_ctx->class_id, &dev_ctx->device_obj.deviceType,
++ sizeof(struct hv_guid));
++ memcpy(&dev_ctx->device_id, &dev_ctx->device_obj.deviceInstance,
++ sizeof(struct hv_guid));
+
+ /* No need to bind a driver to the root device. */
+ dev_ctx->device.parent = NULL;
+- dev_ctx->device.bus = &vmbus_drv_ctx->bus; /* NULL; vmbus_remove() does not get invoked */
++ /* NULL; vmbus_remove() does not get invoked */
++ dev_ctx->device.bus = &vmbus_drv_ctx->bus;
+
+ /* Setup the device dispatch table */
+ dev_ctx->device.release = vmbus_bus_release;
+
+ /* Setup the bus as root device */
+ ret = device_register(&dev_ctx->device);
+- if (ret)
+- {
+- DPRINT_ERR(VMBUS_DRV, "ERROR - Unable to register vmbus root device");
++ if (ret) {
++ DPRINT_ERR(VMBUS_DRV,
++ "ERROR - Unable to register vmbus root device");
+
+ free_irq(vmbus_irq, NULL);
+ bus_unregister(&vmbus_drv_ctx->bus);
+@@ -436,20 +358,17 @@ cleanup:
+ return ret;
+ }
+
+-
+-/*++
+-
+-Name: vmbus_bus_exit()
+-
+-Desc: Terminate the vmbus driver. This routine is opposite of vmbus_bus_init()
+-
+---*/
++/**
++ * vmbus_bus_exit - Terminate the vmbus driver.
++ *
++ * This routine is opposite of vmbus_bus_init()
++ */
+ static void vmbus_bus_exit(void)
+ {
+ struct vmbus_driver *vmbus_drv_obj = &g_vmbus_drv.drv_obj;
+- struct vmbus_driver_context *vmbus_drv_ctx=&g_vmbus_drv;
++ struct vmbus_driver_context *vmbus_drv_ctx = &g_vmbus_drv;
+
+- struct device_context *dev_ctx=&g_vmbus_drv.device_ctx;
++ struct device_context *dev_ctx = &g_vmbus_drv.device_ctx;
+
+ DPRINT_ENTER(VMBUS_DRV);
+
+@@ -475,21 +394,18 @@ static void vmbus_bus_exit(void)
+ return;
+ }
+
+-/*++
+-
+-Name: vmbus_child_driver_register()
+-
+-Desc: Register a vmbus's child driver
+-
+---*/
+-int vmbus_child_driver_register(struct driver_context* driver_ctx)
++/**
++ * vmbus_child_driver_register - Register a vmbus's child driver
++ */
++int vmbus_child_driver_register(struct driver_context *driver_ctx)
+ {
+ struct vmbus_driver *vmbus_drv_obj = &g_vmbus_drv.drv_obj;
+ int ret;
+
+ DPRINT_ENTER(VMBUS_DRV);
+
+- DPRINT_INFO(VMBUS_DRV, "child driver (%p) registering - name %s", driver_ctx, driver_ctx->driver.name);
++ DPRINT_INFO(VMBUS_DRV, "child driver (%p) registering - name %s",
++ driver_ctx, driver_ctx->driver.name);
+
+ /* The child driver on this vmbus */
+ driver_ctx->driver.bus = &g_vmbus_drv.bus;
+@@ -502,21 +418,17 @@ int vmbus_child_driver_register(struct d
+
+ return ret;
+ }
+-
+ EXPORT_SYMBOL(vmbus_child_driver_register);
+
+-/*++
+-
+-Name: vmbus_child_driver_unregister()
+-
+-Desc: Unregister a vmbus's child driver
+-
+---*/
+-void vmbus_child_driver_unregister(struct driver_context* driver_ctx)
++/**
++ * vmbus_child_driver_unregister Unregister a vmbus's child driver
++ */
++void vmbus_child_driver_unregister(struct driver_context *driver_ctx)
+ {
+ DPRINT_ENTER(VMBUS_DRV);
+
+- DPRINT_INFO(VMBUS_DRV, "child driver (%p) unregistering - name %s", driver_ctx, driver_ctx->driver.name);
++ DPRINT_INFO(VMBUS_DRV, "child driver (%p) unregistering - name %s",
++ driver_ctx, driver_ctx->driver.name);
+
+ driver_unregister(&driver_ctx->driver);
+
+@@ -524,47 +436,37 @@ void vmbus_child_driver_unregister(struc
+
+ DPRINT_EXIT(VMBUS_DRV);
+ }
+-
+ EXPORT_SYMBOL(vmbus_child_driver_unregister);
+
+-/*++
+-
+-Name: vmbus_get_interface()
+-
+-Desc: Get the vmbus channel interface. This is invoked by child/client driver that sits
+- above vmbus
+---*/
++/**
++ * vmbus_get_interface - Get the vmbus channel interface.
++ *
++ * This is invoked by child/client driver that sits above vmbus
++ */
+ void vmbus_get_interface(struct vmbus_channel_interface *interface)
+ {
+ struct vmbus_driver *vmbus_drv_obj = &g_vmbus_drv.drv_obj;
+
+ vmbus_drv_obj->GetChannelInterface(interface);
+ }
+-
+ EXPORT_SYMBOL(vmbus_get_interface);
+
+-
+-/*++
+-
+-Name: vmbus_child_device_get_info()
+-
+-Desc: Get the vmbus child device info. This is invoked to display various device attributes in sysfs.
+---*/
+-static void vmbus_child_device_get_info(struct hv_device *device_obj, struct hv_device_info *device_info)
++/**
++ * vmbus_child_device_get_info - Get the vmbus child device info.
++ *
++ * This is invoked to display various device attributes in sysfs.
++ */
++static void vmbus_child_device_get_info(struct hv_device *device_obj,
++ struct hv_device_info *device_info)
+ {
+ struct vmbus_driver *vmbus_drv_obj = &g_vmbus_drv.drv_obj;
+
+ vmbus_drv_obj->GetChannelInfo(device_obj, device_info);
+ }
+
+-
+-/*++
+-
+-Name: vmbus_child_device_create()
+-
+-Desc: Creates and registers a new child device on the vmbus.
+-
+---*/
++/**
++ * vmbus_child_device_create - Creates and registers a new child device on the vmbus.
++ */
+ static struct hv_device *vmbus_child_device_create(struct hv_guid *type,
+ struct hv_guid *instance,
+ void *context)
+@@ -576,31 +478,38 @@ static struct hv_device *vmbus_child_dev
+
+ /* Allocate the new child device */
+ child_device_ctx = kzalloc(sizeof(struct device_context), GFP_KERNEL);
+- if (!child_device_ctx)
+- {
+- DPRINT_ERR(VMBUS_DRV, "unable to allocate device_context for child device");
++ if (!child_device_ctx) {
++ DPRINT_ERR(VMBUS_DRV,
++ "unable to allocate device_context for child device");
+ DPRINT_EXIT(VMBUS_DRV);
+
+ return NULL;
+ }
+
+ DPRINT_DBG(VMBUS_DRV, "child device (%p) allocated - "
+- "type {%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x%02x%02x},"
+- "id {%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x%02x%02x}",
++ "type {%02x%02x%02x%02x-%02x%02x-%02x%02x-"
++ "%02x%02x%02x%02x%02x%02x%02x%02x},"
++ "id {%02x%02x%02x%02x-%02x%02x-%02x%02x-"
++ "%02x%02x%02x%02x%02x%02x%02x%02x}",
+ &child_device_ctx->device,
+ type->data[3], type->data[2], type->data[1], type->data[0],
+ type->data[5], type->data[4], type->data[7], type->data[6],
+ type->data[8], type->data[9], type->data[10], type->data[11],
+ type->data[12], type->data[13], type->data[14], type->data[15],
+- instance->data[3], instance->data[2], instance->data[1], instance->data[0],
+- instance->data[5], instance->data[4], instance->data[7], instance->data[6],
+- instance->data[8], instance->data[9], instance->data[10], instance->data[11],
+- instance->data[12], instance->data[13], instance->data[14], instance->data[15]);
++ instance->data[3], instance->data[2],
++ instance->data[1], instance->data[0],
++ instance->data[5], instance->data[4],
++ instance->data[7], instance->data[6],
++ instance->data[8], instance->data[9],
++ instance->data[10], instance->data[11],
++ instance->data[12], instance->data[13],
++ instance->data[14], instance->data[15]);
+
+ child_device_obj = &child_device_ctx->device_obj;
+ child_device_obj->context = context;
+ memcpy(&child_device_obj->deviceType, &type, sizeof(struct hv_guid));
+- memcpy(&child_device_obj->deviceInstance, &instance, sizeof(struct hv_guid));
++ memcpy(&child_device_obj->deviceInstance, &instance,
++ sizeof(struct hv_guid));
+
+ memcpy(&child_device_ctx->class_id, &type, sizeof(struct hv_guid));
+ memcpy(&child_device_ctx->device_id, &instance, sizeof(struct hv_guid));
+@@ -610,53 +519,59 @@ static struct hv_device *vmbus_child_dev
+ return child_device_obj;
+ }
+
+-/*++
+-
+-Name: vmbus_child_device_register()
+-
+-Desc: Register the child device on the specified bus
+-
+---*/
+-static int vmbus_child_device_register(struct hv_device *root_device_obj, struct hv_device *child_device_obj)
++/**
++ * vmbus_child_device_register - Register the child device on the specified bus
++ */
++static int vmbus_child_device_register(struct hv_device *root_device_obj,
++ struct hv_device *child_device_obj)
+ {
+- int ret=0;
+- struct device_context *root_device_ctx = to_device_context(root_device_obj);
+- struct device_context *child_device_ctx = to_device_context(child_device_obj);
++ int ret = 0;
++ struct device_context *root_device_ctx =
++ to_device_context(root_device_obj);
++ struct device_context *child_device_ctx =
++ to_device_context(child_device_obj);
+ static atomic_t device_num = ATOMIC_INIT(0);
+
+ DPRINT_ENTER(VMBUS_DRV);
+
+- DPRINT_DBG(VMBUS_DRV, "child device (%p) registering", child_device_ctx);
++ DPRINT_DBG(VMBUS_DRV, "child device (%p) registering",
++ child_device_ctx);
+
+ /* Make sure we are not registered already */
+-
+- if (strlen(dev_name(&child_device_ctx->device)) != 0)
+- {
+- DPRINT_ERR(VMBUS_DRV, "child device (%p) already registered - busid %s", child_device_ctx, dev_name(&child_device_ctx->device));
++ if (strlen(dev_name(&child_device_ctx->device)) != 0) {
++ DPRINT_ERR(VMBUS_DRV,
++ "child device (%p) already registered - busid %s",
++ child_device_ctx,
++ dev_name(&child_device_ctx->device));
+
+ ret = -1;
+ goto Cleanup;
+ }
+
+ /* Set the device bus id. Otherwise, device_register()will fail. */
+- dev_set_name(&child_device_ctx->device, "vmbus_0_%d", atomic_inc_return(&device_num));
++ dev_set_name(&child_device_ctx->device, "vmbus_0_%d",
++ atomic_inc_return(&device_num));
+
+ /* The new device belongs to this bus */
+ child_device_ctx->device.bus = &g_vmbus_drv.bus; /* device->dev.bus; */
+ child_device_ctx->device.parent = &root_device_ctx->device;
+ child_device_ctx->device.release = vmbus_device_release;
+
+- /* Register with the LDM. This will kick off the driver/device binding...which will */
+- /* eventually call vmbus_match() and vmbus_probe() */
++ /*
++ * Register with the LDM. This will kick off the driver/device
++ * binding...which will eventually call vmbus_match() and vmbus_probe()
++ */
+ ret = device_register(&child_device_ctx->device);
+
+ /* vmbus_probe() error does not get propergate to device_register(). */
+ ret = child_device_ctx->probe_error;
+
+ if (ret)
+- DPRINT_ERR(VMBUS_DRV, "unable to register child device (%p)", &child_device_ctx->device);
++ DPRINT_ERR(VMBUS_DRV, "unable to register child device (%p)",
++ &child_device_ctx->device);
+ else
+- DPRINT_INFO(VMBUS_DRV, "child device (%p) registered", &child_device_ctx->device);
++ DPRINT_INFO(VMBUS_DRV, "child device (%p) registered",
++ &child_device_ctx->device);
+
+ Cleanup:
+ DPRINT_EXIT(VMBUS_DRV);
+@@ -664,38 +579,33 @@ Cleanup:
+ return ret;
+ }
+
+-/*++
+-
+-Name: vmbus_child_device_unregister()
+-
+-Desc: Remove the specified child device from the vmbus.
+-
+---*/
++/**
++ * vmbus_child_device_unregister - Remove the specified child device from the vmbus.
++ */
+ static void vmbus_child_device_unregister(struct hv_device *device_obj)
+ {
+ struct device_context *device_ctx = to_device_context(device_obj);
+
+ DPRINT_ENTER(VMBUS_DRV);
+
+- DPRINT_INFO(VMBUS_DRV, "unregistering child device (%p)", &device_ctx->device);
++ DPRINT_INFO(VMBUS_DRV, "unregistering child device (%p)",
++ &device_ctx->device);
+
+- /* Kick off the process of unregistering the device. */
+- /* This will call vmbus_remove() and eventually vmbus_device_release() */
++ /*
++ * Kick off the process of unregistering the device.
++ * This will call vmbus_remove() and eventually vmbus_device_release()
++ */
+ device_unregister(&device_ctx->device);
+
+- DPRINT_INFO(VMBUS_DRV, "child device (%p) unregistered", &device_ctx->device);
++ DPRINT_INFO(VMBUS_DRV, "child device (%p) unregistered",
++ &device_ctx->device);
+
+ DPRINT_EXIT(VMBUS_DRV);
+ }
+
+-
+-/*++
+-
+-Name: vmbus_child_device_destroy()
+-
+-Desc: Destroy the specified child device on the vmbus.
+-
+---*/
++/**
++ * vmbus_child_device_destroy - Destroy the specified child device on the vmbus.
++ */
+ static void vmbus_child_device_destroy(struct hv_device *device_obj)
+ {
+ DPRINT_ENTER(VMBUS_DRV);
+@@ -703,66 +613,83 @@ static void vmbus_child_device_destroy(s
+ DPRINT_EXIT(VMBUS_DRV);
+ }
+
+-/*++
+-
+-Name: vmbus_uevent()
+-
+-Desc: 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
+-
+---*/
++/**
++ * vmbus_uevent - add uevent for our device
++ *
++ * 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
++ */
+ static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env)
+ {
+ struct device_context *device_ctx = device_to_device_context(device);
+- int i=0;
+- int len=0;
++ int i = 0;
++ int len = 0;
+ int ret;
+
+ DPRINT_ENTER(VMBUS_DRV);
+
+- DPRINT_INFO(VMBUS_DRV, "generating uevent - VMBUS_DEVICE_CLASS_GUID={%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x%02x%02x}",
+- device_ctx->class_id.data[3], device_ctx->class_id.data[2],
+- device_ctx->class_id.data[1], device_ctx->class_id.data[0],
+- device_ctx->class_id.data[5], device_ctx->class_id.data[4],
+- device_ctx->class_id.data[7], device_ctx->class_id.data[6],
+- device_ctx->class_id.data[8], device_ctx->class_id.data[9],
+- device_ctx->class_id.data[10], device_ctx->class_id.data[11],
+- device_ctx->class_id.data[12], device_ctx->class_id.data[13],
+- device_ctx->class_id.data[14], device_ctx->class_id.data[15]);
++ DPRINT_INFO(VMBUS_DRV, "generating uevent - VMBUS_DEVICE_CLASS_GUID={"
++ "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
++ "%02x%02x%02x%02x%02x%02x%02x%02x}",
++ device_ctx->class_id.data[3], device_ctx->class_id.data[2],
++ device_ctx->class_id.data[1], device_ctx->class_id.data[0],
++ device_ctx->class_id.data[5], device_ctx->class_id.data[4],
++ device_ctx->class_id.data[7], device_ctx->class_id.data[6],
++ device_ctx->class_id.data[8], device_ctx->class_id.data[9],
++ device_ctx->class_id.data[10],
++ device_ctx->class_id.data[11],
++ device_ctx->class_id.data[12],
++ device_ctx->class_id.data[13],
++ device_ctx->class_id.data[14],
++ device_ctx->class_id.data[15]);
+
+ env->envp_idx = i;
+ env->buflen = len;
+- 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}",
+- device_ctx->class_id.data[3], device_ctx->class_id.data[2],
+- device_ctx->class_id.data[1], device_ctx->class_id.data[0],
+- device_ctx->class_id.data[5], device_ctx->class_id.data[4],
+- device_ctx->class_id.data[7], device_ctx->class_id.data[6],
+- device_ctx->class_id.data[8], device_ctx->class_id.data[9],
+- device_ctx->class_id.data[10], device_ctx->class_id.data[11],
+- device_ctx->class_id.data[12], device_ctx->class_id.data[13],
+- device_ctx->class_id.data[14], device_ctx->class_id.data[15]);
++ 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}",
++ device_ctx->class_id.data[3],
++ device_ctx->class_id.data[2],
++ device_ctx->class_id.data[1],
++ device_ctx->class_id.data[0],
++ device_ctx->class_id.data[5],
++ device_ctx->class_id.data[4],
++ device_ctx->class_id.data[7],
++ device_ctx->class_id.data[6],
++ device_ctx->class_id.data[8],
++ device_ctx->class_id.data[9],
++ device_ctx->class_id.data[10],
++ device_ctx->class_id.data[11],
++ device_ctx->class_id.data[12],
++ device_ctx->class_id.data[13],
++ device_ctx->class_id.data[14],
++ device_ctx->class_id.data[15]);
+
+ if (ret)
+- {
+ return ret;
+- }
+-
+- 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}",
+- device_ctx->device_id.data[3], device_ctx->device_id.data[2],
+- device_ctx->device_id.data[1], device_ctx->device_id.data[0],
+- device_ctx->device_id.data[5], device_ctx->device_id.data[4],
+- device_ctx->device_id.data[7], device_ctx->device_id.data[6],
+- device_ctx->device_id.data[8], device_ctx->device_id.data[9],
+- device_ctx->device_id.data[10], device_ctx->device_id.data[11],
+- device_ctx->device_id.data[12], device_ctx->device_id.data[13],
+- device_ctx->device_id.data[14], device_ctx->device_id.data[15]);
+
++ 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}",
++ device_ctx->device_id.data[3],
++ device_ctx->device_id.data[2],
++ device_ctx->device_id.data[1],
++ device_ctx->device_id.data[0],
++ device_ctx->device_id.data[5],
++ device_ctx->device_id.data[4],
++ device_ctx->device_id.data[7],
++ device_ctx->device_id.data[6],
++ device_ctx->device_id.data[8],
++ device_ctx->device_id.data[9],
++ device_ctx->device_id.data[10],
++ device_ctx->device_id.data[11],
++ device_ctx->device_id.data[12],
++ device_ctx->device_id.data[13],
++ device_ctx->device_id.data[14],
++ device_ctx->device_id.data[15]);
+ if (ret)
+- {
+ return ret;
+- }
+
+ env->envp[env->envp_idx] = NULL;
+
+@@ -771,29 +698,32 @@ static int vmbus_uevent(struct device *d
+ return 0;
+ }
+
+-/*++
+-
+-Name: vmbus_match()
+-
+-Desc: Attempt to match the specified device to the specified driver
+-
+---*/
++/**
++ * 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;
++ int match = 0;
+ struct driver_context *driver_ctx = driver_to_driver_context(driver);
+ struct device_context *device_ctx = device_to_device_context(device);
+
+ DPRINT_ENTER(VMBUS_DRV);
+
+ /* We found our driver ? */
+- if (memcmp(&device_ctx->class_id, &driver_ctx->class_id, sizeof(struct hv_guid)) == 0)
+- {
+- /* !! NOTE: The driver_ctx is not a vmbus_drv_ctx. We typecast it here to access the */
+- /* struct hv_driver field */
+- struct vmbus_driver_context *vmbus_drv_ctx = (struct vmbus_driver_context*)driver_ctx;
++ if (memcmp(&device_ctx->class_id, &driver_ctx->class_id,
++ sizeof(struct hv_guid)) == 0) {
++ /*
++ * !! NOTE: The driver_ctx is not a vmbus_drv_ctx. We typecast
++ * it here to access the struct hv_driver field
++ */
++ struct vmbus_driver_context *vmbus_drv_ctx =
++ (struct vmbus_driver_context *)driver_ctx;
++
+ device_ctx->device_obj.Driver = &vmbus_drv_ctx->drv_obj.Base;
+- DPRINT_INFO(VMBUS_DRV, "device object (%p) set to driver object (%p)", &device_ctx->device_obj, device_ctx->device_obj.Driver);
++ DPRINT_INFO(VMBUS_DRV,
++ "device object (%p) set to driver object (%p)",
++ &device_ctx->device_obj,
++ device_ctx->device_obj.Driver);
+
+ match = 1;
+ }
+@@ -803,62 +733,58 @@ static int vmbus_match(struct device *de
+ return match;
+ }
+
+-
+-/*++
+-
+-Name: vmbus_probe_failed_cb()
+-
+-Desc: Callback when a driver probe failed in vmbus_probe(). We need a callback because
+- we cannot invoked device_unregister() inside vmbus_probe() since vmbus_probe() may be
+- invoked inside device_register() i.e. we cannot call device_unregister() inside
+- device_register()
+---*/
++/**
++ * vmbus_probe_failed_cb - Callback when a driver probe failed in vmbus_probe()
++ *
++ * We need a callback because we cannot invoked device_unregister() inside
++ * vmbus_probe() since vmbus_probe() may be invoked inside device_register()
++ * i.e. we cannot call device_unregister() inside device_register()
++ */
+ static void vmbus_probe_failed_cb(struct work_struct *context)
+ {
+- struct device_context *device_ctx = (struct device_context*)context;
+-
++ struct device_context *device_ctx = (struct device_context *)context;
+
+ DPRINT_ENTER(VMBUS_DRV);
+
+- /* Kick off the process of unregistering the device. */
+- /* This will call vmbus_remove() and eventually vmbus_device_release() */
++ /*
++ * Kick off the process of unregistering the device.
++ * This will call vmbus_remove() and eventually vmbus_device_release()
++ */
+ device_unregister(&device_ctx->device);
+
+ /* put_device(&device_ctx->device); */
+ DPRINT_EXIT(VMBUS_DRV);
+ }
+
+-
+-/*++
+-
+-Name: vmbus_probe()
+-
+-Desc: Add the new vmbus's child device
+-
+---*/
++/**
++ * vmbus_probe - Add the new vmbus's child device
++ */
+ static int vmbus_probe(struct device *child_device)
+ {
+- int ret=0;
+- struct driver_context *driver_ctx = driver_to_driver_context(child_device->driver);
+- struct device_context *device_ctx = device_to_device_context(child_device);
++ int ret = 0;
++ struct driver_context *driver_ctx =
++ driver_to_driver_context(child_device->driver);
++ struct device_context *device_ctx =
++ device_to_device_context(child_device);
+
+ DPRINT_ENTER(VMBUS_DRV);
+
+ /* Let the specific open-source driver handles the probe if it can */
+- if (driver_ctx->probe)
+- {
++ if (driver_ctx->probe) {
+ ret = device_ctx->probe_error = driver_ctx->probe(child_device);
+- if (ret != 0)
+- {
+- DPRINT_ERR(VMBUS_DRV, "probe() failed for device %s (%p) on driver %s (%d)...", dev_name(child_device), child_device, child_device->driver->name, ret);
++ if (ret != 0) {
++ DPRINT_ERR(VMBUS_DRV, "probe() failed for device %s "
++ "(%p) on driver %s (%d)...",
++ dev_name(child_device), child_device,
++ child_device->driver->name, ret);
+
+- INIT_WORK(&device_ctx->probe_failed_work_item, vmbus_probe_failed_cb);
++ INIT_WORK(&device_ctx->probe_failed_work_item,
++ vmbus_probe_failed_cb);
+ schedule_work(&device_ctx->probe_failed_work_item);
+ }
+- }
+- else
+- {
+- DPRINT_ERR(VMBUS_DRV, "probe() method not set for driver - %s", child_device->driver->name);
++ } else {
++ DPRINT_ERR(VMBUS_DRV, "probe() method not set for driver - %s",
++ child_device->driver->name);
+ ret = -1;
+ }
+
+@@ -866,61 +792,51 @@ static int vmbus_probe(struct device *ch
+ return ret;
+ }
+
+-
+-/*++
+-
+-Name: vmbus_remove()
+-
+-Desc: Remove a vmbus device
+-
+---*/
++/**
++ * vmbus_remove - Remove a vmbus device
++ */
+ static int vmbus_remove(struct device *child_device)
+ {
+- int ret=0;
++ int ret;
+ struct driver_context *driver_ctx;
+
+ DPRINT_ENTER(VMBUS_DRV);
+
+ /* Special case root bus device */
+- if (child_device->parent == NULL)
+- {
+- /* No-op since it is statically defined and handle in vmbus_bus_exit() */
++ if (child_device->parent == NULL) {
++ /*
++ * No-op since it is statically defined and handle in
++ * vmbus_bus_exit()
++ */
+ DPRINT_EXIT(VMBUS_DRV);
+ return 0;
+ }
+
+- if (child_device->driver)
+- {
++ if (child_device->driver) {
+ driver_ctx = driver_to_driver_context(child_device->driver);
+
+- /* Let the specific open-source driver handles the removal if it can */
+- if (driver_ctx->remove)
+- {
++ /*
++ * Let the specific open-source driver handles the removal if
++ * it can
++ */
++ if (driver_ctx->remove) {
+ ret = driver_ctx->remove(child_device);
+- }
+- else
+- {
+- DPRINT_ERR(VMBUS_DRV, "remove() method not set for driver - %s", child_device->driver->name);
++ } else {
++ DPRINT_ERR(VMBUS_DRV,
++ "remove() method not set for driver - %s",
++ child_device->driver->name);
+ ret = -1;
+ }
+ }
+- else
+- {
+-
+- }
+
+ DPRINT_EXIT(VMBUS_DRV);
+
+ return 0;
+ }
+
+-/*++
+-
+-Name: vmbus_shutdown()
+-
+-Desc: Shutdown a vmbus device
+-
+---*/
++/**
++ * vmbus_shutdown - Shutdown a vmbus device
++ */
+ static void vmbus_shutdown(struct device *child_device)
+ {
+ struct driver_context *driver_ctx;
+@@ -928,16 +844,17 @@ static void vmbus_shutdown(struct device
+ DPRINT_ENTER(VMBUS_DRV);
+
+ /* Special case root bus device */
+- if (child_device->parent == NULL)
+- {
+- /* No-op since it is statically defined and handle in vmbus_bus_exit() */
++ if (child_device->parent == NULL) {
++ /*
++ * No-op since it is statically defined and handle in
++ * vmbus_bus_exit()
++ */
+ DPRINT_EXIT(VMBUS_DRV);
+ return;
+ }
+
+ /* The device may not be attached yet */
+- if (!child_device->driver)
+- {
++ if (!child_device->driver) {
+ DPRINT_EXIT(VMBUS_DRV);
+ return;
+ }
+@@ -946,22 +863,16 @@ static void vmbus_shutdown(struct device
+
+ /* Let the specific open-source driver handles the removal if it can */
+ if (driver_ctx->shutdown)
+- {
+ driver_ctx->shutdown(child_device);
+- }
+
+ DPRINT_EXIT(VMBUS_DRV);
+
+ return;
+ }
+
+-/*++
+-
+-Name: vmbus_bus_release()
+-
+-Desc: Final callback release of the vmbus root device
+-
+---*/
++/**
++ * vmbus_bus_release - Final callback release of the vmbus root device
++ */
+ static void vmbus_bus_release(struct device *device)
+ {
+ DPRINT_ENTER(VMBUS_DRV);
+@@ -973,13 +884,9 @@ static void vmbus_bus_release(struct dev
+ DPRINT_EXIT(VMBUS_DRV);
+ }
+
+-/*++
+-
+-Name: vmbus_device_release()
+-
+-Desc: Final callback release of the vmbus child device
+-
+---*/
++/**
++ * vmbus_device_release - Final callback release of the vmbus child device
++ */
+ static void vmbus_device_release(struct device *device)
+ {
+ struct device_context *device_ctx = device_to_device_context(device);
+@@ -990,19 +897,14 @@ static void vmbus_device_release(struct
+ kfree(device_ctx);
+
+ /* !!DO NOT REFERENCE device_ctx anymore at this point!! */
+-
+ DPRINT_EXIT(VMBUS_DRV);
+
+ return;
+ }
+
+-/*++
+-
+-Name: vmbus_msg_dpc()
+-
+-Desc: Tasklet routine to handle hypervisor messages
+-
+---*/
++/**
++ * vmbus_msg_dpc - Tasklet routine to handle hypervisor messages
++ */
+ static void vmbus_msg_dpc(unsigned long data)
+ {
+ struct vmbus_driver *vmbus_drv_obj = (struct vmbus_driver *)data;
+@@ -1017,13 +919,9 @@ static void vmbus_msg_dpc(unsigned long
+ DPRINT_EXIT(VMBUS_DRV);
+ }
+
+-/*++
+-
+-Name: vmbus_msg_dpc()
+-
+-Desc: Tasklet routine to handle hypervisor events
+-
+---*/
++/**
++ * vmbus_msg_dpc - Tasklet routine to handle hypervisor events
++ */
+ static void vmbus_event_dpc(unsigned long data)
+ {
+ struct vmbus_driver *vmbus_drv_obj = (struct vmbus_driver *)data;
+@@ -1038,17 +936,10 @@ static void vmbus_event_dpc(unsigned lon
+ DPRINT_EXIT(VMBUS_DRV);
+ }
+
+-/*++
+-
+-Name: vmbus_msg_dpc()
+-
+-Desc: ISR routine
+-
+---*/
+-static irqreturn_t vmbus_isr(int irq, void* dev_id)
++static irqreturn_t vmbus_isr(int irq, void *dev_id)
+ {
+- int ret=0;
+ struct vmbus_driver *vmbus_driver_obj = &g_vmbus_drv.drv_obj;
++ int ret;
+
+ DPRINT_ENTER(VMBUS_DRV);
+
+@@ -1058,48 +949,31 @@ static irqreturn_t vmbus_isr(int irq, vo
+ ret = vmbus_driver_obj->OnIsr(&vmbus_driver_obj->Base);
+
+ /* Schedules a dpc if necessary */
+- if (ret > 0)
+- {
+- if (test_bit(0, (unsigned long*)&ret))
+- {
++ if (ret > 0) {
++ if (test_bit(0, (unsigned long *)&ret))
+ tasklet_schedule(&g_vmbus_drv.msg_dpc);
+- }
+
+- if (test_bit(1, (unsigned long*)&ret))
+- {
++ if (test_bit(1, (unsigned long *)&ret))
+ tasklet_schedule(&g_vmbus_drv.event_dpc);
+- }
+
+ DPRINT_EXIT(VMBUS_DRV);
+ return IRQ_HANDLED;
+- }
+- else
+- {
++ } else {
+ DPRINT_EXIT(VMBUS_DRV);
+ return IRQ_NONE;
+ }
+ }
+
+-MODULE_LICENSE("GPL");
+-
+-
+-/*++
+-
+-Name: vmbus_init()
+-
+-Desc: Main vmbus driver entry routine
+-
+---*/
+ static int __init vmbus_init(void)
+ {
+- int ret=0;
++ int ret = 0;
+
+ DPRINT_ENTER(VMBUS_DRV);
+
+ DPRINT_INFO(VMBUS_DRV,
+ "Vmbus initializing.... current log level 0x%x (%x,%x)",
+ vmbus_loglevel, HIWORD(vmbus_loglevel), LOWORD(vmbus_loglevel));
+-/* Todo: it is used for loglevel, to be ported to new kernel. */
++ /* Todo: it is used for loglevel, to be ported to new kernel. */
+
+ ret = vmbus_bus_init(VmbusInitialize);
+
+@@ -1107,29 +981,19 @@ static int __init vmbus_init(void)
+ return ret;
+ }
+
+-
+-
+-/*++
+-
+-Name: vmbus_init()
+-
+-Desc: Main vmbus driver exit routine
+-
+---*/
+ static void __exit vmbus_exit(void)
+ {
+ DPRINT_ENTER(VMBUS_DRV);
+
+ vmbus_bus_exit();
+-/* Todo: it is used for loglevel, to be ported to new kernel. */
++ /* Todo: it is used for loglevel, to be ported to new kernel. */
+ DPRINT_EXIT(VMBUS_DRV);
+-
+ return;
+ }
+
++MODULE_LICENSE("GPL");
+ module_param(vmbus_irq, int, S_IRUGO);
+ module_param(vmbus_loglevel, int, S_IRUGO);
+
+ module_init(vmbus_init);
+ module_exit(vmbus_exit);
+-/* eof */
diff --git a/staging/staging-hv-remove-function-pointer-typedefs-from-netvscapi.h.patch b/staging/staging-hv-remove-function-pointer-typedefs-from-netvscapi.h.patch
new file mode 100644
index 00000000000000..8048acb57e83df
--- /dev/null
+++ b/staging/staging-hv-remove-function-pointer-typedefs-from-netvscapi.h.patch
@@ -0,0 +1,90 @@
+From foo@baz Wed Sep 2 11:24:48 PDT 2009
+Date: Wed, 02 Sep 2009 11:24:48 -0700
+To: Greg KH <greg@kroah.com>
+From: Greg Kroah-Hartman <gregkh@suse.de>
+Subject: Staging: hv: remove function pointer typedefs from NetVscApi.h
+
+function pointer typedefs are allowed in the kernel, but only if they
+make sense, which they really do not here, as they are not passed around
+with any kind of frequency. So just spell them all out, it makes the
+code smaller and easier to understand overall.
+
+Cc: Hank Janssen <hjanssen@microsoft.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+---
+ drivers/staging/hv/NetVscApi.h | 32 ++++++++------------------------
+ drivers/staging/hv/RndisFilter.c | 2 +-
+ 2 files changed, 9 insertions(+), 25 deletions(-)
+
+--- a/drivers/staging/hv/NetVscApi.h
++++ b/drivers/staging/hv/NetVscApi.h
+@@ -35,19 +35,6 @@
+ /* Fwd declaration */
+ struct hv_netvsc_packet;
+
+-/* Data types */
+-typedef int (*PFN_ON_OPEN)(struct hv_device *Device);
+-typedef int (*PFN_ON_CLOSE)(struct hv_device *Device);
+-
+-typedef void (*PFN_QUERY_LINKSTATUS)(struct hv_device *Device);
+-typedef int (*PFN_ON_SEND)(struct hv_device *dev,
+- struct hv_netvsc_packet *packet);
+-typedef void (*PFN_ON_SENDRECVCOMPLETION)(void *Context);
+-
+-typedef int (*PFN_ON_RECVCALLBACK)(struct hv_device *dev,
+- struct hv_netvsc_packet *packet);
+-typedef void (*PFN_ON_LINKSTATUS_CHANGED)(struct hv_device *dev, u32 Status);
+-
+ /* Represent the xfer page packet which contains 1 or more netvsc packet */
+ struct xferpage_packet {
+ LIST_ENTRY ListEntry;
+@@ -80,12 +67,12 @@ struct hv_netvsc_packet {
+ struct{
+ u64 ReceiveCompletionTid;
+ void *ReceiveCompletionContext;
+- PFN_ON_SENDRECVCOMPLETION OnReceiveCompletion;
++ void (*OnReceiveCompletion)(void *context);
+ } Recv;
+ struct{
+ u64 SendCompletionTid;
+ void *SendCompletionContext;
+- PFN_ON_SENDRECVCOMPLETION OnSendCompletion;
++ void (*OnSendCompletion)(void *context);
+ } Send;
+ } Completion;
+
+@@ -114,17 +101,14 @@ struct netvsc_driver {
+ * This is set by the caller to allow us to callback when we
+ * receive a packet from the "wire"
+ */
+- PFN_ON_RECVCALLBACK OnReceiveCallback;
+-
+- PFN_ON_LINKSTATUS_CHANGED OnLinkStatusChanged;
++ int (*OnReceiveCallback)(struct hv_device *dev,
++ struct hv_netvsc_packet *packet);
++ void (*OnLinkStatusChanged)(struct hv_device *dev, u32 Status);
+
+ /* Specific to this driver */
+- PFN_ON_OPEN OnOpen;
+- PFN_ON_CLOSE OnClose;
+- PFN_ON_SEND OnSend;
+- /* PFN_ON_RECVCOMPLETION OnReceiveCompletion; */
+-
+- /* PFN_QUERY_LINKSTATUS QueryLinkStatus; */
++ int (*OnOpen)(struct hv_device *dev);
++ int (*OnClose)(struct hv_device *dev);
++ int (*OnSend)(struct hv_device *dev, struct hv_netvsc_packet *packet);
+
+ void *Context;
+ };
+--- a/drivers/staging/hv/RndisFilter.c
++++ b/drivers/staging/hv/RndisFilter.c
+@@ -73,7 +73,7 @@ struct rndis_request {
+
+ struct rndis_filter_packet {
+ void *CompletionContext;
+- PFN_ON_SENDRECVCOMPLETION OnCompletion;
++ void (*OnCompletion)(void *context);
+ struct rndis_message Message;
+ };
+
diff --git a/staging/staging-hv-remove-function-pointer-typedefs-from-storvscapi.h.patch b/staging/staging-hv-remove-function-pointer-typedefs-from-storvscapi.h.patch
new file mode 100644
index 00000000000000..b02345e96e6dce
--- /dev/null
+++ b/staging/staging-hv-remove-function-pointer-typedefs-from-storvscapi.h.patch
@@ -0,0 +1,59 @@
+From foo@baz Wed Sep 2 11:28:55 PDT 2009
+Date: Wed, 02 Sep 2009 11:28:55 -0700
+To: Greg KH <greg@kroah.com>
+From: Greg Kroah-Hartman <gregkh@suse.de>
+Subject: Staging: hv: remove function pointer typedefs from StorVscApi.h
+
+function pointer typedefs are allowed in the kernel, but only if they
+make sense, which they really do not here, as they are not passed around
+with any kind of frequency. So just spell them all out, it makes the
+code smaller and easier to understand overall.
+
+Cc: Hank Janssen <hjanssen@microsoft.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+---
+ drivers/staging/hv/StorVscApi.h | 17 +++++------------
+ 1 file changed, 5 insertions(+), 12 deletions(-)
+
+--- a/drivers/staging/hv/StorVscApi.h
++++ b/drivers/staging/hv/StorVscApi.h
+@@ -45,14 +45,6 @@
+
+ struct hv_storvsc_request;
+
+-/* Data types */
+-typedef int (*PFN_ON_IO_REQUEST)(struct hv_device *Device,
+- struct hv_storvsc_request *Request);
+-typedef void (*PFN_ON_IO_REQUEST_COMPLTN)(struct hv_storvsc_request *Request);
+-
+-typedef int (*PFN_ON_HOST_RESET)(struct hv_device *Device);
+-typedef void (*PFN_ON_HOST_RESCAN)(struct hv_device *Device);
+-
+ /* Matches Windows-end */
+ enum storvsc_request_type{
+ WRITE_TYPE,
+@@ -76,7 +68,7 @@ struct hv_storvsc_request {
+
+ void *Context;
+
+- PFN_ON_IO_REQUEST_COMPLTN OnIOCompletion;
++ void (*OnIOCompletion)(struct hv_storvsc_request *Request);
+
+ /* This points to the memory after DataBuffer */
+ void *Extension;
+@@ -100,11 +92,12 @@ struct storvsc_driver_object {
+ u32 MaxOutstandingRequestsPerChannel;
+
+ /* Set by the caller to allow us to re-enumerate the bus on the host */
+- PFN_ON_HOST_RESCAN OnHostRescan;
++ void (*OnHostRescan)(struct hv_device *Device);
+
+ /* Specific to this driver */
+- PFN_ON_IO_REQUEST OnIORequest;
+- PFN_ON_HOST_RESET OnHostReset;
++ int (*OnIORequest)(struct hv_device *Device,
++ struct hv_storvsc_request *Request);
++ int (*OnHostReset)(struct hv_device *Device);
+ };
+
+ struct storvsc_device_info {
diff --git a/staging/staging-hv-remove-function-pointer-typedefs-from-vmbus.h.patch b/staging/staging-hv-remove-function-pointer-typedefs-from-vmbus.h.patch
new file mode 100644
index 00000000000000..2b115a631a78f5
--- /dev/null
+++ b/staging/staging-hv-remove-function-pointer-typedefs-from-vmbus.h.patch
@@ -0,0 +1,117 @@
+From foo@baz Wed Sep 2 11:53:59 PDT 2009
+Date: Wed, 02 Sep 2009 11:53:59 -0700
+To: Greg KH <greg@kroah.com>
+From: Greg Kroah-Hartman <gregkh@suse.de>
+Subject: Staging: hv: remove function pointer typedefs from vmbus.h
+
+It's amazing the hoops that people go through to make code work
+when they don't opensource the whole thing. Passing these types
+of function pointers around for no good reason is a mess, this needs
+to be unwound as everything is now in the open.
+
+Cc: Hank Janssen <hjanssen@microsoft.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ drivers/staging/hv/blkvsc_drv.c | 4 ++--
+ drivers/staging/hv/netvsc_drv.c | 4 ++--
+ drivers/staging/hv/storvsc_drv.c | 4 ++--
+ drivers/staging/hv/vmbus.h | 4 ----
+ drivers/staging/hv/vmbus_drv.c | 4 ++--
+ 5 files changed, 8 insertions(+), 12 deletions(-)
+
+--- a/drivers/staging/hv/blkvsc_drv.c
++++ b/drivers/staging/hv/blkvsc_drv.c
+@@ -165,7 +165,7 @@ static struct block_device_operations bl
+ /**
+ * blkvsc_drv_init - BlkVsc driver initialization.
+ */
+-static int blkvsc_drv_init(PFN_DRIVERINITIALIZE pfn_drv_init)
++static int blkvsc_drv_init(int (*drv_init)(struct hv_driver *drv))
+ {
+ struct storvsc_driver_object *storvsc_drv_obj = &g_blkvsc_drv.drv_obj;
+ struct driver_context *drv_ctx = &g_blkvsc_drv.drv_ctx;
+@@ -178,7 +178,7 @@ static int blkvsc_drv_init(PFN_DRIVERINI
+ storvsc_drv_obj->RingBufferSize = blkvsc_ringbuffer_size;
+
+ /* Callback to client driver to complete the initialization */
+- pfn_drv_init(&storvsc_drv_obj->Base);
++ drv_init(&storvsc_drv_obj->Base);
+
+ drv_ctx->driver.name = storvsc_drv_obj->Base.name;
+ memcpy(&drv_ctx->class_id, &storvsc_drv_obj->Base.deviceType,
+--- a/drivers/staging/hv/netvsc_drv.c
++++ b/drivers/staging/hv/netvsc_drv.c
+@@ -559,7 +559,7 @@ static void netvsc_drv_exit(void)
+ return;
+ }
+
+-static int netvsc_drv_init(PFN_DRIVERINITIALIZE pfn_drv_init)
++static int netvsc_drv_init(int (*drv_init)(struct hv_driver *drv))
+ {
+ struct netvsc_driver *net_drv_obj = &g_netvsc_drv.drv_obj;
+ struct driver_context *drv_ctx = &g_netvsc_drv.drv_ctx;
+@@ -574,7 +574,7 @@ static int netvsc_drv_init(PFN_DRIVERINI
+ net_drv_obj->OnLinkStatusChanged = netvsc_linkstatus_callback;
+
+ /* Callback to client driver to complete the initialization */
+- pfn_drv_init(&net_drv_obj->Base);
++ drv_init(&net_drv_obj->Base);
+
+ drv_ctx->driver.name = net_drv_obj->Base.name;
+ memcpy(&drv_ctx->class_id, &net_drv_obj->Base.deviceType,
+--- a/drivers/staging/hv/storvsc_drv.c
++++ b/drivers/staging/hv/storvsc_drv.c
+@@ -137,7 +137,7 @@ static struct scsi_host_template scsi_dr
+ /**
+ * storvsc_drv_init - StorVsc driver initialization.
+ */
+-static int storvsc_drv_init(PFN_DRIVERINITIALIZE pfn_drv_init)
++static int storvsc_drv_init(int (*drv_init)(struct hv_driver *drv))
+ {
+ int ret;
+ struct storvsc_driver_object *storvsc_drv_obj = &g_storvsc_drv.drv_obj;
+@@ -151,7 +151,7 @@ static int storvsc_drv_init(PFN_DRIVERIN
+ storvsc_drv_obj->OnHostRescan = storvsc_host_rescan;
+
+ /* Callback to client driver to complete the initialization */
+- pfn_drv_init(&storvsc_drv_obj->Base);
++ drv_init(&storvsc_drv_obj->Base);
+
+ DPRINT_INFO(STORVSC_DRV,
+ "request extension size %u, max outstanding reqs %u",
+--- a/drivers/staging/hv/vmbus_drv.c
++++ b/drivers/staging/hv/vmbus_drv.c
+@@ -241,7 +241,7 @@ static ssize_t vmbus_show_device_attr(st
+ * - setup the vmbus root device
+ * - retrieve the channel offers
+ */
+-static int vmbus_bus_init(PFN_DRIVERINITIALIZE pfn_drv_init)
++static int vmbus_bus_init(int (*drv_init)(struct hv_driver *drv))
+ {
+ struct vmbus_driver_context *vmbus_drv_ctx = &g_vmbus_drv;
+ struct vmbus_driver *vmbus_drv_obj = &g_vmbus_drv.drv_obj;
+@@ -261,7 +261,7 @@ static int vmbus_bus_init(PFN_DRIVERINIT
+ vmbus_drv_obj->OnChildDeviceRemove = vmbus_child_device_unregister;
+
+ /* Call to bus driver to initialize */
+- ret = pfn_drv_init(&vmbus_drv_obj->Base);
++ ret = drv_init(&vmbus_drv_obj->Base);
+ if (ret != 0) {
+ DPRINT_ERR(VMBUS_DRV, "Unable to initialize vmbus (%d)", ret);
+ goto cleanup;
+--- a/drivers/staging/hv/vmbus.h
++++ b/drivers/staging/hv/vmbus.h
+@@ -26,12 +26,8 @@
+ #define _VMBUS_H_
+
+ #include <linux/device.h>
+-
+ #include "VmbusApi.h"
+
+-typedef int (*PFN_DRIVERINITIALIZE)(struct hv_driver *drv);
+-typedef int (*PFN_DRIVEREXIT)(struct hv_driver *drv);
+-
+ struct driver_context {
+ struct hv_guid class_id;
+
diff --git a/staging/staging-hv-remove-function-pointer-typedefs-from-vmbusapi.h.patch b/staging/staging-hv-remove-function-pointer-typedefs-from-vmbusapi.h.patch
new file mode 100644
index 00000000000000..b91505704d98f3
--- /dev/null
+++ b/staging/staging-hv-remove-function-pointer-typedefs-from-vmbusapi.h.patch
@@ -0,0 +1,205 @@
+From foo@baz Wed Sep 2 11:18:10 PDT 2009
+Date: Wed, 02 Sep 2009 11:18:10 -0700
+To: Greg KH <greg@kroah.com>
+From: Greg Kroah-Hartman <gregkh@suse.de>
+Subject: Staging: hv: remove function pointer typedefs from VmbusApi.h
+
+function pointer typedefs are allowed in the kernel, but only if they
+make sense, which they really do not here, as they are not passed around
+with any kind of frequency. So just spell them all out, it makes the
+code smaller and easier to understand overall.
+
+Cc: Hank Janssen <hjanssen@microsoft.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ drivers/staging/hv/ChannelInterface.c | 2
+ drivers/staging/hv/VmbusApi.h | 140 ++++++++++------------------------
+ 2 files changed, 43 insertions(+), 99 deletions(-)
+
+--- a/drivers/staging/hv/ChannelInterface.c
++++ b/drivers/staging/hv/ChannelInterface.c
+@@ -28,7 +28,7 @@
+ static int IVmbusChannelOpen(struct hv_device *device, u32 SendBufferSize,
+ u32 RecvRingBufferSize, void *UserData,
+ u32 UserDataLen,
+- VMBUS_CHANNEL_CALLBACK ChannelCallback,
++ void (*ChannelCallback)(void *context),
+ void *Context)
+ {
+ return VmbusChannelOpen(device->context, SendBufferSize,
+--- a/drivers/staging/hv/VmbusApi.h
++++ b/drivers/staging/hv/VmbusApi.h
+@@ -58,72 +58,6 @@ struct hv_multipage_buffer {
+ struct hv_driver;
+ struct hv_device;
+
+-/* All drivers */
+-typedef int (*PFN_ON_DEVICEADD)(struct hv_device *Device,
+- void *AdditionalInfo);
+-typedef int (*PFN_ON_DEVICEREMOVE)(struct hv_device *Device);
+-typedef char** (*PFN_ON_GETDEVICEIDS)(void);
+-typedef void (*PFN_ON_CLEANUP)(struct hv_driver *Driver);
+-
+-/* Vmbus extensions */
+-typedef int (*PFN_ON_ISR)(struct hv_driver *drv);
+-typedef void (*PFN_ON_DPC)(struct hv_driver *drv);
+-typedef void (*PFN_GET_CHANNEL_OFFERS)(void);
+-
+-typedef struct hv_device * (*PFN_ON_CHILDDEVICE_CREATE)
+- (struct hv_guid *DeviceType,
+- struct hv_guid *DeviceInstance,
+- void *Context);
+-typedef void (*PFN_ON_CHILDDEVICE_DESTROY)(struct hv_device *Device);
+-typedef int (*PFN_ON_CHILDDEVICE_ADD)(struct hv_device *RootDevice,
+- struct hv_device *ChildDevice);
+-typedef void (*PFN_ON_CHILDDEVICE_REMOVE)(struct hv_device *Device);
+-
+-/* Vmbus channel interface */
+-typedef void (*VMBUS_CHANNEL_CALLBACK)(void *context);
+-typedef int (*VMBUS_CHANNEL_OPEN)(struct hv_device *Device, u32 SendBufferSize,
+- u32 RecvRingBufferSize,
+- void *UserData,
+- u32 UserDataLen,
+- VMBUS_CHANNEL_CALLBACK ChannelCallback,
+- void *Context);
+-typedef void (*VMBUS_CHANNEL_CLOSE)(struct hv_device *Device);
+-typedef int (*VMBUS_CHANNEL_SEND_PACKET)(struct hv_device *Device,
+- const void *Buffer,
+- u32 BufferLen,
+- u64 RequestId,
+- u32 Type,
+- u32 Flags);
+-typedef int (*VMBUS_CHANNEL_SEND_PACKET_PAGEBUFFER)(struct hv_device *Device,
+- struct hv_page_buffer PageBuffers[],
+- u32 PageCount,
+- void *Buffer,
+- u32 BufferLen,
+- u64 RequestId);
+-typedef int (*VMBUS_CHANNEL_SEND_PACKET_MULTIPAGEBUFFER)
+- (struct hv_device *Device,
+- struct hv_multipage_buffer *mpb,
+- void *Buffer,
+- u32 BufferLen,
+- u64 RequestId);
+-typedef int (*VMBUS_CHANNEL_RECV_PACKET)(struct hv_device *Device,
+- void *Buffer,
+- u32 BufferLen,
+- u32 *BufferActualLen,
+- u64 *RequestId);
+-typedef int(*VMBUS_CHANNEL_RECV_PACKET_PAW)(struct hv_device *Device,
+- void *Buffer,
+- u32 BufferLen,
+- u32 *BufferActualLen,
+- u64 *RequestId);
+-typedef int (*VMBUS_CHANNEL_ESTABLISH_GPADL)(struct hv_device *Device,
+- void *Buffer,
+- u32 BufferLen,
+- u32 *GpadlHandle);
+-typedef int (*VMBUS_CHANNEL_TEARDOWN_GPADL)(struct hv_device *Device,
+- u32 GpadlHandle);
+-
+-
+ struct hv_dev_port_info {
+ u32 InterruptMask;
+ u32 ReadIndex;
+@@ -150,24 +84,33 @@ struct hv_device_info {
+ struct hv_dev_port_info Outbound;
+ };
+
+-typedef void (*VMBUS_GET_CHANNEL_INFO)(struct hv_device *Device,
+- struct hv_device_info *DeviceInfo);
+-
+ struct vmbus_channel_interface {
+- VMBUS_CHANNEL_OPEN Open;
+- VMBUS_CHANNEL_CLOSE Close;
+- VMBUS_CHANNEL_SEND_PACKET SendPacket;
+- VMBUS_CHANNEL_SEND_PACKET_PAGEBUFFER SendPacketPageBuffer;
+- VMBUS_CHANNEL_SEND_PACKET_MULTIPAGEBUFFER SendPacketMultiPageBuffer;
+- VMBUS_CHANNEL_RECV_PACKET RecvPacket;
+- VMBUS_CHANNEL_RECV_PACKET_PAW RecvPacketRaw;
+- VMBUS_CHANNEL_ESTABLISH_GPADL EstablishGpadl;
+- VMBUS_CHANNEL_TEARDOWN_GPADL TeardownGpadl;
+- VMBUS_GET_CHANNEL_INFO GetInfo;
++ int (*Open)(struct hv_device *Device, u32 SendBufferSize,
++ u32 RecvRingBufferSize, void *UserData, u32 UserDataLen,
++ void (*ChannelCallback)(void *context),
++ void *Context);
++ void (*Close)(struct hv_device *device);
++ int (*SendPacket)(struct hv_device *Device, const void *Buffer,
++ u32 BufferLen, u64 RequestId, u32 Type, u32 Flags);
++ int (*SendPacketPageBuffer)(struct hv_device *dev,
++ struct hv_page_buffer PageBuffers[],
++ u32 PageCount, void *Buffer, u32 BufferLen,
++ u64 RequestId);
++ int (*SendPacketMultiPageBuffer)(struct hv_device *device,
++ struct hv_multipage_buffer *mpb,
++ void *Buffer,
++ u32 BufferLen,
++ u64 RequestId);
++ int (*RecvPacket)(struct hv_device *dev, void *buf, u32 buflen,
++ u32 *BufferActualLen, u64 *RequestId);
++ int (*RecvPacketRaw)(struct hv_device *dev, void *buf, u32 buflen,
++ u32 *BufferActualLen, u64 *RequestId);
++ int (*EstablishGpadl)(struct hv_device *dev, void *buf, u32 buflen,
++ u32 *GpadlHandle);
++ int (*TeardownGpadl)(struct hv_device *device, u32 GpadlHandle);
++ void (*GetInfo)(struct hv_device *dev, struct hv_device_info *devinfo);
+ };
+
+-typedef void (*VMBUS_GET_CHANNEL_INTERFACE)(struct vmbus_channel_interface *i);
+-
+ /* Base driver object */
+ struct hv_driver {
+ const char *name;
+@@ -175,12 +118,9 @@ struct hv_driver {
+ /* the device type supported by this driver */
+ struct hv_guid deviceType;
+
+- PFN_ON_DEVICEADD OnDeviceAdd;
+- PFN_ON_DEVICEREMOVE OnDeviceRemove;
+-
+- /* device ids supported by this driver */
+- PFN_ON_GETDEVICEIDS OnGetDeviceIds;
+- PFN_ON_CLEANUP OnCleanup;
++ int (*OnDeviceAdd)(struct hv_device *device, void *data);
++ int (*OnDeviceRemove)(struct hv_device *device);
++ void (*OnCleanup)(struct hv_driver *driver);
+
+ struct vmbus_channel_interface VmbusChannelInterface;
+ };
+@@ -211,19 +151,23 @@ struct vmbus_driver {
+ struct hv_driver Base;
+
+ /* Set by the caller */
+- PFN_ON_CHILDDEVICE_CREATE OnChildDeviceCreate;
+- PFN_ON_CHILDDEVICE_DESTROY OnChildDeviceDestroy;
+- PFN_ON_CHILDDEVICE_ADD OnChildDeviceAdd;
+- PFN_ON_CHILDDEVICE_REMOVE OnChildDeviceRemove;
++ struct hv_device * (*OnChildDeviceCreate)(struct hv_guid *DeviceType,
++ struct hv_guid *DeviceInstance,
++ void *Context);
++ void (*OnChildDeviceDestroy)(struct hv_device *device);
++ int (*OnChildDeviceAdd)(struct hv_device *RootDevice,
++ struct hv_device *ChildDevice);
++ void (*OnChildDeviceRemove)(struct hv_device *device);
+
+ /* Set by the callee */
+- PFN_ON_ISR OnIsr;
+- PFN_ON_DPC OnMsgDpc;
+- PFN_ON_DPC OnEventDpc;
+- PFN_GET_CHANNEL_OFFERS GetChannelOffers;
+-
+- VMBUS_GET_CHANNEL_INTERFACE GetChannelInterface;
+- VMBUS_GET_CHANNEL_INFO GetChannelInfo;
++ int (*OnIsr)(struct hv_driver *driver);
++ void (*OnMsgDpc)(struct hv_driver *driver);
++ void (*OnEventDpc)(struct hv_driver *driver);
++ void (*GetChannelOffers)(void);
++
++ void (*GetChannelInterface)(struct vmbus_channel_interface *i);
++ void (*GetChannelInfo)(struct hv_device *dev,
++ struct hv_device_info *devinfo);
+ };
+
+ int VmbusInitialize(struct hv_driver *drv);
diff --git a/staging/staging-hv-remove-pfn_channel_callback.patch b/staging/staging-hv-remove-pfn_channel_callback.patch
new file mode 100644
index 00000000000000..0d8c60c9049059
--- /dev/null
+++ b/staging/staging-hv-remove-pfn_channel_callback.patch
@@ -0,0 +1,70 @@
+From foo@baz Wed Sep 2 11:44:19 PDT 2009
+Date: Wed, 02 Sep 2009 11:44:19 -0700
+To: Greg KH <greg@kroah.com>
+From: Greg Kroah-Hartman <gregkh@suse.de>
+Subject: Staging: hv: remove PFN_CHANNEL_CALLBACK
+
+Come on people, it doesn't get simpler than this, why
+have a typedef for something so tiny...
+
+Cc: Hank Janssen <hjanssen@microsoft.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+
+---
+ drivers/staging/hv/Channel.c | 4 ++--
+ drivers/staging/hv/Channel.h | 2 +-
+ drivers/staging/hv/ChannelMgmt.h | 4 +---
+ 3 files changed, 4 insertions(+), 6 deletions(-)
+
+--- a/drivers/staging/hv/Channel.c
++++ b/drivers/staging/hv/Channel.c
+@@ -169,7 +169,7 @@ void VmbusChannelGetDebugInfo(struct vmb
+ */
+ int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize,
+ u32 RecvRingBufferSize, void *UserData, u32 UserDataLen,
+- PFN_CHANNEL_CALLBACK pfnOnChannelCallback, void *Context)
++ void (*OnChannelCallback)(void *context), void *Context)
+ {
+ struct vmbus_channel_open_channel *openMsg;
+ struct vmbus_channel_msginfo *openInfo;
+@@ -183,7 +183,7 @@ int VmbusChannelOpen(struct vmbus_channe
+ ASSERT(!(SendRingBufferSize & (PAGE_SIZE - 1)));
+ ASSERT(!(RecvRingBufferSize & (PAGE_SIZE - 1)));
+
+- NewChannel->OnChannelCallback = pfnOnChannelCallback;
++ NewChannel->OnChannelCallback = OnChannelCallback;
+ NewChannel->ChannelCallbackContext = Context;
+
+ /* Allocate the ring buffer */
+--- a/drivers/staging/hv/Channel.h
++++ b/drivers/staging/hv/Channel.h
+@@ -57,7 +57,7 @@ extern int VmbusChannelOpen(struct vmbus
+ u32 RecvRingBufferSize,
+ void *UserData,
+ u32 UserDataLen,
+- PFN_CHANNEL_CALLBACK pfnOnChannelCallback,
++ void(*OnChannelCallback)(void *context),
+ void *Context);
+
+ extern void VmbusChannelClose(struct vmbus_channel *channel);
+--- a/drivers/staging/hv/ChannelMgmt.h
++++ b/drivers/staging/hv/ChannelMgmt.h
+@@ -218,8 +218,6 @@ struct vmbus_channel_version_response {
+ bool VersionSupported;
+ } __attribute__((packed));
+
+-typedef void (*PFN_CHANNEL_CALLBACK)(void *context);
+-
+ enum vmbus_channel_state {
+ CHANNEL_OFFER_STATE,
+ CHANNEL_OPENING_STATE,
+@@ -256,7 +254,7 @@ struct vmbus_channel {
+ /* Channel callback are invoked in this workqueue context */
+ /* HANDLE dataWorkQueue; */
+
+- PFN_CHANNEL_CALLBACK OnChannelCallback;
++ void (*OnChannelCallback)(void *context);
+ void *ChannelCallbackContext;
+ };
+
diff --git a/staging/staging-hv-rename-struct-netvsc_device.patch b/staging/staging-hv-rename-struct-netvsc_device.patch
new file mode 100644
index 00000000000000..cee4f6bc93469e
--- /dev/null
+++ b/staging/staging-hv-rename-struct-netvsc_device.patch
@@ -0,0 +1,301 @@
+From foo@baz Wed Sep 2 10:35:56 PDT 2009
+Date: Wed, 02 Sep 2009 10:35:56 -0700
+To: Greg KH <greg@kroah.com>
+From: Greg Kroah-Hartman <gregkh@suse.de>
+Subject: Staging: hv: rename struct NETVSC_DEVICE
+
+The Linux kernel doesn't have all caps structures, we don't like to
+shout at our programmers, it makes them grumpy. Instead, we like to
+sooth them with small, rounded letters, which puts them in a nice,
+compliant mood, and makes them more productive and happier, allowing
+them more fufilling lives overall.
+
+
+Cc: Hank Janssen <hjanssen@microsoft.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ drivers/staging/hv/NetVsc.c | 56 +++++++++++++++++++--------------------
+ drivers/staging/hv/NetVsc.h | 2 -
+ drivers/staging/hv/RndisFilter.c | 12 ++++----
+ 3 files changed, 35 insertions(+), 35 deletions(-)
+
+--- a/drivers/staging/hv/NetVsc.c
++++ b/drivers/staging/hv/NetVsc.c
+@@ -50,9 +50,9 @@ static int NetVscInitializeSendBufferWit
+
+ static int NetVscInitializeReceiveBufferWithNetVsp(struct hv_device *Device);
+
+-static int NetVscDestroySendBuffer(struct NETVSC_DEVICE *NetDevice);
++static int NetVscDestroySendBuffer(struct netvsc_device *NetDevice);
+
+-static int NetVscDestroyReceiveBuffer(struct NETVSC_DEVICE *NetDevice);
++static int NetVscDestroyReceiveBuffer(struct netvsc_device *NetDevice);
+
+ static int NetVscConnectToVsp(struct hv_device *Device);
+
+@@ -71,11 +71,11 @@ static void NetVscSendReceiveCompletion(
+ u64 TransactionId);
+
+
+-static struct NETVSC_DEVICE *AllocNetDevice(struct hv_device *Device)
++static struct netvsc_device *AllocNetDevice(struct hv_device *Device)
+ {
+- struct NETVSC_DEVICE *netDevice;
++ struct netvsc_device *netDevice;
+
+- netDevice = kzalloc(sizeof(struct NETVSC_DEVICE), GFP_KERNEL);
++ netDevice = kzalloc(sizeof(struct netvsc_device), GFP_KERNEL);
+ if (!netDevice)
+ return NULL;
+
+@@ -88,7 +88,7 @@ static struct NETVSC_DEVICE *AllocNetDev
+ return netDevice;
+ }
+
+-static void FreeNetDevice(struct NETVSC_DEVICE *Device)
++static void FreeNetDevice(struct netvsc_device *Device)
+ {
+ ASSERT(atomic_read(&Device->RefCount) == 0);
+ Device->Device->Extension = NULL;
+@@ -97,9 +97,9 @@ static void FreeNetDevice(struct NETVSC_
+
+
+ /* Get the net device object iff exists and its refcount > 1 */
+-static struct NETVSC_DEVICE *GetOutboundNetDevice(struct hv_device *Device)
++static struct netvsc_device *GetOutboundNetDevice(struct hv_device *Device)
+ {
+- struct NETVSC_DEVICE *netDevice;
++ struct netvsc_device *netDevice;
+
+ netDevice = Device->Extension;
+ if (netDevice && atomic_read(&netDevice->RefCount) > 1)
+@@ -111,9 +111,9 @@ static struct NETVSC_DEVICE *GetOutbound
+ }
+
+ /* Get the net device object iff exists and its refcount > 0 */
+-static struct NETVSC_DEVICE *GetInboundNetDevice(struct hv_device *Device)
++static struct netvsc_device *GetInboundNetDevice(struct hv_device *Device)
+ {
+- struct NETVSC_DEVICE *netDevice;
++ struct netvsc_device *netDevice;
+
+ netDevice = Device->Extension;
+ if (netDevice && atomic_read(&netDevice->RefCount))
+@@ -126,7 +126,7 @@ static struct NETVSC_DEVICE *GetInboundN
+
+ static void PutNetDevice(struct hv_device *Device)
+ {
+- struct NETVSC_DEVICE *netDevice;
++ struct netvsc_device *netDevice;
+
+ netDevice = Device->Extension;
+ ASSERT(netDevice);
+@@ -134,9 +134,9 @@ static void PutNetDevice(struct hv_devic
+ atomic_dec(&netDevice->RefCount);
+ }
+
+-static struct NETVSC_DEVICE *ReleaseOutboundNetDevice(struct hv_device *Device)
++static struct netvsc_device *ReleaseOutboundNetDevice(struct hv_device *Device)
+ {
+- struct NETVSC_DEVICE *netDevice;
++ struct netvsc_device *netDevice;
+
+ netDevice = Device->Extension;
+ if (netDevice == NULL)
+@@ -149,9 +149,9 @@ static struct NETVSC_DEVICE *ReleaseOutb
+ return netDevice;
+ }
+
+-static struct NETVSC_DEVICE *ReleaseInboundNetDevice(struct hv_device *Device)
++static struct netvsc_device *ReleaseInboundNetDevice(struct hv_device *Device)
+ {
+- struct NETVSC_DEVICE *netDevice;
++ struct netvsc_device *netDevice;
+
+ netDevice = Device->Extension;
+ if (netDevice == NULL)
+@@ -208,7 +208,7 @@ int NetVscInitialize(struct hv_driver *d
+ static int NetVscInitializeReceiveBufferWithNetVsp(struct hv_device *Device)
+ {
+ int ret = 0;
+- struct NETVSC_DEVICE *netDevice;
++ struct netvsc_device *netDevice;
+ struct nvsp_message *initPacket;
+
+ DPRINT_ENTER(NETVSC);
+@@ -339,7 +339,7 @@ Exit:
+ static int NetVscInitializeSendBufferWithNetVsp(struct hv_device *Device)
+ {
+ int ret = 0;
+- struct NETVSC_DEVICE *netDevice;
++ struct netvsc_device *netDevice;
+ struct nvsp_message *initPacket;
+
+ DPRINT_ENTER(NETVSC);
+@@ -431,7 +431,7 @@ Exit:
+ return ret;
+ }
+
+-static int NetVscDestroyReceiveBuffer(struct NETVSC_DEVICE *NetDevice)
++static int NetVscDestroyReceiveBuffer(struct netvsc_device *NetDevice)
+ {
+ struct nvsp_message *revokePacket;
+ int ret = 0;
+@@ -511,7 +511,7 @@ static int NetVscDestroyReceiveBuffer(st
+ return ret;
+ }
+
+-static int NetVscDestroySendBuffer(struct NETVSC_DEVICE *NetDevice)
++static int NetVscDestroySendBuffer(struct netvsc_device *NetDevice)
+ {
+ struct nvsp_message *revokePacket;
+ int ret = 0;
+@@ -589,7 +589,7 @@ static int NetVscDestroySendBuffer(struc
+ static int NetVscConnectToVsp(struct hv_device *Device)
+ {
+ int ret;
+- struct NETVSC_DEVICE *netDevice;
++ struct netvsc_device *netDevice;
+ struct nvsp_message *initPacket;
+ int ndisVersion;
+
+@@ -693,7 +693,7 @@ Cleanup:
+ return ret;
+ }
+
+-static void NetVscDisconnectFromVsp(struct NETVSC_DEVICE *NetDevice)
++static void NetVscDisconnectFromVsp(struct netvsc_device *NetDevice)
+ {
+ DPRINT_ENTER(NETVSC);
+
+@@ -710,7 +710,7 @@ static int NetVscOnDeviceAdd(struct hv_d
+ {
+ int ret = 0;
+ int i;
+- struct NETVSC_DEVICE *netDevice;
++ struct netvsc_device *netDevice;
+ struct hv_netvsc_packet *packet;
+ LIST_ENTRY *entry;
+ struct netvsc_driver *netDriver =
+@@ -813,7 +813,7 @@ Cleanup:
+ */
+ static int NetVscOnDeviceRemove(struct hv_device *Device)
+ {
+- struct NETVSC_DEVICE *netDevice;
++ struct netvsc_device *netDevice;
+ struct hv_netvsc_packet *netvscPacket;
+ LIST_ENTRY *entry;
+
+@@ -881,7 +881,7 @@ static void NetVscOnCleanup(struct hv_dr
+ static void NetVscOnSendCompletion(struct hv_device *Device,
+ struct vmpacket_descriptor *Packet)
+ {
+- struct NETVSC_DEVICE *netDevice;
++ struct netvsc_device *netDevice;
+ struct nvsp_message *nvspPacket;
+ struct hv_netvsc_packet *nvscPacket;
+
+@@ -931,7 +931,7 @@ static void NetVscOnSendCompletion(struc
+ static int NetVscOnSend(struct hv_device *Device,
+ struct hv_netvsc_packet *Packet)
+ {
+- struct NETVSC_DEVICE *netDevice;
++ struct netvsc_device *netDevice;
+ int ret = 0;
+
+ struct nvsp_message sendMessage;
+@@ -990,7 +990,7 @@ static int NetVscOnSend(struct hv_device
+ static void NetVscOnReceive(struct hv_device *Device,
+ struct vmpacket_descriptor *Packet)
+ {
+- struct NETVSC_DEVICE *netDevice;
++ struct netvsc_device *netDevice;
+ struct vmtransfer_page_packet_header *vmxferpagePacket;
+ struct nvsp_message *nvspPacket;
+ struct hv_netvsc_packet *netvscPacket = NULL;
+@@ -1255,7 +1255,7 @@ static void NetVscOnReceiveCompletion(vo
+ {
+ struct hv_netvsc_packet *packet = Context;
+ struct hv_device *device = (struct hv_device *)packet->Device;
+- struct NETVSC_DEVICE *netDevice;
++ struct netvsc_device *netDevice;
+ u64 transactionId = 0;
+ bool fSendReceiveComp = false;
+ unsigned long flags;
+@@ -1312,7 +1312,7 @@ void NetVscOnChannelCallback(void *Conte
+ const int netPacketSize = 2048;
+ int ret;
+ struct hv_device *device = Context;
+- struct NETVSC_DEVICE *netDevice;
++ struct netvsc_device *netDevice;
+ u32 bytesRecvd;
+ u64 requestId;
+ unsigned char packet[netPacketSize];
+--- a/drivers/staging/hv/NetVsc.h
++++ b/drivers/staging/hv/NetVsc.h
+@@ -290,7 +290,7 @@ struct nvsp_message {
+
+
+ /* Per netvsc channel-specific */
+-struct NETVSC_DEVICE {
++struct netvsc_device {
+ struct hv_device *Device;
+
+ atomic_t RefCount;
+--- a/drivers/staging/hv/RndisFilter.c
++++ b/drivers/staging/hv/RndisFilter.c
+@@ -40,7 +40,7 @@ enum rndis_device_state {
+ };
+
+ struct rndis_device {
+- struct NETVSC_DEVICE *NetDevice;
++ struct netvsc_device *NetDevice;
+
+ enum rndis_device_state State;
+ u32 LinkStatus;
+@@ -390,7 +390,7 @@ static void RndisFilterReceiveData(struc
+ static int RndisFilterOnReceive(struct hv_device *Device,
+ struct hv_netvsc_packet *Packet)
+ {
+- struct NETVSC_DEVICE *netDevice = Device->Extension;
++ struct netvsc_device *netDevice = Device->Extension;
+ struct rndis_device *rndisDevice;
+ struct rndis_message rndisMessage;
+ struct rndis_message *rndisHeader;
+@@ -791,7 +791,7 @@ static int RndisFilterOnDeviceAdd(struct
+ void *AdditionalInfo)
+ {
+ int ret;
+- struct NETVSC_DEVICE *netDevice;
++ struct netvsc_device *netDevice;
+ struct rndis_device *rndisDevice;
+ struct netvsc_device_info *deviceInfo = AdditionalInfo;
+
+@@ -867,7 +867,7 @@ static int RndisFilterOnDeviceAdd(struct
+
+ static int RndisFilterOnDeviceRemove(struct hv_device *Device)
+ {
+- struct NETVSC_DEVICE *netDevice = Device->Extension;
++ struct netvsc_device *netDevice = Device->Extension;
+ struct rndis_device *rndisDevice = netDevice->Extension;
+
+ DPRINT_ENTER(NETVSC);
+@@ -896,7 +896,7 @@ static void RndisFilterOnCleanup(struct
+ static int RndisFilterOnOpen(struct hv_device *Device)
+ {
+ int ret;
+- struct NETVSC_DEVICE *netDevice = Device->Extension;
++ struct netvsc_device *netDevice = Device->Extension;
+
+ DPRINT_ENTER(NETVSC);
+
+@@ -911,7 +911,7 @@ static int RndisFilterOnOpen(struct hv_d
+ static int RndisFilterOnClose(struct hv_device *Device)
+ {
+ int ret;
+- struct NETVSC_DEVICE *netDevice = Device->Extension;
++ struct netvsc_device *netDevice = Device->Extension;
+
+ DPRINT_ENTER(NETVSC);
+