diff options
author | Stephen Boyd <swboyd@chromium.org> | 2019-05-10 14:01:47 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-05-24 14:55:04 -0400 |
commit | 354635039d935dba16ba35054b27dd6671fd3d14 (patch) | |
tree | 0d329048115c18436a1cbd847424b321967f552e /drivers/firmware | |
parent | 7ef0b1524417743e6861490420225affe451486b (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.h | 10 | ||||
-rw-r--r-- | drivers/firmware/google/framebuffer-coreboot.c | 14 | ||||
-rw-r--r-- | drivers/firmware/google/memconsole-coreboot.c | 14 | ||||
-rw-r--r-- | drivers/firmware/google/vpd.c | 14 |
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. */ |
92 | void coreboot_driver_unregister(struct coreboot_driver *driver); | 93 | void 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 | 100 | module_coreboot_driver(framebuffer_driver); | |
101 | static int __init coreboot_framebuffer_init(void) | ||
102 | { | ||
103 | return coreboot_driver_register(&framebuffer_driver); | ||
104 | } | ||
105 | |||
106 | static void coreboot_framebuffer_exit(void) | ||
107 | { | ||
108 | coreboot_driver_unregister(&framebuffer_driver); | ||
109 | } | ||
110 | |||
111 | module_init(coreboot_framebuffer_init); | ||
112 | module_exit(coreboot_framebuffer_exit); | ||
113 | 101 | ||
114 | MODULE_AUTHOR("Samuel Holland <samuel@sholland.org>"); | 102 | MODULE_AUTHOR("Samuel Holland <samuel@sholland.org>"); |
115 | MODULE_LICENSE("GPL"); | 103 | MODULE_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 | 119 | module_coreboot_driver(memconsole_driver); | |
120 | static void coreboot_memconsole_exit(void) | ||
121 | { | ||
122 | coreboot_driver_unregister(&memconsole_driver); | ||
123 | } | ||
124 | |||
125 | static int __init coreboot_memconsole_init(void) | ||
126 | { | ||
127 | return coreboot_driver_register(&memconsole_driver); | ||
128 | } | ||
129 | |||
130 | module_exit(coreboot_memconsole_exit); | ||
131 | module_init(coreboot_memconsole_init); | ||
132 | 120 | ||
133 | MODULE_AUTHOR("Google, Inc."); | 121 | MODULE_AUTHOR("Google, Inc."); |
134 | MODULE_LICENSE("GPL"); | 122 | MODULE_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 | 327 | module_coreboot_driver(vpd_driver); | |
328 | static int __init coreboot_vpd_init(void) | ||
329 | { | ||
330 | return coreboot_driver_register(&vpd_driver); | ||
331 | } | ||
332 | |||
333 | static void __exit coreboot_vpd_exit(void) | ||
334 | { | ||
335 | coreboot_driver_unregister(&vpd_driver); | ||
336 | } | ||
337 | |||
338 | module_init(coreboot_vpd_init); | ||
339 | module_exit(coreboot_vpd_exit); | ||
340 | 328 | ||
341 | MODULE_AUTHOR("Google, Inc."); | 329 | MODULE_AUTHOR("Google, Inc."); |
342 | MODULE_LICENSE("GPL"); | 330 | MODULE_LICENSE("GPL"); |