18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_ci#include <linux/kernel.h> 38c2ecf20Sopenharmony_ci#include <linux/module.h> 48c2ecf20Sopenharmony_ci#include <linux/of.h> 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#include "notifier-error-inject.h" 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_cistatic int priority; 98c2ecf20Sopenharmony_cimodule_param(priority, int, 0); 108c2ecf20Sopenharmony_ciMODULE_PARM_DESC(priority, "specify OF reconfig notifier priority"); 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_cistatic struct notifier_err_inject reconfig_err_inject = { 138c2ecf20Sopenharmony_ci .actions = { 148c2ecf20Sopenharmony_ci { NOTIFIER_ERR_INJECT_ACTION(OF_RECONFIG_ATTACH_NODE) }, 158c2ecf20Sopenharmony_ci { NOTIFIER_ERR_INJECT_ACTION(OF_RECONFIG_DETACH_NODE) }, 168c2ecf20Sopenharmony_ci { NOTIFIER_ERR_INJECT_ACTION(OF_RECONFIG_ADD_PROPERTY) }, 178c2ecf20Sopenharmony_ci { NOTIFIER_ERR_INJECT_ACTION(OF_RECONFIG_REMOVE_PROPERTY) }, 188c2ecf20Sopenharmony_ci { NOTIFIER_ERR_INJECT_ACTION(OF_RECONFIG_UPDATE_PROPERTY) }, 198c2ecf20Sopenharmony_ci {} 208c2ecf20Sopenharmony_ci } 218c2ecf20Sopenharmony_ci}; 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_cistatic struct dentry *dir; 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_cistatic int err_inject_init(void) 268c2ecf20Sopenharmony_ci{ 278c2ecf20Sopenharmony_ci int err; 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci dir = notifier_err_inject_init("OF-reconfig", 308c2ecf20Sopenharmony_ci notifier_err_inject_dir, &reconfig_err_inject, priority); 318c2ecf20Sopenharmony_ci if (IS_ERR(dir)) 328c2ecf20Sopenharmony_ci return PTR_ERR(dir); 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci err = of_reconfig_notifier_register(&reconfig_err_inject.nb); 358c2ecf20Sopenharmony_ci if (err) 368c2ecf20Sopenharmony_ci debugfs_remove_recursive(dir); 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci return err; 398c2ecf20Sopenharmony_ci} 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_cistatic void err_inject_exit(void) 428c2ecf20Sopenharmony_ci{ 438c2ecf20Sopenharmony_ci of_reconfig_notifier_unregister(&reconfig_err_inject.nb); 448c2ecf20Sopenharmony_ci debugfs_remove_recursive(dir); 458c2ecf20Sopenharmony_ci} 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_cimodule_init(err_inject_init); 488c2ecf20Sopenharmony_cimodule_exit(err_inject_exit); 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("OF reconfig notifier error injection module"); 518c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL"); 528c2ecf20Sopenharmony_ciMODULE_AUTHOR("Akinobu Mita <akinobu.mita@gmail.com>"); 53