^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #include <linux/of.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include "notifier-error-inject.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) static int priority;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) module_param(priority, int, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) MODULE_PARM_DESC(priority, "specify OF reconfig notifier priority");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) static struct notifier_err_inject reconfig_err_inject = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) .actions = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) { NOTIFIER_ERR_INJECT_ACTION(OF_RECONFIG_ATTACH_NODE) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) { NOTIFIER_ERR_INJECT_ACTION(OF_RECONFIG_DETACH_NODE) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) { NOTIFIER_ERR_INJECT_ACTION(OF_RECONFIG_ADD_PROPERTY) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) { NOTIFIER_ERR_INJECT_ACTION(OF_RECONFIG_REMOVE_PROPERTY) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) { NOTIFIER_ERR_INJECT_ACTION(OF_RECONFIG_UPDATE_PROPERTY) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) static struct dentry *dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) static int err_inject_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) dir = notifier_err_inject_init("OF-reconfig",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) notifier_err_inject_dir, &reconfig_err_inject, priority);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) if (IS_ERR(dir))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) return PTR_ERR(dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) err = of_reconfig_notifier_register(&reconfig_err_inject.nb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) debugfs_remove_recursive(dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) static void err_inject_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) of_reconfig_notifier_unregister(&reconfig_err_inject.nb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) debugfs_remove_recursive(dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) module_init(err_inject_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) module_exit(err_inject_exit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) MODULE_DESCRIPTION("OF reconfig notifier error injection module");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) MODULE_AUTHOR("Akinobu Mita <akinobu.mita@gmail.com>");