Staging: hv: hv_mouse: fix camelcase use of struct synthhid_msg_hdr
[pandora-kernel.git] / drivers / staging / hv / hv_mouse.c
index 5fc14a2..b7e75e0 100644 (file)
 /*
  * Data types
  */
-struct input_dev_info {
-       unsigned short VendorID;
-       unsigned short ProductID;
-       unsigned short VersionNumber;
-       char           Name[128];
+struct hv_input_dev_info {
+       unsigned short vendor;
+       unsigned short product;
+       unsigned short version;
+       char name[128];
 };
 
 /* Represents the input vsc driver */
+/* FIXME - can be removed entirely */
 struct mousevsc_drv_obj {
-       struct hv_driver Base; // Must be the first field
-       /*
-        * This is set by the caller to allow us to callback when
-        * we receive a packet from the "wire"
-        */
-       void (*OnDeviceInfo)(struct hv_device *dev,
-                            struct input_dev_info* info);
-       void (*OnInputReport)(struct hv_device *dev, void* packet, u32 len);
-       void (*OnReportDescriptor)(struct hv_device *dev,
-                                  void* packet, u32 len);
-       /* Specific to this driver */
-       int (*OnOpen)(struct hv_device *Device);
-       int (*OnClose)(struct hv_device *Device);
-       void *Context;
+       struct hv_driver Base;
 };
 
 
@@ -95,14 +83,12 @@ enum synthhid_msg_type {
  * Basic message structures.
  */
 struct synthhid_msg_hdr {
-       enum synthhid_msg_type  Type;    /* Type of the enclosed message */
-       u32                     Size;    /* Size of the enclosed message
-                                         *  (size of the data payload)
-                                         */
+       enum synthhid_msg_type type;
+       u32 size;
 };
 
 struct synthhid_msg {
-       struct synthhid_msg_hdr Header;
+       struct synthhid_msg_hdr header;
        char                    Data[1]; /* Enclosed message */
 };
 
@@ -119,29 +105,29 @@ union synthhid_version {
  * Protocol messages
  */
 struct synthhid_protocol_request {
-       struct synthhid_msg_hdr Header;
+       struct synthhid_msg_hdr header;
        union synthhid_version VersionRequested;
 };
 
 struct synthhid_protocol_response {
-       struct synthhid_msg_hdr Header;
+       struct synthhid_msg_hdr header;
        union synthhid_version VersionRequested;
        unsigned char Approved;
 };
 
 struct synthhid_device_info {
-       struct synthhid_msg_hdr     Header;
-       struct input_dev_info       HidDeviceAttributes;
+       struct synthhid_msg_hdr header;
+       struct hv_input_dev_info    HidDeviceAttributes;
        unsigned char               HidDescriptorInformation[1];
 };
 
 struct synthhid_device_info_ack {
-       struct synthhid_msg_hdr Header;
+       struct synthhid_msg_hdr header;
        unsigned char           Reserved;
 };
 
 struct synthhid_input_report {
-       struct synthhid_msg_hdr Header;
+       struct synthhid_msg_hdr header;
        char                    ReportBuffer[1];
 };
 
@@ -199,7 +185,7 @@ struct mousevsc_dev {
        struct hid_descriptor   *HidDesc;
        unsigned char           *ReportDesc;
        u32                     ReportDescSize;
-       struct input_dev_info   DeviceAttr;
+       struct hv_input_dev_info DeviceAttr;
 };
 
 
@@ -214,23 +200,14 @@ static const struct hv_guid gMousevscDeviceType = {
                 0xB9, 0x8B, 0x8B, 0xA1, 0xA1, 0xF3, 0xF9, 0x5A}
 };
 
-/*
- * Internal routines
- */
-static int MousevscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo);
-
-static int MousevscOnDeviceRemove(struct hv_device *Device);
-
-static void MousevscOnCleanup(struct hv_driver *Device);
-
-static void MousevscOnChannelCallback(void *Context);
-
-static int MousevscConnectToVsp(struct hv_device *Device);
-
 static void MousevscOnReceive(struct hv_device *Device,
                              struct vmpacket_descriptor *Packet);
 
-static inline struct mousevsc_dev *AllocInputDevice(struct hv_device *Device)
+static void deviceinfo_callback(struct hv_device *dev, struct hv_input_dev_info *info);
+static void inputreport_callback(struct hv_device *dev, void *packet, u32 len);
+static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len);
+
+static struct mousevsc_dev *AllocInputDevice(struct hv_device *Device)
 {
        struct mousevsc_dev *inputDevice;
 
@@ -251,7 +228,7 @@ static inline struct mousevsc_dev *AllocInputDevice(struct hv_device *Device)
        return inputDevice;
 }
 
-static inline void FreeInputDevice(struct mousevsc_dev *Device)
+static void FreeInputDevice(struct mousevsc_dev *Device)
 {
        WARN_ON(atomic_read(&Device->RefCount) == 0);
        kfree(Device);
@@ -260,7 +237,7 @@ static inline void FreeInputDevice(struct mousevsc_dev *Device)
 /*
  * Get the inputdevice object if exists and its refcount > 1
  */
-static inline struct mousevsc_dev *GetInputDevice(struct hv_device *Device)
+static struct mousevsc_dev *GetInputDevice(struct hv_device *Device)
 {
        struct mousevsc_dev *inputDevice;
 
@@ -286,7 +263,7 @@ static inline struct mousevsc_dev *GetInputDevice(struct hv_device *Device)
 /*
  * Get the inputdevice object iff exists and its refcount > 0
  */
-static inline struct mousevsc_dev *MustGetInputDevice(struct hv_device *Device)
+static struct mousevsc_dev *MustGetInputDevice(struct hv_device *Device)
 {
        struct mousevsc_dev *inputDevice;
 
@@ -300,7 +277,7 @@ static inline struct mousevsc_dev *MustGetInputDevice(struct hv_device *Device)
        return inputDevice;
 }
 
-static inline void PutInputDevice(struct hv_device *Device)
+static void PutInputDevice(struct hv_device *Device)
 {
        struct mousevsc_dev *inputDevice;
 
@@ -312,7 +289,7 @@ static inline void PutInputDevice(struct hv_device *Device)
 /*
  * Drop ref count to 1 to effectively disable GetInputDevice()
  */
-static inline struct mousevsc_dev *ReleaseInputDevice(struct hv_device *Device)
+static struct mousevsc_dev *ReleaseInputDevice(struct hv_device *Device)
 {
        struct mousevsc_dev *inputDevice;
 
@@ -328,7 +305,7 @@ static inline struct mousevsc_dev *ReleaseInputDevice(struct hv_device *Device)
 /*
  * Drop ref count to 0. No one can use InputDevice object.
  */
-static inline struct mousevsc_dev *FinalReleaseInputDevice(struct hv_device *Device)
+static struct mousevsc_dev *FinalReleaseInputDevice(struct hv_device *Device)
 {
        struct mousevsc_dev *inputDevice;
 
@@ -342,252 +319,7 @@ static inline struct mousevsc_dev *FinalReleaseInputDevice(struct hv_device *Dev
        return inputDevice;
 }
 
-static int mouse_vsc_initialize(struct hv_driver *Driver)
-{
-       struct mousevsc_drv_obj *inputDriver =
-               (struct mousevsc_drv_obj *)Driver;
-       int ret = 0;
-
-       Driver->name = gDriverName;
-       memcpy(&Driver->dev_type, &gMousevscDeviceType,
-              sizeof(struct hv_guid));
-
-       /* Setup the dispatch table */
-       inputDriver->Base.dev_add               = MousevscOnDeviceAdd;
-       inputDriver->Base.dev_rm = MousevscOnDeviceRemove;
-       inputDriver->Base.cleanup               = MousevscOnCleanup;
-
-       inputDriver->OnOpen                     = NULL;
-       inputDriver->OnClose                    = NULL;
-
-       return ret;
-}
-
-/*
- *
- * Name:
- *     MousevscOnDeviceAdd()
- *
- * Description:
- *     Callback when the device belonging to this driver is added
- *
- */
-int
-MousevscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo)
-{
-       int ret = 0;
-       struct mousevsc_dev *inputDevice;
-       struct mousevsc_drv_obj *inputDriver;
-       struct input_dev_info deviceInfo;
-
-       inputDevice = AllocInputDevice(Device);
-
-       if (!inputDevice) {
-               ret = -1;
-               goto Cleanup;
-       }
-
-       inputDevice->bInitializeComplete = false;
-
-       /* Open the channel */
-       ret = vmbus_open(Device->channel,
-               INPUTVSC_SEND_RING_BUFFER_SIZE,
-               INPUTVSC_RECV_RING_BUFFER_SIZE,
-               NULL,
-               0,
-               MousevscOnChannelCallback,
-               Device
-               );
-
-       if (ret != 0) {
-               pr_err("unable to open channel: %d", ret);
-               return -1;
-       }
-
-       pr_info("InputVsc channel open: %d", ret);
-
-       ret = MousevscConnectToVsp(Device);
-
-       if (ret != 0) {
-               pr_err("unable to connect channel: %d", ret);
-
-               vmbus_close(Device->channel);
-               return ret;
-       }
-
-       inputDriver = (struct mousevsc_drv_obj *)inputDevice->Device->drv;
-
-       deviceInfo.VendorID = inputDevice->DeviceAttr.VendorID;
-       deviceInfo.ProductID = inputDevice->DeviceAttr.ProductID;
-       deviceInfo.VersionNumber = inputDevice->DeviceAttr.VersionNumber;
-       strcpy(deviceInfo.Name, "Microsoft Vmbus HID-compliant Mouse");
-
-       /* Send the device info back up */
-       inputDriver->OnDeviceInfo(Device, &deviceInfo);
-
-       /* Send the report desc back up */
-       /* workaround SA-167 */
-       if (inputDevice->ReportDesc[14] == 0x25)
-               inputDevice->ReportDesc[14] = 0x29;
-
-       inputDriver->OnReportDescriptor(Device, inputDevice->ReportDesc, inputDevice->ReportDescSize);
-
-       inputDevice->bInitializeComplete = true;
-
-Cleanup:
-       return ret;
-}
-
-int
-MousevscConnectToVsp(struct hv_device *Device)
-{
-       int ret = 0;
-       struct mousevsc_dev *inputDevice;
-       struct mousevsc_prt_msg *request;
-       struct mousevsc_prt_msg *response;
-
-       inputDevice = GetInputDevice(Device);
-
-       if (!inputDevice) {
-               pr_err("unable to get input device...device being destroyed?");
-               return -1;
-       }
-
-       init_waitqueue_head(&inputDevice->ProtocolWaitEvent);
-       init_waitqueue_head(&inputDevice->DeviceInfoWaitEvent);
-
-       request = &inputDevice->ProtocolReq;
-
-       /*
-        * Now, initiate the vsc/vsp initialization protocol on the open channel
-        */
-       memset(request, sizeof(struct mousevsc_prt_msg), 0);
-
-       request->PacketType = PipeMessageData;
-       request->DataSize = sizeof(struct synthhid_protocol_request);
-
-       request->u.Request.Header.Type = SynthHidProtocolRequest;
-       request->u.Request.Header.Size = sizeof(unsigned long);
-       request->u.Request.VersionRequested.AsDWord =
-               SYNTHHID_INPUT_VERSION_DWORD;
-
-       pr_info("synthhid protocol request...");
-
-       ret = vmbus_sendpacket(Device->channel, request,
-                                       sizeof(struct pipe_prt_msg) -
-                                       sizeof(unsigned char) +
-                                       sizeof(struct synthhid_protocol_request),
-                                       (unsigned long)request,
-                                       VM_PKT_DATA_INBAND,
-                                       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
-       if (ret != 0) {
-               pr_err("unable to send synthhid protocol request.");
-               goto Cleanup;
-       }
-
-       inputDevice->protocol_wait_condition = 0;
-       wait_event_timeout(inputDevice->ProtocolWaitEvent, inputDevice->protocol_wait_condition, msecs_to_jiffies(1000));
-       if (inputDevice->protocol_wait_condition == 0) {
-               ret = -ETIMEDOUT;
-               goto Cleanup;
-       }
-
-       response = &inputDevice->ProtocolResp;
-
-       if (!response->u.Response.Approved) {
-               pr_err("synthhid protocol request failed (version %d)",
-                      SYNTHHID_INPUT_VERSION_DWORD);
-               ret = -1;
-               goto Cleanup;
-       }
-
-       inputDevice->device_wait_condition = 0;
-       wait_event_timeout(inputDevice->DeviceInfoWaitEvent, inputDevice->device_wait_condition, msecs_to_jiffies(1000));
-       if (inputDevice->device_wait_condition == 0) {
-               ret = -ETIMEDOUT;
-               goto Cleanup;
-       }
-
-       /*
-        * We should have gotten the device attr, hid desc and report
-        * desc at this point
-        */
-       if (!inputDevice->DeviceInfoStatus)
-               pr_info("**** input channel up and running!! ****");
-       else
-               ret = -1;
-
-Cleanup:
-       PutInputDevice(Device);
-
-       return ret;
-}
-
-
-/*
- *
- * Name:
- *     MousevscOnDeviceRemove()
- *
- * Description:
- *     Callback when the our device is being removed
- *
- */
-int
-MousevscOnDeviceRemove(struct hv_device *Device)
-{
-       struct mousevsc_dev *inputDevice;
-       int ret = 0;
-
-       pr_info("disabling input device (%p)...",
-                   Device->ext);
-
-       inputDevice = ReleaseInputDevice(Device);
-
-
-       /*
-        * At this point, all outbound traffic should be disable. We only
-        * allow inbound traffic (responses) to proceed
-        *
-        * so that outstanding requests can be completed.
-        */
-       while (inputDevice->NumOutstandingRequests) {
-               pr_info("waiting for %d requests to complete...", inputDevice->NumOutstandingRequests);
-
-               udelay(100);
-       }
-
-       pr_info("removing input device (%p)...", Device->ext);
-
-       inputDevice = FinalReleaseInputDevice(Device);
-
-       pr_info("input device (%p) safe to remove", inputDevice);
-
-       /* Close the channel */
-       vmbus_close(Device->channel);
-
-       FreeInputDevice(inputDevice);
-
-       return ret;
-}
-
-
-/*
- *
- * Name:
- *     MousevscOnCleanup()
- *
- * Description:
- *     Perform any cleanup when the driver is removed
- */
-static void MousevscOnCleanup(struct hv_driver *drv)
-{
-}
-
-
-static void
-MousevscOnSendCompletion(struct hv_device *Device,
-                        struct vmpacket_descriptor *Packet)
+static void MousevscOnSendCompletion(struct hv_device *Device, struct vmpacket_descriptor *Packet)
 {
        struct mousevsc_dev *inputDevice;
        void *request;
@@ -608,10 +340,7 @@ MousevscOnSendCompletion(struct hv_device *Device,
        PutInputDevice(Device);
 }
 
-void
-MousevscOnReceiveDeviceInfo(
-       struct mousevsc_dev *InputDevice,
-       struct synthhid_device_info *DeviceInfo)
+static void MousevscOnReceiveDeviceInfo(struct mousevsc_dev *InputDevice, struct synthhid_device_info *DeviceInfo)
 {
        int ret = 0;
        struct hid_descriptor *desc;
@@ -621,7 +350,7 @@ MousevscOnReceiveDeviceInfo(
        InputDevice->DeviceInfoStatus = 0;
 
        /* Save the device attr */
-       memcpy(&InputDevice->DeviceAttr, &DeviceInfo->HidDeviceAttributes, sizeof(struct input_dev_info));
+       memcpy(&InputDevice->DeviceAttr, &DeviceInfo->HidDeviceAttributes, sizeof(struct hv_input_dev_info));
 
        /* Save the hid desc */
        desc = (struct hid_descriptor *)DeviceInfo->HidDescriptorInformation;
@@ -657,8 +386,8 @@ MousevscOnReceiveDeviceInfo(
        ack.PacketType = PipeMessageData;
        ack.DataSize = sizeof(struct synthhid_device_info_ack);
 
-       ack.u.Ack.Header.Type = SynthHidInitialDeviceInfoAck;
-       ack.u.Ack.Header.Size = 1;
+       ack.u.Ack.header.type = SynthHidInitialDeviceInfoAck;
+       ack.u.Ack.header.size = 1;
        ack.u.Ack.Reserved = 0;
 
        ret = vmbus_sendpacket(InputDevice->Device->channel,
@@ -695,11 +424,7 @@ Cleanup:
        wake_up(&InputDevice->DeviceInfoWaitEvent);
 }
 
-
-void
-MousevscOnReceiveInputReport(
-       struct mousevsc_dev *InputDevice,
-       struct synthhid_input_report *InputReport)
+static void MousevscOnReceiveInputReport(struct mousevsc_dev *InputDevice, struct synthhid_input_report *InputReport)
 {
        struct mousevsc_drv_obj *inputDriver;
 
@@ -710,13 +435,12 @@ MousevscOnReceiveInputReport(
 
        inputDriver = (struct mousevsc_drv_obj *)InputDevice->Device->drv;
 
-       inputDriver->OnInputReport(InputDevice->Device,
-                                  InputReport->ReportBuffer,
-                                  InputReport->Header.Size);
+       inputreport_callback(InputDevice->Device,
+                            InputReport->ReportBuffer,
+                            InputReport->header.size);
 }
 
-void
-MousevscOnReceive(struct hv_device *Device, struct vmpacket_descriptor *Packet)
+static void MousevscOnReceive(struct hv_device *Device, struct vmpacket_descriptor *Packet)
 {
        struct pipe_prt_msg *pipeMsg;
        struct synthhid_msg *hidMsg;
@@ -739,7 +463,7 @@ MousevscOnReceive(struct hv_device *Device, struct vmpacket_descriptor *Packet)
 
        hidMsg = (struct synthhid_msg *)&pipeMsg->Data[0];
 
-       switch (hidMsg->Header.Type) {
+       switch (hidMsg->header.type) {
        case SynthHidProtocolResponse:
                memcpy(&inputDevice->ProtocolResp, pipeMsg, pipeMsg->DataSize+sizeof(struct pipe_prt_msg) - sizeof(unsigned char));
                inputDevice->protocol_wait_condition = 1;
@@ -747,7 +471,7 @@ MousevscOnReceive(struct hv_device *Device, struct vmpacket_descriptor *Packet)
                break;
 
        case SynthHidInitialDeviceInfo:
-               WARN_ON(pipeMsg->DataSize >= sizeof(struct input_dev_info));
+               WARN_ON(pipeMsg->DataSize >= sizeof(struct hv_input_dev_info));
 
                /*
                 * Parse out the device info into device attr,
@@ -763,14 +487,14 @@ MousevscOnReceive(struct hv_device *Device, struct vmpacket_descriptor *Packet)
                break;
        default:
                pr_err("unsupported hid msg type - type %d len %d",
-                      hidMsg->Header.Type, hidMsg->Header.Size);
+                      hidMsg->header.type, hidMsg->header.size);
                break;
        }
 
        PutInputDevice(Device);
 }
 
-void MousevscOnChannelCallback(void *Context)
+static void MousevscOnChannelCallback(void *Context)
 {
        const int packetSize = 0x100;
        int ret = 0;
@@ -858,13 +582,204 @@ void MousevscOnChannelCallback(void *Context)
        return;
 }
 
+static int MousevscConnectToVsp(struct hv_device *Device)
+{
+       int ret = 0;
+       struct mousevsc_dev *inputDevice;
+       struct mousevsc_prt_msg *request;
+       struct mousevsc_prt_msg *response;
+
+       inputDevice = GetInputDevice(Device);
+
+       if (!inputDevice) {
+               pr_err("unable to get input device...device being destroyed?");
+               return -1;
+       }
+
+       init_waitqueue_head(&inputDevice->ProtocolWaitEvent);
+       init_waitqueue_head(&inputDevice->DeviceInfoWaitEvent);
+
+       request = &inputDevice->ProtocolReq;
+
+       /*
+        * Now, initiate the vsc/vsp initialization protocol on the open channel
+        */
+       memset(request, sizeof(struct mousevsc_prt_msg), 0);
+
+       request->PacketType = PipeMessageData;
+       request->DataSize = sizeof(struct synthhid_protocol_request);
+
+       request->u.Request.header.type = SynthHidProtocolRequest;
+       request->u.Request.header.size = sizeof(unsigned long);
+       request->u.Request.VersionRequested.AsDWord =
+               SYNTHHID_INPUT_VERSION_DWORD;
+
+       pr_info("synthhid protocol request...");
+
+       ret = vmbus_sendpacket(Device->channel, request,
+                                       sizeof(struct pipe_prt_msg) -
+                                       sizeof(unsigned char) +
+                                       sizeof(struct synthhid_protocol_request),
+                                       (unsigned long)request,
+                                       VM_PKT_DATA_INBAND,
+                                       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
+       if (ret != 0) {
+               pr_err("unable to send synthhid protocol request.");
+               goto Cleanup;
+       }
+
+       inputDevice->protocol_wait_condition = 0;
+       wait_event_timeout(inputDevice->ProtocolWaitEvent, inputDevice->protocol_wait_condition, msecs_to_jiffies(1000));
+       if (inputDevice->protocol_wait_condition == 0) {
+               ret = -ETIMEDOUT;
+               goto Cleanup;
+       }
+
+       response = &inputDevice->ProtocolResp;
+
+       if (!response->u.Response.Approved) {
+               pr_err("synthhid protocol request failed (version %d)",
+                      SYNTHHID_INPUT_VERSION_DWORD);
+               ret = -1;
+               goto Cleanup;
+       }
+
+       inputDevice->device_wait_condition = 0;
+       wait_event_timeout(inputDevice->DeviceInfoWaitEvent, inputDevice->device_wait_condition, msecs_to_jiffies(1000));
+       if (inputDevice->device_wait_condition == 0) {
+               ret = -ETIMEDOUT;
+               goto Cleanup;
+       }
+
+       /*
+        * We should have gotten the device attr, hid desc and report
+        * desc at this point
+        */
+       if (!inputDevice->DeviceInfoStatus)
+               pr_info("**** input channel up and running!! ****");
+       else
+               ret = -1;
+
+Cleanup:
+       PutInputDevice(Device);
+
+       return ret;
+}
+
+static int MousevscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo)
+{
+       int ret = 0;
+       struct mousevsc_dev *inputDevice;
+       struct mousevsc_drv_obj *inputDriver;
+       struct hv_input_dev_info deviceInfo;
+
+       inputDevice = AllocInputDevice(Device);
+
+       if (!inputDevice) {
+               ret = -1;
+               goto Cleanup;
+       }
+
+       inputDevice->bInitializeComplete = false;
+
+       /* Open the channel */
+       ret = vmbus_open(Device->channel,
+               INPUTVSC_SEND_RING_BUFFER_SIZE,
+               INPUTVSC_RECV_RING_BUFFER_SIZE,
+               NULL,
+               0,
+               MousevscOnChannelCallback,
+               Device
+               );
+
+       if (ret != 0) {
+               pr_err("unable to open channel: %d", ret);
+               return -1;
+       }
+
+       pr_info("InputVsc channel open: %d", ret);
+
+       ret = MousevscConnectToVsp(Device);
+
+       if (ret != 0) {
+               pr_err("unable to connect channel: %d", ret);
+
+               vmbus_close(Device->channel);
+               return ret;
+       }
+
+       inputDriver = (struct mousevsc_drv_obj *)inputDevice->Device->drv;
+
+       deviceInfo.vendor = inputDevice->DeviceAttr.vendor;
+       deviceInfo.product = inputDevice->DeviceAttr.product;
+       deviceInfo.version = inputDevice->DeviceAttr.version;
+       strcpy(deviceInfo.name, "Microsoft Vmbus HID-compliant Mouse");
+
+       /* Send the device info back up */
+       deviceinfo_callback(Device, &deviceInfo);
+
+       /* Send the report desc back up */
+       /* workaround SA-167 */
+       if (inputDevice->ReportDesc[14] == 0x25)
+               inputDevice->ReportDesc[14] = 0x29;
+
+       reportdesc_callback(Device, inputDevice->ReportDesc,
+                           inputDevice->ReportDescSize);
+
+       inputDevice->bInitializeComplete = true;
+
+Cleanup:
+       return ret;
+}
+
+static int MousevscOnDeviceRemove(struct hv_device *Device)
+{
+       struct mousevsc_dev *inputDevice;
+       int ret = 0;
+
+       pr_info("disabling input device (%p)...",
+                   Device->ext);
+
+       inputDevice = ReleaseInputDevice(Device);
+
+
+       /*
+        * At this point, all outbound traffic should be disable. We only
+        * allow inbound traffic (responses) to proceed
+        *
+        * so that outstanding requests can be completed.
+        */
+       while (inputDevice->NumOutstandingRequests) {
+               pr_info("waiting for %d requests to complete...", inputDevice->NumOutstandingRequests);
+
+               udelay(100);
+       }
+
+       pr_info("removing input device (%p)...", Device->ext);
+
+       inputDevice = FinalReleaseInputDevice(Device);
+
+       pr_info("input device (%p) safe to remove", inputDevice);
+
+       /* Close the channel */
+       vmbus_close(Device->channel);
+
+       FreeInputDevice(inputDevice);
+
+       return ret;
+}
+
+static void MousevscOnCleanup(struct hv_driver *drv)
+{
+}
+
 /*
  * Data types
  */
 struct input_device_context {
        struct vm_device        *device_ctx;
        struct hid_device       *hid_device;
-       struct input_dev_info   device_info;
+       struct hv_input_dev_info device_info;
        int                     connected;
 };
 
@@ -875,20 +790,19 @@ struct mousevsc_driver_context {
 
 static struct mousevsc_driver_context g_mousevsc_drv;
 
-void mousevsc_deviceinfo_callback(struct hv_device *dev,
-                                 struct input_dev_info *info)
+static void deviceinfo_callback(struct hv_device *dev, struct hv_input_dev_info *info)
 {
        struct vm_device *device_ctx = to_vm_device(dev);
        struct input_device_context *input_device_ctx =
                dev_get_drvdata(&device_ctx->device);
 
        memcpy(&input_device_ctx->device_info, info,
-              sizeof(struct input_dev_info));
+              sizeof(struct hv_input_dev_info));
 
-       DPRINT_INFO(INPUTVSC_DRV, "mousevsc_deviceinfo_callback()");
+       DPRINT_INFO(INPUTVSC_DRV, "%s", __func__);
 }
 
-void mousevsc_inputreport_callback(struct hv_device *dev, void *packet, u32 len)
+static void inputreport_callback(struct hv_device *dev, void *packet, u32 len)
 {
        int ret = 0;
 
@@ -902,16 +816,16 @@ void mousevsc_inputreport_callback(struct hv_device *dev, void *packet, u32 len)
        DPRINT_DBG(INPUTVSC_DRV, "hid_input_report (ret %d)", ret);
 }
 
-int mousevsc_hid_open(struct hid_device *hid)
+static int mousevsc_hid_open(struct hid_device *hid)
 {
        return 0;
 }
 
-void mousevsc_hid_close(struct hid_device *hid)
+static void mousevsc_hid_close(struct hid_device *hid)
 {
 }
 
-int mousevsc_probe(struct device *device)
+static int mousevsc_probe(struct device *device)
 {
        int ret = 0;
 
@@ -942,8 +856,7 @@ int mousevsc_probe(struct device *device)
        return 0;
 }
 
-
-int mousevsc_remove(struct device *device)
+static int mousevsc_remove(struct device *device)
 {
        int ret = 0;
 
@@ -986,7 +899,7 @@ int mousevsc_remove(struct device *device)
        return ret;
 }
 
-void mousevsc_reportdesc_callback(struct hv_device *dev, void *packet, u32 len)
+static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len)
 {
        struct vm_device *device_ctx = to_vm_device(dev);
        struct input_device_context *input_device_ctx =
@@ -1007,14 +920,14 @@ void mousevsc_reportdesc_callback(struct hv_device *dev, void *packet, u32 len)
                hid_dev->ll_driver->open  = mousevsc_hid_open;
                hid_dev->ll_driver->close = mousevsc_hid_close;
 
-               hid_dev->bus =  0x06;  /* BUS_VIRTUAL */
-               hid_dev->vendor = input_device_ctx->device_info.VendorID;
-               hid_dev->product = input_device_ctx->device_info.ProductID;
-               hid_dev->version = input_device_ctx->device_info.VersionNumber;
+               hid_dev->bus = BUS_VIRTUAL;
+               hid_dev->vendor = input_device_ctx->device_info.vendor;
+               hid_dev->product = input_device_ctx->device_info.product;
+               hid_dev->version = input_device_ctx->device_info.version;
                hid_dev->dev = device_ctx->device;
 
                sprintf(hid_dev->name, "%s",
-                       input_device_ctx->device_info.Name);
+                       input_device_ctx->device_info.name);
 
                /*
                 * HJ Do we want to call it with a 0
@@ -1040,7 +953,7 @@ void mousevsc_reportdesc_callback(struct hv_device *dev, void *packet, u32 len)
        kfree(hid_dev);
 }
 
-int mousevsc_drv_exit_cb(struct device *dev, void *data)
+static int mousevsc_drv_exit_cb(struct device *dev, void *data)
 {
        struct device **curr = (struct device **)data;
        *curr = dev;
@@ -1048,7 +961,7 @@ int mousevsc_drv_exit_cb(struct device *dev, void *data)
        return 1;
 }
 
-void mousevsc_drv_exit(void)
+static void mousevsc_drv_exit(void)
 {
        struct mousevsc_drv_obj *mousevsc_drv_obj = &g_mousevsc_drv.drv_obj;
        struct driver_context *drv_ctx = &g_mousevsc_drv.drv_ctx;
@@ -1081,6 +994,25 @@ void mousevsc_drv_exit(void)
        return;
 }
 
+static int mouse_vsc_initialize(struct hv_driver *Driver)
+{
+       struct mousevsc_drv_obj *inputDriver =
+               (struct mousevsc_drv_obj *)Driver;
+       int ret = 0;
+
+       Driver->name = gDriverName;
+       memcpy(&Driver->dev_type, &gMousevscDeviceType,
+              sizeof(struct hv_guid));
+
+       /* Setup the dispatch table */
+       inputDriver->Base.dev_add = MousevscOnDeviceAdd;
+       inputDriver->Base.dev_rm = MousevscOnDeviceRemove;
+       inputDriver->Base.cleanup = MousevscOnCleanup;
+
+       return ret;
+}
+
+
 static int __init mousevsc_init(void)
 {
        struct mousevsc_drv_obj *input_drv_obj = &g_mousevsc_drv.drv_obj;
@@ -1088,10 +1020,6 @@ static int __init mousevsc_init(void)
 
        DPRINT_INFO(INPUTVSC_DRV, "Hyper-V Mouse driver initializing.");
 
-       input_drv_obj->OnDeviceInfo = mousevsc_deviceinfo_callback;
-       input_drv_obj->OnInputReport = mousevsc_inputreport_callback;
-       input_drv_obj->OnReportDescriptor = mousevsc_reportdesc_callback;
-
        /* Callback to client driver to complete the initialization */
        mouse_vsc_initialize(&input_drv_obj->Base);