aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/hv/StorVsc.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2009-08-28 19:26:48 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2009-09-15 15:02:01 -0400
commit7dd03fc4be4bcfcc8c56b22494da501c569e5b4d (patch)
treefaf28cbe3e7edb2e39eec17942d0a1d45eb3b602 /drivers/staging/hv/StorVsc.c
parente681b95438da3db44d7f847960ba827b624f59d5 (diff)
Staging: hv: remove typedefs from StorVsc.c
Cc: Hank Janssen <hjanssen@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/hv/StorVsc.c')
-rw-r--r--drivers/staging/hv/StorVsc.c91
1 files changed, 44 insertions, 47 deletions
diff --git a/drivers/staging/hv/StorVsc.c b/drivers/staging/hv/StorVsc.c
index 75b92a051c8..ccb6d2ad30b 100644
--- a/drivers/staging/hv/StorVsc.c
+++ b/drivers/staging/hv/StorVsc.c
@@ -38,9 +38,7 @@
38 38
39 39
40/* Data types */ 40/* Data types */
41 41struct storvsc_request_extension {
42
43typedef struct _STORVSC_REQUEST_EXTENSION {
44 /* LIST_ENTRY ListEntry; */ 42 /* LIST_ENTRY ListEntry; */
45 43
46 struct hv_storvsc_request *Request; 44 struct hv_storvsc_request *Request;
@@ -50,11 +48,11 @@ typedef struct _STORVSC_REQUEST_EXTENSION {
50 struct osd_waitevent *WaitEvent; 48 struct osd_waitevent *WaitEvent;
51 49
52 struct vstor_packet VStorPacket; 50 struct vstor_packet VStorPacket;
53} STORVSC_REQUEST_EXTENSION; 51};
54 52
55 53
56/* A storvsc device is a device object that contains a vmbus channel */ 54/* A storvsc device is a device object that contains a vmbus channel */
57typedef struct _STORVSC_DEVICE{ 55struct storvsc_device {
58 struct hv_device *Device; 56 struct hv_device *Device;
59 57
60 atomic_t RefCount; /* 0 indicates the device is being destroyed */ 58 atomic_t RefCount; /* 0 indicates the device is being destroyed */
@@ -74,11 +72,10 @@ typedef struct _STORVSC_DEVICE{
74 /* HANDLE OutstandingRequestLock; */ 72 /* HANDLE OutstandingRequestLock; */
75 73
76 /* Used for vsc/vsp channel reset process */ 74 /* Used for vsc/vsp channel reset process */
77 STORVSC_REQUEST_EXTENSION InitRequest; 75 struct storvsc_request_extension InitRequest;
76 struct storvsc_request_extension ResetRequest;
78 77
79 STORVSC_REQUEST_EXTENSION ResetRequest; 78};
80
81} STORVSC_DEVICE;
82 79
83 80
84 81
@@ -133,14 +130,14 @@ static void
133StorVscOnIOCompletion( 130StorVscOnIOCompletion(
134 struct hv_device *Device, 131 struct hv_device *Device,
135 struct vstor_packet *VStorPacket, 132 struct vstor_packet *VStorPacket,
136 STORVSC_REQUEST_EXTENSION *RequestExt 133 struct storvsc_request_extension *RequestExt
137 ); 134 );
138 135
139static void 136static void
140StorVscOnReceive( 137StorVscOnReceive(
141 struct hv_device *Device, 138 struct hv_device *Device,
142 struct vstor_packet *VStorPacket, 139 struct vstor_packet *VStorPacket,
143 STORVSC_REQUEST_EXTENSION *RequestExt 140 struct storvsc_request_extension *RequestExt
144 ); 141 );
145 142
146static int 143static int
@@ -148,11 +145,11 @@ StorVscConnectToVsp(
148 struct hv_device *Device 145 struct hv_device *Device
149 ); 146 );
150 147
151static inline STORVSC_DEVICE* AllocStorDevice(struct hv_device *Device) 148static inline struct storvsc_device *AllocStorDevice(struct hv_device *Device)
152{ 149{
153 STORVSC_DEVICE *storDevice; 150 struct storvsc_device *storDevice;
154 151
155 storDevice = kzalloc(sizeof(STORVSC_DEVICE), GFP_KERNEL); 152 storDevice = kzalloc(sizeof(struct storvsc_device), GFP_KERNEL);
156 if (!storDevice) 153 if (!storDevice)
157 return NULL; 154 return NULL;
158 155
@@ -166,18 +163,18 @@ static inline STORVSC_DEVICE* AllocStorDevice(struct hv_device *Device)
166 return storDevice; 163 return storDevice;
167} 164}
168 165
169static inline void FreeStorDevice(STORVSC_DEVICE *Device) 166static inline void FreeStorDevice(struct storvsc_device *Device)
170{ 167{
171 ASSERT( atomic_read(&Device->RefCount) == 0); 168 ASSERT( atomic_read(&Device->RefCount) == 0);
172 kfree(Device); 169 kfree(Device);
173} 170}
174 171
175/* Get the stordevice object iff exists and its refcount > 1 */ 172/* Get the stordevice object iff exists and its refcount > 1 */
176static inline STORVSC_DEVICE* GetStorDevice(struct hv_device *Device) 173static inline struct storvsc_device* GetStorDevice(struct hv_device *Device)
177{ 174{
178 STORVSC_DEVICE *storDevice; 175 struct storvsc_device *storDevice;
179 176
180 storDevice = (STORVSC_DEVICE*)Device->Extension; 177 storDevice = (struct storvsc_device *)Device->Extension;
181 if (storDevice && atomic_read(&storDevice->RefCount) > 1) 178 if (storDevice && atomic_read(&storDevice->RefCount) > 1)
182 atomic_inc(&storDevice->RefCount); 179 atomic_inc(&storDevice->RefCount);
183 else 180 else
@@ -187,11 +184,11 @@ static inline STORVSC_DEVICE* GetStorDevice(struct hv_device *Device)
187} 184}
188 185
189/* Get the stordevice object iff exists and its refcount > 0 */ 186/* Get the stordevice object iff exists and its refcount > 0 */
190static inline STORVSC_DEVICE* MustGetStorDevice(struct hv_device *Device) 187static inline struct storvsc_device *MustGetStorDevice(struct hv_device *Device)
191{ 188{
192 STORVSC_DEVICE *storDevice; 189 struct storvsc_device *storDevice;
193 190
194 storDevice = (STORVSC_DEVICE*)Device->Extension; 191 storDevice = (struct storvsc_device *)Device->Extension;
195 if (storDevice && atomic_read(&storDevice->RefCount)) 192 if (storDevice && atomic_read(&storDevice->RefCount))
196 atomic_inc(&storDevice->RefCount); 193 atomic_inc(&storDevice->RefCount);
197 else 194 else
@@ -202,9 +199,9 @@ static inline STORVSC_DEVICE* MustGetStorDevice(struct hv_device *Device)
202 199
203static inline void PutStorDevice(struct hv_device *Device) 200static inline void PutStorDevice(struct hv_device *Device)
204{ 201{
205 STORVSC_DEVICE *storDevice; 202 struct storvsc_device *storDevice;
206 203
207 storDevice = (STORVSC_DEVICE*)Device->Extension; 204 storDevice = (struct storvsc_device *)Device->Extension;
208 ASSERT(storDevice); 205 ASSERT(storDevice);
209 206
210 atomic_dec(&storDevice->RefCount); 207 atomic_dec(&storDevice->RefCount);
@@ -212,11 +209,11 @@ static inline void PutStorDevice(struct hv_device *Device)
212} 209}
213 210
214/* Drop ref count to 1 to effectively disable GetStorDevice() */ 211/* Drop ref count to 1 to effectively disable GetStorDevice() */
215static inline STORVSC_DEVICE* ReleaseStorDevice(struct hv_device *Device) 212static inline struct storvsc_device *ReleaseStorDevice(struct hv_device *Device)
216{ 213{
217 STORVSC_DEVICE *storDevice; 214 struct storvsc_device *storDevice;
218 215
219 storDevice = (STORVSC_DEVICE*)Device->Extension; 216 storDevice = (struct storvsc_device *)Device->Extension;
220 ASSERT(storDevice); 217 ASSERT(storDevice);
221 218
222 /* Busy wait until the ref drop to 2, then set it to 1 */ 219 /* Busy wait until the ref drop to 2, then set it to 1 */
@@ -229,11 +226,11 @@ static inline STORVSC_DEVICE* ReleaseStorDevice(struct hv_device *Device)
229} 226}
230 227
231/* Drop ref count to 0. No one can use StorDevice object. */ 228/* Drop ref count to 0. No one can use StorDevice object. */
232static inline STORVSC_DEVICE* FinalReleaseStorDevice(struct hv_device *Device) 229static inline struct storvsc_device *FinalReleaseStorDevice(struct hv_device *Device)
233{ 230{
234 STORVSC_DEVICE *storDevice; 231 struct storvsc_device *storDevice;
235 232
236 storDevice = (STORVSC_DEVICE*)Device->Extension; 233 storDevice = (struct storvsc_device *)Device->Extension;
237 ASSERT(storDevice); 234 ASSERT(storDevice);
238 235
239 /* Busy wait until the ref drop to 1, then set it to 0 */ 236 /* Busy wait until the ref drop to 1, then set it to 0 */
@@ -266,8 +263,8 @@ StorVscInitialize(
266 263
267 DPRINT_ENTER(STORVSC); 264 DPRINT_ENTER(STORVSC);
268 265
269 DPRINT_DBG(STORVSC, "sizeof(STORVSC_REQUEST)=%zd sizeof(STORVSC_REQUEST_EXTENSION)=%zd sizeof(struct vstor_packet)=%zd, sizeof(struct vmscsi_request)=%zd", 266 DPRINT_DBG(STORVSC, "sizeof(STORVSC_REQUEST)=%zd sizeof(struct storvsc_request_extension)=%zd sizeof(struct vstor_packet)=%zd, sizeof(struct vmscsi_request)=%zd",
270 sizeof(struct hv_storvsc_request), sizeof(STORVSC_REQUEST_EXTENSION), sizeof(struct vstor_packet), sizeof(struct vmscsi_request)); 267 sizeof(struct hv_storvsc_request), sizeof(struct storvsc_request_extension), sizeof(struct vstor_packet), sizeof(struct vmscsi_request));
271 268
272 /* Make sure we are at least 2 pages since 1 page is used for control */ 269 /* Make sure we are at least 2 pages since 1 page is used for control */
273 ASSERT(storDriver->RingBufferSize >= (PAGE_SIZE << 1)); 270 ASSERT(storDriver->RingBufferSize >= (PAGE_SIZE << 1));
@@ -275,7 +272,7 @@ StorVscInitialize(
275 Driver->name = gDriverName; 272 Driver->name = gDriverName;
276 memcpy(&Driver->deviceType, &gStorVscDeviceType, sizeof(struct hv_guid)); 273 memcpy(&Driver->deviceType, &gStorVscDeviceType, sizeof(struct hv_guid));
277 274
278 storDriver->RequestExtSize = sizeof(STORVSC_REQUEST_EXTENSION); 275 storDriver->RequestExtSize = sizeof(struct storvsc_request_extension);
279 276
280 /* 277 /*
281 * Divide the ring buffer data size (which is 1 page less 278 * Divide the ring buffer data size (which is 1 page less
@@ -317,7 +314,7 @@ StorVscOnDeviceAdd(
317 ) 314 )
318{ 315{
319 int ret=0; 316 int ret=0;
320 STORVSC_DEVICE *storDevice; 317 struct storvsc_device *storDevice;
321 /* struct vmstorage_channel_properties *props; */ 318 /* struct vmstorage_channel_properties *props; */
322 struct storvsc_device_info *deviceInfo = (struct storvsc_device_info *)AdditionalInfo; 319 struct storvsc_device_info *deviceInfo = (struct storvsc_device_info *)AdditionalInfo;
323 320
@@ -363,8 +360,8 @@ Cleanup:
363static int StorVscChannelInit(struct hv_device *Device) 360static int StorVscChannelInit(struct hv_device *Device)
364{ 361{
365 int ret=0; 362 int ret=0;
366 STORVSC_DEVICE *storDevice; 363 struct storvsc_device *storDevice;
367 STORVSC_REQUEST_EXTENSION *request; 364 struct storvsc_request_extension *request;
368 struct vstor_packet *vstorPacket; 365 struct vstor_packet *vstorPacket;
369 366
370 storDevice = GetStorDevice(Device); 367 storDevice = GetStorDevice(Device);
@@ -380,7 +377,7 @@ static int StorVscChannelInit(struct hv_device *Device)
380 377
381 /* Now, initiate the vsc/vsp initialization protocol on the open channel */ 378 /* Now, initiate the vsc/vsp initialization protocol on the open channel */
382 379
383 memset(request, sizeof(STORVSC_REQUEST_EXTENSION), 0); 380 memset(request, sizeof(struct storvsc_request_extension), 0);
384 request->WaitEvent = osd_WaitEventCreate(); 381 request->WaitEvent = osd_WaitEventCreate();
385 382
386 vstorPacket->Operation = VStorOperationBeginInitialization; 383 vstorPacket->Operation = VStorOperationBeginInitialization;
@@ -572,7 +569,7 @@ StorVscOnDeviceRemove(
572 struct hv_device *Device 569 struct hv_device *Device
573 ) 570 )
574{ 571{
575 STORVSC_DEVICE *storDevice; 572 struct storvsc_device *storDevice;
576 int ret=0; 573 int ret=0;
577 574
578 DPRINT_ENTER(STORVSC); 575 DPRINT_ENTER(STORVSC);
@@ -633,8 +630,8 @@ StorVscOnHostReset(
633{ 630{
634 int ret=0; 631 int ret=0;
635 632
636 STORVSC_DEVICE *storDevice; 633 struct storvsc_device *storDevice;
637 STORVSC_REQUEST_EXTENSION *request; 634 struct storvsc_request_extension *request;
638 struct vstor_packet *vstorPacket; 635 struct vstor_packet *vstorPacket;
639 636
640 DPRINT_ENTER(STORVSC); 637 DPRINT_ENTER(STORVSC);
@@ -702,8 +699,8 @@ StorVscOnIORequest(
702 struct hv_storvsc_request *Request 699 struct hv_storvsc_request *Request
703 ) 700 )
704{ 701{
705 STORVSC_DEVICE *storDevice; 702 struct storvsc_device *storDevice;
706 STORVSC_REQUEST_EXTENSION* requestExtension = (STORVSC_REQUEST_EXTENSION*) Request->Extension; 703 struct storvsc_request_extension* requestExtension = (struct storvsc_request_extension*) Request->Extension;
707 struct vstor_packet *vstorPacket =&requestExtension->VStorPacket; 704 struct vstor_packet *vstorPacket =&requestExtension->VStorPacket;
708 int ret=0; 705 int ret=0;
709 706
@@ -814,11 +811,11 @@ static void
814StorVscOnIOCompletion( 811StorVscOnIOCompletion(
815 struct hv_device *Device, 812 struct hv_device *Device,
816 struct vstor_packet *VStorPacket, 813 struct vstor_packet *VStorPacket,
817 STORVSC_REQUEST_EXTENSION *RequestExt 814 struct storvsc_request_extension *RequestExt
818 ) 815 )
819{ 816{
820 struct hv_storvsc_request *request; 817 struct hv_storvsc_request *request;
821 STORVSC_DEVICE *storDevice; 818 struct storvsc_device *storDevice;
822 819
823 DPRINT_ENTER(STORVSC); 820 DPRINT_ENTER(STORVSC);
824 821
@@ -884,7 +881,7 @@ static void
884StorVscOnReceive( 881StorVscOnReceive(
885 struct hv_device *Device, 882 struct hv_device *Device,
886 struct vstor_packet *VStorPacket, 883 struct vstor_packet *VStorPacket,
887 STORVSC_REQUEST_EXTENSION *RequestExt 884 struct storvsc_request_extension *RequestExt
888 ) 885 )
889{ 886{
890 switch(VStorPacket->Operation) 887 switch(VStorPacket->Operation)
@@ -921,11 +918,11 @@ StorVscOnChannelCallback(
921{ 918{
922 int ret=0; 919 int ret=0;
923 struct hv_device *device = (struct hv_device*)Context; 920 struct hv_device *device = (struct hv_device*)Context;
924 STORVSC_DEVICE *storDevice; 921 struct storvsc_device *storDevice;
925 u32 bytesRecvd; 922 u32 bytesRecvd;
926 u64 requestId; 923 u64 requestId;
927 unsigned char packet[ALIGN_UP(sizeof(struct vstor_packet),8)]; 924 unsigned char packet[ALIGN_UP(sizeof(struct vstor_packet),8)];
928 STORVSC_REQUEST_EXTENSION *request; 925 struct storvsc_request_extension *request;
929 926
930 DPRINT_ENTER(STORVSC); 927 DPRINT_ENTER(STORVSC);
931 928
@@ -952,7 +949,7 @@ StorVscOnChannelCallback(
952 949
953 /* ASSERT(bytesRecvd == sizeof(struct vstor_packet)); */ 950 /* ASSERT(bytesRecvd == sizeof(struct vstor_packet)); */
954 951
955 request = (STORVSC_REQUEST_EXTENSION*)(unsigned long)requestId; 952 request = (struct storvsc_request_extension*)(unsigned long)requestId;
956 ASSERT(request); 953 ASSERT(request);
957 954
958 /* if (vstorPacket.Flags & SYNTHETIC_FLAG) */ 955 /* if (vstorPacket.Flags & SYNTHETIC_FLAG) */