Commit 6bad88da authored by K. Y. Srinivasan's avatar K. Y. Srinivasan Committed by Greg Kroah-Hartman

Staging: hv: Remove the vm_device structure

Consolidate all device related state in struct hv_device by
moving the device field from struct vm_device to
struct hv_device. As part of this, also get rid of struct
vm_device since the consolidation is complete.
Signed-off-by: default avatarK. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: default avatarAbhishek Kane <v-abkane@microsoft.com>
Signed-off-by: default avatarHaiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: default avatarHank Janssen <hjanssen@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent d5889771
...@@ -95,7 +95,7 @@ struct blkvsc_request { ...@@ -95,7 +95,7 @@ struct blkvsc_request {
/* Per device structure */ /* Per device structure */
struct block_device_context { struct block_device_context {
/* point back to our device context */ /* point back to our device context */
struct vm_device *device_ctx; struct hv_device *device_ctx;
struct kmem_cache *request_pool; struct kmem_cache *request_pool;
spinlock_t lock; spinlock_t lock;
struct gendisk *gd; struct gendisk *gd;
...@@ -240,8 +240,7 @@ static int blkvsc_probe(struct device *device) ...@@ -240,8 +240,7 @@ static int blkvsc_probe(struct device *device)
drv_to_hv_drv(device->driver); drv_to_hv_drv(device->driver);
struct storvsc_driver_object *storvsc_drv_obj = struct storvsc_driver_object *storvsc_drv_obj =
drv->priv; drv->priv;
struct vm_device *device_ctx = device_to_vm_device(device); struct hv_device *device_obj = device_to_hv_device(device);
struct hv_device *device_obj = &device_ctx->device_obj;
struct block_device_context *blkdev = NULL; struct block_device_context *blkdev = NULL;
struct storvsc_device_info device_info; struct storvsc_device_info device_info;
...@@ -273,7 +272,7 @@ static int blkvsc_probe(struct device *device) ...@@ -273,7 +272,7 @@ static int blkvsc_probe(struct device *device)
/* ASSERT(sizeof(struct blkvsc_request_group) <= */ /* ASSERT(sizeof(struct blkvsc_request_group) <= */
/* sizeof(struct blkvsc_request)); */ /* 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) + sizeof(struct blkvsc_request) +
storvsc_drv_obj->request_ext_size, 0, storvsc_drv_obj->request_ext_size, 0,
SLAB_HWCACHE_ALIGN, NULL); SLAB_HWCACHE_ALIGN, NULL);
...@@ -290,7 +289,7 @@ static int blkvsc_probe(struct device *device) ...@@ -290,7 +289,7 @@ static int blkvsc_probe(struct device *device)
goto Cleanup; goto Cleanup;
} }
blkdev->device_ctx = device_ctx; blkdev->device_ctx = device_obj;
/* this identified the device 0 or 1 */ /* this identified the device 0 or 1 */
blkdev->target = device_info.target_id; blkdev->target = device_info.target_id;
/* this identified the ide ctrl 0 or 1 */ /* this identified the ide ctrl 0 or 1 */
...@@ -723,8 +722,7 @@ static int blkvsc_remove(struct device *device) ...@@ -723,8 +722,7 @@ static int blkvsc_remove(struct device *device)
drv_to_hv_drv(device->driver); drv_to_hv_drv(device->driver);
struct storvsc_driver_object *storvsc_drv_obj = struct storvsc_driver_object *storvsc_drv_obj =
drv->priv; drv->priv;
struct vm_device *device_ctx = device_to_vm_device(device); struct hv_device *device_obj = device_to_hv_device(device);
struct hv_device *device_obj = &device_ctx->device_obj;
struct block_device_context *blkdev = dev_get_drvdata(device); struct block_device_context *blkdev = dev_get_drvdata(device);
unsigned long flags; unsigned long flags;
int ret; int ret;
...@@ -839,7 +837,7 @@ static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req, ...@@ -839,7 +837,7 @@ static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req,
void (*request_completion)(struct hv_storvsc_request *)) void (*request_completion)(struct hv_storvsc_request *))
{ {
struct block_device_context *blkdev = blkvsc_req->dev; 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 = struct hv_driver *drv =
drv_to_hv_drv(device_ctx->device.driver); drv_to_hv_drv(device_ctx->device.driver);
struct storvsc_driver_object *storvsc_drv_obj = struct storvsc_driver_object *storvsc_drv_obj =
...@@ -884,7 +882,7 @@ static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req, ...@@ -884,7 +882,7 @@ static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req,
storvsc_req->sense_buffer = blkvsc_req->sense_buffer; storvsc_req->sense_buffer = blkvsc_req->sense_buffer;
storvsc_req->sense_buffer_size = SCSI_SENSE_BUFFERSIZE; 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); &blkvsc_req->request);
if (ret == 0) if (ret == 0)
blkdev->num_outstanding_reqs++; blkdev->num_outstanding_reqs++;
......
...@@ -771,7 +771,7 @@ static void MousevscOnCleanup(struct hv_driver *drv) ...@@ -771,7 +771,7 @@ static void MousevscOnCleanup(struct hv_driver *drv)
* Data types * Data types
*/ */
struct input_device_context { struct input_device_context {
struct vm_device *device_ctx; struct hv_device *device_ctx;
struct hid_device *hid_device; struct hid_device *hid_device;
struct hv_input_dev_info device_info; struct hv_input_dev_info device_info;
int connected; int connected;
...@@ -782,9 +782,8 @@ static struct mousevsc_drv_obj g_mousevsc_drv; ...@@ -782,9 +782,8 @@ static struct mousevsc_drv_obj g_mousevsc_drv;
static void deviceinfo_callback(struct hv_device *dev, struct hv_input_dev_info *info) 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 = 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, memcpy(&input_device_ctx->device_info, info,
sizeof(struct hv_input_dev_info)); sizeof(struct hv_input_dev_info));
...@@ -796,9 +795,8 @@ static void inputreport_callback(struct hv_device *dev, void *packet, u32 len) ...@@ -796,9 +795,8 @@ static void inputreport_callback(struct hv_device *dev, void *packet, u32 len)
{ {
int ret = 0; int ret = 0;
struct vm_device *device_ctx = to_vm_device(dev);
struct input_device_context *input_dev_ctx = 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, ret = hid_input_report(input_dev_ctx->hid_device,
HID_INPUT_REPORT, packet, len, 1); HID_INPUT_REPORT, packet, len, 1);
...@@ -823,8 +821,7 @@ static int mousevsc_probe(struct device *device) ...@@ -823,8 +821,7 @@ static int mousevsc_probe(struct device *device)
drv_to_hv_drv(device->driver); drv_to_hv_drv(device->driver);
struct mousevsc_drv_obj *mousevsc_drv_obj = drv->priv; 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_to_hv_device(device);
struct hv_device *device_obj = &device_ctx->device_obj;
struct input_device_context *input_dev_ctx; struct input_device_context *input_dev_ctx;
input_dev_ctx = kmalloc(sizeof(struct input_device_context), input_dev_ctx = kmalloc(sizeof(struct input_device_context),
...@@ -852,8 +849,7 @@ static int mousevsc_remove(struct device *device) ...@@ -852,8 +849,7 @@ static int mousevsc_remove(struct device *device)
drv_to_hv_drv(device->driver); drv_to_hv_drv(device->driver);
struct mousevsc_drv_obj *mousevsc_drv_obj = drv->priv; 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_to_hv_device(device);
struct hv_device *device_obj = &device_ctx->device_obj;
struct input_device_context *input_dev_ctx; struct input_device_context *input_dev_ctx;
input_dev_ctx = kmalloc(sizeof(struct input_device_context), input_dev_ctx = kmalloc(sizeof(struct input_device_context),
...@@ -887,9 +883,8 @@ static int mousevsc_remove(struct device *device) ...@@ -887,9 +883,8 @@ static int mousevsc_remove(struct device *device)
static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len) 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 = struct input_device_context *input_device_ctx =
dev_get_drvdata(&device_ctx->device); dev_get_drvdata(&dev->device);
struct hid_device *hid_dev; struct hid_device *hid_dev;
/* hid_debug = -1; */ /* hid_debug = -1; */
...@@ -910,7 +905,7 @@ static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len) ...@@ -910,7 +905,7 @@ static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len)
hid_dev->vendor = input_device_ctx->device_info.vendor; hid_dev->vendor = input_device_ctx->device_info.vendor;
hid_dev->product = input_device_ctx->device_info.product; hid_dev->product = input_device_ctx->device_info.product;
hid_dev->version = input_device_ctx->device_info.version; 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", sprintf(hid_dev->name, "%s",
input_device_ctx->device_info.name); input_device_ctx->device_info.name);
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
struct net_device_context { struct net_device_context {
/* point back to our device context */ /* point back to our device context */
struct vm_device *device_ctx; struct hv_device *device_ctx;
unsigned long avail; unsigned long avail;
}; };
...@@ -70,7 +70,7 @@ static void netvsc_set_multicast_list(struct net_device *net) ...@@ -70,7 +70,7 @@ static void netvsc_set_multicast_list(struct net_device *net)
static int netvsc_open(struct net_device *net) static int netvsc_open(struct net_device *net)
{ {
struct net_device_context *net_device_ctx = netdev_priv(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; int ret = 0;
if (netif_carrier_ok(net)) { if (netif_carrier_ok(net)) {
...@@ -93,7 +93,7 @@ static int netvsc_open(struct net_device *net) ...@@ -93,7 +93,7 @@ static int netvsc_open(struct net_device *net)
static int netvsc_close(struct net_device *net) static int netvsc_close(struct net_device *net)
{ {
struct net_device_context *net_device_ctx = netdev_priv(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; int ret;
netif_stop_queue(net); netif_stop_queue(net);
...@@ -190,7 +190,7 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net) ...@@ -190,7 +190,7 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
packet->completion.send.send_completion_ctx = packet; packet->completion.send.send_completion_ctx = packet;
packet->completion.send.send_completion_tid = (unsigned long)skb; 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); packet);
if (ret == 0) { if (ret == 0) {
net->stats.tx_bytes += skb->len; net->stats.tx_bytes += skb->len;
...@@ -218,8 +218,7 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net) ...@@ -218,8 +218,7 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
static void netvsc_linkstatus_callback(struct hv_device *device_obj, static void netvsc_linkstatus_callback(struct hv_device *device_obj,
unsigned int status) unsigned int status)
{ {
struct vm_device *device_ctx = to_vm_device(device_obj); struct net_device *net = dev_get_drvdata(&device_obj->device);
struct net_device *net = dev_get_drvdata(&device_ctx->device);
if (!net) { if (!net) {
DPRINT_ERR(NETVSC_DRV, "got link status but net device " DPRINT_ERR(NETVSC_DRV, "got link status but net device "
...@@ -244,8 +243,7 @@ static void netvsc_linkstatus_callback(struct hv_device *device_obj, ...@@ -244,8 +243,7 @@ static void netvsc_linkstatus_callback(struct hv_device *device_obj,
static int netvsc_recv_callback(struct hv_device *device_obj, static int netvsc_recv_callback(struct hv_device *device_obj,
struct hv_netvsc_packet *packet) struct hv_netvsc_packet *packet)
{ {
struct vm_device *device_ctx = to_vm_device(device_obj); struct net_device *net = dev_get_drvdata(&device_obj->device);
struct net_device *net = dev_get_drvdata(&device_ctx->device);
struct sk_buff *skb; struct sk_buff *skb;
void *data; void *data;
int i; int i;
...@@ -335,8 +333,7 @@ static int netvsc_probe(struct device *device) ...@@ -335,8 +333,7 @@ static int netvsc_probe(struct device *device)
struct hv_driver *drv = struct hv_driver *drv =
drv_to_hv_drv(device->driver); drv_to_hv_drv(device->driver);
struct netvsc_driver *net_drv_obj = drv->priv; struct netvsc_driver *net_drv_obj = drv->priv;
struct vm_device *device_ctx = device_to_vm_device(device); struct hv_device *device_obj = device_to_hv_device(device);
struct hv_device *device_obj = &device_ctx->device_obj;
struct net_device *net = NULL; struct net_device *net = NULL;
struct net_device_context *net_device_ctx; struct net_device_context *net_device_ctx;
struct netvsc_device_info device_info; struct netvsc_device_info device_info;
...@@ -353,7 +350,7 @@ static int netvsc_probe(struct device *device) ...@@ -353,7 +350,7 @@ static int netvsc_probe(struct device *device)
netif_carrier_off(net); netif_carrier_off(net);
net_device_ctx = netdev_priv(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; net_device_ctx->avail = ring_size;
dev_set_drvdata(device, net); dev_set_drvdata(device, net);
...@@ -405,9 +402,8 @@ static int netvsc_remove(struct device *device) ...@@ -405,9 +402,8 @@ static int netvsc_remove(struct device *device)
struct hv_driver *drv = struct hv_driver *drv =
drv_to_hv_drv(device->driver); drv_to_hv_drv(device->driver);
struct netvsc_driver *net_drv_obj = drv->priv; struct netvsc_driver *net_drv_obj = drv->priv;
struct vm_device *device_ctx = device_to_vm_device(device); struct hv_device *device_obj = device_to_hv_device(device);
struct net_device *net = dev_get_drvdata(&device_ctx->device); struct net_device *net = dev_get_drvdata(&device_obj->device);
struct hv_device *device_obj = &device_ctx->device_obj;
int ret; int ret;
if (net == NULL) { if (net == NULL) {
......
...@@ -42,7 +42,7 @@ struct host_device_context { ...@@ -42,7 +42,7 @@ struct host_device_context {
/* must be 1st field /* must be 1st field
* FIXME this is a bug */ * FIXME this is a bug */
/* point back to our device context */ /* point back to our device context */
struct vm_device *device_ctx; struct hv_device *device_ctx;
struct kmem_cache *request_pool; struct kmem_cache *request_pool;
unsigned int port; unsigned int port;
unsigned char path; unsigned char path;
...@@ -216,8 +216,7 @@ static int storvsc_probe(struct device *device) ...@@ -216,8 +216,7 @@ static int storvsc_probe(struct device *device)
struct hv_driver *drv = struct hv_driver *drv =
drv_to_hv_drv(device->driver); drv_to_hv_drv(device->driver);
struct storvsc_driver_object *storvsc_drv_obj = drv->priv; 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_to_hv_device(device);
struct hv_device *device_obj = &device_ctx->device_obj;
struct Scsi_Host *host; struct Scsi_Host *host;
struct host_device_context *host_device_ctx; struct host_device_context *host_device_ctx;
struct storvsc_device_info device_info; struct storvsc_device_info device_info;
...@@ -238,10 +237,10 @@ static int storvsc_probe(struct device *device) ...@@ -238,10 +237,10 @@ static int storvsc_probe(struct device *device)
memset(host_device_ctx, 0, sizeof(struct host_device_context)); memset(host_device_ctx, 0, sizeof(struct host_device_context));
host_device_ctx->port = host->host_no; 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 = 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) + sizeof(struct storvsc_cmd_request) +
storvsc_drv_obj->request_ext_size, 0, storvsc_drv_obj->request_ext_size, 0,
SLAB_HWCACHE_ALIGN, NULL); SLAB_HWCACHE_ALIGN, NULL);
...@@ -298,8 +297,7 @@ static int storvsc_remove(struct device *device) ...@@ -298,8 +297,7 @@ static int storvsc_remove(struct device *device)
struct hv_driver *drv = struct hv_driver *drv =
drv_to_hv_drv(device->driver); drv_to_hv_drv(device->driver);
struct storvsc_driver_object *storvsc_drv_obj = drv->priv; 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_to_hv_device(device);
struct hv_device *device_obj = &device_ctx->device_obj;
struct Scsi_Host *host = dev_get_drvdata(device); struct Scsi_Host *host = dev_get_drvdata(device);
struct host_device_context *host_device_ctx = struct host_device_context *host_device_ctx =
(struct host_device_context *)host->hostdata; (struct host_device_context *)host->hostdata;
...@@ -589,7 +587,7 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd, ...@@ -589,7 +587,7 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
int ret; int ret;
struct host_device_context *host_device_ctx = struct host_device_context *host_device_ctx =
(struct host_device_context *)scmnd->device->host->hostdata; (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 = struct hv_driver *drv =
drv_to_hv_drv(device_ctx->device.driver); drv_to_hv_drv(device_ctx->device.driver);
struct storvsc_driver_object *storvsc_drv_obj = drv->priv; struct storvsc_driver_object *storvsc_drv_obj = drv->priv;
...@@ -737,7 +735,7 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd, ...@@ -737,7 +735,7 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
retry_request: retry_request:
/* Invokes the vsc to start an IO */ /* 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); &cmd_request->request);
if (ret == -1) { if (ret == -1) {
/* no more space */ /* no more space */
...@@ -824,18 +822,18 @@ static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd) ...@@ -824,18 +822,18 @@ static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd)
int ret; int ret;
struct host_device_context *host_device_ctx = struct host_device_context *host_device_ctx =
(struct host_device_context *)scmnd->device->host->hostdata; (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...", 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 */ /* 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) if (ret != 0)
return ret; return ret;
DPRINT_INFO(STORVSC_DRV, "sdev (%p) dev obj (%p) - host reseted", DPRINT_INFO(STORVSC_DRV, "sdev (%p) dev obj (%p) - host reseted",
scmnd->device, &device_ctx->device_obj); scmnd->device, device_ctx);
return ret; return ret;
} }
......
...@@ -29,19 +29,11 @@ ...@@ -29,19 +29,11 @@
#include "vmbus_api.h" #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) static inline struct hv_driver *drv_to_hv_drv(struct device_driver *d)
......
...@@ -128,6 +128,8 @@ struct hv_device { ...@@ -128,6 +128,8 @@ struct hv_device {
/* the device instance id of this device */ /* the device instance id of this device */
struct hv_guid dev_instance; struct hv_guid dev_instance;
struct device device;
struct vmbus_channel *channel; struct vmbus_channel *channel;
/* Device extension; */ /* Device extension; */
......
...@@ -49,7 +49,7 @@ struct vmbus_driver_context { ...@@ -49,7 +49,7 @@ struct vmbus_driver_context {
struct tasklet_struct event_dpc; struct tasklet_struct event_dpc;
/* The bus root device */ /* 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); static int vmbus_match(struct device *device, struct device_driver *driver);
...@@ -349,12 +349,12 @@ static ssize_t vmbus_show_device_attr(struct device *dev, ...@@ -349,12 +349,12 @@ static ssize_t vmbus_show_device_attr(struct device *dev,
struct device_attribute *dev_attr, struct device_attribute *dev_attr,
char *buf) 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; struct hv_device_info device_info;
memset(&device_info, 0, sizeof(struct hv_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")) { if (!strcmp(dev_attr->attr.name, "class_id")) {
return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-" return sprintf(buf, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-"
...@@ -459,7 +459,7 @@ static int vmbus_bus_init(void) ...@@ -459,7 +459,7 @@ 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_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; int ret;
unsigned int vector; unsigned int vector;
...@@ -530,9 +530,9 @@ static int vmbus_bus_init(void) ...@@ -530,9 +530,9 @@ 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 */ /* 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) { 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");
...@@ -585,11 +585,11 @@ static void vmbus_bus_exit(void) ...@@ -585,11 +585,11 @@ static void vmbus_bus_exit(void)
struct hv_driver *driver = &vmbus_drv.drv_obj; 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 vm_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) if (driver->dev_rm)
driver->dev_rm(&dev_ctx->device_obj); driver->dev_rm(dev_ctx);
if (driver->cleanup) if (driver->cleanup)
driver->cleanup(driver); driver->cleanup(driver);
...@@ -664,12 +664,11 @@ struct hv_device *vmbus_child_device_create(struct hv_guid *type, ...@@ -664,12 +664,11 @@ struct hv_device *vmbus_child_device_create(struct hv_guid *type,
struct hv_guid *instance, struct hv_guid *instance,
struct vmbus_channel *channel) struct vmbus_channel *channel)
{ {
struct vm_device *child_device_ctx;
struct hv_device *child_device_obj; struct hv_device *child_device_obj;
/* Allocate the new child device */ /* Allocate the new child device */
child_device_ctx = kzalloc(sizeof(struct vm_device), GFP_KERNEL); child_device_obj = kzalloc(sizeof(struct hv_device), GFP_KERNEL);
if (!child_device_ctx) { if (!child_device_obj) {
DPRINT_ERR(VMBUS_DRV, DPRINT_ERR(VMBUS_DRV,
"unable to allocate device_context for child device"); "unable to allocate device_context for child device");
return NULL; return NULL;
...@@ -680,7 +679,7 @@ struct hv_device *vmbus_child_device_create(struct hv_guid *type, ...@@ -680,7 +679,7 @@ struct hv_device *vmbus_child_device_create(struct hv_guid *type,
"%02x%02x%02x%02x%02x%02x%02x%02x}," "%02x%02x%02x%02x%02x%02x%02x%02x},"
"id {%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}", "%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[3], type->data[2], type->data[1], type->data[0],
type->data[5], type->data[4], type->data[7], type->data[6], type->data[5], type->data[4], type->data[7], type->data[6],
type->data[8], type->data[9], type->data[10], type->data[11], type->data[8], type->data[9], type->data[10], type->data[11],
...@@ -694,7 +693,6 @@ struct hv_device *vmbus_child_device_create(struct hv_guid *type, ...@@ -694,7 +693,6 @@ struct hv_device *vmbus_child_device_create(struct hv_guid *type,
instance->data[12], instance->data[13], instance->data[12], instance->data[13],
instance->data[14], instance->data[15]); instance->data[14], instance->data[15]);
child_device_obj = &child_device_ctx->device_obj;
child_device_obj->channel = channel; child_device_obj->channel = channel;
memcpy(&child_device_obj->dev_type, type, sizeof(struct hv_guid)); memcpy(&child_device_obj->dev_type, type, sizeof(struct hv_guid));
memcpy(&child_device_obj->dev_instance, instance, memcpy(&child_device_obj->dev_instance, instance,
...@@ -711,39 +709,36 @@ int vmbus_child_device_register(struct hv_device *root_device_obj, ...@@ -711,39 +709,36 @@ int vmbus_child_device_register(struct hv_device *root_device_obj,
struct hv_device *child_device_obj) struct hv_device *child_device_obj)
{ {
int ret = 0; 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); static atomic_t device_num = ATOMIC_INIT(0);
DPRINT_DBG(VMBUS_DRV, "child device (%p) registering", DPRINT_DBG(VMBUS_DRV, "child device (%p) registering",
child_device_ctx); child_device_obj);
/* Set the device name. Otherwise, device_register() will fail. */ /* 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)); atomic_inc_return(&device_num));
/* The new device belongs to this bus */ /* The new device belongs to this bus */
child_device_ctx->device.bus = &vmbus_drv.bus; /* device->dev.bus; */ child_device_obj->device.bus = &vmbus_drv.bus; /* device->dev.bus; */
child_device_ctx->device.parent = &root_device_ctx->device; child_device_obj->device.parent = &root_device_obj->device;
child_device_ctx->device.release = vmbus_device_release; child_device_obj->device.release = vmbus_device_release;
/* /*
* Register with the LDM. This will kick off the driver/device * Register with the LDM. This will kick off the driver/device
* binding...which will eventually call vmbus_match() and vmbus_probe() * 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(). */ /* 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) if (ret)
DPRINT_ERR(VMBUS_DRV, "unable to register child device (%p)", DPRINT_ERR(VMBUS_DRV, "unable to register child device (%p)",
&child_device_ctx->device); &child_device_obj->device);
else else
DPRINT_INFO(VMBUS_DRV, "child device (%p) registered", DPRINT_INFO(VMBUS_DRV, "child device (%p) registered",
&child_device_ctx->device); &child_device_obj->device);
return ret; return ret;
} }
...@@ -754,19 +749,18 @@ int vmbus_child_device_register(struct hv_device *root_device_obj, ...@@ -754,19 +749,18 @@ int vmbus_child_device_register(struct hv_device *root_device_obj,
*/ */
void vmbus_child_device_unregister(struct hv_device *device_obj) 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)", DPRINT_INFO(VMBUS_DRV, "unregistering child device (%p)",
&device_ctx->device); &device_obj->device);
/* /*
* Kick off the process of unregistering the device. * Kick off the process of unregistering the device.
* This will call vmbus_remove() and eventually vmbus_device_release() * 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", DPRINT_INFO(VMBUS_DRV, "child device (%p) unregistered",
&device_ctx->device); &device_obj->device);
} }
/* /*
...@@ -778,8 +772,7 @@ void vmbus_child_device_unregister(struct hv_device *device_obj) ...@@ -778,8 +772,7 @@ void vmbus_child_device_unregister(struct hv_device *device_obj)
*/ */
static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env) 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_to_hv_device(device);
struct hv_device *dev = &device_ctx->device_obj;
int ret; int ret;
DPRINT_INFO(VMBUS_DRV, "generating uevent - VMBUS_DEVICE_CLASS_GUID={" DPRINT_INFO(VMBUS_DRV, "generating uevent - VMBUS_DEVICE_CLASS_GUID={"
...@@ -852,17 +845,17 @@ static int vmbus_match(struct device *device, struct device_driver *driver) ...@@ -852,17 +845,17 @@ static int vmbus_match(struct device *device, struct device_driver *driver)
{ {
int match = 0; int match = 0;
struct hv_driver *drv = drv_to_hv_drv(driver); 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 ? */ /* 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) { sizeof(struct hv_guid)) == 0) {
device_ctx->device_obj.drv = drv->priv; device_ctx->drv = drv->priv;
DPRINT_INFO(VMBUS_DRV, DPRINT_INFO(VMBUS_DRV,
"device object (%p) set to driver object (%p)", "device object (%p) set to driver object (%p)",
&device_ctx->device_obj, &device_ctx,
device_ctx->device_obj.drv); device_ctx->drv);
match = 1; match = 1;
} }
...@@ -878,7 +871,7 @@ static int vmbus_match(struct device *device, struct device_driver *driver) ...@@ -878,7 +871,7 @@ static int vmbus_match(struct device *device, struct device_driver *driver)
*/ */
static void vmbus_probe_failed_cb(struct work_struct *context) 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. * Kick off the process of unregistering the device.
...@@ -897,13 +890,11 @@ static int vmbus_probe(struct device *child_device) ...@@ -897,13 +890,11 @@ static int vmbus_probe(struct device *child_device)
int ret = 0; int ret = 0;
struct hv_driver *drv = struct hv_driver *drv =
drv_to_hv_drv(child_device->driver); drv_to_hv_drv(child_device->driver);
struct vm_device *device_ctx = struct hv_device *dev = device_to_hv_device(child_device);
device_to_vm_device(child_device);
struct hv_device *dev = &device_ctx->device_obj;
/* Let the specific open-source driver handles the probe if it can */ /* Let the specific open-source driver handles the probe if it can */
if (drv->driver.probe) { if (drv->driver.probe) {
ret = device_ctx->device_obj.probe_error = ret = dev->probe_error =
drv->driver.probe(child_device); drv->driver.probe(child_device);
if (ret != 0) { if (ret != 0) {
DPRINT_ERR(VMBUS_DRV, "probe() failed for device %s " DPRINT_ERR(VMBUS_DRV, "probe() failed for device %s "
...@@ -1006,7 +997,7 @@ static void vmbus_bus_release(struct device *device) ...@@ -1006,7 +997,7 @@ static void vmbus_bus_release(struct device *device)
*/ */
static void vmbus_device_release(struct device *device) 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); kfree(device_ctx);
......
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