2019-05-19 12:08:20 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2012-07-30 21:43:13 +00:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
2012-12-13 23:32:52 +00:00
|
|
|
#include <linux/of.h>
|
2012-07-30 21:43:13 +00:00
|
|
|
|
|
|
|
#include "notifier-error-inject.h"
|
|
|
|
|
|
|
|
static int priority;
|
|
|
|
module_param(priority, int, 0);
|
2012-12-13 23:32:52 +00:00
|
|
|
MODULE_PARM_DESC(priority, "specify OF reconfig notifier priority");
|
2012-07-30 21:43:13 +00:00
|
|
|
|
|
|
|
static struct notifier_err_inject reconfig_err_inject = {
|
|
|
|
.actions = {
|
2012-12-13 23:32:52 +00:00
|
|
|
{ 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) },
|
2012-07-30 21:43:13 +00:00
|
|
|
{}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct dentry *dir;
|
|
|
|
|
|
|
|
static int err_inject_init(void)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
2012-12-13 23:32:52 +00:00
|
|
|
dir = notifier_err_inject_init("OF-reconfig",
|
2012-07-30 21:43:13 +00:00
|
|
|
notifier_err_inject_dir, &reconfig_err_inject, priority);
|
|
|
|
if (IS_ERR(dir))
|
|
|
|
return PTR_ERR(dir);
|
|
|
|
|
2012-12-13 23:32:52 +00:00
|
|
|
err = of_reconfig_notifier_register(&reconfig_err_inject.nb);
|
2012-07-30 21:43:13 +00:00
|
|
|
if (err)
|
|
|
|
debugfs_remove_recursive(dir);
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void err_inject_exit(void)
|
|
|
|
{
|
2012-12-13 23:32:52 +00:00
|
|
|
of_reconfig_notifier_unregister(&reconfig_err_inject.nb);
|
2012-07-30 21:43:13 +00:00
|
|
|
debugfs_remove_recursive(dir);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(err_inject_init);
|
|
|
|
module_exit(err_inject_exit);
|
|
|
|
|
2012-12-13 23:32:52 +00:00
|
|
|
MODULE_DESCRIPTION("OF reconfig notifier error injection module");
|
2012-07-30 21:43:13 +00:00
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_AUTHOR("Akinobu Mita <akinobu.mita@gmail.com>");
|