## Automatically generated incremental diff
## From:   linux-2.5.69-bk7
## To:     linux-2.5.69-bk8
## Robot:  $Id: make-incremental-diff,v 1.11 2002/02/20 02:59:33 hpa Exp $

diff -urN linux-2.5.69-bk7/Documentation/scsi/aic79xx.txt linux-2.5.69-bk8/Documentation/scsi/aic79xx.txt
--- linux-2.5.69-bk7/Documentation/scsi/aic79xx.txt	2003-05-04 16:53:36.000000000 -0700
+++ linux-2.5.69-bk8/Documentation/scsi/aic79xx.txt	2003-05-13 04:44:27.000000000 -0700
@@ -371,9 +371,33 @@
     - Fax Technical Support at +852-2869-7100
 
 -------------------------------------------------------------------
-
-(c) 2003 Adaptec, Inc. All Rights Reserved. No part of this 
-publication may be reproduced, stored in a retrieval system, or 
-transmitted in any form or by any means, electronic, mechanical, 
-photocopying, recording or otherwise, without prior written consent 
-of Adaptec, Inc., 691 South Milpitas Blvd., Milpitas, CA 95035.
+/*
+ * Copyright (c) 2003 Adaptec Inc. 691 S. Milpitas Blvd., Milpitas CA 95035 USA.
+ * All rights reserved.
+ *
+ * You are permitted to redistribute, use and modify this README file in whole
+ * or in part in conjunction with redistribution of software governed by the
+ * General Public License, provided that the following conditions are met:
+ * 1. Redistributions of README file must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ * 3. Modifications or new contributions must be attributed in a copyright
+ *    notice identifying the author ("Contributor") and added below the
+ *    original copyright notice. The copyright notice is for purposes of
+ *    identifying contributors and should not be deemed as permission to alter
+ *    the permissions given by Adaptec.
+ *
+ * THIS README FILE IS PROVIDED BY ADAPTEC AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, ANY
+ * WARRANTIES OF NON-INFRINGEMENT OR THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * ADAPTEC OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS README
+ * FILE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
diff -urN linux-2.5.69-bk7/Documentation/scsi/aic7xxx.txt linux-2.5.69-bk8/Documentation/scsi/aic7xxx.txt
--- linux-2.5.69-bk7/Documentation/scsi/aic7xxx.txt	2003-05-04 16:53:08.000000000 -0700
+++ linux-2.5.69-bk8/Documentation/scsi/aic7xxx.txt	2003-05-13 04:44:27.000000000 -0700
@@ -132,6 +132,16 @@
 
 2. Version History
 
+        6.2.33 - Dynamically disable PCI parity error reporting after
+		 10 errors are reported to the user.  These errors are
+		 the result of some other device issuing PCI transactions
+		 with bad parity.  Once the user has been informed of the
+		 problem, continuing to report the errors just degrades
+		 our performance.
+
+        6.2.32 - Dynamically sized S/G lists to avoid SCSI malloc
+		 pool fragmentation and SCSI mid-layer deadlock.
+
         6.2.28 - Domain Validation Fixes
                  PCI parity error disable
                  Enhanced Memory Mapped I/O probe
@@ -160,6 +170,7 @@
        Default Value: 0x0000
    -----------------------------------------------------------------
               Option: no_probe
+              Option: probe_eisa_vl
           Definition: Do not probe for EISA/VLB controllers.
                       This is a toggle.  If the driver is compiled
                       to not probe EISA/VLB controllers by default,
@@ -339,9 +350,33 @@
     - Fax Technical Support at +852-2869-7100
 
 -------------------------------------------------------------------
-
-(c) 2002 Adaptec, Inc. All Rights Reserved. No part of this 
-publication may be reproduced, stored in a retrieval system, or 
-transmitted in any form or by any means, electronic, mechanical, 
-photocopying, recording or otherwise, without prior written consent 
-of Adaptec, Inc., 691 South Milpitas Blvd., Milpitas, CA 95035.
+/*
+ * Copyright (c) 2003 Adaptec Inc. 691 S. Milpitas Blvd., Milpitas CA 95035 USA.
+ * All rights reserved.
+ *
+ * You are permitted to redistribute, use and modify this README file in whole
+ * or in part in conjunction with redistribution of software governed by the
+ * General Public License, provided that the following conditions are met:
+ * 1. Redistributions of README file must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ * 3. Modifications or new contributions must be attributed in a copyright
+ *    notice identifying the author ("Contributor") and added below the
+ *    original copyright notice. The copyright notice is for purposes of
+ *    identifying contributors and should not be deemed as permission to alter
+ *    the permissions given by Adaptec.
+ *
+ * THIS README FILE IS PROVIDED BY ADAPTEC AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, ANY
+ * WARRANTIES OF NON-INFRINGEMENT OR THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * ADAPTEC OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS README
+ * FILE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
diff -urN linux-2.5.69-bk7/Makefile linux-2.5.69-bk8/Makefile
--- linux-2.5.69-bk7/Makefile	2003-05-13 04:44:23.000000000 -0700
+++ linux-2.5.69-bk8/Makefile	2003-05-13 04:44:27.000000000 -0700
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 5
 SUBLEVEL = 69
-EXTRAVERSION = -bk7
+EXTRAVERSION = -bk8
 
 # *DOCUMENTATION*
 # To see a list of typical targets execute "make help"
diff -urN linux-2.5.69-bk7/arch/alpha/kernel/core_marvel.c linux-2.5.69-bk8/arch/alpha/kernel/core_marvel.c
--- linux-2.5.69-bk7/arch/alpha/kernel/core_marvel.c	2003-05-04 16:53:01.000000000 -0700
+++ linux-2.5.69-bk8/arch/alpha/kernel/core_marvel.c	2003-05-13 04:44:27.000000000 -0700
@@ -780,7 +780,7 @@
 		rtc_access.function = 0x49;		/* GET_TOY */
 		if (write) rtc_access.function = 0x48;	/* PUT_TOY */
 
-#if CONFIG_SMP
+#ifdef CONFIG_SMP
 		if (smp_processor_id() != boot_cpuid)
 			smp_call_function_on_cpu(__marvel_access_rtc,
 						 &rtc_access,
diff -urN linux-2.5.69-bk7/arch/alpha/kernel/entry.S linux-2.5.69-bk8/arch/alpha/kernel/entry.S
--- linux-2.5.69-bk7/arch/alpha/kernel/entry.S	2003-05-04 16:52:48.000000000 -0700
+++ linux-2.5.69-bk8/arch/alpha/kernel/entry.S	2003-05-13 04:44:27.000000000 -0700
@@ -849,7 +849,7 @@
 	   about this loop.  */
 	ldq	$3, TASK_REAL_PARENT($2)
 1:	ldl	$1, TASK_TGID($3)
-#if CONFIG_SMP
+#ifdef CONFIG_SMP
 	mov	$3, $4
 	mb
 	ldq	$3, TASK_REAL_PARENT($2)
diff -urN linux-2.5.69-bk7/arch/alpha/kernel/irq.c linux-2.5.69-bk8/arch/alpha/kernel/irq.c
--- linux-2.5.69-bk7/arch/alpha/kernel/irq.c	2003-05-04 16:53:36.000000000 -0700
+++ linux-2.5.69-bk8/arch/alpha/kernel/irq.c	2003-05-13 04:44:27.000000000 -0700
@@ -556,7 +556,7 @@
 unlock:
 		spin_unlock_irqrestore(&irq_desc[i].lock, flags);
 	}
-#if CONFIG_SMP
+#ifdef CONFIG_SMP
 	seq_puts(p, "IPI: ");
 	for (i = 0; i < NR_CPUS; i++)
 		if (cpu_online(i))
diff -urN linux-2.5.69-bk7/arch/alpha/kernel/module.c linux-2.5.69-bk8/arch/alpha/kernel/module.c
--- linux-2.5.69-bk7/arch/alpha/kernel/module.c	2003-05-04 16:52:49.000000000 -0700
+++ linux-2.5.69-bk8/arch/alpha/kernel/module.c	2003-05-13 04:44:27.000000000 -0700
@@ -300,3 +300,8 @@
 {
 	return 0;
 }
+
+void
+module_arch_cleanup(struct module *mod)
+{
+}
diff -urN linux-2.5.69-bk7/arch/arm/common/sa1111.c linux-2.5.69-bk8/arch/arm/common/sa1111.c
--- linux-2.5.69-bk7/arch/arm/common/sa1111.c	2003-05-04 16:53:41.000000000 -0700
+++ linux-2.5.69-bk8/arch/arm/common/sa1111.c	2003-05-13 04:44:27.000000000 -0700
@@ -419,7 +419,7 @@
 
 	spin_lock_irqsave(&sachip->lock, flags);
 
-#if CONFIG_ARCH_SA1100
+#ifdef CONFIG_ARCH_SA1100
 	/*
 	 * First, set up the 3.6864MHz clock on GPIO 27 for the SA-1111:
 	 * (SA-1110 Developer's Manual, section 9.1.2.1)
diff -urN linux-2.5.69-bk7/arch/arm/kernel/module.c linux-2.5.69-bk8/arch/arm/kernel/module.c
--- linux-2.5.69-bk7/arch/arm/kernel/module.c	2003-05-04 16:53:00.000000000 -0700
+++ linux-2.5.69-bk8/arch/arm/kernel/module.c	2003-05-13 04:44:27.000000000 -0700
@@ -159,3 +159,8 @@
 {
 	return 0;
 }
+
+void
+module_arch_cleanup(struct module *mod)
+{
+}
diff -urN linux-2.5.69-bk7/arch/cris/drivers/eeprom.c linux-2.5.69-bk8/arch/cris/drivers/eeprom.c
--- linux-2.5.69-bk7/arch/cris/drivers/eeprom.c	2003-05-04 16:53:12.000000000 -0700
+++ linux-2.5.69-bk8/arch/cris/drivers/eeprom.c	2003-05-13 04:44:27.000000000 -0700
@@ -163,7 +163,7 @@
   init_waitqueue_head(&eeprom.wait_q);
   eeprom.busy = 0;
 
-#if CONFIG_ETRAX_I2C_EEPROM_PROBE
+#ifdef CONFIG_ETRAX_I2C_EEPROM_PROBE
 #define EETEXT "Found"
 #else
 #define EETEXT "Assuming"
@@ -191,7 +191,7 @@
   eeprom.usec_delay_step = 128;
   eeprom.adapt_state = 0;
   
-#if CONFIG_ETRAX_I2C_EEPROM_PROBE
+#ifdef CONFIG_ETRAX_I2C_EEPROM_PROBE
   i2c_start();
   i2c_outbyte(0x80);
   if(!i2c_getack())
diff -urN linux-2.5.69-bk7/arch/i386/kernel/acpi/sleep.c linux-2.5.69-bk8/arch/i386/kernel/acpi/sleep.c
--- linux-2.5.69-bk7/arch/i386/kernel/acpi/sleep.c	2003-05-04 16:53:14.000000000 -0700
+++ linux-2.5.69-bk8/arch/i386/kernel/acpi/sleep.c	2003-05-13 04:44:27.000000000 -0700
@@ -75,7 +75,7 @@
 		printk(KERN_ERR "ACPI: Wakeup code way too big, S3 disabled.\n");
 		return;
 	}
-#if CONFIG_X86_PAE
+#ifdef CONFIG_X86_PAE
 	printk(KERN_ERR "ACPI: S3 and PAE do not like each other for now, S3 disabled.\n");
 	return;
 #endif
diff -urN linux-2.5.69-bk7/arch/i386/kernel/cpu/cpufreq/p4-clockmod.c linux-2.5.69-bk8/arch/i386/kernel/cpu/cpufreq/p4-clockmod.c
--- linux-2.5.69-bk7/arch/i386/kernel/cpu/cpufreq/p4-clockmod.c	2003-05-04 16:53:41.000000000 -0700
+++ linux-2.5.69-bk8/arch/i386/kernel/cpu/cpufreq/p4-clockmod.c	2003-05-13 04:44:27.000000000 -0700
@@ -104,18 +104,20 @@
 	}
 
 	rdmsr(MSR_IA32_THERM_STATUS, l, h);
+#if 0
 	if (l & 0x01)
-//		printk(KERN_DEBUG PFX "CPU#%d currently thermal throttled\n", cpu);
-
+		printk(KERN_DEBUG PFX "CPU#%d currently thermal throttled\n", cpu);
+#endif
 	if (has_N44_O17_errata[cpu] && (newstate == DC_25PT || newstate == DC_DFLT))
 		newstate = DC_38PT;
 
 	rdmsr(MSR_IA32_THERM_CONTROL, l, h);
 	if (newstate == DC_DISABLE) {
-//		printk(KERN_INFO PFX "CPU#%d disabling modulation\n", cpu);
+		/* printk(KERN_INFO PFX "CPU#%d disabling modulation\n", cpu); */
 		wrmsr(MSR_IA32_THERM_CONTROL, l & ~(1<<4), h);
 	} else {
-//		printk(KERN_INFO PFX "CPU#%d setting duty cycle to %d%%\n", cpu, ((125 * newstate) / 10));
+		/* printk(KERN_INFO PFX "CPU#%d setting duty cycle to %d%%\n",
+			cpu, ((125 * newstate) / 10)); */
 		/* bits 63 - 5	: reserved 
 		 * bit  4	: enable/disable
 		 * bits 3-1	: duty cycle
diff -urN linux-2.5.69-bk7/arch/i386/kernel/cpu/mtrr/if.c linux-2.5.69-bk8/arch/i386/kernel/cpu/mtrr/if.c
--- linux-2.5.69-bk7/arch/i386/kernel/cpu/mtrr/if.c	2003-05-04 16:53:08.000000000 -0700
+++ linux-2.5.69-bk8/arch/i386/kernel/cpu/mtrr/if.c	2003-05-13 04:44:27.000000000 -0700
@@ -70,7 +70,7 @@
 
 /* RED-PEN: seq_file can seek now. this is ignored. */
 static ssize_t
-mtrr_write(struct file *file, const char *buf, size_t len, loff_t * ppos)
+mtrr_write(struct file *file, const char __user *buf, size_t len, loff_t * ppos)
 /*  Format of control line:
     "base=%Lx size=%Lx type=%s"     OR:
     "disable=%d"
@@ -133,12 +133,13 @@
 
 static int
 mtrr_ioctl(struct inode *inode, struct file *file,
-	   unsigned int cmd, unsigned long arg)
+	   unsigned int cmd, unsigned long __arg)
 {
 	int err;
 	mtrr_type type;
 	struct mtrr_sentry sentry;
 	struct mtrr_gentry gentry;
+	void __user *arg = (void __user *) __arg;
 
 	switch (cmd) {
 	default:
@@ -146,7 +147,7 @@
 	case MTRRIOC_ADD_ENTRY:
 		if (!capable(CAP_SYS_ADMIN))
 			return -EPERM;
-		if (copy_from_user(&sentry, (void *) arg, sizeof sentry))
+		if (copy_from_user(&sentry, arg, sizeof sentry))
 			return -EFAULT;
 		err =
 		    mtrr_file_add(sentry.base, sentry.size, sentry.type, 1,
@@ -157,7 +158,7 @@
 	case MTRRIOC_SET_ENTRY:
 		if (!capable(CAP_SYS_ADMIN))
 			return -EPERM;
-		if (copy_from_user(&sentry, (void *) arg, sizeof sentry))
+		if (copy_from_user(&sentry, arg, sizeof sentry))
 			return -EFAULT;
 		err = mtrr_add(sentry.base, sentry.size, sentry.type, 0);
 		if (err < 0)
@@ -166,7 +167,7 @@
 	case MTRRIOC_DEL_ENTRY:
 		if (!capable(CAP_SYS_ADMIN))
 			return -EPERM;
-		if (copy_from_user(&sentry, (void *) arg, sizeof sentry))
+		if (copy_from_user(&sentry, arg, sizeof sentry))
 			return -EFAULT;
 		err = mtrr_file_del(sentry.base, sentry.size, file, 0);
 		if (err < 0)
@@ -175,14 +176,14 @@
 	case MTRRIOC_KILL_ENTRY:
 		if (!capable(CAP_SYS_ADMIN))
 			return -EPERM;
-		if (copy_from_user(&sentry, (void *) arg, sizeof sentry))
+		if (copy_from_user(&sentry, arg, sizeof sentry))
 			return -EFAULT;
 		err = mtrr_del(-1, sentry.base, sentry.size);
 		if (err < 0)
 			return err;
 		break;
 	case MTRRIOC_GET_ENTRY:
-		if (copy_from_user(&gentry, (void *) arg, sizeof gentry))
+		if (copy_from_user(&gentry, arg, sizeof gentry))
 			return -EFAULT;
 		if (gentry.regnum >= num_var_ranges)
 			return -EINVAL;
@@ -198,13 +199,13 @@
 			gentry.type = type;
 		}
 
-		if (copy_to_user((void *) arg, &gentry, sizeof gentry))
+		if (copy_to_user(arg, &gentry, sizeof gentry))
 			return -EFAULT;
 		break;
 	case MTRRIOC_ADD_PAGE_ENTRY:
 		if (!capable(CAP_SYS_ADMIN))
 			return -EPERM;
-		if (copy_from_user(&sentry, (void *) arg, sizeof sentry))
+		if (copy_from_user(&sentry, arg, sizeof sentry))
 			return -EFAULT;
 		err =
 		    mtrr_file_add(sentry.base, sentry.size, sentry.type, 1,
@@ -215,7 +216,7 @@
 	case MTRRIOC_SET_PAGE_ENTRY:
 		if (!capable(CAP_SYS_ADMIN))
 			return -EPERM;
-		if (copy_from_user(&sentry, (void *) arg, sizeof sentry))
+		if (copy_from_user(&sentry, arg, sizeof sentry))
 			return -EFAULT;
 		err = mtrr_add_page(sentry.base, sentry.size, sentry.type, 0);
 		if (err < 0)
@@ -224,7 +225,7 @@
 	case MTRRIOC_DEL_PAGE_ENTRY:
 		if (!capable(CAP_SYS_ADMIN))
 			return -EPERM;
-		if (copy_from_user(&sentry, (void *) arg, sizeof sentry))
+		if (copy_from_user(&sentry, arg, sizeof sentry))
 			return -EFAULT;
 		err = mtrr_file_del(sentry.base, sentry.size, file, 1);
 		if (err < 0)
@@ -233,21 +234,21 @@
 	case MTRRIOC_KILL_PAGE_ENTRY:
 		if (!capable(CAP_SYS_ADMIN))
 			return -EPERM;
-		if (copy_from_user(&sentry, (void *) arg, sizeof sentry))
+		if (copy_from_user(&sentry, arg, sizeof sentry))
 			return -EFAULT;
 		err = mtrr_del_page(-1, sentry.base, sentry.size);
 		if (err < 0)
 			return err;
 		break;
 	case MTRRIOC_GET_PAGE_ENTRY:
-		if (copy_from_user(&gentry, (void *) arg, sizeof gentry))
+		if (copy_from_user(&gentry, arg, sizeof gentry))
 			return -EFAULT;
 		if (gentry.regnum >= num_var_ranges)
 			return -EINVAL;
 		mtrr_if->get(gentry.regnum, &gentry.base, &gentry.size, &type);
 		gentry.type = type;
 
-		if (copy_to_user((void *) arg, &gentry, sizeof gentry))
+		if (copy_to_user(arg, &gentry, sizeof gentry))
 			return -EFAULT;
 		break;
 	}
diff -urN linux-2.5.69-bk7/arch/i386/kernel/dmi_scan.c linux-2.5.69-bk8/arch/i386/kernel/dmi_scan.c
--- linux-2.5.69-bk7/arch/i386/kernel/dmi_scan.c	2003-05-13 04:44:23.000000000 -0700
+++ linux-2.5.69-bk8/arch/i386/kernel/dmi_scan.c	2003-05-13 04:44:27.000000000 -0700
@@ -841,7 +841,7 @@
 	{ acer_cpufreq_pst, "Acer Aspire", {
 			MATCH(DMI_SYS_VENDOR, "Insyde Software"),
 			MATCH(DMI_BIOS_VERSION, "3A71"),
-			NO_MATCH, NO_MATCH, NO_MATCH
+			NO_MATCH, NO_MATCH,
 			} },
 
 	{ NULL, }
diff -urN linux-2.5.69-bk7/arch/i386/kernel/head.S linux-2.5.69-bk8/arch/i386/kernel/head.S
--- linux-2.5.69-bk7/arch/i386/kernel/head.S	2003-05-04 16:53:02.000000000 -0700
+++ linux-2.5.69-bk8/arch/i386/kernel/head.S	2003-05-13 04:44:27.000000000 -0700
@@ -483,7 +483,7 @@
 	.quad 0x0000000000000000	/* 0xf0 - unused */
 	.quad 0x0000000000000000	/* 0xf8 - GDT entry 31: double-fault TSS */
 
-#if CONFIG_SMP
+#ifdef CONFIG_SMP
 	.fill (NR_CPUS-1)*GDT_ENTRIES,8,0 /* other CPU's GDT */
 #endif
 
diff -urN linux-2.5.69-bk7/arch/i386/kernel/i386_ksyms.c linux-2.5.69-bk8/arch/i386/kernel/i386_ksyms.c
--- linux-2.5.69-bk7/arch/i386/kernel/i386_ksyms.c	2003-05-04 16:53:57.000000000 -0700
+++ linux-2.5.69-bk8/arch/i386/kernel/i386_ksyms.c	2003-05-13 04:44:27.000000000 -0700
@@ -73,9 +73,6 @@
 #ifdef CONFIG_X86_NUMAQ
 EXPORT_SYMBOL(xquad_portio);
 #endif
-#ifndef CONFIG_X86_WP_WORKS_OK
-EXPORT_SYMBOL(__verify_write);
-#endif
 EXPORT_SYMBOL(dump_thread);
 EXPORT_SYMBOL(dump_fpu);
 EXPORT_SYMBOL(dump_extended_fpu);
diff -urN linux-2.5.69-bk7/arch/i386/kernel/io_apic.c linux-2.5.69-bk8/arch/i386/kernel/io_apic.c
--- linux-2.5.69-bk7/arch/i386/kernel/io_apic.c	2003-05-13 04:44:23.000000000 -0700
+++ linux-2.5.69-bk8/arch/i386/kernel/io_apic.c	2003-05-13 04:44:27.000000000 -0700
@@ -240,22 +240,22 @@
 			clear_IO_APIC_pin(apic, pin);
 }
 
-static void set_ioapic_affinity (unsigned int irq, unsigned long mask)
+static void set_ioapic_affinity (unsigned int irq, unsigned long cpu_mask)
 {
 	unsigned long flags;
 	int pin;
 	struct irq_pin_list *entry = irq_2_pin + irq;
-
-	/*
-	 * Only the first 8 bits are valid.
-	 */
-	mask = mask << 24;
+	unsigned int apicid_value;
+	
+	apicid_value = cpu_mask_to_apicid(cpu_mask);
+	/* Prepare to do the io_apic_write */
+	apicid_value = apicid_value << 24;
 	spin_lock_irqsave(&ioapic_lock, flags);
 	for (;;) {
 		pin = entry->pin;
 		if (pin == -1)
 			break;
-		io_apic_write(entry->apic, 0x10 + 1 + pin*2, mask);
+		io_apic_write(entry->apic, 0x10 + 1 + pin*2, apicid_value);
 		if (!entry->next)
 			break;
 		entry = irq_2_pin + entry->next;
@@ -279,7 +279,7 @@
 
 extern unsigned long irq_affinity[NR_IRQS];
 
-static int __cacheline_aligned pending_irq_balance_apicid[NR_IRQS];
+static int __cacheline_aligned pending_irq_balance_cpumask[NR_IRQS];
 
 #define IRQBALANCE_CHECK_ARCH -999
 static int irqbalance_disabled = IRQBALANCE_CHECK_ARCH;
@@ -356,7 +356,7 @@
 		unsigned long flags;
 
 		spin_lock_irqsave(&desc->lock, flags);
-		pending_irq_balance_apicid[irq]=cpu_to_logical_apicid(new_cpu);
+		pending_irq_balance_cpumask[irq] = 1 << new_cpu;
 		spin_unlock_irqrestore(&desc->lock, flags);
 	}
 }
@@ -553,8 +553,7 @@
 				selected_irq, min_loaded);
 		/* mark for change destination */
 		spin_lock_irqsave(&desc->lock, flags);
-		pending_irq_balance_apicid[selected_irq] =
-				cpu_to_logical_apicid(min_loaded);
+		pending_irq_balance_cpumask[selected_irq] = 1 << min_loaded;
 		spin_unlock_irqrestore(&desc->lock, flags);
 		/* Since we made a change, come back sooner to 
 		 * check for more variation.
@@ -586,7 +585,7 @@
 	
 	/* push everything to CPU 0 to give us a starting point.  */
 	for (i = 0 ; i < NR_IRQS ; i++)
-		pending_irq_balance_apicid[i] = cpu_to_logical_apicid(0);
+		pending_irq_balance_cpumask[i] = 1;
 
 repeat:
 	set_current_state(TASK_INTERRUPTIBLE);
@@ -663,9 +662,9 @@
 static inline void move_irq(int irq)
 {
 	/* note - we hold the desc->lock */
-	if (unlikely(pending_irq_balance_apicid[irq])) {
-		set_ioapic_affinity(irq, pending_irq_balance_apicid[irq]);
-		pending_irq_balance_apicid[irq] = 0;
+	if (unlikely(pending_irq_balance_cpumask[irq])) {
+		set_ioapic_affinity(irq, pending_irq_balance_cpumask[irq]);
+		pending_irq_balance_cpumask[irq] = 0;
 	}
 }
 
diff -urN linux-2.5.69-bk7/arch/i386/kernel/ioport.c linux-2.5.69-bk8/arch/i386/kernel/ioport.c
--- linux-2.5.69-bk7/arch/i386/kernel/ioport.c	2003-05-04 16:53:14.000000000 -0700
+++ linux-2.5.69-bk8/arch/i386/kernel/ioport.c	2003-05-13 04:44:27.000000000 -0700
@@ -84,15 +84,17 @@
 		t->ts_io_bitmap = bitmap;
 	}
 
-	tss = init_tss + get_cpu();
-	if (bitmap)
-		tss->bitmap = IO_BITMAP_OFFSET;	/* Activate it in the TSS */
-
 	/*
 	 * do it in the per-thread copy and in the TSS ...
 	 */
 	set_bitmap(t->ts_io_bitmap, from, num, !turn_on);
-	set_bitmap(tss->io_bitmap, from, num, !turn_on);
+	tss = init_tss + get_cpu();
+	if (tss->bitmap == IO_BITMAP_OFFSET) { /* already active? */
+		set_bitmap(tss->io_bitmap, from, num, !turn_on);
+	} else {
+		memcpy(tss->io_bitmap, t->ts_io_bitmap, IO_BITMAP_BYTES);
+		tss->bitmap = IO_BITMAP_OFFSET;	/* Activate it in the TSS */
+	}
 	put_cpu();
 out:
 	return ret;
diff -urN linux-2.5.69-bk7/arch/i386/kernel/irq.c linux-2.5.69-bk8/arch/i386/kernel/irq.c
--- linux-2.5.69-bk7/arch/i386/kernel/irq.c	2003-05-04 16:53:01.000000000 -0700
+++ linux-2.5.69-bk8/arch/i386/kernel/irq.c	2003-05-13 04:44:27.000000000 -0700
@@ -92,7 +92,7 @@
  * each architecture has to answer this themselves, it doesn't deserve
  * a generic callback i think.
  */
-#if CONFIG_X86
+#ifdef CONFIG_X86
 	printk("unexpected IRQ trap at vector %02x\n", irq);
 #ifdef CONFIG_X86_LOCAL_APIC
 	/*
@@ -173,7 +173,7 @@
 		if (cpu_online(j))
 			seq_printf(p, "%10u ", nmi_count(j));
 	seq_putc(p, '\n');
-#if CONFIG_X86_LOCAL_APIC
+#ifdef CONFIG_X86_LOCAL_APIC
 	seq_printf(p, "LOC: ");
 	for (j = 0; j < NR_CPUS; j++)
 		if (cpu_online(j))
@@ -189,7 +189,7 @@
 	return 0;
 }
 
-#if CONFIG_SMP
+#ifdef CONFIG_SMP
 inline void synchronize_irq(unsigned int irq)
 {
 	while (irq_desc[irq].status & IRQ_INPROGRESS)
@@ -828,7 +828,7 @@
 
 #define HEX_DIGITS 8
 
-static unsigned int parse_hex_value (const char *buffer,
+static unsigned int parse_hex_value (const char __user *buffer,
 		unsigned long count, unsigned long *ret)
 {
 	unsigned char hexnum [HEX_DIGITS];
@@ -865,7 +865,7 @@
 	return 0;
 }
 
-#if CONFIG_SMP
+#ifdef CONFIG_SMP
 
 static struct proc_dir_entry * smp_affinity_entry [NR_IRQS];
 
@@ -878,7 +878,7 @@
 	return sprintf (page, "%08lx\n", irq_affinity[(long)data]);
 }
 
-static int irq_affinity_write_proc (struct file *file, const char *buffer,
+static int irq_affinity_write_proc (struct file *file, const char __user *buffer,
 					unsigned long count, void *data)
 {
 	int irq = (long) data, full_count = count, err;
@@ -914,7 +914,7 @@
 	return sprintf (page, "%08lx\n", *mask);
 }
 
-static int prof_cpu_mask_write_proc (struct file *file, const char *buffer,
+static int prof_cpu_mask_write_proc (struct file *file, const char __user *buffer,
 					unsigned long count, void *data)
 {
 	unsigned long *mask = (unsigned long *) data, full_count = count, err;
@@ -944,7 +944,7 @@
 	/* create /proc/irq/1234 */
 	irq_dir[irq] = proc_mkdir(name, root_irq_dir);
 
-#if CONFIG_SMP
+#ifdef CONFIG_SMP
 	{
 		struct proc_dir_entry *entry;
 
diff -urN linux-2.5.69-bk7/arch/i386/kernel/module.c linux-2.5.69-bk8/arch/i386/kernel/module.c
--- linux-2.5.69-bk7/arch/i386/kernel/module.c	2003-05-04 16:53:14.000000000 -0700
+++ linux-2.5.69-bk8/arch/i386/kernel/module.c	2003-05-13 04:44:27.000000000 -0700
@@ -123,3 +123,7 @@
 	} 	
 	return 0;
 }
+
+void module_arch_cleanup(struct module *mod)
+{
+}
diff -urN linux-2.5.69-bk7/arch/i386/kernel/ptrace.c linux-2.5.69-bk8/arch/i386/kernel/ptrace.c
--- linux-2.5.69-bk7/arch/i386/kernel/ptrace.c	2003-05-04 16:53:08.000000000 -0700
+++ linux-2.5.69-bk8/arch/i386/kernel/ptrace.c	2003-05-13 04:44:27.000000000 -0700
@@ -155,7 +155,7 @@
  */
 static int
 ptrace_get_thread_area(struct task_struct *child,
-		       int idx, struct user_desc *user_desc)
+		       int idx, struct user_desc __user *user_desc)
 {
 	struct user_desc info;
 	struct desc_struct *desc;
@@ -206,7 +206,7 @@
  */
 static int
 ptrace_set_thread_area(struct task_struct *child,
-		       int idx, struct user_desc *user_desc)
+		       int idx, struct user_desc __user *user_desc)
 {
 	struct user_desc info;
 	struct desc_struct *desc;
@@ -458,7 +458,7 @@
 		ret = 0;
 		if (!child->used_math)
 			init_fpu(child);
-		get_fpregs((struct user_i387_struct *)data, child);
+		get_fpregs((struct user_i387_struct __user *)data, child);
 		break;
 	}
 
@@ -469,7 +469,7 @@
 			break;
 		}
 		child->used_math = 1;
-		set_fpregs(child, (struct user_i387_struct *)data);
+		set_fpregs(child, (struct user_i387_struct __user *)data);
 		ret = 0;
 		break;
 	}
@@ -482,7 +482,7 @@
 		}
 		if (!child->used_math)
 			init_fpu(child);
-		ret = get_fpxregs((struct user_fxsr_struct *)data, child);
+		ret = get_fpxregs((struct user_fxsr_struct __user *)data, child);
 		break;
 	}
 
@@ -493,18 +493,18 @@
 			break;
 		}
 		child->used_math = 1;
-		ret = set_fpxregs(child, (struct user_fxsr_struct *)data);
+		ret = set_fpxregs(child, (struct user_fxsr_struct __user *)data);
 		break;
 	}
 
 	case PTRACE_GET_THREAD_AREA:
 		ret = ptrace_get_thread_area(child,
-					     addr, (struct user_desc *) data);
+					     addr, (struct user_desc __user *) data);
 		break;
 
 	case PTRACE_SET_THREAD_AREA:
 		ret = ptrace_set_thread_area(child,
-					     addr, (struct user_desc *) data);
+					     addr, (struct user_desc __user *) data);
 		break;
 
 	default:
diff -urN linux-2.5.69-bk7/arch/i386/kernel/reboot.c linux-2.5.69-bk8/arch/i386/kernel/reboot.c
--- linux-2.5.69-bk7/arch/i386/kernel/reboot.c	2003-05-04 16:53:08.000000000 -0700
+++ linux-2.5.69-bk8/arch/i386/kernel/reboot.c	2003-05-13 04:44:27.000000000 -0700
@@ -215,7 +215,7 @@
 
 void machine_restart(char * __unused)
 {
-#if CONFIG_SMP
+#ifdef CONFIG_SMP
 	int cpuid;
 	
 	cpuid = GET_APIC_ID(apic_read(APIC_ID));
diff -urN linux-2.5.69-bk7/arch/i386/kernel/setup.c linux-2.5.69-bk8/arch/i386/kernel/setup.c
--- linux-2.5.69-bk7/arch/i386/kernel/setup.c	2003-05-13 04:44:23.000000000 -0700
+++ linux-2.5.69-bk8/arch/i386/kernel/setup.c	2003-05-13 04:44:27.000000000 -0700
@@ -597,7 +597,7 @@
 	} else {
 		if (highmem_pages == -1)
 			highmem_pages = 0;
-#if CONFIG_HIGHMEM
+#ifdef CONFIG_HIGHMEM
 		if (highmem_pages >= max_pfn) {
 			printk(KERN_ERR "highmem size specified (%uMB) is bigger than pages available (%luMB)!.\n", pages_to_mb(highmem_pages), pages_to_mb(max_pfn));
 			highmem_pages = 0;
diff -urN linux-2.5.69-bk7/arch/i386/kernel/signal.c linux-2.5.69-bk8/arch/i386/kernel/signal.c
--- linux-2.5.69-bk7/arch/i386/kernel/signal.c	2003-05-04 16:53:14.000000000 -0700
+++ linux-2.5.69-bk8/arch/i386/kernel/signal.c	2003-05-13 04:44:27.000000000 -0700
@@ -116,7 +116,7 @@
 }
 
 asmlinkage int
-sys_sigaltstack(const stack_t *uss, stack_t *uoss)
+sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss)
 {
 	struct pt_regs *regs = (struct pt_regs *) &uss;
 	return do_sigaltstack(uss, uoss, regs->esp);
@@ -244,6 +244,11 @@
 		goto badframe;
 	/* It is more difficult to avoid calling this function than to
 	   call it and ignore errors.  */
+	/*
+	 * THIS CANNOT WORK! "&st" is a kernel address, and "do_sigaltstack()"
+	 * takes a user address (and verifies that it is a user address). End
+	 * result: it does exactly _nothing_.
+	 */
 	do_sigaltstack(&st, NULL, regs->esp);
 
 	return eax;
diff -urN linux-2.5.69-bk7/arch/i386/kernel/smpboot.c linux-2.5.69-bk8/arch/i386/kernel/smpboot.c
--- linux-2.5.69-bk7/arch/i386/kernel/smpboot.c	2003-05-04 16:53:14.000000000 -0700
+++ linux-2.5.69-bk8/arch/i386/kernel/smpboot.c	2003-05-13 04:44:27.000000000 -0700
@@ -1153,7 +1153,7 @@
 	zap_low_mappings();
 }
 
-void __init smp_intr_init()
+void __init smp_intr_init(void)
 {
 	/*
 	 * IRQ0 must be given a fixed assignment and initialized,
diff -urN linux-2.5.69-bk7/arch/i386/kernel/traps.c linux-2.5.69-bk8/arch/i386/kernel/traps.c
--- linux-2.5.69-bk7/arch/i386/kernel/traps.c	2003-05-04 16:53:03.000000000 -0700
+++ linux-2.5.69-bk8/arch/i386/kernel/traps.c	2003-05-13 04:44:27.000000000 -0700
@@ -101,7 +101,7 @@
 		stack = (unsigned long*)&stack;
 
 	printk("Call Trace:");
-#if CONFIG_KALLSYMS
+#ifdef CONFIG_KALLSYMS
 	printk("\n");
 #endif
 	i = 1;
@@ -438,7 +438,7 @@
 	unsigned char reason = get_nmi_reason();
  
 	if (!(reason & 0xc0)) {
-#if CONFIG_X86_LOCAL_APIC
+#ifdef CONFIG_X86_LOCAL_APIC
 		/*
 		 * Ok, so this is none of the documented NMI sources,
 		 * so it must be the NMI watchdog.
diff -urN linux-2.5.69-bk7/arch/i386/mm/highmem.c linux-2.5.69-bk8/arch/i386/mm/highmem.c
--- linux-2.5.69-bk7/arch/i386/mm/highmem.c	2003-05-04 16:53:31.000000000 -0700
+++ linux-2.5.69-bk8/arch/i386/mm/highmem.c	2003-05-13 04:44:27.000000000 -0700
@@ -36,7 +36,7 @@
 
 	idx = type + KM_TYPE_NR*smp_processor_id();
 	vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
-#if CONFIG_DEBUG_HIGHMEM
+#ifdef CONFIG_DEBUG_HIGHMEM
 	if (!pte_none(*(kmap_pte-idx)))
 		BUG();
 #endif
@@ -48,7 +48,7 @@
 
 void kunmap_atomic(void *kvaddr, enum km_type type)
 {
-#if CONFIG_DEBUG_HIGHMEM
+#ifdef CONFIG_DEBUG_HIGHMEM
 	unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK;
 	enum fixed_addresses idx = type + KM_TYPE_NR*smp_processor_id();
 
diff -urN linux-2.5.69-bk7/arch/i386/mm/init.c linux-2.5.69-bk8/arch/i386/mm/init.c
--- linux-2.5.69-bk7/arch/i386/mm/init.c	2003-05-04 16:53:36.000000000 -0700
+++ linux-2.5.69-bk8/arch/i386/mm/init.c	2003-05-13 04:44:27.000000000 -0700
@@ -55,7 +55,7 @@
 {
 	pmd_t *pmd_table;
 		
-#if CONFIG_X86_PAE
+#ifdef CONFIG_X86_PAE
 	pmd_table = (pmd_t *) alloc_bootmem_low_pages(PAGE_SIZE);
 	set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
 	if (pmd_table != pmd_offset(pgd, 0)) 
@@ -188,7 +188,7 @@
 	return 0;
 }
 
-#if CONFIG_HIGHMEM
+#ifdef CONFIG_HIGHMEM
 pte_t *kmap_pte;
 pgprot_t kmap_prot;
 
@@ -265,7 +265,7 @@
 	unsigned long vaddr;
 	pgd_t *pgd_base = swapper_pg_dir;
 
-#if CONFIG_X86_PAE
+#ifdef CONFIG_X86_PAE
 	int i;
 	/* Init entries of the first-level page table to the zero page */
 	for (i = 0; i < PTRS_PER_PGD; i++)
@@ -295,7 +295,7 @@
 
 	permanent_kmaps_init(pgd_base);
 
-#if CONFIG_X86_PAE
+#ifdef CONFIG_X86_PAE
 	/*
 	 * Add low memory identity-mappings - SMP needs it when
 	 * starting up on an AP from real-mode. In the non-PAE
@@ -317,7 +317,7 @@
 	 * us, because pgd_clear() is a no-op on i386.
 	 */
 	for (i = 0; i < USER_PTRS_PER_PGD; i++)
-#if CONFIG_X86_PAE
+#ifdef CONFIG_X86_PAE
 		set_pgd(swapper_pg_dir+i, __pgd(1 + __pa(empty_zero_page)));
 #else
 		set_pgd(swapper_pg_dir+i, __pgd(0));
@@ -363,7 +363,7 @@
 
 	load_cr3(swapper_pg_dir);
 
-#if CONFIG_X86_PAE
+#ifdef CONFIG_X86_PAE
 	/*
 	 * We will bail out later - printk doesn't work right now so
 	 * the user would just see a hanging kernel.
@@ -487,7 +487,7 @@
 		(unsigned long) (totalhigh_pages << (PAGE_SHIFT-10))
 	       );
 
-#if CONFIG_X86_PAE
+#ifdef CONFIG_X86_PAE
 	if (!cpu_has_pae)
 		panic("cannot execute a PAE-enabled kernel on a PAE-less CPU!");
 #endif
@@ -505,7 +505,7 @@
 #endif
 }
 
-#if CONFIG_X86_PAE
+#ifdef CONFIG_X86_PAE
 struct kmem_cache_s *pae_pgd_cachep;
 
 void __init pgtable_cache_init(void)
diff -urN linux-2.5.69-bk7/arch/i386/mm/ioremap.c linux-2.5.69-bk8/arch/i386/mm/ioremap.c
--- linux-2.5.69-bk7/arch/i386/mm/ioremap.c	2003-05-04 16:53:08.000000000 -0700
+++ linux-2.5.69-bk8/arch/i386/mm/ioremap.c	2003-05-13 04:44:27.000000000 -0700
@@ -222,7 +222,6 @@
 		return;
 	} 
 
-	unmap_vm_area(p);
 	if (p->flags && p->phys_addr < virt_to_phys(high_memory)) { 
 		change_page_attr(virt_to_page(__va(p->phys_addr)),
 				 p->size >> PAGE_SHIFT,
diff -urN linux-2.5.69-bk7/arch/i386/mm/pgtable.c linux-2.5.69-bk8/arch/i386/mm/pgtable.c
--- linux-2.5.69-bk7/arch/i386/mm/pgtable.c	2003-05-04 16:53:57.000000000 -0700
+++ linux-2.5.69-bk8/arch/i386/mm/pgtable.c	2003-05-13 04:44:27.000000000 -0700
@@ -141,7 +141,7 @@
 {
 	struct page *pte;
 
-#if CONFIG_HIGHPTE
+#ifdef CONFIG_HIGHPTE
 	pte = alloc_pages(GFP_KERNEL|__GFP_HIGHMEM|__GFP_REPEAT, 0);
 #else
 	pte = alloc_pages(GFP_KERNEL|__GFP_REPEAT, 0);
@@ -151,7 +151,7 @@
 	return pte;
 }
 
-#if CONFIG_X86_PAE
+#ifdef CONFIG_X86_PAE
 
 pgd_t *pgd_alloc(struct mm_struct *mm)
 {
diff -urN linux-2.5.69-bk7/arch/i386/oprofile/init.c linux-2.5.69-bk8/arch/i386/oprofile/init.c
--- linux-2.5.69-bk7/arch/i386/oprofile/init.c	2003-05-04 16:53:32.000000000 -0700
+++ linux-2.5.69-bk8/arch/i386/oprofile/init.c	2003-05-13 04:44:27.000000000 -0700
@@ -9,6 +9,7 @@
 
 #include <linux/oprofile.h>
 #include <linux/init.h>
+#include <linux/errno.h>
  
 /* We support CPUs that have performance counters like the Pentium Pro
  * with the NMI mode driver.
diff -urN linux-2.5.69-bk7/arch/ia64/hp/sim/simscsi.c linux-2.5.69-bk8/arch/ia64/hp/sim/simscsi.c
--- linux-2.5.69-bk7/arch/ia64/hp/sim/simscsi.c	2003-05-04 16:53:14.000000000 -0700
+++ linux-2.5.69-bk8/arch/ia64/hp/sim/simscsi.c	2003-05-13 04:44:27.000000000 -0700
@@ -386,6 +386,19 @@
 	return 0;
 }
 
-static Scsi_Host_Template driver_template = SIMSCSI;
-
+static Scsi_Host_Template driver_template = {
+	.name			= "simscsi",
+	.detect			= simscsi_detect,
+	.release		= simscsi_release,
+	.info			= simscsi_info,	
+	.queuecommand		= simscsi_queuecommand,
+	.eh_host_reset_handler	= simscsi_host_reset,
+	.bios_param		= simscsi_biosparam,
+	.can_queue		= SIMSCSI_REQ_QUEUE_LEN,
+	.this_id		= -1,
+	.sg_tablesize		= SG_ALL,
+	.max_sectors		= 1024,
+	.cmd_per_lun		= SIMSCSI_REQ_QUEUE_LEN,
+	.use_clustering		= DISABLE_CLUSTERING,
+};
 #include "../drivers/scsi/scsi_module.c"
diff -urN linux-2.5.69-bk7/arch/ia64/hp/sim/simscsi.h linux-2.5.69-bk8/arch/ia64/hp/sim/simscsi.h
--- linux-2.5.69-bk7/arch/ia64/hp/sim/simscsi.h	2003-05-04 16:52:49.000000000 -0700
+++ linux-2.5.69-bk8/arch/ia64/hp/sim/simscsi.h	2003-05-13 04:44:27.000000000 -0700
@@ -20,22 +20,4 @@
 extern int simscsi_biosparam (struct scsi_device *, struct block_device *,
 		sector_t, int[]);
 
-#define SIMSCSI {						\
-	.name			= "simscsi",			\
-	.detect			= simscsi_detect,		\
-	.release		= simscsi_release,		\
-	.info			= simscsi_info,			\
-	.queuecommand		= simscsi_queuecommand,		\
-	.eh_host_reset_handler	= simscsi_host_reset,		\
-	.bios_param		= simscsi_biosparam,		\
-	.can_queue		= SIMSCSI_REQ_QUEUE_LEN,	\
-	.this_id		= -1,				\
-	.sg_tablesize		= SG_ALL,			\
-	.max_sectors		= 1024,				\
-	.cmd_per_lun		= SIMSCSI_REQ_QUEUE_LEN,	\
-	.present		= 0,				\
-	.unchecked_isa_dma	= 0,				\
-	.use_clustering		= DISABLE_CLUSTERING		\
-}
-
 #endif /* SIMSCSI_H */
diff -urN linux-2.5.69-bk7/arch/ia64/kernel/entry.S linux-2.5.69-bk8/arch/ia64/kernel/entry.S
--- linux-2.5.69-bk7/arch/ia64/kernel/entry.S	2003-05-04 16:53:08.000000000 -0700
+++ linux-2.5.69-bk8/arch/ia64/kernel/entry.S	2003-05-13 04:44:27.000000000 -0700
@@ -838,7 +838,7 @@
 	rsm psr.i		// disable interrupts
 	;;
 	adds r17=TI_FLAGS+IA64_TASK_SIZE,r13
-#if CONFIG_PREEMPT
+#ifdef CONFIG_PREEMPT
 (pKStk)	adds r20=TI_PRE_COUNT+IA64_TASK_SIZE,r13
 	;;
 (pKStk)	st4 [r20]=r0		// preempt_count() <- 0
diff -urN linux-2.5.69-bk7/arch/ia64/kernel/gate.S linux-2.5.69-bk8/arch/ia64/kernel/gate.S
--- linux-2.5.69-bk7/arch/ia64/kernel/gate.S	2003-05-04 16:53:37.000000000 -0700
+++ linux-2.5.69-bk8/arch/ia64/kernel/gate.S	2003-05-13 04:44:27.000000000 -0700
@@ -17,7 +17,7 @@
 .start_gate:
 
 
-#if CONFIG_FSYS
+#ifdef CONFIG_FSYS
 
 #include <asm/errno.h>
 
diff -urN linux-2.5.69-bk7/arch/ia64/kernel/irq.c linux-2.5.69-bk8/arch/ia64/kernel/irq.c
--- linux-2.5.69-bk7/arch/ia64/kernel/irq.c	2003-05-13 04:44:23.000000000 -0700
+++ linux-2.5.69-bk8/arch/ia64/kernel/irq.c	2003-05-13 04:44:27.000000000 -0700
@@ -108,7 +108,7 @@
  * each architecture has to answer this themselves, it doesn't deserve
  * a generic callback i think.
  */
-#if CONFIG_X86
+#ifdef CONFIG_X86
 	printk(KERN_ERR "unexpected IRQ trap at vector %02x\n", irq);
 #ifdef CONFIG_X86_LOCAL_APIC
 	/*
@@ -122,7 +122,7 @@
 	ack_APIC_irq();
 #endif
 #endif
-#if CONFIG_IA64
+#ifdef CONFIG_IA64
 	printk(KERN_ERR "Unexpected irq vector 0x%x on CPU %u!\n", irq, smp_processor_id());
 #endif
 }
@@ -194,7 +194,7 @@
 		if (cpu_online(j))
 			seq_printf(p, "%10u ", nmi_count(j));
 	seq_putc(p, '\n');
-#if CONFIG_X86_LOCAL_APIC
+#ifdef CONFIG_X86_LOCAL_APIC
 	seq_puts(p, "LOC: ");
 	for (j = 0; j < NR_CPUS; j++)
 		if (cpu_online(j))
@@ -210,7 +210,7 @@
 	return 0;
 }
 
-#if CONFIG_SMP
+#ifdef CONFIG_SMP
 inline void synchronize_irq(unsigned int irq)
 {
 	while (irq_desc(irq)->status & IRQ_INPROGRESS)
@@ -870,7 +870,7 @@
 	return 0;
 }
 
-#if CONFIG_SMP
+#ifdef CONFIG_SMP
 
 static struct proc_dir_entry * smp_affinity_entry [NR_IRQS];
 
@@ -973,7 +973,7 @@
 	/* create /proc/irq/1234 */
 	irq_dir[irq] = proc_mkdir(name, root_irq_dir);
 
-#if CONFIG_SMP
+#ifdef CONFIG_SMP
 	{
 		struct proc_dir_entry *entry;
 
diff -urN linux-2.5.69-bk7/arch/m68k/kernel/entry.S linux-2.5.69-bk8/arch/m68k/kernel/entry.S
--- linux-2.5.69-bk7/arch/m68k/kernel/entry.S	2003-05-04 16:52:49.000000000 -0700
+++ linux-2.5.69-bk8/arch/m68k/kernel/entry.S	2003-05-13 04:44:27.000000000 -0700
@@ -188,7 +188,7 @@
 
 
 #if 0
-#if CONFIG_AMIGA
+#ifdef CONFIG_AMIGA
 ami_inthandler:
 	addql	#1,irq_stat+CPUSTAT_LOCAL_IRQ_COUNT
 	SAVE_ALL_INT
diff -urN linux-2.5.69-bk7/arch/m68k/sun3/prom/init.c linux-2.5.69-bk8/arch/m68k/sun3/prom/init.c
--- linux-2.5.69-bk7/arch/m68k/sun3/prom/init.c	2003-05-04 16:53:41.000000000 -0700
+++ linux-2.5.69-bk8/arch/m68k/sun3/prom/init.c	2003-05-13 04:44:27.000000000 -0700
@@ -32,7 +32,7 @@
 
 void __init prom_init(struct linux_romvec *rp)
 {
-#if CONFIG_AP1000
+#ifdef CONFIG_AP1000
 	extern struct linux_romvec *ap_prom_init(void);
 	rp = ap_prom_init();
 #endif
diff -urN linux-2.5.69-bk7/arch/m68k/sun3/prom/printf.c linux-2.5.69-bk8/arch/m68k/sun3/prom/printf.c
--- linux-2.5.69-bk7/arch/m68k/sun3/prom/printf.c	2003-05-04 16:53:00.000000000 -0700
+++ linux-2.5.69-bk8/arch/m68k/sun3/prom/printf.c	2003-05-13 04:44:27.000000000 -0700
@@ -38,7 +38,7 @@
 
 	bptr = ppbuf;
 
-#if CONFIG_AP1000
+#ifdef CONFIG_AP1000
         ap_write(1,bptr,strlen(bptr));
 #else
 
diff -urN linux-2.5.69-bk7/arch/m68knommu/platform/5249/MOTOROLA/crt0_ram.S linux-2.5.69-bk8/arch/m68knommu/platform/5249/MOTOROLA/crt0_ram.S
--- linux-2.5.69-bk7/arch/m68knommu/platform/5249/MOTOROLA/crt0_ram.S	2003-05-04 16:53:40.000000000 -0700
+++ linux-2.5.69-bk8/arch/m68knommu/platform/5249/MOTOROLA/crt0_ram.S	2003-05-13 04:44:27.000000000 -0700
@@ -93,7 +93,7 @@
 	move.l  %d0, 0x180(%a1)			/* Set PLL register */
 	nop
 
-#if CONFIG_CLOCK_140MHz
+#ifdef CONFIG_CLOCK_140MHz
 	/*
 	 *	Set initial clock frequency. This assumes M5249C3 board
 	 *	is fitted with 11.2896MHz crystal. It will program the
diff -urN linux-2.5.69-bk7/arch/mips/arc/misc.c linux-2.5.69-bk8/arch/mips/arc/misc.c
--- linux-2.5.69-bk7/arch/mips/arc/misc.c	2003-05-04 16:53:03.000000000 -0700
+++ linux-2.5.69-bk8/arch/mips/arc/misc.c	2003-05-13 04:44:27.000000000 -0700
@@ -19,7 +19,7 @@
 {
 	bc_disable();
 	cli();
-#if CONFIG_SCSI_SGIWD93
+#ifdef CONFIG_SCSI_SGIWD93
 	reset_wd33c93(sgiwd93_host);
 #endif
 	romvec->halt();
@@ -29,7 +29,7 @@
 {
 	bc_disable();
 	cli();
-#if CONFIG_SCSI_SGIWD93
+#ifdef CONFIG_SCSI_SGIWD93
 	reset_wd33c93(sgiwd93_host);
 #endif
 	romvec->pdown();
@@ -40,7 +40,7 @@
 {
 	bc_disable();
 	cli();
-#if CONFIG_SCSI_SGIWD93
+#ifdef CONFIG_SCSI_SGIWD93
 	reset_wd33c93(sgiwd93_host);
 #endif
 	romvec->restart();
@@ -50,7 +50,7 @@
 {
 	bc_disable();
 	cli();
-#if CONFIG_SCSI_SGIWD93
+#ifdef CONFIG_SCSI_SGIWD93
 	reset_wd33c93(sgiwd93_host);
 #endif
 	romvec->reboot();
@@ -60,7 +60,7 @@
 {
 	bc_disable();
 	cli();
-#if CONFIG_SCSI_SGIWD93
+#ifdef CONFIG_SCSI_SGIWD93
 	reset_wd33c93(sgiwd93_host);
 #endif
 	romvec->imode();
diff -urN linux-2.5.69-bk7/arch/mips64/arc/misc.c linux-2.5.69-bk8/arch/mips64/arc/misc.c
--- linux-2.5.69-bk7/arch/mips64/arc/misc.c	2003-05-04 16:53:35.000000000 -0700
+++ linux-2.5.69-bk8/arch/mips64/arc/misc.c	2003-05-13 04:44:27.000000000 -0700
@@ -29,7 +29,7 @@
 {
 	bc_disable();
 	cli();
-#if CONFIG_SCSI_SGIWD93
+#ifdef CONFIG_SCSI_SGIWD93
 	reset_wd33c93(sgiwd93_host);
 #endif
 	ARC_CALL0(halt);
@@ -41,7 +41,7 @@
 {
 	bc_disable();
 	cli();
-#if CONFIG_SCSI_SGIWD93
+#ifdef CONFIG_SCSI_SGIWD93
 	reset_wd33c93(sgiwd93_host);
 #endif
 	ARC_CALL0(pdown);
@@ -54,7 +54,7 @@
 {
 	bc_disable();
 	cli();
-#if CONFIG_SCSI_SGIWD93
+#ifdef CONFIG_SCSI_SGIWD93
 	reset_wd33c93(sgiwd93_host);
 #endif
 	ARC_CALL0(restart);
@@ -66,7 +66,7 @@
 {
 	bc_disable();
 	cli();
-#if CONFIG_SCSI_SGIWD93
+#ifdef CONFIG_SCSI_SGIWD93
 	reset_wd33c93(sgiwd93_host);
 #endif
 	ARC_CALL0(reboot);
@@ -78,7 +78,7 @@
 {
 	bc_disable();
 	cli();
-#if CONFIG_SCSI_SGIWD93
+#ifdef CONFIG_SCSI_SGIWD93
 	reset_wd33c93(sgiwd93_host);
 #endif
 	ARC_CALL0(imode);
diff -urN linux-2.5.69-bk7/arch/parisc/hpux/wrappers.S linux-2.5.69-bk8/arch/parisc/hpux/wrappers.S
--- linux-2.5.69-bk7/arch/parisc/hpux/wrappers.S	2003-05-04 16:53:41.000000000 -0700
+++ linux-2.5.69-bk8/arch/parisc/hpux/wrappers.S	2003-05-13 04:44:27.000000000 -0700
@@ -129,7 +129,7 @@
 	/* Set the return value for the child */
 
 hpux_child_return:
-#if CONFIG_SMP || CONFIG_PREEMPT
+#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT)
 	bl	schedule_tail, %r2
 	nop
 #endif
diff -urN linux-2.5.69-bk7/arch/parisc/kernel/module.c linux-2.5.69-bk8/arch/parisc/kernel/module.c
--- linux-2.5.69-bk7/arch/parisc/kernel/module.c	2003-05-04 16:53:57.000000000 -0700
+++ linux-2.5.69-bk8/arch/parisc/kernel/module.c	2003-05-13 04:44:27.000000000 -0700
@@ -568,3 +568,7 @@
 #endif
 	return 0;
 }
+
+void module_arch_cleanup(struct module *mod)
+{
+}
diff -urN linux-2.5.69-bk7/arch/ppc/kernel/module.c linux-2.5.69-bk8/arch/ppc/kernel/module.c
--- linux-2.5.69-bk7/arch/ppc/kernel/module.c	2003-05-04 16:53:08.000000000 -0700
+++ linux-2.5.69-bk8/arch/ppc/kernel/module.c	2003-05-13 04:44:27.000000000 -0700
@@ -269,3 +269,7 @@
 {
 	return 0;
 }
+
+void module_arch_cleanup(struct module *mod)
+{
+}
diff -urN linux-2.5.69-bk7/arch/ppc/kernel/process.c linux-2.5.69-bk8/arch/ppc/kernel/process.c
--- linux-2.5.69-bk7/arch/ppc/kernel/process.c	2003-05-04 16:53:14.000000000 -0700
+++ linux-2.5.69-bk8/arch/ppc/kernel/process.c	2003-05-13 04:44:27.000000000 -0700
@@ -524,7 +524,7 @@
 	while (count < 16 && sp > prev_sp && sp < stack_top && (sp & 3) == 0) {
 		if (count == 0) {
 			printk("Call trace:");
-#if CONFIG_KALLSYMS
+#ifdef CONFIG_KALLSYMS
 			printk("\n");
 #endif
 		} else {
@@ -534,7 +534,7 @@
 			} else
 				ret = *(unsigned long *)(sp + 4);
 			printk(" [%08lx] ", ret);
-#if CONFIG_KALLSYMS
+#ifdef CONFIG_KALLSYMS
 			print_symbol("%s", ret);
 			printk("\n");
 #endif
diff -urN linux-2.5.69-bk7/arch/ppc64/kernel/module.c linux-2.5.69-bk8/arch/ppc64/kernel/module.c
--- linux-2.5.69-bk7/arch/ppc64/kernel/module.c	2003-05-13 04:44:23.000000000 -0700
+++ linux-2.5.69-bk8/arch/ppc64/kernel/module.c	2003-05-13 04:44:27.000000000 -0700
@@ -384,3 +384,7 @@
 				me->num_exentries);
 	return 0;
 }
+
+void module_arch_cleanup(struct module *mod)
+{
+}
diff -urN linux-2.5.69-bk7/arch/s390/kernel/module.c linux-2.5.69-bk8/arch/s390/kernel/module.c
--- linux-2.5.69-bk7/arch/s390/kernel/module.c	2003-05-04 16:53:41.000000000 -0700
+++ linux-2.5.69-bk8/arch/s390/kernel/module.c	2003-05-13 04:44:27.000000000 -0700
@@ -386,3 +386,7 @@
 		kfree(me->arch.syminfo);
 	return 0;
 }
+
+void module_arch_cleanup(struct module *mod)
+{
+}
diff -urN linux-2.5.69-bk7/arch/s390/kernel/s390_ksyms.c linux-2.5.69-bk8/arch/s390/kernel/s390_ksyms.c
--- linux-2.5.69-bk7/arch/s390/kernel/s390_ksyms.c	2003-05-04 16:53:32.000000000 -0700
+++ linux-2.5.69-bk8/arch/s390/kernel/s390_ksyms.c	2003-05-13 04:44:27.000000000 -0700
@@ -13,7 +13,7 @@
 #include <asm/delay.h>
 #include <asm/pgalloc.h>
 #include <asm/setup.h>
-#if CONFIG_IP_MULTICAST
+#ifdef CONFIG_IP_MULTICAST
 #include <net/arp.h>
 #endif
 
diff -urN linux-2.5.69-bk7/arch/s390/kernel/traps.c linux-2.5.69-bk8/arch/s390/kernel/traps.c
--- linux-2.5.69-bk7/arch/s390/kernel/traps.c	2003-05-04 16:53:09.000000000 -0700
+++ linux-2.5.69-bk8/arch/s390/kernel/traps.c	2003-05-13 04:44:27.000000000 -0700
@@ -304,7 +304,7 @@
 	}
 	else
 	{
-#if CONFIG_REMOTE_DEBUG
+#ifdef CONFIG_REMOTE_DEBUG
 		if(gdb_stub_initialised)
 		{
 			gdb_stub_handle_exception(regs, signal);
diff -urN linux-2.5.69-bk7/arch/s390/math-emu/math.c linux-2.5.69-bk8/arch/s390/math-emu/math.c
--- linux-2.5.69-bk7/arch/s390/math-emu/math.c	2003-05-04 16:53:12.000000000 -0700
+++ linux-2.5.69-bk8/arch/s390/math-emu/math.c	2003-05-13 04:44:27.000000000 -0700
@@ -102,7 +102,7 @@
         struct pt_regs *regs;
         __u16 *location;
         
-#if CONFIG_SYSCTL
+#ifdef CONFIG_SYSCTL
         if(sysctl_ieee_emulation_warnings)
 #endif
         {
diff -urN linux-2.5.69-bk7/arch/sparc/kernel/module.c linux-2.5.69-bk8/arch/sparc/kernel/module.c
--- linux-2.5.69-bk7/arch/sparc/kernel/module.c	2003-05-04 16:52:48.000000000 -0700
+++ linux-2.5.69-bk8/arch/sparc/kernel/module.c	2003-05-13 04:44:27.000000000 -0700
@@ -145,3 +145,7 @@
 {
 	return 0;
 }
+
+void module_arch_cleanup(struct module *mod)
+{
+}
diff -urN linux-2.5.69-bk7/arch/sparc/kernel/process.c linux-2.5.69-bk8/arch/sparc/kernel/process.c
--- linux-2.5.69-bk7/arch/sparc/kernel/process.c	2003-05-04 16:53:02.000000000 -0700
+++ linux-2.5.69-bk8/arch/sparc/kernel/process.c	2003-05-13 04:44:27.000000000 -0700
@@ -186,18 +186,6 @@
 	machine_halt();
 }
 
-void show_regwindow(struct reg_window *rw)
-{
-	printk("l0: %08lx l1: %08lx l2: %08lx l3: %08lx "
-	       "l4: %08lx l5: %08lx l6: %08lx l7: %08lx\n",
-	       rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
-	       rw->locals[4], rw->locals[5], rw->locals[6], rw->locals[7]);
-	printk("i0: %08lx i1: %08lx i2: %08lx i3: %08lx "
-	       "i4: %08lx i5: %08lx fp: %08lx i7: %08lx\n",
-	       rw->ins[0], rw->ins[1], rw->ins[2], rw->ins[3],
-	       rw->ins[4], rw->ins[5], rw->ins[6], rw->ins[7]);
-}
-
 static spinlock_t sparc_backtrace_lock = SPIN_LOCK_UNLOCKED;
 
 void __show_backtrace(unsigned long fp)
@@ -248,6 +236,7 @@
 }
 #endif
 
+#if 0
 void show_stackframe(struct sparc_stackf *sf)
 {
 	unsigned long size;
@@ -275,24 +264,27 @@
 		printk("s%d: %08lx\n", i++, *stk++);
 	} while ((size -= sizeof(unsigned long)));
 }
+#endif
 
-void show_regs(struct pt_regs * regs)
+void show_regs(struct pt_regs *r)
 {
-        printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx    %s\n", regs->psr,
-	       regs->pc, regs->npc, regs->y, print_tainted());
-	printk("g0: %08lx g1: %08lx g2: %08lx g3: %08lx ",
-	       regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
-	       regs->u_regs[3]);
-	printk("g4: %08lx g5: %08lx g6: %08lx g7: %08lx\n",
-	       regs->u_regs[4], regs->u_regs[5], regs->u_regs[6],
-	       regs->u_regs[7]);
-	printk("o0: %08lx o1: %08lx o2: %08lx o3: %08lx ",
-	       regs->u_regs[8], regs->u_regs[9], regs->u_regs[10],
-	       regs->u_regs[11]);
-	printk("o4: %08lx o5: %08lx sp: %08lx o7: %08lx\n",
-	       regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
-	       regs->u_regs[15]);
-	show_regwindow((struct reg_window *)regs->u_regs[14]);
+	struct reg_window *rw = (struct reg_window *) r->u_regs[14];
+
+        printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx    %s\n",
+	       r->psr, r->pc, r->npc, r->y, print_tainted());
+	printk("%%G: %08lx %08lx  %08lx %08lx  %08lx %08lx  %08lx %08lx\n",
+	       r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
+	       r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
+	printk("%%O: %08lx %08lx  %08lx %08lx  %08lx %08lx  %08lx %08lx\n",
+	       r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
+	       r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
+
+	printk("%%L: %08lx %08lx  %08lx %08lx  %08lx %08lx  %08lx %08lx\n",
+	       rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
+	       rw->locals[4], rw->locals[5], rw->locals[6], rw->locals[7]);
+	printk("%%I: %08lx %08lx  %08lx %08lx  %08lx %08lx  %08lx %08lx\n",
+	       rw->ins[0], rw->ins[1], rw->ins[2], rw->ins[3],
+	       rw->ins[4], rw->ins[5], rw->ins[6], rw->ins[7]);
 }
 
 void show_trace_task(struct task_struct *tsk)
diff -urN linux-2.5.69-bk7/arch/sparc/kernel/sparc_ksyms.c linux-2.5.69-bk8/arch/sparc/kernel/sparc_ksyms.c
--- linux-2.5.69-bk7/arch/sparc/kernel/sparc_ksyms.c	2003-05-04 16:53:01.000000000 -0700
+++ linux-2.5.69-bk8/arch/sparc/kernel/sparc_ksyms.c	2003-05-13 04:44:27.000000000 -0700
@@ -157,7 +157,7 @@
 EXPORT_SYMBOL(rtc_lock);
 EXPORT_SYMBOL(mostek_lock);
 EXPORT_SYMBOL(mstk48t02_regs);
-#if CONFIG_SUN_AUXIO
+#ifdef CONFIG_SUN_AUXIO
 EXPORT_SYMBOL(set_auxio);
 EXPORT_SYMBOL(get_auxio);
 #endif
@@ -183,7 +183,7 @@
 EXPORT_SYMBOL_NOVERS(BTFIXUP_CALL(mmu_release_scsi_sgl));
 EXPORT_SYMBOL_NOVERS(BTFIXUP_CALL(mmu_release_scsi_one));
 
-#if CONFIG_SBUS
+#ifdef CONFIG_SBUS
 EXPORT_SYMBOL(sbus_root);
 EXPORT_SYMBOL(dma_chain);
 EXPORT_SYMBOL(sbus_set_sbus64);
@@ -198,7 +198,7 @@
 EXPORT_SYMBOL(sbus_iounmap);
 EXPORT_SYMBOL(sbus_ioremap);
 #endif
-#if CONFIG_PCI
+#ifdef CONFIG_PCI
 EXPORT_SYMBOL(ebus_chain);
 EXPORT_SYMBOL(insl);
 EXPORT_SYMBOL(outsl);
diff -urN linux-2.5.69-bk7/arch/sparc/mm/init.c linux-2.5.69-bk8/arch/sparc/mm/init.c
--- linux-2.5.69-bk7/arch/sparc/mm/init.c	2003-05-04 16:53:14.000000000 -0700
+++ linux-2.5.69-bk8/arch/sparc/mm/init.c	2003-05-13 04:44:27.000000000 -0700
@@ -107,8 +107,6 @@
 		add_to_free_ctxlist(ctx_list_pool + ctx);
 }
 
-#define DEBUG_BOOTMEM
-
 extern unsigned long cmdline_memory_size;
 unsigned long last_valid_pfn;
 
@@ -157,14 +155,11 @@
 
 unsigned long __init bootmem_init(unsigned long *pages_avail)
 {
-	unsigned long bootmap_size, start_pfn, max_pfn;
+	unsigned long bootmap_size, start_pfn;
 	unsigned long end_of_phys_memory = 0UL;
 	unsigned long bootmap_pfn, bytes_avail, size;
 	int i;
 
-#ifdef DEBUG_BOOTMEM
-	prom_printf("bootmem_init: Scan sp_banks,  ");
-#endif
 	bytes_avail = 0UL;
 	for (i = 0; sp_banks[i].num_bytes != 0; i++) {
 		end_of_phys_memory = sp_banks[i].base_addr +
@@ -234,10 +229,6 @@
 	}
 #endif	
 	/* Initialize the boot-time allocator. */
-#ifdef DEBUG_BOOTMEM
-	prom_printf("init_bootmem(spfn[%lx],bpfn[%lx],mlpfn[%lx])\n",
-		    start_pfn, bootmap_pfn, max_low_pfn);
-#endif
 	bootmap_size = init_bootmem_node(NODE_DATA(0), bootmap_pfn, phys_base>>PAGE_SHIFT, max_low_pfn);
 
 	/* Now register the available physical memory with the
@@ -264,23 +255,14 @@
 
 		size = (last_pfn - curr_pfn) << PAGE_SHIFT;
 		*pages_avail += last_pfn - curr_pfn;
-#ifdef DEBUG_BOOTMEM
-		prom_printf("free_bootmem: base[%lx] size[%lx]\n",
-			    sp_banks[i].base_addr,
-			    size);
-#endif
-		free_bootmem(sp_banks[i].base_addr,
-			     size);
+
+		free_bootmem(sp_banks[i].base_addr, size);
 	}
 
 #ifdef CONFIG_BLK_DEV_INITRD
 	if (initrd_start) {
-		size = initrd_end - initrd_start;
-#ifdef DEBUG_BOOTMEM
-		prom_printf("reserve_bootmem: base[%lx] size[%lx]\n",
-			     initrd_start, size);
-#endif
 		/* Reserve the initrd image area. */
+		size = initrd_end - initrd_start;
 		reserve_bootmem(initrd_start, size);
 		*pages_avail -= PAGE_ALIGN(size) >> PAGE_SHIFT;
 
@@ -290,9 +272,6 @@
 #endif
 	/* Reserve the kernel text/data/bss. */
 	size = (start_pfn << PAGE_SHIFT) - phys_base;
-#ifdef DEBUG_BOOTMEM
-	prom_printf("reserve_bootmem: base[%lx] size[%lx]\n", phys_base, size);
-#endif
 	reserve_bootmem(phys_base, size);
 	*pages_avail -= PAGE_ALIGN(size) >> PAGE_SHIFT;
 
@@ -301,10 +280,6 @@
 	 * in free_all_bootmem.
 	 */
 	size = bootmap_size;
-#ifdef DEBUG_BOOTMEM
-	prom_printf("reserve_bootmem: base[%lx] size[%lx]\n",
-		    (bootmap_pfn << PAGE_SHIFT), size);
-#endif
 	reserve_bootmem((bootmap_pfn << PAGE_SHIFT), size);
 	*pages_avail -= PAGE_ALIGN(size) >> PAGE_SHIFT;
 
@@ -448,9 +423,6 @@
 	max_mapnr = last_valid_pfn - (phys_base >> PAGE_SHIFT);
 	high_memory = __va(max_low_pfn << PAGE_SHIFT);
 
-#ifdef DEBUG_BOOTMEM
-	prom_printf("mem_init: Calling free_all_bootmem().\n");
-#endif
 	num_physpages = totalram_pages = free_all_bootmem();
 
 	for (i = 0; sp_banks[i].num_bytes != 0; i++) {
diff -urN linux-2.5.69-bk7/arch/sparc/mm/srmmu.c linux-2.5.69-bk8/arch/sparc/mm/srmmu.c
--- linux-2.5.69-bk7/arch/sparc/mm/srmmu.c	2003-05-04 16:53:32.000000000 -0700
+++ linux-2.5.69-bk8/arch/sparc/mm/srmmu.c	2003-05-13 04:44:27.000000000 -0700
@@ -1310,7 +1310,7 @@
 	flush_tlb_all();
 	poke_srmmu();
 
-#if CONFIG_SUN_IO
+#ifdef CONFIG_SUN_IO
 	srmmu_allocate_ptable_skeleton(sparc_iomap.start, IOBASE_END);
 	srmmu_allocate_ptable_skeleton(DVMA_VADDR, DVMA_END);
 #endif
diff -urN linux-2.5.69-bk7/arch/sparc64/kernel/module.c linux-2.5.69-bk8/arch/sparc64/kernel/module.c
--- linux-2.5.69-bk7/arch/sparc64/kernel/module.c	2003-05-04 16:53:33.000000000 -0700
+++ linux-2.5.69-bk8/arch/sparc64/kernel/module.c	2003-05-13 04:44:27.000000000 -0700
@@ -138,7 +138,9 @@
 /* Free memory returned from module_core_alloc/module_init_alloc */
 void module_free(struct module *mod, void *module_region)
 {
+	write_lock(&vmlist_lock);
 	module_unmap(module_region);
+	write_unlock(&vmlist_lock);
 	/* FIXME: If module_region == mod->init_region, trim exception
            table entries. */
 }
@@ -273,3 +275,7 @@
 {
 	return 0;
 }
+
+void module_arch_cleanup(struct module *mod)
+{
+}
diff -urN linux-2.5.69-bk7/arch/sparc64/kernel/sparc64_ksyms.c linux-2.5.69-bk8/arch/sparc64/kernel/sparc64_ksyms.c
--- linux-2.5.69-bk7/arch/sparc64/kernel/sparc64_ksyms.c	2003-05-04 16:53:37.000000000 -0700
+++ linux-2.5.69-bk8/arch/sparc64/kernel/sparc64_ksyms.c	2003-05-13 04:44:27.000000000 -0700
@@ -196,11 +196,11 @@
 EXPORT_SYMBOL(mostek_lock);
 EXPORT_SYMBOL(mstk48t02_regs);
 EXPORT_SYMBOL(request_fast_irq);
-#if CONFIG_SUN_AUXIO
+#ifdef CONFIG_SUN_AUXIO
 EXPORT_SYMBOL(auxio_set_led);
 EXPORT_SYMBOL(auxio_set_lte);
 #endif
-#if CONFIG_SBUS
+#ifdef CONFIG_SBUS
 EXPORT_SYMBOL(sbus_root);
 EXPORT_SYMBOL(dma_chain);
 EXPORT_SYMBOL(sbus_set_sbus64);
diff -urN linux-2.5.69-bk7/arch/um/kernel/irq.c linux-2.5.69-bk8/arch/um/kernel/irq.c
--- linux-2.5.69-bk7/arch/um/kernel/irq.c	2003-05-04 16:53:37.000000000 -0700
+++ linux-2.5.69-bk8/arch/um/kernel/irq.c	2003-05-13 04:44:27.000000000 -0700
@@ -48,7 +48,7 @@
  * each architecture has to answer this themselves, it doesn't deserve
  * a generic callback i think.
  */
-#if CONFIG_X86
+#ifdef CONFIG_X86
 	printk(KERN_ERR "unexpected IRQ trap at vector %02x\n", irq);
 #ifdef CONFIG_X86_LOCAL_APIC
 	/*
@@ -121,7 +121,7 @@
 	}
 	p += sprintf(p, "\n");
 #ifdef notdef
-#if CONFIG_SMP
+#ifdef CONFIG_SMP
 	p += sprintf(p, "LOC: ");
 	for (j = 0; j < num_online_cpus(); j++)
 		p += sprintf(p, "%10u ",
@@ -198,7 +198,7 @@
 	spin_unlock_irqrestore(&desc->lock, flags);
 }
 
-#if CONFIG_SMP
+#ifdef CONFIG_SMP
 inline void synchronize_irq(unsigned int irq)
 {
 	/* is there anything to synchronize with? */
@@ -621,7 +621,7 @@
 
 	err = parse_hex_value(buffer, count, &new_value);
 
-#if CONFIG_SMP
+#ifdef CONFIG_SMP
 	/*
 	 * Do not allow disabling IRQs completely - it's a too easy
 	 * way to make the system unusable accidentally :-) At least
diff -urN linux-2.5.69-bk7/arch/um/kernel/mem.c linux-2.5.69-bk8/arch/um/kernel/mem.c
--- linux-2.5.69-bk7/arch/um/kernel/mem.c	2003-05-04 16:53:13.000000000 -0700
+++ linux-2.5.69-bk8/arch/um/kernel/mem.c	2003-05-13 04:44:27.000000000 -0700
@@ -124,7 +124,7 @@
 	kmem_top = new;
 }
 
-#if CONFIG_HIGHMEM
+#ifdef CONFIG_HIGHMEM
 /* Changed during early boot */
 pte_t *kmap_pte;
 pgprot_t kmap_prot;
@@ -329,7 +329,7 @@
 	vaddr = __fix_to_virt(__end_of_fixed_addresses - 1) & PMD_MASK;
 	fixrange_init(vaddr, FIXADDR_TOP, swapper_pg_dir);
 
-#if CONFIG_HIGHMEM
+#ifdef CONFIG_HIGHMEM
 	init_highmem();
 	setup_highmem(highmem);
 #endif
diff -urN linux-2.5.69-bk7/arch/um/kernel/sys_call_table.c linux-2.5.69-bk8/arch/um/kernel/sys_call_table.c
--- linux-2.5.69-bk7/arch/um/kernel/sys_call_table.c	2003-05-04 16:53:40.000000000 -0700
+++ linux-2.5.69-bk8/arch/um/kernel/sys_call_table.c	2003-05-13 04:44:27.000000000 -0700
@@ -236,7 +236,7 @@
 extern syscall_handler_t sys_remap_file_pages;
 extern syscall_handler_t sys_set_tid_address;
 
-#if CONFIG_NFSD
+#ifdef CONFIG_NFSD
 #define NFSSERVCTL sys_nfsservctl
 #else
 #define NFSSERVCTL sys_ni_syscall
diff -urN linux-2.5.69-bk7/arch/v850/kernel/module.c linux-2.5.69-bk8/arch/v850/kernel/module.c
--- linux-2.5.69-bk7/arch/v850/kernel/module.c	2003-05-04 16:53:31.000000000 -0700
+++ linux-2.5.69-bk8/arch/v850/kernel/module.c	2003-05-13 04:44:27.000000000 -0700
@@ -230,3 +230,8 @@
 
 	return 0;
 }
+
+void
+module_arch_cleanup(struct module *mod)
+{
+}
diff -urN linux-2.5.69-bk7/arch/x86_64/kernel/irq.c linux-2.5.69-bk8/arch/x86_64/kernel/irq.c
--- linux-2.5.69-bk7/arch/x86_64/kernel/irq.c	2003-05-04 16:53:13.000000000 -0700
+++ linux-2.5.69-bk8/arch/x86_64/kernel/irq.c	2003-05-13 04:44:27.000000000 -0700
@@ -90,7 +90,7 @@
  * each architecture has to answer this themselves, it doesn't deserve
  * a generic callback i think.
  */
-#if CONFIG_X86
+#ifdef CONFIG_X86
 	printk("unexpected IRQ trap at vector %02x\n", irq);
 #ifdef CONFIG_X86_LOCAL_APIC
 	/*
@@ -171,7 +171,7 @@
 		if (cpu_online(j))
 		seq_printf(p, "%10u ", cpu_pda[j].__nmi_count);
 	seq_putc(p, '\n');
-#if CONFIG_X86_LOCAL_APIC
+#ifdef CONFIG_X86_LOCAL_APIC
 	seq_printf(p, "LOC: ");
 	for (j = 0; j < NR_CPUS; j++)
 		if (cpu_online(j))
@@ -827,7 +827,7 @@
 	return 0;
 }
 
-#if CONFIG_SMP
+#ifdef CONFIG_SMP
 
 static struct proc_dir_entry * smp_affinity_entry [NR_IRQS];
 
@@ -906,7 +906,7 @@
 	/* create /proc/irq/1234 */
 	irq_dir[irq] = proc_mkdir(name, root_irq_dir);
 
-#if CONFIG_SMP
+#ifdef CONFIG_SMP
 	{
 		struct proc_dir_entry *entry;
 
diff -urN linux-2.5.69-bk7/arch/x86_64/kernel/module.c linux-2.5.69-bk8/arch/x86_64/kernel/module.c
--- linux-2.5.69-bk7/arch/x86_64/kernel/module.c	2003-05-04 16:53:41.000000000 -0700
+++ linux-2.5.69-bk8/arch/x86_64/kernel/module.c	2003-05-13 04:44:27.000000000 -0700
@@ -48,7 +48,6 @@
 	for (prevp = &mod_vmlist ; (map = *prevp) ; prevp = &map->next) {
 		if ((unsigned long)map->addr == addr) {
 			*prevp = map->next;
-			write_unlock(&vmlist_lock); 
 			goto found;
 		}
 	}
@@ -57,6 +56,7 @@
 	return;
  found:
 	unmap_vm_area(map);
+	write_unlock(&vmlist_lock); 
 	if (map->pages) {
 		for (i = 0; i < map->nr_pages; i++)
 			if (map->pages[i])
@@ -231,3 +231,7 @@
 {
 	return 0;
 }
+
+void module_arch_cleanup(struct module *mod)
+{
+}
diff -urN linux-2.5.69-bk7/arch/x86_64/kernel/reboot.c linux-2.5.69-bk8/arch/x86_64/kernel/reboot.c
--- linux-2.5.69-bk7/arch/x86_64/kernel/reboot.c	2003-05-04 16:53:37.000000000 -0700
+++ linux-2.5.69-bk8/arch/x86_64/kernel/reboot.c	2003-05-13 04:44:27.000000000 -0700
@@ -68,7 +68,7 @@
 
 void machine_restart(char * __unused)
 {
-#if CONFIG_SMP
+#ifdef CONFIG_SMP
 	int cpuid;
 	
 	cpuid = GET_APIC_ID(apic_read(APIC_ID));
diff -urN linux-2.5.69-bk7/arch/x86_64/kernel/traps.c linux-2.5.69-bk8/arch/x86_64/kernel/traps.c
--- linux-2.5.69-bk7/arch/x86_64/kernel/traps.c	2003-05-04 16:52:49.000000000 -0700
+++ linux-2.5.69-bk8/arch/x86_64/kernel/traps.c	2003-05-13 04:44:27.000000000 -0700
@@ -529,7 +529,7 @@
 	unsigned char reason = inb(0x61);
 
 	if (!(reason & 0xc0)) {
-#if CONFIG_X86_LOCAL_APIC
+#ifdef CONFIG_X86_LOCAL_APIC
 		/*
 		 * Ok, so this is none of the documented NMI sources,
 		 * so it must be the NMI watchdog.
diff -urN linux-2.5.69-bk7/arch/x86_64/mm/ioremap.c linux-2.5.69-bk8/arch/x86_64/mm/ioremap.c
--- linux-2.5.69-bk7/arch/x86_64/mm/ioremap.c	2003-05-04 16:53:41.000000000 -0700
+++ linux-2.5.69-bk8/arch/x86_64/mm/ioremap.c	2003-05-13 04:44:27.000000000 -0700
@@ -222,7 +222,6 @@
 		return;
 	} 
 
-	unmap_vm_area(p);
 	if (p->flags && p->phys_addr < virt_to_phys(high_memory)) { 
 		change_page_attr(virt_to_page(__va(p->phys_addr)),
 				 p->size >> PAGE_SHIFT,
diff -urN linux-2.5.69-bk7/crypto/Kconfig linux-2.5.69-bk8/crypto/Kconfig
--- linux-2.5.69-bk7/crypto/Kconfig	2003-05-04 16:53:41.000000000 -0700
+++ linux-2.5.69-bk8/crypto/Kconfig	2003-05-13 04:44:27.000000000 -0700
@@ -6,14 +6,16 @@
 
 config CRYPTO
 	bool "Cryptographic API"
-	default y if INET_AH=y || INET_AH=m || INET_ESP=y || INET_ESP=m
+	default y if INET_AH=y || INET_AH=m || INET_ESP=y || INET_ESP=m || INET6_AH=y || INET6_AH=m || \
+		     INET6_ESP=y || INET6_ESP=m
 	help
 	  This option provides the core Cryptographic API.
 
 config CRYPTO_HMAC
 	bool "HMAC support"
 	depends on CRYPTO
-	default y if INET_AH=y || INET_AH=m || INET_ESP=y || INET_ESP=m
+	default y if INET_AH=y || INET_AH=m || INET_ESP=y || INET_ESP=m || INET6_AH=y || INET6_AH=m || \
+		     INET6_ESP=y || INET6_ESP=m
 	help
 	  HMAC: Keyed-Hashing for Message Authentication (RFC2104).
 	  This is required for IPSec.
@@ -33,14 +35,16 @@
 config CRYPTO_MD5
 	tristate "MD5 digest algorithm"
 	depends on CRYPTO
-	default y if INET_AH=y || INET_AH=m || INET_ESP=y || INET_ESP=m
+	default y if INET_AH=y || INET_AH=m || INET_ESP=y || INET_ESP=m || INET6_AH=y || INET6_AH=m || \
+	             INET6_ESP=y || INET6_ESP=m
 	help
 	  MD5 message digest algorithm (RFC1321).
 
 config CRYPTO_SHA1
 	tristate "SHA1 digest algorithm"
 	depends on CRYPTO
-	default y if INET_AH=y || INET_AH=m || INET_ESP=y || INET_ESP=m
+	default y if INET_AH=y || INET_AH=m || INET_ESP=y || INET_ESP=m  || INET6_AH=y || INET6_AH=m || \
+	             INET6_ESP=y || INET6_ESP=m
 	help
 	  SHA-1 secure hash standard (FIPS 180-1/DFIPS 180-2).
 
@@ -68,7 +72,7 @@
 config CRYPTO_DES
 	tristate "DES and Triple DES EDE cipher algorithms"
 	depends on CRYPTO
-	default y if INET_AH=y || INET_AH=m || INET_ESP=y || INET_ESP=m
+	default y if INET_ESP=y || INET_ESP=m || INET6_ESP=y || INET6_ESP=m
 	help
 	  DES cipher algorithm (FIPS 46-2), and Triple DES EDE (FIPS 46-3).
 
diff -urN linux-2.5.69-bk7/drivers/acorn/scsi/acornscsi.c linux-2.5.69-bk8/drivers/acorn/scsi/acornscsi.c
--- linux-2.5.69-bk7/drivers/acorn/scsi/acornscsi.c	2003-05-04 16:53:31.000000000 -0700
+++ linux-2.5.69-bk8/drivers/acorn/scsi/acornscsi.c	2003-05-13 04:44:27.000000000 -0700
@@ -2935,37 +2935,6 @@
 	}
     }
 
-    p += sprintf(p, "\nAttached devices:\n");
-
-    list_for_each_entry(scd, &instance->my_devices, siblings) {
-	int len;
-
-	proc_print_scsidevice(scd, p, &len, 0);
-	p += len;
-
-	p += sprintf(p, "Extensions: ");
-
-	if (scd->tagged_supported)
-	    p += sprintf(p, "TAG %sabled [%d] ",
-			  scd->tagged_queue ? "en" : "dis", scd->current_tag);
-	p += sprintf(p, "\nTransfers: ");
-	if (host->device[scd->id].sync_xfer & 15)
-	    p += sprintf(p, "sync, offset %d, %d ns\n",
-			  host->device[scd->id].sync_xfer & 15,
-			  acornscsi_getperiod(host->device[scd->id].sync_xfer));
-	else
-	    p += sprintf(p, "async\n");
-
-	pos = p - buffer;
-	if (pos + begin < offset) {
-	    begin += pos;
-	    p = buffer;
-	}
-	pos = p - buffer;
-	if (pos + begin > offset + length)
-	    break;
-    }
-
     pos = p - buffer;
 
     *start = buffer + (offset - begin);
@@ -3110,7 +3079,6 @@
 	.remove		= __devexit_p(acornscsi_remove),
 	.id_table	= acornscsi_cids,
 	.drv = {
-		.devclass	= &shost_devclass,
 		.name		= "acornscsi",
 	},
 };
diff -urN linux-2.5.69-bk7/drivers/acorn/scsi/arxescsi.c linux-2.5.69-bk8/drivers/acorn/scsi/arxescsi.c
--- linux-2.5.69-bk7/drivers/acorn/scsi/arxescsi.c	2003-05-04 16:53:31.000000000 -0700
+++ linux-2.5.69-bk8/drivers/acorn/scsi/arxescsi.c	2003-05-13 04:44:27.000000000 -0700
@@ -397,7 +397,6 @@
 	.remove		= __devexit_p(arxescsi_remove),
 	.id_table	= arxescsi_cids,
 	.drv = {
-		.devclass	= &shost_devclass,
 		.name		= "arxescsi",
 	},
 };
diff -urN linux-2.5.69-bk7/drivers/acorn/scsi/cumana_1.c linux-2.5.69-bk8/drivers/acorn/scsi/cumana_1.c
--- linux-2.5.69-bk7/drivers/acorn/scsi/cumana_1.c	2003-05-04 16:53:02.000000000 -0700
+++ linux-2.5.69-bk8/drivers/acorn/scsi/cumana_1.c	2003-05-13 04:44:27.000000000 -0700
@@ -334,7 +334,6 @@
 	.remove		= __devexit_p(cumanascsi1_remove),
 	.id_table	= cumanascsi1_cids,
 	.drv = {
-		.devclass	= &shost_devclass,
 		.name		= "cumanascsi1",
 	},
 };
diff -urN linux-2.5.69-bk7/drivers/acorn/scsi/cumana_2.c linux-2.5.69-bk8/drivers/acorn/scsi/cumana_2.c
--- linux-2.5.69-bk7/drivers/acorn/scsi/cumana_2.c	2003-05-04 16:53:36.000000000 -0700
+++ linux-2.5.69-bk8/drivers/acorn/scsi/cumana_2.c	2003-05-13 04:44:27.000000000 -0700
@@ -380,26 +380,6 @@
 
 	pos += sprintf(buffer+pos, "\nAttached devices:\n");
 
-	list_for_each_entry(scd, &host->my_devices, siblings) {
-		int len;
-
-		proc_print_scsidevice(scd, buffer, &len, pos);
-		pos += len;
-		pos += sprintf(buffer+pos, "Extensions: ");
-		if (scd->tagged_supported)
-			pos += sprintf(buffer+pos, "TAG %sabled [%d] ",
-				       scd->tagged_queue ? "en" : "dis",
-				       scd->current_tag);
-		pos += sprintf(buffer+pos, "\n");
-
-		if (pos + begin < offset) {
-			begin += pos;
-			pos = 0;
-		}
-		if (pos + begin > offset + length)
-			break;
-	}
-
 	*start = buffer + (offset - begin);
 	pos -= offset - begin;
 	if (pos > length)
@@ -572,7 +552,6 @@
 	.remove		= __devexit_p(cumanascsi2_remove),
 	.id_table	= cumanascsi2_cids,
 	.drv = {
-		.devclass	= &shost_devclass,
 		.name		= "cumanascsi2",
 	},
 };
diff -urN linux-2.5.69-bk7/drivers/acorn/scsi/eesox.c linux-2.5.69-bk8/drivers/acorn/scsi/eesox.c
--- linux-2.5.69-bk7/drivers/acorn/scsi/eesox.c	2003-05-04 16:53:56.000000000 -0700
+++ linux-2.5.69-bk8/drivers/acorn/scsi/eesox.c	2003-05-13 04:44:27.000000000 -0700
@@ -452,25 +452,6 @@
 
 	pos += fas216_print_stats(&info->info, buffer + pos);
 
-	pos += sprintf(buffer+pos, "\nAttached devices:\n");
-
-	list_for_each_entry(scd, &host->my_devices, siblings) {
-		int len;
-
-		proc_print_scsidevice(scd, buffer, &len, pos);
-		pos += len;
-		pos += sprintf(buffer+pos, "Extensions: ");
-		if (scd->tagged_supported)
-			pos += sprintf(buffer+pos, "TAG %sabled [%d] ",
-					scd->tagged_queue ? "en" : "dis",
-					scd->current_tag);
-		pos += sprintf (buffer+pos, "\n");
-
-		if (pos + begin < offset) {
-			begin += pos;
-			pos = 0;
-		}
-	}
 	*start = buffer + (offset - begin);
 	pos -= offset - begin;
 	if (pos > length)
@@ -679,7 +660,6 @@
 	.remove		= __devexit_p(eesoxscsi_remove),
 	.id_table	= eesoxscsi_cids,
 	.drv = {
-		.devclass	= &shost_devclass,
 		.name		= "eesoxscsi",
 	},
 };
diff -urN linux-2.5.69-bk7/drivers/acorn/scsi/oak.c linux-2.5.69-bk8/drivers/acorn/scsi/oak.c
--- linux-2.5.69-bk7/drivers/acorn/scsi/oak.c	2003-05-04 16:52:48.000000000 -0700
+++ linux-2.5.69-bk8/drivers/acorn/scsi/oak.c	2003-05-13 04:44:27.000000000 -0700
@@ -192,7 +192,6 @@
 	.remove		= __devexit_p(oakscsi_remove),
 	.id_table	= oakscsi_cids,
 	.drv = {
-		.devclass	= &shost_devclass,
 		.name		= "oakscsi",
 	},
 };
diff -urN linux-2.5.69-bk7/drivers/acorn/scsi/powertec.c linux-2.5.69-bk8/drivers/acorn/scsi/powertec.c
--- linux-2.5.69-bk7/drivers/acorn/scsi/powertec.c	2003-05-04 16:53:33.000000000 -0700
+++ linux-2.5.69-bk8/drivers/acorn/scsi/powertec.c	2003-05-13 04:44:27.000000000 -0700
@@ -475,7 +475,6 @@
 	.remove		= __devexit_p(powertecscsi_remove),
 	.id_table	= powertecscsi_cids,
 	.drv = {
-		.devclass	= &shost_devclass,
 		.name		= "powertecscsi",
 	},
 };
diff -urN linux-2.5.69-bk7/drivers/block/cciss_scsi.c linux-2.5.69-bk8/drivers/block/cciss_scsi.c
--- linux-2.5.69-bk7/drivers/block/cciss_scsi.c	2003-05-04 16:53:08.000000000 -0700
+++ linux-2.5.69-bk8/drivers/block/cciss_scsi.c	2003-05-13 04:44:27.000000000 -0700
@@ -51,8 +51,6 @@
 	int cmd_type);
 
 
-int __init cciss_scsi_detect(Scsi_Host_Template *tpnt);
-int cciss_scsi_release(struct Scsi_Host *sh);
 const char *cciss_scsi_info(struct Scsi_Host *sa);
 
 int cciss_scsi_proc_info(
@@ -84,22 +82,17 @@
 	{ .name = "cciss7", .ndevices = 0 },
 };
 
-/* We need one Scsi_Host_Template *per controller* instead of 
-   the usual one Scsi_Host_Template per controller *type*. This 
-   is so PCI hot plug could have a remote possibility of still
-   working even with the SCSI system.  It's so 
-   scsi_unregister_host will differentiate the controllers. 
-   When register_scsi_module is called, each host template is 
-   customized (name change) in cciss_register_scsi() (that's
-   called from cciss_engage_scsi, called from
-   cciss.c:cciss_proc_write(), on "engage scsi" being received
-   from user space.) */
-
-static 
-Scsi_Host_Template driver_template[MAX_CTLR] =
-{
-	CCISS_SCSI, CCISS_SCSI, CCISS_SCSI, CCISS_SCSI,
-	CCISS_SCSI, CCISS_SCSI, CCISS_SCSI, CCISS_SCSI,
+static Scsi_Host_Template cciss_driver_template = {
+	.module			= THIS_MODULE,
+	.name			= "cciss",
+	.proc_name		= "cciss",
+	.proc_info		= cciss_scsi_proc_info,
+	.queuecommand		= cciss_scsi_queue_command,
+	.can_queue		= SCSI_CCISS_CAN_QUEUE,
+	.this_id		= 7,
+	.sg_tablesize		= MAXSGENTRIES,
+	.cmd_per_lun		= 1,
+	.use_clustering		= DISABLE_CLUSTERING,
 };
 
 #pragma pack(1)
@@ -700,60 +693,31 @@
 	scsi_cmd_free(ctlr, cp);
 }
 
-/* cciss_scsi_detect is called from the scsi mid layer.  
-   The scsi mid layer (scsi_register_host) is
-   called from cciss.c:cciss_init_one().  */
-
-int __init 
-cciss_scsi_detect(Scsi_Host_Template *tpnt)
+static int __init 
+cciss_scsi_detect(int ctlr)
 {
-	int i;
 	struct Scsi_Host *sh;
 
-	/* Tell the kernel we want to be a SCSI driver... */
-	sh = scsi_register(tpnt, sizeof(struct ctlr_info *));
-	if (sh == NULL) return 0;
+	sh = scsi_register(&cciss_driver_template, sizeof(struct ctlr_info *));
+	if (sh == NULL)
+		return 0;
 
 	sh->io_port = 0;	// good enough?  FIXME, 
 	sh->n_io_port = 0;	// I don't think we use these two...
 
 	sh->this_id = SELF_SCSI_ID;  
 
-	/* This is a bit kludgey, using the adapter name to figure out */
-	/* which scsi host template we've got, won't scale beyond 9 ctlrs. */
-	i = tpnt->name[5] - '0';
-
-#	if MAX_CTLR > 9
-#		error "cciss_scsi.c: MAX_CTLR > 9, code maintenance needed."
-#	endif	
-
-	if (i<0 || i>=MAX_CTLR || hba[i] == NULL) {
-		/* we didn't find ourself... we shouldn't get here. */
-		printk("cciss_scsi_detect: could not find ourself in hba[]\n");
-		return 0;
-	}
-
 	((struct cciss_scsi_adapter_data_t *) 
-		hba[i]->scsi_ctlr)->scsi_host = (void *) sh;
-	sh->hostdata[0] = (unsigned long) hba[i];
-	sh->irq = hba[i]->intr;
+		hba[ctlr]->scsi_ctlr)->scsi_host = (void *) sh;
+	sh->hostdata[0] = (unsigned long) hba[ctlr];
+	sh->irq = hba[ctlr]->intr;
 	sh->unique_id = sh->irq;
-	scsi_set_device(sh, &hba[i]->pdev->dev);
+	scsi_add_host(sh, &hba[ctlr]->pdev->dev);
 
-	return 1;	/* Say we have 1 scsi adapter, this will be */
-			/* called multiple times, once for each adapter */
-			/* from cciss.c:cciss_init_one().  We do it this */
-			/* way for PCI-hot plug reasons. (we don't know how */
-			/* many adapters we have total, so we say we have */
-			/* 1, each of a unique type.) */
+	return 1;
 }
 
 static void __exit cleanup_cciss_module(void);
-int
-cciss_scsi_release(struct Scsi_Host *sh)
-{
-	return 0;
-}
 
 static void
 cciss_unmap_one(struct pci_dev *pdev,
@@ -1382,33 +1346,6 @@
 }
 
 static void 
-init_driver_template(int ctlr)
-{
-	memset(&driver_template[ctlr], 0, sizeof(driver_template[ctlr]));
-	driver_template[ctlr].name = ccissscsi[ctlr].name;
-	driver_template[ctlr].proc_name = ccissscsi[ctlr].name;
-	driver_template[ctlr].detect = cciss_scsi_detect;
-	driver_template[ctlr].release = cciss_scsi_release;
-	driver_template[ctlr].proc_info = cciss_scsi_proc_info;
-	driver_template[ctlr].queuecommand = cciss_scsi_queue_command;
-	driver_template[ctlr].eh_abort_handler = NULL;
-	driver_template[ctlr].eh_device_reset_handler = NULL;
-	driver_template[ctlr].can_queue = SCSI_CCISS_CAN_QUEUE;
-	driver_template[ctlr].this_id = 7;
-	driver_template[ctlr].sg_tablesize = MAXSGENTRIES;
-	driver_template[ctlr].cmd_per_lun = 1;
-	driver_template[ctlr].use_clustering = DISABLE_CLUSTERING;
-	driver_template[ctlr].module = THIS_MODULE;
-
-	/* set scsi_host to NULL so our detect routine will 
-	   find us on register */
-
-	((struct cciss_scsi_adapter_data_t *) 
-		hba[ctlr]->scsi_ctlr)->scsi_host = NULL;
-
-}
-
-static void 
 cciss_unregister_scsi(int ctlr)
 {
 	struct cciss_scsi_adapter_data_t *sa;
@@ -1422,15 +1359,18 @@
 	stk = &sa->cmd_stack; 
 
 	/* if we weren't ever actually registered, don't unregister */ 
-	if (((struct cciss_scsi_adapter_data_t *) 
-		hba[ctlr]->scsi_ctlr)->registered) {
+	if (sa->registered) {
 		spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags);
-		scsi_unregister_host(&driver_template[ctlr]);
+		scsi_remove_host(sa->scsi_host);
+		scsi_unregister(sa->scsi_host);
 		spin_lock_irqsave(CCISS_LOCK(ctlr), flags);
 	}
-	init_driver_template(ctlr);
+
+	/* set scsi_host to NULL so our detect routine will 
+	   find us on register */
+	sa->scsi_host = NULL;
 	scsi_cmd_stack_free(ctlr);
-	kfree(hba[ctlr]->scsi_ctlr);
+	kfree(sa);
 	spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags);
 }
 
@@ -1440,9 +1380,6 @@
 	unsigned long flags;
 
 	CPQ_TAPE_LOCK(ctlr, flags);
-	driver_template[ctlr].name = ccissscsi[ctlr].name;
-	driver_template[ctlr].proc_name = ccissscsi[ctlr].name;
-	driver_template[ctlr].module = THIS_MODULE;;
 
 	/* Since this is really a block driver, the SCSI core may not be 
 	   initialized at init time, in which case, calling scsi_register_host
@@ -1454,7 +1391,7 @@
 		((struct cciss_scsi_adapter_data_t *) 
 			hba[ctlr]->scsi_ctlr)->registered = 1;
 		CPQ_TAPE_UNLOCK(ctlr, flags);
-		return scsi_register_host(&driver_template[ctlr]);
+		return cciss_scsi_detect(ctlr);
 	}
 	CPQ_TAPE_UNLOCK(ctlr, flags);
 	printk(KERN_INFO 
@@ -1489,8 +1426,8 @@
 static void
 cciss_proc_tape_report(int ctlr, unsigned char *buffer, off_t *pos, off_t *len)
 {
+	unsigned long flags;
 	int size;
-	unsigned int flags;
 
 	*pos = *pos -1; *len = *len - 1; // cut off the last trailing newline
 
diff -urN linux-2.5.69-bk7/drivers/block/cciss_scsi.h linux-2.5.69-bk8/drivers/block/cciss_scsi.h
--- linux-2.5.69-bk7/drivers/block/cciss_scsi.h	2003-05-04 16:53:29.000000000 -0700
+++ linux-2.5.69-bk8/drivers/block/cciss_scsi.h	2003-05-13 04:44:27.000000000 -0700
@@ -38,23 +38,6 @@
 
 #define SCSI_CCISS_CAN_QUEUE 2
 
-/* this notation works fine for static initializations (as is the usual
-   case for linux scsi drivers), but not so well for dynamic settings,
-   so, if you change this, you also have to change cciss_unregister_scsi()
-   in cciss_scsi.c  */
-#define CCISS_SCSI {    \
-	name:           	"",				\
-	detect:         	cciss_scsi_detect,		\
-	release:        	cciss_scsi_release,		\
-	proc_info:           	cciss_scsi_proc_info,		\
-	queuecommand:   	cciss_scsi_queue_command,	\
-	can_queue:      	SCSI_CCISS_CAN_QUEUE,		\
-	this_id:        	7,				\
-	sg_tablesize:   	MAXSGENTRIES, 			\
-	cmd_per_lun:		1,				\
-	use_clustering:		DISABLE_CLUSTERING,\
-} 
-
 /* 
 	info:           	cciss_scsi_info,		\
 
diff -urN linux-2.5.69-bk7/drivers/block/scsi_ioctl.c linux-2.5.69-bk8/drivers/block/scsi_ioctl.c
--- linux-2.5.69-bk7/drivers/block/scsi_ioctl.c	2003-05-04 16:53:57.000000000 -0700
+++ linux-2.5.69-bk8/drivers/block/scsi_ioctl.c	2003-05-13 04:44:27.000000000 -0700
@@ -299,13 +299,14 @@
 #define MOVE_MEDIUM_TIMEOUT		(5 * 60 * HZ)
 #define READ_ELEMENT_STATUS_TIMEOUT	(5 * 60 * HZ)
 #define READ_DEFECT_DATA_TIMEOUT	(60 * HZ )
+#define OMAX_SB_LEN 16          /* For backward compatibility */
 
 static int sg_scsi_ioctl(request_queue_t *q, struct block_device *bdev,
 			 Scsi_Ioctl_Command *sic)
 {
 	struct request *rq;
 	int err, in_len, out_len, bytes, opcode, cmdlen;
-	char *buffer = NULL, sense[24];
+	char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
 
 	/*
 	 * get in an out lengths, verify they don't exceed a page worth of data
@@ -378,9 +379,12 @@
 	blk_do_rq(q, bdev, rq);
 	err = rq->errors & 0xff;	/* only 8 bit SCSI status */
 	if (err) {
-		if (rq->sense_len)
-			if (copy_to_user(sic->data, rq->sense, rq->sense_len))
+		if (rq->sense_len && rq->sense) {
+			bytes = (OMAX_SB_LEN > rq->sense_len) ?
+				rq->sense_len : OMAX_SB_LEN;
+			if (copy_to_user(sic->data, rq->sense, bytes))
 				err = -EFAULT;
+		}
 	} else {
 		if (copy_to_user(sic->data, buffer, out_len))
 			err = -EFAULT;
diff -urN linux-2.5.69-bk7/drivers/cpufreq/proc_intf.c linux-2.5.69-bk8/drivers/cpufreq/proc_intf.c
--- linux-2.5.69-bk7/drivers/cpufreq/proc_intf.c	2003-05-04 16:53:02.000000000 -0700
+++ linux-2.5.69-bk8/drivers/cpufreq/proc_intf.c	2003-05-13 04:44:27.000000000 -0700
@@ -209,6 +209,9 @@
 {
 	struct proc_dir_entry *entry = NULL;
 
+	if (!cpufreq_driver)
+		return -ENODEV;
+
         /* are these acceptable values? */
 	entry = create_proc_entry("cpufreq", S_IFREG|S_IRUGO|S_IWUSR, 
 				  &proc_root);
diff -urN linux-2.5.69-bk7/drivers/ide/ide-probe.c linux-2.5.69-bk8/drivers/ide/ide-probe.c
--- linux-2.5.69-bk7/drivers/ide/ide-probe.c	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/drivers/ide/ide-probe.c	2003-05-13 04:44:28.000000000 -0700
@@ -803,7 +803,7 @@
 		return;
 
 	if ((hwif->chipset != ide_4drives || !hwif->mate || !hwif->mate->present) &&
-#if CONFIG_BLK_DEV_PDC4030
+#ifdef CONFIG_BLK_DEV_PDC4030
 	    (hwif->chipset != ide_pdc4030 || hwif->channel == 0) &&
 #endif /* CONFIG_BLK_DEV_PDC4030 */
 	    (hwif_check_regions(hwif))) {
diff -urN linux-2.5.69-bk7/drivers/isdn/eicon/eicon_mod.c linux-2.5.69-bk8/drivers/isdn/eicon/eicon_mod.c
--- linux-2.5.69-bk7/drivers/isdn/eicon/eicon_mod.c	2003-05-04 16:53:02.000000000 -0700
+++ linux-2.5.69-bk8/drivers/isdn/eicon/eicon_mod.c	2003-05-13 04:44:28.000000000 -0700
@@ -245,7 +245,7 @@
 							card->hwif.isa.shmem = (eicon_isa_shmem *)a;
 							return 0;
 						case EICON_BUS_MCA:
-#if CONFIG_MCA
+#ifdef CONFIG_MCA
 							if (eicon_mca_find_card(
 								0, a,
 								card->hwif.isa.irq,
@@ -853,7 +853,7 @@
 		card->type = Type;
 		switch (Type) {
 #ifdef CONFIG_ISDN_DRV_EICON_ISA
-#if CONFIG_MCA /* only needed for MCA */
+#ifdef CONFIG_MCA /* only needed for MCA */
                         case EICON_CTYPE_S:
                         case EICON_CTYPE_SX:
                         case EICON_CTYPE_SCOM:
@@ -1342,7 +1342,7 @@
 static void __exit
 eicon_exit(void)
 {
-#if CONFIG_PCI	
+#ifdef CONFIG_PCI	
 #ifdef CONFIG_ISDN_DRV_EICON_PCI
 	card_t *pCard;
 	word wCardIndex;
@@ -1374,7 +1374,7 @@
 		eicon_freecard(last);
         }
 
-#if CONFIG_PCI	
+#ifdef CONFIG_PCI	
 #ifdef CONFIG_ISDN_DRV_EICON_PCI
 	pCard = DivasCards;
 	for (wCardIndex = 0; wCardIndex < MAX_CARDS; wCardIndex++)
diff -urN linux-2.5.69-bk7/drivers/isdn/eicon/eicon_pci.c linux-2.5.69-bk8/drivers/isdn/eicon/eicon_pci.c
--- linux-2.5.69-bk7/drivers/isdn/eicon/eicon_pci.c	2003-05-04 16:53:41.000000000 -0700
+++ linux-2.5.69-bk8/drivers/isdn/eicon/eicon_pci.c	2003-05-13 04:44:28.000000000 -0700
@@ -26,7 +26,7 @@
 
 char *eicon_pci_revision = "$Revision: 1.1.4.1.2.3 $";
 
-#if CONFIG_PCI	         /* intire stuff is only for PCI */
+#ifdef CONFIG_PCI	         /* entire stuff is only for PCI */
 #ifdef CONFIG_ISDN_DRV_EICON_PCI
 
 int eicon_pci_find_card(char *ID)
diff -urN linux-2.5.69-bk7/drivers/isdn/hisax/avm_pci.c linux-2.5.69-bk8/drivers/isdn/hisax/avm_pci.c
--- linux-2.5.69-bk7/drivers/isdn/hisax/avm_pci.c	2003-05-04 16:53:09.000000000 -0700
+++ linux-2.5.69-bk8/drivers/isdn/hisax/avm_pci.c	2003-05-13 04:44:28.000000000 -0700
@@ -730,7 +730,7 @@
 			}
 		}
 #endif
-#if CONFIG_PCI
+#ifdef CONFIG_PCI
 		if ((dev_avm = pci_find_device(PCI_VENDOR_ID_AVM,
 			PCI_DEVICE_ID_AVM_A1,  dev_avm))) {
 			if (avm_pci_probe(card->cs, dev_avm))
diff -urN linux-2.5.69-bk7/drivers/isdn/hisax/diva.c linux-2.5.69-bk8/drivers/isdn/hisax/diva.c
--- linux-2.5.69-bk7/drivers/isdn/hisax/diva.c	2003-05-04 16:53:41.000000000 -0700
+++ linux-2.5.69-bk8/drivers/isdn/hisax/diva.c	2003-05-13 04:44:28.000000000 -0700
@@ -772,7 +772,7 @@
 		}
 	}
 #endif
-#if CONFIG_PCI
+#ifdef CONFIG_PCI
 	if ((dev_diva = pci_find_device(PCI_VENDOR_ID_EICON,
 					PCI_DEVICE_ID_EICON_DIVA20,
 					dev_diva))) {
diff -urN linux-2.5.69-bk7/drivers/isdn/hisax/elsa.c linux-2.5.69-bk8/drivers/isdn/hisax/elsa.c
--- linux-2.5.69-bk7/drivers/isdn/hisax/elsa.c	2003-05-04 16:53:02.000000000 -0700
+++ linux-2.5.69-bk8/drivers/isdn/hisax/elsa.c	2003-05-13 04:44:28.000000000 -0700
@@ -1098,7 +1098,7 @@
 			return 0;
 		return 1;
 	} else if (card->typ == ISDN_CTYPE_ELSA_PCI) {
-#if CONFIG_PCI
+#ifdef CONFIG_PCI
 		if ((dev_qs1000 = pci_find_device(PCI_VENDOR_ID_ELSA,
 			PCI_DEVICE_ID_ELSA_MICROLINK, dev_qs1000))) {
 			if (elsa_qs_pci_probe(card->cs, dev_qs1000,
diff -urN linux-2.5.69-bk7/drivers/isdn/hisax/niccy.c linux-2.5.69-bk8/drivers/isdn/hisax/niccy.c
--- linux-2.5.69-bk7/drivers/isdn/hisax/niccy.c	2003-05-04 16:53:13.000000000 -0700
+++ linux-2.5.69-bk8/drivers/isdn/hisax/niccy.c	2003-05-13 04:44:28.000000000 -0700
@@ -319,7 +319,7 @@
 			return 0;
 		return 1;
 	} else {
-#if CONFIG_PCI
+#ifdef CONFIG_PCI
 		if ((niccy_dev = pci_find_device(PCI_VENDOR_ID_SATSAGEM,
 			PCI_DEVICE_ID_SATSAGEM_NICCY, niccy_dev))) {
 			if (niccy_pci_probe(card->cs, niccy_dev) < 0)
diff -urN linux-2.5.69-bk7/drivers/isdn/hisax/sedlbauer.c linux-2.5.69-bk8/drivers/isdn/hisax/sedlbauer.c
--- linux-2.5.69-bk7/drivers/isdn/hisax/sedlbauer.c	2003-05-04 16:53:55.000000000 -0700
+++ linux-2.5.69-bk8/drivers/isdn/hisax/sedlbauer.c	2003-05-13 04:44:28.000000000 -0700
@@ -789,7 +789,7 @@
 	}
 #endif
 /* Probe for Sedlbauer speed pci */
-#if CONFIG_PCI
+#ifdef CONFIG_PCI
 	dev_sedl = pci_find_device(PCI_VENDOR_ID_TIGERJET,
 				   PCI_DEVICE_ID_TIGERJET_100, dev_sedl);
 	if (dev_sedl) {
diff -urN linux-2.5.69-bk7/drivers/message/fusion/mptscsih.c linux-2.5.69-bk8/drivers/message/fusion/mptscsih.c
--- linux-2.5.69-bk7/drivers/message/fusion/mptscsih.c	2003-05-04 16:53:13.000000000 -0700
+++ linux-2.5.69-bk8/drivers/message/fusion/mptscsih.c	2003-05-13 04:44:28.000000000 -0700
@@ -3631,8 +3631,30 @@
 /* see mptscsih.h */
 
 #ifdef MPT_SCSIHOST_NEED_ENTRY_EXIT_HOOKUPS
-	static Scsi_Host_Template driver_template = MPT_SCSIHOST;
-#	include "../../scsi/scsi_module.c"
+static Scsi_Host_Template driver_template = {
+	.proc_name			= "mptscsih",
+	.proc_info			= x_scsi_proc_info,
+	.name				= "MPT SCSI Host",
+	.detect				= x_scsi_detect,
+	.release			= x_scsi_release,
+	.info				= x_scsi_info,	
+	.queuecommand			= x_scsi_queuecommand,
+	.slave_alloc			= x_scsi_slave_alloc,
+	.slave_configure		= x_scsi_slave_configure,
+	.slave_destroy			= x_scsi_slave_destroy,
+	.eh_abort_handler		= x_scsi_abort,
+	.eh_device_reset_handler	= x_scsi_dev_reset,
+	.eh_bus_reset_handler		= x_scsi_bus_reset,
+	.eh_host_reset_handler		= x_scsi_host_reset,
+	.bios_param			= x_scsi_bios_param,
+	.can_queue			= MPT_SCSI_CAN_QUEUE,
+	.this_id			= -1,
+	.sg_tablesize			= MPT_SCSI_SG_DEPTH,
+	.max_sectors			= MPT_SCSI_MAX_SECTORS,
+	.cmd_per_lun			= MPT_SCSI_CMD_PER_LUN,
+	.use_clustering			= ENABLE_CLUSTERING,
+};
+#include "../../scsi/scsi_module.c"
 #endif
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
diff -urN linux-2.5.69-bk7/drivers/message/fusion/mptscsih.h linux-2.5.69-bk8/drivers/message/fusion/mptscsih.h
--- linux-2.5.69-bk7/drivers/message/fusion/mptscsih.h	2003-05-04 16:53:57.000000000 -0700
+++ linux-2.5.69-bk8/drivers/message/fusion/mptscsih.h	2003-05-13 04:44:28.000000000 -0700
@@ -201,36 +201,6 @@
 extern	void		 x_scsi_slave_destroy(Scsi_Device *);
 extern	int		 x_scsi_proc_info(char *, char **, off_t, int, int, int);
 
-#define PROC_SCSI_DECL  .proc_name = "mptscsih",
-
-#define MPT_SCSIHOST {						\
-	PROC_SCSI_DECL						\
-	.proc_info			= x_scsi_proc_info,	\
-	.name				= "MPT SCSI Host",	\
-	.detect				= x_scsi_detect,	\
-	.release			= x_scsi_release,	\
-	.info				= x_scsi_info,		\
-	.command			= NULL,			\
-	.queuecommand			= x_scsi_queuecommand,	\
-	.slave_alloc			= x_scsi_slave_alloc,	\
-	.slave_configure		= x_scsi_slave_configure,	\
-	.slave_destroy			= x_scsi_slave_destroy,	\
-	.eh_strategy_handler		= NULL,			\
-	.eh_abort_handler		= x_scsi_abort,		\
-	.eh_device_reset_handler	= x_scsi_dev_reset,	\
-	.eh_bus_reset_handler		= x_scsi_bus_reset,	\
-	.eh_host_reset_handler		= x_scsi_host_reset,	\
-	.bios_param			= x_scsi_bios_param,	\
-	.can_queue			= MPT_SCSI_CAN_QUEUE,	\
-	.this_id			= -1,			\
-	.sg_tablesize			= MPT_SCSI_SG_DEPTH,	\
-	.max_sectors			= MPT_SCSI_MAX_SECTORS,	\
-	.cmd_per_lun			= MPT_SCSI_CMD_PER_LUN,	\
-	.unchecked_isa_dma		= 0,			\
-	.use_clustering			= ENABLE_CLUSTERING,	\
-}
-
-
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 
 /*  include/scsi/scsi.h may not be quite complete...  */
diff -urN linux-2.5.69-bk7/drivers/mtd/maps/sa1100-flash.c linux-2.5.69-bk8/drivers/mtd/maps/sa1100-flash.c
--- linux-2.5.69-bk7/drivers/mtd/maps/sa1100-flash.c	2003-05-04 16:53:08.000000000 -0700
+++ linux-2.5.69-bk8/drivers/mtd/maps/sa1100-flash.c	2003-05-13 04:44:28.000000000 -0700
@@ -337,7 +337,7 @@
 
 #ifdef CONFIG_SA1100_FREEBIRD
 static struct mtd_partition freebird_partitions[] = {
-#if CONFIG_SA1100_FREEBIRD_NEW
+#ifdef CONFIG_SA1100_FREEBIRD_NEW
 	{
 		.name		= "firmware",
 		.size		= 0x00040000,
diff -urN linux-2.5.69-bk7/drivers/pnp/resource.c linux-2.5.69-bk8/drivers/pnp/resource.c
--- linux-2.5.69-bk7/drivers/pnp/resource.c	2003-05-04 16:53:32.000000000 -0700
+++ linux-2.5.69-bk8/drivers/pnp/resource.c	2003-05-13 04:44:28.000000000 -0700
@@ -422,7 +422,7 @@
 
 static irqreturn_t pnp_test_handler(int irq, void *dev_id, struct pt_regs *regs)
 {
-	return IRQ_NONE;
+	return IRQ_HANDLED;
 }
 
 int pnp_check_irq(struct pnp_dev * dev, int idx)
diff -urN linux-2.5.69-bk7/drivers/scsi/3w-xxxx.c linux-2.5.69-bk8/drivers/scsi/3w-xxxx.c
--- linux-2.5.69-bk7/drivers/scsi/3w-xxxx.c	2003-05-04 16:53:41.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/3w-xxxx.c	2003-05-13 04:44:28.000000000 -0700
@@ -3439,7 +3439,24 @@
 	outl(control_reg_value, control_reg_addr);
 } /* End tw_unmask_command_interrupt() */
 
-/* Now get things going */
-static Scsi_Host_Template driver_template = TWXXXX;
+static Scsi_Host_Template driver_template = {
+	.proc_name		= "3w-xxxx",
+	.proc_info		= tw_scsi_proc_info,
+	.name			= "3ware Storage Controller",
+	.detect			= tw_scsi_detect,
+	.release		= tw_scsi_release,
+	.queuecommand		= tw_scsi_queue,
+	.eh_abort_handler	= tw_scsi_eh_abort,
+	.eh_host_reset_handler	= tw_scsi_eh_reset,
+	.bios_param		= tw_scsi_biosparam,
+	.can_queue		= TW_Q_LENGTH-2,
+	.this_id		= -1,
+	.sg_tablesize		= TW_MAX_SGL_LENGTH,
+	.max_sectors		= TW_MAX_SECTORS,
+	.cmd_per_lun		= TW_MAX_CMDS_PER_LUN,	
+	.use_clustering		= ENABLE_CLUSTERING,
+	.emulated		= 1,
+	.highmem_io		= 1,
+};
 #include "scsi_module.c"
 
diff -urN linux-2.5.69-bk7/drivers/scsi/3w-xxxx.h linux-2.5.69-bk8/drivers/scsi/3w-xxxx.h
--- linux-2.5.69-bk7/drivers/scsi/3w-xxxx.h	2003-05-04 16:53:08.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/3w-xxxx.h	2003-05-13 04:44:28.000000000 -0700
@@ -497,26 +497,4 @@
 int tw_state_request_start(TW_Device_Extension *tw_dev, int *request_id);
 void tw_unmask_command_interrupt(TW_Device_Extension *tw_dev);
 
-/* Scsi_Host_Template Initializer */
-#define TWXXXX {					\
-	.proc_name	= "3w-xxxx",			\
-	.proc_info	= tw_scsi_proc_info,		\
-	.name		= "3ware Storage Controller",	\
-	.detect		= tw_scsi_detect,		\
-	.release	= tw_scsi_release,		\
-	.queuecommand	= tw_scsi_queue,		\
-	.eh_abort_handler	= tw_scsi_eh_abort,	\
-	.eh_host_reset_handler	= tw_scsi_eh_reset,	\
-	.bios_param	= tw_scsi_biosparam,		\
-	.can_queue	= TW_Q_LENGTH-2,		\
-	.this_id	= -1,				\
-	.sg_tablesize	= TW_MAX_SGL_LENGTH,		\
-	.max_sectors    = TW_MAX_SECTORS,		\
-	.cmd_per_lun	= TW_MAX_CMDS_PER_LUN,		\
-	.present	= 0,				\
-	.unchecked_isa_dma	= 0,			\
-	.use_clustering	= ENABLE_CLUSTERING,		\
-	.emulated	= 1,				\
-	.highmem_io	= 1				\
-}
 #endif /* _3W_XXXX_H */
diff -urN linux-2.5.69-bk7/drivers/scsi/AM53C974.c linux-2.5.69-bk8/drivers/scsi/AM53C974.c
--- linux-2.5.69-bk7/drivers/scsi/AM53C974.c	2003-05-04 16:53:14.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/AM53C974.c	2003-05-13 04:44:28.000000000 -0700
@@ -2453,5 +2453,21 @@
 MODULE_LICENSE("GPL");
 
 
-static Scsi_Host_Template driver_template = AM53C974;
+static Scsi_Host_Template driver_template = {
+	.proc_name		= "am53c974",
+	.name           	= "AM53C974",
+	.detect         	= AM53C974_pci_detect,
+	.release        	= AM53C974_release,	
+	.info			= AM53C974_info,
+	.command		= AM53C974_command,
+	.queuecommand		= AM53C974_queue_command,
+	.abort			= AM53C974_abort,
+	.reset			= AM53C974_reset,
+	.can_queue		= 12,
+	.this_id		= -1,
+	.sg_tablesize		= SG_ALL,
+	.cmd_per_lun		= 1,
+	.use_clustering		= DISABLE_CLUSTERING,
+};
+
 #include "scsi_module.c"
diff -urN linux-2.5.69-bk7/drivers/scsi/AM53C974.h linux-2.5.69-bk8/drivers/scsi/AM53C974.h
--- linux-2.5.69-bk7/drivers/scsi/AM53C974.h	2003-05-04 16:53:40.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/AM53C974.h	2003-05-13 04:44:28.000000000 -0700
@@ -50,23 +50,6 @@
 	unsigned char max_offset[8];	/* max. sync. offset (setup), only valid if corresponding sync_en is nonzero */
 };
 
-#define AM53C974 {				  \
-    .proc_name      = "am53c974",    	          \
-    .name           = "AM53C974",        		  \
-    .detect         = AM53C974_pci_detect,	  \
-    .release        = AM53C974_release,		  \
-    .info           = AM53C974_info,     		  \
-    .command        = AM53C974_command,  		  \
-    .queuecommand   = AM53C974_queue_command,	  \
-    .abort          = AM53C974_abort,    		  \
-    .reset          = AM53C974_reset,    		  \
-    .can_queue      = 12,                 	  \
-    .this_id        = -1,                           \
-    .sg_tablesize   = SG_ALL,            		  \
-    .cmd_per_lun    = 1,                 		  \
-    .use_clustering = DISABLE_CLUSTERING 		  \
-    }
-
 static int AM53C974_pci_detect(Scsi_Host_Template * tpnt);
 static int AM53C974_release(struct Scsi_Host *shp);
 static const char *AM53C974_info(struct Scsi_Host *);
diff -urN linux-2.5.69-bk7/drivers/scsi/BusLogic.c linux-2.5.69-bk8/drivers/scsi/BusLogic.c
--- linux-2.5.69-bk7/drivers/scsi/BusLogic.c	2003-05-04 16:53:41.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/BusLogic.c	2003-05-13 04:44:28.000000000 -0700
@@ -3213,6 +3213,7 @@
 	    Place CCB back on the Host Adapter's free list.
 	  */
 	  BusLogic_DeallocateCCB(CCB);
+#if 0	/* this needs to be redone different for new EH */
 	  /*
 	    Bus Device Reset CCBs have the Command field non-NULL only when a
 	    Bus Device Reset was requested for a Command that did not have a
@@ -3228,6 +3229,7 @@
 	      Command->scsi_done(Command);
 	      Command = NextCommand;
 	    }
+#endif
 	  /*
 	    Iterate over the CCBs for this Host Adapter performing completion
 	    processing for any CCBs marked as Reset for this Target.
@@ -3948,6 +3950,7 @@
       {
 	Command = CCB->Command;
 	BusLogic_DeallocateCCB(CCB);
+#if 0	/* this needs to be redone different for new EH */
 	while (Command != NULL)
 	  {
 	    SCSI_Command_T *NextCommand = Command->reset_chain;
@@ -3956,6 +3959,7 @@
 	    Command->scsi_done(Command);
 	    Command = NextCommand;
 	  }
+#endif
       }
   for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++)
     {
@@ -3967,7 +3971,7 @@
   return Result;
 }
 
-
+#if 0	/* old-style EH code references a dead struct scsi_cmnd member */
 /*
   BusLogic_SendBusDeviceReset sends a Bus Device Reset to the Target
   Device associated with Command.
@@ -4204,6 +4208,7 @@
     }
   return SCSI_RESET_PUNT;
 }
+#endif
 
 
 /*
@@ -5113,6 +5118,18 @@
 */
 MODULE_LICENSE("GPL");
 
-static SCSI_Host_Template_T driver_template = BUSLOGIC;
-
+static SCSI_Host_Template_T driver_template = {
+	.proc_name		= "BusLogic",
+	.proc_info		= BusLogic_ProcDirectoryInfo,
+	.name			= "BusLogic",
+	.detect			= BusLogic_DetectHostAdapter,
+	.release		= BusLogic_ReleaseHostAdapter,
+	.info			= BusLogic_DriverInfo,
+	.queuecommand		= BusLogic_QueueCommand,
+	.slave_configure	= BusLogic_SlaveConfigure,
+	.bios_param		= BusLogic_BIOSDiskParameters,
+	.unchecked_isa_dma	= 1,
+	.max_sectors		= 128,
+	.use_clustering		= ENABLE_CLUSTERING,
+};
 #include "scsi_module.c"
diff -urN linux-2.5.69-bk7/drivers/scsi/BusLogic.h linux-2.5.69-bk8/drivers/scsi/BusLogic.h
--- linux-2.5.69-bk7/drivers/scsi/BusLogic.h	2003-05-04 16:53:14.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/BusLogic.h	2003-05-13 04:44:28.000000000 -0700
@@ -59,30 +59,6 @@
 extern int BusLogic_ProcDirectoryInfo(char *, char **, off_t, int, int, int);
 extern int BusLogic_SlaveConfigure(SCSI_Device_T *);
 
-
-/*
-  Define the BusLogic SCSI Host Template structure.
-*/
-
-#define BUSLOGIC							       \
-  { .proc_name      = "BusLogic",			  /* ProcFS Directory Entry */ \
-    .proc_info      = BusLogic_ProcDirectoryInfo,	  /* ProcFS Info Function   */ \
-    .name           = "BusLogic",			  /* Driver Name            */ \
-    .detect         = BusLogic_DetectHostAdapter,	  /* Detect Host Adapter    */ \
-    .release        = BusLogic_ReleaseHostAdapter,  /* Release Host Adapter   */ \
-    .info           = BusLogic_DriverInfo,	  /* Driver Info Function   */ \
-    .queuecommand   = BusLogic_QueueCommand,	  /* Queue Command Function */ \
-    .slave_configure = BusLogic_SlaveConfigure,	  /* Configure a SCSI_Device*/ \
-    .bios_param     = BusLogic_BIOSDiskParameters,  /* BIOS Disk Parameters   */ \
-    .unchecked_isa_dma = 1,			  /* Default Initial Value  */ \
-    .max_sectors    = 128,			  /* I/O queue len limit    */ \
-    .use_clustering = ENABLE_CLUSTERING }		  /* Enable Clustering	    */
-
-
-/*
-  BusLogic_DriverVersion protects the private portion of this file.
-*/
-
 #ifdef BusLogic_DriverVersion
 
 
diff -urN linux-2.5.69-bk7/drivers/scsi/Makefile linux-2.5.69-bk8/drivers/scsi/Makefile
--- linux-2.5.69-bk7/drivers/scsi/Makefile	2003-05-04 16:53:37.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/Makefile	2003-05-13 04:44:28.000000000 -0700
@@ -124,7 +124,8 @@
 
 scsi_mod-y			+= scsi.o hosts.o scsi_ioctl.o constants.o \
 				   scsicam.o scsi_error.o scsi_lib.o \
-				   scsi_scan.o scsi_syms.o scsi_sysfs.o
+				   scsi_scan.o scsi_syms.o scsi_sysfs.o \
+				   scsi_devinfo.o
 scsi_mod-$(CONFIG_PROC_FS)	+= scsi_proc.o
 scsi_mod-$(CONFIG_X86_PC9800)	+= scsi_pc98.o
 			
diff -urN linux-2.5.69-bk7/drivers/scsi/NCR_D700.c linux-2.5.69-bk8/drivers/scsi/NCR_D700.c
--- linux-2.5.69-bk7/drivers/scsi/NCR_D700.c	2003-05-04 16:53:02.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/NCR_D700.c	2003-05-13 04:44:28.000000000 -0700
@@ -92,18 +92,12 @@
 
 #define NCR_D700_VERSION "2.2"
 
-#include <linux/config.h>
-#include <linux/blk.h>
+#include <linux/blkdev.h>
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/mca.h>
-
-#include <asm/dma.h>
-#include <asm/system.h>
 #include <asm/io.h>
-#include <asm/pgtable.h>
-#include <asm/byteorder.h>
 
 #include "scsi.h"
 #include "hosts.h"
@@ -111,16 +105,6 @@
 #include "53c700.h"
 #include "NCR_D700.h"
 
-#ifndef CONFIG_MCA
-#error "NCR_D700 driver only compiles for MCA"
-#endif
-
-#ifdef NCR_D700_DEBUG
-#define STATIC
-#else
-#define STATIC static
-#endif
-
 char *NCR_D700;			/* command line from insmod */
 
 MODULE_AUTHOR("James Bottomley");
@@ -170,34 +154,101 @@
 	return 1;
 }
 
-#ifndef MODULE
-__setup("NCR_D700=", param_setup);
-#endif
+/* Host template.  The 53c700 routine NCR_700_detect will
+ * fill in all of the missing routines */
+static Scsi_Host_Template NCR_D700_driver_template = {
+	.module			= THIS_MODULE,
+	.name			= "NCR Dual 700 MCA",
+	.proc_name		= "NCR_D700",
+	.this_id		= 7,
+};
 
-/* private stack allocated structure for passing device information from
- * detect to probe */
-struct NCR_700_info {
-	Scsi_Host_Template *tpnt;
-	int found;
+/* We needs this helper because we have two hosts per struct device */
+struct NCR_D700_private {
+	struct device		*dev;
+	struct Scsi_Host	*hosts[2];
 };
 
-/* Detect a D700 card.  Note, because of the set up---the chips are
+static int 
+NCR_D700_probe_one(struct NCR_D700_private *p, int siop,
+		int irq, int slot, u32 region, int differential)
+{
+	struct NCR_700_Host_Parameters *hostdata;
+	struct Scsi_Host *host;
+	int ret;
+
+	hostdata = kmalloc(sizeof(*hostdata), GFP_KERNEL);
+	if (!hostdata) {
+		printk(KERN_ERR "NCR D700: SIOP%d: Failed to allocate host"
+		       "data, detatching\n", siop);
+		return -ENOMEM;
+	}
+	memset(hostdata, 0, sizeof(*hostdata));
+
+	if (!request_region(region, 64, "NCR_D700")) {
+		printk(KERN_ERR "NCR D700: Failed to reserve IO region 0x%x\n",
+				region);
+		ret = -ENODEV;
+		goto region_failed;
+	}
+		
+	/* Fill in the three required pieces of hostdata */
+	hostdata->base = region;
+	hostdata->differential = (((1<<siop) & differential) != 0);
+	hostdata->clock = NCR_D700_CLOCK_MHZ;
+
+	/* and register the siop */
+	host = NCR_700_detect(&NCR_D700_driver_template, hostdata);
+	if (!host) {
+		ret = -ENOMEM;
+		goto detect_failed;
+	}
+
+	host->irq = irq;
+	/* FIXME: Read this from SUS */
+	host->this_id = id_array[slot * 2 + siop];
+	printk(KERN_NOTICE "NCR D700: SIOP%d, SCSI id is %d\n",
+			siop, host->this_id);
+	if (request_irq(irq, NCR_700_intr, SA_SHIRQ, "NCR_D700", host)) {
+		printk(KERN_ERR "NCR D700: SIOP%d: irq problem, "
+				"detatching\n", siop);
+		ret = -ENODEV;
+		goto irq_failed;
+	}
+
+	scsi_add_host(host, p->dev);
+
+	p->hosts[siop] = host;
+	hostdata->dev = p->dev;
+	return 0;
+
+ irq_failed:
+	scsi_unregister(host);
+	NCR_700_release(host);
+ detect_failed:
+	release_region(host->base, 64);
+ region_failed:
+	kfree(hostdata);
+
+	return ret;
+}
+
+/* Detect a D700 card.  Note, because of the setup --- the chips are
  * essentially connectecd to the MCA bus independently, it is easier
  * to set them up as two separate host adapters, rather than one
  * adapter with two channels */
 static int
 NCR_D700_probe(struct device *dev)
 {
+	struct NCR_D700_private *p;
 	int differential;
 	static int banner = 1;
 	struct mca_device *mca_dev = to_mca_device(dev);
 	int slot = mca_dev->slot;
-	struct NCR_700_info *info = to_mca_driver(dev->driver)->driver_data;
 	int found = 0;
 	int irq, i;
 	int pos3j, pos3k, pos3a, pos3b, pos4;
 	__u32 base_addr, offset_addr;
-	struct Scsi_Host *host = NULL;
 
 	/* enable board interrupt */
 	pos4 = mca_device_read_pos(mca_dev, 4);
@@ -232,8 +283,6 @@
 
 	printk(KERN_NOTICE "NCR D700: found in slot %d  irq = %d  I/O base = 0x%x\n", slot, irq, offset_addr);
 
-	info->tpnt->proc_name = "NCR_D700";
-
 	/*outb(BOARD_RESET, base_addr);*/
 
 	/* clear any pending interrupts */
@@ -259,70 +308,56 @@
 		break;
 	}
 
+	p = kmalloc(sizeof(*p), GFP_KERNEL);
+	if (!p)
+		return -ENOMEM;
+	p->dev = dev;
+
 	/* plumb in both 700 chips */
-	for(i=0; i<2; i++) {
-		__u32 region = offset_addr | (0x80 * i);
-		struct NCR_700_Host_Parameters *hostdata =
-			kmalloc(sizeof(struct NCR_700_Host_Parameters),
-				GFP_KERNEL);
-		if(hostdata == NULL) {
-			printk(KERN_ERR "NCR D700: Failed to allocate host data for channel %d, detatching\n", i);
-			continue;
-		}
-		memset(hostdata, 0, sizeof(struct NCR_700_Host_Parameters));
-		if(request_region(region, 64, "NCR_D700") == NULL) {
-			printk(KERN_ERR "NCR D700: Failed to reserve IO region 0x%x\n", region);
-			kfree(hostdata);
-			continue;
-		}
-		
-		/* Fill in the three required pieces of hostdata */
-		hostdata->base = region;
-		hostdata->differential = (((1<<i) & differential) != 0);
-		hostdata->clock = NCR_D700_CLOCK_MHZ;
-		/* and register the chip */
-		if((host = NCR_700_detect(info->tpnt, hostdata)) == NULL) {
-			kfree(hostdata);
-			release_region(host->base, 64);
-			continue;
-		}
-		host->irq = irq;
-		/* FIXME: Read this from SUS */
-		host->this_id = id_array[slot * 2 + i];
-		printk(KERN_NOTICE "NCR D700: SIOP%d, SCSI id is %d\n",
-		       i, host->this_id);
-		if(request_irq(irq, NCR_700_intr, SA_SHIRQ, "NCR_D700", host)) {
-			printk(KERN_ERR "NCR D700, channel %d: irq problem, detatching\n", i);
-			scsi_unregister(host);
-			NCR_700_release(host);
-			continue;
-		}
-		scsi_set_device(host, dev);
-		hostdata->dev = dev;
-		found++;
+	for (i = 0; i < 2; i++) {
+		int err;
+
+		if ((err = NCR_D700_probe_one(p, i, irq, slot,
+					      offset_addr + (0x80 * i),
+					      differential)) != 0)
+			printk("D700: SIOP%d: probe failed, error = %d\n",
+			       i, err);
+		else
+			found++;
 	}
-	info->found += found;
 
-	if(found) {
-		mca_device_set_claim(mca_dev, 1);
-		strncpy(dev->name, "NCR_D700", sizeof(dev->name));
+	if (!found) {
+		kfree(p);
+		return -ENODEV;
 	}
 
-	return found? 0 : -ENODEV;
+	mca_device_set_claim(mca_dev, 1);
+	strncpy(dev->name, "NCR_D700", sizeof(dev->name));
+	dev_set_drvdata(dev, p);
+	return 0;
 }
 
-
-STATIC int
-D700_release(struct Scsi_Host *host)
+static void
+NCR_D700_remove_one(struct Scsi_Host *host)
 {
-	struct D700_Host_Parameters *hostdata = 
-		(struct D700_Host_Parameters *)host->hostdata[0];
-
+	scsi_remove_host(host);
 	NCR_700_release(host);
-	kfree(hostdata);
+	kfree((struct NCR_700_Host_Parameters *)host->hostdata[0]);
 	free_irq(host->irq, host);
 	release_region(host->base, 64);
-	return 1;
+}
+
+static int
+NCR_D700_remove(struct device *dev)
+{
+	struct NCR_D700_private *p = dev_get_drvdata(dev);
+	int i;
+
+	for (i = 0; i < 2; i++)
+		NCR_D700_remove_one(p->hosts[i]);
+
+	kfree(p);
+	return 0;
 }
 
 static short NCR_D700_id_table[] = { NCR_D700_MCA_ID, 0 };
@@ -330,34 +365,29 @@
 struct mca_driver NCR_D700_driver = {
 	.id_table = NCR_D700_id_table,
 	.driver = {
-		.name = "NCR_D700",
-		.bus = &mca_bus_type,
-		.probe = NCR_D700_probe,
+		.name		= "NCR_D700",
+		.bus		= &mca_bus_type,
+		.probe		= NCR_D700_probe,
+		.remove		= NCR_D700_remove,
 	},
 };
-		
 
-STATIC int __init
-D700_detect(Scsi_Host_Template *tpnt)
+static int __init NCR_D700_init(void)
 {
-	struct NCR_700_info info;
-
-	if(!MCA_bus)
-		return 0;
-
 #ifdef MODULE
-	if(NCR_D700)
+	if (NCR_D700)
 		param_setup(NCR_D700);
 #endif
-	info.tpnt = tpnt;
-	info.found = 0;
-	NCR_D700_driver.driver_data = &info;
-	mca_register_driver(&NCR_D700_driver);
 
-	return info.found;
+	return mca_register_driver(&NCR_D700_driver);
+}
+
+static void __exit NCR_D700_exit(void)
+{
+	mca_unregister_driver(&NCR_D700_driver);
 }
-	
-static Scsi_Host_Template driver_template = NCR_D700_SCSI;
 
-#include "scsi_module.c"
+module_init(NCR_D700_init);
+module_exit(NCR_D700_exit);
 
+__setup("NCR_D700=", param_setup);
diff -urN linux-2.5.69-bk7/drivers/scsi/NCR_D700.h linux-2.5.69-bk8/drivers/scsi/NCR_D700.h
--- linux-2.5.69-bk7/drivers/scsi/NCR_D700.h	2003-05-04 16:53:31.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/NCR_D700.h	2003-05-13 04:44:28.000000000 -0700
@@ -14,22 +14,6 @@
 /* The MCA identifier */
 #define NCR_D700_MCA_ID		0x0092
 
-static int D700_detect(Scsi_Host_Template *);
-static int D700_release(struct Scsi_Host *host);
-
-
-/* Host template.  Note the name and proc_name are optional, all the
- * remaining parameters shown below must be filled in.  The 53c700
- * routine NCR_700_detect will fill in all of the missing routines */
-#define NCR_D700_SCSI {						\
-	.name =				"NCR Dual 700 MCA",	\
-	.proc_name =			"NCR_D700",		\
-	.detect = 			D700_detect,		\
-	.release =			D700_release,		\
-	.this_id =			7,			\
-}
-
-
 /* Defines for the Board registers */
 #define	BOARD_RESET		0x80	/* board level reset */
 #define ADD_PARENB		0x04	/* Address Parity Enabled */
diff -urN linux-2.5.69-bk7/drivers/scsi/aacraid/README linux-2.5.69-bk8/drivers/scsi/aacraid/README
--- linux-2.5.69-bk7/drivers/scsi/aacraid/README	2003-05-04 16:53:01.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/aacraid/README	2003-05-13 04:44:28.000000000 -0700
@@ -18,6 +18,12 @@
 	ADAPTEC 2120S
 	ADAPTEC 2200S
 	ADAPTEC 5400S
+	Legend S220
+	Legend S230
+	Adaptec 3230S
+	Adaptec 3240S
+	ASR-2020S PCI-X
+	AAR-2410SA SATA
 
 People
 -------------------------
@@ -28,6 +34,9 @@
 					 added new ioctls, changed scsi interface to use new error handler,
 					 increased the number of fibs and outstanding commands to a container)
 
+					(fixed 64bit and 64G memory model, changed confusing naming convention
+					 where fibs that go to the hardware are consistently called hw_fibs and
+					 not just fibs like the name of the driver tracking structure)
 Original Driver
 -------------------------
 Adaptec Unix OEM Product Group
diff -urN linux-2.5.69-bk7/drivers/scsi/aacraid/aachba.c linux-2.5.69-bk8/drivers/scsi/aacraid/aachba.c
--- linux-2.5.69-bk7/drivers/scsi/aacraid/aachba.c	2003-05-04 16:53:14.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/aacraid/aachba.c	2003-05-13 04:44:28.000000000 -0700
@@ -40,8 +40,7 @@
 #include "aacraid.h"
 
 /*	SCSI Commands */
-/*	TODO:  dmb - use the ones defined in include/scsi/scsi.h */
-
+/* TODO dmb - use the ones defined in include/scsi/scsi.h*/
 #define	SS_TEST			0x00	/* Test unit ready */
 #define SS_REZERO		0x01	/* Rezero unit */
 #define	SS_REQSEN		0x03	/* Request Sense */
@@ -60,15 +59,15 @@
 #define SS_SEEK			0x2B	/* Seek */
 
 /* values for inqd_pdt: Peripheral device type in plain English */
-#define	INQD_PDT_DA	0x00		/* Direct-access (DISK) device */
-#define	INQD_PDT_PROC	0x03		/* Processor device */
-#define	INQD_PDT_CHNGR	0x08		/* Changer (jukebox, scsi2) */
-#define	INQD_PDT_COMM	0x09		/* Communication device (scsi2) */
-#define	INQD_PDT_NOLUN2 0x1f		/* Unknown Device (scsi2) */
-#define	INQD_PDT_NOLUN	0x7f		/* Logical Unit Not Present */
+#define	INQD_PDT_DA	0x00	/* Direct-access (DISK) device */
+#define	INQD_PDT_PROC	0x03	/* Processor device */
+#define	INQD_PDT_CHNGR	0x08	/* Changer (jukebox, scsi2) */
+#define	INQD_PDT_COMM	0x09	/* Communication device (scsi2) */
+#define	INQD_PDT_NOLUN2 0x1f	/* Unknown Device (scsi2) */
+#define	INQD_PDT_NOLUN	0x7f	/* Logical Unit Not Present */
 
-#define	INQD_PDT_DMASK	0x1F		/* Peripheral Device Type Mask */
-#define	INQD_PDT_QMASK	0xE0		/* Peripheral Device Qualifer Mask */
+#define	INQD_PDT_DMASK	0x1F	/* Peripheral Device Type Mask */
+#define	INQD_PDT_QMASK	0xE0	/* Peripheral Device Qualifer Mask */
 
 #define	TARGET_LUN_TO_CONTAINER(target, lun)	(target)
 #define CONTAINER_TO_TARGET(cont)		((cont))
@@ -81,22 +80,22 @@
 /*
  *	Sense keys
  */
-#define SENKEY_NO_SENSE      			0x00	
-#define SENKEY_UNDEFINED     			0x01	
-#define SENKEY_NOT_READY     			0x02	
-#define SENKEY_MEDIUM_ERR    			0x03	
-#define SENKEY_HW_ERR        			0x04	
-#define SENKEY_ILLEGAL       			0x05	
-#define SENKEY_ATTENTION     			0x06	
-#define SENKEY_PROTECTED     			0x07	
-#define SENKEY_BLANK         			0x08	
-#define SENKEY_V_UNIQUE      			0x09	
-#define SENKEY_CPY_ABORT     			0x0A	
-#define SENKEY_ABORT         			0x0B	
-#define SENKEY_EQUAL         			0x0C	
-#define SENKEY_VOL_OVERFLOW  			0x0D	
-#define SENKEY_MISCOMP       			0x0E	
-#define SENKEY_RESERVED      			0x0F	
+#define SENKEY_NO_SENSE      0x00	
+#define SENKEY_UNDEFINED     0x01	
+#define SENKEY_NOT_READY     0x02	
+#define SENKEY_MEDIUM_ERR    0x03	
+#define SENKEY_HW_ERR        0x04	
+#define SENKEY_ILLEGAL       0x05	
+#define SENKEY_ATTENTION     0x06	
+#define SENKEY_PROTECTED     0x07	
+#define SENKEY_BLANK         0x08	
+#define SENKEY_V_UNIQUE      0x09	
+#define SENKEY_CPY_ABORT     0x0A	
+#define SENKEY_ABORT         0x0B	
+#define SENKEY_EQUAL         0x0C	
+#define SENKEY_VOL_OVERFLOW  0x0D	
+#define SENKEY_MISCOMP       0x0E	
+#define SENKEY_RESERVED      0x0F	
 
 /*
  *	Sense codes
@@ -160,24 +159,24 @@
  *----------------------------------------------------------------------------*/
 /* SCSI inquiry data */
 struct inquiry_data {
-	u8 inqd_pdt;		/* Peripheral qualifier | Peripheral Device Type  */
-	u8 inqd_dtq;		/* RMB | Device Type Qualifier  */
-	u8 inqd_ver;		/* ISO version | ECMA version | ANSI-approved version */
-	u8 inqd_rdf;		/* AENC | TrmIOP | Response data format */
-	u8 inqd_len;		/* Additional length (n-4) */
-	u8 inqd_pad1[2];	/* Reserved - must be zero */
-	u8 inqd_pad2;		/* RelAdr | WBus32 | WBus16 |  Sync  | Linked |Reserved| CmdQue | SftRe */
-	u8 inqd_vid[8];		/* Vendor ID */
-	u8 inqd_pid[16];	/* Product ID */
-	u8 inqd_prl[4];		/* Product Revision Level */
+	u8 inqd_pdt;	/* Peripheral qualifier | Peripheral Device Type  */
+	u8 inqd_dtq;	/* RMB | Device Type Qualifier  */
+	u8 inqd_ver;	/* ISO version | ECMA version | ANSI-approved version */
+	u8 inqd_rdf;	/* AENC | TrmIOP | Response data format */
+	u8 inqd_len;	/* Additional length (n-4) */
+	u8 inqd_pad1[2];/* Reserved - must be zero */
+	u8 inqd_pad2;	/* RelAdr | WBus32 | WBus16 |  Sync  | Linked |Reserved| CmdQue | SftRe */
+	u8 inqd_vid[8];	/* Vendor ID */
+	u8 inqd_pid[16];/* Product ID */
+	u8 inqd_prl[4];	/* Product Revision Level */
 };
 
 struct sense_data {
 	u8 error_code;		/* 70h (current errors), 71h(deferred errors) */
 	u8 valid:1;		/* A valid bit of one indicates that the information  */
-	/* field contains valid information as defined in the
-	 * SCSI-2 Standard.
-	 */
+				/* field contains valid information as defined in the
+				 * SCSI-2 Standard.
+				 */
 	u8 segment_number;	/* Only used for COPY, COMPARE, or COPY AND VERIFY Commands */
 	u8 sense_key:4;		/* Sense Key */
 	u8 reserved:1;
@@ -257,13 +256,14 @@
 				    1, 1,
 				    NULL, NULL);
 		if (status < 0 ) {
-			printk(KERN_WARNING "ProbeContainers: SendFIB failed.\n");
+			printk(KERN_WARNING "aac_get_containers: SendFIB failed.\n");
 			break;
 		}
 		dresp = (struct aac_mount *)fib_data(fibptr);
 
 		if ((le32_to_cpu(dresp->status) == ST_OK) &&
-		    (le32_to_cpu(dresp->mnt[0].vol) != CT_NONE)) {
+		    (le32_to_cpu(dresp->mnt[0].vol) != CT_NONE) &&
+		    (le32_to_cpu(dresp->mnt[0].state) != FSCS_HIDDEN)) {
 			fsa_dev_ptr->valid[index] = 1;
 			fsa_dev_ptr->type[index] = le32_to_cpu(dresp->mnt[0].vol);
 			fsa_dev_ptr->size[index] = le32_to_cpu(dresp->mnt[0].capacity);
@@ -274,8 +274,9 @@
 		/*
 		 *	If there are no more containers, then stop asking.
 		 */
-		if ((index + 1) >= le32_to_cpu(dresp->count))
+		if ((index + 1) >= le32_to_cpu(dresp->count)){
 			break;
+		}
 	}
 	fib_free(fibptr);
 	fsa_dev[instance] = fsa_dev_ptr;
@@ -328,7 +329,8 @@
 	dresp = (struct aac_mount *) fib_data(fibptr);
 
 	if ((le32_to_cpu(dresp->status) == ST_OK) &&
-	    (le32_to_cpu(dresp->mnt[0].vol) != CT_NONE)) {
+	    (le32_to_cpu(dresp->mnt[0].vol) != CT_NONE) &&
+	    (le32_to_cpu(dresp->mnt[0].state) != FSCS_HIDDEN)) {
 		fsa_dev_ptr->valid[cid] = 1;
 		fsa_dev_ptr->type[cid] = le32_to_cpu(dresp->mnt[0].vol);
 		fsa_dev_ptr->size[cid] = le32_to_cpu(dresp->mnt[0].capacity);
@@ -429,7 +431,7 @@
 	sense_buf[1] = 0;	/* Segment number, always zero */
 
 	if (incorrect_length) {
-		sense_buf[2] = sense_key | 0x20;	/* Set ILI bit | sense key */
+		sense_buf[2] = sense_key | 0x20;/* Set ILI bit | sense key */
 		sense_buf[3] = BYTE3(residue);
 		sense_buf[4] = BYTE2(residue);
 		sense_buf[5] = BYTE1(residue);
@@ -448,11 +450,11 @@
 		sense_buf[15] = 0;
 
 		if (sense_code == SENCODE_INVALID_PARAM_FIELD)
-			sense_buf[15] = 0x80;	/* Std sense key specific field */
+			sense_buf[15] = 0x80;/* Std sense key specific field */
 		/* Illegal parameter is in the parameter block */
 
 		if (sense_code == SENCODE_INVALID_CDB_FIELD)
-			sense_buf[15] = 0xc0;	/* Std sense key specific field */
+			sense_buf[15] = 0xc0;/* Std sense key specific field */
 		/* Illegal parameter is in the CDB block */
 		sense_buf[15] |= bit_pointer;
 		sense_buf[16] = field_pointer >> 8;	/* MSB */
@@ -463,9 +465,10 @@
 static void aac_io_done(Scsi_Cmnd * scsicmd)
 {
 	unsigned long cpu_flags;
-	spin_lock_irqsave(scsicmd->device->host->host_lock, cpu_flags);
+	struct Scsi_Host *host = scsicmd->device->host;
+	spin_lock_irqsave(host->host_lock, cpu_flags);
 	scsicmd->scsi_done(scsicmd);
-	spin_unlock_irqrestore(scsicmd->device->host->host_lock, cpu_flags);
+	spin_unlock_irqrestore(host->host_lock, cpu_flags);
 }
 
 static void __aac_io_done(Scsi_Cmnd * scsicmd)
@@ -498,40 +501,53 @@
 	memcpy(&dev->adapter_info, info, sizeof(struct aac_adapter_info));
 
 	tmp = dev->adapter_info.kernelrev;
-	printk(KERN_INFO "%s%d: kernel %d.%d.%d build %d\n", 
+	printk(KERN_INFO"%s%d: kernel %d.%d.%d build %d\n", 
 			dev->name, dev->id,
 			tmp>>24,(tmp>>16)&0xff,(tmp>>8)&0xff,
 			dev->adapter_info.kernelbuild);
 	tmp = dev->adapter_info.monitorrev;
-	printk(KERN_INFO "%s%d: monitor %d.%d.%d build %d\n", 
+	printk(KERN_INFO"%s%d: monitor %d.%d.%d build %d\n", 
 			dev->name, dev->id,
 			tmp>>24,(tmp>>16)&0xff,(tmp>>8)&0xff,
 			dev->adapter_info.monitorbuild);
 	tmp = dev->adapter_info.biosrev;
-	printk(KERN_INFO "%s%d: bios %d.%d.%d build %d\n", 
+	printk(KERN_INFO"%s%d: bios %d.%d.%d build %d\n", 
 			dev->name, dev->id,
 			tmp>>24,(tmp>>16)&0xff,(tmp>>8)&0xff,
 			dev->adapter_info.biosbuild);
-	printk(KERN_INFO "%s%d: serial %x%x\n",
+	printk(KERN_INFO"%s%d: serial %x%x\n",
 			dev->name, dev->id,
 			dev->adapter_info.serial[0],
 			dev->adapter_info.serial[1]);
-	dev->pae_support = 0;
+
 	dev->nondasd_support = 0;
-	if( BITS_PER_LONG >= 64 && 
-	  (dev->adapter_info.options & AAC_OPT_SGMAP_HOST64)){
-		printk(KERN_INFO "%s%d: 64 Bit PAE enabled\n", dev->name, dev->id);
+	if(dev->adapter_info.options & AAC_OPT_NONDASD){
+//		dev->nondasd_support = 1;
+// dmb - temporarily disable nondasd
+	}
+	if(nondasd != -1) {  
+		dev->nondasd_support = (nondasd!=0);
+	}
+	if(dev->nondasd_support != 0){
+		printk(KERN_INFO"%s%d: Non-DASD support enabled\n",dev->name, dev->id);
+	}
+
+	dev->pae_support = 0;
+	if( (sizeof(dma_addr_t) > 4) && (dev->adapter_info.options & AAC_OPT_SGMAP_HOST64)){
 		dev->pae_support = 1;
 	}
-	/* TODO - dmb temporary until fw can set this bit  */
-	dev->pae_support = (BITS_PER_LONG >= 64);
+
+	if(paemode != -1){
+		dev->pae_support = (paemode!=0);
+	}
 	if(dev->pae_support != 0) {
-		printk(KERN_INFO "%s%d: 64 Bit PAE enabled\n", dev->name, dev->id);
+		printk(KERN_INFO"%s%d: 64 Bit PAE enabled\n", dev->name, dev->id);
+		pci_set_dma_mask(dev->pdev, (dma_addr_t)0xFFFFFFFFFFFFFFFFULL);
 	}
 
-	if(dev->adapter_info.options & AAC_OPT_NONDASD){
-		dev->nondasd_support = 1;
-	}
+	fib_complete(fibptr);
+	fib_free(fibptr);
+
 	return rcode;
 }
 
@@ -550,7 +566,7 @@
 	cid =TARGET_LUN_TO_CONTAINER(scsicmd->device->id, scsicmd->device->lun);
 
 	lba = ((scsicmd->cmnd[1] & 0x1F) << 16) | (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3];
-	dprintk((KERN_DEBUG "read_callback[cpu %d]: lba = %d, t = %ld.\n", smp_processor_id(), lba, jiffies));
+	dprintk((KERN_DEBUG "read_callback[cpu %d]: lba = %u, t = %ld.\n", smp_processor_id(), lba, jiffies));
 
 	if (fibptr == NULL)
 		BUG();
@@ -561,7 +577,7 @@
 			scsicmd->use_sg,
 			scsi_to_pci_dma_dir(scsicmd->sc_data_direction));
 	else if(scsicmd->request_bufflen)
-		pci_unmap_single(dev->pdev, scsicmd->SCp.dma_handle,
+		pci_unmap_single(dev->pdev, (dma_addr_t)(ulong)scsicmd->SCp.ptr,
 				 scsicmd->request_bufflen,
 				 scsi_to_pci_dma_dir(scsicmd->sc_data_direction));
 	readreply = (struct aac_read_reply *)fib_data(fibptr);
@@ -595,7 +611,7 @@
 	cid = TARGET_LUN_TO_CONTAINER(scsicmd->device->id, scsicmd->device->lun);
 
 	lba = ((scsicmd->cmnd[1] & 0x1F) << 16) | (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3];
-	dprintk((KERN_DEBUG "write_callback[cpu %d]: lba = %d, t = %ld.\n", smp_processor_id(), lba, jiffies));
+	dprintk((KERN_DEBUG "write_callback[cpu %d]: lba = %u, t = %ld.\n", smp_processor_id(), lba, jiffies));
 	if (fibptr == NULL)
 		BUG();
 
@@ -605,7 +621,7 @@
 			scsicmd->use_sg,
 			scsi_to_pci_dma_dir(scsicmd->sc_data_direction));
 	else if(scsicmd->request_bufflen)
-		pci_unmap_single(dev->pdev, scsicmd->SCp.dma_handle,
+		pci_unmap_single(dev->pdev, (dma_addr_t)(ulong)scsicmd->SCp.ptr,
 				 scsicmd->request_bufflen,
 				 scsi_to_pci_dma_dir(scsicmd->sc_data_direction));
 
@@ -677,7 +693,7 @@
 		readcmd->block = cpu_to_le32(lba);
 		readcmd->pad   = cpu_to_le16(0);
 		readcmd->flags = cpu_to_le16(0); 
-		
+
 		aac_build_sg64(scsicmd, &readcmd->sg);
 		if(readcmd->sg.count > MAX_DRIVER_SG_SEGMENT_COUNT)
 			BUG();
@@ -718,8 +734,9 @@
 			  (fib_callback) read_callback, 
 			  (void *) scsicmd);
 	}
+
 	
-	
+
 	/*
 	 *	Check that the command queued to the controller
 	 */
@@ -761,7 +778,7 @@
 		lba = (scsicmd->cmnd[2] << 24) | (scsicmd->cmnd[3] << 16) | (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];
 		count = (scsicmd->cmnd[7] << 8) | scsicmd->cmnd[8];
 	}
-	dprintk((KERN_DEBUG "aac_write[cpu %d]: lba = %lu, t = %ld.\n", smp_processor_id(), lba, jiffies));
+	dprintk((KERN_DEBUG "aac_write[cpu %d]: lba = %u, t = %ld.\n", smp_processor_id(), lba, jiffies));
 	/*
 	 *	Allocate and initialize a Fib then setup a BlockWrite command
 	 */
@@ -772,8 +789,7 @@
 	}
 	fib_init(cmd_fibcontext);
 
-	if(dev->pae_support == 1)
-	{
+	if(dev->pae_support == 1){
 		struct aac_write64 *writecmd;
 		writecmd = (struct aac_write64 *) fib_data(cmd_fibcontext);
 		writecmd->command = cpu_to_le32(VM_CtHostWrite64);
@@ -797,9 +813,7 @@
 			  0, 1, 
 			  (fib_callback) write_callback, 
 			  (void *) scsicmd);
-	}
-	else 
-	{
+	} else {
 		struct aac_write *writecmd;
 		writecmd = (struct aac_write *) fib_data(cmd_fibcontext);
 		writecmd->command = cpu_to_le32(VM_CtBlockWrite);
@@ -809,8 +823,10 @@
 		writecmd->sg.count = cpu_to_le32(1);
 		/* ->stable is not used - it did mean which type of write */
 
-		if (count * 512 > (64 * 1024))
+		if (count * 512 > (64 * 1024)) {
 			BUG();
+		}
+
 		aac_build_sg(scsicmd, &writecmd->sg);
 		if(writecmd->sg.count > MAX_DRIVER_SG_SEGMENT_COUNT)
 			BUG();
@@ -861,18 +877,19 @@
 	struct fsa_scsi_hba *fsa_dev_ptr;
 	int cardtype;
 	int ret;
-	struct aac_dev *dev = (struct aac_dev *)scsicmd->device->host->hostdata;
+	struct Scsi_Host *host = scsicmd->device->host;
+	struct aac_dev *dev = (struct aac_dev *)host->hostdata;
 	
 	cardtype = dev->cardtype;
 
-	fsa_dev_ptr = fsa_dev[scsicmd->device->host->unique_id];
+	fsa_dev_ptr = fsa_dev[host->unique_id];
 
 	/*
 	 *	If the bus, target or lun is out of range, return fail
 	 *	Test does not apply to ID 16, the pseudo id for the controller
 	 *	itself.
 	 */
-	if (scsicmd->device->id != scsicmd->device->host->this_id) {
+	if (scsicmd->device->id != host->this_id) {
 		if ((scsicmd->device->channel == 0) ){
 			if( (scsicmd->device->id >= AAC_MAX_TARGET) || (scsicmd->device->lun != 0)){ 
 				scsicmd->result = DID_NO_CONNECT << 16;
@@ -890,9 +907,9 @@
 				case SS_INQUIR:
 				case SS_RDCAP:
 				case SS_TEST:
-					spin_unlock_irq(scsicmd->device->host->host_lock);
+					spin_unlock_irq(host->host_lock);
 					probe_container(dev, cid);
-					spin_lock_irq(scsicmd->device->host->host_lock);
+					spin_lock_irq(host->host_lock);
 					if (fsa_dev_ptr->valid[cid] == 0) {
 						scsicmd->result = DID_NO_CONNECT << 16;
 						__aac_io_done(scsicmd);
@@ -959,7 +976,7 @@
 		 *	see: <vendor>.c i.e. aac.c
 		 */
 		setinqstr(cardtype, (void *) (inq_data_ptr->inqd_vid), fsa_dev_ptr->type[cid]);
-		if (scsicmd->device->id == scsicmd->device->host->this_id)
+		if (scsicmd->device->id == host->this_id)
 			inq_data_ptr->inqd_pdt = INQD_PDT_PROC;	/* Processor device */
 		else
 			inq_data_ptr->inqd_pdt = INQD_PDT_DA;	/* Direct/random access device */
@@ -1053,20 +1070,21 @@
 			 *	containers to /dev/sd device names
 			 */
 			 
-			spin_unlock_irq(scsicmd->device->host->host_lock);
+			spin_unlock_irq(host->host_lock);
 			if  (scsicmd->request->rq_disk)
 				memcpy(fsa_dev_ptr->devname[cid],
 					scsicmd->request->rq_disk->disk_name,
 					8);
+
 			ret = aac_read(scsicmd, cid);
-			spin_lock_irq(scsicmd->device->host->host_lock);
+			spin_lock_irq(host->host_lock);
 			return ret;
 
 		case SS_WRITE:
 		case SM_WRITE:
-			spin_unlock_irq(scsicmd->device->host->host_lock);
+			spin_unlock_irq(host->host_lock);
 			ret = aac_write(scsicmd, cid);
-			spin_lock_irq(scsicmd->device->host->host_lock);
+			spin_lock_irq(host->host_lock);
 			return ret;
 		default:
 			/*
@@ -1219,8 +1237,7 @@
 			scsicmd->use_sg,
 			scsi_to_pci_dma_dir(scsicmd->sc_data_direction));
 	else if(scsicmd->request_bufflen)
-		pci_unmap_single(dev->pdev, scsicmd->SCp.dma_handle,
-			scsicmd->request_bufflen,
+		pci_unmap_single(dev->pdev, (ulong)scsicmd->SCp.ptr, scsicmd->request_bufflen,
 			scsi_to_pci_dma_dir(scsicmd->sc_data_direction));
 
 	/*
@@ -1239,17 +1256,23 @@
 	/*
 	 * Next check the srb status
 	 */
-	switch(le32_to_cpu(srbreply->srb_status)){
+	switch( (le32_to_cpu(srbreply->srb_status))&0x3f){
 	case SRB_STATUS_ERROR_RECOVERY:
 	case SRB_STATUS_PENDING:
 	case SRB_STATUS_SUCCESS:
 		if(scsicmd->cmnd[0] == INQUIRY ){
 			u8 b;
+			u8 b1;
 			/* We can't expose disk devices because we can't tell whether they
-			 * are the raw container drives or stand alone drives
+			 * are the raw container drives or stand alone drives.  If they have
+			 * the removable bit set then we should expose them though.
 			 */
-			b = *(u8*)scsicmd->buffer;
-			if( (b & 0x0f) == TYPE_DISK ){
+			b = (*(u8*)scsicmd->buffer)&0x1f;
+			b1 = ((u8*)scsicmd->buffer)[1];
+			if( b==TYPE_TAPE || b==TYPE_WORM || b==TYPE_ROM || b==TYPE_MOD|| b==TYPE_MEDIUM_CHANGER 
+					|| (b==TYPE_DISK && (b1&0x80)) ){
+				scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8;
+			} else {
 				scsicmd->result = DID_NO_CONNECT << 16 | COMMAND_COMPLETE << 8;
 			}
 		} else {
@@ -1271,6 +1294,22 @@
 			}
 			scsicmd->result = DID_ERROR << 16 | COMMAND_COMPLETE << 8;
 			break;
+		case INQUIRY: {
+			u8 b;
+			u8 b1;
+			/* We can't expose disk devices because we can't tell whether they
+			* are the raw container drives or stand alone drives
+			*/
+			b = (*(u8*)scsicmd->buffer)&0x0f;
+			b1 = ((u8*)scsicmd->buffer)[1];
+			if( b==TYPE_TAPE || b==TYPE_WORM || b==TYPE_ROM || b==TYPE_MOD|| b==TYPE_MEDIUM_CHANGER
+					|| (b==TYPE_DISK && (b1&0x80)) ){
+				scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8;
+			} else {
+				scsicmd->result = DID_NO_CONNECT << 16 | COMMAND_COMPLETE << 8;
+			}
+			break;
+		}
 		default:
 			scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8;
 			break;
@@ -1326,17 +1365,19 @@
 	case SRB_STATUS_DOMAIN_VALIDATION_FAIL:
 	default:
 #ifdef AAC_DETAILED_STATUS_INFO
-		printk("aacraid: SRB ERROR (%s)\n",aac_get_status_string(le32_to_cpu(srbreply->srb_status)));
+		printk("aacraid: SRB ERROR(%u) %s scsi cmd 0x%x - scsi status 0x%x\n",le32_to_cpu(srbreply->srb_status&0x3f),aac_get_status_string(le32_to_cpu(srbreply->srb_status)), scsicmd->cmnd[0], le32_to_cpu(srbreply->scsi_status) );
 #endif
 		scsicmd->result = DID_ERROR << 16 | COMMAND_COMPLETE << 8;
 		break;
 	}
 	if (le32_to_cpu(srbreply->scsi_status) == 0x02 ){  // Check Condition
 		int len;
+		scsicmd->result |= CHECK_CONDITION;
 		len = (srbreply->sense_data_size > sizeof(scsicmd->sense_buffer))?
 				sizeof(scsicmd->sense_buffer):srbreply->sense_data_size;
 		printk(KERN_WARNING "aac_srb_callback: check condition, status = %d len=%d\n", le32_to_cpu(srbreply->status), len);
 		memcpy(scsicmd->sense_buffer, srbreply->sense_data, len);
+		
 	}
 	/*
 	 * OR in the scsi status (already shifted up a bit)
@@ -1365,6 +1406,7 @@
 	struct aac_srb *srbcmd;
 	u16 fibsize;
 	u32 flag;
+	u32 timeout;
 
 	if( scsicmd->device->id > 15 || scsicmd->device->lun > 7) {
 		scsicmd->result = DID_NO_CONNECT << 16;
@@ -1406,7 +1448,11 @@
 	srbcmd->target   = cpu_to_le32(scsicmd->device->id);
 	srbcmd->lun      = cpu_to_le32(scsicmd->device->lun);
 	srbcmd->flags    = cpu_to_le32(flag);
-	srbcmd->timeout  = cpu_to_le32(0);  // timeout not used
+	timeout = (scsicmd->timeout-jiffies)/HZ;
+	if(timeout == 0){
+		timeout = 1;
+	}
+	srbcmd->timeout  = cpu_to_le32(timeout);  // timeout in seconds
 	srbcmd->retry_limit =cpu_to_le32(0); // Obsolete parameter
 	srbcmd->cdb_size = cpu_to_le32(scsicmd->cmd_len);
 	
@@ -1511,7 +1557,7 @@
 		psg->count = cpu_to_le32(1);
 		psg->sg[0].addr = cpu_to_le32(addr);
 		psg->sg[0].count = cpu_to_le32(scsicmd->request_bufflen);  
-		scsicmd->SCp.dma_handle = addr;
+		scsicmd->SCp.ptr = (char *)addr;
 		byte_count = scsicmd->request_bufflen;
 	}
 	return byte_count;
@@ -1572,7 +1618,7 @@
 		psg->sg[0].addr[1] = (u32)(le_addr>>32);
 		psg->sg[0].addr[0] = (u32)(le_addr & 0xffffffff);
 		psg->sg[0].count = cpu_to_le32(scsicmd->request_bufflen);  
-		scsicmd->SCp.dma_handle = addr;
+		scsicmd->SCp.ptr = (char *)addr;
 		byte_count = scsicmd->request_bufflen;
 	}
 	return byte_count;
diff -urN linux-2.5.69-bk7/drivers/scsi/aacraid/aacraid.h linux-2.5.69-bk8/drivers/scsi/aacraid/aacraid.h
--- linux-2.5.69-bk7/drivers/scsi/aacraid/aacraid.h	2003-05-04 16:53:08.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/aacraid/aacraid.h	2003-05-13 04:44:28.000000000 -0700
@@ -1,18 +1,17 @@
+//#define dprintk(x) printk x
 #define dprintk(x)
-/*#define dprintk(x) printk x */
 
 /*------------------------------------------------------------------------------
  *              D E F I N E S
  *----------------------------------------------------------------------------*/
-
 #define MAXIMUM_NUM_CONTAINERS	31
 #define MAXIMUM_NUM_ADAPTERS	8
 
 #define AAC_NUM_FIB	578
-#define AAC_NUM_IO_FIB	512
+//#define AAC_NUM_IO_FIB	512
+#define AAC_NUM_IO_FIB	100
 
 #define AAC_MAX_TARGET (MAXIMUM_NUM_CONTAINERS+1)
-//#define AAC_MAX_TARGET 	(16)
 #define AAC_MAX_LUN	(8)
 
 /*
@@ -24,6 +23,9 @@
 
 #define AAC_DETAILED_STATUS_INFO
 
+extern int nondasd;
+extern int paemode;
+
 struct diskparm
 {
 	int heads;
@@ -237,6 +239,92 @@
 };
 
 /*
+ * Implement our own version of these so we have 64 bit compatability
+ * The adapter uses these and can only handle 32 bit addresses
+ */
+
+struct aac_list_head {
+	u32 next;
+	u32 prev;
+};
+
+#define AAC_INIT_LIST_HEAD(ptr) do { \
+	(ptr)->next = (u32)(ulong)(ptr); \
+	(ptr)->prev = (u32)(ulong)(ptr); \
+} while (0)
+/**
+ * aac_list_empty - tests whether a list is empty
+ * @head: the list to test.
+ */
+static __inline__ int aac_list_empty(struct aac_list_head *head)
+{
+	return head->next == ((u32)(ulong)head);
+}
+
+/*
+ * Insert a new entry between two known consecutive entries. 
+ *
+ * This is only for internal list manipulation where we know
+ * the prev/next entries already!
+ */
+static __inline__ void aac_list_add(struct aac_list_head * n,
+	struct aac_list_head * prev,
+	struct aac_list_head * next)
+{
+	next->prev = (u32)(ulong)n;
+	n->next = (u32)(ulong)next;
+	n->prev = (u32)(ulong)prev;
+	prev->next = (u32)(ulong)n;
+}
+
+/**
+ * list_add_tail - add a new entry
+ * @new: new entry to be added
+ * @head: list head to add it before
+ *
+ * Insert a new entry before the specified head.
+ * This is useful for implementing queues.
+ */
+static __inline__ void aac_list_add_tail(struct aac_list_head *n, struct aac_list_head *head)
+{
+	aac_list_add(n, (struct aac_list_head*)(ulong)(head->prev), head);
+}
+
+/*
+ * Delete a list entry by making the prev/next entries
+ * point to each other.
+ *
+ * This is only for internal list manipulation where we know
+ * the prev/next entries already!
+ */
+static __inline__ void __aac_list_del(struct aac_list_head * p,
+				  struct aac_list_head * n)
+{
+	n->prev = (u32)(ulong)p;
+	p->next = (u32)(ulong)n;
+}
+
+/**
+ * aac_list_del - deletes entry from list.
+ * @entry: the element to delete from the list.
+ * Note: list_empty on entry does not return true after this, the entry is in an undefined state.
+ */
+static __inline__ void aac_list_del(struct aac_list_head *entry)
+{
+	__aac_list_del((struct aac_list_head*)(ulong)entry->prev,(struct aac_list_head*)(ulong) entry->next);
+	entry->next = entry->prev = 0;
+}
+
+/**
+ * aac_list_entry - get the struct for this entry
+ * @ptr:	the &struct list_head pointer.
+ * @type:	the type of the struct this is embedded in.
+ * @member:	the name of the list_struct within the struct.
+ */
+#define aac_list_entry(ptr, type, member) \
+	((type *)((char *)(ptr)-(ulong)(&((type *)0)->member)))
+
+/*
  *	Assign type values to the FSA communication data structures
  */
 
@@ -249,11 +337,11 @@
 #define		FsaNormal	1
 #define		FsaHigh		2
 
+
 /*
  * Define the FIB. The FIB is the where all the requested data and
  * command information are put to the application on the FSA adapter.
  */
-
 struct aac_fibhdr {
 	u32 XferState;			// Current transfer state for this CCB
 	u16 Command;			// Routing information for the destination
@@ -269,7 +357,8 @@
 		    u32 _ReceiverTimeStart; 	// Timestamp for receipt of fib
 		    u32 _ReceiverTimeDone;	// Timestamp for completion of fib
 		} _s;
-		struct list_head _FibLinks;	// Used to link Adapter Initiated Fibs on the host
+		struct aac_list_head _FibLinks;	// Used to link Adapter Initiated Fibs on the host
+//		struct list_head _FibLinks;	// Used to link Adapter Initiated Fibs on the host
 	} _u;
 };
 
@@ -451,21 +540,22 @@
  */
  
 struct aac_queue {
-	u64		 	logical;		/* This is the address we give the adapter */
-	struct aac_entry	*base;		   	/* This is the system virtual address */
-	struct aac_qhdr 	headers;       		/* A pointer to the producer and consumer queue headers for this queue */
-	u32	 		entries;	   	/* Number of queue entries on this queue */
-	wait_queue_head_t	qfull;		      	/* Event to wait on if the queue is full */
-	wait_queue_head_t	cmdready;	  	/* Indicates there is a Command ready from the adapter on this queue. */
-                                        		/* This is only valid for adapter to host command queues. */                      
-	spinlock_t	 	*lock;		     	/* Spinlock for this queue must take this lock before accessing the lock */
-	spinlock_t		lockdata;		/* Actual lock (used only on one side of the lock) */
-	unsigned long		SavedIrql;      	/* Previous IRQL when the spin lock is taken */
-	u32			padding;		/* Padding - FIXME - can remove I believe */
-	struct list_head 	cmdq;		   	/* A queue of FIBs which need to be prcessed by the FS thread. This is */
+	u64		 	logical;	/*address we give the adapter */
+	struct aac_entry	*base;		/*system virtual address */
+	struct aac_qhdr 	headers;       	/*producer,consumer q headers*/
+	u32	 		entries;	/*Number of queue entries */
+	wait_queue_head_t	qfull;		/*Event to wait on if q full */
+	wait_queue_head_t	cmdready;	/*Cmd ready from the adapter */
+                  /* This is only valid for adapter to host command queues. */ 
+	spinlock_t	 	*lock;		/* Spinlock for this queue must take this lock before accessing the lock */
+	spinlock_t		lockdata;	/* Actual lock (used only on one side of the lock) */
+	u32 			SavedIrql;     	/* Previous IRQL when the spin lock is taken */
+	u32			padding;	/* Padding - FIXME - can remove I believe */
+	struct aac_list_head 	cmdq;	   	/* A queue of FIBs which need to be prcessed by the FS thread. This is */
+//	struct list_head 	cmdq;	   	/* A queue of FIBs which need to be prcessed by the FS thread. This is */
                                 		        /* only valid for command queues which receive entries from the adapter. */
 	struct list_head	pendingq;		/* A queue of outstanding fib's to the adapter. */
-	unsigned long		numpending;		/* Number of entries on outstanding queue. */
+	u32			numpending;		/* Number of entries on outstanding queue. */
 	struct aac_dev *	dev;			/* Back pointer to adapter structure */
 };
 
@@ -629,7 +719,7 @@
 	struct semaphore 	wait_sem;	// this is used to wait for the next fib to arrive.
 	int			wait;		// Set to true when thread is in WaitForSingleObject
 	unsigned long		count;		// total number of FIBs on FibList
-	struct list_head	fibs;
+	struct aac_list_head	hw_fib_list;	// this holds hw_fibs which should be 32 bit addresses
 };
 
 struct fsa_scsi_hba {
@@ -650,7 +740,6 @@
 	 *	The Adapter that this I/O is destined for.
 	 */
 	struct aac_dev 		*dev;
-	u64			logicaladdr;	/* 64 bit */
 	/*
 	 *	This is the event the sendfib routine will wait on if the
 	 *	caller did not pass one and this is synch io.
@@ -669,7 +758,8 @@
 	struct list_head	queue;
 
 	void 			*data;
-	struct hw_fib		*fib;		/* Actual shared object */
+	struct hw_fib		*hw_fib;		/* Actual shared object */
+	dma_addr_t		hw_fib_pa;		/* physical address of hw_fib*/
 };
 
 /*
@@ -696,6 +786,7 @@
 	u32	biosrev;
 	u32	biosbuild;
 	u32	cluster;
+	u32	clusterchannelmask; 
 	u32	serial[2];
 	u32	battery;
 	u32	options;
@@ -746,13 +837,13 @@
 	 */	
 	dma_addr_t		hw_fib_pa;
 	struct hw_fib		*hw_fib_va;
-#if BITS_PER_LONG >= 64
 	ulong			fib_base_va;
-#endif
 	/*
 	 *	Fib Headers
 	 */
-	struct fib		fibs[AAC_NUM_FIB];
+// dmb	struct fib              fibs[AAC_NUM_FIB]; /* Doing it here takes up too much from the scsi pool*/
+	struct fib              *fibs;
+
 	struct fib		*free_fib;
 	struct fib		*timeout_fib;
 	spinlock_t		fib_lock;
@@ -771,6 +862,7 @@
 	unsigned long		fsrev;		/* Main driver's revision number */
 	
 	struct aac_init		*init;		/* Holds initialization info to communicate with adapter */
+//	void *			init_pa; 	/* Holds physical address of the init struct */
 	dma_addr_t		init_pa; 	/* Holds physical address of the init struct */
 	
 	struct pci_dev		*pdev;		/* Our PCI interface */
@@ -1148,7 +1240,9 @@
 	u32			altoid;		// != oid <==> snapshot or broken mirror exists
 };
 
-#define FSCS_READONLY	0x0002	/*	possible result of broken mirror */
+#define FSCS_NOTCLEAN	0x0001  /* fsck is neccessary before mounting */
+#define FSCS_READONLY	0x0002	/* possible result of broken mirror */
+#define FSCS_HIDDEN	0x0004	/* should be ignored - set during a clear */
 
 struct aac_query_mount {
 	u32		command;
@@ -1359,16 +1453,6 @@
 	u8 data[1];		/* Undefined length (from kernel viewpoint) */
 };
 
-static inline u32 fib2addr(struct hw_fib *hw)
-{
-	return (u32)hw;
-}
-
-static inline struct hw_fib *addr2fib(u32 addr)
-{
-	return (struct hw_fib *)addr;
-}
-
 /**
  * 	Convert capacity to cylinders
  *  	accounting for the fact capacity could be a 64 bit value
@@ -1376,12 +1460,8 @@
  */
 static inline u32 cap_to_cyls(sector_t capacity, u32 divisor)
 {
-#ifdef CONFIG_LBD
-	do_div(capacity, divisor);
-#else
-	capacity /= divisor;
-#endif
-	return (u32) capacity;
+	sector_div(capacity, divisor);
+	return (u32)capacity;
 }
 
 const char *aac_driverinfo(struct Scsi_Host *);
@@ -1397,7 +1477,7 @@
 int aac_consumer_avail(struct aac_dev * dev, struct aac_queue * q);
 void aac_consumer_free(struct aac_dev * dev, struct aac_queue * q, u32 qnum);
 int fib_complete(struct fib * context);
-#define fib_data(fibctx) ((void *)(fibctx)->fib->data)
+#define fib_data(fibctx) ((void *)(fibctx)->hw_fib->data)
 int aac_detach(struct aac_dev *dev);
 struct aac_dev *aac_init_adapter(struct aac_dev *dev);
 int aac_get_containers(struct aac_dev *dev);
diff -urN linux-2.5.69-bk7/drivers/scsi/aacraid/commctrl.c linux-2.5.69-bk8/drivers/scsi/aacraid/commctrl.c
--- linux-2.5.69-bk7/drivers/scsi/aacraid/commctrl.c	2003-05-04 16:53:12.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/aacraid/commctrl.c	2003-05-13 04:44:28.000000000 -0700
@@ -63,7 +63,7 @@
 	if(fibptr == NULL)
 		return -ENOMEM;
 		
-	kfib = fibptr->fib;
+	kfib = fibptr->hw_fib;
 	/*
 	 *	First copy in the header so that we can check the size field.
 	 */
@@ -150,7 +150,7 @@
 		 *	the list to 0.
 		 */
 		fibctx->count = 0;
-		INIT_LIST_HEAD(&fibctx->fibs);
+		AAC_INIT_LIST_HEAD(&fibctx->hw_fib_list);
 		fibctx->jiffies = jiffies/HZ;
 		/*
 		 *	Now add this context onto the adapter's 
@@ -181,7 +181,7 @@
 {
 	struct fib_ioctl f;
 	struct aac_fib_context *fibctx, *aifcp;
-	struct hw_fib * fib;
+	struct hw_fib * hw_fib;
 	int status;
 	struct list_head * entry;
 	int found;
@@ -224,25 +224,25 @@
 	 *	-EAGAIN
 	 */
 return_fib:
-	if (!list_empty(&fibctx->fibs)) {
-		struct list_head * entry;
+	if (!aac_list_empty(&fibctx->hw_fib_list)) {
+		struct aac_list_head * entry;
 		/*
 		 *	Pull the next fib from the fibs
 		 */
-		entry = fibctx->fibs.next;
-		list_del(entry);
+		entry = (struct aac_list_head*)(ulong)fibctx->hw_fib_list.next;
+		aac_list_del(entry);
 		
-		fib = list_entry(entry, struct hw_fib, header.FibLinks);
+		hw_fib = aac_list_entry(entry, struct hw_fib, header.FibLinks);
 		fibctx->count--;
 		spin_unlock_irqrestore(&dev->fib_lock, flags);
-		if (copy_to_user(f.fib, fib, sizeof(struct hw_fib))) {
-			kfree(fib);
+		if (copy_to_user(f.fib, hw_fib, sizeof(struct hw_fib))) {
+			kfree(hw_fib);
 			return -EFAULT;
 		}	
 		/*
 		 *	Free the space occupied by this copy of the fib.
 		 */
-		kfree(fib);
+		kfree(hw_fib);
 		status = 0;
 		fibctx->jiffies = jiffies/HZ;
 	} else {
@@ -264,24 +264,24 @@
 
 int aac_close_fib_context(struct aac_dev * dev, struct aac_fib_context * fibctx)
 {
-	struct hw_fib *fib;
+	struct hw_fib *hw_fib;
 
 	/*
 	 *	First free any FIBs that have not been consumed.
 	 */
-	while (!list_empty(&fibctx->fibs)) {
-		struct list_head * entry;
+	while (!aac_list_empty(&fibctx->hw_fib_list)) {
+		struct aac_list_head * entry;
 		/*
 		 *	Pull the next fib from the fibs
 		 */
-		entry = fibctx->fibs.next;
-		list_del(entry);
-		fib = list_entry(entry, struct hw_fib, header.FibLinks);
+		entry = (struct aac_list_head*)(ulong)(fibctx->hw_fib_list.next);
+		aac_list_del(entry);
+		hw_fib = aac_list_entry(entry, struct hw_fib, header.FibLinks);
 		fibctx->count--;
 		/*
 		 *	Free the space occupied by this copy of the fib.
 		 */
-		kfree(fib);
+		kfree(hw_fib);
 	}
 	/*
 	 *	Remove the Context from the AdapterFibContext List
@@ -372,6 +372,204 @@
 	return 0;
 }
 
+/**
+ *
+ * aac_send_raw_scb
+ *
+ */
+
+int aac_send_raw_srb(struct aac_dev* dev, void* arg)
+{
+	struct fib* srbfib;
+	int status;
+	struct aac_srb *srbcmd;
+	struct aac_srb *user_srb = arg;
+	struct aac_srb_reply* user_reply;
+	struct aac_srb_reply* reply;
+	u32 fibsize = 0;
+	u32 flags = 0;
+	s32 rcode = 0;
+	u32 data_dir;
+	ulong sg_user[32];
+	ulong sg_list[32];
+	u32   sg_indx = 0;
+	u32 byte_count = 0;
+	u32 actual_fibsize = 0;
+	int i;
+
+
+	if (!capable(CAP_SYS_ADMIN)){
+		printk(KERN_DEBUG"aacraid: No permission to send raw srb\n"); 
+		return -EPERM;
+	}
+	/*
+	 *	Allocate and initialize a Fib then setup a BlockWrite command
+	 */
+	if (!(srbfib = fib_alloc(dev))) {
+		return -1;
+	}
+	fib_init(srbfib);
+
+	srbcmd = (struct aac_srb*) fib_data(srbfib);
+
+	if(copy_from_user((void*)&fibsize, (void*)&user_srb->count,sizeof(u32))){
+		printk(KERN_DEBUG"aacraid: Could not copy data size from user\n"); 
+		rcode = -EFAULT;
+		goto cleanup;
+	}
+
+	if(copy_from_user(srbcmd, user_srb,fibsize)){
+		printk(KERN_DEBUG"aacraid: Could not copy srb from user\n"); 
+		rcode = -EFAULT;
+		goto cleanup;
+	}
+
+	user_reply = arg+fibsize;
+
+	flags = srbcmd->flags;
+	// Fix up srb for endian and force some values
+	srbcmd->function = cpu_to_le32(SRBF_ExecuteScsi);	// Force this
+	srbcmd->channel  = cpu_to_le32(srbcmd->channel);
+	srbcmd->target   = cpu_to_le32(srbcmd->target);
+	srbcmd->lun      = cpu_to_le32(srbcmd->lun);
+	srbcmd->flags    = cpu_to_le32(srbcmd->flags);
+	srbcmd->timeout  = cpu_to_le32(srbcmd->timeout);
+	srbcmd->retry_limit =cpu_to_le32(0); // Obsolete parameter
+	srbcmd->cdb_size = cpu_to_le32(srbcmd->cdb_size);
+	
+	switch(srbcmd->flags){
+	case SRB_DataOut:
+		data_dir = SCSI_DATA_WRITE;
+		break;
+	case (SRB_DataIn | SRB_DataOut):
+		data_dir = SCSI_DATA_UNKNOWN;  
+		break;
+	case SRB_DataIn:
+		data_dir = SCSI_DATA_READ;
+		break;
+	default:
+		data_dir = SCSI_DATA_NONE;
+	}
+	if( dev->pae_support ==1 ) {
+		struct sgmap64* psg = (struct sgmap64*)&srbcmd->sg;
+		byte_count = 0;
+
+		// This should also catch if user used the 32 bit sgmap
+		actual_fibsize = sizeof (struct aac_srb) + (((srbcmd->sg.count & 0xff) - 1) * sizeof (struct sgentry64));
+		if(actual_fibsize != fibsize){ // User made a mistake - should not continue
+			printk(KERN_DEBUG"aacraid: Bad Size specified in Raw SRB command\n");
+			rcode = -EINVAL;
+			goto cleanup;
+		}
+
+		for (i = 0; i < psg->count; i++) {
+			dma_addr_t addr; 
+			u64 le_addr;
+			void* p;
+			p = kmalloc(psg->sg[i].count,GFP_KERNEL|__GFP_DMA);
+			if(p == 0) {
+				printk(KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n",
+				psg->sg[i].count,i,psg->count);
+				rcode = -ENOMEM;
+				goto cleanup;
+			}
+			sg_user[i] = (ulong)psg->sg[i].addr;
+			sg_list[i] = (ulong)p; // save so we can clean up later
+			sg_indx = i;
+
+			if( flags & SRB_DataOut ){
+				if(copy_from_user(p,psg->sg[i].addr,psg->sg[i].count)){
+					printk(KERN_DEBUG"aacraid: Could not copy sg data from user\n"); 
+					rcode = -EFAULT;
+					goto cleanup;
+				}
+			}
+			addr = pci_map_single(dev->pdev, p, psg->sg[i].count, scsi_to_pci_dma_dir(data_dir));
+
+			le_addr = cpu_to_le64(addr);
+			psg->sg[i].addr[1] = (u32)(le_addr>>32);
+			psg->sg[i].addr[0] = (u32)(le_addr & 0xffffffff);
+			psg->sg[i].count = cpu_to_le32(psg->sg[i].count);  
+			byte_count += psg->sg[i].count;
+		}
+
+		srbcmd->count = cpu_to_le32(byte_count);
+		status = fib_send(ScsiPortCommand64, srbfib, actual_fibsize, FsaNormal, 1, 1,0,0);
+	} else {
+		struct sgmap* psg = &srbcmd->sg;
+		byte_count = 0;
+
+		actual_fibsize = sizeof (struct aac_srb) + (((srbcmd->sg.count & 0xff) - 1) * sizeof (struct sgentry));
+		if(actual_fibsize != fibsize){ // User made a mistake - should not continue
+			printk(KERN_DEBUG"aacraid: Bad Size specified in Raw SRB command\n");
+			rcode = -EINVAL;
+			goto cleanup;
+		}
+		for (i = 0; i < psg->count; i++) {
+			dma_addr_t addr; 
+			void* p;
+			p = kmalloc(psg->sg[i].count,GFP_KERNEL);
+			if(p == 0) {
+				printk(KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n",
+				psg->sg[i].count,i,psg->count);
+				rcode = -ENOMEM;
+				goto cleanup;
+			}
+			sg_user[i] = (ulong)(psg->sg[i].addr);
+			sg_list[i] = (ulong)p; // save so we can clean up later
+			sg_indx = i;
+
+			if( flags & SRB_DataOut ){
+				if(copy_from_user((void*)p,(void*)(ulong)(psg->sg[i].addr),psg->sg[i].count)){
+					printk(KERN_DEBUG"aacraid: Could not copy sg data from user\n"); 
+					rcode = -EFAULT;
+					goto cleanup;
+				}
+			}
+			addr = pci_map_single(dev->pdev, p, psg->sg[i].count, scsi_to_pci_dma_dir(data_dir));
+
+			psg->sg[i].addr = cpu_to_le32(addr);
+			psg->sg[i].count = cpu_to_le32(psg->sg[i].count);  
+			byte_count += psg->sg[i].count;
+		}
+		srbcmd->count = cpu_to_le32(byte_count);
+		status = fib_send(ScsiPortCommand, srbfib, actual_fibsize, FsaNormal, 1, 1, 0, 0);
+	}
+
+	if (status != 0){
+		printk(KERN_DEBUG"aacraid: Could not send raw srb fib to hba\n"); 
+		rcode = -1;
+		goto cleanup;
+	}
+
+	if( flags & SRB_DataIn ) {
+		for(i = 0 ; i <= sg_indx; i++){
+			if(copy_to_user((void*)(sg_user[i]),(void*)(sg_list[i]),le32_to_cpu(srbcmd->sg.sg[i].count))){
+				printk(KERN_DEBUG"aacraid: Could not copy sg data to user\n"); 
+				rcode = -EFAULT;
+				goto cleanup;
+
+			}
+		}
+	}
+
+	reply = (struct aac_srb_reply *) fib_data(srbfib);
+	if(copy_to_user(user_reply,reply,sizeof(struct aac_srb_reply))){
+		printk(KERN_DEBUG"aacraid: Could not copy reply to user\n"); 
+		rcode = -EFAULT;
+		goto cleanup;
+	}
+
+cleanup:
+	for(i=0; i <= sg_indx; i++){
+		kfree((void*)sg_list[i]);
+	}
+	fib_complete(srbfib);
+	fib_free(srbfib);
+
+	return rcode;
+}
+
 
 struct aac_pci_info {
         u32 bus;
@@ -386,8 +584,10 @@
 	pci_info.bus = dev->pdev->bus->number;
 	pci_info.slot = PCI_SLOT(dev->pdev->devfn);
 
-       if(copy_to_user( arg, (void*)&pci_info, sizeof(struct aac_pci_info)))
+       if(copy_to_user( arg, (void*)&pci_info, sizeof(struct aac_pci_info))){
+		printk(KERN_DEBUG "aacraid: Could not copy pci info\n");
                return -EFAULT;
+	}
         return 0;
  }
  
@@ -420,6 +620,9 @@
 	case FSACTL_CLOSE_GET_ADAPTER_FIB:
 		status = close_getadapter_fib(dev, arg);
 		break;
+	case FSACTL_SEND_RAW_SRB:
+		status = aac_send_raw_srb(dev,arg);
+		break;
 	case FSACTL_GET_PCI_INFO:
 		status = aac_get_pci_info(dev,arg);
 		break;
diff -urN linux-2.5.69-bk7/drivers/scsi/aacraid/comminit.c linux-2.5.69-bk8/drivers/scsi/aacraid/comminit.c
--- linux-2.5.69-bk7/drivers/scsi/aacraid/comminit.c	2003-05-04 16:53:01.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/aacraid/comminit.c	2003-05-13 04:44:28.000000000 -0700
@@ -39,6 +39,7 @@
 #include <linux/slab.h>
 #include <linux/blk.h>
 #include <linux/completion.h>
+#include <linux/mm.h>
 #include <asm/semaphore.h>
 #include "scsi.h"
 #include "hosts.h"
@@ -58,10 +59,11 @@
 	struct aac_init *init;
 	dma_addr_t phys;
 
-	/* FIXME: Adaptec add 128 bytes to this value - WHY ?? */
 	size = fibsize + sizeof(struct aac_init) + commsize + commalign + printfbufsiz;
 
+ 
 	base = pci_alloc_consistent(dev->pdev, size, &phys);
+
 	if(base == NULL)
 	{
 		printk(KERN_ERR "aacraid: unable to create mapping.\n");
@@ -70,18 +72,10 @@
 	dev->comm_addr = (void *)base;
 	dev->comm_phys = phys;
 	dev->comm_size = size;
-
+	
 	dev->init = (struct aac_init *)(base + fibsize);
 	dev->init_pa = phys + fibsize;
 
-	/*
-	 *	Cache the upper bits of the virtual mapping for 64bit boxes
-	 *	FIXME: this crap should be rewritten
-	 */
-#if BITS_PER_LONG >= 64 
-	dev->fib_base_va = ((ulong)base & 0xffffffff00000000);
-#endif
-
 	init = dev->init;
 
 	init->InitStructRevision = cpu_to_le32(ADAPTER_INIT_STRUCT_REVISION);
@@ -92,16 +86,19 @@
 	 *	Adapter Fibs are the first thing allocated so that they
 	 *	start page aligned
 	 */
-	init->AdapterFibsVirtualAddress = cpu_to_le32((u32)base);
-	init->AdapterFibsPhysicalAddress = cpu_to_le32(phys);
+	dev->fib_base_va = (ulong)base;
+	
+	init->AdapterFibsVirtualAddress = cpu_to_le32((u32)(ulong)phys);
+	init->AdapterFibsPhysicalAddress = cpu_to_le32((u32)phys);
 	init->AdapterFibsSize = cpu_to_le32(fibsize);
 	init->AdapterFibAlign = cpu_to_le32(sizeof(struct hw_fib));
+	init->HostPhysMemPages = cpu_to_le32(num_physpages);		// number of 4k pages of host physical memory
 
 	/*
 	 * Increment the base address by the amount already used
 	 */
 	base = base + fibsize + sizeof(struct aac_init);
-	phys = phys + fibsize + sizeof(struct aac_init);
+	phys = (dma_addr_t)((ulong)phys + fibsize + sizeof(struct aac_init));
 	/*
 	 *	Align the beginning of Headers to commalign
 	 */
@@ -111,8 +108,8 @@
 	/*
 	 *	Fill in addresses of the Comm Area Headers and Queues
 	 */
-	*commaddr = (unsigned long *)base;
-	init->CommHeaderAddress = cpu_to_le32(phys);
+	*commaddr = base;
+	init->CommHeaderAddress = cpu_to_le32((u32)phys);
 	/*
 	 *	Increment the base address by the size of the CommArea
 	 */
@@ -134,14 +131,14 @@
 	q->dev = dev;
 	INIT_LIST_HEAD(&q->pendingq);
 	init_waitqueue_head(&q->cmdready);
-	INIT_LIST_HEAD(&q->cmdq);
+	AAC_INIT_LIST_HEAD(&q->cmdq);
 	init_waitqueue_head(&q->qfull);
 	spin_lock_init(&q->lockdata);
 	q->lock = &q->lockdata;
 	q->headers.producer = mem;
 	q->headers.consumer = mem+1;
-	*q->headers.producer = cpu_to_le32(qsize);
-	*q->headers.consumer = cpu_to_le32(qsize);
+	*(q->headers.producer) = cpu_to_le32(qsize);
+	*(q->headers.consumer) = cpu_to_le32(qsize);
 	q->entries = qsize;
 }
 
@@ -227,7 +224,6 @@
 	struct aac_entry * queues;
 	unsigned long size;
 	struct aac_queue_block * comm = dev->queues;
-
 	/*
 	 *	Now allocate and initialize the zone structures used as our 
 	 *	pool of FIB context records.  The size of the zone is based
@@ -246,9 +242,9 @@
 	if (!aac_alloc_comm(dev, (void * *)&headers, size, QUEUE_ALIGNMENT))
 		return -ENOMEM;
 
-	queues = (struct aac_entry *)((unsigned char *)headers + hdrsize);
+	queues = (struct aac_entry *)(((ulong)headers) + hdrsize);
 
-	/* Adapter to Host normal proirity Command queue */ 
+	/* Adapter to Host normal priority Command queue */ 
 	comm->queue[HostNormCmdQueue].base = queues;
 	aac_queue_init(dev, &comm->queue[HostNormCmdQueue], headers, HOST_NORM_CMD_ENTRIES);
 	queues += HOST_NORM_CMD_ENTRIES;
@@ -278,7 +274,6 @@
 	/* adapter to host normal priority response queue */
 	comm->queue[HostNormRespQueue].base = queues;
 	aac_queue_init(dev, &comm->queue[HostNormRespQueue], headers, HOST_NORM_RESP_ENTRIES);
-    
 	queues += HOST_NORM_RESP_ENTRIES;
 	headers += 2;
 
@@ -313,6 +308,7 @@
 	/*
 	 *	Ok now init the communication subsystem
 	 */
+
 	dev->queues = (struct aac_queue_block *) kmalloc(sizeof(struct aac_queue_block), GFP_KERNEL);
 	if (dev->queues == NULL) {
 		printk(KERN_ERR "Error could not allocate comm region.\n");
@@ -320,13 +316,17 @@
 	}
 	memset(dev->queues, 0, sizeof(struct aac_queue_block));
 
-	if (aac_comm_init(dev)<0)
+	if (aac_comm_init(dev)<0){
+		kfree(dev->queues);
 		return NULL;
+	}
 	/*
 	 *	Initialize the list of fibs
 	 */
-	if(fib_setup(dev)<0)
+	if(fib_setup(dev)<0){
+		kfree(dev->queues);
 		return NULL;
+	}
 		
 	INIT_LIST_HEAD(&dev->fib_list);
 	init_completion(&dev->aif_completion);
diff -urN linux-2.5.69-bk7/drivers/scsi/aacraid/commsup.c linux-2.5.69-bk8/drivers/scsi/aacraid/commsup.c
--- linux-2.5.69-bk7/drivers/scsi/aacraid/commsup.c	2003-05-04 16:53:35.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/aacraid/commsup.c	2003-05-13 04:44:28.000000000 -0700
@@ -79,39 +79,39 @@
  *	fib_setup	-	setup the fibs
  *	@dev: Adapter to set up
  *
- *	Allocate the PCI space for the fibs, map it and then initialise the
+ *	Allocate the PCI space for the fibs, map it and then intialise the
  *	fib area, the unmapped fib data and also the free list
  */
 
 int fib_setup(struct aac_dev * dev)
 {
 	struct fib *fibptr;
-	struct hw_fib *fib;
-	dma_addr_t fibpa;
+	struct hw_fib *hw_fib_va;
+	dma_addr_t hw_fib_pa;
 	int i;
 	
 	if(fib_map_alloc(dev)<0)
 		return -ENOMEM;
 		
-	fib = dev->hw_fib_va;
-	fibpa = dev->hw_fib_pa;
-	memset(fib, 0, sizeof(struct hw_fib) * AAC_NUM_FIB);
+	hw_fib_va = dev->hw_fib_va;
+	hw_fib_pa = dev->hw_fib_pa;
+	memset(hw_fib_va, 0, sizeof(struct hw_fib) * AAC_NUM_FIB);
 	/*
 	 *	Initialise the fibs
 	 */
 	for (i = 0, fibptr = &dev->fibs[i]; i < AAC_NUM_FIB; i++, fibptr++) 
 	{
 		fibptr->dev = dev;
-		fibptr->fib = fib;
-		fibptr->data = (void *) fibptr->fib->data;
+		fibptr->hw_fib = hw_fib_va;
+		fibptr->data = (void *) fibptr->hw_fib->data;
 		fibptr->next = fibptr+1;	/* Forward chain the fibs */
 		init_MUTEX_LOCKED(&fibptr->event_wait);
 		spin_lock_init(&fibptr->event_lock);
-		fib->header.XferState = cpu_to_le32(0xffffffff);
-		fib->header.SenderSize = cpu_to_le16(sizeof(struct hw_fib));
-		fibptr->logicaladdr = (unsigned long) fibpa;
-		fib = (struct hw_fib *)((unsigned char *)fib + sizeof(struct hw_fib));
-		fibpa = fibpa + sizeof(struct hw_fib);
+		hw_fib_va->header.XferState = cpu_to_le32(0xffffffff);
+		hw_fib_va->header.SenderSize = cpu_to_le16(sizeof(struct hw_fib));
+		fibptr->hw_fib_pa = hw_fib_pa;
+		hw_fib_va = (struct hw_fib *)((unsigned char *)hw_fib_va + sizeof(struct hw_fib));
+		hw_fib_pa = hw_fib_pa + sizeof(struct hw_fib); 
 	}
 	/*
 	 *	Add the fib chain to the free list
@@ -136,11 +136,15 @@
 {
 	struct fib * fibptr;
 	unsigned long flags;
-	
 	spin_lock_irqsave(&dev->fib_lock, flags);
 	fibptr = dev->free_fib;	
-	if(!fibptr)
-		BUG();
+	while(!fibptr){
+		spin_unlock_irqrestore(&dev->fib_lock, flags);
+		set_current_state(TASK_UNINTERRUPTIBLE);
+		schedule_timeout(1);
+		spin_lock_irqsave(&dev->fib_lock, flags);
+		fibptr = dev->free_fib;	
+	}
 	dev->free_fib = fibptr->next;
 	spin_unlock_irqrestore(&dev->fib_lock, flags);
 	/*
@@ -152,7 +156,7 @@
 	 *	Null out fields that depend on being zero at the start of
 	 *	each I/O
 	 */
-	fibptr->fib->header.XferState = cpu_to_le32(0);
+	fibptr->hw_fib->header.XferState = cpu_to_le32(0);
 	fibptr->callback = NULL;
 	fibptr->callback_data = NULL;
 
@@ -172,15 +176,14 @@
 	unsigned long flags;
 
 	spin_lock_irqsave(&fibptr->dev->fib_lock, flags);
-
 	if (fibptr->flags & FIB_CONTEXT_FLAG_TIMED_OUT) {
 		aac_config.fib_timeouts++;
 		fibptr->next = fibptr->dev->timeout_fib;
 		fibptr->dev->timeout_fib = fibptr;
 	} else {
-		if (fibptr->fib->header.XferState != 0) {
+		if (fibptr->hw_fib->header.XferState != 0) {
 			printk(KERN_WARNING "fib_free, XferState != 0, fibptr = 0x%p, XferState = 0x%x\n", 
-				 (void *)fibptr, fibptr->fib->header.XferState);
+				 (void*)fibptr, fibptr->hw_fib->header.XferState);
 		}
 		fibptr->next = fibptr->dev->free_fib;
 		fibptr->dev->free_fib = fibptr;
@@ -197,14 +200,14 @@
  
 void fib_init(struct fib *fibptr)
 {
-	struct hw_fib *fib = fibptr->fib;
+	struct hw_fib *hw_fib = fibptr->hw_fib;
 
-	fib->header.StructType = FIB_MAGIC;
-	fib->header.Size = cpu_to_le16(sizeof(struct hw_fib));
-        fib->header.XferState = cpu_to_le32(HostOwned | FibInitialized | FibEmpty | FastResponseCapable);
-	fib->header.SenderFibAddress = cpu_to_le32(0);
-	fib->header.ReceiverFibAddress = cpu_to_le32(0);
-	fib->header.SenderSize = cpu_to_le16(sizeof(struct hw_fib));
+	hw_fib->header.StructType = FIB_MAGIC;
+	hw_fib->header.Size = cpu_to_le16(sizeof(struct hw_fib));
+        hw_fib->header.XferState = cpu_to_le32(HostOwned | FibInitialized | FibEmpty | FastResponseCapable);
+	hw_fib->header.SenderFibAddress = cpu_to_le32(fibptr->hw_fib_pa);
+	hw_fib->header.ReceiverFibAddress = cpu_to_le32(fibptr->hw_fib_pa);
+	hw_fib->header.SenderSize = cpu_to_le16(sizeof(struct hw_fib));
 }
 
 /**
@@ -217,10 +220,10 @@
  
 void fib_dealloc(struct fib * fibptr)
 {
-	struct hw_fib *fib = fibptr->fib;
-	if(fib->header.StructType != FIB_MAGIC) 
+	struct hw_fib *hw_fib = fibptr->hw_fib;
+	if(hw_fib->header.StructType != FIB_MAGIC) 
 		BUG();
-	fib->header.XferState = cpu_to_le32(0);        
+	hw_fib->header.XferState = cpu_to_le32(0);        
 }
 
 /*
@@ -257,7 +260,7 @@
 	q = &dev->queues->queue[qid];
 	
 	*index = le32_to_cpu(*(q->headers.producer));
-		if (*index - 2 == le32_to_cpu(*(q->headers.consumer)))
+	if ((*index - 2) == le32_to_cpu(*(q->headers.consumer)))
 			*nonotify = 1; 
 
 	if (qid == AdapHighCmdQueue) {
@@ -277,10 +280,14 @@
 		if (*index >= ADAP_NORM_RESP_ENTRIES) 
 			*index = 0; /* Wrap to front of the Producer Queue. */
 	}
-	else BUG();
+	else {
+		printk("aacraid: invalid qid\n");
+		BUG();
+	}
 
-        if (*index + 1 == le32_to_cpu(*(q->headers.consumer))) { /* Queue is full */
-		printk(KERN_WARNING "Queue %d full, %ld outstanding.\n", qid, q->numpending);
+        if ((*index + 1) == le32_to_cpu(*(q->headers.consumer))) { /* Queue is full */
+		printk(KERN_WARNING "Queue %d full, %d outstanding.\n",
+				qid, q->numpending);
 		return 0;
 	} else {
 	        *entry = q->base + *index;
@@ -288,7 +295,7 @@
 	}
 }   
 
-/**
+/*Command thread: *
  *	aac_queue_get		-	get the next free QE
  *	@dev: Adapter
  *	@index: Returned index
@@ -304,7 +311,7 @@
  *	success.
  */
 
-static int aac_queue_get(struct aac_dev * dev, u32 * index, u32 qid, struct hw_fib * fib, int wait, struct fib * fibptr, unsigned long *nonotify)
+static int aac_queue_get(struct aac_dev * dev, u32 * index, u32 qid, struct hw_fib * hw_fib, int wait, struct fib * fibptr, unsigned long *nonotify)
 {
 	struct aac_entry * entry = NULL;
 	int map = 0;
@@ -322,7 +329,7 @@
 	        /*
 	         *	Setup queue entry with a command, status and fib mapped
 	         */
-	        entry->size = cpu_to_le32(le16_to_cpu(fib->header.Size));
+	        entry->size = cpu_to_le32(le16_to_cpu(hw_fib->header.Size));
 	        map = 1;
 	}
 	else if (qid == AdapHighRespQueue || qid == AdapNormRespQueue)
@@ -334,17 +341,18 @@
         	/*
         	 *	Setup queue entry with command, status and fib mapped
         	 */
-        	entry->size = cpu_to_le32(le16_to_cpu(fib->header.Size));
-        	entry->addr = cpu_to_le32(fib->header.SenderFibAddress);     		/* Restore adapters pointer to the FIB */
-		fib->header.ReceiverFibAddress = fib->header.SenderFibAddress;		/* Let the adapter now where to find its data */
+        	entry->size = cpu_to_le32(le16_to_cpu(hw_fib->header.Size));
+        	entry->addr = hw_fib->header.SenderFibAddress;
+     			/* Restore adapters pointer to the FIB */
+		hw_fib->header.ReceiverFibAddress = hw_fib->header.SenderFibAddress;	/* Let the adapter now where to find its data */
         	map = 0;
-	} 
+	}
 	/*
 	 *	If MapFib is true than we need to map the Fib and put pointers
 	 *	in the queue entry.
 	 */
 	if (map)
-		entry->addr = cpu_to_le32((unsigned long)(fibptr->logicaladdr));
+		entry->addr = fibptr->hw_fib_pa;
 	return 0;
 }
 
@@ -415,11 +423,10 @@
 	u32 qid;
 	struct aac_dev * dev = fibptr->dev;
 	unsigned long nointr = 0;
-	struct hw_fib * fib = fibptr->fib;
+	struct hw_fib * hw_fib = fibptr->hw_fib;
 	struct aac_queue * q;
 	unsigned long flags = 0;
-
-	if (!(le32_to_cpu(fib->header.XferState) & HostOwned))
+	if (!(le32_to_cpu(hw_fib->header.XferState) & HostOwned))
 		return -EBUSY;
 	/*
 	 *	There are 5 cases with the wait and reponse requested flags. 
@@ -435,19 +442,22 @@
 	if (wait && !reply) {
 		return -EINVAL;
 	} else if (!wait && reply) {
-		fib->header.XferState |= cpu_to_le32(Async | ResponseExpected);
+		hw_fib->header.XferState |= cpu_to_le32(Async | ResponseExpected);
 		FIB_COUNTER_INCREMENT(aac_config.AsyncSent);
 	} else if (!wait && !reply) {
-		fib->header.XferState |= cpu_to_le32(NoResponseExpected);
+		hw_fib->header.XferState |= cpu_to_le32(NoResponseExpected);
 		FIB_COUNTER_INCREMENT(aac_config.NoResponseSent);
 	} else if (wait && reply) {
-		fib->header.XferState |= cpu_to_le32(ResponseExpected);
+		hw_fib->header.XferState |= cpu_to_le32(ResponseExpected);
 		FIB_COUNTER_INCREMENT(aac_config.NormalSent);
 	} 
 	/*
 	 *	Map the fib into 32bits by using the fib number
 	 */
-	fib->header.SenderData = fibptr-&dev->fibs[0];	/* for callback */
+
+//	hw_fib->header.SenderFibAddress = ((u32)(fibptr-dev->fibs)) << 1;
+	hw_fib->header.SenderFibAddress = cpu_to_le32((u32)(ulong)fibptr->hw_fib_pa);
+	hw_fib->header.SenderData = (u32)(fibptr - dev->fibs);
 	/*
 	 *	Set FIB state to indicate where it came from and if we want a
 	 *	response from the adapter. Also load the command from the
@@ -455,15 +465,14 @@
 	 *
 	 *	Map the hw fib pointer as a 32bit value
 	 */
-	fib->header.SenderFibAddress = fib2addr(fib);
-	fib->header.Command = cpu_to_le16(command);
-	fib->header.XferState |= cpu_to_le32(SentFromHost);
-	fibptr->fib->header.Flags = 0;				/* Zero the flags field - its internal only...	 */
+	hw_fib->header.Command = cpu_to_le16(command);
+	hw_fib->header.XferState |= cpu_to_le32(SentFromHost);
+	fibptr->hw_fib->header.Flags = 0;	/* 0 the flags field - internal only*/
 	/*
 	 *	Set the size of the Fib we want to send to the adapter
 	 */
-	fib->header.Size = cpu_to_le16(sizeof(struct aac_fibhdr) + size);
-	if (le16_to_cpu(fib->header.Size) > le16_to_cpu(fib->header.SenderSize)) {
+	hw_fib->header.Size = cpu_to_le16(sizeof(struct aac_fibhdr) + size);
+	if (le16_to_cpu(hw_fib->header.Size) > le16_to_cpu(hw_fib->header.SenderSize)) {
 		return -EMSGSIZE;
 	}                
 	/*
@@ -471,22 +480,25 @@
 	 *	the adapter a command is ready.
 	 */
 	if (priority == FsaHigh) {
-		fib->header.XferState |= cpu_to_le32(HighPriority);
+		hw_fib->header.XferState |= cpu_to_le32(HighPriority);
 		qid = AdapHighCmdQueue;
 	} else {
-		fib->header.XferState |= cpu_to_le32(NormalPriority);
+		hw_fib->header.XferState |= cpu_to_le32(NormalPriority);
 		qid = AdapNormCmdQueue;
 	}
 	q = &dev->queues->queue[qid];
 
 	if(wait)
 		spin_lock_irqsave(&fibptr->event_lock, flags);
-	if(aac_queue_get( dev, &index, qid, fib, 1, fibptr, &nointr)<0)
+	if(aac_queue_get( dev, &index, qid, hw_fib, 1, fibptr, &nointr)<0)
 		return -EWOULDBLOCK;
 	dprintk((KERN_DEBUG "fib_send: inserting a queue entry at index %d.\n",index));
 	dprintk((KERN_DEBUG "Fib contents:.\n"));
-	dprintk((KERN_DEBUG "  Command =               %d.\n", fib->header.Command));
-	dprintk((KERN_DEBUG "  XferState  =            %x.\n", fib->header.XferState));
+	dprintk((KERN_DEBUG "  Command =               %d.\n", hw_fib->header.Command));
+	dprintk((KERN_DEBUG "  XferState  =            %x.\n", hw_fib->header.XferState));
+	dprintk((KERN_DEBUG "  hw_fib va being sent=%p\n",fibptr->hw_fib));
+	dprintk((KERN_DEBUG "  hw_fib pa being sent=%xl\n",(ulong)fibptr->hw_fib_pa));
+	dprintk((KERN_DEBUG "  fib being sent=%p\n",fibptr));
 	/*
 	 *	Fill in the Callback and CallbackContext if we are not
 	 *	going to wait.
@@ -500,6 +512,7 @@
 	q->numpending++;
 
 	fibptr->done = 0;
+	fibptr->flags = 0;
 
 	if(aac_insert_entry(dev, index, qid, (nointr & aac_config.irq_mod)) < 0)
 		return -EWOULDBLOCK;
@@ -513,10 +526,11 @@
 		if(fibptr->done == 0)
 			BUG();
 			
-		if((fibptr->flags & FIB_CONTEXT_FLAG_TIMED_OUT))
+		if((fibptr->flags & FIB_CONTEXT_FLAG_TIMED_OUT)){
 			return -ETIMEDOUT;
-		else
+		} else {
 			return 0;
+		}
 	}
 	/*
 	 *	If the user does not want a response than return success otherwise
@@ -543,8 +557,7 @@
 {
 	u32 index;
 	int status;
-
-	if (*q->headers.producer == *q->headers.consumer) {
+	if (le32_to_cpu(*q->headers.producer) == le32_to_cpu(*q->headers.consumer)) {
 		status = 0;
 	} else {
 		/*
@@ -564,7 +577,7 @@
 
 int aac_consumer_avail(struct aac_dev *dev, struct aac_queue * q)
 {
-	return (*q->headers.producer != *q->headers.consumer);
+	return (le32_to_cpu(*q->headers.producer) != le32_to_cpu(*q->headers.consumer));
 }
 
 
@@ -583,7 +596,7 @@
 	int wasfull = 0;
 	u32 notify;
 
-	if (*q->headers.producer+1 == *q->headers.consumer)
+	if ((le32_to_cpu(*q->headers.producer)+1) == le32_to_cpu(*q->headers.consumer))
 		wasfull = 1;
         
 	if (le32_to_cpu(*q->headers.consumer) >= q->entries)
@@ -625,16 +638,15 @@
 
 int fib_adapter_complete(struct fib * fibptr, unsigned short size)
 {
-	struct hw_fib * fib = fibptr->fib;
+	struct hw_fib * hw_fib = fibptr->hw_fib;
 	struct aac_dev * dev = fibptr->dev;
 	unsigned long nointr = 0;
-
-	if (le32_to_cpu(fib->header.XferState) == 0)
+	if (le32_to_cpu(hw_fib->header.XferState) == 0)
         	return 0;
 	/*
 	 *	If we plan to do anything check the structure type first.
 	 */ 
-	if ( fib->header.StructType != FIB_MAGIC ) {
+	if ( hw_fib->header.StructType != FIB_MAGIC ) {
         	return -EINVAL;
 	}
 	/*
@@ -644,37 +656,36 @@
 	 *	and want to send a response back to the adapter. This will 
 	 *	send the completed cdb to the adapter.
 	 */
-	if (fib->header.XferState & cpu_to_le32(SentFromAdapter)) {
-	        fib->header.XferState |= cpu_to_le32(HostProcessed);
-	        if (fib->header.XferState & cpu_to_le32(HighPriority)) {
+	if (hw_fib->header.XferState & cpu_to_le32(SentFromAdapter)) {
+	        hw_fib->header.XferState |= cpu_to_le32(HostProcessed);
+	        if (hw_fib->header.XferState & cpu_to_le32(HighPriority)) {
         		u32 index;
        			if (size) 
 			{
 				size += sizeof(struct aac_fibhdr);
-				if (size > le16_to_cpu(fib->header.SenderSize))
+				if (size > le16_to_cpu(hw_fib->header.SenderSize))
 					return -EMSGSIZE;
-				fib->header.Size = cpu_to_le16(size);
+				hw_fib->header.Size = cpu_to_le16(size);
 			}
-			if(aac_queue_get(dev, &index, AdapHighRespQueue, fib, 1, NULL, &nointr) < 0) {
+			if(aac_queue_get(dev, &index, AdapHighRespQueue, hw_fib, 1, NULL, &nointr) < 0) {
 				return -EWOULDBLOCK;
 			}
 			if (aac_insert_entry(dev, index, AdapHighRespQueue,  (nointr & (int)aac_config.irq_mod)) != 0) {
 			}
 		}
-		else if (fib->header.XferState & NormalPriority) 
+		else if (hw_fib->header.XferState & NormalPriority) 
 		{
 			u32 index;
 
 			if (size) {
 				size += sizeof(struct aac_fibhdr);
-				if (size > le16_to_cpu(fib->header.SenderSize)) 
+				if (size > le16_to_cpu(hw_fib->header.SenderSize)) 
 					return -EMSGSIZE;
-				fib->header.Size = cpu_to_le16(size);
+				hw_fib->header.Size = cpu_to_le16(size);
 			}
-			if (aac_queue_get(dev, &index, AdapNormRespQueue, fib, 1, NULL, &nointr) < 0) 
+			if (aac_queue_get(dev, &index, AdapNormRespQueue, hw_fib, 1, NULL, &nointr) < 0) 
 				return -EWOULDBLOCK;
-			if (aac_insert_entry(dev, index, AdapNormRespQueue, 
-				(nointr & (int)aac_config.irq_mod)) != 0) 
+			if (aac_insert_entry(dev, index, AdapNormRespQueue, (nointr & (int)aac_config.irq_mod)) != 0) 
 			{
 			}
 		}
@@ -696,19 +707,19 @@
  
 int fib_complete(struct fib * fibptr)
 {
-	struct hw_fib * fib = fibptr->fib;
+	struct hw_fib * hw_fib = fibptr->hw_fib;
 
 	/*
 	 *	Check for a fib which has already been completed
 	 */
 
-	if (fib->header.XferState == cpu_to_le32(0))
+	if (hw_fib->header.XferState == cpu_to_le32(0))
         	return 0;
 	/*
 	 *	If we plan to do anything check the structure type first.
 	 */ 
 
-	if (fib->header.StructType != FIB_MAGIC)
+	if (hw_fib->header.StructType != FIB_MAGIC)
 	        return -EINVAL;
 	/*
 	 *	This block completes a cdb which orginated on the host and we 
@@ -716,19 +727,19 @@
 	 *	command is complete that we had sent to the adapter and this
 	 *	cdb could be reused.
 	 */
-	if((fib->header.XferState & cpu_to_le32(SentFromHost)) &&
-		(fib->header.XferState & cpu_to_le32(AdapterProcessed)))
+	if((hw_fib->header.XferState & cpu_to_le32(SentFromHost)) &&
+		(hw_fib->header.XferState & cpu_to_le32(AdapterProcessed)))
 	{
 		fib_dealloc(fibptr);
 	}
-	else if(fib->header.XferState & cpu_to_le32(SentFromHost))
+	else if(hw_fib->header.XferState & cpu_to_le32(SentFromHost))
 	{
 		/*
 		 *	This handles the case when the host has aborted the I/O
 		 *	to the adapter because the adapter is not responding
 		 */
 		fib_dealloc(fibptr);
-	} else if(fib->header.XferState & cpu_to_le32(HostOwned)) {
+	} else if(hw_fib->header.XferState & cpu_to_le32(HostOwned)) {
 		fib_dealloc(fibptr);
 	} else {
 		BUG();
@@ -778,13 +789,13 @@
 
 static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr)
 {
-	struct hw_fib * fib = fibptr->fib;
+	struct hw_fib * hw_fib = fibptr->hw_fib;
 	/*
 	 * Set the status of this FIB to be Invalid parameter.
 	 *
 	 *	*(u32 *)fib->data = ST_INVAL;
 	 */
-	*(u32 *)fib->data = cpu_to_le32(ST_OK);
+	*(u32 *)hw_fib->data = cpu_to_le32(ST_OK);
 	fib_adapter_complete(fibptr, sizeof(u32));
 }
 
@@ -800,7 +811,7 @@
  
 int aac_command_thread(struct aac_dev * dev)
 {
-	struct hw_fib *fib, *newfib;
+	struct hw_fib *hw_fib, *newfib;
 	struct fib fibptr; /* for error logging */
 	struct aac_queue_block *queues = dev->queues;
 	struct aac_fib_context *fibctx;
@@ -828,17 +839,18 @@
 	while(1) 
 	{
 		spin_lock_irqsave(queues->queue[HostNormCmdQueue].lock, flags);
-		while(!list_empty(&(queues->queue[HostNormCmdQueue].cmdq))) {
-			struct list_head *entry;
+		while(!aac_list_empty(&(queues->queue[HostNormCmdQueue].cmdq))) {
+			struct aac_list_head *entry;
 			struct aac_aifcmd * aifcmd;
 
 			set_current_state(TASK_RUNNING);
 		
-			entry = queues->queue[HostNormCmdQueue].cmdq.next;
-			list_del(entry);
+			entry = (struct aac_list_head*)(ulong)(queues->queue[HostNormCmdQueue].cmdq.next);
+			dprintk(("aacraid: Command thread: removing fib from cmdq (%p)\n",entry));
+			aac_list_del(entry);
 			
 			spin_unlock_irqrestore(queues->queue[HostNormCmdQueue].lock, flags);
-			fib = list_entry(entry, struct hw_fib, header.FibLinks);
+			hw_fib = aac_list_entry(entry, struct hw_fib, header.FibLinks);
 			/*
 			 *	We will process the FIB here or pass it to a 
 			 *	worker thread that is TBD. We Really can't 
@@ -848,16 +860,17 @@
 			memset(&fibptr, 0, sizeof(struct fib));
 			fibptr.type = FSAFS_NTC_FIB_CONTEXT;
 			fibptr.size = sizeof( struct fib );
-			fibptr.fib = fib;
-			fibptr.data = fib->data;
+			fibptr.hw_fib = hw_fib;
+			fibptr.data = hw_fib->data;
 			fibptr.dev = dev;
 			/*
 			 *	We only handle AifRequest fibs from the adapter.
 			 */
-			aifcmd = (struct aac_aifcmd *) fib->data;
+			aifcmd = (struct aac_aifcmd *) hw_fib->data;
 			if (aifcmd->command == le16_to_cpu(AifCmdDriverNotify)) {
 				aac_handle_aif(dev, &fibptr);
 			} else {
+				struct list_head *entry;
 				/* The u32 here is important and intended. We are using
 				   32bit wrapping time to fit the adapter field */
 				   
@@ -906,12 +919,12 @@
 						/*
 						 * Make the copy of the FIB
 						 */
-						memcpy(newfib, fib, sizeof(struct hw_fib));
+						memcpy(newfib, hw_fib, sizeof(struct hw_fib));
 						/*
 						 * Put the FIB onto the
 						 * fibctx's fibs
 						 */
-						list_add_tail(&newfib->header.FibLinks, &fibctx->fibs);
+						aac_list_add_tail(&newfib->header.FibLinks, &fibctx->hw_fib_list);
 						fibctx->count++;
 						/* 
 						 * Set the event to wake up the
@@ -926,7 +939,7 @@
 				/*
 				 *	Set the status of this FIB
 				 */
-				*(u32 *)fib->data = cpu_to_le32(ST_OK);
+				*(u32 *)hw_fib->data = cpu_to_le32(ST_OK);
 				fib_adapter_complete(&fibptr, sizeof(u32));
 				spin_unlock_irqrestore(&dev->fib_lock, flagv);
 			}
diff -urN linux-2.5.69-bk7/drivers/scsi/aacraid/dpcsup.c linux-2.5.69-bk8/drivers/scsi/aacraid/dpcsup.c
--- linux-2.5.69-bk7/drivers/scsi/aacraid/dpcsup.c	2003-05-04 16:53:14.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/aacraid/dpcsup.c	2003-05-13 04:44:28.000000000 -0700
@@ -65,7 +65,6 @@
 	unsigned long flags;
 
 	spin_lock_irqsave(q->lock, flags);	
-
 	/*
 	 *	Keep pulling response QEs off the response queue and waking
 	 *	up the waiters until there are no more QEs. We then return
@@ -74,12 +73,13 @@
 	 */
 	while(aac_consumer_get(dev, q, &entry))
 	{
-		int fast;
+		u32 fast ;
+		fast = (entry->addr & cpu_to_le32(0x01));
+		hwfib = (struct hw_fib *)((char *)dev->hw_fib_va + 
+				((entry->addr & ~0x01) - dev->hw_fib_pa));
+		fib = &dev->fibs[hwfib->header.SenderData];
 
-		fast = (int) (entry->addr & 0x01);
-		hwfib = addr2fib(entry->addr & ~0x01);
 		aac_consumer_free(dev, q, HostNormRespQueue);
-		fib = &dev->fibs[hwfib->header.SenderData];
 		/*
 		 *	Remove this fib from the Outstanding I/O queue.
 		 *	But only if it has not already been timed out.
@@ -93,6 +93,7 @@
 			dev->queues->queue[AdapNormCmdQueue].numpending--;
 		} else {
 			printk(KERN_WARNING "aacraid: FIB timeout (%x).\n", fib->flags);
+			printk(KERN_DEBUG"aacraid: hwfib=%p fib index=%i fib=%p\n",hwfib, hwfib->header.SenderData,fib);
 			continue;
 		}
 		spin_unlock_irqrestore(q->lock, flags);
@@ -171,11 +172,12 @@
 	 */
 	while(aac_consumer_get(dev, q, &entry))
 	{
-		struct hw_fib * fib;
-		fib = addr2fib(entry->addr);
+		struct hw_fib * hw_fib;
+		hw_fib = (struct hw_fib *)((char *)dev->hw_fib_va + 
+				((entry->addr & ~0x01) - dev->hw_fib_pa));
 
 		if (dev->aif_thread) {
-		        list_add_tail(&fib->header.FibLinks, &q->cmdq);
+		        aac_list_add_tail(&hw_fib->header.FibLinks, &q->cmdq);
 	 	        aac_consumer_free(dev, q, HostNormCmdQueue);
 		        wake_up_interruptible(&q->cmdready);
 		} else {
@@ -185,13 +187,13 @@
 			memset(&fibctx, 0, sizeof(struct fib));
 			fibctx.type = FSAFS_NTC_FIB_CONTEXT;
 			fibctx.size = sizeof(struct fib);
-			fibctx.fib = fib;
-			fibctx.data = fib->data;
+			fibctx.hw_fib = hw_fib;
+			fibctx.data = hw_fib->data;
 			fibctx.dev = dev;
 			/*
 			 *	Set the status of this FIB
 			 */
-			*(u32 *)fib->data = cpu_to_le32(ST_OK);
+			*(u32 *)hw_fib->data = cpu_to_le32(ST_OK);
 			fib_adapter_complete(&fibctx, sizeof(u32));
 			spin_lock_irqsave(q->lock, flags);
 		}		
diff -urN linux-2.5.69-bk7/drivers/scsi/aacraid/linit.c linux-2.5.69-bk8/drivers/scsi/aacraid/linit.c
--- linux-2.5.69-bk7/drivers/scsi/aacraid/linit.c	2003-05-04 16:53:13.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/aacraid/linit.c	2003-05-13 04:44:28.000000000 -0700
@@ -35,7 +35,7 @@
  *	
  */
 
-#define AAC_DRIVER_VERSION		"0.9.9ac6-TEST"
+#define AAC_DRIVER_VERSION		"1.1.2"
 #define AAC_DRIVER_BUILD_DATE		__DATE__
 
 #include <linux/module.h>
@@ -53,20 +53,23 @@
 #include <linux/blk.h>
 #include "scsi.h"
 #include "hosts.h"
-
 #include <scsi/scsicam.h>
 
 #include "aacraid.h"
 
+
 #define AAC_DRIVERNAME	"aacraid"
 
 MODULE_AUTHOR("Red Hat Inc and Adaptec");
-MODULE_DESCRIPTION("Supports Dell PERC2, 2/Si, 3/Si, 3/Di, PERC 320/DC, Adaptec 2120S, 2200S, 5400S, and HP NetRAID-4M devices. http://domsch.com/linux/ or http://linux.adaptec.com");
+MODULE_DESCRIPTION("Supports Dell PERC2, 2/Si, 3/Si, 3/Di, Adaptec Advanced Raid Products, and HP NetRAID-4M devices. http://domsch.com/linux/ or http://linux.adaptec.com");
 MODULE_LICENSE("GPL");
 MODULE_PARM(nondasd, "i");
 MODULE_PARM_DESC(nondasd, "Control scanning of hba for nondasd devices. 0=off, 1=on");
+MODULE_PARM(paemode, "i");
+MODULE_PARM_DESC(paemode, "Control whether dma addressing is using PAE. 0=off, 1=on");
 
-static int nondasd=-1;
+int nondasd=-1;
+int paemode=-1;
 
 struct aac_dev *aac_devices[MAXIMUM_NUM_ADAPTERS];
 
@@ -76,12 +79,12 @@
 /*
  * Because of the way Linux names scsi devices, the order in this table has
  * become important.  Check for on-board Raid first, add-in cards second.
- *
+ */
+/*
  * dmb - For now we add the number of channels to this structure.  
  * In the future we should add a fib that reports the number of channels
  * for the card.  At that time we can remove the channels from here
  */
- 
 static struct aac_driver_ident aac_drivers[] = {
 	{ 0x1028, 0x0001, 0x1028, 0x0001, aac_rx_init, "percraid", "DELL    ", "PERCRAID        ", 2 }, /* PERC 2/Si */
 	{ 0x1028, 0x0002, 0x1028, 0x0002, aac_rx_init, "percraid", "DELL    ", "PERCRAID        ", 2 }, /* PERC 3/Di */
@@ -97,11 +100,22 @@
 	{ 0x9005, 0x0285, 0x9005, 0x0286, aac_rx_init, "aacraid",  "ADAPTEC ", "Adaptec 2120S   ", 1 }, /* Adaptec 2120S (Crusader)*/
 	{ 0x9005, 0x0285, 0x9005, 0x0285, aac_rx_init, "aacraid",  "ADAPTEC ", "Adaptec 2200S   ", 2 }, /* Adaptec 2200S (Vulcan)*/
 	{ 0x9005, 0x0285, 0x9005, 0x0287, aac_rx_init, "aacraid",  "ADAPTEC ", "Adaptec 2200S   ", 2 }, /* Adaptec 2200S (Vulcan-2m)*/
-	{ 0x9005, 0x0285, 0x1028, 0x0287, aac_rx_init, "percraid", "DELL    ", "PERCRAID        ", 2 }, /* Dell PERC 320/DC */
+	{ 0x9005, 0x0285, 0x17aa, 0x0286, aac_rx_init, "aacraid",  "Legend  ", "Legend S220     ", 1 }, /* Legend S220*/
+	{ 0x9005, 0x0285, 0x17aa, 0x0287, aac_rx_init, "aacraid",  "Legend  ", "Legend S230     ", 2 }, /* Legend S230*/
+
+	{ 0x9005, 0x0285, 0x9005, 0x0288, aac_rx_init, "aacraid",  "ADAPTEC ", "Adaptec 3230S   ", 2 }, /* Adaptec 3230S (Harrier)*/
+	{ 0x9005, 0x0285, 0x9005, 0x0289, aac_rx_init, "aacraid",  "ADAPTEC ", "Adaptec 3240S   ", 2 }, /* Adaptec 3240S (Tornado)*/
+	{ 0x9005, 0x0285, 0x9005, 0x028a, aac_rx_init, "aacraid",  "ADAPTEC ", "ASR-2020S PCI-X ", 2 }, /* ASR-2020S PCI-X ZCR (Skyhawk)*/
+	{ 0x9005, 0x0285, 0x9005, 0x028b, aac_rx_init, "aacraid",  "ADAPTEC ", "ASR-2020S PCI-X ", 2 }, /* ASR-2020S SO-DIMM PCI-X ZCR(Terminator)*/
+	{ 0x9005, 0x0285, 0x9005, 0x0290, aac_rx_init, "aacraid",  "ADAPTEC ", "AAR-2410SA SATA ", 2 }, /* AAR-2410SA PCI SATA 4ch (Jaguar II)*/
+	{ 0x9005, 0x0250, 0x1014, 0x0279, aac_rx_init, "aacraid",  "ADAPTEC ", "Adaptec         ", 2 }, /* (Marco)*/
+	{ 0x9005, 0x0250, 0x1014, 0x028c, aac_rx_init, "aacraid",  "ADAPTEC ", "Adaptec         ", 2 }, /* (Sebring)*/
+
+	{ 0x9005, 0x0285, 0x1028, 0x0287, aac_rx_init, "percraid", "DELL    ", "PERC 320/DC     ", 2 }, /* Perc 320/DC*/
 	{ 0x1011, 0x0046, 0x9005, 0x0365, aac_sa_init, "aacraid",  "ADAPTEC ", "Adaptec 5400S   ", 4 }, /* Adaptec 5400S (Mustang)*/
 	{ 0x1011, 0x0046, 0x9005, 0x0364, aac_sa_init, "aacraid",  "ADAPTEC ", "AAC-364         ", 4 }, /* Adaptec 5400S (Mustang)*/
 	{ 0x1011, 0x0046, 0x9005, 0x1364, aac_sa_init, "percraid", "DELL    ", "PERCRAID        ", 4 }, /* Dell PERC2 "Quad Channel" */
-	{ 0x1011, 0x0046, 0x103c, 0x10c2, aac_sa_init, "hpnraid",  "HP      ", "NetRAID-4M      ", 4 }  /* HP NetRAID-4M */
+	{ 0x1011, 0x0046, 0x103c, 0x10c2, aac_sa_init, "hpnraid",  "HP      ", "NetRAID         ", 4 }  /* HP NetRAID-4M */
 };
 
 #define NUM_AACTYPES	(sizeof(aac_drivers) / sizeof(struct aac_driver_ident))
@@ -122,7 +136,7 @@
 static int aac_release(struct Scsi_Host *);
 static int aac_queuecommand(Scsi_Cmnd *, void (*CompletionRoutine)(Scsi_Cmnd *));
 static int aac_biosparm(struct scsi_device *, struct block_device *,
-		sector_t, int *);
+			sector_t, int *);
 static int aac_procinfo(char *, char **, off_t, int, int, int);
 static int aac_ioctl(Scsi_Device *, int, void *);
 static int aac_eh_abort(Scsi_Cmnd * cmd);
@@ -130,7 +144,7 @@
 static int aac_eh_bus_reset(Scsi_Cmnd* cmd);
 static int aac_eh_reset(Scsi_Cmnd* cmd);
 
-static int aac_slave_configure(Scsi_Device *);
+static int aac_slave_configure(struct scsi_device *);
 
 /**
  *	aac_detect	-	Probe for aacraid cards
@@ -162,13 +176,12 @@
 	struct fsa_scsi_hba *fsa_dev_ptr;
 	char *name = NULL;
 	
-	printk(KERN_INFO "Red Hat/Adaptec aacraid driver, %s\n", AAC_DRIVER_BUILD_DATE);
+	printk(KERN_INFO "Red Hat/Adaptec aacraid driver (%s %s)\n", AAC_DRIVER_VERSION, AAC_DRIVER_BUILD_DATE);
 
 	/* setting up the proc directory structure */
 	template->proc_name = "aacraid";
 
-	for( index = 0; index != num_aacdrivers; index++ )
-	{
+	for( index = 0; index != num_aacdrivers; index++ ) {
 		device_id = aac_drivers[index].device;
 		vendor_id = aac_drivers[index].vendor;
 		name = aac_drivers[index].name;
@@ -206,16 +219,10 @@
 			 * specific information.
 			 */
 			host_ptr = scsi_register( template, sizeof(struct aac_dev) );
-			if(host_ptr == NULL)
-				continue;
-
 			/* 
 			 * These three parameters can be used to allow for wide SCSI 
 			 * and for host adapters that support multiple buses.
 			 */
-			host_ptr->max_id = 17;
-			host_ptr->max_lun = 8;
-			host_ptr->max_channel = 1;
 			host_ptr->irq = dev->irq;		/* Adapter IRQ number */
 			/* host_ptr->base = ( char * )(dev->resource[0].start & ~0xff); */
 			host_ptr->base = dev->resource[0].start;
@@ -236,9 +243,13 @@
 			/* attach a pointer back to Scsi_Host */
 			aac->scsi_host_ptr = host_ptr;	
 			aac->pdev = dev;
-			aac->cardtype =  index;
 			aac->name = aac->scsi_host_ptr->hostt->name;
 			aac->id = aac->scsi_host_ptr->unique_id;
+			aac->cardtype =  index;
+
+			aac->fibs = (struct fib*) kmalloc(sizeof(struct fib)*AAC_NUM_FIB, GFP_KERNEL);
+			spin_lock_init(&aac->fib_lock);
+
 			/* Initialize the ordinal number of the device to -1 */
 			fsa_dev_ptr = &(aac->fsa_dev);
 			for( container = 0; container < MAXIMUM_NUM_CONTAINERS; container++ )
@@ -255,46 +266,28 @@
 			} 
 			dprintk((KERN_DEBUG "%s:%d device initialization successful.\n", name, host_ptr->unique_id));
 			aac_get_adapter_info(aac);
-			if(nondasd != -1) 
-			{
-				/* someone told us how to set this on the cmdline */
-				aac->nondasd_support = (nondasd!=0);
-			}
-			if(aac->nondasd_support != 0){
-				printk(KERN_INFO "%s%d: Non-DASD support enabled\n", aac->name, aac->id);
-			}
-			dprintk((KERN_DEBUG "%s:%d options flag %04x.\n",name, host_ptr->unique_id,aac->adapter_info.options));
-			if(aac->nondasd_support == 1)
-			{
-				/*
-				 * max channel will be the physical channels plus 1 virtual channel 
-				 * all containers are on the virtual channel 0
-				 * physical channels are address by their actual physical number+1
-				 */
+			if(aac->nondasd_support == 1){
+			/*
+			 * max channel will be the physical channels plus 1 virtual channel 
+			 * all containers are on the virtual channel 0
+			 * physical channels are address by their actual physical number+1
+			 */
 				host_ptr->max_channel = aac_drivers[index].channels+1;
 			} else {
 				host_ptr->max_channel = 1;
- 			}
-			dprintk((KERN_DEBUG "Device has %d logical channels\n", host_ptr->max_channel));
+			}
+			dprintk((KERN_DEBUG "Device has %d logical channels\n",host_ptr->max_channel));
 			aac_get_containers(aac);
 			aac_devices[aac_count-1] = aac;
+//			spin_unlock_irqrestore(&aac->fib_lock, flags);
 
 			/*
-			 * dmb - we may need to move these 3 parms somewhere else once
+			 * dmb - we may need to move the setting of these parms somewhere else once
 			 * we get a fib that can report the actual numbers
 			 */
 			host_ptr->max_id = AAC_MAX_TARGET;
 			host_ptr->max_lun = AAC_MAX_LUN;
-			
-			/*
-			 *  If we are PAE capable then our future DMA mappings
-			 *  (for read/write commands) are 64bit clean and don't 
-			 *  need bouncing. This assumes we do no other 32bit only
-			 *  allocations (eg fib table expands) after this point.
-			 */
-			 
-			if(aac->pae_support)
-				pci_set_dma_mask(dev, 0xFFFFFFFFFFFFFFFFUL);
+
 		}
 	}
 
@@ -356,17 +349,19 @@
  *	Queues a command for execution by the associated Host Adapter.
  */ 
 
-static int aac_queuecommand(Scsi_Cmnd *scsi_cmnd_ptr, void (*complete)(Scsi_Cmnd *))
+static int aac_queuecommand(Scsi_Cmnd *scsi_cmnd_ptr, void (*CompletionRoutine)(Scsi_Cmnd *))
 {
 	int ret;
 
-	scsi_cmnd_ptr->scsi_done = complete;
+	scsi_cmnd_ptr->scsi_done = CompletionRoutine;
 	/*
 	 *	aac_scsi_cmd() handles command processing, setting the 
 	 *	result code and calling completion routine. 
 	 */
-	if((ret = aac_scsi_cmd(scsi_cmnd_ptr)) != 0)
+	if((ret = aac_scsi_cmd(scsi_cmnd_ptr)) != 0){
 		dprintk((KERN_DEBUG "aac_scsi_cmd failed.\n"));
+		return FAILED;
+	}
 	return ret;
 } 
 
@@ -396,8 +391,9 @@
 
 /**
  *	aac_biosparm	-	return BIOS parameters for disk
- *	@disk: SCSI disk object to process
- *	@device: Disk in question
+ *	@sdev: The scsi device corresponding to the disk
+ *	@bdev: the block device corresponding to the disk
+ *	@capacity: the sector capacity of the disk
  *	@geom: geometry block to fill in
  *
  *	Return the Heads/Sectors/Cylinders BIOS Disk Parameters for Disk.  
@@ -416,10 +412,10 @@
  */
  
 static int aac_biosparm(struct scsi_device *sdev, struct block_device *bdev,
-		sector_t capacity, int *geom)
+			sector_t capacity, int *geom)
 {
 	struct diskparm *param = (struct diskparm *)geom;
-	u8 *buf;
+	unsigned char *buf;
 
 	dprintk((KERN_DEBUG "aac_biosparm.\n"));
 
@@ -445,15 +441,14 @@
 		param->sectors = 32;
 	}
 
-	param->cylinders = cap_to_cyls(capacity,
-			(param->heads * param->sectors));
+	param->cylinders = cap_to_cyls(capacity, param->heads * param->sectors);
 
 	/*
-	 *	Read the partition table block
+	 *	Read the first 1024 bytes from the disk device
 	 */
 
 	buf = scsi_bios_ptable(bdev);
-	
+
 	/* 
 	 *	If the boot sector partition table is valid, search for a partition 
 	 *	table entry whose end_head matches one of the standard geometry 
@@ -462,7 +457,7 @@
 	 
 	if(*(unsigned short *)(buf + 0x40) == cpu_to_le16(0xaa55))
 	{
-		struct partition *first = (struct partition *)buf;
+		struct partition *first = (struct partition * )buf;
 		struct partition *entry = first;
 		int saved_cylinders = param->cylinders;
 		int num;
@@ -500,8 +495,7 @@
 			end_sec = first->end_sector & 0x3f;
 		}
 
-		param->cylinders = cap_to_cyls(capacity,
-				(param->heads * param->sectors));
+		param->cylinders = cap_to_cyls(capacity, param->heads * param->sectors);
 
 		if(num < 4 && end_sec == param->sectors)
 		{
@@ -522,15 +516,17 @@
 }
 
 /**
- *	aac_slave_configure	-	do device specific setup
- *	@dev:	SCSI device we are attaching
+ *	aac_queuedepth		-	compute queue depths
+ *	@host:	SCSI host in question
+ *	@dev:	SCSI device we are considering
  *
- * 	Currently, all we do is set the queue depth on the device.
+ *	Selects queue depths for each target device based on the host adapter's
+ *	total capacity and the queue depth supported by the target device.
+ *	A queue depth of one automatically disables tagged queueing.
  */
 
-static int aac_slave_configure(Scsi_Device * dev )
+static int aac_slave_configure(struct scsi_device * dev )
 {
-
 	if(dev->tagged_supported)
 		scsi_adjust_queue_depth(dev, MSG_ORDERED_TAG, 128);
 	else
@@ -543,75 +539,13 @@
 	return 0;
 }
 
+/*------------------------------------------------------------------------------
+	aac_ioctl()
 
-/**
- *	aac_eh_abort	-	Abort command if possible.
- *	@cmd:	SCSI command block to abort
- *
- *	Called when the midlayer wishes to abort a command. We don't support
- *	this facility, and our firmware looks after life for us. We just
- *	report this as failing
- */
- 
-static int aac_eh_abort(Scsi_Cmnd *cmd)
-{
-	return FAILED;
-}
-
-/**
- *	aac_eh_device_reset	-	Reset command handling
- *	@cmd:	SCSI command block causing the reset
- *
- *	Issue a reset of a SCSI device. We are ourselves not truely a SCSI
- *	controller and our firmware will do the work for us anyway. Thus this
- *	is a no-op. We just return FAILED.
- */
-
-static int aac_eh_device_reset(Scsi_Cmnd *cmd)
-{
-	return FAILED;
-}
-
-/**
- *	aac_eh_bus_reset	-	Reset command handling
- *	@scsi_cmd:	SCSI command block causing the reset
- *
- *	Issue a reset of a SCSI bus. We are ourselves not truely a SCSI
- *	controller and our firmware will do the work for us anyway. Thus this
- *	is a no-op. We just return FAILED.
- */
-
-static int aac_eh_bus_reset(Scsi_Cmnd* cmd)
-{
-	return FAILED;
-}
-
-/**
- *	aac_eh_hba_reset	-	Reset command handling
- *	@scsi_cmd:	SCSI command block causing the reset
- *
- *	Issue a reset of a SCSI host. If things get this bad then arguably we should
- *	go take a look at what the host adapter is doing and see if something really
- *	broke (as can occur at least on my Dell QC card if a drive keeps failing spinup)
- */
-
-static int aac_eh_reset(Scsi_Cmnd* cmd)
-{
-	printk(KERN_ERR "aacraid: Host adapter reset request. SCSI hang ?\n");
-	return FAILED;
-}
-
-/**
- *	aac_ioctl 	-	Handle SCSI ioctls
- *	@scsi_dev_ptr: scsi device to operate upon
- *	@cmd: ioctl command to use issue
- *	@arg: ioctl data pointer
- *
- *	Issue an ioctl on an aacraid device. Returns a standard unix error code or
- *	zero for success
- */
- 
+		Handle SCSI ioctls
+ *----------------------------------------------------------------------------*/
 static int aac_ioctl(Scsi_Device * scsi_dev_ptr, int cmd, void * arg)
+/*----------------------------------------------------------------------------*/
 {
 	struct aac_dev *dev;
 	dprintk((KERN_DEBUG "aac_ioctl.\n"));
@@ -694,14 +628,59 @@
 	.this_id        		= 16,
 	.sg_tablesize   		= 16,
 	.max_sectors    		= 128,
-	.cmd_per_lun    		= 1,
-	.eh_abort_handler       	= aac_eh_abort,
-	.eh_device_reset_handler 	= aac_eh_device_reset,
+	.cmd_per_lun    		= AAC_NUM_IO_FIB, 
+	.eh_abort_handler		= aac_eh_abort,
+	.eh_device_reset_handler	= aac_eh_device_reset,
 	.eh_bus_reset_handler		= aac_eh_bus_reset,
 	.eh_host_reset_handler		= aac_eh_reset,
 	.use_clustering			= ENABLE_CLUSTERING,
 };
 
+/*===========================================================================
+ * Error Handling routines
+ *===========================================================================
+ */
+
+
+/*
+ *
+ * We don't support abortting commands.
+ */
+static int aac_eh_abort(Scsi_Cmnd * scsicmd)
+{
+	printk("aacraid: abort failed\n");
+	return FAILED;
+}
+
+/*
+ * We don't support device resets.
+ */
+static int aac_eh_device_reset(Scsi_Cmnd* cmd)
+{
+	printk("aacraid: device reset failed\n");
+	return FAILED;
+}
+
+
+static int aac_eh_bus_reset(Scsi_Cmnd* cmd)
+{
+	printk("aacraid: bus reset failed\n");
+	return FAILED;
+}
+
+static int aac_eh_reset(Scsi_Cmnd* cmd)
+{
+	printk("aacraid: hba reset failed\n");
+	return FAILED;
+}
+
+
+/*===========================================================================
+ * 
+ *===========================================================================
+ */
+
+
 #include "scsi_module.c"
 
 /**
diff -urN linux-2.5.69-bk7/drivers/scsi/aacraid/sa.c linux-2.5.69-bk8/drivers/scsi/aacraid/sa.c
--- linux-2.5.69-bk7/drivers/scsi/aacraid/sa.c	2003-05-04 16:53:32.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/aacraid/sa.c	2003-05-13 04:44:28.000000000 -0700
@@ -352,7 +352,7 @@
 	 *	Wait for the adapter to be up and running. Wait up to 3 minutes.
 	 */
 	while (!(sa_readl(dev, Mailbox7) & KERNEL_UP_AND_RUNNING)) {
-		if (time_after(start+180*HZ, jiffies)) {
+		if (time_after(jiffies, start+180*HZ)) {
 			status = sa_readl(dev, Mailbox7) >> 16;
 			printk(KERN_WARNING "%s%d: adapter kernel failed to start, init status = %d.\n", name, instance, le32_to_cpu(status));
 			return -1;
diff -urN linux-2.5.69-bk7/drivers/scsi/advansys.c linux-2.5.69-bk8/drivers/scsi/advansys.c
--- linux-2.5.69-bk7/drivers/scsi/advansys.c	2003-05-04 16:53:08.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/advansys.c	2003-05-13 04:44:28.000000000 -0700
@@ -4303,7 +4303,6 @@
     int                 leftlen;
     char                *curbuf;
     off_t               advoffset;
-    Scsi_Device         *scd;
 #ifdef ADVANSYS_STATS
     int                 tgt_id;
 #endif /* ADVANSYS_STATS */
@@ -6198,13 +6197,33 @@
  * --- Loadable Driver Support
  */
 
-#if ASC_LINUX_KERNEL24
-static
-#endif
-#if ASC_LINUX_KERNEL24 || (ASC_LINUX_KERNEL22 && defined(MODULE))
-Scsi_Host_Template driver_template = ADVANSYS;
-# include "scsi_module.c"
-#endif
+static Scsi_Host_Template driver_template = {
+    .proc_name                  = "advansys",
+    .proc_info                  = advansys_proc_info,
+    .name                       = "advansys",
+    .detect                     = advansys_detect, 
+    .release                    = advansys_release,
+    .info                       = advansys_info,
+    .queuecommand               = advansys_queuecommand,
+    .eh_bus_reset_handler	= advansys_reset,
+    .bios_param                 = advansys_biosparam,
+    .slave_configure		= advansys_slave_configure,
+    /*
+     * Because the driver may control an ISA adapter 'unchecked_isa_dma'
+     * must be set. The flag will be cleared in advansys_detect for non-ISA
+     * adapters. Refer to the comment in scsi_module.c for more information.
+     */
+    .unchecked_isa_dma          = 1,
+    /*
+     * All adapters controlled by this driver are capable of large
+     * scatter-gather lists. According to the mid-level SCSI documentation
+     * this obviates any performance gain provided by setting
+     * 'use_clustering'. But empirically while CPU utilization is increased
+     * by enabling clustering, I/O throughput increases as well.
+     */
+    .use_clustering             = ENABLE_CLUSTERING,
+};
+#include "scsi_module.c"
 
 
 /*
diff -urN linux-2.5.69-bk7/drivers/scsi/advansys.h linux-2.5.69-bk8/drivers/scsi/advansys.h
--- linux-2.5.69-bk7/drivers/scsi/advansys.h	2003-05-04 16:53:56.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/advansys.h	2003-05-13 04:44:28.000000000 -0700
@@ -67,61 +67,4 @@
 /* init/main.c setup function */
 void advansys_setup(char *, int *);
 
-/*
- * AdvanSys Host Driver Scsi_Host_Template (struct SHT) from hosts.h.
- */
-#if ASC_LINUX_KERNEL24
-#define ADVANSYS { \
-    .proc_name                  = "advansys", \
-    .proc_info                  = advansys_proc_info, \
-    .name                       = "advansys", \
-    .detect                     = advansys_detect, \
-    .release                    = advansys_release, \
-    .info                       = advansys_info, \
-    .queuecommand               = advansys_queuecommand, \
-    .eh_bus_reset_handler	= advansys_reset, \
-    .bios_param                 = advansys_biosparam, \
-    .slave_configure		= advansys_slave_configure, \
-    /* \
-     * Because the driver may control an ISA adapter 'unchecked_isa_dma' \
-     * must be set. The flag will be cleared in advansys_detect for non-ISA \
-     * adapters. Refer to the comment in scsi_module.c for more information. \
-     */ \
-    .unchecked_isa_dma          = 1, \
-    /* \
-     * All adapters controlled by this driver are capable of large \
-     * scatter-gather lists. According to the mid-level SCSI documentation \
-     * this obviates any performance gain provided by setting \
-     * 'use_clustering'. But empirically while CPU utilization is increased \
-     * by enabling clustering, I/O throughput increases as well. \
-     */ \
-    .use_clustering             = ENABLE_CLUSTERING, \
-}
-#elif ASC_LINUX_KERNEL22
-#define ADVANSYS { \
-    .proc_info                  = advansys_proc_info, \
-    .name                       = "advansys", \
-    .detect                     = advansys_detect, \
-    .release                    = advansys_release, \
-    .info                       = advansys_info, \
-    .queuecommand               = advansys_queuecommand, \
-    .use_new_eh_code		= 1, \
-    .eh_bus_reset_handler	= advansys_reset, \
-    .bios_param                 = advansys_biosparam, \
-    /* \
-     * Because the driver may control an ISA adapter 'unchecked_isa_dma' \
-     * must be set. The flag will be cleared in advansys_detect for non-ISA \
-     * adapters. Refer to the comment in scsi_module.c for more information. \
-     */ \
-    .unchecked_isa_dma          = 1, \
-    /* \
-     * All adapters controlled by this driver are capable of large \
-     * scatter-gather lists. According to the mid-level SCSI documentation \
-     * this obviates any performance gain provided by setting \
-     * 'use_clustering'. But empirically while CPU utilization is increased \
-     * by enabling clustering, I/O throughput increases as well. \
-     */ \
-    .use_clustering             = ENABLE_CLUSTERING, \
-}
-#endif
 #endif /* _ADVANSYS_H */
diff -urN linux-2.5.69-bk7/drivers/scsi/aha1542.c linux-2.5.69-bk8/drivers/scsi/aha1542.c
--- linux-2.5.69-bk7/drivers/scsi/aha1542.c	2003-05-04 16:53:31.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/aha1542.c	2003-05-13 04:44:28.000000000 -0700
@@ -67,7 +67,7 @@
 		       int nseg,
 		       int badseg)
 {
-	printk(KERN_CRIT "sgpnt[%d:%d] page %p/0x%x length %d\n",
+	printk(KERN_CRIT "sgpnt[%d:%d] page %p/0x%x length %ld\n",
 	       badseg, nseg,
 	       page_address(sgpnt[badseg].page) + sgpnt[badseg].offset,
 	       SCSI_SG_PA(&sgpnt[badseg]),
@@ -1813,7 +1813,22 @@
 MODULE_LICENSE("GPL");
 
 
-/* Eventually this will go into an include file, but this will be later */
-static Scsi_Host_Template driver_template = AHA1542;
-
+static Scsi_Host_Template driver_template = {
+	.proc_name		= "aha1542",
+	.name			= "Adaptec 1542",
+	.detect			= aha1542_detect,
+	.command		= aha1542_command,
+	.queuecommand		= aha1542_queuecommand,
+	.eh_abort_handler	= aha1542_abort,
+	.eh_device_reset_handler= aha1542_dev_reset,
+	.eh_bus_reset_handler	= aha1542_bus_reset,
+	.eh_host_reset_handler	= aha1542_host_reset,
+	.bios_param		= aha1542_biosparam,
+	.can_queue		= AHA1542_MAILBOXES, 
+	.this_id		= 7,
+	.sg_tablesize		= AHA1542_SCATTER,
+	.cmd_per_lun		= AHA1542_CMDLUN,
+	.unchecked_isa_dma	= 1, 
+	.use_clustering		= ENABLE_CLUSTERING,
+};
 #include "scsi_module.c"
diff -urN linux-2.5.69-bk7/drivers/scsi/aha1542.h linux-2.5.69-bk8/drivers/scsi/aha1542.h
--- linux-2.5.69-bk7/drivers/scsi/aha1542.h	2003-05-04 16:53:35.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/aha1542.h	2003-05-13 04:44:28.000000000 -0700
@@ -151,21 +151,4 @@
 	#define NULL 0
 #endif
 
-#define AHA1542 {    .proc_name			= "aha1542",		\
-		     .name			= "Adaptec 1542", 	\
-		     .detect			= aha1542_detect,		\
-		     .command			= aha1542_command,	\
-		     .queuecommand		= aha1542_queuecommand,	\
-		     .eh_abort_handler		= aha1542_abort,		\
-		     .eh_device_reset_handler	= aha1542_dev_reset,	\
-		     .eh_bus_reset_handler	= aha1542_bus_reset,	\
-		     .eh_host_reset_handler	= aha1542_host_reset,	\
-		     .bios_param		= aha1542_biosparam,      \
-		     .can_queue			= AHA1542_MAILBOXES, 	\
-		     .this_id			= 7, 			\
-		     .sg_tablesize		= AHA1542_SCATTER, 	\
-		     .cmd_per_lun		= AHA1542_CMDLUN, 	\
-		     .unchecked_isa_dma		= 1, 			\
-		     .use_clustering		= ENABLE_CLUSTERING	\
-}
 #endif
diff -urN linux-2.5.69-bk7/drivers/scsi/aha1740.c linux-2.5.69-bk8/drivers/scsi/aha1740.c
--- linux-2.5.69-bk7/drivers/scsi/aha1740.c	2003-05-04 16:53:08.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/aha1740.c	2003-05-13 04:44:28.000000000 -0700
@@ -598,9 +598,20 @@
 
 MODULE_LICENSE("GPL");
 
-/* Eventually this will go into an include file, but this will be later */
-static Scsi_Host_Template driver_template = AHA1740;
-
+static Scsi_Host_Template driver_template = {
+	.proc_name		= "aha1740",
+	.proc_info		= aha1740_proc_info,
+	.name			= "Adaptec 174x (EISA)",
+	.detect			= aha1740_detect,
+	.command		= aha1740_command,
+	.queuecommand		= aha1740_queuecommand,
+	.bios_param		= aha1740_biosparam,
+	.can_queue		= AHA1740_ECBS,
+	.this_id		= 7, 
+	.sg_tablesize		= AHA1740_SCATTER,
+	.cmd_per_lun		= AHA1740_CMDLUN, 
+	.use_clustering		= ENABLE_CLUSTERING,
+};
 #include "scsi_module.c"
 
 /* Okay, you made it all the way through.  As of this writing, 3/31/93, I'm
diff -urN linux-2.5.69-bk7/drivers/scsi/aha1740.h linux-2.5.69-bk8/drivers/scsi/aha1740.h
--- linux-2.5.69-bk7/drivers/scsi/aha1740.h	2003-05-04 16:53:32.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/aha1740.h	2003-05-13 04:44:28.000000000 -0700
@@ -162,17 +162,4 @@
 #define AHA1740_SCATTER 16
 #define AHA1740_CMDLUN 1
 
-#define AHA1740 {  .proc_name      = "aha1740",				\
-		   .proc_info      = aha1740_proc_info,	                \
-		   .name           = "Adaptec 174x (EISA)",		\
-		   .detect         = aha1740_detect,			\
-		   .command        = aha1740_command,			\
-		   .queuecommand   = aha1740_queuecommand,		\
-		   .bios_param     = aha1740_biosparam,                   \
-		   .can_queue      = AHA1740_ECBS, 			\
-		   .this_id        = 7, 					\
-		   .sg_tablesize   = AHA1740_SCATTER, 			\
-		   .cmd_per_lun    = AHA1740_CMDLUN, 			\
-		   .use_clustering = ENABLE_CLUSTERING}
-
 #endif
diff -urN linux-2.5.69-bk7/drivers/scsi/aic7xxx/Makefile linux-2.5.69-bk8/drivers/scsi/aic7xxx/Makefile
--- linux-2.5.69-bk7/drivers/scsi/aic7xxx/Makefile	2003-05-04 16:53:56.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/aic7xxx/Makefile	2003-05-13 04:44:28.000000000 -0700
@@ -1,7 +1,7 @@
 #
 # Makefile for the Linux aic7xxx SCSI driver.
 #
-# $Id: //depot/linux-aic79xx-2.5.0/drivers/scsi/aic7xxx/Makefile#5 $
+# $Id: //depot/linux-aic79xx-2.5.0/drivers/scsi/aic7xxx/Makefile#6 $
 #
 
 # Let kbuild descend into aicasm when cleaning
@@ -33,7 +33,7 @@
 						   aic79xx_proc.o	\
 						   aic79xx_osm_pci.o
 
-EXTRA_CFLAGS += -Idrivers/scsi
+EXTRA_CFLAGS += -Idrivers/scsi -Werror
 #EXTRA_CFLAGS += -g
 
 # Files generated that shall be removed upon make clean
diff -urN linux-2.5.69-bk7/drivers/scsi/aic7xxx/aic7770.c linux-2.5.69-bk8/drivers/scsi/aic7xxx/aic7770.c
--- linux-2.5.69-bk7/drivers/scsi/aic7xxx/aic7770.c	2003-05-04 16:53:57.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/aic7xxx/aic7770.c	2003-05-13 04:44:28.000000000 -0700
@@ -37,7 +37,7 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  *
- * $Id: //depot/aic7xxx/aic7xxx/aic7770.c#29 $
+ * $Id: //depot/aic7xxx/aic7xxx/aic7770.c#30 $
  *
  * $FreeBSD$
  */
@@ -314,7 +314,7 @@
 	if (bootverbose)
 		printf("%s: Reading SEEPROM...", ahc_name(ahc));
 	have_seeprom = ahc_read_seeprom(&sd, (uint16_t *)sc,
-					/*start_addr*/0, sizeof(sc)/2);
+					/*start_addr*/0, sizeof(*sc)/2);
 
 	if (have_seeprom) {
 
diff -urN linux-2.5.69-bk7/drivers/scsi/aic7xxx/aic79xx.h linux-2.5.69-bk8/drivers/scsi/aic7xxx/aic79xx.h
--- linux-2.5.69-bk7/drivers/scsi/aic7xxx/aic79xx.h	2003-05-04 16:53:35.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/aic7xxx/aic79xx.h	2003-05-13 04:44:29.000000000 -0700
@@ -37,7 +37,7 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  *
- * $Id: //depot/aic7xxx/aic7xxx/aic79xx.h#88 $
+ * $Id: //depot/aic7xxx/aic7xxx/aic79xx.h#89 $
  *
  * $FreeBSD$
  */
@@ -494,13 +494,11 @@
  *	  transfer.
  */ 
 #define SG_PTR_MASK	0xFFFFFFF8
-/*16*/	uint16_t tag;
-/*18*/	uint8_t  cdb_len;
-/*19*/	uint8_t  task_management;
-/*20*/	uint32_t next_hscb_busaddr;
-/*24*/	uint64_t dataptr;
-/*32*/	uint32_t datacnt;	/* Byte 3 is spare. */
-/*36*/	uint32_t sgptr;
+/*16*/	uint64_t dataptr;
+/*24*/	uint32_t datacnt;	/* Byte 3 is spare. */
+/*28*/	uint32_t sgptr;
+/*32*/	uint32_t hscb_busaddr;
+/*36*/	uint32_t next_hscb_busaddr;
 /*40*/	uint8_t  control;	/* See SCB_CONTROL in aic79xx.reg for details */
 /*41*/	uint8_t	 scsiid;	/*
 				 * Selection out Id
@@ -508,8 +506,10 @@
 				 */
 /*42*/	uint8_t  lun;
 /*43*/	uint8_t  task_attribute;
-/*44*/	uint32_t hscb_busaddr;
-/******* Long lun field only downloaded for full 8 byte lun support *******/
+/*44*/	uint8_t  cdb_len;
+/*45*/	uint8_t  task_management;
+/*46*/	uint16_t tag;		/* Reused by Sequencer. */
+/********** Long lun field only downloaded for full 8 byte lun support ********/
 /*48*/  uint8_t	 pkt_long_lun[8];
 /******* Fields below are not Downloaded (Sequencer may use for scratch) ******/
 /*56*/  uint8_t	 spare[8];
diff -urN linux-2.5.69-bk7/drivers/scsi/aic7xxx/aic79xx.reg linux-2.5.69-bk8/drivers/scsi/aic7xxx/aic79xx.reg
--- linux-2.5.69-bk7/drivers/scsi/aic7xxx/aic79xx.reg	2003-05-04 16:53:41.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/aic7xxx/aic79xx.reg	2003-05-13 04:44:29.000000000 -0700
@@ -39,7 +39,7 @@
  *
  * $FreeBSD$
  */
-VERSION = "$Id: //depot/aic7xxx/aic7xxx/aic79xx.reg#65 $"
+VERSION = "$Id: //depot/aic7xxx/aic7xxx/aic79xx.reg#67 $"
 
 /*
  * This file is processed by the aic7xxx_asm utility for use in assembling
@@ -194,7 +194,8 @@
 		TRACEPOINT1,
 		TRACEPOINT2,
 		TRACEPOINT3,
-		SAW_HWERR
+		SAW_HWERR,
+		BAD_SCB_STATUS
 	}
 }
 
@@ -3484,9 +3485,6 @@
 	LONGJMP_ADDR {
 		size		2
 	}
-	LONGJMP_SCB {
-		size		2
-	}
 	ACCUM_SAVE {
 		size		1
 	}
@@ -3799,23 +3797,6 @@
 		size	4
 		alias	SCB_NEXT_COMPLETE
 	}
-	SCB_TAG {
-		size	2
-	}
-	SCB_CDB_LEN {
-		size	1
-		field	SCB_CDB_LEN_PTR	0x80	/* CDB in host memory */
-	}
-	SCB_TASK_MANAGEMENT {
-		size	1
-	}
-	SCB_NEXT {
-		alias	SCB_NEXT_SCB_BUSADDR
-		size	2
-	}
-	SCB_NEXT2 {
-		size	2
-	}
 	SCB_DATAPTR {
 		size	8
 	}
@@ -3834,6 +3815,16 @@
 		field	SG_FULL_RESID	0x02	/* In the first byte */
 		field	SG_LIST_NULL	0x01	/* In the first byte */
 	}
+	SCB_BUSADDR {
+		size	4
+	}
+	SCB_NEXT {
+		alias	SCB_NEXT_SCB_BUSADDR
+		size	2
+	}
+	SCB_NEXT2 {
+		size	2
+	}
 	SCB_CONTROL {
 		size	1
 		field	TARGET_SCB	0x80
@@ -3856,8 +3847,16 @@
 	SCB_TASK_ATTRIBUTE {
 		size	1
 	}
-	SCB_BUSADDR {
-		size	4
+	SCB_CDB_LEN {
+		size	1
+		field	SCB_CDB_LEN_PTR	0x80	/* CDB in host memory */
+	}
+	SCB_TASK_MANAGEMENT {
+		size	1
+	}
+	SCB_TAG {
+		alias	SCB_FIFO_USE_COUNT
+		size	2
 	}
 	SCB_SPARE {
 		size	8
diff -urN linux-2.5.69-bk7/drivers/scsi/aic7xxx/aic79xx.seq linux-2.5.69-bk8/drivers/scsi/aic7xxx/aic79xx.seq
--- linux-2.5.69-bk7/drivers/scsi/aic7xxx/aic79xx.seq	2003-05-04 16:53:40.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/aic7xxx/aic79xx.seq	2003-05-13 04:44:29.000000000 -0700
@@ -40,7 +40,7 @@
  * $FreeBSD$
  */
 
-VERSION = "$Id: //depot/aic7xxx/aic7xxx/aic79xx.seq#89 $"
+VERSION = "$Id: //depot/aic7xxx/aic7xxx/aic79xx.seq#91 $"
 PATCH_ARG_LIST = "struct ahd_softc *ahd"
 PREFIX = "ahd_"
 
@@ -108,8 +108,8 @@
 	test	LQISTAT2, LQIGSAVAIL jz return;
 	/*
 	 * We have received good status for this transaction.  There may
-	 * still be data in our FIFOs draining to the host.  Setup
-	 * monitoring of the draining process or complete the SCB.
+	 * still be data in our FIFOs draining to the host.  Complete
+	 * the SCB only if all data has transferred to the host.
 	 */
 good_status_IU_done:
 	bmov	SCBPTR, GSFIFO, 2;
@@ -135,42 +135,20 @@
 	 * 1) Configured and draining to the host, with a FIFO handler.
 	 * 2) Pending cfg4data, fifo not empty.
 	 *
-	 * Case 1 can be detected by noticing that a longjmp is active for
-	 * the FIFO and LONGJMP_SCB matches our SCB.  In this case, we allow
-	 * the routine servicing the FIFO to complete the SCB.
+	 * Case 1 can be detected by noticing a non-zero FIFO active
+	 * count in the SCB.  In this case, we allow the routine servicing
+	 * the FIFO to complete the SCB.
 	 * 
 	 * Case 2 implies either a pending or yet to occur save data
 	 * pointers for this same context in the other FIFO.  So, if
 	 * we detect case 1, we will properly defer the post of the SCB
 	 * and achieve the desired result.  The pending cfg4data will
 	 * notice that status has been received and complete the SCB.
-	 *
-	 * If the data-transfer has been completed, or no data transfer
-	 * was needed for this SCB, it is safe to complete the command.
-	 */
-	test	SCB_SGPTR, SG_LIST_NULL jz good_status_check_fifos;
-	/*
-	 * All segments have been loaded (or no data transfer), so
-	 * it is safe to complete the command.  Since this was a
-	 * cheap command to check for completion, loop to see if
-	 * more entries can be removed from the GSFIFO.
 	 */
+	test	SCB_FIFO_USE_COUNT, 0xFF jnz idle_loop_gsfifo_in_scsi_mode;
 	call	complete;
 END_CRITICAL;
 	jmp	idle_loop_gsfifo_in_scsi_mode;
-BEGIN_CRITICAL;
-good_status_check_fifos:
-	clc;
-	bmov	ARG_1, SCBPTR, 2;
-	SET_MODE(M_DFF0, M_DFF0)
-	call	check_fifo;
-	jc	return;
-	SET_MODE(M_DFF1, M_DFF1)
-	call	check_fifo;
-	jc	return;
-	SET_MODE(M_SCSI, M_SCSI)
-	jmp	queue_scb_completion;
-END_CRITICAL;
 
 idle_loop_service_fifos:
 	SET_MODE(M_DFF0, M_DFF0)
@@ -179,6 +157,7 @@
 idle_loop_next_fifo:
 	SET_MODE(M_DFF1, M_DFF1)
 	test	LONGJMP_ADDR[1], INVALID_ADDR jz longjmp;
+return:
 	ret;
 
 idle_loop_cchan:
@@ -196,12 +175,31 @@
 scbdma_tohost_done:
 	test	CCSCBCTL, CCARREN jz fill_qoutfifo_dmadone;
 	/*
-	 * A complete SCB upload requires no intervention.
-	 * The SCB is already on the COMPLETE_SCB list
-	 * and its completion notification will now be
-	 * handled just like any other SCB.
+	 * An SCB has been succesfully uploaded to the host.
+	 * If the SCB was uploaded for some reason other than
+	 * bad SCSI status (currently only for underruns), we
+	 * queue the SCB for normal completion.  Otherwise, we
+	 * wait until any select-out activity has halted, and
+	 * then notify the host so that the transaction can be
+	 * dealt with.
+	 */
+	test	SCB_SCSI_STATUS, 0xff jnz scbdma_notify_host;
+	and	CCSCBCTL, ~(CCARREN|CCSCBEN);
+	bmov	COMPLETE_DMA_SCB_HEAD, SCB_NEXT_COMPLETE, 2;
+	bmov	SCB_NEXT_COMPLETE, COMPLETE_SCB_HEAD, 2;
+	bmov	COMPLETE_SCB_HEAD, SCBPTR, 2 ret;
+scbdma_notify_host:
+	SET_MODE(M_SCSI, M_SCSI)
+	test	SCSISEQ0, ENSELO jnz return;
+	test	SSTAT0, (SELDO|SELINGO) jnz return;
+	SET_MODE(M_CCHAN, M_CCHAN)
+	/*
+	 * Remove SCB and notify host.
 	 */
-	and	CCSCBCTL, ~(CCARREN|CCSCBEN) ret;
+	and	CCSCBCTL, ~(CCARREN|CCSCBEN);
+	bmov	COMPLETE_DMA_SCB_HEAD, SCB_NEXT_COMPLETE, 2;
+	SET_SEQINTCODE(BAD_SCB_STATUS)
+	ret;
 fill_qoutfifo_dmadone:
 	and	CCSCBCTL, ~(CCARREN|CCSCBEN);
 	call	qoutfifo_updated;
@@ -263,6 +261,13 @@
 	clr	A;
 	add	CMDS_PENDING, 1;
 	adc	CMDS_PENDING[1], A;
+	/*
+	 * The FIFO use count field is shared with the
+	 * tag set by the host so that our SCB dma engine
+	 * knows the correct location to store the SCB.
+	 * Set it to zero before processing the SCB.
+	 */
+	mov	SCB_FIFO_USE_COUNT, ALLZEROS;
 	/* Update the next SCB address to download. */
 	bmov	NEXT_QUEUED_SCB_ADDR, SCB_NEXT_SCB_BUSADDR, 4;
 	mvi	SCB_NEXT[1], SCB_LIST_NULL;
@@ -339,15 +344,7 @@
 dma_complete_scb:
 	bmov	SCBPTR, COMPLETE_DMA_SCB_HEAD, 2;
 	bmov	SCBHADDR, SCB_BUSADDR, 4;
-	mvi	CCARREN|CCSCBEN|CCSCBRESET call dma_scb;
-	/*
-	 * Now that we've started the DMA, push us onto
-	 * the normal completion queue to have our SCBID
-	 * posted to the kernel.
-	 */
-	bmov	COMPLETE_DMA_SCB_HEAD, SCB_NEXT_COMPLETE, 2;
-	bmov	SCB_NEXT_COMPLETE, COMPLETE_SCB_HEAD, 2;
-	bmov	COMPLETE_SCB_HEAD, SCBPTR, 2 ret;
+	mvi	CCARREN|CCSCBEN|CCSCBRESET jmp dma_scb;
 END_CRITICAL;
 
 /*
@@ -366,8 +363,6 @@
 	mov	CCSCBCTL, SINDEX ret;
 
 BEGIN_CRITICAL;
-setjmp_setscb:
-	bmov	LONGJMP_SCB, SCBPTR, 2;
 setjmp:
 	bmov	LONGJMP_ADDR, STACK, 2 ret;
 setjmp_inline:
@@ -1035,9 +1030,18 @@
 	or	SEQ_FLAGS2, SELECTOUT_QFROZEN;
 	mov	A, ACCUM_SAVE ret;
 
-queue_arg1_scb_completion:
+/*
+ * Complete the current FIFO's SCB if data for this same
+ * SCB is not transferring in the other FIFO.
+ */
+SET_SRC_MODE	M_DFF1;
+SET_DST_MODE	M_DFF1;
+pkt_complete_scb_if_fifos_idle:
+	bmov	ARG_1, SCBPTR, 2;
+	mvi	DFFSXFRCTL, CLRCHN;
 	SET_MODE(M_SCSI, M_SCSI)
 	bmov	SCBPTR, ARG_1, 2;
+	test	SCB_FIFO_USE_COUNT, 0xFF jnz return;
 queue_scb_completion:
 	test	SCB_SCSI_STATUS,0xff	jnz bad_status;
 	/*
@@ -1053,6 +1057,12 @@
 	cmp	SCB_SCSI_STATUS, STATUS_PKT_SENSE je upload_scb;
 	call	freeze_queue;
 upload_scb:
+	/*
+	 * Restore SCB TAG since we reuse this field
+	 * in the sequencer.  We don't want to corrupt
+	 * it on the host.
+	 */
+	bmov	SCB_TAG, SCBPTR, 2;
 	bmov	SCB_NEXT_COMPLETE, COMPLETE_DMA_SCB_HEAD, 2;
 	bmov	COMPLETE_DMA_SCB_HEAD, SCBPTR, 2;
 	or	SCB_SGPTR, SG_STATUS_VALID ret;
@@ -1363,7 +1373,7 @@
 	clr	SG_STATE ret;
 
 p_data_handle_xfer:
-	call	setjmp_setscb;
+	call	setjmp;
 	test	SG_STATE, LOADING_NEEDED jnz service_fifo;
 p_data_clear_handler:
 	or	LONGJMP_ADDR[1], INVALID_ADDR ret;
@@ -1616,25 +1626,32 @@
 		 * and deffer the test by one instruction.
 		 */
 		mov	REG_ISR, LQISTAT2;
-		test	REG_ISR, LQIWORKONLQ jz data_valid;
-		test	SEQINTSRC, SAVEPTRS  jz data_valid;
+		test	REG_ISR, LQIWORKONLQ jz main_isr;
+		test	SEQINTSRC, SAVEPTRS  jz main_isr;
 		test	LONGJMP_ADDR[1], INVALID_ADDR jz saveptr_active_fifo;
 		/*
-		 * Switch to the active FIFO.
+		 * Switch to the active FIFO after clearing the snapshot
+		 * savepointer in the current FIFO.  We do this so that
+		 * a pending CTXTDONE or SAVEPTR is visible in the active
+		 * FIFO.  This status is the only way we can detect if we
+		 * have lost the race (e.g. host paused us) and our attepts
+		 * to disable the channel occurred after all REQs were
+		 * already seen and acked (REQINIT never comes true).
 		 */
+		mvi	DFFSXFRCTL, CLRCHN;
 		xor	MODE_PTR, MK_MODE(M_DFF1, M_DFF1);
-		test	DFCNTRL, DIRECTION jz snapshot_other_fifo;
+		test	DFCNTRL, DIRECTION jz interrupt_return;
 		and	DFCNTRL, ~SCSIEN;
-		test	SSTAT1, REQINIT	jz .;
+snapshot_wait_data_valid:
+		test	SEQINTSRC, (CTXTDONE|SAVEPTRS) jnz snapshot_data_valid;
+		test	SSTAT1, REQINIT	jz snapshot_wait_data_valid;
+snapshot_data_valid:
 		or	DFCNTRL, SCSIEN;
-		/* FALLTHROUGH */
-snapshot_other_fifo:
-		xor	MODE_PTR, MK_MODE(M_DFF1, M_DFF1);
-		/* FALLTHROUGH */
+		or	SEQINTCTL, IRET ret;
 snapshot_saveptr:
 		mvi	DFFSXFRCTL, CLRCHN;
 		or	SEQINTCTL, IRET ret;
-data_valid:
+main_isr:
 	}
 	test	SEQINTSRC, CFG4DATA	jnz cfg4data_intr;
 	test	SEQINTSRC, CFG4ISTAT	jnz cfg4istat_intr;
@@ -1667,9 +1684,11 @@
 	or	SEQINTCTL, IRET ret;
 
 cfg4data_intr:
-	test	SCB_SGPTR[0], SG_LIST_NULL jnz pkt_handle_overrun;
+	test	SCB_SGPTR[0], SG_LIST_NULL jnz pkt_handle_overrun_inc_use_count;
 	call	load_first_seg;
 	call	pkt_handle_xfer;
+	inc	SCB_FIFO_USE_COUNT;
+interrupt_return:
 	or	SEQINTCTL, IRET ret;
 
 cfg4istat_intr:
@@ -1729,7 +1748,6 @@
 	test	DFSTATUS, FIFOEMP jz pkt_handle_overrun
 
 pkt_handle_xfer:
-	bmov	LONGJMP_SCB, SCBPTR, 2;
 	test	SG_STATE, LOADING_NEEDED jz pkt_last_seg;
 	call	setjmp;
 	test	SEQINTSRC, SAVEPTRS jnz pkt_saveptrs;
@@ -1751,7 +1769,7 @@
 pkt_last_seg:
 	call	setjmp;
 	test	SEQINTSRC, SAVEPTRS jnz pkt_saveptrs;
-	test	SG_CACHE_SHADOW, LAST_SEG_DONE jnz last_pkt_xfer_done;
+	test	SG_CACHE_SHADOW, LAST_SEG_DONE jnz pkt_last_seg_done;
 	test	SCSIPHASE, ~DATA_PHASE_MASK jz . + 2;
 	test	SCSISIGO, ATNO jnz . + 2;
 	test	SSTAT2, NONPACKREQ jz return;
@@ -1760,7 +1778,7 @@
 
 /*
  * Either a SAVEPTRS interrupt condition is pending for this FIFO
- * or we have a pending nonpackreq for this FIFO.  We differentiate
+ * or we have a pending NONPACKREQ for this FIFO.  We differentiate
  * between the two by capturing the state of the SAVEPTRS interrupt
  * prior to clearing this status and executing the common code for
  * these two cases.
@@ -1789,118 +1807,134 @@
 pkt_saveptrs_check_status:
 	or	LONGJMP_ADDR[1], INVALID_ADDR;
 	test	REG0, SAVEPTRS jz unexpected_nonpkt_phase;
-	test	SCB_CONTROL, STATUS_RCVD jz pkt_saveptrs_clrchn;
-	jmp	last_pkt_complete;
-pkt_saveptrs_clrchn:
+	dec	SCB_FIFO_USE_COUNT;
+	test	SCB_CONTROL, STATUS_RCVD jnz pkt_complete_scb_if_fifos_idle;
 	mvi	DFFSXFRCTL, CLRCHN ret;
 END_CRITICAL;
 
-last_pkt_xfer_done:
+/*
+ * LAST_SEG_DONE status has been seen in the current FIFO.
+ * This indicates that all of the allowed data for this
+ * command has transferred across the SCSI and host buses.
+ * Check for overrun and see if we can complete this command.
+ */
+pkt_last_seg_done:
 BEGIN_CRITICAL;
-	if ((ahd->bugs & AHD_AUTOFLUSH_BUG) != 0) {
-		or	DFCNTRL, FIFOFLUSH;
-	}
-	test	SCB_CONTROL, STATUS_RCVD jz wait_pkt_end;
-	check_overrun;
-	or	SCB_SGPTR, SG_LIST_NULL;
 	/*
-	 * It is safe to skip the other FIFO check since
-	 * we defer CLRCHN on SAVEPTRS until all data in
-	 * the FIFO are seen by the host and a CFG4DATA
-	 * in this FIFO for the same context is held off
-	 * by hardware.
+	 * Mark transfer as completed.
 	 */
-last_pkt_queue_scb:
-	or	LONGJMP_ADDR[1], INVALID_ADDR;
-	bmov	ARG_1, SCBPTR, 2;
-	mvi	DFFSXFRCTL, CLRCHN;
-	jmp	queue_arg1_scb_completion;
-
-last_pkt_complete:
-	bmov	ARG_1, SCBPTR, 2;
-	mvi	DFFSXFRCTL, CLRCHN;
-check_other_fifo:
-	clc;
-	TOGGLE_DFF_MODE
-	call	check_fifo;
-	jnc	queue_arg1_scb_completion;
-return:
-	ret;
+	or	SCB_SGPTR, SG_LIST_NULL;
 
-wait_pkt_end:
+	/*
+	 * Wait for the current context to finish to verify that
+	 * no overrun condition has occurred.
+	 */
+	test	SEQINTSRC, CTXTDONE jnz pkt_ctxt_done;
 	call	setjmp;
-END_CRITICAL;
-wait_pkt_end_loop:
-	test	SEQINTSRC, CTXTDONE jnz pkt_end;
+pkt_wait_ctxt_done_loop:
+	test	SEQINTSRC, CTXTDONE jnz pkt_ctxt_done;
+	/*
+	 * A sufficiently large overrun or a NONPACKREQ may
+	 * prevent CTXTDONE from ever asserting, so we must
+	 * poll for these statuses too.
+	 */
 	check_overrun;
 	test	SSTAT2, NONPACKREQ jz return;
 	test	SEQINTSRC, CTXTDONE jz unexpected_nonpkt_phase;
-pkt_end:
-BEGIN_CRITICAL;
+	/* FALLTHROUGH */
+
+pkt_ctxt_done:
 	check_overrun;
 	or	LONGJMP_ADDR[1], INVALID_ADDR;
-	or	SCB_SGPTR, SG_LIST_NULL;
-	test	SCB_CONTROL, STATUS_RCVD jnz last_pkt_complete;
+	/*
+	 * If status has been received, it is safe to skip
+	 * the check to see if another FIFO is active because
+	 * LAST_SEG_DONE has been observed.  However, we check
+	 * the FIFO anyway since it costs us only one extra
+	 * instruction to leverage common code to perform the
+	 * SCB completion.
+	 */
+	dec	SCB_FIFO_USE_COUNT;
+	test	SCB_CONTROL, STATUS_RCVD jnz pkt_complete_scb_if_fifos_idle;
 	mvi	DFFSXFRCTL, CLRCHN ret;
 END_CRITICAL;
 
 /*
+ * Must wait until CDB xfer is over before issuing the
+ * clear channel.
+ */
+pkt_handle_cdb:
+	call	setjmp;
+	test	SG_CACHE_SHADOW, LAST_SEG_DONE jz return;
+	or	LONGJMP_ADDR[1], INVALID_ADDR;
+	mvi	DFFSXFRCTL, CLRCHN ret;
+
+/*
  * Watch over the status transfer.  Our host sense buffer is
  * large enough to take the maximum allowed status packet.
  * None-the-less, we must still catch and report overruns to
- * the host.
+ * the host.  Additionally, properly catch unexpected non-packet
+ * phases that are typically caused by CRC errors in status packet
+ * transmission.
  */
 pkt_handle_status:
-	call	setjmp_setscb;
-	test	SG_CACHE_SHADOW, LAST_SEG_DONE jz check_status_overrun;
-	test	SEQINTSRC, CTXTDONE jz return;
-status_IU_done:
-BEGIN_CRITICAL;
+	call	setjmp;
+	test	SG_CACHE_SHADOW, LAST_SEG_DONE jnz pkt_status_check_overrun;
+	test	SEQINTSRC, CTXTDONE jz pkt_status_check_nonpackreq;
+	test	SG_CACHE_SHADOW, LAST_SEG_DONE jnz pkt_status_check_overrun;
+pkt_status_IU_done:
 	if ((ahd->bugs & AHD_AUTOFLUSH_BUG) != 0) {
 		or	DFCNTRL, FIFOFLUSH;
 	}
+	test	DFSTATUS, FIFOEMP jz return;
+BEGIN_CRITICAL;
 	or	LONGJMP_ADDR[1], INVALID_ADDR;
 	mvi	SCB_SCSI_STATUS, STATUS_PKT_SENSE;
 	or	SCB_CONTROL, STATUS_RCVD;
-	jmp	last_pkt_complete;
+	jmp	pkt_complete_scb_if_fifos_idle;
 END_CRITICAL;
-check_status_overrun:
+pkt_status_check_overrun:
 	/*
-	 * We've filled the entire sense buffer.
-	 * Wait for either context done or a negative
-	 * shaddow count.  If the context completes without
-	 * causing the shaddow count to go negative, then
-	 * this was a successful transfer up to the status
-	 * limit.  Otherwise we report the error.
-	 */
-	test	SHCNT[2], 0xFF jnz report_status_overrun;
-	test	SEQINTSRC, CTXTDONE jz return;
-	test	SHCNT[2], 0xFF jz status_IU_done;
-report_status_overrun:
+	 * Status PKT overruns are uncerimoniously recovered with a
+	 * bus reset.  If we've overrun, let the host know so that
+	 * recovery can be performed.
+	 *
+	 * LAST_SEG_DONE has been observed.  If either CTXTDONE or
+	 * a NONPACKREQ phase change have occurred and the FIFO is
+	 * empty, there is no overrun.
+	 */
+	test	DFSTATUS, FIFOEMP jz pkt_status_report_overrun;
+	test	SEQINTSRC, CTXTDONE jz . + 2;
+	test	DFSTATUS, FIFOEMP jnz pkt_status_IU_done;
+	test	SCSIPHASE, ~DATA_PHASE_MASK jz return;
+	test	DFSTATUS, FIFOEMP jnz pkt_status_check_nonpackreq;
+pkt_status_report_overrun:
 	SET_SEQINTCODE(STATUS_OVERRUN)
-	jmp	status_IU_done;
-
-SET_SRC_MODE	M_DFF0;
-SET_DST_MODE	M_DFF0;
-BEGIN_CRITICAL;
-check_fifo:
-	test	LONGJMP_ADDR[1], INVALID_ADDR jnz return;
-	mov	A, ARG_2;
-	cmp	LONGJMP_SCB[1], A	jne return;
-	mov	A, ARG_1;
-	cmp	LONGJMP_SCB[0], A	jne return;
-	stc	ret;
-END_CRITICAL;
-
-/*
- * Must wait until CDB xfer is over before issuing the
- * clear channel.
- */
-pkt_handle_cdb:
-	call	setjmp_setscb;
-	test	SG_CACHE_SHADOW, LAST_SEG_DONE jz return;
-	or	LONGJMP_ADDR[1], INVALID_ADDR;
-	mvi	DFFSXFRCTL, CLRCHN ret;
+	/* SEQUENCER RESTARTED */
+pkt_status_check_nonpackreq:
+	/*
+	 * CTXTDONE may be held off if a NONPACKREQ is associated with
+	 * the current context.  If a NONPACKREQ is observed, decide
+	 * if it is for the current context.  If it is for the current
+	 * context, we must defer NONPACKREQ processing until all data
+	 * has transferred to the host.
+	 */
+	test	SCSIPHASE, ~DATA_PHASE_MASK jz return;
+	test	SCSISIGO, ATNO jnz . + 2;
+	test	SSTAT2, NONPACKREQ jz return;
+	test	SEQINTSRC, CTXTDONE jnz pkt_status_IU_done;
+	test	DFSTATUS, FIFOEMP jz return;
+	/*
+	 * The unexpected nonpkt phase handler assumes that any
+	 * data channel use will have a FIFO reference count.  It
+	 * turns out that the status handler doesn't need a refernce
+	 * count since the status received flag, and thus completion
+	 * processing, cannot be set until the handler is finished.
+	 * We increment the count here to make the nonpkt handler
+	 * happy.
+	 */
+	inc	SCB_FIFO_USE_COUNT;
+	/* FALLTHROUGH */
 
 /*
  * Nonpackreq is a polled status.  It can come true in three situations:
@@ -1929,6 +1963,7 @@
 SET_SRC_MODE	M_DFF0;
 SET_DST_MODE	M_DFF0;
 	or	LONGJMP_ADDR[1], INVALID_ADDR;
+	dec	SCB_FIFO_USE_COUNT;
 	mvi	DFFSXFRCTL, CLRCHN;
 	mvi	CLRSINT2, CLRNONPACKREQ;
 	test	SCSIPHASE, ~(MSG_IN_PHASE|MSG_OUT_PHASE) jnz illegal_phase;
@@ -1945,6 +1980,8 @@
  * data.  Otherwise use an overrun buffer in the host to simulate
  * BITBUCKET.
  */
+pkt_handle_overrun_inc_use_count:
+	inc	SCB_FIFO_USE_COUNT;
 pkt_handle_overrun:
 	SET_SEQINTCODE(CFG4OVERRUN)
 	call	freeze_queue;
@@ -1970,8 +2007,9 @@
 pkt_overrun_end:
 	or	SCB_RESIDUAL_SGPTR, SG_OVERRUN_RESID;
 	test	SEQINTSRC, CTXTDONE jz unexpected_nonpkt_phase;
-	test	SCB_CONTROL, STATUS_RCVD jnz last_pkt_queue_scb;
+	dec	SCB_FIFO_USE_COUNT;
 	or	LONGJMP_ADDR[1], INVALID_ADDR;
+	test	SCB_CONTROL, STATUS_RCVD jnz pkt_complete_scb_if_fifos_idle;
 	mvi	DFFSXFRCTL, CLRCHN ret;
 
 if ((ahd->bugs & AHD_PKT_BITBUCKET_BUG) != 0) {
diff -urN linux-2.5.69-bk7/drivers/scsi/aic7xxx/aic79xx_core.c linux-2.5.69-bk8/drivers/scsi/aic7xxx/aic79xx_core.c
--- linux-2.5.69-bk7/drivers/scsi/aic7xxx/aic79xx_core.c	2003-05-04 16:52:48.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/aic7xxx/aic79xx_core.c	2003-05-13 04:44:29.000000000 -0700
@@ -37,7 +37,7 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  *
- * $Id: //depot/aic7xxx/aic7xxx/aic79xx.c#178 $
+ * $Id: //depot/aic7xxx/aic7xxx/aic79xx.c#190 $
  *
  * $FreeBSD$
  */
@@ -556,6 +556,26 @@
 		       ahd_name(ahd), seqintcode);
 #endif
 	switch (seqintcode) {
+	case BAD_SCB_STATUS:
+	{
+		struct	scb *scb;
+		u_int	scbid;
+		int	cmds_pending;
+
+		scbid = ahd_get_scbptr(ahd);
+		scb = ahd_lookup_scb(ahd, scbid);
+		if (scb != NULL) {
+			ahd_complete_scb(ahd, scb);
+		} else {
+			printf("%s: WARNING no command for scb %d "
+			       "(bad status)\n", ahd_name(ahd), scbid);
+			ahd_dump_card_state(ahd);
+		}
+		cmds_pending = ahd_inw(ahd, CMDS_PENDING);
+		if (cmds_pending > 0)
+			ahd_outw(ahd, CMDS_PENDING, cmds_pending - 1);
+		break;
+	}
 	case ENTERING_NONPACK:
 	{
 		struct	scb *scb;
@@ -604,7 +624,16 @@
 		break;
 	case STATUS_OVERRUN:
 	{
-		printf("%s: Status Overrun", ahd_name(ahd));
+		struct	scb *scb;
+		u_int	scbid;
+
+		scbid = ahd_get_scbptr(ahd);
+		scb = ahd_lookup_scb(ahd, scbid);
+		if (scb != NULL)
+			ahd_print_path(ahd, scb);
+		else
+			printf("%s: ", ahd_name(ahd));
+		printf("SCB %d Packetized Status Overrun", scbid);
 		ahd_dump_card_state(ahd);
 		ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
 		break;
@@ -1023,7 +1052,7 @@
 
 			switch (scb->hscb->task_management) {
 			case SIU_TASKMGMT_ABORT_TASK:
-				tag = scb->hscb->tag;
+				tag = SCB_GET_TAG(scb);
 			case SIU_TASKMGMT_ABORT_TASK_SET:
 			case SIU_TASKMGMT_CLEAR_TASK_SET:
 				lun = scb->hscb->lun;
@@ -1087,7 +1116,7 @@
 			ahd_outb(ahd, SCB_TASK_MANAGEMENT, 0);
 			ahd_search_qinfifo(ahd, SCB_GET_TARGET(ahd, scb),
 					   SCB_GET_CHANNEL(ahd, scb),  
-					   SCB_GET_LUN(scb), scb->hscb->tag, 
+					   SCB_GET_LUN(scb), SCB_GET_TAG(scb), 
 					   ROLE_INITIATOR, /*status*/0,   
 					   SEARCH_REMOVE);
 		}
@@ -1166,7 +1195,7 @@
 		/*
 		 * A change in I/O mode is equivalent to a bus reset.
 		 */
-		ahd_reset_channel(ahd, 'A', /*Initiate Reset*/FALSE);
+		ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
 		ahd_pause(ahd);
 		ahd_setup_iocell_workaround(ahd);
 		ahd_unpause(ahd);
@@ -2183,6 +2212,13 @@
 		ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
 		ahd_outb(ahd, SEQCTL0, ahd_inb(ahd, SEQCTL0) & ~STEP);
   		ahd_outb(ahd, SIMODE1, simode1);
+		/*
+		 * SCSIINT seems to glitch occassionally when
+		 * the interrupt masks are restored.  Clear SCSIINT
+		 * one more time so that only persistent errors
+		 * are seen as a real interrupt.
+		 */
+		ahd_outb(ahd, CLRINT, CLRSCSIINT);
 	}
 	ahd_restore_modes(ahd, saved_modes);
 }
@@ -4887,7 +4923,6 @@
 {
 	int i;
 
-	ahd_fini_scbdata(ahd);
 	switch (ahd->init_level) {
 	default:
 	case 5:
@@ -4919,6 +4954,7 @@
 	ahd_dma_tag_destroy(ahd, ahd->parent_dmat);
 #endif
 	ahd_platform_free(ahd);
+	ahd_fini_scbdata(ahd);
 	for (i = 0; i < AHD_NUM_TARGETS; i++) {
 		struct ahd_tmode_tstate *tstate;
 
@@ -5481,7 +5517,7 @@
 	/* Clean up for the next user */
 	scb->flags = SCB_FLAG_NONE;
 	scb->hscb->control = 0;
-	ahd->scb_data.scbindex[scb->hscb->tag] = NULL;
+	ahd->scb_data.scbindex[SCB_GET_TAG(scb)] = NULL;
 
 	if (scb->col_scb == NULL) {
 
@@ -5584,8 +5620,8 @@
 	if (scb_data->sgs_left != 0) {
 		int offset;
 
-		offset = ahd_sglist_allocsize(ahd)
-		       - (scb_data->sgs_left * ahd_sglist_size(ahd));
+		offset = ((ahd_sglist_allocsize(ahd) / ahd_sglist_size(ahd))
+		       - scb_data->sgs_left) * ahd_sglist_size(ahd);
 		sg_map = SLIST_FIRST(&scb_data->sg_maps);
 		segs = sg_map->vaddr + offset;
 		sg_busaddr = sg_map->physaddr + offset;
@@ -5894,7 +5930,7 @@
 	 * specially from the DMA safe memory chunk used for the QOUTFIFO.
 	 */
 	ahd->next_queued_hscb = (struct hardware_scb *)next_vaddr;
-	ahd->next_queued_hscb->hscb_busaddr = next_baddr;
+	ahd->next_queued_hscb->hscb_busaddr = ahd_htole32(next_baddr);
 
 	ahd->init_level++;
 
@@ -6056,7 +6092,6 @@
 	for (i = 0; i < 2; i++) {
 		ahd_set_modes(ahd, AHD_MODE_DFF0 + i, AHD_MODE_DFF0 + i);
 		ahd_outb(ahd, LONGJMP_ADDR + 1, INVALID_ADDR);
-		ahd_outw(ahd, LONGJMP_SCB, SCB_LIST_NULL);
 		ahd_outb(ahd, SG_STATE, 0);
 		ahd_outb(ahd, CLRSEQINTSRC, 0xFF);
 		ahd_outb(ahd, SEQIMODE,
@@ -6605,24 +6640,29 @@
 void
 ahd_pause_and_flushwork(struct ahd_softc *ahd)
 {
-	ahd_mode_state	saved_modes;
-	u_int		intstat;
-	u_int		maxloops;
-	int		paused;
+	u_int intstat;
+	u_int maxloops;
+	u_int qfreeze_cnt;
 
 	maxloops = 1000;
 	ahd->flags |= AHD_ALL_INTERRUPTS;
-	paused = FALSE;
+	ahd_pause(ahd);
+	/*
+	 * Increment the QFreeze Count so that the sequencer
+	 * will not start new selections.  We do this only
+	 * until we are safely paused without further selections
+	 * pending.
+	 */
+	ahd_outw(ahd, QFREEZE_COUNT, ahd_inw(ahd, QFREEZE_COUNT) + 1);
+	ahd_outb(ahd, SEQ_FLAGS2, ahd_inb(ahd, SEQ_FLAGS2) | SELECTOUT_QFROZEN);
 	do {
 		struct scb *waiting_scb;
 
-		if (paused)
-			ahd_unpause(ahd);
+		ahd_unpause(ahd);
 		ahd_intr(ahd);
 		ahd_pause(ahd);
-		paused = TRUE;
 		ahd_clear_critical_section(ahd);
-		saved_modes = ahd_save_modes(ahd);
+		intstat = ahd_inb(ahd, INTSTAT);
 		ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
 		if ((ahd_inb(ahd, SSTAT0) & (SELDO|SELINGO)) == 0)
 			ahd_outb(ahd, SCSISEQ0,
@@ -6639,22 +6679,32 @@
 		 && (ahd_inb(ahd, SSTAT0) & (SELDO|SELINGO)) != 0)
 			ahd_outb(ahd, SCSISEQ0,
 				 ahd_inb(ahd, SCSISEQ0) | ENSELO);
-
-		intstat = ahd_inb(ahd, INTSTAT);
 	} while (--maxloops
 	      && (intstat != 0xFF || (ahd->features & AHD_REMOVABLE) == 0)
 	      && ((intstat & INT_PEND) != 0
-	       || (ahd_inb(ahd, SSTAT0) & (SELDO|SELINGO))));
+	       || (ahd_inb(ahd, SCSISEQ0) & ENSELO) != 0
+	       || (ahd_inb(ahd, SSTAT0) & (SELDO|SELINGO)) != 0));
+
 	if (maxloops == 0) {
 		printf("Infinite interrupt loop, INTSTAT = %x",
 		      ahd_inb(ahd, INTSTAT));
 	}
+	qfreeze_cnt = ahd_inw(ahd, QFREEZE_COUNT);
+	if (qfreeze_cnt == 0) {
+		printf("%s: ahd_pause_and_flushwork with 0 qfreeze count!\n",
+		       ahd_name(ahd));
+	} else {
+		qfreeze_cnt--;
+	}
+	ahd_outw(ahd, QFREEZE_COUNT, qfreeze_cnt);
+	if (qfreeze_cnt == 0)
+		ahd_outb(ahd, SEQ_FLAGS2,
+			 ahd_inb(ahd, SEQ_FLAGS2) & ~SELECTOUT_QFROZEN);
 
 	ahd_flush_qoutfifo(ahd);
 
 	ahd_platform_flushwork(ahd);
 	ahd->flags &= ~AHD_ALL_INTERRUPTS;
-	ahd_restore_modes(ahd, saved_modes);
 }
 
 int
@@ -7514,14 +7564,17 @@
 		ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
 		ahd_outb(ahd, DFFSTAT, next_fifo);
 	} while (next_fifo != fifo);
+
 	/*
 	 * Reset the bus if we are initiating this reset
 	 */
 	ahd_clear_msg_state(ahd);
 	ahd_outb(ahd, SIMODE1,
 		 ahd_inb(ahd, SIMODE1) & ~(ENBUSFREE|ENSCSIRST|ENBUSFREE));
+
 	if (initiate_reset)
 		ahd_reset_current_bus(ahd);
+
 	ahd_clear_intstat(ahd);
 
 	/*
@@ -7719,9 +7772,6 @@
 	hscb = scb->hscb; 
 
 	/* Freeze the queue until the client sees the error. */
-	ahd_pause(ahd);
-	ahd_clear_critical_section(ahd);
-	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
 	ahd_freeze_devq(ahd, scb);
 	ahd_freeze_scb(scb);
 	qfreeze_cnt = ahd_inw(ahd, QFREEZE_COUNT);
@@ -7734,7 +7784,7 @@
 	if (qfreeze_cnt == 0)
 		ahd_outb(ahd, SEQ_FLAGS2,
 			 ahd_inb(ahd, SEQ_FLAGS2) & ~SELECTOUT_QFROZEN);
-	ahd_unpause(ahd);
+
 	/* Don't want to clobber the original sense code */
 	if ((scb->flags & SCB_SENSE) != 0) {
 		/*
@@ -8592,11 +8642,11 @@
 	LIST_FOREACH(scb, &ahd->pending_scbs, pending_links) {
 		if (i++ > AHD_SCB_MAX)
 			break;
-		cur_col = printf("\n%3d ", SCB_GET_TAG(scb));
+		cur_col = printf("\n%3d FIFO_USE[0x%x] ", SCB_GET_TAG(scb),
+				 ahd_inb(ahd, SCB_FIFO_USE_COUNT));
 		ahd_set_scbptr(ahd, SCB_GET_TAG(scb));
 		ahd_scb_control_print(ahd_inb(ahd, SCB_CONTROL), &cur_col, 60);
 		ahd_scb_scsiid_print(ahd_inb(ahd, SCB_SCSIID), &cur_col, 60);
-		ahd_scb_tag_print(ahd_inb(ahd, SCB_TAG), &cur_col, 60);
 	}
 	printf("\nTotal %d\n", i);
 
@@ -8659,12 +8709,10 @@
 
 		ahd_set_modes(ahd, AHD_MODE_DFF0 + i, AHD_MODE_DFF0 + i);
 		fifo_scbptr = ahd_get_scbptr(ahd);
-		printf("\n%s: FIFO%d %s, LONGJMP == 0x%x, "
-		       "SCB 0x%x, LJSCB 0x%x\n",
+		printf("\n%s: FIFO%d %s, LONGJMP == 0x%x, SCB 0x%x\n",
 		       ahd_name(ahd), i,
 		       (dffstat & (FIFO0FREE << i)) ? "Free" : "Active",
-		       ahd_inw(ahd, LONGJMP_ADDR), fifo_scbptr,
-		       ahd_inw(ahd, LONGJMP_SCB));
+		       ahd_inw(ahd, LONGJMP_ADDR), fifo_scbptr);
 		cur_col = 0;
 		ahd_seqimode_print(ahd_inb(ahd, SEQIMODE), &cur_col, 50);
 		ahd_seqintsrc_print(ahd_inb(ahd, SEQINTSRC), &cur_col, 50);
diff -urN linux-2.5.69-bk7/drivers/scsi/aic7xxx/aic79xx_inline.h linux-2.5.69-bk8/drivers/scsi/aic7xxx/aic79xx_inline.h
--- linux-2.5.69-bk7/drivers/scsi/aic7xxx/aic79xx_inline.h	2003-05-04 16:53:14.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/aic7xxx/aic79xx_inline.h	2003-05-13 04:44:29.000000000 -0700
@@ -37,7 +37,7 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  *
- * $Id: //depot/aic7xxx/aic7xxx/aic79xx_inline.h#44 $
+ * $Id: //depot/aic7xxx/aic7xxx/aic79xx_inline.h#48 $
  *
  * $FreeBSD$
  */
@@ -223,7 +223,7 @@
 		ahd_set_modes(ahd, ahd->saved_src_mode, ahd->saved_dst_mode);
 	}
 
-	if ((ahd_inb(ahd, INTSTAT) & ~(SWTMINT | CMDCMPLT)) == 0)
+	if ((ahd_inb(ahd, INTSTAT) & ~CMDCMPLT) == 0)
 		ahd_outb(ahd, HCNTRL, ahd->unpause);
 
 	ahd_known_modes(ahd, AHD_MODE_UNKNOWN, AHD_MODE_UNKNOWN);
@@ -298,9 +298,12 @@
 		scb->hscb->datacnt = sg->len;
 	} else {
 		struct ahd_dma_seg *sg;
+		uint32_t *dataptr_words;
 
 		sg = (struct ahd_dma_seg *)scb->sg_list;
-		scb->hscb->dataptr = sg->addr;
+		dataptr_words = (uint32_t*)&scb->hscb->dataptr;
+		dataptr_words[0] = sg->addr;
+		dataptr_words[1] = 0;
 		if ((ahd->flags & AHD_39BIT_ADDRESSING) != 0) {
 			uint64_t high_addr;
 
@@ -777,12 +780,15 @@
 
 #ifdef AHD_DEBUG
 	if ((ahd_debug & AHD_SHOW_QUEUE) != 0) {
+		uint64_t host_dataptr;
+
+		host_dataptr = ahd_le64toh(scb->hscb->dataptr);
 		printf("%s: Queueing SCB 0x%x bus addr 0x%x - 0x%x%x/0x%x\n",
 		       ahd_name(ahd),
-		       SCB_GET_TAG(scb), scb->hscb->hscb_busaddr,
-		       (u_int)((scb->hscb->dataptr >> 32) & 0xFFFFFFFF),
-		       (u_int)(scb->hscb->dataptr & 0xFFFFFFFF),
-		       scb->hscb->datacnt);
+		       SCB_GET_TAG(scb), ahd_le32toh(scb->hscb->hscb_busaddr),
+		       (u_int)((host_dataptr >> 32) & 0xFFFFFFFF),
+		       (u_int)(host_dataptr & 0xFFFFFFFF),
+		       ahd_le32toh(scb->hscb->datacnt));
 	}
 #endif
 	/* Tell the adapter about the newly queued SCB */
@@ -805,7 +811,7 @@
 static __inline void	ahd_sync_qoutfifo(struct ahd_softc *ahd, int op);
 static __inline void	ahd_sync_tqinfifo(struct ahd_softc *ahd, int op);
 static __inline u_int	ahd_check_cmdcmpltqueues(struct ahd_softc *ahd);
-static __inline void	ahd_intr(struct ahd_softc *ahd);
+static __inline int	ahd_intr(struct ahd_softc *ahd);
 
 static __inline void
 ahd_sync_qoutfifo(struct ahd_softc *ahd, int op)
@@ -864,7 +870,7 @@
 /*
  * Catch an interrupt from the adapter
  */
-static __inline void
+static __inline int
 ahd_intr(struct ahd_softc *ahd)
 {
 	u_int	intstat;
@@ -876,7 +882,7 @@
 		 * so just return.  This is likely just a shared
 		 * interrupt.
 		 */
-		return;
+		return (0);
 	}
 
 	/*
@@ -891,6 +897,9 @@
 	else
 		intstat = ahd_inb(ahd, INTSTAT);
 
+	if ((intstat & INT_PEND) == 0)
+		return (0);
+
 	if (intstat & CMDCMPLT) {
 		ahd_outb(ahd, CLRINT, CLRCMDINT);
 
@@ -924,28 +933,25 @@
 #endif
 	}
 
-	if (intstat == 0xFF && (ahd->features & AHD_REMOVABLE) != 0)
-		/* Hot eject */
-		return;
-
-	if ((intstat & INT_PEND) == 0)
-		return;
-
-	if (intstat & HWERRINT) {
+	/*
+	 * Handle statuses that may invalidate our cached
+	 * copy of INTSTAT separately.
+	 */
+	if (intstat == 0xFF && (ahd->features & AHD_REMOVABLE) != 0) {
+		/* Hot eject.  Do nothing */
+	} else if (intstat & HWERRINT) {
 		ahd_handle_hwerrint(ahd);
-		return;
-	}
-
-	if ((intstat & (PCIINT|SPLTINT)) != 0) {
+	} else if ((intstat & (PCIINT|SPLTINT)) != 0) {
 		ahd->bus_intr(ahd);
-		return;
-	}
+	} else {
 
-	if ((intstat & SEQINT) != 0)
-		ahd_handle_seqint(ahd, intstat);
+		if ((intstat & SEQINT) != 0)
+			ahd_handle_seqint(ahd, intstat);
 
-	if ((intstat & SCSIINT) != 0)
-		ahd_handle_scsiint(ahd, intstat);
+		if ((intstat & SCSIINT) != 0)
+			ahd_handle_scsiint(ahd, intstat);
+	}
+	return (1);
 }
 
 #endif  /* _AIC79XX_INLINE_H_ */
diff -urN linux-2.5.69-bk7/drivers/scsi/aic7xxx/aic79xx_osm.c linux-2.5.69-bk8/drivers/scsi/aic7xxx/aic79xx_osm.c
--- linux-2.5.69-bk7/drivers/scsi/aic7xxx/aic79xx_osm.c	2003-05-04 16:53:31.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/aic7xxx/aic79xx_osm.c	2003-05-13 04:44:29.000000000 -0700
@@ -1,7 +1,7 @@
 /*
  * Adaptec AIC79xx device driver for Linux.
  *
- * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#141 $
+ * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.c#160 $
  *
  * --------------------------------------------------------------------------
  * Copyright (c) 1994-2000 Justin T. Gibbs.
@@ -67,12 +67,10 @@
 #include <linux/unistd.h>
 static int errno;
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0)
 /*
  * Lock protecting manipulation of the ahd softc list.
  */
 spinlock_t ahd_list_spinlock;
-#endif
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
 struct proc_dir_entry proc_scsi_aic79xx = {
@@ -82,6 +80,11 @@
 };
 #endif
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+/* For dynamic sglist size calculation. */
+u_int ahd_linux_nseg;
+#endif
+
 /*
  * Bucket size for counting good commands in between bad ones.
  */
@@ -352,14 +355,14 @@
  * disabled at the very end.  That should fix everyone up unless there are
  * really strange cirumstances.
  */
-static int aic79xx_reverse_scan = 0;
+static uint32_t aic79xx_reverse_scan;
 
 /*
  * Should we force EXTENDED translation on a controller.
  *     0 == Use whatever is in the SEEPROM or default to off
  *     1 == Use whatever is in the SEEPROM or default to on
  */
-static uint32_t aic79xx_extended = 0;
+static uint32_t aic79xx_extended;
 
 /*
  * PCI bus parity checking of the Adaptec controllers.  This is somewhat
@@ -367,16 +370,15 @@
  * solved a PCI parity problem, but on certain machines with broken PCI
  * chipset configurations, it can generate tons of false error messages.
  * It's included in the driver for completeness.
- *   0 = Shut off PCI parity check
- *  -1 = Normal polarity pci parity checking
- *   1 = reverse polarity pci parity checking
+ *   0	   = Shut off PCI parity check
+ *   non-0 = Enable PCI parity check
  *
  * NOTE: you can't actually pass -1 on the lilo prompt.  So, to set this
  * variable to -1 you would actually want to simply pass the variable
  * name without a number.  That will invert the 0 which will result in
  * -1.
  */
-static int aic79xx_pci_parity = 0;
+static uint32_t aic79xx_pci_parity = ~0;
 
 /*
  * There are lots of broken chipsets in the world.  Some of them will
@@ -384,7 +386,7 @@
  * controller.  I/O mapped register access, if allowed by the given
  * platform, will work in almost all cases.
  */
-int aic79xx_allow_memio = 1;
+uint32_t aic79xx_allow_memio = ~0;
 
 /*
  * aic79xx_detect() has been run, so register all device arrivals
@@ -403,7 +405,7 @@
  * We default to 256ms because some older devices need a longer time
  * to respond to initial selection.
  */
-static int aic79xx_seltime = 0x00;
+static uint32_t aic79xx_seltime;
 
 /*
  * Certain devices do not perform any aging on commands.  Should the
@@ -413,7 +415,7 @@
  * force all outstanding transactions to be serviced prior to a new
  * transaction.
  */
-int aic79xx_periodic_otag;
+uint32_t aic79xx_periodic_otag;
 
 /*
  * Module information and settable options.
@@ -478,6 +480,7 @@
 static void ahd_linux_dev_timed_unfreeze(u_long arg);
 static void ahd_linux_sem_timeout(u_long arg);
 static void ahd_linux_initialize_scsi_bus(struct ahd_softc *ahd);
+static void ahd_linux_size_nseg(void);
 static void ahd_linux_thread_run_complete_queue(struct ahd_softc *ahd);
 static void ahd_linux_start_dv(struct ahd_softc *ahd);
 static void ahd_linux_dv_timeout(struct scsi_cmnd *cmd);
@@ -548,20 +551,17 @@
 static aic_option_callback_t ahd_linux_setup_iocell_info;
 static int ahd_linux_next_unit(void);
 static void ahd_runq_tasklet(unsigned long data);
-static int ahd_linux_halt(struct notifier_block *nb, u_long event, void *buf);
 static int aic79xx_setup(char *c);
 
 /****************************** Inlines ***************************************/
-static __inline void ahd_schedule_completeq(struct ahd_softc *ahd,
-					    struct ahd_cmd *acmd);
+static __inline void ahd_schedule_completeq(struct ahd_softc *ahd);
 static __inline void ahd_schedule_runq(struct ahd_softc *ahd);
 static __inline void ahd_setup_runq_tasklet(struct ahd_softc *ahd);
 static __inline void ahd_teardown_runq_tasklet(struct ahd_softc *ahd);
 static __inline struct ahd_linux_device*
 		     ahd_linux_get_device(struct ahd_softc *ahd, u_int channel,
 					  u_int target, u_int lun, int alloc);
-static struct ahd_cmd *ahd_linux_run_complete_queue(struct ahd_softc *ahd,
-						    struct ahd_cmd *acmd);
+static struct ahd_cmd *ahd_linux_run_complete_queue(struct ahd_softc *ahd);
 static __inline void ahd_linux_check_device_queue(struct ahd_softc *ahd,
 						  struct ahd_linux_device *dev);
 static __inline struct ahd_linux_device *
@@ -574,26 +574,8 @@
 				      bus_addr_t addr, bus_size_t len);
 
 static __inline void
-ahd_schedule_completeq(struct ahd_softc *ahd, struct ahd_cmd *acmd)
+ahd_schedule_completeq(struct ahd_softc *ahd)
 {
-	while (acmd != NULL) {
-		struct ahd_completeq *completeq;
-		struct ahd_cmd *list_cmd;
-		struct ahd_cmd *next_cmd;
-
-		next_cmd = TAILQ_NEXT(acmd, acmd_links.tqe);
-		completeq = &ahd->platform_data->completeq;
-		list_cmd = TAILQ_FIRST(completeq);
-		while (list_cmd != NULL
-		    && acmd_scsi_cmd(list_cmd).serial_number
-		     < acmd_scsi_cmd(acmd).serial_number)
-			list_cmd = TAILQ_NEXT(list_cmd, acmd_links.tqe);
-		if (list_cmd != NULL)
-			TAILQ_INSERT_BEFORE(list_cmd, acmd, acmd_links.tqe);
-		else
-			TAILQ_INSERT_TAIL(completeq, acmd, acmd_links.tqe);
-		acmd = next_cmd;
-	}
 	if ((ahd->platform_data->flags & AHD_RUN_CMPLT_Q_TIMER) == 0) {
 		ahd->platform_data->flags |= AHD_RUN_CMPLT_Q_TIMER;
 		ahd->platform_data->completeq_timer.expires = jiffies;
@@ -662,25 +644,17 @@
 
 #define AHD_LINUX_MAX_RETURNED_ERRORS 4
 static struct ahd_cmd *
-ahd_linux_run_complete_queue(struct ahd_softc *ahd, struct ahd_cmd *acmd)
+ahd_linux_run_complete_queue(struct ahd_softc *ahd)
 {	
+	struct	ahd_cmd *acmd;
 	u_long	done_flags;
 	int	with_errors;
 
 	with_errors = 0;
 	ahd_done_lock(ahd, &done_flags);
-	while (acmd != NULL) {
+	while ((acmd = TAILQ_FIRST(&ahd->platform_data->completeq)) != NULL) {
 		Scsi_Cmnd *cmd;
 
-		cmd = &acmd_scsi_cmd(acmd);
-		acmd = TAILQ_NEXT(acmd, acmd_links.tqe);
-		cmd->host_scribble = NULL;
-		if (ahd_cmd_get_transaction_status(cmd) != DID_OK
-		 || (cmd->result & 0xFF) != SCSI_STATUS_OK)
-			with_errors++;
-
-		cmd->scsi_done(cmd);
-
 		if (with_errors > AHD_LINUX_MAX_RETURNED_ERRORS) {
 			/*
 			 * Linux uses stack recursion to requeue
@@ -690,8 +664,18 @@
 			 * the operating system in case they are going
 			 * to be retried. "ick"
 			 */
+			ahd_schedule_completeq(ahd);
 			break;
 		}
+		TAILQ_REMOVE(&ahd->platform_data->completeq,
+			     acmd, acmd_links.tqe);
+		cmd = &acmd_scsi_cmd(acmd);
+		cmd->host_scribble = NULL;
+		if (ahd_cmd_get_transaction_status(cmd) != DID_OK
+		 || (cmd->result & 0xFF) != SCSI_STATUS_OK)
+			with_errors++;
+
+		cmd->scsi_done(cmd);
 	}
 	ahd_done_unlock(ahd, &done_flags);
 	return (acmd);
@@ -825,6 +809,67 @@
 static int	   ahd_linux_abort(Scsi_Cmnd *);
 
 /*
+ * Calculate a safe value for AHD_NSEG (as expressed through ahd_linux_nseg).
+ *
+ * In pre-2.5.X...
+ * The midlayer allocates an S/G array dynamically when a command is issued
+ * using SCSI malloc.  This array, which is in an OS dependent format that
+ * must later be copied to our private S/G list, is sized to house just the
+ * number of segments needed for the current transfer.  Since the code that
+ * sizes the SCSI malloc pool does not take into consideration fragmentation
+ * of the pool, executing transactions numbering just a fraction of our
+ * concurrent transaction limit with SG list lengths aproaching AHC_NSEG will
+ * quickly depleat the SCSI malloc pool of usable space.  Unfortunately, the
+ * mid-layer does not properly handle this scsi malloc failures for the S/G
+ * array and the result can be a lockup of the I/O subsystem.  We try to size
+ * our S/G list so that it satisfies our drivers allocation requirements in
+ * addition to avoiding fragmentation of the SCSI malloc pool.
+ */
+static void
+ahd_linux_size_nseg(void)
+{
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+	u_int cur_size;
+	u_int best_size;
+
+	/*
+	 * The SCSI allocator rounds to the nearest 512 bytes
+	 * an cannot allocate across a page boundary.  Our algorithm
+	 * is to start at 1K of scsi malloc space per-command and
+	 * loop through all factors of the PAGE_SIZE and pick the best.
+	 */
+	best_size = 0;
+	for (cur_size = 1024; cur_size <= PAGE_SIZE; cur_size *= 2) {
+		u_int nseg;
+
+		nseg = cur_size / sizeof(struct scatterlist);
+		if (nseg < AHD_LINUX_MIN_NSEG)
+			continue;
+
+		if (best_size == 0) {
+			best_size = cur_size;
+			ahd_linux_nseg = nseg;
+		} else {
+			u_int best_rem;
+			u_int cur_rem;
+
+			/*
+			 * Compare the traits of the current "best_size"
+			 * with the current size to determine if the
+			 * current size is a better size.
+			 */
+			best_rem = best_size % sizeof(struct scatterlist);
+			cur_rem = cur_size % sizeof(struct scatterlist);
+			if (cur_rem < best_rem) {
+				best_size = cur_size;
+				ahd_linux_nseg = nseg;
+			}
+		}
+	}
+#endif
+}
+
+/*
  * Try to detect an Adaptec 79XX controller.
  */
 static int
@@ -852,6 +897,10 @@
 		printf("ahd_linux_detect: Unable to attach\n");
 		return (0);
 	}
+	/*
+	 * Determine an appropriate size for our Scatter Gatther lists.
+	 */
+	ahd_linux_size_nseg();
 #ifdef MODULE
 	/*
 	 * If we've been passed any parameters, process them now.
@@ -991,7 +1040,7 @@
 
 		ahd_cmd_set_transaction_status(cmd, CAM_REQUEUE_REQ);
 		ahd_linux_queue_cmd_complete(ahd, cmd);
-		ahd_schedule_completeq(ahd, NULL);
+		ahd_schedule_completeq(ahd);
 		ahd_midlayer_entrypoint_unlock(ahd, &flags);
 		return (0);
 	}
@@ -1001,7 +1050,7 @@
 	if (dev == NULL) {
 		ahd_cmd_set_transaction_status(cmd, CAM_RESRC_UNAVAIL);
 		ahd_linux_queue_cmd_complete(ahd, cmd);
-		ahd_schedule_completeq(ahd, NULL);
+		ahd_schedule_completeq(ahd);
 		ahd_midlayer_entrypoint_unlock(ahd, &flags);
 		printf("%s: aic79xx_linux_queue - Unable to allocate device!\n",
 		       ahd_name(ahd));
@@ -1087,7 +1136,8 @@
 	 && (dev->flags & AHD_DEV_SLAVE_CONFIGURED) != 0) {
 		dev->flags |= AHD_DEV_UNCONFIGURED;
 		if (TAILQ_EMPTY(&dev->busyq)
-		 && dev->active == 0)
+		 && dev->active == 0
+		 && (dev->flags & AHD_DEV_TIMER_ACTIVE) == 0)
 			ahd_linux_free_device(ahd, dev);
 	}
 	ahd_midlayer_entrypoint_unlock(ahd, &flags);
@@ -1102,15 +1152,30 @@
 			     Scsi_Device * scsi_devs)
 {
 	Scsi_Device *device;
+	Scsi_Device *ldev;
 	struct	ahd_softc *ahd;
 	u_long	flags;
-	int	scbnum;
 
 	ahd = *((struct ahd_softc **)host->hostdata);
 	ahd_lock(ahd, &flags);
-	scbnum = 0;
 	for (device = scsi_devs; device != NULL; device = device->next) {
 
+		/*
+		 * Watch out for duplicate devices.  This works around
+		 * some quirks in how the SCSI scanning code does its
+		 * device management.
+		 */
+		for (ldev = scsi_devs; ldev != device; ldev = ldev->next) {
+			if (ldev->host == device->host
+			 && ldev->channel == device->channel
+			 && ldev->id == device->id
+			 && ldev->lun == device->lun)
+				break;
+		}
+		/* Skip duplicate. */
+		if (ldev != device)
+			continue;
+
 		if (device->host == host) {
 			struct	 ahd_linux_device *dev;
 
@@ -1226,6 +1291,7 @@
 	u_int  last_phase;
 	u_int  cdb_byte;
 	int    retval;
+	int    was_paused;
 	int    paused;
 	int    wait;
 	int    disconnected;
@@ -1265,7 +1331,7 @@
 	 * Start by searching the device queue.  If not found
 	 * there, check the pending_scb list.  If not found
 	 * at all, and the system wanted us to just abort the
-	 * command return success.
+	 * command, return success.
 	 */
 	dev = ahd_linux_get_device(ahd, cmd->device->channel,
 				   cmd->device->id, cmd->device->lun,
@@ -1328,6 +1394,7 @@
 	 * didn't "just" miss an interrupt that would
 	 * affect this cmd.
 	 */
+	was_paused = ahd_is_paused(ahd);
 	ahd_pause_and_flushwork(ahd);
 	paused = TRUE;
 
@@ -1338,11 +1405,13 @@
 		goto no_cmd;
 	}
 
+	printf("%s: At time of recovery, card was %spaused\n",
+	       ahd_name(ahd), was_paused ? "" : "not ");
 	ahd_dump_card_state(ahd);
 
 	disconnected = TRUE;
 	if (ahd_search_qinfifo(ahd, cmd->device->id, cmd->device->channel + 'A',
-			       cmd->device->lun, pending_scb->hscb->tag,
+			       cmd->device->lun, SCB_GET_TAG(pending_scb),
 			       ROLE_INITIATOR, CAM_REQ_ABORTED,
 			       SEARCH_COMPLETE) > 0) {
 		printf("%s:%d:%d:%d: Cmd aborted from QINFIFO\n",
@@ -1371,7 +1440,7 @@
 	 * bus or is in the disconnected state.
 	 */
 	if (last_phase != P_BUSFREE
-	 && pending_scb->hscb->tag == active_scbptr) {
+	 && SCB_GET_TAG(pending_scb) == active_scbptr) {
 
 		/*
 		 * We're active on the bus, so assert ATN
@@ -1392,7 +1461,7 @@
 		 * to select the device before it reconnects.
 		 */
 		pending_scb->flags |= SCB_RECOVERY_SCB|SCB_ABORT;
-		ahd_set_scbptr(ahd, pending_scb->hscb->tag);
+		ahd_set_scbptr(ahd, SCB_GET_TAG(pending_scb));
 		pending_scb->hscb->cdb_len = 0;
 		pending_scb->hscb->task_attribute = 0;
 		pending_scb->hscb->task_management = SIU_TASKMGMT_ABORT_TASK;
@@ -1476,21 +1545,15 @@
 		printf("Recovery code sleeping\n");
 		down(&ahd->platform_data->eh_sem);
 		printf("Recovery code awake\n");
-        	ret = del_timer(&timer);
+        	ret = del_timer_sync(&timer);
 		if (ret == 0) {
 			printf("Timer Expired\n");
 			retval = FAILED;
 		}
 		spin_lock_irq(&ahd->platform_data->spin_lock);
 	}
-	acmd = TAILQ_FIRST(&ahd->platform_data->completeq);
-	TAILQ_INIT(&ahd->platform_data->completeq);
 	ahd_schedule_runq(ahd);
-	if (acmd != NULL) {
-		acmd = ahd_linux_run_complete_queue(ahd, acmd);
-		if (acmd != NULL)
-			ahd_schedule_completeq(ahd, acmd);
-	}
+	ahd_linux_run_complete_queue(ahd);
 	ahd_midlayer_entrypoint_unlock(ahd, &s);
 	return (retval);
 }
@@ -1515,7 +1578,6 @@
 	struct	ahd_tmode_tstate *tstate;
 	struct	scb *scb;
 	struct	hardware_scb *hscb;
-	struct	ahd_cmd *acmd;
 	u_long	s;
 	struct	timer_list timer;
 	int	retval;
@@ -1581,19 +1643,13 @@
 	down(&ahd->platform_data->eh_sem);
 	printf("Recovery code awake\n");
 	retval = SUCCESS;
-	if (del_timer(&timer) == 0) {
+	if (del_timer_sync(&timer) == 0) {
 		printf("Timer Expired\n");
 		retval = FAILED;
 	}
 	spin_lock_irq(&ahd->platform_data->spin_lock);
-	acmd = TAILQ_FIRST(&ahd->platform_data->completeq);
-	TAILQ_INIT(&ahd->platform_data->completeq);
 	ahd_schedule_runq(ahd);
-	if (acmd != NULL) {
-		acmd = ahd_linux_run_complete_queue(ahd, acmd);
-		if (acmd != NULL)
-			ahd_schedule_completeq(ahd, acmd);
-	}
+	ahd_linux_run_complete_queue(ahd);
 	ahd_midlayer_entrypoint_unlock(ahd, &s);
 	printf("%s: Device reset returning 0x%x\n", ahd_name(ahd), retval);
 	return (retval);
@@ -1606,7 +1662,6 @@
 ahd_linux_bus_reset(Scsi_Cmnd *cmd)
 {
 	struct ahd_softc *ahd;
-	struct ahd_cmd *acmd;
 	u_long s;
 	int    found;
 
@@ -1619,14 +1674,7 @@
 	ahd_midlayer_entrypoint_lock(ahd, &s);
 	found = ahd_reset_channel(ahd, cmd->device->channel + 'A',
 				  /*initiate reset*/TRUE);
-	acmd = TAILQ_FIRST(&ahd->platform_data->completeq);
-	TAILQ_INIT(&ahd->platform_data->completeq);
-
-	if (acmd != NULL) {
-		acmd = ahd_linux_run_complete_queue(ahd, acmd);
-		if (acmd != NULL)
-			ahd_schedule_completeq(ahd, acmd);
-	}
+	ahd_linux_run_complete_queue(ahd);
 	ahd_midlayer_entrypoint_unlock(ahd, &s);
 
 	if (bootverbose)
@@ -1650,7 +1698,6 @@
 #endif
 	.can_queue		= AHD_MAX_QUEUE,
 	.this_id		= -1,
-	.sg_tablesize		= AHD_NSEG,
 	.cmd_per_lun		= 2,
 	.use_clustering		= ENABLE_CLUSTERING,
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,7)
@@ -1708,44 +1755,17 @@
 		TAILQ_REMOVE(&ahd->platform_data->device_runq, dev, links);
 		dev->flags &= ~AHD_DEV_ON_RUN_LIST;
 		ahd_linux_check_device_queue(ahd, dev);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 		/* Yeild to our interrupt handler */
 		ahd_unlock(ahd, &flags);
 		ahd_lock(ahd, &flags);
+#endif
 	}
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 	ahd_unlock(ahd, &flags);
 #endif
 }
 
-/************************ Shutdown/halt/reboot hook ***************************/
-#include <linux/notifier.h>
-#include <linux/reboot.h>
-
-static struct notifier_block ahd_linux_notifier = {
-	ahd_linux_halt, NULL, 0
-};
-
-static int ahd_linux_halt(struct notifier_block *nb, u_long event, void *buf)
-{
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-	struct ahd_softc *ahd;
-
-	/*
-	 * In 2.5.X, this is called prior to the filesystems
-	 * being synced and the SCSI layer being properly
-	 * shutdown.  A different API is required there,
-	 * but the device hooks for this don't quite look
-	 * right.
-	 */
-	if (event == SYS_DOWN || event == SYS_HALT) {
-		TAILQ_FOREACH(ahd, &ahd_tailq, links) {
-			ahd_shutdown(ahd);
-		}
-	}
-#endif
-	return (NOTIFY_OK);
-}
-
 /******************************** Bus DMA *************************************/
 int
 ahd_dma_tag_create(struct ahd_softc *ahd, bus_dma_tag_t parent,
@@ -1927,7 +1947,7 @@
 }
 
 static void
-ahd_linux_setup_tag_info(void *arg, int instance, int targ, int32_t value)
+ahd_linux_setup_tag_info(u_long arg, int instance, int targ, int32_t value)
 {
 
 	if ((instance >= 0) && (targ >= 0)
@@ -1940,18 +1960,18 @@
 }
 
 static void
-ahd_linux_setup_rd_strm_info(void *arg, int instance, int targ, int32_t value)
+ahd_linux_setup_rd_strm_info(u_long arg, int instance, int targ, int32_t value)
 {
 	if ((instance >= 0)
 	 && (instance < NUM_ELEMENTS(aic79xx_rd_strm_info))) {
-		aic79xx_rd_strm_info[instance] = value * 0xFFFF;
+		aic79xx_rd_strm_info[instance] = value & 0xFFFF;
 		if (bootverbose)
 			printf("rd_strm[%d] = 0x%x\n", instance, value);
 	}
 }
 
 static void
-ahd_linux_setup_dv(void *arg, int instance, int targ, int32_t value)
+ahd_linux_setup_dv(u_long arg, int instance, int targ, int32_t value)
 {
 	if ((instance >= 0)
 	 && (instance < NUM_ELEMENTS(aic79xx_dv_settings))) {
@@ -1962,11 +1982,9 @@
 }
 
 static void
-ahd_linux_setup_iocell_info(void *arg, int instance, int targ, int32_t value)
+ahd_linux_setup_iocell_info(u_long index, int instance, int targ, int32_t value)
 {
-	u_int index;
 
-	index = (u_int)arg;
 	if ((instance >= 0)
 	 && (instance < NUM_ELEMENTS(aic79xx_iocell_info))) {
 		uint8_t *iocell_info;
@@ -1974,7 +1992,7 @@
 		iocell_info = (uint8_t*)&aic79xx_iocell_info[instance];
 		iocell_info[index] = value & 0xFFFF;
 		if (bootverbose)
-			printf("iocell[%d:%d] = %d\n", instance, index, value);
+			printf("iocell[%d:%ld] = %d\n", instance, index, value);
 	}
 }
 
@@ -2053,32 +2071,31 @@
 			ahd_linux_setup_tag_info_global(p + n);
 		} else if (strncmp(p, "tag_info", n) == 0) {
 			s = aic_parse_brace_option("tag_info", p + n, end,
-			    2, ahd_linux_setup_tag_info, NULL);
+			    2, ahd_linux_setup_tag_info, 0);
 		} else if (strncmp(p, "rd_strm", n) == 0) {
-			printf("Calling brace parse for %s\n", p);
 			s = aic_parse_brace_option("rd_strm", p + n, end,
-			    1, ahd_linux_setup_rd_strm_info, NULL);
+			    1, ahd_linux_setup_rd_strm_info, 0);
 		} else if (strncmp(p, "dv", n) == 0) {
 			s = aic_parse_brace_option("dv", p + n, end, 1,
-			    ahd_linux_setup_dv, NULL);
+			    ahd_linux_setup_dv, 0);
 		} else if (strncmp(p, "slewrate", n) == 0) {
 			s = aic_parse_brace_option("slewrate",
 			    p + n, end, 1, ahd_linux_setup_iocell_info,
-			    (void *)AIC79XX_SLEWRATE_INDEX);
+			    AIC79XX_SLEWRATE_INDEX);
 		} else if (strncmp(p, "precomp", n) == 0) {
 			s = aic_parse_brace_option("precomp",
 			    p + n, end, 1, ahd_linux_setup_iocell_info,
-			    (void *)AIC79XX_PRECOMP_INDEX);
+			    AIC79XX_PRECOMP_INDEX);
 		} else if (strncmp(p, "amplitude", n) == 0) {
 			s = aic_parse_brace_option("amplitude",
 			    p + n, end, 1, ahd_linux_setup_iocell_info,
-			    (void *)AIC79XX_AMPLITUDE_INDEX);
+			    AIC79XX_AMPLITUDE_INDEX);
 		} else if (p[n] == ':') {
 			*(options[i].flag) = simple_strtoul(p + n + 1, NULL, 0);
 		} else if (!strncmp(p, "verbose", n)) {
 			*(options[i].flag) = 1;
 		} else {
-			*(options[i].flag) = ~(*(options[i].flag));
+			*(options[i].flag) ^= 0xFFFFFFFF;
 		}
 	}
 	return 1;
@@ -2088,7 +2105,7 @@
 __setup("aic79xx=", aic79xx_setup);
 #endif
 
-int aic79xx_verbose;
+uint32_t aic79xx_verbose;
 
 int
 ahd_linux_register_host(struct ahd_softc *ahd, Scsi_Host_Template *template)
@@ -2120,6 +2137,7 @@
 	host->max_id = (ahd->features & AHD_WIDE) ? 16 : 8;
 	host->max_lun = AHD_NUM_LUNS;
 	host->max_channel = 0;
+	host->sg_tablesize = AHD_NSEG;
 	ahd_set_unit(ahd, ahd_linux_next_unit());
 	sprintf(buf, "scsi%d", host->host_no);
 	new_name = malloc(strlen(buf) + 1, M_DEVBUF, M_NOWAIT);
@@ -2291,8 +2309,6 @@
 #endif
 	ahd_setup_runq_tasklet(ahd);
 	ahd->seltime = (aic79xx_seltime & 0x3) << 4;
-	if (TAILQ_EMPTY(&ahd_tailq))
-		register_reboot_notifier(&ahd_linux_notifier);
 	return (0);
 }
 
@@ -2304,6 +2320,7 @@
 	int i, j;
 
 	if (ahd->platform_data != NULL) {
+		del_timer_sync(&ahd->platform_data->completeq_timer);
 		ahd_linux_kill_dv_thread(ahd);
 		ahd_teardown_runq_tasklet(ahd);
 		if (ahd->platform_data->host != NULL) {
@@ -2317,15 +2334,20 @@
 		for (i = 0; i < AHD_NUM_TARGETS; i++) {
 			targ = ahd->platform_data->targets[i];
 			if (targ != NULL) {
+				/* Keep target around through the loop. */
+				targ->refcount++;
 				for (j = 0; j < AHD_NUM_LUNS; j++) {
-					if (targ->devices[j] != NULL) {
-						dev = targ->devices[j];
-						ahd_linux_free_device(ahd, dev);
-					}
-					if (ahd->platform_data->targets[i] ==
-					    NULL)
-						break;
+
+					if (targ->devices[j] == NULL)
+						continue;
+					dev = targ->devices[j];
+					ahd_linux_free_device(ahd, dev);
 				}
+				/*
+				 * Forcibly free the target now that
+				 * all devices are gone.
+				 */
+				ahd_linux_free_target(ahd, targ);
 			}
 		}
 
@@ -2546,19 +2568,12 @@
 static void
 ahd_linux_thread_run_complete_queue(struct ahd_softc *ahd)
 {
-	struct ahd_cmd *acmd;
 	u_long flags;
 
 	ahd_lock(ahd, &flags);
 	del_timer(&ahd->platform_data->completeq_timer);
 	ahd->platform_data->flags &= ~AHD_RUN_CMPLT_Q_TIMER;
-	acmd = TAILQ_FIRST(&ahd->platform_data->completeq);
-	TAILQ_INIT(&ahd->platform_data->completeq);
-	if (acmd != NULL) {
-		acmd = ahd_linux_run_complete_queue(ahd, acmd);
-		if (acmd != NULL)
-			ahd_schedule_completeq(ahd, acmd);
-	}
+	ahd_linux_run_complete_queue(ahd);
 	ahd_unlock(ahd, &flags);
 }
 
@@ -2921,10 +2936,14 @@
 	}
 
 	ahd_lock(ahd, &s);
-	if (targ->dv_buffer != NULL)
+	if (targ->dv_buffer != NULL) {
 		free(targ->dv_buffer, M_DEVBUF);
-	if (targ->dv_buffer1 != NULL)
+		targ->dv_buffer = NULL;
+	}
+	if (targ->dv_buffer1 != NULL) {
 		free(targ->dv_buffer1, M_DEVBUF);
+		targ->dv_buffer1 = NULL;
+	}
 	targ->flags &= ~AHD_DV_REQUIRED;
 	if (targ->refcount == 0)
 		ahd_linux_free_target(ahd, targ);
@@ -3760,7 +3779,6 @@
 ahd_linux_dv_timeout(struct scsi_cmnd *cmd)
 {
 	struct	ahd_softc *ahd;
-	struct	ahd_cmd *acmd;
 	struct	scb *scb;
 	u_long	flags;
 
@@ -3807,16 +3825,9 @@
 	ahd->platform_data->reset_timer.function =
 	    (ahd_linux_callback_t *)ahd_release_simq;
 	add_timer(&ahd->platform_data->reset_timer);
-	acmd = TAILQ_FIRST(&ahd->platform_data->completeq);
-	TAILQ_INIT(&ahd->platform_data->completeq);
 	if (ahd_linux_next_device_to_run(ahd) != NULL)
 		ahd_schedule_runq(ahd);
-	if (acmd != NULL) {
-		acmd = ahd_linux_run_complete_queue(ahd, acmd);
-		if (acmd != NULL) {
-			ahd_schedule_completeq(ahd, acmd);
-		}
-	}
+	ahd_linux_run_complete_queue(ahd);
 	ahd_unlock(ahd, &flags);
 }
 
@@ -4025,9 +4036,8 @@
 	 && dev->scsi_device->tagged_supported != 0) {
 
 		ahd_set_tags(ahd, &devinfo, AHD_QUEUE_TAGGED);
-		printf("scsi%d:%c:%d:%d: Tagged Queuing enabled.  Depth %d\n",
-	       	       ahd->platform_data->host->host_no, devinfo.channel,
-		       devinfo.target, devinfo.lun, tags);
+		ahd_print_devinfo(ahd, &devinfo);
+		printf("Tagged Queuing enabled.  Depth %d\n", tags);
 	} else {
 		ahd_set_tags(ahd, &devinfo, AHD_QUEUE_NONE);
 	}
@@ -4201,38 +4211,29 @@
 /*
  * SCSI controller interrupt handler.
  */
-void
+AIC_LINUX_IRQRETURN_T
 ahd_linux_isr(int irq, void *dev_id, struct pt_regs * regs)
 {
 	struct	ahd_softc *ahd;
-	struct	ahd_cmd *acmd;
 	u_long	flags;
+	int	ours;
 
 	ahd = (struct ahd_softc *) dev_id;
 	ahd_lock(ahd, &flags); 
-	ahd_intr(ahd);
-	acmd = TAILQ_FIRST(&ahd->platform_data->completeq);
-	TAILQ_INIT(&ahd->platform_data->completeq);
+	ours = ahd_intr(ahd);
 	if (ahd_linux_next_device_to_run(ahd) != NULL)
 		ahd_schedule_runq(ahd);
-	if (acmd != NULL) {
-		acmd = ahd_linux_run_complete_queue(ahd, acmd);
-		if (acmd != NULL) {
-			ahd_schedule_completeq(ahd, acmd);
-		}
-	}
+	ahd_linux_run_complete_queue(ahd);
 	ahd_unlock(ahd, &flags);
+	AIC_LINUX_IRQRETURN(ours);
 }
 
 void
 ahd_platform_flushwork(struct ahd_softc *ahd)
 {
-	struct ahd_cmd *acmd;
 
-	acmd = TAILQ_FIRST(&ahd->platform_data->completeq);
-	TAILQ_INIT(&ahd->platform_data->completeq);
-	while (acmd != NULL)
-		acmd = ahd_linux_run_complete_queue(ahd, acmd);
+	while (ahd_linux_run_complete_queue(ahd) != NULL)
+		;
 }
 
 static struct ahd_linux_target*
@@ -4403,22 +4404,19 @@
 	}
         case AC_SENT_BDR:
 	{
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+		WARN_ON(lun != CAM_LUN_WILDCARD);
+		scsi_report_device_reset(ahd->platform_data->host,
+					 channel - 'A', target);
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
 		Scsi_Device *scsi_dev;
 
 		/*
 		 * Find the SCSI device associated with this
 		 * request and indicate that a UA is expected.
-		 * XXX This should really be handled by the mid-layer.
 		 */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
-		list_for_each_entry(scsi_dev,
-				    &ahd->platform_data->host->my_devices,
-				    siblings) {
-#else
 		for (scsi_dev = ahd->platform_data->host->host_queue;
 		     scsi_dev != NULL; scsi_dev = scsi_dev->next) {
-#endif
 			if (channel - 'A' == scsi_dev->channel
 			 && target == scsi_dev->id
 			 && (lun == CAM_LUN_WILDCARD
@@ -4452,13 +4450,12 @@
 	Scsi_Cmnd *cmd;
 	struct	  ahd_linux_device *dev;
 
-	LIST_REMOVE(scb, pending_links);
-
 	if ((scb->flags & SCB_ACTIVE) == 0) {
-		printf("SCB %d done'd twice\n", scb->hscb->tag);
+		printf("SCB %d done'd twice\n", SCB_GET_TAG(scb));
 		ahd_dump_card_state(ahd);
 		panic("Stopping for safety");
 	}
+	LIST_REMOVE(scb, pending_links);
 	cmd = scb->io_ctx;
 	dev = scb->platform_data->dev;
 	dev->active--;
@@ -4542,7 +4539,8 @@
 
 	if (TAILQ_EMPTY(&dev->busyq)) {
 		if ((dev->flags & AHD_DEV_UNCONFIGURED) != 0
-		 && dev->active == 0)
+		 && dev->active == 0
+		 && (dev->flags & AHD_DEV_TIMER_ACTIVE) == 0)
 			ahd_linux_free_device(ahd, dev);
 	} else if ((dev->flags & AHD_DEV_ON_RUN_LIST) == 0) {
 		TAILQ_INSERT_TAIL(&ahd->platform_data->device_runq, dev, links);
@@ -5065,6 +5063,9 @@
 	if (dev->qfrozen == 0
 	 && (dev->flags & AHD_DEV_ON_RUN_LIST) == 0)
 		ahd_linux_run_device_queue(ahd, dev);
+	if ((dev->flags & AHD_DEV_UNCONFIGURED) != 0
+	 && dev->active == 0)
+		ahd_linux_free_device(ahd, dev);
 	ahd_unlock(ahd, &s);
 }
 
@@ -5143,8 +5144,6 @@
 	scsi_unregister_module(MODULE_SCSI_HA, &aic79xx_driver_template);
 #endif
 	ahd_linux_pci_exit();
-
-	unregister_reboot_notifier(&ahd_linux_notifier);
 }
 
 module_init(ahd_linux_init);
diff -urN linux-2.5.69-bk7/drivers/scsi/aic7xxx/aic79xx_osm.h linux-2.5.69-bk8/drivers/scsi/aic7xxx/aic79xx_osm.h
--- linux-2.5.69-bk7/drivers/scsi/aic7xxx/aic79xx_osm.h	2003-05-04 16:53:32.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/aic7xxx/aic79xx_osm.h	2003-05-13 04:44:29.000000000 -0700
@@ -36,7 +36,7 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  *
- * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#121 $
+ * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#130 $
  *
  */
 #ifndef _AIC79XX_LINUX_H_
@@ -139,7 +139,7 @@
 #endif /* BYTE_ORDER */
 
 /************************* Configuration Data *********************************/
-extern int aic79xx_allow_memio;
+extern uint32_t aic79xx_allow_memio;
 extern int aic79xx_detect_complete;
 extern Scsi_Host_Template aic79xx_driver_template;
 
@@ -246,7 +246,7 @@
 typedef struct timer_list ahd_timer_t;
 
 /********************************** Includes **********************************/
-#if CONFIG_AIC79XX_REG_PRETTY_PRINT
+#ifdef CONFIG_AIC79XX_REG_PRETTY_PRINT
 #define AIC_DEBUG_REGISTERS 1
 #else
 #define AIC_DEBUG_REGISTERS 0
@@ -255,7 +255,7 @@
 
 /***************************** Timer Facilities *******************************/
 #define ahd_timer_init init_timer
-#define ahd_timer_stop del_timer
+#define ahd_timer_stop del_timer_sync
 typedef void ahd_linux_callback_t (u_long);  
 static __inline void ahd_timer_reset(ahd_timer_t *timer, u_int usec,
 				     ahd_callback_t *func, void *arg);
@@ -293,7 +293,7 @@
 #define AHD_SCSI_HAS_HOST_LOCK 0
 #endif
 
-#define AIC79XX_DRIVER_VERSION "1.3.5"
+#define AIC79XX_DRIVER_VERSION "1.3.8"
 
 /**************************** Front End Queues ********************************/
 /*
@@ -488,7 +488,18 @@
  * manner and are allocated below 4GB, the number of S/G segments is
  * unrestricted.
  */
-#define        AHD_NSEG 128
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+/*
+ * We dynamically adjust the number of segments in pre-2.5 kernels to
+ * avoid fragmentation issues in the SCSI mid-layer's private memory
+ * allocator.  See aic79xx_osm.c ahd_linux_size_nseg() for details.
+ */
+extern u_int ahd_linux_nseg;
+#define	AHD_NSEG ahd_linux_nseg
+#define	AHD_LINUX_MIN_NSEG 64
+#else
+#define	AHD_NSEG 128
+#endif
 
 /*
  * Per-SCB OSM storage.
@@ -532,9 +543,7 @@
 	TAILQ_HEAD(, ahd_linux_device) device_runq;
 	struct ahd_completeq	 completeq;
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,93)
 	spinlock_t		 spin_lock;
-#endif
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 	struct tasklet_struct	 runq_tasklet;
 #endif
@@ -730,7 +739,6 @@
 static __inline void ahd_list_lock(unsigned long *flags);
 static __inline void ahd_list_unlock(unsigned long *flags);
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,93)
 static __inline void
 ahd_lockinit(struct ahd_softc *ahd)
 {
@@ -818,63 +826,6 @@
 	spin_unlock_irqrestore(&ahd_list_spinlock, *flags);
 }
 
-#else /* LINUX_VERSION_CODE < KERNEL_VERSION(2,1,0) */
-
-ahd_lockinit(struct ahd_softc *ahd)
-{
-}
-
-static __inline void
-ahd_lock(struct ahd_softc *ahd, unsigned long *flags)
-{
-	save_flags(*flags);
-	cli();
-}
-
-static __inline void
-ahd_unlock(struct ahd_softc *ahd, unsigned long *flags)
-{
-	restore_flags(*flags);
-}
-
-ahd_done_lockinit(struct ahd_softc *ahd)
-{
-}
-
-static __inline void
-ahd_done_lock(struct ahd_softc *ahd, unsigned long *flags)
-{
-	/*
-	 * The done lock is always held while
-	 * the ahd lock is held so blocking
-	 * interrupts again would have no effect.
-	 */
-}
-
-static __inline void
-ahd_done_unlock(struct ahd_softc *ahd, unsigned long *flags)
-{
-}
-
-static __inline void
-ahd_list_lockinit()
-{
-}
-
-static __inline void
-ahd_list_lock(unsigned long *flags)
-{
-	save_flags(*flags);
-	cli();
-}
-
-static __inline void
-ahd_list_unlock(unsigned long *flags)
-{
-	restore_flags(*flags);
-}
-#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,1,0) */
-
 /******************************* PCI Definitions ******************************/
 /*
  * PCIM_xxx: mask to locate subfield in register
@@ -945,16 +896,6 @@
 			    ahd_power_state new_state);
 
 /******************************* PCI Routines *********************************/
-/*
- * We need to use the bios32.h routines if we are kernel version 2.1.92 or less.
- */
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,1,92)
-#if defined(__sparc_v9__) || defined(__powerpc__)
-#error "PPC and Sparc platforms are only supported under 2.1.92 and above"
-#endif
-#include <linux/bios32.h>
-#endif
-
 int			 ahd_linux_pci_init(void);
 void			 ahd_linux_pci_exit(void);
 int			 ahd_pci_map_registers(struct ahd_softc *ahd);
@@ -1270,7 +1211,8 @@
 int	ahd_platform_abort_scbs(struct ahd_softc *ahd, int target,
 				char channel, int lun, u_int tag,
 				role_t role, uint32_t status);
-void	ahd_linux_isr(int irq, void *dev_id, struct pt_regs * regs);
+AIC_LINUX_IRQRETURN_T
+	ahd_linux_isr(int irq, void *dev_id, struct pt_regs * regs);
 void	ahd_platform_flushwork(struct ahd_softc *ahd);
 int	ahd_softc_comp(struct ahd_softc *, struct ahd_softc *);
 void	ahd_done(struct ahd_softc*, struct scb*);
@@ -1285,5 +1227,5 @@
 #define AHD_PCI_CONFIG 0
 #endif
 #define bootverbose aic79xx_verbose
-extern int aic79xx_verbose;
+extern uint32_t aic79xx_verbose;
 #endif /* _AIC79XX_LINUX_H_ */
diff -urN linux-2.5.69-bk7/drivers/scsi/aic7xxx/aic79xx_pci.c linux-2.5.69-bk8/drivers/scsi/aic7xxx/aic79xx_pci.c
--- linux-2.5.69-bk7/drivers/scsi/aic7xxx/aic79xx_pci.c	2003-05-04 16:53:14.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/aic7xxx/aic79xx_pci.c	2003-05-13 04:44:29.000000000 -0700
@@ -38,7 +38,7 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  *
- * $Id: //depot/aic7xxx/aic7xxx/aic79xx_pci.c#70 $
+ * $Id: //depot/aic7xxx/aic7xxx/aic79xx_pci.c#71 $
  *
  * $FreeBSD$
  */
@@ -565,14 +565,13 @@
 #if AHD_DEBUG
 	if (have_seeprom != 0
 	 && (ahd_debug & AHD_DUMP_SEEPROM) != 0) {
-		uint8_t *sc_data;
-		int	 i;
+		uint16_t *sc_data;
+		int	  i;
 
 		printf("%s: Seeprom Contents:", ahd_name(ahd));
-		sc_data = (uint8_t *)sc;
+		sc_data = (uint16_t *)sc;
 		for (i = 0; i < (sizeof(*sc)); i += 2)
-			printf("\n\t0x%.4x", 
-			       sc_data[i] | (sc_data[i+1] << 8));
+			printf("\n\t0x%.4x", sc_data[i]);
 		printf("\n");
 	}
 #endif
diff -urN linux-2.5.69-bk7/drivers/scsi/aic7xxx/aic79xx_proc.c linux-2.5.69-bk8/drivers/scsi/aic7xxx/aic79xx_proc.c
--- linux-2.5.69-bk7/drivers/scsi/aic7xxx/aic79xx_proc.c	2003-05-04 16:53:36.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/aic7xxx/aic79xx_proc.c	2003-05-13 04:44:29.000000000 -0700
@@ -37,7 +37,7 @@
  * String handling code courtesy of Gerard Roudier's <groudier@club-internet.fr>
  * sym driver.
  *
- * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_proc.c#14 $
+ * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_proc.c#17 $
  */
 #include "aic79xx_osm.h"
 #include "aic79xx_inline.h"
@@ -173,8 +173,7 @@
 
 	tinfo = ahd_fetch_transinfo(ahd, channel, our_id,
 				    target_id, &tstate);
-	copy_info(info, "Channel %c Target %d Negotiation Settings\n",
-		  channel, target_id);
+	copy_info(info, "Target %d Negotiation Settings\n", target_id);
 	copy_info(info, "\tUser: ");
 	ahd_format_transinfo(info, &tinfo->user);
 	targ = ahd->platform_data->targets[target_offset];
@@ -318,7 +317,11 @@
 		  AIC79XX_DRIVER_VERSION);
 	copy_info(&info, "%s\n", ahd->description);
 	ahd_controller_info(ahd, ahd_info);
-	copy_info(&info, "%s\n\n", ahd_info);
+	copy_info(&info, "%s\n", ahd_info);
+	copy_info(&info, "Allocated SCBs: %d, SG List Length: %d\n\n",
+		  ahd->scb_data.numscbs, AHD_NSEG);
+
+	max_targ = 15;
 
 	if (ahd->seep_config == NULL)
 		copy_info(&info, "No Serial EEPROM\n");
@@ -335,7 +338,6 @@
 	}
 	copy_info(&info, "\n");
 
-	max_targ = 15;
 	if ((ahd->features & AHD_WIDE) == 0)
 		max_targ = 7;
 
diff -urN linux-2.5.69-bk7/drivers/scsi/aic7xxx/aic79xx_reg.h_shipped linux-2.5.69-bk8/drivers/scsi/aic7xxx/aic79xx_reg.h_shipped
--- linux-2.5.69-bk7/drivers/scsi/aic7xxx/aic79xx_reg.h_shipped	2003-05-04 16:53:56.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/aic7xxx/aic79xx_reg.h_shipped	2003-05-13 04:44:29.000000000 -0700
@@ -2,8 +2,8 @@
  * DO NOT EDIT - This file is automatically generated
  *		 from the following source files:
  *
- * $Id: //depot/aic7xxx/aic7xxx/aic79xx.seq#89 $
- * $Id: //depot/aic7xxx/aic7xxx/aic79xx.reg#65 $
+ * $Id: //depot/aic7xxx/aic7xxx/aic79xx.seq#91 $
+ * $Id: //depot/aic7xxx/aic7xxx/aic79xx.reg#67 $
  */
 typedef int (ahd_reg_print_t)(u_int, u_int *, u_int);
 typedef struct ahd_reg_parse_entry {
@@ -1924,17 +1924,10 @@
 #endif
 
 #if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_longjmp_scb_print;
-#else
-#define ahd_longjmp_scb_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "LONGJMP_SCB", 0xfa, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
 ahd_reg_print_t ahd_accum_save_print;
 #else
 #define ahd_accum_save_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "ACCUM_SAVE", 0xfc, regvalue, cur_col, wrap)
+    ahd_print_register(NULL, 0, "ACCUM_SAVE", 0xfa, regvalue, cur_col, wrap)
 #endif
 
 #if AIC_DEBUG_REGISTERS
@@ -2246,59 +2239,45 @@
 #endif
 
 #if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scb_tag_print;
-#else
-#define ahd_scb_tag_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCB_TAG", 0x190, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scb_cdb_len_print;
-#else
-#define ahd_scb_cdb_len_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCB_CDB_LEN", 0x192, regvalue, cur_col, wrap)
-#endif
-
-#if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scb_task_management_print;
+ahd_reg_print_t ahd_scb_dataptr_print;
 #else
-#define ahd_scb_task_management_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCB_TASK_MANAGEMENT", 0x193, regvalue, cur_col, wrap)
+#define ahd_scb_dataptr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCB_DATAPTR", 0x190, regvalue, cur_col, wrap)
 #endif
 
 #if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scb_next_print;
+ahd_reg_print_t ahd_scb_datacnt_print;
 #else
-#define ahd_scb_next_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCB_NEXT", 0x194, regvalue, cur_col, wrap)
+#define ahd_scb_datacnt_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCB_DATACNT", 0x198, regvalue, cur_col, wrap)
 #endif
 
 #if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scb_next2_print;
+ahd_reg_print_t ahd_scb_sgptr_print;
 #else
-#define ahd_scb_next2_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCB_NEXT2", 0x196, regvalue, cur_col, wrap)
+#define ahd_scb_sgptr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCB_SGPTR", 0x19c, regvalue, cur_col, wrap)
 #endif
 
 #if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scb_dataptr_print;
+ahd_reg_print_t ahd_scb_busaddr_print;
 #else
-#define ahd_scb_dataptr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCB_DATAPTR", 0x198, regvalue, cur_col, wrap)
+#define ahd_scb_busaddr_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCB_BUSADDR", 0x1a0, regvalue, cur_col, wrap)
 #endif
 
 #if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scb_datacnt_print;
+ahd_reg_print_t ahd_scb_next_print;
 #else
-#define ahd_scb_datacnt_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCB_DATACNT", 0x1a0, regvalue, cur_col, wrap)
+#define ahd_scb_next_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCB_NEXT", 0x1a4, regvalue, cur_col, wrap)
 #endif
 
 #if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scb_sgptr_print;
+ahd_reg_print_t ahd_scb_next2_print;
 #else
-#define ahd_scb_sgptr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCB_SGPTR", 0x1a4, regvalue, cur_col, wrap)
+#define ahd_scb_next2_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCB_NEXT2", 0x1a6, regvalue, cur_col, wrap)
 #endif
 
 #if AIC_DEBUG_REGISTERS
@@ -2330,10 +2309,24 @@
 #endif
 
 #if AIC_DEBUG_REGISTERS
-ahd_reg_print_t ahd_scb_busaddr_print;
+ahd_reg_print_t ahd_scb_cdb_len_print;
 #else
-#define ahd_scb_busaddr_print(regvalue, cur_col, wrap) \
-    ahd_print_register(NULL, 0, "SCB_BUSADDR", 0x1ac, regvalue, cur_col, wrap)
+#define ahd_scb_cdb_len_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCB_CDB_LEN", 0x1ac, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scb_task_management_print;
+#else
+#define ahd_scb_task_management_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCB_TASK_MANAGEMENT", 0x1ad, regvalue, cur_col, wrap)
+#endif
+
+#if AIC_DEBUG_REGISTERS
+ahd_reg_print_t ahd_scb_tag_print;
+#else
+#define ahd_scb_tag_print(regvalue, cur_col, wrap) \
+    ahd_print_register(NULL, 0, "SCB_TAG", 0x1ae, regvalue, cur_col, wrap)
 #endif
 
 #if AIC_DEBUG_REGISTERS
@@ -2367,6 +2360,7 @@
 #define		SPLTINT         	0x01
 
 #define	SEQINTCODE      		0x02
+#define		BAD_SCB_STATUS  	0x1a
 #define		SAW_HWERR       	0x19
 #define		TRACEPOINT3     	0x18
 #define		TRACEPOINT2     	0x17
@@ -3508,9 +3502,7 @@
 
 #define	LONGJMP_ADDR    		0xf8
 
-#define	LONGJMP_SCB     		0xfa
-
-#define	ACCUM_SAVE      		0xfc
+#define	ACCUM_SAVE      		0xfa
 
 #define	WAITING_SCB_TAILS		0x100
 
@@ -3656,29 +3648,24 @@
 #define	SCB_SENSE_BUSADDR		0x18c
 #define	SCB_NEXT_COMPLETE		0x18c
 
-#define	SCB_TAG         		0x190
-
-#define	SCB_CDB_LEN     		0x192
-#define		SCB_CDB_LEN_PTR 	0x80
-
-#define	SCB_TASK_MANAGEMENT		0x193
-
-#define	SCB_NEXT        		0x194
-#define	SCB_NEXT_SCB_BUSADDR		0x194
+#define	SCB_DATAPTR     		0x190
 
-#define	SCB_NEXT2       		0x196
-
-#define	SCB_DATAPTR     		0x198
-
-#define	SCB_DATACNT     		0x1a0
+#define	SCB_DATACNT     		0x198
 #define		SG_LAST_SEG     	0x80
 #define		SG_HIGH_ADDR_BITS	0x7f
 
-#define	SCB_SGPTR       		0x1a4
+#define	SCB_SGPTR       		0x19c
 #define		SG_STATUS_VALID 	0x04
 #define		SG_FULL_RESID   	0x02
 #define		SG_LIST_NULL    	0x01
 
+#define	SCB_BUSADDR     		0x1a0
+
+#define	SCB_NEXT        		0x1a4
+#define	SCB_NEXT_SCB_BUSADDR		0x1a4
+
+#define	SCB_NEXT2       		0x1a6
+
 #define	SCB_CONTROL     		0x1a8
 #define		TARGET_SCB      	0x80
 #define		DISCENB         	0x40
@@ -3697,7 +3684,13 @@
 
 #define	SCB_TASK_ATTRIBUTE		0x1ab
 
-#define	SCB_BUSADDR     		0x1ac
+#define	SCB_CDB_LEN     		0x1ac
+#define		SCB_CDB_LEN_PTR 	0x80
+
+#define	SCB_TASK_MANAGEMENT		0x1ad
+
+#define	SCB_TAG         		0x1ae
+#define	SCB_FIFO_USE_COUNT		0x1ae
 
 #define	SCB_SPARE       		0x1b0
 #define	SCB_PKT_LUN     		0x1b0
@@ -3775,5 +3768,5 @@
 
 
 /* Exported Labels */
-#define	LABEL_seq_isr 	0x26d
-#define	LABEL_timer_isr	0x269
+#define	LABEL_seq_isr 	0x270
+#define	LABEL_timer_isr	0x26c
diff -urN linux-2.5.69-bk7/drivers/scsi/aic7xxx/aic79xx_reg_print.c_shipped linux-2.5.69-bk8/drivers/scsi/aic7xxx/aic79xx_reg_print.c_shipped
--- linux-2.5.69-bk7/drivers/scsi/aic7xxx/aic79xx_reg_print.c_shipped	2003-05-04 16:52:48.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/aic7xxx/aic79xx_reg_print.c_shipped	2003-05-13 04:44:29.000000000 -0700
@@ -2,8 +2,8 @@
  * DO NOT EDIT - This file is automatically generated
  *		 from the following source files:
  *
- * $Id: //depot/aic7xxx/aic7xxx/aic79xx.seq#89 $
- * $Id: //depot/aic7xxx/aic7xxx/aic79xx.reg#65 $
+ * $Id: //depot/aic7xxx/aic7xxx/aic79xx.seq#91 $
+ * $Id: //depot/aic7xxx/aic7xxx/aic79xx.reg#67 $
  */
 
 #include "aic79xx_osm.h"
@@ -65,13 +65,14 @@
 	{ "TRACEPOINT1",	0x16, 0xff },
 	{ "TRACEPOINT2",	0x17, 0xff },
 	{ "TRACEPOINT3",	0x18, 0xff },
-	{ "SAW_HWERR",		0x19, 0xff }
+	{ "SAW_HWERR",		0x19, 0xff },
+	{ "BAD_SCB_STATUS",	0x1a, 0xff }
 };
 
 int
 ahd_seqintcode_print(u_int regvalue, u_int *cur_col, u_int wrap)
 {
-	return (ahd_print_register(SEQINTCODE_parse_table, 26, "SEQINTCODE",
+	return (ahd_print_register(SEQINTCODE_parse_table, 27, "SEQINTCODE",
 	    0x02, regvalue, cur_col, wrap));
 }
 
@@ -3098,17 +3099,10 @@
 }
 
 int
-ahd_longjmp_scb_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "LONGJMP_SCB",
-	    0xfa, regvalue, cur_col, wrap));
-}
-
-int
 ahd_accum_save_print(u_int regvalue, u_int *cur_col, u_int wrap)
 {
 	return (ahd_print_register(NULL, 0, "ACCUM_SAVE",
-	    0xfc, regvalue, cur_col, wrap));
+	    0xfa, regvalue, cur_col, wrap));
 }
 
 int
@@ -3492,49 +3486,10 @@
 }
 
 int
-ahd_scb_tag_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SCB_TAG",
-	    0x190, regvalue, cur_col, wrap));
-}
-
-static ahd_reg_parse_entry_t SCB_CDB_LEN_parse_table[] = {
-	{ "SCB_CDB_LEN_PTR",	0x80, 0x80 }
-};
-
-int
-ahd_scb_cdb_len_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(SCB_CDB_LEN_parse_table, 1, "SCB_CDB_LEN",
-	    0x192, regvalue, cur_col, wrap));
-}
-
-int
-ahd_scb_task_management_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SCB_TASK_MANAGEMENT",
-	    0x193, regvalue, cur_col, wrap));
-}
-
-int
-ahd_scb_next_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SCB_NEXT",
-	    0x194, regvalue, cur_col, wrap));
-}
-
-int
-ahd_scb_next2_print(u_int regvalue, u_int *cur_col, u_int wrap)
-{
-	return (ahd_print_register(NULL, 0, "SCB_NEXT2",
-	    0x196, regvalue, cur_col, wrap));
-}
-
-int
 ahd_scb_dataptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
 {
 	return (ahd_print_register(NULL, 0, "SCB_DATAPTR",
-	    0x198, regvalue, cur_col, wrap));
+	    0x190, regvalue, cur_col, wrap));
 }
 
 static ahd_reg_parse_entry_t SCB_DATACNT_parse_table[] = {
@@ -3546,7 +3501,7 @@
 ahd_scb_datacnt_print(u_int regvalue, u_int *cur_col, u_int wrap)
 {
 	return (ahd_print_register(SCB_DATACNT_parse_table, 2, "SCB_DATACNT",
-	    0x1a0, regvalue, cur_col, wrap));
+	    0x198, regvalue, cur_col, wrap));
 }
 
 static ahd_reg_parse_entry_t SCB_SGPTR_parse_table[] = {
@@ -3559,9 +3514,30 @@
 ahd_scb_sgptr_print(u_int regvalue, u_int *cur_col, u_int wrap)
 {
 	return (ahd_print_register(SCB_SGPTR_parse_table, 3, "SCB_SGPTR",
+	    0x19c, regvalue, cur_col, wrap));
+}
+
+int
+ahd_scb_busaddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SCB_BUSADDR",
+	    0x1a0, regvalue, cur_col, wrap));
+}
+
+int
+ahd_scb_next_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SCB_NEXT",
 	    0x1a4, regvalue, cur_col, wrap));
 }
 
+int
+ahd_scb_next2_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SCB_NEXT2",
+	    0x1a6, regvalue, cur_col, wrap));
+}
+
 static ahd_reg_parse_entry_t SCB_CONTROL_parse_table[] = {
 	{ "SCB_TAG_TYPE",	0x03, 0x03 },
 	{ "DISCONNECTED",	0x04, 0x04 },
@@ -3609,14 +3585,32 @@
 	    0x1ab, regvalue, cur_col, wrap));
 }
 
+static ahd_reg_parse_entry_t SCB_CDB_LEN_parse_table[] = {
+	{ "SCB_CDB_LEN_PTR",	0x80, 0x80 }
+};
+
 int
-ahd_scb_busaddr_print(u_int regvalue, u_int *cur_col, u_int wrap)
+ahd_scb_cdb_len_print(u_int regvalue, u_int *cur_col, u_int wrap)
 {
-	return (ahd_print_register(NULL, 0, "SCB_BUSADDR",
+	return (ahd_print_register(SCB_CDB_LEN_parse_table, 1, "SCB_CDB_LEN",
 	    0x1ac, regvalue, cur_col, wrap));
 }
 
 int
+ahd_scb_task_management_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SCB_TASK_MANAGEMENT",
+	    0x1ad, regvalue, cur_col, wrap));
+}
+
+int
+ahd_scb_tag_print(u_int regvalue, u_int *cur_col, u_int wrap)
+{
+	return (ahd_print_register(NULL, 0, "SCB_TAG",
+	    0x1ae, regvalue, cur_col, wrap));
+}
+
+int
 ahd_scb_spare_print(u_int regvalue, u_int *cur_col, u_int wrap)
 {
 	return (ahd_print_register(NULL, 0, "SCB_SPARE",
diff -urN linux-2.5.69-bk7/drivers/scsi/aic7xxx/aic79xx_seq.h_shipped linux-2.5.69-bk8/drivers/scsi/aic7xxx/aic79xx_seq.h_shipped
--- linux-2.5.69-bk7/drivers/scsi/aic7xxx/aic79xx_seq.h_shipped	2003-05-04 16:53:56.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/aic7xxx/aic79xx_seq.h_shipped	2003-05-13 04:44:29.000000000 -0700
@@ -2,102 +2,104 @@
  * DO NOT EDIT - This file is automatically generated
  *		 from the following source files:
  *
- * $Id: //depot/aic7xxx/aic7xxx/aic79xx.seq#89 $
- * $Id: //depot/aic7xxx/aic7xxx/aic79xx.reg#65 $
+ * $Id: //depot/aic7xxx/aic7xxx/aic79xx.seq#91 $
+ * $Id: //depot/aic7xxx/aic7xxx/aic79xx.reg#67 $
  */
 static uint8_t seqprog[] = {
 	0xff, 0x02, 0x06, 0x78,
-	0x00, 0xea, 0x50, 0x59,
+	0x00, 0xea, 0x4e, 0x59,
 	0x01, 0xea, 0x04, 0x30,
 	0xff, 0x04, 0x0c, 0x78,
-	0x19, 0xea, 0x50, 0x59,
+	0x19, 0xea, 0x4e, 0x59,
 	0x19, 0xea, 0x04, 0x00,
-	0x33, 0xea, 0x44, 0x59,
+	0x33, 0xea, 0x42, 0x59,
 	0x33, 0xea, 0x00, 0x00,
 	0x60, 0x3a, 0x1a, 0x68,
 	0x04, 0x47, 0x1b, 0x68,
 	0xff, 0x21, 0x1b, 0x70,
-	0x40, 0x4b, 0x92, 0x69,
-	0x00, 0xe2, 0x54, 0x59,
-	0x40, 0x4b, 0x92, 0x69,
-	0x20, 0x4b, 0x82, 0x69,
+	0x40, 0x4b, 0x90, 0x69,
+	0x00, 0xe2, 0x52, 0x59,
+	0x40, 0x4b, 0x90, 0x69,
+	0x20, 0x4b, 0x80, 0x69,
 	0xfc, 0x42, 0x24, 0x78,
 	0x10, 0x40, 0x24, 0x78,
-	0x00, 0xe2, 0xe0, 0x5d,
+	0x00, 0xe2, 0xd2, 0x5d,
 	0x20, 0x4d, 0x28, 0x78,
-	0x00, 0xe2, 0xe0, 0x5d,
+	0x00, 0xe2, 0xd2, 0x5d,
 	0x30, 0x3f, 0xc0, 0x09,
 	0x30, 0xe0, 0x30, 0x60,
 	0x7f, 0x4a, 0x94, 0x08,
 	0x00, 0xe2, 0x32, 0x40,
 	0xc0, 0x4a, 0x94, 0x00,
 	0x00, 0xe2, 0x3e, 0x58,
-	0x00, 0xe2, 0x70, 0x58,
-	0x00, 0xe2, 0x80, 0x58,
+	0x00, 0xe2, 0x56, 0x58,
+	0x00, 0xe2, 0x66, 0x58,
 	0x00, 0xe2, 0x06, 0x40,
-	0x33, 0xea, 0x44, 0x59,
+	0x33, 0xea, 0x42, 0x59,
 	0x33, 0xea, 0x00, 0x00,
-	0x01, 0x52, 0x96, 0x7d,
+	0x01, 0x52, 0x64, 0x78,
 	0x02, 0x58, 0x50, 0x31,
 	0xff, 0xea, 0x10, 0x0b,
-	0xff, 0x93, 0x4f, 0x78,
+	0xff, 0xad, 0x4f, 0x78,
 	0x50, 0x4b, 0x4a, 0x68,
 	0xbf, 0x3a, 0x74, 0x08,
-	0x14, 0xea, 0x50, 0x59,
+	0x14, 0xea, 0x4e, 0x59,
 	0x14, 0xea, 0x04, 0x00,
 	0x08, 0xa8, 0x51, 0x03,
-	0x01, 0xa4, 0x57, 0x78,
-	0x00, 0xe2, 0x4c, 0x5b,
+	0xff, 0xae, 0x3f, 0x68,
+	0x00, 0xe2, 0x50, 0x5b,
 	0x00, 0xe2, 0x3e, 0x40,
-	0xff, 0xea, 0xd4, 0x19,
-	0x02, 0xa8, 0x84, 0x32,
-	0x00, 0xea, 0x44, 0x59,
+	0x00, 0xea, 0x42, 0x59,
 	0x01, 0xea, 0x00, 0x30,
-	0x00, 0xe2, 0xcc, 0x5d,
-	0x00, 0xe2, 0x96, 0x4d,
-	0x11, 0xea, 0x44, 0x59,
+	0x80, 0xf9, 0x5e, 0x68,
+	0x00, 0xe2, 0x40, 0x59,
+	0x11, 0xea, 0x42, 0x59,
 	0x11, 0xea, 0x00, 0x00,
-	0x00, 0xe2, 0xcc, 0x5d,
-	0x00, 0xe2, 0x96, 0x4d,
-	0x33, 0xea, 0x44, 0x59,
-	0x33, 0xea, 0x00, 0x00,
-	0x00, 0xe2, 0x44, 0x43,
-	0x00, 0xea, 0x44, 0x59,
-	0x01, 0xea, 0x00, 0x30,
-	0x80, 0xf9, 0x78, 0x68,
-	0x00, 0xe2, 0x42, 0x59,
-	0x11, 0xea, 0x44, 0x59,
-	0x11, 0xea, 0x00, 0x00,
-	0x80, 0xf9, 0x42, 0x79,
+	0x80, 0xf9, 0x40, 0x79,
 	0xff, 0xea, 0xd4, 0x0d,
-	0x22, 0xea, 0x44, 0x59,
+	0x22, 0xea, 0x42, 0x59,
 	0x22, 0xea, 0x00, 0x00,
-	0x10, 0x16, 0x8a, 0x78,
+	0x10, 0x16, 0x70, 0x78,
 	0x01, 0x0b, 0xa2, 0x32,
 	0x10, 0x16, 0x2c, 0x00,
-	0x18, 0xad, 0xf8, 0x78,
-	0x04, 0xad, 0xc6, 0x68,
-	0x80, 0xad, 0x96, 0x7d,
-	0x10, 0xad, 0x94, 0x78,
-	0xe7, 0xad, 0x5a, 0x0d,
+	0x18, 0xad, 0xfe, 0x78,
+	0x04, 0xad, 0xca, 0x68,
+	0x80, 0xad, 0x64, 0x78,
+	0x10, 0xad, 0x98, 0x78,
+	0xff, 0x88, 0x83, 0x68,
+	0xe7, 0xad, 0x5a, 0x09,
+	0x02, 0x8c, 0x59, 0x32,
+	0x02, 0x28, 0x19, 0x33,
+	0x02, 0xa8, 0x50, 0x36,
+	0x33, 0xea, 0x42, 0x59,
+	0x33, 0xea, 0x00, 0x00,
+	0x40, 0x3a, 0x64, 0x68,
+	0x50, 0x4b, 0x64, 0x68,
+	0x22, 0xea, 0x42, 0x59,
+	0x22, 0xea, 0x00, 0x00,
 	0xe7, 0xad, 0x5a, 0x09,
-	0x00, 0xe2, 0xa2, 0x58,
+	0x02, 0x8c, 0x59, 0x32,
+	0x1a, 0xea, 0x4e, 0x59,
+	0x1a, 0xea, 0x04, 0x00,
+	0xff, 0xea, 0xd4, 0x0d,
+	0xe7, 0xad, 0x5a, 0x09,
+	0x00, 0xe2, 0xa6, 0x58,
 	0xff, 0xea, 0x56, 0x02,
 	0x04, 0x7c, 0x78, 0x32,
-	0x20, 0x16, 0x96, 0x7d,
+	0x20, 0x16, 0x64, 0x78,
 	0x04, 0x38, 0x79, 0x32,
 	0x80, 0x37, 0x6f, 0x16,
-	0xff, 0x2d, 0xb1, 0x60,
-	0xff, 0x29, 0xb1, 0x60,
-	0x40, 0x51, 0xc1, 0x78,
-	0xff, 0x4f, 0xb1, 0x68,
+	0xff, 0x2d, 0xb5, 0x60,
+	0xff, 0x29, 0xb5, 0x60,
+	0x40, 0x51, 0xc5, 0x78,
+	0xff, 0x4f, 0xb5, 0x68,
 	0xff, 0x4d, 0xc1, 0x19,
 	0x00, 0x4e, 0xd5, 0x19,
-	0x00, 0xe2, 0xc0, 0x50,
+	0x00, 0xe2, 0xc4, 0x50,
 	0x01, 0x4c, 0xc1, 0x31,
 	0x00, 0x50, 0xd5, 0x19,
-	0x00, 0xe2, 0xc0, 0x48,
-	0x80, 0x18, 0x96, 0x7d,
+	0x00, 0xe2, 0xc4, 0x48,
+	0x80, 0x18, 0x64, 0x78,
 	0x02, 0x4a, 0x1d, 0x30,
 	0x10, 0xea, 0x18, 0x00,
 	0x60, 0x18, 0x30, 0x00,
@@ -105,35 +107,36 @@
 	0x02, 0xea, 0x02, 0x00,
 	0xff, 0xea, 0xa0, 0x0a,
 	0x80, 0x18, 0x30, 0x04,
-	0x40, 0xad, 0x96, 0x7d,
+	0x40, 0xad, 0x64, 0x78,
 	0xe7, 0xad, 0x5a, 0x09,
 	0x02, 0xa8, 0x40, 0x31,
 	0xff, 0xea, 0xc0, 0x09,
 	0x01, 0x4e, 0x9d, 0x1a,
 	0x00, 0x4f, 0x9f, 0x22,
-	0x04, 0x94, 0x49, 0x32,
-	0xff, 0xea, 0x2a, 0x03,
-	0xff, 0xea, 0x2e, 0x03,
+	0x01, 0xea, 0x5c, 0x33,
+	0x04, 0xa4, 0x49, 0x32,
+	0xff, 0xea, 0x4a, 0x03,
+	0xff, 0xea, 0x4e, 0x03,
 	0x01, 0x10, 0xd4, 0x31,
-	0x10, 0xa8, 0xed, 0x68,
+	0x10, 0xa8, 0xf3, 0x68,
 	0x3d, 0xa9, 0xc5, 0x29,
 	0xfe, 0xe2, 0xc4, 0x09,
 	0x01, 0xea, 0xc6, 0x01,
 	0x02, 0xe2, 0xc8, 0x31,
 	0x02, 0xec, 0x50, 0x31,
 	0x02, 0xa0, 0xda, 0x31,
-	0xff, 0xa9, 0xec, 0x70,
-	0x02, 0xa0, 0x28, 0x37,
-	0xff, 0x21, 0xf5, 0x70,
+	0xff, 0xa9, 0xf2, 0x70,
+	0x02, 0xa0, 0x48, 0x37,
+	0xff, 0x21, 0xfb, 0x70,
 	0x02, 0x22, 0x51, 0x31,
-	0x02, 0xa0, 0x2c, 0x33,
+	0x02, 0xa0, 0x4c, 0x33,
 	0x02, 0xa0, 0x44, 0x36,
 	0x02, 0xa0, 0x40, 0x32,
 	0x02, 0xa0, 0x44, 0x36,
-	0x04, 0x47, 0xfd, 0x68,
-	0x40, 0x16, 0x28, 0x69,
-	0xff, 0x2d, 0x2d, 0x61,
-	0xff, 0x29, 0x97, 0x75,
+	0x04, 0x47, 0x03, 0x69,
+	0x40, 0x16, 0x2e, 0x69,
+	0xff, 0x2d, 0x33, 0x61,
+	0xff, 0x29, 0x65, 0x70,
 	0x01, 0x37, 0xc1, 0x31,
 	0x02, 0x28, 0x55, 0x32,
 	0x01, 0xea, 0x5a, 0x01,
@@ -145,11 +148,11 @@
 	0x01, 0x50, 0xa1, 0x1a,
 	0xff, 0x4e, 0x9d, 0x1a,
 	0xff, 0x4f, 0x9f, 0x22,
-	0xff, 0x8d, 0x21, 0x71,
-	0x80, 0xac, 0x20, 0x71,
-	0x20, 0x16, 0x20, 0x69,
+	0xff, 0x8d, 0x27, 0x71,
+	0x80, 0xac, 0x26, 0x71,
+	0x20, 0x16, 0x26, 0x69,
 	0x02, 0x8c, 0x51, 0x31,
-	0x00, 0xe2, 0x0a, 0x41,
+	0x00, 0xe2, 0x10, 0x41,
 	0x01, 0xac, 0x08, 0x31,
 	0x09, 0xea, 0x5a, 0x01,
 	0x02, 0x8c, 0x51, 0x32,
@@ -157,14 +160,10 @@
 	0x04, 0x24, 0xf9, 0x30,
 	0x1d, 0xea, 0x38, 0x41,
 	0x02, 0x2c, 0x51, 0x31,
-	0x04, 0xac, 0xf9, 0x30,
-	0x19, 0xea, 0x38, 0x59,
-	0x02, 0x8c, 0x59, 0x32,
-	0x02, 0x28, 0x19, 0x33,
-	0x02, 0xa8, 0x50, 0x36,
+	0x04, 0xa0, 0xf9, 0x30,
+	0x19, 0xea, 0x38, 0x41,
 	0x06, 0xea, 0x08, 0x81,
 	0x01, 0xe2, 0x5a, 0x35,
-	0x02, 0xa8, 0xf4, 0x31,
 	0x02, 0xf2, 0xf0, 0x35,
 	0x02, 0xf2, 0xf0, 0x31,
 	0x02, 0xf8, 0xe4, 0x35,
@@ -180,23 +179,23 @@
 	0x02, 0x20, 0xb9, 0x30,
 	0x02, 0x20, 0x51, 0x31,
 	0x4c, 0xa9, 0xd7, 0x28,
-	0x10, 0xa8, 0x63, 0x79,
+	0x10, 0xa8, 0x61, 0x79,
 	0x01, 0x6b, 0xc0, 0x30,
 	0x02, 0x64, 0xc8, 0x00,
 	0x40, 0x3a, 0x74, 0x04,
-	0x00, 0xe2, 0x70, 0x58,
-	0x33, 0xea, 0x44, 0x59,
+	0x00, 0xe2, 0x56, 0x58,
+	0x33, 0xea, 0x42, 0x59,
 	0x33, 0xea, 0x00, 0x00,
 	0x30, 0x3f, 0xc0, 0x09,
-	0x30, 0xe0, 0x64, 0x61,
-	0x20, 0x3f, 0x7a, 0x69,
-	0x10, 0x3f, 0x64, 0x79,
+	0x30, 0xe0, 0x62, 0x61,
+	0x20, 0x3f, 0x78, 0x69,
+	0x10, 0x3f, 0x62, 0x79,
 	0x02, 0xea, 0x7e, 0x00,
-	0x00, 0xea, 0x44, 0x59,
+	0x00, 0xea, 0x42, 0x59,
 	0x01, 0xea, 0x00, 0x30,
 	0x02, 0x48, 0x51, 0x35,
 	0x01, 0xea, 0x7e, 0x00,
-	0x11, 0xea, 0x44, 0x59,
+	0x11, 0xea, 0x42, 0x59,
 	0x11, 0xea, 0x00, 0x00,
 	0x02, 0x48, 0x51, 0x35,
 	0x08, 0xea, 0x98, 0x00,
@@ -206,11 +205,11 @@
 	0x0f, 0x67, 0xc0, 0x09,
 	0x00, 0x34, 0x69, 0x02,
 	0x20, 0xea, 0x96, 0x00,
-	0x00, 0xe2, 0xf8, 0x41,
-	0x40, 0x3a, 0xae, 0x69,
+	0x00, 0xe2, 0xf6, 0x41,
+	0x40, 0x3a, 0xac, 0x69,
 	0x02, 0x55, 0x06, 0x68,
-	0x02, 0x56, 0xae, 0x69,
-	0xff, 0x5b, 0xae, 0x61,
+	0x02, 0x56, 0xac, 0x69,
+	0xff, 0x5b, 0xac, 0x61,
 	0x02, 0x20, 0x51, 0x31,
 	0x80, 0xea, 0xb2, 0x01,
 	0x44, 0xea, 0x00, 0x00,
@@ -218,36 +217,36 @@
 	0x33, 0xea, 0x00, 0x00,
 	0xff, 0xea, 0xb2, 0x09,
 	0xff, 0xe0, 0xc0, 0x19,
-	0xff, 0xe0, 0xb0, 0x79,
-	0x02, 0x94, 0x51, 0x31,
-	0x00, 0xe2, 0xa6, 0x41,
+	0xff, 0xe0, 0xae, 0x79,
+	0x02, 0xa4, 0x51, 0x31,
+	0x00, 0xe2, 0xa4, 0x41,
 	0x02, 0x5e, 0x50, 0x31,
 	0x02, 0xa8, 0xb8, 0x30,
 	0x02, 0x5c, 0x50, 0x31,
-	0xff, 0x95, 0xc1, 0x71,
-	0x02, 0x94, 0x41, 0x31,
+	0xff, 0xa5, 0xbf, 0x71,
+	0x02, 0xa4, 0x41, 0x31,
 	0x02, 0x22, 0x51, 0x31,
-	0x02, 0xa0, 0x2c, 0x33,
+	0x02, 0xa0, 0x4c, 0x33,
 	0x02, 0xa0, 0x44, 0x32,
-	0x00, 0xe2, 0xca, 0x41,
-	0x10, 0xa8, 0xcb, 0x69,
+	0x00, 0xe2, 0xc8, 0x41,
+	0x10, 0xa8, 0xc9, 0x69,
 	0x3d, 0xa9, 0xc9, 0x29,
 	0x01, 0xe4, 0xc8, 0x01,
 	0x01, 0xea, 0xca, 0x01,
 	0xff, 0xea, 0xda, 0x01,
 	0x02, 0x20, 0x51, 0x31,
-	0x02, 0x96, 0x41, 0x32,
-	0xff, 0x21, 0xd3, 0x61,
+	0x02, 0xa6, 0x41, 0x32,
+	0xff, 0x21, 0xd1, 0x61,
 	0xff, 0xea, 0x46, 0x02,
 	0x02, 0x5c, 0x50, 0x31,
 	0x40, 0xea, 0x96, 0x00,
-	0x02, 0x56, 0xe8, 0x6d,
-	0x01, 0x55, 0xe8, 0x6d,
-	0x10, 0xa8, 0xdf, 0x79,
-	0x10, 0x40, 0xe8, 0x69,
-	0x01, 0x56, 0xe8, 0x79,
-	0xff, 0x93, 0x07, 0x78,
-	0x13, 0xea, 0x50, 0x59,
+	0x02, 0x56, 0xda, 0x6d,
+	0x01, 0x55, 0xda, 0x6d,
+	0x10, 0xa8, 0xdd, 0x79,
+	0x10, 0x40, 0xe6, 0x69,
+	0x01, 0x56, 0xe6, 0x79,
+	0xff, 0xad, 0x07, 0x78,
+	0x13, 0xea, 0x4e, 0x59,
 	0x13, 0xea, 0x04, 0x00,
 	0x00, 0xe2, 0x06, 0x40,
 	0xbf, 0x3a, 0x74, 0x08,
@@ -258,104 +257,104 @@
 	0x40, 0xea, 0x66, 0x02,
 	0x08, 0x3c, 0x78, 0x00,
 	0x80, 0xea, 0x62, 0x02,
-	0x00, 0xe2, 0xac, 0x5b,
+	0x00, 0xe2, 0xb2, 0x5b,
 	0x01, 0x36, 0xc1, 0x31,
-	0x9f, 0xe0, 0x4e, 0x7c,
-	0x80, 0xe0, 0x0c, 0x72,
-	0xa0, 0xe0, 0x44, 0x72,
-	0xc0, 0xe0, 0x3a, 0x72,
-	0xe0, 0xe0, 0x74, 0x72,
-	0x01, 0xea, 0x50, 0x59,
+	0x9f, 0xe0, 0x54, 0x7c,
+	0x80, 0xe0, 0x0a, 0x72,
+	0xa0, 0xe0, 0x42, 0x72,
+	0xc0, 0xe0, 0x38, 0x72,
+	0xe0, 0xe0, 0x72, 0x72,
+	0x01, 0xea, 0x4e, 0x59,
 	0x01, 0xea, 0x04, 0x00,
-	0x00, 0xe2, 0xf8, 0x41,
-	0x80, 0x33, 0x13, 0x7a,
-	0x03, 0xea, 0x50, 0x59,
+	0x00, 0xe2, 0xf6, 0x41,
+	0x80, 0x33, 0x11, 0x7a,
+	0x03, 0xea, 0x4e, 0x59,
 	0x03, 0xea, 0x04, 0x00,
-	0xee, 0x00, 0x1a, 0x6a,
+	0xee, 0x00, 0x18, 0x6a,
 	0x05, 0xea, 0xb4, 0x00,
-	0x33, 0xea, 0x44, 0x59,
+	0x33, 0xea, 0x42, 0x59,
 	0x33, 0xea, 0x00, 0x00,
 	0x02, 0xa8, 0x90, 0x32,
-	0x00, 0xe2, 0x6a, 0x59,
-	0xef, 0x92, 0xd5, 0x19,
-	0x00, 0xe2, 0x2a, 0x52,
+	0x00, 0xe2, 0x68, 0x59,
+	0xef, 0xac, 0xd5, 0x19,
+	0x00, 0xe2, 0x28, 0x52,
 	0x09, 0x80, 0xe1, 0x30,
 	0x02, 0xea, 0x36, 0x00,
 	0xa8, 0xea, 0x32, 0x00,
-	0x00, 0xe2, 0x30, 0x42,
-	0x01, 0x92, 0xd1, 0x30,
+	0x00, 0xe2, 0x2e, 0x42,
+	0x01, 0xac, 0xd1, 0x30,
 	0x10, 0x80, 0x89, 0x31,
 	0x20, 0xea, 0x32, 0x00,
 	0xbf, 0x33, 0x67, 0x0a,
-	0x20, 0x19, 0x32, 0x6a,
-	0x02, 0x4d, 0xf8, 0x69,
+	0x20, 0x19, 0x30, 0x6a,
+	0x02, 0x4d, 0xf6, 0x69,
 	0x40, 0x33, 0x67, 0x02,
-	0x00, 0xe2, 0xf8, 0x41,
-	0x80, 0x33, 0xb1, 0x6a,
+	0x00, 0xe2, 0xf6, 0x41,
+	0x80, 0x33, 0xaf, 0x6a,
 	0x01, 0x44, 0x10, 0x33,
 	0x08, 0xa8, 0x51, 0x03,
-	0x00, 0xe2, 0xf8, 0x41,
+	0x00, 0xe2, 0xf6, 0x41,
 	0x10, 0xea, 0x80, 0x00,
 	0x01, 0x31, 0xc5, 0x31,
-	0x80, 0xe2, 0x60, 0x62,
-	0x10, 0xa8, 0x85, 0x6a,
+	0x80, 0xe2, 0x5e, 0x62,
+	0x10, 0xa8, 0x83, 0x6a,
 	0xc0, 0xaa, 0xc5, 0x01,
-	0x40, 0xa8, 0x51, 0x6a,
+	0x40, 0xa8, 0x4f, 0x6a,
 	0xbf, 0xe2, 0xc4, 0x09,
-	0x20, 0xa8, 0x65, 0x7a,
+	0x20, 0xa8, 0x63, 0x7a,
 	0x01, 0xe2, 0x88, 0x30,
-	0x00, 0xe2, 0xac, 0x5b,
-	0xa0, 0x36, 0x6d, 0x62,
+	0x00, 0xe2, 0xb2, 0x5b,
+	0xa0, 0x36, 0x6b, 0x62,
 	0x23, 0xa8, 0x89, 0x08,
-	0x00, 0xe2, 0xac, 0x5b,
-	0xa0, 0x36, 0x6d, 0x62,
-	0x00, 0xa8, 0x64, 0x42,
-	0xff, 0xe2, 0x64, 0x62,
-	0x00, 0xe2, 0x84, 0x42,
+	0x00, 0xe2, 0xb2, 0x5b,
+	0xa0, 0x36, 0x6b, 0x62,
+	0x00, 0xa8, 0x62, 0x42,
+	0xff, 0xe2, 0x62, 0x62,
+	0x00, 0xe2, 0x82, 0x42,
 	0x40, 0xea, 0x98, 0x00,
 	0x01, 0xe2, 0x88, 0x30,
-	0x00, 0xe2, 0xac, 0x5b,
-	0xa0, 0x36, 0x43, 0x72,
+	0x00, 0xe2, 0xb2, 0x5b,
+	0xa0, 0x36, 0x41, 0x72,
 	0x40, 0xea, 0x98, 0x00,
 	0x01, 0x31, 0x89, 0x32,
 	0x08, 0xea, 0x62, 0x02,
-	0x00, 0xe2, 0xf8, 0x41,
-	0xe0, 0xea, 0xc8, 0x5b,
-	0x80, 0xe0, 0xbc, 0x6a,
-	0x04, 0xe0, 0x5a, 0x73,
-	0x02, 0xe0, 0x8a, 0x73,
-	0x00, 0xea, 0x1a, 0x73,
-	0x03, 0xe0, 0x9a, 0x73,
-	0x23, 0xe0, 0x96, 0x72,
-	0x08, 0xe0, 0xb8, 0x72,
-	0x00, 0xe2, 0xac, 0x5b,
-	0x07, 0xea, 0x50, 0x59,
+	0x00, 0xe2, 0xf6, 0x41,
+	0xe0, 0xea, 0xce, 0x5b,
+	0x80, 0xe0, 0xba, 0x6a,
+	0x04, 0xe0, 0x60, 0x73,
+	0x02, 0xe0, 0x90, 0x73,
+	0x00, 0xea, 0x18, 0x73,
+	0x03, 0xe0, 0xa0, 0x73,
+	0x23, 0xe0, 0x94, 0x72,
+	0x08, 0xe0, 0xb6, 0x72,
+	0x00, 0xe2, 0xb2, 0x5b,
+	0x07, 0xea, 0x4e, 0x59,
 	0x07, 0xea, 0x04, 0x00,
-	0x08, 0x42, 0xf9, 0x71,
-	0x04, 0x42, 0x93, 0x62,
+	0x08, 0x42, 0xf7, 0x71,
+	0x04, 0x42, 0x91, 0x62,
 	0x01, 0x43, 0x89, 0x30,
-	0x00, 0xe2, 0x84, 0x42,
+	0x00, 0xe2, 0x82, 0x42,
 	0x01, 0x44, 0xd4, 0x31,
-	0x00, 0xe2, 0x84, 0x42,
+	0x00, 0xe2, 0x82, 0x42,
 	0x01, 0x00, 0x60, 0x32,
-	0x33, 0xea, 0x44, 0x59,
+	0x33, 0xea, 0x42, 0x59,
 	0x33, 0xea, 0x00, 0x00,
 	0x4c, 0x34, 0xc1, 0x28,
 	0x01, 0x64, 0xc0, 0x31,
-	0x00, 0x30, 0x45, 0x59,
+	0x00, 0x30, 0x43, 0x59,
 	0x01, 0x30, 0x01, 0x30,
-	0x01, 0xe0, 0xb6, 0x7a,
-	0xa0, 0xea, 0xbe, 0x5b,
-	0x01, 0xa0, 0xb6, 0x62,
-	0x01, 0x84, 0xaf, 0x7a,
-	0x01, 0xa7, 0xb8, 0x7a,
-	0x00, 0xe2, 0xb8, 0x42,
-	0x03, 0xea, 0x50, 0x59,
+	0x01, 0xe0, 0xb4, 0x7a,
+	0xa0, 0xea, 0xc4, 0x5b,
+	0x01, 0xa0, 0xb4, 0x62,
+	0x01, 0x84, 0xad, 0x7a,
+	0x01, 0xa7, 0xb6, 0x7a,
+	0x00, 0xe2, 0xb6, 0x42,
+	0x03, 0xea, 0x4e, 0x59,
 	0x03, 0xea, 0x04, 0x00,
-	0x00, 0xe2, 0xb8, 0x42,
-	0x07, 0xea, 0xd0, 0x5b,
+	0x00, 0xe2, 0xb6, 0x42,
+	0x07, 0xea, 0xd6, 0x5b,
 	0x01, 0x44, 0xd4, 0x31,
-	0x00, 0xe2, 0xf8, 0x41,
+	0x00, 0xe2, 0xf6, 0x41,
 	0x3f, 0xe0, 0x6a, 0x0a,
 	0xc0, 0x34, 0xc1, 0x09,
 	0x00, 0x35, 0x51, 0x01,
@@ -366,78 +365,82 @@
 	0x01, 0xea, 0xc6, 0x01,
 	0x02, 0xe2, 0xc8, 0x31,
 	0x02, 0xec, 0x40, 0x31,
-	0xff, 0xa1, 0xd8, 0x72,
+	0xff, 0xa1, 0xd6, 0x72,
 	0x02, 0xe8, 0xda, 0x31,
 	0x02, 0xa0, 0x50, 0x31,
-	0x00, 0xe2, 0xfa, 0x42,
+	0x00, 0xe2, 0xf8, 0x42,
 	0x80, 0x33, 0x67, 0x02,
 	0x01, 0x44, 0xd4, 0x31,
-	0x00, 0xe2, 0xac, 0x5b,
+	0x00, 0xe2, 0xb2, 0x5b,
 	0x01, 0x33, 0x67, 0x02,
-	0xe0, 0x36, 0x15, 0x63,
+	0xe0, 0x36, 0x13, 0x63,
 	0x02, 0x33, 0x67, 0x02,
-	0x20, 0x46, 0x0e, 0x63,
+	0x20, 0x46, 0x0c, 0x63,
 	0xff, 0xea, 0x52, 0x09,
-	0xa8, 0xea, 0xbe, 0x5b,
-	0x04, 0xa8, 0xf5, 0x7a,
+	0xa8, 0xea, 0xc4, 0x5b,
+	0x04, 0xa8, 0xf3, 0x7a,
 	0x01, 0x34, 0xc1, 0x31,
-	0x00, 0xa9, 0xf5, 0x62,
+	0x00, 0xa9, 0xf3, 0x62,
 	0x01, 0x35, 0xc1, 0x31,
-	0x00, 0xaa, 0xff, 0x72,
+	0x00, 0xaa, 0xfd, 0x72,
 	0x01, 0xa9, 0x52, 0x11,
-	0xff, 0xa9, 0xea, 0x6a,
-	0x00, 0xe2, 0x0e, 0x43,
+	0xff, 0xa9, 0xe8, 0x6a,
+	0x00, 0xe2, 0x0c, 0x43,
 	0x10, 0x33, 0x67, 0x02,
-	0x04, 0xa8, 0x0f, 0x7b,
+	0x04, 0xa8, 0x0d, 0x7b,
 	0xfb, 0xa8, 0x51, 0x0b,
 	0xff, 0xea, 0x66, 0x0a,
-	0x01, 0xa4, 0x09, 0x6b,
+	0x01, 0x9c, 0x07, 0x6b,
 	0x02, 0xa8, 0x90, 0x32,
-	0x00, 0xe2, 0x6a, 0x59,
-	0x10, 0xa8, 0xb9, 0x7a,
-	0xff, 0xea, 0xd0, 0x5b,
-	0x00, 0xe2, 0xb8, 0x42,
-	0x04, 0xea, 0x50, 0x59,
+	0x00, 0xe2, 0x68, 0x59,
+	0x10, 0xa8, 0xb7, 0x7a,
+	0xff, 0xea, 0xd6, 0x5b,
+	0x00, 0xe2, 0xb6, 0x42,
+	0x04, 0xea, 0x4e, 0x59,
 	0x04, 0xea, 0x04, 0x00,
-	0x00, 0xe2, 0xb8, 0x42,
-	0x04, 0xea, 0x50, 0x59,
+	0x00, 0xe2, 0xb6, 0x42,
+	0x04, 0xea, 0x4e, 0x59,
 	0x04, 0xea, 0x04, 0x00,
-	0x00, 0xe2, 0xf8, 0x41,
-	0x08, 0xa8, 0xb1, 0x7a,
-	0xc0, 0x33, 0x25, 0x7b,
-	0x80, 0x33, 0xb1, 0x6a,
-	0xff, 0x88, 0x25, 0x6b,
-	0x40, 0x33, 0xb1, 0x6a,
-	0x10, 0xa8, 0x2b, 0x7b,
-	0x0a, 0xea, 0x50, 0x59,
+	0x00, 0xe2, 0xf6, 0x41,
+	0x08, 0xa8, 0xaf, 0x7a,
+	0xc0, 0x33, 0x23, 0x7b,
+	0x80, 0x33, 0xaf, 0x6a,
+	0xff, 0x88, 0x23, 0x6b,
+	0x40, 0x33, 0xaf, 0x6a,
+	0x10, 0xa8, 0x29, 0x7b,
+	0x0a, 0xea, 0x4e, 0x59,
 	0x0a, 0xea, 0x04, 0x00,
-	0x00, 0xe2, 0x44, 0x5b,
-	0x00, 0xe2, 0x76, 0x43,
-	0x50, 0x4b, 0x32, 0x6b,
+	0x00, 0xe2, 0x48, 0x5b,
+	0x00, 0xe2, 0x7c, 0x43,
+	0x50, 0x4b, 0x30, 0x6b,
 	0xbf, 0x3a, 0x74, 0x08,
-	0x01, 0xe0, 0xf8, 0x31,
+	0x01, 0xe0, 0xf4, 0x31,
 	0xff, 0xea, 0xc0, 0x09,
 	0x01, 0x2e, 0x5d, 0x1a,
 	0x00, 0x2f, 0x5f, 0x22,
 	0x04, 0x47, 0x8f, 0x02,
-	0x01, 0xfc, 0xc0, 0x35,
-	0x33, 0xea, 0x44, 0x59,
+	0x01, 0xfa, 0xc0, 0x35,
+	0x02, 0xa8, 0x84, 0x32,
+	0x02, 0xea, 0xb4, 0x00,
+	0x33, 0xea, 0x42, 0x59,
 	0x33, 0xea, 0x00, 0x00,
 	0x02, 0x42, 0x51, 0x31,
-	0xff, 0x88, 0x51, 0x6b,
-	0x01, 0xa4, 0x4d, 0x6b,
-	0x02, 0xa4, 0x55, 0x6b,
-	0x01, 0x84, 0x55, 0x7b,
+	0xff, 0xae, 0x65, 0x68,
+	0xff, 0x88, 0x55, 0x6b,
+	0x01, 0x9c, 0x51, 0x6b,
+	0x02, 0x9c, 0x59, 0x6b,
+	0x01, 0x84, 0x59, 0x7b,
 	0x02, 0x28, 0x19, 0x33,
 	0x02, 0xa8, 0x50, 0x36,
-	0xff, 0x88, 0x55, 0x73,
-	0x00, 0xe2, 0x2e, 0x5b,
+	0xff, 0x88, 0x59, 0x73,
+	0x00, 0xe2, 0x2c, 0x5b,
+	0x02, 0xa8, 0x5c, 0x33,
 	0x02, 0x2c, 0x19, 0x33,
 	0x02, 0xa8, 0x58, 0x32,
-	0x04, 0xa4, 0x49, 0x07,
-	0xc0, 0x33, 0xb1, 0x6a,
+	0x04, 0x9c, 0x39, 0x07,
+	0xc0, 0x33, 0xaf, 0x6a,
 	0x04, 0xa8, 0x51, 0x03,
-	0x20, 0xa8, 0x77, 0x6b,
+	0x20, 0xa8, 0x7d, 0x6b,
 	0x02, 0xa8, 0x40, 0x31,
 	0xc0, 0x34, 0xc1, 0x09,
 	0x00, 0x35, 0x51, 0x01,
@@ -452,73 +455,73 @@
 	0xf7, 0x57, 0xae, 0x08,
 	0x08, 0xea, 0x98, 0x00,
 	0x01, 0x44, 0xd4, 0x31,
-	0xee, 0x00, 0x80, 0x6b,
+	0xee, 0x00, 0x86, 0x6b,
 	0x02, 0xea, 0xb4, 0x00,
-	0x00, 0xe2, 0xa8, 0x5b,
-	0x09, 0x4c, 0x82, 0x7b,
+	0x00, 0xe2, 0xae, 0x5b,
+	0x09, 0x4c, 0x88, 0x7b,
 	0x08, 0x4c, 0x06, 0x68,
-	0x0b, 0xea, 0x50, 0x59,
+	0x0b, 0xea, 0x4e, 0x59,
 	0x0b, 0xea, 0x04, 0x00,
 	0x01, 0x44, 0xd4, 0x31,
-	0x20, 0x33, 0xf9, 0x79,
-	0x00, 0xe2, 0x92, 0x5b,
-	0x00, 0xe2, 0xf8, 0x41,
-	0x01, 0x84, 0x97, 0x7b,
-	0x01, 0xa4, 0x49, 0x07,
-	0x08, 0x60, 0x30, 0x33,
-	0x08, 0x80, 0x41, 0x37,
+	0x20, 0x33, 0xf7, 0x79,
+	0x00, 0xe2, 0x98, 0x5b,
+	0x00, 0xe2, 0xf6, 0x41,
+	0x01, 0x84, 0x9d, 0x7b,
+	0x01, 0x9c, 0x39, 0x07,
+	0x08, 0x60, 0x20, 0x33,
+	0x08, 0x80, 0x31, 0x37,
 	0xdf, 0x33, 0x67, 0x0a,
-	0xee, 0x00, 0xa4, 0x6b,
+	0xee, 0x00, 0xaa, 0x6b,
 	0x05, 0xea, 0xb4, 0x00,
-	0x33, 0xea, 0x44, 0x59,
+	0x33, 0xea, 0x42, 0x59,
 	0x33, 0xea, 0x00, 0x00,
-	0x00, 0xe2, 0x6a, 0x59,
-	0x00, 0xe2, 0xb8, 0x42,
+	0x00, 0xe2, 0x68, 0x59,
+	0x00, 0xe2, 0xb6, 0x42,
 	0x01, 0xea, 0x6c, 0x02,
 	0xc0, 0xea, 0x66, 0x06,
-	0xff, 0x42, 0xb8, 0x6b,
-	0x01, 0x41, 0xac, 0x6b,
-	0x02, 0x41, 0xac, 0x7b,
-	0xff, 0x42, 0xb8, 0x6b,
-	0x01, 0x41, 0xac, 0x6b,
-	0x02, 0x41, 0xac, 0x7b,
-	0xff, 0x42, 0xb8, 0x7b,
-	0x04, 0x4c, 0xac, 0x6b,
+	0xff, 0x42, 0xbe, 0x6b,
+	0x01, 0x41, 0xb2, 0x6b,
+	0x02, 0x41, 0xb2, 0x7b,
+	0xff, 0x42, 0xbe, 0x6b,
+	0x01, 0x41, 0xb2, 0x6b,
+	0x02, 0x41, 0xb2, 0x7b,
+	0xff, 0x42, 0xbe, 0x7b,
+	0x04, 0x4c, 0xb2, 0x6b,
 	0xe0, 0x41, 0x6c, 0x0e,
 	0x01, 0x44, 0xd4, 0x31,
-	0xff, 0x42, 0xc0, 0x7b,
-	0x04, 0x4c, 0xc0, 0x6b,
+	0xff, 0x42, 0xc6, 0x7b,
+	0x04, 0x4c, 0xc6, 0x6b,
 	0xe0, 0x41, 0x6c, 0x0a,
-	0xe0, 0x36, 0xf9, 0x61,
+	0xe0, 0x36, 0xf7, 0x61,
 	0xff, 0xea, 0xca, 0x09,
 	0x01, 0xe2, 0xc8, 0x31,
 	0x01, 0x46, 0xda, 0x35,
 	0x01, 0x44, 0xd4, 0x35,
 	0x10, 0xea, 0x80, 0x00,
 	0x01, 0xe2, 0x62, 0x36,
-	0x04, 0xa6, 0xd8, 0x7b,
+	0x04, 0xa6, 0xde, 0x7b,
 	0xff, 0xea, 0x5a, 0x09,
 	0xff, 0xea, 0x4c, 0x0d,
-	0x01, 0xa6, 0xf6, 0x6b,
-	0x10, 0xad, 0x96, 0x7d,
-	0x80, 0xad, 0xee, 0x6b,
-	0x08, 0xad, 0x96, 0x6d,
+	0x01, 0xa6, 0xfc, 0x6b,
+	0x10, 0xad, 0x64, 0x78,
+	0x80, 0xad, 0xf4, 0x6b,
+	0x08, 0xad, 0x64, 0x68,
 	0x04, 0x84, 0xf9, 0x30,
 	0x00, 0xea, 0x08, 0x81,
 	0xff, 0xea, 0xd4, 0x09,
 	0x02, 0x84, 0xf9, 0x88,
 	0x0d, 0xea, 0x5a, 0x01,
 	0x04, 0xa6, 0x4c, 0x05,
-	0x04, 0xa6, 0x96, 0x7d,
+	0x04, 0xa6, 0x64, 0x78,
 	0xff, 0xea, 0x5a, 0x09,
 	0x03, 0x84, 0x59, 0x89,
 	0x03, 0xea, 0x4c, 0x01,
-	0x80, 0x1a, 0x96, 0x7d,
-	0x08, 0x19, 0x96, 0x7d,
+	0x80, 0x1a, 0x64, 0x78,
+	0x08, 0x19, 0x64, 0x78,
 	0x08, 0xb0, 0xe0, 0x30,
 	0x04, 0xb0, 0xe0, 0x30,
 	0x03, 0xb0, 0xf0, 0x30,
-	0x01, 0x78, 0x04, 0x7c,
+	0x01, 0x78, 0x0a, 0x7c,
 	0x01, 0xa7, 0x4e, 0x11,
 	0x01, 0xb0, 0x06, 0x33,
 	0x7f, 0x83, 0xe9, 0x08,
@@ -529,275 +532,268 @@
 	0x00, 0x86, 0x0d, 0x23,
 	0x00, 0x87, 0x0f, 0x23,
 	0x01, 0x84, 0xc5, 0x31,
-	0x01, 0xa7, 0x1a, 0x7c,
+	0x01, 0xa7, 0x20, 0x7c,
 	0x04, 0xe2, 0xc4, 0x01,
-	0x80, 0x83, 0x21, 0x7c,
+	0x80, 0x83, 0x27, 0x7c,
 	0x02, 0xe2, 0xc4, 0x01,
 	0xff, 0xea, 0x4c, 0x09,
 	0x01, 0xe2, 0x36, 0x30,
 	0xc8, 0x19, 0x32, 0x00,
 	0x88, 0x19, 0x32, 0x00,
 	0x01, 0xac, 0xd4, 0x99,
-	0x00, 0xe2, 0x96, 0x55,
+	0x00, 0xe2, 0x64, 0x50,
 	0xfe, 0xa6, 0x4c, 0x0d,
-	0x0b, 0x98, 0xe1, 0x30,
-	0x01, 0xa0, 0x4f, 0x09,
-	0xfd, 0xa4, 0x49, 0x09,
-	0x80, 0xa3, 0x37, 0x7c,
+	0x0b, 0x90, 0xe1, 0x30,
+	0x01, 0x98, 0x4f, 0x09,
+	0xfd, 0x9c, 0x49, 0x09,
+	0x80, 0x9b, 0x3d, 0x7c,
 	0x02, 0xa4, 0x48, 0x01,
-	0x01, 0xa7, 0x3a, 0x7c,
+	0x01, 0xa7, 0x40, 0x7c,
 	0x04, 0xa4, 0x48, 0x01,
 	0x01, 0xa4, 0x36, 0x30,
 	0xa8, 0xea, 0x32, 0x00,
-	0xfd, 0xa4, 0x49, 0x0b,
-	0x05, 0xa3, 0x07, 0x33,
-	0x80, 0x83, 0x47, 0x6c,
+	0xfd, 0x9c, 0x39, 0x0b,
+	0x05, 0x9b, 0x07, 0x33,
+	0x80, 0x83, 0x4d, 0x6c,
 	0x02, 0xea, 0x4c, 0x05,
 	0xff, 0xea, 0x4c, 0x0d,
 	0x00, 0xe2, 0x3c, 0x59,
-	0x02, 0xa6, 0xda, 0x6b,
+	0x02, 0xa6, 0xe0, 0x6b,
 	0x80, 0xf9, 0xf2, 0x05,
-	0xc0, 0x33, 0x55, 0x7c,
-	0x03, 0xea, 0x50, 0x59,
+	0xc0, 0x33, 0x5b, 0x7c,
+	0x03, 0xea, 0x4e, 0x59,
 	0x03, 0xea, 0x04, 0x00,
-	0x20, 0x33, 0x79, 0x7c,
-	0x01, 0x84, 0x5f, 0x6c,
-	0x06, 0xea, 0x50, 0x59,
+	0x20, 0x33, 0x7f, 0x7c,
+	0x01, 0x84, 0x65, 0x6c,
+	0x06, 0xea, 0x4e, 0x59,
 	0x06, 0xea, 0x04, 0x00,
-	0x00, 0xe2, 0x7c, 0x44,
+	0x00, 0xe2, 0x82, 0x44,
 	0x01, 0x00, 0x60, 0x32,
-	0xee, 0x00, 0x68, 0x6c,
+	0xee, 0x00, 0x6e, 0x6c,
 	0x05, 0xea, 0xb4, 0x00,
-	0x33, 0xea, 0x44, 0x59,
+	0x33, 0xea, 0x42, 0x59,
 	0x33, 0xea, 0x00, 0x00,
 	0x80, 0x3d, 0x7a, 0x00,
-	0xfc, 0x42, 0x6a, 0x7c,
+	0xfc, 0x42, 0x70, 0x7c,
 	0x7f, 0x3d, 0x7a, 0x08,
-	0x00, 0x30, 0x45, 0x59,
+	0x00, 0x30, 0x43, 0x59,
 	0x01, 0x30, 0x01, 0x30,
-	0x09, 0xea, 0x50, 0x59,
+	0x09, 0xea, 0x4e, 0x59,
 	0x09, 0xea, 0x04, 0x00,
-	0x00, 0xe2, 0xf8, 0x41,
-	0x01, 0xa4, 0x5f, 0x6c,
-	0x00, 0xe2, 0x2c, 0x5c,
+	0x00, 0xe2, 0xf6, 0x41,
+	0x01, 0x9c, 0x65, 0x6c,
+	0x00, 0xe2, 0x32, 0x5c,
 	0x20, 0x33, 0x67, 0x02,
 	0x01, 0x00, 0x60, 0x32,
-	0x02, 0xa6, 0x84, 0x7c,
-	0x00, 0xe2, 0x48, 0x5c,
-	0x00, 0xe2, 0x70, 0x58,
-	0x00, 0xe2, 0x80, 0x58,
+	0x02, 0xa6, 0x8a, 0x7c,
+	0x00, 0xe2, 0x4e, 0x5c,
+	0x00, 0xe2, 0x56, 0x58,
+	0x00, 0xe2, 0x66, 0x58,
 	0x00, 0xe2, 0x3a, 0x58,
-	0x00, 0x30, 0x45, 0x59,
+	0x00, 0x30, 0x43, 0x59,
 	0x01, 0x30, 0x01, 0x30,
-	0x20, 0x19, 0x84, 0x6c,
-	0x00, 0xe2, 0xb4, 0x5c,
-	0x04, 0x19, 0x9e, 0x6c,
+	0x20, 0x19, 0x8a, 0x6c,
+	0x00, 0xe2, 0xba, 0x5c,
+	0x04, 0x19, 0xa4, 0x6c,
 	0x02, 0x19, 0x32, 0x00,
-	0x01, 0x84, 0x9f, 0x7c,
-	0x01, 0x1b, 0x98, 0x7c,
-	0x01, 0x1a, 0x9e, 0x6c,
-	0x00, 0xe2, 0x4e, 0x44,
-	0x80, 0x4b, 0xa4, 0x6c,
-	0x01, 0x4c, 0xa0, 0x7c,
-	0x03, 0x42, 0x4e, 0x6c,
-	0x00, 0xe2, 0xd4, 0x5b,
+	0x01, 0x84, 0xa5, 0x7c,
+	0x01, 0x1b, 0x9e, 0x7c,
+	0x01, 0x1a, 0xa4, 0x6c,
+	0x00, 0xe2, 0x54, 0x44,
+	0x80, 0x4b, 0xaa, 0x6c,
+	0x01, 0x4c, 0xa6, 0x7c,
+	0x03, 0x42, 0x54, 0x6c,
+	0x00, 0xe2, 0xda, 0x5b,
 	0x80, 0xf9, 0xf2, 0x01,
-	0x04, 0x33, 0xf9, 0x79,
-	0x00, 0xe2, 0xf8, 0x41,
-	0x08, 0x5d, 0xbc, 0x6c,
-	0x00, 0xe2, 0x70, 0x58,
-	0x00, 0x30, 0x45, 0x59,
+	0x04, 0x33, 0xf7, 0x79,
+	0x00, 0xe2, 0xf6, 0x41,
+	0x08, 0x5d, 0xc2, 0x6c,
+	0x00, 0xe2, 0x56, 0x58,
+	0x00, 0x30, 0x43, 0x59,
 	0x01, 0x30, 0x01, 0x30,
-	0x02, 0x1b, 0xac, 0x7c,
-	0x08, 0x5d, 0xba, 0x7c,
+	0x02, 0x1b, 0xb2, 0x7c,
+	0x08, 0x5d, 0xc0, 0x7c,
 	0x03, 0x68, 0x00, 0x37,
 	0x01, 0x84, 0x09, 0x07,
-	0x80, 0x1b, 0xc6, 0x7c,
-	0x80, 0x84, 0xc7, 0x6c,
+	0x80, 0x1b, 0xcc, 0x7c,
+	0x80, 0x84, 0xcd, 0x6c,
 	0xff, 0x85, 0x0b, 0x1b,
 	0xff, 0x86, 0x0d, 0x23,
 	0xff, 0x87, 0x0f, 0x23,
 	0xf8, 0x1b, 0x08, 0x0b,
 	0xff, 0xea, 0x4e, 0x09,
-	0x04, 0x1b, 0xce, 0x7c,
+	0x04, 0x1b, 0xd4, 0x7c,
 	0x01, 0xa7, 0x4e, 0x01,
 	0xff, 0xea, 0x06, 0x0b,
 	0x03, 0x68, 0x00, 0x37,
-	0x00, 0xe2, 0xc0, 0x58,
+	0x00, 0xe2, 0xc4, 0x58,
 	0x10, 0xea, 0x18, 0x00,
 	0xf9, 0xd9, 0xb2, 0x0d,
 	0x01, 0xd9, 0xb2, 0x05,
 	0x01, 0x52, 0x48, 0x31,
-	0x20, 0xa4, 0xf2, 0x7c,
-	0x20, 0x5b, 0xf2, 0x7c,
-	0x80, 0xf9, 0x00, 0x7d,
+	0x20, 0xa4, 0xfc, 0x7c,
+	0x20, 0x5b, 0xfc, 0x7c,
+	0x80, 0xf9, 0x0a, 0x7d,
+	0x02, 0xea, 0xb4, 0x00,
 	0x11, 0x00, 0x00, 0x10,
-	0x04, 0x19, 0xec, 0x7c,
+	0x04, 0x19, 0x16, 0x7d,
 	0xdf, 0x19, 0x32, 0x08,
-	0x01, 0x4c, 0xe8, 0x7c,
+	0x60, 0x5b, 0xf4, 0x6c,
+	0x01, 0x4c, 0xf0, 0x7c,
 	0x20, 0x19, 0x32, 0x00,
-	0x11, 0x00, 0x00, 0x10,
+	0x01, 0xd9, 0xb2, 0x05,
 	0x02, 0xea, 0xb4, 0x00,
 	0x01, 0xd9, 0xb2, 0x05,
-	0x10, 0x5b, 0x04, 0x6d,
-	0x08, 0x5b, 0x0c, 0x6d,
-	0x20, 0x5b, 0xfe, 0x6c,
-	0x02, 0x5b, 0x2c, 0x6d,
-	0x0e, 0xea, 0x50, 0x59,
+	0x10, 0x5b, 0x0e, 0x6d,
+	0x08, 0x5b, 0x18, 0x6d,
+	0x20, 0x5b, 0x08, 0x6d,
+	0x02, 0x5b, 0x38, 0x6d,
+	0x0e, 0xea, 0x4e, 0x59,
 	0x0e, 0xea, 0x04, 0x00,
-	0x80, 0xf9, 0xee, 0x6c,
+	0x80, 0xf9, 0xf8, 0x6c,
 	0xdf, 0x5c, 0xb8, 0x08,
 	0x01, 0xd9, 0xb2, 0x05,
-	0x01, 0xa4, 0xff, 0x6d,
-	0x00, 0xe2, 0x2c, 0x5c,
-	0x00, 0xe2, 0x36, 0x5d,
+	0x01, 0x9c, 0xf3, 0x6d,
+	0x00, 0xe2, 0x32, 0x5c,
+	0x00, 0xe2, 0x42, 0x5d,
+	0x01, 0xae, 0x5d, 0x1b,
 	0x01, 0xd9, 0xb2, 0x05,
-	0x00, 0xe2, 0x2e, 0x5b,
-	0xf3, 0x92, 0xd5, 0x19,
-	0x00, 0xe2, 0x1a, 0x55,
-	0x80, 0x92, 0x1b, 0x6d,
-	0x0f, 0xea, 0x50, 0x59,
+	0x00, 0xe2, 0x2c, 0x5b,
+	0xf3, 0xac, 0xd5, 0x19,
+	0x00, 0xe2, 0x26, 0x55,
+	0x80, 0xac, 0x27, 0x6d,
+	0x0f, 0xea, 0x4e, 0x59,
 	0x0f, 0xea, 0x04, 0x00,
-	0x00, 0xe2, 0x22, 0x45,
+	0x00, 0xe2, 0x2e, 0x45,
 	0x04, 0x8c, 0xe1, 0x30,
 	0x01, 0xea, 0xf2, 0x00,
 	0x02, 0xea, 0x36, 0x00,
 	0xa8, 0xea, 0x32, 0x00,
-	0xff, 0x93, 0x29, 0x7d,
-	0x14, 0xea, 0x50, 0x59,
+	0xff, 0xad, 0x35, 0x7d,
+	0x14, 0xea, 0x4e, 0x59,
 	0x14, 0xea, 0x04, 0x00,
-	0x00, 0xe2, 0xb0, 0x5d,
+	0x00, 0xe2, 0xa4, 0x5d,
 	0x01, 0xd9, 0xb2, 0x05,
 	0x09, 0x80, 0xe1, 0x30,
 	0x02, 0xea, 0x36, 0x00,
 	0xa8, 0xea, 0x32, 0x00,
-	0x00, 0xe2, 0xd8, 0x5d,
+	0x00, 0xe2, 0x9c, 0x5d,
 	0x01, 0xd9, 0xb2, 0x05,
-	0x02, 0xa8, 0xf4, 0x31,
-	0x02, 0xa6, 0x48, 0x7d,
-	0x00, 0xe2, 0x3e, 0x59,
-	0x20, 0x5b, 0x56, 0x6d,
-	0xfc, 0x42, 0x42, 0x7d,
-	0x10, 0x40, 0x44, 0x6d,
-	0x20, 0x4d, 0x46, 0x7d,
-	0x08, 0x5d, 0x56, 0x6d,
-	0x02, 0xa6, 0xda, 0x6b,
-	0x00, 0xe2, 0x3e, 0x59,
-	0x20, 0x5b, 0x56, 0x6d,
-	0x01, 0x1b, 0x76, 0x6d,
-	0xfc, 0x42, 0x52, 0x7d,
-	0x10, 0x40, 0x54, 0x6d,
-	0x20, 0x4d, 0x96, 0x7d,
-	0x08, 0x5d, 0x96, 0x7d,
+	0x02, 0xa6, 0x52, 0x7d,
+	0x00, 0xe2, 0x3c, 0x59,
+	0x20, 0x5b, 0x60, 0x6d,
+	0xfc, 0x42, 0x4c, 0x7d,
+	0x10, 0x40, 0x4e, 0x6d,
+	0x20, 0x4d, 0x50, 0x7d,
+	0x08, 0x5d, 0x60, 0x6d,
+	0x02, 0xa6, 0xe0, 0x6b,
+	0x00, 0xe2, 0x3c, 0x59,
+	0x20, 0x5b, 0x60, 0x6d,
+	0x01, 0x1b, 0x80, 0x6d,
+	0xfc, 0x42, 0x5c, 0x7d,
+	0x10, 0x40, 0x5e, 0x6d,
+	0x20, 0x4d, 0x64, 0x78,
+	0x08, 0x5d, 0x64, 0x78,
 	0x02, 0x19, 0x32, 0x00,
 	0x01, 0x5b, 0x40, 0x31,
-	0x00, 0xe2, 0xb4, 0x5c,
-	0x00, 0xe2, 0x92, 0x5b,
+	0x00, 0xe2, 0xba, 0x5c,
+	0x00, 0xe2, 0x98, 0x5b,
 	0x20, 0xea, 0xb6, 0x00,
-	0x00, 0xe2, 0xd4, 0x5b,
+	0x00, 0xe2, 0xda, 0x5b,
 	0x20, 0x5c, 0xb8, 0x00,
-	0x04, 0x19, 0x6c, 0x6d,
-	0x01, 0x1a, 0x6c, 0x6d,
-	0x00, 0xe2, 0x3e, 0x59,
-	0x01, 0x1a, 0x96, 0x7d,
+	0x04, 0x19, 0x76, 0x6d,
+	0x01, 0x1a, 0x76, 0x6d,
+	0x00, 0xe2, 0x3c, 0x59,
+	0x01, 0x1a, 0x64, 0x78,
 	0x80, 0xf9, 0xf2, 0x01,
-	0x20, 0xa0, 0xe8, 0x7d,
-	0x08, 0xa8, 0x75, 0x7d,
-	0x00, 0xe2, 0x88, 0x45,
+	0x20, 0xa0, 0xda, 0x7d,
+	0xff, 0xae, 0x5d, 0x1b,
+	0x08, 0xa8, 0x3d, 0x6b,
 	0x02, 0xea, 0xb4, 0x04,
-	0x02, 0x19, 0x32, 0x00,
-	0x08, 0xa8, 0x99, 0x7d,
-	0x04, 0x5d, 0xfe, 0x7d,
-	0x01, 0x1a, 0xfe, 0x7d,
-	0x01, 0xa4, 0x49, 0x03,
+	0x01, 0x9c, 0x39, 0x03,
+	0x40, 0x5b, 0x90, 0x6d,
+	0x00, 0xe2, 0x3c, 0x59,
+	0x40, 0x5b, 0x90, 0x6d,
+	0x04, 0x5d, 0xf4, 0x7d,
+	0x01, 0x1a, 0xf4, 0x7d,
+	0x20, 0x4d, 0x64, 0x78,
+	0x40, 0x5b, 0xda, 0x7d,
+	0x04, 0x5d, 0xf4, 0x7d,
+	0x01, 0x1a, 0xf4, 0x7d,
 	0x80, 0xf9, 0xf2, 0x01,
-	0x02, 0xa8, 0x84, 0x32,
-	0x02, 0xea, 0xb4, 0x00,
-	0x00, 0xe2, 0x3e, 0x43,
-	0x02, 0xa8, 0x84, 0x32,
-	0x02, 0xea, 0xb4, 0x00,
-	0xff, 0xea, 0xd4, 0x19,
-	0x00, 0xe2, 0x4a, 0x59,
-	0x11, 0x00, 0x00, 0x10,
-	0x00, 0xe2, 0xcc, 0x5d,
-	0x00, 0xe2, 0x3e, 0x53,
-	0xff, 0xea, 0xd4, 0x0d,
-	0x00, 0xe2, 0x3e, 0x59,
-	0x40, 0x5b, 0xa4, 0x6d,
-	0x04, 0x5d, 0xfe, 0x7d,
-	0x01, 0x1a, 0xfe, 0x7d,
-	0x20, 0x4d, 0x96, 0x7d,
-	0x40, 0x5b, 0xe8, 0x7d,
-	0x04, 0x5d, 0xfe, 0x7d,
-	0x01, 0x1a, 0xfe, 0x7d,
+	0xff, 0xae, 0x5d, 0x1b,
+	0x08, 0xa8, 0x3d, 0x6b,
+	0x02, 0xea, 0xb4, 0x04,
+	0x00, 0xe2, 0x3c, 0x59,
+	0x01, 0x1b, 0x64, 0x78,
 	0x80, 0xf9, 0xf2, 0x01,
-	0x01, 0xa4, 0x49, 0x03,
-	0x08, 0xa8, 0x89, 0x6d,
 	0x02, 0xea, 0xb4, 0x04,
 	0x00, 0xe2, 0x3c, 0x59,
-	0x01, 0x1b, 0xc0, 0x7d,
-	0x40, 0x5b, 0x96, 0x7d,
+	0x01, 0x1b, 0xb8, 0x6d,
+	0x40, 0x5b, 0xc6, 0x7d,
+	0x01, 0x1b, 0xb8, 0x6d,
 	0x02, 0x19, 0x32, 0x00,
+	0x01, 0x1a, 0x64, 0x78,
 	0x80, 0xf9, 0xf2, 0x01,
 	0xff, 0xea, 0x10, 0x03,
 	0x08, 0xa8, 0x51, 0x03,
-	0x00, 0xe2, 0x88, 0x45,
-	0xff, 0x6a, 0xc6, 0x6d,
-	0x40, 0x5b, 0x96, 0x7d,
-	0xff, 0x6a, 0xb6, 0x7d,
-	0x10, 0xea, 0x50, 0x59,
+	0x00, 0xe2, 0x3c, 0x43,
+	0x01, 0x1a, 0xc2, 0x7d,
+	0x40, 0x5b, 0xbe, 0x7d,
+	0x01, 0x1a, 0xac, 0x6d,
+	0xfc, 0x42, 0x64, 0x78,
+	0x01, 0x1a, 0xc6, 0x6d,
+	0x10, 0xea, 0x4e, 0x59,
 	0x10, 0xea, 0x04, 0x00,
-	0x00, 0xe2, 0xb6, 0x45,
-	0x80, 0xf9, 0x96, 0x6d,
-	0x01, 0x43, 0xc1, 0x31,
-	0x00, 0xfb, 0x96, 0x65,
-	0x01, 0x42, 0xc1, 0x31,
-	0x00, 0xfa, 0x96, 0x65,
-	0x01, 0xe8, 0xd4, 0x1d,
-	0x00, 0xe2, 0x3c, 0x59,
-	0x01, 0x1b, 0x96, 0x7d,
-	0x80, 0xf9, 0xf2, 0x01,
-	0x02, 0xea, 0xb4, 0x04,
+	0xfc, 0x42, 0x64, 0x78,
+	0x10, 0x40, 0xcc, 0x6d,
+	0x20, 0x4d, 0x64, 0x78,
+	0x40, 0x5b, 0xac, 0x6d,
+	0x01, 0x1a, 0x64, 0x78,
+	0x01, 0xae, 0x5d, 0x1b,
 	0x30, 0x3f, 0xc0, 0x09,
-	0x30, 0xe0, 0x96, 0x65,
-	0x40, 0x4b, 0x96, 0x6d,
+	0x30, 0xe0, 0x64, 0x60,
+	0x40, 0x4b, 0x64, 0x68,
 	0xff, 0xea, 0x52, 0x01,
-	0xee, 0x00, 0xee, 0x6d,
+	0xee, 0x00, 0xe0, 0x6d,
 	0x80, 0xf9, 0xf2, 0x01,
+	0xff, 0xae, 0x5d, 0x1b,
 	0x02, 0xea, 0xb4, 0x00,
 	0x20, 0xea, 0x9a, 0x00,
-	0xf3, 0x42, 0xf8, 0x6d,
-	0x12, 0xea, 0x50, 0x59,
+	0xf3, 0x42, 0xec, 0x6d,
+	0x12, 0xea, 0x4e, 0x59,
 	0x12, 0xea, 0x04, 0x00,
-	0x00, 0xe2, 0xf8, 0x41,
-	0x0d, 0xea, 0x50, 0x59,
+	0x00, 0xe2, 0xf6, 0x41,
+	0x0d, 0xea, 0x4e, 0x59,
 	0x0d, 0xea, 0x04, 0x00,
-	0x00, 0xe2, 0xf8, 0x41,
-	0x11, 0xea, 0x50, 0x59,
+	0x00, 0xe2, 0xf6, 0x41,
+	0x01, 0xae, 0x5d, 0x1b,
+	0x11, 0xea, 0x4e, 0x59,
 	0x11, 0xea, 0x04, 0x00,
-	0x00, 0xe2, 0x2e, 0x5b,
+	0x00, 0xe2, 0x2c, 0x5b,
 	0x08, 0x5a, 0xb4, 0x00,
-	0x00, 0xe2, 0x22, 0x5e,
+	0x00, 0xe2, 0x1a, 0x5e,
 	0xa8, 0xea, 0x32, 0x00,
-	0x00, 0xe2, 0x3e, 0x59,
-	0x80, 0x1a, 0x12, 0x7e,
-	0x00, 0xe2, 0x22, 0x5e,
+	0x00, 0xe2, 0x3c, 0x59,
+	0x80, 0x1a, 0x08, 0x7e,
+	0x00, 0xe2, 0x1a, 0x5e,
 	0x80, 0x19, 0x32, 0x00,
-	0x40, 0x5b, 0x18, 0x6e,
-	0x08, 0x5a, 0x18, 0x7e,
-	0x20, 0x4d, 0x96, 0x7d,
+	0x40, 0x5b, 0x0e, 0x6e,
+	0x08, 0x5a, 0x0e, 0x7e,
+	0x20, 0x4d, 0x64, 0x78,
 	0x02, 0x84, 0x09, 0x03,
-	0x40, 0x5b, 0xe8, 0x7d,
-	0x08, 0xa8, 0x81, 0x6d,
+	0x40, 0x5b, 0xda, 0x7d,
+	0xff, 0xae, 0x5d, 0x1b,
 	0x80, 0xf9, 0xf2, 0x01,
+	0x08, 0xa8, 0x3d, 0x6b,
 	0x02, 0xea, 0xb4, 0x04,
 	0x01, 0x38, 0xe1, 0x30,
 	0x05, 0x39, 0xe3, 0x98,
-	0x01, 0xe0, 0xf8, 0x31,
+	0x01, 0xe0, 0xf4, 0x31,
 	0xff, 0xea, 0xc0, 0x09,
 	0x00, 0x3a, 0xe5, 0x20,
 	0x00, 0x3b, 0xe7, 0x20,
-	0x01, 0xfc, 0xc0, 0x31,
+	0x01, 0xfa, 0xc0, 0x31,
 	0x04, 0xea, 0xe8, 0x30,
 	0xff, 0xea, 0xf0, 0x08,
 	0x02, 0xea, 0xf2, 0x00,
@@ -1000,124 +996,121 @@
 	{ ahd_patch0_func, 30, 1, 1 },
 	{ ahd_patch1_func, 37, 1, 2 },
 	{ ahd_patch0_func, 38, 1, 1 },
-	{ ahd_patch2_func, 45, 1, 2 },
-	{ ahd_patch0_func, 46, 1, 1 },
-	{ ahd_patch2_func, 49, 1, 2 },
-	{ ahd_patch0_func, 50, 1, 1 },
-	{ ahd_patch2_func, 53, 1, 2 },
-	{ ahd_patch0_func, 54, 1, 1 },
-	{ ahd_patch2_func, 56, 1, 2 },
-	{ ahd_patch0_func, 57, 1, 1 },
-	{ ahd_patch2_func, 60, 1, 2 },
-	{ ahd_patch0_func, 61, 1, 1 },
-	{ ahd_patch2_func, 64, 1, 2 },
-	{ ahd_patch0_func, 65, 1, 1 },
-	{ ahd_patch2_func, 162, 6, 1 },
-	{ ahd_patch1_func, 168, 2, 1 },
-	{ ahd_patch4_func, 170, 1, 1 },
-	{ ahd_patch2_func, 179, 1, 2 },
-	{ ahd_patch0_func, 180, 1, 1 },
-	{ ahd_patch5_func, 181, 2, 2 },
-	{ ahd_patch0_func, 183, 6, 3 },
-	{ ahd_patch2_func, 186, 1, 2 },
-	{ ahd_patch0_func, 187, 1, 1 },
-	{ ahd_patch2_func, 190, 1, 2 },
-	{ ahd_patch0_func, 191, 1, 1 },
-	{ ahd_patch6_func, 193, 2, 1 },
-	{ ahd_patch4_func, 201, 16, 2 },
-	{ ahd_patch0_func, 217, 1, 1 },
-	{ ahd_patch7_func, 237, 2, 1 },
-	{ ahd_patch1_func, 241, 1, 2 },
-	{ ahd_patch0_func, 242, 1, 1 },
-	{ ahd_patch6_func, 245, 2, 1 },
-	{ ahd_patch1_func, 259, 1, 2 },
-	{ ahd_patch0_func, 260, 1, 1 },
-	{ ahd_patch1_func, 263, 1, 2 },
-	{ ahd_patch0_func, 264, 1, 1 },
-	{ ahd_patch2_func, 267, 1, 2 },
-	{ ahd_patch0_func, 268, 1, 1 },
-	{ ahd_patch1_func, 323, 1, 2 },
-	{ ahd_patch0_func, 324, 1, 1 },
-	{ ahd_patch2_func, 332, 1, 2 },
-	{ ahd_patch0_func, 333, 1, 1 },
-	{ ahd_patch2_func, 336, 1, 2 },
-	{ ahd_patch0_func, 337, 1, 1 },
-	{ ahd_patch1_func, 344, 1, 2 },
-	{ ahd_patch0_func, 345, 1, 1 },
-	{ ahd_patch8_func, 364, 1, 1 },
-	{ ahd_patch8_func, 367, 1, 1 },
-	{ ahd_patch8_func, 369, 1, 1 },
-	{ ahd_patch8_func, 381, 1, 1 },
-	{ ahd_patch1_func, 391, 1, 2 },
-	{ ahd_patch0_func, 392, 1, 1 },
-	{ ahd_patch1_func, 394, 1, 2 },
-	{ ahd_patch0_func, 395, 1, 1 },
-	{ ahd_patch1_func, 403, 1, 2 },
-	{ ahd_patch0_func, 404, 1, 1 },
-	{ ahd_patch2_func, 415, 1, 2 },
-	{ ahd_patch0_func, 416, 1, 1 },
-	{ ahd_patch9_func, 444, 1, 1 },
-	{ ahd_patch1_func, 451, 1, 2 },
-	{ ahd_patch0_func, 452, 1, 1 },
-	{ ahd_patch2_func, 464, 1, 2 },
-	{ ahd_patch0_func, 465, 1, 1 },
-	{ ahd_patch10_func, 470, 6, 2 },
-	{ ahd_patch0_func, 476, 1, 1 },
-	{ ahd_patch11_func, 499, 1, 1 },
-	{ ahd_patch12_func, 508, 1, 1 },
-	{ ahd_patch13_func, 509, 1, 2 },
-	{ ahd_patch0_func, 510, 1, 1 },
-	{ ahd_patch14_func, 515, 1, 1 },
-	{ ahd_patch13_func, 516, 1, 1 },
-	{ ahd_patch15_func, 529, 1, 2 },
-	{ ahd_patch0_func, 530, 1, 1 },
-	{ ahd_patch1_func, 552, 1, 2 },
-	{ ahd_patch0_func, 553, 1, 1 },
-	{ ahd_patch1_func, 556, 1, 2 },
-	{ ahd_patch0_func, 557, 1, 1 },
-	{ ahd_patch2_func, 562, 1, 2 },
-	{ ahd_patch0_func, 563, 1, 1 },
-	{ ahd_patch2_func, 567, 1, 2 },
-	{ ahd_patch0_func, 568, 1, 1 },
-	{ ahd_patch1_func, 569, 1, 2 },
-	{ ahd_patch0_func, 570, 1, 1 },
-	{ ahd_patch2_func, 581, 1, 2 },
-	{ ahd_patch0_func, 582, 1, 1 },
-	{ ahd_patch16_func, 586, 1, 1 },
-	{ ahd_patch17_func, 591, 1, 1 },
-	{ ahd_patch18_func, 592, 2, 1 },
-	{ ahd_patch17_func, 596, 1, 2 },
-	{ ahd_patch0_func, 597, 1, 1 },
-	{ ahd_patch2_func, 600, 1, 2 },
-	{ ahd_patch0_func, 601, 1, 1 },
-	{ ahd_patch2_func, 619, 1, 2 },
-	{ ahd_patch0_func, 620, 1, 1 },
-	{ ahd_patch19_func, 621, 12, 1 },
-	{ ahd_patch1_func, 637, 1, 2 },
-	{ ahd_patch0_func, 638, 1, 1 },
-	{ ahd_patch19_func, 639, 1, 1 },
-	{ ahd_patch1_func, 650, 1, 2 },
-	{ ahd_patch0_func, 651, 1, 1 },
-	{ ahd_patch1_func, 658, 1, 2 },
-	{ ahd_patch0_func, 659, 1, 1 },
-	{ ahd_patch16_func, 683, 1, 1 },
-	{ ahd_patch16_func, 699, 1, 1 },
-	{ ahd_patch2_func, 711, 1, 2 },
-	{ ahd_patch0_func, 712, 1, 1 },
-	{ ahd_patch16_func, 731, 1, 1 },
-	{ ahd_patch1_func, 739, 1, 2 },
-	{ ahd_patch0_func, 740, 1, 1 },
-	{ ahd_patch1_func, 761, 1, 2 },
-	{ ahd_patch0_func, 762, 1, 1 },
-	{ ahd_patch1_func, 764, 1, 2 },
-	{ ahd_patch0_func, 765, 1, 1 },
-	{ ahd_patch1_func, 767, 1, 2 },
-	{ ahd_patch0_func, 768, 1, 1 },
-	{ ahd_patch20_func, 770, 1, 2 },
-	{ ahd_patch0_func, 771, 2, 1 },
-	{ ahd_patch21_func, 774, 4, 2 },
-	{ ahd_patch0_func, 778, 1, 1 },
-	{ ahd_patch21_func, 785, 11, 1 }
+	{ ahd_patch2_func, 43, 1, 2 },
+	{ ahd_patch0_func, 44, 1, 1 },
+	{ ahd_patch2_func, 47, 1, 2 },
+	{ ahd_patch0_func, 48, 1, 1 },
+	{ ahd_patch2_func, 51, 1, 2 },
+	{ ahd_patch0_func, 52, 1, 1 },
+	{ ahd_patch2_func, 65, 1, 2 },
+	{ ahd_patch0_func, 66, 1, 1 },
+	{ ahd_patch2_func, 69, 1, 2 },
+	{ ahd_patch0_func, 70, 1, 1 },
+	{ ahd_patch1_func, 73, 1, 2 },
+	{ ahd_patch0_func, 74, 1, 1 },
+	{ ahd_patch2_func, 161, 6, 1 },
+	{ ahd_patch1_func, 167, 2, 1 },
+	{ ahd_patch4_func, 169, 1, 1 },
+	{ ahd_patch2_func, 178, 1, 2 },
+	{ ahd_patch0_func, 179, 1, 1 },
+	{ ahd_patch5_func, 180, 2, 2 },
+	{ ahd_patch0_func, 182, 6, 3 },
+	{ ahd_patch2_func, 185, 1, 2 },
+	{ ahd_patch0_func, 186, 1, 1 },
+	{ ahd_patch2_func, 189, 1, 2 },
+	{ ahd_patch0_func, 190, 1, 1 },
+	{ ahd_patch6_func, 192, 2, 1 },
+	{ ahd_patch4_func, 200, 16, 2 },
+	{ ahd_patch0_func, 216, 1, 1 },
+	{ ahd_patch7_func, 236, 2, 1 },
+	{ ahd_patch1_func, 240, 1, 2 },
+	{ ahd_patch0_func, 241, 1, 1 },
+	{ ahd_patch6_func, 244, 2, 1 },
+	{ ahd_patch1_func, 258, 1, 2 },
+	{ ahd_patch0_func, 259, 1, 1 },
+	{ ahd_patch1_func, 262, 1, 2 },
+	{ ahd_patch0_func, 263, 1, 1 },
+	{ ahd_patch2_func, 266, 1, 2 },
+	{ ahd_patch0_func, 267, 1, 1 },
+	{ ahd_patch1_func, 322, 1, 2 },
+	{ ahd_patch0_func, 323, 1, 1 },
+	{ ahd_patch2_func, 331, 1, 2 },
+	{ ahd_patch0_func, 332, 1, 1 },
+	{ ahd_patch2_func, 335, 1, 2 },
+	{ ahd_patch0_func, 336, 1, 1 },
+	{ ahd_patch1_func, 343, 1, 2 },
+	{ ahd_patch0_func, 344, 1, 1 },
+	{ ahd_patch8_func, 363, 1, 1 },
+	{ ahd_patch8_func, 366, 1, 1 },
+	{ ahd_patch8_func, 368, 1, 1 },
+	{ ahd_patch8_func, 380, 1, 1 },
+	{ ahd_patch1_func, 390, 1, 2 },
+	{ ahd_patch0_func, 391, 1, 1 },
+	{ ahd_patch1_func, 393, 1, 2 },
+	{ ahd_patch0_func, 394, 1, 1 },
+	{ ahd_patch1_func, 402, 1, 2 },
+	{ ahd_patch0_func, 403, 1, 1 },
+	{ ahd_patch2_func, 416, 1, 2 },
+	{ ahd_patch0_func, 417, 1, 1 },
+	{ ahd_patch9_func, 447, 1, 1 },
+	{ ahd_patch1_func, 454, 1, 2 },
+	{ ahd_patch0_func, 455, 1, 1 },
+	{ ahd_patch2_func, 467, 1, 2 },
+	{ ahd_patch0_func, 468, 1, 1 },
+	{ ahd_patch10_func, 473, 6, 2 },
+	{ ahd_patch0_func, 479, 1, 1 },
+	{ ahd_patch11_func, 502, 1, 1 },
+	{ ahd_patch12_func, 511, 1, 1 },
+	{ ahd_patch13_func, 512, 1, 2 },
+	{ ahd_patch0_func, 513, 1, 1 },
+	{ ahd_patch14_func, 518, 1, 1 },
+	{ ahd_patch13_func, 519, 1, 1 },
+	{ ahd_patch15_func, 532, 1, 2 },
+	{ ahd_patch0_func, 533, 1, 1 },
+	{ ahd_patch1_func, 555, 1, 2 },
+	{ ahd_patch0_func, 556, 1, 1 },
+	{ ahd_patch1_func, 559, 1, 2 },
+	{ ahd_patch0_func, 560, 1, 1 },
+	{ ahd_patch2_func, 565, 1, 2 },
+	{ ahd_patch0_func, 566, 1, 1 },
+	{ ahd_patch2_func, 570, 1, 2 },
+	{ ahd_patch0_func, 571, 1, 1 },
+	{ ahd_patch1_func, 572, 1, 2 },
+	{ ahd_patch0_func, 573, 1, 1 },
+	{ ahd_patch2_func, 584, 1, 2 },
+	{ ahd_patch0_func, 585, 1, 1 },
+	{ ahd_patch16_func, 589, 1, 1 },
+	{ ahd_patch17_func, 594, 1, 1 },
+	{ ahd_patch18_func, 595, 2, 1 },
+	{ ahd_patch17_func, 599, 1, 2 },
+	{ ahd_patch0_func, 600, 1, 1 },
+	{ ahd_patch2_func, 603, 1, 2 },
+	{ ahd_patch0_func, 604, 1, 1 },
+	{ ahd_patch2_func, 622, 1, 2 },
+	{ ahd_patch0_func, 623, 1, 1 },
+	{ ahd_patch19_func, 624, 14, 1 },
+	{ ahd_patch1_func, 642, 1, 2 },
+	{ ahd_patch0_func, 643, 1, 1 },
+	{ ahd_patch19_func, 644, 1, 1 },
+	{ ahd_patch1_func, 656, 1, 2 },
+	{ ahd_patch0_func, 657, 1, 1 },
+	{ ahd_patch1_func, 664, 1, 2 },
+	{ ahd_patch0_func, 665, 1, 1 },
+	{ ahd_patch16_func, 688, 1, 1 },
+	{ ahd_patch16_func, 726, 1, 1 },
+	{ ahd_patch1_func, 737, 1, 2 },
+	{ ahd_patch0_func, 738, 1, 1 },
+	{ ahd_patch1_func, 755, 1, 2 },
+	{ ahd_patch0_func, 756, 1, 1 },
+	{ ahd_patch1_func, 758, 1, 2 },
+	{ ahd_patch0_func, 759, 1, 1 },
+	{ ahd_patch1_func, 762, 1, 2 },
+	{ ahd_patch0_func, 763, 1, 1 },
+	{ ahd_patch20_func, 765, 1, 2 },
+	{ ahd_patch0_func, 766, 2, 1 },
+	{ ahd_patch21_func, 769, 4, 2 },
+	{ ahd_patch0_func, 773, 1, 1 },
+	{ ahd_patch21_func, 781, 11, 1 }
 };
 
 static struct cs {
@@ -1127,18 +1120,15 @@
 	{ 11, 12 },
 	{ 13, 14 },
 	{ 29, 42 },
-	{ 43, 56 },
-	{ 69, 72 },
-	{ 99, 124 },
-	{ 125, 156 },
-	{ 158, 162 },
-	{ 170, 178 },
-	{ 201, 250 },
-	{ 683, 699 },
-	{ 699, 717 },
-	{ 722, 728 },
-	{ 731, 736 },
-	{ 742, 748 }
+	{ 56, 59 },
+	{ 101, 127 },
+	{ 128, 156 },
+	{ 158, 161 },
+	{ 169, 177 },
+	{ 200, 249 },
+	{ 688, 704 },
+	{ 704, 718 },
+	{ 728, 732 }
 };
 
 static const int num_critical_sections = sizeof(critical_sections)
diff -urN linux-2.5.69-bk7/drivers/scsi/aic7xxx/aic7xxx.h linux-2.5.69-bk8/drivers/scsi/aic7xxx/aic7xxx.h
--- linux-2.5.69-bk7/drivers/scsi/aic7xxx/aic7xxx.h	2003-05-04 16:53:31.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/aic7xxx/aic7xxx.h	2003-05-13 04:44:29.000000000 -0700
@@ -37,7 +37,7 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  *
- * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.h#74 $
+ * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.h#75 $
  *
  * $FreeBSD$
  */
@@ -1082,6 +1082,14 @@
 	/* PCI cacheline size. */
 	u_int			  pci_cachesize;
 
+	/*
+	 * Count of parity errors we have seen as a target.
+	 * We auto-disable parity error checking after seeing
+	 * AHC_PCI_TARGET_PERR_THRESH number of errors.
+	 */
+	u_int			  pci_target_perr_count;
+#define		AHC_PCI_TARGET_PERR_THRESH	10
+
 	/* Maximum number of sequencer instructions supported. */
 	u_int			  instruction_ram_size;
 
diff -urN linux-2.5.69-bk7/drivers/scsi/aic7xxx/aic7xxx_core.c linux-2.5.69-bk8/drivers/scsi/aic7xxx/aic7xxx_core.c
--- linux-2.5.69-bk7/drivers/scsi/aic7xxx/aic7xxx_core.c	2003-05-04 16:53:14.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/aic7xxx/aic7xxx_core.c	2003-05-13 04:44:29.000000000 -0700
@@ -37,7 +37,7 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  *
- * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.c#124 $
+ * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.c#128 $
  *
  * $FreeBSD$
  */
@@ -3949,7 +3949,6 @@
 {
 	int i;
 
-	ahc_fini_scbdata(ahc);
 	switch (ahc->init_level) {
 	default:
 	case 5:
@@ -3981,6 +3980,7 @@
 	ahc_dma_tag_destroy(ahc, ahc->parent_dmat);
 #endif
 	ahc_platform_free(ahc);
+	ahc_fini_scbdata(ahc);
 	for (i = 0; i < AHC_NUM_TARGETS; i++) {
 		struct ahc_tmode_tstate *tstate;
 
@@ -5100,7 +5100,7 @@
 	} while (--maxloops
 	      && (intstat != 0xFF || (ahc->features & AHC_REMOVABLE) == 0)
 	      && ((intstat & INT_PEND) != 0
-	       || (ahc_inb(ahc, SSTAT0) & (SELDO|SELINGO))));
+	       || (ahc_inb(ahc, SSTAT0) & (SELDO|SELINGO)) != 0));
 	if (maxloops == 0) {
 		printf("Infinite interrupt loop, INTSTAT = %x",
 		       ahc_inb(ahc, INTSTAT));
diff -urN linux-2.5.69-bk7/drivers/scsi/aic7xxx/aic7xxx_inline.h linux-2.5.69-bk8/drivers/scsi/aic7xxx/aic7xxx_inline.h
--- linux-2.5.69-bk7/drivers/scsi/aic7xxx/aic7xxx_inline.h	2003-05-04 16:53:57.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/aic7xxx/aic7xxx_inline.h	2003-05-13 04:44:29.000000000 -0700
@@ -37,7 +37,7 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  *
- * $Id: //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#40 $
+ * $Id: //depot/aic7xxx/aic7xxx/aic7xxx_inline.h#42 $
  *
  * $FreeBSD$
  */
@@ -500,7 +500,7 @@
 static __inline void	ahc_sync_qoutfifo(struct ahc_softc *ahc, int op);
 static __inline void	ahc_sync_tqinfifo(struct ahc_softc *ahc, int op);
 static __inline u_int	ahc_check_cmdcmpltqueues(struct ahc_softc *ahc);
-static __inline void	ahc_intr(struct ahc_softc *ahc);
+static __inline int	ahc_intr(struct ahc_softc *ahc);
 
 static __inline void
 ahc_sync_qoutfifo(struct ahc_softc *ahc, int op)
@@ -558,7 +558,7 @@
 /*
  * Catch an interrupt from the adapter
  */
-static __inline void
+static __inline int
 ahc_intr(struct ahc_softc *ahc)
 {
 	u_int	intstat;
@@ -570,7 +570,7 @@
 		 * so just return.  This is likely just a shared
 		 * interrupt.
 		 */
-		return;
+		return (0);
 	}
 	/*
 	 * Instead of directly reading the interrupt status register,
@@ -585,6 +585,20 @@
 		intstat = ahc_inb(ahc, INTSTAT);
 	}
 
+	if ((intstat & INT_PEND) == 0) {
+#if AHC_PCI_CONFIG > 0
+		if (ahc->unsolicited_ints > 500) {
+			ahc->unsolicited_ints = 0;
+			if ((ahc->chip & AHC_PCI) != 0
+			 && (ahc_inb(ahc, ERROR) & PCIERRSTAT) != 0)
+				ahc->bus_intr(ahc);
+		}
+#endif
+		ahc->unsolicited_ints++;
+		return (0);
+	}
+	ahc->unsolicited_ints = 0;
+
 	if (intstat & CMDCMPLT) {
 		ahc_outb(ahc, CLRINT, CLRCMDINT);
 
@@ -604,38 +618,25 @@
 #endif
 	}
 
-	if (intstat == 0xFF && (ahc->features & AHC_REMOVABLE) != 0)
-		/* Hot eject */
-		return;
-
-	if ((intstat & INT_PEND) == 0) {
-#if AHC_PCI_CONFIG > 0
-		if (ahc->unsolicited_ints > 500) {
-			ahc->unsolicited_ints = 0;
-			if ((ahc->chip & AHC_PCI) != 0
-			 && (ahc_inb(ahc, ERROR) & PCIERRSTAT) != 0)
-				ahc->bus_intr(ahc);
-		}
-#endif
-		ahc->unsolicited_ints++;
-		return;
-	}
-	ahc->unsolicited_ints = 0;
-
-	if (intstat & BRKADRINT) {
+	/*
+	 * Handle statuses that may invalidate our cached
+	 * copy of INTSTAT separately.
+	 */
+	if (intstat == 0xFF && (ahc->features & AHC_REMOVABLE) != 0) {
+		/* Hot eject.  Do nothing */
+	} else if (intstat & BRKADRINT) {
 		ahc_handle_brkadrint(ahc);
-		/* Fatal error, no more interrupts to handle. */
-		return;
-	}
+	} else if ((intstat & (SEQINT|SCSIINT)) != 0) {
 
-	if ((intstat & (SEQINT|SCSIINT)) != 0)
 		ahc_pause_bug_fix(ahc);
 
-	if ((intstat & SEQINT) != 0)
-		ahc_handle_seqint(ahc, intstat);
+		if ((intstat & SEQINT) != 0)
+			ahc_handle_seqint(ahc, intstat);
 
-	if ((intstat & SCSIINT) != 0)
-		ahc_handle_scsiint(ahc, intstat);
+		if ((intstat & SCSIINT) != 0)
+			ahc_handle_scsiint(ahc, intstat);
+	}
+	return (1);
 }
 
 #endif  /* _AIC7XXX_INLINE_H_ */
diff -urN linux-2.5.69-bk7/drivers/scsi/aic7xxx/aic7xxx_osm.c linux-2.5.69-bk8/drivers/scsi/aic7xxx/aic7xxx_osm.c
--- linux-2.5.69-bk7/drivers/scsi/aic7xxx/aic7xxx_osm.c	2003-05-04 16:53:01.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/aic7xxx/aic7xxx_osm.c	2003-05-13 04:44:29.000000000 -0700
@@ -1,7 +1,7 @@
 /*
  * Adaptec AIC7xxx device driver for Linux.
  *
- * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#206 $
+ * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c#221 $
  *
  * Copyright (c) 1994 John Aycock
  *   The University of Calgary Department of Computer Science.
@@ -146,18 +146,15 @@
 #include <linux/unistd.h>
 static int errno;
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0)
 /*
  * Lock protecting manipulation of the ahc softc list.
  */
 spinlock_t ahc_list_spinlock;
-#endif
 
-/*
- * To generate the correct addresses for the controller to issue
- * on the bus.  Originally added for DEC Alpha support.
- */
-#define VIRT_TO_BUS(a) (uint32_t)virt_to_bus((void *)(a))
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+/* For dynamic sglist size calculation. */
+u_int ahc_linux_nseg;
+#endif
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
 struct proc_dir_entry proc_scsi_aic7xxx = {
@@ -367,31 +364,26 @@
  * disabled at the very end.  That should fix everyone up unless there are
  * really strange cirumstances.
  */
-static int aic7xxx_reverse_scan = 0;
+static uint32_t aic7xxx_reverse_scan;
 
 /*
  * Should we force EXTENDED translation on a controller.
  *     0 == Use whatever is in the SEEPROM or default to off
  *     1 == Use whatever is in the SEEPROM or default to on
  */
-static uint32_t aic7xxx_extended = 0;
+static uint32_t aic7xxx_extended;
 
 /*
  * PCI bus parity checking of the Adaptec controllers.  This is somewhat
  * dubious at best.  To my knowledge, this option has never actually
  * solved a PCI parity problem, but on certain machines with broken PCI
- * chipset configurations, it can generate tons of false error messages.
+ * chipset configurations where stray PCI transactions with bad parity are
+ * the norm rather than the exception, the error messages can be overwelming.
  * It's included in the driver for completeness.
- *   0 = Shut off PCI parity check
- *  -1 = Normal polarity pci parity checking
- *   1 = reverse polarity pci parity checking
- *
- * NOTE: you can't actually pass -1 on the lilo prompt.  So, to set this
- * variable to -1 you would actually want to simply pass the variable
- * name without a number.  That will invert the 0 which will result in
- * -1.
+ *   0	   = Shut off PCI parity check
+ *   non-0 = reverse polarity pci parity checking
  */
-static int aic7xxx_pci_parity = 0;
+static uint32_t aic7xxx_pci_parity = ~0;
 
 /*
  * Certain newer motherboards have put new PCI based devices into the
@@ -404,12 +396,9 @@
  * would result in never finding any devices :)
  */
 #ifndef CONFIG_AIC7XXX_PROBE_EISA_VL
-#define CONFIG_AIC7XXX_PROBE_EISA_VL n
-#endif
-#if CONFIG_AIC7XXX_PROBE_EISA_VL == n
-static int aic7xxx_no_probe = 1;
+static uint32_t aic7xxx_probe_eisa_vl;
 #else
-static int aic7xxx_no_probe;
+static uint32_t aic7xxx_probe_eisa_vl = ~0;
 #endif
 
 /*
@@ -418,7 +407,7 @@
  * controller.  I/O mapped register access, if allowed by the given
  * platform, will work in almost all cases.
  */
-int aic7xxx_allow_memio = 1;
+uint32_t aic7xxx_allow_memio = ~0;
 
 /*
  * aic7xxx_detect() has been run, so register all device arrivals
@@ -437,7 +426,7 @@
  * We default to 256ms because some older devices need a longer time
  * to respond to initial selection.
  */
-static int aic7xxx_seltime = 0x00;
+static uint32_t aic7xxx_seltime;
 
 /*
  * Certain devices do not perform any aging on commands.  Should the
@@ -447,7 +436,7 @@
  * force all outstanding transactions to be serviced prior to a new
  * transaction.
  */
-int aic7xxx_periodic_otag;
+uint32_t aic7xxx_periodic_otag;
 
 /*
  * Module information and settable options.
@@ -472,7 +461,8 @@
 "	verbose			Enable verbose/diagnostic logging\n"
 "	allow_memio		Allow device registers to be memory mapped\n"
 "	debug			Bitmask of debug values to enable\n"
-"	no_probe		Disable EISA/VLB controller probing\n"
+"	no_probe		Toggle EISA/VLB controller probing\n"
+"	probe_eisa_vl		Toggle EISA/VLB controller probing\n"
 "	no_reset		Supress initial bus resets\n"
 "	extended		Enable extended geometry on all controllers\n"
 "	periodic_otag		Send an ordered tagged transaction\n"
@@ -489,10 +479,10 @@
 "\n"
 "	Sample /etc/modules.conf line:\n"
 "		Toggle EISA/VLB probing\n"
-"		Set tag depth on Controller 1/Target 2 to 10 tags\n"
+"		Set tag depth on Controller 1/Target 1 to 10 tags\n"
 "		Shorten the selection timeout to 128ms\n"
 "\n"
-"	options aic7xxx 'aic7xxx=no_probe.tag_info:{{}.{..10}}.seltime:1'\n"
+"	options aic7xxx 'aic7xxx=probe_eisa_vl.tag_info:{{}.{.10}}.seltime:1'\n"
 );
 #endif
 
@@ -508,6 +498,7 @@
 static void ahc_linux_dev_timed_unfreeze(u_long arg);
 static int  ahc_linux_queue_recovery_cmd(Scsi_Cmnd *cmd, scb_flag flag);
 static void ahc_linux_initialize_scsi_bus(struct ahc_softc *ahc);
+static void ahc_linux_size_nseg(void);
 static void ahc_linux_thread_run_complete_queue(struct ahc_softc *ahc);
 static void ahc_linux_start_dv(struct ahc_softc *ahc);
 static void ahc_linux_dv_timeout(struct scsi_cmnd *cmd);
@@ -571,16 +562,14 @@
 static int  aic7xxx_setup(char *s);
 static int  ahc_linux_next_unit(void);
 static void ahc_runq_tasklet(unsigned long data);
-static int  ahc_linux_halt(struct notifier_block *nb, u_long event, void *buf);
-static void ahc_schedule_completeq(struct ahc_softc *ahc, struct ahc_cmd *acmd);
+static struct ahc_cmd *ahc_linux_run_complete_queue(struct ahc_softc *ahc);
 
 /********************************* Inlines ************************************/
 static __inline void ahc_schedule_runq(struct ahc_softc *ahc);
 static __inline struct ahc_linux_device*
 		     ahc_linux_get_device(struct ahc_softc *ahc, u_int channel,
 					  u_int target, u_int lun, int alloc);
-static struct ahc_cmd *ahc_linux_run_complete_queue(struct ahc_softc *ahc,
-						    struct ahc_cmd *acmd);
+static __inline void ahc_schedule_completeq(struct ahc_softc *ahc);
 static __inline void ahc_linux_check_device_queue(struct ahc_softc *ahc,
 						  struct ahc_linux_device *dev);
 static __inline struct ahc_linux_device *
@@ -592,27 +581,9 @@
 		 		      struct ahc_dma_seg *sg,
 				      bus_addr_t addr, bus_size_t len);
 
-static void
-ahc_schedule_completeq(struct ahc_softc *ahc, struct ahc_cmd *acmd)
+static __inline void
+ahc_schedule_completeq(struct ahc_softc *ahc)
 {
-	while (acmd != NULL) {
-		struct ahc_completeq *completeq;
-		struct ahc_cmd *list_cmd;
-		struct ahc_cmd *next_cmd;
-
-		next_cmd = TAILQ_NEXT(acmd, acmd_links.tqe);
-		completeq = &ahc->platform_data->completeq;
-		list_cmd = TAILQ_FIRST(completeq);
-		while (list_cmd != NULL
-		    && acmd_scsi_cmd(list_cmd).serial_number
-		     < acmd_scsi_cmd(acmd).serial_number)
-			list_cmd = TAILQ_NEXT(list_cmd, acmd_links.tqe);
-		if (list_cmd != NULL)
-			TAILQ_INSERT_BEFORE(list_cmd, acmd, acmd_links.tqe);
-		else
-			TAILQ_INSERT_TAIL(completeq, acmd, acmd_links.tqe);
-		acmd = next_cmd;
-	}
 	if ((ahc->platform_data->flags & AHC_RUN_CMPLT_Q_TIMER) == 0) {
 		ahc->platform_data->flags |= AHC_RUN_CMPLT_Q_TIMER;
 		ahc->platform_data->completeq_timer.expires = jiffies;
@@ -664,25 +635,17 @@
 
 #define AHC_LINUX_MAX_RETURNED_ERRORS 4
 static struct ahc_cmd *
-ahc_linux_run_complete_queue(struct ahc_softc *ahc, struct ahc_cmd *acmd)
-{	
+ahc_linux_run_complete_queue(struct ahc_softc *ahc)
+{
+	struct	ahc_cmd *acmd;
 	u_long	done_flags;
 	int	with_errors;
 
 	with_errors = 0;
 	ahc_done_lock(ahc, &done_flags);
-	while (acmd != NULL) {
+	while ((acmd = TAILQ_FIRST(&ahc->platform_data->completeq)) != NULL) {
 		Scsi_Cmnd *cmd;
 
-		cmd = &acmd_scsi_cmd(acmd);
-		acmd = TAILQ_NEXT(acmd, acmd_links.tqe);
-		cmd->host_scribble = NULL;
-		if (ahc_cmd_get_transaction_status(cmd) != DID_OK
-		 || (cmd->result & 0xFF) != SCSI_STATUS_OK)
-			with_errors++;
-
-		cmd->scsi_done(cmd);
-
 		if (with_errors > AHC_LINUX_MAX_RETURNED_ERRORS) {
 			/*
 			 * Linux uses stack recursion to requeue
@@ -692,8 +655,18 @@
 			 * the operating system in case they are going
 			 * to be retried. "ick"
 			 */
+			ahc_schedule_completeq(ahc);
 			break;
 		}
+		TAILQ_REMOVE(&ahc->platform_data->completeq,
+			     acmd, acmd_links.tqe);
+		cmd = &acmd_scsi_cmd(acmd);
+		cmd->host_scribble = NULL;
+		if (ahc_cmd_get_transaction_status(cmd) != DID_OK
+		 || (cmd->result & 0xFF) != SCSI_STATUS_OK)
+			with_errors++;
+
+		cmd->scsi_done(cmd);
 	}
 	ahc_done_unlock(ahc, &done_flags);
 	return (acmd);
@@ -824,6 +797,67 @@
 static int	   ahc_linux_abort(Scsi_Cmnd *);
 
 /*
+ * Calculate a safe value for AHC_NSEG (as expressed through ahc_linux_nseg).
+ *
+ * In pre-2.5.X...
+ * The midlayer allocates an S/G array dynamically when a command is issued
+ * using SCSI malloc.  This array, which is in an OS dependent format that
+ * must later be copied to our private S/G list, is sized to house just the
+ * number of segments needed for the current transfer.  Since the code that
+ * sizes the SCSI malloc pool does not take into consideration fragmentation
+ * of the pool, executing transactions numbering just a fraction of our
+ * concurrent transaction limit with list lengths aproaching AHC_NSEG will
+ * quickly depleat the SCSI malloc pool of usable space.  Unfortunately, the
+ * mid-layer does not properly handle this scsi malloc failures for the S/G
+ * array and the result can be a lockup of the I/O subsystem.  We try to size
+ * our S/G list so that it satisfies our drivers allocation requirements in
+ * addition to avoiding fragmentation of the SCSI malloc pool.
+ */
+static void
+ahc_linux_size_nseg(void)
+{
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+	u_int cur_size;
+	u_int best_size;
+
+	/*
+	 * The SCSI allocator rounds to the nearest 512 bytes
+	 * an cannot allocate across a page boundary.  Our algorithm
+	 * is to start at 1K of scsi malloc space per-command and
+	 * loop through all factors of the PAGE_SIZE and pick the best.
+	 */
+	best_size = 0;
+	for (cur_size = 1024; cur_size <= PAGE_SIZE; cur_size *= 2) {
+		u_int nseg;
+
+		nseg = cur_size / sizeof(struct scatterlist);
+		if (nseg < AHC_LINUX_MIN_NSEG)
+			continue;
+
+		if (best_size == 0) {
+			best_size = cur_size;
+			ahc_linux_nseg = nseg;
+		} else {
+			u_int best_rem;
+			u_int cur_rem;
+
+			/*
+			 * Compare the traits of the current "best_size"
+			 * with the current size to determine if the
+			 * current size is a better size.
+			 */
+			best_rem = best_size % sizeof(struct scatterlist);
+			cur_rem = cur_size % sizeof(struct scatterlist);
+			if (cur_rem < best_rem) {
+				best_size = cur_size;
+				ahc_linux_nseg = nseg;
+			}
+		}
+	}
+#endif
+}
+
+/*
  * Try to detect an Adaptec 7XXX controller.
  */
 static int
@@ -851,6 +885,7 @@
 		printf("ahc_linux_detect: Unable to attach\n");
 		return (0);
 	}
+	ahc_linux_size_nseg();
 #ifdef MODULE
 	/*
 	 * If we've been passed any parameters, process them now.
@@ -881,7 +916,7 @@
 	ahc_linux_pci_init();
 #endif
 
-	if (aic7xxx_no_probe == 0)
+	if (aic7xxx_probe_eisa_vl != 0)
 		aic7770_linux_probe(template);
 
 	/*
@@ -991,7 +1026,7 @@
 
 		ahc_cmd_set_transaction_status(cmd, CAM_REQUEUE_REQ);
 		ahc_linux_queue_cmd_complete(ahc, cmd);
-		ahc_schedule_completeq(ahc, NULL);
+		ahc_schedule_completeq(ahc);
 		ahc_midlayer_entrypoint_unlock(ahc, &flags);
 		return (0);
 	}
@@ -1000,7 +1035,7 @@
 	if (dev == NULL) {
 		ahc_cmd_set_transaction_status(cmd, CAM_RESRC_UNAVAIL);
 		ahc_linux_queue_cmd_complete(ahc, cmd);
-		ahc_schedule_completeq(ahc, NULL);
+		ahc_schedule_completeq(ahc);
 		ahc_midlayer_entrypoint_unlock(ahc, &flags);
 		printf("%s: aic7xxx_linux_queue - Unable to allocate device!\n",
 		       ahc_name(ahc));
@@ -1082,7 +1117,8 @@
 	 && (dev->flags & AHC_DEV_SLAVE_CONFIGURED) != 0) {
 		dev->flags |= AHC_DEV_UNCONFIGURED;
 		if (TAILQ_EMPTY(&dev->busyq)
-		 && dev->active == 0)
+		 && dev->active == 0
+	 	 && (dev->flags & AHC_DEV_TIMER_ACTIVE) == 0)
 			ahc_linux_free_device(ahc, dev);
 	}
 	ahc_midlayer_entrypoint_unlock(ahc, &flags);
@@ -1093,16 +1129,33 @@
  * off the input host adapter.
  */
 static void
-ahc_linux_select_queue_depth(struct Scsi_Host * host,
-			     Scsi_Device * scsi_devs)
+ahc_linux_select_queue_depth(struct Scsi_Host *host, Scsi_Device *scsi_devs)
 {
 	Scsi_Device *device;
+	Scsi_Device *ldev;
 	struct	ahc_softc *ahc;
 	u_long	flags;
 
 	ahc = *((struct ahc_softc **)host->hostdata);
 	ahc_lock(ahc, &flags);
 	for (device = scsi_devs; device != NULL; device = device->next) {
+
+		/*
+		 * Watch out for duplicate devices.  This works around
+		 * some quirks in how the SCSI scanning code does its
+		 * device management.
+		 */
+		for (ldev = scsi_devs; ldev != device; ldev = ldev->next) {
+			if (ldev->host == device->host
+			 && ldev->channel == device->channel
+			 && ldev->id == device->id
+			 && ldev->lun == device->lun)
+				break;
+		}
+		/* Skip duplicate. */
+		if (ldev != device)
+			continue;
+
 		if (device->host == host) {
 			struct	 ahc_linux_device *dev;
 
@@ -1240,7 +1293,6 @@
 ahc_linux_bus_reset(Scsi_Cmnd *cmd)
 {
 	struct ahc_softc *ahc;
-	struct ahc_cmd *acmd;
 	u_long s;
 	int    found;
 
@@ -1248,14 +1300,7 @@
 	ahc_midlayer_entrypoint_lock(ahc, &s);
 	found = ahc_reset_channel(ahc, cmd->device->channel + 'A',
 				  /*initiate reset*/TRUE);
-	acmd = TAILQ_FIRST(&ahc->platform_data->completeq);
-	TAILQ_INIT(&ahc->platform_data->completeq);
-
-	if (acmd != NULL) {
-		acmd = ahc_linux_run_complete_queue(ahc, acmd);
-		if (acmd != NULL)
-			ahc_schedule_completeq(ahc, acmd);
-	}
+	ahc_linux_run_complete_queue(ahc);
 	ahc_midlayer_entrypoint_unlock(ahc, &s);
 
 	if (bootverbose)
@@ -1279,7 +1324,6 @@
 #endif
 	.can_queue		= AHC_MAX_QUEUE,
 	.this_id		= -1,
-	.sg_tablesize		= AHC_NSEG,
 	.cmd_per_lun		= 2,
 	.use_clustering		= ENABLE_CLUSTERING,
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,7)
@@ -1337,44 +1381,17 @@
 		TAILQ_REMOVE(&ahc->platform_data->device_runq, dev, links);
 		dev->flags &= ~AHC_DEV_ON_RUN_LIST;
 		ahc_linux_check_device_queue(ahc, dev);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 		/* Yeild to our interrupt handler */
 		ahc_unlock(ahc, &flags);
 		ahc_lock(ahc, &flags);
+#endif
 	}
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 	ahc_unlock(ahc, &flags);
 #endif
 }
 
-/************************ Shutdown/halt/reboot hook ***************************/
-#include <linux/notifier.h>
-#include <linux/reboot.h>
-
-static struct notifier_block ahc_linux_notifier = {
-	ahc_linux_halt, NULL, 0
-};
-
-static int ahc_linux_halt(struct notifier_block *nb, u_long event, void *buf)
-{
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-	struct ahc_softc *ahc;
-
-	/*
-	 * In 2.5.X, this is called prior to the filesystems
-	 * being synced and the SCSI layer being properly
-	 * shutdown.  A different API is required there,
-	 * but the device hooks for this don't quite look
-	 * right.
-	 */
-	if (event == SYS_DOWN || event == SYS_HALT) {
-		TAILQ_FOREACH(ahc, &ahc_tailq, links) {
-			ahc_shutdown(ahc);
-		}
-	}
-#endif
-	return (NOTIFY_OK);
-}
-
 /******************************** Macros **************************************/
 #define BUILD_SCSIID(ahc, cmd)						    \
 	((((cmd)->device->id << TID_SHIFT) & TID)			    \
@@ -1482,6 +1499,7 @@
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
 	stack_sg.ds_addr = map->bus_addr;
 #else
+#define VIRT_TO_BUS(a) (uint32_t)virt_to_bus((void *)(a))
 	stack_sg.ds_addr = VIRT_TO_BUS(buf);
 #endif
 	stack_sg.ds_len = dmat->maxsize;
@@ -1613,7 +1631,7 @@
 }
 
 static void
-ahc_linux_setup_tag_info(void *arg, int instance, int targ, int32_t value)
+ahc_linux_setup_tag_info(u_long arg, int instance, int targ, int32_t value)
 {
 
 	if ((instance >= 0) && (targ >= 0)
@@ -1626,7 +1644,7 @@
 }
 
 static void
-ahc_linux_setup_dv(void *arg, int instance, int targ, int32_t value)
+ahc_linux_setup_dv(u_long arg, int instance, int targ, int32_t value)
 {
 
 	if ((instance >= 0)
@@ -1661,7 +1679,8 @@
 		{ "debug", &ahc_debug },
 #endif
 		{ "reverse_scan", &aic7xxx_reverse_scan },
-		{ "no_probe", &aic7xxx_no_probe },
+		{ "no_probe", &aic7xxx_probe_eisa_vl },
+		{ "probe_eisa_vl", &aic7xxx_probe_eisa_vl },
 		{ "periodic_otag", &aic7xxx_periodic_otag },
 		{ "pci_parity", &aic7xxx_pci_parity },
 		{ "seltime", &aic7xxx_seltime },
@@ -1694,16 +1713,16 @@
 			ahc_linux_setup_tag_info_global(p + n);
 		} else if (strncmp(p, "tag_info", n) == 0) {
 			s = aic_parse_brace_option("tag_info", p + n, end,
-			    2, ahc_linux_setup_tag_info, NULL);
+			    2, ahc_linux_setup_tag_info, 0);
 		} else if (strncmp(p, "dv", n) == 0) {
 			s = aic_parse_brace_option("dv", p + n, end, 1,
-			    ahc_linux_setup_dv, NULL);
+			    ahc_linux_setup_dv, 0);
 		} else if (p[n] == ':') {
 			*(options[i].flag) = simple_strtoul(p + n + 1, NULL, 0);
 		} else if (strncmp(p, "verbose", n) == 0) {
 			*(options[i].flag) = 1;
 		} else {
-			*(options[i].flag) = ~(*(options[i].flag));
+			*(options[i].flag) ^= 0xFFFFFFFF;
 		}
 	}
 	return 1;
@@ -1713,7 +1732,7 @@
 __setup("aic7xxx=", aic7xxx_setup);
 #endif
 
-int aic7xxx_verbose;
+uint32_t aic7xxx_verbose;
 
 int
 ahc_linux_register_host(struct ahc_softc *ahc, Scsi_Host_Template *template)
@@ -1739,13 +1758,13 @@
 	ahc->platform_data->host = host;
 	host->can_queue = AHC_MAX_QUEUE;
 	host->cmd_per_lun = 2;
-	host->sg_tablesize = AHC_NSEG;
 	/* XXX No way to communicate the ID for multiple channels */
 	host->this_id = ahc->our_id;
 	host->irq = ahc->platform_data->irq;
 	host->max_id = (ahc->features & AHC_WIDE) ? 16 : 8;
 	host->max_lun = AHC_NUM_LUNS;
 	host->max_channel = (ahc->features & AHC_TWIN) ? 1 : 0;
+	host->sg_tablesize = AHC_NSEG;
 	ahc_set_unit(ahc, ahc_linux_next_unit());
 	sprintf(buf, "scsi%d", host->host_no);
 	new_name = malloc(strlen(buf) + 1, M_DEVBUF, M_NOWAIT);
@@ -1953,8 +1972,6 @@
 	if (aic7xxx_pci_parity == 0)
 		ahc->flags |= AHC_DISABLE_PCI_PERR;
 
-	if (TAILQ_EMPTY(&ahc_tailq))
-		register_reboot_notifier(&ahc_linux_notifier);
 	return (0);
 }
 
@@ -1966,6 +1983,7 @@
 	int i, j;
 
 	if (ahc->platform_data != NULL) {
+		del_timer_sync(&ahc->platform_data->completeq_timer);
 		ahc_linux_kill_dv_thread(ahc);
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 		tasklet_kill(&ahc->platform_data->runq_tasklet);
@@ -1981,17 +1999,22 @@
 		for (i = 0; i < AHC_NUM_TARGETS; i++) {
 			targ = ahc->platform_data->targets[i];
 			if (targ != NULL) {
+				/* Keep target around through the loop. */
+				targ->refcount++;
 				for (j = 0; j < AHC_NUM_LUNS; j++) {
-					if (targ->devices[j] != NULL) {
-						dev = targ->devices[j];
-						ahc_linux_free_device(ahc, dev);
-					}
-					if (ahc->platform_data->targets[i] ==
-					    NULL)
-						break;
+
+					if (targ->devices[j] == NULL)
+						continue;
+					dev = targ->devices[j];
+					ahc_linux_free_device(ahc, dev);
 				}
-			}
-		}
+				/*
+				 * Forcibly free the target now that
+				 * all devices are gone.
+				 */
+				ahc_linux_free_target(ahc, targ);
+ 			}
+ 		}
 
 		if (ahc->platform_data->irq != AHC_LINUX_NOIRQ)
 			free_irq(ahc->platform_data->irq, ahc);
@@ -2200,19 +2223,12 @@
 static void
 ahc_linux_thread_run_complete_queue(struct ahc_softc *ahc)
 {
-	struct ahc_cmd *acmd;
 	u_long flags;
 
 	ahc_lock(ahc, &flags);
 	del_timer(&ahc->platform_data->completeq_timer);
 	ahc->platform_data->flags &= ~AHC_RUN_CMPLT_Q_TIMER;
-	acmd = TAILQ_FIRST(&ahc->platform_data->completeq);
-	TAILQ_INIT(&ahc->platform_data->completeq);
-	if (acmd != NULL) {
-		acmd = ahc_linux_run_complete_queue(ahc, acmd);
-		if (acmd != NULL)
-			ahc_schedule_completeq(ahc, acmd);
-	}
+	ahc_linux_run_complete_queue(ahc);
 	ahc_unlock(ahc, &flags);
 }
 
@@ -2575,10 +2591,14 @@
 	}
 
 	ahc_lock(ahc, &s);
-	if (targ->dv_buffer != NULL)
+	if (targ->dv_buffer != NULL) {
 		free(targ->dv_buffer, M_DEVBUF);
-	if (targ->dv_buffer1 != NULL)
+		targ->dv_buffer = NULL;
+	}
+	if (targ->dv_buffer1 != NULL) {
 		free(targ->dv_buffer1, M_DEVBUF);
+		targ->dv_buffer1 = NULL;
+	}
 	targ->flags &= ~AHC_DV_REQUIRED;
 	if (targ->refcount == 0)
 		ahc_linux_free_target(ahc, targ);
@@ -3408,7 +3428,6 @@
 ahc_linux_dv_timeout(struct scsi_cmnd *cmd)
 {
 	struct	ahc_softc *ahc;
-	struct	ahc_cmd *acmd;
 	struct	scb *scb;
 	u_long	flags;
 
@@ -3455,15 +3474,9 @@
 	ahc->platform_data->reset_timer.function =
 	    (ahc_linux_callback_t *)ahc_linux_release_simq;
 	add_timer(&ahc->platform_data->reset_timer);
-	acmd = TAILQ_FIRST(&ahc->platform_data->completeq);
-	TAILQ_INIT(&ahc->platform_data->completeq);
 	if (ahc_linux_next_device_to_run(ahc) != NULL)
 		ahc_schedule_runq(ahc);
-	if (acmd != NULL) {
-		acmd = ahc_linux_run_complete_queue(ahc, acmd);
-		if (acmd != NULL)
-			ahc_schedule_completeq(ahc, acmd);
-	}
+	ahc_linux_run_complete_queue(ahc);
 	ahc_unlock(ahc, &flags);
 }
 
@@ -3639,9 +3652,8 @@
 	 && dev->scsi_device->tagged_supported != 0) {
 
 		ahc_set_tags(ahc, &devinfo, AHC_QUEUE_TAGGED);
-		printf("scsi%d:%c:%d:%d: Tagged Queuing enabled.  Depth %d\n",
-	       	       ahc->platform_data->host->host_no, devinfo.channel,
-		       devinfo.target, devinfo.lun, tags);
+		ahc_print_devinfo(ahc, &devinfo);
+		printf("Tagged Queuing enabled.  Depth %d\n", tags);
 	} else {
 		ahc_set_tags(ahc, &devinfo, AHC_QUEUE_NONE);
 	}
@@ -3863,39 +3875,29 @@
 /*
  * SCSI controller interrupt handler.
  */
-irqreturn_t
+AIC_LINUX_IRQRETURN_T
 ahc_linux_isr(int irq, void *dev_id, struct pt_regs * regs)
 {
 	struct	ahc_softc *ahc;
-	struct	ahc_cmd *acmd;
 	u_long	flags;
+	int	ours;
 
 	ahc = (struct ahc_softc *) dev_id;
 	ahc_lock(ahc, &flags); 
-	ahc_intr(ahc);
-	acmd = TAILQ_FIRST(&ahc->platform_data->completeq);
-	TAILQ_INIT(&ahc->platform_data->completeq);
+	ours = ahc_intr(ahc);
 	if (ahc_linux_next_device_to_run(ahc) != NULL)
 		ahc_schedule_runq(ahc);
-	if (acmd != NULL) {
-		acmd = ahc_linux_run_complete_queue(ahc, acmd);
-		if (acmd != NULL)
-			ahc_schedule_completeq(ahc, acmd);
-	}
+	ahc_linux_run_complete_queue(ahc);
 	ahc_unlock(ahc, &flags);
-	/* FIXME! Was it really ours? */
-	return IRQ_HANDLED;
+	AIC_LINUX_IRQRETURN(ours);
 }
 
 void
 ahc_platform_flushwork(struct ahc_softc *ahc)
 {
-	struct ahc_cmd *acmd;
 
-	acmd = TAILQ_FIRST(&ahc->platform_data->completeq);
-	TAILQ_INIT(&ahc->platform_data->completeq);
-	while (acmd != NULL)
-		acmd = ahc_linux_run_complete_queue(ahc, acmd);
+	while (ahc_linux_run_complete_queue(ahc) != NULL)
+		;
 }
 
 static struct ahc_linux_target*
@@ -4081,22 +4083,19 @@
 	}
         case AC_SENT_BDR:
 	{
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+		WARN_ON(lun != CAM_LUN_WILDCARD);
+		scsi_report_device_reset(ahc->platform_data->host,
+					 channel - 'A', target);
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
 		Scsi_Device *scsi_dev;
 
 		/*
 		 * Find the SCSI device associated with this
 		 * request and indicate that a UA is expected.
-		 * XXX This should really be handled by the mid-layer.
 		 */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
-		list_for_each_entry(scsi_dev,
-				    &ahc->platform_data->host->my_devices,
-				    siblings) {
-#else
 		for (scsi_dev = ahc->platform_data->host->host_queue;
 		     scsi_dev != NULL; scsi_dev = scsi_dev->next) {
-#endif
 			if (channel - 'A' == scsi_dev->channel
 			 && target == scsi_dev->id
 			 && (lun == CAM_LUN_WILDCARD
@@ -4229,7 +4228,8 @@
 
 	if (TAILQ_EMPTY(&dev->busyq)) {
 		if ((dev->flags & AHC_DEV_UNCONFIGURED) != 0
-		 && dev->active == 0)
+		 && dev->active == 0
+	 	 && (dev->flags & AHC_DEV_TIMER_ACTIVE) == 0)
 			ahc_linux_free_device(ahc, dev);
 	} else if ((dev->flags & AHC_DEV_ON_RUN_LIST) == 0) {
 		TAILQ_INSERT_TAIL(&ahc->platform_data->device_runq, dev, links);
@@ -4709,6 +4709,9 @@
 	if (dev->qfrozen == 0
 	 && (dev->flags & AHC_DEV_ON_RUN_LIST) == 0)
 		ahc_linux_run_device_queue(ahc, dev);
+	if (TAILQ_EMPTY(&dev->busyq)
+	 && dev->active == 0)
+		ahc_linux_free_device(ahc, dev);
 	ahc_unlock(ahc, &s);
 }
 
@@ -4727,6 +4730,7 @@
 	u_int  saved_scsiid;
 	u_int  cdb_byte;
 	int    retval;
+	int    was_paused;
 	int    paused;
 	int    wait;
 	int    disconnected;
@@ -4768,7 +4772,7 @@
 	 * Start by searching the device queue.  If not found
 	 * there, check the pending_scb list.  If not found
 	 * at all, and the system wanted us to just abort the
-	 * command return success.
+	 * command, return success.
 	 */
 	dev = ahc_linux_get_device(ahc, cmd->device->channel, cmd->device->id,
 				   cmd->device->lun, /*alloc*/FALSE);
@@ -4855,11 +4859,10 @@
 	 * behind our back and that we didn't "just" miss
 	 * an interrupt that would affect this cmd.
 	 */
+	was_paused = ahc_is_paused(ahc);
 	ahc_pause_and_flushwork(ahc);
 	paused = TRUE;
 
-	ahc_dump_card_state(ahc);
-
 	if ((pending_scb->flags & SCB_ACTIVE) == 0) {
 		printf("%s:%d:%d:%d: Command already completed\n",
 		       ahc_name(ahc), cmd->device->channel, cmd->device->id,
@@ -4867,6 +4870,10 @@
 		goto no_cmd;
 	}
 
+	printf("%s: At time of recovery, card was %spaused\n",
+	       ahc_name(ahc), was_paused ? "" : "not ");
+	ahc_dump_card_state(ahc);
+
 	disconnected = TRUE;
 	if (flag == SCB_ABORT) {
 		if (ahc_search_qinfifo(ahc, cmd->device->id,
@@ -5026,21 +5033,15 @@
 		printf("Recovery code sleeping\n");
 		down(&ahc->platform_data->eh_sem);
 		printf("Recovery code awake\n");
-        	ret = del_timer(&timer);
+        	ret = del_timer_sync(&timer);
 		if (ret == 0) {
 			printf("Timer Expired\n");
 			retval = FAILED;
 		}
 		spin_lock_irq(&ahc->platform_data->spin_lock);
 	}
-	acmd = TAILQ_FIRST(&ahc->platform_data->completeq);
-	TAILQ_INIT(&ahc->platform_data->completeq);
 	ahc_schedule_runq(ahc);
-	if (acmd != NULL) {
-		acmd = ahc_linux_run_complete_queue(ahc, acmd);
-		if (acmd != NULL)
-			ahc_schedule_completeq(ahc, acmd);
-	}
+	ahc_linux_run_complete_queue(ahc);
 	ahc_midlayer_entrypoint_unlock(ahc, &s);
 	return (retval);
 }
@@ -5140,8 +5141,6 @@
 	 */
 	ahc_linux_pci_exit();
 #endif
-
-	unregister_reboot_notifier(&ahc_linux_notifier);
 }
 
 module_init(ahc_linux_init);
diff -urN linux-2.5.69-bk7/drivers/scsi/aic7xxx/aic7xxx_osm.h linux-2.5.69-bk8/drivers/scsi/aic7xxx/aic7xxx_osm.h
--- linux-2.5.69-bk7/drivers/scsi/aic7xxx/aic7xxx_osm.h	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/aic7xxx/aic7xxx_osm.h	2003-05-13 04:44:29.000000000 -0700
@@ -53,7 +53,7 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  *
- * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#131 $
+ * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_osm.h#142 $
  *
  */
 #ifndef _AIC7XXX_LINUX_H_
@@ -150,8 +150,8 @@
 #endif /* BYTE_ORDER */
 
 /************************* Configuration Data *********************************/
-extern int aic7xxx_no_probe;
-extern int aic7xxx_allow_memio;
+extern u_int aic7xxx_no_probe;
+extern u_int aic7xxx_allow_memio;
 extern int aic7xxx_detect_complete;
 extern Scsi_Host_Template aic7xxx_driver_template;
 
@@ -258,7 +258,7 @@
 typedef struct timer_list ahc_timer_t;
 
 /********************************** Includes **********************************/
-#if CONFIG_AIC7XXX_REG_PRETTY_PRINT
+#ifdef CONFIG_AIC7XXX_REG_PRETTY_PRINT
 #define AIC_DEBUG_REGISTERS 1
 #else
 #define AIC_DEBUG_REGISTERS 0
@@ -267,7 +267,7 @@
 
 /***************************** Timer Facilities *******************************/
 #define ahc_timer_init init_timer
-#define ahc_timer_stop del_timer
+#define ahc_timer_stop del_timer_sync
 typedef void ahc_linux_callback_t (u_long);  
 static __inline void ahc_timer_reset(ahc_timer_t *timer, int usec,
 				     ahc_callback_t *func, void *arg);
@@ -305,7 +305,7 @@
 #define AHC_SCSI_HAS_HOST_LOCK 0
 #endif
 
-#define AIC7XXX_DRIVER_VERSION "6.2.31"
+#define AIC7XXX_DRIVER_VERSION "6.2.33"
 
 /**************************** Front End Queues ********************************/
 /*
@@ -494,7 +494,18 @@
  * manner and are allocated below 4GB, the number of S/G segments is
  * unrestricted.
  */
-#define        AHC_NSEG 128
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+/*
+ * We dynamically adjust the number of segments in pre-2.5 kernels to
+ * avoid fragmentation issues in the SCSI mid-layer's private memory
+ * allocator.  See aic7xxx_osm.c ahc_linux_size_nseg() for details.
+ */
+extern u_int ahc_linux_nseg;
+#define	AHC_NSEG ahc_linux_nseg
+#define	AHC_LINUX_MIN_NSEG 64
+#else
+#define	AHC_NSEG 128
+#endif
 
 /*
  * Per-SCB OSM storage.
@@ -538,9 +549,7 @@
 	TAILQ_HEAD(, ahc_linux_device) device_runq;
 	struct ahc_completeq	 completeq;
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,93)
 	spinlock_t		 spin_lock;
-#endif
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 	struct tasklet_struct	 runq_tasklet;
 #endif
@@ -699,7 +708,6 @@
 static __inline void ahc_list_lock(unsigned long *flags);
 static __inline void ahc_list_unlock(unsigned long *flags);
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,93)
 static __inline void
 ahc_lockinit(struct ahc_softc *ahc)
 {
@@ -729,7 +737,8 @@
 	 * trade the io_request_lock for our per-softc lock.
 	 */
 #if AHC_SCSI_HAS_HOST_LOCK == 0
-	ahc_lock(ahc, flags);
+	spin_unlock(&io_request_lock);
+	spin_lock(&ahc->platform_data->spin_lock);
 #endif
 }
 
@@ -737,7 +746,8 @@
 ahc_midlayer_entrypoint_unlock(struct ahc_softc *ahc, unsigned long *flags)
 {
 #if AHC_SCSI_HAS_HOST_LOCK == 0
-	ahc_unlock(ahc, flags);
+	spin_unlock(&ahc->platform_data->spin_lock);
+	spin_lock(&io_request_lock);
 #endif
 }
 
@@ -785,65 +795,6 @@
 	spin_unlock_irqrestore(&ahc_list_spinlock, *flags);
 }
 
-#else /* LINUX_VERSION_CODE < KERNEL_VERSION(2,1,93) */
-
-static __inline void
-ahc_lockinit(struct ahc_softc *ahc)
-{
-}
-
-static __inline void
-ahc_lock(struct ahc_softc *ahc, unsigned long *flags)
-{
-	save_flags(*flags);
-	cli();
-}
-
-static __inline void
-ahc_unlock(struct ahc_softc *ahc, unsigned long *flags)
-{
-	restore_flags(*flags);
-}
-
-static __inline void
-ahc_done_lockinit(struct ahc_softc *ahc)
-{
-}
-
-static __inline void
-ahc_done_lock(struct ahc_softc *ahc, unsigned long *flags)
-{
-	/*
-	 * The done lock is always held while
-	 * the ahc lock is held so blocking
-	 * interrupts again would have no effect.
-	 */
-}
-
-static __inline void
-ahc_done_unlock(struct ahc_softc *ahc, unsigned long *flags)
-{
-}
-
-static __inline void
-ahc_list_lockinit()
-{
-}
-
-static __inline void
-ahc_list_lock(unsigned long *flags)
-{
-	save_flags(*flags);
-	cli();
-}
-
-static __inline void
-ahc_list_unlock(unsigned long *flags)
-{
-	restore_flags(*flags);
-}
-#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,1,0) */
-
 /******************************* PCI Definitions ******************************/
 /*
  * PCIM_xxx: mask to locate subfield in register
@@ -902,16 +853,6 @@
 int			 aic7770_map_int(struct ahc_softc *ahc, u_int irq);
 
 /******************************* PCI Routines *********************************/
-/*
- * We need to use the bios32.h routines if we are kernel version 2.1.92 or less.
- */
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,1,92)
-#if defined(__sparc_v9__) || defined(__powerpc__)
-#error "PPC and Sparc platforms are only supported under 2.1.92 and above"
-#endif
-#include <linux/bios32.h>
-#endif
-
 int			 ahc_linux_pci_init(void);
 void			 ahc_linux_pci_exit(void);
 int			 ahc_pci_map_registers(struct ahc_softc *ahc);
@@ -1224,7 +1165,8 @@
 int	ahc_platform_abort_scbs(struct ahc_softc *ahc, int target,
 				char channel, int lun, u_int tag,
 				role_t role, uint32_t status);
-irqreturn_t ahc_linux_isr(int irq, void *dev_id, struct pt_regs * regs);
+AIC_LINUX_IRQRETURN_T
+	ahc_linux_isr(int irq, void *dev_id, struct pt_regs * regs);
 void	ahc_platform_flushwork(struct ahc_softc *ahc);
 int	ahc_softc_comp(struct ahc_softc *, struct ahc_softc *);
 void	ahc_done(struct ahc_softc*, struct scb*);
@@ -1239,5 +1181,5 @@
 #define AHC_PCI_CONFIG 0
 #endif
 #define bootverbose aic7xxx_verbose
-extern int aic7xxx_verbose;
+extern u_int aic7xxx_verbose;
 #endif /* _AIC7XXX_LINUX_H_ */
diff -urN linux-2.5.69-bk7/drivers/scsi/aic7xxx/aic7xxx_pci.c linux-2.5.69-bk8/drivers/scsi/aic7xxx/aic7xxx_pci.c
--- linux-2.5.69-bk7/drivers/scsi/aic7xxx/aic7xxx_pci.c	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/aic7xxx/aic7xxx_pci.c	2003-05-13 04:44:29.000000000 -0700
@@ -39,7 +39,7 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  *
- * $Id: //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#62 $
+ * $Id: //depot/aic7xxx/aic7xxx/aic7xxx_pci.c#63 $
  *
  * $FreeBSD$
  */
@@ -837,14 +837,6 @@
 	command = ahc_pci_read_config(ahc->dev_softc, PCIR_COMMAND, /*bytes*/1);
 	command |= PCIM_CMD_BUSMASTEREN;
 
-	/*
-	 * Disable PCI parity error reporting.  Users typically
-	 * do this to work around broken PCI chipsets that get
-	 * the parity timing wrong and thus generate lots of spurious
-	 * errors.
-	 */
-	if ((ahc->flags & AHC_DISABLE_PCI_PERR) != 0)
-		command &= ~PCIM_CMD_PERRESPEN;
 	ahc_pci_write_config(ahc->dev_softc, PCIR_COMMAND, command, /*bytes*/1);
 
 	/* On all PCI adapters, we allow SCB paging */
@@ -854,6 +846,19 @@
 	if (error != 0)
 		return (error);
 
+	/*
+	 * Disable PCI parity error checking.  Users typically
+	 * do this to work around broken PCI chipsets that get
+	 * the parity timing wrong and thus generate lots of spurious
+	 * errors.  The chip only allows us to disable *all* parity
+	 * error reporting when doing this, so CIO bus, scb ram, and
+	 * scratch ram parity errors will be ignored too.
+	 */
+	if ((ahc->flags & AHC_DISABLE_PCI_PERR) != 0) {
+		ahc->pause |= FAILDIS;
+		ahc->unpause |= FAILDIS;
+	}
+
 	ahc->bus_intr = ahc_pci_intr;
 	ahc->bus_chip_init = ahc_pci_chip_init;
 	ahc->bus_suspend = ahc_pci_suspend;
@@ -1997,6 +2002,7 @@
 	      ahc_inb(ahc, SEQADDR0) | (ahc_inb(ahc, SEQADDR1) << 8));
 
 	if (status1 & DPE) {
+		ahc->pci_target_perr_count++;
 		printf("%s: Data Parity Error Detected during address "
 		       "or write data phase\n", ahc_name(ahc));
 	}
@@ -2028,6 +2034,19 @@
 		ahc_outb(ahc, CLRINT, CLRPARERR);
 	}
 
+	if (ahc->pci_target_perr_count > AHC_PCI_TARGET_PERR_THRESH) {
+		printf(
+"%s: WARNING WARNING WARNING WARNING\n"
+"%s: Too many PCI parity errors observed as a target.\n"
+"%s: Some device on this bus is generating bad parity.\n"
+"%s: This is an error *observed by*, not *generated by*, this controller.\n"
+"%s: PCI parity error checking has been disabled.\n"
+"%s: WARNING WARNING WARNING WARNING\n",
+		       ahc_name(ahc), ahc_name(ahc), ahc_name(ahc),
+		       ahc_name(ahc), ahc_name(ahc), ahc_name(ahc));
+		ahc->pause |= FAILDIS;
+		ahc->unpause |= FAILDIS;
+	}
 	ahc_unpause(ahc);
 }
 
diff -urN linux-2.5.69-bk7/drivers/scsi/aic7xxx/aic7xxx_proc.c linux-2.5.69-bk8/drivers/scsi/aic7xxx/aic7xxx_proc.c
--- linux-2.5.69-bk7/drivers/scsi/aic7xxx/aic7xxx_proc.c	2003-05-04 16:52:49.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/aic7xxx/aic7xxx_proc.c	2003-05-13 04:44:29.000000000 -0700
@@ -37,7 +37,7 @@
  * String handling code courtesy of Gerard Roudier's <groudier@club-internet.fr>
  * sym driver.
  *
- * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_proc.c#24 $
+ * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7xxx_proc.c#27 $
  */
 #include "aic7xxx_osm.h"
 #include "aic7xxx_inline.h"
@@ -148,8 +148,9 @@
 
 	tinfo = ahc_fetch_transinfo(ahc, channel, our_id,
 				    target_id, &tstate);
-	copy_info(info, "Channel %c Target %d Negotiation Settings\n",
-		  channel, target_id);
+	if ((ahc->features & AHC_TWIN) != 0)
+		copy_info(info, "Channel %c ", channel);
+	copy_info(info, "Target %d Negotiation Settings\n", target_id);
 	copy_info(info, "\tUser: ");
 	ahc_format_transinfo(info, &tinfo->user);
 	targ = ahc->platform_data->targets[target_offset];
@@ -327,7 +328,10 @@
 		  AIC7XXX_DRIVER_VERSION);
 	copy_info(&info, "%s\n", ahc->description);
 	ahc_controller_info(ahc, ahc_info);
-	copy_info(&info, "%s\n\n", ahc_info);
+	copy_info(&info, "%s\n", ahc_info);
+	copy_info(&info, "Allocated SCBs: %d, SG List Length: %d\n\n",
+		  ahc->scb_data->numscbs, AHC_NSEG);
+
 
 	if (ahc->seep_config == NULL)
 		copy_info(&info, "No Serial EEPROM\n");
diff -urN linux-2.5.69-bk7/drivers/scsi/aic7xxx/aiclib.c linux-2.5.69-bk8/drivers/scsi/aic7xxx/aiclib.c
--- linux-2.5.69-bk7/drivers/scsi/aic7xxx/aiclib.c	2003-05-04 16:53:31.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/aic7xxx/aiclib.c	2003-05-13 04:44:29.000000000 -0700
@@ -1335,7 +1335,7 @@
 
 char *
 aic_parse_brace_option(char *opt_name, char *opt_arg, char *end, int depth,
-		       aic_option_callback_t *callback, void *callback_arg)
+		       aic_option_callback_t *callback, u_long callback_arg)
 {
 	char	*tok_end;
 	char	*tok_end2;
diff -urN linux-2.5.69-bk7/drivers/scsi/aic7xxx/aiclib.h linux-2.5.69-bk8/drivers/scsi/aic7xxx/aiclib.h
--- linux-2.5.69-bk7/drivers/scsi/aic7xxx/aiclib.h	2003-05-04 16:53:01.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/aic7xxx/aiclib.h	2003-05-13 04:44:29.000000000 -0700
@@ -15,15 +15,58 @@
  * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
  *
  * $FreeBSD: src/sys/cam/scsi/scsi_all.h,v 1.21 2002/10/08 17:12:44 ken Exp $
+ *
+ * Copyright (c) 2003 Adaptec Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ *
  * $Id$
  */
 
+#ifndef	_AICLIB_H
+#define _AICLIB_H
+
 /*
- * SCSI general  interface description
+ * Linux Interrupt Support.
  */
-
-#ifndef	_SCSI_SCSI_ALL_H
-#define _SCSI_SCSI_ALL_H 1
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+#define	AIC_LINUX_IRQRETURN_T irqreturn_t
+#define	AIC_LINUX_IRQRETURN(ours) return (IRQ_RETVAL(ours))
+#else
+#define	AIC_LINUX_IRQRETURN_T void
+#define	AIC_LINUX_IRQRETURN(ours)  return
+#endif
 
 /*
  * SCSI command format
@@ -906,10 +949,10 @@
 int		aic_static_inquiry_match(caddr_t /*inqbuffer*/,
 					 caddr_t /*table_entry*/);
 
-typedef void aic_option_callback_t(void *, int, int, int32_t);
+typedef void aic_option_callback_t(u_long, int, int, int32_t);
 char *		aic_parse_brace_option(char *opt_name, char *opt_arg,
 				       char *end, int depth,
-				       aic_option_callback_t *, void *);
+				       aic_option_callback_t *, u_long);
 
 static __inline void	 scsi_extract_sense(struct scsi_sense_data *sense,
 					    int *error_code, int *sense_key,
@@ -1003,4 +1046,4 @@
 	return (rv);
 }
 
-#endif /*_SCSI_SCSI_ALL_H*/
+#endif /*_AICLIB_H */
diff -urN linux-2.5.69-bk7/drivers/scsi/aic7xxx_old/aic7xxx.h linux-2.5.69-bk8/drivers/scsi/aic7xxx_old/aic7xxx.h
--- linux-2.5.69-bk7/drivers/scsi/aic7xxx_old/aic7xxx.h	2003-05-04 16:52:49.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/aic7xxx_old/aic7xxx.h	2003-05-13 04:44:29.000000000 -0700
@@ -25,48 +25,4 @@
 
 #define AIC7XXX_H_VERSION  "5.2.0"
 
-/*
- * Scsi_Host_Template (see hosts.h) for AIC-7xxx - some fields
- * to do with card config are filled in after the card is detected.
- */
-#define AIC7XXX	{						\
-	.proc_info		= aic7xxx_proc_info,		\
-	.detect			= aic7xxx_detect,		\
-	.release		= aic7xxx_release,		\
-	.info			= aic7xxx_info,			\
-	.queuecommand		= aic7xxx_queue,		\
-	.slave_alloc		= aic7xxx_slave_alloc,		\
-	.slave_configure	= aic7xxx_slave_configure,	\
-	.slave_destroy		= aic7xxx_slave_destroy,	\
-	.bios_param		= aic7xxx_biosparam,		\
-	.eh_abort_handler	= aic7xxx_abort,		\
-	.eh_device_reset_handler	= aic7xxx_bus_device_reset,	\
-	.eh_host_reset_handler	= aic7xxx_reset,			\
-	.can_queue		= 255,	/* max simultaneous cmds      */\
-	.this_id		= -1,	/* scsi id of host adapter    */\
-	.sg_tablesize		= 0,	/* max scatter-gather cmds    */\
-	.max_sectors		= 2048,	/* max physical sectors in 1 cmd */\
-	.cmd_per_lun		= 3,	/* cmds per lun (linked cmds) */\
-	.present		= 0,	/* number of 7xxx's present   */\
-	.unchecked_isa_dma	= 0,	/* no memory DMA restrictions */\
-	.use_clustering		= ENABLE_CLUSTERING,			\
-}
-
-extern int aic7xxx_queue(Scsi_Cmnd *, void (*)(Scsi_Cmnd *));
-extern int aic7xxx_biosparam(struct scsi_device *, struct block_device *,
-		sector_t, int[]);
-extern int aic7xxx_detect(Scsi_Host_Template *);
-extern int aic7xxx_command(Scsi_Cmnd *);
-extern int aic7xxx_release(struct Scsi_Host *);
-static int aic7xxx_slave_alloc(Scsi_Device *);
-static int aic7xxx_slave_configure(Scsi_Device *);
-static void aic7xxx_slave_destroy(Scsi_Device *);
-extern int aic7xxx_abort(Scsi_Cmnd *);
-extern int aic7xxx_bus_device_reset(Scsi_Cmnd *);
-extern int aic7xxx_reset(Scsi_Cmnd *);
-
-extern const char *aic7xxx_info(struct Scsi_Host *);
-
-extern int aic7xxx_proc_info(char *, char **, off_t, int, int, int);
-
 #endif /* _aic7xxx_h */
diff -urN linux-2.5.69-bk7/drivers/scsi/aic7xxx_old.c linux-2.5.69-bk8/drivers/scsi/aic7xxx_old.c
--- linux-2.5.69-bk7/drivers/scsi/aic7xxx_old.c	2003-05-04 16:53:13.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/aic7xxx_old.c	2003-05-13 04:44:29.000000000 -0700
@@ -1270,6 +1270,7 @@
  *
  ***************************************************************************/
 
+static int aic7xxx_release(struct Scsi_Host *host);
 static void aic7xxx_set_syncrate(struct aic7xxx_host *p, 
 		struct aic7xxx_syncrate *syncrate, int target, int channel,
 		unsigned int period, unsigned int offset, unsigned char options,
@@ -8361,7 +8362,7 @@
  *   Perform a chip reset on the aic7xxx SCSI controller.  The controller
  *   is paused upon return.
  *-F*************************************************************************/
-int
+static int
 aic7xxx_chip_reset(struct aic7xxx_host *p)
 {
   unsigned char sblkctl;
@@ -8996,7 +8997,7 @@
  *       one do-it-all function.  This may be useful when (and if) the
  *       mid-level SCSI code is overhauled.
  *-F*************************************************************************/
-int
+static int
 aic7xxx_detect(Scsi_Host_Template *template)
 {
   struct aic7xxx_host *temp_p = NULL;
@@ -10293,7 +10294,7 @@
  * Description:
  *   Queue a SCB to the controller.
  *-F*************************************************************************/
-int
+static int
 aic7xxx_queue(Scsi_Cmnd *cmd, void (*fn)(Scsi_Cmnd *))
 {
   struct aic7xxx_host *p;
@@ -10364,7 +10365,7 @@
  *   aborted, then we will reset the channel and have all devices renegotiate.
  *   Returns an enumerated type that indicates the status of the operation.
  *-F*************************************************************************/
-int
+static int
 aic7xxx_bus_device_reset(Scsi_Cmnd *cmd)
 {
   struct aic7xxx_host  *p;
@@ -10566,7 +10567,7 @@
  * Description:
  *   Abort the current SCSI command(s).
  *-F*************************************************************************/
-void
+static void
 aic7xxx_panic_abort(struct aic7xxx_host *p, Scsi_Cmnd *cmd)
 {
 
@@ -10592,7 +10593,7 @@
  * Description:
  *   Abort the current SCSI command(s).
  *-F*************************************************************************/
-int
+static int
 aic7xxx_abort(Scsi_Cmnd *cmd)
 {
   struct aic7xxx_scb  *scb = NULL;
@@ -10820,7 +10821,7 @@
  *   DEVICE RESET message - on the offending target before pulling
  *   the SCSI bus reset line.
  *-F*************************************************************************/
-int
+static int
 aic7xxx_reset(Scsi_Cmnd *cmd)
 {
   struct aic7xxx_scb *scb;
@@ -10905,7 +10906,7 @@
  *   This function is broken for today's really large drives and needs
  *   fixed.
  *-F*************************************************************************/
-int
+static int
 aic7xxx_biosparam(struct scsi_device *sdev, struct block_device *bdev,
 		sector_t capacity, int geom[])
 {
@@ -10955,7 +10956,7 @@
  *   Free the passed in Scsi_Host memory structures prior to unloading the
  *   module.
  *-F*************************************************************************/
-int
+static int
 aic7xxx_release(struct Scsi_Host *host)
 {
   struct aic7xxx_host *p = (struct aic7xxx_host *) host->hostdata;
@@ -11141,8 +11142,25 @@
 MODULE_LICENSE("Dual BSD/GPL");
 
 
-/* Eventually this will go into an include file, but this will be later */
-static Scsi_Host_Template driver_template = AIC7XXX;
+static Scsi_Host_Template driver_template = {
+	.proc_info		= aic7xxx_proc_info,
+	.detect			= aic7xxx_detect,
+	.release		= aic7xxx_release,
+	.info			= aic7xxx_info,	
+	.queuecommand		= aic7xxx_queue,
+	.slave_alloc		= aic7xxx_slave_alloc,
+	.slave_configure	= aic7xxx_slave_configure,
+	.slave_destroy		= aic7xxx_slave_destroy,
+	.bios_param		= aic7xxx_biosparam,
+	.eh_abort_handler	= aic7xxx_abort,
+	.eh_device_reset_handler	= aic7xxx_bus_device_reset,
+	.eh_host_reset_handler	= aic7xxx_reset,
+	.can_queue		= 255,
+	.this_id		= -1,
+	.max_sectors		= 2048,
+	.cmd_per_lun		= 3,
+	.use_clustering		= ENABLE_CLUSTERING,
+};
 
 #include "scsi_module.c"
 
diff -urN linux-2.5.69-bk7/drivers/scsi/atp870u.c linux-2.5.69-bk8/drivers/scsi/atp870u.c
--- linux-2.5.69-bk7/drivers/scsi/atp870u.c	2003-05-04 16:53:13.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/atp870u.c	2003-05-13 04:44:29.000000000 -0700
@@ -2748,5 +2748,19 @@
 
 MODULE_LICENSE("GPL");
 
-static Scsi_Host_Template driver_template = ATP870U;
+static Scsi_Host_Template driver_template = {
+	.proc_info		= atp870u_proc_info,
+	.detect			= atp870u_detect,
+	.release		= atp870u_release,
+	.info			= atp870u_info,
+	.command		= atp870u_command,
+	.queuecommand		= atp870u_queuecommand,
+	.eh_abort_handler	= atp870u_abort,
+	.bios_param		= atp870u_biosparam,
+	.can_queue		= qcnt,
+	.this_id		= 7,
+	.sg_tablesize		= ATP870U_SCATTER,
+	.cmd_per_lun		= ATP870U_CMDLUN,
+	.use_clustering		= ENABLE_CLUSTERING,
+};
 #include "scsi_module.c"
diff -urN linux-2.5.69-bk7/drivers/scsi/atp870u.h linux-2.5.69-bk8/drivers/scsi/atp870u.h
--- linux-2.5.69-bk7/drivers/scsi/atp870u.h	2003-05-04 16:53:01.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/atp870u.h	2003-05-13 04:44:29.000000000 -0700
@@ -37,22 +37,4 @@
 
 extern int atp870u_proc_info(char *, char **, off_t, int, int, int);
 
-#define ATP870U {						\
-	.proc_info = atp870u_proc_info,				\
-	.detect = atp870u_detect, 				\
-	.release = atp870u_release,				\
-	.info = atp870u_info,					\
-	.command = atp870u_command,				\
-	.queuecommand = atp870u_queuecommand,			\
-	.eh_abort_handler = atp870u_abort, 			\
-	.bios_param = atp870u_biosparam,				\
-	.can_queue = qcnt,	 /* max simultaneous cmds      */\
-	.this_id = 7,	       /* scsi id of host adapter    */\
-	.sg_tablesize = ATP870U_SCATTER,	/* max scatter-gather cmds    */\
-	.cmd_per_lun = ATP870U_CMDLUN,	/* cmds per lun (linked cmds) */\
-	.present = 0,		/* number of 7xxx's present   */\
-	.unchecked_isa_dma = 0,	/* no memory DMA restrictions */\
-	.use_clustering = ENABLE_CLUSTERING,			\
-}
-
 #endif
diff -urN linux-2.5.69-bk7/drivers/scsi/cpqfcTS.h linux-2.5.69-bk8/drivers/scsi/cpqfcTS.h
--- linux-2.5.69-bk7/drivers/scsi/cpqfcTS.h	2003-05-04 16:53:13.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/cpqfcTS.h	2003-05-13 04:44:29.000000000 -0700
@@ -16,27 +16,4 @@
 		sector_t, int[]);
 extern int cpqfcTS_ioctl( Scsi_Device *ScsiDev, int Cmnd, void *arg);
 
-// note: since Tachyon TS supports an extended scatter/gather
-// linked list of infinite length (with linked Ext S/G pages,
-// limited only by available physical memory) we use SG_ALL.
-
-#define CPQFCTS {                                \
- .detect                 = cpqfcTS_detect,         \
- .release                = cpqfcTS_release,        \
- .info                   = cpqfcTS_info,           \
- .proc_info              = cpqfcTS_proc_info,      \
- .ioctl                  = cpqfcTS_ioctl,          \
- .queuecommand           = cpqfcTS_queuecommand,   \
- .eh_device_reset_handler   = cpqfcTS_eh_device_reset,   \
- .eh_abort_handler       = cpqfcTS_eh_abort,       \
- .bios_param             = cpqfcTS_biosparam,      \
- .can_queue              = CPQFCTS_REQ_QUEUE_LEN,  \
- .this_id                = -1,                     \
- .sg_tablesize           = SG_ALL,                 \
- .cmd_per_lun            = CPQFCTS_CMD_PER_LUN,    \
- .present                = 0,                      \
- .unchecked_isa_dma      = 0,                      \
- .use_clustering         = ENABLE_CLUSTERING,      \
-}
-
 #endif /* CPQFCTS_H */ 
diff -urN linux-2.5.69-bk7/drivers/scsi/cpqfcTSinit.c linux-2.5.69-bk8/drivers/scsi/cpqfcTSinit.c
--- linux-2.5.69-bk7/drivers/scsi/cpqfcTSinit.c	2003-05-04 16:53:01.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/cpqfcTSinit.c	2003-05-13 04:44:29.000000000 -0700
@@ -677,11 +677,6 @@
         scsi_release_request(ScsiPassThruReq); // "de-allocate"
         ScsiPassThruReq = NULL;
 
-        // if (!SDpnt->was_reset && SDpnt->scsi_request_fn)
-        //  (*SDpnt->scsi_request_fn)();
-
-        wake_up(&SDpnt->scpnt_wait);
-
 	// need to pass data back to user (space)?
 	if( (vendor_cmd->rw_flag == VENDOR_READ_OPCODE) &&
 	     vendor_cmd->len )
@@ -1656,10 +1651,6 @@
   scsi_put_command(SCpnt);
   SCpnt = NULL;
 
-  // if (!SDpnt->was_reset && SDpnt->scsi_request_fn)
-  // 	(*SDpnt->scsi_request_fn)();
-
-  wake_up(&SDpnt->scpnt_wait);
   // printk("   LEAVING cpqfcTS_TargetDeviceReset() - return SUCCESS \n");
   return SUCCESS;
 }
@@ -2060,7 +2051,21 @@
 }
 
 
-static Scsi_Host_Template driver_template = CPQFCTS;
-
+static Scsi_Host_Template driver_template = {
+	.detect                 = cpqfcTS_detect,
+	.release                = cpqfcTS_release,
+	.info                   = cpqfcTS_info,
+	.proc_info              = cpqfcTS_proc_info,
+	.ioctl                  = cpqfcTS_ioctl,
+	.queuecommand           = cpqfcTS_queuecommand,
+	.eh_device_reset_handler   = cpqfcTS_eh_device_reset,
+	.eh_abort_handler       = cpqfcTS_eh_abort, 
+	.bios_param             = cpqfcTS_biosparam, 
+	.can_queue              = CPQFCTS_REQ_QUEUE_LEN,
+	.this_id                = -1, 
+	.sg_tablesize           = SG_ALL, 
+	.cmd_per_lun            = CPQFCTS_CMD_PER_LUN,
+	.use_clustering         = ENABLE_CLUSTERING,
+};
 #include "scsi_module.c"
 
diff -urN linux-2.5.69-bk7/drivers/scsi/dc390.h linux-2.5.69-bk8/drivers/scsi/dc390.h
--- linux-2.5.69-bk7/drivers/scsi/dc390.h	2003-05-04 16:53:05.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/dc390.h	2003-05-13 04:44:29.000000000 -0700
@@ -50,45 +50,4 @@
 
 extern int DC390_proc_info(char *buffer, char **start, off_t offset, int length, int hostno, int inout);
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,30)
-#define DC390_T    {					\
-   .proc_name      = "tmscsim",                           \
-   .proc_info      = DC390_proc_info,			\
-   .name           = DC390_BANNER " V" DC390_VERSION,	\
-   .detect         = DC390_detect,			\
-   .release        = DC390_release,			\
-   .queuecommand   = DC390_queue_command,			\
-   .abort          = DC390_abort,				\
-   .reset          = DC390_reset,				\
-   .bios_param     = DC390_bios_param,			\
-   .can_queue      = 42,					\
-   .this_id        = 7,					\
-   .sg_tablesize   = SG_ALL,				\
-   .cmd_per_lun    = 16,					\
-   .unchecked_isa_dma = 0,				\
-   .use_clustering = DISABLE_CLUSTERING			\
-   }
-#else
-extern struct proc_dir_entry DC390_proc_scsi_tmscsim;
-#define DC390_T    {					\
-   .proc_dir       = &DC390_proc_scsi_tmscsim,		\
-   .proc_info      = DC390_proc_info,			\
-   .name           = DC390_BANNER " V" DC390_VERSION,	\
-   .detect         = DC390_detect,			\
-   .release        = DC390_release,			\
-   .queuecommand   = DC390_queue_command,			\
-   .abort          = DC390_abort,				\
-   .reset          = DC390_reset,				\
-   .bios_param     = DC390_bios_param,			\
-   .can_queue      = 42,					\
-   .this_id        = 7,					\
-   .sg_tablesize   = SG_ALL,				\
-   .cmd_per_lun    = 16,					\
-   NEW_EH						\
-   .unchecked_isa_dma = 0,				\
-   .use_clustering = DISABLE_CLUSTERING			\
-   }
-#endif
-#endif /* defined(HOSTS_C) || defined(MODULE) */
-
 #endif /* DC390_H */
diff -urN linux-2.5.69-bk7/drivers/scsi/dc395x.c linux-2.5.69-bk8/drivers/scsi/dc395x.c
--- linux-2.5.69-bk7/drivers/scsi/dc395x.c	2003-05-04 16:53:02.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/dc395x.c	2003-05-13 04:44:29.000000000 -0700
@@ -51,6 +51,7 @@
 #include <linux/delay.h>
 #include <linux/ctype.h>
 #include <linux/blk.h>
+#include <asm/io.h>
 #include "scsi.h"
 #include "hosts.h"
 #include "dc395x.h"
diff -urN linux-2.5.69-bk7/drivers/scsi/dmx3191d.c linux-2.5.69-bk8/drivers/scsi/dmx3191d.c
--- linux-2.5.69-bk7/drivers/scsi/dmx3191d.c	2003-05-04 16:53:32.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/dmx3191d.c	2003-05-13 04:44:29.000000000 -0700
@@ -121,6 +121,21 @@
 
 MODULE_LICENSE("GPL");
 
-static Scsi_Host_Template driver_template = DMX3191D;
+static Scsi_Host_Template driver_template = {
+	.proc_info		= dmx3191d_proc_info,
+	.name			= "Domex DMX3191D",
+	.detect			= dmx3191d_detect,
+	.release		= dmx3191d_release_resources,
+	.info			= dmx3191d_info,
+	.queuecommand		= dmx3191d_queue_command,
+	.eh_abort_handler	= dmx3191d_abort,
+	.eh_bus_reset_handler	= dmx3191d_bus_reset,
+	.eh_device_reset_handler = dmx3191d_device_reset,
+	.eh_host_reset_handler	= dmx3191d_host_reset,
+	.can_queue		= 32,
+        .this_id		= 7,
+        .sg_tablesize		= SG_ALL,
+	.cmd_per_lun		= 2,
+        .use_clustering		= DISABLE_CLUSTERING,
+};
 #include "scsi_module.c"
-
diff -urN linux-2.5.69-bk7/drivers/scsi/dmx3191d.h linux-2.5.69-bk8/drivers/scsi/dmx3191d.h
--- linux-2.5.69-bk7/drivers/scsi/dmx3191d.h	2003-05-04 16:53:28.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/dmx3191d.h	2003-05-13 04:44:29.000000000 -0700
@@ -30,27 +30,6 @@
 static int dmx3191d_host_reset(Scsi_Cmnd *);
 static int dmx3191d_device_reset(Scsi_Cmnd *);
 
-
-#define DMX3191D {				\
-	.proc_info	= dmx3191d_proc_info,		\
-	.name		= "Domex DMX3191D",		\
-	.detect		= dmx3191d_detect,		\
-	.release	= dmx3191d_release_resources,	\
-	.info		= dmx3191d_info,			\
-	.queuecommand	= dmx3191d_queue_command,		\
-	.eh_abort_handler	= dmx3191d_abort,		\
-	.eh_bus_reset_handler	= dmx3191d_bus_reset, 	\
-	.eh_device_reset_handler = dmx3191d_device_reset, 	\
-	.eh_host_reset_handler	= dmx3191d_host_reset, 	\
-	.bios_param	= NULL,				\
-	.can_queue	= 32,				\
-        .this_id	= 7,				\
-        .sg_tablesize	= SG_ALL,				\
-	.cmd_per_lun	= 2,				\
-        .use_clustering	= DISABLE_CLUSTERING		\
-}
-
-
 #define NCR5380_read(reg)			inb(port + reg)
 #define NCR5380_write(reg, value)		outb(value, port + reg)
 
diff -urN linux-2.5.69-bk7/drivers/scsi/dpt_i2o.c linux-2.5.69-bk8/drivers/scsi/dpt_i2o.c
--- linux-2.5.69-bk7/drivers/scsi/dpt_i2o.c	2003-05-04 16:53:37.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/dpt_i2o.c	2003-05-13 04:44:29.000000000 -0700
@@ -2495,8 +2495,6 @@
 				pDev->pScsi_dev->online = FALSE;
 				if (pDev->pScsi_dev->access_count) {
 					// A drive that was mounted is no longer there... bad!
-					SCSI_LOG_ERROR_RECOVERY(1, printk ("%s:Rescan: Previously "
-								 "mounted drive not found!\n",pHba->name));
 					printk(KERN_WARNING"%s:Mounted drive taken offline\n",pHba->name);
 				}
 			}
@@ -3306,6 +3304,24 @@
 
 #endif
 
-static Scsi_Host_Template driver_template = DPT_I2O;
+static Scsi_Host_Template driver_template = {
+	.name			= "dpt_i2o",
+	.proc_name		= "dpt_i2o",
+	.proc_info		= adpt_proc_info,
+	.detect			= adpt_detect,	
+	.release		= adpt_release,
+	.info			= adpt_info,
+	.queuecommand		= adpt_queue,
+	.eh_abort_handler	= adpt_abort,
+	.eh_device_reset_handler = adpt_device_reset,
+	.eh_bus_reset_handler	= adpt_bus_reset,
+	.eh_host_reset_handler	= adpt_reset,
+	.bios_param		= adpt_bios_param,
+	.slave_configure	= adpt_slave_configure,
+	.can_queue		= MAX_TO_IOP_MESSAGES,
+	.this_id		= 7,
+	.cmd_per_lun		= 1,
+	.use_clustering		= ENABLE_CLUSTERING,
+};
 #include "scsi_module.c"
 MODULE_LICENSE("GPL");
diff -urN linux-2.5.69-bk7/drivers/scsi/dpti.h linux-2.5.69-bk8/drivers/scsi/dpti.h
--- linux-2.5.69-bk7/drivers/scsi/dpti.h	2003-05-04 16:52:48.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/dpti.h	2003-05-13 04:44:29.000000000 -0700
@@ -60,49 +60,6 @@
 
 #define DPT_DRIVER_NAME	"Adaptec I2O RAID"
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,00)
-#define DPT_I2O { \
-	.proc_info = adpt_proc_info,					\
-	.detect = adpt_detect,						\
-	.release = adpt_release,						\
-	.info = adpt_info,						\
-	.queuecommand = adpt_queue,					\
-	.eh_abort_handler = adpt_abort,					\
-	.eh_device_reset_handler = adpt_device_reset,			\
-	.eh_bus_reset_handler = adpt_bus_reset,				\
-	.eh_host_reset_handler = adpt_reset,				\
-	.bios_param = adpt_bios_param,					\
-	.can_queue = MAX_TO_IOP_MESSAGES ,/* max simultaneous cmds      */\
-	.this_id = 7,			/* scsi id of host adapter    */\
-	.sg_tablesize = 0,		/* max scatter-gather cmds    */\
-	.cmd_per_lun = 256,		/* cmds per lun (linked cmds) */\
-	.use_clustering = ENABLE_CLUSTERING,				\
-	.use_new_eh_code = 1						\
-}
-
-#else				/* KERNEL_VERSION > 2.2.16 */
-
-#define DPT_I2O { \
-	.proc_info = adpt_proc_info,					\
-	.detect = adpt_detect,						\
-	.release = adpt_release,						\
-	.info = adpt_info,						\
-	.queuecommand = adpt_queue,					\
-	.eh_abort_handler = adpt_abort,					\
-	.eh_device_reset_handler = adpt_device_reset,			\
-	.eh_bus_reset_handler = adpt_bus_reset,				\
-	.eh_host_reset_handler = adpt_reset,				\
-	.bios_param = adpt_bios_param,					\
-	.slave_configure = adpt_slave_configure,				\
-	.can_queue = MAX_TO_IOP_MESSAGES,	/* max simultaneous cmds      */\
-	.this_id = 7,			/* scsi id of host adapter    */\
-	.sg_tablesize = 0,		/* max scatter-gather cmds    */\
-	.cmd_per_lun = 1,			/* cmds per lun (linked cmds) */\
-	.use_clustering = ENABLE_CLUSTERING,				\
-	.proc_name = "dpt_i2o"	/* this is the name of our proc node*/	\
-}
-#endif
-
 #ifndef HOSTS_C
 
 #include "dpt/sys_info.h"
diff -urN linux-2.5.69-bk7/drivers/scsi/dtc.c linux-2.5.69-bk8/drivers/scsi/dtc.c
--- linux-2.5.69-bk7/drivers/scsi/dtc.c	2003-05-04 16:53:36.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/dtc.c	2003-05-13 04:44:29.000000000 -0700
@@ -447,6 +447,19 @@
 
 #include "NCR5380.c"
 
-/* Eventually this will go into an include file, but this will be later */
-static Scsi_Host_Template driver_template = DTC3x80;
+static Scsi_Host_Template driver_template = {
+	.name				= "DTC 3180/3280 ",
+	.detect				= dtc_detect,
+	.queuecommand			= dtc_queue_command,
+	.eh_abort_handler		= dtc_abort,
+	.eh_bus_reset_handler		= dtc_bus_reset,
+	.eh_device_reset_handler	= dtc_device_reset,
+	.eh_host_reset_handler          = dtc_host_reset,
+	.bios_param     		= dtc_biosparam,
+	.can_queue      		= CAN_QUEUE,
+	.this_id        		= 7,
+	.sg_tablesize   		= SG_ALL,
+	.cmd_per_lun    		= CMD_PER_LUN,
+	.use_clustering 		= DISABLE_CLUSTERING,
+};
 #include "scsi_module.c"
diff -urN linux-2.5.69-bk7/drivers/scsi/dtc.h linux-2.5.69-bk8/drivers/scsi/dtc.h
--- linux-2.5.69-bk7/drivers/scsi/dtc.h	2003-05-04 16:53:02.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/dtc.h	2003-05-13 04:44:29.000000000 -0700
@@ -47,27 +47,6 @@
 #define CAN_QUEUE 32 
 #endif
 
-/* 
- * I hadn't thought of this with the earlier drivers - but to prevent
- * macro definition conflicts, we shouldn't define all of the internal
- * macros when this is being used solely for the host stub.
- */
-
-#define DTC3x80 {						\
-	.name				= "DTC 3180/3280 ",	\
-	.detect				= dtc_detect,		\
-	.queuecommand			= dtc_queue_command,	\
-	.eh_abort_handler		= dtc_abort,		\
-	.eh_bus_reset_handler		= dtc_bus_reset,		\
-	.eh_device_reset_handler	= dtc_device_reset,	\
-	.eh_host_reset_handler          = dtc_host_reset,		\
-	.bios_param     = dtc_biosparam,				\
-	.can_queue      = CAN_QUEUE,				\
-	.this_id        = 7,					\
-	.sg_tablesize   = SG_ALL,					\
-	.cmd_per_lun    = CMD_PER_LUN ,				\
-	.use_clustering = DISABLE_CLUSTERING}
-
 #define NCR5380_implementation_fields \
     unsigned int base
 
diff -urN linux-2.5.69-bk7/drivers/scsi/eata.c linux-2.5.69-bk8/drivers/scsi/eata.c
--- linux-2.5.69-bk7/drivers/scsi/eata.c	2003-05-04 16:53:40.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/eata.c	2003-05-13 04:44:29.000000000 -0700
@@ -2375,8 +2375,19 @@
    return FALSE;
 }
 
-static Scsi_Host_Template driver_template = EATA;
-
+static Scsi_Host_Template driver_template = {
+	.name              	= "EATA/DMA 2.0x rev. " EATA_VERSION " ",
+	.detect                  = eata2x_detect,
+	.release                 = eata2x_release,
+	.queuecommand            = eata2x_queuecommand,
+	.eh_abort_handler        = eata2x_eh_abort,
+	.eh_host_reset_handler   = eata2x_eh_host_reset,
+	.bios_param              = eata2x_bios_param,
+	.slave_configure	 = eata2x_slave_configure,
+	.this_id                 = 7,
+	.unchecked_isa_dma       = 1,
+	.use_clustering          = ENABLE_CLUSTERING,
+};
 #include "scsi_module.c"
 
 #ifndef MODULE
diff -urN linux-2.5.69-bk7/drivers/scsi/eata.h linux-2.5.69-bk8/drivers/scsi/eata.h
--- linux-2.5.69-bk7/drivers/scsi/eata.h	2003-05-04 16:53:03.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/eata.h	2003-05-13 04:44:29.000000000 -0700
@@ -13,18 +13,3 @@
 
 #define EATA_VERSION "8.03.00"
 
-#define EATA {                                                               \
-                .name              = "EATA/DMA 2.0x rev. " EATA_VERSION " ",   \
-                .detect                  = eata2x_detect,                      \
-                .release                 = eata2x_release,                     \
-                .queuecommand            = eata2x_queuecommand,                \
-                .eh_abort_handler        = eata2x_eh_abort,                    \
-                .eh_device_reset_handler = NULL,                               \
-                .eh_bus_reset_handler    = NULL,                               \
-                .eh_host_reset_handler   = eata2x_eh_host_reset,               \
-                .bios_param              = eata2x_bios_param,                  \
-		.slave_configure	 = eata2x_slave_configure,	     \
-                .this_id                 = 7,                                  \
-                .unchecked_isa_dma       = 1,                                  \
-                .use_clustering          = ENABLE_CLUSTERING                   \
-             }
diff -urN linux-2.5.69-bk7/drivers/scsi/eata_pio.c linux-2.5.69-bk8/drivers/scsi/eata_pio.c
--- linux-2.5.69-bk7/drivers/scsi/eata_pio.c	2003-05-04 16:53:33.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/eata_pio.c	2003-05-13 04:44:29.000000000 -0700
@@ -106,7 +106,6 @@
 			      int length, int hostno, int rw)
 {
     struct Scsi_Host *shost;
-    struct scsi_device *sdev;
     static u8 buff[512];
     int size, len = 0;
     off_t begin = 0, pos = 0;
diff -urN linux-2.5.69-bk7/drivers/scsi/esp.c linux-2.5.69-bk8/drivers/scsi/esp.c
--- linux-2.5.69-bk7/drivers/scsi/esp.c	2003-05-04 16:53:56.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/esp.c	2003-05-13 04:44:29.000000000 -0700
@@ -4380,10 +4380,7 @@
 	.sg_tablesize		= SG_ALL,
 	.cmd_per_lun		= 1,
 	.use_clustering		= ENABLE_CLUSTERING,
-/* Sparc32's iommu code cannot handle highmem pages yet. */
-#ifdef CONFIG_SPARC64
 	.highmem_io		= 1,
-#endif
 };
 
 #include "scsi_module.c"
diff -urN linux-2.5.69-bk7/drivers/scsi/fcal.c linux-2.5.69-bk8/drivers/scsi/fcal.c
--- linux-2.5.69-bk7/drivers/scsi/fcal.c	2003-05-04 16:53:00.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/fcal.c	2003-05-13 04:44:29.000000000 -0700
@@ -302,7 +302,22 @@
 	return 0;
 }
 
-static Scsi_Host_Template driver_template = FCAL;
-
+static Scsi_Host_Template driver_template = {
+	.name			= "Fibre Channel Arbitrated Loop",
+	.detect			= fcal_detect,
+	.release		= fcal_release,	
+	.proc_info		= fcal_proc_info,
+	.queuecommand		= fcp_scsi_queuecommand,
+	.slave_configure	= fcal_slave_configure,
+	.can_queue		= FCAL_CAN_QUEUE,
+	.this_id		= -1,
+	.sg_tablesize		= 1,
+	.cmd_per_lun		= 1,
+	.use_clustering		= ENABLE_CLUSTERING,
+	.eh_abort_handler	= fcp_scsi_abort,
+	.eh_device_reset_handler = fcp_scsi_dev_reset,
+	.eh_bus_reset_handler	= fcp_scsi_bus_reset,
+	.eh_host_reset_handler	= fcp_scsi_host_reset,
+};
 #include "scsi_module.c"
 
diff -urN linux-2.5.69-bk7/drivers/scsi/fcal.h linux-2.5.69-bk8/drivers/scsi/fcal.h
--- linux-2.5.69-bk7/drivers/scsi/fcal.h	2003-05-04 16:52:49.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/fcal.h	2003-05-13 04:44:29.000000000 -0700
@@ -25,22 +25,4 @@
 int fcal_proc_info (char *, char **, off_t, int, int, int);
 int fcal_slave_configure(Scsi_Device *);
 
-#define FCAL {							\
-	.name			= "Fibre Channel Arbitrated Loop",\
-	.detect			= fcal_detect,			\
-	.release		= fcal_release,			\
-	.proc_info		= fcal_proc_info,			\
-	.queuecommand		= fcp_scsi_queuecommand,		\
-	.slave_configure	= fcal_slave_configure,		\
-	.can_queue		= FCAL_CAN_QUEUE,			\
-	.this_id		= -1,				\
-	.sg_tablesize		= 1,				\
-	.cmd_per_lun		= 1,				\
-	.use_clustering		= ENABLE_CLUSTERING,		\
-	.eh_abort_handler	= fcp_scsi_abort,			\
-	.eh_device_reset_handler = fcp_scsi_dev_reset,		\
-	.eh_bus_reset_handler	= fcp_scsi_bus_reset,		\
-	.eh_host_reset_handler	= fcp_scsi_host_reset,		\
-}	
-
 #endif /* !(_FCAL_H) */
diff -urN linux-2.5.69-bk7/drivers/scsi/fd_mcs.c linux-2.5.69-bk8/drivers/scsi/fd_mcs.c
--- linux-2.5.69-bk7/drivers/scsi/fd_mcs.c	2003-05-04 16:53:12.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/fd_mcs.c	2003-05-13 04:44:29.000000000 -0700
@@ -740,7 +740,7 @@
 #if DEBUG_RACE
 		in_interrupt_flag = 0;
 #endif
-		return;
+		return IRQ_HANDLED;
 	} else if (current_SC->SCp.phase & in_selection) {
 		status = inb(SCSI_Status_port);
 		if (!(status & 0x01)) {
@@ -1436,7 +1436,23 @@
 	return 0;
 }
 
-/* Eventually this will go into an include file, but this will be later */
-	static Scsi_Host_Template driver_template = FD_MCS;
-
+static Scsi_Host_Template driver_template = {
+	.proc_name			= "fd_mcs",
+	.proc_info			= fd_mcs_proc_info,
+	.detect				= fd_mcs_detect,
+	.release			= fd_mcs_release,
+	.info				= fd_mcs_info,
+	.command			= fd_mcs_command,
+	.queuecommand   		= fd_mcs_queue, 
+	.eh_abort_handler		= fd_mcs_abort,
+	.eh_bus_reset_handler		= fd_mcs_bus_reset,
+	.eh_host_reset_handler		= fd_mcs_host_reset,
+	.eh_device_reset_handler	= fd_mcs_device_reset,
+	.bios_param     		= fd_mcs_biosparam,
+	.can_queue      		= 1,
+	.this_id        		= 7,
+	.sg_tablesize   		= 64,
+	.cmd_per_lun    		= 1,
+	.use_clustering 		= DISABLE_CLUSTERING,
+};
 #include "scsi_module.c"
diff -urN linux-2.5.69-bk7/drivers/scsi/fd_mcs.h linux-2.5.69-bk8/drivers/scsi/fd_mcs.h
--- linux-2.5.69-bk7/drivers/scsi/fd_mcs.h	2003-05-04 16:53:03.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/fd_mcs.h	2003-05-13 04:44:29.000000000 -0700
@@ -35,24 +35,4 @@
 static int fd_mcs_proc_info(char *, char **, off_t, int, int, int);
 static const char *fd_mcs_info(struct Scsi_Host *);
 
-#define FD_MCS {\
-                    .proc_name			= "fd_mcs",		\
-                    .proc_info			= fd_mcs_proc_info,	\
-		    .detect			= fd_mcs_detect,		\
-		    .release			= fd_mcs_release,		\
-		    .info			= fd_mcs_info,		\
-		    .command			= fd_mcs_command,		\
-		    .queuecommand   		= fd_mcs_queue,           \
-		    .eh_abort_handler		= fd_mcs_abort,           \
-		    .eh_bus_reset_handler	= fd_mcs_bus_reset,       \
-		    .eh_host_reset_handler	= fd_mcs_host_reset,      \
-		    .eh_device_reset_handler	= fd_mcs_device_reset,    \
-		    .bios_param     		= fd_mcs_biosparam,       \
-		    .can_queue      		= 1, 			\
-		    .this_id        		= 7, 			\
-		    .sg_tablesize   		= 64, 			\
-		    .cmd_per_lun    		= 1, 			\
-		    .use_clustering 		= DISABLE_CLUSTERING	\
-		}
-
 #endif				/* _FD_MCS_H */
diff -urN linux-2.5.69-bk7/drivers/scsi/g_NCR5380.c linux-2.5.69-bk8/drivers/scsi/g_NCR5380.c
--- linux-2.5.69-bk7/drivers/scsi/g_NCR5380.c	2003-05-04 16:53:03.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/g_NCR5380.c	2003-05-13 04:44:29.000000000 -0700
@@ -885,11 +885,24 @@
 #undef PRINTP
 #undef ANDP
 
-/*
- *	Eventually this will go into an include file, but this will be later 
- */
-static Scsi_Host_Template driver_template = GENERIC_NCR5380;
-
+static Scsi_Host_Template driver_template = {
+	.proc_info      	= generic_NCR5380_proc_info,
+	.name           	= "Generic NCR5380/NCR53C400 Scsi Driver",
+	.detect         	= generic_NCR5380_detect,
+	.release        	= generic_NCR5380_release_resources,
+	.info           	= generic_NCR5380_info,
+	.queuecommand   	= generic_NCR5380_queue_command,
+	.eh_abort_handler	= generic_NCR5380_abort,
+	.eh_bus_reset_handler	= generic_NCR5380_bus_reset,
+	.eh_device_reset_handler = generic_NCR5380_device_reset,
+	.eh_host_reset_handler	= generic_NCR5380_host_reset,
+	.bios_param     	= NCR5380_BIOSPARAM,
+	.can_queue      	= CAN_QUEUE,
+        .this_id        	= 7,
+        .sg_tablesize   	= SG_ALL,
+	.cmd_per_lun    	= CMD_PER_LUN,
+        .use_clustering		= DISABLE_CLUSTERING,
+};
 #include <linux/module.h>
 #include "scsi_module.c"
 
diff -urN linux-2.5.69-bk7/drivers/scsi/g_NCR5380.h linux-2.5.69-bk8/drivers/scsi/g_NCR5380.h
--- linux-2.5.69-bk7/drivers/scsi/g_NCR5380.h	2003-05-04 16:52:49.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/g_NCR5380.h	2003-05-13 04:44:29.000000000 -0700
@@ -65,24 +65,6 @@
 #define CAN_QUEUE 16
 #endif
 
-#define GENERIC_NCR5380 {						\
-	.proc_info      = generic_NCR5380_proc_info,			\
-	.name           = "Generic NCR5380/NCR53C400 Scsi Driver",	\
-	.detect         = generic_NCR5380_detect,				\
-	.release        = generic_NCR5380_release_resources,		\
-	.info           = (void *)generic_NCR5380_info,			\
-	.queuecommand   = generic_NCR5380_queue_command,			\
-	.eh_abort_handler = generic_NCR5380_abort,				\
-	.eh_bus_reset_handler = generic_NCR5380_bus_reset,			\
-	.eh_device_reset_handler = generic_NCR5380_device_reset,		\
-	.eh_host_reset_handler = generic_NCR5380_host_reset,			\
-	.bios_param     = NCR5380_BIOSPARAM,				\
-	.can_queue      = CAN_QUEUE,					\
-        .this_id        = 7,						\
-        .sg_tablesize   = SG_ALL,						\
-	.cmd_per_lun    = CMD_PER_LUN ,					\
-        .use_clustering = DISABLE_CLUSTERING}
-
 #ifndef HOSTS_C
 
 #define __STRVAL(x) #x
diff -urN linux-2.5.69-bk7/drivers/scsi/gdth.c linux-2.5.69-bk8/drivers/scsi/gdth.c
--- linux-2.5.69-bk7/drivers/scsi/gdth.c	2003-05-04 16:53:32.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/gdth.c	2003-05-13 04:44:29.000000000 -0700
@@ -5790,7 +5790,34 @@
 
 #else
 
-static Scsi_Host_Template driver_template = GDTH;
+static Scsi_Host_Template driver_template = {
+#if LINUX_VERSION_CODE >= 0x02015F
+	.proc_name		= "gdth", 
+#else
+	.proc_dir		= &proc_scsi_gdth,
+#endif
+	.proc_info		= gdth_proc_info,
+	.name			= "GDT SCSI Disk Array Controller",
+	.detect			= gdth_detect, 
+	.release		= gdth_release,
+	.info			= gdth_info, 
+	.queuecommand		= gdth_queuecommand,
+	.eh_abort_handler	= gdth_eh_abort, 
+	.eh_device_reset_handler = gdth_eh_device_reset,
+	.eh_bus_reset_handler	= gdth_eh_bus_reset,
+	.eh_host_reset_handler	= gdth_eh_host_reset,
+	.bios_param		= gdth_bios_param,
+	.can_queue		= GDTH_MAXCMDS,
+	.this_id		= -1,
+	.sg_tablesize		= GDTH_MAXSG,
+	.cmd_per_lun		= GDTH_MAXC_P_L,
+	.unchecked_isa_dma	= 1,
+	.use_clustering		= ENABLE_CLUSTERING,
+#if LINUX_VERSION_CODE < 0x020501
+	.use_new_eh_code	= 1,
+#endif
+};
+
 #include "scsi_module.c"
 #ifndef MODULE
 __setup("gdth=", option_setup);
diff -urN linux-2.5.69-bk7/drivers/scsi/gdth.h linux-2.5.69-bk8/drivers/scsi/gdth.h
--- linux-2.5.69-bk7/drivers/scsi/gdth.h	2003-05-04 16:53:12.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/gdth.h	2003-05-13 04:44:29.000000000 -0700
@@ -983,29 +983,6 @@
 int gdth_eh_device_reset(Scsi_Cmnd *scp);
 int gdth_eh_bus_reset(Scsi_Cmnd *scp);
 int gdth_eh_host_reset(Scsi_Cmnd *scp);
-#define GDTH { .proc_name =      "gdth",                          \
-               .proc_info =      gdth_proc_info,                  \
-               .name =           "GDT SCSI Disk Array Controller",\
-               .detect =         gdth_detect,                     \
-               .release =        gdth_release,                    \
-               .info =           gdth_info,                       \
-               .command =        NULL,                            \
-               .queuecommand =   gdth_queuecommand,               \
-               .eh_abort_handler = gdth_eh_abort,                 \
-               .eh_device_reset_handler = gdth_eh_device_reset,   \
-               .eh_bus_reset_handler = gdth_eh_bus_reset,         \
-               .eh_host_reset_handler = gdth_eh_host_reset,       \
-               .abort =          NULL,                            \
-               .reset =          NULL,                            \
-               .bios_param =     gdth_bios_param,                 \
-               .can_queue =      GDTH_MAXCMDS,                    \
-               .this_id =        -1,                              \
-               .sg_tablesize =   GDTH_MAXSG,                      \
-               .cmd_per_lun =    GDTH_MAXC_P_L,                   \
-               .present =        0,                               \
-               .unchecked_isa_dma = 1,                            \
-               .use_clustering = ENABLE_CLUSTERING}
-
 #elif LINUX_VERSION_CODE >= 0x020322
 int gdth_bios_param(Disk *,kdev_t,int *);
 int gdth_proc_info(char *,char **,off_t,int,int,int);
@@ -1013,30 +990,6 @@
 int gdth_eh_device_reset(Scsi_Cmnd *scp);
 int gdth_eh_bus_reset(Scsi_Cmnd *scp);
 int gdth_eh_host_reset(Scsi_Cmnd *scp);
-#define GDTH { proc_name:       "gdth",                          \
-               proc_info:       gdth_proc_info,                  \
-               name:            "GDT SCSI Disk Array Controller",\
-               detect:          gdth_detect,                     \
-               release:         gdth_release,                    \
-               info:            gdth_info,                       \
-               command:         NULL,                            \
-               queuecommand:    gdth_queuecommand,               \
-               eh_abort_handler: gdth_eh_abort,                  \
-               eh_device_reset_handler: gdth_eh_device_reset,    \
-               eh_bus_reset_handler: gdth_eh_bus_reset,          \
-               eh_host_reset_handler: gdth_eh_host_reset,        \
-               abort:           gdth_abort,                      \
-               reset:           gdth_reset,                      \
-               bios_param:      gdth_bios_param,                 \
-               can_queue:       GDTH_MAXCMDS,                    \
-               this_id:         -1,                              \
-               sg_tablesize:    GDTH_MAXSG,                      \
-               cmd_per_lun:     GDTH_MAXC_P_L,                   \
-               present:         0,                               \
-               unchecked_isa_dma: 1,                             \
-               use_clustering:  ENABLE_CLUSTERING,               \
-               use_new_eh_code: 1       /* use new error code */ }    
-
 #elif LINUX_VERSION_CODE >= 0x02015F
 int gdth_bios_param(Disk *,kdev_t,int *);
 extern struct proc_dir_entry proc_scsi_gdth;
@@ -1045,76 +998,12 @@
 int gdth_eh_device_reset(Scsi_Cmnd *scp);
 int gdth_eh_bus_reset(Scsi_Cmnd *scp);
 int gdth_eh_host_reset(Scsi_Cmnd *scp);
-#define GDTH { proc_dir:        &proc_scsi_gdth,                 \
-               proc_info:       gdth_proc_info,                  \
-               name:            "GDT SCSI Disk Array Controller",\
-               detect:          gdth_detect,                     \
-               release:         gdth_release,                    \
-               info:            gdth_info,                       \
-               command:         NULL,                            \
-               queuecommand:    gdth_queuecommand,               \
-               eh_abort_handler: gdth_eh_abort,                  \
-               eh_device_reset_handler: gdth_eh_device_reset,    \
-               eh_bus_reset_handler: gdth_eh_bus_reset,          \
-               eh_host_reset_handler: gdth_eh_host_reset,        \
-               abort:           gdth_abort,                      \
-               reset:           gdth_reset,                      \
-               bios_param:      gdth_bios_param,                 \
-               can_queue:       GDTH_MAXCMDS,                    \
-               this_id:         -1,                              \
-               sg_tablesize:    GDTH_MAXSG,                      \
-               cmd_per_lun:     GDTH_MAXC_P_L,                   \
-               present:         0,                               \
-               unchecked_isa_dma: 1,                             \
-               use_clustering:  ENABLE_CLUSTERING,               \
-               use_new_eh_code: 1       /* use new error code */ }    
-
 #elif LINUX_VERSION_CODE >= 0x010300
 int gdth_bios_param(Disk *,kdev_t,int *);
 extern struct proc_dir_entry proc_scsi_gdth;
 int gdth_proc_info(char *,char **,off_t,int,int,int);
-#define GDTH { NULL, NULL,                              \
-                   &proc_scsi_gdth,                     \
-                   gdth_proc_info,                      \
-                   "GDT SCSI Disk Array Controller",    \
-                   gdth_detect,                         \
-                   gdth_release,                        \
-                   gdth_info,                           \
-                   NULL,                                \
-                   gdth_queuecommand,                   \
-                   gdth_abort,                          \
-                   gdth_reset,                          \
-                   NULL,                                \
-                   gdth_bios_param,                     \
-                   GDTH_MAXCMDS,                        \
-                   -1,                                  \
-                   GDTH_MAXSG,                          \
-                   GDTH_MAXC_P_L,                       \
-                   0,                                   \
-                   1,                                   \
-                   ENABLE_CLUSTERING}
-
 #else
 int gdth_bios_param(Disk *,int,int *);
-#define GDTH { NULL, NULL,                              \
-                   "GDT SCSI Disk Array Controller",    \
-                   gdth_detect,                         \
-                   gdth_release,                        \
-                   gdth_info,                           \
-                   NULL,                                \
-                   gdth_queuecommand,                   \
-                   gdth_abort,                          \
-                   gdth_reset,                          \
-                   NULL,                                \
-                   gdth_bios_param,                     \
-                   GDTH_MAXCMDS,                        \
-                   -1,                                  \
-                   GDTH_MAXSG,                          \
-                   GDTH_MAXC_P_L,                       \
-                   0,                                   \
-                   1,                                   \
-                   ENABLE_CLUSTERING}
 #endif
-
 #endif
 
diff -urN linux-2.5.69-bk7/drivers/scsi/hosts.c linux-2.5.69-bk8/drivers/scsi/hosts.c
--- linux-2.5.69-bk7/drivers/scsi/hosts.c	2003-05-04 16:53:00.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/hosts.c	2003-05-13 04:44:29.000000000 -0700
@@ -32,20 +32,20 @@
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/mm.h>
-#include <linux/proc_fs.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/list.h>
 #include <linux/completion.h>
-
-#define __KERNEL_SYSCALLS__
-
 #include <linux/unistd.h>
 #include <asm/dma.h>
 
 #include "scsi.h"
 #include "hosts.h"
 
+#include "scsi_priv.h"
+#include "scsi_logging.h"
+
+
 static LIST_HEAD(scsi_host_list);
 static spinlock_t scsi_host_list_lock = SPIN_LOCK_UNLOCKED;
 
@@ -193,62 +193,6 @@
 	return 0;
 }
 
-static int scsi_remove_legacy_host(struct Scsi_Host *shost)
-{
-	int error;
-
-	error = scsi_remove_host(shost);
-	if (!error)
-		(*shost->hostt->release)(shost);
-	return 0;
-}
-
-static int scsi_check_device_busy(struct scsi_device *sdev)
-{
-	struct Scsi_Host *shost = sdev->host;
-	struct scsi_cmnd *scmd;
-	unsigned long flags;
-
-	/*
-	 * Loop over all of the commands associated with the
-	 * device.  If any of them are busy, then set the state
-	 * back to inactive and bail.
-	 */
-	spin_lock_irqsave(&sdev->list_lock, flags);
-	list_for_each_entry(scmd, &sdev->cmd_list, list) {
-		if (scmd->request && scmd->request->rq_status != RQ_INACTIVE)
-			goto active;
-
-		/*
-		 * No, this device is really free.  Mark it as such, and
-		 * continue on.
-		 */
-		scmd->state = SCSI_STATE_DISCONNECTING;
-		if (scmd->request)
-			scmd->request->rq_status = RQ_SCSI_DISCONNECTING;
-	}
-	spin_unlock_irqrestore(&sdev->list_lock, flags);
-
-	return 0;
-
-active:
-	printk(KERN_ERR "SCSI device not inactive - rq_status=%d, target=%d, "
-			"pid=%ld, state=%d, owner=%d.\n",
-			scmd->request->rq_status, scmd->device->id,
-			scmd->pid, scmd->state, scmd->owner);
-
-	list_for_each_entry(sdev, &shost->my_devices, siblings) {
-		list_for_each_entry(scmd, &sdev->cmd_list, list) {
-			if (scmd->request->rq_status == RQ_SCSI_DISCONNECTING)
-				scmd->request->rq_status = RQ_INACTIVE;
-		}
-	}
-
-	spin_unlock_irqrestore(&sdev->list_lock, flags);
-	printk(KERN_ERR "Device busy???\n");
-	return 1;
-}
-
 /**
  * scsi_remove_host - check a scsi host for release and release
  * @shost:	a pointer to a scsi host to release
@@ -268,11 +212,9 @@
 	list_for_each_entry(sdev, &shost->my_devices, siblings)
 		sdev->online = FALSE;
 
-	list_for_each_entry(sdev, &shost->my_devices, siblings)
-		if (scsi_check_device_busy(sdev))
-			return 1;
-
+	scsi_proc_host_rm(shost);
 	scsi_forget_host(shost);
+	scsi_sysfs_remove_host(shost);
 	return 0;
 }
 
@@ -293,9 +235,11 @@
 	printk(KERN_INFO "scsi%d : %s\n", shost->host_no,
 			sht->info ? sht->info(shost) : sht->name);
 
-	if (dev) {
-		shost->host_gendev = dev;
-	}
+	error = scsi_sysfs_add_host(shost, dev);
+	if (error)
+		return error;
+
+	scsi_proc_host_add(shost);
 
 	scsi_scan_host(shost);
 			
@@ -314,6 +258,15 @@
  **/
 void scsi_unregister(struct Scsi_Host *shost)
 {
+	scsi_host_put(shost);
+}
+
+/**
+ * scsi_free_sdev - free a scsi hosts resources
+ * @shost:	scsi host to free 
+ **/
+void scsi_free_shost(struct Scsi_Host *shost)
+{
 	/* Remove shost from scsi_host_list */
 	spin_lock(&scsi_host_list_lock);
 	list_del(&shost->sh_list);
@@ -332,7 +285,6 @@
 	}
 
 	shost->hostt->present--;
-	scsi_proc_host_rm(shost);
 	scsi_destroy_command_freelist(shost);
 	kfree(shost);
 }
@@ -423,8 +375,14 @@
 	shost->use_clustering = shost_tp->use_clustering;
 	if (!blk_nohighio)
 		shost->highmem_io = shost_tp->highmem_io;
-
-	shost->max_sectors = shost_tp->max_sectors;
+	if (!shost_tp->max_sectors) {
+		/*
+		 * Driver imposes no hard sector transfer limit.
+		 * start at machine infinity initially.
+		 */
+		shost->max_sectors = SCSI_DEFAULT_MAX_SECTORS;
+	} else
+		shost->max_sectors = shost_tp->max_sectors;
 	shost->use_blk_tcq = shost_tp->use_blk_tcq;
 
 	spin_lock(&scsi_host_list_lock);
@@ -447,7 +405,8 @@
 	rval = scsi_setup_command_freelist(shost);
 	if (rval)
 		goto fail;
-	scsi_proc_host_add(shost);
+
+	scsi_sysfs_init_host(shost);
 
 	shost->eh_notify = &sem;
 	kernel_thread((int (*)(void *)) scsi_error_handler, (void *) shost, 0);
@@ -525,7 +484,7 @@
  **/
 int scsi_unregister_host(Scsi_Host_Template *shost_tp)
 {
-	scsi_tp_for_each_host(shost_tp, scsi_remove_legacy_host);
+	scsi_tp_for_each_host(shost_tp, scsi_remove_host);
 	return 0;
 
 }
@@ -576,15 +535,26 @@
 }
 
 /**
+ * *scsi_host_get - inc a Scsi_Host ref count
+ * @shost:	Pointer to Scsi_Host to inc.
+ **/
+void scsi_host_get(struct Scsi_Host *shost)
+{
+
+	get_device(&shost->host_gendev);
+	class_device_get(&shost->class_dev);
+	return;
+}
+
+/**
  * *scsi_host_put - dec a Scsi_Host ref count
  * @shost:	Pointer to Scsi_Host to dec.
  **/
 void scsi_host_put(struct Scsi_Host *shost)
 {
 
-	/* XXX Get list lock */
-	/* XXX dec ref count */
-	/* XXX Release list lock */
+	class_device_put(&shost->class_dev);
+	put_device(&shost->host_gendev);
 	return;
 }
 
diff -urN linux-2.5.69-bk7/drivers/scsi/hosts.h linux-2.5.69-bk8/drivers/scsi/hosts.h
--- linux-2.5.69-bk7/drivers/scsi/hosts.h	2003-05-04 16:53:09.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/hosts.h	2003-05-13 04:44:29.000000000 -0700
@@ -482,9 +482,10 @@
     unsigned int max_host_blocked;
 
     /* 
-     * Support for driverfs filesystem
+     * Support for sysfs
      */
-    struct device *host_gendev;
+    struct device host_gendev;
+    struct class_device class_dev;
 
     /*
      * We should ensure that this is aligned, both for better performance
@@ -495,8 +496,11 @@
         __attribute__ ((aligned (sizeof(unsigned long))));
 };
 
-#define	to_scsi_host(d)	d->driver_data	/* Major logical breakage, but we compile again... */
-	
+#define		dev_to_shost(d)		\
+	container_of(d, struct Scsi_Host, host_gendev)
+#define		class_to_shost(d)	\
+	container_of(d, struct Scsi_Host, class_dev)
+
 /*
  * These two functions are used to allocate and free a pseudo device
  * which will connect to the host adapter itself rather than any
@@ -510,6 +514,7 @@
 extern void scsi_unblock_requests(struct Scsi_Host *);
 extern void scsi_block_requests(struct Scsi_Host *);
 extern void scsi_report_bus_reset(struct Scsi_Host *, int);
+extern void scsi_report_device_reset(struct Scsi_Host *, int, int);
 
 static inline void scsi_assign_lock(struct Scsi_Host *shost, spinlock_t *lock)
 {
@@ -519,21 +524,14 @@
 static inline void scsi_set_device(struct Scsi_Host *shost,
                                    struct device *dev)
 {
-        shost->host_gendev = dev;
+        shost->host_gendev.parent = dev;
 }
 
 static inline struct device *scsi_get_device(struct Scsi_Host *shost)
 {
-        return shost->host_gendev;
+        return shost->host_gendev.parent;
 }
 
-/*
- * Prototypes for functions/data in scsi_scan.c
- */
-extern void scsi_scan_host(struct Scsi_Host *);
-extern void scsi_forget_host(struct Scsi_Host *);
-
-
 struct Scsi_Device_Template
 {
     struct list_head list;
@@ -572,16 +570,8 @@
 extern int scsi_register_host(Scsi_Host_Template *);
 extern int scsi_unregister_host(Scsi_Host_Template *);
 
-extern struct Scsi_Host *scsi_host_get_next(struct Scsi_Host *);
 extern struct Scsi_Host *scsi_host_hn_get(unsigned short);
 extern void scsi_host_put(struct Scsi_Host *);
-extern void scsi_host_init(void);
-
-/*
- * host_busy inc/dec/test functions
- */
-extern void scsi_host_busy_inc(struct Scsi_Host *, Scsi_Device *);
-extern void scsi_host_busy_dec_and_test(struct Scsi_Host *, Scsi_Device *);
 
 /**
  * scsi_find_device - find a device given the host
@@ -601,30 +591,4 @@
         return NULL;
 }
 
-/*
- * sysfs support
- */
-extern int scsi_upper_driver_register(struct Scsi_Device_Template *);
-extern void scsi_upper_driver_unregister(struct Scsi_Device_Template *);
-
-extern struct class shost_class;
-
 #endif
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-indent-level: 4
- * c-brace-imaginary-offset: 0
- * c-brace-offset: -4
- * c-argdecl-indent: 4
- * c-label-offset: -4
- * c-continued-statement-offset: 4
- * c-continued-brace-offset: 0
- * indent-tabs-mode: nil
- * tab-width: 8
- * End:
- */
diff -urN linux-2.5.69-bk7/drivers/scsi/ibmmca.c linux-2.5.69-bk8/drivers/scsi/ibmmca.c
--- linux-2.5.69-bk7/drivers/scsi/ibmmca.c	2003-05-04 16:53:02.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/ibmmca.c	2003-05-13 04:44:29.000000000 -0700
@@ -2484,6 +2484,21 @@
 
 __setup("ibmmcascsi=", option_setup);
 
-static Scsi_Host_Template driver_template = IBMMCA;
-
+static Scsi_Host_Template driver_template = {
+          .proc_name      = "ibmmca",
+	  .proc_info	  = ibmmca_proc_info,
+          .name           = "IBM SCSI-Subsystem",
+          .detect         = ibmmca_detect,
+          .release        = ibmmca_release,
+          .command        = ibmmca_command,
+          .queuecommand   = ibmmca_queuecommand,
+	  .eh_abort_handler = ibmmca_abort,
+	  .eh_host_reset_handler = ibmmca_host_reset,
+          .bios_param     = ibmmca_biosparam,
+          .can_queue      = 16,
+          .this_id        = 7,
+          .sg_tablesize   = 16,
+          .cmd_per_lun    = 1,
+          .use_clustering = ENABLE_CLUSTERING,
+};
 #include "scsi_module.c"
diff -urN linux-2.5.69-bk7/drivers/scsi/ibmmca.h linux-2.5.69-bk8/drivers/scsi/ibmmca.h
--- linux-2.5.69-bk7/drivers/scsi/ibmmca.h	2003-05-04 16:53:35.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/ibmmca.h	2003-05-13 04:44:29.000000000 -0700
@@ -20,29 +20,4 @@
 static int ibmmca_host_reset (Scsi_Cmnd *);
 static int ibmmca_biosparam (struct scsi_device *, struct block_device *, sector_t, int *);
 
-/*
- * 2/8/98
- * Note to maintainer of IBMMCA.  Do not change this initializer back to
- * the old format.  Please ask eric@andante.jic.com if you have any questions
- * about this, but it will break things in the future.
- */
-#define IBMMCA {                                                      \
-          .proc_name      = "ibmmca",             /*proc_name*/         \
-	  .proc_info	  = ibmmca_proc_info,     /*proc info fn*/      \
-          .name           = "IBM SCSI-Subsystem", /*name*/              \
-          .detect         = ibmmca_detect,        /*detect fn*/         \
-          .release        = ibmmca_release,       /*release fn*/        \
-          .command        = ibmmca_command,       /*command fn*/        \
-          .queuecommand   = ibmmca_queuecommand,  /*queuecommand fn*/   \
-	  .eh_abort_handler = ibmmca_abort,         /*abort fn*/          \
-	  .eh_host_reset_handler = ibmmca_host_reset,         /*reset fn*/          \
-          .bios_param     = ibmmca_biosparam,     /*bios fn*/           \
-          .can_queue      = 16,                   /*can_queue*/         \
-          .this_id        = 7,                    /*set by detect*/     \
-          .sg_tablesize   = 16,                   /*sg_tablesize*/      \
-          .cmd_per_lun    = 1,                    /*cmd_per_lun*/       \
-          .unchecked_isa_dma = 0,                 /*32-Bit Busmaster */ \
-          .use_clustering = ENABLE_CLUSTERING     /*use_clustering*/    \
-          }
-
 #endif /* _IBMMCA_H */
diff -urN linux-2.5.69-bk7/drivers/scsi/imm.c linux-2.5.69-bk8/drivers/scsi/imm.c
--- linux-2.5.69-bk7/drivers/scsi/imm.c	2003-05-04 16:53:56.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/imm.c	2003-05-13 04:44:29.000000000 -0700
@@ -107,7 +107,23 @@
  *                   Parallel port probing routines                        *
  ***************************************************************************/
 
-static Scsi_Host_Template driver_template = IMM;
+static Scsi_Host_Template driver_template = {
+	.proc_name			= "imm",
+	.proc_info			= imm_proc_info,
+	.name				= "Iomega VPI2 (imm) interface",
+	.detect				= imm_detect,
+	.release			= imm_release,
+	.command			= imm_command,
+	.queuecommand			= imm_queuecommand,
+	.eh_abort_handler               = imm_abort,
+	.eh_bus_reset_handler           = imm_reset,
+	.eh_host_reset_handler          = imm_reset, 
+	.bios_param		        = imm_biosparam,
+	.this_id			= 7,
+	.sg_tablesize			= SG_ALL,
+	.cmd_per_lun			= 1,
+	.use_clustering			= ENABLE_CLUSTERING,
+};
 #include  "scsi_module.c"
 
 int imm_detect(Scsi_Host_Template * host)
diff -urN linux-2.5.69-bk7/drivers/scsi/imm.h linux-2.5.69-bk8/drivers/scsi/imm.h
--- linux-2.5.69-bk7/drivers/scsi/imm.h	2003-05-04 16:52:48.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/imm.h	2003-05-13 04:44:29.000000000 -0700
@@ -163,21 +163,4 @@
 int imm_biosparam(struct scsi_device *, struct block_device *,
 		sector_t, int *);
 
-#define IMM {	.proc_name			= "imm",			\
-		.proc_info			= imm_proc_info,		\
-		.name				= "Iomega VPI2 (imm) interface",\
-		.detect				= imm_detect,		\
-		.release			= imm_release,		\
-		.command			= imm_command,		\
-		.queuecommand			= imm_queuecommand,	\
-                .eh_abort_handler               = imm_abort,              \
-                .eh_device_reset_handler        = NULL,                   \
-                .eh_bus_reset_handler           = imm_reset,              \
-                .eh_host_reset_handler          = imm_reset,              \
-		.bios_param		        = imm_biosparam,		\
-		.this_id			= 7,			\
-		.sg_tablesize			= SG_ALL,			\
-		.cmd_per_lun			= 1,			\
-		.use_clustering			= ENABLE_CLUSTERING	\
-}
 #endif				/* _IMM_H */
diff -urN linux-2.5.69-bk7/drivers/scsi/in2000.c linux-2.5.69-bk8/drivers/scsi/in2000.c
--- linux-2.5.69-bk7/drivers/scsi/in2000.c	2003-05-04 16:53:36.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/in2000.c	2003-05-13 04:44:29.000000000 -0700
@@ -2312,5 +2312,22 @@
 MODULE_LICENSE("GPL");
 
 
-static Scsi_Host_Template driver_template = IN2000;
+static Scsi_Host_Template driver_template = {
+	.proc_name       		= "in2000",
+	.proc_info       		= in2000_proc_info,
+	.name            		= "Always IN2000",
+	.detect          		= in2000_detect, 
+	.release			= in2000_release,
+	.queuecommand    		= in2000_queuecommand,
+	.eh_abort_handler		= in2000_abort,
+	.eh_bus_reset_handler		= in2000_bus_reset,
+	.eh_device_reset_handler	= in2000_device_reset,
+	.eh_host_reset_handler	= in2000_host_reset, 
+	.bios_param      		= in2000_biosparam, 
+	.can_queue       		= IN2000_CAN_Q,
+	.this_id         		= IN2000_HOST_ID,
+	.sg_tablesize    		= IN2000_SG,
+	.cmd_per_lun     		= IN2000_CPL,
+	.use_clustering  		= DISABLE_CLUSTERING,
+};
 #include "scsi_module.c"
diff -urN linux-2.5.69-bk7/drivers/scsi/in2000.h linux-2.5.69-bk8/drivers/scsi/in2000.h
--- linux-2.5.69-bk7/drivers/scsi/in2000.h	2003-05-04 16:52:48.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/in2000.h	2003-05-13 04:44:29.000000000 -0700
@@ -414,22 +414,4 @@
 #define IN2000_CPL      2
 #define IN2000_HOST_ID  7
 
-#define IN2000 {  .proc_name       		= "in2000",	     /* name of /proc/scsi directory entry */ \
-                  .proc_info       		= in2000_proc_info,    /* pointer to proc info function */ \
-                  .name            		= "Always IN2000",     /* device name */ \
-                  .detect          		= in2000_detect,       /* returns number of in2000's found */ \
-                  .release			= in2000_release,	     /* release the in2000 controller */ \
-                  .queuecommand    		= in2000_queuecommand, /* queue scsi command, don't wait */ \
-                  .eh_abort_handler		= in2000_abort,        /* abort current command */ \
-                  .eh_bus_reset_handler		= in2000_bus_reset,    /* reset scsi bus */ \
-                  .eh_device_reset_handler	= in2000_device_reset, /* reset scsi device */ \
-                  .eh_host_reset_handler	= in2000_host_reset,   /* reset scsi hba */ \
-                  .bios_param      		= in2000_biosparam,    /* figures out BIOS parameters for lilo, etc */ \
-                  .can_queue       		= IN2000_CAN_Q,        /* max commands we can queue up */ \
-                  .this_id         		= IN2000_HOST_ID,      /* host-adapter scsi id */ \
-                  .sg_tablesize    		= IN2000_SG,           /* scatter-gather table size */ \
-                  .cmd_per_lun     		= IN2000_CPL,          /* commands per lun */ \
-                  .use_clustering  		= DISABLE_CLUSTERING,  /* ENABLE_CLUSTERING may speed things up */ \
-                }
-
 #endif /* IN2000_H */
diff -urN linux-2.5.69-bk7/drivers/scsi/ini9100u.c linux-2.5.69-bk8/drivers/scsi/ini9100u.c
--- linux-2.5.69-bk7/drivers/scsi/ini9100u.c	2003-05-04 16:53:08.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/ini9100u.c	2003-05-13 04:44:29.000000000 -0700
@@ -141,7 +141,23 @@
 unsigned int i91u_debug = DEBUG_DEFAULT;
 #endif
 
-static Scsi_Host_Template driver_template = INI9100U;
+static Scsi_Host_Template driver_template = {
+	.proc_name	= "INI9100U",
+	.proc_info	= "INI9100U",
+	.name		= i91u_REVID,
+	.detect		= i91u_detect,
+	.release	= i91u_release,
+	.command	= i91u_command,
+	.queuecommand	= i91u_queue,
+	.abort		= i91u_abort,
+	.reset		= i91u_reset,
+	.bios_param	= i91u_biosparam,
+	.can_queue	= 1,
+	.this_id	= 1,
+	.sg_tablesize	= SG_ALL,
+	.cmd_per_lun 	= 1,
+	.use_clustering	= ENABLE_CLUSTERING,
+};
 #include "scsi_module.c"
 
 char *i91uCopyright = "Copyright (C) 1996-98";
diff -urN linux-2.5.69-bk7/drivers/scsi/ini9100u.h linux-2.5.69-bk8/drivers/scsi/ini9100u.h
--- linux-2.5.69-bk7/drivers/scsi/ini9100u.h	2003-05-04 16:53:31.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/ini9100u.h	2003-05-13 04:44:29.000000000 -0700
@@ -87,34 +87,6 @@
 
 #define i91u_REVID "Initio INI-9X00U/UW SCSI device driver; Revision: 1.03g"
 
-#define INI9100U	{ \
-	.next		= NULL,						\
-	.module		= NULL,						\
-	.proc_name	= "INI9100U", \
-	.proc_info	= NULL,				\
-	.name		= i91u_REVID, \
-	.detect		= i91u_detect, \
-	.release	= i91u_release, \
-	.info		= NULL,					\
-	.command	= i91u_command, \
-	.queuecommand	= i91u_queue, \
- 	.eh_strategy_handler = NULL, \
- 	.eh_abort_handler = NULL, \
- 	.eh_device_reset_handler = NULL, \
- 	.eh_bus_reset_handler = NULL, \
- 	.eh_host_reset_handler = NULL, \
-	.abort		= i91u_abort, \
-	.reset		= i91u_reset, \
-	.bios_param	= i91u_biosparam, \
-	.can_queue	= 1, \
-	.this_id	= 1, \
-	.sg_tablesize	= SG_ALL, \
-	.cmd_per_lun 	= 1, \
-	.present	= 0, \
-	.unchecked_isa_dma = 0, \
-	.use_clustering	= ENABLE_CLUSTERING, \
-}
-
 #define VIRT_TO_BUS(i)  (unsigned int) virt_to_bus((void *)(i))
 #define ULONG   unsigned long
 #define USHORT  unsigned short
diff -urN linux-2.5.69-bk7/drivers/scsi/inia100.c linux-2.5.69-bk8/drivers/scsi/inia100.c
--- linux-2.5.69-bk7/drivers/scsi/inia100.c	2003-05-04 16:53:08.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/inia100.c	2003-05-13 04:44:29.000000000 -0700
@@ -91,7 +91,21 @@
 #include "hosts.h"
 #include "inia100.h"
 
-static Scsi_Host_Template driver_template = INIA100;
+static Scsi_Host_Template driver_template = {
+	.proc_name	= "inia100",
+	.name		= inia100_REVID,
+	.detect		= inia100_detect,
+	.release	= inia100_release,
+	.queuecommand	= inia100_queue,
+	.eh_abort_handler = inia100_abort,
+	.eh_bus_reset_handler	= inia100_bus_reset,
+	.eh_device_reset_handler = inia100_device_reset,
+	.can_queue	= 1,
+	.this_id	= 1,
+	.sg_tablesize	= SG_ALL,
+	.cmd_per_lun 	= 1,
+	.use_clustering	= ENABLE_CLUSTERING,
+};
 #include "scsi_module.c"
 
 #define ORC_RDWORD(x,y)         (short)(inl((int)((ULONG)((ULONG)x+(UCHAR)y)) ))
diff -urN linux-2.5.69-bk7/drivers/scsi/inia100.h linux-2.5.69-bk8/drivers/scsi/inia100.h
--- linux-2.5.69-bk7/drivers/scsi/inia100.h	2003-05-04 16:52:48.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/inia100.h	2003-05-13 04:44:29.000000000 -0700
@@ -76,24 +76,6 @@
 
 #define inia100_REVID "Initio INI-A100U2W SCSI device driver; Revision: 1.02d"
 
-#define INIA100	{ \
-	.proc_name	= "inia100", \
-	.name		= inia100_REVID, \
-	.detect		= inia100_detect, \
-	.release	= inia100_release, \
-	.queuecommand	= inia100_queue, \
-	.eh_abort_handler = inia100_abort, \
-	.eh_bus_reset_handler	= inia100_bus_reset, \
-	.eh_device_reset_handler = inia100_device_reset, \
-	.can_queue	= 1, \
-	.this_id	= 1, \
-	.sg_tablesize	= SG_ALL, \
-	.cmd_per_lun 	= 1, \
-	.present	= 0, \
-	.unchecked_isa_dma = 0, \
-	.use_clustering	= ENABLE_CLUSTERING, \
-}
-
 #define ULONG   unsigned long
 #define PVOID   void *
 #define USHORT  unsigned short
diff -urN linux-2.5.69-bk7/drivers/scsi/ips.c linux-2.5.69-bk8/drivers/scsi/ips.c
--- linux-2.5.69-bk7/drivers/scsi/ips.c	2003-05-04 16:52:48.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/ips.c	2003-05-13 04:44:29.000000000 -0700
@@ -238,20 +238,43 @@
 static const char   ips_name[] = "ips";
 static struct Scsi_Host *ips_sh[IPS_MAX_ADAPTERS];   /* Array of host controller structures */
 static ips_ha_t    *ips_ha[IPS_MAX_ADAPTERS];        /* Array of HA structures */
-static unsigned int ips_next_controller = 0;
-static unsigned int ips_num_controllers = 0;
-static unsigned int ips_released_controllers = 0;
+static unsigned int ips_next_controller;
+static unsigned int ips_num_controllers;
+static unsigned int ips_released_controllers;
 static int          ips_hotplug;
 static int          ips_cmd_timeout = 60;
 static int          ips_reset_timeout = 60 * 5;
 static int          ips_force_memio = 1;             /* Always use Memory Mapped I/O    */
 static int          ips_force_i2o = 1;               /* Always use I2O command delivery */
 static int          ips_ioctlsize = IPS_IOCTL_SIZE;  /* Size of the ioctl buffer        */
-static int          ips_cd_boot = 0;                 /* Booting from Manager CD         */
+static int          ips_cd_boot;                     /* Booting from Manager CD         */
 static char        *ips_FlashData = NULL;            /* CD Boot - Flash Data Buffer      */
-static long         ips_FlashDataInUse = 0;          /* CD Boot - Flash Data In Use Flag */
+static long         ips_FlashDataInUse;              /* CD Boot - Flash Data In Use Flag */
 static uint32_t     MaxLiteCmds = 32;                /* Max Active Cmds for a Lite Adapter */  
-static Scsi_Host_Template ips_driver_template = IPS;
+static Scsi_Host_Template ips_driver_template = {
+	.detect			= ips_detect,
+	.release		= ips_release,
+	.info			= ips_info,
+	.queuecommand		= ips_queue,
+	.eh_abort_handler	= ips_eh_abort,
+	.eh_host_reset_handler	= ips_eh_reset,
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
+	.slave_configure	= ips_slave_configure,
+#else
+	.select_queue_depths	= ips_select_queue_depth,
+#endif
+	.bios_param		= ips_biosparam,
+	.this_id		= -1,
+	.sg_tablesize		= IPS_MAX_SG,
+	.cmd_per_lun		= 3,
+	.use_clustering		= ENABLE_CLUSTERING,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,20) || (defined CONFIG_HIGHIO)
+	.highmem_io		= 1,
+#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+	.use_new_eh_code	= 1,
+#endif
+};
 
 IPS_DEFINE_COMPAT_TABLE( Compatable );               /* Version Compatability Table      */
 
@@ -426,8 +449,8 @@
 static void ips_enable_int_copperhead(ips_ha_t *);
 static void ips_enable_int_copperhead_memio(ips_ha_t *);
 static void ips_enable_int_morpheus(ips_ha_t *);
-static void ips_intr_copperhead(ips_ha_t *);
-static void ips_intr_morpheus(ips_ha_t *);
+static int ips_intr_copperhead(ips_ha_t *);
+static int ips_intr_morpheus(ips_ha_t *);
 static void ips_next(ips_ha_t *, int);
 static void ipsintr_blocking(ips_ha_t *, struct ips_scb *);
 static void ipsintr_done(ips_ha_t *, struct ips_scb *);
@@ -562,8 +585,6 @@
          printk( KERN_WARNING "ERROR: Can't Allocate Large Buffer for Flashing\n" );
       }
    }                                                                               
-   if (!pci_present())
-      return (0);
 
    SHT->proc_info = ips_proc_info;
    SHT->proc_name = "ips";
@@ -682,13 +703,13 @@
    scb->cmd.flush_cache.reserved3 = 0;
    scb->cmd.flush_cache.reserved4 = 0;
 
-   printk(KERN_NOTICE "(%s%d) Flushing Cache.\n", ips_name, ha->host_num);
+   IPS_PRINTK(KERN_WARNING, ha->pcidev, "Flushing Cache.\n");
 
    /* send command */
    if (ips_send_wait(ha, scb, ips_cmd_timeout, IPS_INTR_ON) == IPS_FAILURE)
-      printk(KERN_NOTICE "(%s%d) Incomplete Flush.\n", ips_name, ha->host_num);
+      IPS_PRINTK(KERN_WARNING, ha->pcidev, "Incomplete Flush.\n");
 
-   printk(KERN_NOTICE "(%s%d) Flushing Complete.\n", ips_name, ha->host_num);
+   IPS_PRINTK(KERN_WARNING, ha->pcidev, "Flushing Complete.\n");
 
    ips_sh[i] = NULL;
    ips_ha[i] = NULL;
@@ -755,13 +776,13 @@
       scb->cmd.flush_cache.reserved3 = 0;
       scb->cmd.flush_cache.reserved4 = 0;
 
-      printk(KERN_NOTICE "(%s%d) Flushing Cache.\n", ips_name, ha->host_num);
+      IPS_PRINTK(KERN_WARNING, ha->pcidev, "Flushing Cache.\n");
 
       /* send command */
       if (ips_send_wait(ha, scb, ips_cmd_timeout, IPS_INTR_ON) == IPS_FAILURE)
-         printk(KERN_NOTICE "(%s%d) Incomplete Flush.\n", ips_name, ha->host_num);
+         IPS_PRINTK(KERN_WARNING, ha->pcidev, "Incomplete Flush.\n");
       else
-         printk(KERN_NOTICE "(%s%d) Flushing Complete.\n", ips_name, ha->host_num);
+         IPS_PRINTK(KERN_WARNING, ha->pcidev, "Flushing Complete.\n");
    }
 
    return (NOTIFY_OK);
@@ -911,7 +932,7 @@
       /* Attempt the flush command */
       ret = ips_send_wait(ha, scb, ips_cmd_timeout, IPS_INTR_IORL);
       if (ret == IPS_SUCCESS) {
-         printk(KERN_NOTICE "(%s%d) Reset Request - Flushed Cache\n", ips_name, ha->host_num);
+         IPS_PRINTK(KERN_NOTICE, ha->pcidev, "Reset Request - Flushed Cache\n");
          return (SUCCESS);
          }
    }
@@ -925,16 +946,14 @@
     * command must have already been sent
     * reset the controller
     */
-   printk(KERN_NOTICE "(%s%d) Resetting controller.\n",
-          ips_name, ha->host_num);
+   IPS_PRINTK(KERN_NOTICE, ha->pcidev, "Resetting controller.\n");
    ret = (*ha->func.reset)(ha);
 
    if (!ret) {
       Scsi_Cmnd *scsi_cmd;
 
-      printk(KERN_NOTICE
-             "(%s%d) Controller reset failed - controller now offline.\n",
-             ips_name, ha->host_num);
+      IPS_PRINTK(KERN_NOTICE, ha->pcidev,
+                 "Controller reset failed - controller now offline.\n");
 
       /* Now fail all of the active commands */
       DEBUG_VAR(1, "(%s%d) Failing active commands",
@@ -962,9 +981,8 @@
    if (!ips_clear_adapter(ha, IPS_INTR_IORL)) {
       Scsi_Cmnd *scsi_cmd;
 
-      printk(KERN_NOTICE
-             "(%s%d) Controller reset failed - controller now offline.\n",
-             ips_name, ha->host_num);
+      IPS_PRINTK(KERN_NOTICE, ha->pcidev,
+                 "Controller reset failed - controller now offline.\n");
 
       /* Now fail all of the active commands */
       DEBUG_VAR(1, "(%s%d) Failing active commands",
@@ -1269,7 +1287,8 @@
    ips_ha_t         *ha;
    unsigned long     cpu_flags;
    struct Scsi_Host *host;
-
+   int       irqstatus;
+   
    METHOD_TRACE("do_ipsintr", 2);
 
    ha = (ips_ha_t *) dev_id;
@@ -1289,13 +1308,13 @@
       return IRQ_HANDLED;
    }
 
-   (*ha->func.intr)(ha);
+   irqstatus = (*ha->func.intr)(ha);
 
    IPS_UNLOCK_RESTORE(host->host_lock, cpu_flags);
 
    /* start the next command */
    ips_next(ha, IPS_INTR_ON);
-   return IRQ_HANDLED;
+   return IRQ_RETVAL(irqstatus);
 }
 
 /****************************************************************************/
@@ -1309,7 +1328,7 @@
 /*   ASSUMES interrupts are disabled                                        */
 /*                                                                          */
 /****************************************************************************/
-void
+int
 ips_intr_copperhead(ips_ha_t *ha) {
    ips_stat_t       *sp;
    ips_scb_t        *scb;
@@ -1319,10 +1338,10 @@
    METHOD_TRACE("ips_intr", 2);
 
    if (!ha)
-      return;
+      return 0;
 
    if (!ha->active)
-      return;
+      return 0;
 
    intrstatus = (*ha->func.isintr)(ha);
 
@@ -1331,7 +1350,7 @@
        * Unexpected/Shared interrupt
        */
 
-      return;
+      return 0;
    }
 
    while (TRUE) {
@@ -1358,6 +1377,7 @@
        */
       (*scb->callback) (ha, scb);
    } /* end while */
+   return 1;
 }
 
 /****************************************************************************/
@@ -1371,7 +1391,7 @@
 /*   ASSUMES interrupts are disabled                                        */
 /*                                                                          */
 /****************************************************************************/
-void
+int
 ips_intr_morpheus(ips_ha_t *ha) {
    ips_stat_t       *sp;
    ips_scb_t        *scb;
@@ -1381,10 +1401,10 @@
    METHOD_TRACE("ips_intr_morpheus", 2);
 
    if (!ha)
-      return;
+      return 0;
 
    if (!ha->active)
-      return;
+      return 0;
 
    intrstatus = (*ha->func.isintr)(ha);
 
@@ -1393,7 +1413,7 @@
        * Unexpected/Shared interrupt
        */
 
-      return;
+      return 0;
    }
 
    while (TRUE) {
@@ -1411,8 +1431,7 @@
          break;
 
       if (cstatus.fields.command_id > (IPS_MAX_CMDS - 1)) {
-         printk(KERN_WARNING "(%s%d) Spurious interrupt; no ccb.\n",
-                ips_name, ha->host_num);
+         IPS_PRINTK(KERN_WARNING, ha->pcidev, "Spurious interrupt; no ccb.\n");
 
          continue;
       }
@@ -1426,6 +1445,7 @@
        */
       (*scb->callback) (ha, scb);
    } /* end while */
+   return 1;
 }
 
 /****************************************************************************/
@@ -1728,7 +1748,7 @@
       if(pt->CoppCP.cmd.flashfw.count + ha->flash_datasize >
         (PAGE_SIZE << ha->flash_order)){
          ips_free_flash_copperhead(ha);
-         printk(KERN_WARNING "failed size sanity check\n");
+         IPS_PRINTK(KERN_WARNING, ha->pcidev, "failed size sanity check\n");
          return IPS_FAILURE;
       }
    }
@@ -2400,6 +2420,7 @@
          minor    = buffer[0x1fe + 0xC0];  /* Offset 0x1fe after the header (0xc0) */
          subminor = buffer[0x1fd + 0xC0];  /* Offset 0x1fd after the header (0xc0) */
       } else {
+         kfree(buffer);
          return;
       }
 
@@ -2450,15 +2471,13 @@
    ips_ffdc_reset(ha, IPS_INTR_IORL);
 
    if (!ips_read_config(ha, IPS_INTR_IORL)) {
-      printk(KERN_WARNING "(%s%d) unable to read config from controller.\n",
-             ips_name, ha->host_num);
+      IPS_PRINTK(KERN_WARNING, ha->pcidev, "unable to read config from controller.\n");
 
       return (0);
    } /* end if */
 
    if (!ips_read_adapter_status(ha, IPS_INTR_IORL)) {
-      printk(KERN_WARNING "(%s%d) unable to read controller status.\n",
-             ips_name, ha->host_num);
+      IPS_PRINTK(KERN_WARNING, ha->pcidev, "unable to read controller status.\n");
 
       return (0);
    }
@@ -2467,16 +2486,14 @@
    ips_identify_controller(ha);
 
    if (!ips_read_subsystem_parameters(ha, IPS_INTR_IORL)) {
-      printk(KERN_WARNING "(%s%d) unable to read subsystem parameters.\n",
-             ips_name, ha->host_num);
+      IPS_PRINTK(KERN_WARNING, ha->pcidev, "unable to read subsystem parameters.\n");
 
       return (0);
    }
 
    /* write nvram user page 5 */
    if (!ips_write_driver_status(ha, IPS_INTR_IORL)) {
-      printk(KERN_WARNING "(%s%d) unable to write driver info to controller.\n",
-             ips_name, ha->host_num);
+      IPS_PRINTK(KERN_WARNING, ha->pcidev, "unable to write driver info to controller.\n");
 
       return (0);
    }
@@ -3233,16 +3250,14 @@
    METHOD_TRACE("ipsintr_done", 2);
 
    if (!scb) {
-      printk(KERN_WARNING "(%s%d) Spurious interrupt; scb NULL.\n",
-             ips_name, ha->host_num);
+      IPS_PRINTK(KERN_WARNING, ha->pcidev, "Spurious interrupt; scb NULL.\n");
 
       return ;
    }
 
    if (scb->scsi_cmd == NULL) {
       /* unexpected interrupt */
-      printk(KERN_WARNING "(%s%d) Spurious interrupt; scsi_cmd not set.\n",
-             ips_name, ha->host_num);
+      IPS_PRINTK(KERN_WARNING, ha->pcidev, "Spurious interrupt; scsi_cmd not set.\n");
 
       return;
    }
@@ -4677,8 +4692,8 @@
    }
 
    if (PostByte[0] < IPS_GOOD_POST_STATUS) {
-      printk(KERN_WARNING "(%s%d) reset controller fails (post status %x %x).\n",
-             ips_name, ha->host_num, PostByte[0], PostByte[1]);
+      IPS_PRINTK(KERN_WARNING, ha->pcidev, "reset controller fails (post status %x %x).\n",
+                 PostByte[0], PostByte[1]);
 
       return (0);
    }
@@ -4769,8 +4784,8 @@
    }
 
    if (PostByte[0] < IPS_GOOD_POST_STATUS) {
-      printk(KERN_WARNING "(%s%d) reset controller fails (post status %x %x).\n",
-             ips_name, ha->host_num, PostByte[0], PostByte[1]);
+      IPS_PRINTK(KERN_WARNING, ha->pcidev, "reset controller fails (post status %x %x).\n",
+                 PostByte[0], PostByte[1]);
 
       return (0);
    }
@@ -4856,8 +4871,7 @@
 
    if (i >= 45) {
       /* error occurred */
-      printk(KERN_WARNING "(%s%d) timeout waiting for post.\n",
-             ips_name, ha->host_num);
+      IPS_PRINTK(KERN_WARNING, ha->pcidev, "timeout waiting for post.\n");
 
       return (0);
    }
@@ -4865,7 +4879,7 @@
    Post = readl(ha->mem_ptr + IPS_REG_I960_MSG0);
 
    if (Post == 0x4F00) {                          /* If Flashing the Battery PIC         */
-       printk(KERN_WARNING "Flashing Battery PIC, Please wait ...\n" );
+      IPS_PRINTK(KERN_WARNING, ha->pcidev, "Flashing Battery PIC, Please wait ...\n" );
 
        /* Clear the interrupt bit */
        Isr = (uint32_t) IPS_BIT_I960_MSG0I;
@@ -4880,8 +4894,7 @@
        }
 
        if (i >= 120) {
-          printk(KERN_WARNING "(%s%d) timeout waiting for Battery PIC Flash\n",
-                 ips_name, ha->host_num);
+          IPS_PRINTK(KERN_WARNING, ha->pcidev, "timeout waiting for Battery PIC Flash\n");
           return (0);
        }
 
@@ -4892,8 +4905,7 @@
    writel(Isr, ha->mem_ptr + IPS_REG_I2O_HIR);
 
    if (Post < (IPS_GOOD_POST_STATUS << 8)) {
-      printk(KERN_WARNING "(%s%d) reset controller fails (post status %x).\n",
-             ips_name, ha->host_num, Post);
+      IPS_PRINTK(KERN_WARNING, ha->pcidev, "reset controller fails (post status %x).\n", Post);
 
       return (0);
    }
@@ -4911,8 +4923,7 @@
 
    if (i >= 240) {
       /* error occurred */
-      printk(KERN_WARNING "(%s%d) timeout waiting for config.\n",
-             ips_name, ha->host_num);
+      IPS_PRINTK(KERN_WARNING, ha->pcidev, "timeout waiting for config.\n");
 
       return (0);
    }
@@ -5239,10 +5250,8 @@
          if (!(val & IPS_BIT_START_STOP))
             break;
 
-         printk(KERN_WARNING "(%s%d) ips_issue val [0x%x].\n",
-                ips_name, ha->host_num, val);
-         printk(KERN_WARNING "(%s%d) ips_issue semaphore chk timeout.\n",
-                ips_name, ha->host_num);
+         IPS_PRINTK(KERN_WARNING, ha->pcidev, "ips_issue val [0x%x].\n", val);
+         IPS_PRINTK(KERN_WARNING, ha->pcidev, "ips_issue semaphore chk timeout.\n");
 
          return (IPS_FAILURE);
       } /* end if */
@@ -5295,10 +5304,8 @@
          if (!(val & IPS_BIT_START_STOP))
             break;
 
-         printk(KERN_WARNING "(%s%d) ips_issue val [0x%x].\n",
-                ips_name, ha->host_num, val);
-         printk(KERN_WARNING "(%s%d) ips_issue semaphore chk timeout.\n",
-                ips_name, ha->host_num);
+         IPS_PRINTK(KERN_WARNING, ha->pcidev, "ips_issue val [0x%x].\n", val);
+         IPS_PRINTK(KERN_WARNING, ha->pcidev, "ips_issue semaphore chk timeout.\n");
 
          return (IPS_FAILURE);
       } /* end if */
@@ -5538,8 +5545,7 @@
    METHOD_TRACE("ips_write_driver_status", 1);
 
    if (!ips_readwrite_page5(ha, FALSE, intr)) {
-      printk(KERN_WARNING "(%s%d) unable to read NVRAM page 5.\n",
-             ips_name, ha->host_num);
+      IPS_PRINTK(KERN_WARNING, ha->pcidev, "unable to read NVRAM page 5.\n");
 
       return (0);
    }
@@ -5574,8 +5580,7 @@
 
    /* now update the page */
    if (!ips_readwrite_page5(ha, TRUE, intr)) {
-      printk(KERN_WARNING "(%s%d) unable to write NVRAM page 5.\n",
-             ips_name, ha->host_num);
+      IPS_PRINTK(KERN_WARNING, ha->pcidev, "unable to write NVRAM page 5.\n");
 
       return (0);
    }
@@ -6538,10 +6543,10 @@
          strncpy(&FirmwareString[0], ha->enq->CodeBlkVersion, 8);
          FirmwareString[8] = 0;
 
-         printk(KERN_WARNING "Warning ! ! ! ServeRAID Version Mismatch\n");
-         printk(KERN_WARNING "Bios = %s, Firmware = %s, Device Driver = %s%s\n",
-                              BiosString, FirmwareString, IPS_VERSION_HIGH, IPS_VERSION_LOW );
-         printk(KERN_WARNING "These levels should match to avoid possible compatibility problems.\n" );
+         IPS_PRINTK(KERN_WARNING, ha->pcidev, "Warning ! ! ! ServeRAID Version Mismatch\n");
+         IPS_PRINTK(KERN_WARNING, ha->pcidev, "Bios = %s, Firmware = %s, Device Driver = %s%s\n",
+                    BiosString, FirmwareString, IPS_VERSION_HIGH, IPS_VERSION_LOW );
+         IPS_PRINTK(KERN_WARNING, ha->pcidev, "These levels should match to avoid possible compatibility problems.\n");
      }
  }
  else
@@ -6682,6 +6687,7 @@
 					}
 					break;
 				default:
+					break;
 				}
 			}
 		}
@@ -6725,19 +6731,18 @@
 static int
 ips_register_scsi( int index){
 	struct Scsi_Host *sh;
-	ips_ha_t *ha, *oldha;
+	ips_ha_t *ha, *oldha = ips_ha[index];
 	sh = scsi_register(&ips_driver_template, sizeof(ips_ha_t));
 	if(!sh) {
-		printk(KERN_WARNING "Unable to register controller with SCSI subsystem\n" );
+		IPS_PRINTK(KERN_WARNING, oldha->pcidev, "Unable to register controller with SCSI subsystem\n");
 		return -1;
 	}
-	oldha = ips_ha[index];
 	ha = IPS_HA(sh);
 	memcpy(ha, oldha, sizeof(ips_ha_t));
 	free_irq(oldha->irq, oldha);
 	/* Install the interrupt handler with the new ha */
 	if (request_irq(ha->irq, do_ipsintr, SA_SHIRQ, ips_name, ha)) {
-		printk(KERN_WARNING "Unable to install interrupt handler\n" );
+		IPS_PRINTK(KERN_WARNING, ha->pcidev, "Unable to install interrupt handler\n" );
 		scsi_unregister(sh);
 		return -1;
 	}
@@ -6745,7 +6750,7 @@
 	kfree(oldha);
 	ips_sh[index] = sh;
 	ips_ha[index] = ha;
-	scsi_set_device(sh, &ha->pcidev->dev);
+	IPS_SCSI_SET_DEVICE(sh, ha);
 
 	/* Store away needed values for later use */
 	sh->io_port = ha->io_addr;
@@ -6940,7 +6945,7 @@
        uint32_t offs;
 
        if (!request_mem_region(mem_addr, mem_len, "ips")) {
-          printk(KERN_WARNING "Couldn't allocate IO Memory space %x len %d.\n", mem_addr, mem_len);
+          IPS_PRINTK(KERN_WARNING, pci_dev, "Couldn't allocate IO Memory space %x len %d.\n", mem_addr, mem_len);
           return -1;
           }
 
@@ -6956,14 +6961,14 @@
     /* setup I/O mapped area (if applicable) */
     if (io_addr) {
        if (!request_region(io_addr, io_len, "ips")) {
-          printk(KERN_WARNING "Couldn't allocate IO space %x len %d.\n", io_addr, io_len);
+          IPS_PRINTK(KERN_WARNING, pci_dev, "Couldn't allocate IO space %x len %d.\n", io_addr, io_len);
           return -1;
        }
     }
 
     /* get the revision ID */
     if (pci_read_config_byte(pci_dev, PCI_REVISION_ID, &revision_id)) {
-       printk(KERN_WARNING "Can't get revision id.\n" );
+       IPS_PRINTK(KERN_WARNING, pci_dev, "Can't get revision id.\n");
        return -1;
     }
 
@@ -6972,7 +6977,7 @@
     /* found a controller */
     ha = kmalloc(sizeof(ips_ha_t), GFP_KERNEL);
     if (ha == NULL) {
-       printk(KERN_WARNING "Unable to allocate temporary ha struct\n" );
+       IPS_PRINTK(KERN_WARNING, pci_dev, "Unable to allocate temporary ha struct\n");
        return -1;
     }
 
@@ -7007,20 +7012,23 @@
          !pci_set_dma_mask(ha->pcidev, (u64)0xffffffffffffffff)) {
        (ha)->flags |= IPS_HA_ENH_SG;
     } else {
-       pci_set_dma_mask(ha->pcidev, (u64)0xffffffff);
+       if ( pci_set_dma_mask(ha->pcidev, (u64)0xffffffff) != 0 ) { 
+          printk(KERN_WARNING "Unable to set DMA Mask\n");
+          return ips_abort_init(ha, index);
+       }
     }
 
     ha->enq = kmalloc(sizeof(IPS_ENQ), IPS_INIT_GFP);
 
     if (!ha->enq) {
-       printk(KERN_WARNING "Unable to allocate host inquiry structure\n" );
+       IPS_PRINTK(KERN_WARNING, pci_dev, "Unable to allocate host inquiry structure\n" );
        return ips_abort_init(ha, index);
     }
 
     ha->adapt = pci_alloc_consistent(pci_dev, sizeof(IPS_ADAPTER) +
                                      sizeof(IPS_IO_CMD), &dma_address);
     if (!ha->adapt) {
-       printk(KERN_WARNING "Unable to allocate host adapt & dummy structures\n");
+       IPS_PRINTK(KERN_WARNING, pci_dev, "Unable to allocate host adapt & dummy structures\n");
        return ips_abort_init(ha, index);
     }
     ha->adapt->hw_status_start = dma_address;
@@ -7029,21 +7037,21 @@
     ha->conf = kmalloc(sizeof(IPS_CONF), IPS_INIT_GFP);
 
     if (!ha->conf) {
-       printk(KERN_WARNING "Unable to allocate host conf structure\n" );
+       IPS_PRINTK(KERN_WARNING, pci_dev, "Unable to allocate host conf structure\n");
        return ips_abort_init(ha, index);
     }
 
     ha->nvram = kmalloc(sizeof(IPS_NVRAM_P5), IPS_INIT_GFP);
 
     if (!ha->nvram) {
-       printk(KERN_WARNING "Unable to allocate host NVRAM structure\n" );
+       IPS_PRINTK(KERN_WARNING, pci_dev, "Unable to allocate host NVRAM structure\n");
        return ips_abort_init(ha, index);
     }
 
     ha->subsys = kmalloc(sizeof(IPS_SUBSYS), IPS_INIT_GFP);
 
     if (!ha->subsys) {
-       printk(KERN_WARNING "Unable to allocate host subsystem structure\n" );
+       IPS_PRINTK(KERN_WARNING, pci_dev, "Unable to allocate host subsystem structure\n");
        return ips_abort_init(ha, index);
     }
 
@@ -7055,7 +7063,7 @@
     ha->ioctl_datasize = count;
 
     if (!ha->ioctl_data) {
-       printk(KERN_WARNING "Unable to allocate IOCTL data\n" );
+       IPS_PRINTK(KERN_WARNING, pci_dev, "Unable to allocate IOCTL data\n");
        ha->ioctl_data = NULL;
        ha->ioctl_order = 0;
        ha->ioctl_datasize = 0;
@@ -7083,7 +7091,7 @@
           /*
            * Initialization failed
            */
-          printk(KERN_WARNING "Unable to initialize controller\n" );
+          IPS_PRINTK(KERN_WARNING, pci_dev, "Unable to initialize controller\n");
           return ips_abort_init(ha, index);
        }
     }
@@ -7115,7 +7123,7 @@
 
     /* Install the interrupt handler */
      if (request_irq(ha->irq, do_ipsintr, SA_SHIRQ, ips_name, ha)) {
-       printk(KERN_WARNING "Unable to install interrupt handler\n" );
+       IPS_PRINTK(KERN_WARNING, ha->pcidev, "Unable to install interrupt handler\n");
        return ips_abort_init(ha, index);
     }
 
@@ -7124,13 +7132,13 @@
      */
     ha->max_cmds = 1;
     if (!ips_allocatescbs(ha)) {
-       printk(KERN_WARNING "Unable to allocate a CCB\n" );
+       IPS_PRINTK(KERN_WARNING, ha->pcidev, "Unable to allocate a CCB\n");
        free_irq(ha->irq, ha);
        return ips_abort_init(ha, index);
     }
 
     if (!ips_hainit(ha)) {
-       printk(KERN_WARNING "Unable to initialize controller\n" );
+       IPS_PRINTK(KERN_WARNING, ha->pcidev, "Unable to initialize controller\n");
        free_irq(ha->irq, ha);
        return ips_abort_init(ha, index);
     }
@@ -7139,7 +7147,7 @@
 
     /* allocate CCBs */
     if (!ips_allocatescbs(ha)) {
-       printk(KERN_WARNING "Unable to allocate CCBs\n" );
+       IPS_PRINTK(KERN_WARNING, ha->pcidev, "Unable to allocate CCBs\n");
        free_irq(ha->irq, ha);
        return ips_abort_init(ha, index);
     }
diff -urN linux-2.5.69-bk7/drivers/scsi/ips.h linux-2.5.69-bk8/drivers/scsi/ips.h
--- linux-2.5.69-bk7/drivers/scsi/ips.h	2003-05-04 16:53:08.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/ips.h	2003-05-13 04:44:29.000000000 -0700
@@ -66,9 +66,6 @@
     */
    #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,20) || defined CONFIG_HIGHIO
       #define IPS_HIGHIO
-      #define IPS_HIGHMEM_IO     .highmem_io = 1,
-   #else
-      #define IPS_HIGHMEM_IO
    #endif
 
    #define IPS_HA(x)                   ((ips_ha_t *) x->hostdata)
@@ -94,20 +91,31 @@
                                          sizeof(IPS_ENH_SG_LIST) : sizeof(IPS_STD_SG_LIST))
 
    #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,4)
-      #define pci_set_dma_mask(dev,mask) (1)
+      #define pci_set_dma_mask(dev,mask) ( mask > 0xffffffff ? 1:0 )
       #define scsi_set_pci_device(sh,dev) (0)
    #endif
 
    #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+      typedef void irqreturn_t;
+      #define IRQ_NONE
+      #define IRQ_HANDLED
+      #define IRQ_RETVAL(x)
       #define IPS_REGISTER_HOSTS(SHT)      scsi_register_module(MODULE_SCSI_HA,SHT)
       #define IPS_UNREGISTER_HOSTS(SHT)    scsi_unregister_module(MODULE_SCSI_HA,SHT)
       #define IPS_ADD_HOST(shost,device)
       #define IPS_REMOVE_HOST(shost)
+      #define IPS_SCSI_SET_DEVICE(sh,ha)   scsi_set_pci_device(sh, (ha)->pcidev)
+      #define IPS_PRINTK(level, pcidev, format, arg...)                 \
+            printk(level "%s %s:" format , (pcidev)->driver->name ,     \
+            (pcidev)->slot_name , ## arg)
    #else
       #define IPS_REGISTER_HOSTS(SHT)      (!ips_detect(SHT))
       #define IPS_UNREGISTER_HOSTS(SHT)
       #define IPS_ADD_HOST(shost,device)   scsi_add_host(shost,device)
       #define IPS_REMOVE_HOST(shost)       scsi_remove_host(shost)
+      #define IPS_SCSI_SET_DEVICE(sh,ha)   scsi_set_device(sh, &(ha)->pcidev->dev)
+      #define IPS_PRINTK(level, pcidev, format, arg...)                 \
+            dev_printk(level , &((pcidev)->dev) , format , ## arg)
    #endif
 
    #ifndef MDELAY
@@ -445,47 +453,10 @@
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
    static void ips_select_queue_depth(struct Scsi_Host *, Scsi_Device *);
    static int ips_biosparam(Disk *disk, kdev_t dev, int geom[]);
-#define IPS {	\
-	.detect				= ips_detect,	\
-	.release			= ips_release,	\
-	.info				= ips_info,	\
-	.queuecommand			= ips_queue,	\
-	.eh_abort_handler		= ips_eh_abort,	\
-	.eh_host_reset_handler		= ips_eh_reset,	\
-	.bios_param			= ips_biosparam,\
-	.select_queue_depths		= ips_select_queue_depth, \
-	.can_queue			= 0,		\
-	.this_id			= -1,		\
-	.sg_tablesize			= IPS_MAX_SG,	\
-	.cmd_per_lun			= 16,		\
-	.present			= 0,		\
-	.unchecked_isa_dma		= 0,		\
-	.use_clustering			= ENABLE_CLUSTERING,\
-	.use_new_eh_code		= 1, \
-	IPS_HIGHMEM_IO \
-}
 #else
    static int ips_biosparam(struct scsi_device *sdev, struct block_device *bdev,
 		sector_t capacity, int geom[]);
    int ips_slave_configure(Scsi_Device *SDptr);
-#define IPS {	\
-	.detect			= ips_detect,		\
-	.release		= ips_release,		\
-	.info			= ips_info,		\
-	.queuecommand		= ips_queue,		\
-	.eh_abort_handler	= ips_eh_abort,		\
-	.eh_host_reset_handler	= ips_eh_reset,		\
-	.slave_configure	= ips_slave_configure,	\
-	.bios_param		= ips_biosparam,	\
-	.can_queue		= 0,			\
-	.this_id		= -1,			\
-	.sg_tablesize		= IPS_MAX_SG,		\
-	.cmd_per_lun		= 3,			\
-	.present		= 0,			\
-	.unchecked_isa_dma	= 0,			\
-	.use_clustering		= ENABLE_CLUSTERING,	\
-	.highmem_io		= 1 \
-}
 #endif
 
 /*
@@ -1092,7 +1063,7 @@
    int       (*programbios)(struct ips_ha *, char *, uint32_t, uint32_t);
    int       (*verifybios)(struct ips_ha *, char *, uint32_t, uint32_t);
    void      (*statinit)(struct ips_ha *);
-   void      (*intr)(struct ips_ha *);
+   int       (*intr)(struct ips_ha *);
    void      (*enableint)(struct ips_ha *);
    uint32_t (*statupd)(struct ips_ha *);
 } ips_hw_func_t;
diff -urN linux-2.5.69-bk7/drivers/scsi/lasi700.c linux-2.5.69-bk8/drivers/scsi/lasi700.c
--- linux-2.5.69-bk7/drivers/scsi/lasi700.c	2003-05-04 16:53:02.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/lasi700.c	2003-05-13 04:44:29.000000000 -0700
@@ -208,6 +208,11 @@
 	return 1;
 }
 
-static Scsi_Host_Template driver_template = LASI700_SCSI;
-
+static Scsi_Host_Template driver_template = {
+	.name		= "LASI SCSI 53c700",
+	.proc_name	= "lasi700",
+	.detect		= lasi700_detect,
+	.release	= lasi700_release,
+	.this_id	= 7,
+};
 #include "scsi_module.c"
diff -urN linux-2.5.69-bk7/drivers/scsi/lasi700.h linux-2.5.69-bk8/drivers/scsi/lasi700.h
--- linux-2.5.69-bk7/drivers/scsi/lasi700.h	2003-05-04 16:53:02.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/lasi700.h	2003-05-13 04:44:29.000000000 -0700
@@ -29,15 +29,6 @@
 static int lasi700_driver_callback(struct parisc_device *dev);
 static int lasi700_release(struct Scsi_Host *host);
 
-
-#define LASI700_SCSI {				\
-	.name		= "LASI SCSI 53c700",	\
-	.proc_name	= "lasi700",		\
-	.detect		= lasi700_detect,		\
-	.release	= lasi700_release,	\
-	.this_id	= 7,			\
-}
-
 #define LASI_710_SVERSION	0x082
 #define LASI_700_SVERSION	0x071
 
diff -urN linux-2.5.69-bk7/drivers/scsi/mac53c94.c linux-2.5.69-bk8/drivers/scsi/mac53c94.c
--- linux-2.5.69-bk7/drivers/scsi/mac53c94.c	2003-05-04 16:53:01.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/mac53c94.c	2003-05-13 04:44:29.000000000 -0700
@@ -59,7 +59,7 @@
 static void mac53c94_init(struct fsc_state *);
 static void mac53c94_start(struct fsc_state *);
 static void mac53c94_interrupt(int, void *, struct pt_regs *);
-static void do_mac53c94_interrupt(int, void *, struct pt_regs *);
+static irqreturn_t do_mac53c94_interrupt(int, void *, struct pt_regs *);
 static void cmd_done(struct fsc_state *, int result);
 static void set_dma_cmds(struct fsc_state *, Scsi_Cmnd *);
 static int data_goes_out(Scsi_Cmnd *);
@@ -316,7 +316,7 @@
 		set_dma_cmds(state, cmd);
 }
 
-static void
+static irqreturn_t
 do_mac53c94_interrupt(int irq, void *dev_id, struct pt_regs *ptregs)
 {
 	unsigned long flags;
@@ -325,6 +325,7 @@
 	spin_lock_irqsave(dev->host_lock, flags);
 	mac53c94_interrupt(irq, dev_id, ptregs);
 	spin_unlock_irqrestore(dev->host_lock, flags);
+	return IRQ_HANDLED;
 }
 
 static void
diff -urN linux-2.5.69-bk7/drivers/scsi/megaraid.c linux-2.5.69-bk8/drivers/scsi/megaraid.c
--- linux-2.5.69-bk7/drivers/scsi/megaraid.c	2003-05-04 16:52:48.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/megaraid.c	2003-05-13 04:44:29.000000000 -0700
@@ -5377,9 +5377,27 @@
 	kfree(pdev);
 }
 
-
-static Scsi_Host_Template driver_template = MEGARAID;
-
+static Scsi_Host_Template driver_template = {
+	.name =				"MegaRAID",
+	.proc_info =			megaraid_proc_info,
+	.detect =			megaraid_detect,
+	.release =			megaraid_release,
+	.info =				megaraid_info,
+	.command =			megaraid_command,
+	.queuecommand =			megaraid_queue,	
+	.bios_param =			megaraid_biosparam,
+	.max_sectors =			MAX_SECTORS_PER_IO,
+	.can_queue =			MAX_COMMANDS,
+	.this_id =			DEFAULT_INITIATOR_ID,
+	.sg_tablesize =			MAX_SGLIST,
+	.cmd_per_lun =			DEF_CMD_PER_LUN,
+	.use_clustering =		ENABLE_CLUSTERING,
+	.eh_abort_handler =		megaraid_abort,
+	.eh_device_reset_handler =	megaraid_reset,
+	.eh_bus_reset_handler =		megaraid_reset,
+	.eh_host_reset_handler =	megaraid_reset,
+	.highmem_io =			1,
+};
 #include "scsi_module.c"
 
 /* vi: set ts=8 sw=8 tw=78: */
diff -urN linux-2.5.69-bk7/drivers/scsi/megaraid.h linux-2.5.69-bk8/drivers/scsi/megaraid.h
--- linux-2.5.69-bk7/drivers/scsi/megaraid.h	2003-05-04 16:53:31.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/megaraid.h	2003-05-13 04:44:29.000000000 -0700
@@ -121,33 +121,6 @@
 #define NVIRT_CHAN		4	/* # of virtual channels to represent
 					   up to 60 logical drives */
 
-#define MEGARAID						\
-{								\
-	.name =				"MegaRAID",		\
-	.proc_info =			megaraid_proc_info,	\
-	.detect =			megaraid_detect,	\
-	.release =			megaraid_release,	\
-	.info =				megaraid_info,		\
-	.command =			megaraid_command,	\
-	.queuecommand =			megaraid_queue,		\
-	.bios_param =			megaraid_biosparam,	\
-	.max_sectors =			MAX_SECTORS_PER_IO,	\
-	.can_queue =			MAX_COMMANDS,		\
-	.this_id =			DEFAULT_INITIATOR_ID,	\
-	.sg_tablesize =			MAX_SGLIST,		\
-	.cmd_per_lun =			DEF_CMD_PER_LUN,	\
-	.present =  			0,			\
-	.unchecked_isa_dma =		0,			\
-	.use_clustering =		ENABLE_CLUSTERING,	\
-	.eh_abort_handler =		megaraid_abort,		\
-	.eh_device_reset_handler =	megaraid_reset,		\
-	.eh_bus_reset_handler =		megaraid_reset,		\
-	.eh_host_reset_handler =	megaraid_reset,		\
-	.highmem_io =			1,			\
-}
-
-
-
 typedef struct {
 	/* 0x0 */ u8 cmd;
 	/* 0x1 */ u8 cmdid;
diff -urN linux-2.5.69-bk7/drivers/scsi/mesh.c linux-2.5.69-bk8/drivers/scsi/mesh.c
--- linux-2.5.69-bk7/drivers/scsi/mesh.c	2003-05-04 16:53:33.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/mesh.c	2003-05-13 04:44:29.000000000 -0700
@@ -212,7 +212,7 @@
 static void handle_error(struct mesh_state *);
 static void handle_exception(struct mesh_state *);
 static void mesh_interrupt(int, void *, struct pt_regs *);
-static void do_mesh_interrupt(int, void *, struct pt_regs *);
+static irqreturn_t do_mesh_interrupt(int, void *, struct pt_regs *);
 static void handle_msgin(struct mesh_state *);
 static void mesh_done(struct mesh_state *, int);
 static void mesh_completed(struct mesh_state *, Scsi_Cmnd *);
@@ -1471,7 +1471,7 @@
 	out_8(&mr->sequence, SEQ_ENBRESEL);
 }
 
-static void
+static irqreturn_t
 do_mesh_interrupt(int irq, void *dev_id, struct pt_regs *ptregs)
 {
 	unsigned long flags;
@@ -1480,6 +1480,7 @@
 	spin_lock_irqsave(dev->host_lock, flags);
 	mesh_interrupt(irq, dev_id, ptregs);
 	spin_unlock_irqrestore(dev->host_lock, flags);
+	return IRQ_HANDLED;
 }
 
 static void handle_error(struct mesh_state *ms)
diff -urN linux-2.5.69-bk7/drivers/scsi/ncr53c8xx.c linux-2.5.69-bk8/drivers/scsi/ncr53c8xx.c
--- linux-2.5.69-bk7/drivers/scsi/ncr53c8xx.c	2003-05-04 16:53:08.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/ncr53c8xx.c	2003-05-13 04:44:29.000000000 -0700
@@ -9430,18 +9430,6 @@
 */
 int __init ncr53c8xx_detect(Scsi_Host_Template *tpnt)
 {
-	/*
-	**    Initialize driver general stuff.
-	*/
-#ifdef SCSI_NCR_PROC_INFO_SUPPORT
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,27)
-     tpnt->proc_dir  = &proc_scsi_ncr53c8xx;
-#else
-     tpnt->proc_name = NAME53C8XX;
-#endif
-     tpnt->proc_info = ncr53c8xx_proc_info;
-#endif
-
 #if	defined(SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT) && defined(MODULE)
 if (ncr53c8xx)
 	ncr53c8xx_setup(ncr53c8xx);
@@ -9467,29 +9455,27 @@
 */
 MODULE_LICENSE("GPL");
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-static
-#endif
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) || defined(MODULE)
+static Scsi_Host_Template driver_template =  {
 #ifdef ENABLE_SCSI_ZALON
-Scsi_Host_Template driver_template =  {
-	.proc_name =		"zalon720",
-	.detect =		zalon7xx_detect,
-	.release =		zalon7xx_release,
-	.info =			ncr53c8xx_info,
-	.queuecommand =		ncr53c8xx_queue_command,
-	.slave_configure =	ncr53c8xx_slave_configure,
-	.eh_bus_reset_handler =	ncr53c8xx_bus_reset,
-	.can_queue =		SCSI_NCR_CAN_QUEUE,
-	.this_id =		7,
-	.sg_tablesize =		SCSI_NCR_SG_TABLESIZE,
-	.cmd_per_lun =		SCSI_NCR_CMD_PER_LUN,
-	.use_clustering =	DISABLE_CLUSTERING,
-};
-
-
+	.proc_name		= "zalon720",
+	.detect			= zalon7xx_detect,
+	.release		= zalon7xx_release,
 #else
-Scsi_Host_Template driver_template = NCR53C8XX;
+	.proc_name		= NAME53C8XX,
+	.detect			= ncr53c8xx_detect,
+	.release		= ncr53c8xx_release,
 #endif
-#include "scsi_module.c"
+#ifdef SCSI_NCR_PROC_INFO_SUPPORT
+	.proc_info		= ncr53c8xx_proc_info,
 #endif
+	.info			= ncr53c8xx_info,
+	.queuecommand		= ncr53c8xx_queue_command,
+	.slave_configure	= ncr53c8xx_slave_configure,
+	.eh_bus_reset_handler	= ncr53c8xx_bus_reset,
+	.can_queue		= SCSI_NCR_CAN_QUEUE,
+	.this_id		= 7,
+	.sg_tablesize		= SCSI_NCR_SG_TABLESIZE,
+	.cmd_per_lun		= SCSI_NCR_CMD_PER_LUN,
+	.use_clustering		= DISABLE_CLUSTERING,
+};
+#include "scsi_module.c"
diff -urN linux-2.5.69-bk7/drivers/scsi/ncr53c8xx.h linux-2.5.69-bk8/drivers/scsi/ncr53c8xx.h
--- linux-2.5.69-bk7/drivers/scsi/ncr53c8xx.h	2003-05-04 16:53:12.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/ncr53c8xx.h	2003-05-13 04:44:29.000000000 -0700
@@ -44,38 +44,4 @@
 
 #include "sym53c8xx_defs.h"
 
-/*
-**	Define Scsi_Host_Template parameters
-**
-**	Used by hosts.c and ncr53c8xx.c with module configuration.
-*/
-
-#if (LINUX_VERSION_CODE >= 0x020400) || defined(HOSTS_C) || defined(MODULE)
-
-#include <scsi/scsicam.h>
-
-int ncr53c8xx_abort(Scsi_Cmnd *);
-int ncr53c8xx_detect(Scsi_Host_Template *tpnt);
-const char *ncr53c8xx_info(struct Scsi_Host *host);
-int ncr53c8xx_queue_command(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
-int ncr53c8xx_reset(Scsi_Cmnd *, unsigned int);
-int ncr53c8xx_slave_configure(Scsi_Device *);
-int ncr53c8xx_release(struct Scsi_Host *);
-
-
-#define NCR53C8XX {     .name           = "ncr53c8xx",		\
-			.detect         = ncr53c8xx_detect,	\
-			.release        = ncr53c8xx_release,	\
-			.info           = ncr53c8xx_info, 	\
-			.queuecommand   = ncr53c8xx_queue_command,\
-			.slave_configure = ncr53c8xx_slave_configure,\
-			.eh_bus_reset_handler = ncr53c8xx_bus_reset,	\
-			.can_queue      = SCSI_NCR_CAN_QUEUE,	\
-			.this_id        = 7,			\
-			.sg_tablesize   = SCSI_NCR_SG_TABLESIZE,	\
-			.cmd_per_lun    = SCSI_NCR_CMD_PER_LUN,	\
-			.use_clustering = DISABLE_CLUSTERING} 
-
-#endif /* defined(HOSTS_C) || defined(MODULE) */ 
-
 #endif /* NCR53C8XX_H */
diff -urN linux-2.5.69-bk7/drivers/scsi/nsp32.c linux-2.5.69-bk8/drivers/scsi/nsp32.c
--- linux-2.5.69-bk7/drivers/scsi/nsp32.c	2003-05-04 16:53:13.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/nsp32.c	2003-05-13 04:44:29.000000000 -0700
@@ -2420,7 +2420,6 @@
 static void nsp32_msgout_occur(nsp32_hw_data *data)
 {
 	unsigned int base = data->BaseAddress;
-	unsigned short command;
 	long new_sgtp;
 	int i;
 	
diff -urN linux-2.5.69-bk7/drivers/scsi/osst.c linux-2.5.69-bk8/drivers/scsi/osst.c
--- linux-2.5.69-bk7/drivers/scsi/osst.c	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/osst.c	2003-05-13 04:44:29.000000000 -0700
@@ -5397,15 +5397,10 @@
 	if (SDp->type != TYPE_TAPE || !osst_supports(SDp))
 		return 1;
 
-	if (scsi_slave_attach(SDp)) {
-		printk(KERN_ERR "osst :E: Failed to attach scsi slave.\n");
-		return 1;
-	}
-
 	drive = alloc_disk(1);
 	if (!drive) {
 		printk(KERN_ERR "osst :E: Out of memory. Device not attached.\n");
-		goto out_slave_detach;
+		return 1;
 	}
 
 	/* if this is the first attach, build the infrastructure */
@@ -5580,8 +5575,6 @@
 
 out_put_disk:
         put_disk(drive);
-out_slave_detach:
-        scsi_slave_detach(SDp);
         return 1;
 };
 
@@ -5604,7 +5597,6 @@
 		devfs_unregister_tape(tpnt->drive->number);
 		put_disk(tpnt->drive);
 		os_scsi_tapes[i] = NULL;
-		scsi_slave_detach(SDp);
 		osst_nr_dev--;
 		write_unlock(&os_scsi_tapes_lock);
 		for (mode = 0; mode < ST_NBR_MODES; ++mode) {
diff -urN linux-2.5.69-bk7/drivers/scsi/pas16.c linux-2.5.69-bk8/drivers/scsi/pas16.c
--- linux-2.5.69-bk7/drivers/scsi/pas16.c	2003-05-04 16:52:49.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/pas16.c	2003-05-13 04:44:29.000000000 -0700
@@ -600,9 +600,21 @@
 
 #include "NCR5380.c"
 
-/* Eventually this will go into an include file, but this will be later */
-static Scsi_Host_Template driver_template = MV_PAS16;
-
+static Scsi_Host_Template driver_template = {
+	.name           = "Pro Audio Spectrum-16 SCSI",
+	.detect         = pas16_detect,
+	.queuecommand   = pas16_queue_command,
+	.eh_abort_handler = pas16_abort,
+	.eh_bus_reset_handler = pas16_bus_reset,
+	.eh_device_reset_handler = pas16_device_reset,
+	.eh_host_reset_handler = pas16_host_reset,
+	.bios_param     = pas16_biosparam, 
+	.can_queue      = CAN_QUEUE,
+	.this_id        = 7,
+	.sg_tablesize   = SG_ALL,
+	.cmd_per_lun    = CMD_PER_LUN,
+	.use_clustering = DISABLE_CLUSTERING,
+};
 #include "scsi_module.c"
 
 #ifdef MODULE
diff -urN linux-2.5.69-bk7/drivers/scsi/pas16.h linux-2.5.69-bk8/drivers/scsi/pas16.h
--- linux-2.5.69-bk7/drivers/scsi/pas16.h	2003-05-04 16:53:35.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/pas16.h	2003-05-13 04:44:29.000000000 -0700
@@ -137,27 +137,6 @@
 #define CAN_QUEUE 32 
 #endif
 
-/* 
- * I hadn't thought of this with the earlier drivers - but to prevent
- * macro definition conflicts, we shouldn't define all of the internal
- * macros when this is being used solely for the host stub.
- */
-
-#define MV_PAS16 {					\
-	.name           = "Pro Audio Spectrum-16 SCSI", 	\
-	.detect         = pas16_detect, 			\
-	.queuecommand   = pas16_queue_command,		\
-	.eh_abort_handler = pas16_abort,			\
-	.eh_bus_reset_handler = pas16_bus_reset,		\
-	.eh_device_reset_handler = pas16_device_reset,	\
-	.eh_host_reset_handler = pas16_host_reset,	\
-	.bios_param     = pas16_biosparam, 		\
-	.can_queue      = CAN_QUEUE,			\
-	.this_id        = 7,				\
-	.sg_tablesize   = SG_ALL,				\
-	.cmd_per_lun    = CMD_PER_LUN ,			\
-	.use_clustering = DISABLE_CLUSTERING}
-
 #ifndef HOSTS_C
 
 #define NCR5380_implementation_fields \
diff -urN linux-2.5.69-bk7/drivers/scsi/pci2000.c linux-2.5.69-bk8/drivers/scsi/pci2000.c
--- linux-2.5.69-bk7/drivers/scsi/pci2000.c	2003-05-04 16:53:33.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/pci2000.c	2003-05-13 04:44:29.000000000 -0700
@@ -857,7 +857,21 @@
 
 
 MODULE_LICENSE("Dual BSD/GPL");
-/* Eventually this will go into an include file, but this will be later */
-static Scsi_Host_Template driver_template = PCI2000;
 
+static Scsi_Host_Template driver_template = {
+	.proc_name	= "pci2000",
+	.name		= "PCI-2000 SCSI Intelligent Disk Controller",
+	.detect		= Pci2000_Detect,
+	.release	= Pci2000_Release,
+	.command	= Pci2000_Command,
+	.queuecommand	= Pci2000_QueueCommand,
+	.abort		= Pci2000_Abort,
+	.reset		= Pci2000_Reset,
+	.bios_param	= Pci2000_BiosParam,
+	.can_queue	= 16,
+	.this_id	= -1,
+	.sg_tablesize	= 16,
+	.cmd_per_lun	= 1,
+	.use_clustering	= DISABLE_CLUSTERING,
+};
 #include "scsi_module.c"
diff -urN linux-2.5.69-bk7/drivers/scsi/pci2000.h linux-2.5.69-bk8/drivers/scsi/pci2000.h
--- linux-2.5.69-bk7/drivers/scsi/pci2000.h	2003-05-04 16:53:41.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/pci2000.h	2003-05-13 04:44:29.000000000 -0700
@@ -201,24 +201,4 @@
 	#define NULL 0
 #endif
 
-/* screen is 80 columns wide, damnit! */
-#define PCI2000 {				                        \
-	.proc_name	= "pci2000",					\
-	.name		= "PCI-2000 SCSI Intelligent Disk Controller",	\
-	.detect		= Pci2000_Detect,				\
-	.release	= Pci2000_Release,				\
-	.command	= Pci2000_Command,				\
-	.queuecommand	= Pci2000_QueueCommand,				\
-	.abort		= Pci2000_Abort,				\
-	.reset		= Pci2000_Reset,				\
-	.bios_param	= Pci2000_BiosParam,				\
-	.can_queue	= 16,						\
-	.this_id	= -1,						\
-	.sg_tablesize	= 16,						\
-	.cmd_per_lun	= 1,						\
-	.present	= 0,						\
-	.unchecked_isa_dma = 0,						\
-	.use_clustering	= DISABLE_CLUSTERING,				\
-}
-
 #endif
diff -urN linux-2.5.69-bk7/drivers/scsi/pci2220i.c linux-2.5.69-bk8/drivers/scsi/pci2220i.c
--- linux-2.5.69-bk7/drivers/scsi/pci2220i.c	2003-05-04 16:52:49.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/pci2220i.c	2003-05-13 04:44:29.000000000 -0700
@@ -2925,7 +2925,20 @@
 
 MODULE_LICENSE("Dual BSD/GPL");
 
-/* Eventually this will go into an include file, but this will be later */
-static Scsi_Host_Template driver_template = PCI2220I;
-
+static Scsi_Host_Template driver_template = {
+	.proc_name		= "pci2220i",
+	.name			= "PCI-2220I/PCI-2240I",
+	.detect			= Pci2220i_Detect,
+	.release		= Pci2220i_Release,
+	.command		= Pci2220i_Command,
+	.queuecommand		= Pci2220i_QueueCommand,
+	.abort			= Pci2220i_Abort,
+	.reset			= Pci2220i_Reset,
+	.bios_param		= Pci2220i_BiosParam,
+	.can_queue		= 1,
+	.this_id		= -1,
+	.sg_tablesize		= SG_ALL,
+	.cmd_per_lun		= 1,
+	.use_clustering		= DISABLE_CLUSTERING,
+};
 #include "scsi_module.c"
diff -urN linux-2.5.69-bk7/drivers/scsi/pci2220i.h linux-2.5.69-bk8/drivers/scsi/pci2220i.h
--- linux-2.5.69-bk7/drivers/scsi/pci2220i.h	2003-05-04 16:53:14.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/pci2220i.h	2003-05-13 04:44:29.000000000 -0700
@@ -40,23 +40,4 @@
 #ifndef NULL
 	#define NULL 0
 #endif
-
-#define PCI2220I {					\
-	.proc_name		= "pci2220i",		\
-	.name			= "PCI-2220I/PCI-2240I",	\
-	.detect			= Pci2220i_Detect,	\
-	.release		= Pci2220i_Release,	\
-	.command		= Pci2220i_Command,	\
-	.queuecommand		= Pci2220i_QueueCommand,	\
-	.abort			= Pci2220i_Abort,		\
-	.reset			= Pci2220i_Reset,		\
-	.bios_param		= Pci2220i_BiosParam,	\
-	.can_queue		= 1,			\
-	.this_id		= -1,			\
-	.sg_tablesize		= SG_ALL,			\
-	.cmd_per_lun		= 1,			\
-	.present		= 0,			\
-	.unchecked_isa_dma	= 0,			\
-	.use_clustering		= DISABLE_CLUSTERING,	\
-}
 #endif
diff -urN linux-2.5.69-bk7/drivers/scsi/pcmcia/aha152x_stub.c linux-2.5.69-bk8/drivers/scsi/pcmcia/aha152x_stub.c
--- linux-2.5.69-bk7/drivers/scsi/pcmcia/aha152x_stub.c	2003-05-04 16:53:41.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/pcmcia/aha152x_stub.c	2003-05-13 04:44:29.000000000 -0700
@@ -98,9 +98,8 @@
 
 typedef struct scsi_info_t {
     dev_link_t		link;
+    dev_node_t		node;
     struct Scsi_Host	*host;
-    int			ndev;
-    dev_node_t		node[8];
 } scsi_info_t;
 
 static void aha152x_release_cs(u_long arg);
@@ -217,8 +216,6 @@
     cisparse_t parse;
     int i, last_ret, last_fn;
     u_char tuple_data[64];
-    struct scsi_device *dev;
-    dev_node_t *node, **tail;
     struct Scsi_Host *host;
     
     DEBUG(0, "aha152x_config(0x%p)\n", link);
@@ -275,9 +272,6 @@
     if (ext_trans)
         s.ext_trans = ext_trans;
 
-    tail = &link->dev;
-    info->ndev = 0;
-
     host = aha152x_probe_one(&s);
     if (host == NULL) {
 	printk(KERN_INFO "aha152x_cs: no SCSI devices found\n");
@@ -286,39 +280,10 @@
 
     scsi_add_host(host, NULL);
 
-    list_for_each_entry(dev, &host->my_devices, siblings) {
-	    u_long arg[2], id;
-	    kernel_scsi_ioctl(dev, SCSI_IOCTL_GET_IDLUN, arg);
-	    id = (arg[0]&0x0f) + ((arg[0]>>4)&0xf0) +
-		((arg[0]>>8)&0xf00) + ((arg[0]>>12)&0xf000);
-	    node = &info->node[info->ndev];
-	    node->minor = 0;
-	    switch (dev->type) {
-	    case TYPE_TAPE:
-		node->major = SCSI_TAPE_MAJOR;
-		sprintf(node->dev_name, "st#%04lx", id);
-		break;
-	    case TYPE_DISK:
-	    case TYPE_MOD:
-		node->major = SCSI_DISK0_MAJOR;
-		sprintf(node->dev_name, "sd#%04lx", id);
-		break;
-	    case TYPE_ROM:
-	    case TYPE_WORM:
-		node->major = SCSI_CDROM_MAJOR;
-		sprintf(node->dev_name, "sr#%04lx", id);
-		break;
-	    default:
-		node->major = SCSI_GENERIC_MAJOR;
-		sprintf(node->dev_name, "sg#%04lx", id);
-		break;
-	    }
-	    *tail = node; tail = &node->next;
-	    info->ndev++;
-	    info->host = dev->host;
-    }
+    sprintf(info->node.dev_name, "scsi%d", host->host_no);
+    link->dev = &info->node;
+    info->host = host;
 
-    *tail = NULL;
     link->state &= ~DEV_CONFIG_PENDING;
     return;
     
diff -urN linux-2.5.69-bk7/drivers/scsi/pcmcia/fdomain_stub.c linux-2.5.69-bk8/drivers/scsi/pcmcia/fdomain_stub.c
--- linux-2.5.69-bk7/drivers/scsi/pcmcia/fdomain_stub.c	2003-05-04 16:53:32.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/pcmcia/fdomain_stub.c	2003-05-13 04:44:29.000000000 -0700
@@ -81,9 +81,8 @@
 
 typedef struct scsi_info_t {
     dev_link_t		link;
+    dev_node_t		node;
     struct Scsi_Host	*host;
-    int			ndev;
-    dev_node_t		node[8];
 } scsi_info_t;
 
 extern Scsi_Host_Template fdomain_driver_template;
@@ -206,8 +205,6 @@
     cisparse_t parse;
     int i, last_ret, last_fn, ints[3];
     u_char tuple_data[64];
-    Scsi_Device *dev;
-    dev_node_t *node, **tail;
     char str[16];
     struct Scsi_Host *host;
 
@@ -259,42 +256,8 @@
  
     scsi_add_host(host, NULL);
 
-    tail = &link->dev;
-    info->ndev = 0;
-   
-    list_for_each_entry (dev, &host->my_devices, siblings) {
-	    u_long arg[2], id;
-	    kernel_scsi_ioctl(dev, SCSI_IOCTL_GET_IDLUN, arg);
-	    id = (arg[0]&0x0f) + ((arg[0]>>4)&0xf0) +
-		((arg[0]>>8)&0xf00) + ((arg[0]>>12)&0xf000);
-	    node = &info->node[info->ndev];
-	    node->minor = 0;
-	    switch (dev->type) {
-	    case TYPE_TAPE:
-		node->major = SCSI_TAPE_MAJOR;
-		sprintf(node->dev_name, "st#%04lx", id);
-		break;
-	    case TYPE_DISK:
-	    case TYPE_MOD:
-		node->major = SCSI_DISK0_MAJOR;
-		sprintf(node->dev_name, "sd#%04lx", id);
-		break;
-	    case TYPE_ROM:
-	    case TYPE_WORM:
-		node->major = SCSI_CDROM_MAJOR;
-		sprintf(node->dev_name, "sr#%04lx", id);
-		break;
-	    default:
-		node->major = SCSI_GENERIC_MAJOR;
-		sprintf(node->dev_name, "sg#%04lx", id);
-		break;
-	    }
-	    *tail = node; tail = &node->next;
-	    info->ndev++;
-
-    }
-
-    *tail = NULL;
+    sprintf(info->node.dev_name, "scsi%d", host->host_no);
+    link->dev = &info->node;
     info->host = host;
     
     link->state &= ~DEV_CONFIG_PENDING;
diff -urN linux-2.5.69-bk7/drivers/scsi/pcmcia/nsp_cs.c linux-2.5.69-bk8/drivers/scsi/pcmcia/nsp_cs.c
--- linux-2.5.69-bk7/drivers/scsi/pcmcia/nsp_cs.c	2003-05-04 16:53:56.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/pcmcia/nsp_cs.c	2003-05-13 04:44:29.000000000 -0700
@@ -88,9 +88,8 @@
 
 typedef struct scsi_info_t {
 	dev_link_t             link;
+	dev_node_t	       node;
 	struct Scsi_Host      *host;
-	int	               ndev;
-	dev_node_t             node[8];
 	int                    stop;
 } scsi_info_t;
 
@@ -1621,8 +1620,6 @@
 	memreq_t          map;
 	cistpl_cftable_entry_t dflt = { 0 };
 
-	Scsi_Device	 *dev;
-	dev_node_t	**tail, *node;
 	struct Scsi_Host *host;
 	nsp_hw_data      *data = &nsp_data;
 
@@ -1762,58 +1759,13 @@
 		goto cs_failed;
 	}
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,2))
 	host = __nsp_detect(&nsp_driver_template);
-#else
-	scsi_register_module(MODULE_SCSI_HA, &nsp_driver_template);
-	for (host = scsi_hostlist; host != NULL; host = host->next) {
-		if (host->hostt == &nsp_driver_template)
-			break;
-#endif
-
 	if (!host)
 		goto cs_failed;
 
-	DEBUG(0, "GET_SCSI_INFO\n");
-	tail = &link->dev;
-	info->ndev = 0;
-
-	list_for_each_entry (dev, &host->my_devices, siblings) {
-		u_long arg[2], id;
-		kernel_scsi_ioctl(dev, SCSI_IOCTL_GET_IDLUN, arg);
-		id = (arg[0]&0x0f) + ((arg[0]>>4)&0xf0) +
-			((arg[0]>>8)&0xf00) + ((arg[0]>>12)&0xf000);
-		node = &info->node[info->ndev];
-		node->minor = 0;
-		switch (dev->type) {
-		case TYPE_TAPE:
-			node->major = SCSI_TAPE_MAJOR;
-			sprintf(node->dev_name, "st#%04lx", id);
-			break;
-		case TYPE_DISK:
-		case TYPE_MOD:
-			node->major = SCSI_DISK0_MAJOR;
-			sprintf(node->dev_name, "sd#%04lx", id);
-			break;
-		case TYPE_ROM:
-		case TYPE_WORM:
-			node->major = SCSI_CDROM_MAJOR;
-			sprintf(node->dev_name, "sr#%04lx", id);
-			break;
-		default:
-			node->major = SCSI_GENERIC_MAJOR;
-			sprintf(node->dev_name, "sg#%04lx", id);
-			break;
-		}
-		*tail = node; tail = &node->next;
-		info->ndev++;
-		info->host = dev->host;
-	}
-
-	*tail = NULL;
-	if (info->ndev == 0) {
-		printk(KERN_INFO "nsp_cs: no SCSI devices found\n");
-	}
+	sprintf(info->node.dev_name, "scsi%d", host->host_no);
+	link->dev = &info->node;
+	info->host = host;
 
 	/* Finally, report what we've done */
 	printk(KERN_INFO "nsp_cs: index 0x%02x: Vcc %d.%d",
@@ -1837,10 +1789,7 @@
 		       req.Base+req.Size-1);
 	printk("\n");
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
 	scsi_add_host(host, NULL);
-#endif
-
 	link->state &= ~DEV_CONFIG_PENDING;
 	return;
 
diff -urN linux-2.5.69-bk7/drivers/scsi/pcmcia/qlogic_stub.c linux-2.5.69-bk8/drivers/scsi/pcmcia/qlogic_stub.c
--- linux-2.5.69-bk7/drivers/scsi/pcmcia/qlogic_stub.c	2003-05-04 16:53:31.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/pcmcia/qlogic_stub.c	2003-05-13 04:44:29.000000000 -0700
@@ -85,10 +85,9 @@
 
 typedef struct scsi_info_t {
 	dev_link_t link;
+	dev_node_t node;
 	struct Scsi_Host *host;
 	unsigned short manf_id;
-	int ndev;
-	dev_node_t node[8];
 } scsi_info_t;
 
 static void qlogic_release(u_long arg);
@@ -205,8 +204,6 @@
 	cisparse_t parse;
 	int i, last_ret, last_fn;
 	unsigned short tuple_data[32];
-	Scsi_Device *dev;
-	dev_node_t **tail, *node;
 	struct Scsi_Host *host;
 
 	DEBUG(0, "qlogic_config(0x%p)\n", link);
@@ -263,51 +260,18 @@
 	else
 		qlogicfas_preset(link->io.BasePort1, link->irq.AssignedIRQ);
 
-	tail = &link->dev;
-	info->ndev = 0;
-
 	host = __qlogicfas_detect(&qlogicfas_driver_template);
 	if (!host) {
 		printk(KERN_INFO "qlogic_cs: no SCSI devices found\n");
 		goto out;
 	}
 
-	scsi_add_host(host, NULL);
-
-	list_for_each_entry(dev, &host->my_devices, siblings) {
-		u_long arg[2], id;
-		kernel_scsi_ioctl(dev, SCSI_IOCTL_GET_IDLUN, arg);
-		id = (arg[0] & 0x0f) + ((arg[0] >> 4) & 0xf0) + ((arg[0] >> 8) & 0xf00) + ((arg[0] >> 12) & 0xf000);
-		node = &info->node[info->ndev];
-		node->minor = 0;
-		switch (dev->type) {
-		case TYPE_TAPE:
-			node->major = SCSI_TAPE_MAJOR;
-			sprintf(node->dev_name, "st#%04lx", id);
-			break;
-		case TYPE_DISK:
-		case TYPE_MOD:
-			node->major = SCSI_DISK0_MAJOR;
-			sprintf(node->dev_name, "sd#%04lx", id);
-			break;
-		case TYPE_ROM:
-		case TYPE_WORM:
-			node->major = SCSI_CDROM_MAJOR;
-			sprintf(node->dev_name, "sr#%04lx", id);
-			break;
-		default:
-			node->major = SCSI_GENERIC_MAJOR;
-			sprintf(node->dev_name, "sg#%04lx", id);
-			break;
-		}
-		*tail = node;
-		tail = &node->next;
-		info->ndev++;
-	}
-
-	*tail = NULL;
+	sprintf(info->node.dev_name, "scsi%d", host->host_no);
+	link->dev = &info->node;
 	info->host = host;
 
+	scsi_add_host(host, NULL);
+
 out:
 	link->state &= ~DEV_CONFIG_PENDING;
 	return;
diff -urN linux-2.5.69-bk7/drivers/scsi/pluto.c linux-2.5.69-bk8/drivers/scsi/pluto.c
--- linux-2.5.69-bk7/drivers/scsi/pluto.c	2003-05-04 16:53:09.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/pluto.c	2003-05-13 04:44:29.000000000 -0700
@@ -246,11 +246,6 @@
 				host->max_channel = inq->channels;
 				host->irq = fc->irq;
 
-#ifdef __sparc_v9__
-				host->unchecked_isa_dma = 1;
-#endif
-
-
 				fc->channels = inq->channels + 1;
 				fc->targets = inq->targets;
 				fc->ages = ages;
@@ -345,7 +340,23 @@
 	return 0;
 }
 
-static Scsi_Host_Template driver_template = PLUTO;
+static Scsi_Host_Template driver_template = {
+	.name			= "Sparc Storage Array 100/200",
+	.detect			= pluto_detect,
+	.release		= pluto_release,
+	.info			= pluto_info,
+	.queuecommand		= fcp_scsi_queuecommand,
+	.slave_configure	= pluto_slave_configure,
+	.can_queue		= PLUTO_CAN_QUEUE,
+	.this_id		= -1,
+	.sg_tablesize		= 1,
+	.cmd_per_lun		= 1,
+	.use_clustering		= ENABLE_CLUSTERING,
+	.eh_abort_handler	= fcp_scsi_abort,
+	.eh_device_reset_handler = fcp_scsi_dev_reset,
+	.eh_bus_reset_handler	= fcp_scsi_bus_reset,
+	.eh_host_reset_handler	= fcp_scsi_host_reset,
+};
 
 #include "scsi_module.c"
 
diff -urN linux-2.5.69-bk7/drivers/scsi/pluto.h linux-2.5.69-bk8/drivers/scsi/pluto.h
--- linux-2.5.69-bk7/drivers/scsi/pluto.h	2003-05-04 16:53:31.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/pluto.h	2003-05-13 04:44:29.000000000 -0700
@@ -43,23 +43,5 @@
 const char * pluto_info(struct Scsi_Host *);
 int pluto_slave_configure(Scsi_Device *);
 
-#define PLUTO {							\
-	.name			= "Sparc Storage Array 100/200",	\
-	.detect			= pluto_detect,			\
-	.release		= pluto_release,			\
-	.info			= pluto_info,			\
-	.queuecommand		= fcp_scsi_queuecommand,		\
-	.slave_configure	= pluto_slave_configure,		\
-	.can_queue		= PLUTO_CAN_QUEUE,		\
-	.this_id		= -1,				\
-	.sg_tablesize		= 1,				\
-	.cmd_per_lun		= 1,				\
-	.use_clustering		= ENABLE_CLUSTERING,		\
-	.eh_abort_handler	= fcp_scsi_abort,			\
-	.eh_device_reset_handler = fcp_scsi_dev_reset,		\
-	.eh_bus_reset_handler	= fcp_scsi_bus_reset,		\
-	.eh_host_reset_handler	= fcp_scsi_host_reset,		\
-}	
-
 #endif /* !(_PLUTO_H) */
 
diff -urN linux-2.5.69-bk7/drivers/scsi/ppa.c linux-2.5.69-bk8/drivers/scsi/ppa.c
--- linux-2.5.69-bk7/drivers/scsi/ppa.c	2003-05-04 16:53:32.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/ppa.c	2003-05-13 04:44:29.000000000 -0700
@@ -97,7 +97,23 @@
  *                   Parallel port probing routines                        *
  ***************************************************************************/
 
-static Scsi_Host_Template driver_template = PPA;
+static Scsi_Host_Template driver_template = {
+	.proc_name			= "ppa",
+	.proc_info			= ppa_proc_info,
+	.name				= "Iomega VPI0 (ppa) interface",
+	.detect				= ppa_detect,
+	.release			= ppa_release,
+	.command			= ppa_command,
+	.queuecommand			= ppa_queuecommand,
+	.eh_abort_handler		= ppa_abort,
+	.eh_bus_reset_handler		= ppa_reset,
+	.eh_host_reset_handler		= ppa_reset,
+	.bios_param			= ppa_biosparam,
+	.this_id			= -1,
+	.sg_tablesize			= SG_ALL,
+	.cmd_per_lun			= 1,
+	.use_clustering			= ENABLE_CLUSTERING,
+};
 #include  "scsi_module.c"
 
 /*
diff -urN linux-2.5.69-bk7/drivers/scsi/ppa.h linux-2.5.69-bk8/drivers/scsi/ppa.h
--- linux-2.5.69-bk7/drivers/scsi/ppa.h	2003-05-04 16:53:40.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/ppa.h	2003-05-13 04:44:29.000000000 -0700
@@ -171,21 +171,4 @@
 int ppa_biosparam(struct scsi_device *, struct block_device *,
 		sector_t, int *);
 
-#define PPA {	.proc_name			= "ppa",		\
-		.proc_info			= ppa_proc_info,		\
-		.name				= "Iomega VPI0 (ppa) interface",\
-		.detect				= ppa_detect,		\
-		.release			= ppa_release,		\
-		.command			= ppa_command,		\
-		.queuecommand			= ppa_queuecommand,	\
-		.eh_abort_handler		= ppa_abort,		\
-		.eh_device_reset_handler	= NULL,			\
-		.eh_bus_reset_handler		= ppa_reset,		\
-		.eh_host_reset_handler		= ppa_reset,		\
-		.bios_param			= ppa_biosparam,		\
-		.this_id			= -1,			\
-		.sg_tablesize			= SG_ALL,			\
-		.cmd_per_lun			= 1,			\
-		.use_clustering			= ENABLE_CLUSTERING	\
-}
 #endif				/* _PPA_H */
diff -urN linux-2.5.69-bk7/drivers/scsi/psi240i.c linux-2.5.69-bk8/drivers/scsi/psi240i.c
--- linux-2.5.69-bk7/drivers/scsi/psi240i.c	2003-05-04 16:53:35.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/psi240i.c	2003-05-13 04:44:29.000000000 -0700
@@ -718,8 +718,19 @@
 
 MODULE_LICENSE("GPL");
 
-/* Eventually this will go into an include file, but this will be later */
-static Scsi_Host_Template driver_template = PSI240I;
-
+static Scsi_Host_Template driver_template = {
+	.proc_name		= "psi240i", 
+	.name			= "PSI-240I EIDE Disk Controller",
+	.detect			= Psi240i_Detect,
+	.command		= Psi240i_Command,
+	.queuecommand		= Psi240i_QueueCommand,
+	.abort	  		= Psi240i_Abort,
+	.reset	  		= Psi240i_Reset,
+	.bios_param	  	= Psi240i_BiosParam,
+	.can_queue	  	= 1,
+	.this_id	  	= -1,
+	.sg_tablesize	  	= SG_NONE,
+	.cmd_per_lun	  	= 1, 
+	.use_clustering		= DISABLE_CLUSTERING,
+};
 #include "scsi_module.c"
-
diff -urN linux-2.5.69-bk7/drivers/scsi/psi240i.h linux-2.5.69-bk8/drivers/scsi/psi240i.h
--- linux-2.5.69-bk7/drivers/scsi/psi240i.h	2003-05-04 16:53:41.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/psi240i.h	2003-05-13 04:44:29.000000000 -0700
@@ -320,19 +320,4 @@
 #ifndef NULL
 	#define NULL 0
 #endif
-
-#define PSI240I { .proc_name      = "psi240i", \
-		  .name           = "PSI-240I EIDE Disk Controller",\
-		  .detect         = Psi240i_Detect,			\
-		  .command	  = Psi240i_Command,			\
-		  .queuecommand	  = Psi240i_QueueCommand,		\
-		  .abort	  = Psi240i_Abort,			\
-		  .reset	  = Psi240i_Reset,			\
-		  .bios_param	  = Psi240i_BiosParam,                 	\
-		  .can_queue	  = 1, 					\
-		  .this_id	  = -1, 					\
-		  .sg_tablesize	  = SG_NONE,		 		\
-		  .cmd_per_lun	  = 1, 					\
-		  .use_clustering = DISABLE_CLUSTERING }
-
 #endif
diff -urN linux-2.5.69-bk7/drivers/scsi/qla1280.c linux-2.5.69-bk8/drivers/scsi/qla1280.c
--- linux-2.5.69-bk7/drivers/scsi/qla1280.c	2003-05-04 16:53:57.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/qla1280.c	2003-05-13 04:44:29.000000000 -0700
@@ -5939,15 +5939,24 @@
 	return ret;
 }
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
-#ifdef MODULE
-Scsi_Host_Template driver_template = QLA1280_LINUX_TEMPLATE;
-#include "scsi_module.c"
-#endif
-#else				/* new kernel scsi initialization scheme */
-static Scsi_Host_Template driver_template = QLA1280_LINUX_TEMPLATE;
+static Scsi_Host_Template driver_template = {
+	.proc_info		= qla1280_proc_info,
+	.name			= "Qlogic ISP 1280/12160",
+	.detect			= qla1280_detect,
+	.release		= qla1280_release,
+	.info			= qla1280_info,
+	.queuecommand		= qla1280_queuecommand,
+	.abort			= qla1280_abort,
+	.reset			= qla1280_reset,
+	.slave_configure	= qla1280_slave_configure,
+	.bios_param		= qla1280_biosparam,
+	.can_queue		= 255,
+	.this_id		= -1,
+	.sg_tablesize		= SG_ALL,
+	.cmd_per_lun		= 3,
+	.use_clustering		= ENABLE_CLUSTERING,			\
+};
 #include "scsi_module.c"
-#endif
 
 /************************************************************************
  * qla1280_check_for_dead_scsi_bus                                      *
diff -urN linux-2.5.69-bk7/drivers/scsi/qla1280.h linux-2.5.69-bk8/drivers/scsi/qla1280.h
--- linux-2.5.69-bk7/drivers/scsi/qla1280.h	2003-05-04 16:53:57.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/qla1280.h	2003-05-13 04:44:29.000000000 -0700
@@ -1319,31 +1319,4 @@
 irqreturn_t qla1280_intr_handler(int, void *, struct pt_regs *);
 void qla1280_setup(char *s, int *dummy);
 
-/*
- * Scsi_Host_template (see hosts.h)
- * Device driver Interfaces to mid-level SCSI driver.
- */
-
-#define QLA1280_LINUX_TEMPLATE {				\
-	.proc_info = qla1280_proc_info,				\
-	.name = "Qlogic ISP 1280/12160",				\
-	.detect = qla1280_detect,					\
-	.release = qla1280_release,				\
-	.info = qla1280_info,					\
-	.queuecommand = qla1280_queuecommand,			\
-/*	use_new_eh_code: 0, */					\
-	.abort = qla1280_abort,					\
-	.reset = qla1280_reset,					\
-	.slave_configure = qla1280_slave_configure,		\
-	.bios_param = qla1280_biosparam,				\
-	.can_queue = 255,		/* max simultaneous cmds      */\
-	.this_id = -1,		/* scsi id of host adapter    */\
-	.sg_tablesize = SG_ALL,	/* max scatter-gather cmds    */\
-	.cmd_per_lun = 3,		/* cmds per lun (linked cmds) */\
-	.present = 0,		/* number of 1280's present   */\
-	.unchecked_isa_dma = 0,	/* no memory DMA restrictions */\
-	.use_clustering = ENABLE_CLUSTERING,			\
-	.emulated = 0						\
-}
-
 #endif				/* _IO_HBA_QLA1280_H */
diff -urN linux-2.5.69-bk7/drivers/scsi/qlogicfc.c linux-2.5.69-bk8/drivers/scsi/qlogicfc.c
--- linux-2.5.69-bk7/drivers/scsi/qlogicfc.c	2003-05-04 16:53:36.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/qlogicfc.c	2003-05-13 04:44:29.000000000 -0700
@@ -2228,6 +2228,18 @@
 
 MODULE_LICENSE("GPL");
 
-static Scsi_Host_Template driver_template = QLOGICFC;
-
+static Scsi_Host_Template driver_template = {
+        .detect                 = isp2x00_detect,
+        .release                = isp2x00_release,
+        .info                   = isp2x00_info,
+        .queuecommand           = isp2x00_queuecommand,
+        .eh_abort_handler       = isp2x00_abort,
+        .bios_param             = isp2x00_biosparam,
+        .can_queue              = QLOGICFC_REQ_QUEUE_LEN,
+        .this_id                = -1,
+        .sg_tablesize           = QLOGICFC_MAX_SG(QLOGICFC_REQ_QUEUE_LEN),
+	.cmd_per_lun		= QLOGICFC_CMD_PER_LUN,
+        .use_clustering         = ENABLE_CLUSTERING,
+	.highmem_io		= 1,
+};
 #include "scsi_module.c"
diff -urN linux-2.5.69-bk7/drivers/scsi/qlogicfc.h linux-2.5.69-bk8/drivers/scsi/qlogicfc.h
--- linux-2.5.69-bk7/drivers/scsi/qlogicfc.h	2003-05-04 16:53:12.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/qlogicfc.h	2003-05-13 04:44:29.000000000 -0700
@@ -82,24 +82,4 @@
 #define NULL (0)
 #endif
 
-#define QLOGICFC {							   \
-        .detect                 = isp2x00_detect,                            \
-        .release                = isp2x00_release,                           \
-        .info                   = isp2x00_info,                              \
-        .queuecommand           = isp2x00_queuecommand,                      \
-        .eh_abort_handler       = isp2x00_abort,                             \
-        .bios_param             = isp2x00_biosparam,                         \
-        .can_queue              = QLOGICFC_REQ_QUEUE_LEN,                    \
-        .this_id                = -1,                                        \
-        .sg_tablesize           = QLOGICFC_MAX_SG(QLOGICFC_REQ_QUEUE_LEN),   \
-	.cmd_per_lun		= QLOGICFC_CMD_PER_LUN, 			   \
-        .present                = 0,                                         \
-        .unchecked_isa_dma      = 0,                                         \
-        .use_clustering         = ENABLE_CLUSTERING, 			   \
-	.highmem_io		= 1					   \
-}
-
 #endif /* _QLOGICFC_H */
-
-
-
diff -urN linux-2.5.69-bk7/drivers/scsi/qlogicisp.c linux-2.5.69-bk8/drivers/scsi/qlogicisp.c
--- linux-2.5.69-bk7/drivers/scsi/qlogicisp.c	2003-05-04 16:53:55.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/qlogicisp.c	2003-05-13 04:44:29.000000000 -0700
@@ -1985,6 +1985,16 @@
 
 MODULE_LICENSE("GPL");
 
-static Scsi_Host_Template driver_template = QLOGICISP;
-
+static Scsi_Host_Template driver_template = {
+	.detect			= isp1020_detect,
+	.release		= isp1020_release,
+	.info			= isp1020_info,	
+	.queuecommand		= isp1020_queuecommand,
+	.bios_param		= isp1020_biosparam,
+	.can_queue		= QLOGICISP_REQ_QUEUE_LEN,
+	.this_id		= -1,
+	.sg_tablesize		= QLOGICISP_MAX_SG(QLOGICISP_REQ_QUEUE_LEN),
+	.cmd_per_lun		= 1,
+	.use_clustering		= DISABLE_CLUSTERING,
+};
 #include "scsi_module.c"
diff -urN linux-2.5.69-bk7/drivers/scsi/qlogicisp.h linux-2.5.69-bk8/drivers/scsi/qlogicisp.h
--- linux-2.5.69-bk7/drivers/scsi/qlogicisp.h	2003-05-04 16:52:48.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/qlogicisp.h	2003-05-13 04:44:29.000000000 -0700
@@ -70,20 +70,4 @@
 #ifndef NULL
 #define NULL (0)
 #endif
-
-#define QLOGICISP {							   \
-	.detect			= isp1020_detect,				   \
-	.release		= isp1020_release,			   \
-	.info			= isp1020_info,				   \
-	.queuecommand		= isp1020_queuecommand,			   \
-	.bios_param		= isp1020_biosparam,			   \
-	.can_queue		= QLOGICISP_REQ_QUEUE_LEN,		   \
-	.this_id		= -1,					   \
-	.sg_tablesize		= QLOGICISP_MAX_SG(QLOGICISP_REQ_QUEUE_LEN), \
-	.cmd_per_lun		= 1,					   \
-	.present		= 0,					   \
-	.unchecked_isa_dma	= 0,					   \
-	.use_clustering		= DISABLE_CLUSTERING			   \
-}
-
 #endif /* _QLOGICISP_H */
diff -urN linux-2.5.69-bk7/drivers/scsi/scsi.c linux-2.5.69-bk8/drivers/scsi/scsi.c
--- linux-2.5.69-bk7/drivers/scsi/scsi.c	2003-05-04 16:53:29.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/scsi.c	2003-05-13 04:44:29.000000000 -0700
@@ -56,6 +56,9 @@
 #include "scsi.h"
 #include "hosts.h"
 
+#include "scsi_priv.h"
+#include "scsi_logging.h"
+
 
 /*
  * Definitions and constants.
@@ -111,16 +114,6 @@
 	"Enclosure        ",
 };
 
-static const char * const spaces = "                "; /* 16 of them */
-
-static unsigned scsi_default_dev_flags;
-LIST_HEAD(scsi_dev_info_list);
-
-/* 
- * Function prototypes.
- */
-extern void scsi_times_out(struct scsi_cmnd *cmd);
-
 MODULE_PARM(scsi_logging_level, "i");
 MODULE_PARM_DESC(scsi_logging_level, "SCSI logging level; should be zero or nonzero");
 
@@ -178,6 +171,16 @@
 	return sreq;
 }
 
+void __scsi_release_request(struct scsi_request *sreq)
+{
+	if (likely(sreq->sr_command != NULL)) {
+		struct scsi_cmnd *cmd = sreq->sr_command;
+
+		sreq->sr_command = NULL;
+		scsi_next_command(cmd);
+	}
+}
+
 /*
  * Function:    scsi_release_request
  *
@@ -189,14 +192,7 @@
  */
 void scsi_release_request(struct scsi_request *sreq)
 {
-	if (likely(sreq->sr_command != NULL)) {
-    		struct request_queue *q = sreq->sr_device->request_queue;
-
-		scsi_put_command(sreq->sr_command);
-		sreq->sr_command = NULL;
-		scsi_queue_next_request(q, NULL);
-	}
-
+	__scsi_release_request(sreq);
 	kfree(sreq);
 }
 
@@ -534,7 +530,6 @@
 
 	cmd->request = sreq->sr_request;
 	memcpy(cmd->data_cmnd, sreq->sr_cmnd, sizeof(cmd->data_cmnd));
-	cmd->reset_chain = NULL;
 	cmd->serial_number = 0;
 	cmd->serial_number_at_timeout = 0;
 	cmd->bufflen = sreq->sr_bufflen;
@@ -936,250 +931,6 @@
 	return depth;
 }
 
-
-/*
- * scsi_strcpy_devinfo: called from scsi_dev_info_list_add to copy into
- * devinfo vendor and model strings.
- */
-static void scsi_strcpy_devinfo(char *name, char *to, size_t to_length,
-				char *from, int compatible)
-{
-	size_t from_length;
-
-	from_length = strlen(from);
-	strncpy(to, from, min(to_length, from_length));
-	if (from_length < to_length) {
-		if (compatible) {
-			/*
-			 * NUL terminate the string if it is short.
-			 */
-			to[from_length] = '\0';
-		} else {
-			/* 
-			 * space pad the string if it is short. 
-			 */
-			strncpy(&to[from_length], spaces,
-				to_length - from_length);
-		}
-	}
-	if (from_length > to_length)
-		 printk(KERN_WARNING "%s: %s string '%s' is too long\n",
-			__FUNCTION__, name, from);
-}
-
-/**
- * scsi_dev_info_list_add: add one dev_info list entry.
- * @vendor:	vendor string
- * @model:	model (product) string
- * @strflags:	integer string
- * @flag:	if strflags NULL, use this flag value
- *
- * Description:
- * 	Create and add one dev_info entry for @vendor, @model, @strflags or
- * 	@flag. If @compatible, add to the tail of the list, do not space
- * 	pad, and set devinfo->compatible. The scsi_static_device_list entries
- * 	are added with @compatible 1 and @clfags NULL.
- *
- * Returns: 0 OK, -error on failure.
- **/
-static int scsi_dev_info_list_add(int compatible, char *vendor, char *model,
-			    char *strflags, int flags)
-{
-	struct scsi_dev_info_list *devinfo;
-
-	devinfo = kmalloc(sizeof(*devinfo), GFP_KERNEL);
-	if (!devinfo) {
-		printk(KERN_ERR "%s: no memory\n", __FUNCTION__);
-		return -ENOMEM;
-	}
-
-	scsi_strcpy_devinfo("vendor", devinfo->vendor, sizeof(devinfo->vendor),
-			    vendor, compatible);
-	scsi_strcpy_devinfo("model", devinfo->model, sizeof(devinfo->model),
-			    model, compatible);
-
-	if (strflags)
-		devinfo->flags = simple_strtoul(strflags, NULL, 0);
-	else
-		devinfo->flags = flags;
-
-	devinfo->compatible = compatible;
-
-	if (compatible)
-		list_add_tail(&devinfo->dev_info_list, &scsi_dev_info_list);
-	else
-		list_add(&devinfo->dev_info_list, &scsi_dev_info_list);
-
-	return 0;
-}
-
-/**
- * scsi_dev_info_list_add_str: parse dev_list and add to the
- * scsi_dev_info_list.
- * @dev_list:	string of device flags to add
- *
- * Description:
- * 	Parse dev_list, and add entries to the scsi_dev_info_list.
- * 	dev_list is of the form "vendor:product:flag,vendor:product:flag".
- * 	dev_list is modified via strsep. Can be called for command line
- * 	addition, for proc or mabye a sysfs interface.
- *
- * Returns: 0 if OK, -error on failure.
- **/
-int scsi_dev_info_list_add_str (char *dev_list)
-{
-	char *vendor, *model, *strflags, *next;
-	char *next_check;
-	int res = 0;
-
-	next = dev_list;
-	if (next && next[0] == '"') {
-		/*
-		 * Ignore both the leading and trailing quote.
-		 */
-		next++;
-		next_check = ",\"";
-	} else {
-		next_check = ",";
-	}
-
-	/*
-	 * For the leading and trailing '"' case, the for loop comes
-	 * through the last time with vendor[0] == '\0'.
-	 */
-	for (vendor = strsep(&next, ":"); vendor && (vendor[0] != '\0')
-	     && (res == 0); vendor = strsep(&next, ":")) {
-		strflags = NULL;
-		model = strsep(&next, ":");
-		if (model)
-			strflags = strsep(&next, next_check);
-		if (!model || !strflags) {
-			printk(KERN_ERR "%s: bad dev info string '%s' '%s'"
-			       " '%s'\n", __FUNCTION__, vendor, model,
-			       strflags);
-			res = -EINVAL;
-		} else
-			res = scsi_dev_info_list_add(0 /* compatible */, vendor,
-						     model, strflags, 0);
-	}
-	return res;
-}
-
-/**
- * scsi_dev_info_list_delete: called from scsi.c:exit_scsi to remove
- * 	the scsi_dev_info_list.
- **/
-static void scsi_dev_info_list_delete (void)
-{
-	struct list_head *lh, *lh_next;
-	struct scsi_dev_info_list *devinfo;
-
-	list_for_each_safe(lh, lh_next, &scsi_dev_info_list) {
-		devinfo = list_entry(lh, struct scsi_dev_info_list,
-				     dev_info_list);
-		kfree(devinfo);
-	}
-}
-
-/**
- * scsi_dev_list_init: set up the dynamic device list.
- * @dev_list:	string of device flags to add
- *
- * Description:
- * 	Add command line @dev_list entries, then add
- * 	scsi_static_device_list entries to the scsi device info list.
- **/
-static int scsi_dev_info_list_init (char *dev_list)
-{
-	int error, i;
-
-	error = scsi_dev_info_list_add_str(dev_list);
-	if (error)
-		return error;
-
-	for (i = 0; scsi_static_device_list[i].vendor != NULL; i++) {
-		error = scsi_dev_info_list_add(1 /* compatibile */,
-				scsi_static_device_list[i].vendor,
-				scsi_static_device_list[i].model,
-				NULL,
-				scsi_static_device_list[i].flags);
-		if (error)
-			break;
-	}
-
-	if (error)
-		scsi_dev_info_list_delete();
-	return error;
-}
-
-/**
- * get_device_flags - get device specific flags from the dynamic device
- * list. Called during scan time.
- * @vendor:	vendor name
- * @model:	model name
- *
- * Description:
- *     Search the scsi_dev_info_list for an entry matching @vendor and
- *     @model, if found, return the matching flags value, else return
- *     scsi_default_dev_flags.
- **/
-int scsi_get_device_flags(unsigned char *vendor, unsigned char *model)
-{
-	struct scsi_dev_info_list *devinfo;
-
-	list_for_each_entry(devinfo, &scsi_dev_info_list, dev_info_list) {
-		if (devinfo->compatible) {
-			/*
-			 * Behave like the older version of get_device_flags.
-			 */
-			size_t max;
-			/*
-			 * XXX why skip leading spaces? If an odd INQUIRY
-			 * value, that should have been part of the
-			 * scsi_static_device_list[] entry, such as "  FOO"
-			 * rather than "FOO". Since this code is already
-			 * here, and we don't know what device it is
-			 * trying to work with, leave it as-is.
-			 */
-			max = 8;	/* max length of vendor */
-			while ((max > 0) && *vendor == ' ') {
-				max--;
-				vendor++;
-			}
-			/*
-			 * XXX removing the following strlen() would be
-			 * good, using it means that for a an entry not in
-			 * the list, we scan every byte of every vendor
-			 * listed in scsi_static_device_list[], and never match
-			 * a single one (and still have to compare at
-			 * least the first byte of each vendor).
-			 */
-			if (memcmp(devinfo->vendor, vendor,
-				    min(max, strlen(devinfo->vendor))))
-				continue;
-			/*
-			 * Skip spaces again.
-			 */
-			max = 16;	/* max length of model */
-			while ((max > 0) && *model == ' ') {
-				max--;
-				model++;
-			}
-			if (memcmp(devinfo->model, model,
-				   min(max, strlen(devinfo->model))))
-				continue;
-			return devinfo->flags;
-		} else {
-			if (!memcmp(devinfo->vendor, vendor,
-				     sizeof(devinfo->vendor)) &&
-			     !memcmp(devinfo->model, model,
-				      sizeof(devinfo->model)))
-				return devinfo->flags;
-		}
-	}
-	return scsi_default_dev_flags;
-}
-
 int scsi_attach_device(struct scsi_device *sdev)
 {
 	struct Scsi_Device_Template *sdt;
@@ -1280,39 +1031,6 @@
 }
 
 /*
- * Function:	scsi_slave_attach()
- *
- * Purpose:	Called from the upper level driver attach to handle common
- * 		attach code.
- *
- * Arguments:	sdev - scsi_device to attach
- *
- * Returns:	1 on error, 0 on succes
- *
- * Lock Status:	Protected via scsi_devicelist_mutex.
- */
-int scsi_slave_attach(struct scsi_device *sdev)
-{
-	sdev->attached++;
-	return 0;
-}
-
-/*
- * Function:	scsi_slave_detach()
- *
- * Purpose:	Called from the upper level driver attach to handle common
- * 		detach code.
- *
- * Arguments:	sdev - struct scsi_device to detach
- *
- * Lock Status:	Protected via scsi_devicelist_mutex.
- */
-void scsi_slave_detach(struct scsi_device *sdev)
-{
-	sdev->attached--;
-}
-
-/*
  * This entry point is called from the upper level module's module_init()
  * routine.  That implies that when this function is called, the
  * scsi_mod module is locked down because of upper module layering and
@@ -1377,43 +1095,9 @@
 	return 0;
 }
 
-static char *scsi_dev_flags;
-MODULE_PARM(scsi_dev_flags, "s");
-MODULE_PARM_DESC(scsi_dev_flags,
-	 "Given scsi_dev_flags=vendor:model:flags, add a black/white list"
-	 " entry for vendor and model with an integer value of flags"
-	 " to the scsi device info list");
-MODULE_PARM(scsi_default_dev_flags, "i");
-MODULE_PARM_DESC(scsi_default_dev_flags,
-		 "scsi default device flag integer value");
 MODULE_DESCRIPTION("SCSI core");
 MODULE_LICENSE("GPL");
 
-#ifndef MODULE
-static int __init setup_scsi_dev_flags(char *str)
-{
-	scsi_dev_flags = str;
-	return 1;
-}
-__setup("scsi_dev_flags=", setup_scsi_dev_flags);
-
-static int __init setup_scsi_default_dev_flags(char *str)
-{
-	unsigned int tmp;
-	if (get_option(&str, &tmp) == 1) {
-		scsi_default_dev_flags = tmp;
-		printk(KERN_WARNING "%s %d\n", __FUNCTION__,
-		       scsi_default_dev_flags);
-		return 1;
-	} else {
-		printk(KERN_WARNING "%s: usage scsi_default_dev_flags=intr\n",
-		       __FUNCTION__);
-		return 0;
-	}
-}
-__setup("scsi_default_dev_flags=", setup_scsi_default_dev_flags);
-#endif
-
 static int __init init_scsi(void)
 {
 	int error, i;
@@ -1424,7 +1108,7 @@
 	error = scsi_init_procfs();
 	if (error)
 		goto cleanup_queue;
-	error = scsi_dev_info_list_init(scsi_dev_flags);
+	error = scsi_init_devinfo();
 	if (error)
 		goto cleanup_procfs;
 	error = scsi_sysfs_register();
@@ -1441,7 +1125,7 @@
 	return 0;
 
 cleanup_devlist:
-	scsi_dev_info_list_delete();
+	scsi_exit_devinfo();
 cleanup_procfs:
 	scsi_exit_procfs();
 cleanup_queue:
@@ -1454,7 +1138,7 @@
 static void __exit exit_scsi(void)
 {
 	scsi_sysfs_unregister();
-	scsi_dev_info_list_delete();
+	scsi_exit_devinfo();
 	devfs_remove("scsi");
 	scsi_exit_procfs();
 	scsi_exit_queue();
diff -urN linux-2.5.69-bk7/drivers/scsi/scsi.h linux-2.5.69-bk8/drivers/scsi/scsi.h
--- linux-2.5.69-bk7/drivers/scsi/scsi.h	2003-05-04 16:53:08.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/scsi.h	2003-05-13 04:44:29.000000000 -0700
@@ -18,7 +18,6 @@
 #include <linux/config.h>	    /* for CONFIG_SCSI_LOGGING */
 #include <scsi/scsi.h>
 
-
 /*
  * These are the values that the SCpnt->sc_data_direction and 
  * SRpnt->sr_data_direction can take.  These need to be set
@@ -126,144 +125,11 @@
 #define SCSI_STATE_BHQUEUE         0x100a
 #define SCSI_STATE_MLQUEUE         0x100b
 
-/*
- * These are the values that the owner field can take.
- * They are used as an indication of who the command belongs to.
- */
-#define SCSI_OWNER_HIGHLEVEL      0x100
-#define SCSI_OWNER_MIDLEVEL       0x101
-#define SCSI_OWNER_LOWLEVEL       0x102
-#define SCSI_OWNER_ERROR_HANDLER  0x103
-#define SCSI_OWNER_BH_HANDLER     0x104
-#define SCSI_OWNER_NOBODY         0x105
-
 #define IDENTIFY_BASE       0x80
 #define IDENTIFY(can_disconnect, lun)   (IDENTIFY_BASE |\
 		     ((can_disconnect) ?  0x40 : 0) |\
 		     ((lun) & 0x07))
 
-
-/*
- * This defines the scsi logging feature.  It is a means by which the
- * user can select how much information they get about various goings on,
- * and it can be really useful for fault tracing.  The logging word is divided
- * into 8 nibbles, each of which describes a loglevel.  The division of things
- * is somewhat arbitrary, and the division of the word could be changed if it
- * were really needed for any reason.  The numbers below are the only place where these
- * are specified.  For a first go-around, 3 bits is more than enough, since this
- * gives 8 levels of logging (really 7, since 0 is always off).  Cutting to 2 bits
- * might be wise at some point.
- */
-
-#define SCSI_LOG_ERROR_SHIFT              0
-#define SCSI_LOG_TIMEOUT_SHIFT            3
-#define SCSI_LOG_SCAN_SHIFT               6
-#define SCSI_LOG_MLQUEUE_SHIFT            9
-#define SCSI_LOG_MLCOMPLETE_SHIFT         12
-#define SCSI_LOG_LLQUEUE_SHIFT            15
-#define SCSI_LOG_LLCOMPLETE_SHIFT         18
-#define SCSI_LOG_HLQUEUE_SHIFT            21
-#define SCSI_LOG_HLCOMPLETE_SHIFT         24
-#define SCSI_LOG_IOCTL_SHIFT              27
-
-#define SCSI_LOG_ERROR_BITS               3
-#define SCSI_LOG_TIMEOUT_BITS             3
-#define SCSI_LOG_SCAN_BITS                3
-#define SCSI_LOG_MLQUEUE_BITS             3
-#define SCSI_LOG_MLCOMPLETE_BITS          3
-#define SCSI_LOG_LLQUEUE_BITS             3
-#define SCSI_LOG_LLCOMPLETE_BITS          3
-#define SCSI_LOG_HLQUEUE_BITS             3
-#define SCSI_LOG_HLCOMPLETE_BITS          3
-#define SCSI_LOG_IOCTL_BITS               3
-
-#ifdef CONFIG_SCSI_LOGGING
-
-#define SCSI_CHECK_LOGGING(SHIFT, BITS, LEVEL, CMD)     \
-{                                                       \
-        unsigned int mask;                              \
-                                                        \
-        mask = (1 << (BITS)) - 1;                       \
-        if( ((scsi_logging_level >> (SHIFT)) & mask) > (LEVEL) ) \
-        {                                               \
-                (CMD);                                  \
-        }						\
-}
-
-#define SCSI_SET_LOGGING(SHIFT, BITS, LEVEL)            \
-{                                                       \
-        unsigned int mask;                              \
-                                                        \
-        mask = ((1 << (BITS)) - 1) << SHIFT;            \
-        scsi_logging_level = ((scsi_logging_level & ~mask) \
-                              | ((LEVEL << SHIFT) & mask));     \
-}
-
-
-
-#else
-
-/*
- * With no logging enabled, stub these out so they don't do anything.
- */
-#define SCSI_SET_LOGGING(SHIFT, BITS, LEVEL)
-
-#define SCSI_CHECK_LOGGING(SHIFT, BITS, LEVEL, CMD)
-#endif
-
-/*
- * These are the macros that are actually used throughout the code to
- * log events.  If logging isn't enabled, they are no-ops and will be
- * completely absent from the user's code.
- *
- * The 'set' versions of the macros are really intended to only be called
- * from the /proc filesystem, and in production kernels this will be about
- * all that is ever used.  It could be useful in a debugging environment to
- * bump the logging level when certain strange events are detected, however.
- */
-#define SCSI_LOG_ERROR_RECOVERY(LEVEL,CMD)  \
-        SCSI_CHECK_LOGGING(SCSI_LOG_ERROR_SHIFT, SCSI_LOG_ERROR_BITS, LEVEL,CMD);
-#define SCSI_LOG_TIMEOUT(LEVEL,CMD)  \
-        SCSI_CHECK_LOGGING(SCSI_LOG_TIMEOUT_SHIFT, SCSI_LOG_TIMEOUT_BITS, LEVEL,CMD);
-#define SCSI_LOG_SCAN_BUS(LEVEL,CMD)  \
-        SCSI_CHECK_LOGGING(SCSI_LOG_SCAN_SHIFT, SCSI_LOG_SCAN_BITS, LEVEL,CMD);
-#define SCSI_LOG_MLQUEUE(LEVEL,CMD)  \
-        SCSI_CHECK_LOGGING(SCSI_LOG_MLQUEUE_SHIFT, SCSI_LOG_MLQUEUE_BITS, LEVEL,CMD);
-#define SCSI_LOG_MLCOMPLETE(LEVEL,CMD)  \
-        SCSI_CHECK_LOGGING(SCSI_LOG_MLCOMPLETE_SHIFT, SCSI_LOG_MLCOMPLETE_BITS, LEVEL,CMD);
-#define SCSI_LOG_LLQUEUE(LEVEL,CMD)  \
-        SCSI_CHECK_LOGGING(SCSI_LOG_LLQUEUE_SHIFT, SCSI_LOG_LLQUEUE_BITS, LEVEL,CMD);
-#define SCSI_LOG_LLCOMPLETE(LEVEL,CMD)  \
-        SCSI_CHECK_LOGGING(SCSI_LOG_LLCOMPLETE_SHIFT, SCSI_LOG_LLCOMPLETE_BITS, LEVEL,CMD);
-#define SCSI_LOG_HLQUEUE(LEVEL,CMD)  \
-        SCSI_CHECK_LOGGING(SCSI_LOG_HLQUEUE_SHIFT, SCSI_LOG_HLQUEUE_BITS, LEVEL,CMD);
-#define SCSI_LOG_HLCOMPLETE(LEVEL,CMD)  \
-        SCSI_CHECK_LOGGING(SCSI_LOG_HLCOMPLETE_SHIFT, SCSI_LOG_HLCOMPLETE_BITS, LEVEL,CMD);
-#define SCSI_LOG_IOCTL(LEVEL,CMD)  \
-        SCSI_CHECK_LOGGING(SCSI_LOG_IOCTL_SHIFT, SCSI_LOG_IOCTL_BITS, LEVEL,CMD);
-
-
-#define SCSI_SET_ERROR_RECOVERY_LOGGING(LEVEL)  \
-        SCSI_SET_LOGGING(SCSI_LOG_ERROR_SHIFT, SCSI_LOG_ERROR_BITS, LEVEL);
-#define SCSI_SET_TIMEOUT_LOGGING(LEVEL)  \
-        SCSI_SET_LOGGING(SCSI_LOG_TIMEOUT_SHIFT, SCSI_LOG_TIMEOUT_BITS, LEVEL);
-#define SCSI_SET_SCAN_BUS_LOGGING(LEVEL)  \
-        SCSI_SET_LOGGING(SCSI_LOG_SCAN_SHIFT, SCSI_LOG_SCAN_BITS, LEVEL);
-#define SCSI_SET_MLQUEUE_LOGGING(LEVEL)  \
-        SCSI_SET_LOGGING(SCSI_LOG_MLQUEUE_SHIFT, SCSI_LOG_MLQUEUE_BITS, LEVEL);
-#define SCSI_SET_MLCOMPLETE_LOGGING(LEVEL)  \
-        SCSI_SET_LOGGING(SCSI_LOG_MLCOMPLETE_SHIFT, SCSI_LOG_MLCOMPLETE_BITS, LEVEL);
-#define SCSI_SET_LLQUEUE_LOGGING(LEVEL)  \
-        SCSI_SET_LOGGING(SCSI_LOG_LLQUEUE_SHIFT, SCSI_LOG_LLQUEUE_BITS, LEVEL);
-#define SCSI_SET_LLCOMPLETE_LOGGING(LEVEL)  \
-        SCSI_SET_LOGGING(SCSI_LOG_LLCOMPLETE_SHIFT, SCSI_LOG_LLCOMPLETE_BITS, LEVEL);
-#define SCSI_SET_HLQUEUE_LOGGING(LEVEL)  \
-        SCSI_SET_LOGGING(SCSI_LOG_HLQUEUE_SHIFT, SCSI_LOG_HLQUEUE_BITS, LEVEL);
-#define SCSI_SET_HLCOMPLETE_LOGGING(LEVEL)  \
-        SCSI_SET_LOGGING(SCSI_LOG_HLCOMPLETE_SHIFT, SCSI_LOG_HLCOMPLETE_BITS, LEVEL);
-#define SCSI_SET_IOCTL_LOGGING(LEVEL)  \
-        SCSI_SET_LOGGING(SCSI_LOG_IOCTL_SHIFT, SCSI_LOG_IOCTL_BITS, LEVEL);
-
 /* host byte codes */
 #define DID_OK          0x00	/* NO error                                */
 #define DID_NO_CONNECT  0x01	/* Couldn't connect before timeout period  */
@@ -356,6 +222,7 @@
  * Forward-declaration of structs for prototypes.
  */
 struct Scsi_Host;
+struct scsi_target;
 struct scatterlist;
 
 /*
@@ -365,24 +232,12 @@
 typedef struct scsi_cmnd Scsi_Cmnd;
 typedef struct scsi_request Scsi_Request;
 
-#define SCSI_CMND_MAGIC 0xE25C23A5
-#define SCSI_REQ_MAGIC  0x75F6D354
-
-/*
- * Here is where we prototype most of the mid-layer.
- */
-
-extern unsigned int scsi_logging_level;		/* What do we log? */
-
 /*
  * These are the error handling functions defined in scsi_error.c
  */
-extern void scsi_times_out(Scsi_Cmnd * SCpnt);
 extern void scsi_add_timer(Scsi_Cmnd * SCset, int timeout,
 			   void (*complete) (Scsi_Cmnd *));
 extern int scsi_delete_timer(Scsi_Cmnd * SCset);
-extern void scsi_error_handler(void *host);
-extern int scsi_decide_disposition(Scsi_Cmnd * SCpnt);
 extern int scsi_block_when_processing_errors(Scsi_Device *);
 extern void scsi_sleep(int);
 
@@ -396,39 +251,19 @@
 /*
  * Prototypes for functions in scsi_lib.c
  */
-extern int scsi_maybe_unblock_host(Scsi_Device * SDpnt);
-extern void scsi_setup_cmd_retry(Scsi_Cmnd *SCpnt);
 extern void scsi_io_completion(Scsi_Cmnd * SCpnt, int good_sectors,
 			       int block_sectors);
-extern int scsi_queue_insert(struct scsi_cmnd *cmd, int reason);
-extern void scsi_queue_next_request(request_queue_t *q, struct scsi_cmnd *cmd);
-extern request_queue_t *scsi_alloc_queue(struct scsi_device *sdev);
-extern void scsi_free_queue(request_queue_t *q);
-extern int scsi_init_queue(void);
-extern void scsi_exit_queue(void);
 
 /*
  * Prototypes for functions in scsi.c
  */
-extern int scsi_dispatch_cmd(Scsi_Cmnd * SCpnt);
-extern int scsi_setup_command_freelist(struct Scsi_Host *shost);
-extern void scsi_destroy_command_freelist(struct Scsi_Host *shost);
 extern struct scsi_cmnd *scsi_get_command(struct scsi_device *dev, int flags);
 extern void scsi_put_command(struct scsi_cmnd *cmd);
 extern void scsi_adjust_queue_depth(Scsi_Device *, int, int);
 extern int scsi_track_queue_full(Scsi_Device *, int);
-extern int scsi_slave_attach(struct scsi_device *);
-extern void scsi_slave_detach(struct scsi_device *);
 extern int scsi_device_get(struct scsi_device *);
 extern void scsi_device_put(struct scsi_device *);
 extern void scsi_set_device_offline(struct scsi_device *);
-extern void scsi_done(Scsi_Cmnd * SCpnt);
-extern void scsi_finish_command(Scsi_Cmnd *);
-extern int scsi_retry_command(Scsi_Cmnd *);
-extern int scsi_attach_device(struct scsi_device *);
-extern void scsi_detach_device(struct scsi_device *);
-extern void scsi_rescan_device(struct scsi_device *);
-extern int scsi_get_device_flags(unsigned char *vendor, unsigned char *model);
 
 /*
  * Newer request-based interfaces.
@@ -438,30 +273,10 @@
 extern void scsi_wait_req(Scsi_Request *, const void *cmnd,
 			  void *buffer, unsigned bufflen,
 			  int timeout, int retries);
-
 extern void scsi_do_req(Scsi_Request *, const void *cmnd,
 			void *buffer, unsigned bufflen,
 			void (*done) (struct scsi_cmnd *),
 			int timeout, int retries);
-extern int scsi_insert_special_req(Scsi_Request * SRpnt, int);
-extern void scsi_init_cmd_from_req(Scsi_Cmnd *, Scsi_Request *);
-
-/*
- * Prototypes for functions in scsi_proc.c
- */
-#ifdef CONFIG_PROC_FS
-extern int scsi_init_procfs(void);
-extern void scsi_exit_procfs(void);
-
-extern void scsi_proc_host_add(struct Scsi_Host *);
-extern void scsi_proc_host_rm(struct Scsi_Host *);
-#else
-static inline int scsi_init_procfs(void) { return 0; }
-static inline void scsi_exit_procfs(void) { ; }
-
-static inline void scsi_proc_host_add(struct Scsi_Host *);
-static inline void scsi_proc_host_rm(struct Scsi_Host *);
-#endif /* CONFIG_PROC_FS */
 
 /*
  * Prototypes for functions in scsi_scan.c
@@ -486,40 +301,6 @@
 extern const char *scsi_sense_key_string(unsigned char);
 extern const char *scsi_extd_sense_format(unsigned char, unsigned char);
 
-/*
- * dev_info: for the black/white list in the old scsi_static_device_list
- */
-struct dev_info {
-	char *vendor;
-	char *model;
-	char *revision;	/* revision known to be bad, unused */
-	unsigned flags;
-};
-
-extern struct dev_info scsi_static_device_list[];
-
-/*
- * scsi_dev_info_list: structure to hold black/white listed devices.
- */
-struct scsi_dev_info_list {
-	struct list_head dev_info_list;
-	char vendor[8];
-	char model[16];
-	unsigned flags;
-	unsigned compatible; /* for use with scsi_static_device_list entries */
-};
-extern struct list_head scsi_dev_info_list;
-extern int scsi_dev_info_list_add_str(char *);
-
-/*
- * scsi_target: representation of a scsi target, for now, this is only
- * used for single_lun devices. If no one has active IO to the target,
- * starget_sdev_user is NULL, else it points to the active sdev.
- */
-struct scsi_target {
-	struct scsi_device *starget_sdev_user;
-	unsigned int starget_refcnt;
-};
 
 /*
  *  The scsi_device struct contains what we know about each given scsi
@@ -540,8 +321,6 @@
 	 */
 	struct list_head    siblings;   /* list of all devices on this host */
 	struct list_head    same_target_siblings; /* just the devices sharing same target id */
-	wait_queue_head_t   scpnt_wait;	/* Used to wait if
-					   device is busy */
 	struct Scsi_Host *host;
 	request_queue_t *request_queue;
 	volatile unsigned short device_busy;	/* commands actually active on low-level */
@@ -563,8 +342,6 @@
 					 * vendor-specific cmd's */
 	unsigned sector_size;	/* size in bytes */
 
-	int attached;		/* # of high level drivers attached to 
-				 * this */
 	int access_count;	/* Count of open channels/mounts */
 
 	void *hostdata;		/* available to low-level driver */
@@ -619,9 +396,6 @@
   	/* default value if the device doesn't override */
 	#define SCSI_DEFAULT_DEVICE_BLOCKED	3
 
-
-	// Flag to allow revalidate to succeed in sd_open
-	int allow_revalidate;
 	struct device sdev_driverfs_dev;
 };
 #define	to_scsi_device(d)	\
@@ -698,7 +472,6 @@
 	unsigned short state;
 	unsigned short owner;
 	Scsi_Request *sc_request;
-	struct scsi_cmnd *reset_chain;
 
 	struct list_head list;  /* scsi_cmnd participates in queue lists */
 
@@ -783,14 +556,6 @@
 
 	unsigned flags;
 
-	/*
-	 * Used to indicate that a command which has timed out also
-	 * completed normally.  Typically the completion function will
-	 * do nothing but set this flag in this instance because the
-	 * timeout handler is already running.
-	 */
-	unsigned done_late:1;
-
 	/* Low-level done function - can be used by low-level driver to point
 	 *        to completion function.  Not used by mid/upper level code. */
 	void (*scsi_done) (struct scsi_cmnd *);
@@ -817,11 +582,6 @@
 };
 
 /*
- *  Flag bit for the internal_timeout array
- */
-#define NORMAL_TIMEOUT 0
-
-/*
  * Definitions and prototypes used for scsi mid-level queue.
  */
 #define SCSI_MLQUEUE_HOST_BUSY   0x1055
@@ -829,8 +589,7 @@
 #define SCSI_MLQUEUE_EH_RETRY    0x1057
 
 /*
- * old style reset request from external source
- * (private to sg.c and scsi_error.c, supplied by scsi_obsolete.c)
+ * Reset request from external source
  */
 #define SCSI_TRY_RESET_DEVICE	1
 #define SCSI_TRY_RESET_BUS	2
@@ -922,34 +681,6 @@
         return (Scsi_Cmnd *)req->special;
 }
 
-#define scsi_eh_eflags_chk(scp, flags) (scp->eh_eflags & flags)
-
-#define scsi_eh_eflags_set(scp, flags) do { \
-	scp->eh_eflags |= flags; \
-	} while(0)
-
-#define scsi_eh_eflags_clr(scp, flags) do { \
-	scp->eh_eflags &= ~flags; \
-	} while(0)
-
-#define scsi_eh_eflags_clr_all(scp) (scp->eh_eflags = 0)
-
-/*
- * Scsi Error Handler Flags
- */
-#define SCSI_EH_CANCEL_CMD	0x0001	/* Cancel this cmd */
-#define SCSI_EH_REC_TIMEOUT	0x0002	/* EH retry timed out */
-
-#define SCSI_SENSE_VALID(scmd) ((scmd->sense_buffer[0] & 0x70) == 0x70)
-
-extern int scsi_eh_scmd_add(struct scsi_cmnd *, int);
-
 int scsi_set_medium_removal(Scsi_Device *dev, char state);
 
-extern int scsi_device_register(struct scsi_device *);
-extern void scsi_device_unregister(struct scsi_device *);
-
-extern int scsi_sysfs_register(void);
-extern void scsi_sysfs_unregister(void);
-
 #endif /* _SCSI_H */
diff -urN linux-2.5.69-bk7/drivers/scsi/scsi_debug.c linux-2.5.69-bk8/drivers/scsi/scsi_debug.c
--- linux-2.5.69-bk7/drivers/scsi/scsi_debug.c	2003-05-04 16:53:32.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/scsi_debug.c	2003-05-13 04:44:29.000000000 -0700
@@ -52,9 +52,10 @@
 #include <linux/version.h>
 #endif
 
+#include "scsi_logging.h"
 #include "scsi_debug.h"
 
-static const char * scsi_debug_version_str = "Version: 1.69 (20030329)";
+static const char * scsi_debug_version_str = "Version: 1.70 (20030507)";
 
 /* Additional Sense Code (ASC) used */
 #define NO_ADDED_SENSE 0x0
@@ -144,10 +145,13 @@
 struct sdebug_host_info {
 	struct list_head host_list;
 	struct Scsi_Host *shost;
-	struct device *dev;
+	struct device dev;
 	struct list_head dev_info_list;
 };
 
+#define to_sdebug_host(d)	\
+	container_of(d, struct sdebug_host_info, dev)
+
 static LIST_HEAD(sdebug_host_list);
 static spinlock_t sdebug_host_list_lock = SPIN_LOCK_UNLOCKED;
 
@@ -162,6 +166,30 @@
 };
 static struct sdebug_queued_cmd queued_arr[SCSI_DEBUG_CANQUEUE];
 
+static Scsi_Host_Template sdebug_driver_template = {
+	.proc_info =		scsi_debug_proc_info,
+	.name =			"SCSI DEBUG",
+	.info =			scsi_debug_info,
+	.slave_alloc =		scsi_debug_slave_alloc,
+	.slave_configure =	scsi_debug_slave_configure,
+	.slave_destroy =	scsi_debug_slave_destroy,
+	.ioctl =		scsi_debug_ioctl,
+	.queuecommand =		scsi_debug_queuecommand,
+	.eh_abort_handler =	scsi_debug_abort,
+	.eh_bus_reset_handler = scsi_debug_bus_reset,
+	.eh_device_reset_handler = scsi_debug_device_reset,
+	.eh_host_reset_handler = scsi_debug_host_reset,
+	.bios_param =		scsi_debug_biosparam,
+	.can_queue =		SCSI_DEBUG_CANQUEUE,
+	.this_id =		7,
+	.sg_tablesize =		64,
+	.cmd_per_lun =		3,
+	.max_sectors =		4096,
+	.unchecked_isa_dma = 	0,
+	.use_clustering = 	ENABLE_CLUSTERING,
+	.module =		THIS_MODULE,
+};
+
 static unsigned char * fake_storep;	/* ramdisk storage */
 
 static unsigned char spare_buff[SDEBUG_SENSE_LEN];
@@ -178,9 +206,11 @@
 
 static int sdebug_driver_probe(struct device *);
 static int sdebug_driver_remove(struct device *);
+static struct bus_type pseudo_lld_bus;
 
 static struct device_driver sdebug_driverfs_driver = {
 	.name 		= sdebug_proc_name,
+	.bus		= &pseudo_lld_bus,
 	.probe          = sdebug_driver_probe,
 	.remove         = sdebug_driver_remove,
 };
@@ -221,24 +251,6 @@
 static void sdebug_remove_adapter(void);
 static struct device pseudo_primary;
 static struct bus_type pseudo_lld_bus;
-static int scsi_debug_register_driver(struct device_driver *);
-static int scsi_debug_unregister_driver(struct device_driver *);
-
-static struct sdebug_host_info * 
-		sdebug_shost_to_host_info(struct Scsi_Host *shost)
-{
-	struct sdebug_host_info * sdbg_host, * found = NULL;
-
-	spin_lock(&sdebug_host_list_lock);
-	list_for_each_entry(sdbg_host, &sdebug_host_list, host_list) {
-		if (sdbg_host->shost == shost) {
-			found = sdbg_host;
-			break;
-		}
-	}
-	spin_unlock(&sdebug_host_list_lock);
-	return found;
-}
 
 static unsigned char * scatg2virt(const struct scatterlist * sclp)
 {
@@ -283,10 +295,12 @@
 		bufflen = SDEBUG_SENSE_LEN;
 	}
 
+
         if(target == sdebug_driver_template.this_id) {
-                printk(KERN_WARNING 
-		       "scsi_debug: initiator's id used as target!\n");
-		return schedule_resp(SCpnt, NULL, done, 0, 0);
+		printk(KERN_INFO "scsi_debug: initiator's id used as "
+		       "target!\n");
+		return schedule_resp(SCpnt, NULL, done,
+				     DID_NO_CONNECT << 16, 0);
         }
 
 	if (SCpnt->device->lun >= scsi_debug_max_luns)
@@ -643,6 +657,15 @@
 	return sizeof(ctrl_m_pg);
 }
 
+static int resp_iec_m_pg(unsigned char * p, int pcontrol, int target)
+{	/* Informational Exceptions control mode page for mode_sense */
+	unsigned char iec_m_pg[] = {0x1c, 0xa, 0x08, 0, 0, 0, 0, 0,
+				    0, 0, 0x0, 0x0};
+	memcpy(p, iec_m_pg, sizeof(iec_m_pg));
+	if (1 == pcontrol)
+		memset(p + 2, 0, sizeof(iec_m_pg) - 2);
+	return sizeof(iec_m_pg);
+}
 
 #define SDEBUG_MAX_MSENSE_SZ 256
 
@@ -709,12 +732,17 @@
 		len = resp_ctrl_m_pg(ap, pcontrol, target);
 		offset += len;
 		break;
+	case 0x1c:	/* Informational Exceptions Mode page, all devices */
+		len = resp_iec_m_pg(ap, pcontrol, target);
+		offset += len;
+		break;
 	case 0x3f:	/* Read all Mode pages */
 		len = resp_err_recov_pg(ap, pcontrol, target);
 		len += resp_disconnect_pg(ap + len, pcontrol, target);
 		len += resp_format_pg(ap + len, pcontrol, target);
 		len += resp_caching_pg(ap + len, pcontrol, target);
 		len += resp_ctrl_m_pg(ap + len, pcontrol, target);
+		len += resp_iec_m_pg(ap + len, pcontrol, target);
 		offset += len;
 		break;
 	default:
@@ -865,7 +893,7 @@
 static void timer_intr_handler(unsigned long indx)
 {
 	struct sdebug_queued_cmd * sqcp;
-	unsigned int iflags;
+	unsigned long iflags;
 
 	if (indx >= SCSI_DEBUG_CANQUEUE) {
 		printk(KERN_ERR "scsi_debug:timer_intr_handler: indx too "
@@ -938,9 +966,9 @@
 
 	if (devip)
 		return devip;
-	sdbg_host = sdebug_shost_to_host_info(sdev->host);
+	sdbg_host = *(struct sdebug_host_info **) sdev->host->hostdata;
         if(! sdbg_host) {
-                printk(KERN_ERR "Unable to locate host info\n");
+                printk(KERN_ERR "Host info NULL\n");
 		return NULL;
         }
 	list_for_each_entry(devip, &sdbg_host->dev_info_list, dev_list) {
@@ -1040,7 +1068,7 @@
 		printk(KERN_INFO "scsi_debug: bus_reset\n");
 	++num_bus_resets;
 	if (SCpnt && ((sdp = SCpnt->device)) && ((hp = sdp->host))) {
-		sdbg_host = sdebug_shost_to_host_info(hp);
+		sdbg_host = *(struct sdebug_host_info **) hp->hostdata;
 		if (sdbg_host) {
 			list_for_each_entry(dev_info,
                                             &sdbg_host->dev_info_list,
@@ -1496,7 +1524,7 @@
 
 	device_register(&pseudo_primary);
 	bus_register(&pseudo_lld_bus);
-	scsi_debug_register_driver(&sdebug_driverfs_driver);
+	driver_register(&sdebug_driverfs_driver);
 	do_create_driverfs_files();
 
 	sdebug_driver_template.proc_name = (char *)sdebug_proc_name;
@@ -1521,10 +1549,13 @@
 
 static void __exit scsi_debug_exit(void)
 {
-	/* free up adapters here ?? */
+	int k = scsi_debug_add_host;
+
 	stop_all_queued();
+	for (; k; k--)
+		sdebug_remove_adapter();
 	do_remove_driverfs_files();
-	scsi_debug_unregister_driver(&sdebug_driverfs_driver);
+	driver_unregister(&sdebug_driverfs_driver);
 	bus_unregister(&pseudo_lld_bus);
 	device_unregister(&pseudo_primary);
 
@@ -1550,51 +1581,76 @@
         .match = pseudo_lld_bus_match,
 };
 
-static int scsi_debug_register_driver(struct device_driver *dev_driver)
-{
-	dev_driver->bus = &pseudo_lld_bus;
-	driver_register(dev_driver);
-
-	return 0;
-}
-
-static int scsi_debug_unregister_driver(struct device_driver *dev_driver)
-{
-	driver_unregister(dev_driver);
-	return 0;
-}
-
 static void sdebug_release_adapter(struct device * dev)
 {
-        kfree(dev);
+        struct sdebug_host_info *sdbg_host;
+
+	sdbg_host = to_sdebug_host(dev);
+        kfree(sdbg_host);
 }
 
 static int sdebug_add_adapter()
 {
-        struct device * dev;
-        int error;
+	int k, devs_per_host;
+        int error = 0;
+        struct sdebug_host_info *sdbg_host;
+        struct sdebug_dev_info *sdbg_devinfo;
+        struct list_head *lh, *lh_sf;
+
+        sdbg_host = kmalloc(sizeof(*sdbg_host),GFP_KERNEL);
 
-        dev = kmalloc(sizeof(*dev),GFP_KERNEL);
-        if (NULL == dev) {
+        if (NULL == sdbg_host) {
                 printk(KERN_ERR "%s: out of memory at line %d\n",
                        __FUNCTION__, __LINE__);
                 return -ENOMEM;
         }
-        memset(dev, 0, sizeof(*dev));
 
-        dev->bus = &pseudo_lld_bus;
-        dev->parent = &pseudo_primary;
-        dev->release = &sdebug_release_adapter;
-        sprintf(dev->name, "scsi debug adapter");
-        sprintf(dev->bus_id, "adapter%d", scsi_debug_add_host);
+        memset(sdbg_host, 0, sizeof(*sdbg_host));
+        INIT_LIST_HEAD(&sdbg_host->dev_info_list);
+
+	devs_per_host = scsi_debug_num_tgts * scsi_debug_max_luns;
+        for (k = 0; k < devs_per_host; k++) {
+                sdbg_devinfo = kmalloc(sizeof(*sdbg_devinfo),GFP_KERNEL);
+                if (NULL == sdbg_devinfo) {
+                        printk(KERN_ERR "%s: out of memory at line %d\n",
+                               __FUNCTION__, __LINE__);
+                        error = -ENOMEM;
+			goto clean1;
+                }
+                memset(sdbg_devinfo, 0, sizeof(*sdbg_devinfo));
+                sdbg_devinfo->sdbg_host = sdbg_host;
+                list_add_tail(&sdbg_devinfo->dev_list,
+                              &sdbg_host->dev_info_list);
+        }
+
+        spin_lock(&sdebug_host_list_lock);
+        list_add_tail(&sdbg_host->host_list, &sdebug_host_list);
+        spin_unlock(&sdebug_host_list_lock);
+
+        sdbg_host->dev.bus = &pseudo_lld_bus;
+        sdbg_host->dev.parent = &pseudo_primary;
+        sdbg_host->dev.release = &sdebug_release_adapter;
+        sprintf(sdbg_host->dev.name, "scsi debug adapter");
+        sprintf(sdbg_host->dev.bus_id, "adapter%d", scsi_debug_add_host);
 
-        error = device_register(dev);
+        error = device_register(&sdbg_host->dev);
 
         if (error)
-                kfree(dev);
-        else
-                ++scsi_debug_add_host;
+		goto clean2;
+
+	++scsi_debug_add_host;
+        return error;
+
+clean2:
+	list_for_each_safe(lh, lh_sf, &sdbg_host->dev_info_list) {
+		sdbg_devinfo = list_entry(lh, struct sdebug_dev_info,
+					  dev_list);
+		list_del(&sdbg_devinfo->dev_list);
+		kfree(sdbg_devinfo);
+	}
 
+clean1:
+	kfree(sdbg_host);
         return error;
 }
 
@@ -1603,86 +1659,50 @@
         struct sdebug_host_info * sdbg_host = NULL;
 
         spin_lock(&sdebug_host_list_lock);
-        if (!list_empty(&sdebug_host_list))
+        if (!list_empty(&sdebug_host_list)) {
                 sdbg_host = list_entry(sdebug_host_list.prev,
                                        struct sdebug_host_info, host_list);
+		list_del(&sdbg_host->host_list);
+	}
         spin_unlock(&sdebug_host_list_lock);
 
-        device_unregister(sdbg_host->dev);
+	if (!sdbg_host)
+		return;
+
+        device_unregister(&sdbg_host->dev);
         --scsi_debug_add_host;
 }
 
 static int sdebug_driver_probe(struct device * dev)
 {
-	int k, devs_per_host;
         int error = 0;
         struct sdebug_host_info *sdbg_host;
-        struct sdebug_dev_info *sdbg_devinfo;
-        struct list_head *lh, *lh_sf;
         struct Scsi_Host *hpnt;
 
-        sdbg_host = kmalloc(sizeof(*sdbg_host),GFP_KERNEL);
-        if (NULL == sdbg_host) {
-                printk(KERN_ERR "%s: out of memory at line %d\n",
-                       __FUNCTION__, __LINE__);
-                return -ENOMEM;
-        }
-        memset(sdbg_host, 0, sizeof(*sdbg_host));
-
-        INIT_LIST_HEAD(&sdbg_host->dev_info_list);
+	sdbg_host = to_sdebug_host(dev);
 
-	devs_per_host = scsi_debug_num_tgts * scsi_debug_max_luns;
-        for (k = 0; k < devs_per_host; k++) {
-                sdbg_devinfo = kmalloc(sizeof(*sdbg_devinfo),GFP_KERNEL);
-                if (NULL == sdbg_devinfo) {
-                        printk(KERN_ERR "%s: out of memory at line %d\n",
-                               __FUNCTION__, __LINE__);
-                        error = -ENOMEM;
-                }
-                memset(sdbg_devinfo, 0, sizeof(*sdbg_devinfo));
-                sdbg_devinfo->sdbg_host = sdbg_host;
-                list_add_tail(&sdbg_devinfo->dev_list,
-                              &sdbg_host->dev_info_list);
-        }
-
-        list_add_tail(&sdbg_host->host_list, &sdebug_host_list);
-
-        hpnt = scsi_register(&sdebug_driver_template, 0);
+        hpnt = scsi_register(&sdebug_driver_template, sizeof(sdbg_host));
         if (NULL == hpnt) {
                 printk(KERN_ERR "%s: scsi_register failed\n", __FUNCTION__);
                 error = -ENODEV;
-                goto clean1;
+		return error;
         }
 
         sdbg_host->shost = hpnt;
-        sdbg_host->dev = dev;
+	*((struct sdebug_host_info **)hpnt->hostdata) = sdbg_host;
 	if ((hpnt->this_id >= 0) && (scsi_debug_num_tgts > hpnt->this_id))
 		hpnt->max_id = scsi_debug_num_tgts + 1;
 	else
 		hpnt->max_id = scsi_debug_num_tgts;
 	hpnt->max_lun = scsi_debug_max_luns;
 
-        error = scsi_add_host(hpnt, sdbg_host->dev);
+        error = scsi_add_host(hpnt, &sdbg_host->dev);
         if (error) {
                 printk(KERN_ERR "%s: scsi_add_host failed\n", __FUNCTION__);
                 error = -ENODEV;
-                goto clean2;
-        }
-
-
-        return 0;
-
-clean2:
-        scsi_unregister(hpnt);
-clean1:
-        list_for_each_safe(lh, lh_sf, &sdbg_host->dev_info_list) {
-                sdbg_devinfo = list_entry(lh, struct sdebug_dev_info,
-                                          dev_list);
-                list_del(&sdbg_devinfo->dev_list);
-                kfree(sdbg_devinfo);
+		scsi_unregister(hpnt);
         }
 
-        kfree(sdbg_host);
 
         return error;
 }
@@ -1690,25 +1710,16 @@
 static int sdebug_driver_remove(struct device * dev)
 {
         struct list_head *lh, *lh_sf;
+        struct sdebug_host_info *sdbg_host;
         struct sdebug_dev_info *sdbg_devinfo;
-        struct sdebug_host_info *sdbg_host, *found = NULL;
 
-        spin_lock(&sdebug_host_list_lock);
-        list_for_each_entry(sdbg_host, &sdebug_host_list, host_list) {
-                if (sdbg_host->dev == dev) {
-                        list_del(&sdbg_host->host_list);
-                        found = sdbg_host;
-                        break;
-                }
-        }
-        spin_unlock(&sdebug_host_list_lock);
-
-        if (!found) {
-                printk(KERN_ERR "%s: sdebug_host_info not found\n",
-                       __FUNCTION__);
-                return -ENODEV;
-        }
+	sdbg_host = to_sdebug_host(dev);
 
+	if (!sdbg_host) {
+		printk(KERN_ERR "%s: Unable to locate host info\n",
+		       __FUNCTION__);
+		return -ENODEV;
+	}
 
         if (scsi_remove_host(sdbg_host->shost)) {
                 printk(KERN_ERR "%s: scsi_remove_host failed\n", __FUNCTION__);
@@ -1724,7 +1735,5 @@
                 kfree(sdbg_devinfo);
         }
 
-        kfree(sdbg_host);
-
         return 0;
 }
diff -urN linux-2.5.69-bk7/drivers/scsi/scsi_debug.h linux-2.5.69-bk8/drivers/scsi/scsi_debug.h
--- linux-2.5.69-bk7/drivers/scsi/scsi_debug.h	2003-05-04 16:53:14.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/scsi_debug.h	2003-05-13 04:44:29.000000000 -0700
@@ -24,28 +24,4 @@
 
 #define SCSI_DEBUG_MAX_CMD_LEN 16
 
-static Scsi_Host_Template sdebug_driver_template = {
-	.proc_info =		scsi_debug_proc_info,
-	.name =			"SCSI DEBUG",
-	.info =			scsi_debug_info,
-	.slave_alloc =		scsi_debug_slave_alloc,
-	.slave_configure =	scsi_debug_slave_configure,
-	.slave_destroy =	scsi_debug_slave_destroy,
-	.ioctl =		scsi_debug_ioctl,
-	.queuecommand =		scsi_debug_queuecommand,
-	.eh_abort_handler =	scsi_debug_abort,
-	.eh_bus_reset_handler = scsi_debug_bus_reset,
-	.eh_device_reset_handler = scsi_debug_device_reset,
-	.eh_host_reset_handler = scsi_debug_host_reset,
-	.bios_param =		scsi_debug_biosparam,
-	.can_queue =		SCSI_DEBUG_CANQUEUE,
-	.this_id =		7,
-	.sg_tablesize =		64,
-	.cmd_per_lun =		3,
-	.max_sectors =		4096,
-	.unchecked_isa_dma = 	0,
-	.use_clustering = 	ENABLE_CLUSTERING,
-	.module =		THIS_MODULE,
-};
-
 #endif
diff -urN linux-2.5.69-bk7/drivers/scsi/scsi_devinfo.c linux-2.5.69-bk8/drivers/scsi/scsi_devinfo.c
--- linux-2.5.69-bk7/drivers/scsi/scsi_devinfo.c	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.5.69-bk8/drivers/scsi/scsi_devinfo.c	2003-05-13 04:44:29.000000000 -0700
@@ -0,0 +1,542 @@
+
+#include <linux/blkdev.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
+
+#include "scsi.h"
+#include "scsi_priv.h"
+#include "scsi_devinfo.h"
+
+/*
+ * scsi_dev_info_list: structure to hold black/white listed devices.
+ */
+struct scsi_dev_info_list {
+	struct list_head dev_info_list;
+	char vendor[8];
+	char model[16];
+	unsigned flags;
+	unsigned compatible; /* for use with scsi_static_device_list entries */
+};
+
+
+static const char spaces[] = "                "; /* 16 of them */
+static char *scsi_dev_flags;
+static unsigned scsi_default_dev_flags;
+static LIST_HEAD(scsi_dev_info_list);
+
+/*
+ * scsi_static_device_list: deprecated list of devices that require
+ * settings that differ from the default, includes black-listed (broken)
+ * devices. The entries here are added to the tail of scsi_dev_info_list
+ * via scsi_dev_info_list_init.
+ *
+ * Do not add to this list, use the command line or proc interface to add
+ * to the scsi_dev_info_list. This table will eventually go away.
+ */
+static struct {
+	char *vendor;
+	char *model;
+	char *revision;	/* revision known to be bad, unused */
+	unsigned flags;
+} scsi_static_device_list[] __initdata = {
+	/*
+	 * The following devices are known not to tolerate a lun != 0 scan
+	 * for one reason or another. Some will respond to all luns,
+	 * others will lock up.
+	 */
+	{"Aashima", "IMAGERY 2400SP", "1.03", BLIST_NOLUN},	/* locks up */
+	{"CHINON", "CD-ROM CDS-431", "H42", BLIST_NOLUN},	/* locks up */
+	{"CHINON", "CD-ROM CDS-535", "Q14", BLIST_NOLUN},	/* locks up */
+	{"DENON", "DRD-25X", "V", BLIST_NOLUN},			/* locks up */
+	{"HITACHI", "DK312C", "CM81", BLIST_NOLUN},	/* responds to all lun */
+	{"HITACHI", "DK314C", "CR21", BLIST_NOLUN},	/* responds to all lun */
+	{"IMS", "CDD521/10", "2.06", BLIST_NOLUN},	/* locks up */
+	{"MAXTOR", "XT-3280", "PR02", BLIST_NOLUN},	/* locks up */
+	{"MAXTOR", "XT-4380S", "B3C", BLIST_NOLUN},	/* locks up */
+	{"MAXTOR", "MXT-1240S", "I1.2", BLIST_NOLUN},	/* locks up */
+	{"MAXTOR", "XT-4170S", "B5A", BLIST_NOLUN},	/* locks up */
+	{"MAXTOR", "XT-8760S", "B7B", BLIST_NOLUN},	/* locks up */
+	{"MEDIAVIS", "RENO CD-ROMX2A", "2.03", BLIST_NOLUN},	/* responds to all lun */
+	{"NEC", "CD-ROM DRIVE:841", "1.0", BLIST_NOLUN},/* locks up */
+	{"PHILIPS", "PCA80SC", "V4-2", BLIST_NOLUN},	/* responds to all lun */
+	{"RODIME", "RO3000S", "2.33", BLIST_NOLUN},	/* locks up */
+	{"SUN", "SENA", NULL, BLIST_NOLUN},		/* responds to all luns */
+	/*
+	 * The following causes a failed REQUEST SENSE on lun 1 for
+	 * aha152x controller, which causes SCSI code to reset bus.
+	 */
+	{"SANYO", "CRD-250S", "1.20", BLIST_NOLUN},
+	/*
+	 * The following causes a failed REQUEST SENSE on lun 1 for
+	 * aha152x controller, which causes SCSI code to reset bus.
+	 */
+	{"SEAGATE", "ST157N", "\004|j", BLIST_NOLUN},
+	{"SEAGATE", "ST296", "921", BLIST_NOLUN},	/* responds to all lun */
+	{"SEAGATE", "ST1581", "6538", BLIST_NOLUN},	/* responds to all lun */
+	{"SONY", "CD-ROM CDU-541", "4.3d", BLIST_NOLUN},
+	{"SONY", "CD-ROM CDU-55S", "1.0i", BLIST_NOLUN},
+	{"SONY", "CD-ROM CDU-561", "1.7x", BLIST_NOLUN},
+	{"SONY", "CD-ROM CDU-8012", NULL, BLIST_NOLUN},
+	{"TANDBERG", "TDC 3600", "U07", BLIST_NOLUN},	/* locks up */
+	{"TEAC", "CD-R55S", "1.0H", BLIST_NOLUN},	/* locks up */
+	/*
+	 * The following causes a failed REQUEST SENSE on lun 1 for
+	 * seagate controller, which causes SCSI code to reset bus.
+	 */
+	{"TEAC", "CD-ROM", "1.06", BLIST_NOLUN},
+	{"TEAC", "MT-2ST/45S2-27", "RV M", BLIST_NOLUN},	/* responds to all lun */
+	/*
+	 * The following causes a failed REQUEST SENSE on lun 1 for
+	 * seagate controller, which causes SCSI code to reset bus.
+	 */
+	{"TEXEL", "CD-ROM", "1.06", BLIST_NOLUN},
+	{"QUANTUM", "LPS525S", "3110", BLIST_NOLUN},	/* locks up */
+	{"QUANTUM", "PD1225S", "3110", BLIST_NOLUN},	/* locks up */
+	{"QUANTUM", "FIREBALL ST4.3S", "0F0C", BLIST_NOLUN},	/* locks up */
+	{"MEDIAVIS", "CDR-H93MV", "1.31", BLIST_NOLUN},	/* locks up */
+	{"SANKYO", "CP525", "6.64", BLIST_NOLUN},	/* causes failed REQ SENSE, extra reset */
+	{"HP", "C1750A", "3226", BLIST_NOLUN},		/* scanjet iic */
+	{"HP", "C1790A", "", BLIST_NOLUN},		/* scanjet iip */
+	{"HP", "C2500A", "", BLIST_NOLUN},		/* scanjet iicx */
+	{"YAMAHA", "CDR100", "1.00", BLIST_NOLUN},	/* locks up */
+	{"YAMAHA", "CDR102", "1.00", BLIST_NOLUN},	/* locks up */
+	{"YAMAHA", "CRW8424S", "1.0", BLIST_NOLUN},	/* locks up */
+	{"YAMAHA", "CRW6416S", "1.0c", BLIST_NOLUN},	/* locks up */
+	{"MITSUMI", "CD-R CR-2201CS", "6119", BLIST_NOLUN},	/* locks up */
+	{"RELISYS", "Scorpio", NULL, BLIST_NOLUN},	/* responds to all lun */
+	{"MICROTEK", "ScanMaker II", "5.61", BLIST_NOLUN},	/* responds to all lun */
+	{"NEC", "D3856", "0009", BLIST_NOLUN},
+
+	/*
+	 * Other types of devices that have special flags.
+	 */
+	{"SONY", "CD-ROM CDU-8001", NULL, BLIST_BORKEN},
+	{"TEXEL", "CD-ROM", "1.06", BLIST_BORKEN},
+	{"IOMEGA", "Io20S         *F", NULL, BLIST_KEY},
+	{"INSITE", "Floptical   F*8I", NULL, BLIST_KEY},
+	{"INSITE", "I325VM", NULL, BLIST_KEY},
+	{"LASOUND", "CDX7405", "3.10", BLIST_MAX5LUN | BLIST_SINGLELUN},
+	{"MICROP", "4110", NULL, BLIST_NOTQ},
+	{"NRC", "MBR-7", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
+	{"NRC", "MBR-7.4", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
+	{"REGAL", "CDC-4X", NULL, BLIST_MAX5LUN | BLIST_SINGLELUN},
+	{"NAKAMICH", "MJ-4.8S", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
+	{"NAKAMICH", "MJ-5.16S", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
+	{"PIONEER", "CD-ROM DRM-600", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
+	{"PIONEER", "CD-ROM DRM-602X", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
+	{"PIONEER", "CD-ROM DRM-604X", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
+	{"EMULEX", "MD21/S2     ESDI", NULL, BLIST_SINGLELUN},
+	{"CANON", "IPUBJD", NULL, BLIST_SPARSELUN},
+	{"nCipher", "Fastness Crypto", NULL, BLIST_FORCELUN},
+	{"DEC", "HSG80", NULL, BLIST_FORCELUN},
+	{"COMPAQ", "LOGICAL VOLUME", NULL, BLIST_FORCELUN},
+	{"COMPAQ", "CR3500", NULL, BLIST_FORCELUN},
+	{"NEC", "PD-1 ODX654P", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
+	{"MATSHITA", "PD-1", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
+	{"iomega", "jaz 1GB", "J.86", BLIST_NOTQ | BLIST_NOLUN},
+	{"TOSHIBA", "CDROM", NULL, BLIST_ISROM},
+	{"TOSHIBA", "CD-ROM", NULL, BLIST_ISROM},
+	{"MegaRAID", "LD", NULL, BLIST_FORCELUN},
+	{"DGC", "RAID", NULL, BLIST_SPARSELUN},	/* Dell PV 650F, storage on LUN 0 */
+	{"DGC", "DISK", NULL, BLIST_SPARSELUN},	/* Dell PV 650F, no storage on LUN 0 */
+	{"DELL", "PV660F", NULL, BLIST_SPARSELUN},
+	{"DELL", "PV660F   PSEUDO", NULL, BLIST_SPARSELUN},
+	{"DELL", "PSEUDO DEVICE .", NULL, BLIST_SPARSELUN},	/* Dell PV 530F */
+	{"DELL", "PV530F", NULL, BLIST_SPARSELUN},
+	{"EMC", "SYMMETRIX", NULL, BLIST_SPARSELUN | BLIST_LARGELUN | BLIST_FORCELUN},
+	{"HP", "A6189A", NULL, BLIST_SPARSELUN | BLIST_LARGELUN},	/* HP VA7400 */
+	{"HP", "OPEN-", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, /* HP XP Arrays */
+	{"CMD", "CRA-7280", NULL, BLIST_SPARSELUN},	/* CMD RAID Controller */
+	{"CNSI", "G7324", NULL, BLIST_SPARSELUN},	/* Chaparral G7324 RAID */
+	{"CNSi", "G8324", NULL, BLIST_SPARSELUN},	/* Chaparral G8324 RAID */
+	{"Zzyzx", "RocketStor 500S", NULL, BLIST_SPARSELUN},
+	{"Zzyzx", "RocketStor 2000", NULL, BLIST_SPARSELUN},
+	{"SONY", "TSL", NULL, BLIST_FORCELUN},		/* DDS3 & DDS4 autoloaders */
+	{"DELL", "PERCRAID", NULL, BLIST_FORCELUN},
+	{"HP", "NetRAID-4M", NULL, BLIST_FORCELUN},
+	{"ADAPTEC", "AACRAID", NULL, BLIST_FORCELUN},
+	{"ADAPTEC", "Adaptec 5400S", NULL, BLIST_FORCELUN},
+	{"COMPAQ", "MSA1000", NULL, BLIST_FORCELUN},
+	{"HP", "C1557A", NULL, BLIST_FORCELUN},
+	{"IBM", "AuSaV1S2", NULL, BLIST_FORCELUN},
+	{"FSC", "CentricStor", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
+	{"DDN", "SAN DataDirector", "*", BLIST_SPARSELUN},
+	{"HITACHI", "DF400", "*", BLIST_SPARSELUN},
+	{"HITACHI", "DF500", "*", BLIST_SPARSELUN},
+	{"HITACHI", "DF600", "*", BLIST_SPARSELUN},
+	{"IBM", "ProFibre 4000R", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
+	{"SUN", "T300", "*", BLIST_SPARSELUN},
+	{"SUN", "T4", "*", BLIST_SPARSELUN},
+	{"SGI", "RAID3", "*", BLIST_SPARSELUN},
+	{"SGI", "RAID5", "*", BLIST_SPARSELUN},
+	{"SGI", "TP9100", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
+	{"SGI", "TP9300", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
+	{"SGI", "TP9400", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
+	{"SGI", "TP9500", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
+	{"MYLEX", "DACARMRB", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
+	{ NULL, NULL, NULL, 0 },
+};
+
+/*
+ * scsi_strcpy_devinfo: called from scsi_dev_info_list_add to copy into
+ * devinfo vendor and model strings.
+ */
+static void scsi_strcpy_devinfo(char *name, char *to, size_t to_length,
+				char *from, int compatible)
+{
+	size_t from_length;
+
+	from_length = strlen(from);
+	strncpy(to, from, min(to_length, from_length));
+	if (from_length < to_length) {
+		if (compatible) {
+			/*
+			 * NUL terminate the string if it is short.
+			 */
+			to[from_length] = '\0';
+		} else {
+			/* 
+			 * space pad the string if it is short. 
+			 */
+			strncpy(&to[from_length], spaces,
+				to_length - from_length);
+		}
+	}
+	if (from_length > to_length)
+		 printk(KERN_WARNING "%s: %s string '%s' is too long\n",
+			__FUNCTION__, name, from);
+}
+
+/**
+ * scsi_dev_info_list_add: add one dev_info list entry.
+ * @vendor:	vendor string
+ * @model:	model (product) string
+ * @strflags:	integer string
+ * @flag:	if strflags NULL, use this flag value
+ *
+ * Description:
+ * 	Create and add one dev_info entry for @vendor, @model, @strflags or
+ * 	@flag. If @compatible, add to the tail of the list, do not space
+ * 	pad, and set devinfo->compatible. The scsi_static_device_list entries
+ * 	are added with @compatible 1 and @clfags NULL.
+ *
+ * Returns: 0 OK, -error on failure.
+ **/
+static int scsi_dev_info_list_add(int compatible, char *vendor, char *model,
+			    char *strflags, int flags)
+{
+	struct scsi_dev_info_list *devinfo;
+
+	devinfo = kmalloc(sizeof(*devinfo), GFP_KERNEL);
+	if (!devinfo) {
+		printk(KERN_ERR "%s: no memory\n", __FUNCTION__);
+		return -ENOMEM;
+	}
+
+	scsi_strcpy_devinfo("vendor", devinfo->vendor, sizeof(devinfo->vendor),
+			    vendor, compatible);
+	scsi_strcpy_devinfo("model", devinfo->model, sizeof(devinfo->model),
+			    model, compatible);
+
+	if (strflags)
+		devinfo->flags = simple_strtoul(strflags, NULL, 0);
+	else
+		devinfo->flags = flags;
+
+	devinfo->compatible = compatible;
+
+	if (compatible)
+		list_add_tail(&devinfo->dev_info_list, &scsi_dev_info_list);
+	else
+		list_add(&devinfo->dev_info_list, &scsi_dev_info_list);
+
+	return 0;
+}
+
+/**
+ * scsi_dev_info_list_add_str: parse dev_list and add to the
+ * scsi_dev_info_list.
+ * @dev_list:	string of device flags to add
+ *
+ * Description:
+ * 	Parse dev_list, and add entries to the scsi_dev_info_list.
+ * 	dev_list is of the form "vendor:product:flag,vendor:product:flag".
+ * 	dev_list is modified via strsep. Can be called for command line
+ * 	addition, for proc or mabye a sysfs interface.
+ *
+ * Returns: 0 if OK, -error on failure.
+ **/
+static int scsi_dev_info_list_add_str(char *dev_list)
+{
+	char *vendor, *model, *strflags, *next;
+	char *next_check;
+	int res = 0;
+
+	next = dev_list;
+	if (next && next[0] == '"') {
+		/*
+		 * Ignore both the leading and trailing quote.
+		 */
+		next++;
+		next_check = ",\"";
+	} else {
+		next_check = ",";
+	}
+
+	/*
+	 * For the leading and trailing '"' case, the for loop comes
+	 * through the last time with vendor[0] == '\0'.
+	 */
+	for (vendor = strsep(&next, ":"); vendor && (vendor[0] != '\0')
+	     && (res == 0); vendor = strsep(&next, ":")) {
+		strflags = NULL;
+		model = strsep(&next, ":");
+		if (model)
+			strflags = strsep(&next, next_check);
+		if (!model || !strflags) {
+			printk(KERN_ERR "%s: bad dev info string '%s' '%s'"
+			       " '%s'\n", __FUNCTION__, vendor, model,
+			       strflags);
+			res = -EINVAL;
+		} else
+			res = scsi_dev_info_list_add(0 /* compatible */, vendor,
+						     model, strflags, 0);
+	}
+	return res;
+}
+
+/**
+ * get_device_flags - get device specific flags from the dynamic device
+ * list. Called during scan time.
+ * @vendor:	vendor name
+ * @model:	model name
+ *
+ * Description:
+ *     Search the scsi_dev_info_list for an entry matching @vendor and
+ *     @model, if found, return the matching flags value, else return
+ *     scsi_default_dev_flags.
+ **/
+int scsi_get_device_flags(unsigned char *vendor, unsigned char *model)
+{
+	struct scsi_dev_info_list *devinfo;
+
+	list_for_each_entry(devinfo, &scsi_dev_info_list, dev_info_list) {
+		if (devinfo->compatible) {
+			/*
+			 * Behave like the older version of get_device_flags.
+			 */
+			size_t max;
+			/*
+			 * XXX why skip leading spaces? If an odd INQUIRY
+			 * value, that should have been part of the
+			 * scsi_static_device_list[] entry, such as "  FOO"
+			 * rather than "FOO". Since this code is already
+			 * here, and we don't know what device it is
+			 * trying to work with, leave it as-is.
+			 */
+			max = 8;	/* max length of vendor */
+			while ((max > 0) && *vendor == ' ') {
+				max--;
+				vendor++;
+			}
+			/*
+			 * XXX removing the following strlen() would be
+			 * good, using it means that for a an entry not in
+			 * the list, we scan every byte of every vendor
+			 * listed in scsi_static_device_list[], and never match
+			 * a single one (and still have to compare at
+			 * least the first byte of each vendor).
+			 */
+			if (memcmp(devinfo->vendor, vendor,
+				    min(max, strlen(devinfo->vendor))))
+				continue;
+			/*
+			 * Skip spaces again.
+			 */
+			max = 16;	/* max length of model */
+			while ((max > 0) && *model == ' ') {
+				max--;
+				model++;
+			}
+			if (memcmp(devinfo->model, model,
+				   min(max, strlen(devinfo->model))))
+				continue;
+			return devinfo->flags;
+		} else {
+			if (!memcmp(devinfo->vendor, vendor,
+				     sizeof(devinfo->vendor)) &&
+			     !memcmp(devinfo->model, model,
+				      sizeof(devinfo->model)))
+				return devinfo->flags;
+		}
+	}
+	return scsi_default_dev_flags;
+}
+
+/* 
+ * proc_scsi_dev_info_read: dump the scsi_dev_info_list via
+ * /proc/scsi/device_info
+ */
+static int proc_scsi_devinfo_read(char *buffer, char **start,
+				  off_t offset, int length)
+{
+	struct scsi_dev_info_list *devinfo;
+	int size, len = 0;
+	off_t begin = 0;
+	off_t pos = 0;
+
+	list_for_each_entry(devinfo, &scsi_dev_info_list, dev_info_list) {
+		size = sprintf(buffer + len, "'%.8s' '%.16s' 0x%x\n",
+			devinfo->vendor, devinfo->model, devinfo->flags);
+		len += size;
+		pos = begin + len;
+		if (pos < offset) {
+			len = 0;
+			begin = pos;
+		}
+		if (pos > offset + length)
+			goto stop_output;
+	}
+
+stop_output:
+	*start = buffer + (offset - begin);	/* Start of wanted data */
+	len -= (offset - begin);	/* Start slop */
+	if (len > length)
+		len = length;	/* Ending slop */
+	return (len);
+}
+
+/* 
+ * proc_scsi_dev_info_write: allow additions to the scsi_dev_info_list via
+ * /proc.
+ *
+ * Use: echo "vendor:model:flag" > /proc/scsi/device_info
+ *
+ * To add a black/white list entry for vendor and model with an integer
+ * value of flag to the scsi device info list.
+ */
+static int proc_scsi_devinfo_write(struct file *file, const char *buf,
+				   unsigned long length, void *data)
+{
+	char *buffer;
+	int err = length;
+
+	if (!buf || length>PAGE_SIZE)
+		return -EINVAL;
+	if (!(buffer = (char *) __get_free_page(GFP_KERNEL)))
+		return -ENOMEM;
+	if (copy_from_user(buffer, buf, length)) {
+		err =-EFAULT;
+		goto out;
+	}
+
+	if (length < PAGE_SIZE)
+		buffer[length] = '\0';
+	else if (buffer[PAGE_SIZE-1]) {
+		err = -EINVAL;
+		goto out;
+	}
+
+	scsi_dev_info_list_add_str(buffer);
+
+out:
+	free_page((unsigned long)buffer);
+	return err;
+}
+
+MODULE_PARM(scsi_dev_flags, "s");
+MODULE_PARM_DESC(scsi_dev_flags,
+	 "Given scsi_dev_flags=vendor:model:flags, add a black/white list"
+	 " entry for vendor and model with an integer value of flags"
+	 " to the scsi device info list");
+MODULE_PARM(scsi_default_dev_flags, "i");
+MODULE_PARM_DESC(scsi_default_dev_flags,
+		 "scsi default device flag integer value");
+
+static int __init setup_scsi_dev_flags(char *str)
+{
+	scsi_dev_flags = str;
+	return 1;
+}
+
+static int __init setup_scsi_default_dev_flags(char *str)
+{
+	unsigned int tmp;
+	if (get_option(&str, &tmp) == 1) {
+		scsi_default_dev_flags = tmp;
+		printk(KERN_WARNING "%s %d\n", __FUNCTION__,
+		       scsi_default_dev_flags);
+		return 1;
+	} else {
+		printk(KERN_WARNING "%s: usage scsi_default_dev_flags=intr\n",
+		       __FUNCTION__);
+		return 0;
+	}
+}
+
+/**
+ * scsi_dev_info_list_delete: called from scsi.c:exit_scsi to remove
+ * 	the scsi_dev_info_list.
+ **/
+void scsi_exit_devinfo(void)
+{
+	struct list_head *lh, *lh_next;
+	struct scsi_dev_info_list *devinfo;
+
+	remove_proc_entry("scsi/device_info", 0);
+
+	list_for_each_safe(lh, lh_next, &scsi_dev_info_list) {
+		devinfo = list_entry(lh, struct scsi_dev_info_list,
+				     dev_info_list);
+		kfree(devinfo);
+	}
+}
+
+/**
+ * scsi_dev_list_init: set up the dynamic device list.
+ * @dev_list:	string of device flags to add
+ *
+ * Description:
+ * 	Add command line @dev_list entries, then add
+ * 	scsi_static_device_list entries to the scsi device info list.
+ **/
+int scsi_init_devinfo(void)
+{
+	struct proc_dir_entry *p;
+	int error, i;
+
+	error = scsi_dev_info_list_add_str(scsi_dev_flags);
+	if (error)
+		return error;
+
+	for (i = 0; scsi_static_device_list[i].vendor; i++) {
+		error = scsi_dev_info_list_add(1 /* compatibile */,
+				scsi_static_device_list[i].vendor,
+				scsi_static_device_list[i].model,
+				NULL,
+				scsi_static_device_list[i].flags);
+		if (error)
+			goto out;
+	}
+
+	p = create_proc_entry("scsi/device_info", 0, NULL);
+	if (!p) {
+		error = -ENOMEM;
+		goto out;
+	}
+
+	p->owner = THIS_MODULE;
+	p->get_info = proc_scsi_devinfo_read;
+	p->write_proc = proc_scsi_devinfo_write;
+
+ out:
+	if (error)
+		scsi_exit_devinfo();
+	return error;
+}
+
+__setup("scsi_dev_flags=", setup_scsi_dev_flags);
+__setup("scsi_default_dev_flags=", setup_scsi_default_dev_flags);
diff -urN linux-2.5.69-bk7/drivers/scsi/scsi_devinfo.h linux-2.5.69-bk8/drivers/scsi/scsi_devinfo.h
--- linux-2.5.69-bk7/drivers/scsi/scsi_devinfo.h	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.5.69-bk8/drivers/scsi/scsi_devinfo.h	2003-05-13 04:44:29.000000000 -0700
@@ -0,0 +1,16 @@
+
+/*
+ * Flags for SCSI devices that need special treatment
+ */
+#define BLIST_NOLUN     	0x001	/* Only scan LUN 0 */
+#define BLIST_FORCELUN  	0x002	/* Known to have LUNs, force scanning */
+#define BLIST_BORKEN    	0x004	/* Flag for broken handshaking */
+#define BLIST_KEY       	0x008	/* unlock by special command */
+#define BLIST_SINGLELUN 	0x010	/* Do not use LUNs in parallel */
+#define BLIST_NOTQ		0x020	/* Buggy Tagged Command Queuing */
+#define BLIST_SPARSELUN 	0x040	/* Non consecutive LUN numbering */
+#define BLIST_MAX5LUN		0x080	/* Avoid LUNS >= 5 */
+#define BLIST_ISROM     	0x100	/* Treat as (removable) CD-ROM */
+#define BLIST_LARGELUN		0x200	/* LUNs past 7 on a SCSI-2 device */
+#define BLIST_INQUIRY_36	0x400	/* override additional length field */
+#define BLIST_INQUIRY_58	0x800	/* ... for broken inquiry responses */
diff -urN linux-2.5.69-bk7/drivers/scsi/scsi_error.c linux-2.5.69-bk8/drivers/scsi/scsi_error.c
--- linux-2.5.69-bk7/drivers/scsi/scsi_error.c	2003-05-04 16:52:48.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/scsi_error.c	2003-05-13 04:44:29.000000000 -0700
@@ -28,6 +28,9 @@
 #include "scsi.h"
 #include "hosts.h"
 
+#include "scsi_priv.h"
+#include "scsi_logging.h"
+
 #ifdef DEBUG
 #define SENSE_TIMEOUT SCSI_TIMEOUT
 #else
@@ -188,7 +191,7 @@
 	return sdev->online;
 }
 
-#if CONFIG_SCSI_LOGGING
+#ifdef CONFIG_SCSI_LOGGING
 /**
  * scsi_eh_prt_fail_stats - Log info on failures.
  * @shost:	scsi host being recovered.
@@ -916,7 +919,6 @@
  **/
 static int scsi_try_bus_reset(struct scsi_cmnd *scmd)
 {
-	struct scsi_device *sdev;
 	unsigned long flags;
 	int rtn;
 
@@ -934,16 +936,9 @@
 
 	if (rtn == SUCCESS) {
 		scsi_sleep(BUS_RESET_SETTLE_TIME);
-		/*
-		 * Mark all affected devices to expect a unit attention.
-		 */
-		list_for_each_entry(sdev, &scmd->device->host->my_devices,
-				    siblings)
-			if (scmd->device->channel == sdev->channel) {
-				sdev->was_reset = 1;
-				sdev->expecting_cc_ua = 1;
-			}
+		scsi_report_bus_reset(scmd->device->host, scmd->device->channel);
 	}
+
 	return rtn;
 }
 
@@ -953,7 +948,6 @@
  **/
 static int scsi_try_host_reset(struct scsi_cmnd *scmd)
 {
-	struct scsi_device *sdev;
 	unsigned long flags;
 	int rtn;
 
@@ -971,16 +965,9 @@
 
 	if (rtn == SUCCESS) {
 		scsi_sleep(HOST_RESET_SETTLE_TIME);
-		/*
-		 * Mark all affected devices to expect a unit attention.
-		 */
-		list_for_each_entry(sdev, &scmd->device->host->my_devices,
-				    siblings)
-			if (scmd->device->channel == sdev->channel) {
-				sdev->was_reset = 1;
-				sdev->expecting_cc_ua = 1;
-			}
+		scsi_report_bus_reset(scmd->device->host, scmd->device->channel);
 	}
+
 	return rtn;
 }
 
@@ -1425,8 +1412,7 @@
 	 * now that error recovery is done, we will need to ensure that these
 	 * requests are started.
 	 */
-	list_for_each_entry(sdev, &shost->my_devices, siblings)
-		blk_run_queue(sdev->request_queue);
+	scsi_run_host_queues(shost);
 }
 
 /**
@@ -1638,6 +1624,74 @@
 	complete_and_exit(shost->eh_notify, 0);
 }
 
+/*
+ * Function:    scsi_report_bus_reset()
+ *
+ * Purpose:     Utility function used by low-level drivers to report that
+ *		they have observed a bus reset on the bus being handled.
+ *
+ * Arguments:   shost       - Host in question
+ *		channel     - channel on which reset was observed.
+ *
+ * Returns:     Nothing
+ *
+ * Lock status: No locks are assumed held.
+ *
+ * Notes:       This only needs to be called if the reset is one which
+ *		originates from an unknown location.  Resets originated
+ *		by the mid-level itself don't need to call this, but there
+ *		should be no harm.
+ *
+ *		The main purpose of this is to make sure that a CHECK_CONDITION
+ *		is properly treated.
+ */
+void scsi_report_bus_reset(struct Scsi_Host *shost, int channel)
+{
+	struct scsi_device *sdev;
+
+	list_for_each_entry(sdev, &shost->my_devices, siblings) {
+		if (channel == sdev->channel) {
+			sdev->was_reset = 1;
+			sdev->expecting_cc_ua = 1;
+		}
+	}
+}
+
+/*
+ * Function:    scsi_report_device_reset()
+ *
+ * Purpose:     Utility function used by low-level drivers to report that
+ *		they have observed a device reset on the device being handled.
+ *
+ * Arguments:   shost       - Host in question
+ *		channel     - channel on which reset was observed
+ *		target	    - target on which reset was observed
+ *
+ * Returns:     Nothing
+ *
+ * Lock status: No locks are assumed held.
+ *
+ * Notes:       This only needs to be called if the reset is one which
+ *		originates from an unknown location.  Resets originated
+ *		by the mid-level itself don't need to call this, but there
+ *		should be no harm.
+ *
+ *		The main purpose of this is to make sure that a CHECK_CONDITION
+ *		is properly treated.
+ */
+void scsi_report_device_reset(struct Scsi_Host *shost, int channel, int target)
+{
+	struct scsi_device *sdev;
+
+	list_for_each_entry(sdev, &shost->my_devices, siblings) {
+		if (channel == sdev->channel &&
+		    target == sdev->id) {
+			sdev->was_reset = 1;
+			sdev->expecting_cc_ua = 1;
+		}
+	}
+}
+
 static void
 scsi_reset_provider_done_command(struct scsi_cmnd *scmd)
 {
@@ -1662,7 +1716,6 @@
 	struct scsi_cmnd *scmd = scsi_get_command(dev, GFP_KERNEL);
 	struct request req;
 	int rtn;
-	struct request_queue *q;
 
 	scmd->request = &req;
 	memset(&scmd->eh_timeout, 0, sizeof(scmd->eh_timeout));
@@ -1674,13 +1727,10 @@
     
 	scmd->scsi_done		= scsi_reset_provider_done_command;
 	scmd->done			= NULL;
-	scmd->reset_chain		= NULL;
-        
 	scmd->buffer			= NULL;
 	scmd->bufflen			= 0;
 	scmd->request_buffer		= NULL;
 	scmd->request_bufflen		= 0;
-
 	scmd->internal_timeout		= NORMAL_TIMEOUT;
 	scmd->abort_reason		= DID_ABORT;
 
@@ -1717,8 +1767,6 @@
 	}
 
 	scsi_delete_timer(scmd);
-	q = scmd->device->request_queue;
-	scsi_put_command(scmd);
-	scsi_queue_next_request(q, NULL);
+	scsi_next_command(scmd);
 	return rtn;
 }
diff -urN linux-2.5.69-bk7/drivers/scsi/scsi_ioctl.c linux-2.5.69-bk8/drivers/scsi/scsi_ioctl.c
--- linux-2.5.69-bk7/drivers/scsi/scsi_ioctl.c	2003-05-04 16:53:42.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/scsi_ioctl.c	2003-05-13 04:44:29.000000000 -0700
@@ -23,6 +23,8 @@
 #include "hosts.h"
 #include <scsi/scsi_ioctl.h>
 
+#include "scsi_logging.h"
+
 #define NORMAL_RETRIES			5
 #define IOCTL_NORMAL_TIMEOUT			(10 * HZ)
 #define FORMAT_UNIT_TIMEOUT		(2 * 60 * 60 * HZ)
diff -urN linux-2.5.69-bk7/drivers/scsi/scsi_lib.c linux-2.5.69-bk8/drivers/scsi/scsi_lib.c
--- linux-2.5.69-bk7/drivers/scsi/scsi_lib.c	2003-05-04 16:53:28.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/scsi_lib.c	2003-05-13 04:44:29.000000000 -0700
@@ -19,6 +19,9 @@
 #include "scsi.h"
 #include "hosts.h"
 
+#include "scsi_priv.h"
+#include "scsi_logging.h"
+
 
 #define SG_MEMPOOL_NR		5
 #define SG_MEMPOOL_SIZE		32
@@ -178,19 +181,12 @@
 		 void (*done)(struct scsi_cmnd *),
 		 int timeout, int retries)
 {
-	struct request_queue *q;
-
 	/*
 	 * If the upper level driver is reusing these things, then
 	 * we should release the low-level block now.  Another one will
 	 * be allocated later when this request is getting queued.
 	 */
-	if (sreq->sr_command) {
-		q = sreq->sr_command->device->request_queue;
-		scsi_put_command(sreq->sr_command);
-		sreq->sr_command = NULL;
-		scsi_queue_next_request(q, NULL);
-	}
+	__scsi_release_request(sreq);
 
 	/*
 	 * Our own function scsi_done (which marks the host as not busy,
@@ -236,7 +232,6 @@
 void scsi_wait_req(struct scsi_request *sreq, const void *cmnd, void *buffer,
 		   unsigned bufflen, int timeout, int retries)
 {
-	struct request_queue *q;
 	DECLARE_COMPLETION(wait);
 	
 	sreq->sr_request->waiting = &wait;
@@ -247,12 +242,7 @@
 	wait_for_completion(&wait);
 	sreq->sr_request->waiting = NULL;
 
-	if (sreq->sr_command) {
-		q = sreq->sr_command->device->request_queue;
-		scsi_put_command(sreq->sr_command);
-		scsi_queue_next_request(q, NULL);
-		sreq->sr_command = NULL;
-	}
+	__scsi_release_request(sreq);
 }
 
 /*
@@ -271,7 +261,6 @@
 static int scsi_init_cmd_errh(struct scsi_cmnd *cmd)
 {
 	cmd->owner = SCSI_OWNER_MIDLEVEL;
-	cmd->reset_chain = NULL;
 	cmd->serial_number = 0;
 	cmd->serial_number_at_timeout = 0;
 	cmd->flags = 0;
@@ -296,7 +285,6 @@
 	memcpy(cmd->data_cmnd, cmd->cmnd, sizeof(cmd->cmnd));
 	cmd->buffer = cmd->request_buffer;
 	cmd->bufflen = cmd->request_bufflen;
-	cmd->reset_chain = NULL;
 	cmd->internal_timeout = NORMAL_TIMEOUT;
 	cmd->abort_reason = 0;
 
@@ -369,77 +357,26 @@
 }
 
 /*
- * Function:    scsi_queue_next_request()
+ * Function:	scsi_run_queue()
  *
- * Purpose:     Handle post-processing of completed commands.
+ * Purpose:	Select a proper request queue to serve next
  *
- * Arguments:   cmd	- command that may need to be requeued.
+ * Arguments:	q	- last request's queue
  *
  * Returns:     Nothing
  *
- * Notes:       After command completion, there may be blocks left
- *              over which weren't finished by the previous command
- *              this can be for a number of reasons - the main one is
- *              that a medium error occurred, and the sectors after
- *              the bad block need to be re-read.
- *
- *              If cmd is NULL, it means that the previous command
- *              was completely finished, and we should simply start
- *              a new command, if possible.
- *
- *		This is where a lot of special case code has begun to
- *		accumulate.  It doesn't really affect readability or
- *		anything, but it might be considered architecturally
- *		inelegant.  If more of these special cases start to
- *		accumulate, I am thinking along the lines of implementing
- *		an atexit() like technology that gets run when commands
- *		complete.  I am not convinced that it is worth the
- *		added overhead, however.  Right now as things stand,
- *		there are simple conditional checks, and most hosts
- *		would skip past.
- *
- *		Another possible solution would be to tailor different
- *		handler functions, sort of like what we did in scsi_merge.c.
- *		This is probably a better solution, but the number of different
- *		permutations grows as 2**N, and if too many more special cases
- *		get added, we start to get screwed.
+ * Notes:	The previous command was completely finished, start
+ *		a new one if possible.
  */
-void scsi_queue_next_request(request_queue_t *q, struct scsi_cmnd *cmd)
+static void scsi_run_queue(struct request_queue *q)
 {
-	struct scsi_device *sdev;
-	struct Scsi_Host *shost;
+	struct scsi_device *sdev = q->queuedata;
+	struct Scsi_Host *shost = sdev->host;
 	unsigned long flags;
 
-	if (cmd != NULL) {
-
-		/*
-		 * For some reason, we are not done with this request.
-		 * This happens for I/O errors in the middle of the request,
-		 * in which case we need to request the blocks that come after
-		 * the bad sector.
-		 */
-		spin_lock_irqsave(q->queue_lock, flags);
-		cmd->request->special = cmd;
-		if (blk_rq_tagged(cmd->request))
-			blk_queue_end_tag(q, cmd->request);
-
-		/*
-		 * set REQ_SPECIAL - we have a command
-		 * clear REQ_DONTPREP - we assume the sg table has been 
-		 *	nuked so we need to set it up again.
-		 */
-		cmd->request->flags |= REQ_SPECIAL;
-		cmd->request->flags &= ~REQ_DONTPREP;
-		__elv_add_request(q, cmd->request, 0, 0);
-		spin_unlock_irqrestore(q->queue_lock, flags);
-	}
-
-	sdev = q->queuedata;
-
 	if (sdev->single_lun)
 		scsi_single_lun_run(sdev);
 
-	shost = sdev->host;
 	spin_lock_irqsave(shost->host_lock, flags);
 	while (!list_empty(&shost->starved_list) &&
 	       !shost->host_blocked && !shost->host_self_blocked &&
@@ -477,6 +414,61 @@
 }
 
 /*
+ * Function:	scsi_requeue_command()
+ *
+ * Purpose:	Handle post-processing of completed commands.
+ *
+ * Arguments:	q	- queue to operate on
+ *		cmd	- command that may need to be requeued.
+ *
+ * Returns:	Nothing
+ *
+ * Notes:	After command completion, there may be blocks left
+ *		over which weren't finished by the previous command
+ *		this can be for a number of reasons - the main one is
+ *		I/O errors in the middle of the request, in which case
+ *		we need to request the blocks that come after the bad
+ *		sector.
+ */
+static void scsi_requeue_command(struct request_queue *q, struct scsi_cmnd *cmd)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(q->queue_lock, flags);
+	cmd->request->special = cmd;
+	if (blk_rq_tagged(cmd->request))
+		blk_queue_end_tag(q, cmd->request);
+
+	/*
+	 * set REQ_SPECIAL - we have a command
+	 * clear REQ_DONTPREP - we assume the sg table has been 
+	 *	nuked so we need to set it up again.
+	 */
+	cmd->request->flags |= REQ_SPECIAL;
+	cmd->request->flags &= ~REQ_DONTPREP;
+	__elv_add_request(q, cmd->request, 0, 0);
+	spin_unlock_irqrestore(q->queue_lock, flags);
+
+	scsi_run_queue(q);
+}
+
+void scsi_next_command(struct scsi_cmnd *cmd)
+{
+	struct request_queue *q = cmd->device->request_queue;
+
+	scsi_put_command(cmd);
+	scsi_run_queue(q);
+}
+
+void scsi_run_host_queues(struct Scsi_Host *shost)
+{
+	struct scsi_device *sdev;
+
+	list_for_each_entry(sdev, &shost->my_devices, siblings)
+		scsi_run_queue(sdev->request_queue);
+}
+
+/*
  * Function:    scsi_end_request()
  *
  * Purpose:     Post-processing of completed commands called from interrupt
@@ -516,7 +508,7 @@
 			 * Bleah.  Leftovers again.  Stick the leftovers in
 			 * the front of the queue, and goose the queue again.
 			 */
-			scsi_queue_next_request(q, cmd);
+			scsi_requeue_command(q, cmd);
 		}
 		return cmd;
 	}
@@ -533,8 +525,7 @@
 	 * This will goose the queue request function at the end, so we don't
 	 * need to worry about launching another command.
 	 */
-	scsi_put_command(cmd);
-	scsi_queue_next_request(q, NULL);
+	scsi_next_command(cmd);
 	return NULL;
 }
 
@@ -660,6 +651,18 @@
  *              In other words, if there are no bounce buffers
  *              (the normal case for most drivers), we don't need
  *              the logic to deal with cleaning up afterwards.
+ *
+ *		We must do one of several things here:
+ *
+ *		a) Call scsi_end_request.  This will finish off the
+ *		   specified number of sectors.  If we are done, the
+ *		   command block will be released, and the queue
+ *		   function will be goosed.  If we are not done, then
+ *		   scsi_end_request will directly goose the queue.
+ *
+ *		b) We can just use scsi_requeue_command() here.  This would
+ *		   be used if we just wanted to retry, for example.
+ *
  */
 void scsi_io_completion(struct scsi_cmnd *cmd, int good_sectors,
 			int block_sectors)
@@ -671,19 +674,6 @@
 	int clear_errors = 1;
 
 	/*
-	 * We must do one of several things here:
-	 *
-	 *	Call scsi_end_request.  This will finish off the specified
-	 *	number of sectors.  If we are done, the command block will
-	 *	be released, and the queue function will be goosed.  If we
-	 *	are not done, then scsi_end_request will directly goose
-	 *	the queue.
-	 *
-	 *	We can just use scsi_queue_next_request() here.  This
-	 *	would be used if we just wanted to retry, for example.
-	 *
-	 */
-	/*
 	 * Free up any indirection buffers we allocated for DMA purposes. 
 	 * For the case of a READ, we need to copy the data out of the
 	 * bounce buffer and into the real buffer.
@@ -782,7 +772,7 @@
 			 */
 			if (cmd->sense_buffer[12] == 0x04 &&
 			    cmd->sense_buffer[13] == 0x01) {
-				scsi_queue_next_request(q, cmd);
+				scsi_requeue_command(q, cmd);
 				return;
 			}
 			if ((cmd->sense_buffer[2] & 0xf) == UNIT_ATTENTION) {
@@ -801,7 +791,7 @@
 				 	* media change, so we just retry the
 				 	* request and see what happens.  
 				 	*/
-					scsi_queue_next_request(q, cmd);
+					scsi_requeue_command(q, cmd);
 					return;
 				}
 			}
@@ -821,7 +811,7 @@
 				 * This will cause a retry with a 6-byte
 				 * command.
 				 */
-				scsi_queue_next_request(q, cmd);
+				scsi_requeue_command(q, cmd);
 				result = 0;
 			} else {
 				cmd = scsi_end_request(cmd, 0, this_count, 1);
@@ -853,7 +843,7 @@
 		 * recovery reasons.  Just retry the request
 		 * and see what happens.  
 		 */
-		scsi_queue_next_request(q, cmd);
+		scsi_requeue_command(q, cmd);
 		return;
 	}
 	if (result) {
@@ -1140,66 +1130,61 @@
  *
  * Lock status: IO request lock assumed to be held when called.
  */
-static void scsi_request_fn(request_queue_t *q)
+static void scsi_request_fn(struct request_queue *q)
 {
 	struct scsi_device *sdev = q->queuedata;
 	struct Scsi_Host *shost = sdev->host;
 	struct scsi_cmnd *cmd;
 	struct request *req;
-	unsigned long flags;
 
 	/*
 	 * To start with, we keep looping until the queue is empty, or until
 	 * the host is no longer able to accept any more requests.
 	 */
-	for (;;) {
-		if (blk_queue_plugged(q))
-			goto completed;
-
+	while (!blk_queue_plugged(q)) {
 		/*
 		 * get next queueable request.  We do this early to make sure
 		 * that the request is fully prepared even if we cannot 
 		 * accept it.
 		 */
 		req = elv_next_request(q);
-
-		if (!req)
-			goto completed;
-
-		if (!scsi_dev_queue_ready(q, sdev))
-			goto completed;
+		if (!req || !scsi_dev_queue_ready(q, sdev))
+			break;
 
 		/*
 		 * Remove the request from the request list.
 		 */
-		if (!(blk_queue_tagged(q) && (blk_queue_start_tag(q, req) == 0)))
+		if (!(blk_queue_tagged(q) && !blk_queue_start_tag(q, req)))
 			blkdev_dequeue_request(req);
-
 		sdev->device_busy++;
-		spin_unlock_irq(q->queue_lock);
 
-		spin_lock_irqsave(shost->host_lock, flags);
-		if (!scsi_host_queue_ready(q, shost, sdev))
-			goto host_lock_held;
+		spin_unlock(q->queue_lock);
+		spin_lock(shost->host_lock);
 
+		if (!scsi_host_queue_ready(q, shost, sdev))
+			goto not_ready;
 		if (sdev->single_lun) {
 			if (sdev->sdev_target->starget_sdev_user &&
-			    (sdev->sdev_target->starget_sdev_user != sdev))
-				goto host_lock_held;
-			else
-				sdev->sdev_target->starget_sdev_user = sdev;
+			    sdev->sdev_target->starget_sdev_user != sdev)
+				goto not_ready;
+			sdev->sdev_target->starget_sdev_user = sdev;
 		}
-
 		shost->host_busy++;
-		spin_unlock_irqrestore(shost->host_lock, flags);
-
-		cmd = req->special;
 
 		/*
-		 * Should be impossible for a correctly prepared request
-		 * please mail the stack trace to linux-scsi@vger.kernel.org
+		 * XXX(hch): This is rather suboptimal, scsi_dispatch_cmd will
+		 *		take the lock again.
 		 */
-		BUG_ON(!cmd);
+		spin_unlock_irq(shost->host_lock);
+
+		cmd = req->special;
+		if (unlikely(cmd == NULL)) {
+			printk(KERN_CRIT "impossible request in %s.\n"
+					 "please mail a stack trace to "
+					 "linux-scsi@vger.kernel.org",
+					 __FUNCTION__);
+			BUG();
+		}
 
 		/*
 		 * Finally, initialize any error handling parameters, and set up
@@ -1211,18 +1196,14 @@
 		 * Dispatch the command to the low-level driver.
 		 */
 		scsi_dispatch_cmd(cmd);
-
-		/*
-		 * Now we need to grab the lock again.  We are about to mess
-		 * with the request queue and try to find another command.
-		 */
 		spin_lock_irq(q->queue_lock);
 	}
-completed:
+
 	return;
 
-host_lock_held:
-	spin_unlock_irqrestore(shost->host_lock, flags);
+ not_ready:
+	spin_unlock_irq(shost->host_lock);
+
 	/*
 	 * lock q, handle tag, requeue req, and decrement device_busy. We
 	 * must return with queue_lock held.
@@ -1257,28 +1238,15 @@
 	return BLK_BOUNCE_HIGH;
 }
 
-request_queue_t *scsi_alloc_queue(struct scsi_device *sdev)
+struct request_queue *scsi_alloc_queue(struct scsi_device *sdev)
 {
-	request_queue_t *q;
-	struct Scsi_Host *shost;
+	struct Scsi_Host *shost = sdev->host;
+	struct request_queue *q = kmalloc(sizeof(*q), GFP_ATOMIC);
 
-	q = kmalloc(sizeof(*q), GFP_ATOMIC);
 	if (!q)
 		return NULL;
 	memset(q, 0, sizeof(*q));
 
-	/*
-	 * XXX move host code to scsi_register
-	 */
-	shost = sdev->host;
-	if (!shost->max_sectors) {
-		/*
-		 * Driver imposes no hard sector transfer limit.
-		 * start at machine infinity initially.
-		 */
-		shost->max_sectors = SCSI_DEFAULT_MAX_SECTORS;
-	}
-
 	blk_init_queue(q, scsi_request_fn, &sdev->sdev_lock);
 	blk_queue_prep_rq(q, scsi_prep_fn);
 
@@ -1289,11 +1257,10 @@
 
 	if (!shost->use_clustering)
 		clear_bit(QUEUE_FLAG_CLUSTER, &q->queue_flags);
-
 	return q;
 }
 
-void scsi_free_queue(request_queue_t *q)
+void scsi_free_queue(struct request_queue *q)
 {
 	blk_cleanup_queue(q);
 	kfree(q);
@@ -1342,48 +1309,8 @@
  */
 void scsi_unblock_requests(struct Scsi_Host *shost)
 {
-	struct scsi_device *sdev;
-
 	shost->host_self_blocked = 0;
-
-	/*
-	 * Now that we are unblocked, try to start the queues.
-	 */
-	list_for_each_entry(sdev, &shost->my_devices, siblings)
-		scsi_queue_next_request(sdev->request_queue, NULL);
-}
-
-/*
- * Function:    scsi_report_bus_reset()
- *
- * Purpose:     Utility function used by low-level drivers to report that
- *		they have observed a bus reset on the bus being handled.
- *
- * Arguments:   shost       - Host in question
- *		channel     - channel on which reset was observed.
- *
- * Returns:     Nothing
- *
- * Lock status: No locks are assumed held.
- *
- * Notes:       This only needs to be called if the reset is one which
- *		originates from an unknown location.  Resets originated
- *		by the mid-level itself don't need to call this, but there
- *		should be no harm.
- *
- *		The main purpose of this is to make sure that a CHECK_CONDITION
- *		is properly treated.
- */
-void scsi_report_bus_reset(struct Scsi_Host *shost, int channel)
-{
-	struct scsi_device *sdev;
-
-	list_for_each_entry(sdev, &shost->my_devices, siblings) {
-		if (channel == sdev->channel) {
-			sdev->was_reset = 1;
-			sdev->expecting_cc_ua = 1;
-		}
-	}
+	scsi_run_host_queues(shost);
 }
 
 int __init scsi_init_queue(void)
diff -urN linux-2.5.69-bk7/drivers/scsi/scsi_logging.h linux-2.5.69-bk8/drivers/scsi/scsi_logging.h
--- linux-2.5.69-bk7/drivers/scsi/scsi_logging.h	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.5.69-bk8/drivers/scsi/scsi_logging.h	2003-05-13 04:44:29.000000000 -0700
@@ -0,0 +1,117 @@
+#ifndef _SCSI_LOGGING_H
+#define _SCSI_LOGGING_H
+
+#include <linux/config.h>
+
+/*
+ * This defines the scsi logging feature.  It is a means by which the user
+ * can select how much information they get about various goings on, and it
+ * can be really useful for fault tracing.  The logging word is divided into
+ * 8 nibbles, each of which describes a loglevel.  The division of things is
+ * somewhat arbitrary, and the division of the word could be changed if it
+ * were really needed for any reason.  The numbers below are the only place
+ * where these are specified.  For a first go-around, 3 bits is more than
+ * enough, since this gives 8 levels of logging (really 7, since 0 is always
+ * off).  Cutting to 2 bits might be wise at some point.
+ */
+
+#define SCSI_LOG_ERROR_SHIFT              0
+#define SCSI_LOG_TIMEOUT_SHIFT            3
+#define SCSI_LOG_SCAN_SHIFT               6
+#define SCSI_LOG_MLQUEUE_SHIFT            9
+#define SCSI_LOG_MLCOMPLETE_SHIFT         12
+#define SCSI_LOG_LLQUEUE_SHIFT            15
+#define SCSI_LOG_LLCOMPLETE_SHIFT         18
+#define SCSI_LOG_HLQUEUE_SHIFT            21
+#define SCSI_LOG_HLCOMPLETE_SHIFT         24
+#define SCSI_LOG_IOCTL_SHIFT              27
+
+#define SCSI_LOG_ERROR_BITS               3
+#define SCSI_LOG_TIMEOUT_BITS             3
+#define SCSI_LOG_SCAN_BITS                3
+#define SCSI_LOG_MLQUEUE_BITS             3
+#define SCSI_LOG_MLCOMPLETE_BITS          3
+#define SCSI_LOG_LLQUEUE_BITS             3
+#define SCSI_LOG_LLCOMPLETE_BITS          3
+#define SCSI_LOG_HLQUEUE_BITS             3
+#define SCSI_LOG_HLCOMPLETE_BITS          3
+#define SCSI_LOG_IOCTL_BITS               3
+
+
+#ifdef CONFIG_SCSI_LOGGING
+extern unsigned int scsi_logging_level;
+#define SCSI_CHECK_LOGGING(SHIFT, BITS, LEVEL, CMD)		\
+{								\
+        unsigned int mask = (1 << (BITS)) - 1;			\
+        if (((scsi_logging_level >> (SHIFT)) & mask) > (LEVEL))	\
+		(CMD);						\
+}
+
+#define SCSI_SET_LOGGING(SHIFT, BITS, LEVEL)			\
+{								\
+        unsigned int mask = ((1 << (BITS)) - 1) << SHIFT;	\
+        scsi_logging_level = ((scsi_logging_level & ~mask)	\
+                              | ((LEVEL << SHIFT) & mask));	\
+}
+#else
+/*
+ * With no logging enabled, stub these out so they don't do anything.
+ */
+#define SCSI_CHECK_LOGGING(SHIFT, BITS, LEVEL, CMD)
+#define SCSI_SET_LOGGING(SHIFT, BITS, LEVEL)
+#endif /* CONFIG_SCSI_LOGGING */
+
+/*
+ * These are the macros that are actually used throughout the code to
+ * log events.  If logging isn't enabled, they are no-ops and will be
+ * completely absent from the user's code.
+ *
+ * The 'set' versions of the macros are really intended to only be called
+ * from the /proc filesystem, and in production kernels this will be about
+ * all that is ever used.  It could be useful in a debugging environment to
+ * bump the logging level when certain strange events are detected, however.
+ */
+#define SCSI_LOG_ERROR_RECOVERY(LEVEL,CMD)  \
+        SCSI_CHECK_LOGGING(SCSI_LOG_ERROR_SHIFT, SCSI_LOG_ERROR_BITS, LEVEL,CMD);
+#define SCSI_LOG_TIMEOUT(LEVEL,CMD)  \
+        SCSI_CHECK_LOGGING(SCSI_LOG_TIMEOUT_SHIFT, SCSI_LOG_TIMEOUT_BITS, LEVEL,CMD);
+#define SCSI_LOG_SCAN_BUS(LEVEL,CMD)  \
+        SCSI_CHECK_LOGGING(SCSI_LOG_SCAN_SHIFT, SCSI_LOG_SCAN_BITS, LEVEL,CMD);
+#define SCSI_LOG_MLQUEUE(LEVEL,CMD)  \
+        SCSI_CHECK_LOGGING(SCSI_LOG_MLQUEUE_SHIFT, SCSI_LOG_MLQUEUE_BITS, LEVEL,CMD);
+#define SCSI_LOG_MLCOMPLETE(LEVEL,CMD)  \
+        SCSI_CHECK_LOGGING(SCSI_LOG_MLCOMPLETE_SHIFT, SCSI_LOG_MLCOMPLETE_BITS, LEVEL,CMD);
+#define SCSI_LOG_LLQUEUE(LEVEL,CMD)  \
+        SCSI_CHECK_LOGGING(SCSI_LOG_LLQUEUE_SHIFT, SCSI_LOG_LLQUEUE_BITS, LEVEL,CMD);
+#define SCSI_LOG_LLCOMPLETE(LEVEL,CMD)  \
+        SCSI_CHECK_LOGGING(SCSI_LOG_LLCOMPLETE_SHIFT, SCSI_LOG_LLCOMPLETE_BITS, LEVEL,CMD);
+#define SCSI_LOG_HLQUEUE(LEVEL,CMD)  \
+        SCSI_CHECK_LOGGING(SCSI_LOG_HLQUEUE_SHIFT, SCSI_LOG_HLQUEUE_BITS, LEVEL,CMD);
+#define SCSI_LOG_HLCOMPLETE(LEVEL,CMD)  \
+        SCSI_CHECK_LOGGING(SCSI_LOG_HLCOMPLETE_SHIFT, SCSI_LOG_HLCOMPLETE_BITS, LEVEL,CMD);
+#define SCSI_LOG_IOCTL(LEVEL,CMD)  \
+        SCSI_CHECK_LOGGING(SCSI_LOG_IOCTL_SHIFT, SCSI_LOG_IOCTL_BITS, LEVEL,CMD);
+
+
+#define SCSI_SET_ERROR_RECOVERY_LOGGING(LEVEL)  \
+        SCSI_SET_LOGGING(SCSI_LOG_ERROR_SHIFT, SCSI_LOG_ERROR_BITS, LEVEL);
+#define SCSI_SET_TIMEOUT_LOGGING(LEVEL)  \
+        SCSI_SET_LOGGING(SCSI_LOG_TIMEOUT_SHIFT, SCSI_LOG_TIMEOUT_BITS, LEVEL);
+#define SCSI_SET_SCAN_BUS_LOGGING(LEVEL)  \
+        SCSI_SET_LOGGING(SCSI_LOG_SCAN_SHIFT, SCSI_LOG_SCAN_BITS, LEVEL);
+#define SCSI_SET_MLQUEUE_LOGGING(LEVEL)  \
+        SCSI_SET_LOGGING(SCSI_LOG_MLQUEUE_SHIFT, SCSI_LOG_MLQUEUE_BITS, LEVEL);
+#define SCSI_SET_MLCOMPLETE_LOGGING(LEVEL)  \
+        SCSI_SET_LOGGING(SCSI_LOG_MLCOMPLETE_SHIFT, SCSI_LOG_MLCOMPLETE_BITS, LEVEL);
+#define SCSI_SET_LLQUEUE_LOGGING(LEVEL)  \
+        SCSI_SET_LOGGING(SCSI_LOG_LLQUEUE_SHIFT, SCSI_LOG_LLQUEUE_BITS, LEVEL);
+#define SCSI_SET_LLCOMPLETE_LOGGING(LEVEL)  \
+        SCSI_SET_LOGGING(SCSI_LOG_LLCOMPLETE_SHIFT, SCSI_LOG_LLCOMPLETE_BITS, LEVEL);
+#define SCSI_SET_HLQUEUE_LOGGING(LEVEL)  \
+        SCSI_SET_LOGGING(SCSI_LOG_HLQUEUE_SHIFT, SCSI_LOG_HLQUEUE_BITS, LEVEL);
+#define SCSI_SET_HLCOMPLETE_LOGGING(LEVEL)  \
+        SCSI_SET_LOGGING(SCSI_LOG_HLCOMPLETE_SHIFT, SCSI_LOG_HLCOMPLETE_BITS, LEVEL);
+#define SCSI_SET_IOCTL_LOGGING(LEVEL)  \
+        SCSI_SET_LOGGING(SCSI_LOG_IOCTL_SHIFT, SCSI_LOG_IOCTL_BITS, LEVEL);
+
+#endif /* _SCSI_LOGGING_H */
diff -urN linux-2.5.69-bk7/drivers/scsi/scsi_priv.h linux-2.5.69-bk8/drivers/scsi/scsi_priv.h
--- linux-2.5.69-bk7/drivers/scsi/scsi_priv.h	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.5.69-bk8/drivers/scsi/scsi_priv.h	2003-05-13 04:44:29.000000000 -0700
@@ -0,0 +1,132 @@
+#ifndef _SCSI_PRIV_H
+#define _SCSI_PRIV_H
+
+/*
+ * These are the values that the owner field can take.
+ * They are used as an indication of who the command belongs to.
+ */
+#define SCSI_OWNER_HIGHLEVEL      0x100
+#define SCSI_OWNER_MIDLEVEL       0x101
+#define SCSI_OWNER_LOWLEVEL       0x102
+#define SCSI_OWNER_ERROR_HANDLER  0x103
+#define SCSI_OWNER_BH_HANDLER     0x104
+#define SCSI_OWNER_NOBODY         0x105
+
+/*
+ * Magic values for certain scsi structs. Shouldn't ever be used.
+ */
+#define SCSI_CMND_MAGIC		0xE25C23A5
+#define SCSI_REQ_MAGIC		0x75F6D354
+
+/*
+ *  Flag bit for the internal_timeout array
+ */
+#define NORMAL_TIMEOUT		0
+
+/*
+ * Scsi Error Handler Flags
+ */
+#define scsi_eh_eflags_chk(scp, flags) \
+	((scp)->eh_eflags & (flags))
+#define scsi_eh_eflags_set(scp, flags) \
+	do { (scp)->eh_eflags |= (flags); } while(0)
+#define scsi_eh_eflags_clr(scp, flags) \
+	do { (scp)->eh_eflags &= ~(flags); } while(0)
+#define scsi_eh_eflags_clr_all(scp) \
+	(scp->eh_eflags = 0)
+
+#define SCSI_EH_CANCEL_CMD	0x0001	/* Cancel this cmd */
+#define SCSI_EH_REC_TIMEOUT	0x0002	/* EH retry timed out */
+
+#define SCSI_SENSE_VALID(scmd) \
+	(((scmd)->sense_buffer[0] & 0x70) == 0x70)
+
+struct Scsi_Device_Template;
+
+
+/*
+ * scsi_target: representation of a scsi target, for now, this is only
+ * used for single_lun devices. If no one has active IO to the target,
+ * starget_sdev_user is NULL, else it points to the active sdev.
+ */
+struct scsi_target {
+	struct scsi_device	*starget_sdev_user;
+	unsigned int		starget_refcnt;
+};
+
+
+/* hosts.c */
+extern void scsi_host_busy_inc(struct Scsi_Host *, Scsi_Device *);
+extern void scsi_host_busy_dec_and_test(struct Scsi_Host *, Scsi_Device *);
+extern struct Scsi_Host *scsi_host_get_next(struct Scsi_Host *);
+extern void scsi_host_init(void);
+
+/* scsi.c */
+extern int scsi_dispatch_cmd(struct scsi_cmnd *cmd);
+extern int scsi_setup_command_freelist(struct Scsi_Host *shost);
+extern void scsi_destroy_command_freelist(struct Scsi_Host *shost);
+extern void scsi_done(struct scsi_cmnd *cmd);
+extern void scsi_finish_command(struct scsi_cmnd *cmd);
+extern int scsi_retry_command(struct scsi_cmnd *cmd);
+extern int scsi_attach_device(struct scsi_device *sdev);
+extern void scsi_detach_device(struct scsi_device *sdev);
+extern void scsi_rescan_device(struct scsi_device *sdev);
+extern int scsi_insert_special_req(struct scsi_request *sreq, int);
+extern void scsi_init_cmd_from_req(struct scsi_cmnd *cmd,
+		struct scsi_request *sreq);
+extern void __scsi_release_request(struct scsi_request *sreq);
+
+/* scsi_devinfo.c */
+extern int scsi_get_device_flags(unsigned char *vendor, unsigned char *model);
+extern int scsi_init_devinfo(void);
+extern void scsi_exit_devinfo(void);
+
+/* scsi_error.c */
+extern void scsi_times_out(struct scsi_cmnd *cmd);
+extern void scsi_error_handler(void *host);
+extern int scsi_decide_disposition(struct scsi_cmnd *cmd);
+extern int scsi_eh_scmd_add(struct scsi_cmnd *, int);
+
+/* scsi_lib.c */
+extern int scsi_maybe_unblock_host(struct scsi_device *sdev);
+extern void scsi_setup_cmd_retry(struct scsi_cmnd *cmd);
+extern int scsi_queue_insert(struct scsi_cmnd *cmd, int reason);
+extern void scsi_next_command(struct scsi_cmnd *cmd);
+extern void scsi_run_host_queues(struct Scsi_Host *shost);
+extern struct request_queue *scsi_alloc_queue(struct scsi_device *sdev);
+extern void scsi_free_queue(struct request_queue *q);
+extern int scsi_init_queue(void);
+extern void scsi_exit_queue(void);
+
+/* scsi_proc.c */
+#ifdef CONFIG_PROC_FS
+extern void scsi_proc_host_add(struct Scsi_Host *);
+extern void scsi_proc_host_rm(struct Scsi_Host *);
+extern int scsi_init_procfs(void);
+extern void scsi_exit_procfs(void);
+#else
+# define scsi_proc_host_add(shost)	do { } while (0)
+# define scsi_proc_host_rm(shost)	do { } while (0)
+# define scsi_init_procfs()		(0)
+# define scsi_exit_procfs		do { } while (0)
+#endif /* CONFIG_PROC_FS */
+
+/* scsi_scan.c */
+extern void scsi_scan_host(struct Scsi_Host *shost);
+extern void scsi_forget_host(struct Scsi_Host *shost);
+extern void scsi_free_sdev(struct scsi_device *);
+extern void scsi_free_shost(struct Scsi_Host *);
+extern void scsi_host_get(struct Scsi_Host *);
+
+/* scsi_sysfs.c */
+extern int scsi_device_register(struct scsi_device *);
+extern void scsi_device_unregister(struct scsi_device *);
+extern int scsi_upper_driver_register(struct Scsi_Device_Template *);
+extern void scsi_upper_driver_unregister(struct Scsi_Device_Template *);
+extern void scsi_sysfs_init_host(struct Scsi_Host *);
+extern int scsi_sysfs_add_host(struct Scsi_Host *, struct device *);
+extern void scsi_sysfs_remove_host(struct Scsi_Host *);
+extern int scsi_sysfs_register(void);
+extern void scsi_sysfs_unregister(void);
+
+#endif /* _SCSI_PRIV_H */
diff -urN linux-2.5.69-bk7/drivers/scsi/scsi_proc.c linux-2.5.69-bk8/drivers/scsi/scsi_proc.c
--- linux-2.5.69-bk7/drivers/scsi/scsi_proc.c	2003-05-04 16:53:01.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/scsi_proc.c	2003-05-13 04:44:29.000000000 -0700
@@ -29,6 +29,10 @@
 #include "scsi.h"
 #include "hosts.h"
 
+#include "scsi_priv.h"
+#include "scsi_logging.h"
+
+
 /* 4K page size, but our output routines, use some slack for overruns */
 #define PROC_BLOCK_SIZE (3*1024)
 
@@ -196,77 +200,6 @@
 	return;
 }
 
-/* 
- * proc_scsi_dev_info_read: dump the scsi_dev_info_list via
- * /proc/scsi/device_info
- */
-static int proc_scsi_dev_info_read(char *buffer, char **start, off_t offset,
-				   int length)
-{
-	struct scsi_dev_info_list *devinfo;
-	int size, len = 0;
-	off_t begin = 0;
-	off_t pos = 0;
-
-	list_for_each_entry(devinfo, &scsi_dev_info_list, dev_info_list) {
-		size = sprintf(buffer + len, "'%.8s' '%.16s' 0x%x\n",
-			       devinfo->vendor, devinfo->model, devinfo->flags);
-		len += size;
-		pos = begin + len;
-		if (pos < offset) {
-			len = 0;
-			begin = pos;
-		}
-		if (pos > offset + length)
-			goto stop_output;
-	}
-
-stop_output:
-	*start = buffer + (offset - begin);	/* Start of wanted data */
-	len -= (offset - begin);	/* Start slop */
-	if (len > length)
-		len = length;	/* Ending slop */
-	return (len);
-}
-
-/* 
- * proc_scsi_dev_info_write: allow additions to the scsi_dev_info_list via
- * /proc.
- *
- * Use: echo "vendor:model:flag" > /proc/scsi/device_info
- *
- * To add a black/white list entry for vendor and model with an integer
- * value of flag to the scsi device info list.
- */
-static int proc_scsi_dev_info_write (struct file * file, const char * buf,
-                              unsigned long length, void *data)
-{
-	char *buffer;
-	int err = length;
-
-	if (!buf || length>PAGE_SIZE)
-		return -EINVAL;
-	if (!(buffer = (char *) __get_free_page(GFP_KERNEL)))
-		return -ENOMEM;
-	if (copy_from_user(buffer, buf, length)) {
-		err =-EFAULT;
-		goto out;
-	}
-
-	if (length < PAGE_SIZE)
-		buffer[length] = '\0';
-	else if (buffer[PAGE_SIZE-1]) {
-		err = -EINVAL;
-		goto out;
-	}
-
-	scsi_dev_info_list_add_str(buffer);
-
-out:
-	free_page((unsigned long)buffer);
-	return err;
-}
-
 static int scsi_proc_info(char *buffer, char **start, off_t offset, int length)
 {
 	struct Scsi_Host *shost;
@@ -312,91 +245,6 @@
 	return (len);
 }
 
-#ifdef CONFIG_SCSI_LOGGING
-/*
- * Function:    scsi_dump_status
- *
- * Purpose:     Brain dump of scsi system, used for problem solving.
- *
- * Arguments:   level - used to indicate level of detail.
- *
- * Notes:       The level isn't used at all yet, but we need to find some
- *		way of sensibly logging varying degrees of information.
- *		A quick one-line display of each command, plus the status
- *		would be most useful.
- *
- *              This does depend upon CONFIG_SCSI_LOGGING - I do want some
- *		way of turning it all off if the user wants a lean and mean
- *		kernel.  It would probably also be useful to allow the user
- *		to specify one single host to be dumped.  A second argument
- *		to the function would be useful for that purpose.
- *
- *              FIXME - some formatting of the output into tables would be
- *		        very handy.
- */
-static void scsi_dump_status(int level)
-{
-	int i;
-	struct Scsi_Host *shpnt;
-	Scsi_Cmnd *SCpnt;
-	Scsi_Device *SDpnt;
-	printk(KERN_INFO "Dump of scsi host parameters:\n");
-	i = 0;
-	for (shpnt = scsi_host_get_next(NULL); shpnt;
-	     shpnt = scsi_host_get_next(shpnt)) {
-		printk(KERN_INFO " %d %d : %d %d\n",
-		       shpnt->host_failed,
-		       shpnt->host_busy,
-		       shpnt->host_blocked,
-		       shpnt->host_self_blocked);
-	}
-
-	printk(KERN_INFO "\n\n");
-	printk(KERN_INFO "Dump of scsi command parameters:\n");
-	for (shpnt = scsi_host_get_next(NULL); shpnt;
-	     shpnt = scsi_host_get_next(shpnt)) {
-		printk(KERN_INFO "h:c:t:l (dev sect nsect cnumsec sg) "
-			"(ret all flg) (to/cmd to ito) cmd snse result\n");
-		list_for_each_entry(SDpnt, &shpnt->my_devices, siblings) {
-			unsigned long flags;
-
-			spin_lock_irqsave(&SDpnt->list_lock, flags);
-			list_for_each_entry(SCpnt, &SDpnt->cmd_list, list) {
-				/*  (0) h:c:t:l (dev sect nsect cnumsec sg) (ret all flg) (to/cmd to ito) cmd snse result %d %x      */
-				printk(KERN_INFO "(%3d) %2d:%1d:%2d:%2d (%6s %4llu %4ld %4ld %4x %1d) (%1d %1d 0x%2x) (%4d %4d %4d) 0x%2.2x 0x%2.2x 0x%8.8x\n",
-				       i++,
-
-				       SCpnt->device->host->host_no,
-				       SCpnt->device->channel,
-                                       SCpnt->device->id,
-                                       SCpnt->device->lun,
-
-                                       SCpnt->request->rq_disk ?
-                                       SCpnt->request->rq_disk->disk_name : "?",
-                                       (unsigned long long)SCpnt->request->sector,
-				       SCpnt->request->nr_sectors,
-				       (long)SCpnt->request->current_nr_sectors,
-				       SCpnt->request->rq_status,
-				       SCpnt->use_sg,
-
-				       SCpnt->retries,
-				       SCpnt->allowed,
-				       SCpnt->flags,
-
-				       SCpnt->timeout_per_command,
-				       SCpnt->timeout,
-				       SCpnt->internal_timeout,
-
-				       SCpnt->cmnd[0],
-				       SCpnt->sense_buffer[2],
-				       SCpnt->result);
-			}
-			spin_unlock_irqrestore(&SDpnt->list_lock, flags);
-		}
-	}
-}
-#endif	/* CONFIG_SCSI_LOGGING */ 
-
 static int scsi_add_single_device(uint host, uint channel, uint id, uint lun)
 {
 	struct Scsi_Host *shost;
@@ -440,7 +288,6 @@
 	return error;
 }
 
-
 static int proc_scsi_gen_write(struct file * file, const char * buf,
                               unsigned long length, void *data)
 {
@@ -471,22 +318,6 @@
 
 #ifdef CONFIG_SCSI_LOGGING
 	/*
-	 * Usage: echo "scsi dump #N" > /proc/scsi/scsi
-	 * to dump status of all scsi commands.  The number is used to
-	 * specify the level of detail in the dump.
-	 */
-	if (!strncmp("dump", buffer + 5, 4)) {
-		unsigned int level;
-
-		p = buffer + 10;
-
-		if (*p == '\0')
-			goto out;
-
-		level = simple_strtoul(p, NULL, 0);
-		scsi_dump_status(level);
-	}
-	/*
 	 * Usage: echo "scsi log token #N" > /proc/scsi/scsi
 	 * where token is one of [error,scan,mlqueue,mlcomplete,llqueue,
 	 * llcomplete,hlqueue,hlcomplete]
@@ -614,15 +445,8 @@
 		goto err2;
 	pde->write_proc = proc_scsi_gen_write;
 
-	pde = create_proc_info_entry("scsi/device_info", 0, 0,
-					  proc_scsi_dev_info_read);
-	if (!pde)
-		goto err3;
-	pde->write_proc = proc_scsi_dev_info_write;
 	return 0;
 
-err3:
-	remove_proc_entry("scsi/scsi", 0);
 err2:
 	remove_proc_entry("scsi", 0);
 err1:
@@ -631,7 +455,6 @@
 
 void scsi_exit_procfs(void)
 {
-	remove_proc_entry("scsi/device_info", 0);
 	remove_proc_entry("scsi/scsi", 0);
 	remove_proc_entry("scsi", 0);
 }
diff -urN linux-2.5.69-bk7/drivers/scsi/scsi_scan.c linux-2.5.69-bk8/drivers/scsi/scsi_scan.c
--- linux-2.5.69-bk7/drivers/scsi/scsi_scan.c	2003-05-04 16:53:37.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/scsi_scan.c	2003-05-13 04:44:29.000000000 -0700
@@ -33,173 +33,9 @@
 #include "scsi.h"
 #include "hosts.h"
 
-#ifdef CONFIG_KMOD
-#include <linux/kmod.h>
-#endif
-
-/*
- * Flags for SCSI devices that need special treatment
- */
-#define BLIST_NOLUN     	0x001	/* Only scan LUN 0 */
-#define BLIST_FORCELUN  	0x002	/* Known to have LUNs, force scanning */
-#define BLIST_BORKEN    	0x004	/* Flag for broken handshaking */
-#define BLIST_KEY       	0x008	/* unlock by special command */
-#define BLIST_SINGLELUN 	0x010	/* Do not use LUNs in parallel */
-#define BLIST_NOTQ		0x020	/* Buggy Tagged Command Queuing */
-#define BLIST_SPARSELUN 	0x040	/* Non consecutive LUN numbering */
-#define BLIST_MAX5LUN		0x080	/* Avoid LUNS >= 5 */
-#define BLIST_ISROM     	0x100	/* Treat as (removable) CD-ROM */
-#define BLIST_LARGELUN		0x200	/* LUNs past 7 on a SCSI-2 device */
-#define BLIST_INQUIRY_36	0x400	/* override additional length field */
-#define BLIST_INQUIRY_58	0x800	/* ... for broken inquiry responses */
-
-/*
- * scsi_static_device_list: deprecated list of devices that require
- * settings that differ from the default, includes black-listed (broken)
- * devices. The entries here are added to the tail of scsi_dev_info_list
- * via scsi_dev_info_list_init.
- *
- * Do not add to this list, use the command line or proc interface to add
- * to the scsi_dev_info_list. This table will eventually go away.
- */
-struct dev_info scsi_static_device_list[] __initdata = {
-	/*
-	 * The following devices are known not to tolerate a lun != 0 scan
-	 * for one reason or another. Some will respond to all luns,
-	 * others will lock up.
-	 */
-	{"Aashima", "IMAGERY 2400SP", "1.03", BLIST_NOLUN},	/* locks up */
-	{"CHINON", "CD-ROM CDS-431", "H42", BLIST_NOLUN},	/* locks up */
-	{"CHINON", "CD-ROM CDS-535", "Q14", BLIST_NOLUN},	/* locks up */
-	{"DENON", "DRD-25X", "V", BLIST_NOLUN},			/* locks up */
-	{"HITACHI", "DK312C", "CM81", BLIST_NOLUN},	/* responds to all lun */
-	{"HITACHI", "DK314C", "CR21", BLIST_NOLUN},	/* responds to all lun */
-	{"IMS", "CDD521/10", "2.06", BLIST_NOLUN},	/* locks up */
-	{"MAXTOR", "XT-3280", "PR02", BLIST_NOLUN},	/* locks up */
-	{"MAXTOR", "XT-4380S", "B3C", BLIST_NOLUN},	/* locks up */
-	{"MAXTOR", "MXT-1240S", "I1.2", BLIST_NOLUN},	/* locks up */
-	{"MAXTOR", "XT-4170S", "B5A", BLIST_NOLUN},	/* locks up */
-	{"MAXTOR", "XT-8760S", "B7B", BLIST_NOLUN},	/* locks up */
-	{"MEDIAVIS", "RENO CD-ROMX2A", "2.03", BLIST_NOLUN},	/* responds to all lun */
-	{"NEC", "CD-ROM DRIVE:841", "1.0", BLIST_NOLUN},/* locks up */
-	{"PHILIPS", "PCA80SC", "V4-2", BLIST_NOLUN},	/* responds to all lun */
-	{"RODIME", "RO3000S", "2.33", BLIST_NOLUN},	/* locks up */
-	{"SUN", "SENA", NULL, BLIST_NOLUN},		/* responds to all luns */
-	/*
-	 * The following causes a failed REQUEST SENSE on lun 1 for
-	 * aha152x controller, which causes SCSI code to reset bus.
-	 */
-	{"SANYO", "CRD-250S", "1.20", BLIST_NOLUN},
-	/*
-	 * The following causes a failed REQUEST SENSE on lun 1 for
-	 * aha152x controller, which causes SCSI code to reset bus.
-	 */
-	{"SEAGATE", "ST157N", "\004|j", BLIST_NOLUN},
-	{"SEAGATE", "ST296", "921", BLIST_NOLUN},	/* responds to all lun */
-	{"SEAGATE", "ST1581", "6538", BLIST_NOLUN},	/* responds to all lun */
-	{"SONY", "CD-ROM CDU-541", "4.3d", BLIST_NOLUN},
-	{"SONY", "CD-ROM CDU-55S", "1.0i", BLIST_NOLUN},
-	{"SONY", "CD-ROM CDU-561", "1.7x", BLIST_NOLUN},
-	{"SONY", "CD-ROM CDU-8012", NULL, BLIST_NOLUN},
-	{"TANDBERG", "TDC 3600", "U07", BLIST_NOLUN},	/* locks up */
-	{"TEAC", "CD-R55S", "1.0H", BLIST_NOLUN},	/* locks up */
-	/*
-	 * The following causes a failed REQUEST SENSE on lun 1 for
-	 * seagate controller, which causes SCSI code to reset bus.
-	 */
-	{"TEAC", "CD-ROM", "1.06", BLIST_NOLUN},
-	{"TEAC", "MT-2ST/45S2-27", "RV M", BLIST_NOLUN},	/* responds to all lun */
-	/*
-	 * The following causes a failed REQUEST SENSE on lun 1 for
-	 * seagate controller, which causes SCSI code to reset bus.
-	 */
-	{"TEXEL", "CD-ROM", "1.06", BLIST_NOLUN},
-	{"QUANTUM", "LPS525S", "3110", BLIST_NOLUN},	/* locks up */
-	{"QUANTUM", "PD1225S", "3110", BLIST_NOLUN},	/* locks up */
-	{"QUANTUM", "FIREBALL ST4.3S", "0F0C", BLIST_NOLUN},	/* locks up */
-	{"MEDIAVIS", "CDR-H93MV", "1.31", BLIST_NOLUN},	/* locks up */
-	{"SANKYO", "CP525", "6.64", BLIST_NOLUN},	/* causes failed REQ SENSE, extra reset */
-	{"HP", "C1750A", "3226", BLIST_NOLUN},		/* scanjet iic */
-	{"HP", "C1790A", "", BLIST_NOLUN},		/* scanjet iip */
-	{"HP", "C2500A", "", BLIST_NOLUN},		/* scanjet iicx */
-	{"YAMAHA", "CDR100", "1.00", BLIST_NOLUN},	/* locks up */
-	{"YAMAHA", "CDR102", "1.00", BLIST_NOLUN},	/* locks up */
-	{"YAMAHA", "CRW8424S", "1.0", BLIST_NOLUN},	/* locks up */
-	{"YAMAHA", "CRW6416S", "1.0c", BLIST_NOLUN},	/* locks up */
-	{"MITSUMI", "CD-R CR-2201CS", "6119", BLIST_NOLUN},	/* locks up */
-	{"RELISYS", "Scorpio", NULL, BLIST_NOLUN},	/* responds to all lun */
-	{"MICROTEK", "ScanMaker II", "5.61", BLIST_NOLUN},	/* responds to all lun */
-	{"NEC", "D3856", "0009", BLIST_NOLUN},
-
-	/*
-	 * Other types of devices that have special flags.
-	 */
-	{"SONY", "CD-ROM CDU-8001", NULL, BLIST_BORKEN},
-	{"TEXEL", "CD-ROM", "1.06", BLIST_BORKEN},
-	{"IOMEGA", "Io20S         *F", NULL, BLIST_KEY},
-	{"INSITE", "Floptical   F*8I", NULL, BLIST_KEY},
-	{"INSITE", "I325VM", NULL, BLIST_KEY},
-	{"LASOUND", "CDX7405", "3.10", BLIST_MAX5LUN | BLIST_SINGLELUN},
-	{"MICROP", "4110", NULL, BLIST_NOTQ},
-	{"NRC", "MBR-7", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
-	{"NRC", "MBR-7.4", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
-	{"REGAL", "CDC-4X", NULL, BLIST_MAX5LUN | BLIST_SINGLELUN},
-	{"NAKAMICH", "MJ-4.8S", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
-	{"NAKAMICH", "MJ-5.16S", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
-	{"PIONEER", "CD-ROM DRM-600", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
-	{"PIONEER", "CD-ROM DRM-602X", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
-	{"PIONEER", "CD-ROM DRM-604X", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
-	{"EMULEX", "MD21/S2     ESDI", NULL, BLIST_SINGLELUN},
-	{"CANON", "IPUBJD", NULL, BLIST_SPARSELUN},
-	{"nCipher", "Fastness Crypto", NULL, BLIST_FORCELUN},
-	{"DEC", "HSG80", NULL, BLIST_FORCELUN},
-	{"COMPAQ", "LOGICAL VOLUME", NULL, BLIST_FORCELUN},
-	{"COMPAQ", "CR3500", NULL, BLIST_FORCELUN},
-	{"NEC", "PD-1 ODX654P", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
-	{"MATSHITA", "PD-1", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
-	{"iomega", "jaz 1GB", "J.86", BLIST_NOTQ | BLIST_NOLUN},
-	{"TOSHIBA", "CDROM", NULL, BLIST_ISROM},
-	{"TOSHIBA", "CD-ROM", NULL, BLIST_ISROM},
-	{"MegaRAID", "LD", NULL, BLIST_FORCELUN},
-	{"DGC", "RAID", NULL, BLIST_SPARSELUN},	/* Dell PV 650F, storage on LUN 0 */
-	{"DGC", "DISK", NULL, BLIST_SPARSELUN},	/* Dell PV 650F, no storage on LUN 0 */
-	{"DELL", "PV660F", NULL, BLIST_SPARSELUN},
-	{"DELL", "PV660F   PSEUDO", NULL, BLIST_SPARSELUN},
-	{"DELL", "PSEUDO DEVICE .", NULL, BLIST_SPARSELUN},	/* Dell PV 530F */
-	{"DELL", "PV530F", NULL, BLIST_SPARSELUN},
-	{"EMC", "SYMMETRIX", NULL, BLIST_SPARSELUN | BLIST_LARGELUN | BLIST_FORCELUN},
-	{"HP", "A6189A", NULL, BLIST_SPARSELUN | BLIST_LARGELUN},	/* HP VA7400 */
-	{"HP", "OPEN-", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, /* HP XP Arrays */
-	{"CMD", "CRA-7280", NULL, BLIST_SPARSELUN},	/* CMD RAID Controller */
-	{"CNSI", "G7324", NULL, BLIST_SPARSELUN},	/* Chaparral G7324 RAID */
-	{"CNSi", "G8324", NULL, BLIST_SPARSELUN},	/* Chaparral G8324 RAID */
-	{"Zzyzx", "RocketStor 500S", NULL, BLIST_SPARSELUN},
-	{"Zzyzx", "RocketStor 2000", NULL, BLIST_SPARSELUN},
-	{"SONY", "TSL", NULL, BLIST_FORCELUN},		/* DDS3 & DDS4 autoloaders */
-	{"DELL", "PERCRAID", NULL, BLIST_FORCELUN},
-	{"HP", "NetRAID-4M", NULL, BLIST_FORCELUN},
-	{"ADAPTEC", "AACRAID", NULL, BLIST_FORCELUN},
-	{"ADAPTEC", "Adaptec 5400S", NULL, BLIST_FORCELUN},
-	{"COMPAQ", "MSA1000", NULL, BLIST_FORCELUN},
-	{"HP", "C1557A", NULL, BLIST_FORCELUN},
-	{"IBM", "AuSaV1S2", NULL, BLIST_FORCELUN},
-	{"FSC", "CentricStor", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
-	{"DDN", "SAN DataDirector", "*", BLIST_SPARSELUN},
-	{"HITACHI", "DF400", "*", BLIST_SPARSELUN},
-	{"HITACHI", "DF500", "*", BLIST_SPARSELUN},
-	{"HITACHI", "DF600", "*", BLIST_SPARSELUN},
-	{"IBM", "ProFibre 4000R", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
-	{"SUN", "T300", "*", BLIST_SPARSELUN},
-	{"SUN", "T4", "*", BLIST_SPARSELUN},
-	{"SGI", "RAID3", "*", BLIST_SPARSELUN},
-	{"SGI", "RAID5", "*", BLIST_SPARSELUN},
-	{"SGI", "TP9100", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
-	{"SGI", "TP9300", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
-	{"SGI", "TP9400", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
-	{"SGI", "TP9500", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
-	{"MYLEX", "DACARMRB", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
-	{ NULL, NULL, NULL, 0 },
-};
+#include "scsi_priv.h"
+#include "scsi_logging.h"
+#include "scsi_devinfo.h"
 
 #define ALLOC_FAILURE_MSG	KERN_ERR "%s: Allocation failure during" \
 	" SCSI scanning, some SCSI devices might not be configured\n"
@@ -429,7 +265,6 @@
 
 	sdev->request_queue->queuedata = sdev;
 	scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun);
-	init_waitqueue_head(&sdev->scpnt_wait);
 
 	if (shost->hostt->slave_alloc) {
 		if (shost->hostt->slave_alloc(sdev))
@@ -481,7 +316,7 @@
  *     Undo the actions in scsi_alloc_sdev, including removing @sdev from
  *     the list, and freeing @sdev.
  **/
-static void scsi_free_sdev(struct scsi_device *sdev)
+void scsi_free_sdev(struct scsi_device *sdev)
 {
 	unsigned long flags;
 
@@ -1270,12 +1105,7 @@
 int scsi_remove_device(struct scsi_device *sdev)
 {
 	scsi_detach_device(sdev);
-	if (sdev->attached)
-		return -EINVAL;
-
 	scsi_device_unregister(sdev);
-
-	scsi_free_sdev(sdev);
 	return 0;
 }
 
diff -urN linux-2.5.69-bk7/drivers/scsi/scsi_syms.c linux-2.5.69-bk8/drivers/scsi/scsi_syms.c
--- linux-2.5.69-bk7/drivers/scsi/scsi_syms.c	2003-05-04 16:53:14.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/scsi_syms.c	2003-05-13 04:44:29.000000000 -0700
@@ -21,6 +21,7 @@
 #include "scsi.h"
 #include <scsi/scsi_ioctl.h>
 #include "hosts.h"
+#include "scsi_logging.h"
 
 #include <scsi/scsicam.h>
 
@@ -64,6 +65,7 @@
 EXPORT_SYMBOL(scsi_put_command);
 
 EXPORT_SYMBOL(scsi_report_bus_reset);
+EXPORT_SYMBOL(scsi_report_device_reset);
 EXPORT_SYMBOL(scsi_block_requests);
 EXPORT_SYMBOL(scsi_unblock_requests);
 EXPORT_SYMBOL(scsi_adjust_queue_depth);
@@ -76,8 +78,6 @@
 
 EXPORT_SYMBOL(scsi_io_completion);
 
-EXPORT_SYMBOL(scsi_slave_attach);
-EXPORT_SYMBOL(scsi_slave_detach);
 EXPORT_SYMBOL(scsi_device_get);
 EXPORT_SYMBOL(scsi_device_put);
 EXPORT_SYMBOL(scsi_add_device);
@@ -104,12 +104,5 @@
 /*
  * Externalize timers so that HBAs can safely start/restart commands.
  */
-extern void scsi_add_timer(Scsi_Cmnd *, int, void ((*) (Scsi_Cmnd *)));
-extern int scsi_delete_timer(Scsi_Cmnd *);
 EXPORT_SYMBOL(scsi_add_timer);
 EXPORT_SYMBOL(scsi_delete_timer);
-
-/*
- * sysfs support
- */
-EXPORT_SYMBOL(shost_class);
diff -urN linux-2.5.69-bk7/drivers/scsi/scsi_sysfs.c linux-2.5.69-bk8/drivers/scsi/scsi_sysfs.c
--- linux-2.5.69-bk7/drivers/scsi/scsi_sysfs.c	2003-05-04 16:53:07.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/scsi_sysfs.c	2003-05-13 04:44:29.000000000 -0700
@@ -14,6 +14,7 @@
 #include "scsi.h"
 #include "hosts.h"
 
+#include "scsi_priv.h"
 
 /*
  * shost_show_function: macro to create an attr function that can be used to
@@ -21,9 +22,9 @@
  */
 #define shost_show_function(field, format_string)			\
 static ssize_t								\
-show_##field (struct device *dev, char *buf)				\
+show_##field (struct class_device *class_dev, char *buf)		\
 {									\
-	struct Scsi_Host *shost = to_scsi_host(dev);			\
+	struct Scsi_Host *shost = class_to_shost(class_dev);		\
 	return snprintf (buf, 20, format_string, shost->field);	\
 }
 
@@ -32,8 +33,8 @@
  * read only field.
  */
 #define shost_rd_attr(field, format_string)				\
-	shost_show_function(field, format_string)				\
-static DEVICE_ATTR(field, S_IRUGO, show_##field, NULL)
+	shost_show_function(field, format_string)			\
+static CLASS_DEVICE_ATTR(field, S_IRUGO, show_##field, NULL)
 
 /*
  * Create the actual show/store functions and data structures.
@@ -44,39 +45,16 @@
 shost_rd_attr(sg_tablesize, "%hu\n");
 shost_rd_attr(unchecked_isa_dma, "%d\n");
 
-static struct device_attribute *const shost_attrs[] = {
-	&dev_attr_unique_id,
-	&dev_attr_host_busy,
-	&dev_attr_cmd_per_lun,
-	&dev_attr_sg_tablesize,
-	&dev_attr_unchecked_isa_dma,
+static struct class_device_attribute *const shost_attrs[] = {
+	&class_device_attr_unique_id,
+	&class_device_attr_host_busy,
+	&class_device_attr_cmd_per_lun,
+	&class_device_attr_sg_tablesize,
+	&class_device_attr_unchecked_isa_dma,
 };
 
-/**
- * scsi_host_class_name_show - copy out the SCSI host name
- * @dev:		device to check
- * @page:		copy data into this area
- * @count:		number of bytes to copy
- * @off:		start at this offset in page
- * Return:
- *     number of bytes written into page.
- **/
-static ssize_t scsi_host_class_name_show(struct device *dev, char *page)
-{
-	struct Scsi_Host *shost;
-
-	shost = to_scsi_host(dev);
-
-	if (!shost)
-		return 0;
-	
-	return snprintf(page, 20, "scsi%d\n", shost->host_no);
-}
-
-DEVICE_ATTR(class_name, S_IRUGO, scsi_host_class_name_show, NULL);
-
-struct class shost_class = {
-	.name		= "scsi-host",
+static struct class shost_class = {
+	.name		= "scsi_host",
 };
 
 /**
@@ -113,10 +91,16 @@
 
 int scsi_sysfs_register(void)
 {
-	bus_register(&scsi_bus_type);
-	class_register(&shost_class);
+	int error;
 
-	return 0;
+	error = bus_register(&scsi_bus_type);
+	if (error)
+		return error;
+	error = class_register(&shost_class);
+	if (error)
+		return error;
+
+	return error;
 }
 
 void scsi_sysfs_unregister(void)
@@ -272,6 +256,16 @@
 	&dev_attr_rescan,
 };
 
+static void scsi_device_release(struct device *dev)
+{
+	struct scsi_device *sdev;
+
+	sdev = to_scsi_device(dev);
+	if (!sdev)
+		return;
+	scsi_free_sdev(sdev);
+}
+
 /**
  * scsi_device_register - register a scsi device with the scsi bus
  * @sdev:	scsi_device to register
@@ -285,8 +279,9 @@
 
 	sprintf(sdev->sdev_driverfs_dev.bus_id,"%d:%d:%d:%d",
 		sdev->host->host_no, sdev->channel, sdev->id, sdev->lun);
-	sdev->sdev_driverfs_dev.parent = sdev->host->host_gendev;
+	sdev->sdev_driverfs_dev.parent = &sdev->host->host_gendev;
 	sdev->sdev_driverfs_dev.bus = &scsi_bus_type;
+	sdev->sdev_driverfs_dev.release = scsi_device_release;
 
 	error = device_register(&sdev->sdev_driverfs_dev);
 	if (error)
@@ -314,3 +309,77 @@
 		device_remove_file(&sdev->sdev_driverfs_dev, sdev_attrs[i]);
 	device_unregister(&sdev->sdev_driverfs_dev);
 }
+
+static void scsi_host_release(struct device *dev)
+{
+	struct Scsi_Host *shost;
+
+	shost = dev_to_shost(dev);
+	if (!shost)
+		return;
+
+	scsi_free_shost(shost);
+}
+
+void scsi_sysfs_init_host(struct Scsi_Host *shost)
+{
+	device_initialize(&shost->host_gendev);
+	snprintf(shost->host_gendev.bus_id, BUS_ID_SIZE, "host%d",
+		shost->host_no);
+	snprintf(shost->host_gendev.name, DEVICE_NAME_SIZE, "%s",
+		shost->hostt->proc_name);
+	shost->host_gendev.release = scsi_host_release;
+
+	class_device_initialize(&shost->class_dev);
+	shost->class_dev.dev = &shost->host_gendev;
+	shost->class_dev.class = &shost_class;
+	snprintf(shost->class_dev.class_id, BUS_ID_SIZE, "host%d",
+		  shost->host_no);
+}
+
+/**
+ * scsi_sysfs_add_host - add scsi host to subsystem
+ * @shost:     scsi host struct to add to subsystem
+ * @dev:       parent struct device pointer
+ **/
+int scsi_sysfs_add_host(struct Scsi_Host *shost, struct device *dev)
+{
+	int i, error;
+
+	if (!shost->host_gendev.parent)
+		shost->host_gendev.parent = (dev) ? dev : &legacy_bus;
+
+	error = device_add(&shost->host_gendev);
+	if (error)
+		return error;
+
+	error = class_device_add(&shost->class_dev);
+	if (error)
+		goto clean_device;
+
+	for (i = 0; !error && i < ARRAY_SIZE(shost_attrs); i++)
+		error = class_device_create_file(&shost->class_dev,
+					   shost_attrs[i]);
+	if (error)
+		goto clean_class;
+
+	return error;
+
+clean_class:
+	class_device_del(&shost->class_dev);
+clean_device:
+	device_del(&shost->host_gendev);
+
+	return error;
+}
+
+/**
+ * scsi_sysfs_remove_host - remove scsi host from subsystem
+ * @shost:     scsi host to remove from subsystem
+ **/
+void scsi_sysfs_remove_host(struct Scsi_Host *shost)
+{
+	class_device_del(&shost->class_dev);
+	device_del(&shost->host_gendev);
+}
+
diff -urN linux-2.5.69-bk7/drivers/scsi/sd.c linux-2.5.69-bk8/drivers/scsi/sd.c
--- linux-2.5.69-bk7/drivers/scsi/sd.c	2003-05-04 16:53:36.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/sd.c	2003-05-13 04:44:29.000000000 -0700
@@ -52,6 +52,9 @@
 #include <scsi/scsi_ioctl.h>
 #include <scsi/scsicam.h>
 
+#include "scsi_logging.h"
+
+
 /*
  * Remaining dev_t-handling stuff
  */
@@ -696,7 +699,7 @@
 	int good_sectors = (result == 0 ? this_count : 0);
 	sector_t block_sectors = 1;
 	sector_t error_sector;
-#if CONFIG_SCSI_LOGGING
+#ifdef CONFIG_SCSI_LOGGING
 	SCSI_LOG_HLCOMPLETE(1, printk("sd_rw_intr: %s: res=0x%x\n", 
 				SCpnt->request->rq_disk->disk_name, result));
 	if (0 != result) {
@@ -808,7 +811,8 @@
 	       struct scsi_request *SRpnt, unsigned char *buffer) {
 	unsigned char cmd[10];
 	unsigned long spintime_value = 0;
-	int the_result, retries, spintime;
+	int retries, spintime;
+	unsigned int the_result;
 
 	spintime = 0;
 
@@ -817,7 +821,7 @@
 	do {
 		retries = 0;
 
-		while (retries < 3) {
+		do {
 			cmd[0] = TEST_UNIT_READY;
 			memset((void *) &cmd[1], 0, 9);
 
@@ -831,10 +835,9 @@
 
 			the_result = SRpnt->sr_result;
 			retries++;
-			if (the_result == 0
-			    || SRpnt->sr_sense_buffer[2] != UNIT_ATTENTION)
-				break;
-		}
+		} while (retries < 3 && !scsi_status_is_good(the_result)
+			 && ((driver_byte(the_result) & DRIVER_SENSE)
+			     && SRpnt->sr_sense_buffer[2] == UNIT_ATTENTION));
 
 		/*
 		 * If the drive has indicated to us that it doesn't have
@@ -844,8 +847,15 @@
 		if (media_not_present(sdkp, SRpnt))
 			return;
 
-		if (the_result == 0)
-			break;		/* all is well now */
+		if ((driver_byte(the_result) & DRIVER_SENSE) == 0) {
+			/* no sense, TUR either succeeded or failed
+			 * with a status error */
+			if(!spintime && !scsi_status_is_good(the_result))
+				printk(KERN_NOTICE "%s: Unit Not Ready, error = 0x%x\n", diskname, the_result);
+			break;
+		}
+					
+					
 
 		/*
 		 * If manual intervention is required, or this is an
@@ -853,13 +863,13 @@
 		 */
 		if (SRpnt->sr_sense_buffer[2] == NOT_READY &&
 		    SRpnt->sr_sense_buffer[12] == 4 /* not ready */ &&
-		    SRpnt->sr_sense_buffer[13] == 3)
+		    SRpnt->sr_sense_buffer[13] == 3) {
 			break;		/* manual intervention required */
 
 		/*
 		 * Issue command to spin up drive when not ready
 		 */
-		if (SRpnt->sr_sense_buffer[2] == NOT_READY) {
+		} else if (SRpnt->sr_sense_buffer[2] == NOT_READY) {
 			unsigned long time1;
 			if (!spintime) {
 				printk(KERN_NOTICE "%s: Spinning up disk...",
@@ -886,15 +896,24 @@
 				time1 = schedule_timeout(time1);
 			} while(time1);
 			printk(".");
+		} else {
+			/* we don't understand the sense code, so it's
+			 * probably pointless to loop */
+			if(!spintime) {
+				printk(KERN_NOTICE "%s: Unit Not Ready, sense:\n", diskname);
+				print_req_sense("", SRpnt);
+			}
+			break;
 		}
+				
 	} while (spintime &&
 		 time_after(spintime_value + 100 * HZ, jiffies));
 
 	if (spintime) {
-		if (the_result)
-			printk("not responding...\n");
-		else
+		if (scsi_status_is_good(the_result))
 			printk("ready\n");
+		else
+			printk("not responding...\n");
 	}
 }
 
@@ -1299,14 +1318,10 @@
 	SCSI_LOG_HLQUEUE(3, printk("sd_attach: scsi device: <%d,%d,%d,%d>\n", 
 			 sdp->host->host_no, sdp->channel, sdp->id, sdp->lun));
 
-	error = scsi_slave_attach(sdp);
-	if (error)
-		goto out;
-
 	error = -ENOMEM;
 	sdkp = kmalloc(sizeof(*sdkp), GFP_KERNEL);
 	if (!sdkp)
-		goto out_detach;
+		goto out;
 
 	gd = alloc_disk(16);
 	if (!gd)
@@ -1365,8 +1380,6 @@
 	put_disk(gd);
 out_free:
 	kfree(sdkp);
-out_detach:
-	scsi_slave_detach(sdp);
 out:
 	return error;
 }
@@ -1403,7 +1416,6 @@
 
 	sd_devlist_remove(sdkp);
 	del_gendisk(sdkp->disk);
-	scsi_slave_detach(sdp);
 
 	spin_lock(&sd_index_lock);
 	clear_bit(sdkp->index, sd_index_bits);
@@ -1502,7 +1514,8 @@
 			printk("FAILED\n  No memory for request\n");
 		return 0;
 	}
-		
+
+	SRpnt->sr_data_direction = SCSI_DATA_NONE;
 
 	for(retries = 3; retries > 0; --retries) {
 		unsigned char cmd[10] = { 0 };
diff -urN linux-2.5.69-bk7/drivers/scsi/seagate.c linux-2.5.69-bk8/drivers/scsi/seagate.c
--- linux-2.5.69-bk7/drivers/scsi/seagate.c	2003-05-04 16:53:14.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/seagate.c	2003-05-13 04:44:29.000000000 -0700
@@ -1700,7 +1700,20 @@
 	return 0;
 }
 
-/* Eventually this will go into an include file, but this will be later */
-static Scsi_Host_Template driver_template = SEAGATE_ST0X;
-
+static Scsi_Host_Template driver_template = {
+	.detect         	= seagate_st0x_detect,
+	.release        	= seagate_st0x_release,
+	.info           	= seagate_st0x_info,
+	.command        	= seagate_st0x_command,
+	.queuecommand   	= seagate_st0x_queue_command,
+	.eh_abort_handler	= seagate_st0x_abort,
+	.eh_bus_reset_handler	= seagate_st0x_bus_reset,
+	.eh_host_reset_handler	= seagate_st0x_host_reset,
+	.eh_device_reset_handler = seagate_st0x_device_reset,
+	.can_queue      	= 1,
+	.this_id        	= 7,
+	.sg_tablesize   	= SG_ALL,
+	.cmd_per_lun    	= 1,
+	.use_clustering		= DISABLE_CLUSTERING,
+};
 #include "scsi_module.c"
diff -urN linux-2.5.69-bk7/drivers/scsi/seagate.h linux-2.5.69-bk8/drivers/scsi/seagate.h
--- linux-2.5.69-bk7/drivers/scsi/seagate.h	2003-05-04 16:53:37.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/seagate.h	2003-05-13 04:44:29.000000000 -0700
@@ -19,19 +19,4 @@
 static int seagate_st0x_device_reset(Scsi_Cmnd *);
 static int seagate_st0x_host_reset(Scsi_Cmnd *);
 
-#define SEAGATE_ST0X  {  .detect         = seagate_st0x_detect,			\
-			 .release        = seagate_st0x_release,			\
-			 .info           = seagate_st0x_info,			\
-			 .command        = seagate_st0x_command,			\
-			 .queuecommand   = seagate_st0x_queue_command,		\
-			 .eh_abort_handler	= seagate_st0x_abort,		\
-			 .eh_bus_reset_handler  = seagate_st0x_bus_reset,		\
-			 .eh_host_reset_handler = seagate_st0x_host_reset,	\
-			 .eh_device_reset_handler = seagate_st0x_device_reset,	\
-			 .can_queue      = 1,					\
-			 .this_id        = 7,					\
-			 .sg_tablesize   = SG_ALL,				\
-			 .cmd_per_lun    = 1,					\
-			 .use_clustering = DISABLE_CLUSTERING}
-
 #endif /* _SEAGATE_H */
diff -urN linux-2.5.69-bk7/drivers/scsi/sg.c linux-2.5.69-bk8/drivers/scsi/sg.c
--- linux-2.5.69-bk7/drivers/scsi/sg.c	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/sg.c	2003-05-13 04:44:29.000000000 -0700
@@ -67,6 +67,8 @@
 #include <scsi/scsi_ioctl.h>
 #include <scsi/sg.h>
 
+#include "scsi_logging.h"
+
 #ifdef CONFIG_PROC_FS
 #include <linux/proc_fs.h>
 static int sg_proc_init(void);
@@ -1356,10 +1358,6 @@
 	if (!disk)
 		return -ENOMEM;
 
-	error = scsi_slave_attach(scsidp);
-	if (error)
-		goto out_put;
-		
 	write_lock_irqsave(&sg_dev_arr_lock, iflags);
 	if (sg_nr_dev >= sg_dev_max) {	/* try to resize */
 		Sg_device **tmp_da;
@@ -1372,7 +1370,7 @@
 			printk(KERN_ERR
 			       "sg_attach: device array cannot be resized\n");
 			error = -ENOMEM;
-			goto out_detach;
+			goto out;
 		}
 		write_lock_irqsave(&sg_dev_arr_lock, iflags);
 		memset(tmp_da, 0, tmp_dev_max * sizeof (Sg_device *));
@@ -1397,7 +1395,7 @@
 		if (NULL != sdp)
 			vfree((char *) sdp);
 		error = -ENODEV;
-		goto out_detach;
+		goto out;
 	}
 	if (k < sg_dev_max) {
 		if (NULL == sdp) {
@@ -1413,7 +1411,7 @@
 		write_unlock_irqrestore(&sg_dev_arr_lock, iflags);
 		printk(KERN_ERR "sg_attach: Sg_device cannot be allocated\n");
 		error = -ENOMEM;
-		goto out_detach;
+		goto out;
 	}
 
 	SCSI_LOG_TIMEOUT(3, printk("sg_attach: dev=%d \n", k));
@@ -1468,9 +1466,7 @@
 	}
 	return 0;
 
-out_detach:
-	scsi_slave_detach(scsidp);
-out_put:
+out:
 	put_disk(disk);
 	return error;
 }
@@ -1521,7 +1517,6 @@
 			SCSI_LOG_TIMEOUT(3, printk("sg_detach: dev=%d\n", k));
 			sg_dev_arr[k] = NULL;
 		}
-		scsi_slave_detach(scsidp);
 		sg_nr_dev--;
 		break;
 	}
diff -urN linux-2.5.69-bk7/drivers/scsi/sgiwd93.c linux-2.5.69-bk8/drivers/scsi/sgiwd93.c
--- linux-2.5.69-bk7/drivers/scsi/sgiwd93.c	2003-05-04 16:53:41.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/sgiwd93.c	2003-05-13 04:44:29.000000000 -0700
@@ -227,9 +227,7 @@
 
 	if (request_irq(SGI_WD93_0_IRQ, sgiwd93_intr, 0, "SGI WD93", (void *) sgiwd93_host)) {
 		printk(KERN_WARNING "sgiwd93: Could not register IRQ %d (for host 0).\n", SGI_WD93_0_IRQ);
-#ifdef MODULE
 		wd33c93_release();
-#endif
 		free_page((unsigned long)buf);
 		scsi_unregister(sgiwd93_host);
 		return 0;
@@ -263,9 +261,7 @@
 	
 			if (request_irq(SGI_WD93_1_IRQ, sgiwd93_intr, 0, "SGI WD93", (void *) sgiwd93_host1)) {
 				printk(KERN_WARNING "sgiwd93: Could not allocate irq %d (for host1).\n", SGI_WD93_1_IRQ);
-#ifdef MODULE
 				wd33c93_release();
-#endif
 				free_page((unsigned long)buf);
 				scsi_unregister(sgiwd93_host1);
 				/* Fall through since host0 registered OK */
@@ -278,17 +274,8 @@
 	return 1; /* Found one. */
 }
 
-#define HOSTS_C
-
-#include "sgiwd93.h"
-
-static Scsi_Host_Template driver_template = SGIWD93_SCSI;
-
-#include "scsi_module.c"
-
 int sgiwd93_release(struct Scsi_Host *instance)
 {
-#ifdef MODULE
 	free_irq(SGI_WD93_0_IRQ, sgiwd93_intr);
 	free_page(KSEG0ADDR(hdata->dma_bounce_buffer));
 	wd33c93_release();
@@ -297,6 +284,21 @@
 		free_page(KSEG0ADDR(hdata1->dma_bounce_buffer));
 		wd33c93_release();
 	}
-#endif
 	return 1;
 }
+
+static Scsi_Host_Template driver_template = {
+	.proc_name	     = "SGIWD93",
+	.name                = "SGI WD93",
+	.detect              = sgiwd93_detect,
+	.release             = sgiwd93_release,
+	.queuecommand        = wd33c93_queuecommand,
+	.abort               = wd33c93_abort,
+	.reset               = wd33c93_reset,
+	.can_queue           = CAN_QUEUE,
+	.this_id             = 7,
+	.sg_tablesize        = SG_ALL,
+	.cmd_per_lun	     = CMD_PER_LUN,
+	.use_clustering      = DISABLE_CLUSTERING,
+};
+#include "scsi_module.c"
diff -urN linux-2.5.69-bk7/drivers/scsi/sgiwd93.h linux-2.5.69-bk8/drivers/scsi/sgiwd93.h
--- linux-2.5.69-bk7/drivers/scsi/sgiwd93.h	2003-05-04 16:53:12.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/sgiwd93.h	2003-05-13 04:44:29.000000000 -0700
@@ -25,17 +25,4 @@
 int wd33c93_abort(Scsi_Cmnd *);
 int wd33c93_reset(Scsi_Cmnd *, unsigned int);
 
-#define SGIWD93_SCSI {.proc_name	   = "SGIWD93", \
-		      .name                = "SGI WD93", \
-		      .detect              = sgiwd93_detect,    \
-		      .release             = sgiwd93_release,   \
-		      .queuecommand        = wd33c93_queuecommand, \
-		      .abort               = wd33c93_abort,   \
-		      .reset               = wd33c93_reset,   \
-		      .can_queue           = CAN_QUEUE,       \
-		      .this_id             = 7,               \
-		      .sg_tablesize        = SG_ALL,          \
-		      .cmd_per_lun	   = CMD_PER_LUN,     \
-		      .use_clustering      = DISABLE_CLUSTERING }
-
 #endif /* !(_SGIWD93_H) */
diff -urN linux-2.5.69-bk7/drivers/scsi/sim710.c linux-2.5.69-bk8/drivers/scsi/sim710.c
--- linux-2.5.69-bk7/drivers/scsi/sim710.c	2003-05-04 16:53:37.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/sim710.c	2003-05-13 04:44:29.000000000 -0700
@@ -155,7 +155,7 @@
 static __devexit int
 sim710_device_remove(struct device *dev)
 {
-	struct Scsi_Host *host = to_scsi_host(dev);
+	struct Scsi_Host *host = dev_to_shost(dev);
 	struct NCR_700_Host_Parameters *hostdata =
 		(struct NCR_700_Host_Parameters *)host->hostdata[0];
 
diff -urN linux-2.5.69-bk7/drivers/scsi/sr.c linux-2.5.69-bk8/drivers/scsi/sr.c
--- linux-2.5.69-bk7/drivers/scsi/sr.c	2003-05-04 16:53:08.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/sr.c	2003-05-13 04:44:29.000000000 -0700
@@ -50,6 +50,7 @@
 #include "hosts.h"
 #include <scsi/scsi_ioctl.h>	/* For the door lock/unlock commands */
 
+#include "scsi_logging.h"
 #include "sr.h"
 
 
@@ -514,10 +515,6 @@
 	if (sdev->type != TYPE_ROM && sdev->type != TYPE_WORM)
 		return 1;
 
-	error = scsi_slave_attach(sdev);
-	if (error)
-		return error;
-
 	error = -ENOMEM;
 	cd = kmalloc(sizeof(*cd), GFP_KERNEL);
 	if (!cd)
@@ -591,7 +588,6 @@
 fail_free:
 	kfree(cd);
 fail:
-	scsi_slave_detach(sdev);
 	return error;
 }
 
@@ -819,7 +815,6 @@
 		return;
 
 	sr_devlist_remove(cd);
-	scsi_slave_detach(SDp);
 	del_gendisk(cd->disk);
 
 	spin_lock(&sr_index_lock);
diff -urN linux-2.5.69-bk7/drivers/scsi/st.c linux-2.5.69-bk8/drivers/scsi/st.c
--- linux-2.5.69-bk7/drivers/scsi/st.c	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/st.c	2003-05-13 04:44:29.000000000 -0700
@@ -3725,16 +3725,13 @@
 		return 1;
 	}
 
-	if (scsi_slave_attach(SDp))
-		return 1;
-
 	i = SDp->host->sg_tablesize;
 	if (st_max_sg_segs < i)
 		i = st_max_sg_segs;
 	buffer = new_tape_buffer(TRUE, (SDp->host)->unchecked_isa_dma, i);
 	if (buffer == NULL) {
 		printk(KERN_ERR "st: Can't allocate new tape buffer. Device not attached.\n");
-		goto out_slave_detach;
+		goto out;
 	}
 
 	disk = alloc_disk(1);
@@ -3920,8 +3917,7 @@
 	put_disk(disk);
 out_buffer_free:
 	kfree(buffer);
-out_slave_detach:
-	scsi_slave_detach(SDp);
+out:
 	return 1;
 };
 
@@ -3959,7 +3955,6 @@
 				normalize_buffer(tpnt->buffer);
 				kfree(tpnt->buffer);
 			}
-			scsi_slave_detach(SDp);
 			put_disk(tpnt->disk);
 			kfree(tpnt);
 			return;
diff -urN linux-2.5.69-bk7/drivers/scsi/sym53c416.c linux-2.5.69-bk8/drivers/scsi/sym53c416.c
--- linux-2.5.69-bk7/drivers/scsi/sym53c416.c	2003-05-04 16:53:02.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/sym53c416.c	2003-05-13 04:44:30.000000000 -0700
@@ -875,6 +875,24 @@
 
 #endif
 
-static Scsi_Host_Template driver_template = SYM53C416;
-
+static Scsi_Host_Template driver_template = {
+	.proc_name =		"sym53c416",
+	.name =			"Symbios Logic 53c416",
+	.detect =		sym53c416_detect,
+	.info =			sym53c416_info,	
+	.command =		sym53c416_command,
+	.queuecommand =		sym53c416_queuecommand,
+	.eh_abort_handler =	sym53c416_abort,
+	.eh_host_reset_handler =sym53c416_host_reset,
+	.eh_bus_reset_handler = sym53c416_bus_reset,
+	.eh_device_reset_handler =sym53c416_device_reset,
+	.release = 		sym53c416_release,
+	.bios_param =		sym53c416_bios_param,
+	.can_queue =		1,
+	.this_id =		SYM53C416_SCSI_ID,
+	.sg_tablesize =		32,
+	.cmd_per_lun =		1,
+	.unchecked_isa_dma =	1,
+	.use_clustering =	ENABLE_CLUSTERING,
+};
 #include "scsi_module.c"
diff -urN linux-2.5.69-bk7/drivers/scsi/sym53c416.h linux-2.5.69-bk8/drivers/scsi/sym53c416.h
--- linux-2.5.69-bk7/drivers/scsi/sym53c416.h	2003-05-04 16:53:36.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/sym53c416.h	2003-05-13 04:44:30.000000000 -0700
@@ -34,25 +34,4 @@
 static int sym53c416_bios_param(struct scsi_device *, struct block_device *,
 		sector_t, int *);
 static void sym53c416_setup(char *str, int *ints);
-
-#define SYM53C416 {						\
-		.proc_name =		"sym53c416",		\
-		.name =			"Symbios Logic 53c416",	\
-		.detect =		sym53c416_detect,	\
-		.info =			sym53c416_info,		\
-		.command =		sym53c416_command,	\
-		.queuecommand =		sym53c416_queuecommand,	\
-		.eh_abort_handler =	sym53c416_abort,	\
-		.eh_host_reset_handler =sym53c416_host_reset,	\
-		.eh_bus_reset_handler = sym53c416_bus_reset,	\
-		.eh_device_reset_handler =sym53c416_device_reset,\
-		.release = 		sym53c416_release,	\
-		.bios_param =		sym53c416_bios_param,	\
-		.can_queue =		1,			\
-		.this_id =		SYM53C416_SCSI_ID,	\
-		.sg_tablesize =		32,			\
-		.cmd_per_lun =		1,			\
-		.unchecked_isa_dma =	1,			\
-		.use_clustering =	ENABLE_CLUSTERING	\
-		}
 #endif
diff -urN linux-2.5.69-bk7/drivers/scsi/sym53c8xx.c linux-2.5.69-bk8/drivers/scsi/sym53c8xx.c
--- linux-2.5.69-bk7/drivers/scsi/sym53c8xx.c	2003-05-04 16:53:35.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/sym53c8xx.c	2003-05-13 04:44:30.000000000 -0700
@@ -14718,10 +14718,21 @@
 
 MODULE_LICENSE("GPL");
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-static
-#endif
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) || defined(MODULE)
-Scsi_Host_Template driver_template = SYM53C8XX;
+static Scsi_Host_Template driver_template = {
+	.name           = "sym53c8xx",
+	.detect         = sym53c8xx_detect,
+	.release        = sym53c8xx_release,
+	.info           = sym53c8xx_info, 
+	.queuecommand   = sym53c8xx_queue_command,
+	.slave_configure = sym53c8xx_slave_configure,
+	.abort          = sym53c8xx_abort,
+	.reset          = sym53c8xx_reset,
+	.can_queue      = SCSI_NCR_CAN_QUEUE,
+	.this_id        = 7,
+	.sg_tablesize   = SCSI_NCR_SG_TABLESIZE,
+	.cmd_per_lun    = SCSI_NCR_CMD_PER_LUN,
+	.max_sectors	= MAX_HW_SEGMENTS*8,
+	.use_clustering = DISABLE_CLUSTERING,
+	.highmem_io	= 1
+};
 #include "scsi_module.c"
-#endif
diff -urN linux-2.5.69-bk7/drivers/scsi/sym53c8xx.h linux-2.5.69-bk8/drivers/scsi/sym53c8xx.h
--- linux-2.5.69-bk7/drivers/scsi/sym53c8xx.h	2003-05-04 16:53:13.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/sym53c8xx.h	2003-05-13 04:44:30.000000000 -0700
@@ -77,37 +77,6 @@
 int sym53c8xx_slave_configure(Scsi_Device *);
 int sym53c8xx_release(struct Scsi_Host *);
 
-#if	LINUX_VERSION_CODE >= LinuxVersionCode(2,1,75)
-
-#define SYM53C8XX {     .name           = "sym53c8xx",		\
-			.detect         = sym53c8xx_detect,	\
-			.release        = sym53c8xx_release,	\
-			.info           = sym53c8xx_info, 	\
-			.queuecommand   = sym53c8xx_queue_command,\
-			.slave_configure = sym53c8xx_slave_configure,\
-			.abort          = sym53c8xx_abort,	\
-			.reset          = sym53c8xx_reset,	\
-			.can_queue      = SCSI_NCR_CAN_QUEUE,	\
-			.this_id        = 7,			\
-			.sg_tablesize   = SCSI_NCR_SG_TABLESIZE,	\
-			.cmd_per_lun    = SCSI_NCR_CMD_PER_LUN,	\
-			.max_sectors	= MAX_HW_SEGMENTS*8,	\
-			.use_clustering = DISABLE_CLUSTERING,	\
-			.highmem_io	= 1} 
-
-#else
-
-#define SYM53C8XX {	NULL, NULL, NULL, NULL,				\
-			NULL,			sym53c8xx_detect,	\
-			sym53c8xx_release,	sym53c8xx_info,	NULL,	\
-			sym53c8xx_queue_command,sym53c8xx_abort,	\
-			sym53c8xx_reset, NULL,	scsicam_bios_param,	\
-			SCSI_NCR_CAN_QUEUE,	7,			\
-			SCSI_NCR_SG_TABLESIZE,	SCSI_NCR_CMD_PER_LUN,	\
-			0,	0,	DISABLE_CLUSTERING} 
- 
-#endif /* LINUX_VERSION_CODE */
-
 #endif /* defined(HOSTS_C) || defined(MODULE) */ 
 
 #endif /* SYM53C8XX_H */
diff -urN linux-2.5.69-bk7/drivers/scsi/sym53c8xx_2/sym53c8xx.h linux-2.5.69-bk8/drivers/scsi/sym53c8xx_2/sym53c8xx.h
--- linux-2.5.69-bk7/drivers/scsi/sym53c8xx_2/sym53c8xx.h	2003-05-04 16:53:57.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/sym53c8xx_2/sym53c8xx.h	2003-05-13 04:44:30.000000000 -0700
@@ -79,57 +79,10 @@
 #endif
 #endif
 
-int sym53c8xx_detect(Scsi_Host_Template *tpnt);
-const char *sym53c8xx_info(struct Scsi_Host *host);
-
-int sym53c8xx_queue_command(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
-
-int sym53c8xx_eh_abort_handler(Scsi_Cmnd *);
-int sym53c8xx_eh_device_reset_handler(Scsi_Cmnd *);
-int sym53c8xx_eh_bus_reset_handler(Scsi_Cmnd *);
-int sym53c8xx_eh_host_reset_handler(Scsi_Cmnd *);
-
-int sym53c8xx_slave_configure(Scsi_Device *);
-
-#ifdef MODULE
-int sym53c8xx_release(struct Scsi_Host *);
-#else
-#define sym53c8xx_release NULL
-#endif
-
-
-/*
- *  Host template defintion
- */
-#if (LINUX_VERSION_CODE >= 0x020400) || defined(HOSTS_C) || defined(MODULE)
-
-#include <scsi/scsicam.h>
-
-#define SYM53C8XX {							\
-	.name			= "sym53c8xx",				\
-	.detect			= sym53c8xx_detect,			\
-	.release		= sym53c8xx_release,			\
-	.info			= sym53c8xx_info, 			\
-	.queuecommand		= sym53c8xx_queue_command,		\
-	.slave_configure	= sym53c8xx_slave_configure,		\
-	.eh_abort_handler	= sym53c8xx_eh_abort_handler,		\
-	.eh_device_reset_handler	= sym53c8xx_eh_device_reset_handler,\
-	.eh_bus_reset_handler	= sym53c8xx_eh_bus_reset_handler,	\
-	.eh_host_reset_handler	= sym53c8xx_eh_host_reset_handler,	\
-	.can_queue		= 0,					\
-	.this_id		= 7,					\
-	.sg_tablesize		= 0,					\
-	.cmd_per_lun		= 0,					\
-	.use_clustering		= DISABLE_CLUSTERING,			\
-	.highmem_io		= 1}
-
-#endif /* defined(HOSTS_C) || defined(MODULE) */ 
-
 /*
  *  Translate kernel configuration parameters
  *  into corresponding driver parameters.
  */
-#if !defined(HOSTS_C)
 
 /*
  *  Use normal IO if configured.
@@ -367,6 +320,4 @@
 #endif
 #define boot_verbose	sym_driver_setup.verbose
 
-#endif /* !defined(HOSTS_C) */ 
-
 #endif /* SYM53C8XX_H */
diff -urN linux-2.5.69-bk7/drivers/scsi/sym53c8xx_2/sym_glue.c linux-2.5.69-bk8/drivers/scsi/sym53c8xx_2/sym_glue.c
--- linux-2.5.69-bk7/drivers/scsi/sym53c8xx_2/sym_glue.c	2003-05-04 16:53:57.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/sym53c8xx_2/sym_glue.c	2003-05-13 04:44:30.000000000 -0700
@@ -2558,35 +2558,17 @@
 	bcopy(chip, &device->chip, sizeof(device->chip));
 	device->chip.revision_id = revision;
 
+	if (pci_enable_device(pdev))
+		return -1;
+
+	pci_set_master(pdev);
+
 	/*
 	 *  Read additionnal info from the configuration space.
 	 */
-	pci_read_config_word(pdev, PCI_COMMAND,		&command);
 	pci_read_config_byte(pdev, PCI_CACHE_LINE_SIZE,	&cache_line_size);
 
 	/*
-	 * Enable missing capabilities in the PCI COMMAND register.
-	 */
-#ifdef SYM_CONF_IOMAPPED
-#define	PCI_COMMAND_BITS_TO_ENABLE (PCI_COMMAND_IO | \
-	PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER | PCI_COMMAND_PARITY)
-#else
-#define	PCI_COMMAND_BITS_TO_ENABLE \
-	(PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER | PCI_COMMAND_PARITY)
-#endif
-	if ((command & PCI_COMMAND_BITS_TO_ENABLE)
-		    != PCI_COMMAND_BITS_TO_ENABLE) {
-		printf_info("%s: setting%s%s%s%s...\n", sym_name(device),
-		(command & PCI_COMMAND_IO)     ? "" : " PCI_COMMAND_IO",
-		(command & PCI_COMMAND_MEMORY) ? "" : " PCI_COMMAND_MEMORY",
-		(command & PCI_COMMAND_MASTER) ? "" : " PCI_COMMAND_MASTER",
-		(command & PCI_COMMAND_PARITY) ? "" : " PCI_COMMAND_PARITY");
-		command |= PCI_COMMAND_BITS_TO_ENABLE;
-		pci_write_config_word(pdev, PCI_COMMAND, command);
-	}
-#undef	PCI_COMMAND_BITS_TO_ENABLE
-
-	/*
 	 *  If cache line size is not configured, suggest
 	 *  a value for well known CPUs.
 	 */
@@ -2625,6 +2607,7 @@
 		            sym_name(device), cache_line_size);
 	}
 
+	pci_read_config_word(pdev, PCI_COMMAND,	&command);
 	if ((pci_fix_up & 2) && cache_line_size &&
 	    (chip->features & FE_WRIE) && !(command & PCI_COMMAND_INVALIDATE)) {
 		printf_info("%s: setting PCI_COMMAND_INVALIDATE.\n",
@@ -2725,15 +2708,6 @@
 	/*
 	 *    Initialize driver general stuff.
 	 */
-#ifdef SYM_LINUX_PROC_INFO_SUPPORT
-#if LINUX_VERSION_CODE < LinuxVersionCode(2,3,27)
-     tpnt->proc_dir  = &proc_scsi_sym53c8xx;
-#else
-     tpnt->proc_name = NAME53C8XX;
-#endif
-     tpnt->proc_info = sym53c8xx_proc_info;
-#endif
-
 #ifdef SYM_LINUX_BOOT_COMMAND_LINE_SUPPORT
 #ifdef MODULE
 if (sym53c8xx)
@@ -2916,7 +2890,6 @@
 
 
 
-#ifdef MODULE
 /*
  *  Linux release module stuff.
  *
@@ -2980,7 +2953,6 @@
 
      return 0;
 }
-#endif /* MODULE */
 
 /*
  * For bigots to keep silent. :)
@@ -2992,10 +2964,27 @@
 /*
  * Driver host template.
  */
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,4,0)
-static
+static Scsi_Host_Template driver_template = {
+	.name			= "sym53c8xx",
+	.detect			= sym53c8xx_detect,
+	.release		= sym53c8xx_release,
+	.info			= sym53c8xx_info, 
+	.queuecommand		= sym53c8xx_queue_command,
+	.slave_configure	= sym53c8xx_slave_configure,
+	.eh_abort_handler	= sym53c8xx_eh_abort_handler,
+	.eh_device_reset_handler = sym53c8xx_eh_device_reset_handler,
+	.eh_bus_reset_handler	= sym53c8xx_eh_bus_reset_handler,
+	.eh_host_reset_handler	= sym53c8xx_eh_host_reset_handler,
+	.this_id		= 7,
+	.use_clustering		= DISABLE_CLUSTERING,
+	.highmem_io		= 1,
+#ifdef SYM_LINUX_PROC_INFO_SUPPORT
+	.proc_info		= sym53c8xx_proc_info,
+#if LINUX_VERSION_CODE < LinuxVersionCode(2,3,27)
+	.proc_dir		= &proc_scsi_sym53c8xx,
+#else
+	.proc_name		= NAME53C8XX,
 #endif
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,4,0) || defined(MODULE)
-Scsi_Host_Template driver_template = SYM53C8XX;
-#include "../scsi_module.c"
 #endif
+};
+#include "../scsi_module.c"
diff -urN linux-2.5.69-bk7/drivers/scsi/t128.c linux-2.5.69-bk8/drivers/scsi/t128.c
--- linux-2.5.69-bk7/drivers/scsi/t128.c	2003-05-04 16:53:41.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/t128.c	2003-05-13 04:44:30.000000000 -0700
@@ -400,7 +400,19 @@
 
 #include "NCR5380.c"
 
-/* Eventually this will go into an include file, but this will be later */
-static Scsi_Host_Template driver_template = TRANTOR_T128;
-
+static Scsi_Host_Template driver_template = {
+	.name           = "Trantor T128/T128F/T228",
+	.detect         = t128_detect,
+	.queuecommand   = t128_queue_command,
+	.eh_abort_handler = t128_abort,
+	.eh_bus_reset_handler    = t128_bus_reset,
+	.eh_host_reset_handler   = t128_host_reset,
+	.eh_device_reset_handler = t128_device_reset,
+	.bios_param     = t128_biosparam,
+	.can_queue      = CAN_QUEUE,
+        .this_id        = 7,
+	.sg_tablesize   = SG_ALL,
+	.cmd_per_lun    = CMD_PER_LUN,
+	.use_clustering = DISABLE_CLUSTERING,
+};
 #include "scsi_module.c"
diff -urN linux-2.5.69-bk7/drivers/scsi/t128.h linux-2.5.69-bk8/drivers/scsi/t128.h
--- linux-2.5.69-bk7/drivers/scsi/t128.h	2003-05-04 16:53:08.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/t128.h	2003-05-13 04:44:30.000000000 -0700
@@ -114,27 +114,6 @@
 #define CAN_QUEUE 32 
 #endif
 
-/* 
- * I hadn't thought of this with the earlier drivers - but to prevent
- * macro definition conflicts, we shouldn't define all of the internal
- * macros when this is being used solely for the host stub.
- */
-
-#define TRANTOR_T128 {					\
-	.name           = "Trantor T128/T128F/T228",	\
-	.detect         = t128_detect,			\
-	.queuecommand   = t128_queue_command,		\
-	.eh_abort_handler = t128_abort,			\
-	.eh_bus_reset_handler    = t128_bus_reset,	\
-	.eh_host_reset_handler   = t128_host_reset,	\
-	.eh_device_reset_handler = t128_device_reset,	\
-	.bios_param     = t128_biosparam,			\
-	.can_queue      = CAN_QUEUE,			\
-        .this_id        = 7,				\
-	.sg_tablesize   = SG_ALL,				\
-	.cmd_per_lun    = CMD_PER_LUN,			\
-	.use_clustering = DISABLE_CLUSTERING}
-
 #ifndef HOSTS_C
 
 #define NCR5380_implementation_fields \
diff -urN linux-2.5.69-bk7/drivers/scsi/tmscsim.c linux-2.5.69-bk8/drivers/scsi/tmscsim.c
--- linux-2.5.69-bk7/drivers/scsi/tmscsim.c	2003-05-04 16:53:57.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/tmscsim.c	2003-05-13 04:44:30.000000000 -0700
@@ -3059,7 +3059,20 @@
 }
 #endif /* def MODULE */
 
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,99)
 static Scsi_Host_Template driver_template = DC390_T;
+   .proc_name      = "tmscsim", 
+   .proc_info      = DC390_proc_info,
+   .name           = DC390_BANNER " V" DC390_VERSION,
+   .detect         = DC390_detect,
+   .release        = DC390_release,
+   .queuecommand   = DC390_queue_command,
+   .abort          = DC390_abort,
+   .reset          = DC390_reset,
+   .bios_param     = DC390_bios_param,
+   .can_queue      = 42,
+   .this_id        = 7,
+   .sg_tablesize   = SG_ALL,
+   .cmd_per_lun    = 16,
+   .use_clustering = DISABLE_CLUSTERING,
+};
 #include "scsi_module.c"
-#endif
diff -urN linux-2.5.69-bk7/drivers/scsi/u14-34f.c linux-2.5.69-bk8/drivers/scsi/u14-34f.c
--- linux-2.5.69-bk7/drivers/scsi/u14-34f.c	2003-05-04 16:53:09.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/u14-34f.c	2003-05-13 04:44:30.000000000 -0700
@@ -1897,7 +1897,8 @@
    unsigned long spin_flags;
 
    /* Check if the interrupt must be processed by this handler */
-   if ((j = (unsigned int)((char *)shap - sha)) >= num_boards) return;
+   if ((j = (unsigned int)((char *)shap - sha)) >= num_boards)
+	   return IRQ_NONE;
 
    spin_lock_irqsave(sh[j]->host_lock, spin_flags);
    ihdlr(irq, j);
@@ -1929,8 +1930,19 @@
    return FALSE;
 }
 
-static Scsi_Host_Template driver_template = ULTRASTOR_14_34F;
-
+static Scsi_Host_Template driver_template = {
+	.name         = "UltraStor 14F/34F rev. " U14_34F_VERSION " ",
+	.detect                  = u14_34f_detect,
+	.release                 = u14_34f_release,
+	.queuecommand            = u14_34f_queuecommand,
+	.eh_abort_handler        = u14_34f_eh_abort,
+	.eh_host_reset_handler   = u14_34f_eh_host_reset,
+	.bios_param              = u14_34f_bios_param,
+	.slave_configure         = u14_34f_slave_configure,
+	.this_id                 = 7,
+	.unchecked_isa_dma       = 1, 
+	.use_clustering          = ENABLE_CLUSTERING,
+};
 #include "scsi_module.c"
 
 #ifndef MODULE
diff -urN linux-2.5.69-bk7/drivers/scsi/u14-34f.h linux-2.5.69-bk8/drivers/scsi/u14-34f.h
--- linux-2.5.69-bk7/drivers/scsi/u14-34f.h	2003-05-04 16:53:41.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/u14-34f.h	2003-05-13 04:44:30.000000000 -0700
@@ -12,19 +12,3 @@
 static int u14_34f_slave_configure(Scsi_Device *);
 
 #define U14_34F_VERSION "8.03.00"
-
-#define ULTRASTOR_14_34F {                                                   \
-                .name         = "UltraStor 14F/34F rev. " U14_34F_VERSION " ", \
-                .detect                  = u14_34f_detect,                     \
-                .release                 = u14_34f_release,                    \
-                .queuecommand            = u14_34f_queuecommand,               \
-                .eh_abort_handler        = u14_34f_eh_abort,                   \
-                .eh_device_reset_handler = NULL,                               \
-                .eh_bus_reset_handler    = NULL,                               \
-                .eh_host_reset_handler   = u14_34f_eh_host_reset,              \
-                .bios_param              = u14_34f_bios_param,                 \
-                .slave_configure         = u14_34f_slave_configure,            \
-                .this_id                 = 7,                                  \
-                .unchecked_isa_dma       = 1,                                  \
-                .use_clustering          = ENABLE_CLUSTERING                   \
-                }
diff -urN linux-2.5.69-bk7/drivers/scsi/ultrastor.c linux-2.5.69-bk8/drivers/scsi/ultrastor.c
--- linux-2.5.69-bk7/drivers/scsi/ultrastor.c	2003-05-04 16:53:31.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/ultrastor.c	2003-05-13 04:44:30.000000000 -0700
@@ -252,7 +252,7 @@
 #if ULTRASTOR_MAX_CMDS == 1
   unsigned char mscp_busy;
 #else
-  unsigned short mscp_free;
+  unsigned long mscp_free;
 #endif
   volatile unsigned char aborted[ULTRASTOR_MAX_CMDS];
   struct mscp mscp[ULTRASTOR_MAX_CMDS];
@@ -1174,7 +1174,18 @@
 
 MODULE_LICENSE("GPL");
 
-/* Eventually this will go into an include file, but this will be later */
-static Scsi_Host_Template driver_template = ULTRASTOR_14F;
-
+static Scsi_Host_Template driver_template = {
+	.name              = "UltraStor 14F/24F/34F",
+	.detect            = ultrastor_detect,
+	.info              = ultrastor_info,
+	.queuecommand      = ultrastor_queuecommand,
+	.eh_abort_handler  = ultrastor_abort,
+	.eh_host_reset_handler  = ultrastor_host_reset,	
+	.bios_param        = ultrastor_biosparam,
+	.can_queue         = ULTRASTOR_MAX_CMDS,
+	.sg_tablesize      = ULTRASTOR_14F_MAX_SG,
+	.cmd_per_lun       = ULTRASTOR_MAX_CMDS_PER_LUN,
+	.unchecked_isa_dma = 1,
+	.use_clustering    = ENABLE_CLUSTERING,
+};
 #include "scsi_module.c"
diff -urN linux-2.5.69-bk7/drivers/scsi/ultrastor.h linux-2.5.69-bk8/drivers/scsi/ultrastor.h
--- linux-2.5.69-bk7/drivers/scsi/ultrastor.h	2003-05-04 16:53:13.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/ultrastor.h	2003-05-13 04:44:30.000000000 -0700
@@ -30,21 +30,6 @@
 #define ULTRASTOR_24F_PORT 0xC80
 
 
-#define ULTRASTOR_14F {   .name              = "UltraStor 14F/24F/34F", 	\
-			  .detect            = ultrastor_detect, 		\
-			  .info              = ultrastor_info, 		\
-			  .queuecommand      = ultrastor_queuecommand,	\
-			  .eh_abort_handler  = ultrastor_abort, 		\
-			  .eh_host_reset_handler  = ultrastor_host_reset,	\
-			  .bios_param        = ultrastor_biosparam, 	\
-			  .can_queue         = ULTRASTOR_MAX_CMDS,	\
-			  .this_id           = 0, 			\
-			  .sg_tablesize      = ULTRASTOR_14F_MAX_SG, 	\
-			  .cmd_per_lun       = ULTRASTOR_MAX_CMDS_PER_LUN,\
-			  .unchecked_isa_dma = 1, 			\
-			  .use_clustering    = ENABLE_CLUSTERING }
-
-
 #ifdef ULTRASTOR_PRIVATE
 
 #define UD_ABORT	0x0001
diff -urN linux-2.5.69-bk7/drivers/scsi/wd7000.c linux-2.5.69-bk8/drivers/scsi/wd7000.c
--- linux-2.5.69-bk7/drivers/scsi/wd7000.c	2003-05-04 16:53:56.000000000 -0700
+++ linux-2.5.69-bk8/drivers/scsi/wd7000.c	2003-05-13 04:44:30.000000000 -0700
@@ -1375,7 +1375,6 @@
 static int wd7000_proc_info(char *buffer, char **start, off_t offset, int length, int hostno, int inout)
 {
 	struct Scsi_Host *host = NULL;
-	Scsi_Device *scd;
 	Adapter *adapter;
 	unsigned long flags;
 	char *pos = buffer;
@@ -1450,27 +1449,6 @@
 	SPRINTF(count ? "\n" : "none\n");
 #endif
 
-	/*
-	 * Display driver information for each device attached to the board.
-	 */
-	SPRINTF("\nAttached devices: %s\n", !list_empty(&host->my_devices) ?
-		       	"" : "none");
-
-	list_for_each_entry (scd, &host->my_devices, siblings) {
-		SPRINTF("  [Channel: %02d, Id: %02d, Lun: %02d]  ", scd->channel, scd->id, scd->lun);
-		SPRINTF("%s ", (scd->type < MAX_SCSI_DEVICE_CODE) ? scsi_device_types[(short) scd->type] : "Unknown device");
-
-		for (i = 0; (i < 8) && (scd->vendor[i] >= 0x20); i++)
-			SPRINTF("%c", scd->vendor[i]);
-		SPRINTF(" ");
-
-		for (i = 0; (i < 16) && (scd->model[i] >= 0x20); i++)
-			SPRINTF("%c", scd->model[i]);
-		SPRINTF("\n");
-	}
-
-	SPRINTF("\n");
-
 	spin_unlock_irqrestore(host->host_lock, flags);
 
 	/*
diff -urN linux-2.5.69-bk7/drivers/video/logo/logo.c linux-2.5.69-bk8/drivers/video/logo/logo.c
--- linux-2.5.69-bk7/drivers/video/logo/logo.c	2003-05-04 16:53:32.000000000 -0700
+++ linux-2.5.69-bk8/drivers/video/logo/logo.c	2003-05-13 04:44:30.000000000 -0700
@@ -79,8 +79,10 @@
 		logo = &logo_parisc_clut224;
 #endif
 #ifdef CONFIG_LOGO_SGI_CLUT224
-		/* SGI Linux logo on MIPS/MIPS64 */
+		/* SGI Linux logo on MIPS/MIPS64 and VISWS */
+#ifndef CONFIG_X86_VISWS
 		if (mips_machgroup == MACH_GROUP_SGI)
+#endif
 			logo = &logo_sgi_clut224;
 #endif
 #ifdef CONFIG_LOGO_SUN_CLUT224
diff -urN linux-2.5.69-bk7/fs/buffer.c linux-2.5.69-bk8/fs/buffer.c
--- linux-2.5.69-bk7/fs/buffer.c	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/fs/buffer.c	2003-05-13 04:44:30.000000000 -0700
@@ -253,6 +253,8 @@
 	sync_filesystems(0);	/* Start syncing the filesystems */
 	sync_filesystems(wait);	/* Waitingly sync the filesystems */
 	sync_inodes(wait);	/* Mappings, inodes and blockdevs, again. */
+	if (!wait)
+		printk("Emergency Sync complete\n");
 }
 
 asmlinkage long sys_sync(void)
diff -urN linux-2.5.69-bk7/fs/cifs/cifs_debug.c linux-2.5.69-bk8/fs/cifs/cifs_debug.c
--- linux-2.5.69-bk7/fs/cifs/cifs_debug.c	2003-05-04 16:53:14.000000000 -0700
+++ linux-2.5.69-bk8/fs/cifs/cifs_debug.c	2003-05-13 04:44:30.000000000 -0700
@@ -56,7 +56,7 @@
 	}
 }
 
-#if CONFIG_PROC_FS
+#ifdef CONFIG_PROC_FS
 int
 cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
 		     int count, int *eof, void *data)
diff -urN linux-2.5.69-bk7/fs/cifs/cifsfs.c linux-2.5.69-bk8/fs/cifs/cifsfs.c
--- linux-2.5.69-bk7/fs/cifs/cifsfs.c	2003-05-04 16:53:31.000000000 -0700
+++ linux-2.5.69-bk8/fs/cifs/cifsfs.c	2003-05-13 04:44:30.000000000 -0700
@@ -465,7 +465,7 @@
 init_cifs(void)
 {
 	int rc = 0;
-#if CONFIG_PROC_FS
+#ifdef CONFIG_PROC_FS
 	cifs_proc_init();
 #endif
 	INIT_LIST_HEAD(&GlobalServerList);	/* BB not implemented yet */
@@ -503,7 +503,7 @@
 		}
 		cifs_destroy_inodecache();
 	}
-#if CONFIG_PROC_FS
+#ifdef CONFIG_PROC_FS
 	cifs_proc_clean();
 #endif
 	return rc;
@@ -513,7 +513,7 @@
 exit_cifs(void)
 {
 	cFYI(0, ("In unregister ie exit_cifs"));
-#if CONFIG_PROC_FS
+#ifdef CONFIG_PROC_FS
 	cifs_proc_clean();
 #endif
 	unregister_filesystem(&cifs_fs_type);
diff -urN linux-2.5.69-bk7/fs/coda/sysctl.c linux-2.5.69-bk8/fs/coda/sysctl.c
--- linux-2.5.69-bk7/fs/coda/sysctl.c	2003-05-04 16:53:09.000000000 -0700
+++ linux-2.5.69-bk8/fs/coda/sysctl.c	2003-05-13 04:44:30.000000000 -0700
@@ -244,7 +244,7 @@
 	}
 #endif
 
-#if CONFIG_PROC_FS
+#ifdef CONFIG_PROC_FS
         remove_proc_entry("cache_inv_stats", proc_fs_coda);
         remove_proc_entry("vfs_stats", proc_fs_coda);
 	remove_proc_entry("coda", proc_root_fs);
diff -urN linux-2.5.69-bk7/fs/devfs/base.c linux-2.5.69-bk8/fs/devfs/base.c
--- linux-2.5.69-bk7/fs/devfs/base.c	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/fs/devfs/base.c	2003-05-13 04:44:30.000000000 -0700
@@ -752,6 +752,7 @@
 #  define DPRINTK(flag, format, args...)
 #endif
 
+typedef struct devfs_entry *devfs_handle_t;
 
 struct directory_type
 {
@@ -1424,98 +1425,6 @@
 			 current->egid, &fs_info);
 } 
 
-
-/**
- *	devfs_register - Register a device entry.
- *	@dir: The handle to the parent devfs directory entry. If this is %NULL the
- *		new name is relative to the root of the devfs.
- *	@name: The name of the entry.
- *	@flags: Must be 0
- *	@major: The major number. Not needed for regular files.
- *	@minor: The minor number. Not needed for regular files.
- *	@mode: The default file mode.
- *	@ops: The &file_operations or &block_device_operations structure.
- *		This must not be externally deallocated.
- *	@info: An arbitrary pointer which will be written to the @private_data
- *		field of the &file structure passed to the device driver. You can set
- *		this to whatever you like, and change it once the file is opened (the next
- *		file opened will not see this change).
- *
- *	On failure %NULL is returned.
- */
-
-devfs_handle_t devfs_register (devfs_handle_t dir, const char *name,
-			       unsigned int flags,
-			       unsigned int major, unsigned int minor,
-			       umode_t mode, void *ops, void *info)
-{
-    int err;
-    dev_t devnum = 0, dev = MKDEV(major, minor);
-    struct devfs_entry *de;
-
-    /* we don't accept any flags anymore.  prototype will change soon. */
-    WARN_ON(flags);
-    WARN_ON(dir);
-    WARN_ON(!S_ISCHR(mode));
-
-    if (name == NULL)
-    {
-	PRINTK ("(): NULL name pointer\n");
-	return NULL;
-    }
-    if (ops == NULL)
-    {
-	PRINTK ("(%s): NULL ops pointer\n", name);
-	return NULL;
-    }
-    if ( S_ISDIR (mode) )
-    {
-	PRINTK ("(%s): creating directories is not allowed\n", name);
-	return NULL;
-    }
-    if ( S_ISLNK (mode) )
-    {
-	PRINTK ("(%s): creating symlinks is not allowed\n", name);
-	return NULL;
-    }
-    if ( ( de = _devfs_prepare_leaf (&dir, name, mode) ) == NULL )
-    {
-	PRINTK ("(%s): could not prepare leaf\n", name);
-	if (devnum) devfs_dealloc_devnum (mode, devnum);
-	return NULL;
-    }
-    if (S_ISCHR (mode)) {
-	de->u.cdev.dev = dev;
-	de->u.cdev.autogen = devnum != 0;
-	de->u.cdev.ops = ops;
-    } else if (S_ISBLK (mode)) {
-	de->u.bdev.dev = dev;
-	de->u.cdev.autogen = devnum != 0;
-    } else {
-	PRINTK ("(%s): illegal mode: %x\n", name, mode);
-	devfs_put (de);
-	devfs_put (dir);
-	return (NULL);
-    }
-    de->info = info;
-    de->inode.uid = 0;
-    de->inode.gid = 0;
-    err = _devfs_append_entry(dir, de, NULL);
-    if (err)
-    {
-	PRINTK ("(%s): could not append to parent, err: %d\n", name, err);
-	devfs_put (dir);
-	if (devnum) devfs_dealloc_devnum (mode, devnum);
-	return NULL;
-    }
-    DPRINTK (DEBUG_REGISTER, "(%s): de: %p dir: %p \"%s\"  pp: %p\n",
-	     name, de, dir, dir->name, dir->parent);
-    devfsd_notify (de, DEVFSD_NOTIFY_REGISTERED);
-    devfs_put (dir);
-    return de;
-}   /*  End Function devfs_register  */
-
-
 int devfs_mk_bdev(dev_t dev, umode_t mode, const char *fmt, ...)
 {
 	struct devfs_entry *dir = NULL, *de;
@@ -1935,7 +1844,6 @@
 __setup("devfs=", devfs_setup);
 
 EXPORT_SYMBOL(devfs_put);
-EXPORT_SYMBOL(devfs_register);
 EXPORT_SYMBOL(devfs_mk_symlink);
 EXPORT_SYMBOL(devfs_mk_dir);
 EXPORT_SYMBOL(devfs_remove);
diff -urN linux-2.5.69-bk7/fs/dquot.c linux-2.5.69-bk8/fs/dquot.c
--- linux-2.5.69-bk7/fs/dquot.c	2003-05-04 16:53:35.000000000 -0700
+++ linux-2.5.69-bk8/fs/dquot.c	2003-05-13 04:44:30.000000000 -0700
@@ -1011,9 +1011,12 @@
 	spin_unlock(&dq_data_lock);
 	flush_warnings(transfer_to, warntype);
 	
-	for (cnt = 0; cnt < MAXQUOTAS; cnt++)
-		if (transfer_from[cnt] != NODQUOT)
+	for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
+		if (ret == QUOTA_OK && transfer_from[cnt] != NODQUOT)
 			dqput(transfer_from[cnt]);
+		if (ret == NO_QUOTA && transfer_to[cnt] != NODQUOT)
+			dqput(transfer_to[cnt]);
+	}
 	up_write(&sb_dqopt(inode->i_sb)->dqptr_sem);
 	return ret;
 }
diff -urN linux-2.5.69-bk7/fs/ext2/xattr.h linux-2.5.69-bk8/fs/ext2/xattr.h
--- linux-2.5.69-bk7/fs/ext2/xattr.h	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/fs/ext2/xattr.h	2003-05-13 04:44:30.000000000 -0700
@@ -22,6 +22,7 @@
 #define EXT2_XATTR_INDEX_POSIX_ACL_ACCESS	2
 #define EXT2_XATTR_INDEX_POSIX_ACL_DEFAULT	3
 #define EXT2_XATTR_INDEX_TRUSTED		4
+#define	EXT2_XATTR_INDEX_LUSTRE			5
 #define EXT2_XATTR_INDEX_SECURITY	        6
 
 struct ext2_xattr_header {
diff -urN linux-2.5.69-bk7/fs/ext3/dir.c linux-2.5.69-bk8/fs/ext3/dir.c
--- linux-2.5.69-bk7/fs/ext3/dir.c	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/fs/ext3/dir.c	2003-05-13 04:44:30.000000000 -0700
@@ -103,7 +103,11 @@
 
 	sb = inode->i_sb;
 
-	if (is_dx(inode)) {
+#ifdef CONFIG_EXT3_INDEX
+	if (EXT3_HAS_COMPAT_FEATURE(inode->i_sb,
+				    EXT3_FEATURE_COMPAT_DIR_INDEX) &&
+	    ((EXT3_I(inode)->i_flags & EXT3_INDEX_FL) ||
+	     ((inode->i_size >> sb->s_blocksize_bits) == 1))) {
 		err = ext3_dx_readdir(filp, dirent, filldir);
 		if (err != ERR_BAD_DX_DIR) {
 			ret = err;
@@ -115,6 +119,7 @@
 		 */
 		EXT3_I(filp->f_dentry->d_inode)->i_flags &= ~EXT3_INDEX_FL;
 	}
+#endif
 	stored = 0;
 	bh = NULL;
 	offset = filp->f_pos & (sb->s_blocksize - 1);
@@ -434,6 +439,9 @@
 		filp->private_data = info;
 	}
 
+	if (filp->f_pos == EXT3_HTREE_EOF)
+		return 0;	/* EOF */
+
 	/* Some one has messed with f_pos; reset the world */
 	if (info->last_pos != filp->f_pos) {
 		free_rb_tree_fname(&info->root);
@@ -470,8 +478,10 @@
 						   &info->next_hash);
 			if (ret < 0)
 				return ret;
-			if (ret == 0)
+			if (ret == 0) {
+				filp->f_pos = EXT3_HTREE_EOF;
 				break;
+			}
 			info->curr_node = rb_first(&info->root);
 		}
 
@@ -483,6 +493,10 @@
 
 		info->curr_node = rb_next(info->curr_node);
 		if (!info->curr_node) {
+			if (info->next_hash == ~0) {
+				filp->f_pos = EXT3_HTREE_EOF;
+				break;
+			}
 			info->curr_hash = info->next_hash;
 			info->curr_minor_hash = 0;
 		}
@@ -495,7 +509,7 @@
 
 static int ext3_release_dir (struct inode * inode, struct file * filp)
 {
-       if (is_dx(inode) && filp->private_data)
+       if (filp->private_data)
 		ext3_htree_free_dir_info(filp->private_data);
 
 	return 0;
diff -urN linux-2.5.69-bk7/fs/ext3/hash.c linux-2.5.69-bk8/fs/ext3/hash.c
--- linux-2.5.69-bk7/fs/ext3/hash.c	2003-05-04 16:53:29.000000000 -0700
+++ linux-2.5.69-bk8/fs/ext3/hash.c	2003-05-13 04:44:30.000000000 -0700
@@ -209,7 +209,10 @@
 		hinfo->hash = 0;
 		return -1;
 	}
-	hinfo->hash = hash & ~1;
+	hash = hash & ~1;
+	if (hash == (EXT3_HTREE_EOF << 1))
+		hash = (EXT3_HTREE_EOF-1) << 1;
+	hinfo->hash = hash;
 	hinfo->minor_hash = minor_hash;
 	return 0;
 }
diff -urN linux-2.5.69-bk7/fs/ext3/namei.c linux-2.5.69-bk8/fs/ext3/namei.c
--- linux-2.5.69-bk7/fs/ext3/namei.c	2003-05-04 16:53:32.000000000 -0700
+++ linux-2.5.69-bk8/fs/ext3/namei.c	2003-05-13 04:44:30.000000000 -0700
@@ -170,7 +170,7 @@
 static void dx_insert_block (struct dx_frame *frame, u32 hash, u32 block);
 static int ext3_htree_next_block(struct inode *dir, __u32 hash,
 				 struct dx_frame *frame,
-				 struct dx_frame *frames, int *err,
+				 struct dx_frame *frames, 
 				 __u32 *start_hash);
 static struct buffer_head * ext3_dx_find_entry(struct dentry *dentry,
 		       struct ext3_dir_entry_2 **res_dir, int *err);
@@ -239,6 +239,17 @@
  * Debug
  */
 #ifdef DX_DEBUG
+static void dx_show_index (char * label, struct dx_entry *entries)
+{
+        int i, n = dx_get_count (entries);
+        printk("%s index ", label);
+        for (i = 0; i < n; i++)
+        {
+                printk("%x->%u ", i? dx_get_hash(entries + i): 0, dx_get_block(entries + i));
+        }
+        printk("\n");
+}
+
 struct stats
 { 
 	unsigned names;
@@ -447,22 +458,21 @@
  *
  * This function returns 1 if the caller should continue to search,
  * or 0 if it should not.  If there is an error reading one of the
- * index blocks, it will return -1.
+ * index blocks, it will a negative error code.
  *
  * If start_hash is non-null, it will be filled in with the starting
  * hash of the next page.
  */
 static int ext3_htree_next_block(struct inode *dir, __u32 hash,
 				 struct dx_frame *frame,
-				 struct dx_frame *frames, int *err,
+				 struct dx_frame *frames, 
 				 __u32 *start_hash)
 {
 	struct dx_frame *p;
 	struct buffer_head *bh;
-	int num_frames = 0;
+	int err, num_frames = 0;
 	__u32 bhash;
 
-	*err = ENOENT;
 	p = frame;
 	/*
 	 * Find the next leaf page by incrementing the frame pointer.
@@ -500,8 +510,8 @@
 	 */
 	while (num_frames--) {
 		if (!(bh = ext3_bread(NULL, dir, dx_get_block(p->at),
-				      0, err)))
-			return -1; /* Failure */
+				      0, &err)))
+			return err; /* Failure */
 		p++;
 		brelse (p->bh);
 		p->bh = bh;
@@ -521,6 +531,46 @@
 
 /*
  * This function fills a red-black tree with information from a
+ * directory block.  It returns the number directory entries loaded
+ * into the tree.  If there is an error it is returned in err.
+ */
+static int htree_dirblock_to_tree(struct file *dir_file,
+				  struct inode *dir, int block,
+				  struct dx_hash_info *hinfo,
+				  __u32 start_hash, __u32 start_minor_hash)
+{
+	struct buffer_head *bh;
+	struct ext3_dir_entry_2 *de, *top;
+	int err, count = 0;
+
+	dxtrace(printk("In htree dirblock_to_tree: block %d\n", block));
+	if (!(bh = ext3_bread (NULL, dir, block, 0, &err)))
+		return err;
+	
+	de = (struct ext3_dir_entry_2 *) bh->b_data;
+	top = (struct ext3_dir_entry_2 *) ((char *) de +
+					   dir->i_sb->s_blocksize -
+					   EXT3_DIR_REC_LEN(0));
+	for (; de < top; de = ext3_next_entry(de)) {
+		ext3fs_dirhash(de->name, de->name_len, hinfo);
+		if ((hinfo->hash < start_hash) ||
+		    ((hinfo->hash == start_hash) &&
+		     (hinfo->minor_hash < start_minor_hash)))
+			continue;
+		if ((err = ext3_htree_store_dirent(dir_file,
+				   hinfo->hash, hinfo->minor_hash, de)) != 0) {
+			brelse(bh);
+			return err;
+		}
+		count++;
+	}
+	brelse(bh);
+	return count;
+}
+
+
+/*
+ * This function fills a red-black tree with information from a
  * directory.  We start scanning the directory in hash order, starting
  * at start_hash and start_minor_hash.
  *
@@ -531,8 +581,7 @@
 			 __u32 start_minor_hash, __u32 *next_hash)
 {
 	struct dx_hash_info hinfo;
-	struct buffer_head *bh;
-	struct ext3_dir_entry_2 *de, *top;
+	struct ext3_dir_entry_2 *de;
 	struct dx_frame frames[2], *frame;
 	struct inode *dir;
 	int block, err;
@@ -543,6 +592,14 @@
 	dxtrace(printk("In htree_fill_tree, start hash: %x:%x\n", start_hash,
 		       start_minor_hash));
 	dir = dir_file->f_dentry->d_inode;
+	if (!(EXT3_I(dir)->i_flags & EXT3_INDEX_FL)) {	
+		hinfo.hash_version = EXT3_SB(dir->i_sb)->s_def_hash_version;
+		hinfo.seed = EXT3_SB(dir->i_sb)->s_hash_seed;
+		count = htree_dirblock_to_tree(dir_file, dir, 0, &hinfo,
+					       start_hash, start_minor_hash);
+		*next_hash = ~0;
+		return count;
+	}
 	hinfo.hash = start_hash;
 	hinfo.minor_hash = 0;
 	frame = dx_probe(0, dir_file->f_dentry->d_inode, &hinfo, frames, &err);
@@ -562,34 +619,21 @@
 
 	while (1) {
 		block = dx_get_block(frame->at);
-		dxtrace(printk("Reading block %d\n", block));
-		if (!(bh = ext3_bread (NULL, dir, block, 0, &err)))
+		ret = htree_dirblock_to_tree(dir_file, dir, block, &hinfo,
+					     start_hash, start_minor_hash);
+		if (ret < 0) {
+			err = ret;
 			goto errout;
-	
-		de = (struct ext3_dir_entry_2 *) bh->b_data;
-		top = (struct ext3_dir_entry_2 *) ((char *) de + dir->i_sb->s_blocksize -
-				       EXT3_DIR_REC_LEN(0));
-		for (; de < top; de = ext3_next_entry(de)) {
-			ext3fs_dirhash(de->name, de->name_len, &hinfo);
-			if ((hinfo.hash < start_hash) ||
-			    ((hinfo.hash == start_hash) &&
-			     (hinfo.minor_hash < start_minor_hash)))
-				continue;
-			if ((err = ext3_htree_store_dirent(dir_file,
-				   hinfo.hash, hinfo.minor_hash, de)) != 0) {
-				brelse(bh);
-				goto errout;
-			}
-			count++;
 		}
-		brelse (bh);
-		hashval = ~1;
+		count += ret;
+		hashval = ~0;
 		ret = ext3_htree_next_block(dir, HASH_NB_ALWAYS, 
-					    frame, frames, &err, &hashval);
-		if (next_hash)
-			*next_hash = hashval;
-		if (ret == -1)
+					    frame, frames, &hashval);
+		*next_hash = hashval;
+		if (ret < 0) {
+			err = ret;
 			goto errout;
+		}
 		/*
 		 * Stop if:  (a) there are no more entries, or
 		 * (b) we have inserted at least one entry and the
@@ -600,7 +644,8 @@
 			break;
 	}
 	dx_release(frames);
-	dxtrace(printk("Fill tree: returned %d entries\n", count));
+	dxtrace(printk("Fill tree: returned %d entries, next hash: %x\n", 
+		       count, *next_hash));
 	return count;
 errout:
 	dx_release(frames);
@@ -909,11 +954,12 @@
 		brelse (bh);
 		/* Check to see if we should continue to search */
 		retval = ext3_htree_next_block(dir, hash, frame,
-					       frames, err, 0);
-		if (retval == -1) {
+					       frames, 0);
+		if (retval < 0) {
 			ext3_warning(sb, __FUNCTION__,
 			     "error reading index page in directory #%lu",
 			     dir->i_ino);
+			*err = retval;
 			goto errout;
 		}
 	} while (retval == 1);
diff -urN linux-2.5.69-bk7/fs/ext3/super.c linux-2.5.69-bk8/fs/ext3/super.c
--- linux-2.5.69-bk7/fs/ext3/super.c	2003-05-04 16:53:41.000000000 -0700
+++ linux-2.5.69-bk8/fs/ext3/super.c	2003-05-13 04:44:30.000000000 -0700
@@ -1988,8 +1988,10 @@
 
 #ifdef CONFIG_QUOTA
 
-#define EXT3_OLD_QFMT_BLOCKS 2
-#define EXT3_V0_QFMT_BLOCKS 6
+/* Blocks: (2 data blocks) * (3 indirect + 1 descriptor + 1 bitmap) + superblock */
+#define EXT3_OLD_QFMT_BLOCKS 11
+/* Blocks: quota info + (4 pointer blocks + 1 entry block) * (3 indirect + 1 descriptor + 1 bitmap) + superblock */
+#define EXT3_V0_QFMT_BLOCKS 27
 
 static int (*old_sync_dquot)(struct dquot *dquot);
 
diff -urN linux-2.5.69-bk7/fs/ext3/xattr.h linux-2.5.69-bk8/fs/ext3/xattr.h
--- linux-2.5.69-bk7/fs/ext3/xattr.h	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/fs/ext3/xattr.h	2003-05-13 04:44:30.000000000 -0700
@@ -21,6 +21,7 @@
 #define EXT3_XATTR_INDEX_POSIX_ACL_ACCESS	2
 #define EXT3_XATTR_INDEX_POSIX_ACL_DEFAULT	3
 #define EXT3_XATTR_INDEX_TRUSTED		4
+#define	EXT3_XATTR_INDEX_LUSTRE			5
 #define EXT3_XATTR_INDEX_SECURITY	        6
 
 struct ext3_xattr_header {
diff -urN linux-2.5.69-bk7/fs/fat/inode.c linux-2.5.69-bk8/fs/fat/inode.c
--- linux-2.5.69-bk7/fs/fat/inode.c	2003-05-04 16:53:14.000000000 -0700
+++ linux-2.5.69-bk8/fs/fat/inode.c	2003-05-13 04:44:30.000000000 -0700
@@ -897,6 +897,7 @@
 			       sbi->fsinfo_sector);
 		} else {
 			sbi->free_clusters = CF_LE_L(fsinfo->free_clusters);
+			sbi->prev_free = CF_LE_L(fsinfo->next_cluster);
 		}
 
 		brelse(fsinfo_bh);
diff -urN linux-2.5.69-bk7/fs/fat/misc.c linux-2.5.69-bk8/fs/fat/misc.c
--- linux-2.5.69-bk7/fs/fat/misc.c	2003-05-04 16:53:40.000000000 -0700
+++ linux-2.5.69-bk8/fs/fat/misc.c	2003-05-13 04:44:30.000000000 -0700
@@ -74,6 +74,7 @@
 		       MSDOS_SB(sb)->fsinfo_sector);
 	} else {
 		fsinfo->free_clusters = CF_LE_L(MSDOS_SB(sb)->free_clusters);
+		fsinfo->next_cluster = CF_LE_L(MSDOS_SB(sb)->prev_free);
 		mark_buffer_dirty(bh);
 	}
 	brelse(bh);
@@ -130,19 +131,23 @@
 		unlock_fat(sb);
 		return -ENOSPC;
 	}
-	limit = MSDOS_SB(sb)->clusters;
-	for (count = 0; count < limit; count++) {
-		nr = ((count + MSDOS_SB(sb)->prev_free) % limit) + 2;
+
+	limit = MSDOS_SB(sb)->clusters + 2;
+	nr = MSDOS_SB(sb)->prev_free + 1;
+	for (count = 0; count < MSDOS_SB(sb)->clusters; count++, nr++) {
+		nr = nr % limit;
+		if (nr < 2)
+			nr = 2;
 		if (fat_access(sb, nr, -1) == FAT_ENT_FREE)
 			break;
 	}
-	if (count >= limit) {
+	if (count >= MSDOS_SB(sb)->clusters) {
 		MSDOS_SB(sb)->free_clusters = 0;
 		unlock_fat(sb);
 		return -ENOSPC;
 	}
-	
-	MSDOS_SB(sb)->prev_free = (count + MSDOS_SB(sb)->prev_free + 1) % limit;
+	MSDOS_SB(sb)->prev_free = nr;
+
 	fat_access(sb, nr, FAT_ENT_EOF);
 	if (MSDOS_SB(sb)->free_clusters != -1)
 		MSDOS_SB(sb)->free_clusters--;
diff -urN linux-2.5.69-bk7/fs/intermezzo/methods.c linux-2.5.69-bk8/fs/intermezzo/methods.c
--- linux-2.5.69-bk7/fs/intermezzo/methods.c	2003-05-04 16:53:41.000000000 -0700
+++ linux-2.5.69-bk8/fs/intermezzo/methods.c	2003-05-13 04:44:30.000000000 -0700
@@ -145,7 +145,7 @@
 {
         if ( strlen(cache_type) == strlen("ext2") &&
              memcmp(cache_type, "ext2", strlen("ext2")) == 0 ) {
-#if CONFIG_EXT2_FS
+#ifdef CONFIG_EXT2_FS
                 ops->o_trops = &presto_ext2_journal_ops;
 #else
                 ops->o_trops = NULL;
diff -urN linux-2.5.69-bk7/fs/intermezzo/sysctl.c linux-2.5.69-bk8/fs/intermezzo/sysctl.c
--- linux-2.5.69-bk7/fs/intermezzo/sysctl.c	2003-05-04 16:53:03.000000000 -0700
+++ linux-2.5.69-bk8/fs/intermezzo/sysctl.c	2003-05-13 04:44:30.000000000 -0700
@@ -358,7 +358,7 @@
 	 */
 	PRESTO_FREE(presto_table[PRESTO_PRIMARY_CTLCNT].child, sizeof(ctl_table) * total_entries);
 
-#if CONFIG_PROC_FS
+#ifdef CONFIG_PROC_FS
 	remove_proc_entry("mounts", proc_fs_intermezzo);
 	remove_proc_entry("intermezzo", proc_root_fs);
 #endif
diff -urN linux-2.5.69-bk7/fs/jffs/inode-v23.c linux-2.5.69-bk8/fs/jffs/inode-v23.c
--- linux-2.5.69-bk7/fs/jffs/inode-v23.c	2003-05-04 16:53:32.000000000 -0700
+++ linux-2.5.69-bk8/fs/jffs/inode-v23.c	2003-05-13 04:44:30.000000000 -0700
@@ -55,7 +55,7 @@
 
 #include "jffs_fm.h"
 #include "intrep.h"
-#if CONFIG_JFFS_PROC_FS
+#ifdef CONFIG_JFFS_PROC_FS
 #include "jffs_proc.h"
 #endif
 
diff -urN linux-2.5.69-bk7/fs/ncpfs/ncplib_kernel.c linux-2.5.69-bk8/fs/ncpfs/ncplib_kernel.c
--- linux-2.5.69-bk7/fs/ncpfs/ncplib_kernel.c	2003-05-04 16:53:14.000000000 -0700
+++ linux-2.5.69-bk8/fs/ncpfs/ncplib_kernel.c	2003-05-13 04:44:30.000000000 -0700
@@ -695,7 +695,7 @@
 	__u32 dirent;
 
 	if (!inode) {
-#if CONFIG_NCPFS_DEBUGDENTRY
+#ifdef CONFIG_NCPFS_DEBUGDENTRY
 		PRINTK("ncpfs: ncpdel2: dentry->d_inode == NULL\n");
 #endif
 		return 0xFF;	/* Any error */
diff -urN linux-2.5.69-bk7/fs/nfsd/nfssvc.c linux-2.5.69-bk8/fs/nfsd/nfssvc.c
--- linux-2.5.69-bk7/fs/nfsd/nfssvc.c	2003-05-04 16:53:31.000000000 -0700
+++ linux-2.5.69-bk8/fs/nfsd/nfssvc.c	2003-05-13 04:44:30.000000000 -0700
@@ -103,7 +103,7 @@
 		if (error < 0)
 			goto failure;
 
-#if CONFIG_NFSD_TCP
+#ifdef CONFIG_NFSD_TCP
 		error = svc_makesock(nfsd_serv, IPPROTO_TCP, port);
 		if (error < 0)
 			goto failure;
diff -urN linux-2.5.69-bk7/fs/open.c linux-2.5.69-bk8/fs/open.c
--- linux-2.5.69-bk7/fs/open.c	2003-05-04 16:53:00.000000000 -0700
+++ linux-2.5.69-bk8/fs/open.c	2003-05-13 04:44:30.000000000 -0700
@@ -280,7 +280,7 @@
  * must be owner or have write permission.
  * Else, update from *times, must be owner or super user.
  */
-long do_utimes(char __user * filename, struct timeval __user * times)
+long do_utimes(char __user * filename, struct timeval * times)
 {
 	int error;
 	struct nameidata nd;
diff -urN linux-2.5.69-bk7/fs/partitions/check.c linux-2.5.69-bk8/fs/partitions/check.c
--- linux-2.5.69-bk7/fs/partitions/check.c	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/fs/partitions/check.c	2003-05-13 04:44:30.000000000 -0700
@@ -38,7 +38,7 @@
 #include "ultrix.h"
 #include "efi.h"
 
-#if CONFIG_BLK_DEV_MD
+#ifdef CONFIG_BLK_DEV_MD
 extern void md_autodetect_dev(dev_t dev);
 #endif
 
@@ -340,7 +340,7 @@
 			if (!size)
 				continue;
 			add_partition(disk, j, from, size);
-#if CONFIG_BLK_DEV_MD
+#ifdef CONFIG_BLK_DEV_MD
 			if (!state->parts[j].flags)
 				continue;
 			md_autodetect_dev(bdev->bd_dev+j);
@@ -374,7 +374,7 @@
 		if (!size)
 			continue;
 		add_partition(disk, p, from, size);
-#if CONFIG_BLK_DEV_MD
+#ifdef CONFIG_BLK_DEV_MD
 		if (state->parts[p].flags)
 			md_autodetect_dev(bdev->bd_dev+p);
 #endif
diff -urN linux-2.5.69-bk7/fs/super.c linux-2.5.69-bk8/fs/super.c
--- linux-2.5.69-bk7/fs/super.c	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/fs/super.c	2003-05-13 04:44:30.000000000 -0700
@@ -497,6 +497,7 @@
 		spin_lock(&sb_lock);
 	}
 	spin_unlock(&sb_lock);
+	printk("Emergency Remount complete\n");
 }
 
 void emergency_remount(void)
diff -urN linux-2.5.69-bk7/include/asm-alpha/elf.h linux-2.5.69-bk8/include/asm-alpha/elf.h
--- linux-2.5.69-bk7/include/asm-alpha/elf.h	2003-05-04 16:53:28.000000000 -0700
+++ linux-2.5.69-bk8/include/asm-alpha/elf.h	2003-05-13 04:44:30.000000000 -0700
@@ -2,6 +2,49 @@
 #define __ASM_ALPHA_ELF_H
 
 /*
+ * Alpha ELF relocation types
+ */
+#define R_ALPHA_NONE            0       /* No reloc */
+#define R_ALPHA_REFLONG         1       /* Direct 32 bit */
+#define R_ALPHA_REFQUAD         2       /* Direct 64 bit */
+#define R_ALPHA_GPREL32         3       /* GP relative 32 bit */
+#define R_ALPHA_LITERAL         4       /* GP relative 16 bit w/optimization */
+#define R_ALPHA_LITUSE          5       /* Optimization hint for LITERAL */
+#define R_ALPHA_GPDISP          6       /* Add displacement to GP */
+#define R_ALPHA_BRADDR          7       /* PC+4 relative 23 bit shifted */
+#define R_ALPHA_HINT            8       /* PC+4 relative 16 bit shifted */
+#define R_ALPHA_SREL16          9       /* PC relative 16 bit */
+#define R_ALPHA_SREL32          10      /* PC relative 32 bit */
+#define R_ALPHA_SREL64          11      /* PC relative 64 bit */
+#define R_ALPHA_GPRELHIGH       17      /* GP relative 32 bit, high 16 bits */
+#define R_ALPHA_GPRELLOW        18      /* GP relative 32 bit, low 16 bits */
+#define R_ALPHA_GPREL16         19      /* GP relative 16 bit */
+#define R_ALPHA_COPY            24      /* Copy symbol at runtime */
+#define R_ALPHA_GLOB_DAT        25      /* Create GOT entry */
+#define R_ALPHA_JMP_SLOT        26      /* Create PLT entry */
+#define R_ALPHA_RELATIVE        27      /* Adjust by program base */
+#define R_ALPHA_BRSGP		28
+#define R_ALPHA_TLSGD           29
+#define R_ALPHA_TLS_LDM         30
+#define R_ALPHA_DTPMOD64        31
+#define R_ALPHA_GOTDTPREL       32
+#define R_ALPHA_DTPREL64        33
+#define R_ALPHA_DTPRELHI        34
+#define R_ALPHA_DTPRELLO        35
+#define R_ALPHA_DTPREL16        36
+#define R_ALPHA_GOTTPREL        37
+#define R_ALPHA_TPREL64         38
+#define R_ALPHA_TPRELHI         39
+#define R_ALPHA_TPRELLO         40
+#define R_ALPHA_TPREL16         41
+
+#define SHF_ALPHA_GPREL		0x10000000
+
+/* Legal values for e_flags field of Elf64_Ehdr.  */
+
+#define EF_ALPHA_32BIT		1	/* All addresses are below 2GB */
+
+/*
  * ELF register definitions..
  */
 
diff -urN linux-2.5.69-bk7/include/asm-alpha/hardirq.h linux-2.5.69-bk8/include/asm-alpha/hardirq.h
--- linux-2.5.69-bk7/include/asm-alpha/hardirq.h	2003-05-04 16:53:33.000000000 -0700
+++ linux-2.5.69-bk8/include/asm-alpha/hardirq.h	2003-05-13 04:44:30.000000000 -0700
@@ -79,7 +79,7 @@
 #define irq_enter()		(preempt_count() += HARDIRQ_OFFSET)
 
 
-#if CONFIG_PREEMPT
+#ifdef CONFIG_PREEMPT
 #define in_atomic()	(preempt_count() != kernel_locked())
 # define IRQ_EXIT_OFFSET (HARDIRQ_OFFSET-1)
 #else
diff -urN linux-2.5.69-bk7/include/asm-alpha/kmap_types.h linux-2.5.69-bk8/include/asm-alpha/kmap_types.h
--- linux-2.5.69-bk7/include/asm-alpha/kmap_types.h	2003-05-04 16:53:57.000000000 -0700
+++ linux-2.5.69-bk8/include/asm-alpha/kmap_types.h	2003-05-13 04:44:30.000000000 -0700
@@ -5,7 +5,7 @@
 
 #include <linux/config.h>
 
-#if CONFIG_DEBUG_HIGHMEM
+#ifdef CONFIG_DEBUG_HIGHMEM
 # define D(n) __KM_FENCE_##n ,
 #else
 # define D(n)
diff -urN linux-2.5.69-bk7/include/asm-alpha/spinlock.h linux-2.5.69-bk8/include/asm-alpha/spinlock.h
--- linux-2.5.69-bk7/include/asm-alpha/spinlock.h	2003-05-04 16:53:32.000000000 -0700
+++ linux-2.5.69-bk8/include/asm-alpha/spinlock.h	2003-05-13 04:44:30.000000000 -0700
@@ -16,7 +16,7 @@
 
 typedef struct {
 	volatile unsigned int lock /*__attribute__((aligned(32))) */;
-#if CONFIG_DEBUG_SPINLOCK
+#ifdef CONFIG_DEBUG_SPINLOCK
 	int on_cpu;
 	int line_no;
 	void *previous;
@@ -25,7 +25,7 @@
 #endif
 } spinlock_t;
 
-#if CONFIG_DEBUG_SPINLOCK
+#ifdef CONFIG_DEBUG_SPINLOCK
 #define SPIN_LOCK_UNLOCKED (spinlock_t) {0, -1, 0, 0, 0, 0}
 #define spin_lock_init(x)						\
 	((x)->lock = 0, (x)->on_cpu = -1, (x)->previous = 0, (x)->task = 0)
@@ -37,7 +37,7 @@
 #define spin_is_locked(x)	((x)->lock != 0)
 #define spin_unlock_wait(x)	({ do { barrier(); } while ((x)->lock); })
 
-#if CONFIG_DEBUG_SPINLOCK
+#ifdef CONFIG_DEBUG_SPINLOCK
 extern void _raw_spin_unlock(spinlock_t * lock);
 extern void debug_spin_lock(spinlock_t * lock, const char *, int);
 extern int debug_spin_trylock(spinlock_t * lock, const char *, int);
@@ -102,7 +102,7 @@
 #define rwlock_init(x)	do { *(x) = RW_LOCK_UNLOCKED; } while(0)
 #define rwlock_is_locked(x)	(*(volatile int *)(x) != 0)
 
-#if CONFIG_DEBUG_RWLOCK
+#ifdef CONFIG_DEBUG_RWLOCK
 extern void _raw_write_lock(rwlock_t * lock);
 extern void _raw_read_lock(rwlock_t * lock);
 #else
diff -urN linux-2.5.69-bk7/include/asm-arm/elf.h linux-2.5.69-bk8/include/asm-arm/elf.h
--- linux-2.5.69-bk7/include/asm-arm/elf.h	2003-05-04 16:53:41.000000000 -0700
+++ linux-2.5.69-bk8/include/asm-arm/elf.h	2003-05-13 04:44:30.000000000 -0700
@@ -16,6 +16,10 @@
 #define EM_ARM	40
 #define EF_ARM_APCS26 0x08
 
+#define R_ARM_NONE	0
+#define R_ARM_PC24	1
+#define R_ARM_ABS32	2
+
 #define ELF_NGREG (sizeof (struct pt_regs) / sizeof(elf_greg_t))
 typedef elf_greg_t elf_gregset_t[ELF_NGREG];
 
diff -urN linux-2.5.69-bk7/include/asm-generic/rmap.h linux-2.5.69-bk8/include/asm-generic/rmap.h
--- linux-2.5.69-bk7/include/asm-generic/rmap.h	2003-05-04 16:53:32.000000000 -0700
+++ linux-2.5.69-bk8/include/asm-generic/rmap.h	2003-05-13 04:44:30.000000000 -0700
@@ -61,7 +61,7 @@
 	return page->index + low_bits;
 }
 
-#if CONFIG_HIGHPTE
+#ifdef CONFIG_HIGHPTE
 static inline pte_addr_t ptep_to_paddr(pte_t *ptep)
 {
 	pte_addr_t paddr;
diff -urN linux-2.5.69-bk7/include/asm-h8300/hardirq.h linux-2.5.69-bk8/include/asm-h8300/hardirq.h
--- linux-2.5.69-bk7/include/asm-h8300/hardirq.h	2003-05-04 16:53:31.000000000 -0700
+++ linux-2.5.69-bk8/include/asm-h8300/hardirq.h	2003-05-13 04:44:30.000000000 -0700
@@ -74,13 +74,13 @@
 
 #define irq_enter()		(preempt_count() += HARDIRQ_OFFSET)
 
-#if CONFIG_PREEMPT
+#ifdef CONFIG_PREEMPT
 # define IRQ_EXIT_OFFSET (HARDIRQ_OFFSET-1)
 #else
 # define IRQ_EXIT_OFFSET HARDIRQ_OFFSET
 #endif
 
-#if CONFIG_PREEMPT
+#ifdef CONFIG_PREEMPT
 # define in_atomic()	(preempt_count() != kernel_locked())
 # define IRQ_EXIT_OFFSET (HARDIRQ_OFFSET-1)
 #else
diff -urN linux-2.5.69-bk7/include/asm-i386/elf.h linux-2.5.69-bk8/include/asm-i386/elf.h
--- linux-2.5.69-bk7/include/asm-i386/elf.h	2003-05-04 16:53:35.000000000 -0700
+++ linux-2.5.69-bk8/include/asm-i386/elf.h	2003-05-13 04:44:30.000000000 -0700
@@ -12,6 +12,19 @@
 
 #include <linux/utsname.h>
 
+#define R_386_NONE	0
+#define R_386_32	1
+#define R_386_PC32	2
+#define R_386_GOT32	3
+#define R_386_PLT32	4
+#define R_386_COPY	5
+#define R_386_GLOB_DAT	6
+#define R_386_JMP_SLOT	7
+#define R_386_RELATIVE	8
+#define R_386_GOTOFF	9
+#define R_386_GOTPC	10
+#define R_386_NUM	11
+
 typedef unsigned long elf_greg_t;
 
 #define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t))
diff -urN linux-2.5.69-bk7/include/asm-i386/mach-bigsmp/mach_apic.h linux-2.5.69-bk8/include/asm-i386/mach-bigsmp/mach_apic.h
--- linux-2.5.69-bk7/include/asm-i386/mach-bigsmp/mach_apic.h	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/include/asm-i386/mach-bigsmp/mach_apic.h	2003-05-13 04:44:30.000000000 -0700
@@ -34,10 +34,12 @@
 	return 0;
 } 
 static inline unsigned long check_apicid_present(int bit) 
-{ 
+{
 	return (phys_cpu_present_map & (1 << bit));
 }
 
+#define apicid_cluster(apicid) (apicid & 0xF0)
+
 static inline unsigned long calculate_ldr(unsigned long old)
 {
 	unsigned long id;
@@ -134,4 +136,37 @@
 
 #define		GET_APIC_ID(x)	get_apic_id(x)
 
+static inline unsigned int cpu_mask_to_apicid (unsigned long cpumask)
+{
+	int num_bits_set;
+	int cpus_found = 0;
+	int cpu;
+	int apicid;	
+
+	num_bits_set = hweight32(cpumask); 
+	/* Return id to all */
+	if (num_bits_set == 32)
+		return (int) 0xFF;
+	/* 
+	 * The cpus in the mask must all be on the apic cluster.  If are not 
+	 * on the same apicid cluster return default value of TARGET_CPUS. 
+	 */
+	cpu = ffs(cpumask)-1;
+	apicid = cpu_to_logical_apicid(cpu);
+	while (cpus_found < num_bits_set) {
+		if (cpumask & (1 << cpu)) {
+			int new_apicid = cpu_to_logical_apicid(cpu);
+			if (apicid_cluster(apicid) != 
+					apicid_cluster(new_apicid)){
+				printk ("%s: Not a valid mask!\n",__FUNCTION__);
+				return TARGET_CPUS;
+			}
+			apicid = apicid | new_apicid;
+			cpus_found++;
+		}
+		cpu++;
+	}
+	return apicid;
+}
+
 #endif /* __ASM_MACH_APIC_H */
diff -urN linux-2.5.69-bk7/include/asm-i386/mach-default/mach_apic.h linux-2.5.69-bk8/include/asm-i386/mach-default/mach_apic.h
--- linux-2.5.69-bk7/include/asm-i386/mach-default/mach_apic.h	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/include/asm-i386/mach-default/mach_apic.h	2003-05-13 04:44:30.000000000 -0700
@@ -120,4 +120,9 @@
 						&phys_cpu_present_map));
 }
 
+static inline unsigned int cpu_mask_to_apicid (unsigned long cpumask)
+{
+	return cpumask;
+}
+
 #endif /* __ASM_MACH_APIC_H */
diff -urN linux-2.5.69-bk7/include/asm-i386/mach-numaq/mach_apic.h linux-2.5.69-bk8/include/asm-i386/mach-numaq/mach_apic.h
--- linux-2.5.69-bk7/include/asm-i386/mach-numaq/mach_apic.h	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/include/asm-i386/mach-numaq/mach_apic.h	2003-05-13 04:44:30.000000000 -0700
@@ -17,6 +17,7 @@
 #define APIC_BROADCAST_ID      0x0F
 #define check_apicid_used(bitmap, apicid) ((bitmap) & (1 << (apicid)))
 #define check_apicid_present(bit) (phys_cpu_present_map & (1 << bit))
+#define apicid_cluster(apicid) (apicid & 0xF0)
 
 static inline int apic_id_registered(void)
 {
@@ -115,4 +116,37 @@
 
 #define         GET_APIC_ID(x)  get_apic_id(x)
 
+static inline unsigned int cpu_mask_to_apicid (unsigned long cpumask)
+{
+	int num_bits_set;
+	int cpus_found = 0;
+	int cpu;
+	int apicid;	
+
+	num_bits_set = hweight32(cpumask); 
+	/* Return id to all */
+	if (num_bits_set == 32)
+		return (int) 0xFF;
+	/* 
+	 * The cpus in the mask must all be on the apic cluster.  If are not 
+	 * on the same apicid cluster return default value of TARGET_CPUS. 
+	 */
+	cpu = ffs(cpumask)-1;
+	apicid = cpu_to_logical_apicid(cpu);
+	while (cpus_found < num_bits_set) {
+		if (cpumask & (1 << cpu)) {
+			int new_apicid = cpu_to_logical_apicid(cpu);
+			if (apicid_cluster(apicid) != 
+					apicid_cluster(new_apicid)){
+				printk ("%s: Not a valid mask!\n",__FUNCTION__);
+				return TARGET_CPUS;
+			}
+			apicid = apicid | new_apicid;
+			cpus_found++;
+		}
+		cpu++;
+	}
+	return apicid;
+}
+
 #endif /* __ASM_MACH_APIC_H */
diff -urN linux-2.5.69-bk7/include/asm-i386/mach-summit/mach_apic.h linux-2.5.69-bk8/include/asm-i386/mach-summit/mach_apic.h
--- linux-2.5.69-bk7/include/asm-i386/mach-summit/mach_apic.h	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/include/asm-i386/mach-summit/mach_apic.h	2003-05-13 04:44:30.000000000 -0700
@@ -34,7 +34,7 @@
 
 #define APIC_BROADCAST_ID     (0x0F)
 static inline unsigned long check_apicid_used(unsigned long bitmap, int apicid) 
-{ 
+{
 	return (x86_summit ? 0 : (bitmap & (1 << apicid)));
 } 
 
@@ -44,6 +44,8 @@
 	return (x86_summit ? 1 : (phys_cpu_present_map & (1 << bit)));
 }
 
+#define apicid_cluster(apicid) (apicid & 0xF0)
+
 extern u8 bios_cpu_apicid[];
 
 static inline void init_apic_ldr(void)
@@ -142,4 +144,37 @@
 
 #define		GET_APIC_ID(x)	get_apic_id(x)
 
+static inline unsigned int cpu_mask_to_apicid (unsigned long cpumask)
+{
+	int num_bits_set;
+	int cpus_found = 0;
+	int cpu;
+	int apicid;	
+
+	num_bits_set = hweight32(cpumask); 
+	/* Return id to all */
+	if (num_bits_set == 32)
+		return (int) 0xFF;
+	/* 
+	 * The cpus in the mask must all be on the apic cluster.  If are not 
+	 * on the same apicid cluster return default value of TARGET_CPUS. 
+	 */
+	cpu = ffs(cpumask)-1;
+	apicid = cpu_to_logical_apicid(cpu);
+	while (cpus_found < num_bits_set) {
+		if (cpumask & (1 << cpu)) {
+			int new_apicid = cpu_to_logical_apicid(cpu);
+			if (apicid_cluster(apicid) != 
+					apicid_cluster(new_apicid)){
+				printk ("%s: Not a valid mask!\n",__FUNCTION__);
+				return TARGET_CPUS;
+			}
+			apicid = apicid | new_apicid;
+			cpus_found++;
+		}
+		cpu++;
+	}
+	return apicid;
+}
+
 #endif /* __ASM_MACH_APIC_H */
diff -urN linux-2.5.69-bk7/include/asm-i386/mach-visws/mach_apic.h linux-2.5.69-bk8/include/asm-i386/mach-visws/mach_apic.h
--- linux-2.5.69-bk7/include/asm-i386/mach-visws/mach_apic.h	2003-05-04 16:52:49.000000000 -0700
+++ linux-2.5.69-bk8/include/asm-i386/mach-visws/mach_apic.h	2003-05-13 04:44:30.000000000 -0700
@@ -77,4 +77,8 @@
 	return test_bit(boot_cpu_physical_apicid, &phys_cpu_present_map);
 }
 
+static inline unsigned int cpu_mask_to_apicid (unsigned long cpumask)
+{
+	return cpumask;
+}
 #endif /* __ASM_MACH_APIC_H */
diff -urN linux-2.5.69-bk7/include/asm-i386/uaccess.h linux-2.5.69-bk8/include/asm-i386/uaccess.h
--- linux-2.5.69-bk7/include/asm-i386/uaccess.h	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/include/asm-i386/uaccess.h	2003-05-13 04:44:30.000000000 -0700
@@ -42,8 +42,6 @@
 } ____cacheline_aligned_in_smp movsl_mask;
 #endif
 
-int __verify_write(const void *, unsigned long);
-
 #define __addr_ok(addr) ((unsigned long)(addr) < (current_thread_info()->addr_limit.seg))
 
 /*
diff -urN linux-2.5.69-bk7/include/asm-ia64/hardirq.h linux-2.5.69-bk8/include/asm-ia64/hardirq.h
--- linux-2.5.69-bk7/include/asm-ia64/hardirq.h	2003-05-04 16:53:08.000000000 -0700
+++ linux-2.5.69-bk8/include/asm-ia64/hardirq.h	2003-05-13 04:44:30.000000000 -0700
@@ -85,7 +85,7 @@
 
 #define irq_enter()		(preempt_count() += HARDIRQ_OFFSET)
 
-#if CONFIG_PREEMPT
+#ifdef CONFIG_PREEMPT
 # define in_atomic()		((preempt_count() & ~PREEMPT_ACTIVE) != kernel_locked())
 # define IRQ_EXIT_OFFSET (HARDIRQ_OFFSET-1)
 #else
diff -urN linux-2.5.69-bk7/include/asm-ia64/kmap_types.h linux-2.5.69-bk8/include/asm-ia64/kmap_types.h
--- linux-2.5.69-bk7/include/asm-ia64/kmap_types.h	2003-05-04 16:53:14.000000000 -0700
+++ linux-2.5.69-bk8/include/asm-ia64/kmap_types.h	2003-05-13 04:44:30.000000000 -0700
@@ -3,7 +3,7 @@
 
 #include <linux/config.h>
 
-#if CONFIG_DEBUG_HIGHMEM
+#ifdef CONFIG_DEBUG_HIGHMEM
 # define D(n) __KM_FENCE_##n ,
 #else
 # define D(n)
diff -urN linux-2.5.69-bk7/include/asm-ia64/sn/addrs.h linux-2.5.69-bk8/include/asm-ia64/sn/addrs.h
--- linux-2.5.69-bk7/include/asm-ia64/sn/addrs.h	2003-05-04 16:53:36.000000000 -0700
+++ linux-2.5.69-bk8/include/asm-ia64/sn/addrs.h	2003-05-13 04:44:30.000000000 -0700
@@ -215,7 +215,7 @@
 #define REMOTE_HUB_ADDR(_n, _x)	(HUBREG_CAST (NODE_SWIN_BASE(_n, 1) +	\
 					      0x800000 + (_x)))
 #endif
-#if CONFIG_IA64_SGI_SN1
+#ifdef CONFIG_IA64_SGI_SN1
 #define REMOTE_HUB_PI_ADDR(_n, _sn, _x)	(HUBREG_CAST (NODE_SWIN_BASE(_n, 1) +	\
 					      0x800000 + PIREG(_x, _sn)))
 #endif
diff -urN linux-2.5.69-bk7/include/asm-m68k/elf.h linux-2.5.69-bk8/include/asm-m68k/elf.h
--- linux-2.5.69-bk7/include/asm-m68k/elf.h	2003-05-04 16:53:08.000000000 -0700
+++ linux-2.5.69-bk8/include/asm-m68k/elf.h	2003-05-13 04:44:30.000000000 -0700
@@ -9,6 +9,33 @@
 #include <asm/ptrace.h>
 #include <asm/user.h>
 
+/*
+ * 68k ELF relocation types
+ */
+#define R_68K_NONE	0
+#define R_68K_32	1
+#define R_68K_16	2
+#define R_68K_8		3
+#define R_68K_PC32	4
+#define R_68K_PC16	5
+#define R_68K_PC8	6
+#define R_68K_GOT32	7
+#define R_68K_GOT16	8
+#define R_68K_GOT8	9
+#define R_68K_GOT32O	10
+#define R_68K_GOT16O	11
+#define R_68K_GOT8O	12
+#define R_68K_PLT32	13
+#define R_68K_PLT16	14
+#define R_68K_PLT8	15
+#define R_68K_PLT32O	16
+#define R_68K_PLT16O	17
+#define R_68K_PLT8O	18
+#define R_68K_COPY	19
+#define R_68K_GLOB_DAT	20
+#define R_68K_JMP_SLOT	21
+#define R_68K_RELATIVE	22
+
 typedef unsigned long elf_greg_t;
 
 #define ELF_NGREG (sizeof(struct user_regs_struct) / sizeof(elf_greg_t))
diff -urN linux-2.5.69-bk7/include/asm-m68k/hardirq.h linux-2.5.69-bk8/include/asm-m68k/hardirq.h
--- linux-2.5.69-bk7/include/asm-m68k/hardirq.h	2003-05-04 16:53:14.000000000 -0700
+++ linux-2.5.69-bk8/include/asm-m68k/hardirq.h	2003-05-13 04:44:30.000000000 -0700
@@ -73,7 +73,7 @@
 
 #define irq_enter()		(preempt_count() += HARDIRQ_OFFSET)
 
-#if CONFIG_PREEMPT
+#ifdef CONFIG_PREEMPT
 # define in_atomic()	(preempt_count() != kernel_locked())
 # define IRQ_EXIT_OFFSET (HARDIRQ_OFFSET-1)
 #else
diff -urN linux-2.5.69-bk7/include/asm-m68knommu/hardirq.h linux-2.5.69-bk8/include/asm-m68knommu/hardirq.h
--- linux-2.5.69-bk7/include/asm-m68knommu/hardirq.h	2003-05-04 16:53:01.000000000 -0700
+++ linux-2.5.69-bk8/include/asm-m68knommu/hardirq.h	2003-05-13 04:44:30.000000000 -0700
@@ -72,13 +72,13 @@
 
 #define irq_enter()		(preempt_count() += HARDIRQ_OFFSET)
 
-#if CONFIG_PREEMPT
+#ifdef CONFIG_PREEMPT
 # define IRQ_EXIT_OFFSET (HARDIRQ_OFFSET-1)
 #else
 # define IRQ_EXIT_OFFSET HARDIRQ_OFFSET
 #endif
 
-#if CONFIG_PREEMPT
+#ifdef CONFIG_PREEMPT
 # define in_atomic()	(preempt_count() != kernel_locked())
 # define IRQ_EXIT_OFFSET (HARDIRQ_OFFSET-1)
 #else
diff -urN linux-2.5.69-bk7/include/asm-mips/elf.h linux-2.5.69-bk8/include/asm-mips/elf.h
--- linux-2.5.69-bk7/include/asm-mips/elf.h	2003-05-04 16:53:13.000000000 -0700
+++ linux-2.5.69-bk8/include/asm-mips/elf.h	2003-05-13 04:44:30.000000000 -0700
@@ -6,6 +6,91 @@
 #ifndef __ASM_ELF_H
 #define __ASM_ELF_H
 
+#define PT_MIPS_REGINFO		0x70000000
+
+/* Flags in the e_flags field of the header */
+#define EF_MIPS_NOREORDER 0x00000001
+#define EF_MIPS_PIC       0x00000002
+#define EF_MIPS_CPIC      0x00000004
+#define EF_MIPS_ARCH      0xf0000000
+
+#define DT_MIPS_RLD_VERSION	0x70000001
+#define DT_MIPS_TIME_STAMP	0x70000002
+#define DT_MIPS_ICHECKSUM	0x70000003
+#define DT_MIPS_IVERSION	0x70000004
+#define DT_MIPS_FLAGS		0x70000005
+  #define RHF_NONE		  0
+  #define RHF_HARDWAY		  1
+  #define RHF_NOTPOT		  2
+#define DT_MIPS_BASE_ADDRESS	0x70000006
+#define DT_MIPS_CONFLICT	0x70000008
+#define DT_MIPS_LIBLIST		0x70000009
+#define DT_MIPS_LOCAL_GOTNO	0x7000000a
+#define DT_MIPS_CONFLICTNO	0x7000000b
+#define DT_MIPS_LIBLISTNO	0x70000010
+#define DT_MIPS_SYMTABNO	0x70000011
+#define DT_MIPS_UNREFEXTNO	0x70000012
+#define DT_MIPS_GOTSYM		0x70000013
+#define DT_MIPS_HIPAGENO	0x70000014
+#define DT_MIPS_RLD_MAP		0x70000016
+
+#define R_MIPS_NONE		0
+#define R_MIPS_16		1
+#define R_MIPS_32		2
+#define R_MIPS_REL32		3
+#define R_MIPS_26		4
+#define R_MIPS_HI16		5
+#define R_MIPS_LO16		6
+#define R_MIPS_GPREL16		7
+#define R_MIPS_LITERAL		8
+#define R_MIPS_GOT16		9
+#define R_MIPS_PC16		10
+#define R_MIPS_CALL16		11
+#define R_MIPS_GPREL32		12
+/* The remaining relocs are defined on Irix, although they are not
+   in the MIPS ELF ABI.  */
+#define R_MIPS_UNUSED1		13
+#define R_MIPS_UNUSED2		14
+#define R_MIPS_UNUSED3		15
+#define R_MIPS_SHIFT5		16
+#define R_MIPS_SHIFT6		17
+#define R_MIPS_64		18
+#define R_MIPS_GOT_DISP		19
+#define R_MIPS_GOT_PAGE		20
+#define R_MIPS_GOT_OFST		21
+/*
+ * The following two relocation types are specified in the MIPS ABI
+ * conformance guide version 1.2 but not yet in the psABI.
+ */
+#define R_MIPS_GOTHI16		22
+#define R_MIPS_GOTLO16		23
+#define R_MIPS_SUB		24
+#define R_MIPS_INSERT_A		25
+#define R_MIPS_INSERT_B		26
+#define R_MIPS_DELETE		27
+#define R_MIPS_HIGHER		28
+#define R_MIPS_HIGHEST		29
+/*
+ * The following two relocation types are specified in the MIPS ABI
+ * conformance guide version 1.2 but not yet in the psABI.
+ */
+#define R_MIPS_CALLHI16		30
+#define R_MIPS_CALLLO16		31
+/*
+ * This range is reserved for vendor specific relocations.
+ */
+#define R_MIPS_LOVENDOR		100
+#define R_MIPS_HIVENDOR		127
+
+#define SHN_MIPS_ACCOMON	0xff00
+
+#define SHT_MIPS_LIST		0x70000000
+#define SHT_MIPS_CONFLICT	0x70000002
+#define SHT_MIPS_GPTAB		0x70000003
+#define SHT_MIPS_UCODE		0x70000004
+
+#define SHF_MIPS_GPREL	0x10000000
+
 /* ELF register definitions */
 #define ELF_NGREG	45
 #define ELF_NFPREG	33
diff -urN linux-2.5.69-bk7/include/asm-mips64/elf.h linux-2.5.69-bk8/include/asm-mips64/elf.h
--- linux-2.5.69-bk7/include/asm-mips64/elf.h	2003-05-04 16:52:49.000000000 -0700
+++ linux-2.5.69-bk8/include/asm-mips64/elf.h	2003-05-13 04:44:30.000000000 -0700
@@ -9,6 +9,91 @@
 #include <asm/ptrace.h>
 #include <asm/user.h>
 
+#define PT_MIPS_REGINFO		0x70000000
+
+/* Flags in the e_flags field of the header */
+#define EF_MIPS_NOREORDER 0x00000001
+#define EF_MIPS_PIC       0x00000002
+#define EF_MIPS_CPIC      0x00000004
+#define EF_MIPS_ARCH      0xf0000000
+
+#define DT_MIPS_RLD_VERSION	0x70000001
+#define DT_MIPS_TIME_STAMP	0x70000002
+#define DT_MIPS_ICHECKSUM	0x70000003
+#define DT_MIPS_IVERSION	0x70000004
+#define DT_MIPS_FLAGS		0x70000005
+  #define RHF_NONE		  0
+  #define RHF_HARDWAY		  1
+  #define RHF_NOTPOT		  2
+#define DT_MIPS_BASE_ADDRESS	0x70000006
+#define DT_MIPS_CONFLICT	0x70000008
+#define DT_MIPS_LIBLIST		0x70000009
+#define DT_MIPS_LOCAL_GOTNO	0x7000000a
+#define DT_MIPS_CONFLICTNO	0x7000000b
+#define DT_MIPS_LIBLISTNO	0x70000010
+#define DT_MIPS_SYMTABNO	0x70000011
+#define DT_MIPS_UNREFEXTNO	0x70000012
+#define DT_MIPS_GOTSYM		0x70000013
+#define DT_MIPS_HIPAGENO	0x70000014
+#define DT_MIPS_RLD_MAP		0x70000016
+
+#define R_MIPS_NONE		0
+#define R_MIPS_16		1
+#define R_MIPS_32		2
+#define R_MIPS_REL32		3
+#define R_MIPS_26		4
+#define R_MIPS_HI16		5
+#define R_MIPS_LO16		6
+#define R_MIPS_GPREL16		7
+#define R_MIPS_LITERAL		8
+#define R_MIPS_GOT16		9
+#define R_MIPS_PC16		10
+#define R_MIPS_CALL16		11
+#define R_MIPS_GPREL32		12
+/* The remaining relocs are defined on Irix, although they are not
+   in the MIPS ELF ABI.  */
+#define R_MIPS_UNUSED1		13
+#define R_MIPS_UNUSED2		14
+#define R_MIPS_UNUSED3		15
+#define R_MIPS_SHIFT5		16
+#define R_MIPS_SHIFT6		17
+#define R_MIPS_64		18
+#define R_MIPS_GOT_DISP		19
+#define R_MIPS_GOT_PAGE		20
+#define R_MIPS_GOT_OFST		21
+/*
+ * The following two relocation types are specified in the MIPS ABI
+ * conformance guide version 1.2 but not yet in the psABI.
+ */
+#define R_MIPS_GOTHI16		22
+#define R_MIPS_GOTLO16		23
+#define R_MIPS_SUB		24
+#define R_MIPS_INSERT_A		25
+#define R_MIPS_INSERT_B		26
+#define R_MIPS_DELETE		27
+#define R_MIPS_HIGHER		28
+#define R_MIPS_HIGHEST		29
+/*
+ * The following two relocation types are specified in the MIPS ABI
+ * conformance guide version 1.2 but not yet in the psABI.
+ */
+#define R_MIPS_CALLHI16		30
+#define R_MIPS_CALLLO16		31
+/*
+ * This range is reserved for vendor specific relocations.
+ */
+#define R_MIPS_LOVENDOR		100
+#define R_MIPS_HIVENDOR		127
+
+#define SHN_MIPS_ACCOMON	0xff00
+
+#define SHT_MIPS_LIST		0x70000000
+#define SHT_MIPS_CONFLICT	0x70000002
+#define SHT_MIPS_GPTAB		0x70000003
+#define SHT_MIPS_UCODE		0x70000004
+
+#define SHF_MIPS_GPREL	0x10000000
+
 #ifndef ELF_ARCH
 /* ELF register definitions */
 #define ELF_NGREG	45
diff -urN linux-2.5.69-bk7/include/asm-parisc/elf.h linux-2.5.69-bk8/include/asm-parisc/elf.h
--- linux-2.5.69-bk7/include/asm-parisc/elf.h	2003-05-04 16:53:36.000000000 -0700
+++ linux-2.5.69-bk8/include/asm-parisc/elf.h	2003-05-13 04:44:30.000000000 -0700
@@ -9,6 +9,174 @@
 
 #define EM_PARISC 15
 
+/* HPPA specific definitions.  */
+
+/* Legal values for e_flags field of Elf32_Ehdr.  */
+
+#define EF_PARISC_TRAPNIL	0x00010000 /* Trap nil pointer dereference.  */
+#define EF_PARISC_EXT		0x00020000 /* Program uses arch. extensions. */
+#define EF_PARISC_LSB		0x00040000 /* Program expects little endian. */
+#define EF_PARISC_WIDE		0x00080000 /* Program expects wide mode.  */
+#define EF_PARISC_NO_KABP	0x00100000 /* No kernel assisted branch
+					      prediction.  */
+#define EF_PARISC_LAZYSWAP	0x00400000 /* Allow lazy swapping.  */
+#define EF_PARISC_ARCH		0x0000ffff /* Architecture version.  */
+
+/* Defined values for `e_flags & EF_PARISC_ARCH' are:  */
+
+#define EFA_PARISC_1_0		    0x020b /* PA-RISC 1.0 big-endian.  */
+#define EFA_PARISC_1_1		    0x0210 /* PA-RISC 1.1 big-endian.  */
+#define EFA_PARISC_2_0		    0x0214 /* PA-RISC 2.0 big-endian.  */
+
+/* Additional section indeces.  */
+
+#define SHN_PARISC_ANSI_COMMON	0xff00	   /* Section for tenatively declared
+					      symbols in ANSI C.  */
+#define SHN_PARISC_HUGE_COMMON	0xff01	   /* Common blocks in huge model.  */
+
+/* Legal values for sh_type field of Elf32_Shdr.  */
+
+#define SHT_PARISC_EXT		0x70000000 /* Contains product specific ext. */
+#define SHT_PARISC_UNWIND	0x70000001 /* Unwind information.  */
+#define SHT_PARISC_DOC		0x70000002 /* Debug info for optimized code. */
+
+/* Legal values for sh_flags field of Elf32_Shdr.  */
+
+#define SHF_PARISC_SHORT	0x20000000 /* Section with short addressing. */
+#define SHF_PARISC_HUGE		0x40000000 /* Section far from gp.  */
+#define SHF_PARISC_SBP		0x80000000 /* Static branch prediction code. */
+
+/* Legal values for ST_TYPE subfield of st_info (symbol type).  */
+
+#define STT_PARISC_MILLICODE	13	/* Millicode function entry point.  */
+
+#define STT_HP_OPAQUE		(STT_LOOS + 0x1)
+#define STT_HP_STUB		(STT_LOOS + 0x2)
+
+/* HPPA relocs.  */
+
+#define R_PARISC_NONE		0	/* No reloc.  */
+#define R_PARISC_DIR32		1	/* Direct 32-bit reference.  */
+#define R_PARISC_DIR21L		2	/* Left 21 bits of eff. address.  */
+#define R_PARISC_DIR17R		3	/* Right 17 bits of eff. address.  */
+#define R_PARISC_DIR17F		4	/* 17 bits of eff. address.  */
+#define R_PARISC_DIR14R		6	/* Right 14 bits of eff. address.  */
+#define R_PARISC_PCREL32	9	/* 32-bit rel. address.  */
+#define R_PARISC_PCREL21L	10	/* Left 21 bits of rel. address.  */
+#define R_PARISC_PCREL17R	11	/* Right 17 bits of rel. address.  */
+#define R_PARISC_PCREL17F	12	/* 17 bits of rel. address.  */
+#define R_PARISC_PCREL14R	14	/* Right 14 bits of rel. address.  */
+#define R_PARISC_DPREL21L	18	/* Left 21 bits of rel. address.  */
+#define R_PARISC_DPREL14R	22	/* Right 14 bits of rel. address.  */
+#define R_PARISC_GPREL21L	26	/* GP-relative, left 21 bits.  */
+#define R_PARISC_GPREL14R	30	/* GP-relative, right 14 bits.  */
+#define R_PARISC_LTOFF21L	34	/* LT-relative, left 21 bits.  */
+#define R_PARISC_LTOFF14R	38	/* LT-relative, right 14 bits.  */
+#define R_PARISC_SECREL32	41	/* 32 bits section rel. address.  */
+#define R_PARISC_SEGBASE	48	/* No relocation, set segment base.  */
+#define R_PARISC_SEGREL32	49	/* 32 bits segment rel. address.  */
+#define R_PARISC_PLTOFF21L	50	/* PLT rel. address, left 21 bits.  */
+#define R_PARISC_PLTOFF14R	54	/* PLT rel. address, right 14 bits.  */
+#define R_PARISC_LTOFF_FPTR32	57	/* 32 bits LT-rel. function pointer. */
+#define R_PARISC_LTOFF_FPTR21L	58	/* LT-rel. fct ptr, left 21 bits. */
+#define R_PARISC_LTOFF_FPTR14R	62	/* LT-rel. fct ptr, right 14 bits. */
+#define R_PARISC_FPTR64		64	/* 64 bits function address.  */
+#define R_PARISC_PLABEL32	65	/* 32 bits function address.  */
+#define R_PARISC_PCREL64	72	/* 64 bits PC-rel. address.  */
+#define R_PARISC_PCREL22F	74	/* 22 bits PC-rel. address.  */
+#define R_PARISC_PCREL14WR	75	/* PC-rel. address, right 14 bits.  */
+#define R_PARISC_PCREL14DR	76	/* PC rel. address, right 14 bits.  */
+#define R_PARISC_PCREL16F	77	/* 16 bits PC-rel. address.  */
+#define R_PARISC_PCREL16WF	78	/* 16 bits PC-rel. address.  */
+#define R_PARISC_PCREL16DF	79	/* 16 bits PC-rel. address.  */
+#define R_PARISC_DIR64		80	/* 64 bits of eff. address.  */
+#define R_PARISC_DIR14WR	83	/* 14 bits of eff. address.  */
+#define R_PARISC_DIR14DR	84	/* 14 bits of eff. address.  */
+#define R_PARISC_DIR16F		85	/* 16 bits of eff. address.  */
+#define R_PARISC_DIR16WF	86	/* 16 bits of eff. address.  */
+#define R_PARISC_DIR16DF	87	/* 16 bits of eff. address.  */
+#define R_PARISC_GPREL64	88	/* 64 bits of GP-rel. address.  */
+#define R_PARISC_GPREL14WR	91	/* GP-rel. address, right 14 bits.  */
+#define R_PARISC_GPREL14DR	92	/* GP-rel. address, right 14 bits.  */
+#define R_PARISC_GPREL16F	93	/* 16 bits GP-rel. address.  */
+#define R_PARISC_GPREL16WF	94	/* 16 bits GP-rel. address.  */
+#define R_PARISC_GPREL16DF	95	/* 16 bits GP-rel. address.  */
+#define R_PARISC_LTOFF64	96	/* 64 bits LT-rel. address.  */
+#define R_PARISC_LTOFF14WR	99	/* LT-rel. address, right 14 bits.  */
+#define R_PARISC_LTOFF14DR	100	/* LT-rel. address, right 14 bits.  */
+#define R_PARISC_LTOFF16F	101	/* 16 bits LT-rel. address.  */
+#define R_PARISC_LTOFF16WF	102	/* 16 bits LT-rel. address.  */
+#define R_PARISC_LTOFF16DF	103	/* 16 bits LT-rel. address.  */
+#define R_PARISC_SECREL64	104	/* 64 bits section rel. address.  */
+#define R_PARISC_SEGREL64	112	/* 64 bits segment rel. address.  */
+#define R_PARISC_PLTOFF14WR	115	/* PLT-rel. address, right 14 bits.  */
+#define R_PARISC_PLTOFF14DR	116	/* PLT-rel. address, right 14 bits.  */
+#define R_PARISC_PLTOFF16F	117	/* 16 bits LT-rel. address.  */
+#define R_PARISC_PLTOFF16WF	118	/* 16 bits PLT-rel. address.  */
+#define R_PARISC_PLTOFF16DF	119	/* 16 bits PLT-rel. address.  */
+#define R_PARISC_LTOFF_FPTR64	120	/* 64 bits LT-rel. function ptr.  */
+#define R_PARISC_LTOFF_FPTR14WR	123	/* LT-rel. fct. ptr., right 14 bits. */
+#define R_PARISC_LTOFF_FPTR14DR	124	/* LT-rel. fct. ptr., right 14 bits. */
+#define R_PARISC_LTOFF_FPTR16F	125	/* 16 bits LT-rel. function ptr.  */
+#define R_PARISC_LTOFF_FPTR16WF	126	/* 16 bits LT-rel. function ptr.  */
+#define R_PARISC_LTOFF_FPTR16DF	127	/* 16 bits LT-rel. function ptr.  */
+#define R_PARISC_LORESERVE	128
+#define R_PARISC_COPY		128	/* Copy relocation.  */
+#define R_PARISC_IPLT		129	/* Dynamic reloc, imported PLT */
+#define R_PARISC_EPLT		130	/* Dynamic reloc, exported PLT */
+#define R_PARISC_TPREL32	153	/* 32 bits TP-rel. address.  */
+#define R_PARISC_TPREL21L	154	/* TP-rel. address, left 21 bits.  */
+#define R_PARISC_TPREL14R	158	/* TP-rel. address, right 14 bits.  */
+#define R_PARISC_LTOFF_TP21L	162	/* LT-TP-rel. address, left 21 bits. */
+#define R_PARISC_LTOFF_TP14R	166	/* LT-TP-rel. address, right 14 bits.*/
+#define R_PARISC_LTOFF_TP14F	167	/* 14 bits LT-TP-rel. address.  */
+#define R_PARISC_TPREL64	216	/* 64 bits TP-rel. address.  */
+#define R_PARISC_TPREL14WR	219	/* TP-rel. address, right 14 bits.  */
+#define R_PARISC_TPREL14DR	220	/* TP-rel. address, right 14 bits.  */
+#define R_PARISC_TPREL16F	221	/* 16 bits TP-rel. address.  */
+#define R_PARISC_TPREL16WF	222	/* 16 bits TP-rel. address.  */
+#define R_PARISC_TPREL16DF	223	/* 16 bits TP-rel. address.  */
+#define R_PARISC_LTOFF_TP64	224	/* 64 bits LT-TP-rel. address.  */
+#define R_PARISC_LTOFF_TP14WR	227	/* LT-TP-rel. address, right 14 bits.*/
+#define R_PARISC_LTOFF_TP14DR	228	/* LT-TP-rel. address, right 14 bits.*/
+#define R_PARISC_LTOFF_TP16F	229	/* 16 bits LT-TP-rel. address.  */
+#define R_PARISC_LTOFF_TP16WF	230	/* 16 bits LT-TP-rel. address.  */
+#define R_PARISC_LTOFF_TP16DF	231	/* 16 bits LT-TP-rel. address.  */
+#define R_PARISC_HIRESERVE	255
+
+/* Legal values for p_type field of Elf32_Phdr/Elf64_Phdr.  */
+
+#define PT_HP_TLS		(PT_LOOS + 0x0)
+#define PT_HP_CORE_NONE		(PT_LOOS + 0x1)
+#define PT_HP_CORE_VERSION	(PT_LOOS + 0x2)
+#define PT_HP_CORE_KERNEL	(PT_LOOS + 0x3)
+#define PT_HP_CORE_COMM		(PT_LOOS + 0x4)
+#define PT_HP_CORE_PROC		(PT_LOOS + 0x5)
+#define PT_HP_CORE_LOADABLE	(PT_LOOS + 0x6)
+#define PT_HP_CORE_STACK	(PT_LOOS + 0x7)
+#define PT_HP_CORE_SHM		(PT_LOOS + 0x8)
+#define PT_HP_CORE_MMF		(PT_LOOS + 0x9)
+#define PT_HP_PARALLEL		(PT_LOOS + 0x10)
+#define PT_HP_FASTBIND		(PT_LOOS + 0x11)
+#define PT_HP_OPT_ANNOT		(PT_LOOS + 0x12)
+#define PT_HP_HSL_ANNOT		(PT_LOOS + 0x13)
+#define PT_HP_STACK		(PT_LOOS + 0x14)
+
+#define PT_PARISC_ARCHEXT	0x70000000
+#define PT_PARISC_UNWIND	0x70000001
+
+/* Legal values for p_flags field of Elf32_Phdr/Elf64_Phdr.  */
+
+#define PF_PARISC_SBP		0x08000000
+
+#define PF_HP_PAGE_SIZE		0x00100000
+#define PF_HP_FAR_SHARED	0x00200000
+#define PF_HP_NEAR_SHARED	0x00400000
+#define PF_HP_CODE		0x01000000
+#define PF_HP_MODIFY		0x02000000
+#define PF_HP_LAZYSWAP		0x04000000
+#define PF_HP_SBP		0x08000000
+
 /*
  * The following definitions are those for 32-bit ELF binaries on a 32-bit kernel
  * and for 64-bit binaries on a 64-bit kernel.  To run 32-bit binaries on a 64-bit
diff -urN linux-2.5.69-bk7/include/asm-parisc/hardirq.h linux-2.5.69-bk8/include/asm-parisc/hardirq.h
--- linux-2.5.69-bk7/include/asm-parisc/hardirq.h	2003-05-04 16:53:41.000000000 -0700
+++ linux-2.5.69-bk8/include/asm-parisc/hardirq.h	2003-05-13 04:44:30.000000000 -0700
@@ -87,7 +87,7 @@
 
 #define irq_enter()		(preempt_count() += HARDIRQ_OFFSET)
 
-#if CONFIG_PREEMPT
+#ifdef CONFIG_PREEMPT
 # error CONFIG_PREEMT currently not supported.
 # define in_atomic()	 BUG()
 # define IRQ_EXIT_OFFSET (HARDIRQ_OFFSET-1)
diff -urN linux-2.5.69-bk7/include/asm-parisc/kmap_types.h linux-2.5.69-bk8/include/asm-parisc/kmap_types.h
--- linux-2.5.69-bk7/include/asm-parisc/kmap_types.h	2003-05-04 16:53:31.000000000 -0700
+++ linux-2.5.69-bk8/include/asm-parisc/kmap_types.h	2003-05-13 04:44:30.000000000 -0700
@@ -3,7 +3,7 @@
 
 #include <linux/config.h>
 
-#if CONFIG_DEBUG_HIGHMEM
+#ifdef CONFIG_DEBUG_HIGHMEM
 # define D(n) __KM_FENCE_##n ,
 #else
 # define D(n)
diff -urN linux-2.5.69-bk7/include/asm-ppc/elf.h linux-2.5.69-bk8/include/asm-ppc/elf.h
--- linux-2.5.69-bk7/include/asm-ppc/elf.h	2003-05-04 16:52:48.000000000 -0700
+++ linux-2.5.69-bk8/include/asm-ppc/elf.h	2003-05-13 04:44:30.000000000 -0700
@@ -8,6 +8,47 @@
 #include <asm/ptrace.h>
 #include <asm/cputable.h>
 
+/* PowerPC relocations defined by the ABIs */
+#define R_PPC_NONE		0
+#define R_PPC_ADDR32		1	/* 32bit absolute address */
+#define R_PPC_ADDR24		2	/* 26bit address, 2 bits ignored.  */
+#define R_PPC_ADDR16		3	/* 16bit absolute address */
+#define R_PPC_ADDR16_LO		4	/* lower 16bit of absolute address */
+#define R_PPC_ADDR16_HI		5	/* high 16bit of absolute address */
+#define R_PPC_ADDR16_HA		6	/* adjusted high 16bit */
+#define R_PPC_ADDR14		7	/* 16bit address, 2 bits ignored */
+#define R_PPC_ADDR14_BRTAKEN	8
+#define R_PPC_ADDR14_BRNTAKEN	9
+#define R_PPC_REL24		10	/* PC relative 26 bit */
+#define R_PPC_REL14		11	/* PC relative 16 bit */
+#define R_PPC_REL14_BRTAKEN	12
+#define R_PPC_REL14_BRNTAKEN	13
+#define R_PPC_GOT16		14
+#define R_PPC_GOT16_LO		15
+#define R_PPC_GOT16_HI		16
+#define R_PPC_GOT16_HA		17
+#define R_PPC_PLTREL24		18
+#define R_PPC_COPY		19
+#define R_PPC_GLOB_DAT		20
+#define R_PPC_JMP_SLOT		21
+#define R_PPC_RELATIVE		22
+#define R_PPC_LOCAL24PC		23
+#define R_PPC_UADDR32		24
+#define R_PPC_UADDR16		25
+#define R_PPC_REL32		26
+#define R_PPC_PLT32		27
+#define R_PPC_PLTREL32		28
+#define R_PPC_PLT16_LO		29
+#define R_PPC_PLT16_HI		30
+#define R_PPC_PLT16_HA		31
+#define R_PPC_SDAREL16		32
+#define R_PPC_SECTOFF		33
+#define R_PPC_SECTOFF_LO	34
+#define R_PPC_SECTOFF_HI	35
+#define R_PPC_SECTOFF_HA	36
+/* Keep this the last entry.  */
+#define R_PPC_NUM		37
+
 #define ELF_NGREG	48	/* includes nip, msr, lr, etc. */
 #define ELF_NFPREG	33	/* includes fpscr */
 #define ELF_NVRREG	33	/* includes vscr */
diff -urN linux-2.5.69-bk7/include/asm-ppc/hardirq.h linux-2.5.69-bk8/include/asm-ppc/hardirq.h
--- linux-2.5.69-bk7/include/asm-ppc/hardirq.h	2003-05-04 16:52:48.000000000 -0700
+++ linux-2.5.69-bk8/include/asm-ppc/hardirq.h	2003-05-13 04:44:30.000000000 -0700
@@ -82,7 +82,7 @@
 
 #define irq_enter()		(preempt_count() += HARDIRQ_OFFSET)
 
-#if CONFIG_PREEMPT
+#ifdef CONFIG_PREEMPT
 # define in_atomic()	((preempt_count() & ~PREEMPT_ACTIVE) != kernel_locked())
 # define IRQ_EXIT_OFFSET (HARDIRQ_OFFSET-1)
 #else
diff -urN linux-2.5.69-bk7/include/asm-ppc/spinlock.h linux-2.5.69-bk8/include/asm-ppc/spinlock.h
--- linux-2.5.69-bk7/include/asm-ppc/spinlock.h	2003-05-04 16:53:12.000000000 -0700
+++ linux-2.5.69-bk8/include/asm-ppc/spinlock.h	2003-05-13 04:44:30.000000000 -0700
@@ -17,7 +17,7 @@
 } spinlock_t;
 
 #ifdef __KERNEL__
-#if CONFIG_DEBUG_SPINLOCK
+#ifdef CONFIG_DEBUG_SPINLOCK
 #define SPINLOCK_DEBUG_INIT     , 0, 0
 #else
 #define SPINLOCK_DEBUG_INIT     /* */
@@ -86,7 +86,7 @@
 #endif
 } rwlock_t;
 
-#if CONFIG_DEBUG_SPINLOCK
+#ifdef CONFIG_DEBUG_SPINLOCK
 #define RWLOCK_DEBUG_INIT     , 0
 #else
 #define RWLOCK_DEBUG_INIT     /* */
diff -urN linux-2.5.69-bk7/include/asm-ppc64/elf.h linux-2.5.69-bk8/include/asm-ppc64/elf.h
--- linux-2.5.69-bk7/include/asm-ppc64/elf.h	2003-05-04 16:53:36.000000000 -0700
+++ linux-2.5.69-bk8/include/asm-ppc64/elf.h	2003-05-13 04:44:30.000000000 -0700
@@ -1,6 +1,47 @@
 #ifndef __PPC64_ELF_H
 #define __PPC64_ELF_H
 
+/* PowerPC relocations defined by the ABIs */
+#define R_PPC_NONE		0
+#define R_PPC_ADDR32		1	/* 32bit absolute address */
+#define R_PPC_ADDR24		2	/* 26bit address, 2 bits ignored.  */
+#define R_PPC_ADDR16		3	/* 16bit absolute address */
+#define R_PPC_ADDR16_LO		4	/* lower 16bit of absolute address */
+#define R_PPC_ADDR16_HI		5	/* high 16bit of absolute address */
+#define R_PPC_ADDR16_HA		6	/* adjusted high 16bit */
+#define R_PPC_ADDR14		7	/* 16bit address, 2 bits ignored */
+#define R_PPC_ADDR14_BRTAKEN	8
+#define R_PPC_ADDR14_BRNTAKEN	9
+#define R_PPC_REL24		10	/* PC relative 26 bit */
+#define R_PPC_REL14		11	/* PC relative 16 bit */
+#define R_PPC_REL14_BRTAKEN	12
+#define R_PPC_REL14_BRNTAKEN	13
+#define R_PPC_GOT16		14
+#define R_PPC_GOT16_LO		15
+#define R_PPC_GOT16_HI		16
+#define R_PPC_GOT16_HA		17
+#define R_PPC_PLTREL24		18
+#define R_PPC_COPY		19
+#define R_PPC_GLOB_DAT		20
+#define R_PPC_JMP_SLOT		21
+#define R_PPC_RELATIVE		22
+#define R_PPC_LOCAL24PC		23
+#define R_PPC_UADDR32		24
+#define R_PPC_UADDR16		25
+#define R_PPC_REL32		26
+#define R_PPC_PLT32		27
+#define R_PPC_PLTREL32		28
+#define R_PPC_PLT16_LO		29
+#define R_PPC_PLT16_HI		30
+#define R_PPC_PLT16_HA		31
+#define R_PPC_SDAREL16		32
+#define R_PPC_SECTOFF		33
+#define R_PPC_SECTOFF_LO	34
+#define R_PPC_SECTOFF_HI	35
+#define R_PPC_SECTOFF_HA	36
+/* Keep this the last entry.  */
+#define R_PPC_NUM		37
+
 /*
  * ELF register definitions..
  *
diff -urN linux-2.5.69-bk7/include/asm-s390/elf.h linux-2.5.69-bk8/include/asm-s390/elf.h
--- linux-2.5.69-bk7/include/asm-s390/elf.h	2003-05-04 16:53:41.000000000 -0700
+++ linux-2.5.69-bk8/include/asm-s390/elf.h	2003-05-13 04:44:30.000000000 -0700
@@ -9,6 +9,84 @@
 #ifndef __ASMS390_ELF_H
 #define __ASMS390_ELF_H
 
+/* s390 relocations defined by the ABIs */
+#define R_390_NONE		0	/* No reloc.  */
+#define R_390_8			1	/* Direct 8 bit.  */
+#define R_390_12		2	/* Direct 12 bit.  */
+#define R_390_16		3	/* Direct 16 bit.  */
+#define R_390_32		4	/* Direct 32 bit.  */
+#define R_390_PC32		5	/* PC relative 32 bit.	*/
+#define R_390_GOT12		6	/* 12 bit GOT offset.  */
+#define R_390_GOT32		7	/* 32 bit GOT offset.  */
+#define R_390_PLT32		8	/* 32 bit PC relative PLT address.  */
+#define R_390_COPY		9	/* Copy symbol at runtime.  */
+#define R_390_GLOB_DAT		10	/* Create GOT entry.  */
+#define R_390_JMP_SLOT		11	/* Create PLT entry.  */
+#define R_390_RELATIVE		12	/* Adjust by program base.  */
+#define R_390_GOTOFF32		13	/* 32 bit offset to GOT.	 */
+#define R_390_GOTPC		14	/* 32 bit PC rel. offset to GOT.  */
+#define R_390_GOT16		15	/* 16 bit GOT offset.  */
+#define R_390_PC16		16	/* PC relative 16 bit.	*/
+#define R_390_PC16DBL		17	/* PC relative 16 bit shifted by 1.  */
+#define R_390_PLT16DBL		18	/* 16 bit PC rel. PLT shifted by 1.  */
+#define R_390_PC32DBL		19	/* PC relative 32 bit shifted by 1.  */
+#define R_390_PLT32DBL		20	/* 32 bit PC rel. PLT shifted by 1.  */
+#define R_390_GOTPCDBL		21	/* 32 bit PC rel. GOT shifted by 1.  */
+#define R_390_64		22	/* Direct 64 bit.  */
+#define R_390_PC64		23	/* PC relative 64 bit.	*/
+#define R_390_GOT64		24	/* 64 bit GOT offset.  */
+#define R_390_PLT64		25	/* 64 bit PC relative PLT address.  */
+#define R_390_GOTENT		26	/* 32 bit PC rel. to GOT entry >> 1. */
+#define R_390_GOTOFF16		27	/* 16 bit offset to GOT. */
+#define R_390_GOTOFF64		28	/* 64 bit offset to GOT. */
+#define R_390_GOTPLT12		29	/* 12 bit offset to jump slot.	*/
+#define R_390_GOTPLT16		30	/* 16 bit offset to jump slot.	*/
+#define R_390_GOTPLT32		31	/* 32 bit offset to jump slot.	*/
+#define R_390_GOTPLT64		32	/* 64 bit offset to jump slot.	*/
+#define R_390_GOTPLTENT		33	/* 32 bit rel. offset to jump slot.  */
+#define R_390_PLTOFF16		34	/* 16 bit offset from GOT to PLT. */
+#define R_390_PLTOFF32		35	/* 32 bit offset from GOT to PLT. */
+#define R_390_PLTOFF64		36	/* 16 bit offset from GOT to PLT. */
+#define R_390_TLS_LOAD		37	/* Tag for load insn in TLS code. */
+#define R_390_TLS_GDCALL	38	/* Tag for function call in general
+                                           dynamic TLS code.  */
+#define R_390_TLS_LDCALL	39	/* Tag for function call in local
+                                           dynamic TLS code.  */
+#define R_390_TLS_GD32		40	/* Direct 32 bit for general dynamic
+                                           thread local data.  */
+#define R_390_TLS_GD64		41	/* Direct 64 bit for general dynamic
+                                           thread local data.  */
+#define R_390_TLS_GOTIE12	42	/* 12 bit GOT offset for static TLS
+                                           block offset.  */
+#define R_390_TLS_GOTIE32	43	/* 32 bit GOT offset for static TLS
+                                           block offset.  */
+#define R_390_TLS_GOTIE64	44	/* 64 bit GOT offset for static TLS
+                                           block offset.  */
+#define R_390_TLS_LDM32		45	/* Direct 32 bit for local dynamic
+                                           thread local data in LD code.  */
+#define R_390_TLS_LDM64		46	/* Direct 64 bit for local dynamic
+                                           thread local data in LD code.  */
+#define R_390_TLS_IE32		47	/* 32 bit address of GOT entry for
+                                           negated static TLS block offset.  */
+#define R_390_TLS_IE64		48	/* 64 bit address of GOT entry for
+                                           negated static TLS block offset.  */
+#define R_390_TLS_IEENT		49	/* 32 bit rel. offset to GOT entry for
+                                           negated static TLS block offset.  */
+#define R_390_TLS_LE32		50	/* 32 bit negated offset relative to
+                                           static TLS block.  */
+#define R_390_TLS_LE64		51	/* 64 bit negated offset relative to
+                                           static TLS block.  */
+#define R_390_TLS_LDO32		52	/* 32 bit offset relative to TLS
+                                           block.  */
+#define R_390_TLS_LDO64		53	/* 64 bit offset relative to TLS
+                                           block.  */
+#define R_390_TLS_DTPMOD	54	/* ID of module containing symbol.  */
+#define R_390_TLS_DTPOFF	55	/* Offset in TLS block.  */
+#define R_390_TLS_TPOFF		56	/* Negate offset in static TLS
+                                           block.  */
+/* Keep this the last entry.  */
+#define R_390_NUM	57
+
 /*
  * ELF register definitions..
  */
diff -urN linux-2.5.69-bk7/include/asm-s390/hardirq.h linux-2.5.69-bk8/include/asm-s390/hardirq.h
--- linux-2.5.69-bk7/include/asm-s390/hardirq.h	2003-05-04 16:53:57.000000000 -0700
+++ linux-2.5.69-bk8/include/asm-s390/hardirq.h	2003-05-13 04:44:30.000000000 -0700
@@ -82,7 +82,7 @@
 
 #define invoke_softirq() do_call_softirq()
 
-#if CONFIG_PREEMPT
+#ifdef CONFIG_PREEMPT
 # define in_atomic()	(in_interrupt() || preempt_count() == PREEMPT_ACTIVE)
 # define IRQ_EXIT_OFFSET (HARDIRQ_OFFSET-1)
 #else
diff -urN linux-2.5.69-bk7/include/asm-sparc/elf.h linux-2.5.69-bk8/include/asm-sparc/elf.h
--- linux-2.5.69-bk7/include/asm-sparc/elf.h	2003-05-04 16:53:37.000000000 -0700
+++ linux-2.5.69-bk8/include/asm-sparc/elf.h	2003-05-13 04:44:30.000000000 -0700
@@ -11,6 +11,63 @@
 #include <asm/mbus.h>
 #include <asm/uaccess.h>
 
+/*
+ * Sparc section types
+ */
+#define STT_REGISTER		13
+
+/*
+ * Sparc ELF relocation types
+ */
+#define	R_SPARC_NONE		0
+#define	R_SPARC_8		1
+#define	R_SPARC_16		2
+#define	R_SPARC_32		3
+#define	R_SPARC_DISP8		4
+#define	R_SPARC_DISP16		5
+#define	R_SPARC_DISP32		6
+#define	R_SPARC_WDISP30		7
+#define	R_SPARC_WDISP22		8
+#define	R_SPARC_HI22		9
+#define	R_SPARC_22		10
+#define	R_SPARC_13		11
+#define	R_SPARC_LO10		12
+#define	R_SPARC_GOT10		13
+#define	R_SPARC_GOT13		14
+#define	R_SPARC_GOT22		15
+#define	R_SPARC_PC10		16
+#define	R_SPARC_PC22		17
+#define	R_SPARC_WPLT30		18
+#define	R_SPARC_COPY		19
+#define	R_SPARC_GLOB_DAT	20
+#define	R_SPARC_JMP_SLOT	21
+#define	R_SPARC_RELATIVE	22
+#define	R_SPARC_UA32		23
+#define R_SPARC_PLT32		24
+#define R_SPARC_HIPLT22		25
+#define R_SPARC_LOPLT10		26
+#define R_SPARC_PCPLT32		27
+#define R_SPARC_PCPLT22		28
+#define R_SPARC_PCPLT10		29
+#define R_SPARC_10		30
+#define R_SPARC_11		31
+#define R_SPARC_64		32
+#define R_SPARC_OLO10		33
+#define R_SPARC_WDISP16		40
+#define R_SPARC_WDISP19		41
+#define R_SPARC_7		43
+#define R_SPARC_5		44
+#define R_SPARC_6		45
+
+/* Bits present in AT_HWCAP, primarily for Sparc32.  */
+
+#define HWCAP_SPARC_FLUSH       1    /* CPU supports flush instruction. */
+#define HWCAP_SPARC_STBAR       2
+#define HWCAP_SPARC_SWAP        4
+#define HWCAP_SPARC_MULDIV      8
+#define HWCAP_SPARC_V9		16
+#define HWCAP_SPARC_ULTRA3	32
+
 /* For the most part we present code dumps in the format
  * Solaris does.
  */
diff -urN linux-2.5.69-bk7/include/asm-sparc/hardirq.h linux-2.5.69-bk8/include/asm-sparc/hardirq.h
--- linux-2.5.69-bk7/include/asm-sparc/hardirq.h	2003-05-04 16:53:57.000000000 -0700
+++ linux-2.5.69-bk8/include/asm-sparc/hardirq.h	2003-05-13 04:44:30.000000000 -0700
@@ -9,7 +9,6 @@
 
 #include <linux/config.h>
 #include <linux/threads.h>
-#include <linux/brlock.h>
 #include <linux/spinlock.h>
 #include <linux/cache.h>
 
@@ -90,7 +89,7 @@
 #ifndef CONFIG_SMP
 #define irq_enter()             (preempt_count() += HARDIRQ_OFFSET)
 
-#if CONFIG_PREEMPT
+#ifdef CONFIG_PREEMPT
 # define in_atomic()	(preempt_count() != kernel_locked())
 # define IRQ_EXIT_OFFSET (HARDIRQ_OFFSET-1)
 #else
@@ -116,7 +115,7 @@
 #define irq_exit()		br_read_unlock(BR_GLOBALIRQ_LOCK)
 #endif
 
-#if CONFIG_PREEMPT
+#ifdef CONFIG_PREEMPT
 # define in_atomic()	(preempt_count() != kernel_locked())
 #else
 # define in_atomic()	(preempt_count() != 0)
diff -urN linux-2.5.69-bk7/include/asm-sparc64/elf.h linux-2.5.69-bk8/include/asm-sparc64/elf.h
--- linux-2.5.69-bk7/include/asm-sparc64/elf.h	2003-05-04 16:53:09.000000000 -0700
+++ linux-2.5.69-bk8/include/asm-sparc64/elf.h	2003-05-13 04:44:30.000000000 -0700
@@ -13,6 +13,63 @@
 #endif
 
 /*
+ * Sparc section types
+ */
+#define STT_REGISTER		13
+
+/*
+ * Sparc ELF relocation types
+ */
+#define	R_SPARC_NONE		0
+#define	R_SPARC_8		1
+#define	R_SPARC_16		2
+#define	R_SPARC_32		3
+#define	R_SPARC_DISP8		4
+#define	R_SPARC_DISP16		5
+#define	R_SPARC_DISP32		6
+#define	R_SPARC_WDISP30		7
+#define	R_SPARC_WDISP22		8
+#define	R_SPARC_HI22		9
+#define	R_SPARC_22		10
+#define	R_SPARC_13		11
+#define	R_SPARC_LO10		12
+#define	R_SPARC_GOT10		13
+#define	R_SPARC_GOT13		14
+#define	R_SPARC_GOT22		15
+#define	R_SPARC_PC10		16
+#define	R_SPARC_PC22		17
+#define	R_SPARC_WPLT30		18
+#define	R_SPARC_COPY		19
+#define	R_SPARC_GLOB_DAT	20
+#define	R_SPARC_JMP_SLOT	21
+#define	R_SPARC_RELATIVE	22
+#define	R_SPARC_UA32		23
+#define R_SPARC_PLT32		24
+#define R_SPARC_HIPLT22		25
+#define R_SPARC_LOPLT10		26
+#define R_SPARC_PCPLT32		27
+#define R_SPARC_PCPLT22		28
+#define R_SPARC_PCPLT10		29
+#define R_SPARC_10		30
+#define R_SPARC_11		31
+#define R_SPARC_64		32
+#define R_SPARC_OLO10		33
+#define R_SPARC_WDISP16		40
+#define R_SPARC_WDISP19		41
+#define R_SPARC_7		43
+#define R_SPARC_5		44
+#define R_SPARC_6		45
+
+/* Bits present in AT_HWCAP, primarily for Sparc32.  */
+
+#define HWCAP_SPARC_FLUSH       1    /* CPU supports flush instruction. */
+#define HWCAP_SPARC_STBAR       2
+#define HWCAP_SPARC_SWAP        4
+#define HWCAP_SPARC_MULDIV      8
+#define HWCAP_SPARC_V9		16
+#define HWCAP_SPARC_ULTRA3	32
+
+/*
  * These are used to set parameters in the core dumps.
  */
 #ifndef ELF_ARCH
diff -urN linux-2.5.69-bk7/include/asm-sparc64/hardirq.h linux-2.5.69-bk8/include/asm-sparc64/hardirq.h
--- linux-2.5.69-bk7/include/asm-sparc64/hardirq.h	2003-05-04 16:53:35.000000000 -0700
+++ linux-2.5.69-bk8/include/asm-sparc64/hardirq.h	2003-05-13 04:44:30.000000000 -0700
@@ -8,7 +8,6 @@
 
 #include <linux/config.h>
 #include <linux/threads.h>
-#include <linux/brlock.h>
 #include <linux/spinlock.h>
 #include <linux/cache.h>
 
@@ -85,7 +84,7 @@
 
 #define irq_enter()		(preempt_count() += HARDIRQ_OFFSET)
 
-#if CONFIG_PREEMPT
+#ifdef CONFIG_PREEMPT
 # define in_atomic()	(preempt_count() != kernel_locked())
 # define IRQ_EXIT_OFFSET (HARDIRQ_OFFSET-1)
 #else
diff -urN linux-2.5.69-bk7/include/asm-um/pgtable.h linux-2.5.69-bk8/include/asm-um/pgtable.h
--- linux-2.5.69-bk7/include/asm-um/pgtable.h	2003-05-04 16:53:57.000000000 -0700
+++ linux-2.5.69-bk8/include/asm-um/pgtable.h	2003-05-13 04:44:30.000000000 -0700
@@ -71,7 +71,7 @@
 #define VMALLOC_START	(((unsigned long) high_physmem + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
 #define VMALLOC_VMADDR(x) ((unsigned long)(x))
 
-#if CONFIG_HIGHMEM
+#ifdef CONFIG_HIGHMEM
 # define VMALLOC_END	(PKMAP_BASE-2*PAGE_SIZE)
 #else
 # define VMALLOC_END	(FIXADDR_START-2*PAGE_SIZE)
diff -urN linux-2.5.69-bk7/include/asm-v850/hardirq.h linux-2.5.69-bk8/include/asm-v850/hardirq.h
--- linux-2.5.69-bk7/include/asm-v850/hardirq.h	2003-05-04 16:53:02.000000000 -0700
+++ linux-2.5.69-bk8/include/asm-v850/hardirq.h	2003-05-13 04:44:30.000000000 -0700
@@ -72,7 +72,7 @@
 
 #define irq_enter()		(preempt_count() += HARDIRQ_OFFSET)
 
-#if CONFIG_PREEMPT
+#ifdef CONFIG_PREEMPT
 # define in_atomic()    (preempt_count() != kernel_locked())
 # define IRQ_EXIT_OFFSET (HARDIRQ_OFFSET-1)
 #else
diff -urN linux-2.5.69-bk7/include/asm-x86_64/elf.h linux-2.5.69-bk8/include/asm-x86_64/elf.h
--- linux-2.5.69-bk7/include/asm-x86_64/elf.h	2003-05-04 16:53:37.000000000 -0700
+++ linux-2.5.69-bk8/include/asm-x86_64/elf.h	2003-05-13 04:44:30.000000000 -0700
@@ -9,6 +9,27 @@
 #include <asm/user.h>
 #include <asm/processor.h>
 
+/* x86-64 relocation types */
+#define R_X86_64_NONE		0	/* No reloc */
+#define R_X86_64_64		1	/* Direct 64 bit  */
+#define R_X86_64_PC32		2	/* PC relative 32 bit signed */
+#define R_X86_64_GOT32		3	/* 32 bit GOT entry */
+#define R_X86_64_PLT32		4	/* 32 bit PLT address */
+#define R_X86_64_COPY		5	/* Copy symbol at runtime */
+#define R_X86_64_GLOB_DAT	6	/* Create GOT entry */
+#define R_X86_64_JUMP_SLOT	7	/* Create PLT entry */
+#define R_X86_64_RELATIVE	8	/* Adjust by program base */
+#define R_X86_64_GOTPCREL	9	/* 32 bit signed pc relative
+					   offset to GOT */
+#define R_X86_64_32		10	/* Direct 32 bit zero extended */
+#define R_X86_64_32S		11	/* Direct 32 bit sign extended */
+#define R_X86_64_16		12	/* Direct 16 bit zero extended */
+#define R_X86_64_PC16		13	/* 16 bit sign extended pc relative */
+#define R_X86_64_8		14	/* Direct 8 bit sign extended  */
+#define R_X86_64_PC8		15	/* 8 bit sign extended pc relative */
+
+#define R_X86_64_NUM		16
+
 typedef unsigned long elf_greg_t;
 
 #define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t))
diff -urN linux-2.5.69-bk7/include/asm-x86_64/hardirq.h linux-2.5.69-bk8/include/asm-x86_64/hardirq.h
--- linux-2.5.69-bk7/include/asm-x86_64/hardirq.h	2003-05-04 16:53:07.000000000 -0700
+++ linux-2.5.69-bk8/include/asm-x86_64/hardirq.h	2003-05-13 04:44:30.000000000 -0700
@@ -81,7 +81,7 @@
 #define nmi_exit()		(preempt_count() -= HARDIRQ_OFFSET)
 
 
-#if CONFIG_PREEMPT
+#ifdef CONFIG_PREEMPT
 # define in_atomic()   ((preempt_count() & ~PREEMPT_ACTIVE) != kernel_locked())
 # define IRQ_EXIT_OFFSET (HARDIRQ_OFFSET-1)
 #else
diff -urN linux-2.5.69-bk7/include/linux/blkdev.h linux-2.5.69-bk8/include/linux/blkdev.h
--- linux-2.5.69-bk7/include/linux/blkdev.h	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/include/linux/blkdev.h	2003-05-13 04:44:30.000000000 -0700
@@ -304,7 +304,7 @@
 #define BLK_BOUNCE_ANY		((u64)blk_max_pfn << PAGE_SHIFT)
 #define BLK_BOUNCE_ISA		(ISA_DMA_THRESHOLD)
 
-#if CONFIG_MMU
+#ifdef CONFIG_MMU
 extern int init_emergency_isa_pool(void);
 extern void blk_queue_bounce(request_queue_t *q, struct bio **bio);
 #else
diff -urN linux-2.5.69-bk7/include/linux/brlock.h linux-2.5.69-bk8/include/linux/brlock.h
--- linux-2.5.69-bk7/include/linux/brlock.h	2003-05-04 16:53:12.000000000 -0700
+++ linux-2.5.69-bk8/include/linux/brlock.h	1969-12-31 16:00:00.000000000 -0800
@@ -1,222 +0,0 @@
-#ifndef __LINUX_BRLOCK_H
-#define __LINUX_BRLOCK_H
-
-/*
- * 'Big Reader' read-write spinlocks.
- *
- * super-fast read/write locks, with write-side penalty. The point
- * is to have a per-CPU read/write lock. Readers lock their CPU-local
- * readlock, writers must lock all locks to get write access. These
- * CPU-read-write locks are semantically identical to normal rwlocks.
- * Memory usage is higher as well. (NR_CPUS*L1_CACHE_BYTES bytes)
- *
- * The most important feature is that these spinlocks do not cause
- * cacheline ping-pong in the 'most readonly data' case.
- *
- * Copyright 2000, Ingo Molnar <mingo@redhat.com>
- *
- * Registry idea and naming [ crutial! :-) ] by:
- *
- *                 David S. Miller <davem@redhat.com>
- *
- * David has an implementation that doesn't use atomic operations in
- * the read branch via memory ordering tricks - i guess we need to
- * split this up into a per-arch thing? The atomicity issue is a
- * secondary item in profiles, at least on x86 platforms.
- *
- * The atomic op version overhead is indeed a big deal on
- * load-locked/store-conditional cpus (ALPHA/MIPS/PPC) and
- * compare-and-swap cpus (Sparc64).  So we control which
- * implementation to use with a __BRLOCK_USE_ATOMICS define. -DaveM
- *
- */
-
-/* Register bigreader lock indices here. */
-enum brlock_indices {
-	BR_NETPROTO_LOCK,
-	__BR_END
-};
-
-#include <linux/config.h>
-
-#ifdef CONFIG_SMP
-
-#include <linux/cache.h>
-#include <linux/spinlock.h>
-
-#if defined(__i386__) || defined(__ia64__) || defined(__x86_64__)
-#define __BRLOCK_USE_ATOMICS
-#else
-#undef __BRLOCK_USE_ATOMICS
-#endif
-
-#ifdef __BRLOCK_USE_ATOMICS
-typedef rwlock_t	brlock_read_lock_t;
-#else
-typedef unsigned int	brlock_read_lock_t;
-#endif
-
-/*
- * align last allocated index to the next cacheline:
- */
-#define __BR_IDX_MAX \
-	(((sizeof(brlock_read_lock_t)*__BR_END + SMP_CACHE_BYTES-1) & ~(SMP_CACHE_BYTES-1)) / sizeof(brlock_read_lock_t))
-
-extern brlock_read_lock_t __brlock_array[NR_CPUS][__BR_IDX_MAX];
-
-#ifndef __BRLOCK_USE_ATOMICS
-struct br_wrlock {
-	spinlock_t lock;
-} __attribute__ ((__aligned__(SMP_CACHE_BYTES)));
-
-extern struct br_wrlock __br_write_locks[__BR_IDX_MAX];
-#endif
-
-extern void __br_lock_usage_bug (void);
-
-#ifdef __BRLOCK_USE_ATOMICS
-
-static inline void br_read_lock (enum brlock_indices idx)
-{
-	/*
-	 * This causes a link-time bug message if an
-	 * invalid index is used:
-	 */
-	if (idx >= __BR_END)
-		__br_lock_usage_bug();
-
-	preempt_disable();
-	_raw_read_lock(&__brlock_array[smp_processor_id()][idx]);
-}
-
-static inline void br_read_unlock (enum brlock_indices idx)
-{
-	if (idx >= __BR_END)
-		__br_lock_usage_bug();
-
-	read_unlock(&__brlock_array[smp_processor_id()][idx]);
-}
-
-#else /* ! __BRLOCK_USE_ATOMICS */
-static inline void br_read_lock (enum brlock_indices idx)
-{
-	unsigned int *ctr;
-	spinlock_t *lock;
-
-	/*
-	 * This causes a link-time bug message if an
-	 * invalid index is used:
-	 */
-	if (idx >= __BR_END)
-		__br_lock_usage_bug();
-
-	preempt_disable();
-	ctr = &__brlock_array[smp_processor_id()][idx];
-	lock = &__br_write_locks[idx].lock;
-again:
-	(*ctr)++;
-	mb();
-	if (spin_is_locked(lock)) {
-		(*ctr)--;
-		wmb(); /*
-			* The release of the ctr must become visible
-			* to the other cpus eventually thus wmb(),
-			* we don't care if spin_is_locked is reordered
-			* before the releasing of the ctr.
-			* However IMHO this wmb() is superflous even in theory.
-			* It would not be superflous only if on the
-			* other CPUs doing a ldl_l instead of an ldl
-			* would make a difference and I don't think this is
-			* the case.
-			* I'd like to clarify this issue further
-			* but for now this is a slow path so adding the
-			* wmb() will keep us on the safe side.
-			*/
-		while (spin_is_locked(lock))
-			barrier();
-		goto again;
-	}
-}
-
-static inline void br_read_unlock (enum brlock_indices idx)
-{
-	unsigned int *ctr;
-
-	if (idx >= __BR_END)
-		__br_lock_usage_bug();
-
-	ctr = &__brlock_array[smp_processor_id()][idx];
-
-	wmb();
-	(*ctr)--;
-	preempt_enable();
-}
-#endif /* __BRLOCK_USE_ATOMICS */
-
-/* write path not inlined - it's rare and larger */
-
-extern void FASTCALL(__br_write_lock (enum brlock_indices idx));
-extern void FASTCALL(__br_write_unlock (enum brlock_indices idx));
-
-static inline void br_write_lock (enum brlock_indices idx)
-{
-	if (idx >= __BR_END)
-		__br_lock_usage_bug();
-	__br_write_lock(idx);
-}
-
-static inline void br_write_unlock (enum brlock_indices idx)
-{
-	if (idx >= __BR_END)
-		__br_lock_usage_bug();
-	__br_write_unlock(idx);
-}
-
-#else
-# define br_read_lock(idx)	({ (void)(idx); preempt_disable(); })
-# define br_read_unlock(idx)	({ (void)(idx); preempt_enable(); })
-# define br_write_lock(idx)	({ (void)(idx); preempt_disable(); })
-# define br_write_unlock(idx)	({ (void)(idx); preempt_enable(); })
-#endif	/* CONFIG_SMP */
-
-/*
- * Now enumerate all of the possible sw/hw IRQ protected
- * versions of the interfaces.
- */
-#define br_read_lock_irqsave(idx, flags) \
-	do { local_irq_save(flags); br_read_lock(idx); } while (0)
-
-#define br_read_lock_irq(idx) \
-	do { local_irq_disable(); br_read_lock(idx); } while (0)
-
-#define br_read_lock_bh(idx) \
-	do { local_bh_disable(); br_read_lock(idx); } while (0)
-
-#define br_write_lock_irqsave(idx, flags) \
-	do { local_irq_save(flags); br_write_lock(idx); } while (0)
-
-#define br_write_lock_irq(idx) \
-	do { local_irq_disable(); br_write_lock(idx); } while (0)
-
-#define br_write_lock_bh(idx) \
-	do { local_bh_disable(); br_write_lock(idx); } while (0)
-
-#define br_read_unlock_irqrestore(idx, flags) \
-	do { br_read_unlock(irx); local_irq_restore(flags); } while (0)
-
-#define br_read_unlock_irq(idx) \
-	do { br_read_unlock(idx); local_irq_enable(); } while (0)
-
-#define br_read_unlock_bh(idx) \
-	do { br_read_unlock(idx); local_bh_enable(); } while (0)
-
-#define br_write_unlock_irqrestore(idx, flags) \
-	do { br_write_unlock(irx); local_irq_restore(flags); } while (0)
-
-#define br_write_unlock_irq(idx) \
-	do { br_write_unlock(idx); local_irq_enable(); } while (0)
-
-#define br_write_unlock_bh(idx) \
-	do { br_write_unlock(idx); local_bh_enable(); } while (0)
-
-#endif /* __LINUX_BRLOCK_H */
diff -urN linux-2.5.69-bk7/include/linux/capability.h linux-2.5.69-bk8/include/linux/capability.h
--- linux-2.5.69-bk7/include/linux/capability.h	2003-05-04 16:53:08.000000000 -0700
+++ linux-2.5.69-bk8/include/linux/capability.h	2003-05-13 04:44:30.000000000 -0700
@@ -14,6 +14,7 @@
 #define _LINUX_CAPABILITY_H
 
 #include <linux/types.h>
+#include <linux/compiler.h>
 
 /* User-level do most of the mapping between kernel and user
    capabilities based on the version tag given by the kernel. The
@@ -31,13 +32,13 @@
 typedef struct __user_cap_header_struct {
 	__u32 version;
 	int pid;
-} *cap_user_header_t;
+} __user *cap_user_header_t;
  
 typedef struct __user_cap_data_struct {
         __u32 effective;
         __u32 permitted;
         __u32 inheritable;
-} *cap_user_data_t;
+} __user *cap_user_data_t;
   
 #ifdef __KERNEL__
 
diff -urN linux-2.5.69-bk7/include/linux/cpufreq.h linux-2.5.69-bk8/include/linux/cpufreq.h
--- linux-2.5.69-bk7/include/linux/cpufreq.h	2003-05-04 16:53:32.000000000 -0700
+++ linux-2.5.69-bk8/include/linux/cpufreq.h	2003-05-13 04:44:30.000000000 -0700
@@ -311,4 +311,7 @@
 
 #endif /* CONFIG_CPU_FREQ_TABLE */
 
+/* Currently exported only for the proc interface, remove when that goes */
+extern struct cpufreq_driver *cpufreq_driver;
+
 #endif /* _LINUX_CPUFREQ_H */
diff -urN linux-2.5.69-bk7/include/linux/devfs_fs_kernel.h linux-2.5.69-bk8/include/linux/devfs_fs_kernel.h
--- linux-2.5.69-bk7/include/linux/devfs_fs_kernel.h	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/include/linux/devfs_fs_kernel.h	2003-05-13 04:44:30.000000000 -0700
@@ -11,20 +11,7 @@
 
 #define DEVFS_SUPER_MAGIC                0x1373
 
-#define DEVFS_FL_NONE           0x000 /* This helps to make code more readable
-				         no, it doesn't  --hch */
-#define DEVFS_FL_DEFAULT        DEVFS_FL_NONE
-
-
-typedef struct devfs_entry * devfs_handle_t;
-
-struct gendisk;
-
 #ifdef CONFIG_DEVFS_FS
-extern devfs_handle_t devfs_register (devfs_handle_t dir, const char *name,
-				      unsigned int flags,
-				      unsigned int major, unsigned int minor,
-				      umode_t mode, void *ops, void *info);
 extern int devfs_mk_bdev(dev_t dev, umode_t mode, const char *fmt, ...)
 	__attribute__((format (printf, 3, 4)));
 extern int devfs_mk_cdev(dev_t dev, umode_t mode, const char *fmt, ...)
@@ -36,19 +23,8 @@
 	__attribute__((format (printf, 1, 2)));
 extern int devfs_register_tape(const char *name);
 extern void devfs_unregister_tape(int num);
-extern void devfs_register_partition(struct gendisk *dev, int part);
 extern void mount_devfs_fs(void);
 #else  /*  CONFIG_DEVFS_FS  */
-static inline devfs_handle_t devfs_register (devfs_handle_t dir,
-					     const char *name,
-					     unsigned int flags,
-					     unsigned int major,
-					     unsigned int minor,
-					     umode_t mode,
-					     void *ops, void *info)
-{
-    return NULL;
-}
 static inline int devfs_mk_bdev(dev_t dev, umode_t mode, const char *fmt, ...)
 {
 	return 0;
@@ -75,9 +51,6 @@
 static inline void devfs_unregister_tape(int num)
 {
 }
-static inline void devfs_register_partition(struct gendisk *dev, int part)
-{
-}
 static inline void mount_devfs_fs (void)
 {
     return;
diff -urN linux-2.5.69-bk7/include/linux/elf.h linux-2.5.69-bk8/include/linux/elf.h
--- linux-2.5.69-bk7/include/linux/elf.h	2003-05-04 16:53:02.000000000 -0700
+++ linux-2.5.69-bk8/include/linux/elf.h	2003-05-13 04:44:30.000000000 -0700
@@ -34,13 +34,6 @@
 #define PT_LOPROC  0x70000000
 #define PT_HIPROC  0x7fffffff
 #define PT_GNU_EH_FRAME		0x6474e550
-#define PT_MIPS_REGINFO		0x70000000
-
-/* Flags in the e_flags field of the header */
-#define EF_MIPS_NOREORDER 0x00000001
-#define EF_MIPS_PIC       0x00000002
-#define EF_MIPS_CPIC      0x00000004
-#define EF_MIPS_ARCH      0xf0000000
 
 /* These constants define the different elf file types */
 #define ET_NONE   0
@@ -130,25 +123,6 @@
 #define DT_JMPREL	23
 #define DT_LOPROC	0x70000000
 #define DT_HIPROC	0x7fffffff
-#define DT_MIPS_RLD_VERSION	0x70000001
-#define DT_MIPS_TIME_STAMP	0x70000002
-#define DT_MIPS_ICHECKSUM	0x70000003
-#define DT_MIPS_IVERSION	0x70000004
-#define DT_MIPS_FLAGS		0x70000005
-  #define RHF_NONE		  0
-  #define RHF_HARDWAY		  1
-  #define RHF_NOTPOT		  2
-#define DT_MIPS_BASE_ADDRESS	0x70000006
-#define DT_MIPS_CONFLICT	0x70000008
-#define DT_MIPS_LIBLIST		0x70000009
-#define DT_MIPS_LOCAL_GOTNO	0x7000000a
-#define DT_MIPS_CONFLICTNO	0x7000000b
-#define DT_MIPS_LIBLISTNO	0x70000010
-#define DT_MIPS_SYMTABNO	0x70000011
-#define DT_MIPS_UNREFEXTNO	0x70000012
-#define DT_MIPS_GOTSYM		0x70000013
-#define DT_MIPS_HIPAGENO	0x70000014
-#define DT_MIPS_RLD_MAP		0x70000016
 
 /* This info is needed when parsing the symbol table */
 #define STB_LOCAL  0
@@ -212,508 +186,6 @@
 #define ELF64_R_SYM(i)			((i) >> 32)
 #define ELF64_R_TYPE(i)			((i) & 0xffffffff)
 
-#define R_ARM_NONE	0
-#define R_ARM_PC24	1
-#define R_ARM_ABS32	2
-
-#define R_386_NONE	0
-#define R_386_32	1
-#define R_386_PC32	2
-#define R_386_GOT32	3
-#define R_386_PLT32	4
-#define R_386_COPY	5
-#define R_386_GLOB_DAT	6
-#define R_386_JMP_SLOT	7
-#define R_386_RELATIVE	8
-#define R_386_GOTOFF	9
-#define R_386_GOTPC	10
-#define R_386_NUM	11
-
-#define R_MIPS_NONE		0
-#define R_MIPS_16		1
-#define R_MIPS_32		2
-#define R_MIPS_REL32		3
-#define R_MIPS_26		4
-#define R_MIPS_HI16		5
-#define R_MIPS_LO16		6
-#define R_MIPS_GPREL16		7
-#define R_MIPS_LITERAL		8
-#define R_MIPS_GOT16		9
-#define R_MIPS_PC16		10
-#define R_MIPS_CALL16		11
-#define R_MIPS_GPREL32		12
-/* The remaining relocs are defined on Irix, although they are not
-   in the MIPS ELF ABI.  */
-#define R_MIPS_UNUSED1		13
-#define R_MIPS_UNUSED2		14
-#define R_MIPS_UNUSED3		15
-#define R_MIPS_SHIFT5		16
-#define R_MIPS_SHIFT6		17
-#define R_MIPS_64		18
-#define R_MIPS_GOT_DISP		19
-#define R_MIPS_GOT_PAGE		20
-#define R_MIPS_GOT_OFST		21
-/*
- * The following two relocation types are specified in the MIPS ABI
- * conformance guide version 1.2 but not yet in the psABI.
- */
-#define R_MIPS_GOTHI16		22
-#define R_MIPS_GOTLO16		23
-#define R_MIPS_SUB		24
-#define R_MIPS_INSERT_A		25
-#define R_MIPS_INSERT_B		26
-#define R_MIPS_DELETE		27
-#define R_MIPS_HIGHER		28
-#define R_MIPS_HIGHEST		29
-/*
- * The following two relocation types are specified in the MIPS ABI
- * conformance guide version 1.2 but not yet in the psABI.
- */
-#define R_MIPS_CALLHI16		30
-#define R_MIPS_CALLLO16		31
-/*
- * This range is reserved for vendor specific relocations.
- */
-#define R_MIPS_LOVENDOR		100
-#define R_MIPS_HIVENDOR		127
-
-/*
- * Sparc section types
- */
-#define STT_REGISTER		13
-
-/*
- * Sparc ELF relocation types
- */
-#define	R_SPARC_NONE		0
-#define	R_SPARC_8		1
-#define	R_SPARC_16		2
-#define	R_SPARC_32		3
-#define	R_SPARC_DISP8		4
-#define	R_SPARC_DISP16		5
-#define	R_SPARC_DISP32		6
-#define	R_SPARC_WDISP30		7
-#define	R_SPARC_WDISP22		8
-#define	R_SPARC_HI22		9
-#define	R_SPARC_22		10
-#define	R_SPARC_13		11
-#define	R_SPARC_LO10		12
-#define	R_SPARC_GOT10		13
-#define	R_SPARC_GOT13		14
-#define	R_SPARC_GOT22		15
-#define	R_SPARC_PC10		16
-#define	R_SPARC_PC22		17
-#define	R_SPARC_WPLT30		18
-#define	R_SPARC_COPY		19
-#define	R_SPARC_GLOB_DAT	20
-#define	R_SPARC_JMP_SLOT	21
-#define	R_SPARC_RELATIVE	22
-#define	R_SPARC_UA32		23
-#define R_SPARC_PLT32		24
-#define R_SPARC_HIPLT22		25
-#define R_SPARC_LOPLT10		26
-#define R_SPARC_PCPLT32		27
-#define R_SPARC_PCPLT22		28
-#define R_SPARC_PCPLT10		29
-#define R_SPARC_10		30
-#define R_SPARC_11		31
-#define R_SPARC_64		32
-#define R_SPARC_OLO10		33
-#define R_SPARC_WDISP16		40
-#define R_SPARC_WDISP19		41
-#define R_SPARC_7		43
-#define R_SPARC_5		44
-#define R_SPARC_6		45
-
-/* Bits present in AT_HWCAP, primarily for Sparc32.  */
-
-#define HWCAP_SPARC_FLUSH       1    /* CPU supports flush instruction. */
-#define HWCAP_SPARC_STBAR       2
-#define HWCAP_SPARC_SWAP        4
-#define HWCAP_SPARC_MULDIV      8
-#define HWCAP_SPARC_V9		16
-#define HWCAP_SPARC_ULTRA3	32
-
-/*
- * 68k ELF relocation types
- */
-#define R_68K_NONE	0
-#define R_68K_32	1
-#define R_68K_16	2
-#define R_68K_8		3
-#define R_68K_PC32	4
-#define R_68K_PC16	5
-#define R_68K_PC8	6
-#define R_68K_GOT32	7
-#define R_68K_GOT16	8
-#define R_68K_GOT8	9
-#define R_68K_GOT32O	10
-#define R_68K_GOT16O	11
-#define R_68K_GOT8O	12
-#define R_68K_PLT32	13
-#define R_68K_PLT16	14
-#define R_68K_PLT8	15
-#define R_68K_PLT32O	16
-#define R_68K_PLT16O	17
-#define R_68K_PLT8O	18
-#define R_68K_COPY	19
-#define R_68K_GLOB_DAT	20
-#define R_68K_JMP_SLOT	21
-#define R_68K_RELATIVE	22
-
-/*
- * Alpha ELF relocation types
- */
-#define R_ALPHA_NONE            0       /* No reloc */
-#define R_ALPHA_REFLONG         1       /* Direct 32 bit */
-#define R_ALPHA_REFQUAD         2       /* Direct 64 bit */
-#define R_ALPHA_GPREL32         3       /* GP relative 32 bit */
-#define R_ALPHA_LITERAL         4       /* GP relative 16 bit w/optimization */
-#define R_ALPHA_LITUSE          5       /* Optimization hint for LITERAL */
-#define R_ALPHA_GPDISP          6       /* Add displacement to GP */
-#define R_ALPHA_BRADDR          7       /* PC+4 relative 23 bit shifted */
-#define R_ALPHA_HINT            8       /* PC+4 relative 16 bit shifted */
-#define R_ALPHA_SREL16          9       /* PC relative 16 bit */
-#define R_ALPHA_SREL32          10      /* PC relative 32 bit */
-#define R_ALPHA_SREL64          11      /* PC relative 64 bit */
-#define R_ALPHA_GPRELHIGH       17      /* GP relative 32 bit, high 16 bits */
-#define R_ALPHA_GPRELLOW        18      /* GP relative 32 bit, low 16 bits */
-#define R_ALPHA_GPREL16         19      /* GP relative 16 bit */
-#define R_ALPHA_COPY            24      /* Copy symbol at runtime */
-#define R_ALPHA_GLOB_DAT        25      /* Create GOT entry */
-#define R_ALPHA_JMP_SLOT        26      /* Create PLT entry */
-#define R_ALPHA_RELATIVE        27      /* Adjust by program base */
-#define R_ALPHA_BRSGP		28
-#define R_ALPHA_TLSGD           29
-#define R_ALPHA_TLS_LDM         30
-#define R_ALPHA_DTPMOD64        31
-#define R_ALPHA_GOTDTPREL       32
-#define R_ALPHA_DTPREL64        33
-#define R_ALPHA_DTPRELHI        34
-#define R_ALPHA_DTPRELLO        35
-#define R_ALPHA_DTPREL16        36
-#define R_ALPHA_GOTTPREL        37
-#define R_ALPHA_TPREL64         38
-#define R_ALPHA_TPRELHI         39
-#define R_ALPHA_TPRELLO         40
-#define R_ALPHA_TPREL16         41
-
-#define SHF_ALPHA_GPREL		0x10000000
-
-
-/* PowerPC relocations defined by the ABIs */
-#define R_PPC_NONE		0
-#define R_PPC_ADDR32		1	/* 32bit absolute address */
-#define R_PPC_ADDR24		2	/* 26bit address, 2 bits ignored.  */
-#define R_PPC_ADDR16		3	/* 16bit absolute address */
-#define R_PPC_ADDR16_LO		4	/* lower 16bit of absolute address */
-#define R_PPC_ADDR16_HI		5	/* high 16bit of absolute address */
-#define R_PPC_ADDR16_HA		6	/* adjusted high 16bit */
-#define R_PPC_ADDR14		7	/* 16bit address, 2 bits ignored */
-#define R_PPC_ADDR14_BRTAKEN	8
-#define R_PPC_ADDR14_BRNTAKEN	9
-#define R_PPC_REL24		10	/* PC relative 26 bit */
-#define R_PPC_REL14		11	/* PC relative 16 bit */
-#define R_PPC_REL14_BRTAKEN	12
-#define R_PPC_REL14_BRNTAKEN	13
-#define R_PPC_GOT16		14
-#define R_PPC_GOT16_LO		15
-#define R_PPC_GOT16_HI		16
-#define R_PPC_GOT16_HA		17
-#define R_PPC_PLTREL24		18
-#define R_PPC_COPY		19
-#define R_PPC_GLOB_DAT		20
-#define R_PPC_JMP_SLOT		21
-#define R_PPC_RELATIVE		22
-#define R_PPC_LOCAL24PC		23
-#define R_PPC_UADDR32		24
-#define R_PPC_UADDR16		25
-#define R_PPC_REL32		26
-#define R_PPC_PLT32		27
-#define R_PPC_PLTREL32		28
-#define R_PPC_PLT16_LO		29
-#define R_PPC_PLT16_HI		30
-#define R_PPC_PLT16_HA		31
-#define R_PPC_SDAREL16		32
-#define R_PPC_SECTOFF		33
-#define R_PPC_SECTOFF_LO	34
-#define R_PPC_SECTOFF_HI	35
-#define R_PPC_SECTOFF_HA	36
-/* Keep this the last entry.  */
-#define R_PPC_NUM		37
-
-/* s390 relocations defined by the ABIs */
-#define R_390_NONE		0	/* No reloc.  */
-#define R_390_8			1	/* Direct 8 bit.  */
-#define R_390_12		2	/* Direct 12 bit.  */
-#define R_390_16		3	/* Direct 16 bit.  */
-#define R_390_32		4	/* Direct 32 bit.  */
-#define R_390_PC32		5	/* PC relative 32 bit.	*/
-#define R_390_GOT12		6	/* 12 bit GOT offset.  */
-#define R_390_GOT32		7	/* 32 bit GOT offset.  */
-#define R_390_PLT32		8	/* 32 bit PC relative PLT address.  */
-#define R_390_COPY		9	/* Copy symbol at runtime.  */
-#define R_390_GLOB_DAT		10	/* Create GOT entry.  */
-#define R_390_JMP_SLOT		11	/* Create PLT entry.  */
-#define R_390_RELATIVE		12	/* Adjust by program base.  */
-#define R_390_GOTOFF32		13	/* 32 bit offset to GOT.	 */
-#define R_390_GOTPC		14	/* 32 bit PC rel. offset to GOT.  */
-#define R_390_GOT16		15	/* 16 bit GOT offset.  */
-#define R_390_PC16		16	/* PC relative 16 bit.	*/
-#define R_390_PC16DBL		17	/* PC relative 16 bit shifted by 1.  */
-#define R_390_PLT16DBL		18	/* 16 bit PC rel. PLT shifted by 1.  */
-#define R_390_PC32DBL		19	/* PC relative 32 bit shifted by 1.  */
-#define R_390_PLT32DBL		20	/* 32 bit PC rel. PLT shifted by 1.  */
-#define R_390_GOTPCDBL		21	/* 32 bit PC rel. GOT shifted by 1.  */
-#define R_390_64		22	/* Direct 64 bit.  */
-#define R_390_PC64		23	/* PC relative 64 bit.	*/
-#define R_390_GOT64		24	/* 64 bit GOT offset.  */
-#define R_390_PLT64		25	/* 64 bit PC relative PLT address.  */
-#define R_390_GOTENT		26	/* 32 bit PC rel. to GOT entry >> 1. */
-#define R_390_GOTOFF16		27	/* 16 bit offset to GOT. */
-#define R_390_GOTOFF64		28	/* 64 bit offset to GOT. */
-#define R_390_GOTPLT12		29	/* 12 bit offset to jump slot.	*/
-#define R_390_GOTPLT16		30	/* 16 bit offset to jump slot.	*/
-#define R_390_GOTPLT32		31	/* 32 bit offset to jump slot.	*/
-#define R_390_GOTPLT64		32	/* 64 bit offset to jump slot.	*/
-#define R_390_GOTPLTENT		33	/* 32 bit rel. offset to jump slot.  */
-#define R_390_PLTOFF16		34	/* 16 bit offset from GOT to PLT. */
-#define R_390_PLTOFF32		35	/* 32 bit offset from GOT to PLT. */
-#define R_390_PLTOFF64		36	/* 16 bit offset from GOT to PLT. */
-#define R_390_TLS_LOAD		37	/* Tag for load insn in TLS code. */
-#define R_390_TLS_GDCALL	38	/* Tag for function call in general
-                                           dynamic TLS code.  */
-#define R_390_TLS_LDCALL	39	/* Tag for function call in local
-                                           dynamic TLS code.  */
-#define R_390_TLS_GD32		40	/* Direct 32 bit for general dynamic
-                                           thread local data.  */
-#define R_390_TLS_GD64		41	/* Direct 64 bit for general dynamic
-                                           thread local data.  */
-#define R_390_TLS_GOTIE12	42	/* 12 bit GOT offset for static TLS
-                                           block offset.  */
-#define R_390_TLS_GOTIE32	43	/* 32 bit GOT offset for static TLS
-                                           block offset.  */
-#define R_390_TLS_GOTIE64	44	/* 64 bit GOT offset for static TLS
-                                           block offset.  */
-#define R_390_TLS_LDM32		45	/* Direct 32 bit for local dynamic
-                                           thread local data in LD code.  */
-#define R_390_TLS_LDM64		46	/* Direct 64 bit for local dynamic
-                                           thread local data in LD code.  */
-#define R_390_TLS_IE32		47	/* 32 bit address of GOT entry for
-                                           negated static TLS block offset.  */
-#define R_390_TLS_IE64		48	/* 64 bit address of GOT entry for
-                                           negated static TLS block offset.  */
-#define R_390_TLS_IEENT		49	/* 32 bit rel. offset to GOT entry for
-                                           negated static TLS block offset.  */
-#define R_390_TLS_LE32		50	/* 32 bit negated offset relative to
-                                           static TLS block.  */
-#define R_390_TLS_LE64		51	/* 64 bit negated offset relative to
-                                           static TLS block.  */
-#define R_390_TLS_LDO32		52	/* 32 bit offset relative to TLS
-                                           block.  */
-#define R_390_TLS_LDO64		53	/* 64 bit offset relative to TLS
-                                           block.  */
-#define R_390_TLS_DTPMOD	54	/* ID of module containing symbol.  */
-#define R_390_TLS_DTPOFF	55	/* Offset in TLS block.  */
-#define R_390_TLS_TPOFF		56	/* Negate offset in static TLS
-                                           block.  */
-/* Keep this the last entry.  */
-#define R_390_NUM	57
-
-/* x86-64 relocation types */
-#define R_X86_64_NONE		0	/* No reloc */
-#define R_X86_64_64		1	/* Direct 64 bit  */
-#define R_X86_64_PC32		2	/* PC relative 32 bit signed */
-#define R_X86_64_GOT32		3	/* 32 bit GOT entry */
-#define R_X86_64_PLT32		4	/* 32 bit PLT address */
-#define R_X86_64_COPY		5	/* Copy symbol at runtime */
-#define R_X86_64_GLOB_DAT	6	/* Create GOT entry */
-#define R_X86_64_JUMP_SLOT	7	/* Create PLT entry */
-#define R_X86_64_RELATIVE	8	/* Adjust by program base */
-#define R_X86_64_GOTPCREL	9	/* 32 bit signed pc relative
-					   offset to GOT */
-#define R_X86_64_32		10	/* Direct 32 bit zero extended */
-#define R_X86_64_32S		11	/* Direct 32 bit sign extended */
-#define R_X86_64_16		12	/* Direct 16 bit zero extended */
-#define R_X86_64_PC16		13	/* 16 bit sign extended pc relative */
-#define R_X86_64_8		14	/* Direct 8 bit sign extended  */
-#define R_X86_64_PC8		15	/* 8 bit sign extended pc relative */
-
-#define R_X86_64_NUM		16
-
-/* Legal values for e_flags field of Elf64_Ehdr.  */
-
-#define EF_ALPHA_32BIT		1	/* All addresses are below 2GB */
-
-/* HPPA specific definitions.  */
-
-/* Legal values for e_flags field of Elf32_Ehdr.  */
-
-#define EF_PARISC_TRAPNIL	0x00010000 /* Trap nil pointer dereference.  */
-#define EF_PARISC_EXT		0x00020000 /* Program uses arch. extensions. */
-#define EF_PARISC_LSB		0x00040000 /* Program expects little endian. */
-#define EF_PARISC_WIDE		0x00080000 /* Program expects wide mode.  */
-#define EF_PARISC_NO_KABP	0x00100000 /* No kernel assisted branch
-					      prediction.  */
-#define EF_PARISC_LAZYSWAP	0x00400000 /* Allow lazy swapping.  */
-#define EF_PARISC_ARCH		0x0000ffff /* Architecture version.  */
-
-/* Defined values for `e_flags & EF_PARISC_ARCH' are:  */
-
-#define EFA_PARISC_1_0		    0x020b /* PA-RISC 1.0 big-endian.  */
-#define EFA_PARISC_1_1		    0x0210 /* PA-RISC 1.1 big-endian.  */
-#define EFA_PARISC_2_0		    0x0214 /* PA-RISC 2.0 big-endian.  */
-
-/* Additional section indeces.  */
-
-#define SHN_PARISC_ANSI_COMMON	0xff00	   /* Section for tenatively declared
-					      symbols in ANSI C.  */
-#define SHN_PARISC_HUGE_COMMON	0xff01	   /* Common blocks in huge model.  */
-
-/* Legal values for sh_type field of Elf32_Shdr.  */
-
-#define SHT_PARISC_EXT		0x70000000 /* Contains product specific ext. */
-#define SHT_PARISC_UNWIND	0x70000001 /* Unwind information.  */
-#define SHT_PARISC_DOC		0x70000002 /* Debug info for optimized code. */
-
-/* Legal values for sh_flags field of Elf32_Shdr.  */
-
-#define SHF_PARISC_SHORT	0x20000000 /* Section with short addressing. */
-#define SHF_PARISC_HUGE		0x40000000 /* Section far from gp.  */
-#define SHF_PARISC_SBP		0x80000000 /* Static branch prediction code. */
-
-/* Legal values for ST_TYPE subfield of st_info (symbol type).  */
-
-#define STT_PARISC_MILLICODE	13	/* Millicode function entry point.  */
-
-#define STT_HP_OPAQUE		(STT_LOOS + 0x1)
-#define STT_HP_STUB		(STT_LOOS + 0x2)
-
-/* HPPA relocs.  */
-
-#define R_PARISC_NONE		0	/* No reloc.  */
-#define R_PARISC_DIR32		1	/* Direct 32-bit reference.  */
-#define R_PARISC_DIR21L		2	/* Left 21 bits of eff. address.  */
-#define R_PARISC_DIR17R		3	/* Right 17 bits of eff. address.  */
-#define R_PARISC_DIR17F		4	/* 17 bits of eff. address.  */
-#define R_PARISC_DIR14R		6	/* Right 14 bits of eff. address.  */
-#define R_PARISC_PCREL32	9	/* 32-bit rel. address.  */
-#define R_PARISC_PCREL21L	10	/* Left 21 bits of rel. address.  */
-#define R_PARISC_PCREL17R	11	/* Right 17 bits of rel. address.  */
-#define R_PARISC_PCREL17F	12	/* 17 bits of rel. address.  */
-#define R_PARISC_PCREL14R	14	/* Right 14 bits of rel. address.  */
-#define R_PARISC_DPREL21L	18	/* Left 21 bits of rel. address.  */
-#define R_PARISC_DPREL14R	22	/* Right 14 bits of rel. address.  */
-#define R_PARISC_GPREL21L	26	/* GP-relative, left 21 bits.  */
-#define R_PARISC_GPREL14R	30	/* GP-relative, right 14 bits.  */
-#define R_PARISC_LTOFF21L	34	/* LT-relative, left 21 bits.  */
-#define R_PARISC_LTOFF14R	38	/* LT-relative, right 14 bits.  */
-#define R_PARISC_SECREL32	41	/* 32 bits section rel. address.  */
-#define R_PARISC_SEGBASE	48	/* No relocation, set segment base.  */
-#define R_PARISC_SEGREL32	49	/* 32 bits segment rel. address.  */
-#define R_PARISC_PLTOFF21L	50	/* PLT rel. address, left 21 bits.  */
-#define R_PARISC_PLTOFF14R	54	/* PLT rel. address, right 14 bits.  */
-#define R_PARISC_LTOFF_FPTR32	57	/* 32 bits LT-rel. function pointer. */
-#define R_PARISC_LTOFF_FPTR21L	58	/* LT-rel. fct ptr, left 21 bits. */
-#define R_PARISC_LTOFF_FPTR14R	62	/* LT-rel. fct ptr, right 14 bits. */
-#define R_PARISC_FPTR64		64	/* 64 bits function address.  */
-#define R_PARISC_PLABEL32	65	/* 32 bits function address.  */
-#define R_PARISC_PCREL64	72	/* 64 bits PC-rel. address.  */
-#define R_PARISC_PCREL22F	74	/* 22 bits PC-rel. address.  */
-#define R_PARISC_PCREL14WR	75	/* PC-rel. address, right 14 bits.  */
-#define R_PARISC_PCREL14DR	76	/* PC rel. address, right 14 bits.  */
-#define R_PARISC_PCREL16F	77	/* 16 bits PC-rel. address.  */
-#define R_PARISC_PCREL16WF	78	/* 16 bits PC-rel. address.  */
-#define R_PARISC_PCREL16DF	79	/* 16 bits PC-rel. address.  */
-#define R_PARISC_DIR64		80	/* 64 bits of eff. address.  */
-#define R_PARISC_DIR14WR	83	/* 14 bits of eff. address.  */
-#define R_PARISC_DIR14DR	84	/* 14 bits of eff. address.  */
-#define R_PARISC_DIR16F		85	/* 16 bits of eff. address.  */
-#define R_PARISC_DIR16WF	86	/* 16 bits of eff. address.  */
-#define R_PARISC_DIR16DF	87	/* 16 bits of eff. address.  */
-#define R_PARISC_GPREL64	88	/* 64 bits of GP-rel. address.  */
-#define R_PARISC_GPREL14WR	91	/* GP-rel. address, right 14 bits.  */
-#define R_PARISC_GPREL14DR	92	/* GP-rel. address, right 14 bits.  */
-#define R_PARISC_GPREL16F	93	/* 16 bits GP-rel. address.  */
-#define R_PARISC_GPREL16WF	94	/* 16 bits GP-rel. address.  */
-#define R_PARISC_GPREL16DF	95	/* 16 bits GP-rel. address.  */
-#define R_PARISC_LTOFF64	96	/* 64 bits LT-rel. address.  */
-#define R_PARISC_LTOFF14WR	99	/* LT-rel. address, right 14 bits.  */
-#define R_PARISC_LTOFF14DR	100	/* LT-rel. address, right 14 bits.  */
-#define R_PARISC_LTOFF16F	101	/* 16 bits LT-rel. address.  */
-#define R_PARISC_LTOFF16WF	102	/* 16 bits LT-rel. address.  */
-#define R_PARISC_LTOFF16DF	103	/* 16 bits LT-rel. address.  */
-#define R_PARISC_SECREL64	104	/* 64 bits section rel. address.  */
-#define R_PARISC_SEGREL64	112	/* 64 bits segment rel. address.  */
-#define R_PARISC_PLTOFF14WR	115	/* PLT-rel. address, right 14 bits.  */
-#define R_PARISC_PLTOFF14DR	116	/* PLT-rel. address, right 14 bits.  */
-#define R_PARISC_PLTOFF16F	117	/* 16 bits LT-rel. address.  */
-#define R_PARISC_PLTOFF16WF	118	/* 16 bits PLT-rel. address.  */
-#define R_PARISC_PLTOFF16DF	119	/* 16 bits PLT-rel. address.  */
-#define R_PARISC_LTOFF_FPTR64	120	/* 64 bits LT-rel. function ptr.  */
-#define R_PARISC_LTOFF_FPTR14WR	123	/* LT-rel. fct. ptr., right 14 bits. */
-#define R_PARISC_LTOFF_FPTR14DR	124	/* LT-rel. fct. ptr., right 14 bits. */
-#define R_PARISC_LTOFF_FPTR16F	125	/* 16 bits LT-rel. function ptr.  */
-#define R_PARISC_LTOFF_FPTR16WF	126	/* 16 bits LT-rel. function ptr.  */
-#define R_PARISC_LTOFF_FPTR16DF	127	/* 16 bits LT-rel. function ptr.  */
-#define R_PARISC_LORESERVE	128
-#define R_PARISC_COPY		128	/* Copy relocation.  */
-#define R_PARISC_IPLT		129	/* Dynamic reloc, imported PLT */
-#define R_PARISC_EPLT		130	/* Dynamic reloc, exported PLT */
-#define R_PARISC_TPREL32	153	/* 32 bits TP-rel. address.  */
-#define R_PARISC_TPREL21L	154	/* TP-rel. address, left 21 bits.  */
-#define R_PARISC_TPREL14R	158	/* TP-rel. address, right 14 bits.  */
-#define R_PARISC_LTOFF_TP21L	162	/* LT-TP-rel. address, left 21 bits. */
-#define R_PARISC_LTOFF_TP14R	166	/* LT-TP-rel. address, right 14 bits.*/
-#define R_PARISC_LTOFF_TP14F	167	/* 14 bits LT-TP-rel. address.  */
-#define R_PARISC_TPREL64	216	/* 64 bits TP-rel. address.  */
-#define R_PARISC_TPREL14WR	219	/* TP-rel. address, right 14 bits.  */
-#define R_PARISC_TPREL14DR	220	/* TP-rel. address, right 14 bits.  */
-#define R_PARISC_TPREL16F	221	/* 16 bits TP-rel. address.  */
-#define R_PARISC_TPREL16WF	222	/* 16 bits TP-rel. address.  */
-#define R_PARISC_TPREL16DF	223	/* 16 bits TP-rel. address.  */
-#define R_PARISC_LTOFF_TP64	224	/* 64 bits LT-TP-rel. address.  */
-#define R_PARISC_LTOFF_TP14WR	227	/* LT-TP-rel. address, right 14 bits.*/
-#define R_PARISC_LTOFF_TP14DR	228	/* LT-TP-rel. address, right 14 bits.*/
-#define R_PARISC_LTOFF_TP16F	229	/* 16 bits LT-TP-rel. address.  */
-#define R_PARISC_LTOFF_TP16WF	230	/* 16 bits LT-TP-rel. address.  */
-#define R_PARISC_LTOFF_TP16DF	231	/* 16 bits LT-TP-rel. address.  */
-#define R_PARISC_HIRESERVE	255
-
-/* Legal values for p_type field of Elf32_Phdr/Elf64_Phdr.  */
-
-#define PT_HP_TLS		(PT_LOOS + 0x0)
-#define PT_HP_CORE_NONE		(PT_LOOS + 0x1)
-#define PT_HP_CORE_VERSION	(PT_LOOS + 0x2)
-#define PT_HP_CORE_KERNEL	(PT_LOOS + 0x3)
-#define PT_HP_CORE_COMM		(PT_LOOS + 0x4)
-#define PT_HP_CORE_PROC		(PT_LOOS + 0x5)
-#define PT_HP_CORE_LOADABLE	(PT_LOOS + 0x6)
-#define PT_HP_CORE_STACK	(PT_LOOS + 0x7)
-#define PT_HP_CORE_SHM		(PT_LOOS + 0x8)
-#define PT_HP_CORE_MMF		(PT_LOOS + 0x9)
-#define PT_HP_PARALLEL		(PT_LOOS + 0x10)
-#define PT_HP_FASTBIND		(PT_LOOS + 0x11)
-#define PT_HP_OPT_ANNOT		(PT_LOOS + 0x12)
-#define PT_HP_HSL_ANNOT		(PT_LOOS + 0x13)
-#define PT_HP_STACK		(PT_LOOS + 0x14)
-
-#define PT_PARISC_ARCHEXT	0x70000000
-#define PT_PARISC_UNWIND	0x70000001
-
-/* Legal values for p_flags field of Elf32_Phdr/Elf64_Phdr.  */
-
-#define PF_PARISC_SBP		0x08000000
-
-#define PF_HP_PAGE_SIZE		0x00100000
-#define PF_HP_FAR_SHARED	0x00200000
-#define PF_HP_NEAR_SHARED	0x00400000
-#define PF_HP_CODE		0x01000000
-#define PF_HP_MODIFY		0x02000000
-#define PF_HP_LAZYSWAP		0x04000000
-#define PF_HP_SBP		0x08000000
-
-
 typedef struct elf32_rel {
   Elf32_Addr	r_offset;
   Elf32_Word	r_info;
@@ -837,17 +309,12 @@
 #define SHT_HIPROC	0x7fffffff
 #define SHT_LOUSER	0x80000000
 #define SHT_HIUSER	0xffffffff
-#define SHT_MIPS_LIST		0x70000000
-#define SHT_MIPS_CONFLICT	0x70000002
-#define SHT_MIPS_GPTAB		0x70000003
-#define SHT_MIPS_UCODE		0x70000004
 
 /* sh_flags */
 #define SHF_WRITE	0x1
 #define SHF_ALLOC	0x2
 #define SHF_EXECINSTR	0x4
 #define SHF_MASKPROC	0xf0000000
-#define SHF_MIPS_GPREL	0x10000000
 
 /* special section indexes */
 #define SHN_UNDEF	0
@@ -857,7 +324,6 @@
 #define SHN_ABS		0xfff1
 #define SHN_COMMON	0xfff2
 #define SHN_HIRESERVE	0xffff
-#define SHN_MIPS_ACCOMON	0xff00
  
 typedef struct {
   Elf32_Word	sh_name;
diff -urN linux-2.5.69-bk7/include/linux/ext3_fs.h linux-2.5.69-bk8/include/linux/ext3_fs.h
--- linux-2.5.69-bk7/include/linux/ext3_fs.h	2003-05-04 16:53:32.000000000 -0700
+++ linux-2.5.69-bk8/include/linux/ext3_fs.h	2003-05-13 04:44:30.000000000 -0700
@@ -625,6 +625,8 @@
 	u32		*seed;
 };
 
+#define EXT3_HTREE_EOF	0x7fffffff
+
 #ifdef __KERNEL__
 /*
  * Control parameters used by ext3_htree_next_block
diff -urN linux-2.5.69-bk7/include/linux/fs.h linux-2.5.69-bk8/include/linux/fs.h
--- linux-2.5.69-bk7/include/linux/fs.h	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/include/linux/fs.h	2003-05-13 04:44:30.000000000 -0700
@@ -691,7 +691,7 @@
 typedef struct {
 	size_t written;
 	size_t count;
-	char * buf;
+	char __user * buf;
 	int error;
 } read_descriptor_t;
 
@@ -722,7 +722,7 @@
 	int (*lock) (struct file *, int, struct file_lock *);
 	ssize_t (*readv) (struct file *, const struct iovec *, unsigned long, loff_t *);
 	ssize_t (*writev) (struct file *, const struct iovec *, unsigned long, loff_t *);
-	ssize_t (*sendfile) (struct file *, loff_t *, size_t, read_actor_t, void *);
+	ssize_t (*sendfile) (struct file *, loff_t *, size_t, read_actor_t, void __user *);
 	ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int);
 	unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
 };
@@ -1017,7 +1017,7 @@
 
 /* fs/open.c */
 
-asmlinkage long sys_open(const char *, int, int);
+asmlinkage long sys_open(const char __user *, int, int);
 asmlinkage long sys_close(unsigned int);	/* yes, it's really unsigned */
 extern int do_truncate(struct dentry *, loff_t start);
 
@@ -1207,15 +1207,15 @@
 int generic_write_checks(struct inode *inode, struct file *file,
 			loff_t *pos, size_t *count, int isblk);
 extern ssize_t generic_file_write(struct file *, const char __user *, size_t, loff_t *);
-extern ssize_t generic_file_aio_read(struct kiocb *, char *, size_t, loff_t);
-extern ssize_t generic_file_aio_write(struct kiocb *, const char *, size_t, loff_t);
+extern ssize_t generic_file_aio_read(struct kiocb *, char __user *, size_t, loff_t);
+extern ssize_t generic_file_aio_write(struct kiocb *, const char __user *, size_t, loff_t);
 extern ssize_t generic_file_aio_write_nolock(struct kiocb *, const struct iovec *,
 				unsigned long, loff_t *);
 extern ssize_t do_sync_read(struct file *filp, char __user *buf, size_t len, loff_t *ppos);
 extern ssize_t do_sync_write(struct file *filp, const char __user *buf, size_t len, loff_t *ppos);
 ssize_t generic_file_write_nolock(struct file *file, const struct iovec *iov,
 				unsigned long nr_segs, loff_t *ppos);
-extern ssize_t generic_file_sendfile(struct file *, loff_t *, size_t, read_actor_t, void *);
+extern ssize_t generic_file_sendfile(struct file *, loff_t *, size_t, read_actor_t, void __user *);
 extern void do_generic_mapping_read(struct address_space *, struct file_ra_state *, struct file *,
 				    loff_t *, read_descriptor_t *, read_actor_t);
 extern void
diff -urN linux-2.5.69-bk7/include/linux/futex.h linux-2.5.69-bk8/include/linux/futex.h
--- linux-2.5.69-bk7/include/linux/futex.h	2003-05-04 16:53:33.000000000 -0700
+++ linux-2.5.69-bk8/include/linux/futex.h	2003-05-13 04:44:30.000000000 -0700
@@ -6,6 +6,6 @@
 #define FUTEX_WAKE (1)
 #define FUTEX_FD (2)
 
-extern asmlinkage long sys_futex(u32 *uaddr, int op, int val, struct timespec *utime);
+extern asmlinkage long sys_futex(u32 __user *uaddr, int op, int val, struct timespec __user *utime);
 
 #endif
diff -urN linux-2.5.69-bk7/include/linux/ipv6.h linux-2.5.69-bk8/include/linux/ipv6.h
--- linux-2.5.69-bk7/include/linux/ipv6.h	2003-05-04 16:53:35.000000000 -0700
+++ linux-2.5.69-bk8/include/linux/ipv6.h	2003-05-13 04:44:30.000000000 -0700
@@ -121,6 +121,7 @@
 #include <linux/icmpv6.h>
 #include <net/if_inet6.h>       /* struct ipv6_mc_socklist */
 #include <linux/tcp.h>
+#include <linux/udp.h>
 
 /* 
    This structure contains results of exthdrs parsing
@@ -178,6 +179,11 @@
 
 	struct ipv6_txoptions	*opt;
 	struct sk_buff		*pktoptions;
+	struct {
+		struct ipv6_txoptions *opt;
+		struct rt6_info	*rt;
+		struct flowi *fl;
+	} cork;
 };
 
 struct raw6_opt {
@@ -200,6 +206,7 @@
 	struct sock	  sk;
 	struct ipv6_pinfo *pinet6;
 	struct inet_opt   inet;
+	struct udp_opt	  udp;
 	struct ipv6_pinfo inet6;
 };
 
diff -urN linux-2.5.69-bk7/include/linux/mm.h linux-2.5.69-bk8/include/linux/mm.h
--- linux-2.5.69-bk7/include/linux/mm.h	2003-05-04 16:53:00.000000000 -0700
+++ linux-2.5.69-bk8/include/linux/mm.h	2003-05-13 04:44:30.000000000 -0700
@@ -23,8 +23,13 @@
 
 #include <asm/page.h>
 #include <asm/pgtable.h>
+#include <asm/processor.h>
 #include <asm/atomic.h>
 
+#ifndef MM_VM_SIZE
+#define MM_VM_SIZE(mm)	TASK_SIZE
+#endif
+
 /*
  * Linux kernel virtual memory manager primitives.
  * The idea being to have a "virtual" mm in the same way
diff -urN linux-2.5.69-bk7/include/linux/moduleloader.h linux-2.5.69-bk8/include/linux/moduleloader.h
--- linux-2.5.69-bk7/include/linux/moduleloader.h	2003-05-04 16:53:13.000000000 -0700
+++ linux-2.5.69-bk8/include/linux/moduleloader.h	2003-05-13 04:44:30.000000000 -0700
@@ -41,4 +41,7 @@
 		    const Elf_Shdr *sechdrs,
 		    struct module *mod);
 
+/* Any cleanup needed when module leaves. */
+void module_arch_cleanup(struct module *mod);
+
 #endif
diff -urN linux-2.5.69-bk7/include/linux/msdos_fs.h linux-2.5.69-bk8/include/linux/msdos_fs.h
--- linux-2.5.69-bk7/include/linux/msdos_fs.h	2003-05-04 16:53:37.000000000 -0700
+++ linux-2.5.69-bk8/include/linux/msdos_fs.h	2003-05-13 04:44:30.000000000 -0700
@@ -146,8 +146,7 @@
 	__u32   reserved1[120];	/* Nothing as far as I can tell */
 	__u32   signature2;	/* 0x61417272L */
 	__u32   free_clusters;	/* Free cluster count.  -1 if unknown */
-	__u32   next_cluster;	/* Most recently allocated cluster.
-				 * Unused under Linux. */
+	__u32   next_cluster;	/* Most recently allocated cluster */
 	__u32   reserved2[4];
 };
 
diff -urN linux-2.5.69-bk7/include/linux/net.h linux-2.5.69-bk8/include/linux/net.h
--- linux-2.5.69-bk7/include/linux/net.h	2003-05-04 16:53:13.000000000 -0700
+++ linux-2.5.69-bk8/include/linux/net.h	2003-05-13 04:44:30.000000000 -0700
@@ -96,18 +96,18 @@
 	struct module	*owner;
 	int		(*release)   (struct socket *sock);
 	int		(*bind)	     (struct socket *sock,
-				      struct sockaddr *umyaddr,
+				      struct sockaddr *myaddr,
 				      int sockaddr_len);
 	int		(*connect)   (struct socket *sock,
-				      struct sockaddr *uservaddr,
+				      struct sockaddr *vaddr,
 				      int sockaddr_len, int flags);
 	int		(*socketpair)(struct socket *sock1,
 				      struct socket *sock2);
 	int		(*accept)    (struct socket *sock,
 				      struct socket *newsock, int flags);
 	int		(*getname)   (struct socket *sock,
-				      struct sockaddr *uaddr,
-				      int *usockaddr_len, int peer);
+				      struct sockaddr *addr,
+				      int *sockaddr_len, int peer);
 	unsigned int	(*poll)	     (struct file *file, struct socket *sock,
 				      struct poll_table_struct *wait);
 	int		(*ioctl)     (struct socket *sock, unsigned int cmd,
@@ -115,9 +115,9 @@
 	int		(*listen)    (struct socket *sock, int len);
 	int		(*shutdown)  (struct socket *sock, int flags);
 	int		(*setsockopt)(struct socket *sock, int level,
-				      int optname, char *optval, int optlen);
+				      int optname, char __user *optval, int optlen);
 	int		(*getsockopt)(struct socket *sock, int level,
-				      int optname, char *optval, int *optlen);
+				      int optname, char __user *optval, int __user *optlen);
 	int		(*sendmsg)   (struct kiocb *iocb, struct socket *sock,
 				      struct msghdr *m, int total_len);
 	int		(*recvmsg)   (struct kiocb *iocb, struct socket *sock,
diff -urN linux-2.5.69-bk7/include/linux/netdevice.h linux-2.5.69-bk8/include/linux/netdevice.h
--- linux-2.5.69-bk7/include/linux/netdevice.h	2003-05-04 16:53:41.000000000 -0700
+++ linux-2.5.69-bk8/include/linux/netdevice.h	2003-05-13 04:44:30.000000000 -0700
@@ -456,7 +456,7 @@
 	int			(*func) (struct sk_buff *, struct net_device *,
 					 struct packet_type *);
 	void			*data;	/* Private to the packet type		*/
-	struct packet_type	*next;
+	struct list_head	list;
 };
 
 
@@ -472,6 +472,7 @@
 extern struct net_device    *dev_getbyhwaddr(unsigned short type, char *hwaddr);
 extern void		dev_add_pack(struct packet_type *pt);
 extern void		dev_remove_pack(struct packet_type *pt);
+extern void		__dev_remove_pack(struct packet_type *pt);
 extern int		dev_get(const char *name);
 extern struct net_device	*dev_get_by_flags(unsigned short flags,
 						  unsigned short mask);
diff -urN linux-2.5.69-bk7/include/linux/nfs_fs_sb.h linux-2.5.69-bk8/include/linux/nfs_fs_sb.h
--- linux-2.5.69-bk7/include/linux/nfs_fs_sb.h	2003-05-04 16:53:57.000000000 -0700
+++ linux-2.5.69-bk8/include/linux/nfs_fs_sb.h	2003-05-13 04:44:30.000000000 -0700
@@ -27,7 +27,7 @@
 	char *			hostname;	/* remote hostname */
 	struct nfs_fh		fh;
 	struct sockaddr_in	addr;
-#if CONFIG_NFS_V4
+#ifdef CONFIG_NFS_V4
 	/* Our own IP address, as a null-terminated string.
 	 * This is used to generate the clientid, and the callback address.
 	 */
diff -urN linux-2.5.69-bk7/include/linux/pagemap.h linux-2.5.69-bk8/include/linux/pagemap.h
--- linux-2.5.69-bk7/include/linux/pagemap.h	2003-05-04 16:52:49.000000000 -0700
+++ linux-2.5.69-bk8/include/linux/pagemap.h	2003-05-13 04:44:30.000000000 -0700
@@ -172,7 +172,7 @@
  * This assumes that two userspace pages are always sufficient.  That's
  * not true if PAGE_CACHE_SIZE > PAGE_SIZE.
  */
-static inline int fault_in_pages_writeable(char *uaddr, int size)
+static inline int fault_in_pages_writeable(char __user *uaddr, int size)
 {
 	int ret;
 
@@ -182,7 +182,7 @@
 	 */
 	ret = __put_user(0, uaddr);
 	if (ret == 0) {
-		char *end = uaddr + size - 1;
+		char __user *end = uaddr + size - 1;
 
 		/*
 		 * If the page was already mapped, this will get a cache miss
@@ -195,14 +195,14 @@
 	return ret;
 }
 
-static inline void fault_in_pages_readable(const char *uaddr, int size)
+static inline void fault_in_pages_readable(const char __user *uaddr, int size)
 {
 	volatile char c;
 	int ret;
 
 	ret = __get_user(c, (char *)uaddr);
 	if (ret == 0) {
-		const char *end = uaddr + size - 1;
+		const char __user *end = uaddr + size - 1;
 
 		if (((unsigned long)uaddr & PAGE_MASK) !=
 				((unsigned long)end & PAGE_MASK))
diff -urN linux-2.5.69-bk7/include/linux/proc_fs.h linux-2.5.69-bk8/include/linux/proc_fs.h
--- linux-2.5.69-bk7/include/linux/proc_fs.h	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/include/linux/proc_fs.h	2003-05-13 04:44:30.000000000 -0700
@@ -48,7 +48,7 @@
 
 typedef	int (read_proc_t)(char *page, char **start, off_t off,
 			  int count, int *eof, void *data);
-typedef	int (write_proc_t)(struct file *file, const char *buffer,
+typedef	int (write_proc_t)(struct file *file, const char __user *buffer,
 			   unsigned long count, void *data);
 typedef int (get_info_t)(char *, char **, off_t, int);
 
diff -urN linux-2.5.69-bk7/include/linux/ptrace.h linux-2.5.69-bk8/include/linux/ptrace.h
--- linux-2.5.69-bk7/include/linux/ptrace.h	2003-05-04 16:53:02.000000000 -0700
+++ linux-2.5.69-bk8/include/linux/ptrace.h	2003-05-13 04:44:30.000000000 -0700
@@ -69,8 +69,8 @@
 #include <linux/compiler.h>		/* For unlikely.  */
 #include <linux/sched.h>		/* For struct task_struct.  */
 
-extern int ptrace_readdata(struct task_struct *tsk, unsigned long src, char *dst, int len);
-extern int ptrace_writedata(struct task_struct *tsk, char * src, unsigned long dst, int len);
+extern int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst, int len);
+extern int ptrace_writedata(struct task_struct *tsk, char __user *src, unsigned long dst, int len);
 extern int ptrace_attach(struct task_struct *tsk);
 extern int ptrace_detach(struct task_struct *, unsigned int);
 extern void ptrace_disable(struct task_struct *);
diff -urN linux-2.5.69-bk7/include/linux/sched.h linux-2.5.69-bk8/include/linux/sched.h
--- linux-2.5.69-bk7/include/linux/sched.h	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/include/linux/sched.h	2003-05-13 04:44:30.000000000 -0700
@@ -371,8 +371,8 @@
 
 	wait_queue_head_t wait_chldexit;	/* for wait4() */
 	struct completion *vfork_done;		/* for vfork() */
-	int *set_child_tid;			/* CLONE_CHILD_SETTID */
-	int *clear_child_tid;			/* CLONE_CHILD_CLEARTID */
+	int __user *set_child_tid;		/* CLONE_CHILD_SETTID */
+	int __user *clear_child_tid;		/* CLONE_CHILD_CLEARTID */
 
 	unsigned long rt_priority;
 	unsigned long it_real_value, it_prof_value, it_virt_value;
@@ -563,7 +563,7 @@
 extern int kill_sl(pid_t, int, int);
 extern int kill_proc(pid_t, int, int);
 extern int do_sigaction(int, const struct k_sigaction *, struct k_sigaction *);
-extern int do_sigaltstack(const stack_t *, stack_t *, unsigned long);
+extern int do_sigaltstack(const stack_t __user *, stack_t __user *, unsigned long);
 
 /* These can be the second arg to send_sig_info/send_group_sig_info.  */
 #define SEND_SIG_NOINFO ((struct siginfo *) 0)
@@ -636,7 +636,7 @@
 extern task_t *child_reaper;
 
 extern int do_execve(char *, char __user * __user *, char __user * __user *, struct pt_regs *);
-extern struct task_struct *do_fork(unsigned long, unsigned long, struct pt_regs *, unsigned long, int *, int *);
+extern struct task_struct *do_fork(unsigned long, unsigned long, struct pt_regs *, unsigned long, int __user *, int __user *);
 
 #ifdef CONFIG_SMP
 extern void wait_task_inactive(task_t * p);
diff -urN linux-2.5.69-bk7/include/linux/seq_file.h linux-2.5.69-bk8/include/linux/seq_file.h
--- linux-2.5.69-bk7/include/linux/seq_file.h	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/include/linux/seq_file.h	2003-05-13 04:44:30.000000000 -0700
@@ -29,7 +29,7 @@
 };
 
 int seq_open(struct file *, struct seq_operations *);
-ssize_t seq_read(struct file *, char *, size_t, loff_t *);
+ssize_t seq_read(struct file *, char __user *, size_t, loff_t *);
 loff_t seq_lseek(struct file *, loff_t, int);
 int seq_release(struct inode *, struct file *);
 int seq_escape(struct seq_file *, const char *, const char *);
diff -urN linux-2.5.69-bk7/include/linux/signal.h linux-2.5.69-bk8/include/linux/signal.h
--- linux-2.5.69-bk7/include/linux/signal.h	2003-05-04 16:53:03.000000000 -0700
+++ linux-2.5.69-bk8/include/linux/signal.h	2003-05-13 04:44:30.000000000 -0700
@@ -201,7 +201,7 @@
 	sig->tail = &sig->head;
 }
 
-extern long do_sigpending(void *, unsigned long);
+extern long do_sigpending(void __user *, unsigned long);
 extern int sigprocmask(int, sigset_t *, sigset_t *);
 
 #ifndef HAVE_ARCH_GET_SIGNAL_TO_DELIVER
diff -urN linux-2.5.69-bk7/include/linux/skbuff.h linux-2.5.69-bk8/include/linux/skbuff.h
--- linux-2.5.69-bk7/include/linux/skbuff.h	2003-05-04 16:53:32.000000000 -0700
+++ linux-2.5.69-bk8/include/linux/skbuff.h	2003-05-13 04:44:30.000000000 -0700
@@ -792,6 +792,15 @@
 	return len + skb_headlen(skb);
 }
 
+static inline void skb_fill_page_desc(struct sk_buff *skb, int i, struct page *page, int off, int size)
+{
+	skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
+	frag->page = page;
+	frag->page_offset = off;
+	frag->size = size;
+	skb_shinfo(skb)->nr_frags = i+1;
+}
+
 #define SKB_PAGE_ASSERT(skb) do { if (skb_shinfo(skb)->nr_frags) \
 					BUG(); } while (0)
 #define SKB_FRAG_ASSERT(skb) do { if (skb_shinfo(skb)->frag_list) \
diff -urN linux-2.5.69-bk7/include/linux/smp_lock.h linux-2.5.69-bk8/include/linux/smp_lock.h
--- linux-2.5.69-bk7/include/linux/smp_lock.h	2003-05-04 16:53:37.000000000 -0700
+++ linux-2.5.69-bk8/include/linux/smp_lock.h	2003-05-13 04:44:30.000000000 -0700
@@ -5,7 +5,7 @@
 #include <linux/sched.h>
 #include <linux/spinlock.h>
 
-#if CONFIG_SMP || CONFIG_PREEMPT
+#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT)
 
 extern spinlock_t kernel_flag;
 
diff -urN linux-2.5.69-bk7/include/linux/socket.h linux-2.5.69-bk8/include/linux/socket.h
--- linux-2.5.69-bk7/include/linux/socket.h	2003-05-04 16:53:36.000000000 -0700
+++ linux-2.5.69-bk8/include/linux/socket.h	2003-05-13 04:44:30.000000000 -0700
@@ -9,6 +9,7 @@
 #include <linux/sockios.h>		/* the SIOCxxx I/O controls	*/
 #include <linux/uio.h>			/* iovec support		*/
 #include <linux/types.h>		/* pid_t			*/
+#include <linux/compiler.h>		/* __user			*/
 
 typedef unsigned short	sa_family_t;
 
@@ -242,8 +243,8 @@
 #define MSG_CMSG_COMPAT	0		/* We never have 32 bit fixups */
 #endif
 
-extern asmlinkage long sys_sendmsg(int fd, struct msghdr *msg, unsigned flags);
-extern asmlinkage long sys_recvmsg(int fd, struct msghdr *msg, unsigned flags);
+extern asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
+extern asmlinkage long sys_recvmsg(int fd, struct msghdr __user *msg, unsigned flags);
 
 
 
@@ -285,8 +286,8 @@
 extern int verify_iovec(struct msghdr *m, struct iovec *iov, char *address, int mode);
 extern int memcpy_toiovec(struct iovec *v, unsigned char *kdata, int len);
 extern void memcpy_tokerneliovec(struct iovec *iov, unsigned char *kdata, int len);
-extern int move_addr_to_user(void *kaddr, int klen, void *uaddr, int *ulen);
-extern int move_addr_to_kernel(void *uaddr, int ulen, void *kaddr);
+extern int move_addr_to_user(void *kaddr, int klen, void __user *uaddr, int __user *ulen);
+extern int move_addr_to_kernel(void __user *uaddr, int ulen, void *kaddr);
 extern int put_cmsg(struct msghdr*, int level, int type, int len, void *data);
 
 #endif
diff -urN linux-2.5.69-bk7/include/linux/sysctl.h linux-2.5.69-bk8/include/linux/sysctl.h
--- linux-2.5.69-bk7/include/linux/sysctl.h	2003-05-04 16:53:31.000000000 -0700
+++ linux-2.5.69-bk8/include/linux/sysctl.h	2003-05-13 04:44:30.000000000 -0700
@@ -36,11 +36,11 @@
 				   member of a struct __sysctl_args to have? */
 
 struct __sysctl_args {
-	int *name;
+	int __user *name;
 	int nlen;
-	void *oldval;
-	size_t *oldlenp;
-	void *newval;
+	void __user *oldval;
+	size_t __user *oldlenp;
+	void __user *newval;
 	size_t newlen;
 	unsigned long __unused[4];
 };
@@ -674,40 +674,40 @@
 
 #ifdef __KERNEL__
 
-extern asmlinkage long sys_sysctl(struct __sysctl_args *);
+extern asmlinkage long sys_sysctl(struct __sysctl_args __user *);
 extern void sysctl_init(void);
 
 typedef struct ctl_table ctl_table;
 
-typedef int ctl_handler (ctl_table *table, int *name, int nlen,
+typedef int ctl_handler (ctl_table *table, int __user *name, int nlen,
 			 void __user *oldval, size_t __user *oldlenp,
 			 void __user *newval, size_t newlen, 
 			 void **context);
 
 typedef int proc_handler (ctl_table *ctl, int write, struct file * filp,
-			  void *buffer, size_t *lenp);
+			  void __user *buffer, size_t *lenp);
 
 extern int proc_dostring(ctl_table *, int, struct file *,
-			 void *, size_t *);
+			 void __user *, size_t *);
 extern int proc_dointvec(ctl_table *, int, struct file *,
-			 void *, size_t *);
+			 void __user *, size_t *);
 extern int proc_dointvec_bset(ctl_table *, int, struct file *,
-			      void *, size_t *);
+			      void __user *, size_t *);
 extern int proc_dointvec_minmax(ctl_table *, int, struct file *,
-				void *, size_t *);
+				void __user *, size_t *);
 extern int proc_dointvec_jiffies(ctl_table *, int, struct file *,
-				 void *, size_t *);
+				 void __user *, size_t *);
 extern int proc_doulongvec_minmax(ctl_table *, int, struct file *,
-				  void *, size_t *);
+				  void __user *, size_t *);
 extern int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int,
-				      struct file *, void *, size_t *);
+				      struct file *, void __user *, size_t *);
 
-extern int do_sysctl (int *name, int nlen,
-		      void *oldval, size_t *oldlenp,
-		      void *newval, size_t newlen);
+extern int do_sysctl (int __user *name, int nlen,
+		      void __user *oldval, size_t __user *oldlenp,
+		      void __user *newval, size_t newlen);
 
 extern int do_sysctl_strategy (ctl_table *table, 
-			       int *name, int nlen,
+			       int __user *name, int nlen,
 			       void __user *oldval, size_t __user *oldlenp,
 			       void __user *newval, size_t newlen, void ** context);
 
diff -urN linux-2.5.69-bk7/include/linux/time.h linux-2.5.69-bk8/include/linux/time.h
--- linux-2.5.69-bk7/include/linux/time.h	2003-05-04 16:53:32.000000000 -0700
+++ linux-2.5.69-bk8/include/linux/time.h	2003-05-13 04:44:30.000000000 -0700
@@ -204,7 +204,7 @@
 extern int do_sys_settimeofday(struct timeval *tv, struct timezone *tz);
 extern void clock_was_set(void); // call when ever the clock is set
 extern long do_nanosleep(struct timespec *t);
-extern long do_utimes(char * filename, struct timeval * times);
+extern long do_utimes(char __user * filename, struct timeval * times);
 #endif
 
 #define FD_SETSIZE		__FD_SETSIZE
diff -urN linux-2.5.69-bk7/include/linux/tpqic02.h linux-2.5.69-bk8/include/linux/tpqic02.h
--- linux-2.5.69-bk7/include/linux/tpqic02.h	2003-05-04 16:53:02.000000000 -0700
+++ linux-2.5.69-bk8/include/linux/tpqic02.h	2003-05-13 04:44:30.000000000 -0700
@@ -12,7 +12,7 @@
 
 #include <linux/config.h>
 
-#if CONFIG_QIC02_TAPE || CONFIG_QIC02_TAPE_MODULE
+#if defined(CONFIG_QIC02_TAPE) || defined(CONFIG_QIC02_TAPE_MODULE)
 
 /* need to have QIC02_TAPE_DRIVE and QIC02_TAPE_IFC expand to something */
 #include <linux/mtio.h>
diff -urN linux-2.5.69-bk7/include/net/compat.h linux-2.5.69-bk8/include/net/compat.h
--- linux-2.5.69-bk7/include/net/compat.h	2003-05-04 16:53:08.000000000 -0700
+++ linux-2.5.69-bk8/include/net/compat.h	2003-05-13 04:44:30.000000000 -0700
@@ -27,7 +27,7 @@
 #define compat_msghdr	msghdr		/* to avoid compiler warnings */
 #endif /* defined(CONFIG_COMPAT) */
 
-extern int get_compat_msghdr(struct msghdr *, struct compat_msghdr *);
+extern int get_compat_msghdr(struct msghdr *, struct compat_msghdr __user *);
 extern int verify_compat_iovec(struct msghdr *, struct iovec *, char *, int);
 extern asmlinkage long compat_sys_sendmsg(int,struct compat_msghdr *,unsigned);
 extern asmlinkage long compat_sys_recvmsg(int,struct compat_msghdr *,unsigned);
diff -urN linux-2.5.69-bk7/include/net/ip.h linux-2.5.69-bk8/include/net/ip.h
--- linux-2.5.69-bk7/include/net/ip.h	2003-05-04 16:53:35.000000000 -0700
+++ linux-2.5.69-bk8/include/net/ip.h	2003-05-13 04:44:30.000000000 -0700
@@ -230,6 +230,23 @@
 	buf[3]=addr&0x7F;
 }
 
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+#include <linux/ipv6.h>
+#endif
+
+static __inline__ void inet_reset_saddr(struct sock *sk)
+{
+	inet_sk(sk)->rcv_saddr = inet_sk(sk)->saddr = 0;
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+	if (sk->family == PF_INET6) {
+		struct ipv6_pinfo *np = inet6_sk(sk);
+
+		memset(&np->saddr, 0, sizeof(np->saddr));
+		memset(&np->rcv_saddr, 0, sizeof(np->rcv_saddr));
+	}
+#endif
+}
+
 #endif
 
 extern int	ip_call_ra_chain(struct sk_buff *skb);
diff -urN linux-2.5.69-bk7/include/net/ipv6.h linux-2.5.69-bk8/include/net/ipv6.h
--- linux-2.5.69-bk7/include/net/ipv6.h	2003-05-04 16:53:37.000000000 -0700
+++ linux-2.5.69-bk8/include/net/ipv6.h	2003-05-13 04:44:30.000000000 -0700
@@ -316,6 +316,26 @@
 					       struct ipv6_txoptions *opt,
 					       int hlimit, int flags);
 
+extern int			ip6_append_data(struct sock *sk,
+						int getfrag(void *from, char *to, int offset, int len, int odd, struct sk_buff *skb),
+		    				void *from,
+						int length,
+						int transhdrlen,
+		      				int hlimit,
+						struct ipv6_txoptions *opt,
+						struct flowi *fl,
+						struct rt6_info *rt,
+						unsigned int flags);
+
+extern int			ip6_push_pending_frames(struct sock *sk);
+
+extern void			ip6_flush_pending_frames(struct sock *sk);
+
+extern int			ip6_dst_lookup(struct sock *sk,
+					       struct dst_entry **dst,
+					       struct flowi *fl,
+					       struct in6_addr **saddr);
+
 /*
  *	skb processing functions
  */
diff -urN linux-2.5.69-bk7/include/net/xfrm.h linux-2.5.69-bk8/include/net/xfrm.h
--- linux-2.5.69-bk7/include/net/xfrm.h	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/include/net/xfrm.h	2003-05-13 04:44:30.000000000 -0700
@@ -123,6 +123,12 @@
 	/* Data for encapsulator */
 	struct xfrm_encap_tmpl	*encap;
 
+	/* IPComp needs an IPIP tunnel for handling uncompressed packets */
+	struct xfrm_state	*tunnel;
+
+	/* If a tunnel, number of users + 1 */
+	atomic_t		tunnel_users;
+
 	/* State for replay detection */
 	struct xfrm_replay_state replay;
 
@@ -196,6 +202,8 @@
 extern struct xfrm_state_afinfo *xfrm_state_get_afinfo(unsigned short family);
 extern void xfrm_state_put_afinfo(struct xfrm_state_afinfo *afinfo);
 
+extern void xfrm_state_delete_tunnel(struct xfrm_state *x);
+
 struct xfrm_decap_state;
 struct xfrm_type
 {
@@ -699,6 +707,11 @@
 	return 0;
 }
 
+static inline int xfrm_state_kern(struct xfrm_state *x)
+{
+	return atomic_read(&x->tunnel_users);
+}
+
 /*
  * xfrm algorithm information
  */
diff -urN linux-2.5.69-bk7/include/scsi/scsi.h linux-2.5.69-bk8/include/scsi/scsi.h
--- linux-2.5.69-bk7/include/scsi/scsi.h	2003-05-04 16:53:56.000000000 -0700
+++ linux-2.5.69-bk8/include/scsi/scsi.h	2003-05-13 04:44:30.000000000 -0700
@@ -111,14 +111,39 @@
 #define SAM_STAT_CHECK_CONDITION 0x02
 #define SAM_STAT_CONDITION_MET   0x04
 #define SAM_STAT_BUSY            0x08
-#define SAM_STAT_IMMEDIATE       0x10
-#define SAM_STAT_IMMEDIATE_CONDITION_MET 0x14
+#define SAM_STAT_INTERMEDIATE    0x10
+#define SAM_STAT_INTERMEDIATE_CONDITION_MET 0x14
 #define SAM_STAT_RESERVATION_CONFLICT 0x18
 #define SAM_STAT_COMMAND_TERMINATED 0x22	/* obsolete in SAM-3 */
 #define SAM_STAT_TASK_SET_FULL   0x28
 #define SAM_STAT_ACA_ACTIVE      0x30
 #define SAM_STAT_TASK_ABORTED    0x40
 
+/** scsi_status_is_good - check the status return.
+ *
+ * @status: the status passed up from the driver (including host and
+ *          driver components)
+ *
+ * This returns true for known good conditions that may be treated as
+ * command completed normally
+ */
+static inline int scsi_status_is_good(int status)
+{
+	/* mask out the relevant bits
+	 *
+	 * FIXME: bit0 is listed as reserved in SCSI-2, but is
+	 * significant in SCSI-3.  For now, we follow the SCSI-2
+	 * behaviour and ignore reserved bits. */
+	
+	status &= 0xfe;
+
+	return ((status == SAM_STAT_GOOD)
+		|| (status == SAM_STAT_INTERMEDIATE)
+		|| (status == SAM_STAT_INTERMEDIATE_CONDITION_MET)
+		/* FIXME: this is obsolete in SAM-3 */
+		|| (status == SAM_STAT_COMMAND_TERMINATED));
+}
+
 /*
  *  Status codes. These are deprecated as they are shifted 1 bit right
  *  from those found in the SCSI standards. This causes confusion for
diff -urN linux-2.5.69-bk7/ipc/msg.c linux-2.5.69-bk8/ipc/msg.c
--- linux-2.5.69-bk7/ipc/msg.c	2003-05-04 16:52:48.000000000 -0700
+++ linux-2.5.69-bk8/ipc/msg.c	2003-05-13 04:44:30.000000000 -0700
@@ -74,7 +74,7 @@
 #define msg_buildid(id, seq) \
 	ipc_buildid(&msg_ids, id, seq)
 
-static void freeque (int id);
+static void freeque (struct msg_queue *msq, int id);
 static int newque (key_t key, int msgflg);
 #ifdef CONFIG_PROC_FS
 static int sysvipc_msg_read_proc(char *buffer, char **start, off_t offset, int length, int *eof, void *data);
@@ -272,16 +272,21 @@
 		wake_up_process(msr->r_tsk);
 	}
 }
-
-static void freeque (int id)
+/* 
+ * freeque() wakes up waiters on the sender and receiver waiting queue, 
+ * removes the message queue from message queue ID 
+ * array, and cleans up all the messages associated with this queue.
+ *
+ * msg_ids.sem and the spinlock for this message queue is hold
+ * before freeque() is called. msg_ids.sem remains locked on exit.
+ */
+static void freeque (struct msg_queue *msq, int id)
 {
-	struct msg_queue *msq;
 	struct list_head *tmp;
 
-	msq = msg_rmid(id);
-
 	expunge_all(msq,-EIDRM);
 	ss_wakeup(&msq->q_senders,1);
+	msq = msg_rmid(id);
 	msg_unlock(msq);
 		
 	tmp = msq->q_messages.next;
@@ -574,7 +579,7 @@
 		break;
 	}
 	case IPC_RMID:
-		freeque (msqid); 
+		freeque (msq, msqid); 
 		break;
 	}
 	err = 0;
diff -urN linux-2.5.69-bk7/ipc/sem.c linux-2.5.69-bk8/ipc/sem.c
--- linux-2.5.69-bk7/ipc/sem.c	2003-05-04 16:53:12.000000000 -0700
+++ linux-2.5.69-bk8/ipc/sem.c	2003-05-13 04:44:30.000000000 -0700
@@ -79,7 +79,7 @@
 static struct ipc_ids sem_ids;
 
 static int newary (key_t, int, int);
-static void freeary (int id);
+static void freeary (struct sem_array *sma, int id);
 #ifdef CONFIG_PROC_FS
 static int sysvipc_sem_read_proc(char *buffer, char **start, off_t offset, int length, int *eof, void *data);
 #endif
@@ -405,16 +405,16 @@
 	return semzcnt;
 }
 
-/* Free a semaphore set. */
-static void freeary (int id)
+/* Free a semaphore set. freeary() is called with sem_ids.sem down and
+ * the spinlock for this semaphore set hold. sem_ids.sem remains locked
+ * on exit.
+ */
+static void freeary (struct sem_array *sma, int id)
 {
-	struct sem_array *sma;
 	struct sem_undo *un;
 	struct sem_queue *q;
 	int size;
 
-	sma = sem_rmid(id);
-
 	/* Invalidate the existing undo structures for this semaphore set.
 	 * (They will be freed without any further action in sem_exit()
 	 * or during the next semop.)
@@ -428,6 +428,9 @@
 		q->prev = NULL;
 		wake_up_process(q->sleeper); /* doesn't sleep */
 	}
+
+	/* Remove the semaphore set from the ID array*/
+	sma = sem_rmid(id);
 	sem_unlock(sma);
 
 	used_sems -= sma->sem_nsems;
@@ -764,7 +767,7 @@
 
 	switch(cmd){
 	case IPC_RMID:
-		freeary(semid);
+		freeary(sma, semid);
 		err = 0;
 		break;
 	case IPC_SET:
diff -urN linux-2.5.69-bk7/kernel/cpufreq.c linux-2.5.69-bk8/kernel/cpufreq.c
--- linux-2.5.69-bk7/kernel/cpufreq.c	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/kernel/cpufreq.c	2003-05-13 04:44:30.000000000 -0700
@@ -29,9 +29,11 @@
  * level driver of CPUFreq support, and its locking mutex. 
  * cpu_max_freq is in kHz.
  */
-static struct cpufreq_driver   	*cpufreq_driver;
+struct cpufreq_driver   	*cpufreq_driver;
 static DECLARE_MUTEX            (cpufreq_driver_sem);
 
+/* required for the proc interface, remove when that goes away */
+EXPORT_SYMBOL_GPL(cpufreq_driver);
 
 /**
  * Two notifier lists: the "policy" list is involved in the 
diff -urN linux-2.5.69-bk7/kernel/exit.c linux-2.5.69-bk8/kernel/exit.c
--- linux-2.5.69-bk7/kernel/exit.c	2003-05-04 16:53:41.000000000 -0700
+++ linux-2.5.69-bk8/kernel/exit.c	2003-05-13 04:44:30.000000000 -0700
@@ -756,7 +756,7 @@
 	struct pid_link *link = p->pids + PIDTYPE_TGID;
 	struct list_head *tmp, *head = &link->pidptr->task_list;
 
-#if CONFIG_SMP
+#ifdef CONFIG_SMP
 	if (!p->sighand)
 		BUG();
 	if (!spin_is_locked(&p->sighand->siglock) &&
diff -urN linux-2.5.69-bk7/kernel/fork.c linux-2.5.69-bk8/kernel/fork.c
--- linux-2.5.69-bk7/kernel/fork.c	2003-05-04 16:53:02.000000000 -0700
+++ linux-2.5.69-bk8/kernel/fork.c	2003-05-13 04:44:30.000000000 -0700
@@ -379,7 +379,6 @@
 	free_mm(mm);
 	return NULL;
 }
-	
 
 /*
  * Allocate and initialize an mm_struct.
@@ -450,7 +449,7 @@
 		complete(vfork_done);
 	}
 	if (tsk->clear_child_tid && atomic_read(&mm->mm_users) > 1) {
-		u32 * tidptr = tsk->clear_child_tid;
+		u32 __user * tidptr = tsk->clear_child_tid;
 		tsk->clear_child_tid = NULL;
 
 		/*
@@ -543,7 +542,7 @@
 		} else {
 			fs->altrootmnt = NULL;
 			fs->altroot = NULL;
-		}	
+		}
 		read_unlock(&old->lock);
 	}
 	return fs;
@@ -562,14 +561,14 @@
 	}
 	tsk->fs = __copy_fs_struct(current->fs);
 	if (!tsk->fs)
-		return -1;
+		return -ENOMEM;
 	return 0;
 }
 
 static int count_open_files(struct files_struct *files, int size)
 {
 	int i;
-	
+
 	/* Find the last open fd */
 	for (i = size/(8*sizeof(long)); i > 0; ) {
 		if (files->open_fds->fds_bits[--i])
@@ -669,7 +668,7 @@
 	if (newf->max_fdset > open_files) {
 		int left = (newf->max_fdset-open_files)/8;
 		int start = open_files / (8 * sizeof(unsigned long));
-		
+
 		memset(&newf->open_fds->fds_bits[start], 0, left);
 		memset(&newf->close_on_exec->fds_bits[start], 0, left);
 	}
@@ -697,7 +696,7 @@
 	sig = kmem_cache_alloc(sighand_cachep, GFP_KERNEL);
 	tsk->sighand = sig;
 	if (!sig)
-		return -1;
+		return -ENOMEM;
 	spin_lock_init(&sig->siglock);
 	atomic_set(&sig->count, 1);
 	memcpy(sig->action, current->sighand->action, sizeof(sig->action));
@@ -715,7 +714,7 @@
 	sig = kmem_cache_alloc(signal_cachep, GFP_KERNEL);
 	tsk->signal = sig;
 	if (!sig)
-		return -1;
+		return -ENOMEM;
 	atomic_set(&sig->count, 1);
 	sig->group_exit = 0;
 	sig->group_exit_code = 0;
@@ -738,7 +737,7 @@
 	p->flags = new_flags;
 }
 
-asmlinkage long sys_set_tid_address(int *tidptr)
+asmlinkage long sys_set_tid_address(int __user *tidptr)
 {
 	current->clear_child_tid = tidptr;
 
@@ -757,8 +756,8 @@
 			    unsigned long stack_start,
 			    struct pt_regs *regs,
 			    unsigned long stack_size,
-			    int *parent_tidptr,
-			    int *child_tidptr)
+			    int __user *parent_tidptr,
+			    int __user *child_tidptr)
 {
 	int retval;
 	struct task_struct *p = NULL;
@@ -800,7 +799,7 @@
 	 */
 	if (nr_threads >= max_threads)
 		goto bad_fork_cleanup_count;
-	
+
 	if (!try_module_get(p->thread_info->exec_domain->module))
 		goto bad_fork_cleanup_count;
 
@@ -860,23 +859,22 @@
 	p->security = NULL;
 
 	retval = -ENOMEM;
-	if (security_task_alloc(p))
+	if ((retval = security_task_alloc(p)))
 		goto bad_fork_cleanup;
 	/* copy all the process information */
-	if (copy_semundo(clone_flags, p))
+	if ((retval = copy_semundo(clone_flags, p)))
 		goto bad_fork_cleanup_security;
-	if (copy_files(clone_flags, p))
+	if ((retval = copy_files(clone_flags, p)))
 		goto bad_fork_cleanup_semundo;
-	if (copy_fs(clone_flags, p))
+	if ((retval = copy_fs(clone_flags, p)))
 		goto bad_fork_cleanup_files;
-	if (copy_sighand(clone_flags, p))
+	if ((retval = copy_sighand(clone_flags, p)))
 		goto bad_fork_cleanup_fs;
-	if (copy_signal(clone_flags, p))
+	if ((retval = copy_signal(clone_flags, p)))
 		goto bad_fork_cleanup_sighand;
-	if (copy_mm(clone_flags, p))
+	if ((retval = copy_mm(clone_flags, p)))
 		goto bad_fork_cleanup_signal;
-	retval = copy_namespace(clone_flags, p);
-	if (retval)
+	if ((retval = copy_namespace(clone_flags, p)))
 		goto bad_fork_cleanup_mm;
 	retval = copy_thread(0, clone_flags, stack_start, stack_size, p, regs);
 	if (retval)
@@ -1073,8 +1071,8 @@
 			    unsigned long stack_start,
 			    struct pt_regs *regs,
 			    unsigned long stack_size,
-			    int *parent_tidptr,
-			    int *child_tidptr)
+			    int __user *parent_tidptr,
+			    int __user *child_tidptr)
 {
 	struct task_struct *p;
 	int trace = 0;
diff -urN linux-2.5.69-bk7/kernel/ksyms.c linux-2.5.69-bk8/kernel/ksyms.c
--- linux-2.5.69-bk7/kernel/ksyms.c	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/kernel/ksyms.c	2003-05-13 04:44:30.000000000 -0700
@@ -40,7 +40,6 @@
 #include <linux/mm.h>
 #include <linux/capability.h>
 #include <linux/highuid.h>
-#include <linux/brlock.h>
 #include <linux/fs.h>
 #include <linux/uio.h>
 #include <linux/tty.h>
@@ -429,17 +428,6 @@
 #endif
 EXPORT_SYMBOL(mod_timer);
 
-#ifdef CONFIG_SMP
-
-/* Big-Reader lock implementation */
-EXPORT_SYMBOL(__brlock_array);
-#ifndef __BRLOCK_USE_ATOMICS
-EXPORT_SYMBOL(__br_write_locks);
-#endif
-EXPORT_SYMBOL(__br_write_lock);
-EXPORT_SYMBOL(__br_write_unlock);
-#endif
-
 #ifdef HAVE_DISABLE_HLT
 EXPORT_SYMBOL(disable_hlt);
 EXPORT_SYMBOL(enable_hlt);
@@ -459,7 +447,7 @@
 EXPORT_SYMBOL(complete_and_exit);
 EXPORT_SYMBOL(default_wake_function);
 EXPORT_SYMBOL(__wake_up);
-#if CONFIG_SMP
+#ifdef CONFIG_SMP
 EXPORT_SYMBOL_GPL(__wake_up_sync); /* internal use only */
 #endif
 EXPORT_SYMBOL(wake_up_process);
@@ -477,10 +465,10 @@
 EXPORT_SYMBOL(set_user_nice);
 EXPORT_SYMBOL(task_nice);
 EXPORT_SYMBOL_GPL(idle_cpu);
-#if CONFIG_SMP
+#ifdef CONFIG_SMP
 EXPORT_SYMBOL_GPL(set_cpus_allowed);
 #endif
-#if CONFIG_SMP || CONFIG_PREEMPT
+#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT)
 EXPORT_SYMBOL(kernel_flag);
 #endif
 EXPORT_SYMBOL(jiffies);
diff -urN linux-2.5.69-bk7/kernel/module.c linux-2.5.69-bk8/kernel/module.c
--- linux-2.5.69-bk7/kernel/module.c	2003-05-04 16:53:36.000000000 -0700
+++ linux-2.5.69-bk8/kernel/module.c	2003-05-13 04:44:30.000000000 -0700
@@ -214,6 +214,8 @@
 	INIT_LIST_HEAD(&mod->modules_which_use_me);
 	for (i = 0; i < NR_CPUS; i++)
 		atomic_set(&mod->ref[i].count, 0);
+	/* Hold reference count during initialization. */
+	atomic_set(&mod->ref[smp_processor_id()].count, 1);
 	/* Backwards compatibility macros put refcount during init. */
 	mod->waiter = current;
 }
@@ -462,6 +464,21 @@
 }
 EXPORT_SYMBOL(cleanup_module);
 
+static void wait_for_zero_refcount(struct module *mod)
+{
+	/* Since we might sleep for some time, drop the semaphore first */
+	up(&module_mutex);
+	for (;;) {
+		DEBUGP("Looking at refcount...\n");
+		set_current_state(TASK_UNINTERRUPTIBLE);
+		if (module_refcount(mod) == 0)
+			break;
+		schedule();
+	}
+	current->state = TASK_RUNNING;
+	down(&module_mutex);
+}
+
 asmlinkage long
 sys_delete_module(const char __user *name_user, unsigned int flags)
 {
@@ -500,16 +517,6 @@
 		goto out;
 	}
 
-	/* Coming up?  Allow force on stuck modules. */
-	if (mod->state == MODULE_STATE_COMING) {
-		forced = try_force(flags);
-		if (!forced) {
-			/* This module can't be removed */
-			ret = -EBUSY;
-			goto out;
-		}
-	}
-
 	/* If it has an init func, it must have an exit func to unload */
 	if ((mod->init != init_module && mod->exit == cleanup_module)
 	    || mod->unsafe) {
@@ -529,35 +536,22 @@
 	/* If it's not unused, quit unless we are told to block. */
 	if ((flags & O_NONBLOCK) && module_refcount(mod) != 0) {
 		forced = try_force(flags);
-		if (!forced)
+		if (!forced) {
 			ret = -EWOULDBLOCK;
-	} else {
-		mod->waiter = current;
-		mod->state = MODULE_STATE_GOING;
+			restart_refcounts();
+			goto out;
+		}
 	}
-	restart_refcounts();
-
-	if (ret != 0)
-		goto out;
-
-	if (forced)
-		goto destroy;
 
-	/* Since we might sleep for some time, drop the semaphore first */
-	up(&module_mutex);
-	for (;;) {
-		DEBUGP("Looking at refcount...\n");
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		if (module_refcount(mod) == 0)
-			break;
-		schedule();
-	}
-	current->state = TASK_RUNNING;
+	/* Mark it as dying. */
+	mod->waiter = current;
+	mod->state = MODULE_STATE_GOING;
+	restart_refcounts();
 
-	DEBUGP("Regrabbing mutex...\n");
-	down(&module_mutex);
+	/* Never wait if forced. */
+	if (!forced && module_refcount(mod) != 0)
+		wait_for_zero_refcount(mod);
 
- destroy:
 	/* Final destruction now noone is using it. */
 	mod->exit();
 	free_module(mod);
@@ -910,6 +904,9 @@
 	list_del(&mod->list);
 	spin_unlock_irq(&modlist_lock);
 
+	/* Arch-specific cleanup. */
+	module_arch_cleanup(mod);
+
 	/* Module unload stuff */
 	module_unload_free(mod);
 
@@ -1276,6 +1273,7 @@
 	mod->module_init = ptr;
 
 	/* Transfer each section which specifies SHF_ALLOC */
+	DEBUGP("final section addresses:\n");
 	for (i = 0; i < hdr->e_shnum; i++) {
 		void *dest;
 
@@ -1293,6 +1291,7 @@
 			       sechdrs[i].sh_size);
 		/* Update sh_addr to point to copy in image. */
 		sechdrs[i].sh_addr = (unsigned long)dest;
+		DEBUGP("\t0x%lx %s\n", sechdrs[i].sh_addr, secstrings + sechdrs[i].sh_name);
 	}
 	/* Module has been moved. */
 	mod = (void *)sechdrs[modindex].sh_addr;
@@ -1448,6 +1447,7 @@
 			printk(KERN_ERR "%s: module is now stuck!\n",
 			       mod->name);
 		else {
+			module_put(mod);
 			down(&module_mutex);
 			free_module(mod);
 			up(&module_mutex);
@@ -1458,6 +1458,8 @@
 	/* Now it's a first class citizen! */
 	down(&module_mutex);
 	mod->state = MODULE_STATE_LIVE;
+	/* Drop initial reference. */
+	module_put(mod);
 	module_free(mod, mod->module_init);
 	mod->module_init = NULL;
 	mod->init_size = 0;
diff -urN linux-2.5.69-bk7/kernel/panic.c linux-2.5.69-bk8/kernel/panic.c
--- linux-2.5.69-bk7/kernel/panic.c	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/kernel/panic.c	2003-05-13 04:44:30.000000000 -0700
@@ -110,7 +110,7 @@
  *	The string is overwritten by the next call to print_taint().
  */
  
-const char *print_tainted()
+const char *print_tainted(void)
 {
 	static char buf[20];
 	if (tainted) {
diff -urN linux-2.5.69-bk7/kernel/pid.c linux-2.5.69-bk8/kernel/pid.c
--- linux-2.5.69-bk7/kernel/pid.c	2003-05-04 16:53:32.000000000 -0700
+++ linux-2.5.69-bk8/kernel/pid.c	2003-05-13 04:44:30.000000000 -0700
@@ -252,6 +252,7 @@
 	attach_pid(thread, PIDTYPE_TGID, thread->tgid);
 	attach_pid(thread, PIDTYPE_PGID, thread->pgrp);
 	attach_pid(thread, PIDTYPE_SID, thread->session);
+	list_add_tail(&thread->tasks, &init_task.tasks);
 
 	attach_pid(leader, PIDTYPE_PID, leader->pid);
 	attach_pid(leader, PIDTYPE_TGID, leader->tgid);
diff -urN linux-2.5.69-bk7/kernel/posix-timers.c linux-2.5.69-bk8/kernel/posix-timers.c
--- linux-2.5.69-bk7/kernel/posix-timers.c	2003-05-04 16:53:31.000000000 -0700
+++ linux-2.5.69-bk8/kernel/posix-timers.c	2003-05-13 04:44:30.000000000 -0700
@@ -357,13 +357,10 @@
 			rtn->tgid != current->tgid))
 		return NULL;
 
-	if ((event->sigev_notify & SIGEV_SIGNAL & MIPS_SIGEV) &&
+	if ((event->sigev_notify & ~SIGEV_NONE & MIPS_SIGEV) &&
 			((unsigned) (event->sigev_signo > SIGRTMAX)))
 		return NULL;
 
-	if (event->sigev_notify & ~(SIGEV_SIGNAL | SIGEV_THREAD_ID))
-		return NULL;
-
 	return rtn;
 }
 
diff -urN linux-2.5.69-bk7/kernel/sched.c linux-2.5.69-bk8/kernel/sched.c
--- linux-2.5.69-bk7/kernel/sched.c	2003-05-04 16:53:37.000000000 -0700
+++ linux-2.5.69-bk8/kernel/sched.c	2003-05-13 04:44:30.000000000 -0700
@@ -863,7 +863,7 @@
 
 #endif /* CONFIG_NUMA */
 
-#if CONFIG_SMP
+#ifdef CONFIG_SMP
 
 /*
  * double_lock_balance - lock the busiest runqueue
@@ -1309,7 +1309,7 @@
 	}
 pick_next_task:
 	if (unlikely(!rq->nr_running)) {
-#if CONFIG_SMP
+#ifdef CONFIG_SMP
 		load_balance(rq, 1, cpu_to_node_mask(smp_processor_id()));
 		if (rq->nr_running)
 			goto pick_next_task;
@@ -1440,7 +1440,7 @@
 	__wake_up_common(q, mode, 1, 0);
 }
 
-#if CONFIG_SMP
+#ifdef CONFIG_SMP
 
 /**
  * __wake_up - sync- wake up threads blocked on a waitqueue.
@@ -2261,7 +2261,7 @@
 #endif
 }
 
-#if CONFIG_SMP
+#ifdef CONFIG_SMP
 /*
  * This is how migration works:
  *
@@ -2443,7 +2443,7 @@
 
 #endif
 
-#if CONFIG_SMP || CONFIG_PREEMPT
+#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT)
 /*
  * The 'big kernel lock'
  *
diff -urN linux-2.5.69-bk7/kernel/signal.c linux-2.5.69-bk8/kernel/signal.c
--- linux-2.5.69-bk7/kernel/signal.c	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/kernel/signal.c	2003-05-13 04:44:30.000000000 -0700
@@ -761,7 +761,7 @@
 
 	if (!irqs_disabled())
 		BUG();
-#if CONFIG_SMP
+#ifdef CONFIG_SMP
 	if (!spin_is_locked(&t->sighand->siglock))
 		BUG();
 #endif
@@ -846,7 +846,7 @@
 	unsigned int mask;
 	int ret = 0;
 
-#if CONFIG_SMP
+#ifdef CONFIG_SMP
 	if (!spin_is_locked(&p->sighand->siglock))
 		BUG();
 #endif
diff -urN linux-2.5.69-bk7/kernel/sysctl.c linux-2.5.69-bk8/kernel/sysctl.c
--- linux-2.5.69-bk7/kernel/sysctl.c	2003-05-04 16:53:02.000000000 -0700
+++ linux-2.5.69-bk8/kernel/sysctl.c	2003-05-13 04:44:30.000000000 -0700
@@ -103,10 +103,10 @@
 extern int acct_parm[];
 #endif
 
-static int parse_table(int *, int, void *, size_t *, void *, size_t,
+static int parse_table(int __user *, int, void __user *, size_t __user *, void __user *, size_t,
 		       ctl_table *, void **);
 static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
-		  void *buffer, size_t *lenp);
+		  void __user *buffer, size_t *lenp);
 
 static ctl_table root_table[];
 static struct ctl_table_header root_table_header =
@@ -127,8 +127,8 @@
 
 #ifdef CONFIG_PROC_FS
 
-static ssize_t proc_readsys(struct file *, char *, size_t, loff_t *);
-static ssize_t proc_writesys(struct file *, const char *, size_t, loff_t *);
+static ssize_t proc_readsys(struct file *, char __user *, size_t, loff_t *);
+static ssize_t proc_writesys(struct file *, const char __user *, size_t, loff_t *);
 static int proc_sys_permission(struct inode *, int);
 
 struct file_operations proc_sys_file_operations = {
@@ -374,8 +374,8 @@
 #endif
 }
 
-int do_sysctl(int *name, int nlen, void *oldval, size_t *oldlenp,
-	       void *newval, size_t newlen)
+int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
+	       void __user *newval, size_t newlen)
 {
 	struct list_head *tmp;
 
@@ -443,7 +443,7 @@
 	return test_perm(table->mode, op);
 }
 
-static int parse_table(int *name, int nlen,
+static int parse_table(int __user *name, int nlen,
 		       void __user *oldval, size_t __user *oldlenp,
 		       void __user *newval, size_t newlen,
 		       ctl_table *table, void **context)
@@ -484,7 +484,7 @@
 
 /* Perform the actual read/write of a sysctl table entry. */
 int do_sysctl_strategy (ctl_table *table, 
-			int *name, int nlen,
+			int __user *name, int nlen,
 			void __user *oldval, size_t __user *oldlenp,
 			void __user *newval, size_t newlen, void **context)
 {
@@ -721,7 +721,7 @@
 	}
 }
 
-static ssize_t do_rw_proc(int write, struct file * file, char * buf,
+static ssize_t do_rw_proc(int write, struct file * file, char __user * buf,
 			  size_t count, loff_t *ppos)
 {
 	int op;
@@ -752,16 +752,16 @@
 	return res;
 }
 
-static ssize_t proc_readsys(struct file * file, char * buf,
+static ssize_t proc_readsys(struct file * file, char __user * buf,
 			    size_t count, loff_t *ppos)
 {
 	return do_rw_proc(0, file, buf, count, ppos);
 }
 
-static ssize_t proc_writesys(struct file * file, const char * buf,
+static ssize_t proc_writesys(struct file * file, const char __user * buf,
 			     size_t count, loff_t *ppos)
 {
-	return do_rw_proc(1, file, (char *) buf, count, ppos);
+	return do_rw_proc(1, file, (char __user *) buf, count, ppos);
 }
 
 static int proc_sys_permission(struct inode *inode, int op)
@@ -1345,7 +1345,7 @@
  */
 
 /* The generic string strategy routine: */
-int sysctl_string(ctl_table *table, int *name, int nlen,
+int sysctl_string(ctl_table *table, int __user *name, int nlen,
 		  void __user *oldval, size_t __user *oldlenp,
 		  void __user *newval, size_t newlen, void **context)
 {
@@ -1388,9 +1388,9 @@
  * are between the minimum and maximum values given in the arrays
  * table->extra1 and table->extra2, respectively.
  */
-int sysctl_intvec(ctl_table *table, int *name, int nlen,
-		void *oldval, size_t *oldlenp,
-		void *newval, size_t newlen, void **context)
+int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
+		void __user *oldval, size_t __user *oldlenp,
+		void __user *newval, size_t newlen, void **context)
 {
 	int i, *vec, *min, *max;
 	size_t length;
@@ -1423,9 +1423,9 @@
 }
 
 /* Strategy function to convert jiffies to seconds */ 
-int sysctl_jiffies(ctl_table *table, int *name, int nlen,
-		void *oldval, size_t *oldlenp,
-		void *newval, size_t newlen, void **context)
+int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
+		void __user *oldval, size_t __user *oldlenp,
+		void __user *newval, size_t newlen, void **context)
 {
 	if (oldval) {
 		size_t olen;
@@ -1459,47 +1459,47 @@
 	return -ENOSYS;
 }
 
-int sysctl_string(ctl_table *table, int *name, int nlen,
-		  void *oldval, size_t *oldlenp,
-		  void *newval, size_t newlen, void **context)
+int sysctl_string(ctl_table *table, int __user *name, int nlen,
+		  void __user *oldval, size_t __user *oldlenp,
+		  void __user *newval, size_t newlen, void **context)
 {
 	return -ENOSYS;
 }
 
-int sysctl_intvec(ctl_table *table, int *name, int nlen,
-		void *oldval, size_t *oldlenp,
-		void *newval, size_t newlen, void **context)
+int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
+		void __user *oldval, size_t __user *oldlenp,
+		void __user *newval, size_t newlen, void **context)
 {
 	return -ENOSYS;
 }
 
-int sysctl_jiffies(ctl_table *table, int *name, int nlen,
-		void *oldval, size_t *oldlenp,
-		void *newval, size_t newlen, void **context)
+int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
+		void __user *oldval, size_t __user *oldlenp,
+		void __user *newval, size_t newlen, void **context)
 {
 	return -ENOSYS;
 }
 
 int proc_dostring(ctl_table *table, int write, struct file *filp,
-		  void *buffer, size_t *lenp)
+		  void __user *buffer, size_t *lenp)
 {
 	return -ENOSYS;
 }
 
 int proc_dointvec(ctl_table *table, int write, struct file *filp,
-		  void *buffer, size_t *lenp)
+		  void __user *buffer, size_t *lenp)
 {
 	return -ENOSYS;
 }
 
 int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
-			void *buffer, size_t *lenp)
+			void __user *buffer, size_t *lenp)
 {
 	return -ENOSYS;
 }
 
 int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
-		    void *buffer, size_t *lenp)
+		    void __user *buffer, size_t *lenp)
 {
 	return -ENOSYS;
 }
@@ -1511,14 +1511,14 @@
 }
 
 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
-		    void *buffer, size_t *lenp)
+		    void __user *buffer, size_t *lenp)
 {
 	return -ENOSYS;
 }
 
 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
 				      struct file *filp,
-				      void *buffer, size_t *lenp)
+				      void __user *buffer, size_t *lenp)
 {
     return -ENOSYS;
 }
diff -urN linux-2.5.69-bk7/kernel/timer.c linux-2.5.69-bk8/kernel/timer.c
--- linux-2.5.69-bk7/kernel/timer.c	2003-05-04 16:53:37.000000000 -0700
+++ linux-2.5.69-bk8/kernel/timer.c	2003-05-13 04:44:30.000000000 -0700
@@ -905,7 +905,7 @@
 	parent = me->group_leader->real_parent;
 	for (;;) {
 		pid = parent->tgid;
-#if CONFIG_SMP
+#ifdef CONFIG_SMP
 {
 		struct task_struct *old = parent;
 
diff -urN linux-2.5.69-bk7/lib/Makefile linux-2.5.69-bk8/lib/Makefile
--- linux-2.5.69-bk7/lib/Makefile	2003-05-04 16:53:00.000000000 -0700
+++ linux-2.5.69-bk8/lib/Makefile	2003-05-13 04:44:30.000000000 -0700
@@ -8,7 +8,7 @@
 
 L_TARGET := lib.a
 
-obj-y := errno.o ctype.o string.o vsprintf.o brlock.o cmdline.o \
+obj-y := errno.o ctype.o string.o vsprintf.o cmdline.o \
 	 bust_spinlocks.o rbtree.o radix-tree.o dump_stack.o \
 	 kobject.o idr.o
 
diff -urN linux-2.5.69-bk7/lib/brlock.c linux-2.5.69-bk8/lib/brlock.c
--- linux-2.5.69-bk7/lib/brlock.c	2003-05-04 16:53:35.000000000 -0700
+++ linux-2.5.69-bk8/lib/brlock.c	1969-12-31 16:00:00.000000000 -0800
@@ -1,72 +0,0 @@
-/*
- *
- * linux/lib/brlock.c
- *
- * 'Big Reader' read-write spinlocks.  See linux/brlock.h for details.
- *
- * Copyright 2000, Ingo Molnar <mingo@redhat.com>
- * Copyright 2000, David S. Miller <davem@redhat.com>
- */
-
-#include <linux/config.h>
-
-#ifdef CONFIG_SMP
-
-#include <linux/sched.h>
-#include <linux/brlock.h>
-
-#ifdef __BRLOCK_USE_ATOMICS
-
-brlock_read_lock_t __brlock_array[NR_CPUS][__BR_IDX_MAX] =
-   { [0 ... NR_CPUS-1] = { [0 ... __BR_IDX_MAX-1] = RW_LOCK_UNLOCKED } };
-
-void __br_write_lock (enum brlock_indices idx)
-{
-	int i;
-
-	preempt_disable();
-	for (i = 0; i < NR_CPUS; i++)
-		_raw_write_lock(&__brlock_array[i][idx]);
-}
-
-void __br_write_unlock (enum brlock_indices idx)
-{
-	int i;
-
-	for (i = 0; i < NR_CPUS; i++)
-		_raw_write_unlock(&__brlock_array[i][idx]);
-	preempt_enable();
-}
-
-#else /* ! __BRLOCK_USE_ATOMICS */
-
-brlock_read_lock_t __brlock_array[NR_CPUS][__BR_IDX_MAX] =
-   { [0 ... NR_CPUS-1] = { [0 ... __BR_IDX_MAX-1] = 0 } };
-
-struct br_wrlock __br_write_locks[__BR_IDX_MAX] =
-   { [0 ... __BR_IDX_MAX-1] = { SPIN_LOCK_UNLOCKED } };
-
-void __br_write_lock (enum brlock_indices idx)
-{
-	int i;
-
-	preempt_disable();
-again:
-	_raw_spin_lock(&__br_write_locks[idx].lock);
-	for (i = 0; i < NR_CPUS; i++)
-		if (__brlock_array[i][idx] != 0) {
-			_raw_spin_unlock(&__br_write_locks[idx].lock);
-			barrier();
-			cpu_relax();
-			goto again;
-		}
-}
-
-void __br_write_unlock (enum brlock_indices idx)
-{
-	spin_unlock(&__br_write_locks[idx].lock);
-}
-
-#endif /* __BRLOCK_USE_ATOMICS */
-
-#endif /* CONFIG_SMP */
diff -urN linux-2.5.69-bk7/mm/bootmem.c linux-2.5.69-bk8/mm/bootmem.c
--- linux-2.5.69-bk7/mm/bootmem.c	2003-05-04 16:53:09.000000000 -0700
+++ linux-2.5.69-bk8/mm/bootmem.c	2003-05-13 04:44:30.000000000 -0700
@@ -311,7 +311,7 @@
 
 void __init free_bootmem_node (pg_data_t *pgdat, unsigned long physaddr, unsigned long size)
 {
-	return(free_bootmem_core(pgdat->bdata, physaddr, size));
+	free_bootmem_core(pgdat->bdata, physaddr, size);
 }
 
 unsigned long __init free_all_bootmem_node (pg_data_t *pgdat)
@@ -336,7 +336,7 @@
 
 void __init free_bootmem (unsigned long addr, unsigned long size)
 {
-	return(free_bootmem_core(contig_page_data.bdata, addr, size));
+	free_bootmem_core(contig_page_data.bdata, addr, size);
 }
 
 unsigned long __init free_all_bootmem (void)
diff -urN linux-2.5.69-bk7/mm/filemap.c linux-2.5.69-bk8/mm/filemap.c
--- linux-2.5.69-bk7/mm/filemap.c	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/mm/filemap.c	2003-05-13 04:44:30.000000000 -0700
@@ -802,7 +802,7 @@
 }
 
 ssize_t
-generic_file_aio_read(struct kiocb *iocb, char *buf, size_t count, loff_t pos)
+generic_file_aio_read(struct kiocb *iocb, char __user *buf, size_t count, loff_t pos)
 {
 	struct iovec local_iov = { .iov_base = buf, .iov_len = count };
 
@@ -812,7 +812,7 @@
 EXPORT_SYMBOL(generic_file_aio_read);
 
 ssize_t
-generic_file_read(struct file *filp, char *buf, size_t count, loff_t *ppos)
+generic_file_read(struct file *filp, char __user *buf, size_t count, loff_t *ppos)
 {
 	struct iovec local_iov = { .iov_base = buf, .iov_len = count };
 	struct kiocb kiocb;
@@ -846,7 +846,7 @@
 }
 
 ssize_t generic_file_sendfile(struct file *in_file, loff_t *ppos,
-			 size_t count, read_actor_t actor, void *target)
+			 size_t count, read_actor_t actor, void __user *target)
 {
 	read_descriptor_t desc;
 
@@ -1412,7 +1412,7 @@
 
 static inline int
 filemap_copy_from_user(struct page *page, unsigned long offset,
-			const char *buf, unsigned bytes)
+			const char __user *buf, unsigned bytes)
 {
 	char *kaddr;
 	int left;
@@ -1437,7 +1437,7 @@
 	int left = 0;
 
 	while (bytes) {
-		char *buf = iov->iov_base + base;
+		char __user *buf = iov->iov_base + base;
 		int copy = min(bytes, iov->iov_len - base);
 		base = 0;
 		if ((left = __copy_from_user(vaddr, buf, copy)))
@@ -1601,7 +1601,7 @@
 	const struct iovec *cur_iov = iov; /* current iovec */
 	size_t		iov_base = 0;	   /* offset in the current iovec */
 	unsigned long	seg;
-	char		*buf;
+	char __user	*buf;
 
 	ocount = 0;
 	for (seg = 0; seg < nr_segs; seg++) {
@@ -1775,13 +1775,13 @@
 	return ret;
 }
 
-ssize_t generic_file_aio_write(struct kiocb *iocb, const char *buf,
+ssize_t generic_file_aio_write(struct kiocb *iocb, const char __user *buf,
 			       size_t count, loff_t pos)
 {
 	struct file *file = iocb->ki_filp;
 	struct inode *inode = file->f_dentry->d_inode->i_mapping->host;
 	ssize_t err;
-	struct iovec local_iov = { .iov_base = (void *)buf, .iov_len = count };
+	struct iovec local_iov = { .iov_base = (void __user *)buf, .iov_len = count };
 
 	BUG_ON(iocb->ki_pos != pos);
 
@@ -1795,12 +1795,12 @@
 EXPORT_SYMBOL(generic_file_aio_write);
 EXPORT_SYMBOL(generic_file_aio_write_nolock);
 
-ssize_t generic_file_write(struct file *file, const char *buf,
+ssize_t generic_file_write(struct file *file, const char __user *buf,
 			   size_t count, loff_t *ppos)
 {
 	struct inode	*inode = file->f_dentry->d_inode->i_mapping->host;
 	ssize_t		err;
-	struct iovec local_iov = { .iov_base = (void *)buf, .iov_len = count };
+	struct iovec local_iov = { .iov_base = (void __user *)buf, .iov_len = count };
 
 	down(&inode->i_sem);
 	err = generic_file_write_nolock(file, &local_iov, 1, ppos);
diff -urN linux-2.5.69-bk7/mm/mincore.c linux-2.5.69-bk8/mm/mincore.c
--- linux-2.5.69-bk7/mm/mincore.c	2003-05-04 16:53:56.000000000 -0700
+++ linux-2.5.69-bk8/mm/mincore.c	2003-05-13 04:44:30.000000000 -0700
@@ -39,7 +39,7 @@
 }
 
 static long mincore_vma(struct vm_area_struct * vma,
-	unsigned long start, unsigned long end, unsigned char * vec)
+	unsigned long start, unsigned long end, unsigned char __user * vec)
 {
 	long error, i, remaining;
 	unsigned char * tmp;
@@ -106,7 +106,7 @@
  *  -EAGAIN - A kernel resource was temporarily unavailable.
  */
 asmlinkage long sys_mincore(unsigned long start, size_t len,
-	unsigned char * vec)
+	unsigned char __user * vec)
 {
 	int index = 0;
 	unsigned long end;
diff -urN linux-2.5.69-bk7/mm/mmap.c linux-2.5.69-bk8/mm/mmap.c
--- linux-2.5.69-bk7/mm/mmap.c	2003-05-04 16:53:32.000000000 -0700
+++ linux-2.5.69-bk8/mm/mmap.c	2003-05-13 04:44:30.000000000 -0700
@@ -471,6 +471,8 @@
 			spin_unlock(lock);
 			if (need_up)
 				up(&inode->i_mapping->i_shared_sem);
+			if (file)
+				fput(file);
 
 			mm->map_count--;
 			kmem_cache_free(vm_area_cachep, next);
@@ -1440,7 +1442,7 @@
 	vm_unacct_memory(nr_accounted);
 	BUG_ON(mm->map_count);	/* This is just debugging */
 	clear_page_tables(tlb, FIRST_USER_PGD_NR, USER_PTRS_PER_PGD);
-	tlb_finish_mmu(tlb, 0, TASK_SIZE);
+	tlb_finish_mmu(tlb, 0, MM_VM_SIZE(mm));
 
 	vma = mm->mmap;
 	mm->mmap = mm->mmap_cache = NULL;
diff -urN linux-2.5.69-bk7/mm/page_alloc.c linux-2.5.69-bk8/mm/page_alloc.c
--- linux-2.5.69-bk7/mm/page_alloc.c	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/mm/page_alloc.c	2003-05-13 04:44:30.000000000 -0700
@@ -336,21 +336,17 @@
 static struct page *__rmqueue(struct zone *zone, unsigned int order)
 {
 	struct free_area * area;
-	unsigned int current_order = order;
-	struct list_head *head, *curr;
+	unsigned int current_order;
 	struct page *page;
 	unsigned int index;
 
-	for (current_order=order; current_order < MAX_ORDER; ++current_order) {
+	for (current_order = order; current_order < MAX_ORDER; ++current_order) {
 		area = zone->free_area + current_order;
-		head = &area->free_list;
-		curr = head->next;
-
 		if (list_empty(&area->free_list))
 			continue;
 
-		page = list_entry(curr, struct page, list);
-		list_del(curr);
+		page = list_entry(area->free_list.next, struct page, list);
+		list_del(&page->list);
 		index = page - zone->zone_mem_map;
 		if (current_order != MAX_ORDER-1)
 			MARK_USED(index, current_order, area);
@@ -792,7 +788,7 @@
 	return nr_free_zone_pages(GFP_HIGHUSER & GFP_ZONEMASK);
 }
 
-#if CONFIG_HIGHMEM
+#ifdef CONFIG_HIGHMEM
 unsigned int nr_free_highpages (void)
 {
 	pg_data_t *pgdat;
diff -urN linux-2.5.69-bk7/mm/shmem.c linux-2.5.69-bk8/mm/shmem.c
--- linux-2.5.69-bk7/mm/shmem.c	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/mm/shmem.c	2003-05-13 04:44:30.000000000 -0700
@@ -1114,7 +1114,7 @@
 }
 
 static ssize_t
-shmem_file_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
+shmem_file_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
 {
 	struct inode	*inode = file->f_dentry->d_inode;
 	loff_t		pos;
@@ -1310,7 +1310,7 @@
 	update_atime(inode);
 }
 
-static ssize_t shmem_file_read(struct file *filp, char *buf, size_t count, loff_t *ppos)
+static ssize_t shmem_file_read(struct file *filp, char __user *buf, size_t count, loff_t *ppos)
 {
 	read_descriptor_t desc;
 
@@ -1333,7 +1333,7 @@
 }
 
 static ssize_t shmem_file_sendfile(struct file *in_file, loff_t *ppos,
-			 size_t count, read_actor_t actor, void *target)
+			 size_t count, read_actor_t actor, void __user *target)
 {
 	read_descriptor_t desc;
 
@@ -1519,7 +1519,7 @@
 	return 0;
 }
 
-static int shmem_readlink_inline(struct dentry *dentry, char *buffer, int buflen)
+static int shmem_readlink_inline(struct dentry *dentry, char __user *buffer, int buflen)
 {
 	return vfs_readlink(dentry, buffer, buflen, (const char *)SHMEM_I(dentry->d_inode));
 }
@@ -1529,7 +1529,7 @@
 	return vfs_follow_link(nd, (const char *)SHMEM_I(dentry->d_inode));
 }
 
-static int shmem_readlink(struct dentry *dentry, char *buffer, int buflen)
+static int shmem_readlink(struct dentry *dentry, char __user *buffer, int buflen)
 {
 	struct page *page = NULL;
 	int res = shmem_getpage(dentry->d_inode, 0, &page, SGP_READ);
diff -urN linux-2.5.69-bk7/mm/slab.c linux-2.5.69-bk8/mm/slab.c
--- linux-2.5.69-bk7/mm/slab.c	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/mm/slab.c	2003-05-13 04:44:30.000000000 -0700
@@ -949,7 +949,7 @@
 	 *   with object sizes just above a power of two have a significant
 	 *   amount of internal fragmentation
 	 */
-	if ((size < (PAGE_SIZE>>3) || fls(size-1) == fls(size-1+3*BYTES_PER_WORD))
+	if ((size < 4096 || fls(size-1) == fls(size-1+3*BYTES_PER_WORD))
 			&& !(flags & SLAB_MUST_HWCACHE_ALIGN)) {
 		flags |= SLAB_RED_ZONE|SLAB_STORE_USER;
 	}
@@ -2448,7 +2448,7 @@
  * @count: data len
  * @data: unused
  */
-ssize_t slabinfo_write(struct file *file, const char *buffer,
+ssize_t slabinfo_write(struct file *file, const char __user *buffer,
 				size_t count, loff_t *ppos)
 {
 	char kbuf[MAX_SLABINFO_WRITE+1], *tmp;
diff -urN linux-2.5.69-bk7/mm/vmalloc.c linux-2.5.69-bk8/mm/vmalloc.c
--- linux-2.5.69-bk7/mm/vmalloc.c	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/mm/vmalloc.c	2003-05-13 04:44:30.000000000 -0700
@@ -260,6 +260,7 @@
 	return NULL;
 
 found:
+	unmap_vm_area(tmp);
 	*p = tmp->next;
 	write_unlock(&vmlist_lock);
 	return tmp;
@@ -283,8 +284,6 @@
 				addr);
 		return;
 	}
-
-	unmap_vm_area(area);
 	
 	if (deallocate_pages) {
 		int i;
diff -urN linux-2.5.69-bk7/net/bridge/br_fdb.c linux-2.5.69-bk8/net/bridge/br_fdb.c
--- linux-2.5.69-bk7/net/bridge/br_fdb.c	2003-05-04 16:53:01.000000000 -0700
+++ linux-2.5.69-bk8/net/bridge/br_fdb.c	2003-05-13 04:44:30.000000000 -0700
@@ -20,25 +20,19 @@
 #include <asm/uaccess.h>
 #include "br_private.h"
 
-static __inline__ unsigned long __timeout(struct net_bridge *br)
+/* if topology_changing then use forward_delay (default 15 sec)
+ * otherwise keep longer (default 5 minutes)
+ */
+static __inline__ unsigned long hold_time(const struct net_bridge *br)
 {
-	unsigned long timeout;
-
-	timeout = jiffies - br->ageing_time;
-	if (br->topology_change)
-		timeout = jiffies - br->forward_delay;
-
-	return timeout;
+	return br->topology_change ? br->forward_delay : br->ageing_time;
 }
 
-static __inline__ int has_expired(struct net_bridge *br,
-				  struct net_bridge_fdb_entry *fdb)
+static __inline__ int has_expired(const struct net_bridge *br,
+				  const struct net_bridge_fdb_entry *fdb)
 {
-	if (!fdb->is_static &&
-	    time_before_eq(fdb->ageing_timer, __timeout(br)))
-		return 1;
-
-	return 0;
+	return !fdb->is_static 
+		&& time_before_eq(fdb->ageing_timer + hold_time(br), jiffies);
 }
 
 static __inline__ void copy_fdb(struct __fdb_entry *ent, 
@@ -52,7 +46,7 @@
 		: ((jiffies - f->ageing_timer) * USER_HZ) / HZ;
 }
 
-static __inline__ int br_mac_hash(unsigned char *mac)
+static __inline__ int br_mac_hash(const unsigned char *mac)
 {
 	unsigned long x;
 
@@ -68,7 +62,14 @@
 	return x & (BR_HASH_SIZE - 1);
 }
 
-void br_fdb_changeaddr(struct net_bridge_port *p, unsigned char *newaddr)
+static __inline__ void fdb_delete(struct net_bridge_fdb_entry *f)
+{
+	hlist_del(&f->hlist);
+	list_del(&f->age_list);
+	br_fdb_put(f);
+}
+
+void br_fdb_changeaddr(struct net_bridge_port *p, const unsigned char *newaddr)
 {
 	struct net_bridge *br;
 	int i;
@@ -98,25 +99,29 @@
 	write_unlock_bh(&br->hash_lock);
 }
 
-void br_fdb_cleanup(struct net_bridge *br)
+void br_fdb_cleanup(unsigned long _data)
 {
-	int i;
-	unsigned long timeout;
-
-	timeout = __timeout(br);
+	struct net_bridge *br = (struct net_bridge *)_data;
+	struct list_head *l, *n;
+	unsigned long delay;
 
 	write_lock_bh(&br->hash_lock);
-	for (i=0;i<BR_HASH_SIZE;i++) {
-		struct hlist_node *h, *g;
-		
-		hlist_for_each_safe(h, g, &br->hash[i]) {
-			struct net_bridge_fdb_entry *f
-				= hlist_entry(h, struct net_bridge_fdb_entry, hlist);
-			if (!f->is_static &&
-			    time_before_eq(f->ageing_timer, timeout)) {
-				hlist_del(&f->hlist);
-				br_fdb_put(f);
+	delay = hold_time(br);
+
+	list_for_each_safe(l, n, &br->age_list) {
+		struct net_bridge_fdb_entry *f
+			= list_entry(l, struct net_bridge_fdb_entry, age_list);
+		unsigned long expires = f->ageing_timer + delay;
+
+		if (time_before_eq(expires, jiffies)) {
+			if (!f->is_static) {
+				pr_debug("expire age %lu jiffies %lu\n",
+					 f->ageing_timer, jiffies);
+				fdb_delete(f);
 			}
+		} else {
+			mod_timer(&br->gc_timer, expires);
+			break;
 		}
 	}
 	write_unlock_bh(&br->hash_lock);
@@ -134,8 +139,7 @@
 			struct net_bridge_fdb_entry *f
 				= hlist_entry(h, struct net_bridge_fdb_entry, hlist);
 			if (f->dst == p) {
-				hlist_del(&f->hlist);
-				br_fdb_put(f);
+				fdb_delete(f);
 			}
 		}
 	}
@@ -237,55 +241,46 @@
 	return num;
 }
 
-static __inline__ void __fdb_possibly_replace(struct net_bridge_fdb_entry *fdb,
-					      struct net_bridge_port *source,
-					      int is_local)
-{
-	if (!fdb->is_static || is_local) {
-		fdb->dst = source;
-		fdb->is_local = is_local;
-		fdb->is_static = is_local;
-		fdb->ageing_timer = jiffies;
-	}
-}
-
-void br_fdb_insert(struct net_bridge *br,
-		   struct net_bridge_port *source,
-		   unsigned char *addr,
-		   int is_local)
+void br_fdb_insert(struct net_bridge *br, struct net_bridge_port *source,
+		   const unsigned char *addr, int is_local)
 {
 	struct hlist_node *h;
 	struct net_bridge_fdb_entry *fdb;
-	int hash;
-
-	hash = br_mac_hash(addr);
+	int hash = br_mac_hash(addr);
 
 	write_lock_bh(&br->hash_lock);
 	hlist_for_each(h, &br->hash[hash]) {
 		fdb = hlist_entry(h, struct net_bridge_fdb_entry, hlist);
 		if (!fdb->is_local &&
 		    !memcmp(fdb->addr.addr, addr, ETH_ALEN)) {
-			__fdb_possibly_replace(fdb, source, is_local);
-			write_unlock_bh(&br->hash_lock);
-			return;
+			if (likely(!fdb->is_static || is_local)) {
+				/* move to end of age list */
+				list_del(&fdb->age_list);
+				goto update;
+			}
+			goto out;
 		}
-
 	}
 
 	fdb = kmalloc(sizeof(*fdb), GFP_ATOMIC);
-	if (fdb == NULL) {
-		write_unlock_bh(&br->hash_lock);
-		return;
-	}
+	if (fdb == NULL) 
+		goto out;
 
 	memcpy(fdb->addr.addr, addr, ETH_ALEN);
 	atomic_set(&fdb->use_count, 1);
+	hlist_add_head(&fdb->hlist, &br->hash[hash]);
+
+	if (!timer_pending(&br->gc_timer)) {
+		br->gc_timer.expires = jiffies + hold_time(br);
+		add_timer(&br->gc_timer);
+	}
+
+ update:
 	fdb->dst = source;
 	fdb->is_local = is_local;
 	fdb->is_static = is_local;
 	fdb->ageing_timer = jiffies;
-
-	hlist_add_head(&fdb->hlist, &br->hash[hash]);
-
+	list_add_tail(&fdb->age_list, &br->age_list);
+ out:
 	write_unlock_bh(&br->hash_lock);
 }
diff -urN linux-2.5.69-bk7/net/bridge/br_if.c linux-2.5.69-bk8/net/bridge/br_if.c
--- linux-2.5.69-bk7/net/bridge/br_if.c	2003-05-04 16:53:56.000000000 -0700
+++ linux-2.5.69-bk8/net/bridge/br_if.c	2003-05-13 04:44:30.000000000 -0700
@@ -84,8 +84,6 @@
 	memset(br, 0, sizeof(*br));
 	dev = &br->dev;
 
-	init_timer(&br->tick);
-
 	strncpy(dev->name, name, IFNAMSIZ);
 	dev->priv = br;
 	dev->priv_flags = IFF_EBRIDGE;
@@ -109,12 +107,10 @@
 	br->bridge_forward_delay = br->forward_delay = 15 * HZ;
 	br->topology_change = 0;
 	br->topology_change_detected = 0;
-	br_timer_clear(&br->hello_timer);
-	br_timer_clear(&br->tcn_timer);
-	br_timer_clear(&br->topology_change_timer);
-
 	br->ageing_time = 300 * HZ;
-	br->gc_interval = 4 * HZ;
+	INIT_LIST_HEAD(&br->age_list);
+
+	br_stp_timer_init(br);
 
 	return br;
 }
diff -urN linux-2.5.69-bk7/net/bridge/br_ioctl.c linux-2.5.69-bk8/net/bridge/br_ioctl.c
--- linux-2.5.69-bk7/net/bridge/br_ioctl.c	2003-05-04 16:53:02.000000000 -0700
+++ linux-2.5.69-bk8/net/bridge/br_ioctl.c	2003-05-13 04:44:30.000000000 -0700
@@ -32,9 +32,10 @@
 }
 
 /* Report time remaining in user HZ  */
-static unsigned long timer_residue(const struct br_timer *timer)
+static unsigned long timer_residue(const struct timer_list *timer)
 {
-	return ticks_to_user(timer->running ? (jiffies - timer->expires) : 0);
+	return ticks_to_user(timer_pending(timer) 
+			     ? (timer->expires - jiffies) : 0);
 }
 
 static int br_ioctl_device(struct net_bridge *br,
@@ -87,7 +88,6 @@
 		b.root_port = br->root_port;
 		b.stp_enabled = br->stp_enabled;
 		b.ageing_time = ticks_to_user(br->ageing_time);
-		b.gc_interval = ticks_to_user(br->gc_interval);
 		b.hello_timer_value = timer_residue(&br->hello_timer);
 		b.tcn_timer_value = timer_residue(&br->tcn_timer);
 		b.topology_change_timer_value = timer_residue(&br->topology_change_timer);
@@ -146,8 +146,7 @@
 		br->ageing_time = user_to_ticks(arg0);
 		return 0;
 
-	case BRCTL_SET_GC_INTERVAL:
-		br->gc_interval = user_to_ticks(arg0);
+	case BRCTL_SET_GC_INTERVAL:	 /* no longer used */
 		return 0;
 
 	case BRCTL_GET_PORT_INFO:
diff -urN linux-2.5.69-bk7/net/bridge/br_private.h linux-2.5.69-bk8/net/bridge/br_private.h
--- linux-2.5.69-bk7/net/bridge/br_private.h	2003-05-04 16:53:08.000000000 -0700
+++ linux-2.5.69-bk8/net/bridge/br_private.h	2003-05-13 04:44:30.000000000 -0700
@@ -18,7 +18,6 @@
 #include <linux/netdevice.h>
 #include <linux/miscdevice.h>
 #include <linux/if_bridge.h>
-#include "br_private_timer.h"
 
 #define BR_HASH_BITS 8
 #define BR_HASH_SIZE (1 << BR_HASH_BITS)
@@ -44,10 +43,11 @@
 struct net_bridge_fdb_entry
 {
 	struct hlist_node		hlist;
-	atomic_t			use_count;
-	mac_addr			addr;
 	struct net_bridge_port		*dst;
+	struct list_head		age_list;
+	atomic_t			use_count;
 	unsigned long			ageing_timer;
+	mac_addr			addr;
 	unsigned			is_local:1;
 	unsigned			is_static:1;
 };
@@ -71,10 +71,9 @@
 	unsigned			config_pending:1;
 	int				priority;
 
-	struct br_timer			forward_delay_timer;
-	struct br_timer			hold_timer;
-	struct br_timer			message_age_timer;
-
+	struct timer_list		forward_delay_timer;
+	struct timer_list		hold_timer;
+	struct timer_list		message_age_timer;
 	struct rcu_head			rcu;
 };
 
@@ -86,7 +85,7 @@
 	struct net_device_stats		statistics;
 	rwlock_t			hash_lock;
 	struct hlist_head		hash[BR_HASH_SIZE];
-	struct timer_list		tick;
+	struct list_head		age_list;
 
 	/* STP */
 	bridge_id			designated_root;
@@ -103,13 +102,12 @@
 	unsigned			topology_change:1;
 	unsigned			topology_change_detected:1;
 
-	struct br_timer			hello_timer;
-	struct br_timer			tcn_timer;
-	struct br_timer			topology_change_timer;
-	struct br_timer			gc_timer;
+	struct timer_list		hello_timer;
+	struct timer_list		tcn_timer;
+	struct timer_list		topology_change_timer;
+	struct timer_list		gc_timer;
 
 	int				ageing_time;
-	int				gc_interval;
 };
 
 extern struct notifier_block br_device_notifier;
@@ -128,8 +126,8 @@
 
 /* br_fdb.c */
 extern void br_fdb_changeaddr(struct net_bridge_port *p,
-		       unsigned char *newaddr);
-extern void br_fdb_cleanup(struct net_bridge *br);
+			      const unsigned char *newaddr);
+extern void br_fdb_cleanup(unsigned long arg);
 extern void br_fdb_delete_by_port(struct net_bridge *br,
 			   struct net_bridge_port *p);
 extern struct net_bridge_fdb_entry *br_fdb_get(struct net_bridge *br,
@@ -140,9 +138,9 @@
 			int maxnum,
 			int offset);
 extern void br_fdb_insert(struct net_bridge *br,
-		   struct net_bridge_port *source,
-		   unsigned char *addr,
-		   int is_local);
+			  struct net_bridge_port *source,
+			  const unsigned char *addr,
+			  int is_local);
 
 /* br_forward.c */
 extern void br_deliver(const struct net_bridge_port *to,
@@ -188,10 +186,10 @@
 extern void br_netfilter_fini(void);
 
 /* br_stp.c */
+extern void br_log_state(const struct net_bridge_port *p);
 extern struct net_bridge_port *br_get_port(struct net_bridge *br,
 				    int port_no);
 extern void br_init_port(struct net_bridge_port *p);
-extern port_id br_make_port_id(struct net_bridge_port *p);
 extern void br_become_designated_port(struct net_bridge_port *p);
 
 /* br_stp_if.c */
@@ -210,4 +208,8 @@
 /* br_stp_bpdu.c */
 extern void br_stp_handle_bpdu(struct sk_buff *skb);
 
+/* br_stp_timer.c */
+extern void br_stp_timer_init(struct net_bridge *br);
+extern void br_stp_port_timer_init(struct net_bridge_port *p);
+
 #endif
diff -urN linux-2.5.69-bk7/net/bridge/br_private_stp.h linux-2.5.69-bk8/net/bridge/br_private_stp.h
--- linux-2.5.69-bk7/net/bridge/br_private_stp.h	2003-05-04 16:53:31.000000000 -0700
+++ linux-2.5.69-bk8/net/bridge/br_private_stp.h	2003-05-13 04:44:30.000000000 -0700
@@ -47,7 +47,6 @@
 extern void br_port_state_selection(struct net_bridge *);
 extern void br_received_config_bpdu(struct net_bridge_port *p, struct br_config_bpdu *bpdu);
 extern void br_received_tcn_bpdu(struct net_bridge_port *p);
-extern void br_tick(unsigned long __data);
 extern void br_transmit_config(struct net_bridge_port *p);
 extern void br_transmit_tcn(struct net_bridge *br);
 extern void br_topology_change_detection(struct net_bridge *br);
diff -urN linux-2.5.69-bk7/net/bridge/br_private_timer.h linux-2.5.69-bk8/net/bridge/br_private_timer.h
--- linux-2.5.69-bk7/net/bridge/br_private_timer.h	2003-05-04 16:53:08.000000000 -0700
+++ linux-2.5.69-bk8/net/bridge/br_private_timer.h	1969-12-31 16:00:00.000000000 -0800
@@ -1,54 +0,0 @@
-/*
- *	Linux ethernet bridge
- *
- *	Authors:
- *	Lennert Buytenhek		<buytenh@gnu.org>
- *
- *	$Id: br_private_timer.h,v 1.1 2000/02/18 16:47:13 davem Exp $
- *
- *	This program is free software; you can redistribute it and/or
- *	modify it under the terms of the GNU General Public License
- *	as published by the Free Software Foundation; either version
- *	2 of the License, or (at your option) any later version.
- */
-
-#ifndef _BR_PRIVATE_TIMER_H
-#define _BR_PRIVATE_TIMER_H
-
-struct br_timer
-{
-	int running;
-	unsigned long expires;
-};
-
-extern __inline__ void br_timer_clear(struct br_timer *t)
-{
-	t->running = 0;
-}
-
-extern __inline__ unsigned long br_timer_get_residue(struct br_timer *t)
-{
-	if (t->running)
-		return jiffies - t->expires;
-
-	return 0;
-}
-
-extern __inline__ void br_timer_set(struct br_timer *t, unsigned long x)
-{
-	t->expires = x;
-	t->running = 1;
-}
-
-extern __inline__ int br_timer_is_running(struct br_timer *t)
-{
-	return t->running;
-}
-
-extern __inline__ int br_timer_has_expired(struct br_timer *t, unsigned long to)
-{
-	return t->running && time_after_eq(jiffies, t->expires + to);
-}
-
-
-#endif
diff -urN linux-2.5.69-bk7/net/bridge/br_stp.c linux-2.5.69-bk8/net/bridge/br_stp.c
--- linux-2.5.69-bk7/net/bridge/br_stp.c	2003-05-04 16:53:07.000000000 -0700
+++ linux-2.5.69-bk8/net/bridge/br_stp.c	2003-05-13 04:44:30.000000000 -0700
@@ -12,7 +12,6 @@
  *	as published by the Free Software Foundation; either version
  *	2 of the License, or (at your option) any later version.
  */
-
 #include <linux/kernel.h>
 #include <linux/if_bridge.h>
 #include <linux/smp_lock.h>
@@ -20,6 +19,18 @@
 #include "br_private.h"
 #include "br_private_stp.h"
 
+static const char *br_port_state_names[] = {
+	"disabled", "learning", "forwarding", "blocking",
+};
+
+void br_log_state(const struct net_bridge_port *p)
+{
+	pr_info("%s: port %d(%s) entering %s state\n",
+		p->br->dev.name, p->port_no, p->dev->name, 
+		br_port_state_names[p->state]);
+
+}
+
 /* called under bridge lock */
 struct net_bridge_port *br_get_port(struct net_bridge *br, int port_no)
 {
@@ -34,7 +45,8 @@
 }
 
 /* called under bridge lock */
-static int br_should_become_root_port(struct net_bridge_port *p, int root_port)
+static int br_should_become_root_port(const struct net_bridge_port *p, 
+				      int root_port)
 {
 	struct net_bridge *br;
 	struct net_bridge_port *rp;
@@ -116,9 +128,12 @@
 	br->hello_time = br->bridge_hello_time;
 	br->forward_delay = br->bridge_forward_delay;
 	br_topology_change_detection(br);
-	br_timer_clear(&br->tcn_timer);
-	br_config_bpdu_generation(br);
-	br_timer_set(&br->hello_timer, jiffies);
+	del_timer(&br->tcn_timer);
+
+	if (br->dev.flags & IFF_UP) {
+		br_config_bpdu_generation(br);
+		mod_timer(&br->hello_timer, jiffies + br->hello_time);
+	}
 }
 
 /* called under bridge lock */
@@ -127,7 +142,8 @@
 	struct br_config_bpdu bpdu;
 	struct net_bridge *br;
 
-	if (br_timer_is_running(&p->hold_timer)) {
+
+	if (timer_pending(&p->hold_timer)) {
 		p->config_pending = 1;
 		return;
 	}
@@ -142,12 +158,11 @@
 	bpdu.port_id = p->port_id;
 	bpdu.message_age = 0;
 	if (!br_is_root_bridge(br)) {
-		struct net_bridge_port *root;
-		unsigned long age;
+		struct net_bridge_port *root
+			= br_get_port(br, br->root_port);
+		bpdu.max_age = root->message_age_timer.expires - jiffies;
 
-		root = br_get_port(br, br->root_port);
-		age = br_timer_get_residue(&root->message_age_timer) + 1;
-		bpdu.message_age = age;
+		if (bpdu.max_age <= 0) bpdu.max_age = 1;
 	}
 	bpdu.max_age = br->max_age;
 	bpdu.hello_time = br->hello_time;
@@ -157,22 +172,26 @@
 
 	p->topology_change_ack = 0;
 	p->config_pending = 0;
-	br_timer_set(&p->hold_timer, jiffies);
+	
+	mod_timer(&p->hold_timer, jiffies + BR_HOLD_TIME);
 }
 
 /* called under bridge lock */
-static void br_record_config_information(struct net_bridge_port *p, struct br_config_bpdu *bpdu)
+static inline void br_record_config_information(struct net_bridge_port *p, 
+						const struct br_config_bpdu *bpdu)
 {
 	p->designated_root = bpdu->root;
 	p->designated_cost = bpdu->root_path_cost;
 	p->designated_bridge = bpdu->bridge_id;
 	p->designated_port = bpdu->port_id;
 
-	br_timer_set(&p->message_age_timer, jiffies - bpdu->message_age);
+	mod_timer(&p->message_age_timer, jiffies 
+		  + (p->br->max_age - bpdu->message_age));
 }
 
 /* called under bridge lock */
-static void br_record_config_timeout_values(struct net_bridge *br, struct br_config_bpdu *bpdu)
+static inline void br_record_config_timeout_values(struct net_bridge *br, 
+					    const struct br_config_bpdu *bpdu)
 {
 	br->max_age = bpdu->max_age;
 	br->hello_time = bpdu->hello_time;
@@ -187,7 +206,7 @@
 }
 
 /* called under bridge lock */
-static int br_should_become_designated_port(struct net_bridge_port *p)
+static int br_should_become_designated_port(const struct net_bridge_port *p)
 {
 	struct net_bridge *br;
 	int t;
@@ -261,25 +280,28 @@
 }
 
 /* called under bridge lock */
-static void br_topology_change_acknowledged(struct net_bridge *br)
+static inline void br_topology_change_acknowledged(struct net_bridge *br)
 {
 	br->topology_change_detected = 0;
-	br_timer_clear(&br->tcn_timer);
+	del_timer(&br->tcn_timer);
 }
 
 /* called under bridge lock */
 void br_topology_change_detection(struct net_bridge *br)
 {
-	printk(KERN_INFO "%s: topology change detected", br->dev.name);
+	if (!(br->dev.flags & IFF_UP))
+		return;
 
+	pr_info("%s: topology change detected", br->dev.name);
 	if (br_is_root_bridge(br)) {
 		printk(", propagating");
 		br->topology_change = 1;
-		br_timer_set(&br->topology_change_timer, jiffies);
+		mod_timer(&br->topology_change_timer, jiffies
+			  + br->bridge_forward_delay + br->bridge_max_age);
 	} else if (!br->topology_change_detected) {
 		printk(", sending tcn bpdu");
 		br_transmit_tcn(br);
-		br_timer_set(&br->tcn_timer, jiffies);
+		mod_timer(&br->tcn_timer, jiffies + br->bridge_hello_time);
 	}
 
 	printk("\n");
@@ -299,7 +321,7 @@
 }
 
 /* called under bridge lock */
-static void br_reply(struct net_bridge_port *p)
+static inline void br_reply(struct net_bridge_port *p)
 {
 	br_transmit_config(p);
 }
@@ -323,6 +345,7 @@
 	p->designated_port = p->port_id;
 }
 
+
 /* called under bridge lock */
 static void br_make_blocking(struct net_bridge_port *p)
 {
@@ -332,11 +355,9 @@
 		    p->state == BR_STATE_LEARNING)
 			br_topology_change_detection(p->br);
 
-		printk(KERN_INFO "%s: port %i(%s) entering %s state\n",
-		       p->br->dev.name, p->port_no, p->dev->name, "blocking");
-
 		p->state = BR_STATE_BLOCKING;
-		br_timer_clear(&p->forward_delay_timer);
+		br_log_state(p);
+		del_timer(&p->forward_delay_timer);
 	}
 }
 
@@ -345,20 +366,12 @@
 {
 	if (p->state == BR_STATE_BLOCKING) {
 		if (p->br->stp_enabled) {
-			printk(KERN_INFO "%s: port %i(%s) entering %s state\n",
-			       p->br->dev.name, p->port_no, p->dev->name,
-			       "listening");
-
 			p->state = BR_STATE_LISTENING;
 		} else {
-			printk(KERN_INFO "%s: port %i(%s) entering %s state\n",
-			       p->br->dev.name, p->port_no, p->dev->name,
-			       "learning");
-
 			p->state = BR_STATE_LEARNING;
 		}
-		br_timer_set(&p->forward_delay_timer, jiffies);
-	}
+		br_log_state(p);
+		mod_timer(&p->forward_delay_timer, jiffies + p->br->forward_delay);	}
 }
 
 /* called under bridge lock */
@@ -373,7 +386,7 @@
 				p->topology_change_ack = 0;
 				br_make_forwarding(p);
 			} else if (br_is_designated_port(p)) {
-				br_timer_clear(&p->message_age_timer);
+				del_timer(&p->message_age_timer);
 				br_make_forwarding(p);
 			} else {
 				p->config_pending = 0;
@@ -381,11 +394,12 @@
 				br_make_blocking(p);
 			}
 		}
+
 	}
 }
 
 /* called under bridge lock */
-static void br_topology_change_acknowledge(struct net_bridge_port *p)
+static inline void br_topology_change_acknowledge(struct net_bridge_port *p)
 {
 	p->topology_change_ack = 1;
 	br_transmit_config(p);
@@ -396,20 +410,23 @@
 {
 	struct net_bridge *br;
 	int was_root;
-
+ 
 	br = p->br;
 	was_root = br_is_root_bridge(br);
+
 	if (br_supersedes_port_info(p, bpdu)) {
 		br_record_config_information(p, bpdu);
 		br_configuration_update(br);
 		br_port_state_selection(br);
 
 		if (!br_is_root_bridge(br) && was_root) {
-			br_timer_clear(&br->hello_timer);
+			del_timer(&br->hello_timer);
 			if (br->topology_change_detected) {
-				br_timer_clear(&br->topology_change_timer);
+				del_timer(&br->topology_change_timer);
 				br_transmit_tcn(br);
-				br_timer_set(&br->tcn_timer, jiffies);
+
+				mod_timer(&br->tcn_timer, 
+					  jiffies + br->bridge_hello_time);
 			}
 		}
 
@@ -428,7 +445,7 @@
 void br_received_tcn_bpdu(struct net_bridge_port *p)
 {
 	if (br_is_designated_port(p)) {
-		printk(KERN_INFO "%s: received tcn bpdu on port %i(%s)\n",
+		pr_info("%s: received tcn bpdu on port %i(%s)\n",
 		       p->br->dev.name, p->port_no, p->dev->name);
 
 		br_topology_change_detection(p->br);
diff -urN linux-2.5.69-bk7/net/bridge/br_stp_if.c linux-2.5.69-bk8/net/bridge/br_stp_if.c
--- linux-2.5.69-bk7/net/bridge/br_stp_if.c	2003-05-04 16:53:41.000000000 -0700
+++ linux-2.5.69-bk8/net/bridge/br_stp_if.c	2003-05-13 04:44:30.000000000 -0700
@@ -20,7 +20,7 @@
 #include "br_private.h"
 #include "br_private_stp.h"
 
-__u16 br_make_port_id(struct net_bridge_port *p)
+static inline __u16 br_make_port_id(const struct net_bridge_port *p)
 {
 	return (p->priority << 8) | p->port_no;
 }
@@ -33,33 +33,25 @@
 	p->state = BR_STATE_BLOCKING;
 	p->topology_change_ack = 0;
 	p->config_pending = 0;
-	br_timer_clear(&p->message_age_timer);
-	br_timer_clear(&p->forward_delay_timer);
-	br_timer_clear(&p->hold_timer);
+
+	br_stp_port_timer_init(p);
 }
 
 /* called under bridge lock */
 void br_stp_enable_bridge(struct net_bridge *br)
 {
 	struct net_bridge_port *p;
-	struct timer_list *timer = &br->tick;
 
 	spin_lock_bh(&br->lock);
-	init_timer(timer);
-	timer->data = (unsigned long) br;
-	timer->function = br_tick;
-	timer->expires = jiffies + 1;
-	add_timer(timer);
-
-	br_timer_set(&br->hello_timer, jiffies);
+	br->hello_timer.expires = jiffies + br->hello_time;
+	add_timer(&br->hello_timer);
 	br_config_bpdu_generation(br);
 
 	list_for_each_entry(p, &br->port_list, list) {
 		if (p->dev->flags & IFF_UP)
 			br_stp_enable_port(p);
-	}
 
-	br_timer_set(&br->gc_timer, jiffies);
+	}
 	spin_unlock_bh(&br->lock);
 }
 
@@ -68,22 +60,22 @@
 {
 	struct net_bridge_port *p;
 
-	spin_lock_bh(&br->lock);
-	br->topology_change = 0;
-	br->topology_change_detected = 0;
-	br_timer_clear(&br->hello_timer);
-	br_timer_clear(&br->topology_change_timer);
-	br_timer_clear(&br->tcn_timer);
-	br_timer_clear(&br->gc_timer);
-	br_fdb_cleanup(br);
-
+	spin_lock(&br->lock);
 	list_for_each_entry(p, &br->port_list, list) {
 		if (p->state != BR_STATE_DISABLED)
 			br_stp_disable_port(p);
+
 	}
-	spin_unlock_bh(&br->lock);
 
-	del_timer_sync(&br->tick);
+	br->topology_change = 0;
+	br->topology_change_detected = 0;
+	spin_unlock(&br->lock);
+
+	del_timer_sync(&br->hello_timer);
+	del_timer_sync(&br->topology_change_timer);
+	del_timer_sync(&br->tcn_timer);
+	del_timer_sync(&br->gc_timer);
+
 }
 
 /* called under bridge lock */
@@ -108,10 +100,13 @@
 	p->state = BR_STATE_DISABLED;
 	p->topology_change_ack = 0;
 	p->config_pending = 0;
-	br_timer_clear(&p->message_age_timer);
-	br_timer_clear(&p->forward_delay_timer);
-	br_timer_clear(&p->hold_timer);
+
+	del_timer(&p->message_age_timer);
+	del_timer(&p->forward_delay_timer);
+	del_timer(&p->hold_timer);
+
 	br_configuration_update(br);
+
 	br_port_state_selection(br);
 
 	if (br_is_root_bridge(br) && !wasroot)
diff -urN linux-2.5.69-bk7/net/bridge/br_stp_timer.c linux-2.5.69-bk8/net/bridge/br_stp_timer.c
--- linux-2.5.69-bk7/net/bridge/br_stp_timer.c	2003-05-04 16:53:31.000000000 -0700
+++ linux-2.5.69-bk8/net/bridge/br_stp_timer.c	2003-05-13 04:44:30.000000000 -0700
@@ -20,51 +20,59 @@
 #include "br_private.h"
 #include "br_private_stp.h"
 
-static void dump_bridge_id(bridge_id *id)
-{
-	printk("%.2x%.2x.%.2x:%.2x:%.2x:%.2x:%.2x:%.2x", id->prio[0],
-	       id->prio[1], id->addr[0], id->addr[1], id->addr[2], id->addr[3],
-	       id->addr[4], id->addr[5]);
-}
-
 /* called under bridge lock */
-static int br_is_designated_for_some_port(struct net_bridge *br)
+static int br_is_designated_for_some_port(const struct net_bridge *br)
 {
 	struct net_bridge_port *p;
 
 	list_for_each_entry(p, &br->port_list, list) {
 		if (p->state != BR_STATE_DISABLED &&
-		    !memcmp(&p->designated_bridge, &br->bridge_id, 8))
+		    !memcmp(&p->designated_bridge, &br->bridge_id, 8)) 
 			return 1;
 	}
 
 	return 0;
 }
 
-/* called under bridge lock */
-static void br_hello_timer_expired(struct net_bridge *br)
+static void br_hello_timer_expired(unsigned long arg)
 {
-	br_config_bpdu_generation(br);
-	br_timer_set(&br->hello_timer, jiffies);
+	struct net_bridge *br = (struct net_bridge *)arg;
+	
+	pr_debug("%s: hello timer expired\n", br->dev.name);
+	spin_lock_bh(&br->lock);
+	if (br->dev.flags & IFF_UP) {
+		br_config_bpdu_generation(br);
+
+		br->hello_timer.expires = jiffies + br->hello_time;
+		add_timer(&br->hello_timer);
+	}
+	spin_unlock_bh(&br->lock);
 }
 
-/* called under bridge lock */
-static void br_message_age_timer_expired(struct net_bridge_port *p)
+static void br_message_age_timer_expired(unsigned long arg)
 {
-	struct net_bridge *br;
+	struct net_bridge_port *p = (struct net_bridge_port *) arg;
+	struct net_bridge *br = p->br;
+	const bridge_id *id = &p->designated_bridge;
 	int was_root;
 
-	br = p->br;
-	printk(KERN_INFO "%s: ", br->dev.name);
-	printk("neighbour ");
-	dump_bridge_id(&p->designated_bridge);
-	printk(" lost on port %i(%s)\n", p->port_no, p->dev->name);
+	if (p->state == BR_STATE_DISABLED)
+		return;
+
+	
+	pr_info("%s: neighbor %.2x%.2x.%.2x:%.2x:%.2x:%.2x:%.2x:%.2x lost on port %d(%s)\n",
+		br->dev.name, 
+		id->prio[0], id->prio[1], 
+		id->addr[0], id->addr[1], id->addr[2], 
+		id->addr[3], id->addr[4], id->addr[5],
+		p->port_no, p->dev->name);
 
 	/*
 	 * According to the spec, the message age timer cannot be
 	 * running when we are the root bridge. So..  this was_root
 	 * check is redundant. I'm leaving it in for now, though.
 	 */
+	spin_lock_bh(&br->lock);
 	was_root = br_is_root_bridge(br);
 
 	br_become_designated_port(p);
@@ -72,107 +80,101 @@
 	br_port_state_selection(br);
 	if (br_is_root_bridge(br) && !was_root)
 		br_become_root_bridge(br);
+	spin_unlock_bh(&br->lock);
 }
 
-/* called under bridge lock */
-static void br_forward_delay_timer_expired(struct net_bridge_port *p)
+static void br_forward_delay_timer_expired(unsigned long arg)
 {
-	if (p->state == BR_STATE_LISTENING) {
-		printk(KERN_INFO "%s: port %i(%s) entering %s state\n",
-		       p->br->dev.name, p->port_no, p->dev->name, "learning");
+	struct net_bridge_port *p = (struct net_bridge_port *) arg;
+	struct net_bridge *br = p->br;
 
+	pr_debug("%s: %d(%s) forward delay timer\n",
+		 br->dev.name, p->port_no, p->dev->name);
+	spin_lock_bh(&br->lock);
+	if (p->state == BR_STATE_LISTENING) {
 		p->state = BR_STATE_LEARNING;
-		br_timer_set(&p->forward_delay_timer, jiffies);
+		p->forward_delay_timer.expires = jiffies + br->forward_delay;
+		add_timer(&p->forward_delay_timer);
 	} else if (p->state == BR_STATE_LEARNING) {
-		printk(KERN_INFO "%s: port %i(%s) entering %s state\n",
-		       p->br->dev.name, p->port_no, p->dev->name, "forwarding");
-
 		p->state = BR_STATE_FORWARDING;
-		if (br_is_designated_for_some_port(p->br))
-			br_topology_change_detection(p->br);
+		if (br_is_designated_for_some_port(br))
+			br_topology_change_detection(br);
 	}
+	br_log_state(p);
+	spin_unlock_bh(&br->lock);
 }
 
-/* called under bridge lock */
-static void br_tcn_timer_expired(struct net_bridge *br)
+static void br_tcn_timer_expired(unsigned long arg)
 {
-	printk(KERN_INFO "%s: retransmitting tcn bpdu\n", br->dev.name);
-	br_transmit_tcn(br);
-	br_timer_set(&br->tcn_timer, jiffies);
+	struct net_bridge *br = (struct net_bridge *) arg;
+
+	pr_debug("%s: tcn timer expired\n", br->dev.name);
+	spin_lock_bh(&br->lock);
+	if (br->dev.flags & IFF_UP) {
+		br_transmit_tcn(br);
+	
+		br->tcn_timer.expires = jiffies + br->bridge_hello_time;
+		add_timer(&br->tcn_timer);
+	}
+	spin_unlock_bh(&br->lock);
 }
 
-/* called under bridge lock */
-static void br_topology_change_timer_expired(struct net_bridge *br)
+static void br_topology_change_timer_expired(unsigned long arg)
 {
+	struct net_bridge *br = (struct net_bridge *) arg;
+
+	pr_debug("%s: topo change timer expired\n", br->dev.name);
+	spin_lock_bh(&br->lock);
 	br->topology_change_detected = 0;
 	br->topology_change = 0;
+	spin_unlock_bh(&br->lock);
 }
 
-/* called under bridge lock */
-static void br_hold_timer_expired(struct net_bridge_port *p)
+static void br_hold_timer_expired(unsigned long arg)
 {
+	struct net_bridge_port *p = (struct net_bridge_port *) arg;
+
+	pr_debug("%s: %d(%s) hold timer expired\n", 
+		 p->br->dev.name,  p->port_no, p->dev->name);
+
+	spin_lock_bh(&p->br->lock);
 	if (p->config_pending)
 		br_transmit_config(p);
+	spin_unlock_bh(&p->br->lock);
 }
 
-/* called under bridge lock */
-static void br_check_port_timers(struct net_bridge_port *p)
+static inline void br_timer_init(struct timer_list *timer,
+			  void (*_function)(unsigned long),
+			  unsigned long _data)
 {
-	if (br_timer_has_expired(&p->message_age_timer, p->br->max_age)) {
-		br_timer_clear(&p->message_age_timer);
-		br_message_age_timer_expired(p);
-	}
-
-	if (br_timer_has_expired(&p->forward_delay_timer, p->br->forward_delay)) {
-		br_timer_clear(&p->forward_delay_timer);
-		br_forward_delay_timer_expired(p);
-	}
-
-	if (br_timer_has_expired(&p->hold_timer, BR_HOLD_TIME)) {
-		br_timer_clear(&p->hold_timer);
-		br_hold_timer_expired(p);
-	}
+	init_timer(timer);
+	timer->function = _function;
+	timer->data = _data;
 }
 
-/* called under bridge lock */
-static void br_check_timers(struct net_bridge *br)
+void br_stp_timer_init(struct net_bridge *br)
 {
-	struct net_bridge_port *p;
+	br_timer_init(&br->hello_timer, br_hello_timer_expired,
+		      (unsigned long) br);
 
-	if (br_timer_has_expired(&br->gc_timer, br->gc_interval)) {
-		br_timer_set(&br->gc_timer, jiffies);
-		br_fdb_cleanup(br);
-	}
+	br_timer_init(&br->tcn_timer, br_tcn_timer_expired, 
+		      (unsigned long) br);
 
-	if (br_timer_has_expired(&br->hello_timer, br->hello_time)) {
-		br_timer_clear(&br->hello_timer);
-		br_hello_timer_expired(br);
-	}
-
-	if (br_timer_has_expired(&br->tcn_timer, br->bridge_hello_time)) {
-		br_timer_clear(&br->tcn_timer);
-		br_tcn_timer_expired(br);
-	}
-
-	if (br_timer_has_expired(&br->topology_change_timer, br->bridge_forward_delay + br->bridge_max_age)) {
-		br_timer_clear(&br->topology_change_timer);
-		br_topology_change_timer_expired(br);
-	}
+	br_timer_init(&br->topology_change_timer,
+		      br_topology_change_timer_expired,
+		      (unsigned long) br);
 
-	list_for_each_entry(p, &br->port_list, list) {
-		if (p->state != BR_STATE_DISABLED)
-			br_check_port_timers(p);
-	}
+	br_timer_init(&br->gc_timer, br_fdb_cleanup, (unsigned long) br);
 }
 
-void br_tick(unsigned long __data)
+void br_stp_port_timer_init(struct net_bridge_port *p)
 {
-	struct net_bridge *br = (struct net_bridge *)__data;
+	br_timer_init(&p->message_age_timer, br_message_age_timer_expired,
+		      (unsigned long) p);
 
-	if (spin_trylock_bh(&br->lock)) {
-		br_check_timers(br);
-		spin_unlock_bh(&br->lock);
-	}
-	br->tick.expires = jiffies + 1;
-	add_timer(&br->tick);
-}
+	br_timer_init(&p->forward_delay_timer, br_forward_delay_timer_expired,
+		      (unsigned long) p);
+		      
+	br_timer_init(&p->hold_timer, br_hold_timer_expired,
+		      (unsigned long) p);
+}	
diff -urN linux-2.5.69-bk7/net/core/dev.c linux-2.5.69-bk8/net/core/dev.c
--- linux-2.5.69-bk7/net/core/dev.c	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/net/core/dev.c	2003-05-13 04:44:30.000000000 -0700
@@ -90,7 +90,6 @@
 #include <linux/etherdevice.h>
 #include <linux/notifier.h>
 #include <linux/skbuff.h>
-#include <linux/brlock.h>
 #include <net/sock.h>
 #include <linux/rtnetlink.h>
 #include <linux/proc_fs.h>
@@ -170,8 +169,9 @@
  *		86DD	IPv6
  */
 
-static struct packet_type *ptype_base[16];	/* 16 way hashed list */
-static struct packet_type *ptype_all;		/* Taps */
+static spinlock_t ptype_lock = SPIN_LOCK_UNLOCKED;
+static struct list_head ptype_base[16];	/* 16 way hashed list */
+static struct list_head ptype_all;		/* Taps */
 
 #ifdef OFFLINE_SAMPLE
 static void sample_queue(unsigned long dummy);
@@ -239,14 +239,17 @@
  *	Add a protocol handler to the networking stack. The passed &packet_type
  *	is linked into kernel lists and may not be freed until it has been
  *	removed from the kernel lists.
+ *
+ *	This call does not sleep therefore it can not 
+ *	guarantee all CPU's that are in middle of receiving packets
+ *	will see the new packet type (until the next received packet).
  */
 
 void dev_add_pack(struct packet_type *pt)
 {
 	int hash;
 
-	br_write_lock_bh(BR_NETPROTO_LOCK);
-
+	spin_lock_bh(&ptype_lock);
 #ifdef CONFIG_NET_FASTROUTE
 	/* Hack to detect packet socket */
 	if (pt->data && (long)(pt->data) != 1) {
@@ -256,52 +259,76 @@
 #endif
 	if (pt->type == htons(ETH_P_ALL)) {
 		netdev_nit++;
-		pt->next  = ptype_all;
-		ptype_all = pt;
+		list_add_rcu(&pt->list, &ptype_all);
 	} else {
 		hash = ntohs(pt->type) & 15;
-		pt->next = ptype_base[hash];
-		ptype_base[hash] = pt;
+		list_add_rcu(&pt->list, &ptype_base[hash]);
 	}
-	br_write_unlock_bh(BR_NETPROTO_LOCK);
+	spin_unlock_bh(&ptype_lock);
 }
 
 extern void linkwatch_run_queue(void);
 
+
+
 /**
- *	dev_remove_pack	 - remove packet handler
+ *	__dev_remove_pack	 - remove packet handler
  *	@pt: packet type declaration
  *
  *	Remove a protocol handler that was previously added to the kernel
  *	protocol handlers by dev_add_pack(). The passed &packet_type is removed
  *	from the kernel lists and can be freed or reused once this function
- *	returns.
+ *	returns. 
+ *
+ *      The packet type might still be in use by receivers
+ *	and must not be freed until after all the CPU's have gone
+ *	through a quiescent state.
  */
-void dev_remove_pack(struct packet_type *pt)
+void __dev_remove_pack(struct packet_type *pt)
 {
-	struct packet_type **pt1;
+	struct list_head *head;
+	struct packet_type *pt1;
 
-	br_write_lock_bh(BR_NETPROTO_LOCK);
+	spin_lock_bh(&ptype_lock);
 
 	if (pt->type == htons(ETH_P_ALL)) {
 		netdev_nit--;
-		pt1 = &ptype_all;
+		head = &ptype_all;
 	} else
-		pt1 = &ptype_base[ntohs(pt->type) & 15];
+		head = &ptype_base[ntohs(pt->type) & 15];
 
-	for (; *pt1; pt1 = &((*pt1)->next)) {
-		if (pt == *pt1) {
-			*pt1 = pt->next;
+	list_for_each_entry(pt1, head, list) {
+		if (pt == pt1) {
 #ifdef CONFIG_NET_FASTROUTE
 			if (pt->data)
 				netdev_fastroute_obstacles--;
 #endif
+			list_del_rcu(&pt->list);
 			goto out;
 		}
 	}
+
 	printk(KERN_WARNING "dev_remove_pack: %p not found.\n", pt);
 out:
-	br_write_unlock_bh(BR_NETPROTO_LOCK);
+	spin_unlock_bh(&ptype_lock);
+}
+/**
+ *	dev_remove_pack	 - remove packet handler
+ *	@pt: packet type declaration
+ *
+ *	Remove a protocol handler that was previously added to the kernel
+ *	protocol handlers by dev_add_pack(). The passed &packet_type is removed
+ *	from the kernel lists and can be freed or reused once this function
+ *	returns.
+ *
+ *	This call sleeps to guarantee that no CPU is looking at the packet
+ *	type after return.
+ */
+void dev_remove_pack(struct packet_type *pt)
+{
+	__dev_remove_pack(pt);
+	
+	synchronize_net();
 }
 
 /******************************************************************************
@@ -943,8 +970,8 @@
 	struct packet_type *ptype;
 	do_gettimeofday(&skb->stamp);
 
-	br_read_lock(BR_NETPROTO_LOCK);
-	for (ptype = ptype_all; ptype; ptype = ptype->next) {
+	rcu_read_lock();
+	list_for_each_entry_rcu(ptype, &ptype_all, list) {
 		/* Never send packets back to the socket
 		 * they originated from - MvS (miquels@drinkel.ow.org)
 		 */
@@ -974,7 +1001,7 @@
 			ptype->func(skb2, skb->dev, ptype);
 		}
 	}
-	br_read_unlock(BR_NETPROTO_LOCK);
+	rcu_read_unlock();
 }
 
 /* Calculate csum in the case, when packet is misrouted.
@@ -1365,7 +1392,7 @@
 	if (skb_is_nonlinear(skb) && skb_linearize(skb, GFP_ATOMIC))
 		goto out_kfree;
 
-#if CONFIG_SMP
+#ifdef CONFIG_SMP
 	/* Old protocols did not depened on BHs different of NET_BH and
 	   TIMER_BH - they need to be fixed for the new assumptions.
 	 */
@@ -1488,7 +1515,8 @@
 	skb->h.raw = skb->nh.raw = skb->data;
 
 	pt_prev = NULL;
-	for (ptype = ptype_all; ptype; ptype = ptype->next) {
+	rcu_read_lock();
+	list_for_each_entry_rcu(ptype, &ptype_all, list) {
 		if (!ptype->dev || ptype->dev == skb->dev) {
 			if (pt_prev) {
 				if (!pt_prev->data) {
@@ -1511,17 +1539,15 @@
 
 #if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
 	if (skb->dev->br_port) {
-		int ret;
-
 		ret = handle_bridge(skb, pt_prev);
 		if (br_handle_frame_hook(skb) == 0) 
-			return ret;
+			goto out;
 
 		pt_prev = NULL;
 	}
 #endif
 
-	for (ptype = ptype_base[ntohs(type) & 15]; ptype; ptype = ptype->next) {
+	list_for_each_entry_rcu(ptype, &ptype_base[ntohs(type)&15], list) {
 		if (ptype->type == type &&
 		    (!ptype->dev || ptype->dev == skb->dev)) {
 			if (pt_prev) {
@@ -1552,6 +1578,8 @@
 		ret = NET_RX_DROP;
 	}
 
+ out:
+	rcu_read_unlock();
 	return ret;
 }
 
@@ -1625,7 +1653,8 @@
 	unsigned long start_time = jiffies;
 	int budget = netdev_max_backlog;
 
-	br_read_lock(BR_NETPROTO_LOCK);
+	
+	preempt_disable();
 	local_irq_disable();
 
 	while (!list_empty(&queue->poll_list)) {
@@ -1654,7 +1683,7 @@
 	}
 out:
 	local_irq_enable();
-	br_read_unlock(BR_NETPROTO_LOCK);
+	preempt_enable();
 	return;
 
 softnet_break:
@@ -1997,9 +2026,9 @@
 		dev_hold(master);
 	}
 
-	br_write_lock_bh(BR_NETPROTO_LOCK);
 	slave->master = master;
-	br_write_unlock_bh(BR_NETPROTO_LOCK);
+	
+	synchronize_net();
 
 	if (old)
 		dev_put(old);
@@ -2663,8 +2692,8 @@
 /* Synchronize with packet receive processing. */
 void synchronize_net(void) 
 {
-	br_write_lock_bh(BR_NETPROTO_LOCK);
-	br_write_unlock_bh(BR_NETPROTO_LOCK);
+	might_sleep();
+	synchronize_kernel();
 }
 
 /**
@@ -2848,6 +2877,10 @@
 
 	subsystem_register(&net_subsys);
 
+	INIT_LIST_HEAD(&ptype_all);
+	for (i = 0; i < 16; i++) 
+		INIT_LIST_HEAD(&ptype_base[i]);
+
 #ifdef CONFIG_NET_DIVERT
 	dv_init();
 #endif /* CONFIG_NET_DIVERT */
diff -urN linux-2.5.69-bk7/net/core/wireless.c linux-2.5.69-bk8/net/core/wireless.c
--- linux-2.5.69-bk7/net/core/wireless.c	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/net/core/wireless.c	2003-05-13 04:44:30.000000000 -0700
@@ -53,6 +53,7 @@
 /***************************** INCLUDES *****************************/
 
 #include <linux/config.h>		/* Not needed ??? */
+#include <linux/module.h>
 #include <linux/types.h>		/* off_t */
 #include <linux/netdevice.h>		/* struct ifreq, dev_get_by_name() */
 #include <linux/proc_fs.h>
diff -urN linux-2.5.69-bk7/net/ipv4/af_inet.c linux-2.5.69-bk8/net/ipv4/af_inet.c
--- linux-2.5.69-bk7/net/ipv4/af_inet.c	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/net/ipv4/af_inet.c	2003-05-13 04:44:30.000000000 -0700
@@ -1013,7 +1013,7 @@
 out:
 	spin_unlock_bh(&inetsw_lock);
 
-	synchronize_kernel();
+	synchronize_net();
 
 	return;
 
@@ -1040,7 +1040,7 @@
 		list_del_rcu(&p->list);
 		spin_unlock_bh(&inetsw_lock);
 
-		synchronize_kernel();
+		synchronize_net();
 	}
 }
 
diff -urN linux-2.5.69-bk7/net/ipv4/ip_output.c linux-2.5.69-bk8/net/ipv4/ip_output.c
--- linux-2.5.69-bk7/net/ipv4/ip_output.c	2003-05-04 16:53:56.000000000 -0700
+++ linux-2.5.69-bk8/net/ipv4/ip_output.c	2003-05-13 04:44:30.000000000 -0700
@@ -685,16 +685,6 @@
 	return 0;
 }
 
-static void
-skb_fill_page_desc(struct sk_buff *skb, int i, struct page *page, int off, int size)
-{
-	skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
-	frag->page = page;
-	frag->page_offset = off;
-	frag->size = size;
-	skb_shinfo(skb)->nr_frags = i+1;
-}
-
 static inline unsigned int
 csum_page(struct page *page, int offset, int copy)
 {
diff -urN linux-2.5.69-bk7/net/ipv4/ipcomp.c linux-2.5.69-bk8/net/ipv4/ipcomp.c
--- linux-2.5.69-bk7/net/ipv4/ipcomp.c	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/net/ipv4/ipcomp.c	2003-05-13 04:44:30.000000000 -0700
@@ -269,6 +269,67 @@
 	xfrm_state_put(x);
 }
 
+/* We always hold one tunnel user reference to indicate a tunnel */ 
+static struct xfrm_state *ipcomp_tunnel_create(struct xfrm_state *x)
+{
+	struct xfrm_state *t;
+	
+	t = xfrm_state_alloc();
+	if (t == NULL)
+		goto out;
+
+	t->id.proto = IPPROTO_IPIP;
+	t->id.spi = x->props.saddr.a4;
+	t->id.daddr.a4 = x->id.daddr.a4;
+	memcpy(&t->sel, &x->sel, sizeof(t->sel));
+	t->props.family = AF_INET;
+	t->props.mode = 1;
+	t->props.saddr.a4 = x->props.saddr.a4;
+	
+	t->type = xfrm_get_type(IPPROTO_IPIP, t->props.family);
+	if (t->type == NULL)
+		goto error;
+		
+	if (t->type->init_state(t, NULL))
+		goto error;
+
+	t->km.state = XFRM_STATE_VALID;
+	atomic_set(&t->tunnel_users, 1);
+out:
+	return t;
+
+error:
+	xfrm_state_put(t);
+	t = NULL;
+	goto out;
+}
+
+/*
+ * Must be protected by xfrm_cfg_sem.  State and tunnel user references are
+ * always incremented on success.
+ */
+static int ipcomp_tunnel_attach(struct xfrm_state *x)
+{
+	int err = 0;
+	struct xfrm_state *t;
+
+	t = xfrm_state_lookup((xfrm_address_t *)&x->id.daddr.a4,
+	                      x->props.saddr.a4, IPPROTO_IPIP, AF_INET);
+	if (!t) {
+		t = ipcomp_tunnel_create(x);
+		if (!t) {
+			err = -EINVAL;
+			goto out;
+		}
+		xfrm_state_insert(t);
+		xfrm_state_hold(t);
+	}
+	x->tunnel = t;
+	atomic_inc(&t->tunnel_users);
+out:
+	return err;
+}
+
 static void ipcomp_free_data(struct ipcomp_data *ipcd)
 {
 	if (ipcd->tfm)
@@ -308,6 +369,12 @@
 	if (!ipcd->tfm)
 		goto error;
 
+	if (x->props.mode) {
+		err = ipcomp_tunnel_attach(x);
+		if (err)
+			goto error;
+	}
+
 	calg_desc = xfrm_calg_get_byname(x->calg->alg_name);
 	BUG_ON(!calg_desc);
 	ipcd->threshold = calg_desc->uinfo.comp.threshold;
diff -urN linux-2.5.69-bk7/net/ipv4/netfilter/ip_conntrack_core.c linux-2.5.69-bk8/net/ipv4/netfilter/ip_conntrack_core.c
--- linux-2.5.69-bk7/net/ipv4/netfilter/ip_conntrack_core.c	2003-05-04 16:52:48.000000000 -0700
+++ linux-2.5.69-bk8/net/ipv4/netfilter/ip_conntrack_core.c	2003-05-13 04:44:30.000000000 -0700
@@ -1188,12 +1188,9 @@
 	local_bh_enable();
 
 	if (!skb) {
-		if (sk) sock_put(sk);
+		if (sk)
+			sock_put(sk);
 		return skb;
-	} else if (skb_is_nonlinear(skb) && skb_linearize(skb, GFP_ATOMIC) != 0) {
-		kfree_skb(skb);
-		if (sk) sock_put(sk);
-		return NULL;
 	}
 
 	if (sk) {
diff -urN linux-2.5.69-bk7/net/ipv4/netfilter/ip_fw_compat.c linux-2.5.69-bk8/net/ipv4/netfilter/ip_fw_compat.c
--- linux-2.5.69-bk7/net/ipv4/netfilter/ip_fw_compat.c	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/net/ipv4/netfilter/ip_fw_compat.c	2003-05-13 04:44:30.000000000 -0700
@@ -15,34 +15,10 @@
 #include <linux/netfilter_ipv4/compat_firewall.h>
 #include <linux/netfilter_ipv4/ip_conntrack.h>
 #include <linux/netfilter_ipv4/ip_conntrack_core.h>
+#include "ip_fw_compat.h"
 
 static struct firewall_ops *fwops;
 
-/* From ip_fw_compat_redir.c */
-extern unsigned int
-do_redirect(struct sk_buff *skb,
-	    const struct net_device *dev,
-	    u_int16_t redirpt);
-
-extern void
-check_for_redirect(struct sk_buff *skb);
-
-extern void
-check_for_unredirect(struct sk_buff *skb);
-
-/* From ip_fw_compat_masq.c */
-extern unsigned int
-do_masquerade(struct sk_buff **pskb, const struct net_device *dev);
-
-extern unsigned int
-check_for_masq_error(struct sk_buff **pskb);
-
-extern unsigned int
-check_for_demasq(struct sk_buff **pskb);
-
-extern int __init masq_init(void);
-extern void masq_cleanup(void);
-
 /* They call these; we do what they want. */
 int register_firewall(int pf, struct firewall_ops *fw)
 {
diff -urN linux-2.5.69-bk7/net/ipv4/netfilter/ip_fw_compat.h linux-2.5.69-bk8/net/ipv4/netfilter/ip_fw_compat.h
--- linux-2.5.69-bk7/net/ipv4/netfilter/ip_fw_compat.h	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.5.69-bk8/net/ipv4/netfilter/ip_fw_compat.h	2003-05-13 04:44:30.000000000 -0700
@@ -0,0 +1,28 @@
+#ifndef _LINUX_IP_FW_COMPAT_H
+#define _LINUX_IP_FW_COMPAT_H
+
+/* From ip_fw_compat_redir.c */
+extern unsigned int
+do_redirect(struct sk_buff *skb,
+	    const struct net_device *dev,
+	    u_int16_t redirpt);
+
+extern void
+check_for_redirect(struct sk_buff *skb);
+
+extern void
+check_for_unredirect(struct sk_buff *skb);
+
+/* From ip_fw_compat_masq.c */
+extern unsigned int
+do_masquerade(struct sk_buff **pskb, const struct net_device *dev);
+
+extern void check_for_masq_error(struct sk_buff **pskb);
+
+extern unsigned int
+check_for_demasq(struct sk_buff **pskb);
+
+extern int __init masq_init(void);
+extern void masq_cleanup(void);
+
+#endif /* _LINUX_IP_FW_COMPAT_H */
diff -urN linux-2.5.69-bk7/net/ipv4/netfilter/ip_fw_compat_masq.c linux-2.5.69-bk8/net/ipv4/netfilter/ip_fw_compat_masq.c
--- linux-2.5.69-bk7/net/ipv4/netfilter/ip_fw_compat_masq.c	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/net/ipv4/netfilter/ip_fw_compat_masq.c	2003-05-13 04:44:30.000000000 -0700
@@ -25,6 +25,7 @@
 #include <linux/netfilter_ipv4/ip_nat.h>
 #include <linux/netfilter_ipv4/ip_nat_core.h>
 #include <linux/netfilter_ipv4/listhelp.h>
+#include "ip_fw_compat.h"
 
 #if 0
 #define DEBUGP printk
diff -urN linux-2.5.69-bk7/net/ipv4/netfilter/ip_fw_compat_redir.c linux-2.5.69-bk8/net/ipv4/netfilter/ip_fw_compat_redir.c
--- linux-2.5.69-bk7/net/ipv4/netfilter/ip_fw_compat_redir.c	2003-05-04 16:53:36.000000000 -0700
+++ linux-2.5.69-bk8/net/ipv4/netfilter/ip_fw_compat_redir.c	2003-05-13 04:44:30.000000000 -0700
@@ -28,6 +28,7 @@
 #define ASSERT_WRITE_LOCK(x) MUST_BE_LOCKED(&redir_lock)
 
 #include <linux/netfilter_ipv4/listhelp.h>
+#include "ip_fw_compat.h"
 
 #if 0
 #define DEBUGP printk
diff -urN linux-2.5.69-bk7/net/ipv4/tcp.c linux-2.5.69-bk8/net/ipv4/tcp.c
--- linux-2.5.69-bk7/net/ipv4/tcp.c	2003-05-04 16:53:08.000000000 -0700
+++ linux-2.5.69-bk8/net/ipv4/tcp.c	2003-05-13 04:44:30.000000000 -0700
@@ -2140,17 +2140,8 @@
 
 	inet->dport = 0;
 
-	if (!(sk->userlocks & SOCK_BINDADDR_LOCK)) {
-		inet->rcv_saddr = inet->saddr = 0;
-#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
-		if (sk->family == PF_INET6) {
-			struct ipv6_pinfo *np = inet6_sk(sk);
-
-			memset(&np->saddr, 0, 16);
-			memset(&np->rcv_saddr, 0, 16);
-		}
-#endif
-	}
+	if (!(sk->userlocks & SOCK_BINDADDR_LOCK))
+		inet_reset_saddr(sk);
 
 	sk->shutdown = 0;
 	__clear_bit(SOCK_DONE, &sk->flags);
diff -urN linux-2.5.69-bk7/net/ipv4/udp.c linux-2.5.69-bk8/net/ipv4/udp.c
--- linux-2.5.69-bk7/net/ipv4/udp.c	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/net/ipv4/udp.c	2003-05-13 04:44:30.000000000 -0700
@@ -920,17 +920,9 @@
 	inet->daddr = 0;
 	inet->dport = 0;
 	sk->bound_dev_if = 0;
-	if (!(sk->userlocks&SOCK_BINDADDR_LOCK)) {
-		inet->rcv_saddr = inet->saddr = 0;
-#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
-		if (sk->family == PF_INET6) {
-			struct ipv6_pinfo *np = inet6_sk(sk);
+	if (!(sk->userlocks & SOCK_BINDADDR_LOCK))
+		inet_reset_saddr(sk);
 
-			memset(&np->saddr, 0, 16);
-			memset(&np->rcv_saddr, 0, 16);
-		}
-#endif
-	}
 	if (!(sk->userlocks&SOCK_BINDPORT_LOCK)) {
 		sk->prot->unhash(sk);
 		inet->sport = 0;
diff -urN linux-2.5.69-bk7/net/ipv4/xfrm4_state.c linux-2.5.69-bk8/net/ipv4/xfrm4_state.c
--- linux-2.5.69-bk7/net/ipv4/xfrm4_state.c	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/net/ipv4/xfrm4_state.c	2003-05-13 04:44:30.000000000 -0700
@@ -101,7 +101,7 @@
 		x0->lft.hard_add_expires_seconds = XFRM_ACQ_EXPIRES;
 		xfrm_state_hold(x0);
 		mod_timer(&x0->timer, jiffies + XFRM_ACQ_EXPIRES*HZ);
-		xfrm_state_hold(0);
+		xfrm_state_hold(x0);
 		list_add_tail(&x0->bydst, xfrm4_state_afinfo.state_bydst+h);
 		wake_up(&km_waitq);
 	}
diff -urN linux-2.5.69-bk7/net/ipv4/xfrm4_tunnel.c linux-2.5.69-bk8/net/ipv4/xfrm4_tunnel.c
--- linux-2.5.69-bk7/net/ipv4/xfrm4_tunnel.c	2003-05-04 16:53:02.000000000 -0700
+++ linux-2.5.69-bk8/net/ipv4/xfrm4_tunnel.c	2003-05-13 04:44:30.000000000 -0700
@@ -163,36 +163,32 @@
 			      skb->nh.iph->saddr,
 			      IPPROTO_IPIP, AF_INET);
 
-	if (x) {
-		spin_lock(&x->lock);
+	if (!x)
+		goto drop;
 
-		if (unlikely(x->km.state != XFRM_STATE_VALID))
-			goto drop_unlock;
-	}
+	spin_lock(&x->lock);
+
+	if (unlikely(x->km.state != XFRM_STATE_VALID))
+		goto drop_unlock;
 
 	err = ipip_xfrm_rcv(x, NULL, skb);
 	if (err)
 		goto drop_unlock;
 
-	if (x) {
-		x->curlft.bytes += skb->len;
-		x->curlft.packets++;
-
-		spin_unlock(&x->lock);
-
-		xfrm_state_put(x);
-	}
-
-	return 0;
+	x->curlft.bytes += skb->len;
+	x->curlft.packets++;
+	spin_unlock(&x->lock);
+	xfrm_state_put(x);
+out:	
+	return err;
 
 drop_unlock:
-	if (x) {
-		spin_unlock(&x->lock);
-		xfrm_state_put(x);
-	}
+	spin_unlock(&x->lock);
+	xfrm_state_put(x);
+drop:
+	err = NET_RX_DROP;
 	kfree_skb(skb);
-out:
-	return 0;
+	goto out;
 }
 
 static void ipip_err(struct sk_buff *skb, u32 info)
diff -urN linux-2.5.69-bk7/net/ipv6/af_inet6.c linux-2.5.69-bk8/net/ipv6/af_inet6.c
--- linux-2.5.69-bk7/net/ipv6/af_inet6.c	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/net/ipv6/af_inet6.c	2003-05-13 04:44:30.000000000 -0700
@@ -355,10 +355,7 @@
 
 	/* Make sure we are allowed to bind here. */
 	if (sk->prot->get_port(sk, snum) != 0) {
-		inet->rcv_saddr = inet->saddr = 0;
-		memset(&np->rcv_saddr, 0, sizeof(struct in6_addr));
-		memset(&np->saddr, 0, sizeof(struct in6_addr));
-
+		inet_reset_saddr(sk);
 		release_sock(sk);
 		return -EADDRINUSE;
 	}
@@ -637,7 +634,7 @@
 		list_del_rcu(&p->list);
 		spin_unlock_bh(&inetsw6_lock);
 
-		synchronize_kernel();
+		synchronize_net();
 	}
 }
 
diff -urN linux-2.5.69-bk7/net/ipv6/icmp.c linux-2.5.69-bk8/net/ipv6/icmp.c
--- linux-2.5.69-bk7/net/ipv6/icmp.c	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/net/ipv6/icmp.c	2003-05-13 04:44:30.000000000 -0700
@@ -28,6 +28,7 @@
  *	YOSHIFUJI Hideaki @USAGI:	added sysctl for icmp rate limit.
  *	Randy Dunlap and
  *	YOSHIFUJI Hideaki @USAGI:	Per-interface statistics support
+ *	Kazunori MIYAZAWA @USAGI:       change output process to use ip6_append_data
  */
 
 #include <linux/module.h>
@@ -104,42 +105,6 @@
 	spin_unlock_bh(&icmpv6_socket->sk->lock.slock);
 }
 
-
-
-/*
- *	getfrag callback
- */
-
-static int icmpv6_getfrag(const void *data, struct in6_addr *saddr, 
-			   char *buff, unsigned int offset, unsigned int len)
-{
-	struct icmpv6_msg *msg = (struct icmpv6_msg *) data;
-	struct icmp6hdr *icmph;
-	__u32 csum;
-
-	if (offset) {
-		csum = skb_copy_and_csum_bits(msg->skb, msg->offset +
-					      (offset - sizeof(struct icmp6hdr)),
-					      buff, len, msg->csum);
-		msg->csum = csum;
-		return 0;
-	}
-
-	csum = csum_partial_copy_nocheck((void *) &msg->icmph, buff,
-					 sizeof(struct icmp6hdr), msg->csum);
-
-	csum = skb_copy_and_csum_bits(msg->skb, msg->offset,
-				      buff + sizeof(struct icmp6hdr),
-				      len - sizeof(struct icmp6hdr), csum);
-
-	icmph = (struct icmp6hdr *) buff;
-
-	icmph->icmp6_cksum = csum_ipv6_magic(saddr, msg->daddr, msg->len,
-					     IPPROTO_ICMPV6, csum);
-	return 0; 
-}
-
-
 /* 
  * Slightly more convenient version of icmpv6_send.
  */
@@ -242,22 +207,74 @@
 	return (optval&0xC0) == 0x80;
 }
 
+int icmpv6_push_pending_frames(struct sock *sk, struct flowi *fl, struct icmp6hdr *thdr, int len)
+{
+	struct sk_buff *skb;
+	struct icmp6hdr *icmp6h;
+	int err = 0;
+
+	if ((skb = skb_peek(&sk->write_queue)) == NULL)
+		goto out;
+
+	icmp6h = (struct icmp6hdr*) skb->h.raw;
+	memcpy(icmp6h, thdr, sizeof(struct icmp6hdr));
+	icmp6h->icmp6_cksum = 0;
+
+	if (skb_queue_len(&sk->write_queue) == 1) {
+		skb->csum = csum_partial((char *)icmp6h,
+					sizeof(struct icmp6hdr), skb->csum);
+		icmp6h->icmp6_cksum = csum_ipv6_magic(fl->fl6_src,
+					     fl->fl6_dst,
+					     len, fl->proto, skb->csum);
+	} else {
+		u32 tmp_csum = 0;
+
+		skb_queue_walk(&sk->write_queue, skb) {
+			tmp_csum = csum_add(tmp_csum, skb->csum);
+		}
+
+		tmp_csum = csum_partial((char *)icmp6h,
+					sizeof(struct icmp6hdr), tmp_csum);
+		tmp_csum = csum_ipv6_magic(fl->fl6_src,
+					   fl->fl6_dst,
+					   len, fl->proto, tmp_csum);
+		icmp6h->icmp6_cksum = tmp_csum;
+	}
+	if (icmp6h->icmp6_cksum == 0)
+		icmp6h->icmp6_cksum = -1;
+	ip6_push_pending_frames(sk);
+out:
+	return err;
+}
+
+static int icmpv6_getfrag(void *from, char *to, int offset, int len, int odd, struct sk_buff *skb)
+{
+	struct sk_buff *org_skb = (struct sk_buff *)from;
+	__u32 csum = 0;
+	csum = skb_copy_and_csum_bits(org_skb, offset, to, len, csum);
+	skb->csum = csum_block_add(skb->csum, csum, odd);
+	return 0;
+}
+
 /*
  *	Send an ICMP message in response to a packet in error
  */
-
 void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info, 
 		 struct net_device *dev)
 {
 	struct inet6_dev *idev;
 	struct ipv6hdr *hdr = skb->nh.ipv6h;
 	struct sock *sk = icmpv6_socket->sk;
-	struct in6_addr *saddr = NULL;
-	int iif = 0;
-	struct icmpv6_msg msg;
+	struct ipv6_pinfo *np = inet6_sk(sk);
+	struct in6_addr *saddr = NULL, *tmp_saddr = NULL;
+	struct dst_entry *dst;
+	struct icmp6hdr tmp_hdr;
 	struct flowi fl;
+	int iif = 0;
 	int addr_type = 0;
-	int len;
+	int len, plen;
+	int hlimit = -1;
+	int err = 0;
 
 	if ((u8*)hdr < skb->head || (u8*)(hdr+1) > skb->tail)
 		return;
@@ -328,36 +345,48 @@
 	if (!icmpv6_xrlim_allow(sk, type, &fl))
 		goto out;
 
-	/*
-	 *	ok. kick it. checksum will be provided by the 
-	 *	getfrag_t callback.
-	 */
-
-	msg.icmph.icmp6_type = type;
-	msg.icmph.icmp6_code = code;
-	msg.icmph.icmp6_cksum = 0;
-	msg.icmph.icmp6_pointer = htonl(info);
-
-	msg.skb = skb;
-	msg.offset = skb->nh.raw - skb->data;
-	msg.csum = 0;
-	msg.daddr = &hdr->saddr;
-
-	len = skb->len - msg.offset + sizeof(struct icmp6hdr);
-	len = min_t(unsigned int, len, IPV6_MIN_MTU - sizeof(struct ipv6hdr));
-
+	tmp_hdr.icmp6_type = type;
+	tmp_hdr.icmp6_code = code;
+	tmp_hdr.icmp6_cksum = 0;
+	tmp_hdr.icmp6_pointer = htonl(info);
+
+	if (!fl.oif && ipv6_addr_is_multicast(fl.fl6_dst))
+		fl.oif = np->mcast_oif;
+
+	err = ip6_dst_lookup(sk, &dst, &fl, &tmp_saddr);
+	if (err) goto out;
+
+	if (hlimit < 0) {
+		if (ipv6_addr_is_multicast(fl.fl6_dst))
+			hlimit = np->mcast_hops;
+		else
+			hlimit = np->hop_limit;
+		if (hlimit < 0)
+			hlimit = ((struct rt6_info*)dst)->rt6i_hoplimit;
+	}
+
+	plen = skb->nh.raw - skb->data;
+	__skb_pull(skb, plen);
+	len = skb->len;
+	len = min_t(unsigned int, len, IPV6_MIN_MTU - sizeof(struct ipv6hdr) -sizeof(struct icmp6hdr));
 	if (len < 0) {
 		if (net_ratelimit())
 			printk(KERN_DEBUG "icmp: len problem\n");
+		__skb_push(skb, plen);
 		goto out;
 	}
 
-	msg.len = len;
-
 	idev = in6_dev_get(skb->dev);
-	
-	ip6_build_xmit(sk, icmpv6_getfrag, &msg, &fl, len, NULL, -1,
-		       MSG_DONTWAIT);
+
+	err = ip6_append_data(sk, icmpv6_getfrag, skb, len + sizeof(struct icmp6hdr), sizeof(struct icmp6hdr),
+				hlimit, NULL, &fl, (struct rt6_info*)dst, MSG_DONTWAIT);
+	if (err) {
+		ip6_flush_pending_frames(sk);
+		goto out;
+	}
+	err = icmpv6_push_pending_frames(sk, &fl, &tmp_hdr, len + sizeof(struct icmp6hdr));
+	__skb_push(skb, plen);
+
 	if (type >= ICMPV6_DEST_UNREACH && type <= ICMPV6_PARAMPROB)
 		ICMP6_INC_STATS_OFFSET_BH(idev, Icmp6OutDestUnreachs, type - ICMPV6_DEST_UNREACH);
 	ICMP6_INC_STATS_BH(idev, Icmp6OutMsgs);
@@ -365,6 +394,7 @@
 	if (likely(idev != NULL))
 		in6_dev_put(idev);
 out:
+	if (tmp_saddr) kfree(tmp_saddr);
 	icmpv6_xmit_unlock();
 }
 
@@ -372,10 +402,14 @@
 {
 	struct sock *sk = icmpv6_socket->sk;
 	struct inet6_dev *idev;
+	struct ipv6_pinfo *np = inet6_sk(sk);
+	struct in6_addr *saddr = NULL, *tmp_saddr = NULL;
 	struct icmp6hdr *icmph = (struct icmp6hdr *) skb->h.raw;
-	struct in6_addr *saddr;
-	struct icmpv6_msg msg;
+	struct icmp6hdr tmp_hdr;
 	struct flowi fl;
+	struct dst_entry *dst;
+	int err = 0;
+	int hlimit = -1;
 
 	saddr = &skb->nh.ipv6h->daddr;
 
@@ -383,39 +417,55 @@
 	    ipv6_chk_acast_addr(0, saddr)) 
 		saddr = NULL;
 
-	msg.icmph.icmp6_type = ICMPV6_ECHO_REPLY;
-	msg.icmph.icmp6_code = 0;
-	msg.icmph.icmp6_cksum = 0;
-	msg.icmph.icmp6_identifier = icmph->icmp6_identifier;
-	msg.icmph.icmp6_sequence = icmph->icmp6_sequence;
-
-	msg.skb = skb;
-	msg.offset = 0;
-	msg.csum = 0;
-	msg.len = skb->len + sizeof(struct icmp6hdr);
-	msg.daddr =  &skb->nh.ipv6h->saddr;
+	memcpy(&tmp_hdr, icmph, sizeof(tmp_hdr));
+	tmp_hdr.icmp6_type = ICMPV6_ECHO_REPLY;
 
 	fl.proto = IPPROTO_ICMPV6;
-	fl.fl6_dst = msg.daddr;
+	fl.fl6_dst = &skb->nh.ipv6h->saddr;
 	fl.fl6_src = saddr;
 	fl.oif = skb->dev->ifindex;
 	fl.fl6_flowlabel = 0;
 	fl.fl_icmp_type = ICMPV6_ECHO_REPLY;
 	fl.fl_icmp_code = 0;
 
+	icmpv6_xmit_lock();
+
+	if (!fl.oif && ipv6_addr_is_multicast(fl.nl_u.ip6_u.daddr))
+		fl.oif = np->mcast_oif;
+
+	err = ip6_dst_lookup(sk, &dst, &fl, &tmp_saddr);
+
+	if (err) goto out;
+
+	if (hlimit < 0) {
+		if (ipv6_addr_is_multicast(fl.fl6_dst))
+			hlimit = np->mcast_hops;
+		else
+			hlimit = np->hop_limit;
+		if (hlimit < 0)
+			hlimit = ((struct rt6_info*)dst)->rt6i_hoplimit;
+	}
+
 	idev = in6_dev_get(skb->dev);
 
-	icmpv6_xmit_lock();
+	err = ip6_append_data(sk, icmpv6_getfrag, skb, skb->len + sizeof(struct icmp6hdr),
+				sizeof(struct icmp6hdr), hlimit, NULL, &fl,
+				(struct rt6_info*)dst, MSG_DONTWAIT);
 
-	ip6_build_xmit(sk, icmpv6_getfrag, &msg, &fl, msg.len, NULL, -1,
-		       MSG_DONTWAIT);
-	ICMP6_INC_STATS_BH(idev, Icmp6OutEchoReplies);
-	ICMP6_INC_STATS_BH(idev, Icmp6OutMsgs);
+	if (err) {
+		ip6_flush_pending_frames(sk);
+		goto out;
+	}
+	err = icmpv6_push_pending_frames(sk, &fl, &tmp_hdr, skb->len + sizeof(struct icmp6hdr));
 
-	icmpv6_xmit_unlock();
+        ICMP6_INC_STATS_BH(idev, Icmp6OutEchoReplies);
+        ICMP6_INC_STATS_BH(idev, Icmp6OutMsgs);
 
 	if (likely(idev != NULL))
 		in6_dev_put(idev);
+out: 
+	if (tmp_saddr) kfree(tmp_saddr);
+	icmpv6_xmit_unlock();
 }
 
 static void icmpv6_notify(struct sk_buff *skb, int type, int code, u32 info)
diff -urN linux-2.5.69-bk7/net/ipv6/ip6_output.c linux-2.5.69-bk8/net/ipv6/ip6_output.c
--- linux-2.5.69-bk7/net/ipv6/ip6_output.c	2003-05-04 16:53:01.000000000 -0700
+++ linux-2.5.69-bk8/net/ipv6/ip6_output.c	2003-05-13 04:44:30.000000000 -0700
@@ -23,6 +23,9 @@
  *
  *      H. von Brand    :       Added missing #include <linux/string.h>
  *	Imran Patel	: 	frag id should be in NBO
+ *      Kazunori MIYAZAWA @USAGI
+ *			:       add ip6_append_data and related functions
+ *				for datagram xmit
  */
 
 #include <linux/config.h>
@@ -52,6 +55,8 @@
 #include <net/icmp.h>
 #include <net/xfrm.h>
 
+static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff*));
+
 static __inline__ void ipv6_select_ident(struct sk_buff *skb, struct frag_hdr *fhdr)
 {
 	static u32 ipv6_fragmentation_id = 1;
@@ -98,7 +103,7 @@
 }
 
 
-int ip6_output(struct sk_buff *skb)
+int ip6_output2(struct sk_buff *skb)
 {
 	struct dst_entry *dst = skb->dst;
 	struct net_device *dev = dst->dev;
@@ -134,6 +139,13 @@
 	return NF_HOOK(PF_INET6, NF_IP6_POST_ROUTING, skb,NULL, skb->dev,ip6_output_finish);
 }
 
+int ip6_output(struct sk_buff *skb)
+{
+	if ((skb->len > skb->dst->dev->mtu || skb_shinfo(skb)->frag_list))
+		return ip6_fragment(skb, ip6_output2);
+	else
+		return ip6_output2(skb);
+}
 
 #ifdef CONFIG_NETFILTER
 int ip6_route_me_harder(struct sk_buff *skb)
@@ -847,3 +859,658 @@
 	kfree_skb(skb);
 	return -EINVAL;
 }
+
+static void ip6_copy_metadata(struct sk_buff *to, struct sk_buff *from)
+{
+	to->pkt_type = from->pkt_type;
+	to->priority = from->priority;
+	to->protocol = from->protocol;
+	to->security = from->security;
+	to->dst = dst_clone(from->dst);
+	to->dev = from->dev;
+
+#ifdef CONFIG_NET_SCHED
+	to->tc_index = from->tc_index;
+#endif
+#ifdef CONFIG_NETFILTER
+	to->nfmark = from->nfmark;
+	/* Connection association is same as pre-frag packet */
+	to->nfct = from->nfct;
+	nf_conntrack_get(to->nfct);
+#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
+	to->nf_bridge = from->nf_bridge;
+	nf_bridge_get(to->nf_bridge);
+#endif
+#ifdef CONFIG_NETFILTER_DEBUG
+	to->nf_debug = from->nf_debug;
+#endif
+#endif
+}
+
+static int ip6_found_nexthdr(struct sk_buff *skb, u8 **nexthdr)
+{
+	u16 offset = sizeof(struct ipv6hdr);
+	struct ipv6_opt_hdr *exthdr = (struct ipv6_opt_hdr*)(skb->nh.ipv6h + 1);
+	unsigned int packet_len = skb->tail - skb->nh.raw;
+	int found_rhdr = 0;
+	*nexthdr = &skb->nh.ipv6h->nexthdr;
+
+	while (offset + 1 <= packet_len) {
+
+		switch (**nexthdr) {
+
+		case NEXTHDR_HOP:
+		case NEXTHDR_ROUTING:
+		case NEXTHDR_DEST:
+			if (**nexthdr == NEXTHDR_ROUTING) found_rhdr = 1;
+			if (**nexthdr == NEXTHDR_DEST && found_rhdr) return offset;
+			offset += ipv6_optlen(exthdr);
+			*nexthdr = &exthdr->nexthdr;
+			exthdr = (struct ipv6_opt_hdr*)(skb->nh.raw + offset);
+			break;
+		default :
+			return offset;
+		}
+	}
+
+	return offset;
+}
+
+static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff*))
+{
+	struct net_device *dev;
+	struct rt6_info *rt = (struct rt6_info*)skb->dst;
+	struct sk_buff *frag;
+	struct ipv6hdr *tmp_hdr;
+	struct frag_hdr *fh;
+	unsigned int mtu, hlen, left, len;
+	u32 frag_id = 0;
+	int ptr, offset = 0, err=0;
+	u8 *prevhdr, nexthdr = 0;
+
+	dev = rt->u.dst.dev;
+	hlen = ip6_found_nexthdr(skb, &prevhdr);
+	nexthdr = *prevhdr;
+
+	mtu = dst_pmtu(&rt->u.dst) - hlen - sizeof(struct frag_hdr);
+
+	if (skb_shinfo(skb)->frag_list) {
+		int first_len = 0;
+
+		if (first_len - hlen > mtu ||
+		    ((first_len - hlen) & 7) ||
+		    skb_cloned(skb))
+			goto slow_path;
+
+		for (frag = skb_shinfo(skb)->frag_list; frag; frag = frag->next) {
+			/* Correct geometry. */
+			if (frag->len > mtu ||
+			    ((frag->len & 7) && frag->next) ||
+			    skb_headroom(frag) < hlen)
+			    goto slow_path;
+
+			/* Correct socket ownership. */
+			if (frag->sk == NULL)
+				goto slow_path;
+
+			/* Partially cloned skb? */
+			if (skb_shared(frag))
+				goto slow_path;
+		}
+
+		err = 0;
+		offset = 0;
+		frag = skb_shinfo(skb)->frag_list;
+		skb_shinfo(skb)->frag_list = 0;
+		/* BUILD HEADER */
+
+		tmp_hdr = kmalloc(hlen, GFP_ATOMIC);
+		if (!tmp_hdr) {
+			IP6_INC_STATS(Ip6FragFails);
+			return -ENOMEM;
+		}
+
+		*prevhdr = NEXTHDR_FRAGMENT;
+		memcpy(tmp_hdr, skb->nh.raw, hlen);
+		__skb_pull(skb, hlen);
+		fh = (struct frag_hdr*)__skb_push(skb, sizeof(struct frag_hdr));
+		skb->nh.raw = __skb_push(skb, hlen);
+		memcpy(skb->nh.raw, tmp_hdr, hlen);
+
+		ipv6_select_ident(skb, fh);
+		fh->nexthdr = nexthdr;
+		fh->reserved = 0;
+		fh->frag_off = htons(0x0001);
+		frag_id = fh->identification;
+
+		first_len = skb_pagelen(skb);
+		skb->data_len = first_len - skb_headlen(skb);
+		skb->len = first_len;
+		skb->nh.ipv6h->payload_len = htons(first_len - sizeof(struct ipv6hdr));
+ 
+
+		for (;;) {
+			/* Prepare header of the next frame,
+			 * before previous one went down. */
+			if (frag) {
+				frag->h.raw = frag->data;
+				fh = (struct frag_hdr*)__skb_push(frag, sizeof(struct frag_hdr));
+				frag->nh.raw = __skb_push(frag, hlen);
+				memcpy(frag->nh.raw, tmp_hdr, hlen);
+				offset += skb->len - hlen - sizeof(struct frag_hdr);
+				fh->nexthdr = nexthdr;
+				fh->reserved = 0;
+				if (frag->next != NULL)
+					offset |= 0x0001;
+				fh->frag_off = htons(offset);
+				fh->identification = frag_id;
+				frag->nh.ipv6h->payload_len = htons(frag->len - sizeof(struct ipv6hdr));
+				ip6_copy_metadata(frag, skb);
+			}
+			err = output(skb);
+
+			if (err || !frag)
+				break;
+
+			skb = frag;
+			frag = skb->next;
+			skb->next = NULL;
+		}
+
+		if (tmp_hdr)
+			kfree(tmp_hdr);
+
+		if (err == 0) {
+			IP6_INC_STATS(Ip6FragOKs);
+			return 0;
+		}
+
+		while (frag) {
+			skb = frag->next;
+			kfree_skb(frag);
+			frag = skb;
+		}
+
+		IP6_INC_STATS(Ip6FragFails);
+		return err;
+	}
+
+slow_path:
+	left = skb->len - hlen;		/* Space per frame */
+	ptr = hlen;			/* Where to start from */
+
+	/*
+	 *	Fragment the datagram.
+	 */
+
+	*prevhdr = NEXTHDR_FRAGMENT;
+
+	/*
+	 *	Keep copying data until we run out.
+	 */
+	while(left > 0)	{
+		len = left;
+		/* IF: it doesn't fit, use 'mtu' - the data space left */
+		if (len > mtu)
+			len = mtu;
+		/* IF: we are not sending upto and including the packet end
+		   then align the next start on an eight byte boundary */
+		if (len < left)	{
+			len &= ~7;
+		}
+		/*
+		 *	Allocate buffer.
+		 */
+
+		if ((frag = alloc_skb(len+hlen+sizeof(struct frag_hdr)+LL_RESERVED_SPACE(rt->u.dst.dev), GFP_ATOMIC)) == NULL) {
+			NETDEBUG(printk(KERN_INFO "IPv6: frag: no memory for new fragment!\n"));
+			err = -ENOMEM;
+			goto fail;
+		}
+
+		/*
+		 *	Set up data on packet
+		 */
+
+		ip6_copy_metadata(frag, skb);
+		skb_reserve(frag, LL_RESERVED_SPACE(rt->u.dst.dev));
+		skb_put(frag, len + hlen + sizeof(struct frag_hdr));
+		frag->nh.raw = frag->data;
+		fh = (struct frag_hdr*)(frag->data + hlen);
+		frag->h.raw = frag->data + hlen + sizeof(struct frag_hdr);
+
+		/*
+		 *	Charge the memory for the fragment to any owner
+		 *	it might possess
+		 */
+		if (skb->sk)
+			skb_set_owner_w(frag, skb->sk);
+
+		/*
+		 *	Copy the packet header into the new buffer.
+		 */
+		memcpy(frag->nh.raw, skb->data, hlen);
+
+		/*
+		 *	Build fragment header.
+		 */
+		fh->nexthdr = nexthdr;
+		fh->reserved = 0;
+		if (frag_id) {
+			ipv6_select_ident(skb, fh);
+			frag_id = fh->identification;
+		} else
+			fh->identification = frag_id;
+
+		/*
+		 *	Copy a block of the IP datagram.
+		 */
+		if (skb_copy_bits(skb, ptr, frag->h.raw, len))
+			BUG();
+		left -= len;
+
+		fh->frag_off = htons( left > 0 ?  (offset | 0x0001) : offset);
+		frag->nh.ipv6h->payload_len = htons(frag->len - sizeof(struct ipv6hdr));
+
+		ptr += len;
+		offset += len;
+
+		/*
+		 *	Put this fragment into the sending queue.
+		 */
+
+		IP6_INC_STATS(Ip6FragCreates);
+
+		err = output(frag);
+		if (err)
+			goto fail;
+	}
+	kfree_skb(skb);
+	IP6_INC_STATS(Ip6FragOKs);
+	return err;
+
+fail:
+	kfree_skb(skb); 
+	IP6_INC_STATS(Ip6FragFails);
+	return err;
+}
+
+int ip6_dst_lookup(struct sock *sk, struct dst_entry **dst, struct flowi *fl, struct in6_addr **saddr)
+{
+	struct ipv6_pinfo *np = inet6_sk(sk);
+	int err = 0;
+
+	*dst = __sk_dst_check(sk, np->dst_cookie);
+	if (*dst) {
+		struct rt6_info *rt = (struct rt6_info*)*dst;
+
+			/* Yes, checking route validity in not connected
+			   case is not very simple. Take into account,
+			   that we do not support routing by source, TOS,
+			   and MSG_DONTROUTE 		--ANK (980726)
+
+			   1. If route was host route, check that
+			      cached destination is current.
+			      If it is network route, we still may
+			      check its validity using saved pointer
+			      to the last used address: daddr_cache.
+			      We do not want to save whole address now,
+			      (because main consumer of this service
+			       is tcp, which has not this problem),
+			      so that the last trick works only on connected
+			      sockets.
+			   2. oif also should be the same.
+			 */
+
+		if (((rt->rt6i_dst.plen != 128 ||
+		      ipv6_addr_cmp(fl->fl6_dst, &rt->rt6i_dst.addr))
+		     && (np->daddr_cache == NULL ||
+			 ipv6_addr_cmp(fl->fl6_dst, np->daddr_cache)))
+		    || (fl->oif && fl->oif != (*dst)->dev->ifindex)) {
+			*dst = NULL;
+		} else
+			dst_hold(*dst);
+	}
+
+	if (*dst == NULL)
+		*dst = ip6_route_output(sk, fl);
+
+	if ((*dst)->error) {
+		IP6_INC_STATS(Ip6OutNoRoutes);
+		dst_release(*dst);
+		return -ENETUNREACH;
+	}
+
+	if (fl->fl6_src == NULL) {
+		*saddr = kmalloc(sizeof(struct in6_addr), GFP_ATOMIC);
+		err = ipv6_get_saddr(*dst, fl->fl6_dst, *saddr);
+
+		if (err) {
+#if IP6_DEBUG >= 2
+			printk(KERN_DEBUG "ip6_build_xmit: "
+			       "no availiable source address\n");
+#endif
+			return err;
+		}
+		fl->fl6_src = *saddr;
+	}
+
+        if (*dst) {
+		if ((err = xfrm_lookup(dst, fl, sk, 0)) < 0) {
+			dst_release(*dst);	
+			return -ENETUNREACH;
+		}
+        }
+
+	return 0;
+}
+
+int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to, int offset, int len, int odd, struct sk_buff *skb),
+		    void *from, int length, int transhdrlen,
+		    int hlimit, struct ipv6_txoptions *opt, struct flowi *fl, struct rt6_info *rt,
+		    unsigned int flags)
+{
+	struct inet_opt *inet = inet_sk(sk);
+	struct ipv6_pinfo *np = inet6_sk(sk);
+	struct sk_buff *skb;
+	unsigned int maxfraglen, fragheaderlen;
+	int exthdrlen;
+	int hh_len;
+	int mtu;
+	int copy = 0;
+	int err;
+	int offset = 0;
+	int csummode = CHECKSUM_NONE;
+
+	if (flags&MSG_PROBE)
+		return 0;
+	if (skb_queue_empty(&sk->write_queue)) {
+		/*
+		 * setup for corking
+		 */
+		if (opt) {
+			if (np->cork.opt == NULL)
+				np->cork.opt = kmalloc(opt->tot_len, sk->allocation);
+			memcpy(np->cork.opt, opt, opt->tot_len);
+			inet->cork.flags |= IPCORK_OPT;
+			/* need source address above miyazawa*/
+			exthdrlen += opt->opt_flen ? opt->opt_flen : 0;
+		}
+		dst_hold(&rt->u.dst);
+		np->cork.rt = rt;
+		np->cork.fl = fl;
+		inet->cork.fragsize = mtu = dst_pmtu(&rt->u.dst);
+		inet->cork.length = 0;
+		inet->sndmsg_page = NULL;
+		inet->sndmsg_off = 0;
+		if ((exthdrlen = rt->u.dst.header_len) != 0) {
+			length += exthdrlen;
+			transhdrlen += exthdrlen;
+		}
+	} else {
+		rt = np->cork.rt;
+		if (inet->cork.flags & IPCORK_OPT)
+			opt = np->cork.opt;
+		transhdrlen = 0;
+		exthdrlen = 0;
+		mtu = inet->cork.fragsize;
+	}
+
+	hh_len = (rt->u.dst.dev->hard_header_len&~15) + 16;
+
+	fragheaderlen = sizeof(struct ipv6hdr) + (opt ? opt->opt_nflen : 0);
+	maxfraglen = ((mtu - fragheaderlen) & ~7) + fragheaderlen - sizeof(struct frag_hdr);
+
+	if (mtu < 65576) {
+		if (inet->cork.length + length > 0xFFFF - fragheaderlen) {
+			ipv6_local_error(sk, EMSGSIZE, fl, mtu-exthdrlen);
+			return -EMSGSIZE;
+		}
+	}
+
+	inet->cork.length += length;
+
+	if ((skb = skb_peek_tail(&sk->write_queue)) == NULL)
+		goto alloc_new_skb;
+
+	while (length > 0) {
+		if ((copy = maxfraglen - skb->len) <= 0) {
+			char *data;
+			unsigned int datalen;
+			unsigned int fraglen;
+			unsigned int alloclen;
+			BUG_TRAP(copy == 0);
+alloc_new_skb:
+			datalen = maxfraglen - fragheaderlen;
+			if (datalen > length)
+				datalen = length;
+			fraglen = datalen + fragheaderlen;
+			if ((flags & MSG_MORE) &&
+			    !(rt->u.dst.dev->features&NETIF_F_SG))
+				alloclen = maxfraglen;
+			else
+				alloclen = fraglen;
+			alloclen += sizeof(struct frag_hdr);
+			if (transhdrlen) {
+				skb = sock_alloc_send_skb(sk,
+						alloclen + hh_len + 15,
+						(flags & MSG_DONTWAIT), &err);
+			} else {
+				skb = NULL;
+				if (atomic_read(&sk->wmem_alloc) <= 2*sk->sndbuf)
+					skb = sock_wmalloc(sk,
+							   alloclen + hh_len + 15, 1,
+							   sk->allocation);
+				if (unlikely(skb == NULL))
+					err = -ENOBUFS;
+			}
+			if (skb == NULL)
+				goto error;
+			/*
+			 *	Fill in the control structures
+			 */
+			skb->ip_summed = csummode;
+			skb->csum = 0;
+			/* reserve 8 byte for fragmentation */
+			skb_reserve(skb, hh_len+sizeof(struct frag_hdr));
+
+			/*
+			 *	Find where to start putting bytes
+			 */
+			data = skb_put(skb, fraglen);
+			skb->nh.raw = data + exthdrlen;
+			data += fragheaderlen;
+			skb->h.raw = data + exthdrlen;
+			copy = datalen - transhdrlen;
+			if (copy > 0 && getfrag(from, data + transhdrlen, offset, copy, 0, skb) < 0) {
+				err = -EFAULT;
+				kfree_skb(skb);
+				goto error;
+			}
+
+			offset += copy;
+			length -= datalen;
+			transhdrlen = 0;
+			exthdrlen = 0;
+			csummode = CHECKSUM_NONE;
+
+			/*
+			 * Put the packet on the pending queue
+			 */
+			__skb_queue_tail(&sk->write_queue, skb);
+			continue;
+		}
+
+		if (copy > length)
+			copy = length;
+
+		if (!(rt->u.dst.dev->features&NETIF_F_SG)) {
+			unsigned int off;
+
+			off = skb->len;
+			if (getfrag(from, skb_put(skb, copy),
+						offset, copy, off, skb) < 0) {
+				__skb_trim(skb, off);
+				err = -EFAULT;
+				goto error;
+			}
+		} else {
+			int i = skb_shinfo(skb)->nr_frags;
+			skb_frag_t *frag = &skb_shinfo(skb)->frags[i-1];
+			struct page *page = inet->sndmsg_page;
+			int off = inet->sndmsg_off;
+			unsigned int left;
+
+			if (page && (left = PAGE_SIZE - off) > 0) {
+				if (copy >= left)
+					copy = left;
+				if (page != frag->page) {
+					if (i == MAX_SKB_FRAGS) {
+						err = -EMSGSIZE;
+						goto error;
+					}
+					get_page(page);
+					skb_fill_page_desc(skb, i, page, inet->sndmsg_off, 0);
+					frag = &skb_shinfo(skb)->frags[i];
+				}
+			} else if(i < MAX_SKB_FRAGS) {
+				if (copy > PAGE_SIZE)
+					copy = PAGE_SIZE;
+				page = alloc_pages(sk->allocation, 0);
+				if (page == NULL) {
+					err = -ENOMEM;
+					goto error;
+				}
+				inet->sndmsg_page = page;
+				inet->sndmsg_off = 0;
+
+				skb_fill_page_desc(skb, i, page, 0, 0);
+				frag = &skb_shinfo(skb)->frags[i];
+				skb->truesize += PAGE_SIZE;
+				atomic_add(PAGE_SIZE, &sk->wmem_alloc);
+			} else {
+				err = -EMSGSIZE;
+				goto error;
+			}
+			if (getfrag(from, page_address(frag->page)+frag->page_offset+frag->size, offset, copy, skb->len, skb) < 0) {
+				err = -EFAULT;
+				goto error;
+			}
+			inet->sndmsg_off += copy;
+			frag->size += copy;
+			skb->len += copy;
+			skb->data_len += copy;
+		}
+		offset += copy;
+		length -= copy;
+	}
+	return 0;
+error:
+	inet->cork.length -= length;
+	IP6_INC_STATS(Ip6OutDiscards);
+	return err;
+}
+
+int ip6_push_pending_frames(struct sock *sk)
+{
+	struct sk_buff *skb, *tmp_skb;
+	struct sk_buff **tail_skb;
+	struct in6_addr *final_dst = NULL;
+	struct inet_opt *inet = inet_sk(sk);
+	struct ipv6_pinfo *np = inet6_sk(sk);
+	struct ipv6hdr *hdr;
+	struct ipv6_txoptions *opt = np->cork.opt;
+	struct rt6_info *rt = np->cork.rt;
+	struct flowi *fl = np->cork.fl;
+	unsigned char proto = fl->proto;
+	int err = 0;
+
+	if ((skb = __skb_dequeue(&sk->write_queue)) == NULL)
+		goto out;
+	tail_skb = &(skb_shinfo(skb)->frag_list);
+
+	/* move skb->data to ip header from ext header */
+	if (skb->data < skb->nh.raw)
+		__skb_pull(skb, skb->nh.raw - skb->data);
+	while ((tmp_skb = __skb_dequeue(&sk->write_queue)) != NULL) {
+		__skb_pull(tmp_skb, skb->h.raw - skb->nh.raw);
+		*tail_skb = tmp_skb;
+		tail_skb = &(tmp_skb->next);
+		skb->len += tmp_skb->len;
+		skb->data_len += tmp_skb->len;
+#if 0 /* Logically correct, but useless work, ip_fragment() will have to undo */
+		skb->truesize += tmp_skb->truesize;
+		__sock_put(tmp_skb->sk);
+		tmp_skb->destructor = NULL;
+		tmp_skb->sk = NULL;
+#endif
+	}
+
+	final_dst = fl->fl6_dst;
+	__skb_pull(skb, skb->h.raw - skb->nh.raw);
+	if (opt && opt->opt_flen)
+		ipv6_push_frag_opts(skb, opt, &proto);
+	if (opt && opt->opt_nflen)
+		ipv6_push_nfrag_opts(skb, opt, &proto, &final_dst);
+
+	skb->nh.ipv6h = hdr = (struct ipv6hdr*) skb_push(skb, sizeof(struct ipv6hdr));
+	
+	*(u32*)hdr = fl->fl6_flowlabel | htonl(0x60000000);
+
+	if (skb->len < 65536)
+		hdr->payload_len = htons(skb->len - sizeof(struct ipv6hdr));
+	else
+		hdr->payload_len = 0;
+	hdr->hop_limit = np->hop_limit;
+	hdr->nexthdr = proto;
+	memcpy(&hdr->saddr, fl->fl6_src, sizeof(struct in6_addr));
+	memcpy(&hdr->daddr, final_dst, sizeof(struct in6_addr));
+
+	skb->dst = dst_clone(&rt->u.dst);
+	err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, skb, NULL, skb->dst->dev, dst_output);
+	if (err) {
+		if (err > 0)
+			err = inet->recverr ? net_xmit_errno(err) : 0;
+		if (err)
+			goto error;
+	}
+
+out:
+	inet->cork.flags &= ~IPCORK_OPT;
+	if (np->cork.opt) {
+		kfree(np->cork.opt);
+		np->cork.opt = NULL;
+	}
+	if (np->cork.rt) {
+		np->cork.rt = NULL;
+	}
+	if (np->cork.fl) {
+		np->cork.fl = NULL;
+	}
+	return err;
+error:
+	goto out;
+}
+
+void ip6_flush_pending_frames(struct sock *sk)
+{
+	struct inet_opt *inet = inet_sk(sk);
+	struct ipv6_pinfo *np = inet6_sk(sk);
+	struct sk_buff *skb;
+
+	while ((skb = __skb_dequeue_tail(&sk->write_queue)) != NULL)
+		kfree_skb(skb);
+
+	inet->cork.flags &= ~IPCORK_OPT;
+
+	if (np->cork.opt) {
+		kfree(np->cork.opt);
+		np->cork.opt = NULL;
+	}
+	if (np->cork.rt) {
+		np->cork.rt = NULL;
+	}
+	if (np->cork.fl) {
+		np->cork.fl = NULL;
+	}
+}
diff -urN linux-2.5.69-bk7/net/ipv6/raw.c linux-2.5.69-bk8/net/ipv6/raw.c
--- linux-2.5.69-bk7/net/ipv6/raw.c	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/net/ipv6/raw.c	2003-05-13 04:44:30.000000000 -0700
@@ -12,6 +12,7 @@
  *	Fixes:
  *	Hideaki YOSHIFUJI	:	sin6_scope_id support
  *	YOSHIFUJI,H.@USAGI	:	raw checksum (RFC2292(bis) compliance) 
+ *	Kazunori MIYAZAWA @USAGI:	change process style to use ip6_append_data
  *
  *	This program is free software; you can redistribute it and/or
  *      modify it under the terms of the GNU General Public License
@@ -29,6 +30,8 @@
 #include <linux/netdevice.h>
 #include <linux/if_arp.h>
 #include <linux/icmpv6.h>
+#include <linux/netfilter.h>
+#include <linux/netfilter_ipv6.h>
 #include <asm/uaccess.h>
 #include <asm/ioctls.h>
 
@@ -438,87 +441,115 @@
 	goto out_free;
 }
 
-/*
- *	Sending...
- */
+static int rawv6_push_pending_frames(struct sock *sk, struct flowi *fl, struct raw6_opt *opt, int len)
+{
+	struct sk_buff *skb;
+	int err = 0;
+	u16 *csum;
 
-struct rawv6_fakehdr {
-	struct iovec	*iov;
-	struct sock	*sk;
-	__u32		len;
-	__u32		cksum;
-	__u32		proto;
-	struct in6_addr *daddr;
-};
+	if ((skb = skb_peek(&sk->write_queue)) == NULL)
+		goto out;
 
-static int rawv6_getfrag(const void *data, struct in6_addr *saddr, 
-			  char *buff, unsigned int offset, unsigned int len)
-{
-	struct iovec *iov = (struct iovec *) data;
+	if (opt->offset + 1 < len)
+		csum = (u16 *)(skb->h.raw + opt->offset);
+	else {
+		err = -EINVAL;
+		goto out;
+	}
+
+	if (skb_queue_len(&sk->write_queue) == 1) {
+		/*
+		 * Only one fragment on the socket.
+		 */
+		/* should be check HW csum miyazawa */
+		*csum = csum_ipv6_magic(fl->fl6_src,
+					     fl->fl6_dst,
+					     len, fl->proto, skb->csum);
+	} else {
+		u32 tmp_csum = 0;
+
+		skb_queue_walk(&sk->write_queue, skb) {
+			tmp_csum = csum_add(tmp_csum, skb->csum);
+		}
 
-	return memcpy_fromiovecend(buff, iov, offset, len);
+		tmp_csum = csum_ipv6_magic(fl->fl6_src,
+					fl->fl6_dst,
+					len, fl->proto, tmp_csum);
+		*csum = tmp_csum;
+	}
+	if (*csum == 0)
+		*csum = -1;
+	ip6_push_pending_frames(sk);
+out:
+	return err;
 }
 
-static int rawv6_frag_cksum(const void *data, struct in6_addr *addr,
-			     char *buff, unsigned int offset, 
-			     unsigned int len)
+static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
+			struct flowi *fl, struct rt6_info *rt, 
+			unsigned int flags)
 {
-	struct rawv6_fakehdr *hdr = (struct rawv6_fakehdr *) data;
-	
-	if (csum_partial_copy_fromiovecend(buff, hdr->iov, offset, 
-						    len, &hdr->cksum))
-		return -EFAULT;
-	
-	if (offset == 0) {
-		struct sock *sk;
-		struct raw6_opt *opt;
-		struct in6_addr *daddr;
-		
-		sk = hdr->sk;
-		opt = raw6_sk(sk);
+	struct inet_opt *inet = inet_sk(sk);
+	struct ipv6hdr *iph;
+	struct sk_buff *skb;
+	unsigned int hh_len;
+	int err;
 
-		if (hdr->daddr)
-			daddr = hdr->daddr;
-		else
-			daddr = addr + 1;
-		
-		hdr->cksum = csum_ipv6_magic(addr, daddr, hdr->len,
-					     hdr->proto, hdr->cksum);
-		
-		if (opt->offset + 1 < len) {
-			__u16 *csum;
+	if (length > rt->u.dst.dev->mtu) {
+		ipv6_local_error(sk, EMSGSIZE, fl, rt->u.dst.dev->mtu);
+		return -EMSGSIZE;
+	}
+	if (flags&MSG_PROBE)
+		goto out;
 
-			csum = (__u16 *) (buff + opt->offset);
-			if (*csum) {
-				/* in case cksum was not initialized */
-				__u32 sum = hdr->cksum;
-				sum += *csum;
-				*csum = hdr->cksum = (sum + (sum>>16));
-			} else {
-				*csum = hdr->cksum;
-			}
-		} else {
-			if (net_ratelimit())
-				printk(KERN_DEBUG "icmp: cksum offset too big\n");
-			return -EINVAL;
-		}
-	}	
-	return 0; 
-}
+	hh_len = LL_RESERVED_SPACE(rt->u.dst.dev);
+
+	skb = sock_alloc_send_skb(sk, length+hh_len+15,
+				  flags&MSG_DONTWAIT, &err);
+	if (skb == NULL)
+		goto error; 
+	skb_reserve(skb, hh_len);
+
+	skb->priority = sk->priority;
+	skb->dst = dst_clone(&rt->u.dst);
 
+	skb->nh.ipv6h = iph = (struct ipv6hdr *)skb_put(skb, length);
 
+	skb->ip_summed = CHECKSUM_NONE;
+
+	skb->h.raw = skb->nh.raw;
+	err = memcpy_fromiovecend((void *)iph, from, 0, length);
+	if (err)
+		goto error_fault;
+
+	err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, skb, NULL, rt->u.dst.dev,
+		      dst_output);
+	if (err > 0)
+		err = inet->recverr ? net_xmit_errno(err) : 0;
+	if (err)
+		goto error;
+out:
+	return 0;
+
+error_fault:
+	err = -EFAULT;
+	kfree_skb(skb);
+error:
+	IP6_INC_STATS(Ip6OutDiscards);
+	return err; 
+}
 static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, int len)
 {
 	struct ipv6_txoptions opt_space;
 	struct sockaddr_in6 * sin6 = (struct sockaddr_in6 *) msg->msg_name;
+	struct in6_addr *daddr, *saddr = NULL;
 	struct inet_opt *inet = inet_sk(sk);
 	struct ipv6_pinfo *np = inet6_sk(sk);
+	struct raw6_opt *raw_opt = raw6_sk(sk);
 	struct ipv6_txoptions *opt = NULL;
 	struct ip6_flowlabel *flowlabel = NULL;
+	struct dst_entry *dst = NULL;
 	struct flowi fl;
 	int addr_len = msg->msg_namelen;
-	struct in6_addr *daddr;
-	struct raw6_opt *raw_opt;
 	int hlimit = -1;
 	u16 proto;
 	int err;
@@ -552,6 +583,8 @@
 
 		if (!proto)
 			proto = inet->num;
+		else if (proto != inet->num)
+			return(-EINVAL);
 
 		if (proto > 255)
 			return(-EINVAL);
@@ -590,6 +623,7 @@
 		 * unspecfied destination address 
 		 * treated as error... is this correct ?
 		 */
+		fl6_sock_release(flowlabel);
 		return(-EINVAL);
 	}
 
@@ -619,39 +653,71 @@
 	if (flowlabel)
 		opt = fl6_merge_options(&opt_space, flowlabel, opt);
 
-	raw_opt = raw6_sk(sk);
-
 	fl.proto = proto;
 	fl.fl6_dst = daddr;
 	if (fl.fl6_src == NULL && !ipv6_addr_any(&np->saddr))
 		fl.fl6_src = &np->saddr;
 	fl.fl_icmp_type = 0;
 	fl.fl_icmp_code = 0;
-	
-	if (raw_opt->checksum) {
-		struct rawv6_fakehdr hdr;
-		
-		hdr.iov = msg->msg_iov;
-		hdr.sk  = sk;
-		hdr.len = len;
-		hdr.cksum = 0;
-		hdr.proto = proto;
 
-		if (opt && opt->srcrt)
-			hdr.daddr = daddr;
+	/* merge ip6_build_xmit from ip6_output */
+	if (opt && opt->srcrt) {
+		struct rt0_hdr *rt0 = (struct rt0_hdr *) opt->srcrt;
+		fl.fl6_dst = rt0->addr;
+	}
+
+	if (!fl.oif && ipv6_addr_is_multicast(fl.nl_u.ip6_u.daddr))
+		fl.oif = np->mcast_oif;
+
+	err = ip6_dst_lookup(sk, &dst, &fl, &saddr);
+	if (err) goto out;
+
+	if (hlimit < 0) {
+		if (ipv6_addr_is_multicast(fl.fl6_dst))
+			hlimit = np->mcast_hops;
 		else
-			hdr.daddr = NULL;
+			hlimit = np->hop_limit;
+		if (hlimit < 0)
+			hlimit = ((struct rt6_info*)dst)->rt6i_hoplimit;
+	}
+
+	if (msg->msg_flags&MSG_CONFIRM)
+		goto do_confirm;
 
-		err = ip6_build_xmit(sk, rawv6_frag_cksum, &hdr, &fl, len,
-				     opt, hlimit, msg->msg_flags);
+back_from_confirm:
+	if (inet->hdrincl) {
+		err = rawv6_send_hdrinc(sk, msg->msg_iov, len, &fl, (struct rt6_info*)dst, msg->msg_flags);
 	} else {
-		err = ip6_build_xmit(sk, rawv6_getfrag, msg->msg_iov, &fl, len,
-				     opt, hlimit, msg->msg_flags);
+		lock_sock(sk);
+		err = ip6_append_data(sk, ip_generic_getfrag, msg->msg_iov, len, 0,
+					hlimit, opt, &fl, (struct rt6_info*)dst, msg->msg_flags);
+
+		if (err)
+			ip6_flush_pending_frames(sk);
+		else if (!(msg->msg_flags & MSG_MORE)) {
+			if (raw_opt->checksum) {
+				err = rawv6_push_pending_frames(sk, &fl, raw_opt, len);
+			} else {
+				err = ip6_push_pending_frames(sk);
+			}
+		}
 	}
+done:
+	ip6_dst_store(sk, dst, fl.nl_u.ip6_u.daddr == &np->daddr ? &np->daddr : NULL);
+	if (err > 0)
+		err = np->recverr ? net_xmit_errno(err) : 0;
 
+	release_sock(sk);
+out:	
 	fl6_sock_release(flowlabel);
-
+	if (saddr) kfree(saddr);
 	return err<0?err:len;
+do_confirm:
+	dst_confirm(dst);
+	if (!(msg->msg_flags & MSG_PROBE) || len)
+		goto back_from_confirm;
+	err = 0;
+	goto done;
 }
 
 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname, 
diff -urN linux-2.5.69-bk7/net/ipv6/udp.c linux-2.5.69-bk8/net/ipv6/udp.c
--- linux-2.5.69-bk7/net/ipv6/udp.c	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/net/ipv6/udp.c	2003-05-13 04:44:30.000000000 -0700
@@ -14,6 +14,7 @@
  *	YOSHIFUJI Hideaki @USAGI and:	Support IPV6_V6ONLY socket option, which
  *	Alexey Kuznetsov		allow both IPv4 and IPv6 sockets to bind
  *					a single port at the same time.
+ *      Kazunori MIYAZAWA @USAGI:       change process style to use ip6_append_data
  *
  *	This program is free software; you can redistribute it and/or
  *      modify it under the terms of the GNU General Public License
@@ -738,96 +739,117 @@
 	kfree_skb(skb);
 	return(0);	
 }
-
 /*
- *	Sending
+ * Throw away all pending data and cancel the corking. Socket is locked.
  */
-
-struct udpv6fakehdr 
+static void udp_v6_flush_pending_frames(struct sock *sk)
 {
-	struct udphdr	uh;
-	struct iovec	*iov;
-	__u32		wcheck;
-	__u32		pl_len;
-	struct in6_addr *daddr;
-};
+	struct udp_opt *up = udp_sk(sk);
+
+	if (up->pending) {
+		up->pending = 0;
+		ip6_flush_pending_frames(sk);
+        }
+}
 
 /*
- *	with checksum
+ *	Sending
  */
 
-static int udpv6_getfrag(const void *data, struct in6_addr *addr,
-			 char *buff, unsigned int offset, unsigned int len)
+static int udp_v6_push_pending_frames(struct sock *sk, struct udp_opt *up)
 {
-	struct udpv6fakehdr *udh = (struct udpv6fakehdr *) data;
-	char *dst;
-	int final = 0;
-	int clen = len;
+	struct sk_buff *skb;
+	struct udphdr *uh;
+	struct ipv6_pinfo *np = inet6_sk(sk);
+	struct flowi *fl = np->cork.fl;
+	int err = 0;
 
-	dst = buff;
+	/* Grab the skbuff where UDP header space exists. */
+	if ((skb = skb_peek(&sk->write_queue)) == NULL)
+		goto out;
 
-	if (offset) {
-		offset -= sizeof(struct udphdr);
+	/*
+	 * Create a UDP header
+	 */
+	uh = skb->h.uh;
+	uh->source = fl->fl_ip_sport;
+	uh->dest = fl->fl_ip_dport;
+	uh->len = htons(up->len);
+	uh->check = 0;
+
+	if (sk->no_check == UDP_CSUM_NOXMIT) {
+		skb->ip_summed = CHECKSUM_NONE;
+		goto send;
+	}
+
+	if (skb_queue_len(&sk->write_queue) == 1) {
+		skb->csum = csum_partial((char *)uh,
+				sizeof(struct udphdr), skb->csum);
+		uh->check = csum_ipv6_magic(fl->fl6_src,
+					    fl->fl6_dst,
+					    up->len, fl->proto, skb->csum);
 	} else {
-		dst += sizeof(struct udphdr);
-		final = 1;
-		clen -= sizeof(struct udphdr);
-	}
-
-	if (csum_partial_copy_fromiovecend(dst, udh->iov, offset,
-					   clen, &udh->wcheck))
-		return -EFAULT;
+		u32 tmp_csum = 0;
 
-	if (final) {
-		struct in6_addr *daddr;
-		
-		udh->wcheck = csum_partial((char *)udh, sizeof(struct udphdr),
-					   udh->wcheck);
-
-		if (udh->daddr) {
-			daddr = udh->daddr;
-		} else {
-			/*
-			 *	use packet destination address
-			 *	this should improve cache locality
-			 */
-			daddr = addr + 1;
-		}
-		udh->uh.check = csum_ipv6_magic(addr, daddr,
-						udh->pl_len, IPPROTO_UDP,
-						udh->wcheck);
-		if (udh->uh.check == 0)
-			udh->uh.check = -1;
+		skb_queue_walk(&sk->write_queue, skb) {
+			tmp_csum = csum_add(tmp_csum, skb->csum);
+		}
+		tmp_csum = csum_partial((char *)uh,
+				sizeof(struct udphdr), tmp_csum);
+                tmp_csum = csum_ipv6_magic(fl->fl6_src,
+					   fl->fl6_dst,
+					   up->len, fl->proto, tmp_csum);
+                uh->check = tmp_csum;
 
-		memcpy(buff, udh, sizeof(struct udphdr));
 	}
-	return 0;
+	if (uh->check == 0)
+		uh->check = -1;
+
+send:
+	err = ip6_push_pending_frames(sk);
+out:
+	up->len = 0;
+	up->pending = 0;
+	return err;
 }
 
-static int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, int ulen)
+static int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, int len)
 {
 	struct ipv6_txoptions opt_space;
-	struct udpv6fakehdr udh;
+	struct udp_opt *up = udp_sk(sk);
 	struct inet_opt *inet = inet_sk(sk);
 	struct ipv6_pinfo *np = inet6_sk(sk);
 	struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) msg->msg_name;
+	struct in6_addr *daddr, *saddr = NULL;
 	struct ipv6_txoptions *opt = NULL;
 	struct ip6_flowlabel *flowlabel = NULL;
 	struct flowi fl;
+	struct dst_entry *dst;
 	int addr_len = msg->msg_namelen;
-	struct in6_addr *daddr;
-	int len = ulen + sizeof(struct udphdr);
+	int ulen = len;
 	int addr_type;
 	int hlimit = -1;
-	
+	int corkreq = up->corkflag || msg->msg_flags&MSG_MORE;
 	int err;
 	
 	/* Rough check on arithmetic overflow,
 	   better check is made in ip6_build_xmit
 	   */
-	if (ulen < 0 || ulen > INT_MAX - sizeof(struct udphdr))
+	if (len < 0 || len > INT_MAX - sizeof(struct udphdr))
 		return -EMSGSIZE;
 	
+	if (up->pending) {
+		/*
+		 * There are pending frames.
+		 * The socket lock must be held while it's corked.
+		 */
+		lock_sock(sk);
+		if (likely(up->pending))
+			goto do_append_data;
+		release_sock(sk);
+	}
+	ulen += sizeof(struct udphdr);
+
 	fl.fl6_flowlabel = 0;
 	fl.oif = 0;
 
@@ -835,7 +857,7 @@
 		if (sin6->sin6_family == AF_INET) {
 			if (__ipv6_only_sock(sk))
 				return -ENETUNREACH;
-			return udp_sendmsg(iocb, sk, msg, ulen);
+			return udp_sendmsg(iocb, sk, msg, len);
 		}
 
 		if (addr_len < SIN6_LEN_RFC2133)
@@ -847,7 +869,7 @@
 		if (sin6->sin6_port == 0)
 			return -EINVAL;
 
-		udh.uh.dest = sin6->sin6_port;
+		up->dport = sin6->sin6_port;
 		daddr = &sin6->sin6_addr;
 
 		if (np->sndflow) {
@@ -873,7 +895,7 @@
 		if (sk->state != TCP_ESTABLISHED)
 			return -ENOTCONN;
 
-		udh.uh.dest = inet->dport;
+		up->dport = inet->dport;
 		daddr = &np->daddr;
 		fl.fl6_flowlabel = np->flow_label;
 	}
@@ -888,15 +910,14 @@
 
 		sin.sin_family = AF_INET;
 		sin.sin_addr.s_addr = daddr->s6_addr32[3];
-		sin.sin_port = udh.uh.dest;
+		sin.sin_port = up->dport;
 		msg->msg_name = (struct sockaddr *)(&sin);
 		msg->msg_namelen = sizeof(sin);
 		fl6_sock_release(flowlabel);
 
-		return udp_sendmsg(iocb, sk, msg, ulen);
+		return udp_sendmsg(iocb, sk, msg, len);
 	}
 
-	udh.daddr = NULL;
 	if (!fl.oif)
 		fl.oif = sk->bound_dev_if;
 	fl.fl6_src = NULL;
@@ -922,33 +943,172 @@
 		opt = np->opt;
 	if (flowlabel)
 		opt = fl6_merge_options(&opt_space, flowlabel, opt);
-	if (opt && opt->srcrt)
-		udh.daddr = daddr;
-
-	udh.uh.source = inet->sport;
-	udh.uh.len = len < 0x10000 ? htons(len) : 0;
-	udh.uh.check = 0;
-	udh.iov = msg->msg_iov;
-	udh.wcheck = 0;
-	udh.pl_len = len;
 
 	fl.proto = IPPROTO_UDP;
 	fl.fl6_dst = daddr;
 	if (fl.fl6_src == NULL && !ipv6_addr_any(&np->saddr))
 		fl.fl6_src = &np->saddr;
-	fl.fl_ip_dport = udh.uh.dest;
-	fl.fl_ip_sport = udh.uh.source;
+	fl.fl_ip_dport = up->dport;
+	fl.fl_ip_sport = inet->sport;
+	
+	/* merge ip6_build_xmit from ip6_output */
+	if (opt && opt->srcrt) {
+		struct rt0_hdr *rt0 = (struct rt0_hdr *) opt->srcrt;
+		fl.fl6_dst = rt0->addr;
+	}
 
-	err = ip6_build_xmit(sk, udpv6_getfrag, &udh, &fl, len, opt, hlimit,
-			     msg->msg_flags);
+	if (!fl.oif && ipv6_addr_is_multicast(fl.nl_u.ip6_u.daddr))
+		fl.oif = np->mcast_oif;
 
+	err = ip6_dst_lookup(sk, &dst, &fl, &saddr);
+	if (err) goto out;
+
+	if (hlimit < 0) {
+		if (ipv6_addr_is_multicast(fl.fl6_dst))
+			hlimit = np->mcast_hops;
+		else
+			hlimit = np->hop_limit;
+		if (hlimit < 0)
+			hlimit = ((struct rt6_info*)dst)->rt6i_hoplimit;
+	}
+
+	if (msg->msg_flags&MSG_CONFIRM)
+		goto do_confirm;
+back_from_confirm:
+
+	lock_sock(sk);
+	if (unlikely(up->pending)) {
+		/* The socket is already corked while preparing it. */
+		/* ... which is an evident application bug. --ANK */
+		release_sock(sk);
+
+		NETDEBUG(if (net_ratelimit()) printk(KERN_DEBUG "udp cork app bug 2\n"));
+		err = -EINVAL;
+		goto out;
+	}
+
+	up->pending = 1;
+
+do_append_data:
+	up->len += ulen;
+	err = ip6_append_data(sk, ip_generic_getfrag, msg->msg_iov, ulen, sizeof(struct udphdr),
+			      hlimit, opt, &fl, (struct rt6_info*)dst,
+			      corkreq ? msg->msg_flags|MSG_MORE : msg->msg_flags);
+	if (err)
+		udp_v6_flush_pending_frames(sk);
+	else if (!corkreq)
+		err = udp_v6_push_pending_frames(sk, up);
+
+	ip6_dst_store(sk, dst, fl.nl_u.ip6_u.daddr == &np->daddr ? &np->daddr : NULL);
+	if (err > 0)
+		err = np->recverr ? net_xmit_errno(err) : 0;
+	release_sock(sk);
+out:
 	fl6_sock_release(flowlabel);
+	if (saddr) kfree(saddr);
+	if (!err) {
+		UDP6_INC_STATS_USER(UdpOutDatagrams);
+		return len;
+	}
+	return err;
 
-	if (err < 0)
-		return err;
+do_confirm:
+	dst_confirm(dst);
+	if (!(msg->msg_flags&MSG_PROBE) || len)
+		goto back_from_confirm;
+	err = 0;
+	goto out;
+}
+
+static int udpv6_destroy_sock(struct sock *sk)
+{
+	lock_sock(sk);
+	udp_v6_flush_pending_frames(sk);
+	release_sock(sk);
+
+	inet6_destroy_sock(sk);
+
+	return 0;
+}
+
+/*
+ *	Socket option code for UDP
+ */
+static int udpv6_setsockopt(struct sock *sk, int level, int optname, 
+			  char *optval, int optlen)
+{
+	struct udp_opt *up = udp_sk(sk);
+	int val;
+	int err = 0;
+
+	if (level != SOL_UDP)
+		return ipv6_setsockopt(sk, level, optname, optval, optlen);
 
-	UDP6_INC_STATS_USER(UdpOutDatagrams);
-	return ulen;
+	if(optlen<sizeof(int))
+		return -EINVAL;
+
+	if (get_user(val, (int *)optval))
+		return -EFAULT;
+
+	switch(optname) {
+	case UDP_CORK:
+		if (val != 0) {
+			up->corkflag = 1;
+		} else {
+			up->corkflag = 0;
+			lock_sock(sk);
+			udp_v6_push_pending_frames(sk, up);
+			release_sock(sk);
+		}
+		break;
+		
+	case UDP_ENCAP:
+		up->encap_type = val;
+		break;
+
+	default:
+		err = -ENOPROTOOPT;
+		break;
+	};
+
+	return err;
+}
+
+static int udpv6_getsockopt(struct sock *sk, int level, int optname, 
+			  char *optval, int *optlen)
+{
+	struct udp_opt *up = udp_sk(sk);
+	int val, len;
+
+	if (level != SOL_UDP)
+		return ipv6_getsockopt(sk, level, optname, optval, optlen);
+
+	if(get_user(len,optlen))
+		return -EFAULT;
+
+	len = min_t(unsigned int, len, sizeof(int));
+	
+	if(len < 0)
+		return -EINVAL;
+
+	switch(optname) {
+	case UDP_CORK:
+		val = up->corkflag;
+		break;
+
+	case UDP_ENCAP:
+		val = up->encap_type;
+		break;
+
+	default:
+		return -ENOPROTOOPT;
+	};
+
+  	if(put_user(len, optlen))
+  		return -EFAULT;
+	if(copy_to_user(optval, &val,len))
+		return -EFAULT;
+  	return 0;
 }
 
 static struct inet6_protocol udpv6_protocol = {
@@ -1038,9 +1198,9 @@
 	.connect =	udpv6_connect,
 	.disconnect =	udp_disconnect,
 	.ioctl =	udp_ioctl,
-	.destroy =	inet6_destroy_sock,
-	.setsockopt =	ipv6_setsockopt,
-	.getsockopt =	ipv6_getsockopt,
+	.destroy =	udpv6_destroy_sock,
+	.setsockopt =	udpv6_setsockopt,
+	.getsockopt =	udpv6_getsockopt,
 	.sendmsg =	udpv6_sendmsg,
 	.recvmsg =	udpv6_recvmsg,
 	.backlog_rcv =	udpv6_queue_rcv_skb,
diff -urN linux-2.5.69-bk7/net/irda/irlap.c linux-2.5.69-bk8/net/irda/irlap.c
--- linux-2.5.69-bk7/net/irda/irlap.c	2003-05-04 16:53:41.000000000 -0700
+++ linux-2.5.69-bk8/net/irda/irlap.c	2003-05-13 04:44:30.000000000 -0700
@@ -1117,7 +1117,7 @@
 		len += sprintf(buf+len, "  win size: %d, ",
 			       self->window_size);
 		len += sprintf(buf+len, "win: %d, ", self->window);
-#if CONFIG_IRDA_DYNAMIC_WINDOW
+#ifdef CONFIG_IRDA_DYNAMIC_WINDOW
 		len += sprintf(buf+len, "line capacity: %d, ",
 			       self->line_capacity);
 		len += sprintf(buf+len, "bytes left: %d\n", self->bytes_left);
diff -urN linux-2.5.69-bk7/net/irda/irlap_event.c linux-2.5.69-bk8/net/irda/irlap_event.c
--- linux-2.5.69-bk7/net/irda/irlap_event.c	2003-05-04 16:53:32.000000000 -0700
+++ linux-2.5.69-bk8/net/irda/irlap_event.c	2003-05-13 04:44:30.000000000 -0700
@@ -43,7 +43,7 @@
 
 #include <net/irda/irda_device.h>
 
-#if CONFIG_IRDA_FAST_RR
+#ifdef CONFIG_IRDA_FAST_RR
 int sysctl_fast_poll_increase = 50;
 #endif
 
diff -urN linux-2.5.69-bk7/net/key/af_key.c linux-2.5.69-bk8/net/key/af_key.c
--- linux-2.5.69-bk7/net/key/af_key.c	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/net/key/af_key.c	2003-05-13 04:44:30.000000000 -0700
@@ -1241,7 +1241,8 @@
 		}
 	}
 
-	if (x1 && x1->id.spi && hdr->sadb_msg_type == SADB_ADD) {
+	if (x1 && ((x1->id.spi && hdr->sadb_msg_type == SADB_ADD) ||
+	     (hdr->sadb_msg_type == SADB_UPDATE && xfrm_state_kern(x1)))) {
 		x->km.state = XFRM_STATE_DEAD;
 		xfrm_state_put(x);
 		xfrm_state_put(x1);
@@ -1286,6 +1287,11 @@
 	if (x == NULL)
 		return -ESRCH;
 
+	if (xfrm_state_kern(x)) {
+		xfrm_state_put(x);
+		return -EPERM;
+	}
+	
 	xfrm_state_delete(x);
 	xfrm_state_put(x);
 
diff -urN linux-2.5.69-bk7/net/netsyms.c linux-2.5.69-bk8/net/netsyms.c
--- linux-2.5.69-bk7/net/netsyms.c	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/net/netsyms.c	2003-05-13 04:44:30.000000000 -0700
@@ -304,6 +304,7 @@
 EXPORT_SYMBOL(xfrm_state_unregister_afinfo);
 EXPORT_SYMBOL(xfrm_state_get_afinfo);
 EXPORT_SYMBOL(xfrm_state_put_afinfo);
+EXPORT_SYMBOL(xfrm_state_delete_tunnel);
 EXPORT_SYMBOL(xfrm_replay_check);
 EXPORT_SYMBOL(xfrm_replay_advance);
 EXPORT_SYMBOL(xfrm_check_selectors);
@@ -466,6 +467,8 @@
 EXPORT_SYMBOL(sysctl_max_syn_backlog);
 #endif
 
+EXPORT_SYMBOL(ip_generic_getfrag);
+
 #endif
 
 EXPORT_SYMBOL(tcp_read_sock);
@@ -570,6 +573,7 @@
 EXPORT_SYMBOL(netif_receive_skb);
 EXPORT_SYMBOL(dev_add_pack);
 EXPORT_SYMBOL(dev_remove_pack);
+EXPORT_SYMBOL(__dev_remove_pack);
 EXPORT_SYMBOL(dev_get);
 EXPORT_SYMBOL(dev_alloc);
 EXPORT_SYMBOL(dev_alloc_name);
diff -urN linux-2.5.69-bk7/net/nonet.c linux-2.5.69-bk8/net/nonet.c
--- linux-2.5.69-bk7/net/nonet.c	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/net/nonet.c	2003-05-13 04:44:30.000000000 -0700
@@ -8,6 +8,7 @@
  * Copyright (c) Matthew Wilcox 2003
  */
 
+#include <linux/module.h>
 #include <linux/errno.h>
 #include <linux/fs.h>
 #include <linux/init.h>
diff -urN linux-2.5.69-bk7/net/packet/af_packet.c linux-2.5.69-bk8/net/packet/af_packet.c
--- linux-2.5.69-bk7/net/packet/af_packet.c	2003-05-04 16:53:35.000000000 -0700
+++ linux-2.5.69-bk8/net/packet/af_packet.c	2003-05-13 04:44:30.000000000 -0700
@@ -774,6 +774,7 @@
 		 */
 		dev_remove_pack(&po->prot_hook);
 		po->running = 0;
+		po->num = 0;
 		__sock_put(sk);
 	}
 
@@ -819,9 +820,12 @@
 
 	spin_lock(&po->bind_lock);
 	if (po->running) {
-		dev_remove_pack(&po->prot_hook);
 		__sock_put(sk);
 		po->running = 0;
+		po->num = 0;
+		spin_unlock(&po->bind_lock);
+		dev_remove_pack(&po->prot_hook);
+		spin_lock(&po->bind_lock);
 	}
 
 	po->num = protocol;
@@ -1374,7 +1378,7 @@
 			if (dev->ifindex == po->ifindex) {
 				spin_lock(&po->bind_lock);
 				if (po->running) {
-					dev_remove_pack(&po->prot_hook);
+					__dev_remove_pack(&po->prot_hook);
 					__sock_put(sk);
 					po->running = 0;
 					sk->err = ENETDOWN;
@@ -1618,9 +1622,14 @@
 
 	/* Detach socket from network */
 	spin_lock(&po->bind_lock);
-	if (po->running)
-		dev_remove_pack(&po->prot_hook);
+	if (po->running) {
+		__dev_remove_pack(&po->prot_hook);
+		po->num = 0;
+		po->running = 0;
+	}
 	spin_unlock(&po->bind_lock);
+		
+	synchronize_net();
 
 	err = -EBUSY;
 	if (closing || atomic_read(&po->mapped) == 0) {
diff -urN linux-2.5.69-bk7/net/rxrpc/proc.c linux-2.5.69-bk8/net/rxrpc/proc.c
--- linux-2.5.69-bk7/net/rxrpc/proc.c	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/net/rxrpc/proc.c	2003-05-13 04:44:30.000000000 -0700
@@ -52,7 +52,6 @@
 static int rxrpc_proc_peers_show(struct seq_file *m, void *v);
 
 static struct seq_operations rxrpc_proc_peers_ops = {
-	.owner	= THIS_MODULE,
 	.start	= rxrpc_proc_peers_start,
 	.next	= rxrpc_proc_peers_next,
 	.stop	= rxrpc_proc_peers_stop,
@@ -102,6 +101,7 @@
 };
 
 static struct file_operations rxrpc_proc_calls_fops = {
+	.owner		= THIS_MODULE,
 	.open		= rxrpc_proc_calls_open,
 	.read		= seq_read,
 	.llseek		= seq_lseek,
diff -urN linux-2.5.69-bk7/net/sched/sch_ingress.c linux-2.5.69-bk8/net/sched/sch_ingress.c
--- linux-2.5.69-bk7/net/sched/sch_ingress.c	2003-05-04 16:53:36.000000000 -0700
+++ linux-2.5.69-bk8/net/sched/sch_ingress.c	2003-05-13 04:44:30.000000000 -0700
@@ -222,11 +222,6 @@
 */
 
 	if (dev->qdisc_ingress) {
-		/* FIXME: Push down to ->enqueue functions --RR */
-		if (skb_is_nonlinear(*pskb)
-		    && skb_linearize(*pskb, GFP_ATOMIC) != 0)
-			return NF_DROP;
-
 		spin_lock(&dev->queue_lock);
 		if ((q = dev->qdisc_ingress) != NULL)
 			fwres = q->enqueue(skb, q);
diff -urN linux-2.5.69-bk7/net/sctp/socket.c linux-2.5.69-bk8/net/sctp/socket.c
--- linux-2.5.69-bk7/net/sctp/socket.c	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/net/sctp/socket.c	2003-05-13 04:44:30.000000000 -0700
@@ -448,7 +448,7 @@
 	 * 							--daisy
 	 */
 
-#if CONFIG_IP_SCTP_ADDIP
+#ifdef CONFIG_IP_SCTP_ADDIP
 	/* Add these addresses to all associations on this endpoint.  */
 	if (retval >= 0) {
 		struct list_head *pos;
@@ -568,7 +568,7 @@
 	 * ADDIP code.
 	 * 							--daisy
 	 */
-#if CONFIG_IP_SCTP_ADDIP
+#ifdef CONFIG_IP_SCTP_ADDIP
 	/* Remove these addresses from all associations on this endpoint.  */
 	if (retval >= 0) {
 		struct list_head *pos;
diff -urN linux-2.5.69-bk7/net/socket.c linux-2.5.69-bk8/net/socket.c
--- linux-2.5.69-bk7/net/socket.c	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/net/socket.c	2003-05-13 04:44:30.000000000 -0700
@@ -95,9 +95,9 @@
 #include <linux/netfilter.h>
 
 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
-static ssize_t sock_aio_read(struct kiocb *iocb, char *buf,
+static ssize_t sock_aio_read(struct kiocb *iocb, char __user *buf,
 			 size_t size, loff_t pos);
-static ssize_t sock_aio_write(struct kiocb *iocb, const char *buf,
+static ssize_t sock_aio_write(struct kiocb *iocb, const char __user *buf,
 			  size_t size, loff_t pos);
 static int sock_mmap(struct file *file, struct vm_area_struct * vma);
 
@@ -218,7 +218,7 @@
  *	invalid addresses -EFAULT is returned. On a success 0 is returned.
  */
 
-int move_addr_to_kernel(void *uaddr, int ulen, void *kaddr)
+int move_addr_to_kernel(void __user *uaddr, int ulen, void *kaddr)
 {
 	if(ulen<0||ulen>MAX_SOCK_ADDR)
 		return -EINVAL;
@@ -246,7 +246,7 @@
  *	specified. Zero is returned for a success.
  */
  
-int move_addr_to_user(void *kaddr, int klen, void *uaddr, int *ulen)
+int move_addr_to_user(void *kaddr, int klen, void __user *uaddr, int __user *ulen)
 {
 	int err;
 	int len;
@@ -591,7 +591,7 @@
  *	area ubuf...ubuf+size-1 is writable before asking the protocol.
  */
 
-static ssize_t sock_aio_read(struct kiocb *iocb, char *ubuf,
+static ssize_t sock_aio_read(struct kiocb *iocb, char __user *ubuf,
 			 size_t size, loff_t pos)
 {
 	struct sock_iocb *x = kiocb_to_siocb(iocb);
@@ -624,7 +624,7 @@
  *	is readable by the user process.
  */
 
-static ssize_t sock_aio_write(struct kiocb *iocb, const char *ubuf,
+static ssize_t sock_aio_write(struct kiocb *iocb, const char __user *ubuf,
 			  size_t size, loff_t pos)
 {
 	struct sock_iocb *x = kiocb_to_siocb(iocb);
@@ -646,7 +646,7 @@
 	x->async_msg.msg_flags = !(iocb->ki_filp->f_flags & O_NONBLOCK) ? 0 : MSG_DONTWAIT;
 	if (sock->type == SOCK_SEQPACKET)
 		x->async_msg.msg_flags |= MSG_EOR;
-	x->async_iov.iov_base = (void *)ubuf;
+	x->async_iov.iov_base = (void __user *)ubuf;
 	x->async_iov.iov_len = size;
 	
 	return __sock_sendmsg(iocb, sock, &x->async_msg, size);
@@ -1124,7 +1124,7 @@
  *	Create a pair of connected sockets.
  */
 
-asmlinkage long sys_socketpair(int family, int type, int protocol, int usockvec[2])
+asmlinkage long sys_socketpair(int family, int type, int protocol, int __user *usockvec)
 {
 	struct socket *sock1, *sock2;
 	int fd1, fd2, err;
@@ -1194,7 +1194,7 @@
  *	the protocol layer (having also checked the address is ok).
  */
 
-asmlinkage long sys_bind(int fd, struct sockaddr *umyaddr, int addrlen)
+asmlinkage long sys_bind(int fd, struct sockaddr __user *umyaddr, int addrlen)
 {
 	struct socket *sock;
 	char address[MAX_SOCK_ADDR];
@@ -1256,7 +1256,7 @@
  *	clean when we restucture accept also.
  */
 
-asmlinkage long sys_accept(int fd, struct sockaddr *upeer_sockaddr, int *upeer_addrlen)
+asmlinkage long sys_accept(int fd, struct sockaddr __user *upeer_sockaddr, int __user *upeer_addrlen)
 {
 	struct socket *sock, *newsock;
 	int err, len;
@@ -1326,7 +1326,7 @@
  *	include the -EINPROGRESS status for such sockets.
  */
 
-asmlinkage long sys_connect(int fd, struct sockaddr *uservaddr, int addrlen)
+asmlinkage long sys_connect(int fd, struct sockaddr __user *uservaddr, int addrlen)
 {
 	struct socket *sock;
 	char address[MAX_SOCK_ADDR];
@@ -1356,7 +1356,7 @@
  *	name to user space.
  */
 
-asmlinkage long sys_getsockname(int fd, struct sockaddr *usockaddr, int *usockaddr_len)
+asmlinkage long sys_getsockname(int fd, struct sockaddr __user *usockaddr, int __user *usockaddr_len)
 {
 	struct socket *sock;
 	char address[MAX_SOCK_ADDR];
@@ -1386,7 +1386,7 @@
  *	name to user space.
  */
 
-asmlinkage long sys_getpeername(int fd, struct sockaddr *usockaddr, int *usockaddr_len)
+asmlinkage long sys_getpeername(int fd, struct sockaddr __user *usockaddr, int __user *usockaddr_len)
 {
 	struct socket *sock;
 	char address[MAX_SOCK_ADDR];
@@ -1414,8 +1414,8 @@
  *	the protocol.
  */
 
-asmlinkage long sys_sendto(int fd, void * buff, size_t len, unsigned flags,
-			   struct sockaddr *addr, int addr_len)
+asmlinkage long sys_sendto(int fd, void __user * buff, size_t len, unsigned flags,
+			   struct sockaddr __user *addr, int addr_len)
 {
 	struct socket *sock;
 	char address[MAX_SOCK_ADDR];
@@ -1457,7 +1457,7 @@
  *	Send a datagram down a socket. 
  */
 
-asmlinkage long sys_send(int fd, void * buff, size_t len, unsigned flags)
+asmlinkage long sys_send(int fd, void __user * buff, size_t len, unsigned flags)
 {
 	return sys_sendto(fd, buff, len, flags, NULL, 0);
 }
@@ -1468,8 +1468,8 @@
  *	sender address from kernel to user space.
  */
 
-asmlinkage long sys_recvfrom(int fd, void * ubuf, size_t size, unsigned flags,
-			     struct sockaddr *addr, int *addr_len)
+asmlinkage long sys_recvfrom(int fd, void __user * ubuf, size_t size, unsigned flags,
+			     struct sockaddr __user *addr, int __user *addr_len)
 {
 	struct socket *sock;
 	struct iovec iov;
@@ -1508,7 +1508,7 @@
  *	Receive a datagram from a socket. 
  */
 
-asmlinkage long sys_recv(int fd, void * ubuf, size_t size, unsigned flags)
+asmlinkage long sys_recv(int fd, void __user * ubuf, size_t size, unsigned flags)
 {
 	return sys_recvfrom(fd, ubuf, size, flags, NULL, NULL);
 }
@@ -1518,7 +1518,7 @@
  *	to pass the user mode parameter for the protocols to sort out.
  */
 
-asmlinkage long sys_setsockopt(int fd, int level, int optname, char *optval, int optlen)
+asmlinkage long sys_setsockopt(int fd, int level, int optname, char __user *optval, int optlen)
 {
 	int err;
 	struct socket *sock;
@@ -1548,7 +1548,7 @@
  *	to pass a user mode parameter for the protocols to sort out.
  */
 
-asmlinkage long sys_getsockopt(int fd, int level, int optname, char *optval, int *optlen)
+asmlinkage long sys_getsockopt(int fd, int level, int optname, char __user *optval, int __user *optlen)
 {
 	int err;
 	struct socket *sock;
@@ -1607,9 +1607,9 @@
  *	BSD sendmsg interface
  */
 
-asmlinkage long sys_sendmsg(int fd, struct msghdr *msg, unsigned flags)
+asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags)
 {
-	struct compat_msghdr *msg_compat = (struct compat_msghdr *)msg;
+	struct compat_msghdr __user *msg_compat = (struct compat_msghdr __user *)msg;
 	struct socket *sock;
 	char address[MAX_SOCK_ADDR];
 	struct iovec iovstack[UIO_FASTIOV], *iov = iovstack;
@@ -1670,7 +1670,12 @@
 				goto out_freeiov;
 		}
 		err = -EFAULT;
-		if (copy_from_user(ctl_buf, msg_sys.msg_control, ctl_len))
+		/*
+		 * Careful! Before this, msg_sys.msg_control contains a user pointer.
+		 * Afterwards, it will be a kernel pointer. Thus the compiler-assisted
+		 * checking falls down on this.
+		 */
+		if (copy_from_user(ctl_buf, (void __user *) msg_sys.msg_control, ctl_len))
 			goto out_freectl;
 		msg_sys.msg_control = ctl_buf;
 	}
@@ -1696,9 +1701,9 @@
  *	BSD recvmsg interface
  */
 
-asmlinkage long sys_recvmsg(int fd, struct msghdr *msg, unsigned int flags)
+asmlinkage long sys_recvmsg(int fd, struct msghdr __user *msg, unsigned int flags)
 {
-	struct compat_msghdr *msg_compat = (struct compat_msghdr *)msg;
+	struct compat_msghdr __user *msg_compat = (struct compat_msghdr __user *)msg;
 	struct socket *sock;
 	struct iovec iovstack[UIO_FASTIOV];
 	struct iovec *iov=iovstack;
@@ -1710,8 +1715,8 @@
 	char addr[MAX_SOCK_ADDR];
 
 	/* user mode address pointers */
-	struct sockaddr *uaddr;
-	int *uaddr_len;
+	struct sockaddr __user *uaddr;
+	int __user *uaddr_len;
 	
 	if (MSG_CMSG_COMPAT & flags) {
 		if (get_compat_msghdr(&msg_sys, msg_compat))
@@ -1742,7 +1747,7 @@
 	 *	kernel msghdr to use the kernel address space)
 	 */
 	 
-	uaddr = msg_sys.msg_name;
+	uaddr = (void __user *) msg_sys.msg_name;
 	uaddr_len = COMPAT_NAMELEN(msg);
 	if (MSG_CMSG_COMPAT & flags) {
 		err = verify_compat_iovec(&msg_sys, iov, addr, VERIFY_WRITE);
@@ -1806,7 +1811,7 @@
  *  it is set by the callees. 
  */
 
-asmlinkage long sys_socketcall(int call, unsigned long *args)
+asmlinkage long sys_socketcall(int call, unsigned long __user *args)
 {
 	unsigned long a[6];
 	unsigned long a0,a1;
@@ -1828,54 +1833,54 @@
 			err = sys_socket(a0,a1,a[2]);
 			break;
 		case SYS_BIND:
-			err = sys_bind(a0,(struct sockaddr *)a1, a[2]);
+			err = sys_bind(a0,(struct sockaddr __user *)a1, a[2]);
 			break;
 		case SYS_CONNECT:
-			err = sys_connect(a0, (struct sockaddr *)a1, a[2]);
+			err = sys_connect(a0, (struct sockaddr __user *)a1, a[2]);
 			break;
 		case SYS_LISTEN:
 			err = sys_listen(a0,a1);
 			break;
 		case SYS_ACCEPT:
-			err = sys_accept(a0,(struct sockaddr *)a1, (int *)a[2]);
+			err = sys_accept(a0,(struct sockaddr __user *)a1, (int __user *)a[2]);
 			break;
 		case SYS_GETSOCKNAME:
-			err = sys_getsockname(a0,(struct sockaddr *)a1, (int *)a[2]);
+			err = sys_getsockname(a0,(struct sockaddr __user *)a1, (int __user *)a[2]);
 			break;
 		case SYS_GETPEERNAME:
-			err = sys_getpeername(a0, (struct sockaddr *)a1, (int *)a[2]);
+			err = sys_getpeername(a0, (struct sockaddr __user *)a1, (int __user *)a[2]);
 			break;
 		case SYS_SOCKETPAIR:
-			err = sys_socketpair(a0,a1, a[2], (int *)a[3]);
+			err = sys_socketpair(a0,a1, a[2], (int __user *)a[3]);
 			break;
 		case SYS_SEND:
-			err = sys_send(a0, (void *)a1, a[2], a[3]);
+			err = sys_send(a0, (void __user *)a1, a[2], a[3]);
 			break;
 		case SYS_SENDTO:
-			err = sys_sendto(a0,(void *)a1, a[2], a[3],
-					 (struct sockaddr *)a[4], a[5]);
+			err = sys_sendto(a0,(void __user *)a1, a[2], a[3],
+					 (struct sockaddr __user *)a[4], a[5]);
 			break;
 		case SYS_RECV:
-			err = sys_recv(a0, (void *)a1, a[2], a[3]);
+			err = sys_recv(a0, (void __user *)a1, a[2], a[3]);
 			break;
 		case SYS_RECVFROM:
-			err = sys_recvfrom(a0, (void *)a1, a[2], a[3],
-					   (struct sockaddr *)a[4], (int *)a[5]);
+			err = sys_recvfrom(a0, (void __user *)a1, a[2], a[3],
+					   (struct sockaddr __user *)a[4], (int __user *)a[5]);
 			break;
 		case SYS_SHUTDOWN:
 			err = sys_shutdown(a0,a1);
 			break;
 		case SYS_SETSOCKOPT:
-			err = sys_setsockopt(a0, a1, a[2], (char *)a[3], a[4]);
+			err = sys_setsockopt(a0, a1, a[2], (char __user *)a[3], a[4]);
 			break;
 		case SYS_GETSOCKOPT:
-			err = sys_getsockopt(a0, a1, a[2], (char *)a[3], (int *)a[4]);
+			err = sys_getsockopt(a0, a1, a[2], (char __user *)a[3], (int __user *)a[4]);
 			break;
 		case SYS_SENDMSG:
-			err = sys_sendmsg(a0, (struct msghdr *) a1, a[2]);
+			err = sys_sendmsg(a0, (struct msghdr __user *) a1, a[2]);
 			break;
 		case SYS_RECVMSG:
-			err = sys_recvmsg(a0, (struct msghdr *) a1, a[2]);
+			err = sys_recvmsg(a0, (struct msghdr __user *) a1, a[2]);
 			break;
 		default:
 			err = -EINVAL;
diff -urN linux-2.5.69-bk7/net/wanrouter/wanproc.c linux-2.5.69-bk8/net/wanrouter/wanproc.c
--- linux-2.5.69-bk7/net/wanrouter/wanproc.c	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/net/wanrouter/wanproc.c	2003-05-13 04:44:31.000000000 -0700
@@ -25,6 +25,7 @@
 #include <linux/stddef.h>	/* offsetof(), etc. */
 #include <linux/errno.h>	/* return codes */
 #include <linux/kernel.h>
+#include <linux/module.h>
 #include <linux/slab.h>	/* kmalloc(), kfree() */
 #include <linux/mm.h>		/* verify_area(), etc. */
 #include <linux/string.h>	/* inline mem*, str* functions */
diff -urN linux-2.5.69-bk7/net/xfrm/xfrm_state.c linux-2.5.69-bk8/net/xfrm/xfrm_state.c
--- linux-2.5.69-bk7/net/xfrm/xfrm_state.c	2003-05-13 04:44:24.000000000 -0700
+++ linux-2.5.69-bk8/net/xfrm/xfrm_state.c	2003-05-13 04:44:31.000000000 -0700
@@ -172,6 +172,7 @@
 	if (x) {
 		memset(x, 0, sizeof(struct xfrm_state));
 		atomic_set(&x->refcnt, 1);
+		atomic_set(&x->tunnel_users, 0);
 		INIT_LIST_HEAD(&x->bydst);
 		INIT_LIST_HEAD(&x->byspi);
 		init_timer(&x->timer);
@@ -234,6 +235,7 @@
 
 void xfrm_state_delete(struct xfrm_state *x)
 {
+	xfrm_state_delete_tunnel(x);
 	spin_lock_bh(&x->lock);
 	__xfrm_state_delete(x);
 	spin_unlock_bh(&x->lock);
@@ -248,7 +250,8 @@
 	for (i = 0; i < XFRM_DST_HSIZE; i++) {
 restart:
 		list_for_each_entry(x, xfrm_state_bydst+i, bydst) {
-			if (proto == IPSEC_PROTO_ANY || x->id.proto == proto) {
+			if (!xfrm_state_kern(x) &&
+			    (proto == IPSEC_PROTO_ANY || x->id.proto == proto)) {
 				xfrm_state_hold(x);
 				spin_unlock_bh(&xfrm_state_lock);
 
@@ -790,6 +793,20 @@
 	read_unlock(&afinfo->lock);
 }
 
+/* Temporarily located here until net/xfrm/xfrm_tunnel.c is created */
+void xfrm_state_delete_tunnel(struct xfrm_state *x)
+{
+	if (x->tunnel) {
+		struct xfrm_state *t = x->tunnel;
+
+		if (atomic_read(&t->tunnel_users) == 2)
+			xfrm_state_delete(t);
+		atomic_dec(&t->tunnel_users);
+		xfrm_state_put(t);
+		x->tunnel = NULL;
+	}
+}
+
 void __init xfrm_state_init(void)
 {
 	int i;
diff -urN linux-2.5.69-bk7/net/xfrm/xfrm_user.c linux-2.5.69-bk8/net/xfrm/xfrm_user.c
--- linux-2.5.69-bk7/net/xfrm/xfrm_user.c	2003-05-04 16:53:32.000000000 -0700
+++ linux-2.5.69-bk8/net/xfrm/xfrm_user.c	2003-05-13 04:44:31.000000000 -0700
@@ -281,6 +281,11 @@
 	if (x == NULL)
 		return -ESRCH;
 
+	if (xfrm_state_kern(x)) {
+		xfrm_state_put(x);
+		return -EPERM;
+	}
+
 	xfrm_state_delete(x);
 	xfrm_state_put(x);
 
