[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231221085109.2830794-2-yi.fang.gan@intel.com>
Date: Thu, 21 Dec 2023 16:51:08 +0800
From: "Gan, Yi Fang" <yi.fang.gan@...el.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Andrew Halaney <ahalaney@...hat.com>,
Javier Martinez Canillas <javierm@...hat.com>,
John Stultz <jstultz@...gle.com>,
"Rafael J . Wysocki" <rafael@...nel.org>,
Gan Yi Fang <yi.fang.gan@...el.com>,
Jens Axboe <axboe@...nel.dk>,
Russell King <linux@...linux.org.uk>,
Andrew Lunn <andrew@...n.ch>,
Heiner Kallweit <hkallweit1@...il.com>,
"David S . Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Marek BehĂșn <kabel@...nel.org>,
netdev@...r.kernel.org,
linux-stm32@...md-mailman.stormreply.com,
linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org
Cc: Looi Hong Aun <hong.aun.looi@...el.com>,
Voon Weifeng <weifeng.voon@...el.com>,
Song Yoong Siang <yoong.siang.song@...el.com>,
Lai Peter Jun Ann <peter.jun.ann.lai@...el.com>,
Choong Yong Liang <yong.liang.choong@...el.com>
Subject: [PATCH net v2 1/2] driver.h: add helper macro for module_exit() boilerplate
For the modules need a module_init() but don't need to do
anything special in module_exit() might need to have an empty
module_exit(). This patch add a new macro module_exit_stub() to
replace the empty module_exit(). The macro is useful to remove
the module_exit() boilerplate.
Cc: <stable@...r.kernel.org> # 6.1+
Suggested-by: Lobakin, Aleksander <aleksander.lobakin@...el.com>
Signed-off-by: Gan, Yi Fang <yi.fang.gan@...el.com>
---
include/linux/device/driver.h | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/include/linux/device/driver.h b/include/linux/device/driver.h
index 7738f458995f..7d322eef501e 100644
--- a/include/linux/device/driver.h
+++ b/include/linux/device/driver.h
@@ -288,4 +288,18 @@ static int __init __driver##_init(void) \
} \
device_initcall(__driver##_init);
+/**
+ * module_exit_stub() - Helper macro for drivers that have init but don't
+ * do anything in exit. This eliminates some boilerplate.
+ * Each module may only use this macro once, and calling it replaces
+ * module_exit().
+ *
+ * @__driver: driver name
+ */
+#define module_exit_stub(__driver) \
+static void __exit __driver##_exit(void) \
+{ \
+} \
+module_exit(__driver##_exit)
+
#endif /* _DEVICE_DRIVER_H_ */
--
2.34.1
Powered by blists - more mailing lists