pvr_debugfs.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // SPDX-License-Identifier: GPL-2.0-only OR MIT
  2. /* Copyright (c) 2023 Imagination Technologies Ltd. */
  3. #include "pvr_debugfs.h"
  4. #include "pvr_device.h"
  5. #include "pvr_fw_trace.h"
  6. #include <linux/dcache.h>
  7. #include <linux/debugfs.h>
  8. #include <linux/err.h>
  9. #include <linux/kernel.h>
  10. #include <linux/types.h>
  11. #include <drm/drm_device.h>
  12. #include <drm/drm_file.h>
  13. #include <drm/drm_print.h>
  14. static const struct pvr_debugfs_entry pvr_debugfs_entries[] = {
  15. {"pvr_fw", pvr_fw_trace_debugfs_init},
  16. };
  17. void
  18. pvr_debugfs_init(struct drm_minor *minor)
  19. {
  20. struct drm_device *drm_dev = minor->dev;
  21. struct pvr_device *pvr_dev = to_pvr_device(drm_dev);
  22. struct dentry *root = minor->debugfs_root;
  23. for (size_t i = 0; i < ARRAY_SIZE(pvr_debugfs_entries); ++i) {
  24. const struct pvr_debugfs_entry *entry = &pvr_debugfs_entries[i];
  25. struct dentry *dir;
  26. dir = debugfs_create_dir(entry->name, root);
  27. if (IS_ERR(dir)) {
  28. drm_warn(drm_dev,
  29. "failed to create debugfs dir '%s' (err=%d)",
  30. entry->name, (int)PTR_ERR(dir));
  31. continue;
  32. }
  33. entry->init(pvr_dev, dir);
  34. }
  35. }
  36. /*
  37. * Since all entries are created under &drm_minor->debugfs_root, there's no
  38. * need for a pvr_debugfs_fini() as DRM will clean up everything under its root
  39. * automatically.
  40. */