From nobody Sat Sep 28 10:38:24 2024
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 4XG3hc60kCz5X8MP;
	Sat, 28 Sep 2024 10:38:24 +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 "R11" (verified OK))
	by mx1.freebsd.org (Postfix) with ESMTPS id 4XG3hc1mMCz47FS;
	Sat, 28 Sep 2024 10:38:24 +0000 (UTC)
	(envelope-from git@FreeBSD.org)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim;
	t=1727519904;
	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=s/bO9JY/ixDi82/5I6MDhdrujR4SxdyaIfqEebxREqo=;
	b=tQj50mH48YVD0wfZX+xMcrTqVdapdNPMQI+S7IVFJwMyjpDNyPifGLWPRVm3TaFV+eUBCX
	Yk6ACl5PNr41xp/UbD10EtCNVX4H2X4dv9KOkSYx1SfUQj0S2vZEa/FQgLr2L89jtSlSD6
	0wutxfer3XcypyBwgCAZ94ukbotBAZV1VrE15eTHPXayFiXbUJKLEUimSKCciM8GscOEU0
	gmX52zJvyRK32Dsdn4pixUu/GmlCQs4D+4nFIF33oaUg0aUB4EYavluWXpij70ohIzEUD+
	2/87H3rcCyaiMOO8zlgtPiB+r9ChNxsrshqtTlsAVZp6uQ5WjwMuTZnio69YYw==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org;
	s=dkim; t=1727519904;
	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=s/bO9JY/ixDi82/5I6MDhdrujR4SxdyaIfqEebxREqo=;
	b=gjBnAKEgrS9ZLy9eQRj3TLk9EvtIOqu2TJpnTU/AAKxsa84CSjRjOzXtuDtF5jnE/fNQ8d
	w1WxOzaheR/VQsPMhwcYVFVKRnnBfajPZxH5UTLhwa7JYYKuGiWSu2nOON2orhWKMHFwN4
	4XMkwhOFIEts5/wDnCVYG4VTz9KYvI3kwsZPyyRzIioqQo5D3bitmVkniLiWKxPI+HHMyd
	/MTLvDw5f9vTxc4/GHuI2RAb6ksuLTU4TDcLpfRgshXfR6KSeK4An4TVaTBggGQaA2Rdrc
	SGvdujFNoHzeuoQiMcSMGfy9tWGy+3PyKFyYWeobAWhFRbg/0t3yMMTBcArodw==
ARC-Authentication-Results: i=1;
	mx1.freebsd.org;
	none
ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1727519904; a=rsa-sha256; cv=none;
	b=T8dw5S3r9QbPIHmG5F1X4rrOnc9zyhX01c78hh6jfsNQpIR87JgIcrxodRlxBNzxeT1YwQ
	1HAHeiFtmvynAQNSpPdPRfcM/OCjQcjxozUN9sqFDYa9mRLIluShRt+XKhYhLn57YN7Ka0
	zNj/rFNqEvlibnT9hcXAxqr8kcMxmVt37PpNNWtYxEEHEcTrLtDZ6l7bW8mneHbIVldNw7
	nem93chJXCQin5Kqw5umGIbuxvIr9vf9LEzbxcH2CXrN5nB3TtK/zK1wrEW8F7uEcnrcfo
	pqJgxuhe/ZBykOB2kdnLk2oWglkRDYqUSPn734+UGjHg5KDWnzappz1vS2S4SQ==
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 4XG3hc0vZ9zLnR;
	Sat, 28 Sep 2024 10:38:24 +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 48SAcOon098205;
	Sat, 28 Sep 2024 10:38:24 GMT
	(envelope-from git@gitrepo.freebsd.org)
Received: (from git@localhost)
	by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 48SAcOAQ098202;
	Sat, 28 Sep 2024 10:38:24 GMT
	(envelope-from git)
Date: Sat, 28 Sep 2024 10:38:24 GMT
Message-Id: <202409281038.48SAcOAQ098202@gitrepo.freebsd.org>
To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org,
        dev-commits-src-branches@FreeBSD.org
From: "Bjoern A. Zeeb" <bz@FreeBSD.org>
Subject: git: e138f36f6422 - stable/14 - LinuxKPI: add general
  module_driver(), use it for module_pci_driver()
List-Id: Commits to the stable branches of the FreeBSD src repository <dev-commits-src-branches.freebsd.org>
List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches
List-Help: <mailto:dev-commits-src-branches+help@freebsd.org>
List-Post: <mailto:dev-commits-src-branches@freebsd.org>
List-Subscribe: <mailto:dev-commits-src-branches+subscribe@freebsd.org>
List-Unsubscribe: <mailto:dev-commits-src-branches+unsubscribe@freebsd.org>
X-BeenThere: dev-commits-src-branches@freebsd.org
Sender: owner-dev-commits-src-branches@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/14
X-Git-Reftype: branch
X-Git-Commit: e138f36f6422212ac8b459ecfb2f0677404a3a7d
Auto-Submitted: auto-generated

The branch stable/14 has been updated by bz:

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

commit e138f36f6422212ac8b459ecfb2f0677404a3a7d
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2024-08-28 14:21:33 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2024-09-28 10:35:14 +0000

    LinuxKPI: add general module_driver(), use it for module_pci_driver()
    
    Factor out module_pci_driver() from 366d68f283793 into a general
    module_driver() so other bus attachments can also use the same kind
    of macro without duplicating all the lines.
    
    Redefine module_pci_driver() using the new general macro.
    
    No functional changes intended.
    
    Sponsored by:   The FreeBSD Foundation
    Reviewed by:    manu
    Differential Revision: https://reviews.freebsd.org/D46467
    
    (cherry picked from commit f5c7feee7129dc88a2e5dc3ce0a075cb5e4f534a)
---
 .../linuxkpi/common/include/linux/device/driver.h  | 33 ++++++++++++++++++++++
 sys/compat/linuxkpi/common/include/linux/pci.h     | 21 ++------------
 2 files changed, 36 insertions(+), 18 deletions(-)

diff --git a/sys/compat/linuxkpi/common/include/linux/device/driver.h b/sys/compat/linuxkpi/common/include/linux/device/driver.h
new file mode 100644
index 000000000000..03b510c9c8b7
--- /dev/null
+++ b/sys/compat/linuxkpi/common/include/linux/device/driver.h
@@ -0,0 +1,33 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2021 Bjoern A. Zeeb
+ * Copyright (c) 2024 The FreeBSD Foundation
+ *
+ * Portions of this software were developed by Björn Zeeb
+ * under sponsorship from the FreeBSD Foundation.
+ */
+
+#ifndef	LINUXKPI_LINUX_DEVICE_DRIVER_H
+#define	LINUXKPI_LINUX_DEVICE_DRIVER_H
+
+#include <sys/cdefs.h>
+#include <linux/module.h>
+
+#define	module_driver(_drv, _regf, _unregf)					\
+static inline int								\
+__CONCAT(__CONCAT(_, _drv), _init)(void)					\
+{										\
+	return (_regf(&(_drv)));		 				\
+}										\
+										\
+static inline void								\
+__CONCAT(__CONCAT(_, _drv), _exit)(void)					\
+{										\
+	_unregf(&(_drv));							\
+}										\
+										\
+module_init(__CONCAT(__CONCAT(_, _drv), _init));				\
+module_exit(__CONCAT(__CONCAT(_, _drv), _exit))
+
+#endif	/* LINUXKPI_LINUX_DEVICE_DRIVER_H */
diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h
index f9b60ae186b5..73882b312db5 100644
--- a/sys/compat/linuxkpi/common/include/linux/pci.h
+++ b/sys/compat/linuxkpi/common/include/linux/pci.h
@@ -36,6 +36,7 @@
 #define	CONFIG_PCI_MSI
 
 #include <linux/types.h>
+#include <linux/device/driver.h>
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -274,24 +275,8 @@ extern spinlock_t pci_lock;
 
 #define	__devexit_p(x)	x
 
-#define module_pci_driver(_driver)					\
-									\
-static inline int							\
-_pci_init(void)								\
-{									\
-									\
-	return (linux_pci_register_driver(&_driver));			\
-}									\
-									\
-static inline void							\
-_pci_exit(void)								\
-{									\
-									\
-	linux_pci_unregister_driver(&_driver);				\
-}									\
-									\
-module_init(_pci_init);							\
-module_exit(_pci_exit)
+#define	module_pci_driver(_drv)						\
+    module_driver(_drv, linux_pci_register_driver, linux_pci_unregister_driver)
 
 struct msi_msg {
 	uint32_t			data;