sec_of_kunit.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #ifndef __SEC_OF_KUNIT_H__
  2. #define __SEC_OF_KUNIT_H__
  3. #include <linux/miscdevice.h>
  4. #include <linux/of.h>
  5. #include <linux/samsung/builder_pattern.h>
  6. struct sec_of_kunit_data {
  7. struct miscdevice misc;
  8. struct device_node *root;
  9. struct device_node *of_node;
  10. struct builder *bd;
  11. };
  12. /* NOTE: Inspired from 'drivers/of/unittest.c'. */
  13. #define SEC_OF_KUNIT_DTB_INFO_EXTERN(name) \
  14. extern uint8_t __dtb_##name##_begin[]; \
  15. extern uint8_t __dtb_##name##_end[]
  16. #define SEC_OF_KUNIT_DTB_INFO(overlay_name) \
  17. struct sec_of_dtb_info overlay_name ## _info = { \
  18. .dtb_begin = __dtb_##overlay_name##_begin, \
  19. .dtb_end = __dtb_##overlay_name##_end, \
  20. .name = #overlay_name, \
  21. }
  22. struct sec_of_dtb_info {
  23. uint8_t *dtb_begin;
  24. uint8_t *dtb_end;
  25. char *name;
  26. };
  27. #if IS_ENABLED(CONFIG_KUNIT)
  28. extern int sec_of_kunit_data_init(struct sec_of_kunit_data *testdata, const char *name, struct builder *bd, const char *compatible, struct sec_of_dtb_info *info);
  29. extern void sec_of_kunit_data_exit(struct sec_of_kunit_data *testdata);
  30. extern struct device_node *sec_of_kunit_dtb_to_fdt(struct sec_of_dtb_info *info);
  31. #else
  32. static int sec_of_kunit_data_init(struct sec_of_kunit_data *testdata, const char *name, struct builder *bd, const char *compatible, struct sec_of_dtb_info *info) { return -EINVAL; }
  33. static void sec_of_kunit_data_exit(struct sec_of_kunit_data *testdata) {}
  34. static inline struct device_node *sec_of_kunit_dtb_to_fdt(struct sec_of_dtb_info *info) { return ERR_PTR(-EINVAL); }
  35. #endif
  36. #endif /* __SEC_OF_KUNIT_H__ */