]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
firmware: coreboot: Make bus registration symmetric
authorStephen Boyd <swboyd@chromium.org>
Wed, 15 Aug 2018 20:37:05 +0000 (13:37 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 14 Sep 2018 13:37:23 +0000 (15:37 +0200)
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 <wnhuang@chromium.org>
Cc: Julius Werner <jwerner@chromium.org>
Cc: Brian Norris <briannorris@chromium.org>
Cc: Samuel Holland <samuel@sholland.org>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/firmware/google/coreboot_table.c

index 898bb9abc41f153204284a625edea91e4631b3fd..f417170f83ea443e762dbed716dc35dc8b41f237 100644 (file)
@@ -70,12 +70,6 @@ static struct bus_type coreboot_bus_type = {
        .remove         = coreboot_bus_remove,
 };
 
-static int __init coreboot_bus_init(void)
-{
-       return bus_register(&coreboot_bus_type);
-}
-module_init(coreboot_bus_init);
-
 static void coreboot_device_release(struct device *dev)
 {
        struct coreboot_device *device = CB_DEV(dev);
@@ -114,6 +108,10 @@ int coreboot_table_init(struct device *dev, void __iomem *ptr)
                goto out;
        }
 
+       ret = bus_register(&coreboot_bus_type);
+       if (ret)
+               goto out;
+
        ptr_entry = (void *)ptr_header + header.header_bytes;
        for (i = 0; i < header.table_entries; i++) {
                memcpy_fromio(&entry, ptr_entry, sizeof(entry));
@@ -138,6 +136,10 @@ int coreboot_table_init(struct device *dev, void __iomem *ptr)
 
                ptr_entry += entry.size;
        }
+
+       if (ret)
+               bus_unregister(&coreboot_bus_type);
+
 out:
        iounmap(ptr);
        return ret;