staging:iio:trigger handle name attr in core, remove old alloc and register any contr...
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / staging / hv / hv_mouse.c
blob359e73741c484ea5da31b0e41531f1701526d420
1 /*
2 * Copyright (c) 2009, Citrix Systems, Inc.
3 * Copyright (c) 2010, Microsoft Corporation.
4 * Copyright (c) 2011, Novell Inc.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
15 #include <linux/init.h>
16 #include <linux/module.h>
17 #include <linux/delay.h>
18 #include <linux/device.h>
19 #include <linux/workqueue.h>
20 #include <linux/sched.h>
21 #include <linux/wait.h>
22 #include <linux/input.h>
23 #include <linux/hid.h>
24 #include <linux/hiddev.h>
25 #include <linux/pci.h>
26 #include <linux/dmi.h>
27 #include <linux/delay.h>
29 #include "hyperv.h"
33 * Data types
35 struct hv_input_dev_info {
36 unsigned short vendor;
37 unsigned short product;
38 unsigned short version;
39 char name[128];
42 /* The maximum size of a synthetic input message. */
43 #define SYNTHHID_MAX_INPUT_REPORT_SIZE 16
46 * Current version
48 * History:
49 * Beta, RC < 2008/1/22 1,0
50 * RC > 2008/1/22 2,0
52 #define SYNTHHID_INPUT_VERSION_MAJOR 2
53 #define SYNTHHID_INPUT_VERSION_MINOR 0
54 #define SYNTHHID_INPUT_VERSION (SYNTHHID_INPUT_VERSION_MINOR | \
55 (SYNTHHID_INPUT_VERSION_MAJOR << 16))
58 #pragma pack(push,1)
60 * Message types in the synthetic input protocol
62 enum synthhid_msg_type {
63 SynthHidProtocolRequest,
64 SynthHidProtocolResponse,
65 SynthHidInitialDeviceInfo,
66 SynthHidInitialDeviceInfoAck,
67 SynthHidInputReport,
68 SynthHidMax
72 * Basic message structures.
74 struct synthhid_msg_hdr {
75 enum synthhid_msg_type type;
76 u32 size;
79 struct synthhid_msg {
80 struct synthhid_msg_hdr header;
81 char data[1]; /* Enclosed message */
84 union synthhid_version {
85 struct {
86 u16 minor_version;
87 u16 major_version;
89 u32 version;
93 * Protocol messages
95 struct synthhid_protocol_request {
96 struct synthhid_msg_hdr header;
97 union synthhid_version version_requested;
100 struct synthhid_protocol_response {
101 struct synthhid_msg_hdr header;
102 union synthhid_version version_requested;
103 unsigned char approved;
106 struct synthhid_device_info {
107 struct synthhid_msg_hdr header;
108 struct hv_input_dev_info hid_dev_info;
109 struct hid_descriptor hid_descriptor;
112 struct synthhid_device_info_ack {
113 struct synthhid_msg_hdr header;
114 unsigned char reserved;
117 struct synthhid_input_report {
118 struct synthhid_msg_hdr header;
119 char buffer[1];
122 #pragma pack(pop)
124 #define INPUTVSC_SEND_RING_BUFFER_SIZE 10*PAGE_SIZE
125 #define INPUTVSC_RECV_RING_BUFFER_SIZE 10*PAGE_SIZE
127 #define NBITS(x) (((x)/BITS_PER_LONG)+1)
129 enum pipe_prot_msg_type {
130 PipeMessageInvalid = 0,
131 PipeMessageData,
132 PipeMessageMaximum
136 struct pipe_prt_msg {
137 enum pipe_prot_msg_type type;
138 u32 size;
139 char data[1];
143 * Data types
145 struct mousevsc_prt_msg {
146 enum pipe_prot_msg_type type;
147 u32 size;
148 union {
149 struct synthhid_protocol_request request;
150 struct synthhid_protocol_response response;
151 struct synthhid_device_info_ack ack;
156 * Represents an mousevsc device
158 struct mousevsc_dev {
159 struct hv_device *device;
160 /* 0 indicates the device is being destroyed */
161 atomic_t ref_count;
162 int num_outstanding_req;
163 unsigned char init_complete;
164 struct mousevsc_prt_msg protocol_req;
165 struct mousevsc_prt_msg protocol_resp;
166 /* Synchronize the request/response if needed */
167 wait_queue_head_t protocol_wait_event;
168 wait_queue_head_t dev_info_wait_event;
169 int protocol_wait_condition;
170 int device_wait_condition;
171 int dev_info_status;
173 struct hid_descriptor *hid_desc;
174 unsigned char *report_desc;
175 u32 report_desc_size;
176 struct hv_input_dev_info hid_dev_info;
180 static const char *driver_name = "mousevsc";
182 /* {CFA8B69E-5B4A-4cc0-B98B-8BA1A1F3F95A} */
183 static const struct hv_guid mouse_guid = {
184 .data = {0x9E, 0xB6, 0xA8, 0xCF, 0x4A, 0x5B, 0xc0, 0x4c,
185 0xB9, 0x8B, 0x8B, 0xA1, 0xA1, 0xF3, 0xF9, 0x5A}
188 static void deviceinfo_callback(struct hv_device *dev, struct hv_input_dev_info *info);
189 static void inputreport_callback(struct hv_device *dev, void *packet, u32 len);
190 static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len);
192 static struct mousevsc_dev *alloc_input_device(struct hv_device *device)
194 struct mousevsc_dev *input_dev;
196 input_dev = kzalloc(sizeof(struct mousevsc_dev), GFP_KERNEL);
198 if (!input_dev)
199 return NULL;
202 * Set to 2 to allow both inbound and outbound traffics
203 * (ie get_input_device() and must_get_input_device()) to proceed.
205 atomic_cmpxchg(&input_dev->ref_count, 0, 2);
207 input_dev->device = device;
208 device->ext = input_dev;
210 return input_dev;
213 static void free_input_device(struct mousevsc_dev *device)
215 WARN_ON(atomic_read(&device->ref_count) == 0);
216 kfree(device);
220 * Get the inputdevice object if exists and its refcount > 1
222 static struct mousevsc_dev *get_input_device(struct hv_device *device)
224 struct mousevsc_dev *input_dev;
226 input_dev = (struct mousevsc_dev *)device->ext;
229 * FIXME
230 * This sure isn't a valid thing to print for debugging, no matter
231 * what the intention is...
233 * printk(KERN_ERR "-------------------------> REFCOUNT = %d",
234 * input_dev->ref_count);
237 if (input_dev && atomic_read(&input_dev->ref_count) > 1)
238 atomic_inc(&input_dev->ref_count);
239 else
240 input_dev = NULL;
242 return input_dev;
246 * Get the inputdevice object iff exists and its refcount > 0
248 static struct mousevsc_dev *must_get_input_device(struct hv_device *device)
250 struct mousevsc_dev *input_dev;
252 input_dev = (struct mousevsc_dev *)device->ext;
254 if (input_dev && atomic_read(&input_dev->ref_count))
255 atomic_inc(&input_dev->ref_count);
256 else
257 input_dev = NULL;
259 return input_dev;
262 static void put_input_device(struct hv_device *device)
264 struct mousevsc_dev *input_dev;
266 input_dev = (struct mousevsc_dev *)device->ext;
268 atomic_dec(&input_dev->ref_count);
272 * Drop ref count to 1 to effectively disable get_input_device()
274 static struct mousevsc_dev *release_input_device(struct hv_device *device)
276 struct mousevsc_dev *input_dev;
278 input_dev = (struct mousevsc_dev *)device->ext;
280 /* Busy wait until the ref drop to 2, then set it to 1 */
281 while (atomic_cmpxchg(&input_dev->ref_count, 2, 1) != 2)
282 udelay(100);
284 return input_dev;
288 * Drop ref count to 0. No one can use input_device object.
290 static struct mousevsc_dev *final_release_input_device(struct hv_device *device)
292 struct mousevsc_dev *input_dev;
294 input_dev = (struct mousevsc_dev *)device->ext;
296 /* Busy wait until the ref drop to 1, then set it to 0 */
297 while (atomic_cmpxchg(&input_dev->ref_count, 1, 0) != 1)
298 udelay(100);
300 device->ext = NULL;
301 return input_dev;
304 static void mousevsc_on_send_completion(struct hv_device *device,
305 struct vmpacket_descriptor *packet)
307 struct mousevsc_dev *input_dev;
308 void *request;
310 input_dev = must_get_input_device(device);
311 if (!input_dev) {
312 pr_err("unable to get input device...device being destroyed?");
313 return;
316 request = (void *)(unsigned long)packet->trans_id;
318 if (request == &input_dev->protocol_req) {
319 /* FIXME */
320 /* Shouldn't we be doing something here? */
323 put_input_device(device);
326 static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
327 struct synthhid_device_info *device_info)
329 int ret = 0;
330 struct hid_descriptor *desc;
331 struct mousevsc_prt_msg ack;
333 /* Assume success for now */
334 input_device->dev_info_status = 0;
336 /* Save the device attr */
337 memcpy(&input_device->hid_dev_info, &device_info->hid_dev_info,
338 sizeof(struct hv_input_dev_info));
340 /* Save the hid desc */
341 desc = &device_info->hid_descriptor;
342 WARN_ON(desc->bLength > 0);
344 input_device->hid_desc = kzalloc(desc->bLength, GFP_KERNEL);
346 if (!input_device->hid_desc) {
347 pr_err("unable to allocate hid descriptor - size %d", desc->bLength);
348 goto Cleanup;
351 memcpy(input_device->hid_desc, desc, desc->bLength);
353 /* Save the report desc */
354 input_device->report_desc_size = desc->desc[0].wDescriptorLength;
355 input_device->report_desc = kzalloc(input_device->report_desc_size,
356 GFP_KERNEL);
358 if (!input_device->report_desc) {
359 pr_err("unable to allocate report descriptor - size %d",
360 input_device->report_desc_size);
361 goto Cleanup;
364 memcpy(input_device->report_desc,
365 ((unsigned char *)desc) + desc->bLength,
366 desc->desc[0].wDescriptorLength);
368 /* Send the ack */
369 memset(&ack, 0, sizeof(struct mousevsc_prt_msg));
371 ack.type = PipeMessageData;
372 ack.size = sizeof(struct synthhid_device_info_ack);
374 ack.ack.header.type = SynthHidInitialDeviceInfoAck;
375 ack.ack.header.size = 1;
376 ack.ack.reserved = 0;
378 ret = vmbus_sendpacket(input_device->device->channel,
379 &ack,
380 sizeof(struct pipe_prt_msg) - sizeof(unsigned char) +
381 sizeof(struct synthhid_device_info_ack),
382 (unsigned long)&ack,
383 VM_PKT_DATA_INBAND,
384 VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
385 if (ret != 0) {
386 pr_err("unable to send synthhid device info ack - ret %d",
387 ret);
388 goto Cleanup;
391 input_device->device_wait_condition = 1;
392 wake_up(&input_device->dev_info_wait_event);
394 return;
396 Cleanup:
397 kfree(input_device->hid_desc);
398 input_device->hid_desc = NULL;
400 kfree(input_device->report_desc);
401 input_device->report_desc = NULL;
403 input_device->dev_info_status = -1;
404 input_device->device_wait_condition = 1;
405 wake_up(&input_device->dev_info_wait_event);
408 static void mousevsc_on_receive_input_report(struct mousevsc_dev *input_device,
409 struct synthhid_input_report *input_report)
411 struct hv_driver *input_drv;
413 if (!input_device->init_complete) {
414 pr_info("Initialization incomplete...ignoring input_report msg");
415 return;
418 input_drv = drv_to_hv_drv(input_device->device->device.driver);
420 inputreport_callback(input_device->device,
421 input_report->buffer,
422 input_report->header.size);
425 static void mousevsc_on_receive(struct hv_device *device,
426 struct vmpacket_descriptor *packet)
428 struct pipe_prt_msg *pipe_msg;
429 struct synthhid_msg *hid_msg;
430 struct mousevsc_dev *input_dev;
432 input_dev = must_get_input_device(device);
433 if (!input_dev) {
434 pr_err("unable to get input device...device being destroyed?");
435 return;
438 pipe_msg = (struct pipe_prt_msg *)((unsigned long)packet +
439 (packet->offset8 << 3));
441 if (pipe_msg->type != PipeMessageData) {
442 pr_err("unknown pipe msg type - type %d len %d",
443 pipe_msg->type, pipe_msg->size);
444 put_input_device(device);
445 return ;
448 hid_msg = (struct synthhid_msg *)&pipe_msg->data[0];
450 switch (hid_msg->header.type) {
451 case SynthHidProtocolResponse:
452 memcpy(&input_dev->protocol_resp, pipe_msg,
453 pipe_msg->size + sizeof(struct pipe_prt_msg) -
454 sizeof(unsigned char));
455 input_dev->protocol_wait_condition = 1;
456 wake_up(&input_dev->protocol_wait_event);
457 break;
459 case SynthHidInitialDeviceInfo:
460 WARN_ON(pipe_msg->size >= sizeof(struct hv_input_dev_info));
463 * Parse out the device info into device attr,
464 * hid desc and report desc
466 mousevsc_on_receive_device_info(input_dev,
467 (struct synthhid_device_info *)&pipe_msg->data[0]);
468 break;
469 case SynthHidInputReport:
470 mousevsc_on_receive_input_report(input_dev,
471 (struct synthhid_input_report *)&pipe_msg->data[0]);
473 break;
474 default:
475 pr_err("unsupported hid msg type - type %d len %d",
476 hid_msg->header.type, hid_msg->header.size);
477 break;
480 put_input_device(device);
483 static void mousevsc_on_channel_callback(void *context)
485 const int packetSize = 0x100;
486 int ret = 0;
487 struct hv_device *device = (struct hv_device *)context;
488 struct mousevsc_dev *input_dev;
490 u32 bytes_recvd;
491 u64 req_id;
492 unsigned char packet[0x100];
493 struct vmpacket_descriptor *desc;
494 unsigned char *buffer = packet;
495 int bufferlen = packetSize;
497 input_dev = must_get_input_device(device);
499 if (!input_dev) {
500 pr_err("unable to get input device...device being destroyed?");
501 return;
504 do {
505 ret = vmbus_recvpacket_raw(device->channel, buffer,
506 bufferlen, &bytes_recvd, &req_id);
508 if (ret == 0) {
509 if (bytes_recvd > 0) {
510 desc = (struct vmpacket_descriptor *)buffer;
512 switch (desc->type) {
513 case VM_PKT_COMP:
514 mousevsc_on_send_completion(
515 device, desc);
516 break;
518 case VM_PKT_DATA_INBAND:
519 mousevsc_on_receive(
520 device, desc);
521 break;
523 default:
524 pr_err("unhandled packet type %d, tid %llx len %d\n",
525 desc->type,
526 req_id,
527 bytes_recvd);
528 break;
531 /* reset */
532 if (bufferlen > packetSize) {
533 kfree(buffer);
535 buffer = packet;
536 bufferlen = packetSize;
538 } else {
540 * pr_debug("nothing else to read...");
541 * reset
543 if (bufferlen > packetSize) {
544 kfree(buffer);
546 buffer = packet;
547 bufferlen = packetSize;
549 break;
551 } else if (ret == -2) {
552 /* Handle large packet */
553 bufferlen = bytes_recvd;
554 buffer = kzalloc(bytes_recvd, GFP_KERNEL);
556 if (buffer == NULL) {
557 buffer = packet;
558 bufferlen = packetSize;
560 /* Try again next time around */
561 pr_err("unable to allocate buffer of size %d!",
562 bytes_recvd);
563 break;
566 } while (1);
568 put_input_device(device);
570 return;
573 static int mousevsc_connect_to_vsp(struct hv_device *device)
575 int ret = 0;
576 struct mousevsc_dev *input_dev;
577 struct mousevsc_prt_msg *request;
578 struct mousevsc_prt_msg *response;
580 input_dev = get_input_device(device);
582 if (!input_dev) {
583 pr_err("unable to get input device...device being destroyed?");
584 return -1;
587 init_waitqueue_head(&input_dev->protocol_wait_event);
588 init_waitqueue_head(&input_dev->dev_info_wait_event);
590 request = &input_dev->protocol_req;
593 * Now, initiate the vsc/vsp initialization protocol on the open channel
595 memset(request, 0, sizeof(struct mousevsc_prt_msg));
597 request->type = PipeMessageData;
598 request->size = sizeof(struct synthhid_protocol_request);
600 request->request.header.type = SynthHidProtocolRequest;
601 request->request.header.size = sizeof(unsigned long);
602 request->request.version_requested.version = SYNTHHID_INPUT_VERSION;
604 pr_info("synthhid protocol request...");
606 ret = vmbus_sendpacket(device->channel, request,
607 sizeof(struct pipe_prt_msg) -
608 sizeof(unsigned char) +
609 sizeof(struct synthhid_protocol_request),
610 (unsigned long)request,
611 VM_PKT_DATA_INBAND,
612 VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
613 if (ret != 0) {
614 pr_err("unable to send synthhid protocol request.");
615 goto Cleanup;
618 input_dev->protocol_wait_condition = 0;
619 wait_event_timeout(input_dev->protocol_wait_event,
620 input_dev->protocol_wait_condition, msecs_to_jiffies(1000));
621 if (input_dev->protocol_wait_condition == 0) {
622 ret = -ETIMEDOUT;
623 goto Cleanup;
626 response = &input_dev->protocol_resp;
628 if (!response->response.approved) {
629 pr_err("synthhid protocol request failed (version %d)",
630 SYNTHHID_INPUT_VERSION);
631 ret = -1;
632 goto Cleanup;
635 input_dev->device_wait_condition = 0;
636 wait_event_timeout(input_dev->dev_info_wait_event,
637 input_dev->device_wait_condition, msecs_to_jiffies(1000));
638 if (input_dev->device_wait_condition == 0) {
639 ret = -ETIMEDOUT;
640 goto Cleanup;
644 * We should have gotten the device attr, hid desc and report
645 * desc at this point
647 if (!input_dev->dev_info_status)
648 pr_info("**** input channel up and running!! ****");
649 else
650 ret = -1;
652 Cleanup:
653 put_input_device(device);
655 return ret;
658 static int mousevsc_on_device_add(struct hv_device *device,
659 void *additional_info)
661 int ret = 0;
662 struct mousevsc_dev *input_dev;
663 struct hv_driver *input_drv;
664 struct hv_input_dev_info dev_info;
666 input_dev = alloc_input_device(device);
668 if (!input_dev) {
669 ret = -1;
670 goto Cleanup;
673 input_dev->init_complete = false;
675 /* Open the channel */
676 ret = vmbus_open(device->channel,
677 INPUTVSC_SEND_RING_BUFFER_SIZE,
678 INPUTVSC_RECV_RING_BUFFER_SIZE,
679 NULL,
681 mousevsc_on_channel_callback,
682 device
685 if (ret != 0) {
686 pr_err("unable to open channel: %d", ret);
687 free_input_device(input_dev);
688 return -1;
691 pr_info("InputVsc channel open: %d", ret);
693 ret = mousevsc_connect_to_vsp(device);
695 if (ret != 0) {
696 pr_err("unable to connect channel: %d", ret);
698 vmbus_close(device->channel);
699 free_input_device(input_dev);
700 return ret;
703 input_drv = drv_to_hv_drv(input_dev->device->device.driver);
705 dev_info.vendor = input_dev->hid_dev_info.vendor;
706 dev_info.product = input_dev->hid_dev_info.product;
707 dev_info.version = input_dev->hid_dev_info.version;
708 strcpy(dev_info.name, "Microsoft Vmbus HID-compliant Mouse");
710 /* Send the device info back up */
711 deviceinfo_callback(device, &dev_info);
713 /* Send the report desc back up */
714 /* workaround SA-167 */
715 if (input_dev->report_desc[14] == 0x25)
716 input_dev->report_desc[14] = 0x29;
718 reportdesc_callback(device, input_dev->report_desc,
719 input_dev->report_desc_size);
721 input_dev->init_complete = true;
723 Cleanup:
724 return ret;
727 static int mousevsc_on_device_remove(struct hv_device *device)
729 struct mousevsc_dev *input_dev;
730 int ret = 0;
732 pr_info("disabling input device (%p)...",
733 device->ext);
735 input_dev = release_input_device(device);
739 * At this point, all outbound traffic should be disable. We only
740 * allow inbound traffic (responses) to proceed
742 * so that outstanding requests can be completed.
744 while (input_dev->num_outstanding_req) {
745 pr_info("waiting for %d requests to complete...",
746 input_dev->num_outstanding_req);
748 udelay(100);
751 pr_info("removing input device (%p)...", device->ext);
753 input_dev = final_release_input_device(device);
755 pr_info("input device (%p) safe to remove", input_dev);
757 /* Close the channel */
758 vmbus_close(device->channel);
760 free_input_device(input_dev);
762 return ret;
767 * Data types
769 struct input_device_context {
770 struct hv_device *device_ctx;
771 struct hid_device *hid_device;
772 struct hv_input_dev_info device_info;
773 int connected;
777 static void deviceinfo_callback(struct hv_device *dev, struct hv_input_dev_info *info)
779 struct input_device_context *input_device_ctx =
780 dev_get_drvdata(&dev->device);
782 memcpy(&input_device_ctx->device_info, info,
783 sizeof(struct hv_input_dev_info));
785 DPRINT_INFO(INPUTVSC_DRV, "%s", __func__);
788 static void inputreport_callback(struct hv_device *dev, void *packet, u32 len)
790 int ret = 0;
792 struct input_device_context *input_dev_ctx =
793 dev_get_drvdata(&dev->device);
795 ret = hid_input_report(input_dev_ctx->hid_device,
796 HID_INPUT_REPORT, packet, len, 1);
798 DPRINT_DBG(INPUTVSC_DRV, "hid_input_report (ret %d)", ret);
801 static int mousevsc_hid_open(struct hid_device *hid)
803 return 0;
806 static void mousevsc_hid_close(struct hid_device *hid)
810 static int mousevsc_probe(struct hv_device *dev)
812 int ret = 0;
814 struct input_device_context *input_dev_ctx;
816 input_dev_ctx = kmalloc(sizeof(struct input_device_context),
817 GFP_KERNEL);
819 dev_set_drvdata(&dev->device, input_dev_ctx);
821 /* Call to the vsc driver to add the device */
822 ret = mousevsc_on_device_add(dev, NULL);
824 if (ret != 0) {
825 DPRINT_ERR(INPUTVSC_DRV, "unable to add input vsc device");
827 return -1;
830 return 0;
833 static int mousevsc_remove(struct hv_device *dev)
835 int ret = 0;
837 struct input_device_context *input_dev_ctx;
839 input_dev_ctx = kmalloc(sizeof(struct input_device_context),
840 GFP_KERNEL);
842 dev_set_drvdata(&dev->device, input_dev_ctx);
844 if (input_dev_ctx->connected) {
845 hidinput_disconnect(input_dev_ctx->hid_device);
846 input_dev_ctx->connected = 0;
850 * Call to the vsc driver to let it know that the device
851 * is being removed
853 ret = mousevsc_on_device_remove(dev);
855 if (ret != 0) {
856 DPRINT_ERR(INPUTVSC_DRV,
857 "unable to remove vsc device (ret %d)", ret);
860 kfree(input_dev_ctx);
862 return ret;
865 static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len)
867 struct input_device_context *input_device_ctx =
868 dev_get_drvdata(&dev->device);
869 struct hid_device *hid_dev;
871 /* hid_debug = -1; */
872 hid_dev = kmalloc(sizeof(struct hid_device), GFP_KERNEL);
874 if (hid_parse_report(hid_dev, packet, len)) {
875 DPRINT_INFO(INPUTVSC_DRV, "Unable to call hd_parse_report");
876 return;
879 if (hid_dev) {
880 DPRINT_INFO(INPUTVSC_DRV, "hid_device created");
882 hid_dev->ll_driver->open = mousevsc_hid_open;
883 hid_dev->ll_driver->close = mousevsc_hid_close;
885 hid_dev->bus = BUS_VIRTUAL;
886 hid_dev->vendor = input_device_ctx->device_info.vendor;
887 hid_dev->product = input_device_ctx->device_info.product;
888 hid_dev->version = input_device_ctx->device_info.version;
889 hid_dev->dev = dev->device;
891 sprintf(hid_dev->name, "%s",
892 input_device_ctx->device_info.name);
895 * HJ Do we want to call it with a 0
897 if (!hidinput_connect(hid_dev, 0)) {
898 hid_dev->claimed |= HID_CLAIMED_INPUT;
900 input_device_ctx->connected = 1;
902 DPRINT_INFO(INPUTVSC_DRV,
903 "HID device claimed by input\n");
906 if (!hid_dev->claimed) {
907 DPRINT_ERR(INPUTVSC_DRV,
908 "HID device not claimed by "
909 "input or hiddev\n");
912 input_device_ctx->hid_device = hid_dev;
915 kfree(hid_dev);
919 static struct hv_driver mousevsc_drv = {
920 .probe = mousevsc_probe,
921 .remove = mousevsc_remove,
924 static void mousevsc_drv_exit(void)
926 vmbus_child_driver_unregister(&mousevsc_drv.driver);
929 static int __init mousevsc_init(void)
931 struct hv_driver *drv = &mousevsc_drv;
933 DPRINT_INFO(INPUTVSC_DRV, "Hyper-V Mouse driver initializing.");
935 memcpy(&drv->dev_type, &mouse_guid,
936 sizeof(struct hv_guid));
938 drv->driver.name = driver_name;
939 drv->name = driver_name;
941 /* The driver belongs to vmbus */
942 vmbus_child_driver_register(&drv->driver);
944 return 0;
947 static void __exit mousevsc_exit(void)
949 mousevsc_drv_exit();
953 * We don't want to automatically load this driver just yet, it's quite
954 * broken. It's safe if you want to load it yourself manually, but
955 * don't inflict it on unsuspecting users, that's just mean.
957 #if 0
960 * We use a PCI table to determine if we should autoload this driver This is
961 * needed by distro tools to determine if the hyperv drivers should be
962 * installed and/or configured. We don't do anything else with the table, but
963 * it needs to be present.
965 const static struct pci_device_id microsoft_hv_pci_table[] = {
966 { PCI_DEVICE(0x1414, 0x5353) }, /* VGA compatible controller */
967 { 0 }
969 MODULE_DEVICE_TABLE(pci, microsoft_hv_pci_table);
970 #endif
972 MODULE_LICENSE("GPL");
973 MODULE_VERSION(HV_DRV_VERSION);
974 module_init(mousevsc_init);
975 module_exit(mousevsc_exit);