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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
f0dee9f26c
commit
a6e4d8e3fe
@@ -42,7 +42,6 @@
|
|||||||
|
|
||||||
/* Main vmbus driver data structure */
|
/* Main vmbus driver data structure */
|
||||||
struct vmbus_driver_context {
|
struct vmbus_driver_context {
|
||||||
struct hv_driver drv_obj;
|
|
||||||
|
|
||||||
struct bus_type bus;
|
struct bus_type bus;
|
||||||
struct tasklet_struct msg_dpc;
|
struct tasklet_struct msg_dpc;
|
||||||
@@ -458,7 +457,6 @@ static ssize_t vmbus_show_device_attr(struct device *dev,
|
|||||||
static int vmbus_bus_init(void)
|
static int vmbus_bus_init(void)
|
||||||
{
|
{
|
||||||
struct vmbus_driver_context *vmbus_drv_ctx = &vmbus_drv;
|
struct vmbus_driver_context *vmbus_drv_ctx = &vmbus_drv;
|
||||||
struct hv_driver *driver = &vmbus_drv.drv_obj;
|
|
||||||
struct hv_device *dev_ctx = &vmbus_drv.device_ctx;
|
struct hv_device *dev_ctx = &vmbus_drv.device_ctx;
|
||||||
int ret;
|
int ret;
|
||||||
unsigned int vector;
|
unsigned int vector;
|
||||||
@@ -474,13 +472,6 @@ static int vmbus_bus_init(void)
|
|||||||
sizeof(struct vmbus_channel_packet_page_buffer),
|
sizeof(struct vmbus_channel_packet_page_buffer),
|
||||||
sizeof(struct vmbus_channel_packet_multipage_buffer));
|
sizeof(struct vmbus_channel_packet_multipage_buffer));
|
||||||
|
|
||||||
driver->name = driver_name;
|
|
||||||
memcpy(&driver->dev_type, &device_type, sizeof(struct hv_guid));
|
|
||||||
|
|
||||||
/* Setup dispatch table */
|
|
||||||
driver->dev_add = vmbus_dev_add;
|
|
||||||
driver->dev_rm = vmbus_dev_rm;
|
|
||||||
driver->cleanup = vmbus_cleanup;
|
|
||||||
|
|
||||||
/* Hypervisor initialization...setup hypercall page..etc */
|
/* Hypervisor initialization...setup hypercall page..etc */
|
||||||
ret = hv_init();
|
ret = hv_init();
|
||||||
@@ -490,22 +481,16 @@ static int vmbus_bus_init(void)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sanity checks */
|
|
||||||
if (!driver->dev_add) {
|
|
||||||
DPRINT_ERR(VMBUS_DRV, "OnDeviceAdd() routine not set");
|
|
||||||
ret = -1;
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
vmbus_drv_ctx->bus.name = driver->name;
|
vmbus_drv_ctx->bus.name = driver_name;
|
||||||
|
|
||||||
/* Initialize the bus context */
|
/* Initialize the bus context */
|
||||||
tasklet_init(&vmbus_drv_ctx->msg_dpc, vmbus_msg_dpc,
|
tasklet_init(&vmbus_drv_ctx->msg_dpc, vmbus_msg_dpc,
|
||||||
(unsigned long)driver);
|
(unsigned long)NULL);
|
||||||
tasklet_init(&vmbus_drv_ctx->event_dpc, vmbus_event_dpc,
|
tasklet_init(&vmbus_drv_ctx->event_dpc, vmbus_event_dpc,
|
||||||
(unsigned long)driver);
|
(unsigned long)NULL);
|
||||||
|
|
||||||
/* Now, register the bus driver with LDM */
|
/* Now, register the bus with LDM */
|
||||||
ret = bus_register(&vmbus_drv_ctx->bus);
|
ret = bus_register(&vmbus_drv_ctx->bus);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
@@ -514,7 +499,7 @@ static int vmbus_bus_init(void)
|
|||||||
|
|
||||||
/* Get the interrupt resource */
|
/* Get the interrupt resource */
|
||||||
ret = request_irq(vmbus_irq, vmbus_isr, IRQF_SAMPLE_RANDOM,
|
ret = request_irq(vmbus_irq, vmbus_isr, IRQF_SAMPLE_RANDOM,
|
||||||
driver->name, NULL);
|
driver_name, NULL);
|
||||||
|
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
DPRINT_ERR(VMBUS_DRV, "ERROR - Unable to request IRQ %d",
|
DPRINT_ERR(VMBUS_DRV, "ERROR - Unable to request IRQ %d",
|
||||||
@@ -529,10 +514,10 @@ static int vmbus_bus_init(void)
|
|||||||
|
|
||||||
DPRINT_INFO(VMBUS_DRV, "irq 0x%x vector 0x%x", vmbus_irq, vector);
|
DPRINT_INFO(VMBUS_DRV, "irq 0x%x vector 0x%x", vmbus_irq, vector);
|
||||||
|
|
||||||
/* Call to bus driver to add the root device */
|
/* Add the root device */
|
||||||
memset(dev_ctx, 0, sizeof(struct hv_device));
|
memset(dev_ctx, 0, sizeof(struct hv_device));
|
||||||
|
|
||||||
ret = driver->dev_add(dev_ctx, &vector);
|
ret = vmbus_dev_add(dev_ctx, &vector);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
DPRINT_ERR(VMBUS_DRV,
|
DPRINT_ERR(VMBUS_DRV,
|
||||||
"ERROR - Unable to add vmbus root device");
|
"ERROR - Unable to add vmbus root device");
|
||||||
@@ -555,7 +540,7 @@ static int vmbus_bus_init(void)
|
|||||||
/* Setup the device dispatch table */
|
/* Setup the device dispatch table */
|
||||||
dev_ctx->device.release = vmbus_bus_release;
|
dev_ctx->device.release = vmbus_bus_release;
|
||||||
|
|
||||||
/* Setup the bus as root device */
|
/* register the root device */
|
||||||
ret = device_register(&dev_ctx->device);
|
ret = device_register(&dev_ctx->device);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
DPRINT_ERR(VMBUS_DRV,
|
DPRINT_ERR(VMBUS_DRV,
|
||||||
@@ -582,17 +567,14 @@ cleanup:
|
|||||||
*/
|
*/
|
||||||
static void vmbus_bus_exit(void)
|
static void vmbus_bus_exit(void)
|
||||||
{
|
{
|
||||||
struct hv_driver *driver = &vmbus_drv.drv_obj;
|
|
||||||
struct vmbus_driver_context *vmbus_drv_ctx = &vmbus_drv;
|
struct vmbus_driver_context *vmbus_drv_ctx = &vmbus_drv;
|
||||||
|
|
||||||
struct hv_device *dev_ctx = &vmbus_drv.device_ctx;
|
struct hv_device *dev_ctx = &vmbus_drv.device_ctx;
|
||||||
|
|
||||||
/* Remove the root device */
|
/* Remove the root device */
|
||||||
if (driver->dev_rm)
|
vmbus_dev_rm(dev_ctx);
|
||||||
driver->dev_rm(dev_ctx);
|
|
||||||
|
|
||||||
if (driver->cleanup)
|
vmbus_cleanup(NULL);
|
||||||
driver->cleanup(driver);
|
|
||||||
|
|
||||||
/* Unregister the root bus device */
|
/* Unregister the root bus device */
|
||||||
device_unregister(&dev_ctx->device);
|
device_unregister(&dev_ctx->device);
|
||||||
@@ -1026,11 +1008,10 @@ 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)
|
||||||
{
|
{
|
||||||
struct hv_driver *driver = &vmbus_drv.drv_obj;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Call to bus driver to handle interrupt */
|
/* Call to bus driver to handle interrupt */
|
||||||
ret = vmbus_on_isr(driver);
|
ret = vmbus_on_isr(NULL);
|
||||||
|
|
||||||
/* Schedules a dpc if necessary */
|
/* Schedules a dpc if necessary */
|
||||||
if (ret > 0) {
|
if (ret > 0) {
|
||||||
|
Reference in New Issue
Block a user