debugfs.c 746 B

1234567891011121314151617181920212223242526272829303132
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * AMD IOMMU driver
  4. *
  5. * Copyright (C) 2018 Advanced Micro Devices, Inc.
  6. *
  7. * Author: Gary R Hook <gary.hook@amd.com>
  8. */
  9. #include <linux/debugfs.h>
  10. #include <linux/pci.h>
  11. #include "amd_iommu.h"
  12. static struct dentry *amd_iommu_debugfs;
  13. static DEFINE_MUTEX(amd_iommu_debugfs_lock);
  14. #define MAX_NAME_LEN 20
  15. void amd_iommu_debugfs_setup(struct amd_iommu *iommu)
  16. {
  17. char name[MAX_NAME_LEN + 1];
  18. mutex_lock(&amd_iommu_debugfs_lock);
  19. if (!amd_iommu_debugfs)
  20. amd_iommu_debugfs = debugfs_create_dir("amd",
  21. iommu_debugfs_dir);
  22. mutex_unlock(&amd_iommu_debugfs_lock);
  23. snprintf(name, MAX_NAME_LEN, "iommu%02d", iommu->index);
  24. iommu->debugfs = debugfs_create_dir(name, amd_iommu_debugfs);
  25. }