linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nubus: Unconditionally register bus type
@ 2018-05-06  1:47 Finn Thain
  0 siblings, 0 replies; 22+ messages in thread
From: Finn Thain @ 2018-05-06  1:47 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Greg Kroah-Hartman, linux-m68k, linux-kernel

Loading a NuBus driver module on a non-NuBus machine triggers the
BUG_ON(!drv->bus->p) in driver_register() because the bus does not get
registered unless MACH_IS_MAC(). Avoid this by registering the bus
unconditionally using postcore_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>
---
 drivers/nubus/bus.c   | 3 ++-
 drivers/nubus/nubus.c | 5 -----
 include/linux/nubus.h | 1 -
 3 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/nubus/bus.c b/drivers/nubus/bus.c
index d306c348c857..27ca9f1a281b 100644
--- a/drivers/nubus/bus.c
+++ b/drivers/nubus/bus.c
@@ -63,7 +63,7 @@ static struct device nubus_parent = {
 	.init_name	= "nubus",
 };
 
-int __init nubus_bus_register(void)
+static int __init nubus_bus_register(void)
 {
 	int err;
 
@@ -78,6 +78,7 @@ int __init nubus_bus_register(void)
 	device_unregister(&nubus_parent);
 	return err;
 }
+postcore_initcall(nubus_bus_register);
 
 static void nubus_device_release(struct device *dev)
 {
diff --git a/drivers/nubus/nubus.c b/drivers/nubus/nubus.c
index 4621ff98138c..f6bab483f4cb 100644
--- a/drivers/nubus/nubus.c
+++ b/drivers/nubus/nubus.c
@@ -869,15 +869,10 @@ 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 = nubus_bus_register();
-	if (err)
-		return err;
 	nubus_scan_bus();
 	return 0;
 }
diff --git a/include/linux/nubus.h b/include/linux/nubus.h
index 6e8200215321..f01e7f4bcff8 100644
--- a/include/linux/nubus.h
+++ b/include/linux/nubus.h
@@ -163,7 +163,6 @@ void nubus_seq_write_rsrc_mem(struct seq_file *m,
 unsigned char *nubus_dirptr(const struct nubus_dirent *nd);
 
 /* Declarations relating to driver model objects */
-int nubus_bus_register(void);
 int nubus_device_register(struct nubus_board *board);
 int nubus_driver_register(struct nubus_driver *ndrv);
 void nubus_driver_unregister(struct nubus_driver *ndrv);
-- 
2.16.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread
* [PATCH] nubus: Unconditionally register bus type
@ 2018-05-06  1:47 Finn Thain
  2018-05-06  4:55 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 22+ messages in thread
From: Finn Thain @ 2018-05-06  1:47 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Greg Kroah-Hartman, linux-m68k, linux-kernel

Loading a NuBus driver module on a non-NuBus machine triggers the
BUG_ON(!drv->bus->p) in driver_register() because the bus does not get
registered unless MACH_IS_MAC(). Avoid this by registering the bus
unconditionally using postcore_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>
---
 drivers/nubus/bus.c   | 3 ++-
 drivers/nubus/nubus.c | 5 -----
 include/linux/nubus.h | 1 -
 3 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/nubus/bus.c b/drivers/nubus/bus.c
index d306c348c857..27ca9f1a281b 100644
--- a/drivers/nubus/bus.c
+++ b/drivers/nubus/bus.c
@@ -63,7 +63,7 @@ static struct device nubus_parent = {
 	.init_name	= "nubus",
 };
 
-int __init nubus_bus_register(void)
+static int __init nubus_bus_register(void)
 {
 	int err;
 
@@ -78,6 +78,7 @@ int __init nubus_bus_register(void)
 	device_unregister(&nubus_parent);
 	return err;
 }
+postcore_initcall(nubus_bus_register);
 
 static void nubus_device_release(struct device *dev)
 {
diff --git a/drivers/nubus/nubus.c b/drivers/nubus/nubus.c
index 4621ff98138c..f6bab483f4cb 100644
--- a/drivers/nubus/nubus.c
+++ b/drivers/nubus/nubus.c
@@ -869,15 +869,10 @@ 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 = nubus_bus_register();
-	if (err)
-		return err;
 	nubus_scan_bus();
 	return 0;
 }
diff --git a/include/linux/nubus.h b/include/linux/nubus.h
index 6e8200215321..f01e7f4bcff8 100644
--- a/include/linux/nubus.h
+++ b/include/linux/nubus.h
@@ -163,7 +163,6 @@ void nubus_seq_write_rsrc_mem(struct seq_file *m,
 unsigned char *nubus_dirptr(const struct nubus_dirent *nd);
 
 /* Declarations relating to driver model objects */
-int nubus_bus_register(void);
 int nubus_device_register(struct nubus_board *board);
 int nubus_driver_register(struct nubus_driver *ndrv);
 void nubus_driver_unregister(struct nubus_driver *ndrv);
-- 
2.16.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2018-05-08  8:27 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <5aee5ede.1c69fb81.353b4.5021SMTPIN_ADDED_MISSING@mx.google.com>
2018-05-08  7:39 ` [PATCH] nubus: Unconditionally register bus type Geert Uytterhoeven
2018-05-08  8:27   ` Finn Thain
2018-05-06  1:47 Finn Thain
  -- strict thread matches above, loose matches on Subject: below --
2018-05-06  1:47 Finn Thain
2018-05-06  4:55 ` Greg Kroah-Hartman
2018-05-06  6:00   ` Finn Thain
2018-05-06 20:20     ` Greg Kroah-Hartman
2018-05-06 21:51       ` Michael Schmitz
2018-05-08  7:00         ` Greg Kroah-Hartman
2018-05-08  7:07           ` Geert Uytterhoeven
2018-05-08  7:25             ` Greg Kroah-Hartman
2018-05-08  7:35               ` Geert Uytterhoeven
2018-05-08  7:41                 ` Greg Kroah-Hartman
2018-05-08  8:01               ` Michael Schmitz
2018-05-06 23:57       ` Finn Thain
2018-05-07 12:53         ` Geert Uytterhoeven
2018-05-07 14:45           ` Greg Kroah-Hartman
2018-05-08  6:28             ` Geert Uytterhoeven
2018-05-07 23:44         ` Finn Thain
2018-05-08  6:32           ` Geert Uytterhoeven
2018-05-08  7:59             ` Finn Thain
2018-05-08  7:01         ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).