diff options
author | Finn Thain <fthain@telegraphics.com.au> | 2018-05-08 21:04:48 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-05-14 10:27:08 -0400 |
commit | bdeeed098811b36d1f988521600a89a400830a4b (patch) | |
tree | 7447eae93d4e230c85f70eee6ea57c95f3566784 | |
parent | 6be5b5b9c5e0104b009cf6996e4df21877576b91 (diff) |
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>
-rw-r--r-- | drivers/nubus/bus.c | 19 | ||||
-rw-r--r-- | drivers/nubus/nubus.c | 2 | ||||
-rw-r--r-- | include/linux/nubus.h | 2 |
3 files changed, 9 insertions, 14 deletions
diff --git a/drivers/nubus/bus.c b/drivers/nubus/bus.c index d306c348c857..a59b6c4bb5b8 100644 --- a/drivers/nubus/bus.c +++ b/drivers/nubus/bus.c | |||
@@ -63,20 +63,15 @@ static struct device nubus_parent = { | |||
63 | .init_name = "nubus", | 63 | .init_name = "nubus", |
64 | }; | 64 | }; |
65 | 65 | ||
66 | int __init nubus_bus_register(void) | 66 | static int __init nubus_bus_register(void) |
67 | { | 67 | { |
68 | int err; | 68 | return bus_register(&nubus_bus_type); |
69 | 69 | } | |
70 | err = device_register(&nubus_parent); | 70 | postcore_initcall(nubus_bus_register); |
71 | if (err) | ||
72 | return err; | ||
73 | |||
74 | err = bus_register(&nubus_bus_type); | ||
75 | if (!err) | ||
76 | return 0; | ||
77 | 71 | ||
78 | device_unregister(&nubus_parent); | 72 | int __init nubus_parent_device_register(void) |
79 | return err; | 73 | { |
74 | return device_register(&nubus_parent); | ||
80 | } | 75 | } |
81 | 76 | ||
82 | static void nubus_device_release(struct device *dev) | 77 | static void nubus_device_release(struct device *dev) |
diff --git a/drivers/nubus/nubus.c b/drivers/nubus/nubus.c index 4621ff98138c..bb0d63a44f41 100644 --- a/drivers/nubus/nubus.c +++ b/drivers/nubus/nubus.c | |||
@@ -875,7 +875,7 @@ static int __init nubus_init(void) | |||
875 | return 0; | 875 | return 0; |
876 | 876 | ||
877 | nubus_proc_init(); | 877 | nubus_proc_init(); |
878 | err = nubus_bus_register(); | 878 | err = nubus_parent_device_register(); |
879 | if (err) | 879 | if (err) |
880 | return err; | 880 | return err; |
881 | nubus_scan_bus(); | 881 | nubus_scan_bus(); |
diff --git a/include/linux/nubus.h b/include/linux/nubus.h index 6e8200215321..eba50b057f6f 100644 --- a/include/linux/nubus.h +++ b/include/linux/nubus.h | |||
@@ -163,7 +163,7 @@ void nubus_seq_write_rsrc_mem(struct seq_file *m, | |||
163 | unsigned char *nubus_dirptr(const struct nubus_dirent *nd); | 163 | unsigned char *nubus_dirptr(const struct nubus_dirent *nd); |
164 | 164 | ||
165 | /* Declarations relating to driver model objects */ | 165 | /* Declarations relating to driver model objects */ |
166 | int nubus_bus_register(void); | 166 | int nubus_parent_device_register(void); |
167 | int nubus_device_register(struct nubus_board *board); | 167 | int nubus_device_register(struct nubus_board *board); |
168 | int nubus_driver_register(struct nubus_driver *ndrv); | 168 | int nubus_driver_register(struct nubus_driver *ndrv); |
169 | void nubus_driver_unregister(struct nubus_driver *ndrv); | 169 | void nubus_driver_unregister(struct nubus_driver *ndrv); |