Skip to content

Commit

Permalink
Staging: hv: Rename struct device_context and re-arrange the fields i…
Browse files Browse the repository at this point in the history
…nside

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: Hank Janssen <hjanssen@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Haiyang Zhang authored and Greg Kroah-Hartman committed Mar 4, 2010
1 parent 26c14cc commit f916a34
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 38 deletions.
8 changes: 4 additions & 4 deletions drivers/staging/hv/blkvsc_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ struct blkvsc_request {
/* Per device structure */
struct block_device_context {
/* point back to our device context */
struct device_context *device_ctx;
struct vm_device *device_ctx;
struct kmem_cache *request_pool;
spinlock_t lock;
struct gendisk *gd;
Expand Down Expand Up @@ -255,7 +255,7 @@ static int blkvsc_probe(struct device *device)
(struct blkvsc_driver_context *)driver_ctx;
struct storvsc_driver_object *storvsc_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 block_device_context *blkdev = NULL;
Expand Down Expand Up @@ -746,7 +746,7 @@ static int blkvsc_remove(struct device *device)
(struct blkvsc_driver_context *)driver_ctx;
struct storvsc_driver_object *storvsc_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 block_device_context *blkdev = dev_get_drvdata(device);
unsigned long flags;
Expand Down Expand Up @@ -866,7 +866,7 @@ static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req,
void (*request_completion)(struct hv_storvsc_request *))
{
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 =
driver_to_driver_context(device_ctx->device.driver);
struct blkvsc_driver_context *blkvsc_drv_ctx =
Expand Down
10 changes: 5 additions & 5 deletions drivers/staging/hv/netvsc_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

struct net_device_context {
/* point back to our device context */
struct device_context *device_ctx;
struct vm_device *device_ctx;
struct net_device_stats stats;
};

Expand Down Expand Up @@ -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,
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);

DPRINT_ENTER(NETVSC_DRV);
Expand All @@ -298,7 +298,7 @@ static void netvsc_linkstatus_callback(struct hv_device *device_obj,
static int netvsc_recv_callback(struct hv_device *device_obj,
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_context *net_device_ctx;
struct sk_buff *skb;
Expand Down Expand Up @@ -390,7 +390,7 @@ static int netvsc_probe(struct device *device)
struct netvsc_driver_context *net_drv_ctx =
(struct netvsc_driver_context *)driver_ctx;
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 net_device *net = NULL;
struct net_device_context *net_device_ctx;
Expand Down Expand Up @@ -462,7 +462,7 @@ static int netvsc_remove(struct device *device)
struct netvsc_driver_context *net_drv_ctx =
(struct netvsc_driver_context *)driver_ctx;
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 hv_device *device_obj = &device_ctx->device_obj;
int ret;
Expand Down
10 changes: 5 additions & 5 deletions drivers/staging/hv/storvsc_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct host_device_context {
/* must be 1st field
* FIXME this is a bug */
/* point back to our device context */
struct device_context *device_ctx;
struct vm_device *device_ctx;
struct kmem_cache *request_pool;
unsigned int port;
unsigned char path;
Expand Down Expand Up @@ -234,7 +234,7 @@ static int storvsc_probe(struct device *device)
(struct storvsc_driver_context *)driver_ctx;
struct storvsc_driver_object *storvsc_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 Scsi_Host *host;
struct host_device_context *host_device_ctx;
Expand Down Expand Up @@ -330,7 +330,7 @@ static int storvsc_remove(struct device *device)
(struct storvsc_driver_context *)driver_ctx;
struct storvsc_driver_object *storvsc_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 Scsi_Host *host = dev_get_drvdata(device);
struct host_device_context *host_device_ctx =
Expand Down Expand Up @@ -631,7 +631,7 @@ static int storvsc_queuecommand(struct scsi_cmnd *scmnd,
int ret;
struct host_device_context *host_device_ctx =
(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 =
driver_to_driver_context(device_ctx->device.driver);
struct storvsc_driver_context *storvsc_drv_ctx =
Expand Down Expand Up @@ -870,7 +870,7 @@ static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd)
int ret;
struct host_device_context *host_device_ctx =
(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);

Expand Down
12 changes: 6 additions & 6 deletions drivers/staging/hv/vmbus.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,23 @@ struct driver_context {
void (*shutdown)(struct device *);
};

struct device_context {
struct vm_device {
struct work_struct probe_failed_work_item;
struct hv_guid class_id;
struct hv_guid device_id;
int probe_error;
struct device device;
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)
Expand Down
36 changes: 18 additions & 18 deletions drivers/staging/hv/vmbus_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct vmbus_driver_context {
struct tasklet_struct event_dpc;

/* 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);
Expand Down Expand Up @@ -136,7 +136,7 @@ static ssize_t vmbus_show_device_attr(struct device *dev,
struct device_attribute *dev_attr,
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;

memset(&device_info, 0, sizeof(struct hv_device_info));
Expand Down Expand Up @@ -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 *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;
unsigned int vector;

Expand Down Expand Up @@ -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);

/* 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);
if (ret != 0) {
Expand Down Expand Up @@ -369,7 +369,7 @@ static void vmbus_bus_exit(void)
struct vmbus_driver *vmbus_drv_obj = &g_vmbus_drv.drv_obj;
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);

Expand Down Expand Up @@ -472,13 +472,13 @@ static struct hv_device *vmbus_child_device_create(struct hv_guid *type,
struct hv_guid *instance,
void *context)
{
struct device_context *child_device_ctx;
struct vm_device *child_device_ctx;
struct hv_device *child_device_obj;

DPRINT_ENTER(VMBUS_DRV);

/* 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) {
DPRINT_ERR(VMBUS_DRV,
"unable to allocate device_context for child device");
Expand Down Expand Up @@ -527,10 +527,10 @@ static int vmbus_child_device_register(struct hv_device *root_device_obj,
struct hv_device *child_device_obj)
{
int ret = 0;
struct device_context *root_device_ctx =
to_device_context(root_device_obj);
struct device_context *child_device_ctx =
to_device_context(child_device_obj);
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_ENTER(VMBUS_DRV);
Expand Down Expand Up @@ -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)
{
struct device_context *device_ctx = to_device_context(device_obj);
struct vm_device *device_ctx = to_vm_device(device_obj);

DPRINT_ENTER(VMBUS_DRV);

Expand Down Expand Up @@ -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)
{
struct device_context *device_ctx = device_to_device_context(device);
struct vm_device *device_ctx = device_to_vm_device(device);
int ret;

DPRINT_ENTER(VMBUS_DRV);
Expand Down Expand Up @@ -688,7 +688,7 @@ static int vmbus_match(struct device *device, struct device_driver *driver)
{
int match = 0;
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);

Expand Down Expand Up @@ -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)
{
struct device_context *device_ctx = (struct device_context *)context;
struct vm_device *device_ctx = (struct vm_device *)context;

DPRINT_ENTER(VMBUS_DRV);

Expand All @@ -747,8 +747,8 @@ static int vmbus_probe(struct device *child_device)
int ret = 0;
struct driver_context *driver_ctx =
driver_to_driver_context(child_device->driver);
struct device_context *device_ctx =
device_to_device_context(child_device);
struct vm_device *device_ctx =
device_to_vm_device(child_device);

DPRINT_ENTER(VMBUS_DRV);

Expand Down Expand Up @@ -872,7 +872,7 @@ static void vmbus_bus_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);

Expand Down

0 comments on commit f916a34

Please sign in to comment.