summaryrefslogtreecommitdiff
path: root/drivers/xen
diff options
context:
space:
mode:
authorAnnie Li <annie.li@oracle.com>2011-11-22 09:58:47 +0800
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2011-11-22 09:24:00 -0500
commitb1e495b2fae578b1bd3ab1906cb15aac43f96fee (patch)
tree5e0495f8a27465b0f43981518060d5301b8b9845 /drivers/xen
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/xen')
-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);
static int gnttab_end_foreign_access_ref_v1(grant_ref_t ref, int readonly)
{
u16 flags, nflags;
+ u16 *pflags;
- nflags = gnttab_shared.v1[ref].flags;
+ pflags = &gnttab_shared.v1[ref].flags;
+ nflags = *pflags;
do {
flags = nflags;
if (flags & (GTF_reading|GTF_writing)) {
printk(KERN_ALERT "WARNING: g.e. still in use!\n");
return 0;
}
- } while ((nflags = sync_cmpxchg(&gnttab_shared.v1[ref].flags, flags, 0)) != flags);
+ } while ((nflags = sync_cmpxchg(pflags, flags, 0)) != flags);
return 1;
}
@@ -316,20 +318,23 @@ static unsigned long gnttab_end_foreign_transfer_ref_v1(grant_ref_t ref)
{
unsigned long frame;
u16 flags;
+ u16 *pflags;
+
+ pflags = &gnttab_shared.v1[ref].flags;
/*
* If a transfer is not even yet started, try to reclaim the grant
* reference and return failure (== 0).
*/
- while (!((flags = gnttab_shared.v1[ref].flags) & GTF_transfer_committed)) {
- if (sync_cmpxchg(&gnttab_shared.v1[ref].flags, flags, 0) == flags)
+ while (!((flags = *pflags) & GTF_transfer_committed)) {
+ if (sync_cmpxchg(pflags, flags, 0) == flags)
return 0;
cpu_relax();
}
/* If a transfer is in progress then wait until it is completed. */
while (!(flags & GTF_transfer_completed)) {
- flags = gnttab_shared.v1[ref].flags;
+ flags = *pflags;
cpu_relax();
}