[PATCH v3 3/5] iommu/amd - Add a README variable for the IOMMU debugfs

From: Gary R Hook
Date: Wed Mar 14 2018 - 19:05:30 EST


Provide help text via a filesystem entry

Signed-off-by: Gary R Hook <gary.hook@xxxxxxx>
---
drivers/iommu/amd_iommu_debugfs.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)

diff --git a/drivers/iommu/amd_iommu_debugfs.c b/drivers/iommu/amd_iommu_debugfs.c
index 170863e5e86b..d95428b1ef90 100644
--- a/drivers/iommu/amd_iommu_debugfs.c
+++ b/drivers/iommu/amd_iommu_debugfs.c
@@ -92,6 +92,31 @@ static const struct file_operations amd_iommu_debugfs_dtecount_ops = {
.write = NULL,
};

+static char readmetext[] =
+"count Count of active devices\n"
+"verbose Provide additional descriptive text\n"
+"\n";
+
+static ssize_t amd_iommu_debugfs_readme_read(struct file *filp,
+ char __user *ubuf,
+ size_t count, loff_t *offp)
+{
+ ssize_t ret;
+
+ ret = simple_read_from_buffer(ubuf, count, offp,
+ readmetext, strlen(readmetext));
+
+ return ret;
+}
+
+
+static const struct file_operations amd_iommu_debugfs_readme_ops = {
+ .owner = THIS_MODULE,
+ .open = simple_open,
+ .read = amd_iommu_debugfs_readme_read,
+ .write = NULL,
+};
+
void amd_iommu_debugfs_setup(struct amd_iommu *iommu)
{
char name[MAX_NAME_LEN + 1];
@@ -125,6 +150,12 @@ void amd_iommu_debugfs_setup(struct amd_iommu *iommu)
if (!d_dte)
goto err;

+ d_dte = debugfs_create_file("README", 0400,
+ iommu->debugfs_instance, iommu,
+ &amd_iommu_debugfs_readme_ops);
+ if (!d_dte)
+ goto err;
+
return;

err: