* [PATCH net-next 1/1] driver.h: add helper macro for module_exit() boilerplate
@ 2023-12-12 9:43 Gan, Yi Fang
2023-12-12 10:16 ` Greg Kroah-Hartman
0 siblings, 1 reply; 2+ messages in thread
From: Gan, Yi Fang @ 2023-12-12 9:43 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J . Wysocki, Javier Martinez Canillas,
John Stultz, Jens Axboe, Andrew Halaney, Lobakin, Aleksander, Gan,
Yi Fang, linux-kernel
Cc: Looi Hong Aun, Voon Weifeng, Song Yoong Siang, Lai, Peter Jun Ann
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.
Signed-off-by: Gan, Yi Fang <yi.fang.gan@intel.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..18e75c7b5c2f 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 one, 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
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH net-next 1/1] driver.h: add helper macro for module_exit() boilerplate
2023-12-12 9:43 [PATCH net-next 1/1] driver.h: add helper macro for module_exit() boilerplate Gan, Yi Fang
@ 2023-12-12 10:16 ` Greg Kroah-Hartman
0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2023-12-12 10:16 UTC (permalink / raw)
To: Gan, Yi Fang
Cc: Rafael J . Wysocki, Javier Martinez Canillas, John Stultz,
Jens Axboe, Andrew Halaney, Lobakin, Aleksander, Gan,
linux-kernel, Looi Hong Aun, Voon Weifeng, Song Yoong Siang, Lai,
Peter Jun Ann
On Tue, Dec 12, 2023 at 05:43:52PM +0800, Gan, Yi Fang wrote:
> 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.
>
> Signed-off-by: Gan, Yi Fang <yi.fang.gan@intel.com>
> ---
> include/linux/device/driver.h | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
Why would we take a macro that no one actually uses?
Please submit this with a user, you all know that this is the case, how
did it pass your internal reviews (hint, I don't think it did...)
thanks,
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-12-12 10:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-12 9:43 [PATCH net-next 1/1] driver.h: add helper macro for module_exit() boilerplate Gan, Yi Fang
2023-12-12 10:16 ` Greg Kroah-Hartman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox