summaryrefslogtreecommitdiffstats
path: root/drivers/firmware
diff options
context:
space:
mode:
authorStephen Boyd <swboyd@chromium.org>2019-05-10 14:01:47 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-05-24 14:55:04 -0400
commit354635039d935dba16ba35054b27dd6671fd3d14 (patch)
tree0d329048115c18436a1cbd847424b321967f552e /drivers/firmware
parent7ef0b1524417743e6861490420225affe451486b (diff)
firmware: google: Add a module_coreboot_driver() macro and use it
Remove some boiler plate code we have in three drivers with a single line each time. This also gets us a free assignment of the driver .owner field, making these drivers work better as modules. Cc: Wei-Ning Huang <wnhuang@chromium.org> Cc: Julius Werner <jwerner@chromium.org> Cc: Brian Norris <briannorris@chromium.org> Cc: Samuel Holland <samuel@sholland.org> Cc: Guenter Roeck <groeck@chromium.org> Signed-off-by: Stephen Boyd <swboyd@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Samuel Holland <samuel@sholland.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/firmware')
-rw-r--r--drivers/firmware/google/coreboot_table.h10
-rw-r--r--drivers/firmware/google/framebuffer-coreboot.c14
-rw-r--r--drivers/firmware/google/memconsole-coreboot.c14
-rw-r--r--drivers/firmware/google/vpd.c14
4 files changed, 13 insertions, 39 deletions
diff --git a/drivers/firmware/google/coreboot_table.h b/drivers/firmware/google/coreboot_table.h
index 71a9de6b15fa..054fa9374c59 100644
--- a/drivers/firmware/google/coreboot_table.h
+++ b/drivers/firmware/google/coreboot_table.h
@@ -20,6 +20,7 @@
20#ifndef __COREBOOT_TABLE_H 20#ifndef __COREBOOT_TABLE_H
21#define __COREBOOT_TABLE_H 21#define __COREBOOT_TABLE_H
22 22
23#include <linux/device.h>
23#include <linux/io.h> 24#include <linux/io.h>
24 25
25/* Coreboot table header structure */ 26/* Coreboot table header structure */
@@ -91,4 +92,13 @@ int coreboot_driver_register(struct coreboot_driver *driver);
91/* Unregister a driver that uses the data from a coreboot table. */ 92/* Unregister a driver that uses the data from a coreboot table. */
92void coreboot_driver_unregister(struct coreboot_driver *driver); 93void coreboot_driver_unregister(struct coreboot_driver *driver);
93 94
95/* module_coreboot_driver() - Helper macro for drivers that don't do
96 * anything special in module init/exit. This eliminates a lot of
97 * boilerplate. Each module may only use this macro once, and
98 * calling it replaces module_init() and module_exit()
99 */
100#define module_coreboot_driver(__coreboot_driver) \
101 module_driver(__coreboot_driver, coreboot_driver_register, \
102 coreboot_driver_unregister)
103
94#endif /* __COREBOOT_TABLE_H */ 104#endif /* __COREBOOT_TABLE_H */
diff --git a/drivers/firmware/google/framebuffer-coreboot.c b/drivers/firmware/google/framebuffer-coreboot.c
index b8b49c067157..69a43116211c 100644
--- a/drivers/firmware/google/framebuffer-coreboot.c
+++ b/drivers/firmware/google/framebuffer-coreboot.c
@@ -97,19 +97,7 @@ static struct coreboot_driver framebuffer_driver = {
97 }, 97 },
98 .tag = CB_TAG_FRAMEBUFFER, 98 .tag = CB_TAG_FRAMEBUFFER,
99}; 99};
100 100module_coreboot_driver(framebuffer_driver);
101static int __init coreboot_framebuffer_init(void)
102{
103 return coreboot_driver_register(&framebuffer_driver);
104}
105
106static void coreboot_framebuffer_exit(void)
107{
108 coreboot_driver_unregister(&framebuffer_driver);
109}
110
111module_init(coreboot_framebuffer_init);
112module_exit(coreboot_framebuffer_exit);
113 101
114MODULE_AUTHOR("Samuel Holland <samuel@sholland.org>"); 102MODULE_AUTHOR("Samuel Holland <samuel@sholland.org>");
115MODULE_LICENSE("GPL"); 103MODULE_LICENSE("GPL");
diff --git a/drivers/firmware/google/memconsole-coreboot.c b/drivers/firmware/google/memconsole-coreboot.c
index b29e10757bfb..86331807f1d5 100644
--- a/drivers/firmware/google/memconsole-coreboot.c
+++ b/drivers/firmware/google/memconsole-coreboot.c
@@ -116,19 +116,7 @@ static struct coreboot_driver memconsole_driver = {
116 }, 116 },
117 .tag = CB_TAG_CBMEM_CONSOLE, 117 .tag = CB_TAG_CBMEM_CONSOLE,
118}; 118};
119 119module_coreboot_driver(memconsole_driver);
120static void coreboot_memconsole_exit(void)
121{
122 coreboot_driver_unregister(&memconsole_driver);
123}
124
125static int __init coreboot_memconsole_init(void)
126{
127 return coreboot_driver_register(&memconsole_driver);
128}
129
130module_exit(coreboot_memconsole_exit);
131module_init(coreboot_memconsole_init);
132 120
133MODULE_AUTHOR("Google, Inc."); 121MODULE_AUTHOR("Google, Inc.");
134MODULE_LICENSE("GPL"); 122MODULE_LICENSE("GPL");
diff --git a/drivers/firmware/google/vpd.c b/drivers/firmware/google/vpd.c
index f240946ed701..12547386bac8 100644
--- a/drivers/firmware/google/vpd.c
+++ b/drivers/firmware/google/vpd.c
@@ -324,19 +324,7 @@ static struct coreboot_driver vpd_driver = {
324 }, 324 },
325 .tag = CB_TAG_VPD, 325 .tag = CB_TAG_VPD,
326}; 326};
327 327module_coreboot_driver(vpd_driver);
328static int __init coreboot_vpd_init(void)
329{
330 return coreboot_driver_register(&vpd_driver);
331}
332
333static void __exit coreboot_vpd_exit(void)
334{
335 coreboot_driver_unregister(&vpd_driver);
336}
337
338module_init(coreboot_vpd_init);
339module_exit(coreboot_vpd_exit);
340 328
341MODULE_AUTHOR("Google, Inc."); 329MODULE_AUTHOR("Google, Inc.");
342MODULE_LICENSE("GPL"); 330MODULE_LICENSE("GPL");