From nobody Wed Jan 18 16:24:49 2023 X-Original-To: dev-commits-src-all@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 4Nxrh16RBdz2yJNt; Wed, 18 Jan 2023 16:24:49 +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 4Nxrh15HXJz3Djk; Wed, 18 Jan 2023 16:24:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674059089; 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=CBF0X8JxmjJ7Hu459xBrwpaIBvLE2cE7qanoDGACM6w=; b=X7NAG2RNhXMKqKkr/Ssipz/eWbFJPC1BAcgdf2kTbyjISvyFGirc6GWfJouHyde4A3uWq5 Y5PNf008emP8r4UAGtJcJdEyJp1dUW1coH7Kflnz/HLd+60ZYFj+E1Y/+DX9bvC0TD/59W EH+GBkVslyE5R5kKUt4r2jkHqPsem1hi8qWOaoBGiPmK/Olj8iXTkaug231jvMQdw0Voav uijEaMpZzJUvCRts96UkR9BEiiujZm96c5QMusp8v62G//EcOJo0GjG5Sf6p4IE/YjtC7y sXZ+qaq+ho+Ka5BHydM4meGw/XSudd795PJ48iAZ1EeoTasDG879QtJT6PRtkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674059089; 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=CBF0X8JxmjJ7Hu459xBrwpaIBvLE2cE7qanoDGACM6w=; b=akvJEPho3FnFHLTLuEwUh1l6nlkRs8O1Eq9S1RQFvSwvhWvVHj0UANNvCJjqM8LMVtYDwS jVQmP6Ba4vBoQepI65I+bi+RiYeySeT9pFbj80SrdCwpsq+uOvrWrugL5E5E5uRMltkNpp dyavtR2TbeecptUOwvL6sPpkVyRugUckpHSqdiZKB/hzONy5BPdcDGpbTI94PmEWfk7FDw oVe21Sk2/yVLdV6Xvgf0S30fnaDE6R8JfGXPvknwATlxlBuAvvK8Doj7W6mVJwtdEekqpX YOBxez1wXYtM/OuOz/t7SJ4pwgLfbXTlw4hJUHbq9NsT/DGqHyuWRdxne+XPgA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674059089; a=rsa-sha256; cv=none; b=rD/1KcQUzkfOGIyZdysn6grrOBB3AkJzbo6SpZyuRO2+quBWtUsSKXSUdPWQA4yR7lEbFs L+LtyXvTtksxq20D1tFP753GF3eyJGXu7F1tWE+nlzMJEU2vOHSth52p0C5vGYf2wLm8Zp Etp8kjAJ6W25FAki0B8KQoIWmzWpKpCpHiwjDIDppQj3Ig+9mqyVH5aSMuMXeJjIhYvmIu 416t3PGaH67EwjAZzsV0LO4lEbNdftR4PFV9r+K8dYB7cFrWzBCpI7yS+r3byts7l0rRFO EaDPHYHjwQDFHK7Kmup8uDfhDPO22r1n2vNzIdiPH3k28m0nDKyvo9OTuf5jow== 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 4Nxrh14P2pzJ3c; Wed, 18 Jan 2023 16:24:49 +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 30IGOnr6037933; Wed, 18 Jan 2023 16:24:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30IGOnEv037932; Wed, 18 Jan 2023 16:24:49 GMT (envelope-from git) Date: Wed, 18 Jan 2023 16:24:49 GMT Message-Id: <202301181624.30IGOnEv037932@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: aa0370996eca - stable/13 - LinuxKPI,lindebugfs: add u8 base type and blob support List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: aa0370996eca5c8d4a8cd2c09888300bbb253994 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=aa0370996eca5c8d4a8cd2c09888300bbb253994 commit aa0370996eca5c8d4a8cd2c09888300bbb253994 Author: Bjoern A. Zeeb AuthorDate: 2022-10-22 18:12:16 +0000 Commit: Bjoern A. Zeeb CommitDate: 2023-01-18 13:24:15 +0000 LinuxKPI,lindebugfs: add u8 base type and blob support Add debugfs_create_u8() based on other already present implementations. Add a read-only implementation for debugfs_create_blob(). Both are needed for iwlwifi debugfs support. Sponsored by: The FreeBSD Foundation OKed by: jfree (earlier version) Differential Revision: https://reviews.freebsd.org/D37090 (cherry picked from commit 0fce2dc1573019d0732f33fa7c26cc228655d3e8) --- sys/compat/lindebugfs/lindebugfs.c | 66 ++++++++++++++++++++++ sys/compat/linuxkpi/common/include/linux/debugfs.h | 11 +++- 2 files changed, 76 insertions(+), 1 deletion(-) diff --git a/sys/compat/lindebugfs/lindebugfs.c b/sys/compat/lindebugfs/lindebugfs.c index b88caf9c3140..b72ceb5e0be9 100644 --- a/sys/compat/lindebugfs/lindebugfs.c +++ b/sys/compat/lindebugfs/lindebugfs.c @@ -367,6 +367,35 @@ debugfs_create_bool(const char *name, umode_t mode, struct dentry *parent, bool &fops_bool_ro, &fops_bool_wo); } + +static int +debugfs_u8_get(void *data, uint64_t *value) +{ + uint8_t *u8data = data; + *value = *u8data; + return (0); +} + +static int +debugfs_u8_set(void *data, uint64_t value) +{ + uint8_t *u8data = data; + *u8data = (uint8_t)value; + return (0); +} + +DEFINE_DEBUGFS_ATTRIBUTE(fops_u8, debugfs_u8_get, debugfs_u8_set, "%u\n"); +DEFINE_DEBUGFS_ATTRIBUTE(fops_u8_ro, debugfs_u8_get, NULL, "%u\n"); +DEFINE_DEBUGFS_ATTRIBUTE(fops_u8_wo, NULL, debugfs_u8_set, "%u\n"); + +void +debugfs_create_u8(const char *name, umode_t mode, struct dentry *parent, uint8_t *value) +{ + debugfs_create_mode_unsafe(name, mode, parent, value, &fops_u8, + &fops_u8_ro, &fops_u8_wo); +} + + static int debugfs_ulong_get(void *data, uint64_t *value) { @@ -394,6 +423,43 @@ debugfs_create_ulong(const char *name, umode_t mode, struct dentry *parent, unsi &fops_ulong_ro, &fops_ulong_wo); } + +static ssize_t +fops_blob_read(struct file *filp, char __user *ubuf, size_t read_size, loff_t *ppos) +{ + struct debugfs_blob_wrapper *blob; + + blob = filp->private_data; + if (blob == NULL) + return (-EINVAL); + if (blob->size == 0 || blob->data == NULL) + return (-EINVAL); + + return (simple_read_from_buffer(ubuf, read_size, ppos, blob->data, blob->size)); +} + +static int +fops_blob_open(struct inode *inode, struct file *filp) +{ + return (simple_open(inode, filp)); +} + +static const struct file_operations __fops_blob_ro = { + .owner = THIS_MODULE, + .open = fops_blob_open, + .read = fops_blob_read, + .llseek = no_llseek +}; + +struct dentry * +debugfs_create_blob(const char *name, umode_t mode, struct dentry *parent, + struct debugfs_blob_wrapper *value) +{ + /* Blobs are read-only. */ + return (debugfs_create_file(name, mode & 0444, parent, value, &__fops_blob_ro)); +} + + 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 ba1fa009dc62..4c9f52a0bc0f 100644 --- a/sys/compat/linuxkpi/common/include/linux/debugfs.h +++ b/sys/compat/linuxkpi/common/include/linux/debugfs.h @@ -47,6 +47,11 @@ struct debugfs_regset32 { int nregs; }; +struct debugfs_blob_wrapper { + void *data; + size_t size; +}; + struct dentry *debugfs_create_file(const char *name, umode_t mode, struct dentry *parent, void *data, const struct file_operations *fops); @@ -75,8 +80,12 @@ void debugfs_remove_recursive(struct dentry *dentry); void debugfs_create_bool(const char *name, umode_t mode, struct dentry *parent, bool *value); - +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); +struct dentry *debugfs_create_blob(const char *name, umode_t mode, + struct dentry *parent, struct debugfs_blob_wrapper *value); + #endif /* _LINUXKPI_LINUX_DEBUGFS_H_ */