/* Per device structure */
struct block_device_context {
/* point back to our device context */
- struct vm_device *device_ctx;
+ struct hv_device *device_ctx;
struct kmem_cache *request_pool;
spinlock_t lock;
struct gendisk *gd;
drv_to_hv_drv(device->driver);
struct storvsc_driver_object *storvsc_drv_obj =
drv->priv;
- struct vm_device *device_ctx = device_to_vm_device(device);
- struct hv_device *device_obj = &device_ctx->device_obj;
+ struct hv_device *device_obj = device_to_hv_device(device);
struct block_device_context *blkdev = NULL;
struct storvsc_device_info device_info;
/* ASSERT(sizeof(struct blkvsc_request_group) <= */
/* sizeof(struct blkvsc_request)); */
- blkdev->request_pool = kmem_cache_create(dev_name(&device_ctx->device),
+ blkdev->request_pool = kmem_cache_create(dev_name(&device_obj->device),
sizeof(struct blkvsc_request) +
storvsc_drv_obj->request_ext_size, 0,
SLAB_HWCACHE_ALIGN, NULL);
goto Cleanup;
}
- blkdev->device_ctx = device_ctx;
+ blkdev->device_ctx = device_obj;
/* this identified the device 0 or 1 */
blkdev->target = device_info.target_id;
/* this identified the ide ctrl 0 or 1 */
drv_to_hv_drv(device->driver);
struct storvsc_driver_object *storvsc_drv_obj =
drv->priv;
- struct vm_device *device_ctx = device_to_vm_device(device);
- struct hv_device *device_obj = &device_ctx->device_obj;
+ struct hv_device *device_obj = device_to_hv_device(device);
struct block_device_context *blkdev = dev_get_drvdata(device);
unsigned long flags;
int ret;
void (*request_completion)(struct hv_storvsc_request *))
{
struct block_device_context *blkdev = blkvsc_req->dev;
- struct vm_device *device_ctx = blkdev->device_ctx;
+ struct hv_device *device_ctx = blkdev->device_ctx;
struct hv_driver *drv =
drv_to_hv_drv(device_ctx->device.driver);
struct storvsc_driver_object *storvsc_drv_obj =
storvsc_req->sense_buffer = blkvsc_req->sense_buffer;
storvsc_req->sense_buffer_size = SCSI_SENSE_BUFFERSIZE;
- ret = storvsc_drv_obj->on_io_request(&blkdev->device_ctx->device_obj,
+ ret = storvsc_drv_obj->on_io_request(blkdev->device_ctx,
&blkvsc_req->request);
if (ret == 0)
blkdev->num_outstanding_reqs++;
* Data types
*/
struct input_device_context {
- struct vm_device *device_ctx;
+ struct hv_device *device_ctx;
struct hid_device *hid_device;
struct hv_input_dev_info device_info;
int connected;
static void deviceinfo_callback(struct hv_device *dev, struct hv_input_dev_info *info)
{
- struct vm_device *device_ctx = to_vm_device(dev);
struct input_device_context *input_device_ctx =
- dev_get_drvdata(&device_ctx->device);
+ dev_get_drvdata(&dev->device);
memcpy(&input_device_ctx->device_info, info,
sizeof(struct hv_input_dev_info));
{
int ret = 0;
- struct vm_device *device_ctx = to_vm_device(dev);
struct input_device_context *input_dev_ctx =
- dev_get_drvdata(&device_ctx->device);
+ dev_get_drvdata(&dev->device);
ret = hid_input_report(input_dev_ctx->hid_device,
HID_INPUT_REPORT, packet, len, 1);
drv_to_hv_drv(device->driver);
struct mousevsc_drv_obj *mousevsc_drv_obj = drv->priv;
- struct vm_device *device_ctx = device_to_vm_device(device);
- struct hv_device *device_obj = &device_ctx->device_obj;
+ struct hv_device *device_obj = device_to_hv_device(device);
struct input_device_context *input_dev_ctx;
input_dev_ctx = kmalloc(sizeof(struct input_device_context),
drv_to_hv_drv(device->driver);
struct mousevsc_drv_obj *mousevsc_drv_obj = drv->priv;
- struct vm_device *device_ctx = device_to_vm_device(device);
- struct hv_device *device_obj = &device_ctx->device_obj;
+ struct hv_device *device_obj = device_to_hv_device(device);
struct input_device_context *input_dev_ctx;
input_dev_ctx = kmalloc(sizeof(struct input_device_context),
static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len)
{
- struct vm_device *device_ctx = to_vm_device(dev);
struct input_device_context *input_device_ctx =
- dev_get_drvdata(&device_ctx->device);
+ dev_get_drvdata(&dev->device);
struct hid_device *hid_dev;
/* hid_debug = -1; */
hid_dev->vendor = input_device_ctx->device_info.vendor;
hid_dev->product = input_device_ctx->device_info.product;
hid_dev->version = input_device_ctx->device_info.version;
- hid_dev->dev = device_ctx->device;
+ hid_dev->dev = dev->device;
sprintf(hid_dev->name, "%s",
input_device_ctx->device_info.name);
struct net_device_context {
/* point back to our device context */
- struct vm_device *device_ctx;
+ struct hv_device *device_ctx;
unsigned long avail;
};
static int netvsc_open(struct net_device *net)
{
struct net_device_context *net_device_ctx = netdev_priv(net);
- struct hv_device *device_obj = &net_device_ctx->device_ctx->device_obj;
+ struct hv_device *device_obj = net_device_ctx->device_ctx;
int ret = 0;
if (netif_carrier_ok(net)) {
static int netvsc_close(struct net_device *net)
{
struct net_device_context *net_device_ctx = netdev_priv(net);
- struct hv_device *device_obj = &net_device_ctx->device_ctx->device_obj;
+ struct hv_device *device_obj = net_device_ctx->device_ctx;
int ret;
netif_stop_queue(net);
packet->completion.send.send_completion_ctx = packet;
packet->completion.send.send_completion_tid = (unsigned long)skb;
- ret = net_drv_obj->send(&net_device_ctx->device_ctx->device_obj,
+ ret = net_drv_obj->send(net_device_ctx->device_ctx,
packet);
if (ret == 0) {
net->stats.tx_bytes += skb->len;
static void netvsc_linkstatus_callback(struct hv_device *device_obj,
unsigned int status)
{
- struct vm_device *device_ctx = to_vm_device(device_obj);
- struct net_device *net = dev_get_drvdata(&device_ctx->device);
+ struct net_device *net = dev_get_drvdata(&device_obj->device);
if (!net) {
DPRINT_ERR(NETVSC_DRV, "got link status but net device "
static int netvsc_recv_callback(struct hv_device *device_obj,
struct hv_netvsc_packet *packet)
{
- struct vm_device *device_ctx = to_vm_device(device_obj);
- struct net_device *net = dev_get_drvdata(&device_ctx->device);
+ struct net_device *net = dev_get_drvdata(&device_obj->device);
struct sk_buff *skb;
void *data;
int i;
struct hv_driver *drv =
drv_to_hv_drv(device->driver);
struct netvsc_driver *net_drv_obj = drv->priv;
- struct vm_device *device_ctx = device_to_vm_device(device);
- struct hv_device *device_obj = &device_ctx->device_obj;
+ struct hv_device *device_obj = device_to_hv_device(device);
struct net_device *net = NULL;
struct net_device_context *net_device_ctx;
struct netvsc_device_info device_info;
netif_carrier_off(net);
net_device_ctx = netdev_priv(net);
- net_device_ctx->device_ctx = device_ctx;
+ net_device_ctx->device_ctx = device_obj;
net_device_ctx->avail = ring_size;
dev_set_drvdata(device, net);
struct hv_driver *drv =
drv_to_hv_drv(device->driver);
struct netvsc_driver *net_drv_obj = drv->priv;
- struct vm_device *device_ctx = device_to_vm_device(device);
- struct net_device *net = dev_get_drvdata(&device_ctx->device);
- struct hv_device *device_obj = &device_ctx->device_obj;
+ struct hv_device *device_obj = device_to_hv_device(device);
+ struct net_device *net = dev_get_drvdata(&device_obj->device);
int ret;
if (net == NULL) {
/* must be 1st field
* FIXME this is a bug */
/* point back to our device context */
- struct vm_device *device_ctx;
+ struct hv_device *device_ctx;
struct kmem_cache *request_pool;
unsigned int port;
unsigned char path;
struct hv_driver *drv =
drv_to_hv_drv(device->driver);
struct storvsc_driver_object *storvsc_drv_obj = drv->priv;
- struct vm_device *device_ctx = device_to_vm_device(device);
- struct hv_device *device_obj = &device_ctx->device_obj;
+ struct hv_device *device_obj = device_to_hv_device(device);
struct Scsi_Host *host;
struct host_device_context *host_device_ctx;
struct storvsc_device_info device_info;
memset(host_device_ctx, 0, sizeof(struct host_device_context));
host_device_ctx->port = host->host_no;
- host_device_ctx->device_ctx = device_ctx;
+ host_device_ctx->device_ctx = device_obj;
host_device_ctx->request_pool =
- kmem_cache_create(dev_name(&device_ctx->device),
+ kmem_cache_create(dev_name(&device_obj->device),
sizeof(struct storvsc_cmd_request) +
storvsc_drv_obj->request_ext_size, 0,
SLAB_HWCACHE_ALIGN, NULL);
struct hv_driver *drv =
drv_to_hv_drv(device->driver);
struct storvsc_driver_object *storvsc_drv_obj = drv->priv;
- struct vm_device *device_ctx = device_to_vm_device(device);
- struct hv_device *device_obj = &device_ctx->device_obj;
+ struct hv_device *device_obj = device_to_hv_device(device);
struct Scsi_Host *host = dev_get_drvdata(device);
struct host_device_context *host_device_ctx =
(struct host_device_context *)host->hostdata;
int ret;
struct host_device_context *host_device_ctx =
(struct host_device_context *)scmnd->device->host->hostdata;
- struct vm_device *device_ctx = host_device_ctx->device_ctx;
+ struct hv_device *device_ctx = host_device_ctx->device_ctx;
struct hv_driver *drv =
drv_to_hv_drv(device_ctx->device.driver);
struct storvsc_driver_object *storvsc_drv_obj = drv->priv;
retry_request:
/* Invokes the vsc to start an IO */
- ret = storvsc_drv_obj->on_io_request(&device_ctx->device_obj,
+ ret = storvsc_drv_obj->on_io_request(device_ctx,
&cmd_request->request);
if (ret == -1) {
/* no more space */
int ret;
struct host_device_context *host_device_ctx =
(struct host_device_context *)scmnd->device->host->hostdata;
- struct vm_device *device_ctx = host_device_ctx->device_ctx;
+ struct hv_device *device_ctx = host_device_ctx->device_ctx;
DPRINT_INFO(STORVSC_DRV, "sdev (%p) dev obj (%p) - host resetting...",
- scmnd->device, &device_ctx->device_obj);
+ scmnd->device, device_ctx);
/* Invokes the vsc to reset the host/bus */
- ret = stor_vsc_on_host_reset(&device_ctx->device_obj);
+ ret = stor_vsc_on_host_reset(device_ctx);
if (ret != 0)
return ret;
DPRINT_INFO(STORVSC_DRV, "sdev (%p) dev obj (%p) - host reseted",
- scmnd->device, &device_ctx->device_obj);
+ scmnd->device, device_ctx);
return ret;
}
#include "vmbus_api.h"
-struct vm_device {
- struct hv_device device_obj;
- struct device device;
-};
-static inline struct vm_device *to_vm_device(struct hv_device *d)
-{
- return container_of(d, struct vm_device, device_obj);
-}
-static inline struct vm_device *device_to_vm_device(struct device *d)
+static inline struct hv_device *device_to_hv_device(struct device *d)
{
- return container_of(d, struct vm_device, device);
+ return container_of(d, struct hv_device, device);
}
static inline struct hv_driver *drv_to_hv_drv(struct device_driver *d)
/* the device instance id of this device */
struct hv_guid dev_instance;
+ struct device device;
+
struct vmbus_channel *channel;
/* Device extension; */
struct tasklet_struct event_dpc;
/* The bus root device */
- struct vm_device device_ctx;
+ struct hv_device device_ctx;
};
static int vmbus_match(struct device *device, struct device_driver *driver);
struct device_attribute *dev_attr,
char *buf)
{
- struct vm_device *device_ctx = device_to_vm_device(dev);
+ struct hv_device *device_ctx = device_to_hv_device(dev);
struct hv_device_info device_info;
memset(&device_info, 0, sizeof(struct hv_device_info));
- get_channel_info(&device_ctx->device_obj, &device_info);
+ get_channel_info(device_ctx, &device_info);
if (!strcmp(dev_attr->attr.name, "class_id")) {
return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-"
{
struct vmbus_driver_context *vmbus_drv_ctx = &vmbus_drv;
struct hv_driver *driver = &vmbus_drv.drv_obj;
- struct vm_device *dev_ctx = &vmbus_drv.device_ctx;
+ struct hv_device *dev_ctx = &vmbus_drv.device_ctx;
int ret;
unsigned int vector;
DPRINT_INFO(VMBUS_DRV, "irq 0x%x vector 0x%x", vmbus_irq, vector);
/* Call to bus driver to add the root device */
- memset(dev_ctx, 0, sizeof(struct vm_device));
+ memset(dev_ctx, 0, sizeof(struct hv_device));
- ret = driver->dev_add(&dev_ctx->device_obj, &vector);
+ ret = driver->dev_add(dev_ctx, &vector);
if (ret != 0) {
DPRINT_ERR(VMBUS_DRV,
"ERROR - Unable to add vmbus root device");
struct hv_driver *driver = &vmbus_drv.drv_obj;
struct vmbus_driver_context *vmbus_drv_ctx = &vmbus_drv;
- struct vm_device *dev_ctx = &vmbus_drv.device_ctx;
+ struct hv_device *dev_ctx = &vmbus_drv.device_ctx;
/* Remove the root device */
if (driver->dev_rm)
- driver->dev_rm(&dev_ctx->device_obj);
+ driver->dev_rm(dev_ctx);
if (driver->cleanup)
driver->cleanup(driver);
struct hv_guid *instance,
struct vmbus_channel *channel)
{
- struct vm_device *child_device_ctx;
struct hv_device *child_device_obj;
/* Allocate the new child device */
- child_device_ctx = kzalloc(sizeof(struct vm_device), GFP_KERNEL);
- if (!child_device_ctx) {
+ child_device_obj = kzalloc(sizeof(struct hv_device), GFP_KERNEL);
+ if (!child_device_obj) {
DPRINT_ERR(VMBUS_DRV,
"unable to allocate device_context for child device");
return NULL;
"%02x%02x%02x%02x%02x%02x%02x%02x},"
"id {%02x%02x%02x%02x-%02x%02x-%02x%02x-"
"%02x%02x%02x%02x%02x%02x%02x%02x}",
- &child_device_ctx->device,
+ &child_device_obj->device,
type->data[3], type->data[2], type->data[1], type->data[0],
type->data[5], type->data[4], type->data[7], type->data[6],
type->data[8], type->data[9], type->data[10], type->data[11],
instance->data[12], instance->data[13],
instance->data[14], instance->data[15]);
- child_device_obj = &child_device_ctx->device_obj;
child_device_obj->channel = channel;
memcpy(&child_device_obj->dev_type, type, sizeof(struct hv_guid));
memcpy(&child_device_obj->dev_instance, instance,
struct hv_device *child_device_obj)
{
int ret = 0;
- struct vm_device *root_device_ctx =
- to_vm_device(root_device_obj);
- struct vm_device *child_device_ctx =
- to_vm_device(child_device_obj);
+
static atomic_t device_num = ATOMIC_INIT(0);
DPRINT_DBG(VMBUS_DRV, "child device (%p) registering",
- child_device_ctx);
+ child_device_obj);
/* Set the device name. Otherwise, device_register() will fail. */
- dev_set_name(&child_device_ctx->device, "vmbus_0_%d",
+ dev_set_name(&child_device_obj->device, "vmbus_0_%d",
atomic_inc_return(&device_num));
/* The new device belongs to this bus */
- child_device_ctx->device.bus = &vmbus_drv.bus; /* device->dev.bus; */
- child_device_ctx->device.parent = &root_device_ctx->device;
- child_device_ctx->device.release = vmbus_device_release;
+ child_device_obj->device.bus = &vmbus_drv.bus; /* device->dev.bus; */
+ child_device_obj->device.parent = &root_device_obj->device;
+ child_device_obj->device.release = vmbus_device_release;
/*
* Register with the LDM. This will kick off the driver/device
* binding...which will eventually call vmbus_match() and vmbus_probe()
*/
- ret = device_register(&child_device_ctx->device);
+ ret = device_register(&child_device_obj->device);
/* vmbus_probe() error does not get propergate to device_register(). */
- ret = child_device_ctx->device_obj.probe_error;
+ ret = child_device_obj->probe_error;
if (ret)
DPRINT_ERR(VMBUS_DRV, "unable to register child device (%p)",
- &child_device_ctx->device);
+ &child_device_obj->device);
else
DPRINT_INFO(VMBUS_DRV, "child device (%p) registered",
- &child_device_ctx->device);
+ &child_device_obj->device);
return ret;
}
*/
void vmbus_child_device_unregister(struct hv_device *device_obj)
{
- struct vm_device *device_ctx = to_vm_device(device_obj);
DPRINT_INFO(VMBUS_DRV, "unregistering child device (%p)",
- &device_ctx->device);
+ &device_obj->device);
/*
* Kick off the process of unregistering the device.
* This will call vmbus_remove() and eventually vmbus_device_release()
*/
- device_unregister(&device_ctx->device);
+ device_unregister(&device_obj->device);
DPRINT_INFO(VMBUS_DRV, "child device (%p) unregistered",
- &device_ctx->device);
+ &device_obj->device);
}
/*
*/
static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env)
{
- struct vm_device *device_ctx = device_to_vm_device(device);
- struct hv_device *dev = &device_ctx->device_obj;
+ struct hv_device *dev = device_to_hv_device(device);
int ret;
DPRINT_INFO(VMBUS_DRV, "generating uevent - VMBUS_DEVICE_CLASS_GUID={"
{
int match = 0;
struct hv_driver *drv = drv_to_hv_drv(driver);
- struct vm_device *device_ctx = device_to_vm_device(device);
+ struct hv_device *device_ctx = device_to_hv_device(device);
/* We found our driver ? */
- if (memcmp(&device_ctx->device_obj.dev_type, &drv->dev_type,
+ if (memcmp(&device_ctx->dev_type, &drv->dev_type,
sizeof(struct hv_guid)) == 0) {
- device_ctx->device_obj.drv = drv->priv;
+ device_ctx->drv = drv->priv;
DPRINT_INFO(VMBUS_DRV,
"device object (%p) set to driver object (%p)",
- &device_ctx->device_obj,
- device_ctx->device_obj.drv);
+ &device_ctx,
+ device_ctx->drv);
match = 1;
}
*/
static void vmbus_probe_failed_cb(struct work_struct *context)
{
- struct vm_device *device_ctx = (struct vm_device *)context;
+ struct hv_device *device_ctx = (struct hv_device *)context;
/*
* Kick off the process of unregistering the device.
int ret = 0;
struct hv_driver *drv =
drv_to_hv_drv(child_device->driver);
- struct vm_device *device_ctx =
- device_to_vm_device(child_device);
- struct hv_device *dev = &device_ctx->device_obj;
+ struct hv_device *dev = device_to_hv_device(child_device);
/* Let the specific open-source driver handles the probe if it can */
if (drv->driver.probe) {
- ret = device_ctx->device_obj.probe_error =
+ ret = dev->probe_error =
drv->driver.probe(child_device);
if (ret != 0) {
DPRINT_ERR(VMBUS_DRV, "probe() failed for device %s "
*/
static void vmbus_device_release(struct device *device)
{
- struct vm_device *device_ctx = device_to_vm_device(device);
+ struct hv_device *device_ctx = device_to_hv_device(device);
kfree(device_ctx);