nubus: Call bus_register unconditionally
authorFinn Thain <fthain@telegraphics.com.au>
Wed, 9 May 2018 01:04:48 +0000 (11:04 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 14 May 2018 14:27:08 +0000 (16:27 +0200)
commitbdeeed098811b36d1f988521600a89a400830a4b
tree7447eae93d4e230c85f70eee6ea57c95f3566784
parent6be5b5b9c5e0104b009cf6996e4df21877576b91
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 <gregkh@linuxfoundation.org>
Reported-by: Michael Schmitz <schmitzmic@gmail.com>
Tested-by: Stan Johnson <userm57@yahoo.com>
Fixes: 7f86c765a6a2 ("nubus: Add support for the driver model")
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/nubus/bus.c
drivers/nubus/nubus.c
include/linux/nubus.h