Commit 772ec4e2 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Staging: hv: coding style cleanups on Vmbus.c

It's now much nicer and cleaner.

Cc: Hank Janssen <hjanssen@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent fd8b85ea
/* /*
*
* Copyright (c) 2009, Microsoft Corporation. * Copyright (c) 2009, Microsoft Corporation.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
...@@ -20,7 +19,6 @@ ...@@ -20,7 +19,6 @@
* Hank Janssen <hjanssen@microsoft.com> * Hank Janssen <hjanssen@microsoft.com>
* *
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/mm.h> #include <linux/mm.h>
#include "osd.h" #include "osd.h"
...@@ -28,12 +26,10 @@ ...@@ -28,12 +26,10 @@
#include "VersionInfo.h" #include "VersionInfo.h"
#include "VmbusPrivate.h" #include "VmbusPrivate.h"
static const char *gDriverName = "vmbus";
/* Globals */ /*
* Windows vmbus does not defined this.
static const char* gDriverName="vmbus";
/* Windows vmbus does not defined this.
* We defined this to be consistent with other devices * We defined this to be consistent with other devices
*/ */
/* {c5295816-f63a-4d5f-8d1a-4daf999ca185} */ /* {c5295816-f63a-4d5f-8d1a-4daf999ca185} */
...@@ -53,84 +49,41 @@ static const struct hv_guid gVmbusDeviceId = { ...@@ -53,84 +49,41 @@ static const struct hv_guid gVmbusDeviceId = {
}; };
static struct hv_driver *gDriver; /* vmbus driver object */ static struct hv_driver *gDriver; /* vmbus driver object */
static struct hv_device* gDevice; /* vmbus root device */ static struct hv_device *gDevice; /* vmbus root device */
/* Internal routines */
static void VmbusGetChannelInterface(struct vmbus_channel_interface *Interface); static void VmbusGetChannelInterface(struct vmbus_channel_interface *Interface);
static void VmbusGetChannelInfo(struct hv_device *DeviceObject,
static void struct hv_device_info *DeviceInfo);
VmbusGetChannelInfo( static void VmbusGetChannelOffers(void);
struct hv_device *DeviceObject, static int VmbusOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo);
struct hv_device_info *DeviceInfo static int VmbusOnDeviceRemove(struct hv_device *dev);
); static void VmbusOnCleanup(struct hv_driver *drv);
static int VmbusOnISR(struct hv_driver *drv);
static void static void VmbusOnMsgDPC(struct hv_driver *drv);
VmbusGetChannelOffers( static void VmbusOnEventDPC(struct hv_driver *drv);
void
); /**
* VmbusInitialize - Main entry point
static int */
VmbusOnDeviceAdd( int VmbusInitialize(struct hv_driver *drv)
struct hv_device *Device,
void *AdditionalInfo
);
static int
VmbusOnDeviceRemove(
struct hv_device *dev
);
static void
VmbusOnCleanup(
struct hv_driver *drv
);
static int
VmbusOnISR(
struct hv_driver *drv
);
static void
VmbusOnMsgDPC(
struct hv_driver *drv
);
static void
VmbusOnEventDPC(
struct hv_driver *drv
);
/*++;
Name:
VmbusInitialize()
Description:
Main entry point
--*/
int
VmbusInitialize(
struct hv_driver *drv
)
{ {
struct vmbus_driver *driver = (struct vmbus_driver *)drv; struct vmbus_driver *driver = (struct vmbus_driver *)drv;
int ret=0; int ret;
DPRINT_ENTER(VMBUS); DPRINT_ENTER(VMBUS);
DPRINT_INFO(VMBUS, "+++++++ Build Date=%s %s +++++++", VersionDate, VersionTime); DPRINT_INFO(VMBUS, "+++++++ Build Date=%s %s +++++++",
DPRINT_INFO(VMBUS, "+++++++ Build Description=%s +++++++", VersionDesc); VersionDate, VersionTime);
DPRINT_INFO(VMBUS, "+++++++ Build Description=%s +++++++",
DPRINT_INFO(VMBUS, "+++++++ Vmbus supported version = %d +++++++", VMBUS_REVISION_NUMBER); VersionDesc);
DPRINT_INFO(VMBUS, "+++++++ Vmbus using SINT %d +++++++", VMBUS_MESSAGE_SINT); DPRINT_INFO(VMBUS, "+++++++ Vmbus supported version = %d +++++++",
VMBUS_REVISION_NUMBER);
DPRINT_DBG(VMBUS, "sizeof(VMBUS_CHANNEL_PACKET_PAGE_BUFFER)=%zd, sizeof(VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER)=%zd", DPRINT_INFO(VMBUS, "+++++++ Vmbus using SINT %d +++++++",
sizeof(struct VMBUS_CHANNEL_PACKET_PAGE_BUFFER), sizeof(struct VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER)); VMBUS_MESSAGE_SINT);
DPRINT_DBG(VMBUS, "sizeof(VMBUS_CHANNEL_PACKET_PAGE_BUFFER)=%zd, "
"sizeof(VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER)=%zd",
sizeof(struct VMBUS_CHANNEL_PACKET_PAGE_BUFFER),
sizeof(struct VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER));
drv->name = gDriverName; drv->name = gDriverName;
memcpy(&drv->deviceType, &gVmbusDeviceType, sizeof(struct hv_guid)); memcpy(&drv->deviceType, &gVmbusDeviceType, sizeof(struct hv_guid));
...@@ -149,10 +102,8 @@ VmbusInitialize( ...@@ -149,10 +102,8 @@ VmbusInitialize(
/* Hypervisor initialization...setup hypercall page..etc */ /* Hypervisor initialization...setup hypercall page..etc */
ret = HvInit(); ret = HvInit();
if (ret != 0) if (ret != 0)
{ DPRINT_ERR(VMBUS, "Unable to initialize the hypervisor - 0x%x",
DPRINT_ERR(VMBUS, "Unable to initialize the hypervisor - 0x%x", ret); ret);
}
gDriver = drv; gDriver = drv;
DPRINT_EXIT(VMBUS); DPRINT_EXIT(VMBUS);
...@@ -160,93 +111,49 @@ VmbusInitialize( ...@@ -160,93 +111,49 @@ VmbusInitialize(
return ret; return ret;
} }
/**
/*++; * VmbusGetChannelOffers - Retrieve the channel offers from the parent partition
*/
Name: static void VmbusGetChannelOffers(void)
VmbusGetChannelOffers()
Description:
Retrieve the channel offers from the parent partition
--*/
static void
VmbusGetChannelOffers(void)
{ {
DPRINT_ENTER(VMBUS); DPRINT_ENTER(VMBUS);
VmbusChannelRequestOffers(); VmbusChannelRequestOffers();
DPRINT_EXIT(VMBUS); DPRINT_EXIT(VMBUS);
} }
/**
/*++; * VmbusGetChannelInterface - Get the channel interface
*/
Name:
VmbusGetChannelInterface()
Description:
Get the channel interface
--*/
static void VmbusGetChannelInterface(struct vmbus_channel_interface *Interface) static void VmbusGetChannelInterface(struct vmbus_channel_interface *Interface)
{ {
GetChannelInterface(Interface); GetChannelInterface(Interface);
} }
/**
/*++; * VmbusGetChannelInfo - Get the device info for the specified device object
*/
Name: static void VmbusGetChannelInfo(struct hv_device *DeviceObject,
VmbusGetChannelInfo() struct hv_device_info *DeviceInfo)
Description:
Get the device info for the specified device object
--*/
static void
VmbusGetChannelInfo(
struct hv_device *DeviceObject,
struct hv_device_info *DeviceInfo
)
{ {
GetChannelInfo(DeviceObject, DeviceInfo); GetChannelInfo(DeviceObject, DeviceInfo);
} }
/**
* VmbusCreateChildDevice - Creates the child device on the bus that represents the channel offer
/*++ */
Name:
VmbusCreateChildDevice()
Description:
Creates the child device on the bus that represents the channel offer
--*/
struct hv_device *VmbusChildDeviceCreate(struct hv_guid *DeviceType, struct hv_device *VmbusChildDeviceCreate(struct hv_guid *DeviceType,
struct hv_guid *DeviceInstance, struct hv_guid *DeviceInstance,
void *Context) void *Context)
{ {
struct vmbus_driver *vmbusDriver = (struct vmbus_driver *)gDriver; struct vmbus_driver *vmbusDriver = (struct vmbus_driver *)gDriver;
return vmbusDriver->OnChildDeviceCreate( return vmbusDriver->OnChildDeviceCreate(DeviceType, DeviceInstance,
DeviceType,
DeviceInstance,
Context); Context);
} }
/**
/*++ * VmbusChildDeviceAdd - Registers the child device with the vmbus
*/
Name:
VmbusChildDeviceAdd()
Description:
Registers the child device with the vmbus
--*/
int VmbusChildDeviceAdd(struct hv_device *ChildDevice) int VmbusChildDeviceAdd(struct hv_device *ChildDevice)
{ {
struct vmbus_driver *vmbusDriver = (struct vmbus_driver *)gDriver; struct vmbus_driver *vmbusDriver = (struct vmbus_driver *)gDriver;
...@@ -254,16 +161,9 @@ int VmbusChildDeviceAdd(struct hv_device *ChildDevice) ...@@ -254,16 +161,9 @@ int VmbusChildDeviceAdd(struct hv_device *ChildDevice)
return vmbusDriver->OnChildDeviceAdd(gDevice, ChildDevice); return vmbusDriver->OnChildDeviceAdd(gDevice, ChildDevice);
} }
/**
/*++ * VmbusChildDeviceRemove Unregisters the child device from the vmbus
*/
Name:
VmbusChildDeviceRemove()
Description:
Unregisters the child device from the vmbus
--*/
void VmbusChildDeviceRemove(struct hv_device *ChildDevice) void VmbusChildDeviceRemove(struct hv_device *ChildDevice)
{ {
struct vmbus_driver *vmbusDriver = (struct vmbus_driver *)gDriver; struct vmbus_driver *vmbusDriver = (struct vmbus_driver *)gDriver;
...@@ -271,52 +171,21 @@ void VmbusChildDeviceRemove(struct hv_device *ChildDevice) ...@@ -271,52 +171,21 @@ void VmbusChildDeviceRemove(struct hv_device *ChildDevice)
vmbusDriver->OnChildDeviceRemove(ChildDevice); vmbusDriver->OnChildDeviceRemove(ChildDevice);
} }
/*++ /**
* VmbusOnDeviceAdd - Callback when the root bus device is added
Name: */
VmbusChildDeviceDestroy() static int VmbusOnDeviceAdd(struct hv_device *dev, void *AdditionalInfo)
Description:
Release the child device from the vmbus
--*/
/* **************
void
VmbusChildDeviceDestroy(
struct hv_device *ChildDevice
)
{
struct vmbus_driver *vmbusDriver = (struct vmbus_driver *)gDriver;
vmbusDriver->OnChildDeviceDestroy(ChildDevice);
}
************* */
/*++
Name:
VmbusOnDeviceAdd()
Description:
Callback when the root bus device is added
--*/
static int
VmbusOnDeviceAdd(
struct hv_device *dev,
void *AdditionalInfo
)
{ {
u32 *irqvector = (u32*) AdditionalInfo; u32 *irqvector = AdditionalInfo;
int ret=0; int ret;
DPRINT_ENTER(VMBUS); DPRINT_ENTER(VMBUS);
gDevice = dev; gDevice = dev;
memcpy(&gDevice->deviceType, &gVmbusDeviceType, sizeof(struct hv_guid)); memcpy(&gDevice->deviceType, &gVmbusDeviceType, sizeof(struct hv_guid));
memcpy(&gDevice->deviceInstance, &gVmbusDeviceId, sizeof(struct hv_guid)); memcpy(&gDevice->deviceInstance, &gVmbusDeviceId,
sizeof(struct hv_guid));
/* strcpy(dev->name, "vmbus"); */ /* strcpy(dev->name, "vmbus"); */
/* SynIC setup... */ /* SynIC setup... */
...@@ -331,91 +200,52 @@ VmbusOnDeviceAdd( ...@@ -331,91 +200,52 @@ VmbusOnDeviceAdd(
return ret; return ret;
} }
/**
/*++ * VmbusOnDeviceRemove - Callback when the root bus device is removed
*/
Name: static int VmbusOnDeviceRemove(struct hv_device *dev)
VmbusOnDeviceRemove()
Description:
Callback when the root bus device is removed
--*/
static int VmbusOnDeviceRemove(
struct hv_device *dev
)
{ {
int ret=0; int ret = 0;
DPRINT_ENTER(VMBUS); DPRINT_ENTER(VMBUS);
VmbusChannelReleaseUnattachedChannels(); VmbusChannelReleaseUnattachedChannels();
VmbusDisconnect(); VmbusDisconnect();
HvSynicCleanup(); HvSynicCleanup();
DPRINT_EXIT(VMBUS); DPRINT_EXIT(VMBUS);
return ret; return ret;
} }
/**
/*++ * VmbusOnCleanup - Perform any cleanup when the driver is removed
*/
Name: static void VmbusOnCleanup(struct hv_driver *drv)
VmbusOnCleanup()
Description:
Perform any cleanup when the driver is removed
--*/
static void
VmbusOnCleanup(
struct hv_driver *drv
)
{ {
/* struct vmbus_driver *driver = (struct vmbus_driver *)drv; */ /* struct vmbus_driver *driver = (struct vmbus_driver *)drv; */
DPRINT_ENTER(VMBUS); DPRINT_ENTER(VMBUS);
HvCleanup(); HvCleanup();
DPRINT_EXIT(VMBUS); DPRINT_EXIT(VMBUS);
} }
/**
/*++ * VmbusOnMsgDPC - DPC routine to handle messages from the hypervisior
*/
Name: static void VmbusOnMsgDPC(struct hv_driver *drv)
VmbusOnMsgDPC()
Description:
DPC routine to handle messages from the hypervisior
--*/
static void
VmbusOnMsgDPC(
struct hv_driver *drv
)
{ {
void *page_addr = gHvContext.synICMessagePage[0]; void *page_addr = gHvContext.synICMessagePage[0];
struct hv_message *msg = (struct hv_message *)page_addr +
struct hv_message *msg = (struct hv_message *)page_addr + VMBUS_MESSAGE_SINT; VMBUS_MESSAGE_SINT;
struct hv_message *copied; struct hv_message *copied;
while (1)
{ while (1) {
if (msg->Header.MessageType == HvMessageTypeNone) /* no msg */ if (msg->Header.MessageType == HvMessageTypeNone) {
{ /* no msg */
break; break;
} } else {
else
{
copied = kmalloc(sizeof(*copied), GFP_ATOMIC); copied = kmalloc(sizeof(*copied), GFP_ATOMIC);
if (copied == NULL) if (copied == NULL)
{
continue; continue;
}
memcpy(copied, msg, sizeof(*copied)); memcpy(copied, msg, sizeof(*copied));
osd_schedule_callback(gVmbusConnection.WorkQueue, osd_schedule_callback(gVmbusConnection.WorkQueue,
...@@ -434,8 +264,7 @@ VmbusOnMsgDPC( ...@@ -434,8 +264,7 @@ VmbusOnMsgDPC(
*/ */
mb(); mb();
if (msg->Header.MessageFlags.MessagePending) if (msg->Header.MessageFlags.MessagePending) {
{
/* /*
* This will cause message queue rescan to * This will cause message queue rescan to
* possibly deliver another msg from the * possibly deliver another msg from the
...@@ -446,58 +275,35 @@ VmbusOnMsgDPC( ...@@ -446,58 +275,35 @@ VmbusOnMsgDPC(
} }
} }
/*++ /**
* VmbusOnEventDPC - DPC routine to handle events from the hypervisior
Name: */
VmbusOnEventDPC() static void VmbusOnEventDPC(struct hv_driver *drv)
Description:
DPC routine to handle events from the hypervisior
--*/
static void
VmbusOnEventDPC(
struct hv_driver* drv
)
{ {
/* TODO: Process any events */ /* TODO: Process any events */
VmbusOnEvents(); VmbusOnEvents();
} }
/**
/*++ * VmbusOnISR - ISR routine
*/
Name: static int VmbusOnISR(struct hv_driver *drv)
VmbusOnISR()
Description:
ISR routine
--*/
static int
VmbusOnISR(
struct hv_driver *drv
)
{ {
/* struct vmbus_driver *driver = (struct vmbus_driver *)drv; */ int ret = 0;
int ret=0;
/* struct page* page; */
void *page_addr; void *page_addr;
struct hv_message *msg; struct hv_message *msg;
union hv_synic_event_flags *event; union hv_synic_event_flags *event;
/* page = SynICMessagePage[0]; */
/* page_addr = page_address(page); */
page_addr = gHvContext.synICMessagePage[0]; page_addr = gHvContext.synICMessagePage[0];
msg = (struct hv_message *)page_addr + VMBUS_MESSAGE_SINT; msg = (struct hv_message *)page_addr + VMBUS_MESSAGE_SINT;
DPRINT_ENTER(VMBUS); DPRINT_ENTER(VMBUS);
/* Check if there are actual msgs to be process */ /* Check if there are actual msgs to be process */
if (msg->Header.MessageType != HvMessageTypeNone) if (msg->Header.MessageType != HvMessageTypeNone) {
{ DPRINT_DBG(VMBUS, "received msg type %d size %d",
DPRINT_DBG(VMBUS, "received msg type %d size %d", msg->Header.MessageType, msg->Header.PayloadSize); msg->Header.MessageType,
msg->Header.PayloadSize);
ret |= 0x1; ret |= 0x1;
} }
...@@ -506,8 +312,7 @@ VmbusOnISR( ...@@ -506,8 +312,7 @@ VmbusOnISR(
event = (union hv_synic_event_flags *)page_addr + VMBUS_MESSAGE_SINT; event = (union hv_synic_event_flags *)page_addr + VMBUS_MESSAGE_SINT;
/* Since we are a child, we only need to check bit 0 */ /* Since we are a child, we only need to check bit 0 */
if (test_and_clear_bit(0, (unsigned long *) &event->Flags32[0])) if (test_and_clear_bit(0, (unsigned long *) &event->Flags32[0])) {
{
DPRINT_DBG(VMBUS, "received event %d", event->Flags32[0]); DPRINT_DBG(VMBUS, "received event %d", event->Flags32[0]);
ret |= 0x2; ret |= 0x2;
} }
...@@ -515,5 +320,3 @@ VmbusOnISR( ...@@ -515,5 +320,3 @@ VmbusOnISR(
DPRINT_EXIT(VMBUS); DPRINT_EXIT(VMBUS);
return ret; return ret;
} }
/* eof */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment