blob: 707ca24f7b187f4c2f18f590e1eee298fcdadcb3 [file] [log] [blame]
Akinobu Mitac9d221f2010-05-26 14:43:36 -07001#include <linux/kernel.h>
Akinobu Mitac9d221f2010-05-26 14:43:36 -07002#include <linux/module.h>
Akinobu Mitaf5a9f522012-07-30 14:43:03 -07003#include <linux/cpu.h>
4
5#include "notifier-error-inject.h"
Akinobu Mitac9d221f2010-05-26 14:43:36 -07006
7static int priority;
Akinobu Mitac9d221f2010-05-26 14:43:36 -07008module_param(priority, int, 0);
9MODULE_PARM_DESC(priority, "specify cpu notifier priority");
10
Akinobu Mitaf5a9f522012-07-30 14:43:03 -070011static struct notifier_err_inject cpu_notifier_err_inject = {
12 .actions = {
13 { NOTIFIER_ERR_INJECT_ACTION(CPU_UP_PREPARE) },
14 { NOTIFIER_ERR_INJECT_ACTION(CPU_UP_PREPARE_FROZEN) },
15 { NOTIFIER_ERR_INJECT_ACTION(CPU_DOWN_PREPARE) },
16 { NOTIFIER_ERR_INJECT_ACTION(CPU_DOWN_PREPARE_FROZEN) },
17 {}
Akinobu Mitac9d221f2010-05-26 14:43:36 -070018 }
Akinobu Mitac9d221f2010-05-26 14:43:36 -070019};
20
Akinobu Mitaf5a9f522012-07-30 14:43:03 -070021static struct dentry *dir;
22
Akinobu Mitac9d221f2010-05-26 14:43:36 -070023static int err_inject_init(void)
24{
Akinobu Mitaf5a9f522012-07-30 14:43:03 -070025 int err;
Akinobu Mitac9d221f2010-05-26 14:43:36 -070026
Akinobu Mitaf5a9f522012-07-30 14:43:03 -070027 dir = notifier_err_inject_init("cpu", notifier_err_inject_dir,
28 &cpu_notifier_err_inject, priority);
29 if (IS_ERR(dir))
30 return PTR_ERR(dir);
31
32 err = register_hotcpu_notifier(&cpu_notifier_err_inject.nb);
33 if (err)
34 debugfs_remove_recursive(dir);
35
36 return err;
Akinobu Mitac9d221f2010-05-26 14:43:36 -070037}
38
39static void err_inject_exit(void)
40{
Akinobu Mitaf5a9f522012-07-30 14:43:03 -070041 unregister_hotcpu_notifier(&cpu_notifier_err_inject.nb);
42 debugfs_remove_recursive(dir);
Akinobu Mitac9d221f2010-05-26 14:43:36 -070043}
44
45module_init(err_inject_init);
46module_exit(err_inject_exit);
47
48MODULE_DESCRIPTION("CPU notifier error injection module");
49MODULE_LICENSE("GPL");
50MODULE_AUTHOR("Akinobu Mita <akinobu.mita@gmail.com>");