Skip to content

Commit bdeeed0

Browse files
Finn Thaingregkh
Finn Thain
authored andcommittedMay 14, 2018
nubus: Call bus_register unconditionally
Loading a NuBus driver module on a non-NuBus machine triggers the BUG_ON(!drv->bus->p) in driver_register(), because bus_register() was not called, because it is conditional on MACH_IS_MAC. Fix the crash by calling bus_register() unconditionally. Call it from a postcore_initcall(), like other busses do. Hence, the bus type is available for device_register(), which happens in a subsys initcall, and for driver_register(), which happens in a device or module initcall. Cc: Greg Kroah-Hartman <[email protected]> Reported-by: Michael Schmitz <[email protected]> Tested-by: Stan Johnson <[email protected]> Fixes: 7f86c76 ("nubus: Add support for the driver model") Signed-off-by: Finn Thain <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 6be5b5b commit bdeeed0

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed
 

‎drivers/nubus/bus.c

+7-12
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,15 @@ static struct device nubus_parent = {
6363
.init_name = "nubus",
6464
};
6565

66-
int __init nubus_bus_register(void)
66+
static int __init nubus_bus_register(void)
6767
{
68-
int err;
69-
70-
err = device_register(&nubus_parent);
71-
if (err)
72-
return err;
73-
74-
err = bus_register(&nubus_bus_type);
75-
if (!err)
76-
return 0;
68+
return bus_register(&nubus_bus_type);
69+
}
70+
postcore_initcall(nubus_bus_register);
7771

78-
device_unregister(&nubus_parent);
79-
return err;
72+
int __init nubus_parent_device_register(void)
73+
{
74+
return device_register(&nubus_parent);
8075
}
8176

8277
static void nubus_device_release(struct device *dev)

‎drivers/nubus/nubus.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ static int __init nubus_init(void)
875875
return 0;
876876

877877
nubus_proc_init();
878-
err = nubus_bus_register();
878+
err = nubus_parent_device_register();
879879
if (err)
880880
return err;
881881
nubus_scan_bus();

‎include/linux/nubus.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ void nubus_seq_write_rsrc_mem(struct seq_file *m,
163163
unsigned char *nubus_dirptr(const struct nubus_dirent *nd);
164164

165165
/* Declarations relating to driver model objects */
166-
int nubus_bus_register(void);
166+
int nubus_parent_device_register(void);
167167
int nubus_device_register(struct nubus_board *board);
168168
int nubus_driver_register(struct nubus_driver *ndrv);
169169
void nubus_driver_unregister(struct nubus_driver *ndrv);

0 commit comments

Comments
 (0)
Please sign in to comment.