aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAnnie Li <annie.li@oracle.com>2011-11-21 20:58:47 -0500
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2011-11-22 09:24:00 -0500
commitb1e495b2fae578b1bd3ab1906cb15aac43f96fee (patch)
tree5e0495f8a27465b0f43981518060d5301b8b9845 /drivers
parent0f9f5a9588468cddeccc9146b86798492c7cd4f5 (diff)
xen/granttable: Refactor some code
Acked-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Annie Li <annie.li@oracle.com> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/xen/grant-table.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index 18355a53763f..0518d0404942 100644
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -257,15 +257,17 @@ EXPORT_SYMBOL_GPL(gnttab_query_foreign_access);
257static int gnttab_end_foreign_access_ref_v1(grant_ref_t ref, int readonly) 257static int gnttab_end_foreign_access_ref_v1(grant_ref_t ref, int readonly)
258{ 258{
259 u16 flags, nflags; 259 u16 flags, nflags;
260 u16 *pflags;
260 261
261 nflags = gnttab_shared.v1[ref].flags; 262 pflags = &gnttab_shared.v1[ref].flags;
263 nflags = *pflags;
262 do { 264 do {
263 flags = nflags; 265 flags = nflags;
264 if (flags & (GTF_reading|GTF_writing)) { 266 if (flags & (GTF_reading|GTF_writing)) {
265 printk(KERN_ALERT "WARNING: g.e. still in use!\n"); 267 printk(KERN_ALERT "WARNING: g.e. still in use!\n");
266 return 0; 268 return 0;
267 } 269 }
268 } while ((nflags = sync_cmpxchg(&gnttab_shared.v1[ref].flags, flags, 0)) != flags); 270 } while ((nflags = sync_cmpxchg(pflags, flags, 0)) != flags);
269 271
270 return 1; 272 return 1;
271} 273}
@@ -316,20 +318,23 @@ static unsigned long gnttab_end_foreign_transfer_ref_v1(grant_ref_t ref)
316{ 318{
317 unsigned long frame; 319 unsigned long frame;
318 u16 flags; 320 u16 flags;
321 u16 *pflags;
322
323 pflags = &gnttab_shared.v1[ref].flags;
319 324
320 /* 325 /*
321 * If a transfer is not even yet started, try to reclaim the grant 326 * If a transfer is not even yet started, try to reclaim the grant
322 * reference and return failure (== 0). 327 * reference and return failure (== 0).
323 */ 328 */
324 while (!((flags = gnttab_shared.v1[ref].flags) & GTF_transfer_committed)) { 329 while (!((flags = *pflags) & GTF_transfer_committed)) {
325 if (sync_cmpxchg(&gnttab_shared.v1[ref].flags, flags, 0) == flags) 330 if (sync_cmpxchg(pflags, flags, 0) == flags)
326 return 0; 331 return 0;
327 cpu_relax(); 332 cpu_relax();
328 } 333 }
329 334
330 /* If a transfer is in progress then wait until it is completed. */ 335 /* If a transfer is in progress then wait until it is completed. */
331 while (!(flags & GTF_transfer_completed)) { 336 while (!(flags & GTF_transfer_completed)) {
332 flags = gnttab_shared.v1[ref].flags; 337 flags = *pflags;
333 cpu_relax(); 338 cpu_relax();
334 } 339 }
335 340