From nobody Thu Feb 16 11:55:39 2023 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PHYL405HWz3q5Hl; Thu, 16 Feb 2023 11:55:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PHYL35kv2z47dm; Thu, 16 Feb 2023 11:55:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676548539; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=AzKxaLkiLeOD+2PQPXGjEjUIOPsqjeAuzI+LvtXxu6c=; b=gavrODCANglu04L1UMMAng5mlehxfK/9IY1yzU3bO+v10h5YxOPVan8HGPfqqKouTAER4c 3Y3Ck04VuKvi5CW1PPgyUxPVGicpNmGGvq826SChekMcg94Cwlvy1Xjf2GLRXj24p7knc2 Ld3cvs0csb4cWGBdk89Ph56ACwbp+8btXwr3/+8DCpXigRQlCRUTU4DAs08n6UgGzOQxRt bN6XnsJprlMvT1CtYmzf4UFSbI4FZXa9l3ONxqgIbp8oBJeT3agZQWSFPfSoupceSCKW5c /lVQ9Rj6pQXjAPeiaXs/SzpSTXe6HWYxcy3nbU0MdWxKIO4UAVnagB0qRPY9Jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676548539; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=AzKxaLkiLeOD+2PQPXGjEjUIOPsqjeAuzI+LvtXxu6c=; b=A3ULqiWCj63r1fFZXXRZ01EYNyxvK2ZfcaBCRkIv1DnwGuXglRwotAnhuAoENRETJIVz1i OnNxi9ZBCYZNAp1SIDN95D7xv4e4kspuBmR1DrhYMkcpQVCpnmYj1Y2iOZXb7L2ncYbhqu XkxBb2/LOdpUszcaiMm8sc+klYHP32EaZy9RSFCqbtHQ0U9J9csBKO/kbTLtEa9hnXn6Jj utz8rI5ThUumacinfPd+zakUrAXGzLgpTgcWUNn991e0aa4MwGtSYdoqz4/04FzPiRBqnr EiBHXpVbClN2q5uODGuZdYDknyuQEC0APTshkaraKQwsMyEHi6Y7GSb8Zrq6VQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1676548539; a=rsa-sha256; cv=none; b=kM5vAZyyXJYDHyHS5reA54i2S9zhmZcfinxNvSE/x3IrFBES2cHdnssXMxhvscUyhl5CXp eyGHzLAEoF5OzevQmh0epAa57b/JnUdlHxgPbKp56EG9ake+rJk8I488Gt80pJVpKgaMIE 1Q6hjy9kjZI63G1J6JtNj7iai0574sbU/iTUzDFMZB9A4ZJm25xhTRx7R52Ojo6w5jzp/i bSJr7gSEQL2nNB6b2dqC+/x12aZfI/tfRAU9+/oeVDt48XmX+vGyluB6kDxK7+PK0aV9NH PmSi+j6Vdkxse0gL5c7mI6esNIHqGPuMBcsgxN99gw2cQpecTzFE7Wfm1mAiJQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4PHYL34YvZz12ht; Thu, 16 Feb 2023 11:55:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 31GBtd1K054874; Thu, 16 Feb 2023 11:55:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 31GBtdUZ054873; Thu, 16 Feb 2023 11:55:39 GMT (envelope-from git) Date: Thu, 16 Feb 2023 11:55:39 GMT Message-Id: <202302161155.31GBtdUZ054873@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: =?utf-8?Q?Jean-S=C3=A9bastien=20P=C3=A9dron?= Subject: git: 7fdbae1bd14a - stable/13 - lindebugfs: Add `debugfs_create_atomic_t()` List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dumbbell X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 7fdbae1bd14ac5ee61563d63b23080f45a5be459 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N 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 AuthorDate: 2022-12-30 10:00:57 +0000 Commit: Jean-Sébastien Pédron 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 #include +#include #include #include #include @@ -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);