Staging: hv: Remove the vm_device structure
Subsystems (2)
PATCH 16/16 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 K. Y. Srinivasan <[email protected]>
Signed-off-by Abhishek Kane <[email protected]>
Signed-off-by Haiyang Zhang <[email protected]>
Signed-off-by Hank Janssen <[email protected]>
--- drivers/staging/hv/blkvsc_drv.c | 16 +++---- drivers/staging/hv/hv_mouse.c | 19 +++------ drivers/staging/hv/netvsc_drv.c | 24 +++++------- drivers/staging/hv/storvsc_drv.c | 24 +++++------ drivers/staging/hv/vmbus.h | 12 +----- drivers/staging/hv/vmbus_api.h | 2 + drivers/staging/hv/vmbus_drv.c | 77 +++++++++++++++++--------------------- 7 files changed, 73 insertions(+), 101 deletions(-)
drivers/staging/hv/blkvsc_drv.c +7 -9
@@ -95,7 +95,7 @@ struct blkvsc_request {/* 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;
@@ -240,8 +240,7 @@ static int blkvsc_probe(struct device *device)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;
@@ -273,7 +272,7 @@ static int blkvsc_probe(struct device *device)/* 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 );
@@ -290,7 +289,7 @@ static int blkvsc_probe(struct device *device) 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 */
@@ -723,8 +722,7 @@ static int blkvsc_remove(struct device *device)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;
@@ -839,7 +837,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 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 =
@@ -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_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++;
drivers/staging/hv/hv_mouse.c +7 -12
@@ -771,7 +771,7 @@ static void MousevscOnCleanup(struct hv_driver *drv)* 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;
@@ -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) { -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 ));
@@ -796,9 +795,8 @@ static void inputreport_callback(struct hv_device *dev, void *packet, u32 len) {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 );
@@ -823,8 +821,7 @@ static int mousevsc_probe(struct device *device)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),
@@ -852,8 +849,7 @@ static int mousevsc_remove(struct device *device)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),
@@ -887,9 +883,8 @@ static int mousevsc_remove(struct device *device)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; */
@@ -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->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);
drivers/staging/hv/netvsc_drv.c +10 -14
@@ -44,7 +44,7 @@struct net_device_context {/* point back to our device context */ -struct vm_device *device_ctx; +struct hv_device *device_ctx;unsigned long avail; };
@@ -70,7 +70,7 @@ static void netvsc_set_multicast_list(struct net_device *net)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)) {
@@ -93,7 +93,7 @@ static int netvsc_open(struct net_device *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);
@@ -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_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;
@@ -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,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 "
@@ -244,8 +243,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 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;
@@ -335,8 +333,7 @@ static int netvsc_probe(struct device *device)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;
@@ -353,7 +350,7 @@ static int netvsc_probe(struct device *device)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);
@@ -405,9 +402,8 @@ static int netvsc_remove(struct device *device)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 ) {
drivers/staging/hv/storvsc_drv.c +11 -13
@@ -42,7 +42,7 @@ struct host_device_context {/* 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;
@@ -216,8 +216,7 @@ static int storvsc_probe(struct device *device)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;
@@ -238,10 +237,10 @@ static int storvsc_probe(struct device *device)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 );
@@ -298,8 +297,7 @@ static int storvsc_remove(struct device *device)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;
@@ -589,7 +587,7 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,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;
@@ -737,7 +735,7 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd, 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 */
@@ -824,18 +822,18 @@ 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 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; }
drivers/staging/hv/vmbus.h +2 -10
@@ -29,19 +29,11 @@#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)
drivers/staging/hv/vmbus_api.h +2 -0
@@ -128,6 +128,8 @@ struct hv_device {/* the device instance id of this device */ struct hv_guid dev_instance; +struct device device; +struct vmbus_channel *channel;/* Device extension; */
drivers/staging/hv/vmbus_drv.c +34 -43
216 lines not on this page · raw message
Signature · 1 line
1.5.5.6