diff -urN linux-test9/Makefile linux/Makefile
--- linux-test9/Makefile	Thu Oct  5 22:21:00 2000
+++ linux/Makefile	Thu Oct  5 22:24:11 2000
@@ -144,7 +144,13 @@
 DRIVERS-$(CONFIG_ARCNET) += drivers/net/arcnet/arcnet.a
 DRIVERS-$(CONFIG_ATM) += drivers/atm/atm.o
 DRIVERS-$(CONFIG_IDE) += drivers/ide/idedriver.o
+
+# Init ordering constraint:
+# scsidrv.o < !drivers/scsi < scsi_upper.o
 DRIVERS-$(CONFIG_SCSI) += drivers/scsi/scsidrv.o
+DRIVERS-$(CONFIG_I2O) += drivers/i2o/i2o.o
+DRIVERS-$(CONFIG_SCSI) += drivers/scsi/upper/scsi_upper.o
+
 DRIVERS-$(CONFIG_IEEE1394) += drivers/ieee1394/ieee1394.a
 
 ifneq ($(CONFIG_CD_NO_IDESCSI)$(CONFIG_BLK_DEV_IDECD)$(CONFIG_BLK_DEV_SR)$(CONFIG_PARIDE_PCD),)
@@ -171,7 +177,6 @@
 DRIVERS-$(CONFIG_TC) += drivers/tc/tc.a
 DRIVERS-$(CONFIG_USB) += drivers/usb/usbdrv.o
 DRIVERS-$(CONFIG_INPUT) += drivers/input/inputdrv.o
-DRIVERS-$(CONFIG_I2O) += drivers/i2o/i2o.o
 DRIVERS-$(CONFIG_IRDA) += drivers/net/irda/irda.o
 DRIVERS-$(CONFIG_I2C) += drivers/i2c/i2c.o
 DRIVERS-$(CONFIG_PHONE) += drivers/telephony/telephony.o
diff -urN linux-test9/drivers/block/genhd.c linux/drivers/block/genhd.c
--- linux-test9/drivers/block/genhd.c	Thu Oct  5 22:21:03 2000
+++ linux/drivers/block/genhd.c	Thu Oct  5 22:24:11 2000
@@ -27,7 +27,6 @@
 extern void console_map_init(void);
 extern int soc_probe(void);
 extern int atmdev_init(void);
-extern int i2o_init(void);
 extern int cpqarray_init(void);
 extern void ieee1394_init(void);
 
@@ -39,9 +38,6 @@
 	chr_dev_init();
 	blk_dev_init();
 	sti();
-#ifdef CONFIG_I2O
-	i2o_init();
-#endif
 #ifdef CONFIG_BLK_DEV_DAC960
 	DAC960_Initialize();
 #endif
diff -urN linux-test9/drivers/i2o/i2o_block.c linux/drivers/i2o/i2o_block.c
--- linux-test9/drivers/i2o/i2o_block.c	Thu Oct  5 22:21:04 2000
+++ linux/drivers/i2o/i2o_block.c	Thu Oct  5 22:28:24 2000
@@ -46,6 +46,7 @@
 #include <linux/fs.h>
 #include <linux/stat.h>
 #include <linux/errno.h>
+#include <linux/init.h>
 #include <linux/file.h>
 #include <linux/ioctl.h>
 #include <linux/i2o.h>
@@ -1591,11 +1592,7 @@
  *  (Just smiley confuses emacs :-)
  */
 
-#ifdef MODULE
-#define i2o_block_init init_module
-#endif
-
-int i2o_block_init(void)
+static int __init i2o_block_init(void)
 {
 	int i;
 
@@ -1611,9 +1608,8 @@
 		       MAJOR_NR);
 		return -EIO;
 	}
-#ifdef MODULE
+	
 	printk(KERN_INFO "i2o_block: registered device at major %d\n", MAJOR_NR);
-#endif
 
 	/*
 	 *	Now fill in the boiler plate
@@ -1694,13 +1690,7 @@
 	return 0;
 }
 
-#ifdef MODULE
-
-EXPORT_NO_SYMBOLS;
-MODULE_AUTHOR("Red Hat Software");
-MODULE_DESCRIPTION("I2O Block Device OSM");
-
-void cleanup_module(void)
+static void __exit i2o_block_exit(void)
 {
 	struct gendisk **gdp;
 	int i;
@@ -1760,4 +1750,10 @@
 			break;
 
 }
-#endif
+
+MODULE_AUTHOR("Red Hat Software");
+MODULE_DESCRIPTION("I2O Block Device OSM");
+
+module_init(i2o_block_init);
+module_exit(i2o_block_exit);
+
diff -urN linux-test9/drivers/i2o/i2o_config.c linux/drivers/i2o/i2o_config.c
--- linux-test9/drivers/i2o/i2o_config.c	Thu Oct  5 22:21:04 2000
+++ linux/drivers/i2o/i2o_config.c	Thu Oct  5 22:46:18 2000
@@ -910,11 +910,7 @@
 	&config_fops
 };	
 
-#ifdef MODULE
-int init_module(void)
-#else
-int __init i2o_config_init(void)
-#endif
+static int __init i2o_config_init(void)
 {
 	printk(KERN_INFO "I2O configuration manager v 0.04.\n");
 	printk(KERN_INFO "  (C) Copyright 1999 Red Hat Software\n");
@@ -948,9 +944,7 @@
 	return 0;
 }
 
-#ifdef MODULE
-
-void cleanup_module(void)
+void __exit i2o_config_exit(void)
 {
 	misc_deregister(&i2o_miscdev);
 	
@@ -961,9 +955,10 @@
 	if(i2o_buffer)
 		kfree(i2o_buffer);
 }
+
+module_init(i2o_config_init);
+module_exit(i2o_config_exit);
  
-EXPORT_NO_SYMBOLS;
 MODULE_AUTHOR("Red Hat Software");
 MODULE_DESCRIPTION("I2O Configuration");
 
-#endif
diff -urN linux-test9/drivers/i2o/i2o_core.c linux/drivers/i2o/i2o_core.c
--- linux-test9/drivers/i2o/i2o_core.c	Thu Oct  5 22:21:04 2000
+++ linux/drivers/i2o/i2o_core.c	Thu Oct  5 22:24:11 2000
@@ -19,7 +19,7 @@
  *		Auvo Häkkinen <Auvo.Hakkinen@cs.Helsinki.FI> 
  *		Deepak Saxena <deepak@plexity.net> 
  *		Boji T Kannanthanam <boji.t.kannanthanam@intel.com>
- * 
+ *		Torben Mathiasen <torben@kernel.dk> 
  */
 
 #include <linux/config.h>
@@ -119,7 +119,6 @@
  */
 static spinlock_t i2o_dev_lock = SPIN_LOCK_UNLOCKED;
 
-#ifdef MODULE
 /* 
  * Function table to send to bus specific layers
  * See <include/linux/i2o.h> for explanation of this
@@ -134,12 +133,9 @@
 	i2o_delete_controller
 };
 
-#ifdef CONFIG_I2O_PCI_MODULE
 extern int i2o_pci_core_attach(struct i2o_core_func_table *);
 extern void i2o_pci_core_detach(void);
-#endif /* CONFIG_I2O_PCI_MODULE */
 
-#endif /* MODULE */
 
 /*
  * Structures and definitions for synchronous message posting.
@@ -3115,8 +3111,6 @@
 }
 
 
-#ifdef MODULE
-
 EXPORT_SYMBOL(i2o_controller_chain);
 EXPORT_SYMBOL(i2o_num_controllers);
 EXPORT_SYMBOL(i2o_find_controller);
@@ -3152,8 +3146,7 @@
 MODULE_AUTHOR("Red Hat Software");
 MODULE_DESCRIPTION("I2O Core");
 
-
-int init_module(void)
+static int __init init_i2o(void)
 {
 	printk(KERN_INFO "I2O Core - (C) Copyright 1999 Red Hat Software\n");
 	if (i2o_install_handler(&i2o_core_handler) < 0)
@@ -3168,10 +3161,8 @@
 	/*
 	 * Attach core to I2O PCI transport (and others as they are developed)
 	 */
-#ifdef CONFIG_I2O_PCI_MODULE
 	if(i2o_pci_core_attach(&i2o_core_functions) < 0)
 		printk(KERN_INFO "i2o: No PCI I2O controllers found\n");
-#endif
 
 	/*
 	 * Initialize event handling thread
@@ -3195,7 +3186,7 @@
 	return 0;
 }
 
-void cleanup_module(void)
+static void __exit exit_i2o(void)
 {
 	int stat;
 
@@ -3221,72 +3212,14 @@
 		}
 	}
 
-#ifdef CONFIG_I2O_PCI_MODULE
 	i2o_pci_core_detach();
-#endif
 
 	i2o_remove_handler(&i2o_core_handler);
 
 	unregister_reboot_notifier(&i2o_reboot_notifier);
 }
 
-#else
-
-extern int i2o_block_init(void);
-extern int i2o_config_init(void);
-extern int i2o_lan_init(void);
-extern int i2o_pci_init(void);
-extern int i2o_proc_init(void);
-extern int i2o_scsi_init(void);
-
-int __init i2o_init(void)
-{
-	printk(KERN_INFO "Loading I2O Core - (c) Copyright 1999 Red Hat Software\n");
-	
-	if (i2o_install_handler(&i2o_core_handler) < 0)
-	{
-		printk(KERN_ERR 
-			"i2o_core: Unable to install core handler.\nI2O stack not loaded!");
-		return 0;
-	}
-
-	core_context = i2o_core_handler.context;
-
-	/*
-	 * Initialize event handling thread
-	 * We may not find any controllers, but still want this as 
-	 * down the road we may have hot pluggable controllers that
-	 * need to be dealt with.
-	 */	
-	init_MUTEX_LOCKED(&evt_sem);
-	if((evt_pid = kernel_thread(i2o_core_evt, &evt_reply, CLONE_SIGHAND)) < 0)
-	{
-		printk(KERN_ERR "I2O: Could not create event handler kernel thread\n");
-		i2o_remove_handler(&i2o_core_handler);
-		return 0;
-	}
-
+module_init(init_i2o);
+module_exit(exit_i2o);
 
-#ifdef CONFIG_I2O_PCI
-	i2o_pci_init();
-#endif
 
-	if(i2o_num_controllers)
-		i2o_sys_init();
-
-	register_reboot_notifier(&i2o_reboot_notifier);
-
-	i2o_config_init();
-#ifdef CONFIG_I2O_BLOCK
-	i2o_block_init();
-#endif
-#ifdef CONFIG_I2O_LAN
-	i2o_lan_init();
-#endif
-#ifdef CONFIG_I2O_PROC
-	i2o_proc_init();
-#endif
-	return 0;
-}
-
-#endif
diff -urN linux-test9/drivers/i2o/i2o_lan.c linux/drivers/i2o/i2o_lan.c
--- linux-test9/drivers/i2o/i2o_lan.c	Thu Oct  5 22:21:04 2000
+++ linux/drivers/i2o/i2o_lan.c	Thu Oct  5 22:46:07 2000
@@ -1421,11 +1421,8 @@
 	return dev;
 }
 
-#ifdef MODULE
-#define i2o_lan_init	init_module
-#endif
 
-int __init i2o_lan_init(void)
+static int __init i2o_lan_init(void)
 {
 	struct net_device *dev;
 	int i;
@@ -1506,9 +1503,8 @@
 	return 0;
 }
 
-#ifdef MODULE
 
-void cleanup_module(void)
+static void __exit i2o_lan_exit(void)
 {
 	int i;
 
@@ -1551,7 +1547,6 @@
 	i2o_remove_handler(&i2o_lan_receive_handler);
 }
 
-EXPORT_NO_SYMBOLS;
 
 MODULE_AUTHOR("University of Helsinki, Department of Computer Science");
 MODULE_DESCRIPTION("I2O Lan OSM");
@@ -1565,4 +1560,5 @@
 MODULE_PARM(tx_batch_mode, "0-2" "i");
 MODULE_PARM_DESC(tx_batch_mode, "0=Send immediatelly, 1=Send in batches, 2=Switch automatically");
 
-#endif
+module_init(i2o_lan_init);
+module_exit(i2o_lan_exit);
diff -urN linux-test9/drivers/i2o/i2o_pci.c linux/drivers/i2o/i2o_pci.c
--- linux-test9/drivers/i2o/i2o_pci.c	Thu Oct  5 22:21:04 2000
+++ linux/drivers/i2o/i2o_pci.c	Thu Oct  5 22:24:11 2000
@@ -31,7 +31,6 @@
 #include <asm/mtrr.h>
 #endif // CONFIG_MTRR
 
-#ifdef MODULE
 /*
  * Core function table
  * See <include/linux/i2o.h> for an explanation
@@ -41,7 +40,6 @@
 /* Core attach function */
 extern int i2o_pci_core_attach(struct i2o_core_func_table *);
 extern void i2o_pci_core_detach(void);
-#endif /* MODULE */
 
 /*
  *	Free bus specific resources
@@ -304,8 +302,6 @@
 }
 #endif // I2O_HOTPLUG_SUPPORT
 
-#ifdef MODULE
-
 int i2o_pci_core_attach(struct i2o_core_func_table *table)
 {
 	MOD_INC_USE_COUNT;
@@ -322,7 +318,7 @@
 	MOD_DEC_USE_COUNT;
 }
 
-int init_module(void)
+static int __init i2o_pci_init(void)
 {
 	printk(KERN_INFO "Linux I2O PCI support (c) 1999 Red Hat Software.\n");
 	
@@ -332,20 +328,16 @@
  
 }
 
-void cleanup_module(void)
+static void __exit i2o_pci_exit(void)
 {
 }
 
+module_init(i2o_pci_init);
+module_exit(i2o_pci_exit);
+
 EXPORT_SYMBOL(i2o_pci_core_attach);
 EXPORT_SYMBOL(i2o_pci_core_detach);
 
 MODULE_AUTHOR("Red Hat Software");
 MODULE_DESCRIPTION("I2O PCI Interface");
 
-#else
-void __init i2o_pci_init(void)
-{
-	printk(KERN_INFO "Linux I2O PCI support (c) 1999 Red Hat Software.\n");
-	i2o_pci_scan();
-}
-#endif
diff -urN linux-test9/drivers/i2o/i2o_proc.c linux/drivers/i2o/i2o_proc.c
--- linux-test9/drivers/i2o/i2o_proc.c	Thu Oct  5 22:21:04 2000
+++ linux/drivers/i2o/i2o_proc.c	Thu Oct  5 22:24:11 2000
@@ -3365,8 +3365,6 @@
 	i2o_remove_handler(&i2o_proc_handler);
 }
 
-#ifdef MODULE
 module_init(i2o_proc_init);
-#endif
 module_exit(i2o_proc_exit);
 
diff -urN linux-test9/drivers/i2o/i2o_scsi.c linux/drivers/i2o/i2o_scsi.c
--- linux-test9/drivers/i2o/i2o_scsi.c	Thu Oct  5 22:21:04 2000
+++ linux/drivers/i2o/i2o_scsi.c	Thu Oct  5 22:24:11 2000
@@ -902,12 +902,8 @@
 	return 0;
 }
 
-/* Loadable module support */
-#ifdef MODULE
-
 MODULE_AUTHOR("Red Hat Software");
 
 Scsi_Host_Template driver_template = I2OSCSI;
 
 #include "../scsi/scsi_module.c"
-#endif
diff -urN linux-test9/drivers/scsi/Makefile linux/drivers/scsi/Makefile
--- linux-test9/drivers/scsi/Makefile	Thu Oct  5 22:21:03 2000
+++ linux/drivers/scsi/Makefile	Thu Oct  5 22:24:11 2000
@@ -6,12 +6,14 @@
 #
 # 20 Sep 2000, Torben Mathiasen <tmm@image.dk>
 # Changed link order to reflect new scsi initialization.
+#
+# 21 Sep 2000, Michael Elizabeth Chastain <mec@shout.net>
+# Moved upper level drivers to drivers/scsi/upper.
 
 O_TARGET := scsidrv.o
 
-SUB_DIRS	:=
-MOD_SUB_DIRS	:=
-MOD_IN_SUB_DIRS	:=
+SUB_DIRS	:= upper
+MOD_IN_SUB_DIRS	:= $(SUB_DIRS)
 ALL_SUB_DIRS	:= $(SUB_DIRS) pcmcia
 
 ifeq ($(CONFIG_PCMCIA),y)
@@ -111,11 +113,6 @@
 obj-$(CONFIG_SCSI_DEBUG)	+= scsi_debug.o
 obj-$(CONFIG_SCSI_FCAL)		+= fcal.o
 
-obj-$(CONFIG_CHR_DEV_ST)	+= st.o
-obj-$(CONFIG_BLK_DEV_SD)	+= sd_mod.o
-obj-$(CONFIG_BLK_DEV_SR)	+= sr_mod.o
-obj-$(CONFIG_CHR_DEV_SG)	+= sg.o
-
 
 
 scsi_mod-objs	:= scsi.o hosts.o scsi_ioctl.o constants.o \
@@ -123,7 +120,6 @@
 			scsi_obsolete.o scsi_queue.o scsi_lib.o \
 			scsi_merge.o scsi_dma.o scsi_scan.o \
 			
-sr_mod-objs	:= sr.o sr_ioctl.o sr_vendor.o
 initio-objs	:= ini9100u.o i91uscsi.o
 a100u2w-objs	:= inia100.o i60uscsi.o
 
@@ -150,12 +146,6 @@
 
 scsi_mod.o: $(scsi_mod-objs)
 	$(LD) -r -o $@ $(scsi_mod-objs)
-
-sd_mod.o: sd.o
-	$(LD) -r -o $@ sd.o
-
-sr_mod.o: $(sr_mod-objs)
-	$(LD) -r -o $@ $(sr_mod-objs)
 
 initio.o: $(initio-objs)
 	$(LD) -r -o $@ $(initio-objs)
diff -urN linux-test9/drivers/scsi/sd.c linux/drivers/scsi/sd.c
--- linux-test9/drivers/scsi/sd.c	Thu Oct  5 22:21:03 2000
+++ linux/drivers/scsi/sd.c	Thu Oct  5 22:35:17 2000
@@ -81,6 +81,7 @@
 struct hd_struct *sd;
 
 static Scsi_Disk *rscsi_disks;
+EXPORT_SYMBOL(rscsi_disks);
 static int *sd_sizes;
 static int *sd_blocksizes;
 static int *sd_hardsizes;	/* Hardware sector size */
diff -urN linux-test9/drivers/scsi/upper/Makefile linux/drivers/scsi/upper/Makefile
--- linux-test9/drivers/scsi/upper/Makefile	Thu Jan  1 01:00:00 1970
+++ linux/drivers/scsi/upper/Makefile	Thu Oct  5 22:24:11 2000
@@ -0,0 +1,63 @@
+#
+# Makefile for linux/drivers/scsi/upper
+#
+# 21 Sep 2000, Michael Elizabeth Chastain <mec@shout.net>
+# Created subdirectory drivers/scsi/upper for upper level drivers.
+# They need their own subdirectory for the benefit of init call ordering.
+
+O_TARGET	:= scsi_upper.o
+
+SUB_DIRS	:= 
+MOD_SUB_DIRS	:= 
+ALL_SUB_DIRS	:= 
+
+export-objs	:=
+
+# sd.h sr.h st.h still live in the main SCSI directory.
+EXTRA_CFLAGS	+= -I ..
+
+obj-$(CONFIG_CHR_DEV_ST)	+= st.o
+obj-$(CONFIG_BLK_DEV_SD)	+= sd_mod.o
+obj-$(CONFIG_BLK_DEV_SR)	+= sr_mod.o
+obj-$(CONFIG_CHR_DEV_SG)	+= sg_mod.o
+
+sd_mod-objs	:= sd.o
+sr_mod-objs	:= sr.o sr_ioctl.o sr_vendor.o
+sg_mod-objs	:= sg.o
+
+# Extract lists of the multi-part drivers.
+# The 'int-*' lists are the intermediate files used to build the multi's.
+
+multi-y		:= $(filter $(list-multi), $(obj-y))
+multi-m		:= $(filter $(list-multi), $(obj-m))
+int-y		:= $(sort $(foreach m, $(multi-y), $($(basename $(m))-objs)))
+int-m		:= $(sort $(foreach m, $(multi-m), $($(basename $(m))-objs)))
+
+# Files that are both resident and modular: remove from modular.
+
+obj-m		:= $(filter-out $(obj-y), $(obj-m))
+int-m		:= $(filter-out $(int-y), $(int-m))
+
+# Take multi-part drivers out of obj-y and put components in.
+
+obj-y		:= $(filter-out $(list-multi), $(obj-y)) $(int-y)
+
+# Translate to Rules.make lists.
+
+O_OBJS		:= $(filter-out $(export-objs), $(obj-y))
+OX_OBJS		:= $(filter     $(export-objs), $(obj-y))
+M_OBJS		:= $(sort $(filter-out $(export-objs), $(obj-m)))
+MX_OBJS		:= $(sort $(filter     $(export-objs), $(obj-m)))
+MI_OBJS		:= $(sort $(filter-out $(export-objs), $(int-m)))
+MIX_OBJS	:= $(sort $(filter     $(export-objs), $(int-m)))
+
+include $(TOPDIR)/Rules.make
+
+sd_mod.o: $(sd_mod-objs)
+	$(LD) -r -o $@ $(sd_mod-objs)
+
+sr_mod.o: $(sr_mod-objs)
+	$(LD) -r -o $@ $(sr_mod-objs)
+
+sg_mod.o: $(sg_mod-objs)
+	$(LD) -r -o $@ $(sg_mod-objs)
diff -urN linux-test9/include/linux/i2o.h linux/include/linux/i2o.h
--- linux-test9/include/linux/i2o.h	Thu Oct  5 22:21:00 2000
+++ linux/include/linux/i2o.h	Thu Oct  5 22:24:11 2000
@@ -173,7 +173,6 @@
 	/* User data follows */
 };
 
-#ifdef MODULE
 /*
  * Used by bus specific modules to communicate with the core
  *
@@ -193,7 +192,6 @@
 	void	(*run_queue)(struct i2o_controller *c);
 	int	(*delete)(struct i2o_controller *);
 };
-#endif // MODULE
 
 /*
  * I2O System table entry

