All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Enrico Weigelt, metux IT consult" <info@metux.net>
To: linux-kernel@vger.kernel.org
Cc: thloh@altera.com, linus.walleij@linaro.org,
	bgolaszewski@baylibre.com, andriy.shevchenko@linux.intel.com,
	shawnguo@kernel.org, s.hauer@pengutronix.de,
	kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com,
	grygorii.strashko@ti.com, ssantosh@kernel.org,
	khilman@kernel.org, mcoquelin.stm32@gmail.com,
	alexandre.torgue@st.com, linux-gpio@vger.kernel.org,
	linux-omap@vger.kernel.org, linux-tegra@vger.kernel.org,
	patches@opensource.cirrus.com
Subject: [PATCH 01/30] include: linux: platform_device: more helpers for declaring platform drivers
Date: Mon, 17 Jun 2019 20:40:42 +0200	[thread overview]
Message-ID: <1560796871-18560-1-git-send-email-info@metux.net> (raw)

From: Enrico Weigelt <info@metux.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@metux.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

             reply	other threads:[~2019-06-17 18:40 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-17 18:40 Enrico Weigelt, metux IT consult [this message]
2019-06-17 18:40 ` [PATCH 02/30] drivers: gpio: altera: use subsys_platform_driver() Enrico Weigelt, metux IT consult
2019-06-17 18:40 ` [PATCH 03/30] drivers: gpio: da9055: " Enrico Weigelt, metux IT consult
2019-06-17 18:40 ` [PATCH 04/30] drivers: gpio: htc-egpio: " Enrico Weigelt, metux IT consult
2019-06-17 18:40 ` [PATCH 05/30] drivers: gpio: lynxpoint: " Enrico Weigelt, metux IT consult
2019-06-17 18:40 ` [PATCH 06/30] drivers: gpio: lantiq: " Enrico Weigelt, metux IT consult
2019-06-17 18:40 ` [PATCH 07/30] drivers: gpio: msic: " Enrico Weigelt, metux IT consult
2019-06-18  9:00   ` Andy Shevchenko
2019-06-17 18:40 ` [PATCH 08/30] drivers: gpio: palmas: " Enrico Weigelt, metux IT consult
2019-06-17 18:40 ` [PATCH 09/30] drivers: gpio: rc5t583: " Enrico Weigelt, metux IT consult
2019-06-17 18:40 ` [PATCH 10/30] drivers: gpio: spear-spics: " Enrico Weigelt, metux IT consult
2019-06-17 18:40 ` [PATCH 11/30] drivers: gpio: stmpe: " Enrico Weigelt, metux IT consult
2019-06-17 18:40 ` [PATCH 12/30] drivers: gpio: stp-xway: " Enrico Weigelt, metux IT consult
2019-06-17 18:40 ` [PATCH 13/30] drivers: gpio: tc3589x: " Enrico Weigelt, metux IT consult
2019-06-17 18:40 ` [PATCH 14/30] drivers: gpio: tegra: " Enrico Weigelt, metux IT consult
2019-06-17 18:40 ` [PATCH 15/30] drivers: gpio: tps6586x: " Enrico Weigelt, metux IT consult
2019-06-17 18:40 ` [PATCH 16/30] drivers: gpio: tps65910: " Enrico Weigelt, metux IT consult
2019-06-17 18:40 ` [PATCH 17/30] drivers: gpio: twl4030: " Enrico Weigelt, metux IT consult
2019-06-17 18:40 ` [PATCH 18/30] drivers: gpio: wm831x: " Enrico Weigelt, metux IT consult
2019-06-17 18:41 ` [PATCH 19/30] drivers: gpio: wm8350: " Enrico Weigelt, metux IT consult
2019-06-17 18:41 ` [PATCH 20/30] drivers: gpio: wm8994: " Enrico Weigelt, metux IT consult
2019-06-17 18:41 ` [PATCH 21/30] drivers: gpio: xilinx: " Enrico Weigelt, metux IT consult
2019-06-17 18:41 ` [PATCH 22/30] drivers: gpio: em: use postcore_platform_driver() Enrico Weigelt, metux IT consult
2019-06-17 18:41 ` [PATCH 23/30] drivers: gpio: ep93xx: " Enrico Weigelt, metux IT consult
2019-06-17 18:41 ` [PATCH 24/30] drivers: gpio: mxs: " Enrico Weigelt, metux IT consult
2019-06-17 18:41 ` [PATCH 25/30] drivers: gpio: omap: " Enrico Weigelt, metux IT consult
2019-06-17 18:41 ` [PATCH 26/30] drivers: gpio: zynq: " Enrico Weigelt, metux IT consult
2019-06-17 18:41 ` [PATCH 27/30] drivers: gpio: iop: use arch_platform_driver() Enrico Weigelt, metux IT consult
2019-06-17 18:41 ` [PATCH 28/30] drivers: gpio: mpc8xxx: " Enrico Weigelt, metux IT consult
2019-06-17 18:41 ` [PATCH 29/30] drivers: gpio: max7300: " Enrico Weigelt, metux IT consult
2019-06-17 18:41 ` [PATCH 30/30] drivers: gpio: max732x: use subsys_i2c_driver() Enrico Weigelt, metux IT consult
2019-06-18  8:57 ` [PATCH 01/30] include: linux: platform_device: more helpers for declaring platform drivers Andy Shevchenko
2019-06-25  9:18 ` Linus Walleij
2019-06-25  9:18   ` Linus Walleij
2019-06-26  6:14 ` Uwe Kleine-König
2019-06-26 17:27   ` Enrico Weigelt, metux IT consult

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1560796871-18560-1-git-send-email-info@metux.net \
    --to=info@metux.net \
    --cc=alexandre.torgue@st.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=festevam@gmail.com \
    --cc=grygorii.strashko@ti.com \
    --cc=kernel@pengutronix.de \
    --cc=khilman@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=patches@opensource.cirrus.com \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    --cc=ssantosh@kernel.org \
    --cc=thloh@altera.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.