RE: [PATCH 18/25] Staging: hv: storvsc: Eliminate the usage of ext field in struct hv_device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> -----Original Message-----
> From: Greg KH [mailto:greg@xxxxxxxxx]
> Sent: Friday, September 09, 2011 4:45 PM
> To: KY Srinivasan
> Cc: gregkh@xxxxxxx; linux-kernel@xxxxxxxxxxxxxxx;
> devel@xxxxxxxxxxxxxxxxxxxxxx; virtualization@xxxxxxxxxxxxxx; Haiyang Zhang
> Subject: Re: [PATCH 18/25] Staging: hv: storvsc: Eliminate the usage of ext field in
> struct hv_device
> 
> On Thu, Sep 08, 2011 at 07:24:29AM -0700, K. Y. Srinivasan wrote:
> > Now, eliminate the usage of ext field in struct  hv_device for storvsc driver.
> > We do this by registering pointer to struct storvsc_device as the driver
> > specific data and eliminating the current usage of driver specific data to
> > save and retrieve the pointer to struct Scsi_Host.
> > Additionally, all access to the driver specific data is through
> > the vmbus wrapper functions.
> >
> > Signed-off-by: K. Y. Srinivasan <kys@xxxxxxxxxxxxx>
> > Signed-off-by: Haiyang Zhang <haiyangz@xxxxxxxxxxxxx>
> > ---
> >  drivers/staging/hv/storvsc_drv.c |   24 +++++++++++++++---------
> >  1 files changed, 15 insertions(+), 9 deletions(-)
> >
> > diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
> > index 57c1035..98d47cd 100644
> > --- a/drivers/staging/hv/storvsc_drv.c
> > +++ b/drivers/staging/hv/storvsc_drv.c
> > @@ -266,6 +266,7 @@ struct storvsc_device {
> >  	bool	 destroy;
> >  	bool	 drain_notify;
> >  	atomic_t num_outstanding_req;
> > +	struct Scsi_Host *host;
> 
> You are properly reference counting this pointer, right?

The scsi_host_alloc() which we use to allocate the host structure, gives us
the needed reference.
> 
> > @@ -306,7 +307,8 @@ static inline struct storvsc_device
> *get_out_stor_device(
> >  {
> >  	struct storvsc_device *stor_device;
> >
> > -	stor_device = (struct storvsc_device *)device->ext;
> > +	stor_device =
> > +		(struct storvsc_device *)hv_get_drvdata(device);
> 
> Casting is not needed at all.
> 
> > @@ -1366,7 +1371,8 @@ static int storvsc_probe(struct hv_device *device,
> >  	stor_device->destroy = false;
> >  	init_waitqueue_head(&stor_device->waiting_to_drain);
> >  	stor_device->device = device;
> > -	device->ext = stor_device;
> > +	stor_device->host = host;
> > +	hv_set_drvdata(device, stor_device);
> 
> Lookie there, no reference count incremented, right?  Or did I miss it
> somewhere else?

We are stashing the pointer to a structure on which we already have a reference
(that was established at the point of allocating the host).

Regards,

K. Y
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux