sec_kunit.h 899 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #ifndef __SEC_KUNIT_H__
  2. #define __SEC_KUNIT_H__
  3. #include <linux/fs.h>
  4. #include <linux/miscdevice.h>
  5. #if IS_ENABLED(CONFIG_KUNIT)
  6. #define __ss_static
  7. #define __ss_inline
  8. #define __ss_always_inline
  9. static inline int sec_kunit_init_miscdevice(struct miscdevice *misc, const char *name)
  10. {
  11. static struct file_operations dummy_fops = {
  12. .owner = THIS_MODULE,
  13. };
  14. misc->minor = MISC_DYNAMIC_MINOR;
  15. misc->name = name;
  16. misc->fops = &dummy_fops;
  17. return misc_register(misc);
  18. }
  19. static inline void sec_kunit_exit_miscdevice(struct miscdevice *misc)
  20. {
  21. misc_deregister(misc);
  22. }
  23. #else
  24. #define __ss_static static
  25. #define __ss_inline inline
  26. #define __ss_always_inline __always_inline
  27. static inline int sec_kunit_init_miscdevice(struct miscdevice *misc, const char *name) { return -EINVAL; }
  28. static inline void sec_kunit_exit_miscdevice(struct miscdevice *misc) {}
  29. #endif
  30. #endif /* __SEC_KUNIT_H__ */