Back to home page

LXR

 
 

    


0001 #include <linux/kernel.h>
0002 #include <linux/module.h>
0003 #include <linux/suspend.h>
0004 
0005 #include "notifier-error-inject.h"
0006 
0007 static int priority;
0008 module_param(priority, int, 0);
0009 MODULE_PARM_DESC(priority, "specify PM notifier priority");
0010 
0011 static struct notifier_err_inject pm_notifier_err_inject = {
0012     .actions = {
0013         { NOTIFIER_ERR_INJECT_ACTION(PM_HIBERNATION_PREPARE) },
0014         { NOTIFIER_ERR_INJECT_ACTION(PM_SUSPEND_PREPARE) },
0015         { NOTIFIER_ERR_INJECT_ACTION(PM_RESTORE_PREPARE) },
0016         {}
0017     }
0018 };
0019 
0020 static struct dentry *dir;
0021 
0022 static int err_inject_init(void)
0023 {
0024     int err;
0025 
0026     dir = notifier_err_inject_init("pm", notifier_err_inject_dir,
0027                     &pm_notifier_err_inject, priority);
0028     if (IS_ERR(dir))
0029         return PTR_ERR(dir);
0030 
0031     err = register_pm_notifier(&pm_notifier_err_inject.nb);
0032     if (err)
0033         debugfs_remove_recursive(dir);
0034 
0035     return err;
0036 }
0037 
0038 static void err_inject_exit(void)
0039 {
0040     unregister_pm_notifier(&pm_notifier_err_inject.nb);
0041     debugfs_remove_recursive(dir);
0042 }
0043 
0044 module_init(err_inject_init);
0045 module_exit(err_inject_exit);
0046 
0047 MODULE_DESCRIPTION("PM notifier error injection module");
0048 MODULE_LICENSE("GPL");
0049 MODULE_AUTHOR("Akinobu Mita <akinobu.mita@gmail.com>");