From: "K. Y. Srinivasan" <kys@microsoft.com>
To: kys@microsoft.com, gregkh@suse.de, linux-kernel@vger.kernel.org,
devel@linuxdriverproject.org, virtualization@lists.osdl.org
Cc: Haiyang Zhang <haiyangz@microsoft.com>,
Mike Sterling <mike.sterling@microsoft.com>,
Abhishek Kane <v-abkane@microsoft.com>
Subject: [PATCH 10/21] Staging: hv: Cleanup root device handling
Date: Thu, 10 Mar 2011 14:08:06 -0800 [thread overview]
Message-ID: <1299794886-1200-1-git-send-email-kys@microsoft.com> (raw)
In-Reply-To: <[PATCH 00/21] Staging: hv: Cleanup vmbus driver>
Now we can complete the cleanup of the root device
management. Use the preferred APIs for creating and
managing the root device. As part of this cleanup get rid
of the root device 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>
---
drivers/staging/hv/vmbus_drv.c | 126 ++++++----------------------------------
1 files changed, 18 insertions(+), 108 deletions(-)
diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index b473f46..8b9394a 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -19,6 +19,7 @@
* Hank Janssen <hjanssen@microsoft.com>
*/
#include <linux/init.h>
+#include <linux/err.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/irq.h>
@@ -40,6 +41,8 @@
#define VMBUS_IRQ 0x5
#define VMBUS_IRQ_VECTOR IRQ5_VECTOR
+static struct device *root_dev; /* Root device */
+
/* Main vmbus driver data structure */
struct vmbus_driver_context {
@@ -47,8 +50,6 @@ struct vmbus_driver_context {
struct tasklet_struct msg_dpc;
struct tasklet_struct event_dpc;
- /* The bus root device */
- struct hv_device device_ctx;
};
static int vmbus_match(struct device *device, struct device_driver *driver);
@@ -60,7 +61,6 @@ static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env);
static irqreturn_t vmbus_isr(int irq, void *dev_id);
static void vmbus_device_release(struct device *device);
-static void vmbus_bus_release(struct device *device);
static ssize_t vmbus_show_device_attr(struct device *dev,
struct device_attribute *dev_attr,
@@ -117,54 +117,6 @@ static struct vmbus_driver_context vmbus_drv = {
static const char *driver_name = "hyperv";
-/*
- * Windows vmbus does not defined this.
- * We defined this to be consistent with other devices
- */
-/* {c5295816-f63a-4d5f-8d1a-4daf999ca185} */
-static const struct hv_guid device_type = {
- .data = {
- 0x16, 0x58, 0x29, 0xc5, 0x3a, 0xf6, 0x5f, 0x4d,
- 0x8d, 0x1a, 0x4d, 0xaf, 0x99, 0x9c, 0xa1, 0x85
- }
-};
-
-/* {ac3760fc-9adf-40aa-9427-a70ed6de95c5} */
-static const struct hv_guid device_id = {
- .data = {
- 0xfc, 0x60, 0x37, 0xac, 0xdf, 0x9a, 0xaa, 0x40,
- 0x94, 0x27, 0xa7, 0x0e, 0xd6, 0xde, 0x95, 0xc5
- }
-};
-
-static struct hv_device *vmbus_device; /* vmbus root device */
-
-
-/*
- * vmbus_dev_add - Callback when the root bus device is added
- */
-static int vmbus_dev_add(struct hv_device *dev, void *info)
-{
- u32 *irqvector = info;
- int ret;
-
- vmbus_device = dev;
-
- memcpy(&vmbus_device->dev_type, &device_type, sizeof(struct hv_guid));
- memcpy(&vmbus_device->dev_instance, &device_id,
- sizeof(struct hv_guid));
-
- /* strcpy(dev->name, "vmbus"); */
- /* SynIC setup... */
- on_each_cpu(hv_synic_init, (void *)irqvector, 1);
-
- /* Connect to VMBus in the root partition */
- ret = vmbus_connect();
-
- /* VmbusSendEvent(device->localPortId+1); */
- return ret;
-}
-
struct onmessage_work_context {
struct work_struct work;
@@ -416,17 +368,14 @@ static ssize_t vmbus_show_device_attr(struct device *dev,
*
* Here, we
* - initialize the vmbus driver context
- * - setup various driver entry points
* - invoke the vmbus hv main init routine
* - get the irq resource
- * - invoke the vmbus to add the vmbus root device
* - setup the vmbus root device
* - retrieve the channel offers
*/
static int vmbus_bus_init(void)
{
struct vmbus_driver_context *vmbus_drv_ctx = &vmbus_drv;
- struct hv_device *dev_ctx = &vmbus_drv.device_ctx;
int ret;
unsigned int vector;
@@ -483,45 +432,34 @@ static int vmbus_bus_init(void)
DPRINT_INFO(VMBUS_DRV, "irq 0x%x vector 0x%x", vmbus_irq, vector);
- /* Add the root device */
- memset(dev_ctx, 0, sizeof(struct hv_device));
+ /* Register the root device */
+ root_dev = root_device_register(driver_name);
- ret = vmbus_dev_add(dev_ctx, &vector);
- if (ret != 0) {
+ if (IS_ERR(root_dev)) {
DPRINT_ERR(VMBUS_DRV,
- "ERROR - Unable to add vmbus root device");
+ "ERROR - Unable to register vmbus root device");
free_irq(vmbus_irq, NULL);
-
bus_unregister(&vmbus_drv_ctx->bus);
- ret = -1;
+ ret = PTR_ERR(root_dev);
goto cleanup;
}
- /* strcpy(dev_ctx->device.bus_id, dev_ctx->device_obj.name); */
- dev_set_name(&dev_ctx->device, "vmbus_0_0");
-
- /* No need to bind a driver to the root device. */
- dev_ctx->device.parent = NULL;
- /* NULL; vmbus_remove() does not get invoked */
- dev_ctx->device.bus = &vmbus_drv_ctx->bus;
- /* Setup the device dispatch table */
- dev_ctx->device.release = vmbus_bus_release;
-
- /* register the root device */
- ret = device_register(&dev_ctx->device);
+ /*
+ * Notify the hypervisor of our irq and
+ * connect to the host.
+ */
+ on_each_cpu(hv_synic_init, (void *)&vector, 1);
+ ret = vmbus_connect();
if (ret) {
- DPRINT_ERR(VMBUS_DRV,
- "ERROR - Unable to register vmbus root device");
-
+ root_device_unregister(root_dev);
free_irq(vmbus_irq, NULL);
bus_unregister(&vmbus_drv_ctx->bus);
-
- ret = -1;
goto cleanup;
}
+
vmbus_request_offers();
wait_for_completion(&hv_channel_ready);
@@ -538,7 +476,6 @@ static void vmbus_bus_exit(void)
{
struct vmbus_driver_context *vmbus_drv_ctx = &vmbus_drv;
- struct hv_device *dev_ctx = &vmbus_drv.device_ctx;
vmbus_release_unattached_channels();
vmbus_disconnect();
@@ -547,7 +484,7 @@ static void vmbus_bus_exit(void)
hv_cleanup();
/* Unregister the root bus device */
- device_unregister(&dev_ctx->device);
+ root_device_unregister(root_dev);
bus_unregister(&vmbus_drv_ctx->bus);
@@ -672,7 +609,7 @@ int vmbus_child_device_register(struct hv_device *child_device_obj)
/* The new device belongs to this bus */
child_device_obj->device.bus = &vmbus_drv.bus; /* device->dev.bus; */
- child_device_obj->device.parent = &vmbus_device->device;
+ child_device_obj->device.parent = root_dev;
child_device_obj->device.release = vmbus_device_release;
/*
@@ -873,14 +810,6 @@ static int vmbus_remove(struct device *child_device)
int ret;
struct hv_driver *drv;
- /* Special case root bus device */
- if (child_device->parent == NULL) {
- /*
- * No-op since it is statically defined and handle in
- * vmbus_bus_exit()
- */
- return 0;
- }
if (child_device->driver) {
drv = drv_to_hv_drv(child_device->driver);
@@ -909,14 +838,6 @@ static void vmbus_shutdown(struct device *child_device)
{
struct hv_driver *drv;
- /* Special case root bus device */
- if (child_device->parent == NULL) {
- /*
- * No-op since it is statically defined and handle in
- * vmbus_bus_exit()
- */
- return;
- }
/* The device may not be attached yet */
if (!child_device->driver)
@@ -931,17 +852,6 @@ static void vmbus_shutdown(struct device *child_device)
return;
}
-/*
- * vmbus_bus_release - Final callback release of the vmbus root device
- */
-static void vmbus_bus_release(struct device *device)
-{
- /* FIXME */
- /* Empty release functions are a bug, or a major sign
- * of a problem design, this MUST BE FIXED! */
- dev_err(device, "%s needs to be fixed!\n", __func__);
- WARN_ON(1);
-}
/*
* vmbus_device_release - Final callback release of the vmbus child device
--
1.5.5.6
next prev parent reply other threads:[~2011-03-10 22:08 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <[PATCH 00/21] Staging: hv: Cleanup vmbus driver>
2011-03-10 22:03 ` [PATCH 01/21] Staging: hv: Simplify root device management K. Y. Srinivasan
2011-03-10 22:04 ` [PATCH 02/21] Staging: hv: Change the signature for vmbus_cleanup() K. Y. Srinivasan
2011-03-10 22:04 ` [PATCH 03/21] Staging: hv: Get rid of the function vmbus_msg_dpc() K. Y. Srinivasan
2011-03-10 22:05 ` [PATCH 04/21] Staging: hv: Eliminate vmbus_event_dpc() K. Y. Srinivasan
2011-03-10 22:06 ` [PATCH 05/21] Staging: hv: Change the signature for vmbus_on_isr() K. Y. Srinivasan
2011-03-10 22:06 ` [PATCH 06/21] Staging: hv: Get rid of vmbus_dev_rm() function K. Y. Srinivasan
2011-03-10 22:06 ` [PATCH 07/21] Staging: hv: Get rid of vmbus_cleanup() function K. Y. Srinivasan
2011-03-10 22:07 ` [PATCH 08/21] Staging: hv: Change the signature for vmbus_child_device_register() K. Y. Srinivasan
2011-03-10 22:07 ` [PATCH 09/21] Staging: hv: Get rid of vmbus_child_dev_add() K. Y. Srinivasan
2011-03-10 22:08 ` K. Y. Srinivasan [this message]
2011-03-14 19:33 ` [PATCH 10/21] Staging: hv: Cleanup root device handling Greg KH
2011-03-14 19:54 ` KY Srinivasan
2011-03-14 19:58 ` Greg KH
2011-03-14 20:13 ` KY Srinivasan
2011-03-10 22:08 ` [PATCH 11/21] Staging: hv: Make vmbus driver a platform pci driver K. Y. Srinivasan
2011-03-10 22:20 ` Greg KH
2011-03-10 22:28 ` KY Srinivasan
2011-03-10 22:32 ` Greg KH
2011-03-10 22:36 ` KY Srinivasan
2011-03-12 23:23 ` KY Srinivasan
2011-03-14 3:24 ` Greg KH
2011-03-14 12:43 ` KY Srinivasan
2011-03-14 19:34 ` Greg KH
2011-03-10 22:08 ` [PATCH 12/21] Staging: hv: Cleanup irq management K. Y. Srinivasan
2011-03-10 22:46 ` Thomas Gleixner
2011-03-10 22:54 ` Hank Janssen
2011-03-11 2:09 ` KY Srinivasan
2011-03-10 22:12 ` [PATCH 13/21] [PATCH 13/21] Staging: hv: Rename vmbus_driver_context structure K. Y. Srinivasan
2011-03-10 22:49 ` Thomas Gleixner
2011-03-11 3:17 ` KY Srinivasan
2011-03-10 22:12 ` [PATCH 14/21] Get rid of the forward declaration for vmbus_uevent K. Y. Srinivasan
2011-03-10 22:13 ` [PATCH 15/21] Staging: hv: Get rid of the forward declaration for vmbus_match K. Y. Srinivasan
2011-03-10 22:14 ` [PATCH 16/21] Staging: hv: Get rid of the forward declaration for vmbus_probe K. Y. Srinivasan
2011-03-10 22:14 ` [PATCH 17/21] Staging: hv: Get rid of the forward declaration for vmbus_remove K. Y. Srinivasan
2011-03-10 22:15 ` [PATCH 18/21] Staging: hv: Get rid of the forward declaration for vmbus_shutdown K. Y. Srinivasan
2011-03-10 22:15 ` [PATCH 19/21] Staging: hv: Get rid of the forward declaration for vmbus_device_release K. Y. Srinivasan
2011-03-10 22:15 ` [PATCH 20/21] Staging: hv: Get rid of the forward declaration for vmbus_isr K. Y. Srinivasan
2011-03-10 22:16 ` [PATCH 21/21] Staging: hv: Get rid of the forward declaration for vmbus_show_device_attr K. Y. Srinivasan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1299794886-1200-1-git-send-email-kys@microsoft.com \
--to=kys@microsoft.com \
--cc=devel@linuxdriverproject.org \
--cc=gregkh@suse.de \
--cc=haiyangz@microsoft.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mike.sterling@microsoft.com \
--cc=v-abkane@microsoft.com \
--cc=virtualization@lists.osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox