mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] Introduce device_platform_driver() macro
@ 2013-02-08 18:07 Alexander Shiyan
  2013-02-08 18:07 ` [PATCH 2/2] Use new device_platform_driver() macro for drivers Alexander Shiyan
  2013-02-11  9:38 ` [PATCH 1/2] Introduce device_platform_driver() macro Sascha Hauer
  0 siblings, 2 replies; 6+ messages in thread
From: Alexander Shiyan @ 2013-02-08 18:07 UTC (permalink / raw)
  To: barebox

device_platform_driver() - Helper macro for drivers that don't do
anything special in module registration. This eliminates a lot of
boilerplate. Driver registration will called on device_initcall.

Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
---
 include/driver.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/include/driver.h b/include/driver.h
index 31f5d69..d8ac66c 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -390,6 +390,18 @@ extern struct list_head bus_list;
 extern struct bus_type platform_bus;
 
 int platform_driver_register(struct driver_d *drv);
+
+/* device_platform_driver() - Helper macro for drivers that don't do
+ * anything special in module registration. This eliminates a lot of
+ * boilerplate. Each module may only use this macro once.
+ */
+#define device_platform_driver(drv)				\
+	static int __init device_platform_driver_init(void)	\
+	{							\
+		return platform_driver_register(&drv);		\
+	}							\
+	device_initcall(device_platform_driver_init)
+
 int platform_device_register(struct device_d *new_device);
 
 struct file_operations {
-- 
1.7.12.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-02-12  8:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-08 18:07 [PATCH 1/2] Introduce device_platform_driver() macro Alexander Shiyan
2013-02-08 18:07 ` [PATCH 2/2] Use new device_platform_driver() macro for drivers Alexander Shiyan
2013-02-11  9:38 ` [PATCH 1/2] Introduce device_platform_driver() macro Sascha Hauer
2013-02-12  6:57   ` Re[2]: " Alexander Shiyan
2013-02-12  7:44     ` Sascha Hauer
2013-02-12  8:01       ` Re[2]: " Alexander Shiyan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox