hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/firmware/google/memconsole-coreboot.c
....@@ -1,21 +1,14 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * memconsole-coreboot.c
34 *
45 * Memory based BIOS console accessed through coreboot table.
56 *
67 * Copyright 2017 Google Inc.
7
- *
8
- * This program is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License v2.0 as published by
10
- * the Free Software Foundation.
11
- *
12
- * This program is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- * GNU General Public License for more details.
168 */
179
1810 #include <linux/device.h>
11
+#include <linux/io.h>
1912 #include <linux/kernel.h>
2013 #include <linux/module.h>
2114
....@@ -28,13 +21,13 @@
2821 struct cbmem_cons {
2922 u32 size_dont_access_after_boot;
3023 u32 cursor;
31
- u8 body[0];
24
+ u8 body[];
3225 } __packed;
3326
3427 #define CURSOR_MASK ((1 << 28) - 1)
3528 #define OVERFLOW (1 << 31)
3629
37
-static struct cbmem_cons __iomem *cbmem_console;
30
+static struct cbmem_cons *cbmem_console;
3831 static u32 cbmem_console_size;
3932
4033 /*
....@@ -75,7 +68,7 @@
7568
7669 static int memconsole_probe(struct coreboot_device *dev)
7770 {
78
- struct cbmem_cons __iomem *tmp_cbmc;
71
+ struct cbmem_cons *tmp_cbmc;
7972
8073 tmp_cbmc = memremap(dev->cbmem_ref.cbmem_addr,
8174 sizeof(*tmp_cbmc), MEMREMAP_WB);
....@@ -85,13 +78,13 @@
8578
8679 /* Read size only once to prevent overrun attack through /dev/mem. */
8780 cbmem_console_size = tmp_cbmc->size_dont_access_after_boot;
88
- cbmem_console = memremap(dev->cbmem_ref.cbmem_addr,
81
+ cbmem_console = devm_memremap(&dev->dev, dev->cbmem_ref.cbmem_addr,
8982 cbmem_console_size + sizeof(*cbmem_console),
9083 MEMREMAP_WB);
9184 memunmap(tmp_cbmc);
9285
93
- if (!cbmem_console)
94
- return -ENOMEM;
86
+ if (IS_ERR(cbmem_console))
87
+ return PTR_ERR(cbmem_console);
9588
9689 memconsole_setup(memconsole_coreboot_read);
9790
....@@ -101,9 +94,6 @@
10194 static int memconsole_remove(struct coreboot_device *dev)
10295 {
10396 memconsole_exit();
104
-
105
- if (cbmem_console)
106
- memunmap(cbmem_console);
10797
10898 return 0;
10999 }
....@@ -116,19 +106,7 @@
116106 },
117107 .tag = CB_TAG_CBMEM_CONSOLE,
118108 };
119
-
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);
109
+module_coreboot_driver(memconsole_driver);
132110
133111 MODULE_AUTHOR("Google, Inc.");
134112 MODULE_LICENSE("GPL");