Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 33e7cf89 authored by Mitchel Humpherys's avatar Mitchel Humpherys
Browse files

iommu/iommu-debug: Move attachment info file to subdirectory



Currently IOMMU attachment info is available in debugfs files located at
<debugfs_root>/iommu/attachments/<attached_device>.  However, there are
more actions that can be taken on attached devices besides just printing
their info.  Make room for more debugfs files for attached devices by
creating a directory for each one, and move the existing info file to:
<debugfs_root>/iommu/attachments/<attached_device>/info.

Change-Id: Ia56efc3aeb5e82afc34314fe48aaa0cd6e5579be
Signed-off-by: default avatarMitchel Humpherys <mitchelh@codeaurora.org>
parent be237cbe
Loading
Loading
Loading
Loading
+20 −9
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ struct iommu_debug_attachment {
	struct list_head list;
};

static int iommu_debug_attachment_show(struct seq_file *s, void *ignored)
static int iommu_debug_attachment_info_show(struct seq_file *s, void *ignored)
{
	struct iommu_debug_attachment *attach = s->private;
	phys_addr_t pt_phys;
@@ -56,13 +56,15 @@ static int iommu_debug_attachment_show(struct seq_file *s, void *ignored)
	return 0;
}

static int iommu_debug_attachment_open(struct inode *inode, struct file *file)
static int iommu_debug_attachment_info_open(struct inode *inode,
					    struct file *file)
{
	return single_open(file, iommu_debug_attachment_show, inode->i_private);
	return single_open(file, iommu_debug_attachment_info_show,
			   inode->i_private);
}

static const struct file_operations iommu_debug_attachment_fops = {
	.open	 = iommu_debug_attachment_open,
static const struct file_operations iommu_debug_attachment_info_fops = {
	.open	 = iommu_debug_attachment_info_open,
	.read	 = seq_read,
	.llseek	 = seq_lseek,
	.release = single_release,
@@ -89,16 +91,25 @@ void iommu_debug_attach_device(struct iommu_domain *domain,
	attach->domain = domain;
	attach->dev = dev;

	attach->dentry = debugfs_create_file(
		attach_name, S_IRUSR, debugfs_attachments_dir, attach,
		&iommu_debug_attachment_fops);
	attach->dentry = debugfs_create_dir(attach_name,
					    debugfs_attachments_dir);
	if (!attach->dentry) {
		pr_err("Couldn't create iommu/attachments/%s debugfs file for domain 0x%p\n",
		pr_err("Couldn't create iommu/attachments/%s debugfs directory for domain 0x%p\n",
		       attach_name, domain);
		kfree(attach);
		goto free_attach_name;
	}

	if (!debugfs_create_file(
		    "info", S_IRUSR, attach->dentry, attach,
		    &iommu_debug_attachment_info_fops)) {
		pr_err("Couldn't create iommu/attachments/%s/info debugfs file for domain 0x%p\n",
		       dev_name(dev), domain);
		debugfs_remove_recursive(attach->dentry);
		kfree(attach);
		goto unlock;
	}

	list_add(&attach->list, &iommu_debug_attachments);
free_attach_name:
	kfree(attach_name);