KVM: i8254: refactor kvm_free_pit
authorRadim Krčmář <rkrcmar@redhat.com>
Wed, 2 Mar 2016 21:56:47 +0000 (22:56 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 4 Mar 2016 08:30:07 +0000 (09:30 +0100)
Could be easier to read, but git history will become deeper.

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/i8254.c

index c24735ae1871f3a1e893325056cd261a6043fcf3..055018e833b6354d1fc116c3d35ebe1c8f7852b3 100644 (file)
@@ -738,18 +738,16 @@ fail_request:
 
 void kvm_free_pit(struct kvm *kvm)
 {
-       struct hrtimer *timer;
-
-       if (kvm->arch.vpit) {
-               kvm_io_bus_unregister_dev(kvm, KVM_PIO_BUS, &kvm->arch.vpit->dev);
-               kvm_io_bus_unregister_dev(kvm, KVM_PIO_BUS,
-                                             &kvm->arch.vpit->speaker_dev);
-               kvm_pit_set_reinject(kvm->arch.vpit, false);
-               timer = &kvm->arch.vpit->pit_state.timer;
-               hrtimer_cancel(timer);
-               flush_kthread_work(&kvm->arch.vpit->expired);
-               kthread_stop(kvm->arch.vpit->worker_task);
-               kvm_free_irq_source_id(kvm, kvm->arch.vpit->irq_source_id);
-               kfree(kvm->arch.vpit);
+       struct kvm_pit *pit = kvm->arch.vpit;
+
+       if (pit) {
+               kvm_io_bus_unregister_dev(kvm, KVM_PIO_BUS, &pit->dev);
+               kvm_io_bus_unregister_dev(kvm, KVM_PIO_BUS, &pit->speaker_dev);
+               kvm_pit_set_reinject(pit, false);
+               hrtimer_cancel(&pit->pit_state.timer);
+               flush_kthread_work(&pit->expired);
+               kthread_stop(pit->worker_task);
+               kvm_free_irq_source_id(kvm, pit->irq_source_id);
+               kfree(pit);
        }
 }