Skip to content

Commit b81e314

Browse files
bebarinogregkh
authored andcommitted
firmware: coreboot: Make bus registration symmetric
The bus is registered in module_init() but is unregistered when the platform driver remove() function calls coreboot_table_exit(). That isn't symmetric and it causes the bus to appear on systems that compile this code in, even when there isn't any coreboot firmware on the device. Let's move the registration to the coreboot_table_init() function so that it matches the exit path. Cc: Wei-Ning Huang <[email protected]> Cc: Julius Werner <[email protected]> Cc: Brian Norris <[email protected]> Cc: Samuel Holland <[email protected]> Signed-off-by: Stephen Boyd <[email protected]> Reviewed-by: Julius Werner <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 20edec3 commit b81e314

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

drivers/firmware/google/coreboot_table.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,6 @@ static struct bus_type coreboot_bus_type = {
7070
.remove = coreboot_bus_remove,
7171
};
7272

73-
static int __init coreboot_bus_init(void)
74-
{
75-
return bus_register(&coreboot_bus_type);
76-
}
77-
module_init(coreboot_bus_init);
78-
7973
static void coreboot_device_release(struct device *dev)
8074
{
8175
struct coreboot_device *device = CB_DEV(dev);
@@ -114,6 +108,10 @@ int coreboot_table_init(struct device *dev, void __iomem *ptr)
114108
goto out;
115109
}
116110

111+
ret = bus_register(&coreboot_bus_type);
112+
if (ret)
113+
goto out;
114+
117115
ptr_entry = (void *)ptr_header + header.header_bytes;
118116
for (i = 0; i < header.table_entries; i++) {
119117
memcpy_fromio(&entry, ptr_entry, sizeof(entry));
@@ -138,6 +136,10 @@ int coreboot_table_init(struct device *dev, void __iomem *ptr)
138136

139137
ptr_entry += entry.size;
140138
}
139+
140+
if (ret)
141+
bus_unregister(&coreboot_bus_type);
142+
141143
out:
142144
iounmap(ptr);
143145
return ret;

0 commit comments

Comments
 (0)