From nobody Mon Apr 7 18:01:28 2025 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 4ZWcTh4v4Xz5rwKp; Mon, 07 Apr 2025 18:01:28 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ZWcTh3nTLz3SKk; Mon, 07 Apr 2025 18:01:28 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1744048888; 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=2TTggWcCSdoCU7A0BM0P6B6HqxfobID8DGUN+e7Knmc=; b=tcGq8+rwwmEkUwfHEd+sYTIcUmi0rrXAxSeVPE4uKhbUKWbyUegd/q1BpSiDXJAJi/Gd8G Tzg2K3yMb7YLdG++V6U3Rp86BTemOLAXhhM+kosew6ayQ+H4tL2VlgznIsiQAx8NGH/dPq gihaLUMf2fgaaUlGBXQW+TVuTYppa3qd4KJCiRLMfZxWZi9MwXU9dQm5PsJ1L3TVk04EEq k/NW2y8E/EGXovOOoogPxiC9/40P8QXPmbYWx/9Qnsafryh+avNl4tTwCYxjBMVMfrrNoH 2OA7v5fLkFuy7Kw/sxE8OZOZSCxjcoOpzAswLOylx53gvOa6f20Gah8ygZx6bA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1744048888; a=rsa-sha256; cv=none; b=ki9AN2bZNiX/2qzFhw8Fz70QMD4vGzG3TNc27Y4CyDyRkhSHZhq4qz/oQt23OLc3NsX0oU /lkMjCSHg0VxRz4+df2HFzXx7cgtalM3edCVaDTS+EXDKPWbwzUrkgjw+8FTT9ppMa59ao vPTAfHJyEQrhd5i0vkvcth2A1S1fx3P3F9FJK6kh1I3zm1Iify6V5CL07cCRoYNMU+oMQ7 1clrStql790b/Le8QPxJq1zZ8uHmzWw5ifHsaRAAGDCh8ISYQ6ertWAg3M9WV+jAkCIyuN kxxQ0p1fZkNna3EP6r0dtIacde/HAjsznS66qM6u3CBuX1cAotpznfVSKjKvWg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1744048888; 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=2TTggWcCSdoCU7A0BM0P6B6HqxfobID8DGUN+e7Knmc=; b=iOXn5ZP8q2pyg1kqJazpI/YFCABtk9YFgpgvN+7m40y3PtckjKDBbSrNuFfBCA4E8fc4bl 6pvtMG7YdfJkFbgEbb03JFtqmNQxU2k7yTnMZUlD6IE/3vk2p2g8Dp8eAvqbliJdXi6AZx ZPA7f1JoiwTSa7SIYFyg+WALxuJOTWCQe2vzA+ySZlAjoJlA8tnFrnokmVPaEOWgaN5qQ8 yDDgzQyZlDQmGizDxIcWTsLXAbRhDSHjC/3MaYqBGo/NG1is0vQWeFx4nFaUQG5QHX0XYB /Ax9v9482chthlggF9g2sjglbMDVk2fJ+SwyjvhQ0OQrVA9cos5ZiDAorhBEGA== 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 4ZWcTh23mZzxCl; Mon, 07 Apr 2025 18:01:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 537I1SjU028279; Mon, 7 Apr 2025 18:01:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 537I1SJs028276; Mon, 7 Apr 2025 18:01:28 GMT (envelope-from git) Date: Mon, 7 Apr 2025 18:01:28 GMT Message-Id: <202504071801.537I1SJs028276@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Jean-S=C3=A9bastien?= =?utf-8?Q?P=C3=A9dron?= Subject: git: 968650dbdaa1 - main - linuxkpi: Add `BIN_ATTR*()` macros 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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/main X-Git-Reftype: branch X-Git-Commit: 968650dbdaa16ac2fac91782522b5074d2202078 Auto-Submitted: auto-generated The branch main has been updated by dumbbell: URL: https://cgit.FreeBSD.org/src/commit/?id=968650dbdaa16ac2fac91782522b5074d2202078 commit 968650dbdaa16ac2fac91782522b5074d2202078 Author: Jean-Sébastien Pédron AuthorDate: 2025-02-25 23:22:26 +0000 Commit: Jean-Sébastien Pédron CommitDate: 2025-04-07 17:35:57 +0000 linuxkpi: Add `BIN_ATTR*()` macros They are helpers to declare static `struct bin_attribute`. The amdgpu DRM driver started to use them for some time but the code was commented out (and this is still the case as of this commit). In Linux 6.8, it declared a new BIN_ATTR. This new code is not commented out. While here, change the first argument of the `read` and `write` callbacks to be a `struct linux_file *` instead of a `struct file *`. This ensures the right structure is being referenced at compile time. Reviewed by: bz Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D49378 --- sys/compat/linuxkpi/common/include/linux/sysfs.h | 41 +++++++++++++++++++++--- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/sysfs.h b/sys/compat/linuxkpi/common/include/linux/sysfs.h index c6692b803789..f11db5ece515 100644 --- a/sys/compat/linuxkpi/common/include/linux/sysfs.h +++ b/sys/compat/linuxkpi/common/include/linux/sysfs.h @@ -53,10 +53,10 @@ struct attribute_group { struct bin_attribute { struct attribute attr; size_t size; - ssize_t (*read)(struct file *, struct kobject *, struct bin_attribute *, - char *, loff_t, size_t); - ssize_t (*write)(struct file *, struct kobject *, struct bin_attribute *, - char *, loff_t, size_t); + ssize_t (*read)(struct linux_file *, struct kobject *, + struct bin_attribute *, char *, loff_t, size_t); + ssize_t (*write)(struct linux_file *, struct kobject *, + struct bin_attribute *, char *, loff_t, size_t); }; #define __ATTR(_name, _mode, _show, _store) { \ @@ -81,6 +81,39 @@ struct bin_attribute { NULL, \ } +#define __BIN_ATTR(_name, _mode, _read, _write, _size) { \ + .attr = { .name = __stringify(_name), .mode = _mode }, \ + .read = _read, .write = _write, .size = _size, \ +} +#define __BIN_ATTR_RO(_name, _size) { \ + .attr = { .name = __stringify(_name), .mode = 0444 }, \ + .read = _name##_read, .size = _size, \ +} +#define __BIN_ATTR_WO(_name, _size) { \ + .attr = { .name = __stringify(_name), .mode = 0200 }, \ + .write = _name##_write, .size = _size, \ +} +#define __BIN_ATTR_WR(_name, _size) { \ + .attr = { .name = __stringify(_name), .mode = 0644 }, \ + .read = _name##_read, .write = _name##_write, .size = _size, \ +} + +#define BIN_ATTR(_name, _mode, _read, _write, _size) \ +struct bin_attribute bin_attr_##_name = \ + __BIN_ATTR(_name, _mode, _read, _write, _size); + +#define BIN_ATTR_RO(_name, _size) \ +struct bin_attribute bin_attr_##_name = \ + __BIN_ATTR_RO(_name, _size); + +#define BIN_ATTR_WO(_name, _size) \ +struct bin_attribute bin_attr_##_name = \ + __BIN_ATTR_WO(_name, _size); + +#define BIN_ATTR_WR(_name, _size) \ +struct bin_attribute bin_attr_##_name = \ + __BIN_ATTR_WR(_name, _size); + /* * Handle our generic '\0' terminated 'C' string. * Two cases: