diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2008-10-02 11:39:36 +0100 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2008-10-02 11:39:36 +0100 |
commit | 4a93b11b6753ae0e0afb93f7307b32543447253b (patch) | |
tree | db7770d40f9f05b0b12b12e5cb81707e86976e70 /xen/common/event_channel.c | |
parent | 668349f38be79d2bd197ff968d728090f6d14faa (diff) | |
download | xen-4a93b11b6753ae0e0afb93f7307b32543447253b.tar.gz xen-4a93b11b6753ae0e0afb93f7307b32543447253b.tar.bz2 xen-4a93b11b6753ae0e0afb93f7307b32543447253b.zip |
Eliminate code duplication with rcu_lock_domain_by_id().
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Diffstat (limited to 'xen/common/event_channel.c')
-rw-r--r-- | xen/common/event_channel.c | 51 |
1 files changed, 9 insertions, 42 deletions
diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c index 006d5eca3a..53dad7acc9 100644 --- a/xen/common/event_channel.c +++ b/xen/common/event_channel.c @@ -129,20 +129,9 @@ static long evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc) domid_t dom = alloc->dom; long rc; - if ( dom == DOMID_SELF ) - { - d = rcu_lock_current_domain(); - } - else - { - if ( (d = rcu_lock_domain_by_id(dom)) == NULL ) - return -ESRCH; - if ( !IS_PRIV_FOR(current->domain, d) ) - { - rcu_unlock_domain(d); - return -EPERM; - } - } + rc = rcu_lock_target_domain_by_id(dom, &d); + if ( rc ) + return rc; spin_lock(&d->evtchn_lock); @@ -663,20 +652,9 @@ static long evtchn_status(evtchn_status_t *status) struct evtchn *chn; long rc = 0; - if ( dom == DOMID_SELF ) - { - d = rcu_lock_current_domain(); - } - else - { - if ( (d = rcu_lock_domain_by_id(dom)) == NULL ) - return -ESRCH; - if ( !IS_PRIV_FOR(current->domain, d) ) - { - rcu_unlock_domain(d); - return -EPERM; - } - } + rc = rcu_lock_target_domain_by_id(dom, &d); + if ( rc ) + return rc; spin_lock(&d->evtchn_lock); @@ -824,20 +802,9 @@ static long evtchn_reset(evtchn_reset_t *r) struct domain *d; int i, rc; - if ( dom == DOMID_SELF ) - { - d = rcu_lock_current_domain(); - } - else - { - if ( (d = rcu_lock_domain_by_id(dom)) == NULL ) - return -ESRCH; - if ( !IS_PRIV_FOR(current->domain, d) ) - { - rc = -EPERM; - goto out; - } - } + rc = rcu_lock_target_domain_by_id(dom, &d); + if ( rc ) + return rc; rc = xsm_evtchn_reset(current->domain, d); if ( rc ) |