Staging: hv: vmbus: Cleanup vmbus_uevent() code
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / staging / hv / vmbus_drv.c
blobafb16704221cb23ef4f2436d365e41ff6fdf5da9
1 /*
2 * Copyright (c) 2009, Microsoft Corporation.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
13 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15 * Place - Suite 330, Boston, MA 02111-1307 USA.
17 * Authors:
18 * Haiyang Zhang <haiyangz@microsoft.com>
19 * Hank Janssen <hjanssen@microsoft.com>
20 * K. Y. Srinivasan <kys@microsoft.com>
23 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
25 #include <linux/init.h>
26 #include <linux/module.h>
27 #include <linux/device.h>
28 #include <linux/irq.h>
29 #include <linux/interrupt.h>
30 #include <linux/sysctl.h>
31 #include <linux/dmi.h>
32 #include <linux/slab.h>
33 #include <linux/acpi.h>
34 #include <acpi/acpi_bus.h>
35 #include <linux/completion.h>
37 #include "hyperv.h"
38 #include "hyperv_vmbus.h"
41 static struct acpi_device *hv_acpi_dev;
43 static struct tasklet_struct msg_dpc;
44 static struct tasklet_struct event_dpc;
46 unsigned int vmbus_loglevel = (ALL_MODULES << 16 | INFO_LVL);
47 EXPORT_SYMBOL(vmbus_loglevel);
48 /* (ALL_MODULES << 16 | DEBUG_LVL_ENTEREXIT); */
49 /* (((VMBUS | VMBUS_DRV)<<16) | DEBUG_LVL_ENTEREXIT); */
51 static struct completion probe_event;
52 static int irq;
54 static void get_channel_info(struct hv_device *device,
55 struct hv_device_info *info)
57 struct vmbus_channel_debug_info debug_info;
59 if (!device->channel)
60 return;
62 vmbus_get_debug_info(device->channel, &debug_info);
64 info->chn_id = debug_info.relid;
65 info->chn_state = debug_info.state;
66 memcpy(&info->chn_type, &debug_info.interfacetype,
67 sizeof(uuid_le));
68 memcpy(&info->chn_instance, &debug_info.interface_instance,
69 sizeof(uuid_le));
71 info->monitor_id = debug_info.monitorid;
73 info->server_monitor_pending = debug_info.servermonitor_pending;
74 info->server_monitor_latency = debug_info.servermonitor_latency;
75 info->server_monitor_conn_id = debug_info.servermonitor_connectionid;
77 info->client_monitor_pending = debug_info.clientmonitor_pending;
78 info->client_monitor_latency = debug_info.clientmonitor_latency;
79 info->client_monitor_conn_id = debug_info.clientmonitor_connectionid;
81 info->inbound.int_mask = debug_info.inbound.current_interrupt_mask;
82 info->inbound.read_idx = debug_info.inbound.current_read_index;
83 info->inbound.write_idx = debug_info.inbound.current_write_index;
84 info->inbound.bytes_avail_toread =
85 debug_info.inbound.bytes_avail_toread;
86 info->inbound.bytes_avail_towrite =
87 debug_info.inbound.bytes_avail_towrite;
89 info->outbound.int_mask =
90 debug_info.outbound.current_interrupt_mask;
91 info->outbound.read_idx = debug_info.outbound.current_read_index;
92 info->outbound.write_idx = debug_info.outbound.current_write_index;
93 info->outbound.bytes_avail_toread =
94 debug_info.outbound.bytes_avail_toread;
95 info->outbound.bytes_avail_towrite =
96 debug_info.outbound.bytes_avail_towrite;
100 * vmbus_show_device_attr - Show the device attribute in sysfs.
102 * This is invoked when user does a
103 * "cat /sys/bus/vmbus/devices/<busdevice>/<attr name>"
105 static ssize_t vmbus_show_device_attr(struct device *dev,
106 struct device_attribute *dev_attr,
107 char *buf)
109 struct hv_device *hv_dev = device_to_hv_device(dev);
110 struct hv_device_info device_info;
112 memset(&device_info, 0, sizeof(struct hv_device_info));
114 get_channel_info(hv_dev, &device_info);
116 if (!strcmp(dev_attr->attr.name, "class_id")) {
117 return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-"
118 "%02x%02x%02x%02x%02x%02x%02x%02x}\n",
119 device_info.chn_type.b[3],
120 device_info.chn_type.b[2],
121 device_info.chn_type.b[1],
122 device_info.chn_type.b[0],
123 device_info.chn_type.b[5],
124 device_info.chn_type.b[4],
125 device_info.chn_type.b[7],
126 device_info.chn_type.b[6],
127 device_info.chn_type.b[8],
128 device_info.chn_type.b[9],
129 device_info.chn_type.b[10],
130 device_info.chn_type.b[11],
131 device_info.chn_type.b[12],
132 device_info.chn_type.b[13],
133 device_info.chn_type.b[14],
134 device_info.chn_type.b[15]);
135 } else if (!strcmp(dev_attr->attr.name, "device_id")) {
136 return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-"
137 "%02x%02x%02x%02x%02x%02x%02x%02x}\n",
138 device_info.chn_instance.b[3],
139 device_info.chn_instance.b[2],
140 device_info.chn_instance.b[1],
141 device_info.chn_instance.b[0],
142 device_info.chn_instance.b[5],
143 device_info.chn_instance.b[4],
144 device_info.chn_instance.b[7],
145 device_info.chn_instance.b[6],
146 device_info.chn_instance.b[8],
147 device_info.chn_instance.b[9],
148 device_info.chn_instance.b[10],
149 device_info.chn_instance.b[11],
150 device_info.chn_instance.b[12],
151 device_info.chn_instance.b[13],
152 device_info.chn_instance.b[14],
153 device_info.chn_instance.b[15]);
154 } else if (!strcmp(dev_attr->attr.name, "state")) {
155 return sprintf(buf, "%d\n", device_info.chn_state);
156 } else if (!strcmp(dev_attr->attr.name, "id")) {
157 return sprintf(buf, "%d\n", device_info.chn_id);
158 } else if (!strcmp(dev_attr->attr.name, "out_intr_mask")) {
159 return sprintf(buf, "%d\n", device_info.outbound.int_mask);
160 } else if (!strcmp(dev_attr->attr.name, "out_read_index")) {
161 return sprintf(buf, "%d\n", device_info.outbound.read_idx);
162 } else if (!strcmp(dev_attr->attr.name, "out_write_index")) {
163 return sprintf(buf, "%d\n", device_info.outbound.write_idx);
164 } else if (!strcmp(dev_attr->attr.name, "out_read_bytes_avail")) {
165 return sprintf(buf, "%d\n",
166 device_info.outbound.bytes_avail_toread);
167 } else if (!strcmp(dev_attr->attr.name, "out_write_bytes_avail")) {
168 return sprintf(buf, "%d\n",
169 device_info.outbound.bytes_avail_towrite);
170 } else if (!strcmp(dev_attr->attr.name, "in_intr_mask")) {
171 return sprintf(buf, "%d\n", device_info.inbound.int_mask);
172 } else if (!strcmp(dev_attr->attr.name, "in_read_index")) {
173 return sprintf(buf, "%d\n", device_info.inbound.read_idx);
174 } else if (!strcmp(dev_attr->attr.name, "in_write_index")) {
175 return sprintf(buf, "%d\n", device_info.inbound.write_idx);
176 } else if (!strcmp(dev_attr->attr.name, "in_read_bytes_avail")) {
177 return sprintf(buf, "%d\n",
178 device_info.inbound.bytes_avail_toread);
179 } else if (!strcmp(dev_attr->attr.name, "in_write_bytes_avail")) {
180 return sprintf(buf, "%d\n",
181 device_info.inbound.bytes_avail_towrite);
182 } else if (!strcmp(dev_attr->attr.name, "monitor_id")) {
183 return sprintf(buf, "%d\n", device_info.monitor_id);
184 } else if (!strcmp(dev_attr->attr.name, "server_monitor_pending")) {
185 return sprintf(buf, "%d\n", device_info.server_monitor_pending);
186 } else if (!strcmp(dev_attr->attr.name, "server_monitor_latency")) {
187 return sprintf(buf, "%d\n", device_info.server_monitor_latency);
188 } else if (!strcmp(dev_attr->attr.name, "server_monitor_conn_id")) {
189 return sprintf(buf, "%d\n",
190 device_info.server_monitor_conn_id);
191 } else if (!strcmp(dev_attr->attr.name, "client_monitor_pending")) {
192 return sprintf(buf, "%d\n", device_info.client_monitor_pending);
193 } else if (!strcmp(dev_attr->attr.name, "client_monitor_latency")) {
194 return sprintf(buf, "%d\n", device_info.client_monitor_latency);
195 } else if (!strcmp(dev_attr->attr.name, "client_monitor_conn_id")) {
196 return sprintf(buf, "%d\n",
197 device_info.client_monitor_conn_id);
198 } else {
199 return 0;
203 /* Set up per device attributes in /sys/bus/vmbus/devices/<bus device> */
204 static struct device_attribute vmbus_device_attrs[] = {
205 __ATTR(id, S_IRUGO, vmbus_show_device_attr, NULL),
206 __ATTR(state, S_IRUGO, vmbus_show_device_attr, NULL),
207 __ATTR(class_id, S_IRUGO, vmbus_show_device_attr, NULL),
208 __ATTR(device_id, S_IRUGO, vmbus_show_device_attr, NULL),
209 __ATTR(monitor_id, S_IRUGO, vmbus_show_device_attr, NULL),
211 __ATTR(server_monitor_pending, S_IRUGO, vmbus_show_device_attr, NULL),
212 __ATTR(server_monitor_latency, S_IRUGO, vmbus_show_device_attr, NULL),
213 __ATTR(server_monitor_conn_id, S_IRUGO, vmbus_show_device_attr, NULL),
215 __ATTR(client_monitor_pending, S_IRUGO, vmbus_show_device_attr, NULL),
216 __ATTR(client_monitor_latency, S_IRUGO, vmbus_show_device_attr, NULL),
217 __ATTR(client_monitor_conn_id, S_IRUGO, vmbus_show_device_attr, NULL),
219 __ATTR(out_intr_mask, S_IRUGO, vmbus_show_device_attr, NULL),
220 __ATTR(out_read_index, S_IRUGO, vmbus_show_device_attr, NULL),
221 __ATTR(out_write_index, S_IRUGO, vmbus_show_device_attr, NULL),
222 __ATTR(out_read_bytes_avail, S_IRUGO, vmbus_show_device_attr, NULL),
223 __ATTR(out_write_bytes_avail, S_IRUGO, vmbus_show_device_attr, NULL),
225 __ATTR(in_intr_mask, S_IRUGO, vmbus_show_device_attr, NULL),
226 __ATTR(in_read_index, S_IRUGO, vmbus_show_device_attr, NULL),
227 __ATTR(in_write_index, S_IRUGO, vmbus_show_device_attr, NULL),
228 __ATTR(in_read_bytes_avail, S_IRUGO, vmbus_show_device_attr, NULL),
229 __ATTR(in_write_bytes_avail, S_IRUGO, vmbus_show_device_attr, NULL),
230 __ATTR_NULL
235 * vmbus_uevent - add uevent for our device
237 * This routine is invoked when a device is added or removed on the vmbus to
238 * generate a uevent to udev in the userspace. The udev will then look at its
239 * rule and the uevent generated here to load the appropriate driver
241 * The alias string will be of the form vmbus:guid where guid is the string
242 * representation of the device guid (each byte of the guid will be
243 * represented with two hex characters.
245 static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env)
247 struct hv_device *dev = device_to_hv_device(device);
248 int i, ret;
249 char alias_name[((sizeof((struct hv_vmbus_device_id *)0)->guid) + 1) * 2];
251 for (i = 0; i < ((sizeof((struct hv_vmbus_device_id *)0)->guid) * 2); i += 2)
252 sprintf(&alias_name[i], "%02x", dev->dev_type.b[i/2]);
254 ret = add_uevent_var(env, "MODALIAS=vmbus:%s", alias_name);
255 return ret;
260 * vmbus_match - Attempt to match the specified device to the specified driver
262 static int vmbus_match(struct device *device, struct device_driver *driver)
264 int match = 0;
265 struct hv_driver *drv = drv_to_hv_drv(driver);
266 struct hv_device *hv_dev = device_to_hv_device(device);
268 /* We found our driver ? */
269 if (!uuid_le_cmp(hv_dev->dev_type, drv->dev_type))
270 match = 1;
272 return match;
276 * vmbus_probe - Add the new vmbus's child device
278 static int vmbus_probe(struct device *child_device)
280 int ret = 0;
281 struct hv_driver *drv =
282 drv_to_hv_drv(child_device->driver);
283 struct hv_device *dev = device_to_hv_device(child_device);
285 if (drv->probe) {
286 ret = drv->probe(dev);
287 if (ret != 0)
288 pr_err("probe failed for device %s (%d)\n",
289 dev_name(child_device), ret);
291 } else {
292 pr_err("probe not set for driver %s\n",
293 dev_name(child_device));
294 ret = -ENODEV;
296 return ret;
300 * vmbus_remove - Remove a vmbus device
302 static int vmbus_remove(struct device *child_device)
304 int ret;
305 struct hv_driver *drv;
307 struct hv_device *dev = device_to_hv_device(child_device);
309 if (child_device->driver) {
310 drv = drv_to_hv_drv(child_device->driver);
312 if (drv->remove) {
313 ret = drv->remove(dev);
314 } else {
315 pr_err("remove not set for driver %s\n",
316 dev_name(child_device));
317 ret = -ENODEV;
321 return 0;
326 * vmbus_shutdown - Shutdown a vmbus device
328 static void vmbus_shutdown(struct device *child_device)
330 struct hv_driver *drv;
331 struct hv_device *dev = device_to_hv_device(child_device);
334 /* The device may not be attached yet */
335 if (!child_device->driver)
336 return;
338 drv = drv_to_hv_drv(child_device->driver);
340 if (drv->shutdown)
341 drv->shutdown(dev);
343 return;
348 * vmbus_device_release - Final callback release of the vmbus child device
350 static void vmbus_device_release(struct device *device)
352 struct hv_device *hv_dev = device_to_hv_device(device);
354 kfree(hv_dev);
358 /* The one and only one */
359 static struct bus_type hv_bus = {
360 .name = "vmbus",
361 .match = vmbus_match,
362 .shutdown = vmbus_shutdown,
363 .remove = vmbus_remove,
364 .probe = vmbus_probe,
365 .uevent = vmbus_uevent,
366 .dev_attrs = vmbus_device_attrs,
369 static const char *driver_name = "hyperv";
372 struct onmessage_work_context {
373 struct work_struct work;
374 struct hv_message msg;
377 static void vmbus_onmessage_work(struct work_struct *work)
379 struct onmessage_work_context *ctx;
381 ctx = container_of(work, struct onmessage_work_context,
382 work);
383 vmbus_onmessage(&ctx->msg);
384 kfree(ctx);
388 * vmbus_on_msg_dpc - DPC routine to handle messages from the hypervisior
390 static void vmbus_on_msg_dpc(unsigned long data)
392 int cpu = smp_processor_id();
393 void *page_addr = hv_context.synic_message_page[cpu];
394 struct hv_message *msg = (struct hv_message *)page_addr +
395 VMBUS_MESSAGE_SINT;
396 struct onmessage_work_context *ctx;
398 while (1) {
399 if (msg->header.message_type == HVMSG_NONE) {
400 /* no msg */
401 break;
402 } else {
403 ctx = kmalloc(sizeof(*ctx), GFP_ATOMIC);
404 if (ctx == NULL)
405 continue;
406 INIT_WORK(&ctx->work, vmbus_onmessage_work);
407 memcpy(&ctx->msg, msg, sizeof(*msg));
408 queue_work(vmbus_connection.work_queue, &ctx->work);
411 msg->header.message_type = HVMSG_NONE;
414 * Make sure the write to MessageType (ie set to
415 * HVMSG_NONE) happens before we read the
416 * MessagePending and EOMing. Otherwise, the EOMing
417 * will not deliver any more messages since there is
418 * no empty slot
420 smp_mb();
422 if (msg->header.message_flags.msg_pending) {
424 * This will cause message queue rescan to
425 * possibly deliver another msg from the
426 * hypervisor
428 wrmsrl(HV_X64_MSR_EOM, 0);
434 * vmbus_on_isr - ISR routine
436 static int vmbus_on_isr(void)
438 int ret = 0;
439 int cpu = smp_processor_id();
440 void *page_addr;
441 struct hv_message *msg;
442 union hv_synic_event_flags *event;
444 page_addr = hv_context.synic_message_page[cpu];
445 msg = (struct hv_message *)page_addr + VMBUS_MESSAGE_SINT;
447 /* Check if there are actual msgs to be process */
448 if (msg->header.message_type != HVMSG_NONE)
449 ret |= 0x1;
451 page_addr = hv_context.synic_event_page[cpu];
452 event = (union hv_synic_event_flags *)page_addr + VMBUS_MESSAGE_SINT;
454 /* Since we are a child, we only need to check bit 0 */
455 if (sync_test_and_clear_bit(0, (unsigned long *) &event->flags32[0]))
456 ret |= 0x2;
458 return ret;
462 static irqreturn_t vmbus_isr(int irq, void *dev_id)
464 int ret;
466 ret = vmbus_on_isr();
468 /* Schedules a dpc if necessary */
469 if (ret > 0) {
470 if (test_bit(0, (unsigned long *)&ret))
471 tasklet_schedule(&msg_dpc);
473 if (test_bit(1, (unsigned long *)&ret))
474 tasklet_schedule(&event_dpc);
476 return IRQ_HANDLED;
477 } else {
478 return IRQ_NONE;
483 * vmbus_bus_init -Main vmbus driver initialization routine.
485 * Here, we
486 * - initialize the vmbus driver context
487 * - invoke the vmbus hv main init routine
488 * - get the irq resource
489 * - retrieve the channel offers
491 static int vmbus_bus_init(int irq)
493 int ret;
494 unsigned int vector;
496 /* Hypervisor initialization...setup hypercall page..etc */
497 ret = hv_init();
498 if (ret != 0) {
499 pr_err("Unable to initialize the hypervisor - 0x%x\n", ret);
500 return ret;
503 /* Initialize the bus context */
504 tasklet_init(&msg_dpc, vmbus_on_msg_dpc, 0);
505 tasklet_init(&event_dpc, vmbus_on_event, 0);
507 /* Now, register the bus with LDM */
508 ret = bus_register(&hv_bus);
509 if (ret)
510 return ret;
512 /* Get the interrupt resource */
513 ret = request_irq(irq, vmbus_isr, IRQF_SAMPLE_RANDOM,
514 driver_name, hv_acpi_dev);
516 if (ret != 0) {
517 pr_err("Unable to request IRQ %d\n",
518 irq);
520 bus_unregister(&hv_bus);
522 return ret;
525 vector = IRQ0_VECTOR + irq;
528 * Notify the hypervisor of our irq and
529 * connect to the host.
531 on_each_cpu(hv_synic_init, (void *)&vector, 1);
532 ret = vmbus_connect();
533 if (ret) {
534 free_irq(irq, hv_acpi_dev);
535 bus_unregister(&hv_bus);
536 return ret;
540 vmbus_request_offers();
542 return 0;
546 * vmbus_child_driver_register() - Register a vmbus's child driver
547 * @drv: Pointer to driver structure you want to register
550 * Registers the given driver with Linux through the 'driver_register()' call
551 * And sets up the hyper-v vmbus handling for this driver.
552 * It will return the state of the 'driver_register()' call.
554 * Mainly used by Hyper-V drivers.
556 int vmbus_child_driver_register(struct device_driver *drv)
558 int ret;
560 pr_info("child driver registering - name %s\n", drv->name);
562 /* The child driver on this vmbus */
563 drv->bus = &hv_bus;
565 ret = driver_register(drv);
567 vmbus_request_offers();
569 return ret;
571 EXPORT_SYMBOL(vmbus_child_driver_register);
574 * vmbus_child_driver_unregister() - Unregister a vmbus's child driver
575 * @drv: Pointer to driver structure you want to un-register
578 * Un-register the given driver with Linux through the 'driver_unregister()'
579 * call. And ungegisters the driver from the Hyper-V vmbus handler.
581 * Mainly used by Hyper-V drivers.
583 void vmbus_child_driver_unregister(struct device_driver *drv)
585 pr_info("child driver unregistering - name %s\n", drv->name);
587 driver_unregister(drv);
590 EXPORT_SYMBOL(vmbus_child_driver_unregister);
593 * vmbus_child_device_create - Creates and registers a new child device
594 * on the vmbus.
596 struct hv_device *vmbus_child_device_create(uuid_le *type,
597 uuid_le *instance,
598 struct vmbus_channel *channel)
600 struct hv_device *child_device_obj;
602 /* Allocate the new child device */
603 child_device_obj = kzalloc(sizeof(struct hv_device), GFP_KERNEL);
604 if (!child_device_obj) {
605 pr_err("Unable to allocate device object for child device\n");
606 return NULL;
609 child_device_obj->channel = channel;
610 memcpy(&child_device_obj->dev_type, type, sizeof(uuid_le));
611 memcpy(&child_device_obj->dev_instance, instance,
612 sizeof(uuid_le));
615 return child_device_obj;
619 * vmbus_child_device_register - Register the child device
621 int vmbus_child_device_register(struct hv_device *child_device_obj)
623 int ret = 0;
625 static atomic_t device_num = ATOMIC_INIT(0);
627 /* Set the device name. Otherwise, device_register() will fail. */
628 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
629 atomic_inc_return(&device_num));
631 /* The new device belongs to this bus */
632 child_device_obj->device.bus = &hv_bus; /* device->dev.bus; */
633 child_device_obj->device.parent = &hv_acpi_dev->dev;
634 child_device_obj->device.release = vmbus_device_release;
637 * Register with the LDM. This will kick off the driver/device
638 * binding...which will eventually call vmbus_match() and vmbus_probe()
640 ret = device_register(&child_device_obj->device);
642 if (ret)
643 pr_err("Unable to register child device\n");
644 else
645 pr_info("child device %s registered\n",
646 dev_name(&child_device_obj->device));
648 return ret;
652 * vmbus_child_device_unregister - Remove the specified child device
653 * from the vmbus.
655 void vmbus_child_device_unregister(struct hv_device *device_obj)
658 * Kick off the process of unregistering the device.
659 * This will call vmbus_remove() and eventually vmbus_device_release()
661 device_unregister(&device_obj->device);
663 pr_info("child device %s unregistered\n",
664 dev_name(&device_obj->device));
669 * VMBUS is an acpi enumerated device. Get the the IRQ information
670 * from DSDT.
673 static acpi_status vmbus_walk_resources(struct acpi_resource *res, void *irq)
676 if (res->type == ACPI_RESOURCE_TYPE_IRQ) {
677 struct acpi_resource_irq *irqp;
678 irqp = &res->data.irq;
680 *((unsigned int *)irq) = irqp->interrupts[0];
683 return AE_OK;
686 static int vmbus_acpi_add(struct acpi_device *device)
688 acpi_status result;
690 hv_acpi_dev = device;
692 result =
693 acpi_walk_resources(device->handle, METHOD_NAME__CRS,
694 vmbus_walk_resources, &irq);
696 if (ACPI_FAILURE(result)) {
697 complete(&probe_event);
698 return -ENODEV;
700 complete(&probe_event);
701 return 0;
704 static const struct acpi_device_id vmbus_acpi_device_ids[] = {
705 {"VMBUS", 0},
706 {"VMBus", 0},
707 {"", 0},
709 MODULE_DEVICE_TABLE(acpi, vmbus_acpi_device_ids);
711 static struct acpi_driver vmbus_acpi_driver = {
712 .name = "vmbus",
713 .ids = vmbus_acpi_device_ids,
714 .ops = {
715 .add = vmbus_acpi_add,
719 static int __init hv_acpi_init(void)
721 int ret, t;
723 init_completion(&probe_event);
726 * Get irq resources first.
729 ret = acpi_bus_register_driver(&vmbus_acpi_driver);
731 if (ret)
732 return ret;
734 t = wait_for_completion_timeout(&probe_event, 5*HZ);
735 if (t == 0) {
736 ret = -ETIMEDOUT;
737 goto cleanup;
740 if (irq <= 0) {
741 ret = -ENODEV;
742 goto cleanup;
745 ret = vmbus_bus_init(irq);
746 if (ret)
747 goto cleanup;
749 return 0;
751 cleanup:
752 acpi_bus_unregister_driver(&vmbus_acpi_driver);
753 return ret;
757 MODULE_LICENSE("GPL");
758 MODULE_VERSION(HV_DRV_VERSION);
759 module_param(vmbus_loglevel, int, S_IRUGO|S_IWUSR);
761 module_init(hv_acpi_init);