Commit f916a34d authored by Haiyang Zhang's avatar Haiyang Zhang Committed by Greg Kroah-Hartman

Staging: hv: Rename struct device_context and re-arrange the fields inside

Rename struct device_context and re-arrange the fields inside.

Rename struct device_context to struct vm_device, and move struct device
field to the end according to Document/driver-model standard.
Signed-off-by: default avatarHank Janssen <hjanssen@microsoft.com>
Signed-off-by: default avatarHaiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 26c14cc1
...@@ -93,7 +93,7 @@ struct blkvsc_request { ...@@ -93,7 +93,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 device_context *device_ctx; struct vm_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;
...@@ -255,7 +255,7 @@ static int blkvsc_probe(struct device *device) ...@@ -255,7 +255,7 @@ static int blkvsc_probe(struct device *device)
(struct blkvsc_driver_context *)driver_ctx; (struct blkvsc_driver_context *)driver_ctx;
struct storvsc_driver_object *storvsc_drv_obj = struct storvsc_driver_object *storvsc_drv_obj =
&blkvsc_drv_ctx->drv_obj; &blkvsc_drv_ctx->drv_obj;
struct device_context *device_ctx = device_to_device_context(device); 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_ctx->device_obj;
struct block_device_context *blkdev = NULL; struct block_device_context *blkdev = NULL;
...@@ -746,7 +746,7 @@ static int blkvsc_remove(struct device *device) ...@@ -746,7 +746,7 @@ static int blkvsc_remove(struct device *device)
(struct blkvsc_driver_context *)driver_ctx; (struct blkvsc_driver_context *)driver_ctx;
struct storvsc_driver_object *storvsc_drv_obj = struct storvsc_driver_object *storvsc_drv_obj =
&blkvsc_drv_ctx->drv_obj; &blkvsc_drv_ctx->drv_obj;
struct device_context *device_ctx = device_to_device_context(device); 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_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;
...@@ -866,7 +866,7 @@ static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req, ...@@ -866,7 +866,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 device_context *device_ctx = blkdev->device_ctx; struct vm_device *device_ctx = blkdev->device_ctx;
struct driver_context *driver_ctx = struct driver_context *driver_ctx =
driver_to_driver_context(device_ctx->device.driver); driver_to_driver_context(device_ctx->device.driver);
struct blkvsc_driver_context *blkvsc_drv_ctx = struct blkvsc_driver_context *blkvsc_drv_ctx =
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
struct net_device_context { struct net_device_context {
/* point back to our device context */ /* point back to our device context */
struct device_context *device_ctx; struct vm_device *device_ctx;
struct net_device_stats stats; struct net_device_stats stats;
}; };
...@@ -271,7 +271,7 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net) ...@@ -271,7 +271,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 device_context *device_ctx = to_device_context(device_obj); 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_ctx->device);
DPRINT_ENTER(NETVSC_DRV); DPRINT_ENTER(NETVSC_DRV);
...@@ -298,7 +298,7 @@ static void netvsc_linkstatus_callback(struct hv_device *device_obj, ...@@ -298,7 +298,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 device_context *device_ctx = to_device_context(device_obj); 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_ctx->device);
struct net_device_context *net_device_ctx; struct net_device_context *net_device_ctx;
struct sk_buff *skb; struct sk_buff *skb;
...@@ -390,7 +390,7 @@ static int netvsc_probe(struct device *device) ...@@ -390,7 +390,7 @@ static int netvsc_probe(struct device *device)
struct netvsc_driver_context *net_drv_ctx = struct netvsc_driver_context *net_drv_ctx =
(struct netvsc_driver_context *)driver_ctx; (struct netvsc_driver_context *)driver_ctx;
struct netvsc_driver *net_drv_obj = &net_drv_ctx->drv_obj; struct netvsc_driver *net_drv_obj = &net_drv_ctx->drv_obj;
struct device_context *device_ctx = device_to_device_context(device); 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_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;
...@@ -462,7 +462,7 @@ static int netvsc_remove(struct device *device) ...@@ -462,7 +462,7 @@ static int netvsc_remove(struct device *device)
struct netvsc_driver_context *net_drv_ctx = struct netvsc_driver_context *net_drv_ctx =
(struct netvsc_driver_context *)driver_ctx; (struct netvsc_driver_context *)driver_ctx;
struct netvsc_driver *net_drv_obj = &net_drv_ctx->drv_obj; struct netvsc_driver *net_drv_obj = &net_drv_ctx->drv_obj;
struct device_context *device_ctx = device_to_device_context(device); struct vm_device *device_ctx = device_to_vm_device(device);
struct net_device *net = dev_get_drvdata(&device_ctx->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_ctx->device_obj;
int ret; int ret;
......
...@@ -41,7 +41,7 @@ struct host_device_context { ...@@ -41,7 +41,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 device_context *device_ctx; struct vm_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;
...@@ -234,7 +234,7 @@ static int storvsc_probe(struct device *device) ...@@ -234,7 +234,7 @@ static int storvsc_probe(struct device *device)
(struct storvsc_driver_context *)driver_ctx; (struct storvsc_driver_context *)driver_ctx;
struct storvsc_driver_object *storvsc_drv_obj = struct storvsc_driver_object *storvsc_drv_obj =
&storvsc_drv_ctx->drv_obj; &storvsc_drv_ctx->drv_obj;
struct device_context *device_ctx = device_to_device_context(device); 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_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;
...@@ -330,7 +330,7 @@ static int storvsc_remove(struct device *device) ...@@ -330,7 +330,7 @@ static int storvsc_remove(struct device *device)
(struct storvsc_driver_context *)driver_ctx; (struct storvsc_driver_context *)driver_ctx;
struct storvsc_driver_object *storvsc_drv_obj = struct storvsc_driver_object *storvsc_drv_obj =
&storvsc_drv_ctx->drv_obj; &storvsc_drv_ctx->drv_obj;
struct device_context *device_ctx = device_to_device_context(device); 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_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 =
...@@ -631,7 +631,7 @@ static int storvsc_queuecommand(struct scsi_cmnd *scmnd, ...@@ -631,7 +631,7 @@ static int storvsc_queuecommand(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 device_context *device_ctx = host_device_ctx->device_ctx; struct vm_device *device_ctx = host_device_ctx->device_ctx;
struct driver_context *driver_ctx = struct driver_context *driver_ctx =
driver_to_driver_context(device_ctx->device.driver); driver_to_driver_context(device_ctx->device.driver);
struct storvsc_driver_context *storvsc_drv_ctx = struct storvsc_driver_context *storvsc_drv_ctx =
...@@ -870,7 +870,7 @@ static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd) ...@@ -870,7 +870,7 @@ 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 device_context *device_ctx = host_device_ctx->device_ctx; struct vm_device *device_ctx = host_device_ctx->device_ctx;
DPRINT_ENTER(STORVSC_DRV); DPRINT_ENTER(STORVSC_DRV);
......
...@@ -43,23 +43,23 @@ struct driver_context { ...@@ -43,23 +43,23 @@ struct driver_context {
void (*shutdown)(struct device *); void (*shutdown)(struct device *);
}; };
struct device_context { struct vm_device {
struct work_struct probe_failed_work_item; struct work_struct probe_failed_work_item;
struct hv_guid class_id; struct hv_guid class_id;
struct hv_guid device_id; struct hv_guid device_id;
int probe_error; int probe_error;
struct device device;
struct hv_device device_obj; struct hv_device device_obj;
struct device device;
}; };
static inline struct device_context *to_device_context(struct hv_device *d) static inline struct vm_device *to_vm_device(struct hv_device *d)
{ {
return container_of(d, struct device_context, device_obj); return container_of(d, struct vm_device, device_obj);
} }
static inline struct device_context *device_to_device_context(struct device *d) static inline struct vm_device *device_to_vm_device(struct device *d)
{ {
return container_of(d, struct device_context, device); return container_of(d, struct vm_device, device);
} }
static inline struct driver_context *driver_to_driver_context(struct device_driver *d) static inline struct driver_context *driver_to_driver_context(struct device_driver *d)
......
...@@ -48,7 +48,7 @@ struct vmbus_driver_context { ...@@ -48,7 +48,7 @@ struct vmbus_driver_context {
struct tasklet_struct event_dpc; struct tasklet_struct event_dpc;
/* The bus root device */ /* The bus root device */
struct device_context device_ctx; struct vm_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);
...@@ -136,7 +136,7 @@ static ssize_t vmbus_show_device_attr(struct device *dev, ...@@ -136,7 +136,7 @@ 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 device_context *device_ctx = device_to_device_context(dev); struct vm_device *device_ctx = device_to_vm_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));
...@@ -246,7 +246,7 @@ static int vmbus_bus_init(int (*drv_init)(struct hv_driver *drv)) ...@@ -246,7 +246,7 @@ static int vmbus_bus_init(int (*drv_init)(struct hv_driver *drv))
{ {
struct vmbus_driver_context *vmbus_drv_ctx = &g_vmbus_drv; struct vmbus_driver_context *vmbus_drv_ctx = &g_vmbus_drv;
struct vmbus_driver *vmbus_drv_obj = &g_vmbus_drv.drv_obj; struct vmbus_driver *vmbus_drv_obj = &g_vmbus_drv.drv_obj;
struct device_context *dev_ctx = &g_vmbus_drv.device_ctx; struct vm_device *dev_ctx = &g_vmbus_drv.device_ctx;
int ret; int ret;
unsigned int vector; unsigned int vector;
...@@ -308,7 +308,7 @@ static int vmbus_bus_init(int (*drv_init)(struct hv_driver *drv)) ...@@ -308,7 +308,7 @@ static int vmbus_bus_init(int (*drv_init)(struct hv_driver *drv))
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 device_context)); memset(dev_ctx, 0, sizeof(struct vm_device));
ret = vmbus_drv_obj->Base.OnDeviceAdd(&dev_ctx->device_obj, &vector); ret = vmbus_drv_obj->Base.OnDeviceAdd(&dev_ctx->device_obj, &vector);
if (ret != 0) { if (ret != 0) {
...@@ -369,7 +369,7 @@ static void vmbus_bus_exit(void) ...@@ -369,7 +369,7 @@ static void vmbus_bus_exit(void)
struct vmbus_driver *vmbus_drv_obj = &g_vmbus_drv.drv_obj; struct vmbus_driver *vmbus_drv_obj = &g_vmbus_drv.drv_obj;
struct vmbus_driver_context *vmbus_drv_ctx = &g_vmbus_drv; struct vmbus_driver_context *vmbus_drv_ctx = &g_vmbus_drv;
struct device_context *dev_ctx = &g_vmbus_drv.device_ctx; struct vm_device *dev_ctx = &g_vmbus_drv.device_ctx;
DPRINT_ENTER(VMBUS_DRV); DPRINT_ENTER(VMBUS_DRV);
...@@ -472,13 +472,13 @@ static struct hv_device *vmbus_child_device_create(struct hv_guid *type, ...@@ -472,13 +472,13 @@ static struct hv_device *vmbus_child_device_create(struct hv_guid *type,
struct hv_guid *instance, struct hv_guid *instance,
void *context) void *context)
{ {
struct device_context *child_device_ctx; struct vm_device *child_device_ctx;
struct hv_device *child_device_obj; struct hv_device *child_device_obj;
DPRINT_ENTER(VMBUS_DRV); DPRINT_ENTER(VMBUS_DRV);
/* Allocate the new child device */ /* Allocate the new child device */
child_device_ctx = kzalloc(sizeof(struct device_context), GFP_KERNEL); child_device_ctx = kzalloc(sizeof(struct vm_device), GFP_KERNEL);
if (!child_device_ctx) { if (!child_device_ctx) {
DPRINT_ERR(VMBUS_DRV, DPRINT_ERR(VMBUS_DRV,
"unable to allocate device_context for child device"); "unable to allocate device_context for child device");
...@@ -527,10 +527,10 @@ static int vmbus_child_device_register(struct hv_device *root_device_obj, ...@@ -527,10 +527,10 @@ static 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 device_context *root_device_ctx = struct vm_device *root_device_ctx =
to_device_context(root_device_obj); to_vm_device(root_device_obj);
struct device_context *child_device_ctx = struct vm_device *child_device_ctx =
to_device_context(child_device_obj); to_vm_device(child_device_obj);
static atomic_t device_num = ATOMIC_INIT(0); static atomic_t device_num = ATOMIC_INIT(0);
DPRINT_ENTER(VMBUS_DRV); DPRINT_ENTER(VMBUS_DRV);
...@@ -573,7 +573,7 @@ static int vmbus_child_device_register(struct hv_device *root_device_obj, ...@@ -573,7 +573,7 @@ static int vmbus_child_device_register(struct hv_device *root_device_obj,
*/ */
static void vmbus_child_device_unregister(struct hv_device *device_obj) static void vmbus_child_device_unregister(struct hv_device *device_obj)
{ {
struct device_context *device_ctx = to_device_context(device_obj); struct vm_device *device_ctx = to_vm_device(device_obj);
DPRINT_ENTER(VMBUS_DRV); DPRINT_ENTER(VMBUS_DRV);
...@@ -611,7 +611,7 @@ static void vmbus_child_device_destroy(struct hv_device *device_obj) ...@@ -611,7 +611,7 @@ static void vmbus_child_device_destroy(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 device_context *device_ctx = device_to_device_context(device); struct vm_device *device_ctx = device_to_vm_device(device);
int ret; int ret;
DPRINT_ENTER(VMBUS_DRV); DPRINT_ENTER(VMBUS_DRV);
...@@ -688,7 +688,7 @@ static int vmbus_match(struct device *device, struct device_driver *driver) ...@@ -688,7 +688,7 @@ static int vmbus_match(struct device *device, struct device_driver *driver)
{ {
int match = 0; int match = 0;
struct driver_context *driver_ctx = driver_to_driver_context(driver); struct driver_context *driver_ctx = driver_to_driver_context(driver);
struct device_context *device_ctx = device_to_device_context(device); struct vm_device *device_ctx = device_to_vm_device(device);
DPRINT_ENTER(VMBUS_DRV); DPRINT_ENTER(VMBUS_DRV);
...@@ -725,7 +725,7 @@ static int vmbus_match(struct device *device, struct device_driver *driver) ...@@ -725,7 +725,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 device_context *device_ctx = (struct device_context *)context; struct vm_device *device_ctx = (struct vm_device *)context;
DPRINT_ENTER(VMBUS_DRV); DPRINT_ENTER(VMBUS_DRV);
...@@ -747,8 +747,8 @@ static int vmbus_probe(struct device *child_device) ...@@ -747,8 +747,8 @@ static int vmbus_probe(struct device *child_device)
int ret = 0; int ret = 0;
struct driver_context *driver_ctx = struct driver_context *driver_ctx =
driver_to_driver_context(child_device->driver); driver_to_driver_context(child_device->driver);
struct device_context *device_ctx = struct vm_device *device_ctx =
device_to_device_context(child_device); device_to_vm_device(child_device);
DPRINT_ENTER(VMBUS_DRV); DPRINT_ENTER(VMBUS_DRV);
...@@ -872,7 +872,7 @@ static void vmbus_bus_release(struct device *device) ...@@ -872,7 +872,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 device_context *device_ctx = device_to_device_context(device); struct vm_device *device_ctx = device_to_vm_device(device);
DPRINT_ENTER(VMBUS_DRV); DPRINT_ENTER(VMBUS_DRV);
......
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