Skip to contentSkip to conversation

riscv-v: kvm: Make kvm_riscv_guest_timer_init a void function

PATCH New Nikolay Borisov 2 participants 2 messages Jul 1, 2022 – Jul 4, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 riscv-v: kvm: Make kvm_riscv_guest_timer_init a void function

It can never fail so convey that fact explicitly by making the function void. Also in kvm_arch_init_vm it makes it clear that there no need to do any cleanup after kvm_riscv_gstage_vmid_init has been called.

---
 arch/riscv/include/asm/kvm_vcpu_timer.h | 2 +-
 arch/riscv/kvm/vcpu_timer.c             | 4 +---
 arch/riscv/kvm/vm.c                     | 4 +++-
 3 files changed, 5 insertions(+), 5 deletions(-)
arch/riscv/include/asm/kvm_vcpu_timer.h +1 -1
index 375281eb49e0..50138e2eb91b 100644
@@ -39,6 +39,6 @@ int kvm_riscv_vcpu_timer_init(struct kvm_vcpu *vcpu);
 int kvm_riscv_vcpu_timer_deinit(struct kvm_vcpu *vcpu);
 int kvm_riscv_vcpu_timer_reset(struct kvm_vcpu *vcpu);
 void kvm_riscv_vcpu_timer_restore(struct kvm_vcpu *vcpu);
-int kvm_riscv_guest_timer_init(struct kvm *kvm);
+void kvm_riscv_guest_timer_init(struct kvm *kvm);
 
 #endif
arch/riscv/kvm/vcpu_timer.c +1 -3
index 5c4c37ff2d48..595043857049 100644
@@ -214,12 +214,10 @@ void kvm_riscv_vcpu_timer_restore(struct kvm_vcpu *vcpu)
 #endif
 }
 
-int kvm_riscv_guest_timer_init(struct kvm *kvm)
+void kvm_riscv_guest_timer_init(struct kvm *kvm)
 {
 	struct kvm_guest_timer *gt = &kvm->arch.timer;
 
 	riscv_cs_get_mult_shift(&gt->nsec_mult, &gt->nsec_shift);
 	gt->time_delta = -get_cycles64();
-
-	return 0;
 }
arch/riscv/kvm/vm.c +3 -1
index 945a2bf5e3f6..65a964d7e70d 100644
@@ -41,7 +41,9 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
 		return r;
 	}
 
-	return kvm_riscv_guest_timer_init(kvm);
+	kvm_riscv_guest_timer_init(kvm);
+
+	return 0;
 }
 
 void kvm_arch_destroy_vm(struct kvm *kvm)
Signature · 1 line
2.25.1
maintainer
#1 lore raw

PATCH 1/1 riscv-v: kvm: Make kvm_riscv_guest_timer_init a void function

Quoted 6 lines · Nikolay Borisov

It can never fail so convey that fact explicitly by making the function void. Also in kvm_arch_init_vm it makes it clear that there no need to do any cleanup after kvm_riscv_gstage_vmid_init has been called.

Minor typo in patch subject. It should have prefix "riscv: kvm:".

I have taken care of above typo and queued it for 5.20

Thanks,
Anup

Quoted 54 lines
---
 arch/riscv/include/asm/kvm_vcpu_timer.h | 2 +-
 arch/riscv/kvm/vcpu_timer.c             | 4 +---
 arch/riscv/kvm/vm.c                     | 4 +++-
 3 files changed, 5 insertions(+), 5 deletions(-)
arch/riscv/include/asm/kvm_vcpu_timer.h +1 -1
index 375281eb49e0..50138e2eb91b 100644
@@ -39,6 +39,6 @@ int kvm_riscv_vcpu_timer_init(struct kvm_vcpu *vcpu);
 int kvm_riscv_vcpu_timer_deinit(struct kvm_vcpu *vcpu);
 int kvm_riscv_vcpu_timer_reset(struct kvm_vcpu *vcpu);
 void kvm_riscv_vcpu_timer_restore(struct kvm_vcpu *vcpu);
-int kvm_riscv_guest_timer_init(struct kvm *kvm);
+void kvm_riscv_guest_timer_init(struct kvm *kvm);
 
 #endif
arch/riscv/kvm/vcpu_timer.c +1 -3
index 5c4c37ff2d48..595043857049 100644
@@ -214,12 +214,10 @@ void kvm_riscv_vcpu_timer_restore(struct kvm_vcpu *vcpu)
 #endif
 }
 
-int kvm_riscv_guest_timer_init(struct kvm *kvm)
+void kvm_riscv_guest_timer_init(struct kvm *kvm)
 {
        struct kvm_guest_timer *gt = &kvm->arch.timer;
 
        riscv_cs_get_mult_shift(&gt->nsec_mult, &gt->nsec_shift);
        gt->time_delta = -get_cycles64();
-
-       return 0;
 }
arch/riscv/kvm/vm.c +3 -2
index 945a2bf5e3f6..65a964d7e70d 100644
@@ -41,7 +41,9 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
                return r;
        }
 
-       return kvm_riscv_guest_timer_init(kvm);
+       kvm_riscv_guest_timer_init(kvm);
+
+       return 0;
 }
 
 void kvm_arch_destroy_vm(struct kvm *kvm)
--

2.25.1