aboutsummaryrefslogtreecommitdiffstats
path: root/xen/arch/x86/hpet.c
diff options
context:
space:
mode:
authorJan Beulich <jbeulich@suse.com>2012-03-23 16:13:29 +0100
committerJan Beulich <jbeulich@suse.com>2012-03-23 16:13:29 +0100
commit0f049e6e2b4919250b1c66fabdbf8d812aa43880 (patch)
treed792ba4075f0a3b0d4a4374ba15c52e7afde4f0d /xen/arch/x86/hpet.c
parente02af69dc20d4a9319fb6992be3d5bc3e41b49ab (diff)
downloadxen-0f049e6e2b4919250b1c66fabdbf8d812aa43880.tar.gz
xen-0f049e6e2b4919250b1c66fabdbf8d812aa43880.tar.bz2
xen-0f049e6e2b4919250b1c66fabdbf8d812aa43880.zip
x86/hpet: simplify hpet_get_channel()
There's no need for a lock here, elimination of which makes the function a leaf one, thus allowing for better (and smaller) code. Further, use the variable next_channel according to its name - so far it represented the most recently used channel rather than the next one to use. Signed-off-by: Jan Beulich <jbeulich@suse.com> Acked-by: Keir Fraser <keir@xen.org>
Diffstat (limited to 'xen/arch/x86/hpet.c')
-rw-r--r--xen/arch/x86/hpet.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/xen/arch/x86/hpet.c b/xen/arch/x86/hpet.c
index b17cd07497..8ead34be60 100644
--- a/xen/arch/x86/hpet.c
+++ b/xen/arch/x86/hpet.c
@@ -402,16 +402,17 @@ static void __init hpet_fsb_cap_lookup(void)
static struct hpet_event_channel *hpet_get_channel(unsigned int cpu)
{
static unsigned int next_channel;
- static spinlock_t next_lock = SPIN_LOCK_UNLOCKED;
unsigned int i, next;
struct hpet_event_channel *ch;
if ( num_hpets_used == 0 )
return hpet_events;
- spin_lock(&next_lock);
- next = next_channel = (next_channel + 1) % num_hpets_used;
- spin_unlock(&next_lock);
+ do {
+ next = next_channel;
+ if ( (i = next + 1) == num_hpets_used )
+ i = 0;
+ } while ( cmpxchg(&next_channel, next, i) != next );
/* try unused channel first */
for ( i = next; i < next + num_hpets_used; i++ )