git: 3521cce445d4 - main - lindebugfs: implement debugfs_create_devm_seqfile()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 10 Oct 2026 18:28:59 UTC
The branch main has been updated by bz:
URL: https://cgit.FreeBSD.org/src/commit/?id=3521cce445d4238aa425629c5fcc1c723b427d3e
commit 3521cce445d4238aa425629c5fcc1c723b427d3e
Author: Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2026-06-10 11:15:42 +0000
Commit: Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2026-10-10 18:28:32 +0000
lindebugfs: implement debugfs_create_devm_seqfile()
Implement debugfs_create_devm_seqfile() keyed by device and a
read function.
This was implemented months ago in order to support debugfs with mt76
but hasn't been exercised since.
The code does not really seem to belong in lindebugfs, but also does
not really fit into debugfs.h (rather fs.h?); leave it here with a
comment for now as neither dumbbell nor I could come up with a better
place.
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D57524
---
sys/compat/lindebugfs/lindebugfs.c | 42 ++++++++++++++++++++++
sys/compat/linuxkpi/common/include/linux/debugfs.h | 5 +++
2 files changed, 47 insertions(+)
diff --git a/sys/compat/lindebugfs/lindebugfs.c b/sys/compat/lindebugfs/lindebugfs.c
index 89652b5685c4..b79990ae36d4 100644
--- a/sys/compat/lindebugfs/lindebugfs.c
+++ b/sys/compat/lindebugfs/lindebugfs.c
@@ -70,6 +70,7 @@
#include <linux/compat.h>
#include <linux/debugfs.h>
#include <linux/fs.h>
+#include <linux/device.h>
MALLOC_DEFINE(M_DFSINT, "debugfsint", "Linux debugfs internal");
@@ -807,6 +808,47 @@ debugfs_create_blob(const char *name, umode_t mode, struct dentry *parent,
return (debugfs_create_file(name, mode & 0444, parent, value, &__fops_blob_ro));
}
+/* ---------------------------------------------------------------------------- */
+/* This should be migrated to ??? */
+
+struct debugfs_devm_seqfile {
+ struct device *dev;
+ int (*readfunc)(struct seq_file *, void *);
+};
+
+static int
+debugfs_devm_seqfile_open(struct inode *inode, struct linux_file *f)
+{
+ struct debugfs_devm_seqfile *s;
+
+ s = inode->i_private;
+ return (single_open(f, s->readfunc, s->dev));
+}
+
+static const struct file_operations debugfs_devm_seqfile_ops = {
+ .owner = THIS_MODULE,
+ .open = debugfs_devm_seqfile_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
+void
+debugfs_create_devm_seqfile(struct device *dev, const char *name,
+ struct dentry *d, int (*readfunc)(struct seq_file *m, void *arg))
+{
+ struct debugfs_devm_seqfile *s;
+
+ s = devm_kzalloc(dev, sizeof(*s), GFP_KERNEL);
+ if (s == NULL)
+ return;
+
+ s->dev = dev;
+ s->readfunc = readfunc;
+
+ debugfs_create_file(name, 0444, d, s, &debugfs_devm_seqfile_ops);
+}
+/* ---------------------------------------------------------------------------- */
static int
lindebugfs_init(PFS_INIT_ARGS)
diff --git a/sys/compat/linuxkpi/common/include/linux/debugfs.h b/sys/compat/linuxkpi/common/include/linux/debugfs.h
index 4d146e085a7b..268ae2bab0da 100644
--- a/sys/compat/linuxkpi/common/include/linux/debugfs.h
+++ b/sys/compat/linuxkpi/common/include/linux/debugfs.h
@@ -121,4 +121,9 @@ void debugfs_create_str(const char *name, umode_t mode, struct dentry *parent,
struct dentry *debugfs_create_blob(const char *name, umode_t mode,
struct dentry *parent, struct debugfs_blob_wrapper *value);
+struct device;
+struct dentry;
+void debugfs_create_devm_seqfile(struct device *, const char *, struct dentry *,
+ int (*)(struct seq_file *, void *));
+
#endif /* _LINUXKPI_LINUX_DEBUGFS_H_ */