of-reconfig-notifier-error-inject.c 1.3 KB

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