aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorK. Y. Srinivasan <kys@microsoft.com>2011-03-10 17:03:51 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2011-03-14 15:29:56 -0400
commita6e4d8e3fee3cb49c4a0f696c26f1c7b1e4d7a1b (patch)
treee9e2998c4077565f53561314d2a8b6481489b233
parentf0dee9f26c31363f43a643a36f1de70a073bca0e (diff)
Staging: hv: Simplify root device management
As part of simplifying root device management, get rid of the hv_driver object from vmbus_driver_context. Signed-off-by: K. Y. Srinivasan <kys@microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com> Signed-off-by: Mike Sterling <mike.sterling@microsoft.com> Signed-off-by: Abhishek Kane <v-abkane@microsoft.com> Signed-off-by: Hank Janssen <hjanssen@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/staging/hv/vmbus_drv.c41
1 files changed, 11 insertions, 30 deletions
diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 159dfdaec0fc..884a4c65159d 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -42,7 +42,6 @@
42 42
43/* Main vmbus driver data structure */ 43/* Main vmbus driver data structure */
44struct vmbus_driver_context { 44struct vmbus_driver_context {
45 struct hv_driver drv_obj;
46 45
47 struct bus_type bus; 46 struct bus_type bus;
48 struct tasklet_struct msg_dpc; 47 struct tasklet_struct msg_dpc;
@@ -458,7 +457,6 @@ static ssize_t vmbus_show_device_attr(struct device *dev,
458static int vmbus_bus_init(void) 457static int vmbus_bus_init(void)
459{ 458{
460 struct vmbus_driver_context *vmbus_drv_ctx = &vmbus_drv; 459 struct vmbus_driver_context *vmbus_drv_ctx = &vmbus_drv;
461 struct hv_driver *driver = &vmbus_drv.drv_obj;
462 struct hv_device *dev_ctx = &vmbus_drv.device_ctx; 460 struct hv_device *dev_ctx = &vmbus_drv.device_ctx;
463 int ret; 461 int ret;
464 unsigned int vector; 462 unsigned int vector;
@@ -474,13 +472,6 @@ static int vmbus_bus_init(void)
474 sizeof(struct vmbus_channel_packet_page_buffer), 472 sizeof(struct vmbus_channel_packet_page_buffer),
475 sizeof(struct vmbus_channel_packet_multipage_buffer)); 473 sizeof(struct vmbus_channel_packet_multipage_buffer));
476 474
477 driver->name = driver_name;
478 memcpy(&driver->dev_type, &device_type, sizeof(struct hv_guid));
479
480 /* Setup dispatch table */
481 driver->dev_add = vmbus_dev_add;
482 driver->dev_rm = vmbus_dev_rm;
483 driver->cleanup = vmbus_cleanup;
484 475
485 /* Hypervisor initialization...setup hypercall page..etc */ 476 /* Hypervisor initialization...setup hypercall page..etc */
486 ret = hv_init(); 477 ret = hv_init();
@@ -490,22 +481,16 @@ static int vmbus_bus_init(void)
490 goto cleanup; 481 goto cleanup;
491 } 482 }
492 483
493 /* Sanity checks */
494 if (!driver->dev_add) {
495 DPRINT_ERR(VMBUS_DRV, "OnDeviceAdd() routine not set");
496 ret = -1;
497 goto cleanup;
498 }
499 484
500 vmbus_drv_ctx->bus.name = driver->name; 485 vmbus_drv_ctx->bus.name = driver_name;
501 486
502 /* Initialize the bus context */ 487 /* Initialize the bus context */
503 tasklet_init(&vmbus_drv_ctx->msg_dpc, vmbus_msg_dpc, 488 tasklet_init(&vmbus_drv_ctx->msg_dpc, vmbus_msg_dpc,
504 (unsigned long)driver); 489 (unsigned long)NULL);
505 tasklet_init(&vmbus_drv_ctx->event_dpc, vmbus_event_dpc, 490 tasklet_init(&vmbus_drv_ctx->event_dpc, vmbus_event_dpc,
506 (unsigned long)driver); 491 (unsigned long)NULL);
507 492
508 /* Now, register the bus driver with LDM */ 493 /* Now, register the bus with LDM */
509 ret = bus_register(&vmbus_drv_ctx->bus); 494 ret = bus_register(&vmbus_drv_ctx->bus);
510 if (ret) { 495 if (ret) {
511 ret = -1; 496 ret = -1;
@@ -514,7 +499,7 @@ static int vmbus_bus_init(void)
514 499
515 /* Get the interrupt resource */ 500 /* Get the interrupt resource */
516 ret = request_irq(vmbus_irq, vmbus_isr, IRQF_SAMPLE_RANDOM, 501 ret = request_irq(vmbus_irq, vmbus_isr, IRQF_SAMPLE_RANDOM,
517 driver->name, NULL); 502 driver_name, NULL);
518 503
519 if (ret != 0) { 504 if (ret != 0) {
520 DPRINT_ERR(VMBUS_DRV, "ERROR - Unable to request IRQ %d", 505 DPRINT_ERR(VMBUS_DRV, "ERROR - Unable to request IRQ %d",
@@ -529,10 +514,10 @@ static int vmbus_bus_init(void)
529 514
530 DPRINT_INFO(VMBUS_DRV, "irq 0x%x vector 0x%x", vmbus_irq, vector); 515 DPRINT_INFO(VMBUS_DRV, "irq 0x%x vector 0x%x", vmbus_irq, vector);
531 516
532 /* Call to bus driver to add the root device */ 517 /* Add the root device */
533 memset(dev_ctx, 0, sizeof(struct hv_device)); 518 memset(dev_ctx, 0, sizeof(struct hv_device));
534 519
535 ret = driver->dev_add(dev_ctx, &vector); 520 ret = vmbus_dev_add(dev_ctx, &vector);
536 if (ret != 0) { 521 if (ret != 0) {
537 DPRINT_ERR(VMBUS_DRV, 522 DPRINT_ERR(VMBUS_DRV,
538 "ERROR - Unable to add vmbus root device"); 523 "ERROR - Unable to add vmbus root device");
@@ -555,7 +540,7 @@ static int vmbus_bus_init(void)
555 /* Setup the device dispatch table */ 540 /* Setup the device dispatch table */
556 dev_ctx->device.release = vmbus_bus_release; 541 dev_ctx->device.release = vmbus_bus_release;
557 542
558 /* Setup the bus as root device */ 543 /* register the root device */
559 ret = device_register(&dev_ctx->device); 544 ret = device_register(&dev_ctx->device);
560 if (ret) { 545 if (ret) {
561 DPRINT_ERR(VMBUS_DRV, 546 DPRINT_ERR(VMBUS_DRV,
@@ -582,17 +567,14 @@ cleanup:
582 */ 567 */
583static void vmbus_bus_exit(void) 568static void vmbus_bus_exit(void)
584{ 569{
585 struct hv_driver *driver = &vmbus_drv.drv_obj;
586 struct vmbus_driver_context *vmbus_drv_ctx = &vmbus_drv; 570 struct vmbus_driver_context *vmbus_drv_ctx = &vmbus_drv;
587 571
588 struct hv_device *dev_ctx = &vmbus_drv.device_ctx; 572 struct hv_device *dev_ctx = &vmbus_drv.device_ctx;
589 573
590 /* Remove the root device */ 574 /* Remove the root device */
591 if (driver->dev_rm) 575 vmbus_dev_rm(dev_ctx);
592 driver->dev_rm(dev_ctx);
593 576
594 if (driver->cleanup) 577 vmbus_cleanup(NULL);
595 driver->cleanup(driver);
596 578
597 /* Unregister the root bus device */ 579 /* Unregister the root bus device */
598 device_unregister(&dev_ctx->device); 580 device_unregister(&dev_ctx->device);
@@ -1026,11 +1008,10 @@ static void vmbus_event_dpc(unsigned long data)
1026 1008
1027static irqreturn_t vmbus_isr(int irq, void *dev_id) 1009static irqreturn_t vmbus_isr(int irq, void *dev_id)
1028{ 1010{
1029 struct hv_driver *driver = &vmbus_drv.drv_obj;
1030 int ret; 1011 int ret;
1031 1012
1032 /* Call to bus driver to handle interrupt */ 1013 /* Call to bus driver to handle interrupt */
1033 ret = vmbus_on_isr(driver); 1014 ret = vmbus_on_isr(NULL);
1034 1015
1035 /* Schedules a dpc if necessary */ 1016 /* Schedules a dpc if necessary */
1036 if (ret > 0) { 1017 if (ret > 0) {