diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2015-03-05 06:26:06 -0500 |
---|---|---|
committer | Christoffer Dall <christoffer.dall@linaro.org> | 2015-03-11 10:27:55 -0400 |
commit | 69ff5c619cb350f43fbab2a491b4b66de7e96959 (patch) | |
tree | ecd6f15b868c9844e1b75656b0f601f4304ad98d /arch | |
parent | 0f37247574b3ef5b130116bbf7c0f9eb8a4c78c2 (diff) |
KVM: arm/arm64: prefer IS_ENABLED to a static variable
IS_ENABLED gives compile-time checking and keeps the code clearer.
The one exception is inside kvm_vm_ioctl_check_extension, where
the established idiom is to wrap the case labels with an #ifdef.
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/kvm/arm.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c index 5560f74f9eee..e0e9434e4869 100644 --- a/arch/arm/kvm/arm.c +++ b/arch/arm/kvm/arm.c | |||
@@ -61,8 +61,6 @@ static atomic64_t kvm_vmid_gen = ATOMIC64_INIT(1); | |||
61 | static u8 kvm_next_vmid; | 61 | static u8 kvm_next_vmid; |
62 | static DEFINE_SPINLOCK(kvm_vmid_lock); | 62 | static DEFINE_SPINLOCK(kvm_vmid_lock); |
63 | 63 | ||
64 | static bool vgic_present; | ||
65 | |||
66 | static void kvm_arm_set_running_vcpu(struct kvm_vcpu *vcpu) | 64 | static void kvm_arm_set_running_vcpu(struct kvm_vcpu *vcpu) |
67 | { | 65 | { |
68 | BUG_ON(preemptible()); | 66 | BUG_ON(preemptible()); |
@@ -172,9 +170,9 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext) | |||
172 | { | 170 | { |
173 | int r; | 171 | int r; |
174 | switch (ext) { | 172 | switch (ext) { |
173 | #ifdef CONFIG_KVM_ARM_VGIC | ||
175 | case KVM_CAP_IRQCHIP: | 174 | case KVM_CAP_IRQCHIP: |
176 | r = vgic_present; | 175 | #endif |
177 | break; | ||
178 | case KVM_CAP_DEVICE_CTRL: | 176 | case KVM_CAP_DEVICE_CTRL: |
179 | case KVM_CAP_USER_MEMORY: | 177 | case KVM_CAP_USER_MEMORY: |
180 | case KVM_CAP_SYNC_MMU: | 178 | case KVM_CAP_SYNC_MMU: |
@@ -831,7 +829,7 @@ static int kvm_vm_ioctl_set_device_addr(struct kvm *kvm, | |||
831 | 829 | ||
832 | switch (dev_id) { | 830 | switch (dev_id) { |
833 | case KVM_ARM_DEVICE_VGIC_V2: | 831 | case KVM_ARM_DEVICE_VGIC_V2: |
834 | if (!vgic_present) | 832 | if (!IS_ENABLED(CONFIG_KVM_ARM_VGIC)) |
835 | return -ENXIO; | 833 | return -ENXIO; |
836 | return kvm_vgic_addr(kvm, type, &dev_addr->addr, true); | 834 | return kvm_vgic_addr(kvm, type, &dev_addr->addr, true); |
837 | default: | 835 | default: |
@@ -847,10 +845,9 @@ long kvm_arch_vm_ioctl(struct file *filp, | |||
847 | 845 | ||
848 | switch (ioctl) { | 846 | switch (ioctl) { |
849 | case KVM_CREATE_IRQCHIP: { | 847 | case KVM_CREATE_IRQCHIP: { |
850 | if (vgic_present) | 848 | if (!IS_ENABLED(CONFIG_KVM_ARM_VGIC)) |
851 | return kvm_vgic_create(kvm, KVM_DEV_TYPE_ARM_VGIC_V2); | ||
852 | else | ||
853 | return -ENXIO; | 849 | return -ENXIO; |
850 | return kvm_vgic_create(kvm, KVM_DEV_TYPE_ARM_VGIC_V2); | ||
854 | } | 851 | } |
855 | case KVM_ARM_SET_DEVICE_ADDR: { | 852 | case KVM_ARM_SET_DEVICE_ADDR: { |
856 | struct kvm_arm_device_addr dev_addr; | 853 | struct kvm_arm_device_addr dev_addr; |
@@ -1035,10 +1032,6 @@ static int init_hyp_mode(void) | |||
1035 | if (err) | 1032 | if (err) |
1036 | goto out_free_context; | 1033 | goto out_free_context; |
1037 | 1034 | ||
1038 | #ifdef CONFIG_KVM_ARM_VGIC | ||
1039 | vgic_present = true; | ||
1040 | #endif | ||
1041 | |||
1042 | /* | 1035 | /* |
1043 | * Init HYP architected timer support | 1036 | * Init HYP architected timer support |
1044 | */ | 1037 | */ |