Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 Feb 2023 11:55:39 GMT
From:      =?utf-8?Q?Jean-S=C3=A9bastien=20P=C3=A9dron?= <dumbbell@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 7fdbae1bd14a - stable/13 - lindebugfs: Add `debugfs_create_atomic_t()`
Message-ID:  <202302161155.31GBtdUZ054873@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by dumbbell (ports committer):

URL: https://cgit.FreeBSD.org/src/commit/?id=7fdbae1bd14ac5ee61563d63b23080f45a5be459

commit 7fdbae1bd14ac5ee61563d63b23080f45a5be459
Author:     Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
AuthorDate: 2022-12-30 10:00:57 +0000
Commit:     Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
CommitDate: 2023-02-16 11:55:11 +0000

    lindebugfs: Add `debugfs_create_atomic_t()`
    
    Reviewed by:    jfree
    Approved by:    jfree
    Differential Revision:  https://reviews.freebsd.org/D37915
    
    (cherry picked from commit f2044a3030fb2a657e59dee4b7e5865acff936bd)
---
 sys/compat/lindebugfs/lindebugfs.c                 | 30 ++++++++++++++++++++++
 sys/compat/linuxkpi/common/include/linux/debugfs.h |  2 ++
 2 files changed, 32 insertions(+)

diff --git a/sys/compat/lindebugfs/lindebugfs.c b/sys/compat/lindebugfs/lindebugfs.c
index b72ceb5e0be9..11a6dac579ac 100644
--- a/sys/compat/lindebugfs/lindebugfs.c
+++ b/sys/compat/lindebugfs/lindebugfs.c
@@ -69,6 +69,7 @@ __FBSDID("$FreeBSD$");
 #include <compat/linux/linux_util.h>
 #include <fs/pseudofs/pseudofs.h>
 
+#include <asm/atomic.h>
 #include <linux/compat.h>
 #include <linux/debugfs.h>
 #include <linux/fs.h>
@@ -424,6 +425,35 @@ debugfs_create_ulong(const char *name, umode_t mode, struct dentry *parent, unsi
 }
 
 
+static int
+debugfs_atomic_t_get(void *data, uint64_t *value)
+{
+	atomic_t *atomic_data = data;
+	*value = atomic_read(atomic_data);
+	return (0);
+}
+
+static int
+debugfs_atomic_t_set(void *data, uint64_t value)
+{
+	atomic_t *atomic_data = data;
+	atomic_set(atomic_data, (int)value);
+	return (0);
+}
+
+DEFINE_DEBUGFS_ATTRIBUTE(fops_atomic_t, debugfs_atomic_t_get, debugfs_atomic_t_set, "%d\n");
+DEFINE_DEBUGFS_ATTRIBUTE(fops_atomic_t_ro, debugfs_atomic_t_get, NULL, "%d\n");
+DEFINE_DEBUGFS_ATTRIBUTE(fops_atomic_t_wo, NULL, debugfs_atomic_t_set, "%d\n");
+
+void
+debugfs_create_atomic_t(const char *name, umode_t mode, struct dentry *parent, atomic_t *value)
+{
+
+	debugfs_create_mode_unsafe(name, mode, parent, value, &fops_atomic_t,
+	    &fops_atomic_t_ro, &fops_atomic_t_wo);
+}
+
+
 static ssize_t
 fops_blob_read(struct file *filp, char __user *ubuf, size_t read_size, loff_t *ppos)
 {
diff --git a/sys/compat/linuxkpi/common/include/linux/debugfs.h b/sys/compat/linuxkpi/common/include/linux/debugfs.h
index 4c9f52a0bc0f..422b96006b04 100644
--- a/sys/compat/linuxkpi/common/include/linux/debugfs.h
+++ b/sys/compat/linuxkpi/common/include/linux/debugfs.h
@@ -84,6 +84,8 @@ void debugfs_create_u8(const char *name, umode_t mode, struct dentry *parent,
     uint8_t *value);
 void debugfs_create_ulong(const char *name, umode_t mode, struct dentry *parent,
     unsigned long *value);
+void debugfs_create_atomic_t(const char *name, umode_t mode, struct dentry *parent,
+    atomic_t *value);
 
 struct dentry *debugfs_create_blob(const char *name, umode_t mode,
     struct dentry *parent, struct debugfs_blob_wrapper *value);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202302161155.31GBtdUZ054873>