KVM: Use syscore_ops instead of sysdev class and sysdev

KVM uses a sysdev class and a sysdev for executing kvm_suspend()
after interrupts have been turned off on the boot CPU (during system
suspend) and for executing kvm_resume() before turning on interrupts
on the boot CPU (during system resume). However, since both of these
functions ignore their arguments, the entire mechanism may be
replaced with a struct syscore_ops object which is simpler.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Avi Kivity <avi@redhat.com>

+8 -26
+8 -26
virt/kvm/kvm_main.c
··· 30 30 #include <linux/debugfs.h> 31 31 #include <linux/highmem.h> 32 32 #include <linux/file.h> 33 - #include <linux/sysdev.h> 33 + #include <linux/syscore_ops.h> 34 34 #include <linux/cpu.h> 35 35 #include <linux/sched.h> 36 36 #include <linux/cpumask.h> ··· 2447 2447 debugfs_remove(kvm_debugfs_dir); 2448 2448 } 2449 2449 2450 - static int kvm_suspend(struct sys_device *dev, pm_message_t state) 2450 + static int kvm_suspend(void) 2451 2451 { 2452 2452 if (kvm_usage_count) 2453 2453 hardware_disable_nolock(NULL); 2454 2454 return 0; 2455 2455 } 2456 2456 2457 - static int kvm_resume(struct sys_device *dev) 2457 + static void kvm_resume(void) 2458 2458 { 2459 2459 if (kvm_usage_count) { 2460 2460 WARN_ON(raw_spin_is_locked(&kvm_lock)); 2461 2461 hardware_enable_nolock(NULL); 2462 2462 } 2463 - return 0; 2464 2463 } 2465 2464 2466 - static struct sysdev_class kvm_sysdev_class = { 2467 - .name = "kvm", 2465 + static struct syscore_ops kvm_syscore_ops = { 2468 2466 .suspend = kvm_suspend, 2469 2467 .resume = kvm_resume, 2470 - }; 2471 - 2472 - static struct sys_device kvm_sysdev = { 2473 - .id = 0, 2474 - .cls = &kvm_sysdev_class, 2475 2468 }; 2476 2469 2477 2470 struct page *bad_page; ··· 2550 2557 goto out_free_2; 2551 2558 register_reboot_notifier(&kvm_reboot_notifier); 2552 2559 2553 - r = sysdev_class_register(&kvm_sysdev_class); 2554 - if (r) 2555 - goto out_free_3; 2556 - 2557 - r = sysdev_register(&kvm_sysdev); 2558 - if (r) 2559 - goto out_free_4; 2560 - 2561 2560 /* A kmem cache lets us meet the alignment requirements of fx_save. */ 2562 2561 if (!vcpu_align) 2563 2562 vcpu_align = __alignof__(struct kvm_vcpu); ··· 2557 2572 0, NULL); 2558 2573 if (!kvm_vcpu_cache) { 2559 2574 r = -ENOMEM; 2560 - goto out_free_5; 2575 + goto out_free_3; 2561 2576 } 2562 2577 2563 2578 r = kvm_async_pf_init(); ··· 2574 2589 goto out_unreg; 2575 2590 } 2576 2591 2592 + register_syscore_ops(&kvm_syscore_ops); 2593 + 2577 2594 kvm_preempt_ops.sched_in = kvm_sched_in; 2578 2595 kvm_preempt_ops.sched_out = kvm_sched_out; 2579 2596 ··· 2587 2600 kvm_async_pf_deinit(); 2588 2601 out_free: 2589 2602 kmem_cache_destroy(kvm_vcpu_cache); 2590 - out_free_5: 2591 - sysdev_unregister(&kvm_sysdev); 2592 - out_free_4: 2593 - sysdev_class_unregister(&kvm_sysdev_class); 2594 2603 out_free_3: 2595 2604 unregister_reboot_notifier(&kvm_reboot_notifier); 2596 2605 unregister_cpu_notifier(&kvm_cpu_notifier); ··· 2614 2631 misc_deregister(&kvm_dev); 2615 2632 kmem_cache_destroy(kvm_vcpu_cache); 2616 2633 kvm_async_pf_deinit(); 2617 - sysdev_unregister(&kvm_sysdev); 2618 - sysdev_class_unregister(&kvm_sysdev_class); 2634 + unregister_syscore_ops(&kvm_syscore_ops); 2619 2635 unregister_reboot_notifier(&kvm_reboot_notifier); 2620 2636 unregister_cpu_notifier(&kvm_cpu_notifier); 2621 2637 on_each_cpu(hardware_disable_nolock, NULL, 1);