ARM: KVM: arch_timer: use symbolic constants
authorMark Rutland <mark.rutland@arm.com>
Wed, 27 Mar 2013 15:56:11 +0000 (15:56 +0000)
committerChristoffer Dall <cdall@cs.columbia.edu>
Mon, 29 Apr 2013 05:22:57 +0000 (22:22 -0700)
In clocksource/arm_arch_timer.h we define useful symbolic constants.
Let's use them to make the KVM arch_timer code clearer.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Cc: Christoffer Dall <cdall@cs.columbia.edu>
Signed-off-by: Christoffer Dall <cdall@cs.columbia.edu>
arch/arm/kvm/arch_timer.c

index 6ac938d46297d27a7217cee66ea1a245e9fead3a..c55b6089e923a1273a94c30856a2af8e9fd0dd79 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/kvm_host.h>
 #include <linux/interrupt.h>
 
+#include <clocksource/arm_arch_timer.h>
 #include <asm/arch_timer.h>
 
 #include <asm/kvm_vgic.h>
@@ -64,7 +65,7 @@ static void kvm_timer_inject_irq(struct kvm_vcpu *vcpu)
 {
        struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu;
 
-       timer->cntv_ctl |= 1 << 1; /* Mask the interrupt in the guest */
+       timer->cntv_ctl |= ARCH_TIMER_CTRL_IT_MASK;
        kvm_vgic_inject_irq(vcpu->kvm, vcpu->vcpu_id,
                            vcpu->arch.timer_cpu.irq->irq,
                            vcpu->arch.timer_cpu.irq->level);
@@ -133,8 +134,8 @@ void kvm_timer_sync_hwstate(struct kvm_vcpu *vcpu)
        cycle_t cval, now;
        u64 ns;
 
-       /* Check if the timer is enabled and unmasked first */
-       if ((timer->cntv_ctl & 3) != 1)
+       if ((timer->cntv_ctl & ARCH_TIMER_CTRL_IT_MASK) ||
+               !(timer->cntv_ctl & ARCH_TIMER_CTRL_ENABLE))
                return;
 
        cval = timer->cntv_cval;