lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 17 Jun 2019 20:40:42 +0200
From:   "Enrico Weigelt, metux IT consult" <info@...ux.net>
To:     linux-kernel@...r.kernel.org
Cc:     thloh@...era.com, linus.walleij@...aro.org,
        bgolaszewski@...libre.com, andriy.shevchenko@...ux.intel.com,
        shawnguo@...nel.org, s.hauer@...gutronix.de, kernel@...gutronix.de,
        festevam@...il.com, linux-imx@....com, grygorii.strashko@...com,
        ssantosh@...nel.org, khilman@...nel.org, mcoquelin.stm32@...il.com,
        alexandre.torgue@...com, linux-gpio@...r.kernel.org,
        linux-omap@...r.kernel.org, linux-tegra@...r.kernel.org,
        patches@...nsource.cirrus.com
Subject: [PATCH 01/30] include: linux: platform_device: more helpers for declaring platform drivers

From: Enrico Weigelt <info@...ux.net>

Add more helper macros for trivial driver init cases, similar to the
already existing module_platform_driver()+friends - now for those which
are initialized at other stages. Lots of drivers couldn't use the existing
macros, as they need to be called at different init stages, eg. subsys,
postcore, arch.

This helps to further reduce driver init boilerplate.

Signed-off-by: Enrico Weigelt <info@...ux.net>
---
 include/linux/platform_device.h | 51 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index beb25f2..5f3a967 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -259,6 +259,57 @@ static inline void platform_set_drvdata(struct platform_device *pdev,
 } \
 module_exit(__platform_driver##_exit);
 
+/* postcore_platform_driver() - Helper macro for drivers that don't do
+ * anything special in module init/exit.  This eliminates a lot of
+ * boilerplate.  Each module may only use this macro once, and
+ * calling it replaces postcore_initcall() and module_exit()
+ */
+#define postcore_platform_driver(__platform_driver) \
+static int __init __platform_driver##_init(void) \
+{ \
+	return platform_driver_register(&(__platform_driver)); \
+} \
+postcore_initcall(__platform_driver##_init); \
+static void __exit __platform_driver##_exit(void) \
+{ \
+	platform_driver_unregister(&(__platform_driver)); \
+} \
+module_exit(__platform_driver##_exit);
+
+/* subsys_platform_driver() - Helper macro for drivers that don't do
+ * anything special in module init/exit.  This eliminates a lot of
+ * boilerplate.  Each module may only use this macro once, and
+ * calling it replaces subsys_initcall() and module_exit()
+ */
+#define subsys_platform_driver(__platform_driver) \
+static int __init __platform_driver##_init(void) \
+{ \
+	return platform_driver_register(&(__platform_driver)); \
+} \
+subsys_initcall(__platform_driver##_init); \
+static void __exit __platform_driver##_exit(void) \
+{ \
+	platform_driver_unregister(&(__platform_driver)); \
+} \
+module_exit(__platform_driver##_exit);
+
+/* arch_platform_driver() - Helper macro for drivers that don't do
+ * anything special in module init/exit.  This eliminates a lot of
+ * boilerplate.  Each module may only use this macro once, and
+ * calling it replaces arch_initcall() and module_exit()
+ */
+#define arch_platform_driver(__platform_driver) \
+static int __init __platform_driver##_init(void) \
+{ \
+	return platform_driver_register(&(__platform_driver)); \
+} \
+arch_initcall(__platform_driver##_init); \
+static void __exit __platform_driver##_exit(void) \
+{ \
+	platform_driver_unregister(&(__platform_driver)); \
+} \
+module_exit(__platform_driver##_exit);
+
 /* builtin_platform_driver_probe() - Helper macro for drivers that don't do
  * anything special in device init.  This eliminates some boilerplate.  Each
  * driver may only use this macro once, and using it replaces device_initcall.
-- 
1.9.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ