Commit 08e5ccf3 authored by Radim Krčmář's avatar Radim Krčmář Committed by Paolo Bonzini

KVM: i8254: refactor kvm_free_pit

Could be easier to read, but git history will become deeper.
Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: default avatarRadim Krčmář <rkrcmar@redhat.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 10d24821
...@@ -738,18 +738,16 @@ struct kvm_pit *kvm_create_pit(struct kvm *kvm, u32 flags) ...@@ -738,18 +738,16 @@ struct kvm_pit *kvm_create_pit(struct kvm *kvm, u32 flags)
void kvm_free_pit(struct kvm *kvm) void kvm_free_pit(struct kvm *kvm)
{ {
struct hrtimer *timer; struct kvm_pit *pit = kvm->arch.vpit;
if (kvm->arch.vpit) { if (pit) {
kvm_io_bus_unregister_dev(kvm, KVM_PIO_BUS, &kvm->arch.vpit->dev); kvm_io_bus_unregister_dev(kvm, KVM_PIO_BUS, &pit->dev);
kvm_io_bus_unregister_dev(kvm, KVM_PIO_BUS, kvm_io_bus_unregister_dev(kvm, KVM_PIO_BUS, &pit->speaker_dev);
&kvm->arch.vpit->speaker_dev); kvm_pit_set_reinject(pit, false);
kvm_pit_set_reinject(kvm->arch.vpit, false); hrtimer_cancel(&pit->pit_state.timer);
timer = &kvm->arch.vpit->pit_state.timer; flush_kthread_work(&pit->expired);
hrtimer_cancel(timer); kthread_stop(pit->worker_task);
flush_kthread_work(&kvm->arch.vpit->expired); kvm_free_irq_source_id(kvm, pit->irq_source_id);
kthread_stop(kvm->arch.vpit->worker_task); kfree(pit);
kvm_free_irq_source_id(kvm, kvm->arch.vpit->irq_source_id);
kfree(kvm->arch.vpit);
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment