ptdump_debugfs.c 718 B

1234567891011121314151617181920212223242526272829303132333435
  1. // SPDX-License-Identifier: GPL-2.0
  2. #include <linux/debugfs.h>
  3. #include <linux/seq_file.h>
  4. #include <asm/ptdump.h>
  5. static int ptdump_show(struct seq_file *m, void *v)
  6. {
  7. struct ptdump_info *info = m->private;
  8. ptdump_walk_pgd(m, info);
  9. return 0;
  10. }
  11. static int ptdump_open(struct inode *inode, struct file *file)
  12. {
  13. return single_open(file, ptdump_show, inode->i_private);
  14. }
  15. static const struct file_operations ptdump_fops = {
  16. .open = ptdump_open,
  17. .read = seq_read,
  18. .llseek = seq_lseek,
  19. .release = single_release,
  20. };
  21. int ptdump_debugfs_register(struct ptdump_info *info, const char *name)
  22. {
  23. struct dentry *pe;
  24. pe = debugfs_create_file(name, 0400, NULL, info, &ptdump_fops);
  25. return pe ? 0 : -ENOMEM;
  26. }