of-reconfig-notifier-error-inject.c 1.27 KB
Newer Older
1 2
#include <linux/kernel.h>
#include <linux/module.h>
3
#include <linux/of.h>
4 5 6 7 8

#include "notifier-error-inject.h"

static int priority;
module_param(priority, int, 0);
9
MODULE_PARM_DESC(priority, "specify OF reconfig notifier priority");
10 11 12

static struct notifier_err_inject reconfig_err_inject = {
	.actions = {
13 14 15 16 17
		{ NOTIFIER_ERR_INJECT_ACTION(OF_RECONFIG_ATTACH_NODE) },
		{ NOTIFIER_ERR_INJECT_ACTION(OF_RECONFIG_DETACH_NODE) },
		{ NOTIFIER_ERR_INJECT_ACTION(OF_RECONFIG_ADD_PROPERTY) },
		{ NOTIFIER_ERR_INJECT_ACTION(OF_RECONFIG_REMOVE_PROPERTY) },
		{ NOTIFIER_ERR_INJECT_ACTION(OF_RECONFIG_UPDATE_PROPERTY) },
18 19 20 21 22 23 24 25 26 27
		{}
	}
};

static struct dentry *dir;

static int err_inject_init(void)
{
	int err;

28
	dir = notifier_err_inject_init("OF-reconfig",
29 30 31 32
		notifier_err_inject_dir, &reconfig_err_inject, priority);
	if (IS_ERR(dir))
		return PTR_ERR(dir);

33
	err = of_reconfig_notifier_register(&reconfig_err_inject.nb);
34 35 36 37 38 39 40 41
	if (err)
		debugfs_remove_recursive(dir);

	return err;
}

static void err_inject_exit(void)
{
42
	of_reconfig_notifier_unregister(&reconfig_err_inject.nb);
43 44 45 46 47 48
	debugfs_remove_recursive(dir);
}

module_init(err_inject_init);
module_exit(err_inject_exit);

49
MODULE_DESCRIPTION("OF reconfig notifier error injection module");
50 51
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Akinobu Mita <akinobu.mita@gmail.com>");