]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
nubus: Switch to dynamic root device
authorJohan Hovold <johan@kernel.org>
Fri, 24 Apr 2026 10:40:11 +0000 (12:40 +0200)
committerGeert Uytterhoeven <geert@linux-m68k.org>
Mon, 18 May 2026 09:16:19 +0000 (11:16 +0200)
Driver core expects devices to be dynamically allocated and will, for
example, complain loudly if a device that lacks a release function is
ever freed.

Use root_device_register() to allocate and register the root device
instead of open coding using a static device.

Signed-off-by: Johan Hovold <johan@kernel.org>
Acked-by: Finn Thain <fthain@linux-m68k.org>
Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
Link: https://patch.msgid.link/20260424104011.2616970-1-johan@kernel.org
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
drivers/nubus/nubus.c

index 559dce302d0636b28ac7ee1061ad4135c29257e7..40ce4991c356341ba1e20de04fc0da1eccdec376 100644 (file)
@@ -41,9 +41,7 @@ module_param_named(populate_procfs, nubus_populate_procfs, bool, 0);
 
 LIST_HEAD(nubus_func_rsrcs);
 
-static struct device nubus_parent = {
-       .init_name      = "nubus",
-};
+static struct device *nubus_parent;
 
 /* Meaning of "bytelanes":
 
@@ -833,7 +831,7 @@ static void __init nubus_add_board(int slot, int bytelanes)
                list_add_tail(&fres->list, &nubus_func_rsrcs);
        }
 
-       if (nubus_device_register(&nubus_parent, board))
+       if (nubus_device_register(nubus_parent, board))
                put_device(&board->dev);
 }
 
@@ -880,18 +878,17 @@ static void __init nubus_scan_bus(void)
 
 static int __init nubus_init(void)
 {
-       int err;
-
        if (!MACH_IS_MAC)
                return 0;
 
        nubus_proc_init();
-       err = device_register(&nubus_parent);
-       if (err) {
-               put_device(&nubus_parent);
-               return err;
-       }
+
+       nubus_parent = root_device_register("nubus");
+       if (IS_ERR(nubus_parent))
+               return PTR_ERR(nubus_parent);
+
        nubus_scan_bus();
+
        return 0;
 }