From nobody Mon Nov 28 17:24:59 2022 X-Original-To: dev-commits-src-main@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 4NLXR01B24z4jQjN; Mon, 28 Nov 2022 17:25:00 +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 4NLXR00czmz42lg; Mon, 28 Nov 2022 17:25:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669656300; 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=pzcQmw8OtUC2JwXRFmbtLF+Y+yqISUSM5uNCGJQNrAM=; b=eUAzBuQ9heQbrB1k1+tXnbUUZH5fkvODxiqo6yIOiHj4yv/0950gbqbsm4S/zxACSlGggo M1uEnyV++LkEe1+Eay1tHlmoATjfV9hlBHg0p9uC1lq4NwcEMMujRSnXPRYpo7ROkQg70Q qFkrNVdJskF4wEVWPW/9MHMrkVCXSCZUbRD0figtEXsMePDQAaIxUySua6HgP5rRYGtRaj Wt15fuvBaIHwFbF5Ruy0Q9C1elXJuhQkuCdmAc8WkhqBxeeqU0WkPqZg9+y4tqTA7YhpDT guBkI2CBtnlR4nEq7TZ1sC3Sp47Vj1AgVIvpp/eiM+aBzOfM4glxlDFn9m/kEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669656300; 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=pzcQmw8OtUC2JwXRFmbtLF+Y+yqISUSM5uNCGJQNrAM=; b=e1ddzrlSirF1eFZbq2dEjLYne71flO7Zowh5N7wtuELncBIareZNsvg7IzbPRXdDU/Fe4W VnT3r1LP1V4XLlSD7uryfN9ghuNc+BCQpOzRAmD8Y+TC+Z6ojv/wIoXFq0oSCSKtD/aLW1 powNqjWoNuvVN2fewnCrmB/l1zGJWHZIZWokHFI4e8YbluWz6T1WPNBHkcQh5I773YsVlf ZRs00UPmMbgRhJ6/IpTfrXK1vGj8PwL21GlSttbqWys1dMnS0MhxiFBQkxucKoenrPZV7B GJS6mUp0//hg5sjGQbQA24VxJMknOkk347qWoAQPt2U8Do023VJCaQdoG4UuzQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1669656300; a=rsa-sha256; cv=none; b=gZjgIQwbvZ53bJzu79MgeUw18BFCFXNQQGszxPwfU0ehoWUXNaf8pE4i1sJmGbpK1ximsQ ZkXESTiDP07V1eN3Nr3CsBwahMhi0xZMXS6lFkWPxPTTnH30tjya+3vPOquxYvISVteQpG yEJmJtbSIFnQeW42SyDWv+0xBI0ck6eYrdYHpy3cpDCcS4+e8wEmMtSwnmFKxqWiWv5dDz xqle6/g7DOcUJqjM2uzMuS1ZA+7Pipy+HY6AMDQFT/mRJvcTJBH2ld7VTxw9v3xo6vT1nA X/VNAEAhd3hmQb6sELWKbxs/UMXoCUiX/vGoFkHOj0SkZYTfUOcNZS5IHtSvuw== 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 4NLXQz6lq7zm31; Mon, 28 Nov 2022 17:24:59 +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 2ASHOxEG080512; Mon, 28 Nov 2022 17:24:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2ASHOxU9080511; Mon, 28 Nov 2022 17:24:59 GMT (envelope-from git) Date: Mon, 28 Nov 2022 17:24:59 GMT Message-Id: <202211281724.2ASHOxU9080511@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 0fce2dc15730 - main - LinuxKPI,lindebugfs: add u8 base type and blob support List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 0fce2dc1573019d0732f33fa7c26cc228655d3e8 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=0fce2dc1573019d0732f33fa7c26cc228655d3e8 commit 0fce2dc1573019d0732f33fa7c26cc228655d3e8 Author: Bjoern A. Zeeb AuthorDate: 2022-10-22 18:12:16 +0000 Commit: Bjoern A. Zeeb CommitDate: 2022-11-28 17:21:50 +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 MFC after: 3 days OKed by: jfree (earlier version) Differential Revision: https://reviews.freebsd.org/D37090 --- 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_ */