Merge master.kernel.org:/pub/scm/linux/kernel/git/mchehab/v4l-dvb
diff --git a/Documentation/filesystems/ext3.txt b/Documentation/filesystems/ext3.txt
index f4d0de6..afb1335 100644
--- a/Documentation/filesystems/ext3.txt
+++ b/Documentation/filesystems/ext3.txt
@@ -84,8 +84,6 @@
 
 noreservation
 
-resize=
-
 bsddf 		(*)	Make 'df' act like BSD.
 minixdf			Make 'df' act like Minix.
 
@@ -175,6 +173,7 @@
 tune2fs: 	create a ext3 journal on a ext2 partition with the -j flag.
 mke2fs: 	create a ext3 partition with the -j flag.
 debugfs: 	ext2 and ext3 file system debugger.
+ext2online:	online (mounted) ext2 and ext3 filesystem resizer
 
 
 References
@@ -184,6 +183,7 @@
 		<file:fs/jbd/>
 
 programs: 	http://e2fsprogs.sourceforge.net/
+		http://ext2resize.sourceforge.net
 
 useful links:	http://www.zip.com.au/~akpm/linux/ext3/ext3-usage.html
 		http://www-106.ibm.com/developerworks/linux/library/l-fs7/
diff --git a/Documentation/kdump/gdbmacros.txt b/Documentation/kdump/gdbmacros.txt
index bc1b9eb..dcf5580 100644
--- a/Documentation/kdump/gdbmacros.txt
+++ b/Documentation/kdump/gdbmacros.txt
@@ -177,3 +177,25 @@
 	'trapinfo <pid>' will tell you by which trap & possibly
 	addresthe kernel paniced.
 end
+
+
+define dmesg
+	set $i = 0
+	set $end_idx = (log_end - 1) & (log_buf_len - 1)
+
+	while ($i < logged_chars)
+		set $idx = (log_end - 1 - logged_chars + $i) & (log_buf_len - 1)
+
+		if ($idx + 100 <= $end_idx) || \
+		   ($end_idx <= $idx && $idx + 100 < log_buf_len)
+			printf "%.100s", &log_buf[$idx]
+			set $i = $i + 100
+		else
+			printf "%c", log_buf[$idx]
+			set $i = $i + 1
+		end
+	end
+end
+document dmesg
+	print the kernel ring buffer
+end
diff --git a/Documentation/oops-tracing.txt b/Documentation/oops-tracing.txt
index 05960f8..2503404 100644
--- a/Documentation/oops-tracing.txt
+++ b/Documentation/oops-tracing.txt
@@ -41,11 +41,9 @@
     run a null modem to a second machine and capture the output there
     using your favourite communication program.  Minicom works well.
 
-(3) Patch the kernel with one of the crash dump patches.  These save
-    data to a floppy disk or video rom or a swap partition.  None of
-    these are standard kernel patches so you have to find and apply
-    them yourself.  Search kernel archives for kmsgdump, lkcd and
-    oops+smram.
+(3) Use Kdump (see Documentation/kdump/kdump.txt),
+    extract the kernel ring buffer from old memory with using dmesg
+    gdbmacro in Documentation/kdump/gdbmacros.txt.
 
 
 Full Information
diff --git a/Documentation/x86_64/boot-options.txt b/Documentation/x86_64/boot-options.txt
index e566aff..72ab9b9 100644
--- a/Documentation/x86_64/boot-options.txt
+++ b/Documentation/x86_64/boot-options.txt
@@ -125,7 +125,7 @@
   cpumask=MASK   only use cpus with bits set in mask
 
   additional_cpus=NUM Allow NUM more CPUs for hotplug
-		 (defaults are specified by the BIOS or half the available CPUs)
+		 (defaults are specified by the BIOS, see Documentation/x86_64/cpu-hotplug-spec)
 
 NUMA
 
diff --git a/Documentation/x86_64/cpu-hotplug-spec b/Documentation/x86_64/cpu-hotplug-spec
new file mode 100644
index 0000000..5c0fa34
--- /dev/null
+++ b/Documentation/x86_64/cpu-hotplug-spec
@@ -0,0 +1,21 @@
+Firmware support for CPU hotplug under Linux/x86-64
+---------------------------------------------------
+
+Linux/x86-64 supports CPU hotplug now. For various reasons Linux wants to
+know in advance boot time the maximum number of CPUs that could be plugged
+into the system. ACPI 3.0 currently has no official way to supply
+this information from the firmware to the operating system.
+
+In ACPI each CPU needs an LAPIC object in the MADT table (5.2.11.5 in the
+ACPI 3.0 specification).  ACPI already has the concept of disabled LAPIC
+objects by setting the Enabled bit in the LAPIC object to zero.
+
+For CPU hotplug Linux/x86-64 expects now that any possible future hotpluggable
+CPU is already available in the MADT. If the CPU is not available yet
+it should have its LAPIC Enabled bit set to 0. Linux will use the number
+of disabled LAPICs to compute the maximum number of future CPUs.
+
+In the worst case the user can overwrite this choice using a command line
+option (additional_cpus=...), but it is recommended to supply the correct
+number (or a reasonable approximation of it, with erring towards more not less)
+in the MADT to avoid manual configuration.
diff --git a/MAINTAINERS b/MAINTAINERS
index b6416a2..0db72a3 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2359,13 +2359,6 @@
 M:	nico@cam.org
 S:	Maintained
 
-SNA NETWORK LAYER
-P:	Jay Schulist
-M:	jschlst@samba.org
-L:	linux-sna@turbolinux.com
-W:	http://www.linux-sna.org
-S:	Supported
-
 SOFTWARE RAID (Multiple Disks) SUPPORT
 P:	Ingo Molnar
 M:	mingo@redhat.com
diff --git a/arch/alpha/kernel/pci-noop.c b/arch/alpha/kernel/pci-noop.c
index 9903e3a..fff5cf9 100644
--- a/arch/alpha/kernel/pci-noop.c
+++ b/arch/alpha/kernel/pci-noop.c
@@ -7,6 +7,7 @@
 #include <linux/pci.h>
 #include <linux/init.h>
 #include <linux/bootmem.h>
+#include <linux/capability.h>
 #include <linux/mm.h>
 #include <linux/errno.h>
 #include <linux/sched.h>
diff --git a/arch/arm/common/rtctime.c b/arch/arm/common/rtctime.c
index 72b03f2..ffb82d5 100644
--- a/arch/arm/common/rtctime.c
+++ b/arch/arm/common/rtctime.c
@@ -17,6 +17,7 @@
 #include <linux/proc_fs.h>
 #include <linux/miscdevice.h>
 #include <linux/spinlock.h>
+#include <linux/capability.h>
 #include <linux/device.h>
 
 #include <asm/rtc.h>
diff --git a/arch/arm/kernel/apm.c b/arch/arm/kernel/apm.c
index b9df1b7..766b6c0 100644
--- a/arch/arm/kernel/apm.c
+++ b/arch/arm/kernel/apm.c
@@ -18,6 +18,7 @@
 #include <linux/proc_fs.h>
 #include <linux/miscdevice.h>
 #include <linux/apm_bios.h>
+#include <linux/capability.h>
 #include <linux/sched.h>
 #include <linux/pm.h>
 #include <linux/device.h>
diff --git a/arch/cris/arch-v10/drivers/ds1302.c b/arch/cris/arch-v10/drivers/ds1302.c
index 10795f6..b100f26 100644
--- a/arch/cris/arch-v10/drivers/ds1302.c
+++ b/arch/cris/arch-v10/drivers/ds1302.c
@@ -148,6 +148,7 @@
 #include <linux/miscdevice.h>
 #include <linux/delay.h>
 #include <linux/bcd.h>
+#include <linux/capability.h>
 
 #include <asm/uaccess.h>
 #include <asm/system.h>
diff --git a/arch/cris/arch-v10/drivers/pcf8563.c b/arch/cris/arch-v10/drivers/pcf8563.c
index f2c5574..af517c2 100644
--- a/arch/cris/arch-v10/drivers/pcf8563.c
+++ b/arch/cris/arch-v10/drivers/pcf8563.c
@@ -28,6 +28,7 @@
 #include <linux/ioctl.h>
 #include <linux/delay.h>
 #include <linux/bcd.h>
+#include <linux/capability.h>
 
 #include <asm/uaccess.h>
 #include <asm/system.h>
diff --git a/arch/i386/Kconfig b/arch/i386/Kconfig
index 815878e..d5d0df7 100644
--- a/arch/i386/Kconfig
+++ b/arch/i386/Kconfig
@@ -41,8 +41,21 @@
 	bool
 	default y
 
+config DMI
+	bool
+	default y
+
 source "init/Kconfig"
 
+config DOUBLEFAULT
+	default y
+	bool "Enable doublefault exception handler" if EMBEDDED
+	help
+          This option allows trapping of rare doublefault exceptions that
+          would otherwise cause a system to silently reboot. Disabling this
+          option saves about 4k and might cause you much additional grey
+          hair.
+
 menu "Processor type and features"
 
 choice
diff --git a/arch/i386/kernel/acpi/boot.c b/arch/i386/kernel/acpi/boot.c
index 447fa9e..2111529 100644
--- a/arch/i386/kernel/acpi/boot.c
+++ b/arch/i386/kernel/acpi/boot.c
@@ -108,7 +108,7 @@
 	if (!phys_addr || !size)
 		return NULL;
 
-	if (phys_addr < (end_pfn_map << PAGE_SHIFT))
+	if (phys_addr+size <= (end_pfn_map << PAGE_SHIFT) + PAGE_SIZE)
 		return __va(phys_addr);
 
 	return NULL;
diff --git a/arch/i386/kernel/apic.c b/arch/i386/kernel/apic.c
index d8f94e7..acd3f1e 100644
--- a/arch/i386/kernel/apic.c
+++ b/arch/i386/kernel/apic.c
@@ -26,6 +26,7 @@
 #include <linux/kernel_stat.h>
 #include <linux/sysdev.h>
 #include <linux/cpu.h>
+#include <linux/module.h>
 
 #include <asm/atomic.h>
 #include <asm/smp.h>
@@ -37,10 +38,17 @@
 #include <asm/i8253.h>
 
 #include <mach_apic.h>
+#include <mach_ipi.h>
 
 #include "io_ports.h"
 
 /*
+ * cpu_mask that denotes the CPUs that needs timer interrupt coming in as
+ * IPIs in place of local APIC timers
+ */
+static cpumask_t timer_bcast_ipi;
+
+/*
  * Knob to control our willingness to enable the local APIC.
  */
 int enable_local_apic __initdata = 0; /* -1=force-disable, +1=force-enable */
@@ -92,10 +100,6 @@
 /* Using APIC to generate smp_local_timer_interrupt? */
 int using_apic_timer = 0;
 
-static DEFINE_PER_CPU(int, prof_multiplier) = 1;
-static DEFINE_PER_CPU(int, prof_old_multiplier) = 1;
-static DEFINE_PER_CPU(int, prof_counter) = 1;
-
 static int enabled_via_apicbase;
 
 void enable_NMI_through_LVT0 (void * dummy)
@@ -935,11 +939,16 @@
 static void __setup_APIC_LVTT(unsigned int clocks)
 {
 	unsigned int lvtt_value, tmp_value, ver;
+	int cpu = smp_processor_id();
 
 	ver = GET_APIC_VERSION(apic_read(APIC_LVR));
 	lvtt_value = APIC_LVT_TIMER_PERIODIC | LOCAL_TIMER_VECTOR;
 	if (!APIC_INTEGRATED(ver))
 		lvtt_value |= SET_APIC_TIMER_BASE(APIC_TIMER_BASE_DIV);
+
+	if (cpu_isset(cpu, timer_bcast_ipi))
+		lvtt_value |= APIC_LVT_MASKED;
+
 	apic_write_around(APIC_LVTT, lvtt_value);
 
 	/*
@@ -1072,7 +1081,7 @@
 	setup_APIC_timer(calibration_result);
 }
 
-void __devinit disable_APIC_timer(void)
+void disable_APIC_timer(void)
 {
 	if (using_apic_timer) {
 		unsigned long v;
@@ -1084,7 +1093,10 @@
 
 void enable_APIC_timer(void)
 {
-	if (using_apic_timer) {
+	int cpu = smp_processor_id();
+
+	if (using_apic_timer &&
+	    !cpu_isset(cpu, timer_bcast_ipi)) {
 		unsigned long v;
 
 		v = apic_read(APIC_LVTT);
@@ -1092,33 +1104,31 @@
 	}
 }
 
-/*
- * the frequency of the profiling timer can be changed
- * by writing a multiplier value into /proc/profile.
- */
-int setup_profiling_timer(unsigned int multiplier)
+void switch_APIC_timer_to_ipi(void *cpumask)
 {
-	int i;
+	cpumask_t mask = *(cpumask_t *)cpumask;
+	int cpu = smp_processor_id();
 
-	/*
-	 * Sanity check. [at least 500 APIC cycles should be
-	 * between APIC interrupts as a rule of thumb, to avoid
-	 * irqs flooding us]
-	 */
-	if ( (!multiplier) || (calibration_result/multiplier < 500))
-		return -EINVAL;
-
-	/* 
-	 * Set the new multiplier for each CPU. CPUs don't start using the
-	 * new values until the next timer interrupt in which they do process
-	 * accounting. At that time they also adjust their APIC timers
-	 * accordingly.
-	 */
-	for (i = 0; i < NR_CPUS; ++i)
-		per_cpu(prof_multiplier, i) = multiplier;
-
-	return 0;
+	if (cpu_isset(cpu, mask) &&
+	    !cpu_isset(cpu, timer_bcast_ipi)) {
+		disable_APIC_timer();
+		cpu_set(cpu, timer_bcast_ipi);
+	}
 }
+EXPORT_SYMBOL(switch_APIC_timer_to_ipi);
+
+void switch_ipi_to_APIC_timer(void *cpumask)
+{
+	cpumask_t mask = *(cpumask_t *)cpumask;
+	int cpu = smp_processor_id();
+
+	if (cpu_isset(cpu, mask) &&
+	    cpu_isset(cpu, timer_bcast_ipi)) {
+		cpu_clear(cpu, timer_bcast_ipi);
+		enable_APIC_timer();
+	}
+}
+EXPORT_SYMBOL(switch_ipi_to_APIC_timer);
 
 #undef APIC_DIVISOR
 
@@ -1134,32 +1144,10 @@
 
 inline void smp_local_timer_interrupt(struct pt_regs * regs)
 {
-	int cpu = smp_processor_id();
-
 	profile_tick(CPU_PROFILING, regs);
-	if (--per_cpu(prof_counter, cpu) <= 0) {
-		/*
-		 * The multiplier may have changed since the last time we got
-		 * to this point as a result of the user writing to
-		 * /proc/profile. In this case we need to adjust the APIC
-		 * timer accordingly.
-		 *
-		 * Interrupts are already masked off at this point.
-		 */
-		per_cpu(prof_counter, cpu) = per_cpu(prof_multiplier, cpu);
-		if (per_cpu(prof_counter, cpu) !=
-					per_cpu(prof_old_multiplier, cpu)) {
-			__setup_APIC_LVTT(
-					calibration_result/
-					per_cpu(prof_counter, cpu));
-			per_cpu(prof_old_multiplier, cpu) =
-						per_cpu(prof_counter, cpu);
-		}
-
 #ifdef CONFIG_SMP
-		update_process_times(user_mode_vm(regs));
+	update_process_times(user_mode_vm(regs));
 #endif
-	}
 
 	/*
 	 * We take the 'long' return path, and there every subsystem
@@ -1206,6 +1194,43 @@
 	irq_exit();
 }
 
+#ifndef CONFIG_SMP
+static void up_apic_timer_interrupt_call(struct pt_regs *regs)
+{
+	int cpu = smp_processor_id();
+
+	/*
+	 * the NMI deadlock-detector uses this.
+	 */
+	per_cpu(irq_stat, cpu).apic_timer_irqs++;
+
+	smp_local_timer_interrupt(regs);
+}
+#endif
+
+void smp_send_timer_broadcast_ipi(struct pt_regs *regs)
+{
+	cpumask_t mask;
+
+	cpus_and(mask, cpu_online_map, timer_bcast_ipi);
+	if (!cpus_empty(mask)) {
+#ifdef CONFIG_SMP
+		send_IPI_mask(mask, LOCAL_TIMER_VECTOR);
+#else
+		/*
+		 * We can directly call the apic timer interrupt handler
+		 * in UP case. Minus all irq related functions
+		 */
+		up_apic_timer_interrupt_call(regs);
+#endif
+	}
+}
+
+int setup_profiling_timer(unsigned int multiplier)
+{
+	return -EINVAL;
+}
+
 /*
  * This interrupt should _never_ happen with our APIC/SMP architecture
  */
diff --git a/arch/i386/kernel/apm.c b/arch/i386/kernel/apm.c
index 9d88271..05312a8 100644
--- a/arch/i386/kernel/apm.c
+++ b/arch/i386/kernel/apm.c
@@ -219,6 +219,7 @@
 #include <linux/sched.h>
 #include <linux/pm.h>
 #include <linux/pm_legacy.h>
+#include <linux/capability.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/smp.h>
diff --git a/arch/i386/kernel/cpu/amd.c b/arch/i386/kernel/cpu/amd.c
index e7697e0..333578a 100644
--- a/arch/i386/kernel/cpu/amd.c
+++ b/arch/i386/kernel/cpu/amd.c
@@ -216,6 +216,12 @@
 			c->x86_max_cores = 1;
 	}
 
+	if (cpuid_eax(0x80000000) >= 0x80000007) {
+		c->x86_power = cpuid_edx(0x80000007);
+		if (c->x86_power & (1<<8))
+			set_bit(X86_FEATURE_CONSTANT_TSC, c->x86_capability);
+	}
+
 #ifdef CONFIG_X86_HT
 	/*
 	 * On a AMD dual core setup the lower bits of the APIC id
@@ -233,6 +239,7 @@
 		       cpu, c->x86_max_cores, cpu_core_id[cpu]);
 	}
 #endif
+
 }
 
 static unsigned int amd_size_cache(struct cpuinfo_x86 * c, unsigned int size)
diff --git a/arch/i386/kernel/cpu/common.c b/arch/i386/kernel/cpu/common.c
index 1704008..15aee26 100644
--- a/arch/i386/kernel/cpu/common.c
+++ b/arch/i386/kernel/cpu/common.c
@@ -204,7 +204,10 @@
 
 /* Do minimum CPU detection early.
    Fields really needed: vendor, cpuid_level, family, model, mask, cache alignment.
-   The others are not touched to avoid unwanted side effects. */
+   The others are not touched to avoid unwanted side effects.
+
+   WARNING: this function is only called on the BP.  Don't add code here
+   that is supposed to run on all CPUs. */
 static void __init early_cpu_detect(void)
 {
 	struct cpuinfo_x86 *c = &boot_cpu_data;
@@ -236,12 +239,6 @@
 		if (cap0 & (1<<19))
 			c->x86_cache_alignment = ((misc >> 8) & 0xff) * 8;
 	}
-
-	early_intel_workaround(c);
-
-#ifdef CONFIG_X86_HT
-	phys_proc_id[smp_processor_id()] = (cpuid_ebx(1) >> 24) & 0xff;
-#endif
 }
 
 void __devinit generic_identify(struct cpuinfo_x86 * c)
@@ -289,6 +286,12 @@
 				get_model_name(c); /* Default name */
 		}
 	}
+
+	early_intel_workaround(c);
+
+#ifdef CONFIG_X86_HT
+	phys_proc_id[smp_processor_id()] = (cpuid_ebx(1) >> 24) & 0xff;
+#endif
 }
 
 static void __devinit squash_the_stupid_serial_number(struct cpuinfo_x86 *c)
diff --git a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
index 871366b..7975e79 100644
--- a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
+++ b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
@@ -40,8 +40,6 @@
 #include <linux/acpi.h>
 #include <acpi/processor.h>
 
-#include "speedstep-est-common.h"
-
 #define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "acpi-cpufreq", msg)
 
 MODULE_AUTHOR("Paul Diefenbaugh, Dominik Brodowski");
@@ -367,6 +365,7 @@
 	unsigned int		cpu = policy->cpu;
 	struct cpufreq_acpi_io	*data;
 	unsigned int		result = 0;
+	struct cpuinfo_x86 *c = &cpu_data[policy->cpu];
 
 	union acpi_object		arg0 = {ACPI_TYPE_BUFFER};
 	u32				arg0_buf[3];
@@ -390,7 +389,7 @@
 	if (result)
 		goto err_free;
 
-	if (is_const_loops_cpu(cpu)) {
+	if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
 		acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
 	}
 
diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c b/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
index edb9873..9a826cd 100644
--- a/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
+++ b/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
@@ -35,8 +35,6 @@
 #include <asm/processor.h>
 #include <asm/cpufeature.h>
 
-#include "speedstep-est-common.h"
-
 #define PFX		"speedstep-centrino: "
 #define MAINTAINER	"Jeremy Fitzhardinge <jeremy@goop.org>"
 
@@ -493,12 +491,13 @@
 	unsigned l, h;
 	int ret;
 	int i;
+	struct cpuinfo_x86 *c = &cpu_data[policy->cpu];
 
 	/* Only Intel makes Enhanced Speedstep-capable CPUs */
 	if (cpu->x86_vendor != X86_VENDOR_INTEL || !cpu_has(cpu, X86_FEATURE_EST))
 		return -ENODEV;
 
-	if (is_const_loops_cpu(policy->cpu)) {
+	if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
 		centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
 	}
 
diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep-est-common.h b/arch/i386/kernel/cpu/cpufreq/speedstep-est-common.h
deleted file mode 100644
index 5ce995c..0000000
--- a/arch/i386/kernel/cpu/cpufreq/speedstep-est-common.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Routines common for drivers handling Enhanced Speedstep Technology
- *  Copyright (C) 2004 Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
- *
- *  Licensed under the terms of the GNU GPL License version 2 -- see
- *  COPYING for details.
- */
-
-static inline int is_const_loops_cpu(unsigned int cpu)
-{
-	struct cpuinfo_x86 	*c = cpu_data + cpu;
-
-	if (c->x86_vendor != X86_VENDOR_INTEL || !cpu_has(c, X86_FEATURE_EST))
-		return 0;
-
-	/*
-	 * on P-4s, the TSC runs with constant frequency independent of cpu freq
-	 * when we use EST
-	 */
-	if (c->x86 == 0xf)
-		return 1;
-
-	return 0;
-}
-
diff --git a/arch/i386/kernel/cpu/intel.c b/arch/i386/kernel/cpu/intel.c
index 5e2da70..8c01201 100644
--- a/arch/i386/kernel/cpu/intel.c
+++ b/arch/i386/kernel/cpu/intel.c
@@ -183,10 +183,13 @@
 	}
 #endif
 
-	if (c->x86 == 15) 
+	if (c->x86 == 15)
 		set_bit(X86_FEATURE_P4, c->x86_capability);
 	if (c->x86 == 6) 
 		set_bit(X86_FEATURE_P3, c->x86_capability);
+	if ((c->x86 == 0xf && c->x86_model >= 0x03) ||
+		(c->x86 == 0x6 && c->x86_model >= 0x0e))
+		set_bit(X86_FEATURE_CONSTANT_TSC, c->x86_capability);
 }
 
 
diff --git a/arch/i386/kernel/cpu/mtrr/if.c b/arch/i386/kernel/cpu/mtrr/if.c
index cf39e20..5ac051b 100644
--- a/arch/i386/kernel/cpu/mtrr/if.c
+++ b/arch/i386/kernel/cpu/mtrr/if.c
@@ -1,5 +1,6 @@
 #include <linux/init.h>
 #include <linux/proc_fs.h>
+#include <linux/capability.h>
 #include <linux/ctype.h>
 #include <linux/module.h>
 #include <linux/seq_file.h>
diff --git a/arch/i386/kernel/cpu/proc.c b/arch/i386/kernel/cpu/proc.c
index 6d91b27..89a85af 100644
--- a/arch/i386/kernel/cpu/proc.c
+++ b/arch/i386/kernel/cpu/proc.c
@@ -29,7 +29,7 @@
 		NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 		NULL, NULL, NULL, "syscall", NULL, NULL, NULL, NULL,
 		NULL, NULL, NULL, "mp", "nx", NULL, "mmxext", NULL,
-		NULL, "fxsr_opt", NULL, NULL, NULL, "lm", "3dnowext", "3dnow",
+		NULL, "fxsr_opt", "rdtscp", NULL, NULL, "lm", "3dnowext", "3dnow",
 
 		/* Transmeta-defined */
 		"recovery", "longrun", NULL, "lrti", NULL, NULL, NULL, NULL,
@@ -40,7 +40,7 @@
 		/* Other (Linux-defined) */
 		"cxmmx", "k6_mtrr", "cyrix_arr", "centaur_mcr",
 		NULL, NULL, NULL, NULL,
-		NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+		"constant_tsc", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 		NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 		NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 
@@ -57,11 +57,21 @@
 		NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 
 		/* AMD-defined (#2) */
-		"lahf_lm", "cmp_legacy", NULL, NULL, NULL, NULL, NULL, NULL,
+		"lahf_lm", "cmp_legacy", "svm", NULL, "cr8legacy", NULL, NULL, NULL,
 		NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 		NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 		NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 	};
+	static char *x86_power_flags[] = {
+		"ts",	/* temperature sensor */
+		"fid",  /* frequency id control */
+		"vid",  /* voltage id control */
+		"ttp",  /* thermal trip */
+		"tm",
+		"stc",
+		NULL,
+		/* nothing */	/* constant_tsc - moved to flags */
+	};
 	struct cpuinfo_x86 *c = v;
 	int i, n = c - cpu_data;
 	int fpu_exception;
@@ -131,6 +141,17 @@
 		     x86_cap_flags[i] != NULL )
 			seq_printf(m, " %s", x86_cap_flags[i]);
 
+	for (i = 0; i < 32; i++)
+		if (c->x86_power & (1 << i)) {
+			if (i < ARRAY_SIZE(x86_power_flags) &&
+			    x86_power_flags[i])
+				seq_printf(m, "%s%s",
+					   x86_power_flags[i][0]?" ":"",
+					   x86_power_flags[i]);
+			else
+				seq_printf(m, " [%d]", i);
+		}
+
 	seq_printf(m, "\nbogomips\t: %lu.%02lu\n\n",
 		     c->loops_per_jiffy/(500000/HZ),
 		     (c->loops_per_jiffy/(5000/HZ)) % 100);
diff --git a/arch/i386/kernel/dmi_scan.c b/arch/i386/kernel/dmi_scan.c
index 58516e2..6a93d75 100644
--- a/arch/i386/kernel/dmi_scan.c
+++ b/arch/i386/kernel/dmi_scan.c
@@ -4,7 +4,7 @@
 #include <linux/module.h>
 #include <linux/dmi.h>
 #include <linux/bootmem.h>
-
+#include <linux/slab.h>
 
 static char * __init dmi_string(struct dmi_header *dm, u8 s)
 {
@@ -19,7 +19,7 @@
 		}
 
 		if (*bp != 0) {
-			str = alloc_bootmem(strlen(bp) + 1);
+			str = dmi_alloc(strlen(bp) + 1);
 			if (str != NULL)
 				strcpy(str, bp);
 			else
@@ -40,7 +40,7 @@
 	u8 *buf, *data;
 	int i = 0;
 		
-	buf = bt_ioremap(base, len);
+	buf = dmi_ioremap(base, len);
 	if (buf == NULL)
 		return -1;
 
@@ -65,7 +65,7 @@
 		data += 2;
 		i++;
 	}
-	bt_iounmap(buf, len);
+	dmi_iounmap(buf, len);
 	return 0;
 }
 
@@ -112,7 +112,7 @@
 		if ((*d & 0x80) == 0)
 			continue;
 
-		dev = alloc_bootmem(sizeof(*dev));
+		dev = dmi_alloc(sizeof(*dev));
 		if (!dev) {
 			printk(KERN_ERR "dmi_save_devices: out of memory.\n");
 			break;
@@ -131,7 +131,7 @@
 	struct dmi_device *dev;
 	void * data;
 
-	data = alloc_bootmem(dm->length);
+	data = dmi_alloc(dm->length);
 	if (data == NULL) {
 		printk(KERN_ERR "dmi_save_ipmi_device: out of memory.\n");
 		return;
@@ -139,7 +139,7 @@
 
 	memcpy(data, dm, dm->length);
 
-	dev = alloc_bootmem(sizeof(*dev));
+	dev = dmi_alloc(sizeof(*dev));
 	if (!dev) {
 		printk(KERN_ERR "dmi_save_ipmi_device: out of memory.\n");
 		return;
@@ -221,7 +221,7 @@
 		}
 	}
 
-out:	printk(KERN_INFO "DMI not present.\n");
+out:	printk(KERN_INFO "DMI not present or invalid.\n");
 }
 
 
diff --git a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c
index 7554f8f..f2dd218 100644
--- a/arch/i386/kernel/io_apic.c
+++ b/arch/i386/kernel/io_apic.c
@@ -1649,7 +1649,7 @@
 	for(apic = 0; apic < nr_ioapics; apic++) {
 		int pin;
 		/* See if any of the pins is in ExtINT mode */
-		for(pin = 0; pin < nr_ioapic_registers[i]; pin++) {
+		for (pin = 0; pin < nr_ioapic_registers[apic]; pin++) {
 			struct IO_APIC_route_entry entry;
 			spin_lock_irqsave(&ioapic_lock, flags);
 			*(((int *)&entry) + 0) = io_apic_read(apic, 0x10 + 2 * pin);
diff --git a/arch/i386/kernel/ioport.c b/arch/i386/kernel/ioport.c
index b59a34d..79026f0 100644
--- a/arch/i386/kernel/ioport.c
+++ b/arch/i386/kernel/ioport.c
@@ -7,6 +7,7 @@
 
 #include <linux/sched.h>
 #include <linux/kernel.h>
+#include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/types.h>
 #include <linux/ioport.h>
diff --git a/arch/i386/kernel/kprobes.c b/arch/i386/kernel/kprobes.c
index 2f372db..6483eeb 100644
--- a/arch/i386/kernel/kprobes.c
+++ b/arch/i386/kernel/kprobes.c
@@ -188,6 +188,19 @@
 			kcb->kprobe_status = KPROBE_REENTER;
 			return 1;
 		} else {
+			if (regs->eflags & VM_MASK) {
+			/* We are in virtual-8086 mode. Return 0 */
+				goto no_kprobe;
+			}
+			if (*addr != BREAKPOINT_INSTRUCTION) {
+			/* The breakpoint instruction was removed by
+			 * another cpu right after we hit, no further
+			 * handling of this interrupt is appropriate
+			 */
+				regs->eip -= sizeof(kprobe_opcode_t);
+				ret = 1;
+				goto no_kprobe;
+			}
 			p = __get_cpu_var(current_kprobe);
 			if (p->break_handler && p->break_handler(p, regs)) {
 				goto ss_probe;
diff --git a/arch/i386/kernel/microcode.c b/arch/i386/kernel/microcode.c
index 165f131..d3fdf00 100644
--- a/arch/i386/kernel/microcode.c
+++ b/arch/i386/kernel/microcode.c
@@ -70,6 +70,7 @@
  */
 
 //#define DEBUG /* pr_debug */
+#include <linux/capability.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/sched.h>
@@ -165,7 +166,7 @@
 
 	wrmsr(MSR_IA32_UCODE_REV, 0, 0);
 	/* see notes above for revision 1.07.  Apparent chip bug */
-	serialize_cpu();
+	sync_core();
 	/* get the current revision from MSR 0x8B */
 	rdmsr(MSR_IA32_UCODE_REV, val[0], uci->rev);
 	pr_debug("microcode: collect_cpu_info : sig=0x%x, pf=0x%x, rev=0x%x\n",
@@ -379,7 +380,7 @@
 	wrmsr(MSR_IA32_UCODE_REV, 0, 0);
 
 	/* see notes above for revision 1.07.  Apparent chip bug */
-	serialize_cpu();
+	sync_core();
 
 	/* get the current revision from MSR 0x8B */
 	rdmsr(MSR_IA32_UCODE_REV, val[0], val[1]);
diff --git a/arch/i386/kernel/reboot.c b/arch/i386/kernel/reboot.c
index 2fa5803..d207242 100644
--- a/arch/i386/kernel/reboot.c
+++ b/arch/i386/kernel/reboot.c
@@ -12,6 +12,7 @@
 #include <linux/efi.h>
 #include <linux/dmi.h>
 #include <linux/ctype.h>
+#include <linux/pm.h>
 #include <asm/uaccess.h>
 #include <asm/apic.h>
 #include <asm/desc.h>
@@ -355,10 +356,10 @@
 
 void machine_power_off(void)
 {
-	machine_shutdown();
-
-	if (pm_power_off)
+	if (pm_power_off) {
+		machine_shutdown();
 		pm_power_off();
+	}
 }
 
 
diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c
index f685637..51e513b 100644
--- a/arch/i386/kernel/setup.c
+++ b/arch/i386/kernel/setup.c
@@ -45,6 +45,7 @@
 #include <linux/nodemask.h>
 #include <linux/kexec.h>
 #include <linux/crash_dump.h>
+#include <linux/dmi.h>
 
 #include <video/edid.h>
 
@@ -146,7 +147,6 @@
 struct e820map e820;
 
 extern void early_cpu_init(void);
-extern void dmi_scan_machine(void);
 extern void generic_apic_probe(char *);
 extern int root_mountflags;
 
@@ -1584,7 +1584,7 @@
 		if (s) {
 			extern void setup_early_printk(char *);
 
-			setup_early_printk(s);
+			setup_early_printk(strchr(s, '=') + 1);
 			printk("early console enabled\n");
 		}
 	}
diff --git a/arch/i386/kernel/time.c b/arch/i386/kernel/time.c
index 41c5b2d..a14d594 100644
--- a/arch/i386/kernel/time.c
+++ b/arch/i386/kernel/time.c
@@ -302,6 +302,12 @@
 	do_timer_interrupt(irq, regs);
 
 	write_sequnlock(&xtime_lock);
+
+#ifdef CONFIG_X86_LOCAL_APIC
+	if (using_apic_timer)
+		smp_send_timer_broadcast_ipi(regs);
+#endif
+
 	return IRQ_HANDLED;
 }
 
diff --git a/arch/i386/kernel/vm86.c b/arch/i386/kernel/vm86.c
index fc19935..cbdb0af 100644
--- a/arch/i386/kernel/vm86.c
+++ b/arch/i386/kernel/vm86.c
@@ -30,6 +30,7 @@
  *
  */
 
+#include <linux/capability.h>
 #include <linux/config.h>
 #include <linux/errno.h>
 #include <linux/interrupt.h>
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index 19ee635..a346e18 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -26,6 +26,7 @@
 #include <linux/fcntl.h>
 #include <linux/mm.h>
 #include <linux/slab.h>
+#include <linux/capability.h>
 #include <linux/console.h>
 #include <linux/module.h>
 #include <linux/serial.h>
diff --git a/arch/ia64/ia32/sys_ia32.c b/arch/ia64/ia32/sys_ia32.c
index 5ea3828..0668b2b7 100644
--- a/arch/ia64/ia32/sys_ia32.c
+++ b/arch/ia64/ia32/sys_ia32.c
@@ -48,6 +48,7 @@
 #include <linux/ptrace.h>
 #include <linux/stat.h>
 #include <linux/ipc.h>
+#include <linux/capability.h>
 #include <linux/compat.h>
 #include <linux/vfs.h>
 #include <linux/mman.h>
diff --git a/arch/ia64/kernel/kprobes.c b/arch/ia64/kernel/kprobes.c
index 4de7f67..346fedf 100644
--- a/arch/ia64/kernel/kprobes.c
+++ b/arch/ia64/kernel/kprobes.c
@@ -638,6 +638,13 @@
 			if (p->break_handler && p->break_handler(p, regs)) {
 				goto ss_probe;
 			}
+		} else if (!is_ia64_break_inst(regs)) {
+			/* The breakpoint instruction was removed by
+			 * another cpu right after we hit, no further
+			 * handling of this interrupt is appropriate
+			 */
+			ret = 1;
+			goto no_kprobe;
 		} else {
 			/* Not our break */
 			goto no_kprobe;
diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
index 410d480..c026ac1 100644
--- a/arch/ia64/kernel/perfmon.c
+++ b/arch/ia64/kernel/perfmon.c
@@ -38,6 +38,7 @@
 #include <linux/pagemap.h>
 #include <linux/mount.h>
 #include <linux/bitops.h>
+#include <linux/capability.h>
 #include <linux/rcupdate.h>
 
 #include <asm/errno.h>
diff --git a/arch/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c
index 1461dc6..a87a162 100644
--- a/arch/ia64/kernel/salinfo.c
+++ b/arch/ia64/kernel/salinfo.c
@@ -29,6 +29,7 @@
  *   Replace some NR_CPUS by cpus_online, for hotplug cpu.
  */
 
+#include <linux/capability.h>
 #include <linux/types.h>
 #include <linux/proc_fs.h>
 #include <linux/module.h>
diff --git a/arch/ia64/sn/kernel/tiocx.c b/arch/ia64/sn/kernel/tiocx.c
index 768c21d..493fb3f 100644
--- a/arch/ia64/sn/kernel/tiocx.c
+++ b/arch/ia64/sn/kernel/tiocx.c
@@ -11,6 +11,7 @@
 #include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/proc_fs.h>
+#include <linux/capability.h>
 #include <linux/device.h>
 #include <linux/delay.h>
 #include <asm/system.h>
diff --git a/arch/m68k/bvme6000/rtc.c b/arch/m68k/bvme6000/rtc.c
index eb63ca6..f7573f2 100644
--- a/arch/m68k/bvme6000/rtc.c
+++ b/arch/m68k/bvme6000/rtc.c
@@ -11,6 +11,7 @@
 #include <linux/miscdevice.h>
 #include <linux/slab.h>
 #include <linux/ioport.h>
+#include <linux/capability.h>
 #include <linux/fcntl.h>
 #include <linux/init.h>
 #include <linux/poll.h>
diff --git a/arch/m68k/kernel/sys_m68k.c b/arch/m68k/kernel/sys_m68k.c
index 2ed7b78..640895b 100644
--- a/arch/m68k/kernel/sys_m68k.c
+++ b/arch/m68k/kernel/sys_m68k.c
@@ -6,6 +6,7 @@
  * platform.
  */
 
+#include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/sched.h>
 #include <linux/mm.h>
diff --git a/arch/m68k/mvme16x/rtc.c b/arch/m68k/mvme16x/rtc.c
index 7977eae..30f5921 100644
--- a/arch/m68k/mvme16x/rtc.c
+++ b/arch/m68k/mvme16x/rtc.c
@@ -11,6 +11,7 @@
 #include <linux/miscdevice.h>
 #include <linux/slab.h>
 #include <linux/ioport.h>
+#include <linux/capability.h>
 #include <linux/fcntl.h>
 #include <linux/init.h>
 #include <linux/poll.h>
diff --git a/arch/mips/kernel/syscall.c b/arch/mips/kernel/syscall.c
index ee98eeb..0068819 100644
--- a/arch/mips/kernel/syscall.c
+++ b/arch/mips/kernel/syscall.c
@@ -9,6 +9,7 @@
  */
 #include <linux/config.h>
 #include <linux/a.out.h>
+#include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/linkage.h>
 #include <linux/mm.h>
diff --git a/arch/mips/kernel/sysirix.c b/arch/mips/kernel/sysirix.c
index 52924f8..0fc3730 100644
--- a/arch/mips/kernel/sysirix.c
+++ b/arch/mips/kernel/sysirix.c
@@ -8,6 +8,7 @@
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/binfmts.h>
+#include <linux/capability.h>
 #include <linux/highuid.h>
 #include <linux/pagemap.h>
 #include <linux/mm.h>
diff --git a/arch/parisc/hpux/sys_hpux.c b/arch/parisc/hpux/sys_hpux.c
index a64fd48..29b4d61 100644
--- a/arch/parisc/hpux/sys_hpux.c
+++ b/arch/parisc/hpux/sys_hpux.c
@@ -22,6 +22,7 @@
  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include <linux/capability.h>
 #include <linux/file.h>
 #include <linux/fs.h>
 #include <linux/namei.h>
diff --git a/arch/parisc/kernel/perf.c b/arch/parisc/kernel/perf.c
index 79dcbcc..11d406c 100644
--- a/arch/parisc/kernel/perf.c
+++ b/arch/parisc/kernel/perf.c
@@ -42,6 +42,7 @@
  *  on every box. 
  */
 
+#include <linux/capability.h>
 #include <linux/init.h>
 #include <linux/proc_fs.h>
 #include <linux/miscdevice.h>
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 935d965..01feed0 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -71,15 +71,39 @@
 	bool
 	default y
 
+config PPC_OF
+	def_bool y
+
+config PPC_UDBG_16550
+	bool
+	default n
+
+config CRASH_DUMP
+	bool "kernel crash dumps (EXPERIMENTAL)"
+	depends on PPC_MULTIPLATFORM
+	depends on EXPERIMENTAL
+	help
+	  Build a kernel suitable for use as a kdump capture kernel.
+	  The kernel will be linked at a different address than normal, and
+	  so can only be used for Kdump.
+
+	  Don't change this unless you know what you are doing.
+
+config GENERIC_TBSYNC
+	bool
+	default y if PPC32 && SMP
+	default n
+
 menu "Processor support"
 choice
 	prompt "Processor Type"
 	depends on PPC32
 	default 6xx
 
-config 6xx
+config CLASSIC32
 	bool "6xx/7xx/74xx"
 	select PPC_FPU
+	select 6xx
 	help
 	  There are four families of PowerPC chips supported.  The more common
 	  types (601, 603, 604, 740, 750, 7400), the Motorola embedded
@@ -93,12 +117,20 @@
 
 config PPC_52xx
 	bool "Freescale 52xx"
+	select 6xx
+	select PPC_FPU
 	
 config PPC_82xx
 	bool "Freescale 82xx"
+	select 6xx
+	select PPC_FPU
 
 config PPC_83xx
 	bool "Freescale 83xx"
+	select 6xx
+	select FSL_SOC
+	select 83xx
+	select PPC_FPU
 
 config 40x
 	bool "AMCC 40x"
@@ -134,6 +166,13 @@
 	depends on PPC64
 	def_bool y
 
+config 6xx
+	bool
+
+# this is temp to handle compat with arch=ppc
+config 83xx
+	bool
+
 config PPC_FPU
 	bool
 	default y if PPC64
@@ -166,7 +205,7 @@
 
 config ALTIVEC
 	bool "AltiVec Support"
-	depends on 6xx || POWER4
+	depends on CLASSIC32 || POWER4
 	---help---
 	  This option enables kernel support for the Altivec extensions to the
 	  PowerPC processor. The kernel currently supports saving and restoring
@@ -239,7 +278,7 @@
 source "init/Kconfig"
 
 menu "Platform support"
-	depends on PPC64 || 6xx
+	depends on PPC64 || CLASSIC32
 
 choice
 	prompt "Machine type"
@@ -330,9 +369,6 @@
 	select MMIO_NVRAM
 	select PPC_UDBG_16550
 
-config PPC_OF
-	def_bool y
-
 config XICS
 	depends on PPC_PSERIES
 	bool
@@ -375,26 +411,11 @@
 	depends on PPC_MAPLE
 	default y
 
-config PPC_UDBG_16550
-	bool
-	default n
-
 config CELL_IIC
 	depends on PPC_CELL
 	bool
 	default y
 
-config CRASH_DUMP
-	bool "kernel crash dumps (EXPERIMENTAL)"
-	depends on PPC_MULTIPLATFORM
-	depends on EXPERIMENTAL
-	help
-	  Build a kernel suitable for use as a kdump capture kernel.
-	  The kernel will be linked at a different address than normal, and
-	  so can only be used for Kdump.
-
-	  Don't change this unless you know what you are doing.
-
 config IBMVIO
 	depends on PPC_PSERIES || PPC_ISERIES
 	bool
@@ -410,11 +431,6 @@
 	bool
 	default n
 
-config GENERIC_TBSYNC
-	bool
-	default y if PPC32 && SMP
-	default n
-
 source "drivers/cpufreq/Kconfig"
 
 config CPU_FREQ_PMAC
@@ -495,6 +511,7 @@
 
 source arch/powerpc/platforms/embedded6xx/Kconfig
 source arch/powerpc/platforms/4xx/Kconfig
+source arch/powerpc/platforms/83xx/Kconfig
 source arch/powerpc/platforms/85xx/Kconfig
 source arch/powerpc/platforms/8xx/Kconfig
 source arch/powerpc/platforms/cell/Kconfig
@@ -718,7 +735,7 @@
 config PPC_INDIRECT_PCI
 	bool
 	depends on PCI
-	default y if 40x || 44x || 85xx || 83xx
+	default y if 40x || 44x || 85xx
 	default n
 
 config EISA
@@ -727,13 +744,16 @@
 config SBUS
 	bool
 
+config FSL_SOC
+	bool
+
 # Yes MCA RS/6000s exist but Linux-PPC does not currently support any
 config MCA
 	bool
 
 config PCI
-	bool "PCI support" if 40x || CPM2 || 83xx || 85xx || PPC_MPC52xx || (EMBEDDED && PPC_ISERIES)
-	default y if !40x && !CPM2 && !8xx && !APUS && !83xx && !85xx
+	bool "PCI support" if 40x || CPM2 || PPC_83xx || 85xx || PPC_MPC52xx || (EMBEDDED && PPC_ISERIES)
+	default y if !40x && !CPM2 && !8xx && !APUS && !PPC_83xx && !85xx
 	default PCI_PERMEDIA if !4xx && !CPM2 && !8xx && APUS
 	default PCI_QSPAN if !4xx && !CPM2 && 8xx
 	help
@@ -746,11 +766,6 @@
 	bool
 	default PCI
 
-config MPC83xx_PCI2
-	bool "  Supprt for 2nd PCI host controller"
-	depends on PCI && MPC834x
-	default y if MPC834x_SYS
-
 config PCI_QSPAN
 	bool "QSpan PCI"
 	depends on !4xx && !CPM2 && 8xx
diff --git a/arch/powerpc/Kconfig.debug b/arch/powerpc/Kconfig.debug
index 30a30bf..9254806 100644
--- a/arch/powerpc/Kconfig.debug
+++ b/arch/powerpc/Kconfig.debug
@@ -115,4 +115,46 @@
 	depends on IBM_OCP || XILINX_OCP
 	default y
 
+choice
+	prompt "Early debugging (dangerous)"
+	bool
+	optional
+	help
+	  Enable early debugging. Careful, if you enable debugging for the
+	  wrong type of machine your kernel _will not boot_.
+
+config PPC_EARLY_DEBUG_LPAR
+	bool "LPAR HV Console"
+	depends on PPC_PSERIES
+	help
+	  Select this to enable early debugging for a machine with a HVC
+	  console on vterm 0.
+
+config PPC_EARLY_DEBUG_G5
+	bool "Apple G5"
+	depends on PPC_PMAC64
+	help
+	  Select this to enable early debugging for Apple G5 machines.
+
+config PPC_EARLY_DEBUG_RTAS
+	bool "RTAS Panel"
+	depends on PPC_RTAS
+	help
+	  Select this to enable early debugging via the RTAS panel.
+
+config PPC_EARLY_DEBUG_MAPLE
+	bool "Maple real mode"
+	depends on PPC_MAPLE
+	help
+	  Select this to enable early debugging for Maple.
+
+config PPC_EARLY_DEBUG_ISERIES
+	bool "iSeries HV Console"
+	depends on PPC_ISERIES
+	help
+	  Select this to enable early debugging for legacy iSeries. You need
+	  to hit "Ctrl-x Ctrl-x" to see the messages on the console.
+
+endchoice
+
 endmenu
diff --git a/arch/powerpc/boot/.gitignore b/arch/powerpc/boot/.gitignore
new file mode 100644
index 0000000..45c9ad2
--- /dev/null
+++ b/arch/powerpc/boot/.gitignore
@@ -0,0 +1,20 @@
+addnote
+infblock.c
+infblock.h
+infcodes.c
+infcodes.h
+inffast.c
+inffast.h
+inflate.c
+inftrees.c
+inftrees.h
+infutil.c
+infutil.h
+kernel-vmlinux.strip.c
+kernel-vmlinux.strip.gz
+uImage
+zImage
+zImage.vmode
+zconf.h
+zlib.h
+zutil.h
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 22726ae..b53d677 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -176,4 +176,4 @@
 install: $(CONFIGURE) $(BOOTIMAGE)
 	sh -x $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" vmlinux System.map "$(INSTALL_PATH)" "$(BOOTIMAGE)"
 
-clean-files := $(addprefix $(objtree)/, $(obj-boot) vmlinux.strip)
+clean-files += $(addprefix $(objtree)/, $(obj-boot) vmlinux.strip)
diff --git a/arch/powerpc/configs/ppc64_defconfig b/arch/powerpc/configs/ppc64_defconfig
index 347f439..0b2b55a 100644
--- a/arch/powerpc/configs/ppc64_defconfig
+++ b/arch/powerpc/configs/ppc64_defconfig
@@ -878,7 +878,7 @@
 #
 # CONFIG_WATCHDOG is not set
 # CONFIG_RTC is not set
-# CONFIG_GEN_RTC is not set
+CONFIG_GEN_RTC=y
 # CONFIG_DTLK is not set
 # CONFIG_R3964 is not set
 # CONFIG_APPLICOM is not set
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 144e284..bbfa1bd 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -61,9 +61,9 @@
 pci64-$(CONFIG_PPC64)		+= pci_64.o pci_dn.o pci_iommu.o \
 				   pci_direct_iommu.o iomap.o
 obj-$(CONFIG_PCI)		+= $(pci64-y)
-kexec-$(CONFIG_PPC64)		:= machine_kexec_64.o
+kexec-$(CONFIG_PPC64)		:= machine_kexec_64.o crash.o
 kexec-$(CONFIG_PPC32)		:= machine_kexec_32.o
-obj-$(CONFIG_KEXEC)		+= machine_kexec.o crash.o $(kexec-y)
+obj-$(CONFIG_KEXEC)		+= machine_kexec.o $(kexec-y)
 
 ifeq ($(CONFIG_PPC_ISERIES),y)
 $(obj)/head_64.o: $(obj)/lparmap.s
diff --git a/arch/powerpc/kernel/crash.c b/arch/powerpc/kernel/crash.c
index 4681155..5f248e3 100644
--- a/arch/powerpc/kernel/crash.c
+++ b/arch/powerpc/kernel/crash.c
@@ -18,7 +18,6 @@
 #include <linux/kexec.h>
 #include <linux/bootmem.h>
 #include <linux/crash_dump.h>
-#include <linux/irq.h>
 #include <linux/delay.h>
 #include <linux/elf.h>
 #include <linux/elfcore.h>
@@ -30,6 +29,7 @@
 #include <asm/kdump.h>
 #include <asm/lmb.h>
 #include <asm/firmware.h>
+#include <asm/smp.h>
 
 #ifdef DEBUG
 #include <asm/udbg.h>
diff --git a/arch/powerpc/kernel/crash_dump.c b/arch/powerpc/kernel/crash_dump.c
index 87effa3..211d726 100644
--- a/arch/powerpc/kernel/crash_dump.c
+++ b/arch/powerpc/kernel/crash_dump.c
@@ -55,6 +55,7 @@
 	DBG(" <- kdump_setup()\n");
 }
 
+#ifdef CONFIG_PROC_VMCORE
 static int __init parse_elfcorehdr(char *p)
 {
 	if (p)
@@ -63,6 +64,7 @@
 	return 0;
 }
 __setup("elfcorehdr=", parse_elfcorehdr);
+#endif
 
 static int __init parse_savemaxmem(char *p)
 {
diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c
index 27b0c40..cfab485 100644
--- a/arch/powerpc/kernel/kprobes.c
+++ b/arch/powerpc/kernel/kprobes.c
@@ -179,6 +179,18 @@
 			kcb->kprobe_status = KPROBE_REENTER;
 			return 1;
 		} else {
+			if (*addr != BREAKPOINT_INSTRUCTION) {
+				/* If trap variant, then it belongs not to us */
+				kprobe_opcode_t cur_insn = *addr;
+				if (is_trap(cur_insn))
+		       			goto no_kprobe;
+				/* The breakpoint instruction was removed by
+				 * another cpu right after we hit, no further
+				 * handling of this interrupt is appropriate
+				 */
+				ret = 1;
+				goto no_kprobe;
+			}
 			p = __get_cpu_var(current_kprobe);
 			if (p->break_handler && p->break_handler(p, regs)) {
 				goto ss_probe;
diff --git a/arch/powerpc/kernel/machine_kexec.c b/arch/powerpc/kernel/machine_kexec.c
index a91e40c..a81ca1b 100644
--- a/arch/powerpc/kernel/machine_kexec.c
+++ b/arch/powerpc/kernel/machine_kexec.c
@@ -14,12 +14,6 @@
 #include <linux/threads.h>
 #include <asm/machdep.h>
 
-/*
- * Provide a dummy crash_notes definition until crash dump is implemented.
- * This prevents breakage of crash_notes attribute in kernel/ksysfs.c.
- */
-note_buf_t crash_notes[NR_CPUS];
-
 void machine_crash_shutdown(struct pt_regs *regs)
 {
 	if (ppc_md.machine_crash_shutdown)
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
index ba21a6c..24fe70f 100644
--- a/arch/powerpc/kernel/pci_64.c
+++ b/arch/powerpc/kernel/pci_64.c
@@ -271,6 +271,9 @@
 	list_for_each_entry(child_bus, &b->children, node)
 		pcibios_claim_one_bus(child_bus);
 }
+#ifdef CONFIG_HOTPLUG
+EXPORT_SYMBOL_GPL(pcibios_claim_one_bus);
+#endif
 
 #ifndef CONFIG_PPC_ISERIES
 static void __init pcibios_claim_of_setup(void)
diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
index ae2e2a3..4b9cfe4 100644
--- a/arch/powerpc/kernel/rtas.c
+++ b/arch/powerpc/kernel/rtas.c
@@ -17,6 +17,7 @@
 #include <linux/spinlock.h>
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/capability.h>
 #include <linux/delay.h>
 
 #include <asm/prom.h>
@@ -29,6 +30,7 @@
 #include <asm/delay.h>
 #include <asm/uaccess.h>
 #include <asm/lmb.h>
+#include <asm/udbg.h>
 
 struct rtas_t rtas = {
 	.lock = SPIN_LOCK_UNLOCKED
@@ -52,7 +54,7 @@
  * are designed only for very early low-level debugging, which
  * is why the token is hard-coded to 10.
  */
-void call_rtas_display_status(unsigned char c)
+static void call_rtas_display_status(char c)
 {
 	struct rtas_args *args = &rtas.args;
 	unsigned long s;
@@ -65,14 +67,14 @@
 	args->nargs = 1;
 	args->nret  = 1;
 	args->rets  = (rtas_arg_t *)&(args->args[1]);
-	args->args[0] = (int)c;
+	args->args[0] = (unsigned char)c;
 
 	enter_rtas(__pa(args));
 
 	spin_unlock_irqrestore(&rtas.lock, s);
 }
 
-void call_rtas_display_status_delay(unsigned char c)
+static void call_rtas_display_status_delay(char c)
 {
 	static int pending_newline = 0;  /* did last write end with unprinted newline? */
 	static int width = 16;
@@ -96,6 +98,11 @@
 	}
 }
 
+void __init udbg_init_rtas(void)
+{
+	udbg_putc = call_rtas_display_status_delay;
+}
+
 void rtas_progress(char *s, unsigned short hex)
 {
 	struct device_node *root;
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index c4b7696..e29b275 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -33,6 +33,7 @@
 #include <linux/unistd.h>
 #include <linux/serial.h>
 #include <linux/serial_8250.h>
+#include <linux/bootmem.h>
 #include <asm/io.h>
 #include <asm/kdump.h>
 #include <asm/prom.h>
@@ -70,33 +71,6 @@
 #define DBG(fmt...)
 #endif
 
-/*
- * Here are some early debugging facilities. You can enable one
- * but your kernel will not boot on anything else if you do so
- */
-
-/* This one is for use on LPAR machines that support an HVC console
- * on vterm 0
- */
-extern void udbg_init_debug_lpar(void);
-/* This one is for use on Apple G5 machines
- */
-extern void udbg_init_pmac_realmode(void);
-/* That's RTAS panel debug */
-extern void call_rtas_display_status_delay(unsigned char c);
-/* Here's maple real mode debug */
-extern void udbg_init_maple_realmode(void);
-
-#define EARLY_DEBUG_INIT() do {} while(0)
-
-#if 0
-#define EARLY_DEBUG_INIT() udbg_init_debug_lpar()
-#define EARLY_DEBUG_INIT() udbg_init_maple_realmode()
-#define EARLY_DEBUG_INIT() udbg_init_pmac_realmode()
-#define EARLY_DEBUG_INIT()						\
-	do { udbg_putc = call_rtas_display_status_delay; } while(0)
-#endif
-
 int have_of = 1;
 int boot_cpuid = 0;
 int boot_cpuid_phys = 0;
@@ -237,11 +211,8 @@
 	struct paca_struct *lpaca = get_paca();
 	static struct machdep_calls **mach;
 
-	/*
-	 * Enable early debugging if any specified (see top of
-	 * this file)
-	 */
-	EARLY_DEBUG_INIT();
+	/* Enable early debugging if any specified (see udbg.h) */
+	udbg_early_init();
 
 	DBG(" -> early_setup()\n");
 
@@ -684,3 +655,28 @@
 	if (ppc_md.cpu_die)
 		ppc_md.cpu_die();
 }
+
+#ifdef CONFIG_SMP
+void __init setup_per_cpu_areas(void)
+{
+	int i;
+	unsigned long size;
+	char *ptr;
+
+	/* Copy section for each CPU (we discard the original) */
+	size = ALIGN(__per_cpu_end - __per_cpu_start, SMP_CACHE_BYTES);
+#ifdef CONFIG_MODULES
+	if (size < PERCPU_ENOUGH_ROOM)
+		size = PERCPU_ENOUGH_ROOM;
+#endif
+
+	for_each_cpu(i) {
+		ptr = alloc_bootmem_node(NODE_DATA(cpu_to_node(i)), size);
+		if (!ptr)
+			panic("Cannot allocate cpu data for CPU %d\n", i);
+
+		paca[i].data_offset = ptr - __per_cpu_start;
+		memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start);
+	}
+}
+#endif
diff --git a/arch/powerpc/kernel/udbg.c b/arch/powerpc/kernel/udbg.c
index 558c1ce..3774e80 100644
--- a/arch/powerpc/kernel/udbg.c
+++ b/arch/powerpc/kernel/udbg.c
@@ -15,11 +15,36 @@
 #include <linux/sched.h>
 #include <linux/console.h>
 #include <asm/processor.h>
+#include <asm/udbg.h>
 
 void (*udbg_putc)(char c);
 int (*udbg_getc)(void);
 int (*udbg_getc_poll)(void);
 
+/*
+ * Early debugging facilities. You can enable _one_ of these via .config,
+ * if you do so your kernel _will not boot_ on anything else. Be careful.
+ */
+void __init udbg_early_init(void)
+{
+#if defined(CONFIG_PPC_EARLY_DEBUG_LPAR)
+	/* For LPAR machines that have an HVC console on vterm 0 */
+	udbg_init_debug_lpar();
+#elif defined(CONFIG_PPC_EARLY_DEBUG_G5)
+	/* For use on Apple G5 machines */
+	udbg_init_pmac_realmode();
+#elif defined(CONFIG_PPC_EARLY_DEBUG_RTAS)
+	/* RTAS panel debug */
+	udbg_init_rtas();
+#elif defined(CONFIG_PPC_EARLY_DEBUG_MAPLE)
+	/* Maple real mode debug */
+	udbg_init_maple_realmode();
+#elif defined(CONFIG_PPC_EARLY_DEBUG_ISERIES)
+	/* For iSeries - hit Ctrl-x Ctrl-x to see the output */
+	udbg_init_iseries();
+#endif
+}
+
 /* udbg library, used by xmon et al */
 void udbg_puts(const char *s)
 {
diff --git a/arch/powerpc/kernel/udbg_16550.c b/arch/powerpc/kernel/udbg_16550.c
index 7541bf4..2da65a9 100644
--- a/arch/powerpc/kernel/udbg_16550.c
+++ b/arch/powerpc/kernel/udbg_16550.c
@@ -155,7 +155,7 @@
 	}
 }
 
-void udbg_init_maple_realmode(void)
+void __init udbg_init_maple_realmode(void)
 {
 	udbg_comport = (volatile struct NS16550 __iomem *)0xf40003f8;
 
diff --git a/arch/powerpc/kernel/vdso32/.gitignore b/arch/powerpc/kernel/vdso32/.gitignore
new file mode 100644
index 0000000..e45fba9
--- /dev/null
+++ b/arch/powerpc/kernel/vdso32/.gitignore
@@ -0,0 +1 @@
+vdso32.lds
diff --git a/arch/powerpc/kernel/vdso64/.gitignore b/arch/powerpc/kernel/vdso64/.gitignore
new file mode 100644
index 0000000..3fd18cf
--- /dev/null
+++ b/arch/powerpc/kernel/vdso64/.gitignore
@@ -0,0 +1 @@
+vdso64.lds
diff --git a/arch/powerpc/platforms/83xx/Kconfig b/arch/powerpc/platforms/83xx/Kconfig
new file mode 100644
index 0000000..b20812d
--- /dev/null
+++ b/arch/powerpc/platforms/83xx/Kconfig
@@ -0,0 +1,26 @@
+menu "Platform support"
+	depends on PPC_83xx
+
+choice
+	prompt "Machine Type"
+	default MPC834x_SYS
+
+config MPC834x_SYS
+	bool "Freescale MPC834x SYS"
+	help
+	  This option enables support for the MPC 834x SYS evaluation board.
+
+	  Be aware that PCI buses can only function when SYS board is plugged
+	  into the PIB (Platform IO Board) board from Freescale which provide
+	  3 PCI slots.  The PIBs PCI initialization is the bootloader's
+	  responsiblilty.
+
+endchoice
+
+config MPC834x
+	bool
+	select PPC_UDBG_16550
+	select PPC_INDIRECT_PCI
+	default y if MPC834x_SYS
+
+endmenu
diff --git a/arch/powerpc/platforms/83xx/Makefile b/arch/powerpc/platforms/83xx/Makefile
new file mode 100644
index 0000000..9d8b28ef
--- /dev/null
+++ b/arch/powerpc/platforms/83xx/Makefile
@@ -0,0 +1,4 @@
+#
+# Makefile for the PowerPC 83xx linux kernel.
+#
+obj-$(CONFIG_MPC834x_SYS)	+= mpc834x_sys.o pci.o
diff --git a/arch/powerpc/platforms/Makefile b/arch/powerpc/platforms/Makefile
index 8836b3a..04073fd 100644
--- a/arch/powerpc/platforms/Makefile
+++ b/arch/powerpc/platforms/Makefile
@@ -7,6 +7,7 @@
 endif
 obj-$(CONFIG_PPC_CHRP)		+= chrp/
 obj-$(CONFIG_4xx)		+= 4xx/
+obj-$(CONFIG_PPC_83xx)		+= 83xx/
 obj-$(CONFIG_85xx)		+= 85xx/
 obj-$(CONFIG_PPC_PSERIES)	+= pseries/
 obj-$(CONFIG_PPC_ISERIES)	+= iseries/
diff --git a/arch/powerpc/platforms/cell/spufs/switch.c b/arch/powerpc/platforms/cell/spufs/switch.c
index 1061c12..212db28 100644
--- a/arch/powerpc/platforms/cell/spufs/switch.c
+++ b/arch/powerpc/platforms/cell/spufs/switch.c
@@ -169,11 +169,33 @@
 	struct spu_priv2 __iomem *priv2 = spu->priv2;
 
 	/* Save, Step 8:
-	 *     Read and save MFC_CNTL[Ss].
+	 *     Suspend DMA and save MFC_CNTL.
 	 */
-	if (csa) {
-		csa->priv2.mfc_control_RW = in_be64(&priv2->mfc_control_RW) &
-		    MFC_CNTL_SUSPEND_DMA_STATUS_MASK;
+	switch (in_be64(&priv2->mfc_control_RW) &
+	       MFC_CNTL_SUSPEND_DMA_STATUS_MASK) {
+	case MFC_CNTL_SUSPEND_IN_PROGRESS:
+		POLL_WHILE_FALSE((in_be64(&priv2->mfc_control_RW) &
+				  MFC_CNTL_SUSPEND_DMA_STATUS_MASK) ==
+				 MFC_CNTL_SUSPEND_COMPLETE);
+		/* fall through */
+	case MFC_CNTL_SUSPEND_COMPLETE:
+		if (csa) {
+			csa->priv2.mfc_control_RW =
+				in_be64(&priv2->mfc_control_RW) |
+				MFC_CNTL_SUSPEND_DMA_QUEUE;
+		}
+		break;
+	case MFC_CNTL_NORMAL_DMA_QUEUE_OPERATION:
+		out_be64(&priv2->mfc_control_RW, MFC_CNTL_SUSPEND_DMA_QUEUE);
+		POLL_WHILE_FALSE((in_be64(&priv2->mfc_control_RW) &
+				  MFC_CNTL_SUSPEND_DMA_STATUS_MASK) ==
+				 MFC_CNTL_SUSPEND_COMPLETE);
+		if (csa) {
+			csa->priv2.mfc_control_RW =
+				in_be64(&priv2->mfc_control_RW) &
+				~MFC_CNTL_SUSPEND_DMA_QUEUE;
+		}
+		break;
 	}
 }
 
@@ -237,6 +259,8 @@
 		eieio();
 		csa->spu_chnldata_RW[7] = in_be64(&priv2->spu_chnldata_RW);
 		eieio();
+	} else {
+		csa->priv2.mfc_control_RW &= ~MFC_CNTL_DECREMENTER_RUNNING;
 	}
 }
 
diff --git a/arch/powerpc/platforms/embedded6xx/Kconfig b/arch/powerpc/platforms/embedded6xx/Kconfig
index 81250090..4fdbc9a 100644
--- a/arch/powerpc/platforms/embedded6xx/Kconfig
+++ b/arch/powerpc/platforms/embedded6xx/Kconfig
@@ -144,16 +144,6 @@
 	  much but it's only been tested on this board version. I think this
 	  board is also known as IceCube.
 
-config MPC834x_SYS
-	bool "Freescale MPC834x SYS"
-	help
-	  This option enables support for the MPC 834x SYS evaluation board.
-
-	  Be aware that PCI buses can only function when SYS board is plugged
-	  into the PIB (Platform IO Board) board from Freescale which provide
-	  3 PCI slots.  The PIBs PCI initialization is the bootloader's
-	  responsiblilty.
-
 config EV64360
 	bool "Marvell-EV64360BP"
 	help
@@ -192,14 +182,6 @@
 	  The MPC8272 CPM has a different internal dpram setup than other CPM2
 	  devices
 
-config 83xx
-	bool
-	default y if MPC834x_SYS
-
-config MPC834x
-	bool
-	default y if MPC834x_SYS
-
 config CPM2
 	bool
 	depends on 8260 || MPC8560 || MPC8555
diff --git a/arch/powerpc/platforms/iseries/setup.c b/arch/powerpc/platforms/iseries/setup.c
index ad5ef805..c6bbe5c 100644
--- a/arch/powerpc/platforms/iseries/setup.c
+++ b/arch/powerpc/platforms/iseries/setup.c
@@ -52,6 +52,7 @@
 #include <asm/iseries/mf.h>
 #include <asm/iseries/hv_lp_event.h>
 #include <asm/iseries/lpar_map.h>
+#include <asm/udbg.h>
 
 #include "naca.h"
 #include "setup.h"
@@ -62,10 +63,8 @@
 #include "call_sm.h"
 #include "call_hpt.h"
 
-extern void hvlog(char *fmt, ...);
-
 #ifdef DEBUG
-#define DBG(fmt...) hvlog(fmt)
+#define DBG(fmt...) udbg_printf(fmt)
 #else
 #define DBG(fmt...)
 #endif
@@ -474,14 +473,6 @@
 	printk("HPT absolute addr = %016lx, size = %dK\n",
 			chunk_to_addr(hptFirstChunk), hptSizeChunks * 256);
 
-	ppc64_pft_size = __ilog2(hptSizePages * HW_PAGE_SIZE);
-
-	/*
-	 * The actual hashed page table is in the hypervisor,
-	 * we have no direct access
-	 */
-	htab_address = NULL;
-
 	/*
 	 * Determine if absolute memory has any
 	 * holes so that we can interpret the
@@ -861,6 +852,11 @@
 	dt_prop(dt, name, (char *)data, sizeof(u64) * n);
 }
 
+void dt_prop_u32_list(struct iseries_flat_dt *dt, char *name, u32 *data, int n)
+{
+	dt_prop(dt, name, (char *)data, sizeof(u32) * n);
+}
+
 void dt_prop_empty(struct iseries_flat_dt *dt, char *name)
 {
 	dt_prop(dt, name, NULL, 0);
@@ -872,6 +868,7 @@
 	unsigned char *p;
 	unsigned int i, index;
 	struct IoHriProcessorVpd *d;
+	u32 pft_size[2];
 
 	/* yuck */
 	snprintf(buf, 32, "PowerPC,%s", cur_cpu_spec->cpu_name);
@@ -882,6 +879,9 @@
 	dt_prop_u32(dt, "#address-cells", 1);
 	dt_prop_u32(dt, "#size-cells", 0);
 
+	pft_size[0] = 0; /* NUMA CEC cookie, 0 for non NUMA  */
+	pft_size[1] = __ilog2(HvCallHpt_getHptPages() * HW_PAGE_SIZE);
+
 	for (i = 0; i < NR_CPUS; i++) {
 		if (paca[i].lppaca.dyn_proc_status >= 2)
 			continue;
@@ -908,6 +908,8 @@
 
 		dt_prop_u32(dt, "reg", i);
 
+		dt_prop_u32_list(dt, "ibm,pft-size", pft_size, 2);
+
 		dt_end_node(dt);
 	}
 
@@ -984,3 +986,16 @@
 	return 0;
 }
 early_param("mem", early_parsemem);
+
+static void hvputc(char c)
+{
+	if (c == '\n')
+		hvputc('\r');
+
+	HvCall_writeLogBuffer(&c, 1);
+}
+
+void __init udbg_init_iseries(void)
+{
+	udbg_putc = hvputc;
+}
diff --git a/arch/powerpc/platforms/powermac/udbg_scc.c b/arch/powerpc/platforms/powermac/udbg_scc.c
index e87d53a..c4352a8 100644
--- a/arch/powerpc/platforms/powermac/udbg_scc.c
+++ b/arch/powerpc/platforms/powermac/udbg_scc.c
@@ -153,7 +153,7 @@
 		udbg_real_scc_putc('\r');
 }
 
-void udbg_init_pmac_realmode(void)
+void __init udbg_init_pmac_realmode(void)
 {
 	sccc = (volatile u8 __iomem *)0x80013020ul;
 	sccd = (volatile u8 __iomem *)0x80013030ul;
diff --git a/arch/powerpc/sysdev/Makefile b/arch/powerpc/sysdev/Makefile
index 14b9abd..0ae8413 100644
--- a/arch/powerpc/sysdev/Makefile
+++ b/arch/powerpc/sysdev/Makefile
@@ -6,4 +6,4 @@
 obj-$(CONFIG_40x)		+= dcr.o
 obj-$(CONFIG_U3_DART)		+= dart_iommu.o
 obj-$(CONFIG_MMIO_NVRAM)	+= mmio_nvram.o
-obj-$(CONFIG_83xx)		+= ipic.o
+obj-$(CONFIG_PPC_83xx)		+= ipic.o
diff --git a/arch/ppc/4xx_io/serial_sicc.c b/arch/ppc/4xx_io/serial_sicc.c
index 84d96b8..ebc4db8 100644
--- a/arch/ppc/4xx_io/serial_sicc.c
+++ b/arch/ppc/4xx_io/serial_sicc.c
@@ -47,6 +47,7 @@
 #include <linux/mm.h>
 #include <linux/slab.h>
 #include <linux/init.h>
+#include <linux/capability.h>
 #include <linux/circ_buf.h>
 #include <linux/serial.h>
 #include <linux/console.h>
diff --git a/arch/ppc/Kconfig b/arch/ppc/Kconfig
index e396f45..d658101 100644
--- a/arch/ppc/Kconfig
+++ b/arch/ppc/Kconfig
@@ -743,6 +743,10 @@
 	bool
 	default y if MPC834x_SYS
 
+config PPC_83xx
+	bool
+	default y if 83xx
+
 config CPM1
 	bool
 	depends on 8xx
diff --git a/arch/ppc/kernel/ppc_htab.c b/arch/ppc/kernel/ppc_htab.c
index ca81002..2f5c765 100644
--- a/arch/ppc/kernel/ppc_htab.c
+++ b/arch/ppc/kernel/ppc_htab.c
@@ -16,6 +16,7 @@
 #include <linux/proc_fs.h>
 #include <linux/stat.h>
 #include <linux/sysctl.h>
+#include <linux/capability.h>
 #include <linux/ctype.h>
 #include <linux/threads.h>
 #include <linux/smp_lock.h>
diff --git a/arch/s390/kernel/compat_linux.c b/arch/s390/kernel/compat_linux.c
index cd3b3c3..bf9a7a3 100644
--- a/arch/s390/kernel/compat_linux.c
+++ b/arch/s390/kernel/compat_linux.c
@@ -55,6 +55,7 @@
 #include <linux/syscalls.h>
 #include <linux/sysctl.h>
 #include <linux/binfmts.h>
+#include <linux/capability.h>
 #include <linux/compat.h>
 #include <linux/vfs.h>
 #include <linux/ptrace.h>
diff --git a/arch/sparc/kernel/sys_sunos.c b/arch/sparc/kernel/sys_sunos.c
index d07ae02..288de27 100644
--- a/arch/sparc/kernel/sys_sunos.c
+++ b/arch/sparc/kernel/sys_sunos.c
@@ -30,6 +30,7 @@
 #include <linux/stat.h>
 #include <linux/slab.h>
 #include <linux/pagemap.h>
+#include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/smp.h>
 #include <linux/smp_lock.h>
diff --git a/arch/sparc64/Kconfig b/arch/sparc64/Kconfig
index b775ceb..ab733be 100644
--- a/arch/sparc64/Kconfig
+++ b/arch/sparc64/Kconfig
@@ -179,7 +179,7 @@
 	bool "512K"
 
 config HUGETLB_PAGE_SIZE_64K
-	depends on !SPARC64_PAGE_SIZE_4MB && !SPARC64_PAGE_SIZE_512K
+	depends on !SPARC64_PAGE_SIZE_4MB && !SPARC64_PAGE_SIZE_512KB
 	bool "64K"
 
 endchoice
diff --git a/arch/sparc64/kernel/kprobes.c b/arch/sparc64/kernel/kprobes.c
index ff5e9d5..b9a9ce7 100644
--- a/arch/sparc64/kernel/kprobes.c
+++ b/arch/sparc64/kernel/kprobes.c
@@ -135,6 +135,14 @@
 			prepare_singlestep(p, regs, kcb);
 			return 1;
 		} else {
+			if (*(u32 *)addr != BREAKPOINT_INSTRUCTION) {
+			/* The breakpoint instruction was removed by
+			 * another cpu right after we hit, no further
+			 * handling of this interrupt is appropriate
+			 */
+				ret = 1;
+				goto no_kprobe;
+			}
 			p = __get_cpu_var(current_kprobe);
 			if (p->break_handler && p->break_handler(p, regs))
 				goto ss_probe;
diff --git a/arch/sparc64/kernel/sys_sparc32.c b/arch/sparc64/kernel/sys_sparc32.c
index de342ee..d4b7a10 100644
--- a/arch/sparc64/kernel/sys_sparc32.c
+++ b/arch/sparc64/kernel/sys_sparc32.c
@@ -11,6 +11,7 @@
 #include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
+#include <linux/capability.h>
 #include <linux/fs.h> 
 #include <linux/mm.h> 
 #include <linux/file.h> 
diff --git a/arch/sparc64/kernel/sys_sunos32.c b/arch/sparc64/kernel/sys_sunos32.c
index bfa4aa6..ae5b32f 100644
--- a/arch/sparc64/kernel/sys_sunos32.c
+++ b/arch/sparc64/kernel/sys_sunos32.c
@@ -12,6 +12,7 @@
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/types.h>
+#include <linux/capability.h>
 #include <linux/compat.h>
 #include <linux/mman.h>
 #include <linux/mm.h>
diff --git a/arch/sparc64/solaris/fs.c b/arch/sparc64/solaris/fs.c
index d7c99fa..4885ca6 100644
--- a/arch/sparc64/solaris/fs.c
+++ b/arch/sparc64/solaris/fs.c
@@ -10,6 +10,7 @@
 #include <linux/types.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
+#include <linux/capability.h>
 #include <linux/fs.h>
 #include <linux/namei.h>
 #include <linux/mm.h>
diff --git a/arch/um/Kconfig b/arch/um/Kconfig
index b4ff2e5..8ff3bcb 100644
--- a/arch/um/Kconfig
+++ b/arch/um/Kconfig
@@ -35,12 +35,12 @@
 
 config MODE_TT
 	bool "Tracing thread support"
-	default y
+	default n
 	help
 	This option controls whether tracing thread support is compiled
-	into UML.  Normally, this should be set to Y.  If you intend to
-	use only skas mode (and the host has the skas patch applied to it),
-	then it is OK to say N here.
+	into UML.  This option is largely obsolete, given that skas0 provides
+	skas security and performance without needing to patch the host.
+	It is safe to say 'N' here.
 
 config STATIC_LINK
 	bool "Force a static link"
diff --git a/arch/um/Makefile b/arch/um/Makefile
index 1b12fee..322972f 100644
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -189,6 +189,12 @@
 	sed 's/ CONFIG/ UML_CONFIG/'
 endef
 
+$(ARCH_DIR)/include/uml-config.h : include/linux/autoconf.h
+	$(call filechk,umlconfig)
+
+$(ARCH_DIR)/user-offsets.s: $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.c
+	$(CC) $(USER_CFLAGS) -S -o $@ $<
+
 define filechk_gen-asm-offsets
         (set -e; \
          echo "/*"; \
@@ -202,24 +208,13 @@
          echo ""; )
 endef
 
-$(ARCH_DIR)/include/uml-config.h : include/linux/autoconf.h
-	$(call filechk,umlconfig)
-
-$(ARCH_DIR)/user-offsets.s: $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.c
-	$(CC) $(USER_CFLAGS) -S -o $@ $<
-
 $(ARCH_DIR)/include/user_constants.h: $(ARCH_DIR)/user-offsets.s
 	$(call filechk,gen-asm-offsets)
 
 CLEAN_FILES += $(ARCH_DIR)/user-offsets.s
 
-$(ARCH_DIR)/kernel-offsets.s: $(ARCH_DIR)/sys-$(SUBARCH)/kernel-offsets.c \
-				   archprepare
-	$(CC) $(CFLAGS) $(NOSTDINC_FLAGS) $(CPPFLAGS) -S -o $@ $<
-
-$(ARCH_DIR)/include/kern_constants.h: $(ARCH_DIR)/kernel-offsets.s
-	$(call filechk,gen-asm-offsets)
-
-CLEAN_FILES += $(ARCH_DIR)/kernel-offsets.s
+$(ARCH_DIR)/include/kern_constants.h:
+	@echo '  SYMLINK $@'
+	$(Q) ln -sf ../../../include/asm-um/asm-offsets.h $@
 
 export SUBARCH USER_CFLAGS OS
diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c
index be61012..e3d5765 100644
--- a/arch/um/drivers/mconsole_kern.c
+++ b/arch/um/drivers/mconsole_kern.c
@@ -500,7 +500,7 @@
 
 static struct console mc_console = { .name	= "mc",
 				     .write	= console_write,
-				     .flags	= CON_PRINTBUFFER | CON_ENABLED,
+				     .flags	= CON_ENABLED,
 				     .index	= -1 };
 
 static int mc_add_console(void)
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index 3a93c6f..7696f8d 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -1073,7 +1073,6 @@
 static int ubd_ioctl(struct inode * inode, struct file * file,
 		     unsigned int cmd, unsigned long arg)
 {
-	struct hd_geometry __user *loc = (struct hd_geometry __user *) arg;
 	struct ubd *dev = inode->i_bdev->bd_disk->private_data;
 	struct hd_driveid ubd_id = {
 		.cyls		= 0,
diff --git a/arch/um/sys-i386/kernel-offsets.c b/arch/um/include/sysdep-i386/kernel-offsets.h
similarity index 79%
rename from arch/um/sys-i386/kernel-offsets.c
rename to arch/um/include/sysdep-i386/kernel-offsets.h
index 35db850..82f96c5 100644
--- a/arch/um/sys-i386/kernel-offsets.c
+++ b/arch/um/include/sysdep-i386/kernel-offsets.h
@@ -1,12 +1,9 @@
-#include <linux/config.h>
 #include <linux/stddef.h>
 #include <linux/sched.h>
-#include <linux/time.h>
 #include <linux/elf.h>
-#include <asm/page.h>
 
 #define DEFINE(sym, val) \
-        asm volatile("\n->" #sym " %0 " #val : : "i" (val))
+	asm volatile("\n->" #sym " %0 " #val : : "i" (val))
 
 #define STR(x) #x
 #define DEFINE_STR(sym, val) asm volatile("\n->" #sym " " STR(val) " " #val: : )
diff --git a/arch/um/sys-x86_64/kernel-offsets.c b/arch/um/include/sysdep-x86_64/kernel-offsets.h
similarity index 89%
rename from arch/um/sys-x86_64/kernel-offsets.c
rename to arch/um/include/sysdep-x86_64/kernel-offsets.h
index bfcb104..5ce93ab 100644
--- a/arch/um/sys-x86_64/kernel-offsets.c
+++ b/arch/um/include/sysdep-x86_64/kernel-offsets.h
@@ -6,7 +6,7 @@
 #include <asm/page.h>
 
 #define DEFINE(sym, val) \
-        asm volatile("\n->" #sym " %0 " #val : : "i" (val))
+	asm volatile("\n->" #sym " %0 " #val : : "i" (val))
 
 #define DEFINE_STR1(x) #x
 #define DEFINE_STR(sym, val) asm volatile("\n->" #sym " " DEFINE_STR1(val) " " #val: : )
diff --git a/arch/um/kernel/asm-offsets.c b/arch/um/kernel/asm-offsets.c
index c13a64a..91ea538 100644
--- a/arch/um/kernel/asm-offsets.c
+++ b/arch/um/kernel/asm-offsets.c
@@ -1 +1 @@
-/* Dummy file to make kbuild happy - unused! */
+#include "sysdep/kernel-offsets.h"
diff --git a/arch/um/kernel/skas/process.c b/arch/um/kernel/skas/process.c
index 9264d40..3b3955d 100644
--- a/arch/um/kernel/skas/process.c
+++ b/arch/um/kernel/skas/process.c
@@ -68,7 +68,7 @@
 
         if((n < 0) || !WIFSTOPPED(status) ||
            (WSTOPSIG(status) != SIGUSR1 && WSTOPSIG(status) != SIGTRAP)){
-		unsigned long regs[FRAME_SIZE];
+		unsigned long regs[HOST_FRAME_SIZE];
 		if(ptrace(PTRACE_GETREGS, pid, 0, regs) < 0)
 			printk("Failed to get registers from stub, "
 			       "errno = %d\n", errno);
@@ -76,7 +76,7 @@
 			int i;
 
 			printk("Stub registers -\n");
-			for(i = 0; i < FRAME_SIZE; i++)
+			for(i = 0; i < HOST_FRAME_SIZE; i++)
 				printk("\t%d - %lx\n", i, regs[i]);
 		}
                 panic("%s : failed to wait for SIGUSR1/SIGTRAP, "
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
index 73747ac..e2d3ca4 100644
--- a/arch/um/kernel/um_arch.c
+++ b/arch/um/kernel/um_arch.c
@@ -243,10 +243,6 @@
 	return(0);
 }
 
-#else
-
-#error Either CONFIG_MODE_TT or CONFIG_MODE_SKAS must be enabled
-
 #endif
 #endif
 #endif
diff --git a/arch/x86_64/Kconfig b/arch/x86_64/Kconfig
index 348b4a0..2efc4be 100644
--- a/arch/x86_64/Kconfig
+++ b/arch/x86_64/Kconfig
@@ -69,12 +69,34 @@
 	bool
 	default y
 
+config DMI
+	bool
+	default y
+
 source "init/Kconfig"
 
 
 menu "Processor type and features"
 
 choice
+	prompt "Subarchitecture Type"
+	default X86_PC
+
+config X86_PC
+	bool "PC-compatible"
+	help
+	  Choose this option if your computer is a standard PC or compatible.
+
+config X86_VSMP
+	bool "Support for ScaleMP vSMP"
+	 help
+	  Support for ScaleMP vSMP systems.  Say 'Y' here if this kernel is
+	  supposed to run on these EM64T-based machines.  Only choose this option
+	  if you have one of these machines.
+
+endchoice
+
+choice
 	prompt "Processor family"
 	default MK8
 
@@ -347,32 +369,24 @@
 	depends on HPET_TIMER && RTC=y
 
 config GART_IOMMU
-	bool "IOMMU support"
+	bool "K8 GART IOMMU support"
 	default y
+	select SWIOTLB
 	depends on PCI
 	help
 	  Support the IOMMU. Needed to run systems with more than 3GB of memory
 	  properly with 32-bit PCI devices that do not support DAC (Double Address
 	  Cycle). The IOMMU can be turned off at runtime with the iommu=off parameter.
 	  Normally the kernel will take the right choice by itself.
-	  This option includes a driver for the AMD Opteron/Athlon64 IOMMU
-	  and a software emulation used on some other systems.
+	  This option includes a driver for the AMD Opteron/Athlon64 northbridge IOMMU
+	  and a software emulation used on other systems.
 	  If unsure, say Y.
 
 # need this always enabled with GART_IOMMU for the VIA workaround
 config SWIOTLB
-       bool
-       depends on GART_IOMMU
-       default y
-
-config DUMMY_IOMMU
 	bool
-	depends on !GART_IOMMU && !SWIOTLB
 	default y
-	help
-	  Don't use IOMMU code. This will cause problems when you have more than 4GB
-	  of memory and any 32-bit devices. Don't turn on unless you know what you
-	  are doing.
+	depends on GART_IOMMU
 
 config X86_MCE
 	bool "Machine check support" if EMBEDDED
diff --git a/arch/x86_64/Makefile b/arch/x86_64/Makefile
index 51d8328..d7fd464 100644
--- a/arch/x86_64/Makefile
+++ b/arch/x86_64/Makefile
@@ -31,6 +31,7 @@
 cflags-$(CONFIG_MPSC) += $(call cc-option,-march=nocona)
 CFLAGS += $(cflags-y)
 
+CFLAGS += -m64
 CFLAGS += -mno-red-zone
 CFLAGS += -mcmodel=kernel
 CFLAGS += -pipe
@@ -38,8 +39,10 @@
 # actually it makes the kernel smaller too.
 CFLAGS += -fno-reorder-blocks	
 CFLAGS += -Wno-sign-compare
-ifneq ($(CONFIG_DEBUG_INFO),y)
+ifneq ($(CONFIG_UNWIND_INFO),y)
 CFLAGS += -fno-asynchronous-unwind-tables
+endif
+ifneq ($(CONFIG_DEBUG_INFO),y)
 # -fweb shrinks the kernel a bit, but the difference is very small
 # it also messes up debugging, so don't use it for now.
 #CFLAGS += $(call cc-option,-fweb)
@@ -50,6 +53,8 @@
 # prevent gcc from generating any FP code by mistake
 CFLAGS += $(call cc-option,-mno-sse -mno-mmx -mno-sse2 -mno-3dnow,)
 
+AFLAGS += -m64
+
 head-y := arch/x86_64/kernel/head.o arch/x86_64/kernel/head64.o arch/x86_64/kernel/init_task.o
 
 libs-y 					+= arch/x86_64/lib/
diff --git a/arch/x86_64/defconfig b/arch/x86_64/defconfig
index 5d56542..054dcd8 100644
--- a/arch/x86_64/defconfig
+++ b/arch/x86_64/defconfig
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.14-git7
-# Sat Nov  5 15:55:50 2005
+# Linux kernel version: 2.6.15-git7
+# Wed Jan 11 11:57:36 2006
 #
 CONFIG_X86_64=y
 CONFIG_64BIT=y
@@ -15,6 +15,7 @@
 CONFIG_GENERIC_ISA_DMA=y
 CONFIG_GENERIC_IOMAP=y
 CONFIG_ARCH_MAY_HAVE_PC_FDC=y
+CONFIG_DMI=y
 
 #
 # Code maturity level options
@@ -35,18 +36,21 @@
 # CONFIG_BSD_PROCESS_ACCT is not set
 CONFIG_SYSCTL=y
 # CONFIG_AUDIT is not set
-CONFIG_HOTPLUG=y
-CONFIG_KOBJECT_UEVENT=y
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
 # CONFIG_CPUSETS is not set
 CONFIG_INITRAMFS_SOURCE=""
+CONFIG_UID16=y
+CONFIG_VM86=y
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
 # CONFIG_EMBEDDED is not set
 CONFIG_KALLSYMS=y
 CONFIG_KALLSYMS_ALL=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_HOTPLUG=y
 CONFIG_PRINTK=y
 CONFIG_BUG=y
+CONFIG_ELF_CORE=y
 CONFIG_BASE_FULL=y
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
@@ -55,8 +59,10 @@
 CONFIG_CC_ALIGN_LABELS=0
 CONFIG_CC_ALIGN_LOOPS=0
 CONFIG_CC_ALIGN_JUMPS=0
+CONFIG_SLAB=y
 # CONFIG_TINY_SHMEM is not set
 CONFIG_BASE_SMALL=0
+# CONFIG_SLOB is not set
 
 #
 # Loadable module support
@@ -71,8 +77,28 @@
 CONFIG_STOP_MACHINE=y
 
 #
+# Block layer
+#
+CONFIG_LBD=y
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+# CONFIG_IOSCHED_AS is not set
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+# CONFIG_DEFAULT_AS is not set
+# CONFIG_DEFAULT_DEADLINE is not set
+CONFIG_DEFAULT_CFQ=y
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="cfq"
+
+#
 # Processor type and features
 #
+CONFIG_X86_PC=y
+# CONFIG_X86_VSMP is not set
 # CONFIG_MK8 is not set
 # CONFIG_MPSC is not set
 CONFIG_GENERIC_CPU=y
@@ -89,14 +115,14 @@
 CONFIG_MTRR=y
 CONFIG_SMP=y
 CONFIG_SCHED_SMT=y
-CONFIG_PREEMPT_NONE=y
-# CONFIG_PREEMPT_VOLUNTARY is not set
+# CONFIG_PREEMPT_NONE is not set
+CONFIG_PREEMPT_VOLUNTARY=y
 # CONFIG_PREEMPT is not set
 CONFIG_PREEMPT_BKL=y
 CONFIG_NUMA=y
 CONFIG_K8_NUMA=y
 CONFIG_X86_64_ACPI_NUMA=y
-# CONFIG_NUMA_EMU is not set
+CONFIG_NUMA_EMU=y
 CONFIG_ARCH_DISCONTIGMEM_ENABLE=y
 CONFIG_ARCH_DISCONTIGMEM_DEFAULT=y
 CONFIG_ARCH_SPARSEMEM_ENABLE=y
@@ -109,6 +135,7 @@
 CONFIG_NEED_MULTIPLE_NODES=y
 # CONFIG_SPARSEMEM_STATIC is not set
 CONFIG_SPLIT_PTLOCK_CPUS=4
+CONFIG_MIGRATION=y
 CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID=y
 CONFIG_NR_CPUS=32
 CONFIG_HOTPLUG_CPU=y
@@ -120,8 +147,9 @@
 CONFIG_X86_MCE=y
 CONFIG_X86_MCE_INTEL=y
 CONFIG_X86_MCE_AMD=y
-CONFIG_PHYSICAL_START=0x100000
 # CONFIG_KEXEC is not set
+# CONFIG_CRASH_DUMP is not set
+CONFIG_PHYSICAL_START=0x100000
 CONFIG_SECCOMP=y
 # CONFIG_HZ_100 is not set
 CONFIG_HZ_250=y
@@ -136,6 +164,7 @@
 # Power management options
 #
 CONFIG_PM=y
+# CONFIG_PM_LEGACY is not set
 # CONFIG_PM_DEBUG is not set
 CONFIG_SOFTWARE_SUSPEND=y
 CONFIG_PM_STD_PARTITION=""
@@ -152,7 +181,7 @@
 CONFIG_ACPI_BATTERY=y
 CONFIG_ACPI_BUTTON=y
 # CONFIG_ACPI_VIDEO is not set
-CONFIG_ACPI_HOTKEY=m
+# CONFIG_ACPI_HOTKEY is not set
 CONFIG_ACPI_FAN=y
 CONFIG_ACPI_PROCESSOR=y
 CONFIG_ACPI_HOTPLUG_CPU=y
@@ -205,7 +234,7 @@
 CONFIG_PCI_DIRECT=y
 CONFIG_PCI_MMCONFIG=y
 CONFIG_UNORDERED_IO=y
-# CONFIG_PCIEPORTBUS is not set
+CONFIG_PCIEPORTBUS=y
 CONFIG_PCI_MSI=y
 # CONFIG_PCI_LEGACY_PROC is not set
 # CONFIG_PCI_DEBUG is not set
@@ -229,7 +258,6 @@
 CONFIG_IA32_AOUT=y
 CONFIG_COMPAT=y
 CONFIG_SYSVIPC_COMPAT=y
-CONFIG_UID16=y
 
 #
 # Networking
@@ -294,8 +322,11 @@
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
 # CONFIG_NET_SCHED is not set
-# CONFIG_NET_CLS_ROUTE is not set
 
 #
 # Network testing
@@ -315,7 +346,7 @@
 #
 CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
-# CONFIG_FW_LOADER is not set
+CONFIG_FW_LOADER=y
 # CONFIG_DEBUG_DRIVER is not set
 
 #
@@ -356,21 +387,7 @@
 CONFIG_BLK_DEV_RAM_COUNT=16
 CONFIG_BLK_DEV_RAM_SIZE=4096
 CONFIG_BLK_DEV_INITRD=y
-CONFIG_LBD=y
 # CONFIG_CDROM_PKTCDVD is not set
-
-#
-# IO Schedulers
-#
-CONFIG_IOSCHED_NOOP=y
-# CONFIG_IOSCHED_AS is not set
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
-# CONFIG_DEFAULT_AS is not set
-CONFIG_DEFAULT_DEADLINE=y
-# CONFIG_DEFAULT_CFQ is not set
-# CONFIG_DEFAULT_NOOP is not set
-CONFIG_DEFAULT_IOSCHED="cfq"
 # CONFIG_ATA_OVER_ETH is not set
 
 #
@@ -410,7 +427,7 @@
 # CONFIG_BLK_DEV_AEC62XX is not set
 # CONFIG_BLK_DEV_ALI15X3 is not set
 CONFIG_BLK_DEV_AMD74XX=y
-# CONFIG_BLK_DEV_ATIIXP is not set
+CONFIG_BLK_DEV_ATIIXP=y
 # CONFIG_BLK_DEV_CMD64X is not set
 # CONFIG_BLK_DEV_TRIFLEX is not set
 # CONFIG_BLK_DEV_CY82C693 is not set
@@ -458,20 +475,21 @@
 # Some SCSI devices (e.g. CD jukebox) support multiple LUNs
 #
 # CONFIG_SCSI_MULTI_LUN is not set
-# CONFIG_SCSI_CONSTANTS is not set
+CONFIG_SCSI_CONSTANTS=y
 # CONFIG_SCSI_LOGGING is not set
 
 #
 # SCSI Transport Attributes
 #
 CONFIG_SCSI_SPI_ATTRS=y
-# CONFIG_SCSI_FC_ATTRS is not set
+CONFIG_SCSI_FC_ATTRS=y
 # CONFIG_SCSI_ISCSI_ATTRS is not set
 # CONFIG_SCSI_SAS_ATTRS is not set
 
 #
 # SCSI low-level drivers
 #
+# CONFIG_ISCSI_TCP is not set
 # CONFIG_BLK_DEV_3W_XXXX_RAID is not set
 # CONFIG_SCSI_3W_9XXX is not set
 # CONFIG_SCSI_ACARD is not set
@@ -485,11 +503,13 @@
 # CONFIG_AIC79XX_DEBUG_ENABLE is not set
 CONFIG_AIC79XX_DEBUG_MASK=0
 # CONFIG_AIC79XX_REG_PRETTY_PRINT is not set
-# CONFIG_MEGARAID_NEWGEN is not set
+CONFIG_MEGARAID_NEWGEN=y
+CONFIG_MEGARAID_MM=y
+CONFIG_MEGARAID_MAILBOX=y
 # CONFIG_MEGARAID_LEGACY is not set
-# CONFIG_MEGARAID_SAS is not set
+CONFIG_MEGARAID_SAS=y
 CONFIG_SCSI_SATA=y
-# CONFIG_SCSI_SATA_AHCI is not set
+CONFIG_SCSI_SATA_AHCI=y
 # CONFIG_SCSI_SATA_SVW is not set
 CONFIG_SCSI_ATA_PIIX=y
 # CONFIG_SCSI_SATA_MV is not set
@@ -498,7 +518,7 @@
 # CONFIG_SCSI_SATA_QSTOR is not set
 # CONFIG_SCSI_SATA_PROMISE is not set
 # CONFIG_SCSI_SATA_SX4 is not set
-# CONFIG_SCSI_SATA_SIL is not set
+CONFIG_SCSI_SATA_SIL=y
 # CONFIG_SCSI_SATA_SIL24 is not set
 # CONFIG_SCSI_SATA_SIS is not set
 # CONFIG_SCSI_SATA_ULI is not set
@@ -518,12 +538,7 @@
 # CONFIG_SCSI_QLOGIC_FC is not set
 # CONFIG_SCSI_QLOGIC_1280 is not set
 CONFIG_SCSI_QLA2XXX=y
-# CONFIG_SCSI_QLA21XX is not set
-# CONFIG_SCSI_QLA22XX is not set
-# CONFIG_SCSI_QLA2300 is not set
-# CONFIG_SCSI_QLA2322 is not set
-# CONFIG_SCSI_QLA6312 is not set
-# CONFIG_SCSI_QLA24XX is not set
+# CONFIG_SCSI_QLA2XXX_EMBEDDED_FIRMWARE is not set
 # CONFIG_SCSI_LPFC is not set
 # CONFIG_SCSI_DC395x is not set
 # CONFIG_SCSI_DC390T is not set
@@ -633,6 +648,7 @@
 # CONFIG_R8169 is not set
 # CONFIG_SIS190 is not set
 # CONFIG_SKGE is not set
+# CONFIG_SKY2 is not set
 # CONFIG_SK98LIN is not set
 # CONFIG_VIA_VELOCITY is not set
 CONFIG_TIGON3=y
@@ -645,7 +661,6 @@
 # CONFIG_IXGB is not set
 CONFIG_S2IO=m
 # CONFIG_S2IO_NAPI is not set
-# CONFIG_2BUFF_MODE is not set
 
 #
 # Token Ring devices
@@ -744,6 +759,7 @@
 CONFIG_SERIAL_8250_CONSOLE=y
 # CONFIG_SERIAL_8250_ACPI is not set
 CONFIG_SERIAL_8250_NR_UARTS=4
+CONFIG_SERIAL_8250_RUNTIME_UARTS=4
 # CONFIG_SERIAL_8250_EXTENDED is not set
 
 #
@@ -751,7 +767,6 @@
 #
 CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
-# CONFIG_SERIAL_JSM is not set
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
@@ -817,10 +832,10 @@
 # CONFIG_DRM is not set
 # CONFIG_MWAVE is not set
 CONFIG_RAW_DRIVER=y
+CONFIG_MAX_RAW_DEVS=256
 CONFIG_HPET=y
 # CONFIG_HPET_RTC_IRQ is not set
 CONFIG_HPET_MMAP=y
-CONFIG_MAX_RAW_DEVS=256
 # CONFIG_HANGCHECK_TIMER is not set
 
 #
@@ -892,6 +907,7 @@
 # Open Sound System
 #
 CONFIG_SOUND_PRIME=y
+CONFIG_OBSOLETE_OSS_DRIVER=y
 # CONFIG_SOUND_BT878 is not set
 # CONFIG_SOUND_CMPCI is not set
 # CONFIG_SOUND_EMU10K1 is not set
@@ -968,7 +984,8 @@
 # CONFIG_USB_STORAGE_SDDR09 is not set
 # CONFIG_USB_STORAGE_SDDR55 is not set
 # CONFIG_USB_STORAGE_JUMPSHOT is not set
-# CONFIG_USB_STORAGE_ONETOUCH is not set
+# CONFIG_USB_STORAGE_ALAUDA is not set
+# CONFIG_USB_LIBUSUAL is not set
 
 #
 # USB Input Devices
@@ -988,6 +1005,7 @@
 # CONFIG_USB_YEALINK is not set
 # CONFIG_USB_XPAD is not set
 # CONFIG_USB_ATI_REMOTE is not set
+# CONFIG_USB_ATI_REMOTE2 is not set
 # CONFIG_USB_KEYSPAN_REMOTE is not set
 # CONFIG_USB_APPLETOUCH is not set
 
@@ -1097,6 +1115,7 @@
 # CONFIG_JFS_FS is not set
 CONFIG_FS_POSIX_ACL=y
 # CONFIG_XFS_FS is not set
+# CONFIG_OCFS2_FS is not set
 # CONFIG_MINIX_FS is not set
 # CONFIG_ROMFS_FS is not set
 CONFIG_INOTIFY=y
@@ -1135,6 +1154,7 @@
 CONFIG_HUGETLB_PAGE=y
 CONFIG_RAMFS=y
 CONFIG_RELAYFS_FS=y
+# CONFIG_CONFIGFS_FS is not set
 
 #
 # Miscellaneous filesystems
@@ -1232,21 +1252,23 @@
 CONFIG_NLS_UTF8=y
 
 #
-# Profiling support
+# Instrumentation Support
 #
 CONFIG_PROFILING=y
 CONFIG_OPROFILE=y
+CONFIG_KPROBES=y
 
 #
 # Kernel hacking
 #
 # CONFIG_PRINTK_TIME is not set
-CONFIG_DEBUG_KERNEL=y
 CONFIG_MAGIC_SYSRQ=y
+CONFIG_DEBUG_KERNEL=y
 CONFIG_LOG_BUF_SHIFT=18
 CONFIG_DETECT_SOFTLOCKUP=y
 # CONFIG_SCHEDSTATS is not set
 # CONFIG_DEBUG_SLAB is not set
+# CONFIG_DEBUG_MUTEXES is not set
 # CONFIG_DEBUG_SPINLOCK is not set
 # CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 # CONFIG_DEBUG_KOBJECT is not set
@@ -1256,8 +1278,8 @@
 # CONFIG_FRAME_POINTER is not set
 # CONFIG_RCU_TORTURE_TEST is not set
 CONFIG_INIT_DEBUG=y
+# CONFIG_DEBUG_RODATA is not set
 # CONFIG_IOMMU_DEBUG is not set
-CONFIG_KPROBES=y
 
 #
 # Security options
diff --git a/arch/x86_64/ia32/ia32_signal.c b/arch/x86_64/ia32/ia32_signal.c
index 0903cc1..e0a9243 100644
--- a/arch/x86_64/ia32/ia32_signal.c
+++ b/arch/x86_64/ia32/ia32_signal.c
@@ -353,7 +353,6 @@
 		 struct pt_regs *regs, unsigned int mask)
 {
 	int tmp, err = 0;
-	u32 eflags;
 
 	tmp = 0;
 	__asm__("movl %%gs,%0" : "=r"(tmp): "0"(tmp));
@@ -378,10 +377,7 @@
 	err |= __put_user(current->thread.trap_no, &sc->trapno);
 	err |= __put_user(current->thread.error_code, &sc->err);
 	err |= __put_user((u32)regs->rip, &sc->eip);
-	eflags = regs->eflags;
-	if (current->ptrace & PT_PTRACED)
-		eflags &= ~TF_MASK;
-	err |= __put_user((u32)eflags, &sc->eflags);
+	err |= __put_user((u32)regs->eflags, &sc->eflags);
 	err |= __put_user((u32)regs->rsp, &sc->esp_at_signal);
 
 	tmp = save_i387_ia32(current, fpstate, regs, 0);
@@ -505,13 +501,9 @@
 	regs->ss = __USER32_DS; 
 
 	set_fs(USER_DS);
-	if (regs->eflags & TF_MASK) {
-		if (current->ptrace & PT_PTRACED) {
-			ptrace_notify(SIGTRAP);
-		} else {
-			regs->eflags &= ~TF_MASK;
-		}
-	}
+    regs->eflags &= ~TF_MASK;
+    if (test_thread_flag(TIF_SINGLESTEP))
+        ptrace_notify(SIGTRAP);
 
 #if DEBUG_SIG
 	printk("SIG deliver (%s:%d): sp=%p pc=%p ra=%p\n",
@@ -605,13 +597,9 @@
 	regs->ss = __USER32_DS; 
 
 	set_fs(USER_DS);
-	if (regs->eflags & TF_MASK) {
-		if (current->ptrace & PT_PTRACED) {
-			ptrace_notify(SIGTRAP);
-		} else {
-			regs->eflags &= ~TF_MASK;
-		}
-	}
+    regs->eflags &= ~TF_MASK;
+    if (test_thread_flag(TIF_SINGLESTEP))
+        ptrace_notify(SIGTRAP);
 
 #if DEBUG_SIG
 	printk("SIG deliver (%s:%d): sp=%p pc=%p ra=%p\n",
diff --git a/arch/x86_64/ia32/ia32entry.S b/arch/x86_64/ia32/ia32entry.S
index 2ff07b4..58f5bfb 100644
--- a/arch/x86_64/ia32/ia32entry.S
+++ b/arch/x86_64/ia32/ia32entry.S
@@ -35,6 +35,18 @@
 	movq	%rax,R8(%rsp)
 	.endm
 
+	.macro CFI_STARTPROC32 simple
+	CFI_STARTPROC	\simple
+	CFI_UNDEFINED	r8
+	CFI_UNDEFINED	r9
+	CFI_UNDEFINED	r10
+	CFI_UNDEFINED	r11
+	CFI_UNDEFINED	r12
+	CFI_UNDEFINED	r13
+	CFI_UNDEFINED	r14
+	CFI_UNDEFINED	r15
+	.endm
+
 /*
  * 32bit SYSENTER instruction entry.
  *
@@ -55,7 +67,7 @@
  * with the int 0x80 path.
  */ 	
 ENTRY(ia32_sysenter_target)
-	CFI_STARTPROC	simple
+	CFI_STARTPROC32	simple
 	CFI_DEF_CFA	rsp,0
 	CFI_REGISTER	rsp,rbp
 	swapgs
@@ -92,6 +104,7 @@
  	.quad 1b,ia32_badarg
  	.previous	
 	GET_THREAD_INFO(%r10)
+	orl    $TS_COMPAT,threadinfo_status(%r10)
 	testl  $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)
 	CFI_REMEMBER_STATE
 	jnz  sysenter_tracesys
@@ -105,6 +118,7 @@
 	cli
 	testl	$_TIF_ALLWORK_MASK,threadinfo_flags(%r10)
 	jnz	int_ret_from_sys_call
+	andl    $~TS_COMPAT,threadinfo_status(%r10)
 	/* clear IF, that popfq doesn't enable interrupts early */
 	andl  $~0x200,EFLAGS-R11(%rsp) 
 	RESTORE_ARGS 1,24,1,1,1,1
@@ -161,7 +175,7 @@
  * with the int 0x80 path.	
  */ 	
 ENTRY(ia32_cstar_target)
-	CFI_STARTPROC	simple
+	CFI_STARTPROC32	simple
 	CFI_DEF_CFA	rsp,0
 	CFI_REGISTER	rip,rcx
 	/*CFI_REGISTER	rflags,r11*/
@@ -191,6 +205,7 @@
 	.quad 1b,ia32_badarg
 	.previous	
 	GET_THREAD_INFO(%r10)
+	orl   $TS_COMPAT,threadinfo_status(%r10)
 	testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)
 	CFI_REMEMBER_STATE
 	jnz   cstar_tracesys
@@ -204,6 +219,7 @@
 	cli
 	testl $_TIF_ALLWORK_MASK,threadinfo_flags(%r10)
 	jnz  int_ret_from_sys_call
+	andl $~TS_COMPAT,threadinfo_status(%r10)
 	RESTORE_ARGS 1,-ARG_SKIP,1,1,1
 	movl RIP-ARGOFFSET(%rsp),%ecx
 	CFI_REGISTER rip,rcx
@@ -276,6 +292,7 @@
 	   this could be a problem. */
 	SAVE_ARGS 0,0,1
 	GET_THREAD_INFO(%r10)
+	orl   $TS_COMPAT,threadinfo_status(%r10)
 	testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)
 	jnz ia32_tracesys
 ia32_do_syscall:	
@@ -318,7 +335,7 @@
 	jmp  ia32_ptregs_common	
 	.endm
 
-	CFI_STARTPROC
+	CFI_STARTPROC32
 
 	PTREGSCALL stub32_rt_sigreturn, sys32_rt_sigreturn, %rdi
 	PTREGSCALL stub32_sigreturn, sys32_sigreturn, %rdi
@@ -333,8 +350,19 @@
 
 ENTRY(ia32_ptregs_common)
 	popq %r11
-	CFI_ADJUST_CFA_OFFSET -8
-	CFI_REGISTER rip, r11
+	CFI_ENDPROC
+	CFI_STARTPROC32	simple
+	CFI_DEF_CFA	rsp,SS+8-ARGOFFSET
+	CFI_REL_OFFSET	rax,RAX-ARGOFFSET
+	CFI_REL_OFFSET	rcx,RCX-ARGOFFSET
+	CFI_REL_OFFSET	rdx,RDX-ARGOFFSET
+	CFI_REL_OFFSET	rsi,RSI-ARGOFFSET
+	CFI_REL_OFFSET	rdi,RDI-ARGOFFSET
+	CFI_REL_OFFSET	rip,RIP-ARGOFFSET
+/*	CFI_REL_OFFSET	cs,CS-ARGOFFSET*/
+/*	CFI_REL_OFFSET	rflags,EFLAGS-ARGOFFSET*/
+	CFI_REL_OFFSET	rsp,RSP-ARGOFFSET
+/*	CFI_REL_OFFSET	ss,SS-ARGOFFSET*/
 	SAVE_REST
 	call *%rax
 	RESTORE_REST
diff --git a/arch/x86_64/ia32/ptrace32.c b/arch/x86_64/ia32/ptrace32.c
index 5f4cdfa..ea4394e 100644
--- a/arch/x86_64/ia32/ptrace32.c
+++ b/arch/x86_64/ia32/ptrace32.c
@@ -28,9 +28,12 @@
 #include <asm/i387.h>
 #include <asm/fpu32.h>
 
-/* determines which flags the user has access to. */
-/* 1 = access 0 = no access */
-#define FLAG_MASK 0x44dd5UL
+/*
+ * Determines which flags the user has access to [1 = access, 0 = no access].
+ * Prohibits changing ID(21), VIP(20), VIF(19), VM(17), IOPL(12-13), IF(9).
+ * Also masks reserved bits (31-22, 15, 5, 3, 1).
+ */
+#define FLAG_MASK 0x54dd5UL
 
 #define R32(l,q) \
 	case offsetof(struct user32, regs.l): stack[offsetof(struct pt_regs, q)/8] = val; break
diff --git a/arch/x86_64/ia32/vsyscall-sigreturn.S b/arch/x86_64/ia32/vsyscall-sigreturn.S
index 8b5a4b0..d90321f 100644
--- a/arch/x86_64/ia32/vsyscall-sigreturn.S
+++ b/arch/x86_64/ia32/vsyscall-sigreturn.S
@@ -7,6 +7,7 @@
  * by doing ".balign 32" must match in both versions of the page.
  */
 
+	.code32
 	.section .text.sigreturn,"ax"
 	.balign 32
 	.globl __kernel_sigreturn
diff --git a/arch/x86_64/ia32/vsyscall-syscall.S b/arch/x86_64/ia32/vsyscall-syscall.S
index b024965b..cf9ef67 100644
--- a/arch/x86_64/ia32/vsyscall-syscall.S
+++ b/arch/x86_64/ia32/vsyscall-syscall.S
@@ -6,6 +6,7 @@
 #include <asm/asm-offsets.h>
 #include <asm/segment.h>
 
+	.code32
 	.text
 	.section .text.vsyscall,"ax"
 	.globl __kernel_vsyscall
diff --git a/arch/x86_64/ia32/vsyscall-sysenter.S b/arch/x86_64/ia32/vsyscall-sysenter.S
index 71f3de5..ae056e5 100644
--- a/arch/x86_64/ia32/vsyscall-sysenter.S
+++ b/arch/x86_64/ia32/vsyscall-sysenter.S
@@ -5,6 +5,7 @@
 #include <asm/ia32_unistd.h>
 #include <asm/asm-offsets.h>
 
+	.code32
 	.text
 	.section .text.vsyscall,"ax"
 	.globl __kernel_vsyscall
diff --git a/arch/x86_64/kernel/Makefile b/arch/x86_64/kernel/Makefile
index 12bc540..72fe60c 100644
--- a/arch/x86_64/kernel/Makefile
+++ b/arch/x86_64/kernel/Makefile
@@ -7,7 +7,8 @@
 obj-y	:= process.o signal.o entry.o traps.o irq.o \
 		ptrace.o time.o ioport.o ldt.o setup.o i8259.o sys_x86_64.o \
 		x8664_ksyms.o i387.o syscall.o vsyscall.o \
-		setup64.o bootflag.o e820.o reboot.o quirks.o i8237.o
+		setup64.o bootflag.o e820.o reboot.o quirks.o i8237.o \
+		dmi_scan.o pci-dma.o pci-nommu.o
 
 obj-$(CONFIG_X86_MCE)         += mce.o
 obj-$(CONFIG_X86_MCE_INTEL)	+= mce_intel.o
@@ -28,9 +29,10 @@
 obj-$(CONFIG_CPU_FREQ)		+= cpufreq/
 obj-$(CONFIG_EARLY_PRINTK)	+= early_printk.o
 obj-$(CONFIG_GART_IOMMU)	+= pci-gart.o aperture.o
-obj-$(CONFIG_DUMMY_IOMMU)	+= pci-nommu.o pci-dma.o
+obj-$(CONFIG_SWIOTLB)		+= pci-swiotlb.o
 obj-$(CONFIG_KPROBES)		+= kprobes.o
 obj-$(CONFIG_X86_PM_TIMER)	+= pmtimer.o
+obj-$(CONFIG_X86_VSMP)		+= vsmp.o
 
 obj-$(CONFIG_MODULES)		+= module.o
 
@@ -47,3 +49,5 @@
 quirks-y			+= ../../i386/kernel/quirks.o
 i8237-y				+= ../../i386/kernel/i8237.o
 msr-$(subst m,y,$(CONFIG_X86_MSR))  += ../../i386/kernel/msr.o
+dmi_scan-y			+= ../../i386/kernel/dmi_scan.o
+
diff --git a/arch/x86_64/kernel/aperture.c b/arch/x86_64/kernel/aperture.c
index c7f4fdd..e4e2b7d 100644
--- a/arch/x86_64/kernel/aperture.c
+++ b/arch/x86_64/kernel/aperture.c
@@ -23,6 +23,7 @@
 #include <asm/io.h>
 #include <asm/proto.h>
 #include <asm/pci-direct.h>
+#include <asm/dma.h>
 
 int iommu_aperture;
 int iommu_aperture_disabled __initdata = 0;
@@ -247,7 +248,7 @@
 		/* Got the aperture from the AGP bridge */
 	} else if (swiotlb && !valid_agp) {
 		/* Do nothing */
-	} else if ((!no_iommu && end_pfn >= 0xffffffff>>PAGE_SHIFT) ||
+	} else if ((!no_iommu && end_pfn >= MAX_DMA32_PFN) ||
 		   force_iommu ||
 		   valid_agp ||
 		   fallback_aper_force) { 
diff --git a/arch/x86_64/kernel/apic.c b/arch/x86_64/kernel/apic.c
index 18691ce..8fdd089 100644
--- a/arch/x86_64/kernel/apic.c
+++ b/arch/x86_64/kernel/apic.c
@@ -25,6 +25,7 @@
 #include <linux/mc146818rtc.h>
 #include <linux/kernel_stat.h>
 #include <linux/sysdev.h>
+#include <linux/module.h>
 
 #include <asm/atomic.h>
 #include <asm/smp.h>
@@ -33,36 +34,36 @@
 #include <asm/pgalloc.h>
 #include <asm/mach_apic.h>
 #include <asm/nmi.h>
+#include <asm/idle.h>
 
 int apic_verbosity;
 
 int disable_apic_timer __initdata;
 
+/*
+ * cpu_mask that denotes the CPUs that needs timer interrupt coming in as
+ * IPIs in place of local APIC timers
+ */
+static cpumask_t timer_interrupt_broadcast_ipi_mask;
+
 /* Using APIC to generate smp_local_timer_interrupt? */
 int using_apic_timer = 0;
 
-static DEFINE_PER_CPU(int, prof_multiplier) = 1;
-static DEFINE_PER_CPU(int, prof_old_multiplier) = 1;
-static DEFINE_PER_CPU(int, prof_counter) = 1;
-
 static void apic_pm_activate(void);
 
 void enable_NMI_through_LVT0 (void * dummy)
 {
-	unsigned int v, ver;
+	unsigned int v;
 	
-	ver = apic_read(APIC_LVR);
-	ver = GET_APIC_VERSION(ver);
 	v = APIC_DM_NMI;                        /* unmask and set to NMI */
-	apic_write_around(APIC_LVT0, v);
+	apic_write(APIC_LVT0, v);
 }
 
 int get_maxlvt(void)
 {
-	unsigned int v, ver, maxlvt;
+	unsigned int v, maxlvt;
 
 	v = apic_read(APIC_LVR);
-	ver = GET_APIC_VERSION(v);
 	maxlvt = GET_APIC_MAXLVT(v);
 	return maxlvt;
 }
@@ -80,33 +81,33 @@
 	 */
 	if (maxlvt >= 3) {
 		v = ERROR_APIC_VECTOR; /* any non-zero vector will do */
-		apic_write_around(APIC_LVTERR, v | APIC_LVT_MASKED);
+		apic_write(APIC_LVTERR, v | APIC_LVT_MASKED);
 	}
 	/*
 	 * Careful: we have to set masks only first to deassert
 	 * any level-triggered sources.
 	 */
 	v = apic_read(APIC_LVTT);
-	apic_write_around(APIC_LVTT, v | APIC_LVT_MASKED);
+	apic_write(APIC_LVTT, v | APIC_LVT_MASKED);
 	v = apic_read(APIC_LVT0);
-	apic_write_around(APIC_LVT0, v | APIC_LVT_MASKED);
+	apic_write(APIC_LVT0, v | APIC_LVT_MASKED);
 	v = apic_read(APIC_LVT1);
-	apic_write_around(APIC_LVT1, v | APIC_LVT_MASKED);
+	apic_write(APIC_LVT1, v | APIC_LVT_MASKED);
 	if (maxlvt >= 4) {
 		v = apic_read(APIC_LVTPC);
-		apic_write_around(APIC_LVTPC, v | APIC_LVT_MASKED);
+		apic_write(APIC_LVTPC, v | APIC_LVT_MASKED);
 	}
 
 	/*
 	 * Clean APIC state for other OSs:
 	 */
-	apic_write_around(APIC_LVTT, APIC_LVT_MASKED);
-	apic_write_around(APIC_LVT0, APIC_LVT_MASKED);
-	apic_write_around(APIC_LVT1, APIC_LVT_MASKED);
+	apic_write(APIC_LVTT, APIC_LVT_MASKED);
+	apic_write(APIC_LVT0, APIC_LVT_MASKED);
+	apic_write(APIC_LVT1, APIC_LVT_MASKED);
 	if (maxlvt >= 3)
-		apic_write_around(APIC_LVTERR, APIC_LVT_MASKED);
+		apic_write(APIC_LVTERR, APIC_LVT_MASKED);
 	if (maxlvt >= 4)
-		apic_write_around(APIC_LVTPC, APIC_LVT_MASKED);
+		apic_write(APIC_LVTPC, APIC_LVT_MASKED);
 	v = GET_APIC_VERSION(apic_read(APIC_LVR));
 	apic_write(APIC_ESR, 0);
 	apic_read(APIC_ESR);
@@ -151,7 +152,7 @@
 		value &= ~APIC_VECTOR_MASK;
 		value |= APIC_SPIV_APIC_ENABLED;
 		value |= 0xf;
-		apic_write_around(APIC_SPIV, value);
+		apic_write(APIC_SPIV, value);
 
 		if (!virt_wire_setup) {
 			/* For LVT0 make it edge triggered, active high, external and enabled */
@@ -161,11 +162,11 @@
 				APIC_LVT_LEVEL_TRIGGER | APIC_LVT_MASKED );
 			value |= APIC_LVT_REMOTE_IRR | APIC_SEND_PENDING;
 			value = SET_APIC_DELIVERY_MODE(value, APIC_MODE_EXTINT);
-			apic_write_around(APIC_LVT0, value);
+			apic_write(APIC_LVT0, value);
 		}
 		else {
 			/* Disable LVT0 */
-			apic_write_around(APIC_LVT0, APIC_LVT_MASKED);
+			apic_write(APIC_LVT0, APIC_LVT_MASKED);
 		}
 
 		/* For LVT1 make it edge triggered, active high, nmi and enabled */
@@ -176,7 +177,7 @@
 			APIC_LVT_LEVEL_TRIGGER | APIC_LVT_MASKED);
 		value |= APIC_LVT_REMOTE_IRR | APIC_SEND_PENDING;
 		value = SET_APIC_DELIVERY_MODE(value, APIC_MODE_NMI);
-		apic_write_around(APIC_LVT1, value);
+		apic_write(APIC_LVT1, value);
 	}
 }
 
@@ -192,7 +193,7 @@
 	 */
 	value = apic_read(APIC_SPIV);
 	value &= ~APIC_SPIV_APIC_ENABLED;
-	apic_write_around(APIC_SPIV, value);
+	apic_write(APIC_SPIV, value);
 }
 
 /*
@@ -269,7 +270,7 @@
 	apic_wait_icr_idle();
 
 	apic_printk(APIC_DEBUG, "Synchronizing Arb IDs.\n");
-	apic_write_around(APIC_ICR, APIC_DEST_ALLINC | APIC_INT_LEVELTRIG
+	apic_write(APIC_ICR, APIC_DEST_ALLINC | APIC_INT_LEVELTRIG
 				| APIC_DM_INIT);
 }
 
@@ -280,7 +281,7 @@
  */
 void __init init_bsp_APIC(void)
 {
-	unsigned int value, ver;
+	unsigned int value;
 
 	/*
 	 * Don't do the setup now if we have a SMP BIOS as the
@@ -290,7 +291,6 @@
 		return;
 
 	value = apic_read(APIC_LVR);
-	ver = GET_APIC_VERSION(value);
 
 	/*
 	 * Do not trust the local APIC being empty at bootup.
@@ -305,22 +305,21 @@
 	value |= APIC_SPIV_APIC_ENABLED;
 	value |= APIC_SPIV_FOCUS_DISABLED;
 	value |= SPURIOUS_APIC_VECTOR;
-	apic_write_around(APIC_SPIV, value);
+	apic_write(APIC_SPIV, value);
 
 	/*
 	 * Set up the virtual wire mode.
 	 */
-	apic_write_around(APIC_LVT0, APIC_DM_EXTINT);
+	apic_write(APIC_LVT0, APIC_DM_EXTINT);
 	value = APIC_DM_NMI;
-	apic_write_around(APIC_LVT1, value);
+	apic_write(APIC_LVT1, value);
 }
 
 void __cpuinit setup_local_APIC (void)
 {
-	unsigned int value, ver, maxlvt;
+	unsigned int value, maxlvt;
 
 	value = apic_read(APIC_LVR);
-	ver = GET_APIC_VERSION(value);
 
 	if ((SPURIOUS_APIC_VECTOR & 0x0f) != 0x0f)
 		__error_in_apic_c();
@@ -345,7 +344,7 @@
 	 */
 	value = apic_read(APIC_TASKPRI);
 	value &= ~APIC_TPRI_MASK;
-	apic_write_around(APIC_TASKPRI, value);
+	apic_write(APIC_TASKPRI, value);
 
 	/*
 	 * Now that we are all set up, enable the APIC
@@ -387,7 +386,7 @@
 	 * Set spurious IRQ vector
 	 */
 	value |= SPURIOUS_APIC_VECTOR;
-	apic_write_around(APIC_SPIV, value);
+	apic_write(APIC_SPIV, value);
 
 	/*
 	 * Set up LVT0, LVT1:
@@ -407,7 +406,7 @@
 		value = APIC_DM_EXTINT | APIC_LVT_MASKED;
 		apic_printk(APIC_VERBOSE, "masked ExtINT on CPU#%d\n", smp_processor_id());
 	}
-	apic_write_around(APIC_LVT0, value);
+	apic_write(APIC_LVT0, value);
 
 	/*
 	 * only the BP should see the LINT1 NMI signal, obviously.
@@ -416,14 +415,14 @@
 		value = APIC_DM_NMI;
 	else
 		value = APIC_DM_NMI | APIC_LVT_MASKED;
-	apic_write_around(APIC_LVT1, value);
+	apic_write(APIC_LVT1, value);
 
 	{
 		unsigned oldvalue;
 		maxlvt = get_maxlvt();
 		oldvalue = apic_read(APIC_ESR);
 		value = ERROR_APIC_VECTOR;      // enables sending errors
-		apic_write_around(APIC_LVTERR, value);
+		apic_write(APIC_LVTERR, value);
 		/*
 		 * spec says clear errors after enabling vector.
 		 */
@@ -660,20 +659,25 @@
 static void __setup_APIC_LVTT(unsigned int clocks)
 {
 	unsigned int lvtt_value, tmp_value, ver;
+	int cpu = smp_processor_id();
 
 	ver = GET_APIC_VERSION(apic_read(APIC_LVR));
 	lvtt_value = APIC_LVT_TIMER_PERIODIC | LOCAL_TIMER_VECTOR;
-	apic_write_around(APIC_LVTT, lvtt_value);
+
+	if (cpu_isset(cpu, timer_interrupt_broadcast_ipi_mask))
+		lvtt_value |= APIC_LVT_MASKED;
+
+	apic_write(APIC_LVTT, lvtt_value);
 
 	/*
 	 * Divide PICLK by 16
 	 */
 	tmp_value = apic_read(APIC_TDCR);
-	apic_write_around(APIC_TDCR, (tmp_value
+	apic_write(APIC_TDCR, (tmp_value
 				& ~(APIC_TDR_DIV_1 | APIC_TDR_DIV_TMBASE))
 				| APIC_TDR_DIV_16);
 
-	apic_write_around(APIC_TMICT, clocks/APIC_DIVISOR);
+	apic_write(APIC_TMICT, clocks/APIC_DIVISOR);
 }
 
 static void setup_APIC_timer(unsigned int clocks)
@@ -682,12 +686,6 @@
 
 	local_irq_save(flags);
 
-	/* For some reasons this doesn't work on Simics, so fake it for now */ 
-	if (!strstr(boot_cpu_data.x86_model_id, "Screwdriver")) { 
-	__setup_APIC_LVTT(clocks);
-		return;
-	} 
-
 	/* wait for irq slice */
  	if (vxtime.hpet_address) {
  		int trigger = hpet_readl(HPET_T0_CMP);
@@ -700,7 +698,7 @@
 		outb_p(0x00, 0x43);
 		c2 = inb_p(0x40);
 		c2 |= inb_p(0x40) << 8;
-	do {
+		do {
 			c1 = c2;
 			outb_p(0x00, 0x43);
 			c2 = inb_p(0x40);
@@ -785,52 +783,68 @@
 	local_irq_enable();
 }
 
-void __cpuinit disable_APIC_timer(void)
+void disable_APIC_timer(void)
 {
 	if (using_apic_timer) {
 		unsigned long v;
 
 		v = apic_read(APIC_LVTT);
-		apic_write_around(APIC_LVTT, v | APIC_LVT_MASKED);
+		apic_write(APIC_LVTT, v | APIC_LVT_MASKED);
 	}
 }
 
 void enable_APIC_timer(void)
 {
-	if (using_apic_timer) {
+	int cpu = smp_processor_id();
+
+	if (using_apic_timer &&
+	    !cpu_isset(cpu, timer_interrupt_broadcast_ipi_mask)) {
 		unsigned long v;
 
 		v = apic_read(APIC_LVTT);
-		apic_write_around(APIC_LVTT, v & ~APIC_LVT_MASKED);
+		apic_write(APIC_LVTT, v & ~APIC_LVT_MASKED);
 	}
 }
 
-/*
- * the frequency of the profiling timer can be changed
- * by writing a multiplier value into /proc/profile.
- */
+void switch_APIC_timer_to_ipi(void *cpumask)
+{
+	cpumask_t mask = *(cpumask_t *)cpumask;
+	int cpu = smp_processor_id();
+
+	if (cpu_isset(cpu, mask) &&
+	    !cpu_isset(cpu, timer_interrupt_broadcast_ipi_mask)) {
+		disable_APIC_timer();
+		cpu_set(cpu, timer_interrupt_broadcast_ipi_mask);
+	}
+}
+EXPORT_SYMBOL(switch_APIC_timer_to_ipi);
+
+void smp_send_timer_broadcast_ipi(void)
+{
+	cpumask_t mask;
+
+	cpus_and(mask, cpu_online_map, timer_interrupt_broadcast_ipi_mask);
+	if (!cpus_empty(mask)) {
+		send_IPI_mask(mask, LOCAL_TIMER_VECTOR);
+	}
+}
+
+void switch_ipi_to_APIC_timer(void *cpumask)
+{
+	cpumask_t mask = *(cpumask_t *)cpumask;
+	int cpu = smp_processor_id();
+
+	if (cpu_isset(cpu, mask) &&
+	    cpu_isset(cpu, timer_interrupt_broadcast_ipi_mask)) {
+		cpu_clear(cpu, timer_interrupt_broadcast_ipi_mask);
+		enable_APIC_timer();
+	}
+}
+EXPORT_SYMBOL(switch_ipi_to_APIC_timer);
+
 int setup_profiling_timer(unsigned int multiplier)
 {
-	int i;
-
-	/*
-	 * Sanity check. [at least 500 APIC cycles should be
-	 * between APIC interrupts as a rule of thumb, to avoid
-	 * irqs flooding us]
-	 */
-	if ( (!multiplier) || (calibration_result/multiplier < 500))
-		return -EINVAL;
-
-	/* 
-	 * Set the new multiplier for each CPU. CPUs don't start using the
-	 * new values until the next timer interrupt in which they do process
-	 * accounting. At that time they also adjust their APIC timers
-	 * accordingly.
-	 */
-	for (i = 0; i < NR_CPUS; ++i)
-		per_cpu(prof_multiplier, i) = multiplier;
-
-	return 0;
+	return -EINVAL;
 }
 
 #ifdef CONFIG_X86_MCE_AMD
@@ -857,32 +871,10 @@
 
 void smp_local_timer_interrupt(struct pt_regs *regs)
 {
-	int cpu = smp_processor_id();
-
 	profile_tick(CPU_PROFILING, regs);
-	if (--per_cpu(prof_counter, cpu) <= 0) {
-		/*
-		 * The multiplier may have changed since the last time we got
-		 * to this point as a result of the user writing to
-		 * /proc/profile. In this case we need to adjust the APIC
-		 * timer accordingly.
-		 *
-		 * Interrupts are already masked off at this point.
-		 */
-		per_cpu(prof_counter, cpu) = per_cpu(prof_multiplier, cpu);
-		if (per_cpu(prof_counter, cpu) != 
-		    per_cpu(prof_old_multiplier, cpu)) {
-			__setup_APIC_LVTT(calibration_result/
-					per_cpu(prof_counter, cpu));
-			per_cpu(prof_old_multiplier, cpu) =
-				per_cpu(prof_counter, cpu);
-		}
-
 #ifdef CONFIG_SMP
-		update_process_times(user_mode(regs));
+	update_process_times(user_mode(regs));
 #endif
-	}
-
 	/*
 	 * We take the 'long' return path, and there every subsystem
 	 * grabs the appropriate locks (kernel lock/ irq lock).
@@ -920,6 +912,7 @@
 	 * Besides, if we don't timer interrupts ignore the global
 	 * interrupt lock, which is the WrongThing (tm) to do.
 	 */
+	exit_idle();
 	irq_enter();
 	smp_local_timer_interrupt(regs);
 	irq_exit();
@@ -979,6 +972,7 @@
 asmlinkage void smp_spurious_interrupt(void)
 {
 	unsigned int v;
+	exit_idle();
 	irq_enter();
 	/*
 	 * Check if this really is a spurious interrupt and ACK it
@@ -1014,6 +1008,7 @@
 {
 	unsigned int v, v1;
 
+	exit_idle();
 	irq_enter();
 	/* First tickle the hardware, only then report what went on. -- REW */
 	v = apic_read(APIC_ESR);
@@ -1060,7 +1055,7 @@
 	connect_bsp_APIC();
 
 	phys_cpu_present_map = physid_mask_of_physid(boot_cpu_id);
-	apic_write_around(APIC_ID, boot_cpu_id);
+	apic_write(APIC_ID, SET_APIC_ID(boot_cpu_id));
 
 	setup_local_APIC();
 
diff --git a/arch/x86_64/kernel/asm-offsets.c b/arch/x86_64/kernel/asm-offsets.c
index aaa6d38..cfb4f9c 100644
--- a/arch/x86_64/kernel/asm-offsets.c
+++ b/arch/x86_64/kernel/asm-offsets.c
@@ -33,6 +33,7 @@
 	ENTRY(flags);
 	ENTRY(addr_limit);
 	ENTRY(preempt_count);
+	ENTRY(status);
 	BLANK();
 #undef ENTRY
 #define ENTRY(entry) DEFINE(pda_ ## entry, offsetof(struct x8664_pda, entry))
@@ -64,5 +65,9 @@
 	DEFINE(pbe_address, offsetof(struct pbe, address));
 	DEFINE(pbe_orig_address, offsetof(struct pbe, orig_address));
 	DEFINE(pbe_next, offsetof(struct pbe, next));
+	BLANK();
+#if DEBUG_STKSZ > EXCEPTION_STKSZ
+	DEFINE(DEBUG_IST, DEBUG_STACK);
+#endif
 	return 0;
 }
diff --git a/arch/x86_64/kernel/early_printk.c b/arch/x86_64/kernel/early_printk.c
index 9cd968d..6dffb49 100644
--- a/arch/x86_64/kernel/early_printk.c
+++ b/arch/x86_64/kernel/early_printk.c
@@ -216,7 +216,7 @@
 	va_end(ap); 
 } 
 
-static int keep_early; 
+static int __initdata keep_early;
 
 int __init setup_early_printk(char *opt) 
 {  
@@ -226,8 +226,6 @@
 	if (early_console_initialized)
 		return -1;
 
-	opt = strchr(opt, '=') + 1;
-
 	strlcpy(buf,opt,sizeof(buf)); 
 	space = strchr(buf, ' '); 
 	if (space)
diff --git a/arch/x86_64/kernel/entry.S b/arch/x86_64/kernel/entry.S
index 9ff4204..632fc0f 100644
--- a/arch/x86_64/kernel/entry.S
+++ b/arch/x86_64/kernel/entry.S
@@ -313,6 +313,7 @@
 	movl threadinfo_flags(%rcx),%edx
 	andl %edi,%edx
 	jnz   int_careful
+	andl    $~TS_COMPAT,threadinfo_status(%rcx)
 	jmp   retint_swapgs
 
 	/* Either reschedule or signal or syscall exit tracking needed. */
@@ -673,7 +674,10 @@
 
 	/* error code is on the stack already */
 	/* handle NMI like exceptions that can happen everywhere */
-	.macro paranoidentry sym
+#ifndef DEBUG_IST
+# define DEBUG_IST 0
+#endif
+	.macro paranoidentry sym, ist=0
 	SAVE_ALL
 	cld
 	movl $1,%ebx
@@ -683,10 +687,20 @@
 	js    1f
 	swapgs
 	xorl  %ebx,%ebx
-1:	movq %rsp,%rdi
+1:
+	.if \ist
+	movq	%gs:pda_data_offset, %rbp
+	.endif
+	movq %rsp,%rdi
 	movq ORIG_RAX(%rsp),%rsi
 	movq $-1,ORIG_RAX(%rsp)
+	.if \ist
+	subq	$EXCEPTION_STACK_SIZE, per_cpu__init_tss + TSS_ist + (\ist - 1) * 8(%rbp)
+	.endif
 	call \sym
+	.if \ist
+	addq	$EXCEPTION_STACK_SIZE, per_cpu__init_tss + TSS_ist + (\ist - 1) * 8(%rbp)
+	.endif
 	cli
 	.endm
 	
@@ -754,7 +768,7 @@
 	jnz  retint_careful
 	swapgs 
 	RESTORE_ARGS 0,8,0						
-	iretq
+	jmp iret_label
 	CFI_ENDPROC
 
 error_kernelspace:
@@ -904,7 +918,7 @@
  	INTR_FRAME
 	pushq $0
 	CFI_ADJUST_CFA_OFFSET 8		
-	paranoidentry do_debug
+	paranoidentry do_debug, DEBUG_IST
 	jmp paranoid_exit
 	CFI_ENDPROC
 	.previous .text
@@ -959,7 +973,12 @@
 	CFI_ENDPROC
 
 KPROBE_ENTRY(int3)
-	zeroentry do_int3	
+ 	INTR_FRAME
+ 	pushq $0
+ 	CFI_ADJUST_CFA_OFFSET 8
+ 	paranoidentry do_int3, DEBUG_IST
+ 	jmp paranoid_exit
+ 	CFI_ENDPROC
 	.previous .text
 
 ENTRY(overflow)
@@ -1021,23 +1040,18 @@
 	CFI_ENDPROC
 #endif
 
-ENTRY(call_debug)
-       zeroentry do_call_debug
-
 ENTRY(call_softirq)
 	CFI_STARTPROC
 	movq %gs:pda_irqstackptr,%rax
-	pushq %r15
-	CFI_ADJUST_CFA_OFFSET 8
-	movq %rsp,%r15
-	CFI_DEF_CFA_REGISTER	r15
+	movq %rsp,%rdx
+	CFI_DEF_CFA_REGISTER	rdx
 	incl %gs:pda_irqcount
 	cmove %rax,%rsp
+	pushq %rdx
+	/*todo CFI_DEF_CFA_EXPRESSION ...*/
 	call __do_softirq
-	movq %r15,%rsp
+	popq %rsp
 	CFI_DEF_CFA_REGISTER	rsp
 	decl %gs:pda_irqcount
-	popq %r15
-	CFI_ADJUST_CFA_OFFSET -8
 	ret
 	CFI_ENDPROC
diff --git a/arch/x86_64/kernel/genapic_cluster.c b/arch/x86_64/kernel/genapic_cluster.c
index a472d62..43fcf62 100644
--- a/arch/x86_64/kernel/genapic_cluster.c
+++ b/arch/x86_64/kernel/genapic_cluster.c
@@ -72,14 +72,11 @@
 static void cluster_send_IPI_allbutself(int vector)
 {
 	cpumask_t mask = cpu_online_map;
-	int me = get_cpu(); /* Ensure we are not preempted when we clear */
 
-	cpu_clear(me, mask);
+	cpu_clear(smp_processor_id(), mask);
 
 	if (!cpus_empty(mask))
 		cluster_send_IPI_mask(mask, vector);
-
-	put_cpu();
 }
 
 static void cluster_send_IPI_all(int vector)
diff --git a/arch/x86_64/kernel/genapic_flat.c b/arch/x86_64/kernel/genapic_flat.c
index 9da3edb..1a2ab82 100644
--- a/arch/x86_64/kernel/genapic_flat.c
+++ b/arch/x86_64/kernel/genapic_flat.c
@@ -83,12 +83,11 @@
 		__send_IPI_shortcut(APIC_DEST_ALLBUT, vector,APIC_DEST_LOGICAL);
 #else
 	cpumask_t allbutme = cpu_online_map;
-	int me = get_cpu(); /* Ensure we are not preempted when we clear */
-	cpu_clear(me, allbutme);
+
+	cpu_clear(smp_processor_id(), allbutme);
 
 	if (!cpus_empty(allbutme))
 		flat_send_IPI_mask(allbutme, vector);
-	put_cpu();
 #endif
 }
 
@@ -149,10 +148,9 @@
 static void physflat_send_IPI_allbutself(int vector)
 {
 	cpumask_t allbutme = cpu_online_map;
-	int me = get_cpu();
-	cpu_clear(me, allbutme);
+
+	cpu_clear(smp_processor_id(), allbutme);
 	physflat_send_IPI_mask(allbutme, vector);
-	put_cpu();
 }
 
 static void physflat_send_IPI_all(int vector)
diff --git a/arch/x86_64/kernel/head.S b/arch/x86_64/kernel/head.S
index 1529096..38fc3d5 100644
--- a/arch/x86_64/kernel/head.S
+++ b/arch/x86_64/kernel/head.S
@@ -379,14 +379,14 @@
  * Also sysret mandates a special GDT layout 
  */
 		 		
-.align L1_CACHE_BYTES
+.align PAGE_SIZE
 
 /* The TLS descriptors are currently at a different place compared to i386.
    Hopefully nobody expects them at a fixed place (Wine?) */
 	
 ENTRY(cpu_gdt_table)
 	.quad	0x0000000000000000	/* NULL descriptor */
-	.quad	0x008f9a000000ffff	/* __KERNEL_COMPAT32_CS */	
+	.quad	0x0			/* unused */
 	.quad	0x00af9a000000ffff	/* __KERNEL_CS */
 	.quad	0x00cf92000000ffff	/* __KERNEL_DS */
 	.quad	0x00cffa000000ffff	/* __USER32_CS */
@@ -396,15 +396,15 @@
 	.quad	0,0			/* TSS */
 	.quad	0,0			/* LDT */
 	.quad   0,0,0			/* three TLS descriptors */ 
-	.quad	0x00009a000000ffff	/* __KERNEL16_CS - 16bit PM for S3 wakeup. */
-					/* base must be patched for real base address. */
+	.quad	0			/* unused */
 gdt_end:	
 	/* asm/segment.h:GDT_ENTRIES must match this */	
 	/* This should be a multiple of the cache line size */
-	/* GDTs of other CPUs: */	
-	.fill (GDT_SIZE * NR_CPUS) - (gdt_end - cpu_gdt_table)
+	/* GDTs of other CPUs are now dynamically allocated */
 
-	.align  L1_CACHE_BYTES
+	/* zero the remaining page */
+	.fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
+
 ENTRY(idt_table)	
 	.rept   256
 	.quad   0
diff --git a/arch/x86_64/kernel/head64.c b/arch/x86_64/kernel/head64.c
index b675c5a..cea20a6 100644
--- a/arch/x86_64/kernel/head64.c
+++ b/arch/x86_64/kernel/head64.c
@@ -92,6 +92,9 @@
 	memcpy(init_level4_pgt, boot_level4_pgt, PTRS_PER_PGD*sizeof(pgd_t));
 	asm volatile("movq %0,%%cr3" :: "r" (__pa_symbol(&init_level4_pgt)));
 
+ 	for (i = 0; i < NR_CPUS; i++)
+ 		cpu_pda(i) = &boot_cpu_pda[i];
+
 	pda_init(0);
 	copy_bootdata(real_mode_data);
 #ifdef CONFIG_SMP
@@ -99,7 +102,7 @@
 #endif
 	s = strstr(saved_command_line, "earlyprintk=");
 	if (s != NULL)
-		setup_early_printk(s);
+		setup_early_printk(strchr(s, '=') + 1);
 #ifdef CONFIG_NUMA
 	s = strstr(saved_command_line, "numa=");
 	if (s != NULL)
diff --git a/arch/x86_64/kernel/i8259.c b/arch/x86_64/kernel/i8259.c
index 6e5101a..b61965f 100644
--- a/arch/x86_64/kernel/i8259.c
+++ b/arch/x86_64/kernel/i8259.c
@@ -549,10 +549,9 @@
 		int vector = FIRST_EXTERNAL_VECTOR + i;
 		if (i >= NR_IRQS)
 			break;
-		if (vector != IA32_SYSCALL_VECTOR && vector != KDB_VECTOR) { 
+		if (vector != IA32_SYSCALL_VECTOR)
 			set_intr_gate(vector, interrupt[i]);
 	}
-	}
 
 #ifdef CONFIG_SMP
 	/*
diff --git a/arch/x86_64/kernel/io_apic.c b/arch/x86_64/kernel/io_apic.c
index 97154ab..e8cf44e 100644
--- a/arch/x86_64/kernel/io_apic.c
+++ b/arch/x86_64/kernel/io_apic.c
@@ -37,6 +37,7 @@
 #include <asm/proto.h>
 #include <asm/mach_apic.h>
 #include <asm/acpi.h>
+#include <asm/dma.h>
 
 #define __apicdebuginit  __init
 
@@ -46,6 +47,9 @@
 
 int disable_timer_pin_1 __initdata;
 
+/* Where if anywhere is the i8259 connect in external int mode */
+static struct { int pin, apic; } ioapic_i8259 = { -1, -1 };
+
 static DEFINE_SPINLOCK(ioapic_lock);
 
 /*
@@ -260,9 +264,6 @@
 void __init check_ioapic(void) 
 { 
 	int num,slot,func; 
-	if (ioapic_force) 
-		return; 
-
 	/* Poor man's PCI discovery */
 	for (num = 0; num < 32; num++) { 
 		for (slot = 0; slot < 32; slot++) { 
@@ -284,7 +285,7 @@
 				switch (vendor) { 
 				case PCI_VENDOR_ID_VIA:
 #ifdef CONFIG_GART_IOMMU
-					if ((end_pfn >= (0xffffffff>>PAGE_SHIFT) ||
+					if ((end_pfn > MAX_DMA32_PFN ||
 					     force_iommu) &&
 					    !iommu_aperture_allowed) {
 						printk(KERN_INFO
@@ -363,7 +364,7 @@
 /*
  * Find the pin to which IRQ[irq] (ISA) is connected
  */
-static int find_isa_irq_pin(int irq, int type)
+static int __init find_isa_irq_pin(int irq, int type)
 {
 	int i;
 
@@ -381,6 +382,31 @@
 	return -1;
 }
 
+static int __init find_isa_irq_apic(int irq, int type)
+{
+	int i;
+
+	for (i = 0; i < mp_irq_entries; i++) {
+		int lbus = mp_irqs[i].mpc_srcbus;
+
+		if ((mp_bus_id_to_type[lbus] == MP_BUS_ISA ||
+		     mp_bus_id_to_type[lbus] == MP_BUS_EISA ||
+		     mp_bus_id_to_type[lbus] == MP_BUS_MCA) &&
+		    (mp_irqs[i].mpc_irqtype == type) &&
+		    (mp_irqs[i].mpc_srcbusirq == irq))
+			break;
+	}
+	if (i < mp_irq_entries) {
+		int apic;
+		for(apic = 0; apic < nr_ioapics; apic++) {
+			if (mp_ioapics[apic].mpc_apicid == mp_irqs[i].mpc_dstapic)
+				return apic;
+		}
+	}
+
+	return -1;
+}
+
 /*
  * Find a specific PCI IRQ entry.
  * Not an __init, possibly needed by modules
@@ -874,7 +900,7 @@
  * Set up the 8259A-master output pin as broadcast to all
  * CPUs.
  */
-static void __init setup_ExtINT_IRQ0_pin(unsigned int pin, int vector)
+static void __init setup_ExtINT_IRQ0_pin(unsigned int apic, unsigned int pin, int vector)
 {
 	struct IO_APIC_route_entry entry;
 	unsigned long flags;
@@ -884,7 +910,7 @@
 	disable_8259A_irq(0);
 
 	/* mask LVT0 */
-	apic_write_around(APIC_LVT0, APIC_LVT_MASKED | APIC_DM_EXTINT);
+	apic_write(APIC_LVT0, APIC_LVT_MASKED | APIC_DM_EXTINT);
 
 	/*
 	 * We use logical delivery to get the timer IRQ
@@ -908,8 +934,8 @@
 	 * Add it to the IO-APIC irq-routing table:
 	 */
 	spin_lock_irqsave(&ioapic_lock, flags);
-	io_apic_write(0, 0x11+2*pin, *(((int *)&entry)+1));
-	io_apic_write(0, 0x10+2*pin, *(((int *)&entry)+0));
+	io_apic_write(apic, 0x11+2*pin, *(((int *)&entry)+1));
+	io_apic_write(apic, 0x10+2*pin, *(((int *)&entry)+0));
 	spin_unlock_irqrestore(&ioapic_lock, flags);
 
 	enable_8259A_irq(0);
@@ -1188,7 +1214,8 @@
 static void __init enable_IO_APIC(void)
 {
 	union IO_APIC_reg_01 reg_01;
-	int i;
+	int i8259_apic, i8259_pin;
+	int i, apic;
 	unsigned long flags;
 
 	for (i = 0; i < PIN_MAP_SIZE; i++) {
@@ -1202,11 +1229,48 @@
 	/*
 	 * The number of IO-APIC IRQ registers (== #pins):
 	 */
-	for (i = 0; i < nr_ioapics; i++) {
+	for (apic = 0; apic < nr_ioapics; apic++) {
 		spin_lock_irqsave(&ioapic_lock, flags);
-		reg_01.raw = io_apic_read(i, 1);
+		reg_01.raw = io_apic_read(apic, 1);
 		spin_unlock_irqrestore(&ioapic_lock, flags);
-		nr_ioapic_registers[i] = reg_01.bits.entries+1;
+		nr_ioapic_registers[apic] = reg_01.bits.entries+1;
+	}
+	for(apic = 0; apic < nr_ioapics; apic++) {
+		int pin;
+		/* See if any of the pins is in ExtINT mode */
+		for (pin = 0; pin < nr_ioapic_registers[apic]; pin++) {
+			struct IO_APIC_route_entry entry;
+			spin_lock_irqsave(&ioapic_lock, flags);
+			*(((int *)&entry) + 0) = io_apic_read(apic, 0x10 + 2 * pin);
+			*(((int *)&entry) + 1) = io_apic_read(apic, 0x11 + 2 * pin);
+			spin_unlock_irqrestore(&ioapic_lock, flags);
+
+
+			/* If the interrupt line is enabled and in ExtInt mode
+			 * I have found the pin where the i8259 is connected.
+			 */
+			if ((entry.mask == 0) && (entry.delivery_mode == dest_ExtINT)) {
+				ioapic_i8259.apic = apic;
+				ioapic_i8259.pin  = pin;
+				goto found_i8259;
+			}
+		}
+	}
+ found_i8259:
+	/* Look to see what if the MP table has reported the ExtINT */
+	i8259_pin  = find_isa_irq_pin(0, mp_ExtINT);
+	i8259_apic = find_isa_irq_apic(0, mp_ExtINT);
+	/* Trust the MP table if nothing is setup in the hardware */
+	if ((ioapic_i8259.pin == -1) && (i8259_pin >= 0)) {
+		printk(KERN_WARNING "ExtINT not setup in hardware but reported by MP table\n");
+		ioapic_i8259.pin  = i8259_pin;
+		ioapic_i8259.apic = i8259_apic;
+	}
+	/* Complain if the MP table and the hardware disagree */
+	if (((ioapic_i8259.apic != i8259_apic) || (ioapic_i8259.pin != i8259_pin)) &&
+		(i8259_pin >= 0) && (ioapic_i8259.pin >= 0))
+	{
+		printk(KERN_WARNING "ExtINT in hardware and MP table differ\n");
 	}
 
 	/*
@@ -1220,7 +1284,6 @@
  */
 void disable_IO_APIC(void)
 {
-	int pin;
 	/*
 	 * Clear the IO-APIC before rebooting:
 	 */
@@ -1231,8 +1294,7 @@
 	 * Put that IOAPIC in virtual wire mode
 	 * so legacy interrupts can be delivered.
 	 */
-	pin = find_isa_irq_pin(0, mp_ExtINT);
-	if (pin != -1) {
+	if (ioapic_i8259.pin != -1) {
 		struct IO_APIC_route_entry entry;
 		unsigned long flags;
 
@@ -1243,21 +1305,23 @@
 		entry.polarity        = 0; /* High */
 		entry.delivery_status = 0;
 		entry.dest_mode       = 0; /* Physical */
-		entry.delivery_mode   = 7; /* ExtInt */
+		entry.delivery_mode   = dest_ExtINT; /* ExtInt */
 		entry.vector          = 0;
-		entry.dest.physical.physical_dest = 0;
-
+		entry.dest.physical.physical_dest =
+					GET_APIC_ID(apic_read(APIC_ID));
 
 		/*
 		 * Add it to the IO-APIC irq-routing table:
 		 */
 		spin_lock_irqsave(&ioapic_lock, flags);
-		io_apic_write(0, 0x11+2*pin, *(((int *)&entry)+1));
-		io_apic_write(0, 0x10+2*pin, *(((int *)&entry)+0));
+		io_apic_write(ioapic_i8259.apic, 0x11+2*ioapic_i8259.pin,
+			*(((int *)&entry)+1));
+		io_apic_write(ioapic_i8259.apic, 0x10+2*ioapic_i8259.pin,
+			*(((int *)&entry)+0));
 		spin_unlock_irqrestore(&ioapic_lock, flags);
 	}
 
-	disconnect_bsp_APIC(pin != -1);
+	disconnect_bsp_APIC(ioapic_i8259.pin != -1);
 }
 
 /*
@@ -1571,7 +1635,7 @@
 	unsigned long v;
 
 	v = apic_read(APIC_LVT0);
-	apic_write_around(APIC_LVT0, v & ~APIC_LVT_MASKED);
+	apic_write(APIC_LVT0, v & ~APIC_LVT_MASKED);
 }
 
 static void disable_lapic_irq (unsigned int irq)
@@ -1579,7 +1643,7 @@
 	unsigned long v;
 
 	v = apic_read(APIC_LVT0);
-	apic_write_around(APIC_LVT0, v | APIC_LVT_MASKED);
+	apic_write(APIC_LVT0, v | APIC_LVT_MASKED);
 }
 
 static void ack_lapic_irq (unsigned int irq)
@@ -1626,20 +1690,21 @@
  */
 static inline void unlock_ExtINT_logic(void)
 {
-	int pin, i;
+	int apic, pin, i;
 	struct IO_APIC_route_entry entry0, entry1;
 	unsigned char save_control, save_freq_select;
 	unsigned long flags;
 
-	pin = find_isa_irq_pin(8, mp_INT);
+	pin  = find_isa_irq_pin(8, mp_INT);
+	apic = find_isa_irq_apic(8, mp_INT);
 	if (pin == -1)
 		return;
 
 	spin_lock_irqsave(&ioapic_lock, flags);
-	*(((int *)&entry0) + 1) = io_apic_read(0, 0x11 + 2 * pin);
-	*(((int *)&entry0) + 0) = io_apic_read(0, 0x10 + 2 * pin);
+	*(((int *)&entry0) + 1) = io_apic_read(apic, 0x11 + 2 * pin);
+	*(((int *)&entry0) + 0) = io_apic_read(apic, 0x10 + 2 * pin);
 	spin_unlock_irqrestore(&ioapic_lock, flags);
-	clear_IO_APIC_pin(0, pin);
+	clear_IO_APIC_pin(apic, pin);
 
 	memset(&entry1, 0, sizeof(entry1));
 
@@ -1652,8 +1717,8 @@
 	entry1.vector = 0;
 
 	spin_lock_irqsave(&ioapic_lock, flags);
-	io_apic_write(0, 0x11 + 2 * pin, *(((int *)&entry1) + 1));
-	io_apic_write(0, 0x10 + 2 * pin, *(((int *)&entry1) + 0));
+	io_apic_write(apic, 0x11 + 2 * pin, *(((int *)&entry1) + 1));
+	io_apic_write(apic, 0x10 + 2 * pin, *(((int *)&entry1) + 0));
 	spin_unlock_irqrestore(&ioapic_lock, flags);
 
 	save_control = CMOS_READ(RTC_CONTROL);
@@ -1671,11 +1736,11 @@
 
 	CMOS_WRITE(save_control, RTC_CONTROL);
 	CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT);
-	clear_IO_APIC_pin(0, pin);
+	clear_IO_APIC_pin(apic, pin);
 
 	spin_lock_irqsave(&ioapic_lock, flags);
-	io_apic_write(0, 0x11 + 2 * pin, *(((int *)&entry0) + 1));
-	io_apic_write(0, 0x10 + 2 * pin, *(((int *)&entry0) + 0));
+	io_apic_write(apic, 0x11 + 2 * pin, *(((int *)&entry0) + 1));
+	io_apic_write(apic, 0x10 + 2 * pin, *(((int *)&entry0) + 0));
 	spin_unlock_irqrestore(&ioapic_lock, flags);
 }
 
@@ -1687,7 +1752,7 @@
  */
 static inline void check_timer(void)
 {
-	int pin1, pin2;
+	int apic1, pin1, apic2, pin2;
 	int vector;
 
 	/*
@@ -1704,14 +1769,17 @@
 	 * the 8259A which implies the virtual wire has to be
 	 * disabled in the local APIC.
 	 */
-	apic_write_around(APIC_LVT0, APIC_LVT_MASKED | APIC_DM_EXTINT);
+	apic_write(APIC_LVT0, APIC_LVT_MASKED | APIC_DM_EXTINT);
 	init_8259A(1);
 	enable_8259A_irq(0);
 
-	pin1 = find_isa_irq_pin(0, mp_INT);
-	pin2 = find_isa_irq_pin(0, mp_ExtINT);
+	pin1  = find_isa_irq_pin(0, mp_INT);
+	apic1 = find_isa_irq_apic(0, mp_INT);
+	pin2  = ioapic_i8259.pin;
+	apic2 = ioapic_i8259.apic;
 
-	apic_printk(APIC_VERBOSE,KERN_INFO "..TIMER: vector=0x%02X pin1=%d pin2=%d\n", vector, pin1, pin2);
+	apic_printk(APIC_VERBOSE,KERN_INFO "..TIMER: vector=0x%02X apic1=%d pin1=%d apic2=%d pin2=%d\n",
+		vector, apic1, pin1, apic2, pin2);
 
 	if (pin1 != -1) {
 		/*
@@ -1729,17 +1797,20 @@
 				clear_IO_APIC_pin(0, pin1);
 			return;
 		}
-		clear_IO_APIC_pin(0, pin1);
-		apic_printk(APIC_QUIET,KERN_ERR "..MP-BIOS bug: 8254 timer not connected to IO-APIC\n");
+		clear_IO_APIC_pin(apic1, pin1);
+		apic_printk(APIC_QUIET,KERN_ERR "..MP-BIOS bug: 8254 timer not "
+				"connected to IO-APIC\n");
 	}
 
-	apic_printk(APIC_VERBOSE,KERN_INFO "...trying to set up timer (IRQ0) through the 8259A ... ");
+	apic_printk(APIC_VERBOSE,KERN_INFO "...trying to set up timer (IRQ0) "
+				"through the 8259A ... ");
 	if (pin2 != -1) {
-		apic_printk(APIC_VERBOSE,"\n..... (found pin %d) ...", pin2);
+		apic_printk(APIC_VERBOSE,"\n..... (found apic %d pin %d) ...",
+			apic2, pin2);
 		/*
 		 * legacy devices should be connected to IO APIC #0
 		 */
-		setup_ExtINT_IRQ0_pin(pin2, vector);
+		setup_ExtINT_IRQ0_pin(apic2, pin2, vector);
 		if (timer_irq_works()) {
 			printk("works.\n");
 			nmi_watchdog_default();
@@ -1751,7 +1822,7 @@
 		/*
 		 * Cleanup, just in case ...
 		 */
-		clear_IO_APIC_pin(0, pin2);
+		clear_IO_APIC_pin(apic2, pin2);
 	}
 	printk(" failed.\n");
 
@@ -1764,21 +1835,21 @@
 
 	disable_8259A_irq(0);
 	irq_desc[0].handler = &lapic_irq_type;
-	apic_write_around(APIC_LVT0, APIC_DM_FIXED | vector);	/* Fixed mode */
+	apic_write(APIC_LVT0, APIC_DM_FIXED | vector);	/* Fixed mode */
 	enable_8259A_irq(0);
 
 	if (timer_irq_works()) {
 		apic_printk(APIC_QUIET, " works.\n");
 		return;
 	}
-	apic_write_around(APIC_LVT0, APIC_LVT_MASKED | APIC_DM_FIXED | vector);
+	apic_write(APIC_LVT0, APIC_LVT_MASKED | APIC_DM_FIXED | vector);
 	apic_printk(APIC_VERBOSE," failed.\n");
 
 	apic_printk(APIC_VERBOSE, KERN_INFO "...trying to set up timer as ExtINT IRQ...");
 
 	init_8259A(0);
 	make_8259A_irq(0);
-	apic_write_around(APIC_LVT0, APIC_DM_EXTINT);
+	apic_write(APIC_LVT0, APIC_DM_EXTINT);
 
 	unlock_ExtINT_logic();
 
diff --git a/arch/x86_64/kernel/ioport.c b/arch/x86_64/kernel/ioport.c
index cde0e86..b816149 100644
--- a/arch/x86_64/kernel/ioport.c
+++ b/arch/x86_64/kernel/ioport.c
@@ -7,6 +7,7 @@
 
 #include <linux/sched.h>
 #include <linux/kernel.h>
+#include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/types.h>
 #include <linux/ioport.h>
diff --git a/arch/x86_64/kernel/irq.c b/arch/x86_64/kernel/irq.c
index d6a04a8..30d2a1e 100644
--- a/arch/x86_64/kernel/irq.c
+++ b/arch/x86_64/kernel/irq.c
@@ -17,6 +17,7 @@
 #include <linux/delay.h>
 #include <asm/uaccess.h>
 #include <asm/io_apic.h>
+#include <asm/idle.h>
 
 atomic_t irq_err_count;
 #ifdef CONFIG_X86_IO_APIC
@@ -69,13 +70,13 @@
 		seq_printf(p, "NMI: ");
 		for (j = 0; j < NR_CPUS; j++)
 			if (cpu_online(j))
-				seq_printf(p, "%10u ", cpu_pda[j].__nmi_count);
+				seq_printf(p, "%10u ", cpu_pda(j)->__nmi_count);
 		seq_putc(p, '\n');
 #ifdef CONFIG_X86_LOCAL_APIC
 		seq_printf(p, "LOC: ");
 		for (j = 0; j < NR_CPUS; j++)
 			if (cpu_online(j))
-				seq_printf(p, "%10u ", cpu_pda[j].apic_timer_irqs);
+				seq_printf(p, "%10u ", cpu_pda(j)->apic_timer_irqs);
 		seq_putc(p, '\n');
 #endif
 		seq_printf(p, "ERR: %10u\n", atomic_read(&irq_err_count));
@@ -98,6 +99,7 @@
 	/* high bits used in ret_from_ code  */
 	unsigned irq = regs->orig_rax & 0xff;
 
+	exit_idle();
 	irq_enter();
 
 	__do_IRQ(irq, regs);
diff --git a/arch/x86_64/kernel/kprobes.c b/arch/x86_64/kernel/kprobes.c
index b7dc1f8..8b866a8 100644
--- a/arch/x86_64/kernel/kprobes.c
+++ b/arch/x86_64/kernel/kprobes.c
@@ -334,6 +334,15 @@
 				return 1;
 			}
 		} else {
+			if (*addr != BREAKPOINT_INSTRUCTION) {
+			/* The breakpoint instruction was removed by
+			 * another cpu right after we hit, no further
+			 * handling of this interrupt is appropriate
+			 */
+				regs->rip = (unsigned long)addr;
+				ret = 1;
+				goto no_kprobe;
+			}
 			p = __get_cpu_var(current_kprobe);
 			if (p->break_handler && p->break_handler(p, regs)) {
 				goto ss_probe;
diff --git a/arch/x86_64/kernel/mce.c b/arch/x86_64/kernel/mce.c
index 183dc61..13a2ead 100644
--- a/arch/x86_64/kernel/mce.c
+++ b/arch/x86_64/kernel/mce.c
@@ -15,6 +15,7 @@
 #include <linux/sysdev.h>
 #include <linux/miscdevice.h>
 #include <linux/fs.h>
+#include <linux/capability.h>
 #include <linux/cpu.h>
 #include <linux/percpu.h>
 #include <linux/ctype.h>
@@ -23,9 +24,10 @@
 #include <asm/mce.h>
 #include <asm/kdebug.h>
 #include <asm/uaccess.h>
+#include <asm/smp.h>
 
 #define MISC_MCELOG_MINOR 227
-#define NR_BANKS 5
+#define NR_BANKS 6
 
 static int mce_dont_init;
 
@@ -91,6 +93,7 @@
 static void print_mce(struct mce *m)
 {
 	printk(KERN_EMERG "\n"
+	       KERN_EMERG "HARDWARE ERROR\n"
 	       KERN_EMERG
 	       "CPU %d: Machine Check Exception: %16Lx Bank %d: %016Lx\n",
 	       m->cpu, m->mcgstatus, m->bank, m->status);
@@ -109,6 +112,9 @@
 	if (m->misc)
 		printk("MISC %Lx ", m->misc); 	
 	printk("\n");
+	printk(KERN_EMERG "This is not a software problem!\n");
+        printk(KERN_EMERG
+    "Run through mcelog --ascii to decode and contact your hardware vendor\n");
 }
 
 static void mce_panic(char *msg, struct mce *backup, unsigned long start)
@@ -168,12 +174,12 @@
 	int panicm_found = 0;
 
 	if (regs)
-		notify_die(DIE_NMI, "machine check", regs, error_code, 255, SIGKILL);
+		notify_die(DIE_NMI, "machine check", regs, error_code, 18, SIGKILL);
 	if (!banks)
 		return;
 
 	memset(&m, 0, sizeof(struct mce));
-	m.cpu = hard_smp_processor_id();
+	m.cpu = safe_smp_processor_id();
 	rdmsrl(MSR_IA32_MCG_STATUS, m.mcgstatus);
 	if (!(m.mcgstatus & MCG_STATUS_RIPV))
 		kill_it = 1;
@@ -573,6 +579,10 @@
 ACCESSOR(bank2ctl,bank[2],mce_restart())
 ACCESSOR(bank3ctl,bank[3],mce_restart())
 ACCESSOR(bank4ctl,bank[4],mce_restart())
+ACCESSOR(bank5ctl,bank[5],mce_restart())
+static struct sysdev_attribute * bank_attributes[NR_BANKS] = {
+	&attr_bank0ctl, &attr_bank1ctl, &attr_bank2ctl,
+	&attr_bank3ctl, &attr_bank4ctl, &attr_bank5ctl};
 ACCESSOR(tolerant,tolerant,)
 ACCESSOR(check_interval,check_interval,mce_restart())
 
@@ -580,6 +590,7 @@
 static __cpuinit int mce_create_device(unsigned int cpu)
 {
 	int err;
+	int i;
 	if (!mce_available(&cpu_data[cpu]))
 		return -EIO;
 
@@ -589,11 +600,9 @@
 	err = sysdev_register(&per_cpu(device_mce,cpu));
 
 	if (!err) {
-		sysdev_create_file(&per_cpu(device_mce,cpu), &attr_bank0ctl);
-		sysdev_create_file(&per_cpu(device_mce,cpu), &attr_bank1ctl);
-		sysdev_create_file(&per_cpu(device_mce,cpu), &attr_bank2ctl);
-		sysdev_create_file(&per_cpu(device_mce,cpu), &attr_bank3ctl);
-		sysdev_create_file(&per_cpu(device_mce,cpu), &attr_bank4ctl);
+		for (i = 0; i < banks; i++)
+			sysdev_create_file(&per_cpu(device_mce,cpu),
+				bank_attributes[i]);
 		sysdev_create_file(&per_cpu(device_mce,cpu), &attr_tolerant);
 		sysdev_create_file(&per_cpu(device_mce,cpu), &attr_check_interval);
 	}
@@ -603,11 +612,11 @@
 #ifdef CONFIG_HOTPLUG_CPU
 static __cpuinit void mce_remove_device(unsigned int cpu)
 {
-	sysdev_remove_file(&per_cpu(device_mce,cpu), &attr_bank0ctl);
-	sysdev_remove_file(&per_cpu(device_mce,cpu), &attr_bank1ctl);
-	sysdev_remove_file(&per_cpu(device_mce,cpu), &attr_bank2ctl);
-	sysdev_remove_file(&per_cpu(device_mce,cpu), &attr_bank3ctl);
-	sysdev_remove_file(&per_cpu(device_mce,cpu), &attr_bank4ctl);
+	int i;
+
+	for (i = 0; i < banks; i++)
+		sysdev_remove_file(&per_cpu(device_mce,cpu),
+			bank_attributes[i]);
 	sysdev_remove_file(&per_cpu(device_mce,cpu), &attr_tolerant);
 	sysdev_remove_file(&per_cpu(device_mce,cpu), &attr_check_interval);
 	sysdev_unregister(&per_cpu(device_mce,cpu));
diff --git a/arch/x86_64/kernel/mce_amd.c b/arch/x86_64/kernel/mce_amd.c
index 1f76175..d3ad7d8 100644
--- a/arch/x86_64/kernel/mce_amd.c
+++ b/arch/x86_64/kernel/mce_amd.c
@@ -27,6 +27,7 @@
 #include <asm/mce.h>
 #include <asm/msr.h>
 #include <asm/percpu.h>
+#include <asm/idle.h>
 
 #define PFX "mce_threshold: "
 #define VERSION "version 1.00.9"
@@ -140,6 +141,7 @@
 	struct mce m;
 
 	ack_APIC_irq();
+	exit_idle();
 	irq_enter();
 
 	memset(&m, 0, sizeof(m));
@@ -318,7 +320,7 @@
 static __cpuinit int threshold_create_bank(unsigned int cpu, int bank)
 {
 	int err = 0;
-	struct threshold_bank *b = 0;
+	struct threshold_bank *b = NULL;
 
 #ifdef CONFIG_SMP
 	if (cpu_core_id[cpu] && shared_bank[bank]) {	/* symlink */
@@ -407,7 +409,7 @@
 	if (shared_bank[bank] && atomic_read(&b->kobj.kref.refcount) > 2) {
 		sprintf(name, "bank%i", bank);
 		sysfs_remove_link(&per_cpu(device_threshold, cpu).kobj, name);
-		per_cpu(threshold_banks, cpu)[bank] = 0;
+		per_cpu(threshold_banks, cpu)[bank] = NULL;
 	} else {
 		kobject_unregister(&b->kobj);
 		kfree(per_cpu(threshold_banks, cpu)[bank]);
diff --git a/arch/x86_64/kernel/mce_intel.c b/arch/x86_64/kernel/mce_intel.c
index 0be0a79..8f533d2 100644
--- a/arch/x86_64/kernel/mce_intel.c
+++ b/arch/x86_64/kernel/mce_intel.c
@@ -10,6 +10,7 @@
 #include <asm/msr.h>
 #include <asm/mce.h>
 #include <asm/hw_irq.h>
+#include <asm/idle.h>
 
 static DEFINE_PER_CPU(unsigned long, next_check);
 
@@ -19,6 +20,7 @@
 
 	ack_APIC_irq();
 
+	exit_idle();
 	irq_enter();
 	if (time_before(jiffies, __get_cpu_var(next_check)))
 		goto done;
@@ -78,7 +80,7 @@
 
 	h = THERMAL_APIC_VECTOR;
 	h |= (APIC_DM_FIXED | APIC_LVT_MASKED);
-	apic_write_around(APIC_LVTTHMR, h);
+	apic_write(APIC_LVTTHMR, h);
 
 	rdmsr(MSR_IA32_THERM_INTERRUPT, l, h);
 	wrmsr(MSR_IA32_THERM_INTERRUPT, l | 0x03, h);
@@ -87,7 +89,7 @@
 	wrmsr(MSR_IA32_MISC_ENABLE, l | (1 << 3), h);
 
 	l = apic_read(APIC_LVTTHMR);
-	apic_write_around(APIC_LVTTHMR, l & ~APIC_LVT_MASKED);
+	apic_write(APIC_LVTTHMR, l & ~APIC_LVT_MASKED);
 	printk(KERN_INFO "CPU%d: Thermal monitoring enabled (%s)\n",
 		cpu, tm2 ? "TM2" : "TM1");
 	return;
diff --git a/arch/x86_64/kernel/nmi.c b/arch/x86_64/kernel/nmi.c
index 39d445e..5fae6f0 100644
--- a/arch/x86_64/kernel/nmi.c
+++ b/arch/x86_64/kernel/nmi.c
@@ -151,23 +151,25 @@
 
 	printk(KERN_INFO "testing NMI watchdog ... ");
 
+#ifdef CONFIG_SMP
 	if (nmi_watchdog == NMI_LOCAL_APIC)
 		smp_call_function(nmi_cpu_busy, (void *)&endflag, 0, 0);
+#endif
 
 	for (cpu = 0; cpu < NR_CPUS; cpu++)
-		counts[cpu] = cpu_pda[cpu].__nmi_count; 
+		counts[cpu] = cpu_pda(cpu)->__nmi_count;
 	local_irq_enable();
 	mdelay((10*1000)/nmi_hz); // wait 10 ticks
 
 	for (cpu = 0; cpu < NR_CPUS; cpu++) {
 		if (!cpu_online(cpu))
 			continue;
-		if (cpu_pda[cpu].__nmi_count - counts[cpu] <= 5) {
+		if (cpu_pda(cpu)->__nmi_count - counts[cpu] <= 5) {
 			endflag = 1;
 			printk("CPU#%d: NMI appears to be stuck (%d->%d)!\n",
 			       cpu,
 			       counts[cpu],
-			       cpu_pda[cpu].__nmi_count);
+			       cpu_pda(cpu)->__nmi_count);
 			nmi_active = 0;
 			lapic_nmi_owner &= ~LAPIC_NMI_WATCHDOG;
 			nmi_perfctr_msr = 0;
diff --git a/arch/x86_64/kernel/pci-dma.c b/arch/x86_64/kernel/pci-dma.c
index cab471c..2f5d832 100644
--- a/arch/x86_64/kernel/pci-dma.c
+++ b/arch/x86_64/kernel/pci-dma.c
@@ -8,53 +8,259 @@
 #include <linux/pci.h>
 #include <linux/module.h>
 #include <asm/io.h>
+#include <asm/proto.h>
 
-/* Map a set of buffers described by scatterlist in streaming
- * mode for DMA.  This is the scatter-gather version of the
- * above pci_map_single interface.  Here the scatter gather list
- * elements are each tagged with the appropriate dma address
- * and length.  They are obtained via sg_dma_{address,length}(SG).
- *
- * NOTE: An implementation may be able to use a smaller number of
- *       DMA address/length pairs than there are SG table elements.
- *       (for example via virtual mapping capabilities)
- *       The routine returns the number of addr/length pairs actually
- *       used, at most nents.
- *
- * Device ownership issues as mentioned above for pci_map_single are
- * the same here.
- */
-int dma_map_sg(struct device *hwdev, struct scatterlist *sg,
-	       int nents, int direction)
+int iommu_merge __read_mostly = 0;
+EXPORT_SYMBOL(iommu_merge);
+
+dma_addr_t bad_dma_address __read_mostly;
+EXPORT_SYMBOL(bad_dma_address);
+
+/* This tells the BIO block layer to assume merging. Default to off
+   because we cannot guarantee merging later. */
+int iommu_bio_merge __read_mostly = 0;
+EXPORT_SYMBOL(iommu_bio_merge);
+
+int iommu_sac_force __read_mostly = 0;
+EXPORT_SYMBOL(iommu_sac_force);
+
+int no_iommu __read_mostly;
+#ifdef CONFIG_IOMMU_DEBUG
+int panic_on_overflow __read_mostly = 1;
+int force_iommu __read_mostly = 1;
+#else
+int panic_on_overflow __read_mostly = 0;
+int force_iommu __read_mostly= 0;
+#endif
+
+/* Dummy device used for NULL arguments (normally ISA). Better would
+   be probably a smaller DMA mask, but this is bug-to-bug compatible
+   to i386. */
+struct device fallback_dev = {
+	.bus_id = "fallback device",
+	.coherent_dma_mask = 0xffffffff,
+	.dma_mask = &fallback_dev.coherent_dma_mask,
+};
+
+/* Allocate DMA memory on node near device */
+noinline static void *
+dma_alloc_pages(struct device *dev, gfp_t gfp, unsigned order)
 {
-	int i;
+	struct page *page;
+	int node;
+	if (dev->bus == &pci_bus_type)
+		node = pcibus_to_node(to_pci_dev(dev)->bus);
+	else
+		node = numa_node_id();
+	page = alloc_pages_node(node, gfp, order);
+	return page ? page_address(page) : NULL;
+}
 
-	BUG_ON(direction == DMA_NONE);
- 	for (i = 0; i < nents; i++ ) {
-		struct scatterlist *s = &sg[i];
-		BUG_ON(!s->page); 
-		s->dma_address = virt_to_bus(page_address(s->page) +s->offset);
-		s->dma_length = s->length;
+/*
+ * Allocate memory for a coherent mapping.
+ */
+void *
+dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
+		   gfp_t gfp)
+{
+	void *memory;
+	unsigned long dma_mask = 0;
+	u64 bus;
+
+	if (!dev)
+		dev = &fallback_dev;
+	dma_mask = dev->coherent_dma_mask;
+	if (dma_mask == 0)
+		dma_mask = 0xffffffff;
+
+	/* Kludge to make it bug-to-bug compatible with i386. i386
+	   uses the normal dma_mask for alloc_coherent. */
+	dma_mask &= *dev->dma_mask;
+
+	/* Why <=? Even when the mask is smaller than 4GB it is often
+	   larger than 16MB and in this case we have a chance of
+	   finding fitting memory in the next higher zone first. If
+	   not retry with true GFP_DMA. -AK */
+	if (dma_mask <= 0xffffffff)
+		gfp |= GFP_DMA32;
+
+ again:
+	memory = dma_alloc_pages(dev, gfp, get_order(size));
+	if (memory == NULL)
+		return NULL;
+
+	{
+		int high, mmu;
+		bus = virt_to_bus(memory);
+	        high = (bus + size) >= dma_mask;
+		mmu = high;
+		if (force_iommu && !(gfp & GFP_DMA))
+			mmu = 1;
+		else if (high) {
+			free_pages((unsigned long)memory,
+				   get_order(size));
+
+			/* Don't use the 16MB ZONE_DMA unless absolutely
+			   needed. It's better to use remapping first. */
+			if (dma_mask < 0xffffffff && !(gfp & GFP_DMA)) {
+				gfp = (gfp & ~GFP_DMA32) | GFP_DMA;
+				goto again;
+			}
+
+			if (dma_ops->alloc_coherent)
+				return dma_ops->alloc_coherent(dev, size,
+							   dma_handle, gfp);
+			return NULL;
+		}
+
+		memset(memory, 0, size);
+		if (!mmu) {
+			*dma_handle = virt_to_bus(memory);
+			return memory;
+		}
 	}
-	return nents;
+
+	if (dma_ops->alloc_coherent) {
+		free_pages((unsigned long)memory, get_order(size));
+		gfp &= ~(GFP_DMA|GFP_DMA32);
+		return dma_ops->alloc_coherent(dev, size, dma_handle, gfp);
+	}
+
+	if (dma_ops->map_simple) {
+		*dma_handle = dma_ops->map_simple(dev, memory,
+					      size,
+					      PCI_DMA_BIDIRECTIONAL);
+		if (*dma_handle != bad_dma_address)
+			return memory;
+	}
+
+	if (panic_on_overflow)
+		panic("dma_alloc_coherent: IOMMU overflow by %lu bytes\n",size);
+	free_pages((unsigned long)memory, get_order(size));
+	return NULL;
 }
+EXPORT_SYMBOL(dma_alloc_coherent);
 
-EXPORT_SYMBOL(dma_map_sg);
-
-/* Unmap a set of streaming mode DMA translations.
- * Again, cpu read rules concerning calls here are the same as for
- * pci_unmap_single() above.
+/*
+ * Unmap coherent memory.
+ * The caller must ensure that the device has finished accessing the mapping.
  */
-void dma_unmap_sg(struct device *dev, struct scatterlist *sg,
-		  int nents, int dir)
+void dma_free_coherent(struct device *dev, size_t size,
+			 void *vaddr, dma_addr_t bus)
 {
-	int i;
-	for (i = 0; i < nents; i++) { 
-		struct scatterlist *s = &sg[i];
-		BUG_ON(s->page == NULL); 
-		BUG_ON(s->dma_address == 0); 
-		dma_unmap_single(dev, s->dma_address, s->dma_length, dir);
-	} 
+	if (dma_ops->unmap_single)
+		dma_ops->unmap_single(dev, bus, size, 0);
+	free_pages((unsigned long)vaddr, get_order(size));
 }
+EXPORT_SYMBOL(dma_free_coherent);
 
-EXPORT_SYMBOL(dma_unmap_sg);
+int dma_supported(struct device *dev, u64 mask)
+{
+	if (dma_ops->dma_supported)
+		return dma_ops->dma_supported(dev, mask);
+
+	/* Copied from i386. Doesn't make much sense, because it will
+	   only work for pci_alloc_coherent.
+	   The caller just has to use GFP_DMA in this case. */
+        if (mask < 0x00ffffff)
+                return 0;
+
+	/* Tell the device to use SAC when IOMMU force is on.  This
+	   allows the driver to use cheaper accesses in some cases.
+
+	   Problem with this is that if we overflow the IOMMU area and
+	   return DAC as fallback address the device may not handle it
+	   correctly.
+
+	   As a special case some controllers have a 39bit address
+	   mode that is as efficient as 32bit (aic79xx). Don't force
+	   SAC for these.  Assume all masks <= 40 bits are of this
+	   type. Normally this doesn't make any difference, but gives
+	   more gentle handling of IOMMU overflow. */
+	if (iommu_sac_force && (mask >= 0xffffffffffULL)) {
+		printk(KERN_INFO "%s: Force SAC with mask %Lx\n", dev->bus_id,mask);
+		return 0;
+	}
+
+	return 1;
+}
+EXPORT_SYMBOL(dma_supported);
+
+int dma_set_mask(struct device *dev, u64 mask)
+{
+	if (!dev->dma_mask || !dma_supported(dev, mask))
+		return -EIO;
+	*dev->dma_mask = mask;
+	return 0;
+}
+EXPORT_SYMBOL(dma_set_mask);
+
+/* iommu=[size][,noagp][,off][,force][,noforce][,leak][,memaper[=order]][,merge]
+         [,forcesac][,fullflush][,nomerge][,biomerge]
+   size  set size of iommu (in bytes)
+   noagp don't initialize the AGP driver and use full aperture.
+   off   don't use the IOMMU
+   leak  turn on simple iommu leak tracing (only when CONFIG_IOMMU_LEAK is on)
+   memaper[=order] allocate an own aperture over RAM with size 32MB^order.
+   noforce don't force IOMMU usage. Default.
+   force  Force IOMMU.
+   merge  Do lazy merging. This may improve performance on some block devices.
+          Implies force (experimental)
+   biomerge Do merging at the BIO layer. This is more efficient than merge,
+            but should be only done with very big IOMMUs. Implies merge,force.
+   nomerge Don't do SG merging.
+   forcesac For SAC mode for masks <40bits  (experimental)
+   fullflush Flush IOMMU on each allocation (default)
+   nofullflush Don't use IOMMU fullflush
+   allowed  overwrite iommu off workarounds for specific chipsets.
+   soft	 Use software bounce buffering (default for Intel machines)
+   noaperture Don't touch the aperture for AGP.
+*/
+__init int iommu_setup(char *p)
+{
+    iommu_merge = 1;
+
+    while (*p) {
+	    if (!strncmp(p,"off",3))
+		    no_iommu = 1;
+	    /* gart_parse_options has more force support */
+	    if (!strncmp(p,"force",5))
+		    force_iommu = 1;
+	    if (!strncmp(p,"noforce",7)) {
+		    iommu_merge = 0;
+		    force_iommu = 0;
+	    }
+
+	    if (!strncmp(p, "biomerge",8)) {
+		    iommu_bio_merge = 4096;
+		    iommu_merge = 1;
+		    force_iommu = 1;
+	    }
+	    if (!strncmp(p, "panic",5))
+		    panic_on_overflow = 1;
+	    if (!strncmp(p, "nopanic",7))
+		    panic_on_overflow = 0;
+	    if (!strncmp(p, "merge",5)) {
+		    iommu_merge = 1;
+		    force_iommu = 1;
+	    }
+	    if (!strncmp(p, "nomerge",7))
+		    iommu_merge = 0;
+	    if (!strncmp(p, "forcesac",8))
+		    iommu_sac_force = 1;
+
+#ifdef CONFIG_SWIOTLB
+	    if (!strncmp(p, "soft",4))
+		    swiotlb = 1;
+#endif
+
+#ifdef CONFIG_GART_IOMMU
+	    gart_parse_options(p);
+#endif
+
+	    p += strcspn(p, ",");
+	    if (*p == ',')
+		    ++p;
+    }
+    return 1;
+}
diff --git a/arch/x86_64/kernel/pci-gart.c b/arch/x86_64/kernel/pci-gart.c
index 2e28e85..c37fc77 100644
--- a/arch/x86_64/kernel/pci-gart.c
+++ b/arch/x86_64/kernel/pci-gart.c
@@ -30,8 +30,8 @@
 #include <asm/proto.h>
 #include <asm/cacheflush.h>
 #include <asm/kdebug.h>
-
-dma_addr_t bad_dma_address;
+#include <asm/swiotlb.h>
+#include <asm/dma.h>
 
 unsigned long iommu_bus_base;	/* GART remapping area (physical) */
 static unsigned long iommu_size; 	/* size of remapping area bytes */
@@ -39,18 +39,6 @@
 
 u32 *iommu_gatt_base; 		/* Remapping table */
 
-int no_iommu; 
-static int no_agp; 
-#ifdef CONFIG_IOMMU_DEBUG
-int panic_on_overflow = 1; 
-int force_iommu = 1;
-#else
-int panic_on_overflow = 0;
-int force_iommu = 0;
-#endif
-int iommu_merge = 1;
-int iommu_sac_force = 0; 
-
 /* If this is disabled the IOMMU will use an optimized flushing strategy
    of only flushing when an mapping is reused. With it true the GART is flushed 
    for every mapping. Problem is that doing the lazy flush seems to trigger
@@ -58,10 +46,6 @@
    also seen with Qlogic at least). */
 int iommu_fullflush = 1;
 
-/* This tells the BIO block layer to assume merging. Default to off
-   because we cannot guarantee merging later. */
-int iommu_bio_merge = 0;
-
 #define MAX_NB 8
 
 /* Allocation bitmap for the remapping area */ 
@@ -102,16 +86,6 @@
 
 static unsigned long next_bit;  /* protected by iommu_bitmap_lock */
 static int need_flush; 		/* global flush state. set for each gart wrap */
-static dma_addr_t dma_map_area(struct device *dev, unsigned long phys_mem,
-			       size_t size, int dir, int do_panic);
-
-/* Dummy device used for NULL arguments (normally ISA). Better would
-   be probably a smaller DMA mask, but this is bug-to-bug compatible to i386. */
-static struct device fallback_dev = {
-	.bus_id = "fallback device",
-	.coherent_dma_mask = 0xffffffff,
-	.dma_mask = &fallback_dev.coherent_dma_mask,
-};
 
 static unsigned long alloc_iommu(int size) 
 { 	
@@ -185,114 +159,7 @@
 	spin_unlock_irqrestore(&iommu_bitmap_lock, flags);
 } 
 
-/* Allocate DMA memory on node near device */
-noinline
-static void *dma_alloc_pages(struct device *dev, gfp_t gfp, unsigned order)
-{
-	struct page *page;
-	int node;
-	if (dev->bus == &pci_bus_type)
-		node = pcibus_to_node(to_pci_dev(dev)->bus);
-	else
-		node = numa_node_id();
-	page = alloc_pages_node(node, gfp, order);
-	return page ? page_address(page) : NULL;
-}
 
-/* 
- * Allocate memory for a coherent mapping.
- */
-void *
-dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
-		   gfp_t gfp)
-{
-	void *memory;
-	unsigned long dma_mask = 0;
-	u64 bus;
-
-	if (!dev)
-		dev = &fallback_dev;
-	dma_mask = dev->coherent_dma_mask;
-	if (dma_mask == 0) 
-		dma_mask = 0xffffffff; 
-
-	/* Kludge to make it bug-to-bug compatible with i386. i386
-	   uses the normal dma_mask for alloc_coherent. */
-	dma_mask &= *dev->dma_mask;
-
-	/* Why <=? Even when the mask is smaller than 4GB it is often larger 
-	   than 16MB and in this case we have a chance of finding fitting memory 
-	   in the next higher zone first. If not retry with true GFP_DMA. -AK */
-	if (dma_mask <= 0xffffffff)
-		gfp |= GFP_DMA32;
-
- again:
-	memory = dma_alloc_pages(dev, gfp, get_order(size));
-	if (memory == NULL)
-		return NULL;
-
-	{
-		int high, mmu;
-		bus = virt_to_bus(memory);
-	        high = (bus + size) >= dma_mask;
-		mmu = high;
-		if (force_iommu && !(gfp & GFP_DMA)) 
-			mmu = 1;
-		if (no_iommu || dma_mask < 0xffffffffUL) { 
-			if (high) {
-				free_pages((unsigned long)memory,
-					   get_order(size));
-
-				if (swiotlb) {
-					return
-					swiotlb_alloc_coherent(dev, size,
-							       dma_handle,
-							       gfp);
-				}
-
-				if (!(gfp & GFP_DMA)) { 
-					gfp = (gfp & ~GFP_DMA32) | GFP_DMA;
-					goto again;
-				}
-				return NULL;
-			}
-			mmu = 0; 
-		} 	
-		memset(memory, 0, size); 
-		if (!mmu) { 
-			*dma_handle = virt_to_bus(memory);
-			return memory;
-		}
-	} 
-
-	*dma_handle = dma_map_area(dev, bus, size, PCI_DMA_BIDIRECTIONAL, 0);
-	if (*dma_handle == bad_dma_address)
-		goto error; 
-	flush_gart(dev);
-	return memory; 
-	
-error:
-	if (panic_on_overflow)
-		panic("dma_alloc_coherent: IOMMU overflow by %lu bytes\n", size);
-	free_pages((unsigned long)memory, get_order(size)); 
-	return NULL; 
-}
-
-/* 
- * Unmap coherent memory.
- * The caller must ensure that the device has finished accessing the mapping.
- */
-void dma_free_coherent(struct device *dev, size_t size,
-			 void *vaddr, dma_addr_t bus)
-{
-	if (swiotlb) {
-		swiotlb_free_coherent(dev, size, vaddr, bus);
-		return;
-	}
-
-	dma_unmap_single(dev, bus, size, 0);
-	free_pages((unsigned long)vaddr, get_order(size)); 		
-}
 
 #ifdef CONFIG_IOMMU_LEAK
 
@@ -326,7 +193,7 @@
 #define CLEAR_LEAK(x)
 #endif
 
-static void iommu_full(struct device *dev, size_t size, int dir, int do_panic)
+static void iommu_full(struct device *dev, size_t size, int dir)
 {
 	/* 
 	 * Ran out of IOMMU space for this operation. This is very bad.
@@ -342,11 +209,11 @@
   "PCI-DMA: Out of IOMMU space for %lu bytes at device %s\n",
 	       size, dev->bus_id);
 
-	if (size > PAGE_SIZE*EMERGENCY_PAGES && do_panic) {
+	if (size > PAGE_SIZE*EMERGENCY_PAGES) {
 		if (dir == PCI_DMA_FROMDEVICE || dir == PCI_DMA_BIDIRECTIONAL)
 			panic("PCI-DMA: Memory would be corrupted\n");
 		if (dir == PCI_DMA_TODEVICE || dir == PCI_DMA_BIDIRECTIONAL) 
-			panic("PCI-DMA: Random memory would be DMAed\n");
+			panic(KERN_ERR "PCI-DMA: Random memory would be DMAed\n");
 	} 
 
 #ifdef CONFIG_IOMMU_LEAK
@@ -385,8 +252,8 @@
 /* Map a single continuous physical area into the IOMMU.
  * Caller needs to check if the iommu is needed and flush.
  */
-static dma_addr_t dma_map_area(struct device *dev, unsigned long phys_mem,
-				size_t size, int dir, int do_panic)
+static dma_addr_t dma_map_area(struct device *dev, dma_addr_t phys_mem,
+				size_t size, int dir)
 { 
 	unsigned long npages = to_pages(phys_mem, size);
 	unsigned long iommu_page = alloc_iommu(npages);
@@ -396,7 +263,7 @@
 			return phys_mem; 
 		if (panic_on_overflow)
 			panic("dma_map_area overflow %lu bytes\n", size);
-		iommu_full(dev, size, dir, do_panic);
+		iommu_full(dev, size, dir);
 		return bad_dma_address;
 	}
 
@@ -408,15 +275,21 @@
 	return iommu_bus_base + iommu_page*PAGE_SIZE + (phys_mem & ~PAGE_MASK);
 }
 
+static dma_addr_t gart_map_simple(struct device *dev, char *buf,
+				 size_t size, int dir)
+{
+	dma_addr_t map = dma_map_area(dev, virt_to_bus(buf), size, dir);
+	flush_gart(dev);
+	return map;
+}
+
 /* Map a single area into the IOMMU */
-dma_addr_t dma_map_single(struct device *dev, void *addr, size_t size, int dir)
+dma_addr_t gart_map_single(struct device *dev, void *addr, size_t size, int dir)
 {
 	unsigned long phys_mem, bus;
 
 	BUG_ON(dir == DMA_NONE);
 
-	if (swiotlb)
-		return swiotlb_map_single(dev,addr,size,dir);
 	if (!dev)
 		dev = &fallback_dev;
 
@@ -424,10 +297,24 @@
 	if (!need_iommu(dev, phys_mem, size))
 		return phys_mem; 
 
-	bus = dma_map_area(dev, phys_mem, size, dir, 1);
-	flush_gart(dev); 
+	bus = gart_map_simple(dev, addr, size, dir);
 	return bus; 
-} 
+}
+
+/*
+ * Wrapper for pci_unmap_single working with scatterlists.
+ */
+void gart_unmap_sg(struct device *dev, struct scatterlist *sg, int nents, int dir)
+{
+	int i;
+
+	for (i = 0; i < nents; i++) {
+		struct scatterlist *s = &sg[i];
+		if (!s->dma_length || !s->length)
+			break;
+		dma_unmap_single(dev, s->dma_address, s->dma_length, dir);
+	}
+}
 
 /* Fallback for dma_map_sg in case of overflow */
 static int dma_map_sg_nonforce(struct device *dev, struct scatterlist *sg,
@@ -443,10 +330,10 @@
 		struct scatterlist *s = &sg[i];
 		unsigned long addr = page_to_phys(s->page) + s->offset; 
 		if (nonforced_iommu(dev, addr, s->length)) { 
-			addr = dma_map_area(dev, addr, s->length, dir, 0);
+			addr = dma_map_area(dev, addr, s->length, dir);
 			if (addr == bad_dma_address) { 
 				if (i > 0) 
-					dma_unmap_sg(dev, sg, i, dir);
+					gart_unmap_sg(dev, sg, i, dir);
 				nents = 0; 
 				sg[0].dma_length = 0;
 				break;
@@ -515,7 +402,7 @@
  * DMA map all entries in a scatterlist.
  * Merge chunks that have page aligned sizes into a continuous mapping. 
  */
-int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, int dir)
+int gart_map_sg(struct device *dev, struct scatterlist *sg, int nents, int dir)
 {
 	int i;
 	int out;
@@ -527,8 +414,6 @@
 	if (nents == 0) 
 		return 0;
 
-	if (swiotlb)
-		return swiotlb_map_sg(dev,sg,nents,dir);
 	if (!dev)
 		dev = &fallback_dev;
 
@@ -571,13 +456,13 @@
 
 error:
 	flush_gart(NULL);
-	dma_unmap_sg(dev, sg, nents, dir);
+	gart_unmap_sg(dev, sg, nents, dir);
 	/* When it was forced try again unforced */
 	if (force_iommu) 
 		return dma_map_sg_nonforce(dev, sg, nents, dir);
 	if (panic_on_overflow)
 		panic("dma_map_sg: overflow on %lu pages\n", pages);
-	iommu_full(dev, pages << PAGE_SHIFT, dir, 0);
+	iommu_full(dev, pages << PAGE_SHIFT, dir);
 	for (i = 0; i < nents; i++)
 		sg[i].dma_address = bad_dma_address;
 	return 0;
@@ -586,18 +471,13 @@
 /*
  * Free a DMA mapping.
  */ 
-void dma_unmap_single(struct device *dev, dma_addr_t dma_addr,
+void gart_unmap_single(struct device *dev, dma_addr_t dma_addr,
 		      size_t size, int direction)
 {
 	unsigned long iommu_page; 
 	int npages;
 	int i;
 
-	if (swiotlb) {
-		swiotlb_unmap_single(dev,dma_addr,size,direction);
-		return;
-	}
-
 	if (dma_addr < iommu_bus_base + EMERGENCY_PAGES*PAGE_SIZE || 
 	    dma_addr >= iommu_bus_base + iommu_size)
 		return;
@@ -610,68 +490,7 @@
 	free_iommu(iommu_page, npages);
 }
 
-/* 
- * Wrapper for pci_unmap_single working with scatterlists.
- */ 
-void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nents, int dir)
-{
-	int i;
-	if (swiotlb) {
-		swiotlb_unmap_sg(dev,sg,nents,dir);
-		return;
-	}
-	for (i = 0; i < nents; i++) { 
-		struct scatterlist *s = &sg[i];
-		if (!s->dma_length || !s->length) 
-			break;
-		dma_unmap_single(dev, s->dma_address, s->dma_length, dir);
-	}
-}
-
-int dma_supported(struct device *dev, u64 mask)
-{
-	/* Copied from i386. Doesn't make much sense, because it will 
-	   only work for pci_alloc_coherent.
-	   The caller just has to use GFP_DMA in this case. */
-        if (mask < 0x00ffffff)
-                return 0;
-
-	/* Tell the device to use SAC when IOMMU force is on. 
-	   This allows the driver to use cheaper accesses in some cases.
-
-	   Problem with this is that if we overflow the IOMMU area
-	   and return DAC as fallback address the device may not handle it correctly.
-	   
-	   As a special case some controllers have a 39bit address mode 
-	   that is as efficient as 32bit (aic79xx). Don't force SAC for these.
-	   Assume all masks <= 40 bits are of this type. Normally this doesn't
-	   make any difference, but gives more gentle handling of IOMMU overflow. */
-	if (iommu_sac_force && (mask >= 0xffffffffffULL)) { 
-		printk(KERN_INFO "%s: Force SAC with mask %Lx\n", dev->bus_id,mask);
-		return 0; 
-	}
-
-	return 1;
-} 
-
-int dma_get_cache_alignment(void)
-{
-	return boot_cpu_data.x86_clflush_size;
-}
-
-EXPORT_SYMBOL(dma_unmap_sg);
-EXPORT_SYMBOL(dma_map_sg);
-EXPORT_SYMBOL(dma_map_single);
-EXPORT_SYMBOL(dma_unmap_single);
-EXPORT_SYMBOL(dma_supported);
-EXPORT_SYMBOL(no_iommu);
-EXPORT_SYMBOL(force_iommu); 
-EXPORT_SYMBOL(bad_dma_address);
-EXPORT_SYMBOL(iommu_bio_merge);
-EXPORT_SYMBOL(iommu_sac_force);
-EXPORT_SYMBOL(dma_get_cache_alignment);
-EXPORT_SYMBOL(dma_alloc_coherent);
-EXPORT_SYMBOL(dma_free_coherent);
+static int no_agp;
 
 static __init unsigned long check_iommu_size(unsigned long aper, u64 aper_size)
 { 
@@ -772,12 +591,27 @@
  nommu:
  	/* Should not happen anymore */
 	printk(KERN_ERR "PCI-DMA: More than 4GB of RAM and no IOMMU\n"
-	       KERN_ERR "PCI-DMA: 32bit PCI IO may malfunction."); 
+	       KERN_ERR "PCI-DMA: 32bit PCI IO may malfunction.\n");
 	return -1; 
 } 
 
 extern int agp_amd64_init(void);
 
+static struct dma_mapping_ops gart_dma_ops = {
+	.mapping_error = NULL,
+	.map_single = gart_map_single,
+	.map_simple = gart_map_simple,
+	.unmap_single = gart_unmap_single,
+	.sync_single_for_cpu = NULL,
+	.sync_single_for_device = NULL,
+	.sync_single_range_for_cpu = NULL,
+	.sync_single_range_for_device = NULL,
+	.sync_sg_for_cpu = NULL,
+	.sync_sg_for_device = NULL,
+	.map_sg = gart_map_sg,
+	.unmap_sg = gart_unmap_sg,
+};
+
 static int __init pci_iommu_init(void)
 { 
 	struct agp_kern_info info;
@@ -799,16 +633,15 @@
 
 	if (swiotlb) { 
 		no_iommu = 1;
-		printk(KERN_INFO "PCI-DMA: Using software bounce buffering for IO (SWIOTLB)\n");
 		return -1; 
 	} 
 	
 	if (no_iommu ||
-	    (!force_iommu && end_pfn < 0xffffffff>>PAGE_SHIFT) ||
+	    (!force_iommu && end_pfn <= MAX_DMA32_PFN) ||
 	    !iommu_aperture ||
 	    (no_agp && init_k8_gatt(&info) < 0)) {
-		printk(KERN_INFO "PCI-DMA: Disabling IOMMU.\n"); 
 		no_iommu = 1;
+		no_iommu_init();
 		return -1;
 	}
 
@@ -885,100 +718,50 @@
 		     
 	flush_gart(NULL);
 
+	printk(KERN_INFO "PCI-DMA: using GART IOMMU.\n");
+	dma_ops = &gart_dma_ops;
+
 	return 0;
 } 
 
 /* Must execute after PCI subsystem */
 fs_initcall(pci_iommu_init);
 
-/* iommu=[size][,noagp][,off][,force][,noforce][,leak][,memaper[=order]][,merge]
-         [,forcesac][,fullflush][,nomerge][,biomerge]
-   size  set size of iommu (in bytes) 
-   noagp don't initialize the AGP driver and use full aperture.
-   off   don't use the IOMMU
-   leak  turn on simple iommu leak tracing (only when CONFIG_IOMMU_LEAK is on)
-   memaper[=order] allocate an own aperture over RAM with size 32MB^order.  
-   noforce don't force IOMMU usage. Default.
-   force  Force IOMMU.
-   merge  Do lazy merging. This may improve performance on some block devices.
-          Implies force (experimental)
-   biomerge Do merging at the BIO layer. This is more efficient than merge,
-            but should be only done with very big IOMMUs. Implies merge,force.
-   nomerge Don't do SG merging.
-   forcesac For SAC mode for masks <40bits  (experimental)
-   fullflush Flush IOMMU on each allocation (default) 
-   nofullflush Don't use IOMMU fullflush
-   allowed  overwrite iommu off workarounds for specific chipsets.
-   soft	 Use software bounce buffering (default for Intel machines)
-   noaperture Don't touch the aperture for AGP.
-*/
-__init int iommu_setup(char *p)
-{ 
-    int arg;
+void gart_parse_options(char *p)
+{
+	int arg;
 
-    while (*p) {
-	    if (!strncmp(p,"noagp",5))
-		    no_agp = 1;
-	    if (!strncmp(p,"off",3))
-		    no_iommu = 1;
-	    if (!strncmp(p,"force",5)) {
-		    force_iommu = 1;
-		    iommu_aperture_allowed = 1;
-	    }
-	    if (!strncmp(p,"allowed",7))
-		    iommu_aperture_allowed = 1;
-	    if (!strncmp(p,"noforce",7)) {
-		    iommu_merge = 0;
-		    force_iommu = 0;
-	    }
-	    if (!strncmp(p, "memaper", 7)) {
-		    fallback_aper_force = 1; 
-		    p += 7; 
-		    if (*p == '=') {
-			    ++p;
-			    if (get_option(&p, &arg))
-				    fallback_aper_order = arg;
-		    }
-	    } 
-	    if (!strncmp(p, "biomerge",8)) {
-		    iommu_bio_merge = 4096;
-		    iommu_merge = 1;
-		    force_iommu = 1;
-	    }
-	    if (!strncmp(p, "panic",5))
-		    panic_on_overflow = 1;
-	    if (!strncmp(p, "nopanic",7))
-		    panic_on_overflow = 0;	    
-	    if (!strncmp(p, "merge",5)) {
-		    iommu_merge = 1;
-		    force_iommu = 1; 
-	    }
-	    if (!strncmp(p, "nomerge",7))
-		    iommu_merge = 0;
-	    if (!strncmp(p, "forcesac",8))
-		    iommu_sac_force = 1;
-	    if (!strncmp(p, "fullflush",8))
-		    iommu_fullflush = 1;
-	    if (!strncmp(p, "nofullflush",11))
-		    iommu_fullflush = 0;
-	    if (!strncmp(p, "soft",4))
-		    swiotlb = 1;
-	    if (!strncmp(p, "noaperture",10))
-		    fix_aperture = 0;
 #ifdef CONFIG_IOMMU_LEAK
-	    if (!strncmp(p,"leak",4)) {
-		    leak_trace = 1;
-		    p += 4; 
-		    if (*p == '=') ++p;
-		    if (isdigit(*p) && get_option(&p, &arg))
-			    iommu_leak_pages = arg;
-	    } else
+	if (!strncmp(p,"leak",4)) {
+		leak_trace = 1;
+		p += 4;
+		if (*p == '=') ++p;
+		if (isdigit(*p) && get_option(&p, &arg))
+			iommu_leak_pages = arg;
+	}
 #endif
-	    if (isdigit(*p) && get_option(&p, &arg)) 
-		    iommu_size = arg;
-	    p += strcspn(p, ",");
-	    if (*p == ',')
-		    ++p;
-    }
-    return 1;
-} 
+	if (isdigit(*p) && get_option(&p, &arg))
+		iommu_size = arg;
+	if (!strncmp(p, "fullflush",8))
+		iommu_fullflush = 1;
+	if (!strncmp(p, "nofullflush",11))
+		iommu_fullflush = 0;
+	if (!strncmp(p,"noagp",5))
+		no_agp = 1;
+	if (!strncmp(p, "noaperture",10))
+		fix_aperture = 0;
+	/* duplicated from pci-dma.c */
+	if (!strncmp(p,"force",5))
+		iommu_aperture_allowed = 1;
+	if (!strncmp(p,"allowed",7))
+		iommu_aperture_allowed = 1;
+	if (!strncmp(p, "memaper", 7)) {
+		fallback_aper_force = 1;
+		p += 7;
+		if (*p == '=') {
+			++p;
+			if (get_option(&p, &arg))
+				fallback_aper_order = arg;
+		}
+	}
+}
diff --git a/arch/x86_64/kernel/pci-nommu.c b/arch/x86_64/kernel/pci-nommu.c
index 5a981dc..e415649 100644
--- a/arch/x86_64/kernel/pci-nommu.c
+++ b/arch/x86_64/kernel/pci-nommu.c
@@ -6,89 +6,94 @@
 #include <linux/string.h>
 #include <asm/proto.h>
 #include <asm/processor.h>
+#include <asm/dma.h>
 
-int iommu_merge = 0;
-EXPORT_SYMBOL(iommu_merge);
-
-dma_addr_t bad_dma_address;
-EXPORT_SYMBOL(bad_dma_address);
-
-int iommu_bio_merge = 0;
-EXPORT_SYMBOL(iommu_bio_merge);
-
-int iommu_sac_force = 0;
-EXPORT_SYMBOL(iommu_sac_force);
-
-/* 
- * Dummy IO MMU functions
- */
-
-void *dma_alloc_coherent(struct device *hwdev, size_t size,
-			 dma_addr_t *dma_handle, gfp_t gfp)
+static int
+check_addr(char *name, struct device *hwdev, dma_addr_t bus, size_t size)
 {
-	void *ret;
-	u64 mask;
-	int order = get_order(size);
-
-	if (hwdev)
-		mask = hwdev->coherent_dma_mask & *hwdev->dma_mask;
-	else
-		mask = 0xffffffff;
-	for (;;) {
-		ret = (void *)__get_free_pages(gfp, order);
-		if (ret == NULL)
-			return NULL;
-		*dma_handle = virt_to_bus(ret);
-		if ((*dma_handle & ~mask) == 0)
-			break;
-		free_pages((unsigned long)ret, order);
-		if (gfp & GFP_DMA)
-			return NULL;
-		gfp |= GFP_DMA;
+        if (hwdev && bus + size > *hwdev->dma_mask) {
+		printk(KERN_ERR
+		    "nommu_%s: overflow %Lx+%lu of device mask %Lx\n",
+	       name, (long long)bus, size, (long long)*hwdev->dma_mask);
+		return 0;
 	}
-
-	memset(ret, 0, size);
-	return ret;
-}
-EXPORT_SYMBOL(dma_alloc_coherent);
-
-void dma_free_coherent(struct device *hwdev, size_t size,
-			 void *vaddr, dma_addr_t dma_handle)
-{
-	free_pages((unsigned long)vaddr, get_order(size));
-}
-EXPORT_SYMBOL(dma_free_coherent);
-
-int dma_supported(struct device *hwdev, u64 mask)
-{
-        /*
-         * we fall back to GFP_DMA when the mask isn't all 1s,
-         * so we can't guarantee allocations that must be
-         * within a tighter range than GFP_DMA..
-	 * RED-PEN this won't work for pci_map_single. Caller has to
-	 * use GFP_DMA in the first place.
-         */
-        if (mask < 0x00ffffff)
-                return 0;
-
 	return 1;
-} 
-EXPORT_SYMBOL(dma_supported);
-
-int dma_get_cache_alignment(void)
-{
-	return boot_cpu_data.x86_clflush_size;
 }
-EXPORT_SYMBOL(dma_get_cache_alignment);
 
-static int __init check_ram(void) 
-{ 
-	if (end_pfn >= 0xffffffff>>PAGE_SHIFT) { 
-		printk(
-		KERN_ERR "WARNING more than 4GB of memory but IOMMU not compiled in.\n"
-		KERN_ERR "WARNING 32bit PCI may malfunction.\n");
-	} 
-	return 0;
-} 
-__initcall(check_ram);
+static dma_addr_t
+nommu_map_single(struct device *hwdev, void *ptr, size_t size,
+	       int direction)
+{
+	dma_addr_t bus = virt_to_bus(ptr);
+	if (!check_addr("map_single", hwdev, bus, size))
+				return bad_dma_address;
+	return bus;
+}
 
+void nommu_unmap_single(struct device *dev, dma_addr_t addr,size_t size,
+			int direction)
+{
+}
+
+/* Map a set of buffers described by scatterlist in streaming
+ * mode for DMA.  This is the scatter-gather version of the
+ * above pci_map_single interface.  Here the scatter gather list
+ * elements are each tagged with the appropriate dma address
+ * and length.  They are obtained via sg_dma_{address,length}(SG).
+ *
+ * NOTE: An implementation may be able to use a smaller number of
+ *       DMA address/length pairs than there are SG table elements.
+ *       (for example via virtual mapping capabilities)
+ *       The routine returns the number of addr/length pairs actually
+ *       used, at most nents.
+ *
+ * Device ownership issues as mentioned above for pci_map_single are
+ * the same here.
+ */
+int nommu_map_sg(struct device *hwdev, struct scatterlist *sg,
+	       int nents, int direction)
+{
+	int i;
+
+	BUG_ON(direction == DMA_NONE);
+ 	for (i = 0; i < nents; i++ ) {
+		struct scatterlist *s = &sg[i];
+		BUG_ON(!s->page);
+		s->dma_address = virt_to_bus(page_address(s->page) +s->offset);
+		if (!check_addr("map_sg", hwdev, s->dma_address, s->length))
+			return 0;
+		s->dma_length = s->length;
+	}
+	return nents;
+}
+
+/* Unmap a set of streaming mode DMA translations.
+ * Again, cpu read rules concerning calls here are the same as for
+ * pci_unmap_single() above.
+ */
+void nommu_unmap_sg(struct device *dev, struct scatterlist *sg,
+		  int nents, int dir)
+{
+}
+
+struct dma_mapping_ops nommu_dma_ops = {
+	.map_single = nommu_map_single,
+	.unmap_single = nommu_unmap_single,
+	.map_sg = nommu_map_sg,
+	.unmap_sg = nommu_unmap_sg,
+	.is_phys = 1,
+};
+
+void __init no_iommu_init(void)
+{
+	if (dma_ops)
+		return;
+	printk(KERN_INFO "PCI-DMA: Disabling IOMMU.\n");
+	dma_ops = &nommu_dma_ops;
+	if (end_pfn > MAX_DMA32_PFN) {
+		printk(KERN_ERR
+		       "WARNING more than 4GB of memory but IOMMU not compiled in.\n"
+		       KERN_ERR "WARNING 32bit PCI may malfunction.\n"
+		       KERN_ERR "You might want to enable CONFIG_GART_IOMMU\n");
+	}
+}
diff --git a/arch/x86_64/kernel/pci-swiotlb.c b/arch/x86_64/kernel/pci-swiotlb.c
new file mode 100644
index 0000000..3569a25
--- /dev/null
+++ b/arch/x86_64/kernel/pci-swiotlb.c
@@ -0,0 +1,42 @@
+/* Glue code to lib/swiotlb.c */
+
+#include <linux/pci.h>
+#include <linux/cache.h>
+#include <linux/module.h>
+#include <asm/dma-mapping.h>
+#include <asm/proto.h>
+#include <asm/swiotlb.h>
+#include <asm/dma.h>
+
+int swiotlb __read_mostly;
+EXPORT_SYMBOL(swiotlb);
+
+struct dma_mapping_ops swiotlb_dma_ops = {
+	.mapping_error = swiotlb_dma_mapping_error,
+	.alloc_coherent = swiotlb_alloc_coherent,
+	.free_coherent = swiotlb_free_coherent,
+	.map_single = swiotlb_map_single,
+	.unmap_single = swiotlb_unmap_single,
+	.sync_single_for_cpu = swiotlb_sync_single_for_cpu,
+	.sync_single_for_device = swiotlb_sync_single_for_device,
+	.sync_single_range_for_cpu = swiotlb_sync_single_range_for_cpu,
+	.sync_single_range_for_device = swiotlb_sync_single_range_for_device,
+	.sync_sg_for_cpu = swiotlb_sync_sg_for_cpu,
+	.sync_sg_for_device = swiotlb_sync_sg_for_device,
+	.map_sg = swiotlb_map_sg,
+	.unmap_sg = swiotlb_unmap_sg,
+	.dma_supported = NULL,
+};
+
+void pci_swiotlb_init(void)
+{
+	/* don't initialize swiotlb if iommu=off (no_iommu=1) */
+	if (!iommu_aperture && !no_iommu &&
+	    (end_pfn > MAX_DMA32_PFN || force_iommu))
+	       swiotlb = 1;
+	if (swiotlb) {
+		swiotlb_init();
+		printk(KERN_INFO "PCI-DMA: Using software bounce buffering for IO (SWIOTLB)\n");
+		dma_ops = &swiotlb_dma_ops;
+	}
+}
diff --git a/arch/x86_64/kernel/process.c b/arch/x86_64/kernel/process.c
index 3060ed9..669cf0e 100644
--- a/arch/x86_64/kernel/process.c
+++ b/arch/x86_64/kernel/process.c
@@ -36,6 +36,7 @@
 #include <linux/utsname.h>
 #include <linux/random.h>
 #include <linux/kprobes.h>
+#include <linux/notifier.h>
 
 #include <asm/uaccess.h>
 #include <asm/pgtable.h>
@@ -50,13 +51,12 @@
 #include <asm/desc.h>
 #include <asm/proto.h>
 #include <asm/ia32.h>
+#include <asm/idle.h>
 
 asmlinkage extern void ret_from_fork(void);
 
 unsigned long kernel_thread_flags = CLONE_VM | CLONE_UNTRACED;
 
-static atomic_t hlt_counter = ATOMIC_INIT(0);
-
 unsigned long boot_option_idle_override = 0;
 EXPORT_SYMBOL(boot_option_idle_override);
 
@@ -66,19 +66,49 @@
 void (*pm_idle)(void);
 static DEFINE_PER_CPU(unsigned int, cpu_idle_state);
 
-void disable_hlt(void)
+static struct notifier_block *idle_notifier;
+static DEFINE_SPINLOCK(idle_notifier_lock);
+
+void idle_notifier_register(struct notifier_block *n)
 {
-	atomic_inc(&hlt_counter);
+	unsigned long flags;
+	spin_lock_irqsave(&idle_notifier_lock, flags);
+	notifier_chain_register(&idle_notifier, n);
+	spin_unlock_irqrestore(&idle_notifier_lock, flags);
+}
+EXPORT_SYMBOL_GPL(idle_notifier_register);
+
+void idle_notifier_unregister(struct notifier_block *n)
+{
+	unsigned long flags;
+	spin_lock_irqsave(&idle_notifier_lock, flags);
+	notifier_chain_unregister(&idle_notifier, n);
+	spin_unlock_irqrestore(&idle_notifier_lock, flags);
+}
+EXPORT_SYMBOL(idle_notifier_unregister);
+
+enum idle_state { CPU_IDLE, CPU_NOT_IDLE };
+static DEFINE_PER_CPU(enum idle_state, idle_state) = CPU_NOT_IDLE;
+
+void enter_idle(void)
+{
+	__get_cpu_var(idle_state) = CPU_IDLE;
+	notifier_call_chain(&idle_notifier, IDLE_START, NULL);
 }
 
-EXPORT_SYMBOL(disable_hlt);
-
-void enable_hlt(void)
+static void __exit_idle(void)
 {
-	atomic_dec(&hlt_counter);
+	__get_cpu_var(idle_state) = CPU_NOT_IDLE;
+	notifier_call_chain(&idle_notifier, IDLE_END, NULL);
 }
 
-EXPORT_SYMBOL(enable_hlt);
+/* Called from interrupts to signify idle end */
+void exit_idle(void)
+{
+	if (current->pid | read_pda(irqcount))
+		return;
+	__exit_idle();
+}
 
 /*
  * We use this if we don't have any better
@@ -88,21 +118,16 @@
 {
 	local_irq_enable();
 
-	if (!atomic_read(&hlt_counter)) {
-		clear_thread_flag(TIF_POLLING_NRFLAG);
-		smp_mb__after_clear_bit();
-		while (!need_resched()) {
-			local_irq_disable();
-			if (!need_resched())
-				safe_halt();
-			else
-				local_irq_enable();
-		}
-		set_thread_flag(TIF_POLLING_NRFLAG);
-	} else {
-		while (!need_resched())
-			cpu_relax();
+	clear_thread_flag(TIF_POLLING_NRFLAG);
+	smp_mb__after_clear_bit();
+	while (!need_resched()) {
+		local_irq_disable();
+		if (!need_resched())
+			safe_halt();
+		else
+			local_irq_enable();
 	}
+	set_thread_flag(TIF_POLLING_NRFLAG);
 }
 
 /*
@@ -201,7 +226,9 @@
 				idle = default_idle;
 			if (cpu_is_offline(smp_processor_id()))
 				play_dead();
+			enter_idle();
 			idle();
+			__exit_idle();
 		}
 
 		preempt_enable_no_resched();
diff --git a/arch/x86_64/kernel/ptrace.c b/arch/x86_64/kernel/ptrace.c
index a87b6ce..86248bc 100644
--- a/arch/x86_64/kernel/ptrace.c
+++ b/arch/x86_64/kernel/ptrace.c
@@ -36,9 +36,12 @@
  * in exit.c or in signal.c.
  */
 
-/* determines which flags the user has access to. */
-/* 1 = access 0 = no access */
-#define FLAG_MASK 0x44dd5UL
+/*
+ * Determines which flags the user has access to [1 = access, 0 = no access].
+ * Prohibits changing ID(21), VIP(20), VIF(19), VM(17), IOPL(12-13), IF(9).
+ * Also masks reserved bits (63-22, 15, 5, 3, 1).
+ */
+#define FLAG_MASK 0x54dd5UL
 
 /* set's the trap flag. */
 #define TRAP_FLAG 0x100UL
diff --git a/arch/x86_64/kernel/reboot.c b/arch/x86_64/kernel/reboot.c
index 75235ed..57117b8 100644
--- a/arch/x86_64/kernel/reboot.c
+++ b/arch/x86_64/kernel/reboot.c
@@ -6,6 +6,7 @@
 #include <linux/kernel.h>
 #include <linux/ctype.h>
 #include <linux/string.h>
+#include <linux/pm.h>
 #include <asm/io.h>
 #include <asm/kdebug.h>
 #include <asm/delay.h>
@@ -154,10 +155,11 @@
 
 void machine_power_off(void)
 {
-	if (!reboot_force) {
-		machine_shutdown();
-	}
-	if (pm_power_off)
+	if (pm_power_off) {
+		if (!reboot_force) {
+			machine_shutdown();
+		}
 		pm_power_off();
+	}
 }
 
diff --git a/arch/x86_64/kernel/setup.c b/arch/x86_64/kernel/setup.c
index a0e0c9c..28895c0 100644
--- a/arch/x86_64/kernel/setup.c
+++ b/arch/x86_64/kernel/setup.c
@@ -44,6 +44,8 @@
 #include <linux/mmzone.h>
 #include <linux/kexec.h>
 #include <linux/cpufreq.h>
+#include <linux/dmi.h>
+#include <linux/dma-mapping.h>
 
 #include <asm/mtrr.h>
 #include <asm/uaccess.h>
@@ -62,7 +64,9 @@
 #include <asm/setup.h>
 #include <asm/mach_apic.h>
 #include <asm/numa.h>
+#include <asm/swiotlb.h>
 #include <asm/sections.h>
+#include <asm/gart-mapping.h>
 
 /*
  * Machine setup..
@@ -87,11 +91,6 @@
 
 unsigned long saved_video_mode;
 
-#ifdef CONFIG_SWIOTLB
-int swiotlb;
-EXPORT_SYMBOL(swiotlb);
-#endif
-
 /*
  * Setup options
  */
@@ -278,10 +277,6 @@
 	int len = 0;
 	int userdef = 0;
 
-	/* Save unparsed command line copy for /proc/cmdline */
-	memcpy(saved_command_line, COMMAND_LINE, COMMAND_LINE_SIZE);
-	saved_command_line[COMMAND_LINE_SIZE-1] = '\0';
-
 	for (;;) {
 		if (c != ' ') 
 			goto next_char; 
@@ -348,10 +343,14 @@
 		    !memcmp(from, "disableapic", 11))
 			disable_apic = 1;
 
-		if (!memcmp(from, "noapic", 6)) 
+		/* Don't confuse with noapictimer */
+		if (!memcmp(from, "noapic", 6) &&
+			(from[6] == ' ' || from[6] == 0))
 			skip_ioapic_setup = 1;
 
-		if (!memcmp(from, "apic", 4)) { 
+		/* Make sure to not confuse with apic= */
+		if (!memcmp(from, "apic", 4) &&
+			(from[4] == ' ' || from[4] == 0)) {
 			skip_ioapic_setup = 0;
 			ioapic_force = 1;
 		}
@@ -386,11 +385,9 @@
 			numa_setup(from+5); 
 #endif
 
-#ifdef CONFIG_GART_IOMMU 
 		if (!memcmp(from,"iommu=",6)) { 
 			iommu_setup(from+6); 
 		}
-#endif
 
 		if (!memcmp(from,"oops=panic", 10))
 			panic_on_oops = 1;
@@ -479,6 +476,8 @@
      k8nops + 1 + 2 + 3 + 4 + 5 + 6 + 7,
 }; 
 
+extern char __vsyscall_0;
+
 /* Replace instructions with better alternatives for this CPU type.
 
    This runs before SMP is initialized to avoid SMP problems with
@@ -490,11 +489,17 @@
 	struct alt_instr *a; 
 	int diff, i, k;
 	for (a = start; (void *)a < end; a++) { 
+		u8 *instr;
+
 		if (!boot_cpu_has(a->cpuid))
 			continue;
 
 		BUG_ON(a->replacementlen > a->instrlen); 
-		__inline_memcpy(a->instr, a->replacement, a->replacementlen); 
+		instr = a->instr;
+		/* vsyscall code is not mapped yet. resolve it manually. */
+		if (instr >= (u8 *)VSYSCALL_START && instr < (u8*)VSYSCALL_END)
+			instr = __va(instr - (u8*)VSYSCALL_START + (u8*)__pa_symbol(&__vsyscall_0));
+		__inline_memcpy(instr, a->replacement, a->replacementlen);
 		diff = a->instrlen - a->replacementlen; 
 
 		/* Pad the rest with nops */
@@ -502,7 +507,7 @@
 			k = diff;
 			if (k > ASM_NOP_MAX)
 				k = ASM_NOP_MAX;
-			__inline_memcpy(a->instr + i, k8_nops[k], k); 
+			__inline_memcpy(instr + i, k8_nops[k], k);
 		} 
 	}
 } 
@@ -706,6 +711,8 @@
 	acpi_boot_init();
 #endif
 
+	init_cpu_to_node();
+
 #ifdef CONFIG_X86_LOCAL_APIC
 	/*
 	 * get boot-time SMP configuration:
@@ -870,7 +877,6 @@
 static int __init init_amd(struct cpuinfo_x86 *c)
 {
 	int r;
-	int level;
 
 #ifdef CONFIG_SMP
 	unsigned long value;
@@ -893,11 +899,6 @@
 	   3DNow is IDd by bit 31 in extended CPUID (1*32+31) anyway */
 	clear_bit(0*32+31, &c->x86_capability);
 	
-	/* C-stepping K8? */
-	level = cpuid_eax(1);
-	if ((level >= 0x0f48 && level < 0x0f50) || level >= 0x0f58)
-		set_bit(X86_FEATURE_K8_C, &c->x86_capability);
-
 	r = get_model_name(c);
 	if (!r) { 
 		switch (c->x86) { 
@@ -910,6 +911,10 @@
 	} 
 	display_cacheinfo(c);
 
+	/* c->x86_power is 8000_0007 edx. Bit 8 is constant TSC */
+	if (c->x86_power & (1<<8))
+		set_bit(X86_FEATURE_CONSTANT_TSC, &c->x86_capability);
+
 	if (c->extended_cpuid_level >= 0x80000008) {
 		c->x86_max_cores = (cpuid_ecx(0x80000008) & 0xff) + 1;
 		if (c->x86_max_cores & (c->x86_max_cores - 1))
@@ -1028,8 +1033,10 @@
 
 	if (c->x86 == 15)
 		c->x86_cache_alignment = c->x86_clflush_size * 2;
-	if (c->x86 >= 15)
+	if ((c->x86 == 0xf && c->x86_model >= 0x03) ||
+	    (c->x86 == 0x6 && c->x86_model >= 0x0e))
 		set_bit(X86_FEATURE_CONSTANT_TSC, &c->x86_capability);
+	set_bit(X86_FEATURE_SYNC_RDTSC, &c->x86_capability);
  	c->x86_max_cores = intel_num_cpu_cores(c);
 
 	srat_detect_node();
@@ -1228,7 +1235,7 @@
 		NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 		NULL, NULL, NULL, "syscall", NULL, NULL, NULL, NULL,
 		NULL, NULL, NULL, NULL, "nx", NULL, "mmxext", NULL,
-		NULL, "fxsr_opt", NULL, NULL, NULL, "lm", "3dnowext", "3dnow",
+		NULL, "fxsr_opt", "rdtscp", NULL, NULL, "lm", "3dnowext", "3dnow",
 
 		/* Transmeta-defined */
 		"recovery", "longrun", NULL, "lrti", NULL, NULL, NULL, NULL,
@@ -1256,7 +1263,7 @@
 		NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 
 		/* AMD-defined (#2) */
-		"lahf_lm", "cmp_legacy", NULL, NULL, NULL, NULL, NULL, NULL,
+		"lahf_lm", "cmp_legacy", "svm", NULL, "cr8_legacy", NULL, NULL, NULL,
 		NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 		NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 		NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
@@ -1267,7 +1274,9 @@
 		"vid",  /* voltage id control */
 		"ttp",  /* thermal trip */
 		"tm",
-		"stc"
+		"stc",
+		NULL,
+		/* nothing */	/* constant_tsc - moved to flags */
 	};
 
 
@@ -1347,8 +1356,11 @@
 		unsigned i;
 		for (i = 0; i < 32; i++) 
 			if (c->x86_power & (1 << i)) {
-				if (i < ARRAY_SIZE(x86_power_flags))
-					seq_printf(m, " %s", x86_power_flags[i]);
+				if (i < ARRAY_SIZE(x86_power_flags) &&
+					x86_power_flags[i])
+					seq_printf(m, "%s%s",
+						x86_power_flags[i][0]?" ":"",
+						x86_power_flags[i]);
 				else
 					seq_printf(m, " [%d]", i);
 			}
@@ -1380,3 +1392,11 @@
 	.stop =	c_stop,
 	.show =	show_cpuinfo,
 };
+
+static int __init run_dmi_scan(void)
+{
+	dmi_scan_machine();
+	return 0;
+}
+core_initcall(run_dmi_scan);
+
diff --git a/arch/x86_64/kernel/setup64.c b/arch/x86_64/kernel/setup64.c
index 06dc354..6eff51e 100644
--- a/arch/x86_64/kernel/setup64.c
+++ b/arch/x86_64/kernel/setup64.c
@@ -30,7 +30,8 @@
 
 cpumask_t cpu_initialized __cpuinitdata = CPU_MASK_NONE;
 
-struct x8664_pda cpu_pda[NR_CPUS] __cacheline_aligned; 
+struct x8664_pda *_cpu_pda[NR_CPUS] __read_mostly;
+struct x8664_pda boot_cpu_pda[NR_CPUS] __cacheline_aligned;
 
 struct desc_ptr idt_descr = { 256 * 16, (unsigned long) idt_table }; 
 
@@ -110,18 +111,18 @@
 		}
 		if (!ptr)
 			panic("Cannot allocate cpu data for CPU %d\n", i);
-		cpu_pda[i].data_offset = ptr - __per_cpu_start;
+		cpu_pda(i)->data_offset = ptr - __per_cpu_start;
 		memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start);
 	}
 } 
 
 void pda_init(int cpu)
 { 
-	struct x8664_pda *pda = &cpu_pda[cpu];
+	struct x8664_pda *pda = cpu_pda(cpu);
 
 	/* Setup up data that may be needed in __get_free_pages early */
 	asm volatile("movl %0,%%fs ; movl %0,%%gs" :: "r" (0)); 
-	wrmsrl(MSR_GS_BASE, cpu_pda + cpu);
+	wrmsrl(MSR_GS_BASE, pda);
 
 	pda->cpunumber = cpu; 
 	pda->irqcount = -1;
@@ -145,7 +146,7 @@
 	pda->irqstackptr += IRQSTACKSIZE-64;
 } 
 
-char boot_exception_stacks[N_EXCEPTION_STACKS * EXCEPTION_STKSZ] 
+char boot_exception_stacks[(N_EXCEPTION_STACKS - 2) * EXCEPTION_STKSZ + DEBUG_STKSZ]
 __attribute__((section(".bss.page_aligned")));
 
 /* May not be marked __init: used by software suspend */
@@ -213,23 +214,14 @@
 	 * Initialize the per-CPU GDT with the boot GDT,
 	 * and set up the GDT descriptor:
 	 */
-	if (cpu) {
-		memcpy(cpu_gdt_table[cpu], cpu_gdt_table[0], GDT_SIZE);
-	}	
+	if (cpu)
+ 		memcpy(cpu_gdt(cpu), cpu_gdt_table, GDT_SIZE);
 
 	cpu_gdt_descr[cpu].size = GDT_SIZE;
-	cpu_gdt_descr[cpu].address = (unsigned long)cpu_gdt_table[cpu];
 	asm volatile("lgdt %0" :: "m" (cpu_gdt_descr[cpu]));
 	asm volatile("lidt %0" :: "m" (idt_descr));
 
-	memcpy(me->thread.tls_array, cpu_gdt_table[cpu], GDT_ENTRY_TLS_ENTRIES * 8);
-
-	/*
-	 * Delete NT
-	 */
-
-	asm volatile("pushfq ; popq %%rax ; btr $14,%%rax ; pushq %%rax ; popfq" ::: "eax");
-
+	memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8);
 	syscall_init();
 
 	wrmsrl(MSR_FS_BASE, 0);
@@ -243,13 +235,27 @@
 	 */
 	for (v = 0; v < N_EXCEPTION_STACKS; v++) {
 		if (cpu) {
-			estacks = (char *)__get_free_pages(GFP_ATOMIC, 
-						   EXCEPTION_STACK_ORDER);
+			static const unsigned int order[N_EXCEPTION_STACKS] = {
+				[0 ... N_EXCEPTION_STACKS - 1] = EXCEPTION_STACK_ORDER,
+				[DEBUG_STACK - 1] = DEBUG_STACK_ORDER
+			};
+
+			estacks = (char *)__get_free_pages(GFP_ATOMIC, order[v]);
 			if (!estacks)
 				panic("Cannot allocate exception stack %ld %d\n",
 				      v, cpu); 
 		}
-		estacks += EXCEPTION_STKSZ;
+		switch (v + 1) {
+#if DEBUG_STKSZ > EXCEPTION_STKSZ
+		case DEBUG_STACK:
+			cpu_pda[cpu].debugstack = (unsigned long)estacks;
+			estacks += DEBUG_STKSZ;
+			break;
+#endif
+		default:
+			estacks += EXCEPTION_STKSZ;
+			break;
+		}
 		t->ist[v] = (unsigned long)estacks;
 	}
 
diff --git a/arch/x86_64/kernel/smp.c b/arch/x86_64/kernel/smp.c
index cfc3d9d..19ef012 100644
--- a/arch/x86_64/kernel/smp.c
+++ b/arch/x86_64/kernel/smp.c
@@ -27,6 +27,7 @@
 #include <asm/mmu_context.h>
 #include <asm/proto.h>
 #include <asm/apicdef.h>
+#include <asm/idle.h>
 
 /*
  *	Smarter SMP flushing macros. 
@@ -280,11 +281,6 @@
 	on_each_cpu(do_flush_tlb_all, NULL, 1, 1);
 }
 
-void smp_kdb_stop(void)
-{
-	send_IPI_allbutself(KDB_VECTOR);
-}
-
 /*
  * this function sends a 'reschedule' IPI to another CPU.
  * it goes straight through and wastes no time serializing
@@ -512,6 +508,7 @@
 	/*
 	 * At this point the info structure may be out of scope unless wait==1
 	 */
+	exit_idle();
 	irq_enter();
 	(*func)(info);
 	irq_exit();
diff --git a/arch/x86_64/kernel/smpboot.c b/arch/x86_64/kernel/smpboot.c
index ecbd7b8..c9e941a 100644
--- a/arch/x86_64/kernel/smpboot.c
+++ b/arch/x86_64/kernel/smpboot.c
@@ -335,7 +335,13 @@
 
 static void __cpuinit tsc_sync_wait(void)
 {
-	if (notscsync || !cpu_has_tsc)
+	/*
+	 * When the CPU has synchronized TSCs assume the BIOS
+  	 * or the hardware already synced.  Otherwise we could
+	 * mess up a possible perfect synchronization with a
+	 * not-quite-perfect algorithm.
+	 */
+	if (notscsync || !cpu_has_tsc || !unsynchronized_tsc())
 		return;
 	sync_tsc(0);
 }
@@ -646,6 +652,7 @@
 		send_status = apic_read(APIC_ICR) & APIC_ICR_BUSY;
 	} while (send_status && (timeout++ < 1000));
 
+	mb();
 	atomic_set(&init_deasserted, 1);
 
 	num_starts = 2;
@@ -659,7 +666,6 @@
 
 	for (j = 1; j <= num_starts; j++) {
 		Dprintk("Sending STARTUP #%d.\n",j);
-		apic_read_around(APIC_SPIV);
 		apic_write(APIC_ESR, 0);
 		apic_read(APIC_ESR);
 		Dprintk("After apic_write.\n");
@@ -698,7 +704,6 @@
 		 * Due to the Pentium erratum 3AP.
 		 */
 		if (maxlvt > 3) {
-			apic_read_around(APIC_SPIV);
 			apic_write(APIC_ESR, 0);
 		}
 		accept_status = (apic_read(APIC_ESR) & 0xEF);
@@ -743,6 +748,30 @@
 	};
 	DECLARE_WORK(work, do_fork_idle, &c_idle);
 
+	/* allocate memory for gdts of secondary cpus. Hotplug is considered */
+	if (!cpu_gdt_descr[cpu].address &&
+		!(cpu_gdt_descr[cpu].address = get_zeroed_page(GFP_KERNEL))) {
+		printk(KERN_ERR "Failed to allocate GDT for CPU %d\n", cpu);
+		return -1;
+	}
+
+	/* Allocate node local memory for AP pdas */
+	if (cpu_pda(cpu) == &boot_cpu_pda[cpu]) {
+		struct x8664_pda *newpda, *pda;
+		int node = cpu_to_node(cpu);
+		pda = cpu_pda(cpu);
+		newpda = kmalloc_node(sizeof (struct x8664_pda), GFP_ATOMIC,
+				      node);
+		if (newpda) {
+			memcpy(newpda, pda, sizeof (struct x8664_pda));
+			cpu_pda(cpu) = newpda;
+		} else
+			printk(KERN_ERR
+		"Could not allocate node local PDA for CPU %d on node %d\n",
+				cpu, node);
+	}
+
+
 	c_idle.idle = get_idle_for_cpu(cpu);
 
 	if (c_idle.idle) {
@@ -778,7 +807,7 @@
 
 do_rest:
 
-	cpu_pda[cpu].pcurrent = c_idle.idle;
+	cpu_pda(cpu)->pcurrent = c_idle.idle;
 
 	start_rip = setup_trampoline();
 
@@ -811,11 +840,8 @@
 	/*
 	 * Be paranoid about clearing APIC errors.
 	 */
-	if (APIC_INTEGRATED(apic_version[apicid])) {
-		apic_read_around(APIC_SPIV);
-		apic_write(APIC_ESR, 0);
-		apic_read(APIC_ESR);
-	}
+	apic_write(APIC_ESR, 0);
+	apic_read(APIC_ESR);
 
 	/*
 	 * Status is now clean
@@ -927,8 +953,8 @@
  *
  * Three ways to find out the number of additional hotplug CPUs:
  * - If the BIOS specified disabled CPUs in ACPI/mptables use that.
- * - otherwise use half of the available CPUs or 2, whatever is more.
  * - The user can overwrite it with additional_cpus=NUM
+ * - Otherwise don't reserve additional CPUs.
  * We do this because additional CPUs waste a lot of memory.
  * -AK
  */
@@ -938,13 +964,10 @@
 	int possible;
 
  	if (additional_cpus == -1) {
- 		if (disabled_cpus > 0) {
+ 		if (disabled_cpus > 0)
  			additional_cpus = disabled_cpus;
- 		} else {
- 			additional_cpus = num_processors / 2;
- 			if (additional_cpus == 0)
- 				additional_cpus = 2;
- 		}
+ 		else
+			additional_cpus = 0;
  	}
 	possible = num_processors + additional_cpus;
 	if (possible > NR_CPUS) 
@@ -996,7 +1019,7 @@
 	/*
 	 * If we couldn't find a local APIC, then get out of here now!
 	 */
-	if (APIC_INTEGRATED(apic_version[boot_cpu_id]) && !cpu_has_apic) {
+	if (!cpu_has_apic) {
 		printk(KERN_ERR "BIOS bug, local APIC #%d not detected!...\n",
 			boot_cpu_id);
 		printk(KERN_ERR "... forcing use of dummy APIC emulation. (tell your hw vendor)\n");
diff --git a/arch/x86_64/kernel/suspend.c b/arch/x86_64/kernel/suspend.c
index fd2bef7..ecbd34c 100644
--- a/arch/x86_64/kernel/suspend.c
+++ b/arch/x86_64/kernel/suspend.c
@@ -120,7 +120,7 @@
 
 	set_tss_desc(cpu,t);	/* This just modifies memory; should not be neccessary. But... This is neccessary, because 386 hardware has concept of busy TSS or some similar stupidity. */
 
-	cpu_gdt_table[cpu][GDT_ENTRY_TSS].type = 9;
+	cpu_gdt(cpu)[GDT_ENTRY_TSS].type = 9;
 
 	syscall_init();                         /* This sets MSR_*STAR and related */
 	load_TR_desc();				/* This does ltr */
diff --git a/arch/x86_64/kernel/time.c b/arch/x86_64/kernel/time.c
index 43c9fa0..f8c47c6 100644
--- a/arch/x86_64/kernel/time.c
+++ b/arch/x86_64/kernel/time.c
@@ -71,14 +71,6 @@
 struct timespec __xtime __section_xtime;
 struct timezone __sys_tz __section_sys_tz;
 
-static inline void rdtscll_sync(unsigned long *tsc)
-{
-#ifdef CONFIG_SMP
-	sync_core();
-#endif
-	rdtscll(*tsc);
-}
-
 /*
  * do_gettimeoffset() returns microseconds since last timer interrupt was
  * triggered by hardware. A memory read of HPET is slower than a register read
@@ -93,7 +85,7 @@
 {
 	unsigned long t;
 	unsigned long x;
-	rdtscll_sync(&t);
+	t = get_cycles_sync();
 	if (t < vxtime.last_tsc) t = vxtime.last_tsc; /* hack */
 	x = ((t - vxtime.last_tsc) * vxtime.tsc_quot) >> 32;
 	return x;
@@ -259,8 +251,8 @@
 #endif
 
 	{
-			BIN_TO_BCD(real_seconds);
-			BIN_TO_BCD(real_minutes);
+		BIN_TO_BCD(real_seconds);
+		BIN_TO_BCD(real_minutes);
 		CMOS_WRITE(real_seconds, RTC_SECONDS);
 		CMOS_WRITE(real_minutes, RTC_MINUTES);
 	}
@@ -297,25 +289,21 @@
 			last_offset = vxtime.last;
 			base = monotonic_base;
 			this_offset = hpet_readl(HPET_COUNTER);
-
 		} while (read_seqretry(&xtime_lock, seq));
 		offset = (this_offset - last_offset);
 		offset *=(NSEC_PER_SEC/HZ)/hpet_tick;
 		return base + offset;
-	}else{
+	} else {
 		do {
 			seq = read_seqbegin(&xtime_lock);
 
 			last_offset = vxtime.last_tsc;
 			base = monotonic_base;
 		} while (read_seqretry(&xtime_lock, seq));
-		sync_core();
-		rdtscll(this_offset);
+		this_offset = get_cycles_sync();
 		offset = (this_offset - last_offset)*1000/cpu_khz; 
 		return base + offset;
 	}
-
-
 }
 EXPORT_SYMBOL(monotonic_clock);
 
@@ -391,7 +379,7 @@
 		delay = LATCH - 1 - delay;
 	}
 
-	rdtscll_sync(&tsc);
+	tsc = get_cycles_sync();
 
 	if (vxtime.mode == VXTIME_HPET) {
 		if (offset - vxtime.last > hpet_tick) {
@@ -471,6 +459,11 @@
  
 	write_sequnlock(&xtime_lock);
 
+#ifdef CONFIG_X86_LOCAL_APIC
+	if (using_apic_timer)
+		smp_send_timer_broadcast_ipi();
+#endif
+
 	return IRQ_HANDLED;
 }
 
@@ -509,10 +502,10 @@
 	return cycles_2_ns(a);
 }
 
-unsigned long get_cmos_time(void)
+static unsigned long get_cmos_time(void)
 {
-	unsigned int timeout, year, mon, day, hour, min, sec;
-	unsigned char last, this;
+	unsigned int timeout = 1000000, year, mon, day, hour, min, sec;
+	unsigned char uip = 0, this = 0;
 	unsigned long flags;
 
 /*
@@ -525,45 +518,41 @@
 
 	spin_lock_irqsave(&rtc_lock, flags);
 
-	timeout = 1000000;
-	last = this = 0;
-
-	while (timeout && last && !this) {
-		last = this;
+	while (timeout && (!uip || this)) {
+		uip |= this;
 		this = CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP;
 		timeout--;
 	}
 
-/*
- * Here we are safe to assume the registers won't change for a whole second, so
- * we just go ahead and read them.
-	 */
-
-		sec = CMOS_READ(RTC_SECONDS);
-		min = CMOS_READ(RTC_MINUTES);
-		hour = CMOS_READ(RTC_HOURS);
-		day = CMOS_READ(RTC_DAY_OF_MONTH);
-		mon = CMOS_READ(RTC_MONTH);
-		year = CMOS_READ(RTC_YEAR);
+	/*
+	 * Here we are safe to assume the registers won't change for a whole
+	 * second, so we just go ahead and read them.
+ 	 */
+	sec = CMOS_READ(RTC_SECONDS);
+	min = CMOS_READ(RTC_MINUTES);
+	hour = CMOS_READ(RTC_HOURS);
+	day = CMOS_READ(RTC_DAY_OF_MONTH);
+	mon = CMOS_READ(RTC_MONTH);
+	year = CMOS_READ(RTC_YEAR);
 
 	spin_unlock_irqrestore(&rtc_lock, flags);
 
-/*
- * We know that x86-64 always uses BCD format, no need to check the config
- * register.
- */
+	/*
+	 * We know that x86-64 always uses BCD format, no need to check the
+	 * config register.
+ 	*/
 
-	    BCD_TO_BIN(sec);
-	    BCD_TO_BIN(min);
-	    BCD_TO_BIN(hour);
-	    BCD_TO_BIN(day);
-	    BCD_TO_BIN(mon);
-	    BCD_TO_BIN(year);
+	BCD_TO_BIN(sec);
+	BCD_TO_BIN(min);
+	BCD_TO_BIN(hour);
+	BCD_TO_BIN(day);
+	BCD_TO_BIN(mon);
+	BCD_TO_BIN(year);
 
-/*
- * x86-64 systems only exists since 2002.
- * This will work up to Dec 31, 2100
- */
+	/*
+	 * x86-64 systems only exists since 2002.
+	 * This will work up to Dec 31, 2100
+	 */
 	year += 2000;
 
 	return mktime(year, mon, day, hour, min, sec);
@@ -695,8 +684,7 @@
 	do {
 		local_irq_disable();
 		hpet_now = hpet_readl(HPET_COUNTER);
-		sync_core();
-		rdtscl(tsc_now);
+		tsc_now = get_cycles_sync();
 		local_irq_restore(flags);
 	} while ((tsc_now - tsc_start) < TICK_COUNT &&
 		 (hpet_now - hpet_start) < TICK_COUNT);
@@ -726,11 +714,9 @@
 	outb(0xb0, 0x43);
 	outb((PIT_TICK_RATE / (1000 / 50)) & 0xff, 0x42);
 	outb((PIT_TICK_RATE / (1000 / 50)) >> 8, 0x42);
-	rdtscll(start);
-	sync_core();
+	start = get_cycles_sync();
 	while ((inb(0x61) & 0x20) == 0);
-	sync_core();
-	rdtscll(end);
+	end = get_cycles_sync();
 
 	spin_unlock_irqrestore(&i8253_lock, flags);
 	
@@ -744,7 +730,7 @@
 	unsigned int 		ntimer;
 
 	if (!vxtime.hpet_address)
-          return -1;
+        	return -1;
 
 	memset(&hd, 0, sizeof (hd));
 
@@ -878,8 +864,6 @@
 	timer_interrupt, SA_INTERRUPT, CPU_MASK_NONE, "timer", NULL, NULL
 };
 
-extern void __init config_acpi_tables(void);
-
 void __init time_init(void)
 {
 	char *timename;
@@ -934,7 +918,7 @@
 	vxtime.mode = VXTIME_TSC;
 	vxtime.quot = (1000000L << 32) / vxtime_hz;
 	vxtime.tsc_quot = (1000L << 32) / cpu_khz;
-	rdtscll_sync(&vxtime.last_tsc);
+	vxtime.last_tsc = get_cycles_sync();
 	setup_irq(0, &irq0);
 
 	set_cyc2ns_scale(cpu_khz);
@@ -948,7 +932,7 @@
  * Make an educated guess if the TSC is trustworthy and synchronized
  * over all CPUs.
  */
-static __init int unsynchronized_tsc(void)
+__init int unsynchronized_tsc(void)
 {
 #ifdef CONFIG_SMP
 	if (oem_force_hpet_timer())
@@ -959,7 +943,7 @@
  		return 0;
 #endif
  	/* Assume multi socket systems are not synchronized */
- 	return num_online_cpus() > 1;
+ 	return num_present_cpus() > 1;
 }
 
 /*
@@ -999,6 +983,10 @@
 static long clock_cmos_diff;
 static unsigned long sleep_start;
 
+/*
+ * sysfs support for the timer.
+ */
+
 static int timer_suspend(struct sys_device *dev, pm_message_t state)
 {
 	/*
@@ -1041,7 +1029,6 @@
 	set_kset_name("timer"),
 };
 
-
 /* XXX this driverfs stuff should probably go elsewhere later -john */
 static struct sys_device device_timer = {
 	.id	= 0,
@@ -1283,8 +1270,6 @@
 }
 #endif
 
-
-
 static int __init nohpet_setup(char *s) 
 { 
 	nohpet = 1;
@@ -1301,5 +1286,3 @@
 }
 
 __setup("notsc", notsc_setup);
-
-
diff --git a/arch/x86_64/kernel/trampoline.S b/arch/x86_64/kernel/trampoline.S
index 6d9c9a8..23a03eb9 100644
--- a/arch/x86_64/kernel/trampoline.S
+++ b/arch/x86_64/kernel/trampoline.S
@@ -42,8 +42,15 @@
 	movl	$0xA5A5A5A5, trampoline_data - r_base
 				# write marker for master knows we're running
 
-	lidt	idt_48 - r_base	# load idt with 0, 0
-	lgdt	gdt_48 - r_base	# load gdt with whatever is appropriate
+	/*
+	 * GDT tables in non default location kernel can be beyond 16MB and
+	 * lgdt will not be able to load the address as in real mode default
+	 * operand size is 16bit. Use lgdtl instead to force operand size
+	 * to 32 bit.
+	 */
+
+	lidtl	idt_48 - r_base	# load idt with 0, 0
+	lgdtl	gdt_48 - r_base	# load gdt with whatever is appropriate
 
 	xor	%ax, %ax
 	inc	%ax		# protected mode (PE) bit
diff --git a/arch/x86_64/kernel/traps.c b/arch/x86_64/kernel/traps.c
index bf337f4..2671fd4 100644
--- a/arch/x86_64/kernel/traps.c
+++ b/arch/x86_64/kernel/traps.c
@@ -70,7 +70,6 @@
 asmlinkage void alignment_check(void);
 asmlinkage void machine_check(void);
 asmlinkage void spurious_interrupt_bug(void);
-asmlinkage void call_debug(void);
 
 struct notifier_block *die_chain;
 static DEFINE_SPINLOCK(die_notifier_lock);
@@ -121,19 +120,31 @@
 static unsigned long *in_exception_stack(unsigned cpu, unsigned long stack,
 					unsigned *usedp, const char **idp)
 {
-	static const char ids[N_EXCEPTION_STACKS][8] = {
+	static char ids[][8] = {
 		[DEBUG_STACK - 1] = "#DB",
 		[NMI_STACK - 1] = "NMI",
 		[DOUBLEFAULT_STACK - 1] = "#DF",
 		[STACKFAULT_STACK - 1] = "#SS",
 		[MCE_STACK - 1] = "#MC",
+#if DEBUG_STKSZ > EXCEPTION_STKSZ
+		[N_EXCEPTION_STACKS ... N_EXCEPTION_STACKS + DEBUG_STKSZ / EXCEPTION_STKSZ - 2] = "#DB[?]"
+#endif
 	};
 	unsigned k;
 
 	for (k = 0; k < N_EXCEPTION_STACKS; k++) {
 		unsigned long end;
 
-		end = per_cpu(init_tss, cpu).ist[k];
+		switch (k + 1) {
+#if DEBUG_STKSZ > EXCEPTION_STKSZ
+		case DEBUG_STACK:
+			end = cpu_pda(cpu)->debugstack + DEBUG_STKSZ;
+			break;
+#endif
+		default:
+			end = per_cpu(init_tss, cpu).ist[k];
+			break;
+		}
 		if (stack >= end)
 			continue;
 		if (stack >= end - EXCEPTION_STKSZ) {
@@ -143,6 +154,22 @@
 			*idp = ids[k];
 			return (unsigned long *)end;
 		}
+#if DEBUG_STKSZ > EXCEPTION_STKSZ
+		if (k == DEBUG_STACK - 1 && stack >= end - DEBUG_STKSZ) {
+			unsigned j = N_EXCEPTION_STACKS - 1;
+
+			do {
+				++j;
+				end -= EXCEPTION_STKSZ;
+				ids[j][4] = '1' + (j - N_EXCEPTION_STACKS);
+			} while (stack < end - EXCEPTION_STKSZ);
+			if (*usedp & (1U << j))
+				break;
+			*usedp |= 1U << j;
+			*idp = ids[j];
+			return (unsigned long *)end;
+		}
+#endif
 	}
 	return NULL;
 }
@@ -156,9 +183,8 @@
 
 void show_trace(unsigned long *stack)
 {
-	unsigned long addr;
 	const unsigned cpu = safe_smp_processor_id();
-	unsigned long *irqstack_end = (unsigned long *)cpu_pda[cpu].irqstackptr;
+	unsigned long *irqstack_end = (unsigned long *)cpu_pda(cpu)->irqstackptr;
 	int i;
 	unsigned used = 0;
 
@@ -166,8 +192,14 @@
 
 #define HANDLE_STACK(cond) \
 	do while (cond) { \
-		addr = *stack++; \
+		unsigned long addr = *stack++; \
 		if (kernel_text_address(addr)) { \
+			if (i > 50) { \
+				printk("\n       "); \
+				i = 0; \
+			} \
+			else \
+				i += printk(" "); \
 			/* \
 			 * If the address is either in the text segment of the \
 			 * kernel, or in the region which contains vmalloc'ed \
@@ -177,25 +209,19 @@
 			 * out the call path that was taken. \
 			 */ \
 			i += printk_address(addr); \
-			if (i > 50) { \
-				printk("\n       "); \
-				i = 0; \
-			} \
-			else \
-				i += printk(" "); \
 		} \
 	} while (0)
 
-	for(i = 0; ; ) {
+	for(i = 11; ; ) {
 		const char *id;
 		unsigned long *estack_end;
 		estack_end = in_exception_stack(cpu, (unsigned long)stack,
 						&used, &id);
 
 		if (estack_end) {
-			i += printk(" <%s> ", id);
+			i += printk(" <%s>", id);
 			HANDLE_STACK (stack < estack_end);
-			i += printk(" <EOE> ");
+			i += printk(" <EOE>");
 			stack = (unsigned long *) estack_end[-2];
 			continue;
 		}
@@ -205,11 +231,11 @@
 				(IRQSTACKSIZE - 64) / sizeof(*irqstack);
 
 			if (stack >= irqstack && stack < irqstack_end) {
-				i += printk(" <IRQ> ");
+				i += printk(" <IRQ>");
 				HANDLE_STACK (stack < irqstack_end);
 				stack = (unsigned long *) (irqstack_end[-1]);
 				irqstack_end = NULL;
-				i += printk(" <EOI> ");
+				i += printk(" <EOI>");
 				continue;
 			}
 		}
@@ -226,8 +252,8 @@
 	unsigned long *stack;
 	int i;
 	const int cpu = safe_smp_processor_id();
-	unsigned long *irqstack_end = (unsigned long *) (cpu_pda[cpu].irqstackptr);
-	unsigned long *irqstack = (unsigned long *) (cpu_pda[cpu].irqstackptr - IRQSTACKSIZE);    
+	unsigned long *irqstack_end = (unsigned long *) (cpu_pda(cpu)->irqstackptr);
+	unsigned long *irqstack = (unsigned long *) (cpu_pda(cpu)->irqstackptr - IRQSTACKSIZE);
 
 	// debugging aid: "show_stack(NULL, NULL);" prints the
 	// back trace for this cpu.
@@ -275,7 +301,7 @@
 	int in_kernel = !user_mode(regs);
 	unsigned long rsp;
 	const int cpu = safe_smp_processor_id(); 
-	struct task_struct *cur = cpu_pda[cpu].pcurrent; 
+	struct task_struct *cur = cpu_pda(cpu)->pcurrent;
 
 		rsp = regs->rsp;
 
@@ -314,20 +340,26 @@
 void handle_BUG(struct pt_regs *regs)
 { 
 	struct bug_frame f;
-	char tmp;
+	long len;
+	const char *prefix = "";
 
 	if (user_mode(regs))
 		return; 
-	if (__copy_from_user(&f, (struct bug_frame *) regs->rip, 
+	if (__copy_from_user(&f, (const void __user *) regs->rip,
 			     sizeof(struct bug_frame)))
 		return; 
 	if (f.filename >= 0 ||
 	    f.ud2[0] != 0x0f || f.ud2[1] != 0x0b) 
 		return;
-	if (__get_user(tmp, (char *)(long)f.filename))
+	len = __strnlen_user((char *)(long)f.filename, PATH_MAX) - 1;
+	if (len < 0 || len >= PATH_MAX)
 		f.filename = (int)(long)"unmapped filename";
+	else if (len > 50) {
+		f.filename += len - 50;
+		prefix = "...";
+	}
 	printk("----------- [cut here ] --------- [please bite here ] ---------\n");
-	printk(KERN_ALERT "Kernel BUG at %.50s:%d\n", (char *)(long)f.filename, f.line);
+	printk(KERN_ALERT "Kernel BUG at %s%.50s:%d\n", prefix, (char *)(long)f.filename, f.line);
 } 
 
 #ifdef CONFIG_BUG
@@ -382,7 +414,7 @@
 	printk("DEBUG_PAGEALLOC");
 #endif
 	printk("\n");
-	notify_die(DIE_OOPS, (char *)str, regs, err, 255, SIGSEGV);
+	notify_die(DIE_OOPS, str, regs, err, current->thread.trap_no, SIGSEGV);
 	show_registers(regs);
 	/* Executive summary in case the oops scrolled away */
 	printk(KERN_ALERT "RIP ");
@@ -399,11 +431,6 @@
 	oops_end(flags);
 	do_exit(SIGSEGV); 
 }
-static inline void die_if_kernel(const char * str, struct pt_regs * regs, long err)
-{
-	if (!(regs->eflags & VM_MASK) && (regs->cs == __KERNEL_CS))
-		die(str, regs, err);
-}
 
 void die_nmi(char *str, struct pt_regs *regs)
 {
@@ -426,19 +453,20 @@
 			      struct pt_regs * regs, long error_code,
 			      siginfo_t *info)
 {
+	struct task_struct *tsk = current;
+
 	conditional_sti(regs);
 
-	if (user_mode(regs)) {
-		struct task_struct *tsk = current;
+	tsk->thread.error_code = error_code;
+	tsk->thread.trap_no = trapnr;
 
+	if (user_mode(regs)) {
 		if (exception_trace && unhandled_signal(tsk, signr))
 			printk(KERN_INFO
 			       "%s[%d] trap %s rip:%lx rsp:%lx error:%lx\n",
 			       tsk->comm, tsk->pid, str,
 			       regs->rip,regs->rsp,error_code); 
 
-		tsk->thread.error_code = error_code;
-		tsk->thread.trap_no = trapnr;
 		if (info)
 			force_sig_info(signr, info, tsk);
 		else
@@ -485,7 +513,7 @@
 DO_ERROR_INFO( 0, SIGFPE,  "divide error", divide_error, FPE_INTDIV, regs->rip)
 DO_ERROR( 4, SIGSEGV, "overflow", overflow)
 DO_ERROR( 5, SIGSEGV, "bounds", bounds)
-DO_ERROR_INFO( 6, SIGILL,  "invalid operand", invalid_op, ILL_ILLOPN, regs->rip)
+DO_ERROR_INFO( 6, SIGILL,  "invalid opcode", invalid_op, ILL_ILLOPN, regs->rip)
 DO_ERROR( 7, SIGSEGV, "device not available", device_not_available)
 DO_ERROR( 9, SIGFPE,  "coprocessor segment overrun", coprocessor_segment_overrun)
 DO_ERROR(10, SIGSEGV, "invalid TSS", invalid_TSS)
@@ -493,24 +521,41 @@
 DO_ERROR_INFO(17, SIGBUS, "alignment check", alignment_check, BUS_ADRALN, 0)
 DO_ERROR(18, SIGSEGV, "reserved", reserved)
 DO_ERROR(12, SIGBUS,  "stack segment", stack_segment)
-DO_ERROR( 8, SIGSEGV, "double fault", double_fault)
+
+asmlinkage void do_double_fault(struct pt_regs * regs, long error_code)
+{
+	static const char str[] = "double fault";
+	struct task_struct *tsk = current;
+
+	/* Return not checked because double check cannot be ignored */
+	notify_die(DIE_TRAP, str, regs, error_code, 8, SIGSEGV);
+
+	tsk->thread.error_code = error_code;
+	tsk->thread.trap_no = 8;
+
+	/* This is always a kernel trap and never fixable (and thus must
+	   never return). */
+	for (;;)
+		die(str, regs, error_code);
+}
 
 asmlinkage void __kprobes do_general_protection(struct pt_regs * regs,
 						long error_code)
 {
+	struct task_struct *tsk = current;
+
 	conditional_sti(regs);
 
-	if (user_mode(regs)) {
-		struct task_struct *tsk = current;
+	tsk->thread.error_code = error_code;
+	tsk->thread.trap_no = 13;
 
+	if (user_mode(regs)) {
 		if (exception_trace && unhandled_signal(tsk, SIGSEGV))
 			printk(KERN_INFO
 		       "%s[%d] general protection rip:%lx rsp:%lx error:%lx\n",
 			       tsk->comm, tsk->pid,
 			       regs->rip,regs->rsp,error_code); 
 
-		tsk->thread.error_code = error_code;
-		tsk->thread.trap_no = 13;
 		force_sig(SIGSEGV, tsk);
 		return;
 	} 
@@ -573,7 +618,7 @@
 		reason = get_nmi_reason();
 
 	if (!(reason & 0xc0)) {
-		if (notify_die(DIE_NMI_IPI, "nmi_ipi", regs, reason, 0, SIGINT)
+		if (notify_die(DIE_NMI_IPI, "nmi_ipi", regs, reason, 2, SIGINT)
 								== NOTIFY_STOP)
 			return;
 #ifdef CONFIG_X86_LOCAL_APIC
@@ -589,7 +634,7 @@
 		unknown_nmi_error(reason, regs);
 		return;
 	}
-	if (notify_die(DIE_NMI, "nmi", regs, reason, 0, SIGINT) == NOTIFY_STOP)
+	if (notify_die(DIE_NMI, "nmi", regs, reason, 2, SIGINT) == NOTIFY_STOP)
 		return; 
 
 	/* AK: following checks seem to be broken on modern chipsets. FIXME */
@@ -600,6 +645,7 @@
 		io_check_error(reason, regs);
 }
 
+/* runs on IST stack. */
 asmlinkage void __kprobes do_int3(struct pt_regs * regs, long error_code)
 {
 	if (notify_die(DIE_INT3, "int3", regs, error_code, 3, SIGTRAP) == NOTIFY_STOP) {
@@ -684,11 +730,9 @@
 	info.si_signo = SIGTRAP;
 	info.si_errno = 0;
 	info.si_code = TRAP_BRKPT;
-	if (!user_mode(regs))
-		goto clear_dr7; 
+	info.si_addr = user_mode(regs) ? (void __user *)regs->rip : NULL;
+	force_sig_info(SIGTRAP, &info, tsk);
 
-	info.si_addr = (void __user *)regs->rip;
-	force_sig_info(SIGTRAP, &info, tsk);	
 clear_dr7:
 	set_debugreg(0UL, 7);
 	return;
@@ -698,7 +742,7 @@
 	regs->eflags &= ~TF_MASK;
 }
 
-static int kernel_math_error(struct pt_regs *regs, char *str)
+static int kernel_math_error(struct pt_regs *regs, const char *str, int trapnr)
 {
 	const struct exception_table_entry *fixup;
 	fixup = search_exception_tables(regs->rip);
@@ -706,8 +750,9 @@
 		regs->rip = fixup->fixup;
 		return 1;
 	}
-	notify_die(DIE_GPF, str, regs, 0, 16, SIGFPE);
+	notify_die(DIE_GPF, str, regs, 0, trapnr, SIGFPE);
 	/* Illegal floating point operation in the kernel */
+	current->thread.trap_no = trapnr;
 	die(str, regs, 0);
 	return 0;
 }
@@ -726,7 +771,7 @@
 
 	conditional_sti(regs);
 	if (!user_mode(regs) &&
-	    kernel_math_error(regs, "kernel x87 math error"))
+	    kernel_math_error(regs, "kernel x87 math error", 16))
 		return;
 
 	/*
@@ -795,7 +840,7 @@
 
 	conditional_sti(regs);
 	if (!user_mode(regs) &&
-        	kernel_math_error(regs, "kernel simd math error"))
+        	kernel_math_error(regs, "kernel simd math error", 19))
 		return;
 
 	/*
@@ -870,19 +915,14 @@
 	me->thread_info->status |= TS_USEDFPU;
 }
 
-void do_call_debug(struct pt_regs *regs) 
-{ 
-	notify_die(DIE_CALL, "debug call", regs, 0, 255, SIGINT); 
-}
-
 void __init trap_init(void)
 {
 	set_intr_gate(0,&divide_error);
 	set_intr_gate_ist(1,&debug,DEBUG_STACK);
 	set_intr_gate_ist(2,&nmi,NMI_STACK);
-	set_system_gate(3,&int3);
-	set_system_gate(4,&overflow);	/* int4-5 can be called from all */
-	set_system_gate(5,&bounds);
+ 	set_system_gate_ist(3,&int3,DEBUG_STACK); /* int3 can be called from all */
+	set_system_gate(4,&overflow);	/* int4 can be called from all */
+	set_intr_gate(5,&bounds);
 	set_intr_gate(6,&invalid_op);
 	set_intr_gate(7,&device_not_available);
 	set_intr_gate_ist(8,&double_fault, DOUBLEFAULT_STACK);
@@ -904,8 +944,6 @@
 	set_system_gate(IA32_SYSCALL_VECTOR, ia32_syscall);
 #endif
        
-	set_intr_gate(KDB_VECTOR, call_debug);
-       
 	/*
 	 * Should be a barrier for any external CPU state.
 	 */
diff --git a/arch/x86_64/kernel/vmlinux.lds.S b/arch/x86_64/kernel/vmlinux.lds.S
index 58b1921..b0eed1f 100644
--- a/arch/x86_64/kernel/vmlinux.lds.S
+++ b/arch/x86_64/kernel/vmlinux.lds.S
@@ -8,6 +8,8 @@
 #include <asm/page.h>
 #include <linux/config.h>
 
+#undef i386	/* in case the preprocessor is a 32bit one */
+
 OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64")
 OUTPUT_ARCH(i386:x86-64)
 ENTRY(phys_startup_64)
@@ -189,7 +191,7 @@
   /* Sections to be discarded */
   /DISCARD/ : {
 	*(.exitcall.exit)
-#ifndef CONFIG_DEBUG_INFO
+#ifndef CONFIG_UNWIND_INFO
 	*(.eh_frame)
 #endif
 	}
diff --git a/arch/x86_64/kernel/vsmp.c b/arch/x86_64/kernel/vsmp.c
new file mode 100644
index 0000000..92f70c7
--- /dev/null
+++ b/arch/x86_64/kernel/vsmp.c
@@ -0,0 +1,45 @@
+/*
+ * vSMPowered(tm) systems specific initialization
+ * Copyright (C) 2005 ScaleMP Inc.
+ *
+ * Use of this code is subject to the terms and conditions of the
+ * GNU general public license version 2. See "COPYING" or
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * Ravikiran Thirumalai <kiran@scalemp.com>,
+ * Shai Fultheim <shai@scalemp.com>
+ */
+
+#include <linux/init.h>
+#include <linux/pci_ids.h>
+#include <linux/pci_regs.h>
+#include <asm/pci-direct.h>
+
+static int __init vsmp_init(void)
+{
+	void *address;
+	unsigned int cap, ctl;
+
+	/* Check if we are running on a ScaleMP vSMP box */
+	if ((read_pci_config_16(0, 0x1f, 0, PCI_VENDOR_ID) != PCI_VENDOR_ID_SCALEMP) ||
+	    (read_pci_config_16(0, 0x1f, 0, PCI_DEVICE_ID) != PCI_DEVICE_ID_SCALEMP_VSMP_CTL))
+		return 0;
+
+	/* set vSMP magic bits to indicate vSMP capable kernel */
+	address = ioremap(read_pci_config(0, 0x1f, 0, PCI_BASE_ADDRESS_0), 8);
+	cap = readl(address);
+	ctl = readl(address + 4);
+	printk("vSMP CTL: capabilities:0x%08x  control:0x%08x\n", cap, ctl);
+	if (cap & ctl & (1 << 4)) {
+		/* Turn on vSMP IRQ fastpath handling (see system.h) */
+		ctl &= ~(1 << 4);
+		writel(ctl, address + 4);
+		ctl = readl(address + 4);
+		printk("vSMP CTL: control set to:0x%08x\n", ctl);
+	}
+
+	iounmap(address);
+	return 0;
+}
+
+core_initcall(vsmp_init);
diff --git a/arch/x86_64/kernel/vsyscall.c b/arch/x86_64/kernel/vsyscall.c
index 70a0bd1..9468fb2 100644
--- a/arch/x86_64/kernel/vsyscall.c
+++ b/arch/x86_64/kernel/vsyscall.c
@@ -35,14 +35,13 @@
 #include <asm/io.h>
 
 #define __vsyscall(nr) __attribute__ ((unused,__section__(".vsyscall_" #nr)))
-#define force_inline __attribute__((always_inline)) inline
 
 int __sysctl_vsyscall __section_sysctl_vsyscall = 1;
 seqlock_t __xtime_lock __section_xtime_lock = SEQLOCK_UNLOCKED;
 
 #include <asm/unistd.h>
 
-static force_inline void timeval_normalize(struct timeval * tv)
+static __always_inline void timeval_normalize(struct timeval * tv)
 {
 	time_t __sec;
 
@@ -53,7 +52,7 @@
 	}
 }
 
-static force_inline void do_vgettimeofday(struct timeval * tv)
+static __always_inline void do_vgettimeofday(struct timeval * tv)
 {
 	long sequence, t;
 	unsigned long sec, usec;
@@ -66,8 +65,7 @@
 			(__jiffies - __wall_jiffies) * (1000000 / HZ);
 
 		if (__vxtime.mode != VXTIME_HPET) {
-			sync_core();
-			rdtscll(t);
+			t = get_cycles_sync();
 			if (t < __vxtime.last_tsc)
 				t = __vxtime.last_tsc;
 			usec += ((t - __vxtime.last_tsc) *
@@ -84,12 +82,12 @@
 }
 
 /* RED-PEN may want to readd seq locking, but then the variable should be write-once. */
-static force_inline void do_get_tz(struct timezone * tz)
+static __always_inline void do_get_tz(struct timezone * tz)
 {
 	*tz = __sys_tz;
 }
 
-static force_inline int gettimeofday(struct timeval *tv, struct timezone *tz)
+static __always_inline int gettimeofday(struct timeval *tv, struct timezone *tz)
 {
 	int ret;
 	asm volatile("vsysc2: syscall"
@@ -98,7 +96,7 @@
 	return ret;
 }
 
-static force_inline long time_syscall(long *t)
+static __always_inline long time_syscall(long *t)
 {
 	long secs;
 	asm volatile("vsysc1: syscall"
diff --git a/arch/x86_64/kernel/x8664_ksyms.c b/arch/x86_64/kernel/x8664_ksyms.c
index b7fd668..b614d54 100644
--- a/arch/x86_64/kernel/x8664_ksyms.c
+++ b/arch/x86_64/kernel/x8664_ksyms.c
@@ -44,22 +44,15 @@
 EXPORT_SYMBOL(drive_info);
 #endif
 
-extern unsigned long get_cmos_time(void);
-
 /* platform dependent support */
 EXPORT_SYMBOL(boot_cpu_data);
 //EXPORT_SYMBOL(dump_fpu);
 EXPORT_SYMBOL(__ioremap);
 EXPORT_SYMBOL(ioremap_nocache);
 EXPORT_SYMBOL(iounmap);
-EXPORT_SYMBOL(enable_irq);
-EXPORT_SYMBOL(disable_irq);
-EXPORT_SYMBOL(disable_irq_nosync);
-EXPORT_SYMBOL(probe_irq_mask);
 EXPORT_SYMBOL(kernel_thread);
 EXPORT_SYMBOL(pm_idle);
 EXPORT_SYMBOL(pm_power_off);
-EXPORT_SYMBOL(get_cmos_time);
 
 EXPORT_SYMBOL(__down_failed);
 EXPORT_SYMBOL(__down_failed_interruptible);
@@ -83,9 +76,6 @@
 EXPORT_SYMBOL(__put_user_4);
 EXPORT_SYMBOL(__put_user_8);
 
-EXPORT_SYMBOL(strpbrk);
-EXPORT_SYMBOL(strstr);
-
 EXPORT_SYMBOL(strncpy_from_user);
 EXPORT_SYMBOL(__strncpy_from_user);
 EXPORT_SYMBOL(clear_user);
@@ -97,25 +87,18 @@
 EXPORT_SYMBOL(strnlen_user);
 
 #ifdef CONFIG_PCI
-EXPORT_SYMBOL(pci_alloc_consistent);
-EXPORT_SYMBOL(pci_free_consistent);
-#endif
-
-#ifdef CONFIG_PCI
 EXPORT_SYMBOL(pci_mem_start);
 #endif
 
 EXPORT_SYMBOL(copy_page);
 EXPORT_SYMBOL(clear_page);
 
-EXPORT_SYMBOL(cpu_pda);
+EXPORT_SYMBOL(_cpu_pda);
 #ifdef CONFIG_SMP
 EXPORT_SYMBOL(cpu_data);
-EXPORT_SYMBOL(cpu_online_map);
 EXPORT_SYMBOL(__write_lock_failed);
 EXPORT_SYMBOL(__read_lock_failed);
 
-EXPORT_SYMBOL(synchronize_irq);
 EXPORT_SYMBOL(smp_call_function);
 EXPORT_SYMBOL(cpu_callout_map);
 #endif
@@ -136,30 +119,17 @@
 #undef memcpy
 #undef memset
 #undef memmove
-#undef memchr
 #undef strlen
-#undef strncmp
-#undef strncpy
-#undef strchr	
 
 extern void * memset(void *,int,__kernel_size_t);
 extern size_t strlen(const char *);
 extern void * memmove(void * dest,const void *src,size_t count);
-extern void *memchr(const void *s, int c, size_t n);
 extern void * memcpy(void *,const void *,__kernel_size_t);
 extern void * __memcpy(void *,const void *,__kernel_size_t);
 
 EXPORT_SYMBOL(memset);
 EXPORT_SYMBOL(strlen);
 EXPORT_SYMBOL(memmove);
-EXPORT_SYMBOL(strncmp);
-EXPORT_SYMBOL(strncpy);
-EXPORT_SYMBOL(strchr);
-EXPORT_SYMBOL(strncat);
-EXPORT_SYMBOL(memchr);
-EXPORT_SYMBOL(strrchr);
-EXPORT_SYMBOL(strnlen);
-EXPORT_SYMBOL(memscan);
 EXPORT_SYMBOL(memcpy);
 EXPORT_SYMBOL(__memcpy);
 
diff --git a/arch/x86_64/lib/copy_user.S b/arch/x86_64/lib/copy_user.S
index dfa358b..79422b6 100644
--- a/arch/x86_64/lib/copy_user.S
+++ b/arch/x86_64/lib/copy_user.S
@@ -4,12 +4,9 @@
  * Functions to copy from and to user space.		
  */		 
 
-#define FIX_ALIGNMENT 1
-		
 	#include <asm/current.h>
 	#include <asm/asm-offsets.h>
 	#include <asm/thread_info.h>
-	#include <asm/cpufeature.h>
 
 /* Standard copy_to_user with segment limit checking */		
 	.globl copy_to_user
@@ -21,23 +18,7 @@
 	jc  bad_to_user
 	cmpq threadinfo_addr_limit(%rax),%rcx
 	jae bad_to_user
-2:	
-	.byte 0xe9	/* 32bit jump */
-	.long .Lcug-1f
-1:
-
-	.section .altinstr_replacement,"ax"
-3:	.byte 0xe9			/* replacement jmp with 8 bit immediate */
-	.long copy_user_generic_c-1b	/* offset */
-	.previous
-	.section .altinstructions,"a"
-	.align 8
-	.quad  2b
-	.quad  3b
-	.byte  X86_FEATURE_K8_C
-	.byte  5
-	.byte  5
-	.previous
+	jmp copy_user_generic
 
 /* Standard copy_from_user with segment limit checking */	
 	.globl copy_from_user
@@ -72,223 +53,44 @@
  * rsi source
  * rdx count
  *
+ * Only 4GB of copy is supported. This shouldn't be a problem
+ * because the kernel normally only writes from/to page sized chunks
+ * even if user space passed a longer buffer.
+ * And more would be dangerous because both Intel and AMD have
+ * errata with rep movsq > 4GB. If someone feels the need to fix
+ * this please consider this.
+ *
  * Output:		
  * eax uncopied bytes or 0 if successful.
  */
-	.globl copy_user_generic	
-	.p2align 4
-copy_user_generic:	
-	.byte 0x66,0x66,0x90	/* 5 byte nop for replacement jump */	
-	.byte 0x66,0x90
-1:		
-	.section .altinstr_replacement,"ax"
-2:	.byte 0xe9	             /* near jump with 32bit immediate */
-	.long copy_user_generic_c-1b /* offset */
-	.previous
-	.section .altinstructions,"a"
-	.align 8
-	.quad  copy_user_generic
-	.quad  2b
-	.byte  X86_FEATURE_K8_C
-	.byte  5
-	.byte  5
-	.previous
-.Lcug:	
-	pushq %rbx
-	xorl %eax,%eax		/*zero for the exception handler */
 
-#ifdef FIX_ALIGNMENT
-	/* check for bad alignment of destination */
-	movl %edi,%ecx
-	andl $7,%ecx
-	jnz  .Lbad_alignment
-.Lafter_bad_alignment:
-#endif
-
-	movq %rdx,%rcx
-
-	movl $64,%ebx	
-	shrq $6,%rdx
-	decq %rdx
-	js   .Lhandle_tail
-	
-	.p2align 4
-.Lloop:
-.Ls1:	movq (%rsi),%r11
-.Ls2:	movq 1*8(%rsi),%r8
-.Ls3:	movq 2*8(%rsi),%r9
-.Ls4:	movq 3*8(%rsi),%r10
-.Ld1:	movq %r11,(%rdi)
-.Ld2:	movq %r8,1*8(%rdi)
-.Ld3:	movq %r9,2*8(%rdi)
-.Ld4:	movq %r10,3*8(%rdi)
-		
-.Ls5:	movq 4*8(%rsi),%r11
-.Ls6:	movq 5*8(%rsi),%r8
-.Ls7:	movq 6*8(%rsi),%r9
-.Ls8:	movq 7*8(%rsi),%r10
-.Ld5:	movq %r11,4*8(%rdi)
-.Ld6:	movq %r8,5*8(%rdi)
-.Ld7:	movq %r9,6*8(%rdi)
-.Ld8:	movq %r10,7*8(%rdi)
-	
-	decq %rdx
-
-	leaq 64(%rsi),%rsi
-	leaq 64(%rdi),%rdi
-	
-	jns  .Lloop
-
-	.p2align 4
-.Lhandle_tail:
-	movl %ecx,%edx
-	andl $63,%ecx
-	shrl $3,%ecx
-	jz   .Lhandle_7
-	movl $8,%ebx
-	.p2align 4
-.Lloop_8:
-.Ls9:	movq (%rsi),%r8
-.Ld9:	movq %r8,(%rdi)
-	decl %ecx
-	leaq 8(%rdi),%rdi
-	leaq 8(%rsi),%rsi
-	jnz .Lloop_8
-	
-.Lhandle_7:		
-	movl %edx,%ecx	
-	andl $7,%ecx
-	jz   .Lende
-	.p2align 4
-.Lloop_1:
-.Ls10:	movb (%rsi),%bl
-.Ld10:	movb %bl,(%rdi)
-	incq %rdi
-	incq %rsi
-	decl %ecx
-	jnz .Lloop_1
-			
-.Lende:
-	popq %rbx
-	ret	
-
-#ifdef FIX_ALIGNMENT		  		
-	/* align destination */
-	.p2align 4
-.Lbad_alignment:
-	movl $8,%r9d
-	subl %ecx,%r9d
-	movl %r9d,%ecx
-	cmpq %r9,%rdx
-	jz   .Lhandle_7
-	js   .Lhandle_7
-.Lalign_1:		
-.Ls11:	movb (%rsi),%bl
-.Ld11:	movb %bl,(%rdi)
-	incq %rsi
-	incq %rdi
-	decl %ecx
-	jnz .Lalign_1
-	subq %r9,%rdx
-	jmp .Lafter_bad_alignment
-#endif
-	
-	/* table sorted by exception address */	
-	.section __ex_table,"a"
-	.align 8
-	.quad .Ls1,.Ls1e
-	.quad .Ls2,.Ls2e
-	.quad .Ls3,.Ls3e
-	.quad .Ls4,.Ls4e	
-	.quad .Ld1,.Ls1e
-	.quad .Ld2,.Ls2e
-	.quad .Ld3,.Ls3e
-	.quad .Ld4,.Ls4e
-	.quad .Ls5,.Ls5e
-	.quad .Ls6,.Ls6e
-	.quad .Ls7,.Ls7e
-	.quad .Ls8,.Ls8e	
-	.quad .Ld5,.Ls5e
-	.quad .Ld6,.Ls6e
-	.quad .Ld7,.Ls7e
-	.quad .Ld8,.Ls8e
-	.quad .Ls9,.Le_quad
-	.quad .Ld9,.Le_quad
-	.quad .Ls10,.Le_byte
-	.quad .Ld10,.Le_byte
-#ifdef FIX_ALIGNMENT	
-	.quad .Ls11,.Lzero_rest
-	.quad .Ld11,.Lzero_rest
-#endif
-	.quad .Le5,.Le_zero
-	.previous
-
-	/* compute 64-offset for main loop. 8 bytes accuracy with error on the 
-	   pessimistic side. this is gross. it would be better to fix the 
-	   interface. */	
-	/* eax: zero, ebx: 64 */
-.Ls1e: 	addl $8,%eax
-.Ls2e: 	addl $8,%eax
-.Ls3e: 	addl $8,%eax
-.Ls4e: 	addl $8,%eax
-.Ls5e: 	addl $8,%eax
-.Ls6e: 	addl $8,%eax
-.Ls7e: 	addl $8,%eax
-.Ls8e: 	addl $8,%eax
-	addq %rbx,%rdi	/* +64 */
-	subq %rax,%rdi  /* correct destination with computed offset */
-
-	shlq $6,%rdx	/* loop counter * 64 (stride length) */
-	addq %rax,%rdx	/* add offset to loopcnt */
-	andl $63,%ecx	/* remaining bytes */
-	addq %rcx,%rdx	/* add them */
-	jmp .Lzero_rest
-
-	/* exception on quad word loop in tail handling */
-	/* ecx:	loopcnt/8, %edx: length, rdi: correct */
-.Le_quad:
-	shll $3,%ecx
-	andl $7,%edx
-	addl %ecx,%edx
-	/* edx: bytes to zero, rdi: dest, eax:zero */
-.Lzero_rest:
-	movq %rdx,%rcx
-.Le_byte:
-	xorl %eax,%eax
-.Le5:	rep 
-	stosb
-	/* when there is another exception while zeroing the rest just return */
-.Le_zero:		
-	movq %rdx,%rax
-	jmp .Lende
-
-	/* C stepping K8 run faster using the string copy instructions.
-	   This is also a lot simpler. Use them when possible.
-	   Patch in jmps to this code instead of copying it fully
-	   to avoid unwanted aliasing in the exception tables. */
-		
- /* rdi	destination
-  * rsi source
-  * rdx count
-  *
-  * Output:		
-  * eax uncopied bytes or 0 if successfull.
-  */			
-copy_user_generic_c:
+	.globl copy_user_generic
+copy_user_generic:
 	movl %edx,%ecx
 	shrl $3,%ecx
 	andl $7,%edx	
+	jz   5f
 1:	rep 
 	movsq 
 	movl %edx,%ecx
+	xor %eax,%eax
 2:	rep
 	movsb
-4:	movl %ecx,%eax
 	ret
+	/* align here? */
+5: 	xorl %eax,%eax
+6:	rep movsq
+	ret
+
+	.section .fixup,"ax"
 3:	lea (%rdx,%rcx,8),%rax
 	ret
-	
+4:	movl %ecx,%eax
+	ret
+	.previous
+
 	.section __ex_table,"a"
 	.quad 1b,3b
 	.quad 2b,4b
+	.quad 6b,4b
 	.previous
diff --git a/arch/x86_64/lib/delay.c b/arch/x86_64/lib/delay.c
index 841bd73..03c460c 100644
--- a/arch/x86_64/lib/delay.c
+++ b/arch/x86_64/lib/delay.c
@@ -39,7 +39,7 @@
 
 inline void __const_udelay(unsigned long xloops)
 {
-	__delay(((xloops * cpu_data[raw_smp_processor_id()].loops_per_jiffy) >> 32) * HZ);
+	__delay((xloops * HZ * cpu_data[raw_smp_processor_id()].loops_per_jiffy) >> 32);
 }
 
 void __udelay(unsigned long usecs)
diff --git a/arch/x86_64/lib/usercopy.c b/arch/x86_64/lib/usercopy.c
index db8abba..9bc2c29 100644
--- a/arch/x86_64/lib/usercopy.c
+++ b/arch/x86_64/lib/usercopy.c
@@ -109,14 +109,11 @@
  * Return 0 on exception, a value greater than N if too long
  */
 
-long strnlen_user(const char __user *s, long n)
+long __strnlen_user(const char __user *s, long n)
 {
 	long res = 0;
 	char c;
 
-	if (!access_ok(VERIFY_READ, s, n))
-		return 0;
-
 	while (1) {
 		if (res>n)
 			return n+1;
@@ -129,6 +126,13 @@
 	}
 }
 
+long strnlen_user(const char __user *s, long n)
+{
+	if (!access_ok(VERIFY_READ, s, n))
+		return 0;
+	return __strnlen_user(s, n);
+}
+
 long strlen_user(const char __user *s)
 {
 	long res = 0;
diff --git a/arch/x86_64/mm/fault.c b/arch/x86_64/mm/fault.c
index 3a63707..26eac19 100644
--- a/arch/x86_64/mm/fault.c
+++ b/arch/x86_64/mm/fault.c
@@ -35,6 +35,13 @@
 #include <asm-generic/sections.h>
 #include <asm/kdebug.h>
 
+/* Page fault error code bits */
+#define PF_PROT	(1<<0)		/* or no page found */
+#define PF_WRITE	(1<<1)
+#define PF_USER	(1<<2)
+#define PF_RSVD	(1<<3)
+#define PF_INSTR	(1<<4)
+
 void bust_spinlocks(int yes)
 {
 	int loglevel_save = console_loglevel;
@@ -68,7 +75,7 @@
 	unsigned char *max_instr;
 
 	/* If it was a exec fault ignore */
-	if (error_code & (1<<4))
+	if (error_code & PF_INSTR)
 		return 0;
 	
 	instr = (unsigned char *)convert_rip_to_linear(current, regs);
@@ -222,17 +229,22 @@
 				 unsigned long error_code)
 {
 	unsigned long flags = oops_begin();
+	struct task_struct *tsk;
 
 	printk(KERN_ALERT "%s: Corrupted page table at address %lx\n",
 	       current->comm, address);
 	dump_pagetable(address);
+	tsk = current;
+	tsk->thread.cr2 = address;
+	tsk->thread.trap_no = 14;
+	tsk->thread.error_code = error_code;
 	__die("Bad pagetable", regs, error_code);
 	oops_end(flags);
 	do_exit(SIGKILL);
 }
 
 /*
- * Handle a fault on the vmalloc or module mapping area
+ * Handle a fault on the vmalloc area
  *
  * This assumes no large pages in there.
  */
@@ -278,7 +290,6 @@
 	   that. */
 	if (!pte_present(*pte) || pte_pfn(*pte) != pte_pfn(*pte_ref))
 		BUG();
-	__flush_tlb_all();
 	return 0;
 }
 
@@ -289,12 +300,6 @@
  * This routine handles page faults.  It determines the address,
  * and the problem, and then passes it off to one of the appropriate
  * routines.
- *
- * error_code:
- *	bit 0 == 0 means no page found, 1 means protection fault
- *	bit 1 == 0 means read, 1 means write
- *	bit 2 == 0 means kernel, 1 means user-mode
- *      bit 3 == 1 means fault was an instruction fetch
  */
 asmlinkage void __kprobes do_page_fault(struct pt_regs *regs,
 					unsigned long error_code)
@@ -337,12 +342,16 @@
 	 *
 	 * This verifies that the fault happens in kernel space
 	 * (error_code & 4) == 0, and that the fault was not a
-	 * protection error (error_code & 1) == 0.
+	 * protection error (error_code & 9) == 0.
 	 */
 	if (unlikely(address >= TASK_SIZE64)) {
-		if (!(error_code & 5) &&
-		      ((address >= VMALLOC_START && address < VMALLOC_END) ||
-		       (address >= MODULES_VADDR && address < MODULES_END))) {
+		/*
+		 * Don't check for the module range here: its PML4
+		 * is always initialized because it's shared with the main
+		 * kernel text. Only vmalloc may need PML4 syncups.
+		 */
+		if (!(error_code & (PF_RSVD|PF_USER|PF_PROT)) &&
+		      ((address >= VMALLOC_START && address < VMALLOC_END))) {
 			if (vmalloc_fault(address) < 0)
 				goto bad_area_nosemaphore;
 			return;
@@ -354,7 +363,7 @@
 		goto bad_area_nosemaphore;
 	}
 
-	if (unlikely(error_code & (1 << 3)))
+	if (unlikely(error_code & PF_RSVD))
 		pgtable_bad(address, regs, error_code);
 
 	/*
@@ -381,7 +390,7 @@
 	 * thus avoiding the deadlock.
 	 */
 	if (!down_read_trylock(&mm->mmap_sem)) {
-		if ((error_code & 4) == 0 &&
+		if ((error_code & PF_USER) == 0 &&
 		    !search_exception_tables(regs->rip))
 			goto bad_area_nosemaphore;
 		down_read(&mm->mmap_sem);
@@ -408,17 +417,17 @@
 good_area:
 	info.si_code = SEGV_ACCERR;
 	write = 0;
-	switch (error_code & 3) {
+	switch (error_code & (PF_PROT|PF_WRITE)) {
 		default:	/* 3: write, present */
 			/* fall through */
-		case 2:		/* write, not present */
+		case PF_WRITE:		/* write, not present */
 			if (!(vma->vm_flags & VM_WRITE))
 				goto bad_area;
 			write++;
 			break;
-		case 1:		/* read, present */
+		case PF_PROT:		/* read, present */
 			goto bad_area;
-		case 0:		/* read, not present */
+		case 0:			/* read, not present */
 			if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
 				goto bad_area;
 	}
@@ -453,7 +462,7 @@
 
 bad_area_nosemaphore:
 	/* User mode accesses just cause a SIGSEGV */
-	if (error_code & 4) {
+	if (error_code & PF_USER) {
 		if (is_prefetch(regs, address, error_code))
 			return;
 
@@ -521,6 +530,9 @@
 	printk_address(regs->rip);
 	printk("\n");
 	dump_pagetable(address);
+	tsk->thread.cr2 = address;
+	tsk->thread.trap_no = 14;
+	tsk->thread.error_code = error_code;
 	__die("Oops", regs, error_code);
 	/* Executive summary in case the body of the oops scrolled away */
 	printk(KERN_EMERG "CR2: %016lx\n", address);
@@ -546,7 +558,7 @@
 	up_read(&mm->mmap_sem);
 
 	/* Kernel mode? Handle exceptions or die */
-	if (!(error_code & 4))
+	if (!(error_code & PF_USER))
 		goto no_context;
 
 	tsk->thread.cr2 = address;
diff --git a/arch/x86_64/mm/init.c b/arch/x86_64/mm/init.c
index 1faae5f..eca6012 100644
--- a/arch/x86_64/mm/init.c
+++ b/arch/x86_64/mm/init.c
@@ -23,6 +23,7 @@
 #include <linux/bootmem.h>
 #include <linux/proc_fs.h>
 #include <linux/pci.h>
+#include <linux/dma-mapping.h>
 
 #include <asm/processor.h>
 #include <asm/system.h>
@@ -38,11 +39,16 @@
 #include <asm/proto.h>
 #include <asm/smp.h>
 #include <asm/sections.h>
+#include <asm/dma-mapping.h>
+#include <asm/swiotlb.h>
 
 #ifndef Dprintk
 #define Dprintk(x...)
 #endif
 
+struct dma_mapping_ops* dma_ops;
+EXPORT_SYMBOL(dma_ops);
+
 static unsigned long dma_reserve __initdata;
 
 DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
@@ -249,14 +255,26 @@
 
 static void __init find_early_table_space(unsigned long end)
 {
-	unsigned long puds, pmds, tables;
+	unsigned long puds, pmds, tables, start;
 
 	puds = (end + PUD_SIZE - 1) >> PUD_SHIFT;
 	pmds = (end + PMD_SIZE - 1) >> PMD_SHIFT;
 	tables = round_up(puds * sizeof(pud_t), PAGE_SIZE) +
 		 round_up(pmds * sizeof(pmd_t), PAGE_SIZE);
 
-	table_start = find_e820_area(0x8000, __pa_symbol(&_text), tables);
+	/* Put page tables beyond the DMA zones if possible.
+	   RED-PEN might be better to spread them out more over
+	   memory to avoid hotspots */
+	if (end > MAX_DMA32_PFN<<PAGE_SHIFT)
+		start = MAX_DMA32_PFN << PAGE_SHIFT;
+	else if (end > MAX_DMA_PFN << PAGE_SHIFT)
+		start = MAX_DMA_PFN << PAGE_SHIFT;
+	else
+		start = 0x8000;
+
+	table_start = find_e820_area(start, end, tables);
+	if (table_start == -1)
+		table_start = find_e820_area(0x8000, end, tables);
 	if (table_start == -1UL)
 		panic("Cannot find space for the kernel page tables");
 
@@ -423,12 +441,9 @@
 	long codesize, reservedpages, datasize, initsize;
 
 #ifdef CONFIG_SWIOTLB
-	if (!iommu_aperture &&
-	    (end_pfn >= 0xffffffff>>PAGE_SHIFT || force_iommu))
-	       swiotlb = 1;
-	if (swiotlb)
-		swiotlb_init();	
+	pci_swiotlb_init();
 #endif
+	no_iommu_init();
 
 	/* How many end-of-memory variables you have, grandma! */
 	max_low_pfn = end_pfn;
diff --git a/arch/x86_64/mm/numa.c b/arch/x86_64/mm/numa.c
index 15b67d2..6ef9f9a 100644
--- a/arch/x86_64/mm/numa.c
+++ b/arch/x86_64/mm/numa.c
@@ -46,8 +46,8 @@
  * 0 if memnodmap[] too small (of shift too small)
  * -1 if node overlap or lost ram (shift too big)
  */
-static int __init populate_memnodemap(
-	const struct node *nodes, int numnodes, int shift)
+static int __init
+populate_memnodemap(const struct node *nodes, int numnodes, int shift)
 {
 	int i; 
 	int res = -1;
@@ -81,7 +81,7 @@
 	while (populate_memnodemap(nodes, numnodes, shift + 1) >= 0)
 		shift++;
 
-	printk(KERN_DEBUG "Using %d for the hash shift.\n",
+	printk(KERN_DEBUG "NUMA: Using %d for the hash shift.\n",
 		shift);
 
 	if (populate_memnodemap(nodes, numnodes, shift) != 1) {
@@ -110,7 +110,7 @@
 
 	start = round_up(start, ZONE_ALIGN); 
 
-	printk("Bootmem setup node %d %016lx-%016lx\n", nodeid, start, end);
+	printk(KERN_INFO "Bootmem setup node %d %016lx-%016lx\n", nodeid, start, end);
 
 	start_pfn = start >> PAGE_SHIFT;
 	end_pfn = end >> PAGE_SHIFT;
@@ -156,7 +156,7 @@
  	start_pfn = node_start_pfn(nodeid);
  	end_pfn = node_end_pfn(nodeid);
 
-	Dprintk(KERN_INFO "setting up node %d %lx-%lx\n",
+	Dprintk(KERN_INFO "Setting up node %d %lx-%lx\n",
 		nodeid, start_pfn, end_pfn);
 
 	size_zones(zones, holes, start_pfn, end_pfn);
@@ -200,7 +200,7 @@
  		while ((x << 1) < sz)
  			x <<= 1;
  		if (x < sz/2)
- 			printk("Numa emulation unbalanced. Complain to maintainer\n");
+ 			printk(KERN_ERR "Numa emulation unbalanced. Complain to maintainer\n");
  		sz = x;
  	}
 
@@ -272,7 +272,7 @@
 
 void __cpuinit numa_set_node(int cpu, int node)
 {
-	cpu_pda[cpu].nodenumber = node;
+	cpu_pda(cpu)->nodenumber = node;
 	cpu_to_node[cpu] = node;
 }
 
@@ -330,8 +330,69 @@
 	return 1;
 } 
 
+/*
+ * Setup early cpu_to_node.
+ *
+ * Populate cpu_to_node[] only if x86_cpu_to_apicid[],
+ * and apicid_to_node[] tables have valid entries for a CPU.
+ * This means we skip cpu_to_node[] initialisation for NUMA
+ * emulation and faking node case (when running a kernel compiled
+ * for NUMA on a non NUMA box), which is OK as cpu_to_node[]
+ * is already initialized in a round robin manner at numa_init_array,
+ * prior to this call, and this initialization is good enough
+ * for the fake NUMA cases.
+ */
+void __init init_cpu_to_node(void)
+{
+	int i;
+ 	for (i = 0; i < NR_CPUS; i++) {
+		u8 apicid = x86_cpu_to_apicid[i];
+		if (apicid == BAD_APICID)
+			continue;
+		if (apicid_to_node[apicid] == NUMA_NO_NODE)
+			continue;
+ 		cpu_to_node[i] = apicid_to_node[apicid];
+	}
+}
+
 EXPORT_SYMBOL(cpu_to_node);
 EXPORT_SYMBOL(node_to_cpumask);
 EXPORT_SYMBOL(memnode_shift);
 EXPORT_SYMBOL(memnodemap);
 EXPORT_SYMBOL(node_data);
+
+#ifdef CONFIG_DISCONTIGMEM
+/*
+ * Functions to convert PFNs from/to per node page addresses.
+ * These are out of line because they are quite big.
+ * They could be all tuned by pre caching more state.
+ * Should do that.
+ */
+
+/* Requires pfn_valid(pfn) to be true */
+struct page *pfn_to_page(unsigned long pfn)
+{
+	int nid = phys_to_nid(((unsigned long)(pfn)) << PAGE_SHIFT);
+	return (pfn - node_start_pfn(nid)) + NODE_DATA(nid)->node_mem_map;
+}
+EXPORT_SYMBOL(pfn_to_page);
+
+unsigned long page_to_pfn(struct page *page)
+{
+	return (long)(((page) - page_zone(page)->zone_mem_map) +
+		      page_zone(page)->zone_start_pfn);
+}
+EXPORT_SYMBOL(page_to_pfn);
+
+int pfn_valid(unsigned long pfn)
+{
+	unsigned nid;
+	if (pfn >= num_physpages)
+		return 0;
+	nid = pfn_to_nid(pfn);
+	if (nid == 0xff)
+		return 0;
+	return pfn >= node_start_pfn(nid) && (pfn) < node_end_pfn(nid);
+}
+EXPORT_SYMBOL(pfn_valid);
+#endif
diff --git a/arch/x86_64/mm/srat.c b/arch/x86_64/mm/srat.c
index 33340bd..8b7f856 100644
--- a/arch/x86_64/mm/srat.c
+++ b/arch/x86_64/mm/srat.c
@@ -17,21 +17,23 @@
 #include <linux/topology.h>
 #include <asm/proto.h>
 #include <asm/numa.h>
+#include <asm/e820.h>
 
 static struct acpi_table_slit *acpi_slit;
 
 static nodemask_t nodes_parsed __initdata;
 static nodemask_t nodes_found __initdata;
 static struct node nodes[MAX_NUMNODES] __initdata;
-static __u8  pxm2node[256] = { [0 ... 255] = 0xff };
+static u8 pxm2node[256] = { [0 ... 255] = 0xff };
 
 static int node_to_pxm(int n);
 
 int pxm_to_node(int pxm)
 {
 	if ((unsigned)pxm >= 256)
-		return 0;
-	return pxm2node[pxm];
+		return -1;
+	/* Extend 0xff to (int)-1 */
+	return (signed char)pxm2node[pxm];
 }
 
 static __init int setup_node(int pxm)
@@ -91,9 +93,36 @@
 	return numa_off || acpi_numa < 0;
 }
 
+/*
+ * A lot of BIOS fill in 10 (= no distance) everywhere. This messes
+ * up the NUMA heuristics which wants the local node to have a smaller
+ * distance than the others.
+ * Do some quick checks here and only use the SLIT if it passes.
+ */
+static __init int slit_valid(struct acpi_table_slit *slit)
+{
+	int i, j;
+	int d = slit->localities;
+	for (i = 0; i < d; i++) {
+		for (j = 0; j < d; j++)  {
+			u8 val = slit->entry[d*i + j];
+			if (i == j) {
+				if (val != 10)
+					return 0;
+			} else if (val <= 10)
+				return 0;
+		}
+	}
+	return 1;
+}
+
 /* Callback for SLIT parsing */
 void __init acpi_numa_slit_init(struct acpi_table_slit *slit)
 {
+	if (!slit_valid(slit)) {
+		printk(KERN_INFO "ACPI: SLIT table looks invalid. Not used.\n");
+		return;
+	}
 	acpi_slit = slit;
 }
 
@@ -168,12 +197,39 @@
 	       nd->start, nd->end);
 }
 
+/* Sanity check to catch more bad SRATs (they are amazingly common).
+   Make sure the PXMs cover all memory. */
+static int nodes_cover_memory(void)
+{
+	int i;
+	unsigned long pxmram, e820ram;
+
+	pxmram = 0;
+	for_each_node_mask(i, nodes_parsed) {
+		unsigned long s = nodes[i].start >> PAGE_SHIFT;
+		unsigned long e = nodes[i].end >> PAGE_SHIFT;
+		pxmram += e - s;
+		pxmram -= e820_hole_size(s, e);
+	}
+
+	e820ram = end_pfn - e820_hole_size(0, end_pfn);
+	if (pxmram < e820ram) {
+		printk(KERN_ERR
+	"SRAT: PXMs only cover %luMB of your %luMB e820 RAM. Not used.\n",
+			(pxmram << PAGE_SHIFT) >> 20,
+			(e820ram << PAGE_SHIFT) >> 20);
+		return 0;
+	}
+	return 1;
+}
+
 void __init acpi_numa_arch_fixup(void) {}
 
 /* Use the information discovered above to actually set up the nodes. */
 int __init acpi_scan_nodes(unsigned long start, unsigned long end)
 {
 	int i;
+
 	if (acpi_numa <= 0)
 		return -1;
 
@@ -184,6 +240,11 @@
 			node_clear(i, nodes_parsed);
 	}
 
+	if (!nodes_cover_memory()) {
+		bad_srat();
+		return -1;
+	}
+
 	memnode_shift = compute_hash_shift(nodes, nodes_weight(nodes_parsed));
 	if (memnode_shift < 0) {
 		printk(KERN_ERR
diff --git a/arch/x86_64/pci/Makefile-BUS b/arch/x86_64/pci/Makefile-BUS
deleted file mode 100644
index 4f0c05a..0000000
--- a/arch/x86_64/pci/Makefile-BUS
+++ /dev/null
@@ -1,22 +0,0 @@
-#
-# Makefile for X86_64 specific PCI routines
-#
-# Reuse the i386 PCI subsystem
-#
-CFLAGS += -I arch/i386/pci
-
-obj-y		:= i386.o
-obj-$(CONFIG_PCI_DIRECT)+= direct.o
-obj-y		+= fixup.o
-obj-$(CONFIG_ACPI)	+= acpi.o
-obj-y			+= legacy.o irq.o common.o
-# mmconfig has a 64bit special
-obj-$(CONFIG_PCI_MMCONFIG) += mmconfig.o
-
-direct-y += ../../i386/pci/direct.o
-acpi-y   += ../../i386/pci/acpi.o
-legacy-y += ../../i386/pci/legacy.o
-irq-y    += ../../i386/pci/irq.o
-common-y += ../../i386/pci/common.o
-fixup-y  += ../../i386/pci/fixup.o
-i386-y  += ../../i386/pci/i386.o
diff --git a/block/ioctl.c b/block/ioctl.c
index 82030e1..e110949 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -1,4 +1,4 @@
-#include <linux/sched.h>		/* for capable() */
+#include <linux/capability.h>
 #include <linux/blkdev.h>
 #include <linux/blkpg.h>
 #include <linux/hdreg.h>
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
index 18de84c..cc72210 100644
--- a/block/scsi_ioctl.c
+++ b/block/scsi_ioctl.c
@@ -21,6 +21,7 @@
 #include <linux/string.h>
 #include <linux/module.h>
 #include <linux/blkdev.h>
+#include <linux/capability.h>
 #include <linux/completion.h>
 #include <linux/cdrom.h>
 #include <linux/slab.h>
diff --git a/drivers/acorn/char/i2c.c b/drivers/acorn/char/i2c.c
index c22bb9d..c26c08b 100644
--- a/drivers/acorn/char/i2c.c
+++ b/drivers/acorn/char/i2c.c
@@ -12,6 +12,7 @@
  *  On Acorn machines, the following i2c devices are on the bus:
  *	- PCF8583 real time clock & static RAM
  */
+#include <linux/capability.h>
 #include <linux/init.h>
 #include <linux/sched.h>
 #include <linux/time.h>
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 807b0df..cc04933 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -843,6 +843,15 @@
 	unsigned int i;
 	unsigned int working = 0;
 
+#ifdef ARCH_APICTIMER_STOPS_ON_C3
+	struct cpuinfo_x86 *c = cpu_data + pr->id;
+	cpumask_t mask = cpumask_of_cpu(pr->id);
+
+	if (c->x86_vendor == X86_VENDOR_INTEL) {
+		on_each_cpu(switch_ipi_to_APIC_timer, &mask, 1, 1);
+	}
+#endif
+
 	for (i = 1; i < ACPI_PROCESSOR_MAX_POWER; i++) {
 		struct acpi_processor_cx *cx = &pr->power.states[i];
 
@@ -857,6 +866,12 @@
 
 		case ACPI_STATE_C3:
 			acpi_processor_power_verify_c3(pr, cx);
+#ifdef ARCH_APICTIMER_STOPS_ON_C3
+			if (c->x86_vendor == X86_VENDOR_INTEL) {
+				on_each_cpu(switch_APIC_timer_to_ipi,
+						&mask, 1, 1);
+			}
+#endif
 			break;
 		}
 
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 5b3d5e9..3d384e3 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -7,6 +7,7 @@
  *
  */
 
+#include <linux/capability.h>
 #include <linux/device.h>
 #include <linux/module.h>
 #include <linux/init.h>
diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index 58801d7..d1a0522 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -13,8 +13,8 @@
 #include <linux/sysdev.h>
 #include <linux/module.h>
 #include <linux/init.h>
-#include <linux/sched.h>	/* capable() */
 #include <linux/topology.h>
+#include <linux/capability.h>
 #include <linux/device.h>
 #include <linux/memory.h>
 #include <linux/kobject.h>
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index beea450..c67ef3e 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -1056,7 +1056,7 @@
 #define IPMI_MEM_ADDR_SPACE 1
 #define IPMI_IO_ADDR_SPACE  2
 
-#if defined(CONFIG_ACPI) || defined(CONFIG_X86) || defined(CONFIG_PCI)
+#if defined(CONFIG_ACPI) || defined(CONFIG_DMI) || defined(CONFIG_PCI)
 static int is_new_interface(int intf, u8 addr_space, unsigned long base_addr)
 {
 	int i;
@@ -1669,7 +1669,7 @@
 }
 #endif
 
-#ifdef CONFIG_X86
+#ifdef CONFIG_DMI
 typedef struct dmi_ipmi_data
 {
 	u8   		type;
@@ -1829,7 +1829,7 @@
 	       ipmi_data->slave_addr);
 	return 0;
 }
-#endif /* CONFIG_X86 */
+#endif /* CONFIG_DMI */
 
 #ifdef CONFIG_PCI
 
@@ -2222,7 +2222,7 @@
 	if (rv && si_trydefaults)
 		rv = try_init_acpi(intf_num, &new_smi);
 #endif
-#ifdef CONFIG_X86
+#ifdef CONFIG_DMI
 	if (rv && si_trydefaults)
 		rv = try_init_smbios(intf_num, &new_smi);
 #endif
@@ -2433,7 +2433,7 @@
 
 	printk(KERN_INFO "IPMI System Interface driver.\n");
 
-#ifdef CONFIG_X86
+#ifdef CONFIG_DMI
 	dmi_find_bmc();
 #endif
 
diff --git a/drivers/char/random.c b/drivers/char/random.c
index bdfdfd2..86be04b 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -632,7 +632,7 @@
 	preempt_enable();
 }
 
-extern void add_input_randomness(unsigned int type, unsigned int code,
+void add_input_randomness(unsigned int type, unsigned int code,
 				 unsigned int value)
 {
 	static unsigned char last_value;
diff --git a/drivers/char/rio/board.h b/drivers/char/rio/board.h
index 0b397e1..29c9802 100644
--- a/drivers/char/rio/board.h
+++ b/drivers/char/rio/board.h
@@ -52,63 +52,57 @@
 /*
 **	The shape of the Host Control area, at offset 0x7C00, Write Only
 */
-struct s_Ctrl
-{
-	BYTE	DpCtl;				/* 7C00 */
-	BYTE	Dp_Unused2_[127];
-	BYTE	DpIntSet;			/* 7C80 */
-	BYTE	Dp_Unused3_[127];
-	BYTE	DpTpuReset;			/* 7D00 */
-	BYTE	Dp_Unused4_[127];
-	BYTE	DpIntReset;			/* 7D80 */
-	BYTE	Dp_Unused5_[127];
+struct s_Ctrl {
+	BYTE DpCtl;		/* 7C00 */
+	BYTE Dp_Unused2_[127];
+	BYTE DpIntSet;		/* 7C80 */
+	BYTE Dp_Unused3_[127];
+	BYTE DpTpuReset;	/* 7D00 */
+	BYTE Dp_Unused4_[127];
+	BYTE DpIntReset;	/* 7D80 */
+	BYTE Dp_Unused5_[127];
 };
 
 /*
 ** The PROM data area on the host (0x7C00), Read Only
 */
-struct s_Prom
-{
-	WORD	DpSlxCode[2];
-	WORD	DpRev;
-	WORD	Dp_Unused6_;
-	WORD	DpUniq[4];
-	WORD	DpJahre;
-	WORD	DpWoche;
-	WORD	DpHwFeature[5];
-	WORD	DpOemId;
-	WORD	DpSiggy[16];
+struct s_Prom {
+	WORD DpSlxCode[2];
+	WORD DpRev;
+	WORD Dp_Unused6_;
+	WORD DpUniq[4];
+	WORD DpJahre;
+	WORD DpWoche;
+	WORD DpHwFeature[5];
+	WORD DpOemId;
+	WORD DpSiggy[16];
 };
 
 /*
 ** Union of the Ctrl and Prom areas
 */
-union u_CtrlProm	/* This is the control/PROM area (0x7C00) */
-{
-	struct s_Ctrl	DpCtrl;
-	struct s_Prom	DpProm;
+union u_CtrlProm {		/* This is the control/PROM area (0x7C00) */
+	struct s_Ctrl DpCtrl;
+	struct s_Prom DpProm;
 };
 
 /*
 ** The top end of memory!
 */
-struct s_ParmMapS		/* Area containing Parm Map Pointer */
-{
-	BYTE	Dp_Unused8_[DP_PARMMAP_ADDR];
-	WORD	DpParmMapAd;
+struct s_ParmMapS {		/* Area containing Parm Map Pointer */
+	BYTE Dp_Unused8_[DP_PARMMAP_ADDR];
+	WORD DpParmMapAd;
 };
 
-struct s_StartUpS
-{
-	BYTE    Dp_Unused9_[DP_STARTUP_ADDR];
-	BYTE	Dp_LongJump[0x4];
-	BYTE	Dp_Unused10_[2];
-	BYTE	Dp_ShortJump[0x2];
+struct s_StartUpS {
+	BYTE Dp_Unused9_[DP_STARTUP_ADDR];
+	BYTE Dp_LongJump[0x4];
+	BYTE Dp_Unused10_[2];
+	BYTE Dp_ShortJump[0x2];
 };
 
-union u_Sram2ParmMap	/* This is the top of memory (0x7E00-0x7FFF) */
-{
-	BYTE	DpSramMem[DP_SRAM2_SIZE];
+union u_Sram2ParmMap {		/* This is the top of memory (0x7E00-0x7FFF) */
+	BYTE DpSramMem[DP_SRAM2_SIZE];
 	struct s_ParmMapS DpParmMapS;
 	struct s_StartUpS DpStartUpS;
 };
@@ -116,13 +110,12 @@
 /*
 **	This is the DP RAM overlay.
 */
-struct DpRam
-{
-    BYTE 		 DpSram1[DP_SRAM1_SIZE];     /* 0000 - 7BFF */
-    union u_CtrlProm     DpCtrlProm;                 /* 7C00 - 7DFF */
-    union u_Sram2ParmMap DpSram2ParmMap;             /* 7E00 - 7FFF */
-    BYTE		 DpScratch[DP_SCRATCH_SIZE]; /* 8000 - 8FFF */
-    BYTE		 DpSram3[DP_SRAM3_SIZE];     /* 9000 - FFFF */
+struct DpRam {
+	BYTE DpSram1[DP_SRAM1_SIZE];	/* 0000 - 7BFF */
+	union u_CtrlProm DpCtrlProm;	/* 7C00 - 7DFF */
+	union u_Sram2ParmMap DpSram2ParmMap;	/* 7E00 - 7FFF */
+	BYTE DpScratch[DP_SCRATCH_SIZE];	/* 8000 - 8FFF */
+	BYTE DpSram3[DP_SRAM3_SIZE];	/* 9000 - FFFF */
 };
 
 #define	DpControl	DpCtrlProm.DpCtrl.DpCtl
diff --git a/drivers/char/rio/bootpkt.h b/drivers/char/rio/bootpkt.h
index c329aeb..602266e 100644
--- a/drivers/char/rio/bootpkt.h
+++ b/drivers/char/rio/bootpkt.h
@@ -41,7 +41,7 @@
 
 #ifndef lint
 #ifdef SCCS
-static char *_rio_bootpkt_h_sccs = "@(#)bootpkt.h	1.1" ;
+static char *_rio_bootpkt_h_sccs = "@(#)bootpkt.h	1.1";
 #endif
 #endif
 
@@ -49,14 +49,13 @@
      * Overlayed onto the Data fields of a regular
      * Packet
      ************************************************/
-typedef struct BOOT_PKT BOOT_PKT ;
+typedef struct BOOT_PKT BOOT_PKT;
 struct BOOT_PKT {
-                    short     seq_num ;
-                    char      data[10] ;
-                } ;
+	short seq_num;
+	char data[10];
+};
 
 
 #endif
 
 /*********** end of file ***********/
-
diff --git a/drivers/char/rio/brates.h b/drivers/char/rio/brates.h
index bd4fc84..dd686d5 100644
--- a/drivers/char/rio/brates.h
+++ b/drivers/char/rio/brates.h
@@ -97,11 +97,10 @@
 
 #define MAX_RATE B2000
 
-struct    baud_rate            /* Tag for baud rates */
-{
-     /* short    host_rate,*/        /* As passed by the driver */
-     short    divisor,          /* The divisor */
-              prescaler;        /* The pre-scaler */
+struct baud_rate {		/* Tag for baud rates */
+	/* short    host_rate, *//* As passed by the driver */
+	short divisor,		/* The divisor */
+	 prescaler;		/* The pre-scaler */
 };
 
 #endif
diff --git a/drivers/char/rio/chan.h b/drivers/char/rio/chan.h
index 5b30654..af14311 100644
--- a/drivers/char/rio/chan.h
+++ b/drivers/char/rio/chan.h
@@ -21,7 +21,7 @@
 
 #ifndef lint
 #ifdef SCCS
-static char *_rio_chan_h_sccs = "@(#)chan.h	1.1" ;
+static char *_rio_chan_h_sccs = "@(#)chan.h	1.1";
 #endif
 #endif
 
diff --git a/drivers/char/rio/cirrus.h b/drivers/char/rio/cirrus.h
index cf056a9..217ff09 100644
--- a/drivers/char/rio/cirrus.h
+++ b/drivers/char/rio/cirrus.h
@@ -73,20 +73,20 @@
 #define	TIMER_TICK	0x82
 #define STOP_BREAK	0x83
 #define BASE(a) ((a) < 4 ? (short*)CIRRUS_FIRST : ((a) < 8 ? (short *)CIRRUS_SECOND : ((a) < 12 ? (short*)CIRRUS_THIRD : (short *)CIRRUS_FOURTH)))
-#define txack1	((short *)0x7104) 
-#define rxack1	((short *)0x7102) 
+#define txack1	((short *)0x7104)
+#define rxack1	((short *)0x7102)
 #define mdack1  ((short *)0x7106)
-#define txack2  ((short *)0x7006) 
-#define rxack2	((short *)0x7004) 
-#define mdack2  ((short *)0x7100) 
+#define txack2  ((short *)0x7006)
+#define rxack2	((short *)0x7004)
+#define mdack2  ((short *)0x7100)
 #define int_latch       ((short *) 0x7800)
-#define int_status      ((short *) 0x7c00) 
-#define tx1_pending     0x20 
-#define rx1_pending     0x10 
-#define md1_pending     0x40 
-#define tx2_pending     0x02 
-#define rx2_pending     0x01 
-#define md2_pending     0x40 
+#define int_status      ((short *) 0x7c00)
+#define tx1_pending     0x20
+#define rx1_pending     0x10
+#define md1_pending     0x40
+#define tx2_pending     0x02
+#define rx2_pending     0x01
+#define md2_pending     0x40
 #define module1_bits	0x07
 #define module1_modern	0x08
 #define module2_bits	0x70
@@ -113,65 +113,65 @@
    NB. These registers are relative values on 8 bit boundaries whereas
    on the RTA's the CIRRUS registers are on word boundaries. Use pointer
    arithmetic (short *) to obtain the real addresses required */
-#define ccr	0x05	/* Channel Command Register     */
-#define ier	0x06	/* Interrupt Enable Register    */
-#define cor1	0x08	/* Channel Option Register 1    */
-#define cor2	0x09	/* Channel Option Register 2    */
-#define cor3	0x0a	/* Channel Option Register 3    */
-#define cor4	0x1e	/* Channel Option Register 4    */
-#define	cor5	0x1f	/* Channel Option Register 5	*/
+#define ccr	0x05		/* Channel Command Register     */
+#define ier	0x06		/* Interrupt Enable Register    */
+#define cor1	0x08		/* Channel Option Register 1    */
+#define cor2	0x09		/* Channel Option Register 2    */
+#define cor3	0x0a		/* Channel Option Register 3    */
+#define cor4	0x1e		/* Channel Option Register 4    */
+#define	cor5	0x1f		/* Channel Option Register 5    */
 
-#define ccsr	0x0b	/* Channel Control Status Register */
-#define rdcr	0x0e	/* Receive Data Count Register  */
-#define tdcr	0x12	/* Transmit Data Count Register */
-#define mcor1	0x15	/* Modem Change Option Register 1 */
-#define mcor2	0x16	/* Modem Change Option Regsiter 2 */
+#define ccsr	0x0b		/* Channel Control Status Register */
+#define rdcr	0x0e		/* Receive Data Count Register  */
+#define tdcr	0x12		/* Transmit Data Count Register */
+#define mcor1	0x15		/* Modem Change Option Register 1 */
+#define mcor2	0x16		/* Modem Change Option Regsiter 2 */
 
-#define livr	0x18	/* Local Interrupt Vector Register */
-#define schr1	0x1a	/* Special Character Register 1 */
-#define schr2	0x1b	/* Special Character Register 2 */
-#define schr3	0x1c	/* Special Character Register 3 */
-#define schr4	0x1d	/* Special Character Register 4 */
+#define livr	0x18		/* Local Interrupt Vector Register */
+#define schr1	0x1a		/* Special Character Register 1 */
+#define schr2	0x1b		/* Special Character Register 2 */
+#define schr3	0x1c		/* Special Character Register 3 */
+#define schr4	0x1d		/* Special Character Register 4 */
 
-#define rtr	0x20    /* Receive Timer Register */
-#define rtpr	0x21	/* Receive Timeout Period Register */
-#define lnc	0x24	/* Lnext character */
+#define rtr	0x20		/* Receive Timer Register */
+#define rtpr	0x21		/* Receive Timeout Period Register */
+#define lnc	0x24		/* Lnext character */
 
-#define rivr	0x43	/* Receive Interrupt Vector Register    */
-#define tivr	0x42	/* Transmit Interrupt Vector Register   */
-#define mivr	0x41	/* Modem Interrupt Vector Register      */
-#define gfrcr	0x40	/* Global Firmware Revision code Reg    */
-#define ricr	0x44	/* Receive Interrupting Channel Reg     */
-#define ticr	0x45	/* Transmit Interrupting Channel Reg    */
-#define micr	0x46	/* Modem Interrupting Channel Register  */
+#define rivr	0x43		/* Receive Interrupt Vector Register    */
+#define tivr	0x42		/* Transmit Interrupt Vector Register   */
+#define mivr	0x41		/* Modem Interrupt Vector Register      */
+#define gfrcr	0x40		/* Global Firmware Revision code Reg    */
+#define ricr	0x44		/* Receive Interrupting Channel Reg     */
+#define ticr	0x45		/* Transmit Interrupting Channel Reg    */
+#define micr	0x46		/* Modem Interrupting Channel Register  */
 
-#define gcr	0x4b	/* Global configuration register*/
-#define misr    0x4c    /* Modem interrupt status register */
+#define gcr	0x4b		/* Global configuration register */
+#define misr    0x4c		/* Modem interrupt status register */
 
 #define rbusr	0x59
 #define tbusr	0x5a
 #define mbusr	0x5b
 
-#define eoir	0x60	/* End Of Interrupt Register */
-#define rdsr	0x62	/* Receive Data / Status Register */
-#define tdr	0x63	/* Transmit Data Register */
-#define svrr	0x67	/* Service Request Register */
+#define eoir	0x60		/* End Of Interrupt Register */
+#define rdsr	0x62		/* Receive Data / Status Register */
+#define tdr	0x63		/* Transmit Data Register */
+#define svrr	0x67		/* Service Request Register */
 
-#define car	0x68	/* Channel Access Register */
-#define mir	0x69	/* Modem Interrupt Register */
-#define tir	0x6a	/* Transmit Interrupt Register */
-#define rir	0x6b	/* Receive Interrupt Register */
-#define msvr1	0x6c	/* Modem Signal Value Register 1 */
-#define msvr2	0x6d	/* Modem Signal Value Register 2*/
-#define psvr	0x6f	/* Printer Signal Value Register*/
+#define car	0x68		/* Channel Access Register */
+#define mir	0x69		/* Modem Interrupt Register */
+#define tir	0x6a		/* Transmit Interrupt Register */
+#define rir	0x6b		/* Receive Interrupt Register */
+#define msvr1	0x6c		/* Modem Signal Value Register 1 */
+#define msvr2	0x6d		/* Modem Signal Value Register 2 */
+#define psvr	0x6f		/* Printer Signal Value Register */
 
-#define tbpr	0x72	/* Transmit Baud Rate Period Register */
-#define tcor	0x76	/* Transmit Clock Option Register */
+#define tbpr	0x72		/* Transmit Baud Rate Period Register */
+#define tcor	0x76		/* Transmit Clock Option Register */
 
-#define rbpr	0x78	/* Receive Baud Rate Period Register */
-#define rber	0x7a	/* Receive Baud Rate Extension Register */
-#define rcor	0x7c	/* Receive Clock Option Register*/
-#define ppr	0x7e	/* Prescalar Period Register    */
+#define rbpr	0x78		/* Receive Baud Rate Period Register */
+#define rber	0x7a		/* Receive Baud Rate Extension Register */
+#define rcor	0x7c		/* Receive Clock Option Register */
+#define ppr	0x7e		/* Prescalar Period Register    */
 
 /* Misc registers used for forcing the 1400 out of its reset woes */
 #define airl	0x6d
@@ -192,10 +192,10 @@
 
 /* RDSR - when status read from FIFO */
 #define	RDSR_BREAK		0x08	/* Break received */
-#define RDSR_TIMEOUT    	0x80    /* No new data timeout */
-#define RDSR_SC1  	  	0x10    /* Special char 1 (tx XON) matched */
-#define RDSR_SC2  	  	0x20    /* Special char 2 (tx XOFF) matched */
-#define RDSR_SC12_MASK	  	0x30    /* Mask for special chars 1 and 2 */
+#define RDSR_TIMEOUT    	0x80	/* No new data timeout */
+#define RDSR_SC1  	  	0x10	/* Special char 1 (tx XON) matched */
+#define RDSR_SC2  	  	0x20	/* Special char 2 (tx XOFF) matched */
+#define RDSR_SC12_MASK	  	0x30	/* Mask for special chars 1 and 2 */
 
 /* PPR */
 #define PPR_DEFAULT	0x31	/* Default value - for a 25Mhz clock gives
@@ -244,7 +244,7 @@
 #define IER_TIMEOUT	0x01	/* Timeout on no data */
 
 #define	IER_DEFAULT	0x94	/* Default values */
-#define IER_PARALLEL    0x84    /* Default for Parallel */
+#define IER_PARALLEL    0x84	/* Default for Parallel */
 #define	IER_EMPTY	0x92	/* Transmitter empty rather than ready */
 
 /* COR1 - Driver only */
@@ -264,11 +264,11 @@
 #define	COR1_7BITS	0x02	/* 7 data bits */
 #define	COR1_8BITS	0x03	/* 8 data bits */
 
-#define COR1_HOST       0xef    /* Safe host bits */
+#define COR1_HOST       0xef	/* Safe host bits */
 
 /* RTA only */
-#define COR1_CINPCK     0x00    /* Check parity of received characters */
-#define COR1_CNINPCK    0x10    /* Don't check parity */
+#define COR1_CINPCK     0x00	/* Check parity of received characters */
+#define COR1_CNINPCK    0x10	/* Don't check parity */
 
 /* COR2 bits for both RTA and driver use */
 #define	COR2_IXANY	0x80	/* IXANY - any character is XON */
@@ -293,9 +293,9 @@
 #define	COR3_FCT	0x20	/* Flow control transparency */
 #define	COR3_SCD12	0x10	/* Special character detect for SCHR's 1 + 2 */
 #define	COR3_FIFO12	0x0c	/* 12 chars for receive FIFO threshold */
-#define COR3_FIFO10     0x0a    /* 10 chars for receive FIFO threshold */
-#define COR3_FIFO8      0x08    /* 8 chars for receive FIFO threshold */
-#define COR3_FIFO6      0x06    /* 6 chars for receive FIFO threshold */
+#define COR3_FIFO10     0x0a	/* 10 chars for receive FIFO threshold */
+#define COR3_FIFO8      0x08	/* 8 chars for receive FIFO threshold */
+#define COR3_FIFO6      0x06	/* 6 chars for receive FIFO threshold */
 
 #define COR3_THRESHOLD  COR3_FIFO8	/* MUST BE LESS THAN MCOR_THRESHOLD */
 
@@ -386,7 +386,7 @@
 
 #define	MCOR_THRESHBITS 0x0F	/* mask for ANDing out the above */
 
-#define	MCOR_THRESHOLD	MCOR_THRESH9 /* MUST BE GREATER THAN COR3_THRESHOLD */
+#define	MCOR_THRESHOLD	MCOR_THRESH9	/* MUST BE GREATER THAN COR3_THRESHOLD */
 
 
 /* RTPR */
@@ -429,25 +429,25 @@
 #define CONFIG		0x01	/* Configure a port */
 #define	MOPEN		0x02	/* Modem open (block for DCD) */
 #define	CLOSE		0x03	/* Close a port */
-#define	WFLUSH		(0x04 | PRE_EMPTIVE) /* Write flush */
-#define	RFLUSH		(0x05 | PRE_EMPTIVE) /* Read flush */
-#define	RESUME		(0x06 | PRE_EMPTIVE) /* Resume if xoffed */
-#define	SBREAK		0x07 	/* Start break */
+#define	WFLUSH		(0x04 | PRE_EMPTIVE)	/* Write flush */
+#define	RFLUSH		(0x05 | PRE_EMPTIVE)	/* Read flush */
+#define	RESUME		(0x06 | PRE_EMPTIVE)	/* Resume if xoffed */
+#define	SBREAK		0x07	/* Start break */
 #define	EBREAK		0x08	/* End break */
-#define	SUSPEND		(0x09 | PRE_EMPTIVE) /* Susp op (behave as tho xoffed) */
-#define FCLOSE          (0x0a | PRE_EMPTIVE) /* Force close */
-#define XPRINT          0x0b    /* Xprint packet */
-#define MBIS		(0x0c | PRE_EMPTIVE) /* Set modem lines */
-#define MBIC		(0x0d | PRE_EMPTIVE) /* Clear modem lines */
-#define MSET		(0x0e | PRE_EMPTIVE) /* Set modem lines */
+#define	SUSPEND		(0x09 | PRE_EMPTIVE)	/* Susp op (behave as tho xoffed) */
+#define FCLOSE          (0x0a | PRE_EMPTIVE)	/* Force close */
+#define XPRINT          0x0b	/* Xprint packet */
+#define MBIS		(0x0c | PRE_EMPTIVE)	/* Set modem lines */
+#define MBIC		(0x0d | PRE_EMPTIVE)	/* Clear modem lines */
+#define MSET		(0x0e | PRE_EMPTIVE)	/* Set modem lines */
 #define PCLOSE		0x0f	/* Pseudo close - Leaves rx/tx enabled */
-#define MGET		(0x10 | PRE_EMPTIVE) /* Force update of modem status */
-#define MEMDUMP		(0x11 | PRE_EMPTIVE) /* Send back mem from addr supplied */
-#define	READ_REGISTER	(0x12 | PRE_EMPTIVE) /* Read CD1400 register (debug) */
+#define MGET		(0x10 | PRE_EMPTIVE)	/* Force update of modem status */
+#define MEMDUMP		(0x11 | PRE_EMPTIVE)	/* Send back mem from addr supplied */
+#define	READ_REGISTER	(0x12 | PRE_EMPTIVE)	/* Read CD1400 register (debug) */
 
 /* "Command" packets going from remote to host COMPLETE and MODEM_STATUS
    use data[4] / data[3] to indicate current state and modem status respectively
-*/ 
+*/
 
 #define	COMPLETE	(0x20 | PRE_EMPTIVE)
 				/* Command complete */
diff --git a/drivers/char/rio/cmd.h b/drivers/char/rio/cmd.h
index c369eda..797b624 100644
--- a/drivers/char/rio/cmd.h
+++ b/drivers/char/rio/cmd.h
@@ -42,7 +42,7 @@
 
 #ifndef lint
 #ifdef SCCS
-static char *_rio_cmd_h_sccs = "@(#)cmd.h	1.1" ;
+static char *_rio_cmd_h_sccs = "@(#)cmd.h	1.1";
 #endif
 #endif
 
@@ -52,7 +52,7 @@
 
 #define CMD_IGNORE_PKT          ( (ushort) 0)
 #define CMD_STATUS_REQ          ( (ushort) 1)
-#define CMD_UNIT_STATUS_REQ     ( (ushort) 2)     /* Is this needed ??? */
+#define CMD_UNIT_STATUS_REQ     ( (ushort) 2)	/* Is this needed ??? */
 #define CMD_CONF_PORT           ( (ushort) 3)
 #define CMD_CONF_UNIT           ( (ushort) 4)
 #define CMD_ROUTE_MAP_REQ       ( (ushort) 5)
@@ -81,4 +81,3 @@
 #endif
 
 /*********** end of file ***********/
-
diff --git a/drivers/char/rio/cmdblk.h b/drivers/char/rio/cmdblk.h
index 2b8efbd..a9a8c45 100644
--- a/drivers/char/rio/cmdblk.h
+++ b/drivers/char/rio/cmdblk.h
@@ -44,16 +44,15 @@
 ** a rup.
 */
 
-struct CmdBlk
-{
- struct CmdBlk *NextP;          /* Pointer to next command block */
- struct	PKT     Packet;         /* A packet, to copy to the rup */
-    	                        /* The func to call to check if OK */
-    	int     (*PreFuncP)(int, struct CmdBlk *);
-    	int     PreArg;         /* The arg for the func */
-    	                        /* The func to call when completed */
-    	int     (*PostFuncP)(int, struct CmdBlk *);
-    	int     PostArg;        /* The arg for the func */
+struct CmdBlk {
+	struct CmdBlk *NextP;	/* Pointer to next command block */
+	struct PKT Packet;	/* A packet, to copy to the rup */
+	/* The func to call to check if OK */
+	int (*PreFuncP) (int, struct CmdBlk *);
+	int PreArg;		/* The arg for the func */
+	/* The func to call when completed */
+	int (*PostFuncP) (int, struct CmdBlk *);
+	int PostArg;		/* The arg for the func */
 };
 
 #define NUM_RIO_CMD_BLKS (3 * (MAX_RUP * 4 + LINKS_PER_UNIT * 4))
diff --git a/drivers/char/rio/cmdpkt.h b/drivers/char/rio/cmdpkt.h
index 46befd3..77cee8d 100644
--- a/drivers/char/rio/cmdpkt.h
+++ b/drivers/char/rio/cmdpkt.h
@@ -54,135 +54,112 @@
 ** This structure overlays a PktCmd->CmdData structure, and so starts
 ** at Data[2] in the actual pkt!
 */
-struct BootSequence
-{
-    WORD	NumPackets;
-    WORD	LoadBase;
-    WORD	CodeSize;
+struct BootSequence {
+	WORD NumPackets;
+	WORD LoadBase;
+	WORD CodeSize;
 };
 
 #define	BOOT_SEQUENCE_LEN	8
 
-struct SamTop
-{
-    BYTE Unit;
-    BYTE Link;
+struct SamTop {
+	BYTE Unit;
+	BYTE Link;
 };
 
-struct CmdHdr
-{
-    BYTE PcCommand;
-    union
-    {
-    BYTE PcPhbNum;
-    BYTE PcLinkNum;
-    BYTE PcIDNum;
-    } U0;
+struct CmdHdr {
+	BYTE PcCommand;
+	union {
+		BYTE PcPhbNum;
+		BYTE PcLinkNum;
+		BYTE PcIDNum;
+	} U0;
 };
 
 
-struct PktCmd
-{
-    union
-    {
-	struct 
-	{
-	    struct CmdHdr CmdHdr;
-	    struct BootSequence PcBootSequence;
-	} S1;
-	struct
-	{
-	    WORD PcSequence;
-	    BYTE PcBootData[RTA_BOOT_DATA_SIZE];
-	} S2;
-	struct
-	{
-	    WORD  __crud__;
-	    BYTE  PcUniqNum[4];	        /* this is really a uint. */
-	    BYTE  PcModuleTypes;  	/* what modules are fitted */
-	} S3;
-	struct
-	{
-	    struct CmdHdr CmdHdr;
-	    BYTE   __undefined__;
-	    BYTE   PcModemStatus;
-	    BYTE   PcPortStatus;
-	    BYTE   PcSubCommand;	/* commands like mem or register dump */
-	    WORD   PcSubAddr;		/* Address for command */
-	    BYTE   PcSubData[64];	/* Date area for command */
-	} S4;
-	struct
-	{
-	    struct CmdHdr CmdHdr;
-	    BYTE   PcCommandText[1];
-	    BYTE   __crud__[20];
-	    BYTE   PcIDNum2;		/* It had to go somewhere! */
-	} S5;
-	struct
-	{
-	    struct CmdHdr CmdHdr;
-	    struct SamTop    Topology[LINKS_PER_UNIT];
-	} S6;
-    } U1;
+struct PktCmd {
+	union {
+		struct {
+			struct CmdHdr CmdHdr;
+			struct BootSequence PcBootSequence;
+		} S1;
+		struct {
+			WORD PcSequence;
+			BYTE PcBootData[RTA_BOOT_DATA_SIZE];
+		} S2;
+		struct {
+			WORD __crud__;
+			BYTE PcUniqNum[4];	/* this is really a uint. */
+			BYTE PcModuleTypes;	/* what modules are fitted */
+		} S3;
+		struct {
+			struct CmdHdr CmdHdr;
+			BYTE __undefined__;
+			BYTE PcModemStatus;
+			BYTE PcPortStatus;
+			BYTE PcSubCommand;	/* commands like mem or register dump */
+			WORD PcSubAddr;	/* Address for command */
+			BYTE PcSubData[64];	/* Date area for command */
+		} S4;
+		struct {
+			struct CmdHdr CmdHdr;
+			BYTE PcCommandText[1];
+			BYTE __crud__[20];
+			BYTE PcIDNum2;	/* It had to go somewhere! */
+		} S5;
+		struct {
+			struct CmdHdr CmdHdr;
+			struct SamTop Topology[LINKS_PER_UNIT];
+		} S6;
+	} U1;
 };
 
-struct PktCmd_M
-{
-    union
-    {
-	struct 
-	{
-	    struct
-	    {
-    		uchar PcCommand;
-    		union
-    		{
-    		    uchar PcPhbNum;
-    		    uchar PcLinkNum;
-    		    uchar PcIDNum;
-    		} U0;
-	    } CmdHdr;
-	    struct
-	    {
-                ushort	NumPackets;
-                ushort	LoadBase;
-                ushort	CodeSize;
-            } PcBootSequence;
-	} S1;
-	struct
-	{
-	    ushort PcSequence;
-	    uchar PcBootData[RTA_BOOT_DATA_SIZE];
-	} S2;
-	struct
-	{
-	    ushort  __crud__;
-	    uchar  PcUniqNum[4];	        /* this is really a uint. */
-	    uchar  PcModuleTypes;  	/* what modules are fitted */
-	} S3;
-	struct
-	{
-	    ushort  __cmd_hdr__;
-	    uchar   __undefined__;
-	    uchar   PcModemStatus;
-	    uchar   PcPortStatus;
-	    uchar   PcSubCommand;
-	    ushort  PcSubAddr;
-	    uchar   PcSubData[64];
-	} S4;
-	struct
-	{
-	    ushort  __cmd_hdr__;
-	    uchar   PcCommandText[1];
-	    uchar   __crud__[20];
-	    uchar   PcIDNum2;		/* Tacked on end */
-	} S5;
-	struct
-	{
-	    ushort  __cmd_hdr__;
-	    struct Top Topology[LINKS_PER_UNIT];
-	} S6;
-    } U1;
+struct PktCmd_M {
+	union {
+		struct {
+			struct {
+				uchar PcCommand;
+				union {
+					uchar PcPhbNum;
+					uchar PcLinkNum;
+					uchar PcIDNum;
+				} U0;
+			} CmdHdr;
+			struct {
+				ushort NumPackets;
+				ushort LoadBase;
+				ushort CodeSize;
+			} PcBootSequence;
+		} S1;
+		struct {
+			ushort PcSequence;
+			uchar PcBootData[RTA_BOOT_DATA_SIZE];
+		} S2;
+		struct {
+			ushort __crud__;
+			uchar PcUniqNum[4];	/* this is really a uint. */
+			uchar PcModuleTypes;	/* what modules are fitted */
+		} S3;
+		struct {
+			ushort __cmd_hdr__;
+			uchar __undefined__;
+			uchar PcModemStatus;
+			uchar PcPortStatus;
+			uchar PcSubCommand;
+			ushort PcSubAddr;
+			uchar PcSubData[64];
+		} S4;
+		struct {
+			ushort __cmd_hdr__;
+			uchar PcCommandText[1];
+			uchar __crud__[20];
+			uchar PcIDNum2;	/* Tacked on end */
+		} S5;
+		struct {
+			ushort __cmd_hdr__;
+			struct Top Topology[LINKS_PER_UNIT];
+		} S6;
+	} U1;
 };
 
 #define Command		U1.S1.CmdHdr.PcCommand
diff --git a/drivers/char/rio/control.h b/drivers/char/rio/control.h
index 1712f62..6853d03 100644
--- a/drivers/char/rio/control.h
+++ b/drivers/char/rio/control.h
@@ -51,12 +51,11 @@
 #define	UFOAD		( CONTROL + 4 )
 #define IWAIT		( CONTROL + 5 )
 
-#define	IFOAD_MAGIC	0xF0AD		/* of course */
+#define	IFOAD_MAGIC	0xF0AD	/* of course */
 #define	ZOMBIE_MAGIC	(~0xDEAD)	/* not dead -> zombie */
-#define	UFOAD_MAGIC	0xD1E		/* kill-your-neighbour */
-#define	IWAIT_MAGIC	0xB1DE		/* Bide your time */
+#define	UFOAD_MAGIC	0xD1E	/* kill-your-neighbour */
+#define	IWAIT_MAGIC	0xB1DE	/* Bide your time */
 
 #endif
 
 /*********** end of file ***********/
-
diff --git a/drivers/char/rio/daemon.h b/drivers/char/rio/daemon.h
index 62dba0e..28a991b 100644
--- a/drivers/char/rio/daemon.h
+++ b/drivers/char/rio/daemon.h
@@ -44,18 +44,16 @@
 ** structures used on /dev/rio
 */
 
-struct Error
-{
-	uint	Error;
-	uint	Entry;
-	uint	Other;
+struct Error {
+	uint Error;
+	uint Entry;
+	uint Other;
 };
 
-struct DownLoad
-{
-	char	*DataP;
-	uint	Count;
-	uint	ProductCode;
+struct DownLoad {
+	char *DataP;
+	uint Count;
+	uint ProductCode;
 };
 
 /*
@@ -66,46 +64,41 @@
 #endif
 
 #ifndef MAX_XP_CTRL_LEN
-#define	MAX_XP_CTRL_LEN 16		/* ALSO IN PORT.H */
+#define	MAX_XP_CTRL_LEN 16	/* ALSO IN PORT.H */
 #endif
 
-struct	PortSetup
-{
-	uint	From;	/* Set/Clear XP & IXANY Control from this port.... */
-	uint	To;	/* .... to this port */
-	uint	XpCps;			/* at this speed */
-	char	XpOn[MAX_XP_CTRL_LEN];	/* this is the start string */
-	char	XpOff[MAX_XP_CTRL_LEN];	/* this is the stop string */
-	uchar	IxAny;			/* enable/disable IXANY */
-	uchar	IxOn;			/* enable/disable IXON */
-	uchar	Lock;			/* lock port params */
-	uchar	Store;			/* store params across closes */
-	uchar	Drain;			/* close only when drained */
+struct PortSetup {
+	uint From;		/* Set/Clear XP & IXANY Control from this port.... */
+	uint To;		/* .... to this port */
+	uint XpCps;		/* at this speed */
+	char XpOn[MAX_XP_CTRL_LEN];	/* this is the start string */
+	char XpOff[MAX_XP_CTRL_LEN];	/* this is the stop string */
+	uchar IxAny;		/* enable/disable IXANY */
+	uchar IxOn;		/* enable/disable IXON */
+	uchar Lock;		/* lock port params */
+	uchar Store;		/* store params across closes */
+	uchar Drain;		/* close only when drained */
 };
 
-struct	LpbReq
-{
-	uint	Host;
-	uint	Link;
-	struct  LPB     *LpbP;
+struct LpbReq {
+	uint Host;
+	uint Link;
+	struct LPB *LpbP;
 };
 
-struct	RupReq
-{
-	uint	HostNum;
-	uint	RupNum;
-	struct  RUP 	*RupP;
+struct RupReq {
+	uint HostNum;
+	uint RupNum;
+	struct RUP *RupP;
 };
 
-struct	PortReq
-{
-	uint	SysPort;
-	struct  Port 	*PortP;
+struct PortReq {
+	uint SysPort;
+	struct Port *PortP;
 };
 
-struct  StreamInfo
-{
-	uint	SysPort;
+struct StreamInfo {
+	uint SysPort;
 #if 0
 	queue_t RQueue;
 	queue_t WQueue;
@@ -115,68 +108,59 @@
 #endif
 };
 
-struct	HostReq
-{
-	uint	HostNum;
-	struct  Host 	*HostP;
+struct HostReq {
+	uint HostNum;
+	struct Host *HostP;
 };
 
-struct	HostDpRam
-{
-	uint	HostNum;
-	struct	DpRam	*DpRamP;
+struct HostDpRam {
+	uint HostNum;
+	struct DpRam *DpRamP;
 };
 
-struct	DebugCtrl
-{
-	uint	SysPort;
-	uint	Debug;
-	uint	Wait;
+struct DebugCtrl {
+	uint SysPort;
+	uint Debug;
+	uint Wait;
 };
 
-struct	MapInfo
-{
-	uint	FirstPort;	/* 8 ports, starting from this (tty) number */
-	uint	RtaUnique;	/* reside on this RTA (unique number) */
+struct MapInfo {
+	uint FirstPort;		/* 8 ports, starting from this (tty) number */
+	uint RtaUnique;		/* reside on this RTA (unique number) */
 };
 
-struct	MapIn
-{
-	uint	NumEntries;		/* How many port sets are we mapping? */
-	struct  MapInfo	*MapInfoP;	/* Pointer to (user space) info */
+struct MapIn {
+	uint NumEntries;	/* How many port sets are we mapping? */
+	struct MapInfo *MapInfoP;	/* Pointer to (user space) info */
 };
 
-struct  SendPack
-{
-        unsigned int	PortNum;
-	unsigned char	Len;
-	unsigned char	Data[PKT_MAX_DATA_LEN];
+struct SendPack {
+	unsigned int PortNum;
+	unsigned char Len;
+	unsigned char Data[PKT_MAX_DATA_LEN];
 };
 
-struct SpecialRupCmd
-{
-	struct	PKT		Packet;
-	unsigned short	Host;
-	unsigned short	RupNum;
+struct SpecialRupCmd {
+	struct PKT Packet;
+	unsigned short Host;
+	unsigned short RupNum;
 };
 
-struct	IdentifyRta
-{
-	ulong	RtaUnique;
-	uchar	ID;
+struct IdentifyRta {
+	ulong RtaUnique;
+	uchar ID;
 };
 
-struct	KillNeighbour
-{
-	ulong	UniqueNum;
-	uchar	Link;
+struct KillNeighbour {
+	ulong UniqueNum;
+	uchar Link;
 };
 
 struct rioVersion {
-    char        version[MAX_VERSION_LEN];
-    char        relid[MAX_VERSION_LEN];
-    int         buildLevel;
-    char        buildDate[MAX_VERSION_LEN];
+	char version[MAX_VERSION_LEN];
+	char relid[MAX_VERSION_LEN];
+	int buildLevel;
+	char buildDate[MAX_VERSION_LEN];
 };
 
 
@@ -316,16 +300,16 @@
 #define	RIO_SET_XP_CPS    rIOCW(155,int)
 #define RIO_GET_IXANY     rIOCR(156,int)	/* ixany allowed? */
 #define RIO_SET_IXANY     rIOCW(157,int)
-#define RIO_SET_IXANY_ON  rIOCN(158)		/* allow ixany */
-#define RIO_SET_IXANY_OFF rIOCN(159)		/* disallow ixany */
+#define RIO_SET_IXANY_ON  rIOCN(158)	/* allow ixany */
+#define RIO_SET_IXANY_OFF rIOCN(159)	/* disallow ixany */
 #define RIO_GET_MODEM     rIOCR(160,int)	/* port is modem/direct line? */
 #define RIO_SET_MODEM     rIOCW(161,int)
-#define RIO_SET_MODEM_ON  rIOCN(162)		/* port is a modem */
-#define RIO_SET_MODEM_OFF rIOCN(163)		/* port is direct */
+#define RIO_SET_MODEM_ON  rIOCN(162)	/* port is a modem */
+#define RIO_SET_MODEM_OFF rIOCN(163)	/* port is direct */
 #define RIO_GET_IXON      rIOCR(164,int)	/* ixon allowed? */
 #define RIO_SET_IXON      rIOCW(165,int)
-#define RIO_SET_IXON_ON   rIOCN(166)		/* allow ixon */
-#define RIO_SET_IXON_OFF  rIOCN(167)		/* disallow ixon */
+#define RIO_SET_IXON_ON   rIOCN(166)	/* allow ixon */
+#define RIO_SET_IXON_OFF  rIOCN(167)	/* disallow ixon */
 
 #define RIO_GET_SIVIEW	  ((('s')<<8) | 106)	/* backwards compatible with SI */
 
diff --git a/drivers/char/rio/debug.h b/drivers/char/rio/debug.h
index b6e0d09..6ae95c0 100644
--- a/drivers/char/rio/debug.h
+++ b/drivers/char/rio/debug.h
@@ -33,7 +33,7 @@
 #define	DBPACKET(pkt, opt, str, chn) 	debug_packet((pkt), (opt), (str), (chn))
 #else
 #define	DBPACKET(pkt, opt, str, c)
-#endif	/* DCIRRUS */
+#endif				/* DCIRRUS */
 
 
-#endif	/* _debug_h_ */
+#endif				/* _debug_h_ */
diff --git a/drivers/char/rio/defaults.h b/drivers/char/rio/defaults.h
index 2e7309e..5b600c3 100644
--- a/drivers/char/rio/defaults.h
+++ b/drivers/char/rio/defaults.h
@@ -37,13 +37,13 @@
 
 #ifndef lint
 #ifdef SCCS
-static char *_rio_defaults_h_sccs = "@(#)defaults.h	1.1" ;
+static char *_rio_defaults_h_sccs = "@(#)defaults.h	1.1";
 #endif
 #endif
 
 
-#define MILLISECOND           (int) (1000/64)   /* 15.625 low ticks */
-#define SECOND                (int) 15625       /* Low priority ticks */
+#define MILLISECOND           (int) (1000/64)	/* 15.625 low ticks */
+#define SECOND                (int) 15625	/* Low priority ticks */
 
 #ifdef RTA
 #define RX_LIMIT       (ushort) 3
@@ -56,4 +56,3 @@
 
 
 /*********** end of file ***********/
-
diff --git a/drivers/char/rio/eisa.h b/drivers/char/rio/eisa.h
index 59371b0..c2abaf0 100644
--- a/drivers/char/rio/eisa.h
+++ b/drivers/char/rio/eisa.h
@@ -60,7 +60,7 @@
 
 #define	EISA_PRODUCT_IDENT_LO		0xC80	/* where RIO_EISA_IDENT is */
 #define	EISA_PRODUCT_IDENT_HI		0xC81
-#define	EISA_PRODUCT_NUMBER		0xC82   /* where PROD_CODE is */
+#define	EISA_PRODUCT_NUMBER		0xC82	/* where PROD_CODE is */
 #define	EISA_REVISION_NUMBER		0xC83	/* revision (1dp) */
 #define	EISA_ENABLE			0xC84	/* set LSB to enable card */
 #define	EISA_UNIQUE_NUM_0		0xC88	/* vomit */
@@ -101,4 +101,4 @@
 #define	INBZ(z,x)	inb(((z)<<12) | (x))
 #define	OUTBZ(z,x,y)	outb((((z)<<12) | (x)), y)
 
-#endif /* __rio_eisa_h__ */
+#endif				/* __rio_eisa_h__ */
diff --git a/drivers/char/rio/enable.h b/drivers/char/rio/enable.h
index 8e9a419..e06673f 100644
--- a/drivers/char/rio/enable.h
+++ b/drivers/char/rio/enable.h
@@ -36,7 +36,7 @@
 
 #ifndef lint
 #ifdef SCCS
-static char *_rio_enable_h_sccs = "@(#)enable.h	1.1" ;
+static char *_rio_enable_h_sccs = "@(#)enable.h	1.1";
 #endif
 #endif
 
@@ -46,5 +46,3 @@
 
 
 /*********** end of file ***********/
-
-
diff --git a/drivers/char/rio/error.h b/drivers/char/rio/error.h
index 229438e..f20f078 100644
--- a/drivers/char/rio/error.h
+++ b/drivers/char/rio/error.h
@@ -80,6 +80,3 @@
 
 
 /*********** end of file ***********/
-
-
-
diff --git a/drivers/char/rio/errors.h b/drivers/char/rio/errors.h
index f920b9f..1d0d891 100644
--- a/drivers/char/rio/errors.h
+++ b/drivers/char/rio/errors.h
@@ -101,4 +101,4 @@
 #define	NOT_ENOUGH_CORE_FOR_PCI_COPY	53
 
 
-#endif /* __rio_errors_h__ */
+#endif				/* __rio_errors_h__ */
diff --git a/drivers/char/rio/formpkt.h b/drivers/char/rio/formpkt.h
index a8b65ae..3c7c91a 100644
--- a/drivers/char/rio/formpkt.h
+++ b/drivers/char/rio/formpkt.h
@@ -41,114 +41,113 @@
 
 #ifndef lint
 #ifdef SCCS
-static char *_rio_formpkt_h_sccs = "@(#)formpkt.h	1.1" ;
+static char *_rio_formpkt_h_sccs = "@(#)formpkt.h	1.1";
 #endif
 #endif
 
-typedef struct FORM_BOOT_PKT_1 FORM_BOOT_PKT_1 ;
+typedef struct FORM_BOOT_PKT_1 FORM_BOOT_PKT_1;
 struct FORM_BOOT_PKT_1 {
-                           ushort pkt_number ;
-                           ushort pkt_total ;
-                           ushort boot_top ;
-                       } ;
+	ushort pkt_number;
+	ushort pkt_total;
+	ushort boot_top;
+};
 
-typedef struct FORM_BOOT_PKT_2 FORM_BOOT_PKT_2 ;
+typedef struct FORM_BOOT_PKT_2 FORM_BOOT_PKT_2;
 struct FORM_BOOT_PKT_2 {
-                           ushort pkt_number ;
-                           char   boot_data[10] ;
-                       } ;
+	ushort pkt_number;
+	char boot_data[10];
+};
 
 
-typedef struct FORM_ATTACH_RTA   FORM_ATTACH_RTA ;
-struct FORM_ATTACH_RTA  {
-                       char    cmd_code ;
-                       char    booter_serial[4] ;
-                       char    booter_link ;
-                       char    bootee_serial[4] ;
-                       char    bootee_link ;
-                   } ;
+typedef struct FORM_ATTACH_RTA FORM_ATTACH_RTA;
+struct FORM_ATTACH_RTA {
+	char cmd_code;
+	char booter_serial[4];
+	char booter_link;
+	char bootee_serial[4];
+	char bootee_link;
+};
 
 
-typedef struct FORM_BOOT_ID   FORM_BOOT_ID ;
-struct FORM_BOOT_ID  {
-                       char    cmd_code ;
-                       char    bootee_serial[4] ;
-                       char    bootee_prod_id ;
-                       char    bootee_link ;
-                   } ;
+typedef struct FORM_BOOT_ID FORM_BOOT_ID;
+struct FORM_BOOT_ID {
+	char cmd_code;
+	char bootee_serial[4];
+	char bootee_prod_id;
+	char bootee_link;
+};
 
 
 
-typedef struct FORM_ROUTE_1   FORM_ROUTE_1 ;
+typedef struct FORM_ROUTE_1 FORM_ROUTE_1;
 struct FORM_ROUTE_1 {
-                        char     cmd_code ;
-                        char     pkt_number ;
-                        char     total_in_sequence ;
-                        char     unit_id ;
-                        char     host_unit_id ;
-                    } ;
+	char cmd_code;
+	char pkt_number;
+	char total_in_sequence;
+	char unit_id;
+	char host_unit_id;
+};
 
-typedef struct FORM_ROUTE_2   FORM_ROUTE_2 ;
+typedef struct FORM_ROUTE_2 FORM_ROUTE_2;
 struct FORM_ROUTE_2 {
-                        char   cmd_code ;
-                        char   pkt_number ;
-                        char   total_in_sequence ;
-                        char   route_data[9] ;
-                    } ;
+	char cmd_code;
+	char pkt_number;
+	char total_in_sequence;
+	char route_data[9];
+};
 
-typedef struct FORM_ROUTE_REQ   FORM_ROUTE_REQ ;
+typedef struct FORM_ROUTE_REQ FORM_ROUTE_REQ;
 struct FORM_ROUTE_REQ {
-                          char   cmd_code ;
-                          char   pkt_number ;
-                          char   total_in_sequence ;
-                          char   route_data[10] ;
-                      } ;
+	char cmd_code;
+	char pkt_number;
+	char total_in_sequence;
+	char route_data[10];
+};
 
 
-typedef struct FORM_ERROR   FORM_ERROR ;
+typedef struct FORM_ERROR FORM_ERROR;
 struct FORM_ERROR {
-                        char   cmd_code ;
-                        char   error_code ;
+	char cmd_code;
+	char error_code;
 
-                    } ;
+};
 
-typedef struct FORM_STATUS   FORM_STATUS ;
+typedef struct FORM_STATUS FORM_STATUS;
 struct FORM_STATUS {
-                        char   cmd_code ;
-                        char   status_code ;
-                        char   last_packet_valid ;
-                        char   tx_buffer ;
-                        char   rx_buffer ;
-                        char   port_status ;
-                        char   phb_status ;
-                    } ;
+	char cmd_code;
+	char status_code;
+	char last_packet_valid;
+	char tx_buffer;
+	char rx_buffer;
+	char port_status;
+	char phb_status;
+};
 
 
-typedef struct FORM_LINK_STATUS   FORM_LINK_STATUS ;
+typedef struct FORM_LINK_STATUS FORM_LINK_STATUS;
 struct FORM_LINK_STATUS {
-                        char    cmd_code ;
-                        char    status_code ;
-                        char    link_number ;
-                        ushort  rx_errors ;
-                        ushort  tx_errors ;
-                        ushort  csum_errors ;
-                        ushort  disconnects ;
-                    } ;
+	char cmd_code;
+	char status_code;
+	char link_number;
+	ushort rx_errors;
+	ushort tx_errors;
+	ushort csum_errors;
+	ushort disconnects;
+};
 
 
 
-typedef struct FORM_PARTITION FORM_PARTITION ;
+typedef struct FORM_PARTITION FORM_PARTITION;
 struct FORM_PARTITION {
-                        char    cmd_code ;
-                        char    status_code ;
-                        char    port_number ;
-                        char    tx_max ;
-                        char    rx_max ;
-                        char    rx_limit ;
-                      } ;
+	char cmd_code;
+	char status_code;
+	char port_number;
+	char tx_max;
+	char rx_max;
+	char rx_limit;
+};
 
 
 #endif
 
 /*********** end of file ***********/
-
diff --git a/drivers/char/rio/func.h b/drivers/char/rio/func.h
index 01987c6..b477841 100644
--- a/drivers/char/rio/func.h
+++ b/drivers/char/rio/func.h
@@ -47,20 +47,19 @@
 int RIOBootCodeUNKNOWN(struct rio_info *, struct DownLoad *);
 void msec_timeout(struct Host *);
 int RIOBootRup(struct rio_info *, uint, struct Host *, struct PKT *);
-int RIOBootOk(struct rio_info *,struct Host *, ulong);
-int RIORtaBound(struct rio_info *, uint); 
+int RIOBootOk(struct rio_info *, struct Host *, ulong);
+int RIORtaBound(struct rio_info *, uint);
 void FillSlot(int, int, uint, struct Host *);
 
 /* riocmd.c */
 int RIOFoadRta(struct Host *, struct Map *);
 int RIOZombieRta(struct Host *, struct Map *);
-int RIOCommandRta(struct rio_info *, uint, int (* func)( struct Host *, 
-								struct Map *));
-int RIOIdentifyRta(struct rio_info *, caddr_t); 
+int RIOCommandRta(struct rio_info *, uint, int (*func) (struct Host *, struct Map *));
+int RIOIdentifyRta(struct rio_info *, caddr_t);
 int RIOKillNeighbour(struct rio_info *, caddr_t);
 int RIOSuspendBootRta(struct Host *, int, int);
 int RIOFoadWakeup(struct rio_info *);
-struct CmdBlk * RIOGetCmdBlk(void);
+struct CmdBlk *RIOGetCmdBlk(void);
 void RIOFreeCmdBlk(struct CmdBlk *);
 int RIOQueueCmdBlk(struct Host *, uint, struct CmdBlk *);
 void RIOPollHostCommands(struct rio_info *, struct Host *);
@@ -71,13 +70,13 @@
 
 /* rioctrl.c */
 int copyin(int, caddr_t, int);
-int riocontrol(struct rio_info *, dev_t,int,caddr_t,int); 
-int RIOPreemptiveCmd(struct rio_info *,struct Port *,uchar);
+int riocontrol(struct rio_info *, dev_t, int, caddr_t, int);
+int RIOPreemptiveCmd(struct rio_info *, struct Port *, uchar);
 
 /* rioinit.c */
 void rioinit(struct rio_info *, struct RioHostInfo *);
 void RIOInitHosts(struct rio_info *, struct RioHostInfo *);
-void RIOISAinit(struct rio_info *,int);
+void RIOISAinit(struct rio_info *, int);
 int RIODoAT(struct rio_info *, int, int);
 caddr_t RIOCheckForATCard(int);
 int RIOAssignAT(struct rio_info *, int, caddr_t, int);
@@ -85,7 +84,7 @@
 void RIOAllocDataStructs(struct rio_info *);
 void RIOSetupDataStructs(struct rio_info *);
 int RIODefaultName(struct rio_info *, struct Host *, uint);
-struct rioVersion * RIOVersid(void);
+struct rioVersion *RIOVersid(void);
 int RIOMapin(paddr_t, int, caddr_t *);
 void RIOMapout(paddr_t, long, caddr_t);
 void RIOHostReset(uint, volatile struct DpRam *, uint);
@@ -108,7 +107,7 @@
 
 /* rioroute.c */
 int RIORouteRup(struct rio_info *, uint, struct Host *, struct PKT *);
-void RIOFixPhbs(struct rio_info *, struct Host *, uint); 
+void RIOFixPhbs(struct rio_info *, struct Host *, uint);
 uint GetUnitType(uint);
 int RIOSetChange(struct rio_info *);
 int RIOFindFreeID(struct rio_info *, struct Host *, uint *, uint *);
@@ -116,9 +115,9 @@
 
 /* riotty.c */
 
-int riotopen(struct tty_struct * tty, struct file * filp);
-int riotclose(void  *ptr);
-int riotioctl(struct rio_info *, struct tty_struct *, register int, register caddr_t); 
+int riotopen(struct tty_struct *tty, struct file *filp);
+int riotclose(void *ptr);
+int riotioctl(struct rio_info *, struct tty_struct *, register int, register caddr_t);
 void ttyseth(struct Port *, struct ttystatics *, struct old_sgttyb *sg);
 
 /* riotable.c */
@@ -127,27 +126,27 @@
 int RIODeleteRta(struct rio_info *, struct Map *);
 int RIOAssignRta(struct rio_info *, struct Map *);
 int RIOReMapPorts(struct rio_info *, struct Host *, struct Map *);
-int RIOChangeName(struct rio_info *, struct Map*);
+int RIOChangeName(struct rio_info *, struct Map *);
 
 #if 0
 /* riodrvr.c */
-struct rio_info * rio_install(struct RioHostInfo *);
+struct rio_info *rio_install(struct RioHostInfo *);
 int rio_uninstall(register struct rio_info *);
 int rio_open(struct rio_info *, int, struct file *);
 int rio_close(struct rio_info *, struct file *);
 int rio_read(struct rio_info *, struct file *, char *, int);
-int rio_write(struct rio_info *, struct file *	f, char *, int);
+int rio_write(struct rio_info *, struct file *f, char *, int);
 int rio_ioctl(struct rio_info *, struct file *, int, char *);
-int rio_select(struct rio_info *, struct file *	f, int, struct sel *);
-int	rio_intr(char *);
-int rio_isr_thread(char  *);
-struct rio_info * rio_info_store( int cmd, struct rio_info * p);
+int rio_select(struct rio_info *, struct file *f, int, struct sel *);
+int rio_intr(char *);
+int rio_isr_thread(char *);
+struct rio_info *rio_info_store(int cmd, struct rio_info *p);
 #endif
 
-extern int    rio_pcicopy(char *src, char *dst, int n);
-extern int rio_minor (struct tty_struct *tty);
-extern int rio_ismodem (struct tty_struct *tty);
+extern int rio_pcicopy(char *src, char *dst, int n);
+extern int rio_minor(struct tty_struct *tty);
+extern int rio_ismodem(struct tty_struct *tty);
 
-extern void rio_start_card_running (struct Host * HostP);
+extern void rio_start_card_running(struct Host *HostP);
 
-#endif	/* __func_h_def */
+#endif				/* __func_h_def */
diff --git a/drivers/char/rio/host.h b/drivers/char/rio/host.h
index 4c65963..f7dfced 100644
--- a/drivers/char/rio/host.h
+++ b/drivers/char/rio/host.h
@@ -49,33 +49,32 @@
 **    Host data structure. This is used for the software equiv. of
 **    the host.
 */
-struct    Host
-{
-    uchar             	    Type;      /* RIO_EISA, RIO_MCA, ... */
-    uchar             	    Ivec;      /* POLLED or ivec number */
-    uchar             	    Mode;      /* Control stuff */
-    uchar                   Slot;      /* Slot */
-    volatile caddr_t        Caddr;     /* KV address of DPRAM */
-    volatile struct DpRam  *CardP;     /* KV address of DPRAM, with overlay */
-    paddr_t          	    PaddrP;    /* Phys. address of DPRAM */
-    char                    Name[MAX_NAME_LEN];  /* The name of the host */
-    uint            	    UniqueNum; /* host unique number */
-    spinlock_t	            HostLock;  /* Lock structure for MPX */
-    /*struct pci_devinfo    PciDevInfo; *//* PCI Bus/Device/Function stuff */
-    /*struct lockb	    HostLock;  *//* Lock structure for MPX */
-    uint                    WorkToBeDone; /* set to true each interrupt */
-    uint                    InIntr;    /* Being serviced? */
-    uint                    IntSrvDone;/* host's interrupt has been serviced */
-    int			    (*Copy)( caddr_t, caddr_t, int ); /* copy func */
-    struct timer_list timer;
-    /*
-    **               I M P O R T A N T !
-    **
-    ** The rest of this data structure is cleared to zero after
-    ** a RIO_HOST_FOAD command.
-    */
-    
-    ulong                   Flags;     /* Whats going down */
+struct Host {
+	uchar Type;		/* RIO_EISA, RIO_MCA, ... */
+	uchar Ivec;		/* POLLED or ivec number */
+	uchar Mode;		/* Control stuff */
+	uchar Slot;		/* Slot */
+	volatile caddr_t Caddr;	/* KV address of DPRAM */
+	volatile struct DpRam *CardP;	/* KV address of DPRAM, with overlay */
+	paddr_t PaddrP;		/* Phys. address of DPRAM */
+	char Name[MAX_NAME_LEN];	/* The name of the host */
+	uint UniqueNum;		/* host unique number */
+	spinlock_t HostLock;	/* Lock structure for MPX */
+	/*struct pci_devinfo    PciDevInfo; *//* PCI Bus/Device/Function stuff */
+	/*struct lockb          HostLock;  *//* Lock structure for MPX */
+	uint WorkToBeDone;	/* set to true each interrupt */
+	uint InIntr;		/* Being serviced? */
+	uint IntSrvDone;	/* host's interrupt has been serviced */
+	int (*Copy) (caddr_t, caddr_t, int);	/* copy func */
+	struct timer_list timer;
+	/*
+	 **               I M P O R T A N T !
+	 **
+	 ** The rest of this data structure is cleared to zero after
+	 ** a RIO_HOST_FOAD command.
+	 */
+
+	ulong Flags;		/* Whats going down */
 #define RC_WAITING            0
 #define RC_STARTUP            1
 #define RC_RUNNING            2
@@ -93,25 +92,25 @@
 #define RC_BOOT_OWN           0x10	/* Only boot RTAs bound to this system */
 #define RC_BOOT_NONE          0x20	/* Don't boot any RTAs (slave mode) */
 
-    struct Top		    Topology[LINKS_PER_UNIT]; /* one per link */
-    struct Map              Mapping[MAX_RUP];     /* Mappings for host */
-    struct PHB		    *PhbP;                /* Pointer to the PHB array */
-    ushort           	    *PhbNumP;             /* Ptr to Number of PHB's */
-    struct LPB 	            *LinkStrP ;           /* Link Structure Array */
-    struct RUP       	    *RupP;                /* Sixteen real rups here */
-    struct PARM_MAP  	    *ParmMapP;            /* points to the parmmap */
-    uint                    ExtraUnits[MAX_EXTRA_UNITS]; /* unknown things */
-    uint                    NumExtraBooted;       /* how many of the above */
-    /*
-    ** Twenty logical rups.
-    ** The first sixteen are the real Rup entries (above), the last four
-    ** are the link RUPs.
-    */
-    struct UnixRup	    UnixRups[MAX_RUP+LINKS_PER_UNIT];
-	int				timeout_id;	/* For calling 100 ms delays */
-	int				timeout_sem;/* For calling 100 ms delays */
-    long locks; /* long req'd for set_bit --RR */
-    char             	    ____end_marker____;
+	struct Top Topology[LINKS_PER_UNIT];	/* one per link */
+	struct Map Mapping[MAX_RUP];	/* Mappings for host */
+	struct PHB *PhbP;	/* Pointer to the PHB array */
+	ushort *PhbNumP;	/* Ptr to Number of PHB's */
+	struct LPB *LinkStrP;	/* Link Structure Array */
+	struct RUP *RupP;	/* Sixteen real rups here */
+	struct PARM_MAP *ParmMapP;	/* points to the parmmap */
+	uint ExtraUnits[MAX_EXTRA_UNITS];	/* unknown things */
+	uint NumExtraBooted;	/* how many of the above */
+	/*
+	 ** Twenty logical rups.
+	 ** The first sixteen are the real Rup entries (above), the last four
+	 ** are the link RUPs.
+	 */
+	struct UnixRup UnixRups[MAX_RUP + LINKS_PER_UNIT];
+	int timeout_id;		/* For calling 100 ms delays */
+	int timeout_sem;	/* For calling 100 ms delays */
+	long locks;		/* long req'd for set_bit --RR */
+	char ____end_marker____;
 };
 #define Control      CardP->DpControl
 #define SetInt       CardP->DpSetInt
@@ -129,6 +128,6 @@
 #define Year         CardP->DpYear
 #define Week         CardP->DpWeek
 
-#define RIO_DUMBPARM 0x0860    /* what not to expect */
+#define RIO_DUMBPARM 0x0860	/* what not to expect */
 
 #endif
diff --git a/drivers/char/rio/hosthw.h b/drivers/char/rio/hosthw.h
index f6f31ec..6281fe4 100644
--- a/drivers/char/rio/hosthw.h
+++ b/drivers/char/rio/hosthw.h
@@ -37,7 +37,7 @@
 
 #ifndef lint
 #ifdef SCCS_LABELS
-static char *_rio_hosthw_h_sccs = "@(#)hosthw.h	1.2" ;
+static char *_rio_hosthw_h_sccs = "@(#)hosthw.h	1.2";
 #endif
 #endif
 
@@ -53,5 +53,3 @@
 
 
 /*********** end of file ***********/
-
-
diff --git a/drivers/char/rio/link.h b/drivers/char/rio/link.h
index 9722503..bfba5b0 100644
--- a/drivers/char/rio/link.h
+++ b/drivers/char/rio/link.h
@@ -70,27 +70,27 @@
 #define  DIE_NOW		(ushort) 0x0200
 
 /* Boot request stuff */
-#define BOOT_REQUEST       ((ushort) 0)    /* Request for a boot */
-#define BOOT_ABORT         ((ushort) 1)    /* Abort a boot */
-#define BOOT_SEQUENCE      ((ushort) 2)    /* Packet with the number of packets
-                                              and load address */
-#define BOOT_COMPLETED     ((ushort) 3)    /* Boot completed */
+#define BOOT_REQUEST       ((ushort) 0)	/* Request for a boot */
+#define BOOT_ABORT         ((ushort) 1)	/* Abort a boot */
+#define BOOT_SEQUENCE      ((ushort) 2)	/* Packet with the number of packets
+					   and load address */
+#define BOOT_COMPLETED     ((ushort) 3)	/* Boot completed */
 
 /* States that a link can be in */
-#define	LINK_DISCONNECTED  ((ushort) 0)    /* Disconnected */
-#define LINK_BOOT1         ((ushort) 1)    /* Trying to send 1st stage boot */
-#define LINK_BOOT2         ((ushort) 2)    /* Trying to send 2nd stage boot */
-#define LINK_BOOT2WAIT     ((ushort) 3)    /* Waiting for selftest results */
-#define LINK_BOOT3         ((ushort) 4)    /* Trying to send 3rd stage boots */
-#define LINK_SYNC          ((ushort) 5)    /* Syncing */
+#define	LINK_DISCONNECTED  ((ushort) 0)	/* Disconnected */
+#define LINK_BOOT1         ((ushort) 1)	/* Trying to send 1st stage boot */
+#define LINK_BOOT2         ((ushort) 2)	/* Trying to send 2nd stage boot */
+#define LINK_BOOT2WAIT     ((ushort) 3)	/* Waiting for selftest results */
+#define LINK_BOOT3         ((ushort) 4)	/* Trying to send 3rd stage boots */
+#define LINK_SYNC          ((ushort) 5)	/* Syncing */
 
-#define LINK_INTRO         ((ushort) 10)    /* Introductory packet */
-#define LINK_SUPPLYID      ((ushort) 11)    /* Trying to supply an ID */
-#define LINK_TOPOLOGY      ((ushort) 12)    /* Send a topology update */
-#define LINK_REQUESTID     ((ushort) 13)    /* Waiting for an ID */
-#define LINK_CONNECTED     ((ushort) 14)    /* Connected */
+#define LINK_INTRO         ((ushort) 10)	/* Introductory packet */
+#define LINK_SUPPLYID      ((ushort) 11)	/* Trying to supply an ID */
+#define LINK_TOPOLOGY      ((ushort) 12)	/* Send a topology update */
+#define LINK_REQUESTID     ((ushort) 13)	/* Waiting for an ID */
+#define LINK_CONNECTED     ((ushort) 14)	/* Connected */
 
-#define LINK_INTERCONNECT  ((ushort) 20)   /* Subnets interconnected */
+#define LINK_INTERCONNECT  ((ushort) 20)	/* Subnets interconnected */
 
 #define LINK_SPARE	   ((ushort) 40)
 
@@ -103,12 +103,12 @@
 ** LED stuff
 */
 #if defined(RTA)
-#define LED_OFF            ((ushort) 0)    /* LED off */
-#define LED_RED            ((ushort) 1)    /* LED Red */
-#define LED_GREEN          ((ushort) 2)    /* LED Green */
-#define LED_ORANGE         ((ushort) 4)    /* LED Orange */
-#define LED_1TO8_OPEN      ((ushort) 1)    /* Port 1->8 LED on */
-#define LED_9TO16_OPEN     ((ushort) 2)    /* Port 9->16 LED on */
+#define LED_OFF            ((ushort) 0)	/* LED off */
+#define LED_RED            ((ushort) 1)	/* LED Red */
+#define LED_GREEN          ((ushort) 2)	/* LED Green */
+#define LED_ORANGE         ((ushort) 4)	/* LED Orange */
+#define LED_1TO8_OPEN      ((ushort) 1)	/* Port 1->8 LED on */
+#define LED_9TO16_OPEN     ((ushort) 2)	/* Port 9->16 LED on */
 #define LED_SET_COLOUR(colour)	(link->led = (colour))
 #define LED_OR_COLOUR(colour)	(link->led |= (colour))
 #define LED_TIMEOUT(time)    (link->led_timeout = RioTimePlus(RioTime(),(time)))
@@ -116,72 +116,72 @@
 #define LED_SET_COLOUR(colour)
 #define LED_OR_COLOUR(colour)
 #define LED_TIMEOUT(time)
-#endif /* RTA */
+#endif				/* RTA */
 
 struct LPB {
-               WORD          link_number ;       /* Link Number */
-               Channel_ptr   in_ch ;             /* Link In Channel */
-               Channel_ptr   out_ch ;            /* Link Out Channel */
+	WORD link_number;	/* Link Number */
+	Channel_ptr in_ch;	/* Link In Channel */
+	Channel_ptr out_ch;	/* Link Out Channel */
 #ifdef RTA
-               uchar        stat_led ;          /* Port open leds */
-               uchar        led ;               /* True, light led! */
+	uchar stat_led;		/* Port open leds */
+	uchar led;		/* True, light led! */
 #endif
-               BYTE attached_serial[4]; /* Attached serial number */
-               BYTE attached_host_serial[4];
-                                                 /* Serial number of Host who
-                                                    booted the other end */
-               WORD          descheduled ;       /* Currently Descheduled */
-               WORD          state;              /* Current state */
-               WORD          send_poll ;         /* Send a Poll Packet */
-               Process_ptr   ltt_p ;             /* Process Descriptor */
-               Process_ptr   lrt_p ;             /* Process Descriptor */
-               WORD          lrt_status ;        /* Current lrt status */
-               WORD          ltt_status ;        /* Current ltt status */
-               WORD          timeout ;           /* Timeout value */
-               WORD          topology;           /* Topology bits */
-               WORD          mon_ltt ;
-               WORD          mon_lrt ;
-               WORD          WaitNoBoot ;	 /* Secs to hold off booting */
-               PKT_ptr       add_packet_list;    /* Add packets to here */
-               PKT_ptr       remove_packet_list; /* Send packets from here */
+	BYTE attached_serial[4];	/* Attached serial number */
+	BYTE attached_host_serial[4];
+	/* Serial number of Host who
+	   booted the other end */
+	WORD descheduled;	/* Currently Descheduled */
+	WORD state;		/* Current state */
+	WORD send_poll;		/* Send a Poll Packet */
+	Process_ptr ltt_p;	/* Process Descriptor */
+	Process_ptr lrt_p;	/* Process Descriptor */
+	WORD lrt_status;	/* Current lrt status */
+	WORD ltt_status;	/* Current ltt status */
+	WORD timeout;		/* Timeout value */
+	WORD topology;		/* Topology bits */
+	WORD mon_ltt;
+	WORD mon_lrt;
+	WORD WaitNoBoot;	/* Secs to hold off booting */
+	PKT_ptr add_packet_list;	/* Add packets to here */
+	PKT_ptr remove_packet_list;	/* Send packets from here */
 #ifdef RTA
 #ifdef DCIRRUS
-#define    QBUFS_PER_REDIRECT (4 / PKTS_PER_BUFFER + 1) 
+#define    QBUFS_PER_REDIRECT (4 / PKTS_PER_BUFFER + 1)
 #else
-#define    QBUFS_PER_REDIRECT (8 / PKTS_PER_BUFFER + 1) 
+#define    QBUFS_PER_REDIRECT (8 / PKTS_PER_BUFFER + 1)
 #endif
-               PKT_ptr_ptr   rd_add ;            /* Add a new Packet here */
-               Q_BUF_ptr     rd_add_qb;          /* Pointer to the add Q buf */
-               PKT_ptr_ptr   rd_add_st_qbb ;     /* Pointer to start of the Q's buf */
-               PKT_ptr_ptr   rd_add_end_qbb ;    /* Pointer to the end of the Q's buf */
-               PKT_ptr_ptr   rd_remove ;         /* Remove a Packet here */
-               Q_BUF_ptr     rd_remove_qb ;      /* Pointer to the remove Q buf */
-               PKT_ptr_ptr   rd_remove_st_qbb ;  /* Pointer to the start of the Q buf */
-               PKT_ptr_ptr   rd_remove_end_qbb ; /* Pointer to the end of the Q buf */
-               ushort        pkts_in_q ;         /* Packets in queue */
+	PKT_ptr_ptr rd_add;	/* Add a new Packet here */
+	Q_BUF_ptr rd_add_qb;	/* Pointer to the add Q buf */
+	PKT_ptr_ptr rd_add_st_qbb;	/* Pointer to start of the Q's buf */
+	PKT_ptr_ptr rd_add_end_qbb;	/* Pointer to the end of the Q's buf */
+	PKT_ptr_ptr rd_remove;	/* Remove a Packet here */
+	Q_BUF_ptr rd_remove_qb;	/* Pointer to the remove Q buf */
+	PKT_ptr_ptr rd_remove_st_qbb;	/* Pointer to the start of the Q buf */
+	PKT_ptr_ptr rd_remove_end_qbb;	/* Pointer to the end of the Q buf */
+	ushort pkts_in_q;	/* Packets in queue */
 #endif
 
-               Channel_ptr   lrt_fail_chan ;     /* Lrt's failure channel */
-               Channel_ptr   ltt_fail_chan ;     /* Ltt's failure channel */
+	Channel_ptr lrt_fail_chan;	/* Lrt's failure channel */
+	Channel_ptr ltt_fail_chan;	/* Ltt's failure channel */
 
 #if defined (HOST) || defined (INKERNEL)
- /* RUP structure for HOST to driver communications */
-               struct RUP           rup ;              
+	/* RUP structure for HOST to driver communications */
+	struct RUP rup;
 #endif
-               struct RUP           link_rup;           /* RUP for the link (POLL,
-                                                    topology etc.) */
-               WORD          attached_link ;     /* Number of attached link */
-               WORD          csum_errors ;       /* csum errors */
-               WORD          num_disconnects ;   /* number of disconnects */
-               WORD          num_sync_rcvd ;     /* # sync's received */
-               WORD          num_sync_rqst ;     /* # sync requests */
-               WORD          num_tx ;            /* Num pkts sent */
-               WORD          num_rx ;            /* Num pkts received */
-               WORD          module_attached;    /* Module tpyes of attached */
-               WORD          led_timeout;        /* LED timeout */
-               WORD          first_port;         /* First port to service */
-               WORD          last_port;          /* Last port to service */
-           } ;
+	struct RUP link_rup;	/* RUP for the link (POLL,
+				   topology etc.) */
+	WORD attached_link;	/* Number of attached link */
+	WORD csum_errors;	/* csum errors */
+	WORD num_disconnects;	/* number of disconnects */
+	WORD num_sync_rcvd;	/* # sync's received */
+	WORD num_sync_rqst;	/* # sync requests */
+	WORD num_tx;		/* Num pkts sent */
+	WORD num_rx;		/* Num pkts received */
+	WORD module_attached;	/* Module tpyes of attached */
+	WORD led_timeout;	/* LED timeout */
+	WORD first_port;	/* First port to service */
+	WORD last_port;		/* Last port to service */
+};
 
 #endif
 
diff --git a/drivers/char/rio/linux_compat.h b/drivers/char/rio/linux_compat.h
index d53843a..17a14c4 100644
--- a/drivers/char/rio/linux_compat.h
+++ b/drivers/char/rio/linux_compat.h
@@ -41,7 +41,7 @@
 #endif
 
 struct ttystatics {
-  struct termios tm;
+	struct termios tm;
 };
 
 #define bzero(d, n)         memset((d), 0, (n))
@@ -97,26 +97,24 @@
 the definitions from Linux, and is incompatible... */
 
 /* RxBaud and TxBaud definitions... */
-#define	RIO_B0			0x00			/* RTS / DTR signals dropped */
-#define	RIO_B50			0x01			/* 50 baud */
-#define	RIO_B75			0x02			/* 75 baud */
-#define	RIO_B110		0x03			/* 110 baud */
-#define	RIO_B134		0x04			/* 134.5 baud */
-#define	RIO_B150		0x05			/* 150 baud */
-#define	RIO_B200		0x06			/* 200 baud */
-#define	RIO_B300		0x07			/* 300 baud */
-#define	RIO_B600		0x08			/* 600 baud */
-#define	RIO_B1200		0x09			/* 1200 baud */
-#define	RIO_B1800		0x0A			/* 1800 baud */
-#define	RIO_B2400		0x0B			/* 2400 baud */
-#define	RIO_B4800		0x0C			/* 4800 baud */
-#define	RIO_B9600		0x0D			/* 9600 baud */
-#define	RIO_B19200		0x0E			/* 19200 baud */
-#define	RIO_B38400		0x0F			/* 38400 baud */
-#define	RIO_B56000		0x10			/* 56000 baud */
-#define	RIO_B57600		0x11			/* 57600 baud */
-#define	RIO_B64000		0x12			/* 64000 baud */
-#define	RIO_B115200		0x13			/* 115200 baud */
-#define	RIO_B2000		0x14			/* 2000 baud */
-
-
+#define	RIO_B0			0x00	/* RTS / DTR signals dropped */
+#define	RIO_B50			0x01	/* 50 baud */
+#define	RIO_B75			0x02	/* 75 baud */
+#define	RIO_B110		0x03	/* 110 baud */
+#define	RIO_B134		0x04	/* 134.5 baud */
+#define	RIO_B150		0x05	/* 150 baud */
+#define	RIO_B200		0x06	/* 200 baud */
+#define	RIO_B300		0x07	/* 300 baud */
+#define	RIO_B600		0x08	/* 600 baud */
+#define	RIO_B1200		0x09	/* 1200 baud */
+#define	RIO_B1800		0x0A	/* 1800 baud */
+#define	RIO_B2400		0x0B	/* 2400 baud */
+#define	RIO_B4800		0x0C	/* 4800 baud */
+#define	RIO_B9600		0x0D	/* 9600 baud */
+#define	RIO_B19200		0x0E	/* 19200 baud */
+#define	RIO_B38400		0x0F	/* 38400 baud */
+#define	RIO_B56000		0x10	/* 56000 baud */
+#define	RIO_B57600		0x11	/* 57600 baud */
+#define	RIO_B64000		0x12	/* 64000 baud */
+#define	RIO_B115200		0x13	/* 115200 baud */
+#define	RIO_B2000		0x14	/* 2000 baud */
diff --git a/drivers/char/rio/list.h b/drivers/char/rio/list.h
index a4f7f1f..36aad4c 100644
--- a/drivers/char/rio/list.h
+++ b/drivers/char/rio/list.h
@@ -38,7 +38,7 @@
 
 #ifdef SCCS_LABELS
 #ifndef lint
-static char *_rio_list_h_sccs = "@(#)list.h	1.9" ;
+static char *_rio_list_h_sccs = "@(#)list.h	1.9";
 #endif
 #endif
 
@@ -166,7 +166,7 @@
 #endif
 
 
-#else /* !IN_KERNEL */
+#else				/* !IN_KERNEL */
 
 #define ZERO_PTR NULL
 
@@ -192,5 +192,5 @@
 #define splx(oldspl)    if ((oldspl) == 0) spl0()
 #endif
 
-#endif /* ifndef _list.h */
+#endif				/* ifndef _list.h */
 /*********** end of file ***********/
diff --git a/drivers/char/rio/lrt.h b/drivers/char/rio/lrt.h
index bbac8fa..b41764d 100644
--- a/drivers/char/rio/lrt.h
+++ b/drivers/char/rio/lrt.h
@@ -36,7 +36,7 @@
 
 #ifndef lint
 #ifdef SCCS_LABELS
-static char *_rio_lrt_h_sccs = "@(#)lrt.h	1.1" ;
+static char *_rio_lrt_h_sccs = "@(#)lrt.h	1.1";
 #endif
 #endif
 
@@ -50,6 +50,3 @@
 
 
 /*********** end of file ***********/
-
-
-
diff --git a/drivers/char/rio/ltt.h b/drivers/char/rio/ltt.h
index f27dcec..ab04004 100644
--- a/drivers/char/rio/ltt.h
+++ b/drivers/char/rio/ltt.h
@@ -36,7 +36,7 @@
 
 #ifndef lint
 #ifdef SCCS_LABELS
-static char *_rio_ltt_h_sccs = "@(#)ltt.h	1.1" ;
+static char *_rio_ltt_h_sccs = "@(#)ltt.h	1.1";
 #endif
 #endif
 
@@ -45,11 +45,8 @@
 #else
 #define LTT_STACK       (ushort) 200
 #endif
- 
+
 
 
 
 /*********** end of file ***********/
-
-
-
diff --git a/drivers/char/rio/lttwake.h b/drivers/char/rio/lttwake.h
index fe17d0e..fdf0c1f 100644
--- a/drivers/char/rio/lttwake.h
+++ b/drivers/char/rio/lttwake.h
@@ -39,7 +39,7 @@
 
 #ifndef lint
 #ifdef SCCS_LABELS
-static char *_rio_lttwake_h_sccs = "@(#)lttwake.h	1.1" ;
+static char *_rio_lttwake_h_sccs = "@(#)lttwake.h	1.1";
 #endif
 #endif
 
@@ -48,6 +48,3 @@
 
 
 /*********** end of file ***********/
-
-
-
diff --git a/drivers/char/rio/map.h b/drivers/char/rio/map.h
index 400645a1..97fe287 100644
--- a/drivers/char/rio/map.h
+++ b/drivers/char/rio/map.h
@@ -46,21 +46,20 @@
 #define	TOTAL_MAP_ENTRIES (MAX_MAP_ENTRY*RIO_SLOTS)
 #define	MAX_NAME_LEN 32
 
-struct Map
-{
-	uint	HostUniqueNum;	        /* Supporting hosts unique number */
-	uint	RtaUniqueNum;	        /* Unique number */
+struct Map {
+	uint HostUniqueNum;	/* Supporting hosts unique number */
+	uint RtaUniqueNum;	/* Unique number */
 	/*
-	** The next two IDs must be swapped on big-endian architectures
-	** when using a v2.04 /etc/rio/config with a v3.00 driver (when
-	** upgrading for example).
-	*/
-	ushort	ID;			/* ID used in the subnet */
-	ushort	ID2;			/* ID of 2nd block of 8 for 16 port */
-	ulong	Flags;			/* Booted, ID Given, Disconnected */
-	ulong	SysPort;		/* First tty mapped to this port */
-	struct Top   Topology[LINKS_PER_UNIT];	/* ID connected to each link */
-	char	Name[MAX_NAME_LEN];        /* Cute name by which RTA is known */
+	 ** The next two IDs must be swapped on big-endian architectures
+	 ** when using a v2.04 /etc/rio/config with a v3.00 driver (when
+	 ** upgrading for example).
+	 */
+	ushort ID;		/* ID used in the subnet */
+	ushort ID2;		/* ID of 2nd block of 8 for 16 port */
+	ulong Flags;		/* Booted, ID Given, Disconnected */
+	ulong SysPort;		/* First tty mapped to this port */
+	struct Top Topology[LINKS_PER_UNIT];	/* ID connected to each link */
+	char Name[MAX_NAME_LEN];	/* Cute name by which RTA is known */
 };
 
 /*
diff --git a/drivers/char/rio/mca.h b/drivers/char/rio/mca.h
index 08a327e..d01e76b 100644
--- a/drivers/char/rio/mca.h
+++ b/drivers/char/rio/mca.h
@@ -70,4 +70,4 @@
 
 #define	RIO_MCA_DEFAULT_MODE	SLOW_LINKS
 
-#endif	/* __rio_mca_h__ */
+#endif				/* __rio_mca_h__ */
diff --git a/drivers/char/rio/mesg.h b/drivers/char/rio/mesg.h
index 9cf6c0b..dd9be58 100644
--- a/drivers/char/rio/mesg.h
+++ b/drivers/char/rio/mesg.h
@@ -38,4 +38,4 @@
 #endif
 
 
-#endif /* __rio_mesg_h__ */
+#endif				/* __rio_mesg_h__ */
diff --git a/drivers/char/rio/param.h b/drivers/char/rio/param.h
index 2dc30b9..de7e571 100644
--- a/drivers/char/rio/param.h
+++ b/drivers/char/rio/param.h
@@ -42,20 +42,19 @@
 ** the param command block, as used in OPEN and PARAM calls.
 */
 
-struct phb_param
-{
-    BYTE    Cmd;        /* It is very important that these line up */
-    BYTE    Cor1;       /* with what is expected at the other end. */
-    BYTE    Cor2;       /* to confirm that you've got it right,    */
-    BYTE    Cor4;       /* check with cirrus/cirrus.h              */
-    BYTE    Cor5;
-    BYTE    TxXon;	/* Transmit X-On character */
-    BYTE    TxXoff;	/* Transmit X-Off character */
-    BYTE    RxXon;	/* Receive X-On character */
-    BYTE    RxXoff;	/* Receive X-Off character */
-    BYTE    LNext;	/* Literal-next character */
-    BYTE    TxBaud;	/* Transmit baudrate */
-    BYTE    RxBaud;	/* Receive baudrate */
+struct phb_param {
+	BYTE Cmd;		/* It is very important that these line up */
+	BYTE Cor1;		/* with what is expected at the other end. */
+	BYTE Cor2;		/* to confirm that you've got it right,    */
+	BYTE Cor4;		/* check with cirrus/cirrus.h              */
+	BYTE Cor5;
+	BYTE TxXon;		/* Transmit X-On character */
+	BYTE TxXoff;		/* Transmit X-Off character */
+	BYTE RxXon;		/* Receive X-On character */
+	BYTE RxXoff;		/* Receive X-Off character */
+	BYTE LNext;		/* Literal-next character */
+	BYTE TxBaud;		/* Transmit baudrate */
+	BYTE RxBaud;		/* Receive baudrate */
 };
 
 #endif
diff --git a/drivers/char/rio/parmmap.h b/drivers/char/rio/parmmap.h
index 46f99df..fe4e005 100644
--- a/drivers/char/rio/parmmap.h
+++ b/drivers/char/rio/parmmap.h
@@ -44,53 +44,50 @@
 #endif
 #endif
 
-typedef struct PARM_MAP PARM_MAP ;
+typedef struct PARM_MAP PARM_MAP;
 
-struct PARM_MAP
-{
-PHB_ptr           phb_ptr ;              /* Pointer to the PHB array */
-WORD_ptr          phb_num_ptr ;          /* Ptr to Number of PHB's */
-FREE_LIST_ptr     free_list;             /* Free List pointer */
-FREE_LIST_ptr     free_list_end;         /* Free List End pointer */
-Q_BUF_ptr_ptr     q_free_list_ptr ;      /* Ptr to Q_BUF variable */
-BYTE_ptr          unit_id_ptr ;          /* Unit Id */
-LPB_ptr           link_str_ptr ;         /* Link Structure Array */
-BYTE_ptr          bootloader_1 ;         /* 1st Stage Boot Loader */
-BYTE_ptr          bootloader_2 ;         /* 2nd Stage Boot Loader */
-WORD_ptr          port_route_map_ptr ;   /* Port Route Map */
-ROUTE_STR_ptr     route_ptr ;            /* Unit Route Map */
-NUMBER_ptr        map_present ;          /* Route Map present */
-NUMBER            pkt_num ;               /* Total number of packets */
-NUMBER            q_num ;                 /* Total number of Q packets */
-WORD              buffers_per_port ;      /* Number of buffers per port */
-WORD              heap_size ;             /* Initial size of heap */
-WORD              heap_left ;             /* Current Heap left */
-WORD              error ;                 /* Error code */
-WORD              tx_max;                 /* Max number of tx pkts per phb */
-WORD              rx_max;                 /* Max number of rx pkts per phb */
-WORD              rx_limit;               /* For high / low watermarks */
-NUMBER            links ;                 /* Links to use */
-NUMBER            timer ;                 /* Interrupts per second */
-RUP_ptr           rups ;                 /* Pointer to the RUPs */
-WORD              max_phb ;              /* Mostly for debugging */
-WORD              living ;               /* Just increments!! */
-WORD              init_done ;            /* Initialisation over */
-WORD              booting_link ;
-WORD              idle_count ;           /* Idle time counter */
-WORD              busy_count ;           /* Busy counter */
-WORD              idle_control ;         /* Control Idle Process */
+struct PARM_MAP {
+	PHB_ptr phb_ptr;	/* Pointer to the PHB array */
+	WORD_ptr phb_num_ptr;	/* Ptr to Number of PHB's */
+	FREE_LIST_ptr free_list;	/* Free List pointer */
+	FREE_LIST_ptr free_list_end;	/* Free List End pointer */
+	Q_BUF_ptr_ptr q_free_list_ptr;	/* Ptr to Q_BUF variable */
+	BYTE_ptr unit_id_ptr;	/* Unit Id */
+	LPB_ptr link_str_ptr;	/* Link Structure Array */
+	BYTE_ptr bootloader_1;	/* 1st Stage Boot Loader */
+	BYTE_ptr bootloader_2;	/* 2nd Stage Boot Loader */
+	WORD_ptr port_route_map_ptr;	/* Port Route Map */
+	ROUTE_STR_ptr route_ptr;	/* Unit Route Map */
+	NUMBER_ptr map_present;	/* Route Map present */
+	NUMBER pkt_num;		/* Total number of packets */
+	NUMBER q_num;		/* Total number of Q packets */
+	WORD buffers_per_port;	/* Number of buffers per port */
+	WORD heap_size;		/* Initial size of heap */
+	WORD heap_left;		/* Current Heap left */
+	WORD error;		/* Error code */
+	WORD tx_max;		/* Max number of tx pkts per phb */
+	WORD rx_max;		/* Max number of rx pkts per phb */
+	WORD rx_limit;		/* For high / low watermarks */
+	NUMBER links;		/* Links to use */
+	NUMBER timer;		/* Interrupts per second */
+	RUP_ptr rups;		/* Pointer to the RUPs */
+	WORD max_phb;		/* Mostly for debugging */
+	WORD living;		/* Just increments!! */
+	WORD init_done;		/* Initialisation over */
+	WORD booting_link;
+	WORD idle_count;	/* Idle time counter */
+	WORD busy_count;	/* Busy counter */
+	WORD idle_control;	/* Control Idle Process */
 #if defined(HOST) || defined(INKERNEL)
-WORD              tx_intr;               /* TX interrupt pending */
-WORD              rx_intr;               /* RX interrupt pending */
-WORD              rup_intr;              /* RUP interrupt pending */
+	WORD tx_intr;		/* TX interrupt pending */
+	WORD rx_intr;		/* RX interrupt pending */
+	WORD rup_intr;		/* RUP interrupt pending */
 #endif
 #if defined(RTA)
-WORD		  dying_count;		/* Count of processes dead */
+	WORD dying_count;	/* Count of processes dead */
 #endif
-} ;
+};
 
 #endif
 
 /*********** end of file ***********/
-
-
diff --git a/drivers/char/rio/pci.h b/drivers/char/rio/pci.h
index dc635bd..1eba911 100644
--- a/drivers/char/rio/pci.h
+++ b/drivers/char/rio/pci.h
@@ -73,4 +73,4 @@
 
 #define	RIO_PCI_DEFAULT_MODE	0x05
 
-#endif	/* __rio_pci_h__ */
+#endif				/* __rio_pci_h__ */
diff --git a/drivers/char/rio/phb.h b/drivers/char/rio/phb.h
index e1483a0..3baebf8 100644
--- a/drivers/char/rio/phb.h
+++ b/drivers/char/rio/phb.h
@@ -58,37 +58,37 @@
 /*************************************************
  * Handshake asserted. Deasserted by the LTT(s)
  ************************************************/
-#define PHB_HANDSHAKE_SET      ((ushort) 0x001) /* Set by LRT */
+#define PHB_HANDSHAKE_SET      ((ushort) 0x001)	/* Set by LRT */
 
-#define PHB_HANDSHAKE_RESET     ((ushort) 0x002) /* Set by ISR / driver */
+#define PHB_HANDSHAKE_RESET     ((ushort) 0x002)	/* Set by ISR / driver */
 
 #define PHB_HANDSHAKE_FLAGS     (PHB_HANDSHAKE_RESET | PHB_HANDSHAKE_SET)
-                                                /* Reset by ltt */
+						/* Reset by ltt */
 
 
 /*************************************************
  * Maximum number of PHB's
  ************************************************/
 #if defined (HOST) || defined (INKERNEL)
-#define MAX_PHB               ((ushort) 128)  /* range 0-127 */
+#define MAX_PHB               ((ushort) 128)	/* range 0-127 */
 #else
-#define MAX_PHB               ((ushort) 8)    /* range 0-7 */
+#define MAX_PHB               ((ushort) 8)	/* range 0-7 */
 #endif
 
 /*************************************************
  * Defines for the mode fields
  ************************************************/
-#define TXPKT_INCOMPLETE        0x0001  /* Previous tx packet not completed */
-#define TXINTR_ENABLED          0x0002  /* Tx interrupt is enabled */
-#define TX_TAB3                 0x0004  /* TAB3 mode */
-#define TX_OCRNL                0x0008  /* OCRNL mode */
-#define TX_ONLCR                0x0010  /* ONLCR mode */
-#define TX_SENDSPACES           0x0020  /* Send n spaces command needs 
-                                           completing */
-#define TX_SENDNULL             0x0040  /* Escaping NULL needs completing */
-#define TX_SENDLF               0x0080  /* LF -> CR LF needs completing */
-#define TX_PARALLELBUG          0x0100  /* CD1400 LF -> CR LF bug on parallel
-                                           port */
+#define TXPKT_INCOMPLETE        0x0001	/* Previous tx packet not completed */
+#define TXINTR_ENABLED          0x0002	/* Tx interrupt is enabled */
+#define TX_TAB3                 0x0004	/* TAB3 mode */
+#define TX_OCRNL                0x0008	/* OCRNL mode */
+#define TX_ONLCR                0x0010	/* ONLCR mode */
+#define TX_SENDSPACES           0x0020	/* Send n spaces command needs
+					   completing */
+#define TX_SENDNULL             0x0040	/* Escaping NULL needs completing */
+#define TX_SENDLF               0x0080	/* LF -> CR LF needs completing */
+#define TX_PARALLELBUG          0x0100	/* CD1400 LF -> CR LF bug on parallel
+					   port */
 #define TX_HANGOVER             (TX_SENDSPACES | TX_SENDLF | TX_SENDNULL)
 #define TX_DTRFLOW		0x0200	/* DTR tx flow control */
 #define	TX_DTRFLOWED		0x0400	/* DTR is low - don't allow more data
@@ -96,34 +96,34 @@
 #define	TX_DATAINFIFO		0x0800	/* There is data in the FIFO */
 #define	TX_BUSY			0x1000	/* Data in FIFO, shift or holding regs */
 
-#define RX_SPARE	        0x0001   /* SPARE */
-#define RXINTR_ENABLED          0x0002   /* Rx interrupt enabled */
-#define RX_ICRNL                0x0008   /* ICRNL mode */
-#define RX_INLCR                0x0010   /* INLCR mode */
-#define RX_IGNCR                0x0020   /* IGNCR mode */
-#define RX_CTSFLOW              0x0040   /* CTSFLOW enabled */
-#define RX_IXOFF                0x0080   /* IXOFF enabled */
-#define RX_CTSFLOWED            0x0100   /* CTSFLOW and CTS dropped */
-#define RX_IXOFFED              0x0200   /* IXOFF and xoff sent */
-#define RX_BUFFERED		0x0400	 /* Try and pass on complete packets */
+#define RX_SPARE	        0x0001	/* SPARE */
+#define RXINTR_ENABLED          0x0002	/* Rx interrupt enabled */
+#define RX_ICRNL                0x0008	/* ICRNL mode */
+#define RX_INLCR                0x0010	/* INLCR mode */
+#define RX_IGNCR                0x0020	/* IGNCR mode */
+#define RX_CTSFLOW              0x0040	/* CTSFLOW enabled */
+#define RX_IXOFF                0x0080	/* IXOFF enabled */
+#define RX_CTSFLOWED            0x0100	/* CTSFLOW and CTS dropped */
+#define RX_IXOFFED              0x0200	/* IXOFF and xoff sent */
+#define RX_BUFFERED		0x0400	/* Try and pass on complete packets */
 
-#define PORT_ISOPEN             0x0001  /* Port open? */
-#define PORT_HUPCL              0x0002  /* Hangup on close? */
-#define PORT_MOPENPEND          0x0004  /* Modem open pending */
-#define PORT_ISPARALLEL         0x0008  /* Parallel port */
-#define PORT_BREAK              0x0010  /* Port on break */
-#define PORT_STATUSPEND		0x0020  /* Status packet pending */
-#define PORT_BREAKPEND          0x0040  /* Break packet pending */
-#define PORT_MODEMPEND          0x0080  /* Modem status packet pending */
-#define PORT_PARALLELBUG        0x0100  /* CD1400 LF -> CR LF bug on parallel
-                                           port */
-#define PORT_FULLMODEM          0x0200  /* Full modem signals */
-#define PORT_RJ45               0x0400  /* RJ45 connector - no RI signal */
-#define PORT_RESTRICTED         0x0600  /* Restricted connector - no RI / DTR */
+#define PORT_ISOPEN             0x0001	/* Port open? */
+#define PORT_HUPCL              0x0002	/* Hangup on close? */
+#define PORT_MOPENPEND          0x0004	/* Modem open pending */
+#define PORT_ISPARALLEL         0x0008	/* Parallel port */
+#define PORT_BREAK              0x0010	/* Port on break */
+#define PORT_STATUSPEND		0x0020	/* Status packet pending */
+#define PORT_BREAKPEND          0x0040	/* Break packet pending */
+#define PORT_MODEMPEND          0x0080	/* Modem status packet pending */
+#define PORT_PARALLELBUG        0x0100	/* CD1400 LF -> CR LF bug on parallel
+					   port */
+#define PORT_FULLMODEM          0x0200	/* Full modem signals */
+#define PORT_RJ45               0x0400	/* RJ45 connector - no RI signal */
+#define PORT_RESTRICTED         0x0600	/* Restricted connector - no RI / DTR */
 
-#define PORT_MODEMBITS          0x0600  /* Mask for modem fields */
+#define PORT_MODEMBITS          0x0600	/* Mask for modem fields */
 
-#define PORT_WCLOSE             0x0800  /* Waiting for close */
+#define PORT_WCLOSE             0x0800	/* Waiting for close */
 #define	PORT_HANDSHAKEFIX	0x1000	/* Port has H/W flow control fix */
 #define	PORT_WASPCLOSED		0x2000	/* Port closed with PCLOSE */
 #define	DUMPMODE		0x4000	/* Dump RTA mem */
@@ -155,139 +155,128 @@
 #define rx_end       u4.s1.rx_end_ptr_ptr
 #define rx_remove    u4.s1.rx_remove_ptr_ptr
 #endif
-typedef struct PHB PHB ;
+typedef struct PHB PHB;
 struct PHB {
 #ifdef RTA
-        ushort      port;
+	ushort port;
 #endif
 #ifdef INKERNEL
-        WORD      source;
+	WORD source;
 #else
-        union       
-        {
-            ushort source;              /* Complete source */
-            struct
-            {
-                unsigned char unit;     /* Source unit */
-                unsigned char port;     /* Source port */
-            } s2;
-        } u2;
+	union {
+		ushort source;	/* Complete source */
+		struct {
+			unsigned char unit;	/* Source unit */
+			unsigned char port;	/* Source port */
+		} s2;
+	} u2;
 #endif
-        WORD      handshake ;
-        WORD      status ;
-        NUMBER       timeout ;           /* Maximum of 1.9 seconds */
-        WORD      link ;              /* Send down this link */
+	WORD handshake;
+	WORD status;
+	NUMBER timeout;		/* Maximum of 1.9 seconds */
+	WORD link;		/* Send down this link */
 #ifdef INKERNEL
-        WORD      destination;
+	WORD destination;
 #else
-        union       
-        {
-            ushort destination;         /* Complete destination */
-            struct
-            {
-                unsigned char unit;     /* Destination unit */
-                unsigned char port;     /* Destination port */
-            } s1;
-        } u1;
+	union {
+		ushort destination;	/* Complete destination */
+		struct {
+			unsigned char unit;	/* Destination unit */
+			unsigned char port;	/* Destination port */
+		} s1;
+	} u1;
 #endif
 #ifdef RTA
-        ushort      tx_pkts_added;
-        ushort      tx_pkts_removed;
-        Q_BUF_ptr   tx_q_start ;        /* Start of the Q list chain */
-        short       num_tx_q_bufs ;     /* Number of Q buffers in the chain */
-        PKT_ptr_ptr tx_add ;            /* Add a new Packet here */
-        Q_BUF_ptr   tx_add_qb;          /* Pointer to the add Q buf */
-        PKT_ptr_ptr tx_add_st_qbb ;     /* Pointer to start of the Q's buf */
-        PKT_ptr_ptr tx_add_end_qbb ;    /* Pointer to the end of the Q's buf */
-        PKT_ptr_ptr tx_remove ;         /* Remove a Packet here */
-        Q_BUF_ptr   tx_remove_qb ;      /* Pointer to the remove Q buf */
-        PKT_ptr_ptr tx_remove_st_qbb ;  /* Pointer to the start of the Q buf */
-        PKT_ptr_ptr tx_remove_end_qbb ; /* Pointer to the end of the Q buf */
+	ushort tx_pkts_added;
+	ushort tx_pkts_removed;
+	Q_BUF_ptr tx_q_start;	/* Start of the Q list chain */
+	short num_tx_q_bufs;	/* Number of Q buffers in the chain */
+	PKT_ptr_ptr tx_add;	/* Add a new Packet here */
+	Q_BUF_ptr tx_add_qb;	/* Pointer to the add Q buf */
+	PKT_ptr_ptr tx_add_st_qbb;	/* Pointer to start of the Q's buf */
+	PKT_ptr_ptr tx_add_end_qbb;	/* Pointer to the end of the Q's buf */
+	PKT_ptr_ptr tx_remove;	/* Remove a Packet here */
+	Q_BUF_ptr tx_remove_qb;	/* Pointer to the remove Q buf */
+	PKT_ptr_ptr tx_remove_st_qbb;	/* Pointer to the start of the Q buf */
+	PKT_ptr_ptr tx_remove_end_qbb;	/* Pointer to the end of the Q buf */
 #endif
 #ifdef INKERNEL
-        PKT_ptr_ptr tx_start ;
-        PKT_ptr_ptr tx_end ;
-        PKT_ptr_ptr tx_add ;
-        PKT_ptr_ptr tx_remove ;
+	PKT_ptr_ptr tx_start;
+	PKT_ptr_ptr tx_end;
+	PKT_ptr_ptr tx_add;
+	PKT_ptr_ptr tx_remove;
 #endif
 #ifdef HOST
-        union
-        {
-            struct
-            {
-                PKT_ptr_ptr tx_start_ptr_ptr;
-                PKT_ptr_ptr tx_end_ptr_ptr;
-                PKT_ptr_ptr tx_add_ptr_ptr;
-                PKT_ptr_ptr tx_remove_ptr_ptr;
-            } s1;
-            struct
-            {
-                ushort * tx_start_ptr;
-                ushort * tx_end_ptr;
-                ushort * tx_add_ptr;
-                ushort * tx_remove_ptr;
-            } s2;
-        } u3;
+	union {
+		struct {
+			PKT_ptr_ptr tx_start_ptr_ptr;
+			PKT_ptr_ptr tx_end_ptr_ptr;
+			PKT_ptr_ptr tx_add_ptr_ptr;
+			PKT_ptr_ptr tx_remove_ptr_ptr;
+		} s1;
+		struct {
+			ushort *tx_start_ptr;
+			ushort *tx_end_ptr;
+			ushort *tx_add_ptr;
+			ushort *tx_remove_ptr;
+		} s2;
+	} u3;
 #endif
 
 #ifdef  RTA
-        ushort      rx_pkts_added;
-        ushort      rx_pkts_removed;
-        Q_BUF_ptr   rx_q_start ;        /* Start of the Q list chain */
-        short       num_rx_q_bufs ;     /* Number of Q buffers in the chain */
-        PKT_ptr_ptr rx_add ;            /* Add a new Packet here */
-        Q_BUF_ptr   rx_add_qb ;         /* Pointer to the add Q buf */
-        PKT_ptr_ptr rx_add_st_qbb ;     /* Pointer to start of the Q's buf */
-        PKT_ptr_ptr rx_add_end_qbb ;    /* Pointer to the end of the Q's buf */
-        PKT_ptr_ptr rx_remove ;         /* Remove a Packet here */
-        Q_BUF_ptr   rx_remove_qb ;      /* Pointer to the remove Q buf */
-        PKT_ptr_ptr rx_remove_st_qbb ;  /* Pointer to the start of the Q buf */
-        PKT_ptr_ptr rx_remove_end_qbb ; /* Pointer to the end of the Q buf */
+	ushort rx_pkts_added;
+	ushort rx_pkts_removed;
+	Q_BUF_ptr rx_q_start;	/* Start of the Q list chain */
+	short num_rx_q_bufs;	/* Number of Q buffers in the chain */
+	PKT_ptr_ptr rx_add;	/* Add a new Packet here */
+	Q_BUF_ptr rx_add_qb;	/* Pointer to the add Q buf */
+	PKT_ptr_ptr rx_add_st_qbb;	/* Pointer to start of the Q's buf */
+	PKT_ptr_ptr rx_add_end_qbb;	/* Pointer to the end of the Q's buf */
+	PKT_ptr_ptr rx_remove;	/* Remove a Packet here */
+	Q_BUF_ptr rx_remove_qb;	/* Pointer to the remove Q buf */
+	PKT_ptr_ptr rx_remove_st_qbb;	/* Pointer to the start of the Q buf */
+	PKT_ptr_ptr rx_remove_end_qbb;	/* Pointer to the end of the Q buf */
 #endif
 #ifdef INKERNEL
-        PKT_ptr_ptr rx_start ;
-        PKT_ptr_ptr rx_end ;
-        PKT_ptr_ptr rx_add ;
-        PKT_ptr_ptr rx_remove ;
+	PKT_ptr_ptr rx_start;
+	PKT_ptr_ptr rx_end;
+	PKT_ptr_ptr rx_add;
+	PKT_ptr_ptr rx_remove;
 #endif
 #ifdef HOST
-        union
-        {
-            struct
-            {
-                PKT_ptr_ptr rx_start_ptr_ptr;
-                PKT_ptr_ptr rx_end_ptr_ptr;
-                PKT_ptr_ptr rx_add_ptr_ptr;
-                PKT_ptr_ptr rx_remove_ptr_ptr;
-            } s1;
-            struct
-            {
-                ushort * rx_start_ptr;
-                ushort * rx_end_ptr;
-                ushort * rx_add_ptr;
-                ushort * rx_remove_ptr;
-            } s2;
-        } u4;
+	union {
+		struct {
+			PKT_ptr_ptr rx_start_ptr_ptr;
+			PKT_ptr_ptr rx_end_ptr_ptr;
+			PKT_ptr_ptr rx_add_ptr_ptr;
+			PKT_ptr_ptr rx_remove_ptr_ptr;
+		} s1;
+		struct {
+			ushort *rx_start_ptr;
+			ushort *rx_end_ptr;
+			ushort *rx_add_ptr;
+			ushort *rx_remove_ptr;
+		} s2;
+	} u4;
 #endif
 
-#ifdef RTA                              /* some fields for the remotes */
-        ushort     flush_count;		/* Count of write flushes */
-        ushort     txmode;		/* Modes for tx */
-        ushort     rxmode;		/* Modes for rx */
-        ushort     portmode;		/* Generic modes */
-        ushort     column;		/* TAB3 column count */
-        ushort     tx_subscript;	/* (TX) Subscript into data field */
-        ushort     rx_subscript;	/* (RX) Subscript into data field */
-        PKT_ptr    rx_incomplete;	/* Hold an incomplete packet here */
-        ushort     modem_bits;		/* Modem bits to mask */
-	ushort	   lastModem;		/* Modem control lines. */
-        ushort     addr;		/* Address for sub commands */
-        ushort     MonitorTstate;	/* TRUE if monitoring tstop */
+#ifdef RTA			/* some fields for the remotes */
+	ushort flush_count;	/* Count of write flushes */
+	ushort txmode;		/* Modes for tx */
+	ushort rxmode;		/* Modes for rx */
+	ushort portmode;	/* Generic modes */
+	ushort column;		/* TAB3 column count */
+	ushort tx_subscript;	/* (TX) Subscript into data field */
+	ushort rx_subscript;	/* (RX) Subscript into data field */
+	PKT_ptr rx_incomplete;	/* Hold an incomplete packet here */
+	ushort modem_bits;	/* Modem bits to mask */
+	ushort lastModem;	/* Modem control lines. */
+	ushort addr;		/* Address for sub commands */
+	ushort MonitorTstate;	/* TRUE if monitoring tstop */
 #endif
 
-        } ;
+};
 
 #endif
 
 /*********** end of file ***********/
-
diff --git a/drivers/char/rio/pkt.h b/drivers/char/rio/pkt.h
index 66bb2ff..882fd42 100644
--- a/drivers/char/rio/pkt.h
+++ b/drivers/char/rio/pkt.h
@@ -69,52 +69,44 @@
 #define CONTROL_PKT_TTL_MASK (PKT_TTL_MASK << 8)
 #define CONTROL_DATA_WNDW  (DATA_WNDW << 8)
 
-struct PKT    {
+struct PKT {
 #ifdef INKERNEL
-                   BYTE    dest_unit ;    /* Destination Unit Id */
-                   BYTE    dest_port ;    /* Destination POrt */
-                   BYTE    src_unit ;     /* Source Unit Id */
-                   BYTE    src_port ;     /* Source POrt */
+	BYTE dest_unit;		/* Destination Unit Id */
+	BYTE dest_port;		/* Destination POrt */
+	BYTE src_unit;		/* Source Unit Id */
+	BYTE src_port;		/* Source POrt */
 #else
-                   union       
-                   {
-                       ushort destination;         /* Complete destination */
-                       struct
-                       {
-                           unsigned char unit;     /* Destination unit */
-                           unsigned char port;     /* Destination port */
-                       } s1;
-                   } u1;
-                   union       
-                   {
-                       ushort source;              /* Complete source */
-                       struct
-                       {
-                           unsigned char unit;     /* Source unit */
-                           unsigned char port;     /* Source port */
-                       } s2;
-                   } u2;
+	union {
+		ushort destination;	/* Complete destination */
+		struct {
+			unsigned char unit;	/* Destination unit */
+			unsigned char port;	/* Destination port */
+		} s1;
+	} u1;
+	union {
+		ushort source;	/* Complete source */
+		struct {
+			unsigned char unit;	/* Source unit */
+			unsigned char port;	/* Source port */
+		} s2;
+	} u2;
 #endif
 #ifdef INKERNEL
-                   BYTE len ;
-                   BYTE control;
+	BYTE len;
+	BYTE control;
 #else
-                   union
-                   {
-                        ushort      control;
-                        struct
-                        {
-                            unsigned char len;
-                            unsigned char control;
-                        } s3;
-                    } u3;
+	union {
+		ushort control;
+		struct {
+			unsigned char len;
+			unsigned char control;
+		} s3;
+	} u3;
 #endif
-                   BYTE    data[PKT_MAX_DATA_LEN] ;     
-                                                   /* Actual data :-) */
-                   WORD  csum ;                  /* C-SUM */
-               } ;
+	BYTE data[PKT_MAX_DATA_LEN];
+	/* Actual data :-) */
+	WORD csum;		/* C-SUM */
+};
 #endif
 
 /*********** end of file ***********/
-
-
diff --git a/drivers/char/rio/poll.h b/drivers/char/rio/poll.h
index d9b8e98..9616ee4 100644
--- a/drivers/char/rio/poll.h
+++ b/drivers/char/rio/poll.h
@@ -39,7 +39,7 @@
 
 #ifndef lint
 #ifdef SCCS_LABELS
-static char *_rio_poll_h_sccs = "@(#)poll.h	1.2" ;
+static char *_rio_poll_h_sccs = "@(#)poll.h	1.2";
 #endif
 #endif
 
@@ -54,23 +54,20 @@
 #define POLL_PERIOD           (int) SECOND
 
 /* The various poll commands */
-#define POLL_POLL             0            /* We are connected and happy.. */
-#define POLL_INTRO            1            /* Introduction packet */
-#define POLL_TOPOLOGY         2            /* Topology update */
-#define POLL_ASSIGN           3            /* ID assign */
-#define POLL_FOAD             4            /* F*** Off And Die */
-#define POLL_LMD	      5		   /* Let Me Die */
-#define POLL_DYB	      6		   /* Die You Ba***** */
+#define POLL_POLL             0	/* We are connected and happy.. */
+#define POLL_INTRO            1	/* Introduction packet */
+#define POLL_TOPOLOGY         2	/* Topology update */
+#define POLL_ASSIGN           3	/* ID assign */
+#define POLL_FOAD             4	/* F*** Off And Die */
+#define POLL_LMD	      5	/* Let Me Die */
+#define POLL_DYB	      6	/* Die You Ba***** */
 
 /* The way data fields are split up for POLL packets */
-#define POLL_HOST_SERIAL      2            /* Host who booted me */
-#define POLL_MY_SERIAL        6            /* My serial number */
-#define POLL_YOUR_ID          1            /* Your ID number */
-#define POLL_TOPOLOGY_FIELDS  2            /* Topology maps */
+#define POLL_HOST_SERIAL      2	/* Host who booted me */
+#define POLL_MY_SERIAL        6	/* My serial number */
+#define POLL_YOUR_ID          1	/* Your ID number */
+#define POLL_TOPOLOGY_FIELDS  2	/* Topology maps */
 
 #endif
 
 /*********** end of file ***********/
-
-
-
diff --git a/drivers/char/rio/port.h b/drivers/char/rio/port.h
index 8506af0..c99b1e7 100644
--- a/drivers/char/rio/port.h
+++ b/drivers/char/rio/port.h
@@ -46,96 +46,94 @@
 */
 
 #ifdef STATS
-struct RIOStats
-{
+struct RIOStats {
 	/*
-	** interrupt statistics
-	*/
-	uint	BreakIntCnt;
-	uint	ModemOffCnt;
-	uint	ModemOnCnt;
-	uint	RxIntCnt;
-	uint	TxIntCnt;
+	 ** interrupt statistics
+	 */
+	uint BreakIntCnt;
+	uint ModemOffCnt;
+	uint ModemOnCnt;
+	uint RxIntCnt;
+	uint TxIntCnt;
 	/*
-	** throughput statistics
-	*/
-	uint	RxCharCnt;
-	uint	RxPktCnt;
-	uint	RxSaveCnt;
-	uint	TxCharCnt;
-	uint	TxPktCnt;
+	 ** throughput statistics
+	 */
+	uint RxCharCnt;
+	uint RxPktCnt;
+	uint RxSaveCnt;
+	uint TxCharCnt;
+	uint TxPktCnt;
 	/*
-	** driver entry statistics
-	*/
-	uint	CloseCnt;
-	uint	IoctlCnt;
-	uint	OpenCnt;
-	uint	ReadCnt;
-	uint	WriteCnt;
+	 ** driver entry statistics
+	 */
+	uint CloseCnt;
+	uint IoctlCnt;
+	uint OpenCnt;
+	uint ReadCnt;
+	uint WriteCnt;
 	/*
-	** proc statistics
-	*/
-	uint	BlockCnt;
-	uint	OutputCnt;
-	uint	ResumeCnt;
-	uint	RflushCnt;
-	uint	SuspendCnt;
-	uint	TbreakCnt;
-	uint	TimeoutCnt;
-	uint	UnblockCnt;
-	uint	WflushCnt;
-	uint	WFBodgeCnt;
+	 ** proc statistics
+	 */
+	uint BlockCnt;
+	uint OutputCnt;
+	uint ResumeCnt;
+	uint RflushCnt;
+	uint SuspendCnt;
+	uint TbreakCnt;
+	uint TimeoutCnt;
+	uint UnblockCnt;
+	uint WflushCnt;
+	uint WFBodgeCnt;
 };
 #endif
 
 /*
 **	Port data structure
 */
-struct	Port
-{
-  struct gs_port gs; 
-  int				PortNum;	/* RIO port no., 0-511 */
-  struct Host	*HostP;
-  volatile caddr_t		Caddr;
-  ushort			HostPort;  /* Port number on host card */
-  uchar			RupNum;	/* Number of RUP for port */
-  uchar			ID2;	/* Second ID of RTA for port */
-  ulong			State;	/* FLAGS for open & xopen */
-#define	RIO_LOPEN	0x00001		/* Local open */
-#define	RIO_MOPEN	0x00002		/* Modem open */
-#define	RIO_WOPEN	0x00004		/* Waiting for open */
-#define	RIO_CLOSING	0x00008		/* The port is being close */
-#define	RIO_XPBUSY	0x00010		/* Transparent printer busy */
-#define	RIO_BREAKING	0x00020		/* Break in progress */
-#define	RIO_DIRECT	0x00040		/* Doing Direct output */
-#define	RIO_EXCLUSIVE	0x00080		/* Stream open for exclusive use */
-#define	RIO_NDELAY	0x00100		/* Stream is open FNDELAY */
-#define	RIO_CARR_ON	0x00200		/* Stream has carrier present */
-#define	RIO_XPWANTR	0x00400		/* Stream wanted by Xprint */
-#define	RIO_RBLK	0x00800		/* Stream is read-blocked */
-#define	RIO_BUSY	0x01000		/* Stream is BUSY for write */
-#define	RIO_TIMEOUT	0x02000		/* Stream timeout in progress */
-#define	RIO_TXSTOP	0x04000		/* Stream output is stopped */
-#define	RIO_WAITFLUSH	0x08000		/* Stream waiting for flush */
-#define	RIO_DYNOROD	0x10000		/* Drain failed */
-#define	RIO_DELETED	0x20000		/* RTA has been deleted */
-#define RIO_ISSCANCODE	0x40000		/* This line is in scancode mode */
+struct Port {
+	struct gs_port gs;
+	int PortNum;		/* RIO port no., 0-511 */
+	struct Host *HostP;
+	volatile caddr_t Caddr;
+	ushort HostPort;	/* Port number on host card */
+	uchar RupNum;		/* Number of RUP for port */
+	uchar ID2;		/* Second ID of RTA for port */
+	ulong State;		/* FLAGS for open & xopen */
+#define	RIO_LOPEN	0x00001	/* Local open */
+#define	RIO_MOPEN	0x00002	/* Modem open */
+#define	RIO_WOPEN	0x00004	/* Waiting for open */
+#define	RIO_CLOSING	0x00008	/* The port is being close */
+#define	RIO_XPBUSY	0x00010	/* Transparent printer busy */
+#define	RIO_BREAKING	0x00020	/* Break in progress */
+#define	RIO_DIRECT	0x00040	/* Doing Direct output */
+#define	RIO_EXCLUSIVE	0x00080	/* Stream open for exclusive use */
+#define	RIO_NDELAY	0x00100	/* Stream is open FNDELAY */
+#define	RIO_CARR_ON	0x00200	/* Stream has carrier present */
+#define	RIO_XPWANTR	0x00400	/* Stream wanted by Xprint */
+#define	RIO_RBLK	0x00800	/* Stream is read-blocked */
+#define	RIO_BUSY	0x01000	/* Stream is BUSY for write */
+#define	RIO_TIMEOUT	0x02000	/* Stream timeout in progress */
+#define	RIO_TXSTOP	0x04000	/* Stream output is stopped */
+#define	RIO_WAITFLUSH	0x08000	/* Stream waiting for flush */
+#define	RIO_DYNOROD	0x10000	/* Drain failed */
+#define	RIO_DELETED	0x20000	/* RTA has been deleted */
+#define RIO_ISSCANCODE	0x40000	/* This line is in scancode mode */
 #define	RIO_USING_EUC	0x100000	/* Using extended Unix chars */
 #define	RIO_CAN_COOK	0x200000	/* This line can do cooking */
-#define RIO_TRIAD_MODE  0x400000        /* Enable TRIAD special ops. */
-#define RIO_TRIAD_BLOCK 0x800000        /* Next read will block */
-#define RIO_TRIAD_FUNC  0x1000000       /* Seen a function key coming in */
-#define RIO_THROTTLE_RX 0x2000000       /* RX needs to be throttled. */
+#define RIO_TRIAD_MODE  0x400000	/* Enable TRIAD special ops. */
+#define RIO_TRIAD_BLOCK 0x800000	/* Next read will block */
+#define RIO_TRIAD_FUNC  0x1000000	/* Seen a function key coming in */
+#define RIO_THROTTLE_RX 0x2000000	/* RX needs to be throttled. */
 
-    ulong			Config;	/* FLAGS for NOREAD.... */
-#define	RIO_NOREAD	0x0001		/* Are not allowed to read port */
-#define	RIO_NOWRITE	0x0002		/* Are not allowed to write port */
-#define	RIO_NOXPRINT	0x0004		/* Are not allowed to xprint port */
-#define	RIO_NOMASK	0x0007		/* All not allowed things */
-#define RIO_IXANY	0x0008          /* Port is allowed ixany */
-#define	RIO_MODEM	0x0010		/* Stream is a modem device */
-#define	RIO_IXON	0x0020		/* Port is allowed ixon */
-#define RIO_WAITDRAIN	0x0040		/* Wait for port to completely drain */
+	ulong Config;		/* FLAGS for NOREAD.... */
+#define	RIO_NOREAD	0x0001	/* Are not allowed to read port */
+#define	RIO_NOWRITE	0x0002	/* Are not allowed to write port */
+#define	RIO_NOXPRINT	0x0004	/* Are not allowed to xprint port */
+#define	RIO_NOMASK	0x0007	/* All not allowed things */
+#define RIO_IXANY	0x0008	/* Port is allowed ixany */
+#define	RIO_MODEM	0x0010	/* Stream is a modem device */
+#define	RIO_IXON	0x0020	/* Port is allowed ixon */
+#define RIO_WAITDRAIN	0x0040	/* Wait for port to completely drain */
 #define RIO_MAP_50_TO_50	0x0080	/* Map 50 baud to 50 baud */
 #define RIO_MAP_110_TO_110	0x0100	/* Map 110 baud to 110 baud */
 
@@ -144,92 +142,90 @@
 ** As LynxOS does not appear to support Hardware Flow Control .....
 ** Define our own flow control flags in 'Config'.
 */
-#define RIO_CTSFLOW	0x0200		/* RIO's own CTSFLOW flag */
-#define RIO_RTSFLOW	0x0400		/* RIO's own RTSFLOW flag */
+#define RIO_CTSFLOW	0x0200	/* RIO's own CTSFLOW flag */
+#define RIO_RTSFLOW	0x0400	/* RIO's own RTSFLOW flag */
 
 
-    struct PHB			*PhbP;	  /* pointer to PHB for port */
-    WORD                        *TxAdd;   /* Add packets here */
-    WORD                        *TxStart; /* Start of add array */
-    WORD                        *TxEnd;         /* End of add array */
-    WORD                        *RxRemove;      /* Remove packets here */
-    WORD                        *RxStart;       /* Start of remove array */
-    WORD                        *RxEnd;         /* End of remove array */
-    uint			RtaUniqueNum;	/* Unique number of RTA */
-    ushort			PortState;	/* status of port */
-    ushort			ModemState;	/* status of modem lines */
-    ulong			ModemLines;	/* Modem bits sent to RTA */
-    uchar			CookMode;	/* who expands CR/LF? */
-    uchar			ParamSem;	/* Prevent write during param */
-    uchar			Mapped;		/* if port mapped onto host */
-    uchar			SecondBlock;	/* if port belongs to 2nd block
-						   of 16 port RTA */
-    uchar			InUse;		/* how many pre-emptive cmds */
-    uchar			Lock;		/* if params locked */
-    uchar			Store;	/* if params stored across closes */
-    uchar			FirstOpen; /* TRUE if first time port opened */
-    uchar			FlushCmdBodge;	/* if doing a (non)flush */
-    uchar			MagicFlags;	/* require intr processing */
+	struct PHB *PhbP;	/* pointer to PHB for port */
+	WORD *TxAdd;		/* Add packets here */
+	WORD *TxStart;		/* Start of add array */
+	WORD *TxEnd;		/* End of add array */
+	WORD *RxRemove;		/* Remove packets here */
+	WORD *RxStart;		/* Start of remove array */
+	WORD *RxEnd;		/* End of remove array */
+	uint RtaUniqueNum;	/* Unique number of RTA */
+	ushort PortState;	/* status of port */
+	ushort ModemState;	/* status of modem lines */
+	ulong ModemLines;	/* Modem bits sent to RTA */
+	uchar CookMode;		/* who expands CR/LF? */
+	uchar ParamSem;		/* Prevent write during param */
+	uchar Mapped;		/* if port mapped onto host */
+	uchar SecondBlock;	/* if port belongs to 2nd block
+				   of 16 port RTA */
+	uchar InUse;		/* how many pre-emptive cmds */
+	uchar Lock;		/* if params locked */
+	uchar Store;		/* if params stored across closes */
+	uchar FirstOpen;	/* TRUE if first time port opened */
+	uchar FlushCmdBodge;	/* if doing a (non)flush */
+	uchar MagicFlags;	/* require intr processing */
 #define	MAGIC_FLUSH	0x01	/* mirror of WflushFlag */
 #define	MAGIC_REBOOT	0x02	/* RTA re-booted, re-open ports */
 #define	MORE_OUTPUT_EYGOR 0x04	/* riotproc failed to empty clists */
-    uchar			WflushFlag;	/* 1 How many WFLUSHs active */
+	uchar WflushFlag;	/* 1 How many WFLUSHs active */
 /*
 ** Transparent print stuff
 */
-    struct Xprint
-    {
+	struct Xprint {
 #ifndef MAX_XP_CTRL_LEN
-#define MAX_XP_CTRL_LEN		16		/* ALSO IN DAEMON.H */
+#define MAX_XP_CTRL_LEN		16	/* ALSO IN DAEMON.H */
 #endif
-	uint			XpCps;
-	char			XpOn[MAX_XP_CTRL_LEN];
-	char			XpOff[MAX_XP_CTRL_LEN];
-	ushort			XpLen;		/* strlen(XpOn)+strlen(XpOff) */
-	uchar			XpActive;
-	uchar			XpLastTickOk;	/* TRUE if we can process */
+		uint XpCps;
+		char XpOn[MAX_XP_CTRL_LEN];
+		char XpOff[MAX_XP_CTRL_LEN];
+		ushort XpLen;	/* strlen(XpOn)+strlen(XpOff) */
+		uchar XpActive;
+		uchar XpLastTickOk;	/* TRUE if we can process */
 #define	XP_OPEN		00001
 #define	XP_RUNABLE	00002
-	struct ttystatics 		*XttyP;
-    } Xprint;
+		struct ttystatics *XttyP;
+	} Xprint;
 #ifdef VPIX
-    v86_t			*StashP;
-    uint			IntMask;
-    struct termss 		VpixSs;
-    uchar			ModemStatusReg;	/* Modem status register */
+	v86_t *StashP;
+	uint IntMask;
+	struct termss VpixSs;
+	uchar ModemStatusReg;	/* Modem status register */
 #endif
-    uchar			RxDataStart;
-    uchar			Cor2Copy;	/* copy of COR2 */
-    char			*Name;		/* points to the Rta's name */
+	uchar RxDataStart;
+	uchar Cor2Copy;		/* copy of COR2 */
+	char *Name;		/* points to the Rta's name */
 #ifdef STATS
-    struct RIOStats 		Stat;		/* ports statistics */
+	struct RIOStats Stat;	/* ports statistics */
 #endif
-    char			*TxRingBuffer;
-    ushort			TxBufferIn;	/* New data arrives here */
-    ushort			TxBufferOut;	/* Intr removes data here */
-    ushort			OldTxBufferOut;	/* Indicates if draining */
-    int				TimeoutId;	/* Timeout ID */
-    uint			Debug;
-    uchar			WaitUntilBooted; /* True if open should block */
-    uint			statsGather;	/* True if gathering stats */
-    ulong			txchars;	/* Chars transmitted */
-    ulong			rxchars;	/* Chars received */
-    ulong			opens;		/* port open count */
-    ulong			closes;		/* port close count */
-    ulong			ioctls;		/* ioctl count */
-    uchar			LastRxTgl;	/* Last state of rx toggle bit */
-  spinlock_t				portSem;	/* Lock using this sem */
-	int				MonitorTstate;	/* Monitoring ? */
-	int				timeout_id;	/* For calling 100 ms delays */
-	int				timeout_sem;/* For calling 100 ms delays */
-	int				firstOpen;	/* First time open ? */
-	char *			p;			/* save the global struc here .. */
+	char *TxRingBuffer;
+	ushort TxBufferIn;	/* New data arrives here */
+	ushort TxBufferOut;	/* Intr removes data here */
+	ushort OldTxBufferOut;	/* Indicates if draining */
+	int TimeoutId;		/* Timeout ID */
+	uint Debug;
+	uchar WaitUntilBooted;	/* True if open should block */
+	uint statsGather;	/* True if gathering stats */
+	ulong txchars;		/* Chars transmitted */
+	ulong rxchars;		/* Chars received */
+	ulong opens;		/* port open count */
+	ulong closes;		/* port close count */
+	ulong ioctls;		/* ioctl count */
+	uchar LastRxTgl;	/* Last state of rx toggle bit */
+	spinlock_t portSem;	/* Lock using this sem */
+	int MonitorTstate;	/* Monitoring ? */
+	int timeout_id;		/* For calling 100 ms delays */
+	int timeout_sem;	/* For calling 100 ms delays */
+	int firstOpen;		/* First time open ? */
+	char *p;		/* save the global struc here .. */
 };
 
-struct ModuleInfo
-{
-	char	*Name;
-	uint	Flags[4];	/* one per port on a module */
+struct ModuleInfo {
+	char *Name;
+	uint Flags[4];		/* one per port on a module */
 };
 #endif
 
@@ -238,8 +234,8 @@
 ** runs into problems with differing struct sizes between driver and config.
 */
 struct PortParams {
-	uint	Port;
-	ulong	Config;
-	ulong	State;
-	struct ttystatics	*TtyP;
+	uint Port;
+	ulong Config;
+	ulong State;
+	struct ttystatics *TtyP;
 };
diff --git a/drivers/char/rio/proto.h b/drivers/char/rio/proto.h
index ddff0ef..f9a3376 100644
--- a/drivers/char/rio/proto.h
+++ b/drivers/char/rio/proto.h
@@ -23,15 +23,15 @@
 /*
 ** boot.c
 */
-void init_boot( char *p, short stage);
+void init_boot(char *p, short stage);
 
 /*
 ** disconct.c
 */
-void kill_boot ( LPB *link );
-void disconnected( LPB *link );
-short boot_3( LPB *link, PKT *pkt );
-short send_3_pkt( LPB *link, PKT *pkt);
+void kill_boot(LPB * link);
+void disconnected(LPB * link);
+short boot_3(LPB * link, PKT * pkt);
+short send_3_pkt(LPB * link, PKT * pkt);
 
 /*
 ** error.c
@@ -41,116 +41,116 @@
 /*
 ** formpkt.c
 */
-ushort sum_it( PKT *pkt ) ;
-void form_rup_pkt( RUP *form_rup, PKT *pkt );
-void form_poll_pkt ( int type, LPB *link, int node );
-void form_route_pkt ( int type, PKT *pkt, LPB *link );
+ushort sum_it(PKT * pkt);
+void form_rup_pkt(RUP * form_rup, PKT * pkt);
+void form_poll_pkt(int type, LPB * link, int node);
+void form_route_pkt(int type, PKT * pkt, LPB * link);
 
 /*
 ** idle.c
 */
-void idle( Process *idle_p );
+void idle(Process * idle_p);
 
 /*
 ** init.c
 */
 void general_init(void);
-void mem_halt( int error);
+void mem_halt(int error);
 
 /*
 ** linkinit.c
 */
-void initlink( u_short number, LPB *link);
-void runlink( LPB *link);
+void initlink(u_short number, LPB * link);
+void runlink(LPB * link);
 
 /*
 ** list.c
 */
 PKT *get_free_start(void);
-void put_free_start( PKT *pkt);
+void put_free_start(PKT * pkt);
 
 #ifdef HOST
-int can_remove_transmit ( PKT **pkt, PKT *pointer );
+int can_remove_transmit(PKT ** pkt, PKT * pointer);
 #endif
 
 #ifdef RTA
-int spl7 ( void );
-int spl0 ( void );
-Q_BUF *get_free_q( void );
+int spl7(void);
+int spl0(void);
+Q_BUF *get_free_q(void);
 PKT *get_free_end(void);
-int add_end( PKT *pkt, PHB *phb, int type);
-unsigned short free_packets( PHB *phb, int type);
-int can_remove_start( PKT **pkt, PHB *phb, int type);
-int can_add_start( PHB *phb, int type);
-int can_add_end( PHB *phb, int type);
-void put_free_end( PKT *pkt);
-int remove_start( PKT **pkt, PHB *phb, int type);
+int add_end(PKT * pkt, PHB * phb, int type);
+unsigned short free_packets(PHB * phb, int type);
+int can_remove_start(PKT ** pkt, PHB * phb, int type);
+int can_add_start(PHB * phb, int type);
+int can_add_end(PHB * phb, int type);
+void put_free_end(PKT * pkt);
+int remove_start(PKT ** pkt, PHB * phb, int type);
 #endif
 
 /*
 ** Lrt.c
 */
-void lrt( Process *lrt_p, LPB *link );
+void lrt(Process * lrt_p, LPB * link);
 
 #ifdef RTA
-void set_led_red ( LPB *link );
+void set_led_red(LPB * link);
 #endif
 
 /*
 ** ltt.c
 */
-void ltt( Process *ltt_p, LPB *link, PHB *phb_ptr[] );
-void send_poll ( LPB *link );
-void request_id ( LPB *link );
-void send_topology_update ( LPB *link );
-void send_topology ( LPB *link );
-void supply_id ( LPB *link );
+void ltt(Process * ltt_p, LPB * link, PHB * phb_ptr[]);
+void send_poll(LPB * link);
+void request_id(LPB * link);
+void send_topology_update(LPB * link);
+void send_topology(LPB * link);
+void supply_id(LPB * link);
 
 #ifdef RTA
-void redirect_queue ( LPB *link, ushort flush );
-int obtain_rup ( int rup_number, PKT **pkt_address, LPB *link );
+void redirect_queue(LPB * link, ushort flush);
+int obtain_rup(int rup_number, PKT ** pkt_address, LPB * link);
 #endif
 
 #ifdef TESTING_PERF
-int consume_cpu( void );
+int consume_cpu(void);
 #endif
 
 /*
 ** lttwake.c
 */
 #ifdef HOST
-void ltt_wakeup( Process *ltt_wakeup_p );
+void ltt_wakeup(Process * ltt_wakeup_p);
 #endif
 
 /*
 ** mapgen.c
 */
-void generate_id_map( short mapping, ROUTE_STR route[] );
-void gen_map( int mapping, int looking_at, int come_from, ROUTE_STR route[], int link, int *ttl );
-void adjust_ttl( int mapping, int looking_at, int come_from, ROUTE_STR route[], int link, int *ttl);
+void generate_id_map(short mapping, ROUTE_STR route[]);
+void gen_map(int mapping, int looking_at, int come_from, ROUTE_STR route[], int link, int *ttl);
+void adjust_ttl(int mapping, int looking_at, int come_from, ROUTE_STR route[], int link, int *ttl);
 void init_sys_map(void);
 
 /*
 ** mmu.c
 */
-char *rio_malloc( unsigned int amount);
-char *rio_calloc( unsigned int num, unsigned int size);
-ERROR rio_mmu_init( uint total_mem );
+char *rio_malloc(unsigned int amount);
+char *rio_calloc(unsigned int num, unsigned int size);
+ERROR rio_mmu_init(uint total_mem);
 
 /*
 ** partn.c
 */
-void partition_tx( struct PHB *phb, u_short tx_size, u_short rx_size, u_short rx_limit);
+void partition_tx(struct PHB *phb, u_short tx_size, u_short rx_size, u_short rx_limit);
 
 /*
 ** poll.c
 */
-void tx_poll( Process *tx_poll_p);
+void tx_poll(Process * tx_poll_p);
 
 /*
 ** process.c
 */
-int  get_proc_space( Process **pd, int **pws, int wssize);
+int get_proc_space(Process ** pd, int **pws, int wssize);
 
 /*
 ** readrom.c
@@ -160,85 +160,85 @@
 /*
 ** rio.c
 */
-int main( void );
+int main(void);
 
 /*
 ** route.c
 */
-void route_update ( PKT *pkt, LPB *link);
+void route_update(PKT * pkt, LPB * link);
 
 /*
 ** rtainit.c
 */
 #if defined(RTA)
 void rta_init(ushort RtaType);
-#endif /* defined(RTA) */
+#endif				/* defined(RTA) */
 
 /*
 ** rupboot.c
 */
-void rup_boot( PKT *pkt, RUP *this_rup, LPB *link);
+void rup_boot(PKT * pkt, RUP * this_rup, LPB * link);
 
 #ifdef RTA
-void kill_your_neighbour( int link_to_kill );
+void kill_your_neighbour(int link_to_kill);
 #endif
 
 /*
 ** rupcmd.c
 */
-void rup_command( PKT *pkt, struct RUP *this_rup, LPB *link);
+void rup_command(PKT * pkt, struct RUP *this_rup, LPB * link);
 
 /*
 ** ruperr.c
 */
-void rup_error( PKT *pkt, RUP *this_rup, LPB *link );
-void illegal_cmd( PKT *src_pkt );
+void rup_error(PKT * pkt, RUP * this_rup, LPB * link);
+void illegal_cmd(PKT * src_pkt);
 
 /*
 ** ruppoll.c
 */
-void rup_poll( PKT *pkt, RUP *this_rup, LPB *link );
+void rup_poll(PKT * pkt, RUP * this_rup, LPB * link);
 
 /*
 ** ruppower.c
 */
-void rup_power( PKT *pkt, RUP *this_rup, LPB *link );
+void rup_power(PKT * pkt, RUP * this_rup, LPB * link);
 
 /*
 ** ruprm.c
 */
-void rup_route_map( PKT *pkt, RUP *this_rup, LPB *link);
+void rup_route_map(PKT * pkt, RUP * this_rup, LPB * link);
 
 /*
 ** rupstat.c
 */
-void rup_status( PKT *pkt, RUP *this_rup, LPB *link);
+void rup_status(PKT * pkt, RUP * this_rup, LPB * link);
 
 /*
 ** rupsync.c
 */
-void rup_sync( PKT *pkt);
+void rup_sync(PKT * pkt);
 
 /*
 ** rxpkt.c
 */
-ERROR  rx_pkt( PKT_ptr_ptr pkt_address, LPB *link);
+ERROR rx_pkt(PKT_ptr_ptr pkt_address, LPB * link);
 
 /*
 ** sendsts.c
 */
-void send_status( PKT *requesting_pkt, RUP *this_rup);
+void send_status(PKT * requesting_pkt, RUP * this_rup);
 
 /*
 ** serial.c
 */
-void assign_serial ( char *ser_in, char *ser_out);
-int cmp_serial ( char *ser_1, char *ser_2);
+void assign_serial(char *ser_in, char *ser_out);
+int cmp_serial(char *ser_1, char *ser_2);
 
 /*
 ** txpkt.c
 */
-ERROR  tx_pkt( PKT *pkt, LPB *link);
-short send_sync( LPB *link);
+ERROR tx_pkt(PKT * pkt, LPB * link);
+short send_sync(LPB * link);
 
-#endif	/* _prototypes_h */
+#endif				/* _prototypes_h */
diff --git a/drivers/char/rio/protsts.h b/drivers/char/rio/protsts.h
index 848111a..69fc4bc 100644
--- a/drivers/char/rio/protsts.h
+++ b/drivers/char/rio/protsts.h
@@ -115,5 +115,3 @@
 #endif
 
 /*********** end of file ***********/
-
-
diff --git a/drivers/char/rio/qbuf.h b/drivers/char/rio/qbuf.h
index 1fce02f..acd9e8e 100644
--- a/drivers/char/rio/qbuf.h
+++ b/drivers/char/rio/qbuf.h
@@ -40,7 +40,7 @@
 
 #ifndef lint
 #ifdef SCCS_LABELS
-static char *_rio_qbuf_h_sccs = "@(#)qbuf.h	1.1" ;
+static char *_rio_qbuf_h_sccs = "@(#)qbuf.h	1.1";
 #endif
 #endif
 
@@ -52,16 +52,15 @@
 #define PKTS_PER_BUFFER    (220 / PKT_LENGTH)
 #endif
 
-typedef struct Q_BUF Q_BUF ;
-struct Q_BUF  {
-                  Q_BUF_ptr next ;
-                  Q_BUF_ptr prev ;
-                  PKT_ptr buf[PKTS_PER_BUFFER] ;
-              } ;
+typedef struct Q_BUF Q_BUF;
+struct Q_BUF {
+	Q_BUF_ptr next;
+	Q_BUF_ptr prev;
+	PKT_ptr buf[PKTS_PER_BUFFER];
+};
 
 
 #endif
 
 
 /*********** end of file ***********/
-
diff --git a/drivers/char/rio/rio.h b/drivers/char/rio/rio.h
index 13a9931..7f45e1a 100644
--- a/drivers/char/rio/rio.h
+++ b/drivers/char/rio/rio.h
@@ -72,8 +72,8 @@
 #define	RIO_HOSTS	4	/* number of hosts that can be found */
 #define	PORTS_PER_HOST	128	/* number of ports per host */
 #define	LINKS_PER_UNIT	4	/* number of links from a host */
-#define	RIO_PORTS	(PORTS_PER_HOST * RIO_HOSTS) /* max. no. of ports */
-#define	RTAS_PER_HOST	(MAX_RUP) /* number of RTAs per host */
+#define	RIO_PORTS	(PORTS_PER_HOST * RIO_HOSTS)	/* max. no. of ports */
+#define	RTAS_PER_HOST	(MAX_RUP)	/* number of RTAs per host */
 #define	PORTS_PER_RTA	(PORTS_PER_HOST/RTAS_PER_HOST)	/* ports on a rta */
 #define	PORTS_PER_MODULE 4	/* number of ports on a plug-in module */
 				/* number of modules on an RTA */
@@ -216,10 +216,9 @@
 #define	RIO_PRI	(PZERO+10)
 #define RIO_CLOSE_PRI	PZERO-1	/* uninterruptible sleeps for close */
 
-typedef struct DbInf
-{
-	uint	Flag;
-	char	Name[8];
+typedef struct DbInf {
+	uint Flag;
+	char Name[8];
 } DbInf;
 
 #ifndef TRUE
@@ -251,7 +250,7 @@
 	*((uint *)PK)    = PP->PacketInfo; \
 }
 
-#define	RIO_LINK_ENABLE	0x80FF /* FF is a hack, mainly for Mips, to        */
+#define	RIO_LINK_ENABLE	0x80FF	/* FF is a hack, mainly for Mips, to        */
 			       /* prevent a really stupid race condition.  */
 
 #define	NOT_INITIALISED	0
@@ -291,4 +290,4 @@
 #define DIST_LINESW_OUTPUT	0x40
 #define DIST_LINESW_MDMINT	0x80
 
-#endif /* __rio_h__ */
+#endif				/* __rio_h__ */
diff --git a/drivers/char/rio/rio_linux.c b/drivers/char/rio/rio_linux.c
index 7085a38..8825bd6 100644
--- a/drivers/char/rio/rio_linux.c
+++ b/drivers/char/rio/rio_linux.c
@@ -33,7 +33,7 @@
  * */
 
 #include <linux/module.h>
-#include <linux/config.h> 
+#include <linux/config.h>
 #include <linux/kdev_t.h>
 #include <asm/io.h>
 #include <linux/kernel.h>
@@ -112,7 +112,7 @@
 #define PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8 0x2000
 #endif
 
-#ifndef RIO_WINDOW_LEN 
+#ifndef RIO_WINDOW_LEN
 #define RIO_WINDOW_LEN 0x10000
 #endif
 
@@ -140,34 +140,51 @@
  */
 #define RIO_REPORT_FIFO
 #define RIO_REPORT_OVERRUN
-#endif 
+#endif
 
 
 /* These constants are derived from SCO Source */
 static struct Conf
-RIOConf =
-{
-  /* locator */         "RIO Config here",
-  /* startuptime */     HZ*2,           /* how long to wait for card to run */
-  /* slowcook */        0,              /* TRUE -> always use line disc. */
-  /* intrpolltime */    1,              /* The frequency of OUR polls */
-  /* breakinterval */   25,             /* x10 mS XXX: units seem to be 1ms not 10! -- REW*/
-  /* timer */           10,             /* mS */
-  /* RtaLoadBase */     0x7000,
-  /* HostLoadBase */    0x7C00,
-  /* XpHz */            5,              /* number of Xprint hits per second */
-  /* XpCps */           120,            /* Xprint characters per second */
-  /* XpOn */            "\033d#",       /* start Xprint for a wyse 60 */
-  /* XpOff */           "\024",         /* end Xprint for a wyse 60 */
-  /* MaxXpCps */        2000,           /* highest Xprint speed */
-  /* MinXpCps */        10,             /* slowest Xprint speed */
-  /* SpinCmds */        1,              /* non-zero for mega fast boots */
-  /* First Addr */      0x0A0000,       /* First address to look at */
-  /* Last Addr */       0xFF0000,       /* Last address looked at */
-  /* BufferSize */      1024,           /* Bytes per port of buffering */
-  /* LowWater */        256,            /* how much data left before wakeup */
-  /* LineLength */      80,             /* how wide is the console? */
-  /* CmdTimeout */      HZ,             /* how long a close command may take */
+ RIOConf = {
+	/* locator */ "RIO Config here",
+					/* startuptime */ HZ * 2,
+					/* how long to wait for card to run */
+				/* slowcook */ 0,
+				/* TRUE -> always use line disc. */
+				/* intrpolltime */ 1,
+				/* The frequency of OUR polls */
+				/* breakinterval */ 25,
+				/* x10 mS XXX: units seem to be 1ms not 10! -- REW */
+				/* timer */ 10,
+				/* mS */
+	/* RtaLoadBase */ 0x7000,
+	/* HostLoadBase */ 0x7C00,
+				/* XpHz */ 5,
+				/* number of Xprint hits per second */
+				/* XpCps */ 120,
+				/* Xprint characters per second */
+				/* XpOn */ "\033d#",
+				/* start Xprint for a wyse 60 */
+				/* XpOff */ "\024",
+				/* end Xprint for a wyse 60 */
+				/* MaxXpCps */ 2000,
+				/* highest Xprint speed */
+				/* MinXpCps */ 10,
+				/* slowest Xprint speed */
+				/* SpinCmds */ 1,
+				/* non-zero for mega fast boots */
+					/* First Addr */ 0x0A0000,
+					/* First address to look at */
+					/* Last Addr */ 0xFF0000,
+					/* Last address looked at */
+				/* BufferSize */ 1024,
+				/* Bytes per port of buffering */
+				/* LowWater */ 256,
+				/* how much data left before wakeup */
+				/* LineLength */ 80,
+				/* how wide is the console? */
+				/* CmdTimeout */ HZ,
+				/* how long a close command may take */
 };
 
 
@@ -175,21 +192,20 @@
 
 /* Function prototypes */
 
-static void rio_disable_tx_interrupts (void * ptr); 
-static void rio_enable_tx_interrupts (void * ptr); 
-static void rio_disable_rx_interrupts (void * ptr); 
-static void rio_enable_rx_interrupts (void * ptr); 
-static int  rio_get_CD (void * ptr); 
-static void rio_shutdown_port (void * ptr);
-static int  rio_set_real_termios (void  *ptr);
-static void rio_hungup (void  *ptr);
-static void rio_close (void  *ptr);
-static int rio_chars_in_buffer (void * ptr);
-static int rio_fw_ioctl (struct inode *inode, struct file *filp,
-		         unsigned int cmd, unsigned long arg);
+static void rio_disable_tx_interrupts(void *ptr);
+static void rio_enable_tx_interrupts(void *ptr);
+static void rio_disable_rx_interrupts(void *ptr);
+static void rio_enable_rx_interrupts(void *ptr);
+static int rio_get_CD(void *ptr);
+static void rio_shutdown_port(void *ptr);
+static int rio_set_real_termios(void *ptr);
+static void rio_hungup(void *ptr);
+static void rio_close(void *ptr);
+static int rio_chars_in_buffer(void *ptr);
+static int rio_fw_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg);
 static int rio_init_drivers(void);
 
-static void my_hd (void *addr, int len);
+static void my_hd(void *addr, int len);
 
 static struct tty_driver *rio_driver, *rio_driver2;
 
@@ -209,7 +225,7 @@
 
 /* These are the only open spaces in my computer. Yours may have more
    or less.... */
-static int rio_probe_addrs[]= {0xc0000, 0xd0000, 0xe0000};
+static int rio_probe_addrs[] = { 0xc0000, 0xd0000, 0xe0000 };
 
 #define NR_RIO_ADDRS ARRAY_SIZE(rio_probe_addrs)
 
@@ -227,17 +243,17 @@
 module_param(rio_irqmask, long, 0);
 
 static struct real_driver rio_real_driver = {
-  rio_disable_tx_interrupts,
-  rio_enable_tx_interrupts,
-  rio_disable_rx_interrupts,
-  rio_enable_rx_interrupts,
-  rio_get_CD,
-  rio_shutdown_port, 
-  rio_set_real_termios, 
-  rio_chars_in_buffer,
-  rio_close,
-  rio_hungup,
-  NULL
+	rio_disable_tx_interrupts,
+	rio_enable_tx_interrupts,
+	rio_disable_rx_interrupts,
+	rio_enable_rx_interrupts,
+	rio_get_CD,
+	rio_shutdown_port,
+	rio_set_real_termios,
+	rio_chars_in_buffer,
+	rio_close,
+	rio_hungup,
+	NULL
 };
 
 /* 
@@ -246,8 +262,8 @@
  */
 
 static struct file_operations rio_fw_fops = {
-	.owner		= THIS_MODULE,
-	.ioctl		= rio_fw_ioctl,
+	.owner = THIS_MODULE,
+	.ioctl = rio_fw_ioctl,
 };
 
 static struct miscdevice rio_fw_device = {
@@ -262,25 +278,22 @@
 
 /* This doesn't work. Who's paranoid around here? Not me! */
 
-static inline int rio_paranoia_check(struct rio_port const * port,
-				    char *name, const char *routine)
+static inline int rio_paranoia_check(struct rio_port const *port, char *name, const char *routine)
 {
 
-  static const char *badmagic =
-    KERN_ERR "rio: Warning: bad rio port magic number for device %s in %s\n";
-  static const char *badinfo =
-    KERN_ERR "rio: Warning: null rio port for device %s in %s\n";
- 
-  if (!port) {
-    printk (badinfo, name, routine);
-    return 1;
-  }
-  if (port->magic != RIO_MAGIC) {
-    printk (badmagic, name, routine);
-    return 1;
-  }
+	static const char *badmagic = KERN_ERR "rio: Warning: bad rio port magic number for device %s in %s\n";
+	static const char *badinfo = KERN_ERR "rio: Warning: null rio port for device %s in %s\n";
 
-  return 0;
+	if (!port) {
+		printk(badinfo, name, routine);
+		return 1;
+	}
+	if (port->magic != RIO_MAGIC) {
+		printk(badmagic, name, routine);
+		return 1;
+	}
+
+	return 0;
 }
 #else
 #define rio_paranoia_check(a,b,c) 0
@@ -288,53 +301,53 @@
 
 
 #ifdef DEBUG
-static void my_hd (void *ad, int len)
+static void my_hd(void *ad, int len)
 {
-  int i, j, ch;
-  unsigned char *addr = ad;
-  
-  for (i=0;i<len;i+=16) {
-    rio_dprintk (RIO_DEBUG_PARAM, "%08x ", (int) addr+i);
-    for (j=0;j<16;j++) {
-      rio_dprintk (RIO_DEBUG_PARAM, "%02x %s", addr[j+i], (j==7)?" ":"");
-    }
-    for (j=0;j<16;j++) {
-      ch = addr[j+i];
-      rio_dprintk (RIO_DEBUG_PARAM, "%c", (ch < 0x20)?'.':((ch > 0x7f)?'.':ch));
-    }
-    rio_dprintk (RIO_DEBUG_PARAM, "\n");
-  }
+	int i, j, ch;
+	unsigned char *addr = ad;
+
+	for (i = 0; i < len; i += 16) {
+		rio_dprintk(RIO_DEBUG_PARAM, "%08x ", (int) addr + i);
+		for (j = 0; j < 16; j++) {
+			rio_dprintk(RIO_DEBUG_PARAM, "%02x %s", addr[j + i], (j == 7) ? " " : "");
+		}
+		for (j = 0; j < 16; j++) {
+			ch = addr[j + i];
+			rio_dprintk(RIO_DEBUG_PARAM, "%c", (ch < 0x20) ? '.' : ((ch > 0x7f) ? '.' : ch));
+		}
+		rio_dprintk(RIO_DEBUG_PARAM, "\n");
+	}
 }
 #else
 #define my_hd(ad,len) do{/* nothing*/ } while (0)
 #endif
 
 
-/* Delay a number of jiffies, allowing a signal to interrupt */ 
-int RIODelay (struct Port *PortP, int njiffies)
+/* Delay a number of jiffies, allowing a signal to interrupt */
+int RIODelay(struct Port *PortP, int njiffies)
 {
-  func_enter ();
+	func_enter();
 
-  rio_dprintk (RIO_DEBUG_DELAY, "delaying %d jiffies\n", njiffies);  
-  msleep_interruptible(jiffies_to_msecs(njiffies));
-  func_exit();
+	rio_dprintk(RIO_DEBUG_DELAY, "delaying %d jiffies\n", njiffies);
+	msleep_interruptible(jiffies_to_msecs(njiffies));
+	func_exit();
 
-  if (signal_pending(current))
-    return RIO_FAIL;
-  else
-    return !RIO_FAIL;
+	if (signal_pending(current))
+		return RIO_FAIL;
+	else
+		return !RIO_FAIL;
 }
 
 
-/* Delay a number of jiffies, disallowing a signal to interrupt */ 
-int RIODelay_ni (struct Port *PortP, int njiffies)
+/* Delay a number of jiffies, disallowing a signal to interrupt */
+int RIODelay_ni(struct Port *PortP, int njiffies)
 {
-  func_enter ();
+	func_enter();
 
-  rio_dprintk (RIO_DEBUG_DELAY, "delaying %d jiffies (ni)\n", njiffies);  
-  msleep(jiffies_to_msecs(njiffies));
-  func_exit();
-  return !RIO_FAIL;
+	rio_dprintk(RIO_DEBUG_DELAY, "delaying %d jiffies (ni)\n", njiffies);
+	msleep(jiffies_to_msecs(njiffies));
+	func_exit();
+	return !RIO_FAIL;
 }
 
 
@@ -350,126 +363,121 @@
 }
 
 
-static int rio_set_real_termios (void *ptr)
+static int rio_set_real_termios(void *ptr)
 {
-  int rv, modem;
-  struct tty_struct *tty;
-  func_enter();
+	int rv, modem;
+	struct tty_struct *tty;
+	func_enter();
 
-  tty = ((struct Port *)ptr)->gs.tty;
+	tty = ((struct Port *) ptr)->gs.tty;
 
-  modem = rio_ismodem(tty);
+	modem = rio_ismodem(tty);
 
-  rv = RIOParam( (struct Port *) ptr, CONFIG, modem, 1);
+	rv = RIOParam((struct Port *) ptr, CONFIG, modem, 1);
 
-  func_exit ();
+	func_exit();
 
-  return rv;
+	return rv;
 }
 
 
-static void rio_reset_interrupt (struct Host *HostP)
+static void rio_reset_interrupt(struct Host *HostP)
 {
-  func_enter();
+	func_enter();
 
-  switch( HostP->Type ) {
-  case RIO_AT:
-  case RIO_MCA:
-  case RIO_PCI:
-    WBYTE(HostP->ResetInt , 0xff);
-  }
+	switch (HostP->Type) {
+	case RIO_AT:
+	case RIO_MCA:
+	case RIO_PCI:
+		WBYTE(HostP->ResetInt, 0xff);
+	}
 
-  func_exit();
+	func_exit();
 }
 
 
-static irqreturn_t rio_interrupt (int irq, void *ptr, struct pt_regs *regs)
+static irqreturn_t rio_interrupt(int irq, void *ptr, struct pt_regs *regs)
 {
-  struct Host *HostP;
-  func_enter ();
+	struct Host *HostP;
+	func_enter();
 
-  HostP = (struct Host*)ptr; /* &p->RIOHosts[(long)ptr]; */
-  rio_dprintk (RIO_DEBUG_IFLOW, "rio: enter rio_interrupt (%d/%d)\n", 
-               irq, HostP->Ivec); 
+	HostP = (struct Host *) ptr;	/* &p->RIOHosts[(long)ptr]; */
+	rio_dprintk(RIO_DEBUG_IFLOW, "rio: enter rio_interrupt (%d/%d)\n", irq, HostP->Ivec);
 
-  /* AAargh! The order in which to do these things is essential and
-     not trivial. 
-     
-     - Rate limit goes before "recursive". Otherwise a series of
-       recursive calls will hang the machine in the interrupt routine. 
+	/* AAargh! The order in which to do these things is essential and
+	   not trivial.
 
-     - hardware twiddling goes before "recursive". Otherwise when we
-       poll the card, and a recursive interrupt happens, we won't
-       ack the card, so it might keep on interrupting us. (especially
-       level sensitive interrupt systems like PCI).
+	   - Rate limit goes before "recursive". Otherwise a series of
+	   recursive calls will hang the machine in the interrupt routine.
 
-     - Rate limit goes before hardware twiddling. Otherwise we won't
-       catch a card that has gone bonkers.
+	   - hardware twiddling goes before "recursive". Otherwise when we
+	   poll the card, and a recursive interrupt happens, we won't
+	   ack the card, so it might keep on interrupting us. (especially
+	   level sensitive interrupt systems like PCI).
 
-     - The "initialized" test goes after the hardware twiddling. Otherwise
-       the card will stick us in the interrupt routine again.
+	   - Rate limit goes before hardware twiddling. Otherwise we won't
+	   catch a card that has gone bonkers.
 
-     - The initialized test goes before recursive. 
-  */
+	   - The "initialized" test goes after the hardware twiddling. Otherwise
+	   the card will stick us in the interrupt routine again.
+
+	   - The initialized test goes before recursive.
+	 */
 
 
 
 #ifdef IRQ_RATE_LIMIT
-  /* Aaargh! I'm ashamed. This costs more lines-of-code than the
-     actual interrupt routine!. (Well, used to when I wrote that comment) */
-  {
-    static int lastjif;
-    static int nintr=0;
+	/* Aaargh! I'm ashamed. This costs more lines-of-code than the
+	   actual interrupt routine!. (Well, used to when I wrote that comment) */
+	{
+		static int lastjif;
+		static int nintr = 0;
 
-    if (lastjif == jiffies) {
-      if (++nintr > IRQ_RATE_LIMIT) {
-        free_irq (HostP->Ivec, ptr);
-        printk (KERN_ERR "rio: Too many interrupts. Turning off interrupt %d.\n", 
-                HostP->Ivec);
-      }
-    } else {
-      lastjif = jiffies;
-      nintr = 0;
-    }
-  }
+		if (lastjif == jiffies) {
+			if (++nintr > IRQ_RATE_LIMIT) {
+				free_irq(HostP->Ivec, ptr);
+				printk(KERN_ERR "rio: Too many interrupts. Turning off interrupt %d.\n", HostP->Ivec);
+			}
+		} else {
+			lastjif = jiffies;
+			nintr = 0;
+		}
+	}
 #endif
-  rio_dprintk (RIO_DEBUG_IFLOW, "rio: We've have noticed the interrupt\n"); 
-  if (HostP->Ivec == irq) {
-    /* Tell the card we've noticed the interrupt. */
-    rio_reset_interrupt (HostP);
-  }
+	rio_dprintk(RIO_DEBUG_IFLOW, "rio: We've have noticed the interrupt\n");
+	if (HostP->Ivec == irq) {
+		/* Tell the card we've noticed the interrupt. */
+		rio_reset_interrupt(HostP);
+	}
 
-  if ((HostP->Flags & RUN_STATE) != RC_RUNNING)
-  	return IRQ_HANDLED;
+	if ((HostP->Flags & RUN_STATE) != RC_RUNNING)
+		return IRQ_HANDLED;
 
-  if (test_and_set_bit (RIO_BOARD_INTR_LOCK, &HostP->locks)) {
-    printk (KERN_ERR "Recursive interrupt! (host %d/irq%d)\n", 
-            (int) ptr, HostP->Ivec);
-    return IRQ_HANDLED;
-  }
+	if (test_and_set_bit(RIO_BOARD_INTR_LOCK, &HostP->locks)) {
+		printk(KERN_ERR "Recursive interrupt! (host %d/irq%d)\n", (int) ptr, HostP->Ivec);
+		return IRQ_HANDLED;
+	}
 
-  RIOServiceHost(p, HostP, irq);
+	RIOServiceHost(p, HostP, irq);
 
-  rio_dprintk ( RIO_DEBUG_IFLOW, "riointr() doing host %d type %d\n", 
-                (int) ptr, HostP->Type);
+	rio_dprintk(RIO_DEBUG_IFLOW, "riointr() doing host %d type %d\n", (int) ptr, HostP->Type);
 
-  clear_bit (RIO_BOARD_INTR_LOCK, &HostP->locks);
-  rio_dprintk (RIO_DEBUG_IFLOW, "rio: exit rio_interrupt (%d/%d)\n", 
-               irq, HostP->Ivec); 
-  func_exit ();
-  return IRQ_HANDLED;
+	clear_bit(RIO_BOARD_INTR_LOCK, &HostP->locks);
+	rio_dprintk(RIO_DEBUG_IFLOW, "rio: exit rio_interrupt (%d/%d)\n", irq, HostP->Ivec);
+	func_exit();
+	return IRQ_HANDLED;
 }
 
 
-static void rio_pollfunc (unsigned long data)
+static void rio_pollfunc(unsigned long data)
 {
-  func_enter ();
+	func_enter();
 
-  rio_interrupt (0, &p->RIOHosts[data], NULL);
-  p->RIOHosts[data].timer.expires = jiffies + rio_poll;
-  add_timer (&p->RIOHosts[data].timer);
+	rio_interrupt(0, &p->RIOHosts[data], NULL);
+	p->RIOHosts[data].timer.expires = jiffies + rio_poll;
+	add_timer(&p->RIOHosts[data].timer);
 
-  func_exit ();
+	func_exit();
 }
 
 
@@ -481,106 +489,106 @@
 /* Ehhm. I don't know how to fiddle with interrupts on the Specialix 
    cards. ....   Hmm. Ok I figured it out. You don't.  -- REW */
 
-static void rio_disable_tx_interrupts (void * ptr) 
+static void rio_disable_tx_interrupts(void *ptr)
 {
-  func_enter();
+	func_enter();
 
-  /*  port->gs.flags &= ~GS_TX_INTEN; */
+	/*  port->gs.flags &= ~GS_TX_INTEN; */
 
-  func_exit();
+	func_exit();
 }
 
 
-static void rio_enable_tx_interrupts (void * ptr) 
+static void rio_enable_tx_interrupts(void *ptr)
 {
-  struct Port *PortP = ptr;
-  /* int hn; */
+	struct Port *PortP = ptr;
+	/* int hn; */
 
-  func_enter();
+	func_enter();
 
-  /* hn = PortP->HostP - p->RIOHosts;
+	/* hn = PortP->HostP - p->RIOHosts;
 
-     rio_dprintk (RIO_DEBUG_TTY, "Pushing host %d\n", hn);
-     rio_interrupt (-1,(void *) hn, NULL); */
+	   rio_dprintk (RIO_DEBUG_TTY, "Pushing host %d\n", hn);
+	   rio_interrupt (-1,(void *) hn, NULL); */
 
-  RIOTxEnable((char *) PortP);
+	RIOTxEnable((char *) PortP);
 
-  /* 
-   * In general we cannot count on "tx empty" interrupts, although
-   * the interrupt routine seems to be able to tell the difference. 
-   */
-  PortP->gs.flags &= ~GS_TX_INTEN;
+	/*
+	 * In general we cannot count on "tx empty" interrupts, although
+	 * the interrupt routine seems to be able to tell the difference.
+	 */
+	PortP->gs.flags &= ~GS_TX_INTEN;
 
-  func_exit();
+	func_exit();
 }
 
 
-static void rio_disable_rx_interrupts (void * ptr) 
+static void rio_disable_rx_interrupts(void *ptr)
 {
-  func_enter();
-  func_exit();
+	func_enter();
+	func_exit();
 }
 
-static void rio_enable_rx_interrupts (void * ptr) 
+static void rio_enable_rx_interrupts(void *ptr)
 {
-  /*  struct rio_port *port = ptr; */
-  func_enter();
-  func_exit();
+	/*  struct rio_port *port = ptr; */
+	func_enter();
+	func_exit();
 }
 
 
 /* Jeez. Isn't this simple?  */
-static int rio_get_CD (void * ptr) 
+static int rio_get_CD(void *ptr)
 {
-  struct Port *PortP = ptr;
-  int rv;
+	struct Port *PortP = ptr;
+	int rv;
 
-  func_enter();
-  rv = (PortP->ModemState & MSVR1_CD) != 0;
+	func_enter();
+	rv = (PortP->ModemState & MSVR1_CD) != 0;
 
-  rio_dprintk (RIO_DEBUG_INIT, "Getting CD status: %d\n", rv);
-  
-  func_exit();  
-  return rv;
+	rio_dprintk(RIO_DEBUG_INIT, "Getting CD status: %d\n", rv);
+
+	func_exit();
+	return rv;
 }
 
 
 /* Jeez. Isn't this simple? Actually, we can sync with the actual port
    by just pushing stuff into the queue going to the port... */
-static int rio_chars_in_buffer (void * ptr) 
+static int rio_chars_in_buffer(void *ptr)
 {
-  func_enter();
+	func_enter();
 
-  func_exit();  
-  return 0;
+	func_exit();
+	return 0;
 }
 
 
 /* Nothing special here... */
-static void rio_shutdown_port (void * ptr) 
+static void rio_shutdown_port(void *ptr)
 {
-  struct Port *PortP;
+	struct Port *PortP;
 
-  func_enter();
+	func_enter();
 
-  PortP = (struct Port *)ptr;
-  PortP->gs.tty = NULL;
+	PortP = (struct Port *) ptr;
+	PortP->gs.tty = NULL;
 #if 0
-  port->gs.flags &= ~ GS_ACTIVE;
-  if (!port->gs.tty) {
-    rio_dprintk (RIO_DBUG_TTY, "No tty.\n");
-    return;
-  }
-  if (!port->gs.tty->termios) {
-    rio_dprintk (RIO_DEBUG_TTY, "No termios.\n");
-    return;
-  }
-  if (port->gs.tty->termios->c_cflag & HUPCL) {
-    rio_setsignals (port, 0, 0);
-  }
+	port->gs.flags &= ~GS_ACTIVE;
+	if (!port->gs.tty) {
+		rio_dprintk(RIO_DBUG_TTY, "No tty.\n");
+		return;
+	}
+	if (!port->gs.tty->termios) {
+		rio_dprintk(RIO_DEBUG_TTY, "No termios.\n");
+		return;
+	}
+	if (port->gs.tty->termios->c_cflag & HUPCL) {
+		rio_setsignals(port, 0, 0);
+	}
 #endif
 
-  func_exit();
+	func_exit();
 }
 
 
@@ -591,16 +599,16 @@
    running minicom on a serial port that is driven by a modularized
    driver. Have the modem hangup. Then remove the driver module. Then
    exit minicom.  I expect an "oops".  -- REW */
-static void rio_hungup (void *ptr)
+static void rio_hungup(void *ptr)
 {
-  struct Port *PortP;
+	struct Port *PortP;
 
-  func_enter();
-  
-  PortP = (struct Port *)ptr;
-  PortP->gs.tty = NULL;
+	func_enter();
 
-  func_exit ();
+	PortP = (struct Port *) ptr;
+	PortP->gs.tty = NULL;
+
+	func_exit();
 }
 
 
@@ -608,146 +616,135 @@
    this. 
    rs_close (...){save_flags;cli;real_close();dec_use_count;restore_flags;}
  */
-static void rio_close (void *ptr)
+static void rio_close(void *ptr)
 {
-  struct Port *PortP;
+	struct Port *PortP;
 
-  func_enter ();
+	func_enter();
 
-  PortP = (struct Port *)ptr;
+	PortP = (struct Port *) ptr;
 
-  riotclose (ptr);
+	riotclose(ptr);
 
-  if(PortP->gs.count) {
-    printk (KERN_ERR "WARNING port count:%d\n", PortP->gs.count);
-    PortP->gs.count = 0; 
-  }                
+	if (PortP->gs.count) {
+		printk(KERN_ERR "WARNING port count:%d\n", PortP->gs.count);
+		PortP->gs.count = 0;
+	}
 
-  PortP->gs.tty = NULL;
-  func_exit ();
+	PortP->gs.tty = NULL;
+	func_exit();
 }
 
 
 
-static int rio_fw_ioctl (struct inode *inode, struct file *filp,
-		         unsigned int cmd, unsigned long arg)
+static int rio_fw_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg)
 {
-  int rc = 0;
-  func_enter();
+	int rc = 0;
+	func_enter();
 
-  /* The "dev" argument isn't used. */
-  rc = riocontrol (p, 0, cmd, (void *)arg, capable(CAP_SYS_ADMIN));
+	/* The "dev" argument isn't used. */
+	rc = riocontrol(p, 0, cmd, (void *) arg, capable(CAP_SYS_ADMIN));
 
-  func_exit ();
-  return rc;
+	func_exit();
+	return rc;
 }
 
-extern int RIOShortCommand(struct rio_info *p, struct Port *PortP,
-               int command, int len, int arg);
+extern int RIOShortCommand(struct rio_info *p, struct Port *PortP, int command, int len, int arg);
 
-static int rio_ioctl (struct tty_struct * tty, struct file * filp, 
-                     unsigned int cmd, unsigned long arg)
+static int rio_ioctl(struct tty_struct *tty, struct file *filp, unsigned int cmd, unsigned long arg)
 {
-  int rc;
-  struct Port *PortP;
-  int ival;
+	int rc;
+	struct Port *PortP;
+	int ival;
 
-  func_enter();
+	func_enter();
 
-  PortP = (struct Port *)tty->driver_data;
+	PortP = (struct Port *) tty->driver_data;
 
-  rc  = 0;
-  switch (cmd) {
+	rc = 0;
+	switch (cmd) {
 #if 0
-  case TIOCGSOFTCAR:
-    rc = put_user(((tty->termios->c_cflag & CLOCAL) ? 1 : 0),
-                  (unsigned int *) arg);
-    break;
+	case TIOCGSOFTCAR:
+		rc = put_user(((tty->termios->c_cflag & CLOCAL) ? 1 : 0), (unsigned int *) arg);
+		break;
 #endif
-  case TIOCSSOFTCAR:
-    if ((rc = get_user(ival, (unsigned int *) arg)) == 0) {
-      tty->termios->c_cflag =
-        (tty->termios->c_cflag & ~CLOCAL) |
-        (ival ? CLOCAL : 0);
-    }
-    break;
-  case TIOCGSERIAL:
-    rc = -EFAULT;
-    if (access_ok(VERIFY_WRITE, (void *) arg,
-                          sizeof(struct serial_struct)))
-      rc = gs_getserial(&PortP->gs, (struct serial_struct *) arg);
-    break;
-  case TCSBRK:
-    if ( PortP->State & RIO_DELETED ) {
-      rio_dprintk (RIO_DEBUG_TTY, "BREAK on deleted RTA\n");
-      rc = -EIO;      
-    } else {
-      if (RIOShortCommand(p, PortP, SBREAK, 2, 250) == RIO_FAIL) {
-         rio_dprintk (RIO_DEBUG_INTR, "SBREAK RIOShortCommand failed\n");
-         rc = -EIO;
-      }          
-    }
-    break;
-  case TCSBRKP:
-    if ( PortP->State & RIO_DELETED ) {
-      rio_dprintk (RIO_DEBUG_TTY, "BREAK on deleted RTA\n");
-      rc = -EIO;      
-    } else {
-      int l;
-      l = arg?arg*100:250;
-      if (l > 255) l = 255;
-      if (RIOShortCommand(p, PortP, SBREAK, 2, arg?arg*100:250) == RIO_FAIL) {
-         rio_dprintk (RIO_DEBUG_INTR, "SBREAK RIOShortCommand failed\n");
-         rc = -EIO;
-      }          
-    }
-    break;
-  case TIOCSSERIAL:
-    rc = -EFAULT;
-    if (access_ok(VERIFY_READ, (void *) arg,
-                          sizeof(struct serial_struct)))
-      rc = gs_setserial(&PortP->gs, (struct serial_struct *) arg);
-    break;
+	case TIOCSSOFTCAR:
+		if ((rc = get_user(ival, (unsigned int *) arg)) == 0) {
+			tty->termios->c_cflag = (tty->termios->c_cflag & ~CLOCAL) | (ival ? CLOCAL : 0);
+		}
+		break;
+	case TIOCGSERIAL:
+		rc = -EFAULT;
+		if (access_ok(VERIFY_WRITE, (void *) arg, sizeof(struct serial_struct)))
+			rc = gs_getserial(&PortP->gs, (struct serial_struct *) arg);
+		break;
+	case TCSBRK:
+		if (PortP->State & RIO_DELETED) {
+			rio_dprintk(RIO_DEBUG_TTY, "BREAK on deleted RTA\n");
+			rc = -EIO;
+		} else {
+			if (RIOShortCommand(p, PortP, SBREAK, 2, 250) == RIO_FAIL) {
+				rio_dprintk(RIO_DEBUG_INTR, "SBREAK RIOShortCommand failed\n");
+				rc = -EIO;
+			}
+		}
+		break;
+	case TCSBRKP:
+		if (PortP->State & RIO_DELETED) {
+			rio_dprintk(RIO_DEBUG_TTY, "BREAK on deleted RTA\n");
+			rc = -EIO;
+		} else {
+			int l;
+			l = arg ? arg * 100 : 250;
+			if (l > 255)
+				l = 255;
+			if (RIOShortCommand(p, PortP, SBREAK, 2, arg ? arg * 100 : 250) == RIO_FAIL) {
+				rio_dprintk(RIO_DEBUG_INTR, "SBREAK RIOShortCommand failed\n");
+				rc = -EIO;
+			}
+		}
+		break;
+	case TIOCSSERIAL:
+		rc = -EFAULT;
+		if (access_ok(VERIFY_READ, (void *) arg, sizeof(struct serial_struct)))
+			rc = gs_setserial(&PortP->gs, (struct serial_struct *) arg);
+		break;
 #if 0
-  /*
-   * note: these IOCTLs no longer reach here.  Use
-   * tiocmset/tiocmget driver methods instead.  The
-   * #if 0 disablement predates this comment.
-   */
-  case TIOCMGET:
-    rc = -EFAULT;
-    if (access_ok(VERIFY_WRITE, (void *) arg,
-                          sizeof(unsigned int))) {
-      rc = 0;
-      ival = rio_getsignals(port);
-      put_user(ival, (unsigned int *) arg);
-    }
-    break;
-  case TIOCMBIS:
-    if ((rc = get_user(ival, (unsigned int *) arg)) == 0) {
-      rio_setsignals(port, ((ival & TIOCM_DTR) ? 1 : -1),
-                           ((ival & TIOCM_RTS) ? 1 : -1));
-    }
-    break;
-  case TIOCMBIC:
-    if ((rc = get_user(ival, (unsigned int *) arg)) == 0) {
-      rio_setsignals(port, ((ival & TIOCM_DTR) ? 0 : -1),
-                           ((ival & TIOCM_RTS) ? 0 : -1));
-    }
-    break;
-  case TIOCMSET:
-    if ((rc = get_user(ival, (unsigned int *) arg)) == 0) {
-      rio_setsignals(port, ((ival & TIOCM_DTR) ? 1 : 0),
-                           ((ival & TIOCM_RTS) ? 1 : 0));
-    }
-    break;
+		/*
+		 * note: these IOCTLs no longer reach here.  Use
+		 * tiocmset/tiocmget driver methods instead.  The
+		 * #if 0 disablement predates this comment.
+		 */
+	case TIOCMGET:
+		rc = -EFAULT;
+		if (access_ok(VERIFY_WRITE, (void *) arg, sizeof(unsigned int))) {
+			rc = 0;
+			ival = rio_getsignals(port);
+			put_user(ival, (unsigned int *) arg);
+		}
+		break;
+	case TIOCMBIS:
+		if ((rc = get_user(ival, (unsigned int *) arg)) == 0) {
+			rio_setsignals(port, ((ival & TIOCM_DTR) ? 1 : -1), ((ival & TIOCM_RTS) ? 1 : -1));
+		}
+		break;
+	case TIOCMBIC:
+		if ((rc = get_user(ival, (unsigned int *) arg)) == 0) {
+			rio_setsignals(port, ((ival & TIOCM_DTR) ? 0 : -1), ((ival & TIOCM_RTS) ? 0 : -1));
+		}
+		break;
+	case TIOCMSET:
+		if ((rc = get_user(ival, (unsigned int *) arg)) == 0) {
+			rio_setsignals(port, ((ival & TIOCM_DTR) ? 1 : 0), ((ival & TIOCM_RTS) ? 1 : 0));
+		}
+		break;
 #endif
-  default:
-    rc = -ENOIOCTLCMD;
-    break;
-  }
-  func_exit();
-  return rc;
+	default:
+		rc = -ENOIOCTLCMD;
+		break;
+	}
+	func_exit();
+	return rc;
 }
 
 
@@ -767,37 +764,37 @@
  * flow control scheme is in use for that port. -- Simon Allen
  */
 
-static void rio_throttle (struct tty_struct * tty)
+static void rio_throttle(struct tty_struct *tty)
 {
-  struct Port *port = (struct Port *)tty->driver_data;
-  
-  func_enter();
-  /* If the port is using any type of input flow
-   * control then throttle the port.
-   */
+	struct Port *port = (struct Port *) tty->driver_data;
 
-  if((tty->termios->c_cflag & CRTSCTS) || (I_IXOFF(tty)) ) {
-    port->State |= RIO_THROTTLE_RX;
-  }
+	func_enter();
+	/* If the port is using any type of input flow
+	 * control then throttle the port.
+	 */
 
-  func_exit();
+	if ((tty->termios->c_cflag & CRTSCTS) || (I_IXOFF(tty))) {
+		port->State |= RIO_THROTTLE_RX;
+	}
+
+	func_exit();
 }
 
 
-static void rio_unthrottle (struct tty_struct * tty)
+static void rio_unthrottle(struct tty_struct *tty)
 {
-  struct Port *port = (struct Port *)tty->driver_data;
+	struct Port *port = (struct Port *) tty->driver_data;
 
-  func_enter();
-  /* Always unthrottle even if flow control is not enabled on
-   * this port in case we disabled flow control while the port
-   * was throttled
-   */
+	func_enter();
+	/* Always unthrottle even if flow control is not enabled on
+	 * this port in case we disabled flow control while the port
+	 * was throttled
+	 */
 
-  port->State &= ~RIO_THROTTLE_RX;
+	port->State &= ~RIO_THROTTLE_RX;
 
-  func_exit();
-  return;
+	func_exit();
+	return;
 }
 
 
@@ -809,35 +806,34 @@
  * ********************************************************************** */
 
 
-static struct vpd_prom *get_VPD_PROM (struct Host *hp)
+static struct vpd_prom *get_VPD_PROM(struct Host *hp)
 {
-  static struct vpd_prom vpdp;
-  char *p;
-  int i;
+	static struct vpd_prom vpdp;
+	char *p;
+	int i;
 
-  func_enter();
-  rio_dprintk (RIO_DEBUG_PROBE, "Going to verify vpd prom at %p.\n", 
-              hp->Caddr + RIO_VPD_ROM);
+	func_enter();
+	rio_dprintk(RIO_DEBUG_PROBE, "Going to verify vpd prom at %p.\n", hp->Caddr + RIO_VPD_ROM);
 
-  p = (char *) &vpdp;
-  for (i=0;i< sizeof (struct vpd_prom);i++)
-    *p++ = readb (hp->Caddr+RIO_VPD_ROM + i*2);
-      /* read_rio_byte (hp, RIO_VPD_ROM + i*2); */
+	p = (char *) &vpdp;
+	for (i = 0; i < sizeof(struct vpd_prom); i++)
+		*p++ = readb(hp->Caddr + RIO_VPD_ROM + i * 2);
+	/* read_rio_byte (hp, RIO_VPD_ROM + i*2); */
 
-  /* Terminate the identifier string. 
-     *** requires one extra byte in struct vpd_prom *** */
-  *p++=0; 
+	/* Terminate the identifier string.
+	 *** requires one extra byte in struct vpd_prom *** */
+	*p++ = 0;
 
-  if (rio_debug & RIO_DEBUG_PROBE)
-    my_hd ((char *)&vpdp, 0x20);
-  
-  func_exit();
+	if (rio_debug & RIO_DEBUG_PROBE)
+		my_hd((char *) &vpdp, 0x20);
 
-  return &vpdp;
+	func_exit();
+
+	return &vpdp;
 }
 
 static struct tty_operations rio_ops = {
-	.open  = riotopen,
+	.open = riotopen,
 	.close = gs_close,
 	.write = gs_write,
 	.put_char = gs_put_char,
@@ -889,7 +885,7 @@
 	rio_driver2->flags = TTY_DRIVER_REAL_RAW;
 	tty_set_operations(rio_driver2, &rio_ops);
 
-	rio_dprintk (RIO_DEBUG_INIT, "set_termios = %p\n", gs_set_termios);
+	rio_dprintk(RIO_DEBUG_INIT, "set_termios = %p\n", gs_set_termios);
 
 	if ((error = tty_register_driver(rio_driver)))
 		goto out2;
@@ -897,116 +893,111 @@
 		goto out3;
 	func_exit();
 	return 0;
-out3:
+      out3:
 	tty_unregister_driver(rio_driver);
-out2:
+      out2:
 	put_tty_driver(rio_driver2);
-out1:
+      out1:
 	put_tty_driver(rio_driver);
-out:
-	printk(KERN_ERR "rio: Couldn't register a rio driver, error = %d\n",
-	     error);
+      out:
+	printk(KERN_ERR "rio: Couldn't register a rio driver, error = %d\n", error);
 	return 1;
 }
 
 
-static void * ckmalloc (int size)
+static void *ckmalloc(int size)
 {
-  void *p;
+	void *p;
 
-  p = kmalloc(size, GFP_KERNEL);
-  if (p) 
-    memset(p, 0, size);
-  return p;
+	p = kmalloc(size, GFP_KERNEL);
+	if (p)
+		memset(p, 0, size);
+	return p;
 }
 
 
 
-static int rio_init_datastructures (void)
+static int rio_init_datastructures(void)
 {
-  int i;
-  struct Port *port;
-  func_enter();
+	int i;
+	struct Port *port;
+	func_enter();
 
-  /* Many drivers statically allocate the maximum number of ports
-     There is no reason not to allocate them dynamically. Is there? -- REW */
-  /* However, the RIO driver allows users to configure their first
-     RTA as the ports numbered 504-511. We therefore need to allocate 
-     the whole range. :-(   -- REW */
-  
+	/* Many drivers statically allocate the maximum number of ports
+	   There is no reason not to allocate them dynamically. Is there? -- REW */
+	/* However, the RIO driver allows users to configure their first
+	   RTA as the ports numbered 504-511. We therefore need to allocate
+	   the whole range. :-(   -- REW */
+
 #define RI_SZ   sizeof(struct rio_info)
 #define HOST_SZ sizeof(struct Host)
 #define PORT_SZ sizeof(struct Port *)
 #define TMIO_SZ sizeof(struct termios *)
-  rio_dprintk (RIO_DEBUG_INIT, "getting : %d %d %d %d %d bytes\n", 
-               RI_SZ, 
-               RIO_HOSTS * HOST_SZ,
-               RIO_PORTS * PORT_SZ,
-               RIO_PORTS * TMIO_SZ,
-               RIO_PORTS * TMIO_SZ);
-  
-  if (!(p                  = ckmalloc (              RI_SZ))) goto free0;
-  if (!(p->RIOHosts        = ckmalloc (RIO_HOSTS * HOST_SZ))) goto free1;
-  if (!(p->RIOPortp        = ckmalloc (RIO_PORTS * PORT_SZ))) goto free2;
-  p->RIOConf = RIOConf;
-  rio_dprintk (RIO_DEBUG_INIT, "Got : %p %p %p\n", 
-               p, p->RIOHosts, p->RIOPortp);
+	rio_dprintk(RIO_DEBUG_INIT, "getting : %d %d %d %d %d bytes\n", RI_SZ, RIO_HOSTS * HOST_SZ, RIO_PORTS * PORT_SZ, RIO_PORTS * TMIO_SZ, RIO_PORTS * TMIO_SZ);
+
+	if (!(p = ckmalloc(RI_SZ)))
+		goto free0;
+	if (!(p->RIOHosts = ckmalloc(RIO_HOSTS * HOST_SZ)))
+		goto free1;
+	if (!(p->RIOPortp = ckmalloc(RIO_PORTS * PORT_SZ)))
+		goto free2;
+	p->RIOConf = RIOConf;
+	rio_dprintk(RIO_DEBUG_INIT, "Got : %p %p %p\n", p, p->RIOHosts, p->RIOPortp);
 
 #if 1
-  for (i = 0; i < RIO_PORTS; i++) {
-    port = p->RIOPortp[i] = ckmalloc (sizeof (struct Port));
-    if (!port) {
-      goto free6;
-    }
-    rio_dprintk (RIO_DEBUG_INIT, "initing port %d (%d)\n", i, port->Mapped);
-    port->PortNum = i;
-    port->gs.magic = RIO_MAGIC;
-    port->gs.close_delay = HZ/2;
-    port->gs.closing_wait = 30 * HZ;
-    port->gs.rd = &rio_real_driver;
-    spin_lock_init(&port->portSem);
-    /*
-     * Initializing wait queue
-     */
-    init_waitqueue_head(&port->gs.open_wait);
-    init_waitqueue_head(&port->gs.close_wait);
-  }
+	for (i = 0; i < RIO_PORTS; i++) {
+		port = p->RIOPortp[i] = ckmalloc(sizeof(struct Port));
+		if (!port) {
+			goto free6;
+		}
+		rio_dprintk(RIO_DEBUG_INIT, "initing port %d (%d)\n", i, port->Mapped);
+		port->PortNum = i;
+		port->gs.magic = RIO_MAGIC;
+		port->gs.close_delay = HZ / 2;
+		port->gs.closing_wait = 30 * HZ;
+		port->gs.rd = &rio_real_driver;
+		spin_lock_init(&port->portSem);
+		/*
+		 * Initializing wait queue
+		 */
+		init_waitqueue_head(&port->gs.open_wait);
+		init_waitqueue_head(&port->gs.close_wait);
+	}
 #else
-  /* We could postpone initializing them to when they are configured. */
+	/* We could postpone initializing them to when they are configured. */
 #endif
 
 
-  
-  if (rio_debug & RIO_DEBUG_INIT) {
-    my_hd (&rio_real_driver, sizeof (rio_real_driver));
-  }
 
-  
-  func_exit();
-  return 0;
+	if (rio_debug & RIO_DEBUG_INIT) {
+		my_hd(&rio_real_driver, sizeof(rio_real_driver));
+	}
 
- free6:for (i--;i>=0;i--)
-        kfree (p->RIOPortp[i]);
+
+	func_exit();
+	return 0;
+
+      free6:for (i--; i >= 0; i--)
+		kfree(p->RIOPortp[i]);
 /*free5:
  free4:
- free3:*/kfree (p->RIOPortp);
- free2:kfree (p->RIOHosts);
- free1:
-  rio_dprintk (RIO_DEBUG_INIT, "Not enough memory! %p %p %p\n", 
-        	       p, p->RIOHosts, p->RIOPortp);
-  kfree(p);        	      
- free0:
-  return -ENOMEM;
+ free3:*/ kfree(p->RIOPortp);
+      free2:kfree(p->RIOHosts);
+      free1:
+	rio_dprintk(RIO_DEBUG_INIT, "Not enough memory! %p %p %p\n", p, p->RIOHosts, p->RIOPortp);
+	kfree(p);
+      free0:
+	return -ENOMEM;
 }
 
-static void  __exit rio_release_drivers(void)
+static void __exit rio_release_drivers(void)
 {
-  func_enter();
-  tty_unregister_driver(rio_driver2);
-  tty_unregister_driver(rio_driver);
-  put_tty_driver(rio_driver2);
-  put_tty_driver(rio_driver);
-  func_exit();
+	func_enter();
+	tty_unregister_driver(rio_driver2);
+	tty_unregister_driver(rio_driver);
+	put_tty_driver(rio_driver2);
+	put_tty_driver(rio_driver);
+	func_exit();
 }
 
 
@@ -1017,7 +1008,7 @@
     There is another bit besides Bit 17. Turning that bit off
     (on boards shipped with the fix in the eeprom) results in a 
     hang on the next access to the card. 
- */
+  */
 
  /******************************************************** 
  * Setting bit 17 in the CNTRL register of the PLX 9050  * 
@@ -1030,319 +1021,293 @@
    EEprom.  As the bit is read/write for the CPU, we can fix it here,
    if we detect that it isn't set correctly. -- REW */
 
-static void fix_rio_pci (struct pci_dev *pdev)
+static void fix_rio_pci(struct pci_dev *pdev)
 {
-  unsigned int hwbase;
-  unsigned long rebase;
-  unsigned int t;
+	unsigned int hwbase;
+	unsigned long rebase;
+	unsigned int t;
 
 #define CNTRL_REG_OFFSET        0x50
 #define CNTRL_REG_GOODVALUE     0x18260000
 
-  pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &hwbase);
-  hwbase &= PCI_BASE_ADDRESS_MEM_MASK;
-  rebase =  (ulong) ioremap(hwbase, 0x80);
-  t = readl (rebase + CNTRL_REG_OFFSET);
-  if (t != CNTRL_REG_GOODVALUE) {
-    printk (KERN_DEBUG "rio: performing cntrl reg fix: %08x -> %08x\n", 
-            t, CNTRL_REG_GOODVALUE); 
-    writel (CNTRL_REG_GOODVALUE, rebase + CNTRL_REG_OFFSET);  
-  }
-  iounmap((char*) rebase);
+	pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &hwbase);
+	hwbase &= PCI_BASE_ADDRESS_MEM_MASK;
+	rebase = (ulong) ioremap(hwbase, 0x80);
+	t = readl(rebase + CNTRL_REG_OFFSET);
+	if (t != CNTRL_REG_GOODVALUE) {
+		printk(KERN_DEBUG "rio: performing cntrl reg fix: %08x -> %08x\n", t, CNTRL_REG_GOODVALUE);
+		writel(CNTRL_REG_GOODVALUE, rebase + CNTRL_REG_OFFSET);
+	}
+	iounmap((char *) rebase);
 }
 #endif
 
 
-static int __init rio_init(void) 
+static int __init rio_init(void)
 {
-  int found = 0;
-  int i;
-  struct Host *hp;
-  int retval;
-  struct vpd_prom *vpdp;
-  int okboard;
+	int found = 0;
+	int i;
+	struct Host *hp;
+	int retval;
+	struct vpd_prom *vpdp;
+	int okboard;
 
 #ifdef CONFIG_PCI
-  struct pci_dev *pdev = NULL;
-  unsigned int tint;
-  unsigned short tshort;
+	struct pci_dev *pdev = NULL;
+	unsigned int tint;
+	unsigned short tshort;
 #endif
 
-  func_enter();
-  rio_dprintk (RIO_DEBUG_INIT, "Initing rio module... (rio_debug=%d)\n", 
-	       rio_debug);
+	func_enter();
+	rio_dprintk(RIO_DEBUG_INIT, "Initing rio module... (rio_debug=%d)\n", rio_debug);
 
-  if (abs ((long) (&rio_debug) - rio_debug) < 0x10000) {
-    printk (KERN_WARNING "rio: rio_debug is an address, instead of a value. "
-            "Assuming -1. Was %x/%p.\n", rio_debug, &rio_debug);
-    rio_debug=-1;
-  }
+	if (abs((long) (&rio_debug) - rio_debug) < 0x10000) {
+		printk(KERN_WARNING "rio: rio_debug is an address, instead of a value. " "Assuming -1. Was %x/%p.\n", rio_debug, &rio_debug);
+		rio_debug = -1;
+	}
 
-  if (misc_register(&rio_fw_device) < 0) {
-    printk(KERN_ERR "RIO: Unable to register firmware loader driver.\n");
-    return -EIO;
-  }
+	if (misc_register(&rio_fw_device) < 0) {
+		printk(KERN_ERR "RIO: Unable to register firmware loader driver.\n");
+		return -EIO;
+	}
 
-  retval = rio_init_datastructures ();
-  if (retval < 0) {
-    misc_deregister(&rio_fw_device);
-    return retval;
-  }
-
+	retval = rio_init_datastructures();
+	if (retval < 0) {
+		misc_deregister(&rio_fw_device);
+		return retval;
+	}
 #ifdef CONFIG_PCI
-    /* First look for the JET devices: */
-    while ((pdev = pci_get_device (PCI_VENDOR_ID_SPECIALIX,
-                                    PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8, 
-                                    pdev))) {
-       if (pci_enable_device(pdev)) continue;
+	/* First look for the JET devices: */
+	while ((pdev = pci_get_device(PCI_VENDOR_ID_SPECIALIX, PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8, pdev))) {
+		if (pci_enable_device(pdev))
+			continue;
 
-      /* Specialix has a whole bunch of cards with
-         0x2000 as the device ID. They say its because
-         the standard requires it. Stupid standard. */
-      /* It seems that reading a word doesn't work reliably on 2.0.
-         Also, reading a non-aligned dword doesn't work. So we read the
-         whole dword at 0x2c and extract the word at 0x2e (SUBSYSTEM_ID)
-         ourselves */
-      /* I don't know why the define doesn't work, constant 0x2c does --REW */ 
-      pci_read_config_dword (pdev, 0x2c, &tint);
-      tshort = (tint >> 16) & 0xffff;
-      rio_dprintk (RIO_DEBUG_PROBE, "Got a specialix card: %x.\n", tint);
-      if (tshort != 0x0100) {
-        rio_dprintk (RIO_DEBUG_PROBE, "But it's not a RIO card (%d)...\n", 
-                    tshort);
-        continue;
-      }
-      rio_dprintk (RIO_DEBUG_PROBE, "cp1\n");
+		/* Specialix has a whole bunch of cards with
+		   0x2000 as the device ID. They say its because
+		   the standard requires it. Stupid standard. */
+		/* It seems that reading a word doesn't work reliably on 2.0.
+		   Also, reading a non-aligned dword doesn't work. So we read the
+		   whole dword at 0x2c and extract the word at 0x2e (SUBSYSTEM_ID)
+		   ourselves */
+		/* I don't know why the define doesn't work, constant 0x2c does --REW */
+		pci_read_config_dword(pdev, 0x2c, &tint);
+		tshort = (tint >> 16) & 0xffff;
+		rio_dprintk(RIO_DEBUG_PROBE, "Got a specialix card: %x.\n", tint);
+		if (tshort != 0x0100) {
+			rio_dprintk(RIO_DEBUG_PROBE, "But it's not a RIO card (%d)...\n", tshort);
+			continue;
+		}
+		rio_dprintk(RIO_DEBUG_PROBE, "cp1\n");
 
-      pci_read_config_dword(pdev, PCI_BASE_ADDRESS_2, &tint);
+		pci_read_config_dword(pdev, PCI_BASE_ADDRESS_2, &tint);
 
-      hp = &p->RIOHosts[p->RIONumHosts];
-      hp->PaddrP =  tint & PCI_BASE_ADDRESS_MEM_MASK;
-      hp->Ivec = pdev->irq;
-      if (((1 << hp->Ivec) & rio_irqmask) == 0)
-              hp->Ivec = 0;
-      hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN);
-      hp->CardP	= (struct DpRam *) hp->Caddr;
-      hp->Type  = RIO_PCI;
-      hp->Copy  = rio_pcicopy; 
-      hp->Mode  = RIO_PCI_BOOT_FROM_RAM;
-      spin_lock_init(&hp->HostLock);
-      rio_reset_interrupt (hp);
-      rio_start_card_running (hp);
+		hp = &p->RIOHosts[p->RIONumHosts];
+		hp->PaddrP = tint & PCI_BASE_ADDRESS_MEM_MASK;
+		hp->Ivec = pdev->irq;
+		if (((1 << hp->Ivec) & rio_irqmask) == 0)
+			hp->Ivec = 0;
+		hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN);
+		hp->CardP = (struct DpRam *) hp->Caddr;
+		hp->Type = RIO_PCI;
+		hp->Copy = rio_pcicopy;
+		hp->Mode = RIO_PCI_BOOT_FROM_RAM;
+		spin_lock_init(&hp->HostLock);
+		rio_reset_interrupt(hp);
+		rio_start_card_running(hp);
 
-      rio_dprintk (RIO_DEBUG_PROBE, "Going to test it (%p/%p).\n",
-                   (void *)p->RIOHosts[p->RIONumHosts].PaddrP,
-                   p->RIOHosts[p->RIONumHosts].Caddr);
-      if (RIOBoardTest( p->RIOHosts[p->RIONumHosts].PaddrP,
-                        p->RIOHosts[p->RIONumHosts].Caddr, 
-                        RIO_PCI, 0 ) == RIO_SUCCESS) {
-              rio_dprintk (RIO_DEBUG_INIT, "Done RIOBoardTest\n");
-              WBYTE(p->RIOHosts[p->RIONumHosts].ResetInt, 0xff);
-              p->RIOHosts[p->RIONumHosts].UniqueNum  =
-                      ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[0]) &0xFF)<< 0)|
-                      ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[1]) &0xFF)<< 8)|
-                      ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[2]) &0xFF)<<16)|
-                      ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[3]) &0xFF)<<24);
-              rio_dprintk (RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n",
-                           p->RIOHosts[p->RIONumHosts].UniqueNum);
-              
-              fix_rio_pci (pdev);
-              p->RIOLastPCISearch = RIO_SUCCESS;
-              p->RIONumHosts++;
-              found++;
-      } else {
-              iounmap((char*) (p->RIOHosts[p->RIONumHosts].Caddr));
-      }
-    }
-    
-    /* Then look for the older PCI card.... : */
+		rio_dprintk(RIO_DEBUG_PROBE, "Going to test it (%p/%p).\n", (void *) p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr);
+		if (RIOBoardTest(p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr, RIO_PCI, 0) == RIO_SUCCESS) {
+			rio_dprintk(RIO_DEBUG_INIT, "Done RIOBoardTest\n");
+			WBYTE(p->RIOHosts[p->RIONumHosts].ResetInt, 0xff);
+			p->RIOHosts[p->RIONumHosts].UniqueNum =
+			    ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[0]) & 0xFF) << 0) |
+			    ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[1]) & 0xFF) << 8) | ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[2]) & 0xFF) << 16) | ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[3]) & 0xFF) << 24);
+			rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum);
 
-  /* These older PCI cards have problems (only byte-mode access is
-     supported), which makes them a bit awkward to support. 
-     They also have problems sharing interrupts. Be careful. 
-     (The driver now refuses to share interrupts for these
-     cards. This should be sufficient).
-  */
+			fix_rio_pci(pdev);
+			p->RIOLastPCISearch = RIO_SUCCESS;
+			p->RIONumHosts++;
+			found++;
+		} else {
+			iounmap((char *) (p->RIOHosts[p->RIONumHosts].Caddr));
+		}
+	}
 
-    /* Then look for the older RIO/PCI devices: */
-    while ((pdev = pci_get_device (PCI_VENDOR_ID_SPECIALIX,
-                                    PCI_DEVICE_ID_SPECIALIX_RIO, 
-                                    pdev))) {
-       if (pci_enable_device(pdev)) continue;
+	/* Then look for the older PCI card.... : */
+
+	/* These older PCI cards have problems (only byte-mode access is
+	   supported), which makes them a bit awkward to support.
+	   They also have problems sharing interrupts. Be careful.
+	   (The driver now refuses to share interrupts for these
+	   cards. This should be sufficient).
+	 */
+
+	/* Then look for the older RIO/PCI devices: */
+	while ((pdev = pci_get_device(PCI_VENDOR_ID_SPECIALIX, PCI_DEVICE_ID_SPECIALIX_RIO, pdev))) {
+		if (pci_enable_device(pdev))
+			continue;
 
 #ifdef CONFIG_RIO_OLDPCI
-      pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &tint);
+		pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &tint);
 
-      hp = &p->RIOHosts[p->RIONumHosts];
-      hp->PaddrP =  tint & PCI_BASE_ADDRESS_MEM_MASK;
-      hp->Ivec = pdev->irq;
-      if (((1 << hp->Ivec) & rio_irqmask) == 0) 
-      	hp->Ivec = 0;
-      hp->Ivec |= 0x8000; /* Mark as non-sharable */
-      hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN);
-      hp->CardP	= (struct DpRam *) hp->Caddr;
-      hp->Type  = RIO_PCI;
-      hp->Copy  = rio_pcicopy;
-      hp->Mode  = RIO_PCI_BOOT_FROM_RAM;
-      spin_lock_init(&hp->HostLock);
+		hp = &p->RIOHosts[p->RIONumHosts];
+		hp->PaddrP = tint & PCI_BASE_ADDRESS_MEM_MASK;
+		hp->Ivec = pdev->irq;
+		if (((1 << hp->Ivec) & rio_irqmask) == 0)
+			hp->Ivec = 0;
+		hp->Ivec |= 0x8000;	/* Mark as non-sharable */
+		hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN);
+		hp->CardP = (struct DpRam *) hp->Caddr;
+		hp->Type = RIO_PCI;
+		hp->Copy = rio_pcicopy;
+		hp->Mode = RIO_PCI_BOOT_FROM_RAM;
+		spin_lock_init(&hp->HostLock);
 
-      rio_dprintk (RIO_DEBUG_PROBE, "Ivec: %x\n", hp->Ivec);
-      rio_dprintk (RIO_DEBUG_PROBE, "Mode: %x\n", hp->Mode);
+		rio_dprintk(RIO_DEBUG_PROBE, "Ivec: %x\n", hp->Ivec);
+		rio_dprintk(RIO_DEBUG_PROBE, "Mode: %x\n", hp->Mode);
 
-      rio_reset_interrupt (hp);
-      rio_start_card_running (hp);
-       rio_dprintk (RIO_DEBUG_PROBE, "Going to test it (%p/%p).\n",
-                   (void *)p->RIOHosts[p->RIONumHosts].PaddrP,
-                   p->RIOHosts[p->RIONumHosts].Caddr);
-      if (RIOBoardTest( p->RIOHosts[p->RIONumHosts].PaddrP,
-                        p->RIOHosts[p->RIONumHosts].Caddr, 
-                        RIO_PCI, 0 ) == RIO_SUCCESS) {
-        WBYTE(p->RIOHosts[p->RIONumHosts].ResetInt, 0xff);
-        p->RIOHosts[p->RIONumHosts].UniqueNum  =
-          ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[0]) &0xFF)<< 0)|
-          ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[1]) &0xFF)<< 8)|
-          ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[2]) &0xFF)<<16)|
-          ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[3]) &0xFF)<<24);
-        rio_dprintk (RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n",
-                   p->RIOHosts[p->RIONumHosts].UniqueNum);
+		rio_reset_interrupt(hp);
+		rio_start_card_running(hp);
+		rio_dprintk(RIO_DEBUG_PROBE, "Going to test it (%p/%p).\n", (void *) p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr);
+		if (RIOBoardTest(p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr, RIO_PCI, 0) == RIO_SUCCESS) {
+			WBYTE(p->RIOHosts[p->RIONumHosts].ResetInt, 0xff);
+			p->RIOHosts[p->RIONumHosts].UniqueNum =
+			    ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[0]) & 0xFF) << 0) |
+			    ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[1]) & 0xFF) << 8) | ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[2]) & 0xFF) << 16) | ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[3]) & 0xFF) << 24);
+			rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum);
 
-        p->RIOLastPCISearch = RIO_SUCCESS;
-        p->RIONumHosts++;
-        found++;
-      } else {
-        iounmap((char*) (p->RIOHosts[p->RIONumHosts].Caddr));
-      }
+			p->RIOLastPCISearch = RIO_SUCCESS;
+			p->RIONumHosts++;
+			found++;
+		} else {
+			iounmap((char *) (p->RIOHosts[p->RIONumHosts].Caddr));
+		}
 #else
-      printk (KERN_ERR "Found an older RIO PCI card, but the driver is not "
-              "compiled to support it.\n");
+		printk(KERN_ERR "Found an older RIO PCI card, but the driver is not " "compiled to support it.\n");
 #endif
-    }
-#endif /* PCI */
+	}
+#endif				/* PCI */
 
-  /* Now probe for ISA cards... */
-  for (i=0;i<NR_RIO_ADDRS;i++) {
-    hp = &p->RIOHosts[p->RIONumHosts];
-    hp->PaddrP = rio_probe_addrs[i];
-    /* There was something about the IRQs of these cards. 'Forget what.--REW */
-    hp->Ivec = 0;
-    hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN);
-    hp->CardP = (struct DpRam *) hp->Caddr;
-    hp->Type = RIO_AT;
-    hp->Copy = rio_pcicopy; /* AT card PCI???? - PVDL
-                             * -- YES! this is now a normal copy. Only the 
-                             * old PCI card uses the special PCI copy. 
-                             * Moreover, the ISA card will work with the 
-                             * special PCI copy anyway. -- REW */
-    hp->Mode = 0;
-    spin_lock_init(&hp->HostLock);
+	/* Now probe for ISA cards... */
+	for (i = 0; i < NR_RIO_ADDRS; i++) {
+		hp = &p->RIOHosts[p->RIONumHosts];
+		hp->PaddrP = rio_probe_addrs[i];
+		/* There was something about the IRQs of these cards. 'Forget what.--REW */
+		hp->Ivec = 0;
+		hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN);
+		hp->CardP = (struct DpRam *) hp->Caddr;
+		hp->Type = RIO_AT;
+		hp->Copy = rio_pcicopy;	/* AT card PCI???? - PVDL
+					 * -- YES! this is now a normal copy. Only the
+					 * old PCI card uses the special PCI copy.
+					 * Moreover, the ISA card will work with the
+					 * special PCI copy anyway. -- REW */
+		hp->Mode = 0;
+		spin_lock_init(&hp->HostLock);
 
-    vpdp = get_VPD_PROM (hp);
-    rio_dprintk (RIO_DEBUG_PROBE, "Got VPD ROM\n");
-    okboard = 0;
-    if ((strncmp (vpdp->identifier, RIO_ISA_IDENT, 16) == 0) ||
-        (strncmp (vpdp->identifier, RIO_ISA2_IDENT, 16) == 0) ||
-        (strncmp (vpdp->identifier, RIO_ISA3_IDENT, 16) == 0)) {
-      /* Board is present... */
-      if (RIOBoardTest (hp->PaddrP, 
-                        hp->Caddr, RIO_AT, 0) == RIO_SUCCESS) {
-        /* ... and feeling fine!!!! */
-        rio_dprintk (RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n",
-                   p->RIOHosts[p->RIONumHosts].UniqueNum);
-        if (RIOAssignAT(p, hp->PaddrP, hp->Caddr, 0)) {        
-          rio_dprintk (RIO_DEBUG_PROBE, "Hmm Tested ok, host%d uniqid = %x.\n",
-                       p->RIONumHosts, 
-                       p->RIOHosts[p->RIONumHosts-1].UniqueNum);
-          okboard++;
-          found++;
-        }
-      }
+		vpdp = get_VPD_PROM(hp);
+		rio_dprintk(RIO_DEBUG_PROBE, "Got VPD ROM\n");
+		okboard = 0;
+		if ((strncmp(vpdp->identifier, RIO_ISA_IDENT, 16) == 0) || (strncmp(vpdp->identifier, RIO_ISA2_IDENT, 16) == 0) || (strncmp(vpdp->identifier, RIO_ISA3_IDENT, 16) == 0)) {
+			/* Board is present... */
+			if (RIOBoardTest(hp->PaddrP, hp->Caddr, RIO_AT, 0) == RIO_SUCCESS) {
+				/* ... and feeling fine!!!! */
+				rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum);
+				if (RIOAssignAT(p, hp->PaddrP, hp->Caddr, 0)) {
+					rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, host%d uniqid = %x.\n", p->RIONumHosts, p->RIOHosts[p->RIONumHosts - 1].UniqueNum);
+					okboard++;
+					found++;
+				}
+			}
 
-    if (!okboard)
-      iounmap ((char*) (hp->Caddr));
-    }
-  }
+			if (!okboard)
+				iounmap((char *) (hp->Caddr));
+		}
+	}
 
 
-  for (i=0;i<p->RIONumHosts;i++) {
-    hp = &p->RIOHosts[i];
-    if (hp->Ivec) {
-      int mode = SA_SHIRQ;
-      if (hp->Ivec & 0x8000) {mode = 0; hp->Ivec &= 0x7fff;}
-      rio_dprintk (RIO_DEBUG_INIT, "Requesting interrupt hp: %p rio_interrupt: %d Mode: %x\n", hp,hp->Ivec, hp->Mode);
-      retval = request_irq (hp->Ivec, rio_interrupt, mode, "rio", hp);
-      rio_dprintk (RIO_DEBUG_INIT, "Return value from request_irq: %d\n", retval);
-      if (retval) {
-              printk(KERN_ERR "rio: Cannot allocate irq %d.\n", hp->Ivec);
-              hp->Ivec = 0;
-      }
-      rio_dprintk (RIO_DEBUG_INIT, "Got irq %d.\n", hp->Ivec);
-      if (hp->Ivec != 0){
-              rio_dprintk (RIO_DEBUG_INIT, "Enabling interrupts on rio card.\n"); 
-              hp->Mode |= RIO_PCI_INT_ENABLE;
-      } else
-              hp->Mode &= !RIO_PCI_INT_ENABLE;
-      rio_dprintk (RIO_DEBUG_INIT, "New Mode: %x\n", hp->Mode);
-      rio_start_card_running (hp);
-    }
-    /* Init the timer "always" to make sure that it can safely be 
-       deleted when we unload... */
+	for (i = 0; i < p->RIONumHosts; i++) {
+		hp = &p->RIOHosts[i];
+		if (hp->Ivec) {
+			int mode = SA_SHIRQ;
+			if (hp->Ivec & 0x8000) {
+				mode = 0;
+				hp->Ivec &= 0x7fff;
+			}
+			rio_dprintk(RIO_DEBUG_INIT, "Requesting interrupt hp: %p rio_interrupt: %d Mode: %x\n", hp, hp->Ivec, hp->Mode);
+			retval = request_irq(hp->Ivec, rio_interrupt, mode, "rio", hp);
+			rio_dprintk(RIO_DEBUG_INIT, "Return value from request_irq: %d\n", retval);
+			if (retval) {
+				printk(KERN_ERR "rio: Cannot allocate irq %d.\n", hp->Ivec);
+				hp->Ivec = 0;
+			}
+			rio_dprintk(RIO_DEBUG_INIT, "Got irq %d.\n", hp->Ivec);
+			if (hp->Ivec != 0) {
+				rio_dprintk(RIO_DEBUG_INIT, "Enabling interrupts on rio card.\n");
+				hp->Mode |= RIO_PCI_INT_ENABLE;
+			} else
+				hp->Mode &= !RIO_PCI_INT_ENABLE;
+			rio_dprintk(RIO_DEBUG_INIT, "New Mode: %x\n", hp->Mode);
+			rio_start_card_running(hp);
+		}
+		/* Init the timer "always" to make sure that it can safely be
+		   deleted when we unload... */
 
-    init_timer (&hp->timer);
-    if (!hp->Ivec) {
-      rio_dprintk (RIO_DEBUG_INIT, "Starting polling at %dj intervals.\n", 
-                   rio_poll);
-      hp->timer.data = i;
-      hp->timer.function = rio_pollfunc;
-      hp->timer.expires = jiffies + rio_poll;
-      add_timer (&hp->timer);
-    }
-  }
+		init_timer(&hp->timer);
+		if (!hp->Ivec) {
+			rio_dprintk(RIO_DEBUG_INIT, "Starting polling at %dj intervals.\n", rio_poll);
+			hp->timer.data = i;
+			hp->timer.function = rio_pollfunc;
+			hp->timer.expires = jiffies + rio_poll;
+			add_timer(&hp->timer);
+		}
+	}
 
-  if (found) {
-    rio_dprintk (RIO_DEBUG_INIT, "rio: total of %d boards detected.\n", found);
-    rio_init_drivers ();
-  } else {
-    /* deregister the misc device we created earlier */
-    misc_deregister(&rio_fw_device);
-  }
+	if (found) {
+		rio_dprintk(RIO_DEBUG_INIT, "rio: total of %d boards detected.\n", found);
+		rio_init_drivers();
+	} else {
+		/* deregister the misc device we created earlier */
+		misc_deregister(&rio_fw_device);
+	}
 
-  func_exit();
-  return found?0:-EIO;
+	func_exit();
+	return found ? 0 : -EIO;
 }
 
 
-static void __exit rio_exit (void)
+static void __exit rio_exit(void)
 {
-  int i; 
-  struct Host *hp;
-  
-  func_enter();
+	int i;
+	struct Host *hp;
 
-  for (i=0,hp=p->RIOHosts;i<p->RIONumHosts;i++, hp++) {
-    RIOHostReset (hp->Type, hp->CardP, hp->Slot);
-    if (hp->Ivec) {
-      free_irq (hp->Ivec, hp);
-      rio_dprintk (RIO_DEBUG_INIT, "freed irq %d.\n", hp->Ivec);
-    }
-    /* It is safe/allowed to del_timer a non-active timer */
-    del_timer (&hp->timer);
-  }
+	func_enter();
 
-  if (misc_deregister(&rio_fw_device) < 0) {
-    printk (KERN_INFO "rio: couldn't deregister control-device\n");
-  }
+	for (i = 0, hp = p->RIOHosts; i < p->RIONumHosts; i++, hp++) {
+		RIOHostReset(hp->Type, hp->CardP, hp->Slot);
+		if (hp->Ivec) {
+			free_irq(hp->Ivec, hp);
+			rio_dprintk(RIO_DEBUG_INIT, "freed irq %d.\n", hp->Ivec);
+		}
+		/* It is safe/allowed to del_timer a non-active timer */
+		del_timer(&hp->timer);
+	}
+
+	if (misc_deregister(&rio_fw_device) < 0) {
+		printk(KERN_INFO "rio: couldn't deregister control-device\n");
+	}
 
 
-  rio_dprintk (RIO_DEBUG_CLEANUP, "Cleaning up drivers\n");
+	rio_dprintk(RIO_DEBUG_CLEANUP, "Cleaning up drivers\n");
 
-  rio_release_drivers ();
+	rio_release_drivers();
 
-  /* Release dynamically allocated memory */
-  kfree (p->RIOPortp);
-  kfree (p->RIOHosts);
-  kfree (p);
+	/* Release dynamically allocated memory */
+	kfree(p->RIOPortp);
+	kfree(p->RIOHosts);
+	kfree(p);
 
-  func_exit();
+	func_exit();
 }
 
 module_init(rio_init);
@@ -1368,4 +1333,3 @@
  * tab-width: 8
  * End:
  */
-
diff --git a/drivers/char/rio/rio_linux.h b/drivers/char/rio/rio_linux.h
index 1fba19d5..4ce77fb 100644
--- a/drivers/char/rio/rio_linux.h
+++ b/drivers/char/rio/rio_linux.h
@@ -37,15 +37,15 @@
 
 
 struct vpd_prom {
-  unsigned short id;
-  char hwrev;
-  char hwass;
-  int uniqid;
-  char myear;
-  char mweek;
-  char hw_feature[5];
-  char oem_id;
-  char identifier[16];
+	unsigned short id;
+	char hwrev;
+	char hwass;
+	int uniqid;
+	char myear;
+	char mweek;
+	char hw_feature[5];
+	char oem_id;
+	char identifier[16];
 };
 
 
@@ -75,13 +75,13 @@
       (L_ISIG(tty)))
 
 
-#endif /* __KERNEL__ */
+#endif				/* __KERNEL__ */
 
 
 #define RIO_BOARD_INTR_LOCK  1
 
 
-#ifndef RIOCTL_MISC_MINOR 
+#ifndef RIOCTL_MISC_MINOR
 /* Allow others to gather this into "major.h" or something like that */
 #define RIOCTL_MISC_MINOR    169
 #endif
@@ -121,39 +121,39 @@
             spin_unlock_irqrestore(sem, flags)
 
 #define rio_spin_lock(sem) \
-            spin_lock(sem) 
+            spin_lock(sem)
 
 #define rio_spin_unlock(sem) \
-            spin_unlock(sem) 
+            spin_unlock(sem)
 
 #endif
 
 
 
 #ifdef CONFIG_RIO_OLDPCI
-static inline void *rio_memcpy_toio (void *dummy, void *dest, void *source, int n)
+static inline void *rio_memcpy_toio(void *dummy, void *dest, void *source, int n)
 {
-  char *dst = dest;
-  char *src = source;
+	char *dst = dest;
+	char *src = source;
 
-  while (n--) {
-    writeb (*src++, dst++);
-    (void) readb (dummy);
-  }
+	while (n--) {
+		writeb(*src++, dst++);
+		(void) readb(dummy);
+	}
 
-  return dest;
+	return dest;
 }
 
 
-static inline void *rio_memcpy_fromio (void *dest, void *source, int n)
+static inline void *rio_memcpy_fromio(void *dest, void *source, int n)
 {
-  char *dst = dest;
-  char *src = source;
+	char *dst = dest;
+	char *src = source;
 
-  while (n--) 
-    *dst++ = readb (src++);
+	while (n--)
+		*dst++ = readb(src++);
 
-  return dest;
+	return dest;
 }
 
 #else
@@ -179,9 +179,8 @@
 #define func_exit()  rio_dprintk (RIO_DEBUG_FLOW, "rio: exit  %s\n", __FUNCTION__)
 #define func_enter2() rio_dprintk (RIO_DEBUG_FLOW, "rio: enter %s (port %d)\n",__FUNCTION__, port->line)
 #else
-#define rio_dprintk(f, str...) /* nothing */
+#define rio_dprintk(f, str...)	/* nothing */
 #define func_enter()
 #define func_exit()
 #define func_enter2()
 #endif
-
diff --git a/drivers/char/rio/rioboard.h b/drivers/char/rio/rioboard.h
index cc6ac6a..822c071 100644
--- a/drivers/char/rio/rioboard.h
+++ b/drivers/char/rio/rioboard.h
@@ -35,7 +35,7 @@
 
 */
 
-#ifndef	_rioboard_h				/* If RIOBOARD.H not already defined */
+#ifndef	_rioboard_h		/* If RIOBOARD.H not already defined */
 #define	_rioboard_h    1
 
 /*****************************************************************************
@@ -46,7 +46,7 @@
 
 /* Hardware Registers... */
 
-#define	RIO_REG_BASE	0x7C00			/* Base of control registers */
+#define	RIO_REG_BASE	0x7C00	/* Base of control registers */
 
 #define	RIO_CONFIG	RIO_REG_BASE + 0x0000	/* WRITE: Configuration Register */
 #define	RIO_INTSET	RIO_REG_BASE + 0x0080	/* WRITE: Interrupt Set */
@@ -58,30 +58,30 @@
 #define	RIO_RESETSTAT	RIO_REG_BASE + 0x0100	/* READ: Reset Status (Jet boards only) */
 
 /* RIO_VPD_ROM definitions... */
-#define	VPD_SLX_ID1	0x00			/* READ: Specialix Identifier #1 */
-#define	VPD_SLX_ID2	0x01			/* READ: Specialix Identifier #2 */
-#define	VPD_HW_REV	0x02			/* READ: Hardware Revision */
-#define	VPD_HW_ASSEM	0x03			/* READ: Hardware Assembly Level */
-#define	VPD_UNIQUEID4	0x04			/* READ: Unique Identifier #4 */
-#define	VPD_UNIQUEID3	0x05			/* READ: Unique Identifier #3 */
-#define	VPD_UNIQUEID2	0x06			/* READ: Unique Identifier #2 */
-#define	VPD_UNIQUEID1	0x07			/* READ: Unique Identifier #1 */
-#define	VPD_MANU_YEAR	0x08			/* READ: Year Of Manufacture (0 = 1970) */
-#define	VPD_MANU_WEEK	0x09			/* READ: Week Of Manufacture (0 = week 1 Jan) */
-#define	VPD_HWFEATURE1	0x0A			/* READ: Hardware Feature Byte 1 */
-#define	VPD_HWFEATURE2	0x0B			/* READ: Hardware Feature Byte 2 */
-#define	VPD_HWFEATURE3	0x0C			/* READ: Hardware Feature Byte 3 */
-#define	VPD_HWFEATURE4	0x0D			/* READ: Hardware Feature Byte 4 */
-#define	VPD_HWFEATURE5	0x0E			/* READ: Hardware Feature Byte 5 */
-#define	VPD_OEMID	0x0F			/* READ: OEM Identifier */
-#define	VPD_IDENT	0x10			/* READ: Identifier string (16 bytes) */
+#define	VPD_SLX_ID1	0x00	/* READ: Specialix Identifier #1 */
+#define	VPD_SLX_ID2	0x01	/* READ: Specialix Identifier #2 */
+#define	VPD_HW_REV	0x02	/* READ: Hardware Revision */
+#define	VPD_HW_ASSEM	0x03	/* READ: Hardware Assembly Level */
+#define	VPD_UNIQUEID4	0x04	/* READ: Unique Identifier #4 */
+#define	VPD_UNIQUEID3	0x05	/* READ: Unique Identifier #3 */
+#define	VPD_UNIQUEID2	0x06	/* READ: Unique Identifier #2 */
+#define	VPD_UNIQUEID1	0x07	/* READ: Unique Identifier #1 */
+#define	VPD_MANU_YEAR	0x08	/* READ: Year Of Manufacture (0 = 1970) */
+#define	VPD_MANU_WEEK	0x09	/* READ: Week Of Manufacture (0 = week 1 Jan) */
+#define	VPD_HWFEATURE1	0x0A	/* READ: Hardware Feature Byte 1 */
+#define	VPD_HWFEATURE2	0x0B	/* READ: Hardware Feature Byte 2 */
+#define	VPD_HWFEATURE3	0x0C	/* READ: Hardware Feature Byte 3 */
+#define	VPD_HWFEATURE4	0x0D	/* READ: Hardware Feature Byte 4 */
+#define	VPD_HWFEATURE5	0x0E	/* READ: Hardware Feature Byte 5 */
+#define	VPD_OEMID	0x0F	/* READ: OEM Identifier */
+#define	VPD_IDENT	0x10	/* READ: Identifier string (16 bytes) */
 #define	VPD_IDENT_LEN	0x10
 
 /* VPD ROM Definitions... */
 #define	SLX_ID1		0x4D
 #define	SLX_ID2		0x98
 
-#define	PRODUCT_ID(a)	((a>>4)&0xF)		/* Use to obtain Product ID from VPD_UNIQUEID1 */
+#define	PRODUCT_ID(a)	((a>>4)&0xF)	/* Use to obtain Product ID from VPD_UNIQUEID1 */
 
 #define	ID_SX_ISA	0x2
 #define	ID_RIO_EISA	0x3
@@ -101,7 +101,7 @@
 
 /* Firmware load position... */
 
-#define	FIRMWARELOADADDR	0x7C00		/* Firmware is loaded _before_ this address */
+#define	FIRMWARELOADADDR	0x7C00	/* Firmware is loaded _before_ this address */
 
 /*****************************************************************************
 *****************************                    *****************************
@@ -112,14 +112,14 @@
 /* Control Register Definitions... */
 #define	RIO_ISA_IDENT	"JBJGPGGHINSMJPJR"
 
-#define	RIO_ISA_CFG_BOOTRAM	0x01		/* Boot from RAM, else Link */
-#define	RIO_ISA_CFG_BUSENABLE	0x02		/* Enable processor bus */
-#define	RIO_ISA_CFG_IRQMASK	0x30		/* Interrupt mask */
-#define	  RIO_ISA_CFG_IRQ12	0x10		/* Interrupt Level 12 */
-#define	  RIO_ISA_CFG_IRQ11	0x20		/* Interrupt Level 11 */
-#define	  RIO_ISA_CFG_IRQ9	0x30		/* Interrupt Level 9 */
-#define	RIO_ISA_CFG_LINK20	0x40		/* 20Mbps link, else 10Mbps */
-#define	RIO_ISA_CFG_WAITSTATE0	0x80		/* 0 waitstates, else 1 */
+#define	RIO_ISA_CFG_BOOTRAM	0x01	/* Boot from RAM, else Link */
+#define	RIO_ISA_CFG_BUSENABLE	0x02	/* Enable processor bus */
+#define	RIO_ISA_CFG_IRQMASK	0x30	/* Interrupt mask */
+#define	  RIO_ISA_CFG_IRQ12	0x10	/* Interrupt Level 12 */
+#define	  RIO_ISA_CFG_IRQ11	0x20	/* Interrupt Level 11 */
+#define	  RIO_ISA_CFG_IRQ9	0x30	/* Interrupt Level 9 */
+#define	RIO_ISA_CFG_LINK20	0x40	/* 20Mbps link, else 10Mbps */
+#define	RIO_ISA_CFG_WAITSTATE0	0x80	/* 0 waitstates, else 1 */
 
 /*****************************************************************************
 *****************************                    *****************************
@@ -130,17 +130,17 @@
 /* Control Register Definitions... */
 #define	RIO_ISA2_IDENT	"JBJGPGGHINSMJPJR"
 
-#define	RIO_ISA2_CFG_BOOTRAM	0x01		/* Boot from RAM, else Link */
-#define	RIO_ISA2_CFG_BUSENABLE	0x02		/* Enable processor bus */
-#define	RIO_ISA2_CFG_INTENABLE	0x04		/* Interrupt enable, else disable */
-#define	RIO_ISA2_CFG_16BIT	0x08		/* 16bit mode, else 8bit */
-#define	RIO_ISA2_CFG_IRQMASK	0x30		/* Interrupt mask */
-#define	  RIO_ISA2_CFG_IRQ15	0x00		/* Interrupt Level 15 */
-#define	  RIO_ISA2_CFG_IRQ12	0x10		/* Interrupt Level 12 */
-#define	  RIO_ISA2_CFG_IRQ11	0x20		/* Interrupt Level 11 */
-#define	  RIO_ISA2_CFG_IRQ9	0x30		/* Interrupt Level 9 */
-#define	RIO_ISA2_CFG_LINK20	0x40		/* 20Mbps link, else 10Mbps */
-#define	RIO_ISA2_CFG_WAITSTATE0	0x80		/* 0 waitstates, else 1 */
+#define	RIO_ISA2_CFG_BOOTRAM	0x01	/* Boot from RAM, else Link */
+#define	RIO_ISA2_CFG_BUSENABLE	0x02	/* Enable processor bus */
+#define	RIO_ISA2_CFG_INTENABLE	0x04	/* Interrupt enable, else disable */
+#define	RIO_ISA2_CFG_16BIT	0x08	/* 16bit mode, else 8bit */
+#define	RIO_ISA2_CFG_IRQMASK	0x30	/* Interrupt mask */
+#define	  RIO_ISA2_CFG_IRQ15	0x00	/* Interrupt Level 15 */
+#define	  RIO_ISA2_CFG_IRQ12	0x10	/* Interrupt Level 12 */
+#define	  RIO_ISA2_CFG_IRQ11	0x20	/* Interrupt Level 11 */
+#define	  RIO_ISA2_CFG_IRQ9	0x30	/* Interrupt Level 9 */
+#define	RIO_ISA2_CFG_LINK20	0x40	/* 20Mbps link, else 10Mbps */
+#define	RIO_ISA2_CFG_WAITSTATE0	0x80	/* 0 waitstates, else 1 */
 
 /*****************************************************************************
 *****************************                   ******************************
@@ -151,14 +151,14 @@
 /* Control Register Definitions... */
 #define	RIO_ISA3_IDENT	"JET HOST BY KEV#"
 
-#define	RIO_ISA3_CFG_BUSENABLE	0x02		/* Enable processor bus */
-#define	RIO_ISA3_CFG_INTENABLE	0x04		/* Interrupt enable, else disable */
-#define	RIO_ISA32_CFG_IRQMASK	0xF30		/* Interrupt mask */
-#define	  RIO_ISA3_CFG_IRQ15	0xF0		/* Interrupt Level 15 */
-#define	  RIO_ISA3_CFG_IRQ12	0xC0		/* Interrupt Level 12 */
-#define	  RIO_ISA3_CFG_IRQ11	0xB0		/* Interrupt Level 11 */
-#define	  RIO_ISA3_CFG_IRQ10	0xA0		/* Interrupt Level 10 */
-#define	  RIO_ISA3_CFG_IRQ9	0x90		/* Interrupt Level 9 */
+#define	RIO_ISA3_CFG_BUSENABLE	0x02	/* Enable processor bus */
+#define	RIO_ISA3_CFG_INTENABLE	0x04	/* Interrupt enable, else disable */
+#define	RIO_ISA32_CFG_IRQMASK	0xF30	/* Interrupt mask */
+#define	  RIO_ISA3_CFG_IRQ15	0xF0	/* Interrupt Level 15 */
+#define	  RIO_ISA3_CFG_IRQ12	0xC0	/* Interrupt Level 12 */
+#define	  RIO_ISA3_CFG_IRQ11	0xB0	/* Interrupt Level 11 */
+#define	  RIO_ISA3_CFG_IRQ10	0xA0	/* Interrupt Level 10 */
+#define	  RIO_ISA3_CFG_IRQ9	0x90	/* Interrupt Level 9 */
 
 /*****************************************************************************
 *********************************             ********************************
@@ -169,9 +169,9 @@
 /* Control Register Definitions... */
 #define	RIO_MCA_IDENT	"JBJGPGGHINSMJPJR"
 
-#define	RIO_MCA_CFG_BOOTRAM	0x01		/* Boot from RAM, else Link */
-#define	RIO_MCA_CFG_BUSENABLE	0x02		/* Enable processor bus */
-#define	RIO_MCA_CFG_LINK20	0x40		/* 20Mbps link, else 10Mbps */
+#define	RIO_MCA_CFG_BOOTRAM	0x01	/* Boot from RAM, else Link */
+#define	RIO_MCA_CFG_BUSENABLE	0x02	/* Enable processor bus */
+#define	RIO_MCA_CFG_LINK20	0x40	/* 20Mbps link, else 10Mbps */
 
 /*****************************************************************************
 ********************************              ********************************
@@ -185,35 +185,35 @@
 #define	EISA_PRODUCT_NUMBER	0xC82
 #define	EISA_REVISION_NUMBER	0xC83
 #define	EISA_CARD_ENABLE	0xC84
-#define	EISA_VPD_UNIQUEID4	0xC88		/* READ: Unique Identifier #4 */
-#define	EISA_VPD_UNIQUEID3	0xC8A		/* READ: Unique Identifier #3 */
-#define	EISA_VPD_UNIQUEID2	0xC90		/* READ: Unique Identifier #2 */
-#define	EISA_VPD_UNIQUEID1	0xC92		/* READ: Unique Identifier #1 */
-#define	EISA_VPD_MANU_YEAR	0xC98		/* READ: Year Of Manufacture (0 = 1970) */
-#define	EISA_VPD_MANU_WEEK	0xC9A		/* READ: Week Of Manufacture (0 = week 1 Jan) */
+#define	EISA_VPD_UNIQUEID4	0xC88	/* READ: Unique Identifier #4 */
+#define	EISA_VPD_UNIQUEID3	0xC8A	/* READ: Unique Identifier #3 */
+#define	EISA_VPD_UNIQUEID2	0xC90	/* READ: Unique Identifier #2 */
+#define	EISA_VPD_UNIQUEID1	0xC92	/* READ: Unique Identifier #1 */
+#define	EISA_VPD_MANU_YEAR	0xC98	/* READ: Year Of Manufacture (0 = 1970) */
+#define	EISA_VPD_MANU_WEEK	0xC9A	/* READ: Week Of Manufacture (0 = week 1 Jan) */
 #define	EISA_MEM_ADDR_23_16	0xC00
 #define	EISA_MEM_ADDR_31_24	0xC01
-#define	EISA_RIO_CONFIG		0xC02		/* WRITE: Configuration Register */
-#define	EISA_RIO_INTSET		0xC03		/* WRITE: Interrupt Set */
-#define	EISA_RIO_INTRESET	0xC03		/* READ:  Interrupt Reset */
+#define	EISA_RIO_CONFIG		0xC02	/* WRITE: Configuration Register */
+#define	EISA_RIO_INTSET		0xC03	/* WRITE: Interrupt Set */
+#define	EISA_RIO_INTRESET	0xC03	/* READ:  Interrupt Reset */
 
 /* Control Register Definitions... */
-#define	RIO_EISA_CFG_BOOTRAM	0x01		/* Boot from RAM, else Link */
-#define	RIO_EISA_CFG_LINK20	0x02		/* 20Mbps link, else 10Mbps */
-#define	RIO_EISA_CFG_BUSENABLE	0x04		/* Enable processor bus */
-#define	RIO_EISA_CFG_PROCRUN	0x08		/* Processor running, else reset */
-#define	RIO_EISA_CFG_IRQMASK	0xF0		/* Interrupt mask */
-#define	  RIO_EISA_CFG_IRQ15	0xF0		/* Interrupt Level 15 */
-#define	  RIO_EISA_CFG_IRQ14	0xE0		/* Interrupt Level 14 */
-#define	  RIO_EISA_CFG_IRQ12	0xC0		/* Interrupt Level 12 */
-#define	  RIO_EISA_CFG_IRQ11	0xB0		/* Interrupt Level 11 */
-#define	  RIO_EISA_CFG_IRQ10	0xA0		/* Interrupt Level 10 */
-#define	  RIO_EISA_CFG_IRQ9	0x90		/* Interrupt Level 9 */
-#define	  RIO_EISA_CFG_IRQ7	0x70		/* Interrupt Level 7 */
-#define	  RIO_EISA_CFG_IRQ6	0x60		/* Interrupt Level 6 */
-#define	  RIO_EISA_CFG_IRQ5	0x50		/* Interrupt Level 5 */
-#define	  RIO_EISA_CFG_IRQ4	0x40		/* Interrupt Level 4 */
-#define	  RIO_EISA_CFG_IRQ3	0x30		/* Interrupt Level 3 */
+#define	RIO_EISA_CFG_BOOTRAM	0x01	/* Boot from RAM, else Link */
+#define	RIO_EISA_CFG_LINK20	0x02	/* 20Mbps link, else 10Mbps */
+#define	RIO_EISA_CFG_BUSENABLE	0x04	/* Enable processor bus */
+#define	RIO_EISA_CFG_PROCRUN	0x08	/* Processor running, else reset */
+#define	RIO_EISA_CFG_IRQMASK	0xF0	/* Interrupt mask */
+#define	  RIO_EISA_CFG_IRQ15	0xF0	/* Interrupt Level 15 */
+#define	  RIO_EISA_CFG_IRQ14	0xE0	/* Interrupt Level 14 */
+#define	  RIO_EISA_CFG_IRQ12	0xC0	/* Interrupt Level 12 */
+#define	  RIO_EISA_CFG_IRQ11	0xB0	/* Interrupt Level 11 */
+#define	  RIO_EISA_CFG_IRQ10	0xA0	/* Interrupt Level 10 */
+#define	  RIO_EISA_CFG_IRQ9	0x90	/* Interrupt Level 9 */
+#define	  RIO_EISA_CFG_IRQ7	0x70	/* Interrupt Level 7 */
+#define	  RIO_EISA_CFG_IRQ6	0x60	/* Interrupt Level 6 */
+#define	  RIO_EISA_CFG_IRQ5	0x50	/* Interrupt Level 5 */
+#define	  RIO_EISA_CFG_IRQ4	0x40	/* Interrupt Level 4 */
+#define	  RIO_EISA_CFG_IRQ3	0x30	/* Interrupt Level 3 */
 
 /*****************************************************************************
 ********************************              ********************************
@@ -224,20 +224,20 @@
 /* Control Register Definitions... */
 #define	RIO_SBUS_IDENT	"JBPGK#\0\0\0\0\0\0\0\0\0\0"
 
-#define	RIO_SBUS_CFG_BOOTRAM	0x01		/* Boot from RAM, else Link */
-#define	RIO_SBUS_CFG_BUSENABLE	0x02		/* Enable processor bus */
-#define	RIO_SBUS_CFG_INTENABLE	0x04		/* Interrupt enable, else disable */
-#define	RIO_SBUS_CFG_IRQMASK	0x38		/* Interrupt mask */
-#define	  RIO_SBUS_CFG_IRQNONE	0x00		/* No Interrupt */
-#define	  RIO_SBUS_CFG_IRQ7	0x38		/* Interrupt Level 7 */
-#define	  RIO_SBUS_CFG_IRQ6	0x30		/* Interrupt Level 6 */
-#define	  RIO_SBUS_CFG_IRQ5	0x28		/* Interrupt Level 5 */
-#define	  RIO_SBUS_CFG_IRQ4	0x20		/* Interrupt Level 4 */
-#define	  RIO_SBUS_CFG_IRQ3	0x18		/* Interrupt Level 3 */
-#define	  RIO_SBUS_CFG_IRQ2	0x10		/* Interrupt Level 2 */
-#define	  RIO_SBUS_CFG_IRQ1	0x08		/* Interrupt Level 1 */
-#define	RIO_SBUS_CFG_LINK20	0x40		/* 20Mbps link, else 10Mbps */
-#define	RIO_SBUS_CFG_PROC25	0x80		/* 25Mhz processor clock, else 20Mhz */
+#define	RIO_SBUS_CFG_BOOTRAM	0x01	/* Boot from RAM, else Link */
+#define	RIO_SBUS_CFG_BUSENABLE	0x02	/* Enable processor bus */
+#define	RIO_SBUS_CFG_INTENABLE	0x04	/* Interrupt enable, else disable */
+#define	RIO_SBUS_CFG_IRQMASK	0x38	/* Interrupt mask */
+#define	  RIO_SBUS_CFG_IRQNONE	0x00	/* No Interrupt */
+#define	  RIO_SBUS_CFG_IRQ7	0x38	/* Interrupt Level 7 */
+#define	  RIO_SBUS_CFG_IRQ6	0x30	/* Interrupt Level 6 */
+#define	  RIO_SBUS_CFG_IRQ5	0x28	/* Interrupt Level 5 */
+#define	  RIO_SBUS_CFG_IRQ4	0x20	/* Interrupt Level 4 */
+#define	  RIO_SBUS_CFG_IRQ3	0x18	/* Interrupt Level 3 */
+#define	  RIO_SBUS_CFG_IRQ2	0x10	/* Interrupt Level 2 */
+#define	  RIO_SBUS_CFG_IRQ1	0x08	/* Interrupt Level 1 */
+#define	RIO_SBUS_CFG_LINK20	0x40	/* 20Mbps link, else 10Mbps */
+#define	RIO_SBUS_CFG_PROC25	0x80	/* 25Mhz processor clock, else 20Mhz */
 
 /*****************************************************************************
 *********************************             ********************************
@@ -248,18 +248,18 @@
 /* Control Register Definitions... */
 #define	RIO_PCI_IDENT	"ECDDPGJGJHJRGSK#"
 
-#define	RIO_PCI_CFG_BOOTRAM	0x01		/* Boot from RAM, else Link */
-#define	RIO_PCI_CFG_BUSENABLE	0x02		/* Enable processor bus */
-#define	RIO_PCI_CFG_INTENABLE	0x04		/* Interrupt enable, else disable */
-#define	RIO_PCI_CFG_LINK20	0x40		/* 20Mbps link, else 10Mbps */
-#define	RIO_PCI_CFG_PROC25	0x80		/* 25Mhz processor clock, else 20Mhz */
+#define	RIO_PCI_CFG_BOOTRAM	0x01	/* Boot from RAM, else Link */
+#define	RIO_PCI_CFG_BUSENABLE	0x02	/* Enable processor bus */
+#define	RIO_PCI_CFG_INTENABLE	0x04	/* Interrupt enable, else disable */
+#define	RIO_PCI_CFG_LINK20	0x40	/* 20Mbps link, else 10Mbps */
+#define	RIO_PCI_CFG_PROC25	0x80	/* 25Mhz processor clock, else 20Mhz */
 
 /* PCI Definitions... */
-#define	SPX_VENDOR_ID		0x11CB		/* Assigned by the PCI SIG */
-#define	SPX_DEVICE_ID		0x8000		/* RIO bridge boards */
-#define	SPX_PLXDEVICE_ID	0x2000		/* PLX bridge boards */
+#define	SPX_VENDOR_ID		0x11CB	/* Assigned by the PCI SIG */
+#define	SPX_DEVICE_ID		0x8000	/* RIO bridge boards */
+#define	SPX_PLXDEVICE_ID	0x2000	/* PLX bridge boards */
 #define	SPX_SUB_VENDOR_ID	SPX_VENDOR_ID	/* Same as vendor id */
-#define	RIO_SUB_SYS_ID		0x0800		/* RIO PCI board */
+#define	RIO_SUB_SYS_ID		0x0800	/* RIO PCI board */
 
 /*****************************************************************************
 *****************************                   ******************************
@@ -270,11 +270,11 @@
 /* Control Register Definitions... */
 #define	RIO_PCI2_IDENT	"JET HOST BY KEV#"
 
-#define	RIO_PCI2_CFG_BUSENABLE	0x02		/* Enable processor bus */
-#define	RIO_PCI2_CFG_INTENABLE	0x04		/* Interrupt enable, else disable */
+#define	RIO_PCI2_CFG_BUSENABLE	0x02	/* Enable processor bus */
+#define	RIO_PCI2_CFG_INTENABLE	0x04	/* Interrupt enable, else disable */
 
 /* PCI Definitions... */
-#define	RIO2_SUB_SYS_ID		0x0100		/* RIO (Jet) PCI board */
+#define	RIO2_SUB_SYS_ID		0x0100	/* RIO (Jet) PCI board */
 
 #endif						/*_rioboard_h */
 
diff --git a/drivers/char/rio/riocmd.c b/drivers/char/rio/riocmd.c
index 533085e..b97dd9f 100644
--- a/drivers/char/rio/riocmd.c
+++ b/drivers/char/rio/riocmd.c
@@ -83,102 +83,98 @@
 static struct IdentifyRta IdRta;
 static struct KillNeighbour KillUnit;
 
-int
-RIOFoadRta(struct Host *HostP, struct Map *MapP)
+int RIOFoadRta(struct Host *HostP, struct Map *MapP)
 {
 	struct CmdBlk *CmdBlkP;
 
-	rio_dprintk (RIO_DEBUG_CMD, "FOAD RTA\n");
+	rio_dprintk(RIO_DEBUG_CMD, "FOAD RTA\n");
 
 	CmdBlkP = RIOGetCmdBlk();
 
-	if ( !CmdBlkP ) {
-		rio_dprintk (RIO_DEBUG_CMD, "FOAD RTA: GetCmdBlk failed\n");
+	if (!CmdBlkP) {
+		rio_dprintk(RIO_DEBUG_CMD, "FOAD RTA: GetCmdBlk failed\n");
 		return -ENXIO;
 	}
 
 	CmdBlkP->Packet.dest_unit = MapP->ID;
 	CmdBlkP->Packet.dest_port = BOOT_RUP;
-	CmdBlkP->Packet.src_unit  = 0;
-	CmdBlkP->Packet.src_port  = BOOT_RUP;
-	CmdBlkP->Packet.len	   = 0x84;
-	CmdBlkP->Packet.data[0]   = IFOAD;
-	CmdBlkP->Packet.data[1]   = 0;
-	CmdBlkP->Packet.data[2]   = IFOAD_MAGIC & 0xFF;
-	CmdBlkP->Packet.data[3]   = (IFOAD_MAGIC >> 8) & 0xFF;
+	CmdBlkP->Packet.src_unit = 0;
+	CmdBlkP->Packet.src_port = BOOT_RUP;
+	CmdBlkP->Packet.len = 0x84;
+	CmdBlkP->Packet.data[0] = IFOAD;
+	CmdBlkP->Packet.data[1] = 0;
+	CmdBlkP->Packet.data[2] = IFOAD_MAGIC & 0xFF;
+	CmdBlkP->Packet.data[3] = (IFOAD_MAGIC >> 8) & 0xFF;
 
-	if ( RIOQueueCmdBlk( HostP, MapP->ID-1, CmdBlkP) == RIO_FAIL ) {
-		rio_dprintk (RIO_DEBUG_CMD, "FOAD RTA: Failed to queue foad command\n");
+	if (RIOQueueCmdBlk(HostP, MapP->ID - 1, CmdBlkP) == RIO_FAIL) {
+		rio_dprintk(RIO_DEBUG_CMD, "FOAD RTA: Failed to queue foad command\n");
 		return -EIO;
 	}
 	return 0;
 }
 
-int
-RIOZombieRta(struct Host *HostP, struct Map *MapP)
+int RIOZombieRta(struct Host *HostP, struct Map *MapP)
 {
 	struct CmdBlk *CmdBlkP;
 
-	rio_dprintk (RIO_DEBUG_CMD, "ZOMBIE RTA\n");
+	rio_dprintk(RIO_DEBUG_CMD, "ZOMBIE RTA\n");
 
 	CmdBlkP = RIOGetCmdBlk();
 
-	if ( !CmdBlkP ) {
-		rio_dprintk (RIO_DEBUG_CMD, "ZOMBIE RTA: GetCmdBlk failed\n");
+	if (!CmdBlkP) {
+		rio_dprintk(RIO_DEBUG_CMD, "ZOMBIE RTA: GetCmdBlk failed\n");
 		return -ENXIO;
 	}
 
 	CmdBlkP->Packet.dest_unit = MapP->ID;
 	CmdBlkP->Packet.dest_port = BOOT_RUP;
-	CmdBlkP->Packet.src_unit  = 0;
-	CmdBlkP->Packet.src_port  = BOOT_RUP;
-	CmdBlkP->Packet.len	   = 0x84;
-	CmdBlkP->Packet.data[0]   = ZOMBIE;
-	CmdBlkP->Packet.data[1]   = 0;
-	CmdBlkP->Packet.data[2]   = ZOMBIE_MAGIC & 0xFF;
-	CmdBlkP->Packet.data[3]   = (ZOMBIE_MAGIC >> 8) & 0xFF;
+	CmdBlkP->Packet.src_unit = 0;
+	CmdBlkP->Packet.src_port = BOOT_RUP;
+	CmdBlkP->Packet.len = 0x84;
+	CmdBlkP->Packet.data[0] = ZOMBIE;
+	CmdBlkP->Packet.data[1] = 0;
+	CmdBlkP->Packet.data[2] = ZOMBIE_MAGIC & 0xFF;
+	CmdBlkP->Packet.data[3] = (ZOMBIE_MAGIC >> 8) & 0xFF;
 
-	if ( RIOQueueCmdBlk( HostP, MapP->ID-1, CmdBlkP) == RIO_FAIL ) {
-		rio_dprintk (RIO_DEBUG_CMD, "ZOMBIE RTA: Failed to queue zombie command\n");
+	if (RIOQueueCmdBlk(HostP, MapP->ID - 1, CmdBlkP) == RIO_FAIL) {
+		rio_dprintk(RIO_DEBUG_CMD, "ZOMBIE RTA: Failed to queue zombie command\n");
 		return -EIO;
 	}
 	return 0;
 }
 
-int
-RIOCommandRta(struct rio_info *p, uint RtaUnique,
-	int (* func)(struct Host *HostP, struct Map *MapP))
+int RIOCommandRta(struct rio_info *p, uint RtaUnique, int (*func) (struct Host * HostP, struct Map * MapP))
 {
 	uint Host;
 
-	rio_dprintk (RIO_DEBUG_CMD, "Command RTA 0x%x func 0x%x\n", RtaUnique, (int)func);
+	rio_dprintk(RIO_DEBUG_CMD, "Command RTA 0x%x func 0x%x\n", RtaUnique, (int) func);
 
-	if ( !RtaUnique )
-		return(0);
+	if (!RtaUnique)
+		return (0);
 
-	for ( Host = 0; Host < p->RIONumHosts; Host++ ) {
+	for (Host = 0; Host < p->RIONumHosts; Host++) {
 		uint Rta;
 		struct Host *HostP = &p->RIOHosts[Host];
 
-		for ( Rta = 0; Rta < RTAS_PER_HOST; Rta++ ) {
+		for (Rta = 0; Rta < RTAS_PER_HOST; Rta++) {
 			struct Map *MapP = &HostP->Mapping[Rta];
 
-			if ( MapP->RtaUniqueNum == RtaUnique ) {
+			if (MapP->RtaUniqueNum == RtaUnique) {
 				uint Link;
 
 				/*
-				** now, lets just check we have a route to it...
-				** IF the routing stuff is working, then one of the
-				** topology entries for this unit will have a legit
-				** route *somewhere*. We care not where - if its got
-				** any connections, we can get to it.
-				*/
-				for ( Link = 0; Link < LINKS_PER_UNIT; Link++ ) {
-					if ( MapP->Topology[Link].Unit <= (uchar)MAX_RUP ) {
+				 ** now, lets just check we have a route to it...
+				 ** IF the routing stuff is working, then one of the
+				 ** topology entries for this unit will have a legit
+				 ** route *somewhere*. We care not where - if its got
+				 ** any connections, we can get to it.
+				 */
+				for (Link = 0; Link < LINKS_PER_UNIT; Link++) {
+					if (MapP->Topology[Link].Unit <= (uchar) MAX_RUP) {
 						/*
-						** Its worth trying the operation...
-						*/
-						return (*func)( HostP, MapP );
+						 ** Its worth trying the operation...
+						 */
+						return (*func) (HostP, MapP);
 					}
 				}
 			}
@@ -188,60 +184,59 @@
 }
 
 
-int
-RIOIdentifyRta(struct rio_info *p, caddr_t arg)
+int RIOIdentifyRta(struct rio_info *p, caddr_t arg)
 {
 	uint Host;
 
-	if ( copyin( (int)arg, (caddr_t)&IdRta, sizeof(IdRta) ) == COPYFAIL ) {
-		rio_dprintk (RIO_DEBUG_CMD, "RIO_IDENTIFY_RTA copy failed\n");
+	if (copyin((int) arg, (caddr_t) & IdRta, sizeof(IdRta)) == COPYFAIL) {
+		rio_dprintk(RIO_DEBUG_CMD, "RIO_IDENTIFY_RTA copy failed\n");
 		p->RIOError.Error = COPYIN_FAILED;
 		return -EFAULT;
 	}
 
-	for ( Host = 0 ; Host < p->RIONumHosts; Host++ ) {
+	for (Host = 0; Host < p->RIONumHosts; Host++) {
 		uint Rta;
 		struct Host *HostP = &p->RIOHosts[Host];
 
-		for ( Rta = 0; Rta < RTAS_PER_HOST; Rta++ ) {
+		for (Rta = 0; Rta < RTAS_PER_HOST; Rta++) {
 			struct Map *MapP = &HostP->Mapping[Rta];
 
-			if ( MapP->RtaUniqueNum == IdRta.RtaUnique ) {
+			if (MapP->RtaUniqueNum == IdRta.RtaUnique) {
 				uint Link;
 				/*
-				** now, lets just check we have a route to it...
-				** IF the routing stuff is working, then one of the
-				** topology entries for this unit will have a legit
-				** route *somewhere*. We care not where - if its got
-				** any connections, we can get to it.
-				*/
-				for ( Link = 0; Link < LINKS_PER_UNIT; Link++ ) {
-					if ( MapP->Topology[Link].Unit <= (uchar)MAX_RUP ) {
+				 ** now, lets just check we have a route to it...
+				 ** IF the routing stuff is working, then one of the
+				 ** topology entries for this unit will have a legit
+				 ** route *somewhere*. We care not where - if its got
+				 ** any connections, we can get to it.
+				 */
+				for (Link = 0; Link < LINKS_PER_UNIT; Link++) {
+					if (MapP->Topology[Link].Unit <= (uchar) MAX_RUP) {
 						/*
-						** Its worth trying the operation...
-						*/
+						 ** Its worth trying the operation...
+						 */
 						struct CmdBlk *CmdBlkP;
 
-						rio_dprintk (RIO_DEBUG_CMD, "IDENTIFY RTA\n");
+						rio_dprintk(RIO_DEBUG_CMD, "IDENTIFY RTA\n");
 
 						CmdBlkP = RIOGetCmdBlk();
 
-						if ( !CmdBlkP ) {
-							rio_dprintk (RIO_DEBUG_CMD, "IDENTIFY RTA: GetCmdBlk failed\n");
+						if (!CmdBlkP) {
+							rio_dprintk(RIO_DEBUG_CMD, "IDENTIFY RTA: GetCmdBlk failed\n");
 							return -ENXIO;
 						}
-		
+
 						CmdBlkP->Packet.dest_unit = MapP->ID;
 						CmdBlkP->Packet.dest_port = BOOT_RUP;
-						CmdBlkP->Packet.src_unit  = 0;
-						CmdBlkP->Packet.src_port  = BOOT_RUP;
-						CmdBlkP->Packet.len	   = 0x84;
-						CmdBlkP->Packet.data[0]   = IDENTIFY;
-						CmdBlkP->Packet.data[1]   = 0;
-						CmdBlkP->Packet.data[2]   = IdRta.ID;
-		
-						if ( RIOQueueCmdBlk( HostP, MapP->ID-1, CmdBlkP) == RIO_FAIL ) {
-							rio_dprintk (RIO_DEBUG_CMD, "IDENTIFY RTA: Failed to queue command\n");
+						CmdBlkP->Packet.src_unit = 0;
+						CmdBlkP->Packet.src_port = BOOT_RUP;
+						CmdBlkP->Packet.len = 0x84;
+						CmdBlkP->Packet.data[0] = IDENTIFY;
+						CmdBlkP->Packet.data[1] = 0;
+						CmdBlkP->Packet.data[2] = IdRta.ID;
+
+						if (RIOQueueCmdBlk(HostP, MapP->ID - 1, CmdBlkP) == RIO_FAIL) {
+							rio_dprintk(RIO_DEBUG_CMD, "IDENTIFY RTA: Failed to queue command\n");
 							return -EIO;
 						}
 						return 0;
@@ -249,114 +244,110 @@
 				}
 			}
 		}
-	} 
+	}
 	return -ENOENT;
 }
 
 
-int
-RIOKillNeighbour(struct rio_info *p, caddr_t arg)
+int RIOKillNeighbour(struct rio_info *p, caddr_t arg)
 {
 	uint Host;
 	uint ID;
 	struct Host *HostP;
 	struct CmdBlk *CmdBlkP;
 
-	rio_dprintk (RIO_DEBUG_CMD, "KILL HOST NEIGHBOUR\n");
+	rio_dprintk(RIO_DEBUG_CMD, "KILL HOST NEIGHBOUR\n");
 
-	if ( copyin( (int)arg, (caddr_t)&KillUnit, sizeof(KillUnit) ) == COPYFAIL ) {
-		rio_dprintk (RIO_DEBUG_CMD, "RIO_KILL_NEIGHBOUR copy failed\n");
+	if (copyin((int) arg, (caddr_t) & KillUnit, sizeof(KillUnit)) == COPYFAIL) {
+		rio_dprintk(RIO_DEBUG_CMD, "RIO_KILL_NEIGHBOUR copy failed\n");
 		p->RIOError.Error = COPYIN_FAILED;
 		return -EFAULT;
 	}
 
-	if ( KillUnit.Link > 3 )
+	if (KillUnit.Link > 3)
 		return -ENXIO;
- 
+
 	CmdBlkP = RIOGetCmdBlk();
 
-	if ( !CmdBlkP ) {
-		rio_dprintk (RIO_DEBUG_CMD, "UFOAD: GetCmdBlk failed\n");
+	if (!CmdBlkP) {
+		rio_dprintk(RIO_DEBUG_CMD, "UFOAD: GetCmdBlk failed\n");
 		return -ENXIO;
 	}
 
 	CmdBlkP->Packet.dest_unit = 0;
-	CmdBlkP->Packet.src_unit  = 0;
+	CmdBlkP->Packet.src_unit = 0;
 	CmdBlkP->Packet.dest_port = BOOT_RUP;
-	CmdBlkP->Packet.src_port  = BOOT_RUP;
-	CmdBlkP->Packet.len	   = 0x84;
-	CmdBlkP->Packet.data[0]   = UFOAD;
-	CmdBlkP->Packet.data[1]   = KillUnit.Link;
-	CmdBlkP->Packet.data[2]   = UFOAD_MAGIC & 0xFF;
-	CmdBlkP->Packet.data[3]   = (UFOAD_MAGIC >> 8) & 0xFF;
+	CmdBlkP->Packet.src_port = BOOT_RUP;
+	CmdBlkP->Packet.len = 0x84;
+	CmdBlkP->Packet.data[0] = UFOAD;
+	CmdBlkP->Packet.data[1] = KillUnit.Link;
+	CmdBlkP->Packet.data[2] = UFOAD_MAGIC & 0xFF;
+	CmdBlkP->Packet.data[3] = (UFOAD_MAGIC >> 8) & 0xFF;
 
-	for ( Host = 0; Host < p->RIONumHosts; Host++ ) {
+	for (Host = 0; Host < p->RIONumHosts; Host++) {
 		ID = 0;
 		HostP = &p->RIOHosts[Host];
 
-		if ( HostP->UniqueNum == KillUnit.UniqueNum ) {
-			if ( RIOQueueCmdBlk( HostP, RTAS_PER_HOST+KillUnit.Link,
-							CmdBlkP) == RIO_FAIL ) {
-				rio_dprintk (RIO_DEBUG_CMD, "UFOAD: Failed queue command\n");
+		if (HostP->UniqueNum == KillUnit.UniqueNum) {
+			if (RIOQueueCmdBlk(HostP, RTAS_PER_HOST + KillUnit.Link, CmdBlkP) == RIO_FAIL) {
+				rio_dprintk(RIO_DEBUG_CMD, "UFOAD: Failed queue command\n");
 				return -EIO;
 			}
 			return 0;
 		}
 
-		for ( ID=0; ID < RTAS_PER_HOST; ID++ ) {
-			if ( HostP->Mapping[ID].RtaUniqueNum == KillUnit.UniqueNum ) {
-				CmdBlkP->Packet.dest_unit = ID+1;
-				if ( RIOQueueCmdBlk( HostP, ID, CmdBlkP) == RIO_FAIL ) {
-					rio_dprintk (RIO_DEBUG_CMD, "UFOAD: Failed queue command\n");
+		for (ID = 0; ID < RTAS_PER_HOST; ID++) {
+			if (HostP->Mapping[ID].RtaUniqueNum == KillUnit.UniqueNum) {
+				CmdBlkP->Packet.dest_unit = ID + 1;
+				if (RIOQueueCmdBlk(HostP, ID, CmdBlkP) == RIO_FAIL) {
+					rio_dprintk(RIO_DEBUG_CMD, "UFOAD: Failed queue command\n");
 					return -EIO;
 				}
 				return 0;
 			}
 		}
 	}
-	RIOFreeCmdBlk( CmdBlkP );
+	RIOFreeCmdBlk(CmdBlkP);
 	return -ENXIO;
 }
 
-int
-RIOSuspendBootRta(struct Host *HostP, int ID, int Link)
+int RIOSuspendBootRta(struct Host *HostP, int ID, int Link)
 {
 	struct CmdBlk *CmdBlkP;
 
-	rio_dprintk (RIO_DEBUG_CMD, "SUSPEND BOOT ON RTA ID %d, link %c\n", ID, 'A' + Link);
+	rio_dprintk(RIO_DEBUG_CMD, "SUSPEND BOOT ON RTA ID %d, link %c\n", ID, 'A' + Link);
 
 	CmdBlkP = RIOGetCmdBlk();
 
-	if ( !CmdBlkP ) {
-		rio_dprintk (RIO_DEBUG_CMD, "SUSPEND BOOT ON RTA: GetCmdBlk failed\n");
+	if (!CmdBlkP) {
+		rio_dprintk(RIO_DEBUG_CMD, "SUSPEND BOOT ON RTA: GetCmdBlk failed\n");
 		return -ENXIO;
 	}
 
 	CmdBlkP->Packet.dest_unit = ID;
 	CmdBlkP->Packet.dest_port = BOOT_RUP;
-	CmdBlkP->Packet.src_unit  = 0;
-	CmdBlkP->Packet.src_port  = BOOT_RUP;
-	CmdBlkP->Packet.len	   = 0x84;
-	CmdBlkP->Packet.data[0]   = IWAIT;
-	CmdBlkP->Packet.data[1]   = Link;
-	CmdBlkP->Packet.data[2]   = IWAIT_MAGIC & 0xFF;
-	CmdBlkP->Packet.data[3]   = (IWAIT_MAGIC >> 8) & 0xFF;
+	CmdBlkP->Packet.src_unit = 0;
+	CmdBlkP->Packet.src_port = BOOT_RUP;
+	CmdBlkP->Packet.len = 0x84;
+	CmdBlkP->Packet.data[0] = IWAIT;
+	CmdBlkP->Packet.data[1] = Link;
+	CmdBlkP->Packet.data[2] = IWAIT_MAGIC & 0xFF;
+	CmdBlkP->Packet.data[3] = (IWAIT_MAGIC >> 8) & 0xFF;
 
-	if ( RIOQueueCmdBlk( HostP, ID - 1, CmdBlkP) == RIO_FAIL ) {
-		rio_dprintk (RIO_DEBUG_CMD, "SUSPEND BOOT ON RTA: Failed to queue iwait command\n");
+	if (RIOQueueCmdBlk(HostP, ID - 1, CmdBlkP) == RIO_FAIL) {
+		rio_dprintk(RIO_DEBUG_CMD, "SUSPEND BOOT ON RTA: Failed to queue iwait command\n");
 		return -EIO;
 	}
 	return 0;
 }
 
-int
-RIOFoadWakeup(struct rio_info *p)
+int RIOFoadWakeup(struct rio_info *p)
 {
 	int port;
 	register struct Port *PortP;
 	unsigned long flags;
 
-	for ( port=0; port<RIO_PORTS; port++) {
+	for (port = 0; port < RIO_PORTS; port++) {
 		PortP = p->RIOPortp[port];
 
 		rio_spin_lock_irqsave(&PortP->portSem, flags);
@@ -377,16 +368,15 @@
 		PortP->TxBufferOut = 0;
 		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
 	}
-	return(0);
+	return (0);
 }
 
 /*
 ** Incoming command on the COMMAND_RUP to be processed.
 */
-static int
-RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT *PacketP)
+static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
 {
-	struct PktCmd *PktCmdP = (struct PktCmd *)PacketP->data;
+	struct PktCmd *PktCmdP = (struct PktCmd *) PacketP->data;
 	struct Port *PortP;
 	struct UnixRup *UnixRupP;
 	ushort SysPort;
@@ -395,128 +385,114 @@
 	ushort subCommand;
 	unsigned long flags;
 
-	func_enter ();
+	func_enter();
 
 #ifdef CHECK
-	CheckHost( Host );
-	CheckHostP( HostP );
-	CheckPacketP( PacketP );
+	CheckHost(Host);
+	CheckHostP(HostP);
+	CheckPacketP(PacketP);
 #endif
 
 	/*
-	** 16 port RTA note:
-	** Command rup packets coming from the RTA will have pkt->data[1] (which
-	** translates to PktCmdP->PhbNum) set to the host port number for the
-	** particular unit. To access the correct BaseSysPort for a 16 port RTA,
-	** we can use PhbNum to get the rup number for the appropriate 8 port
-	** block (for the first block, this should be equal to 'Rup').
-	*/
-	rup = RBYTE(PktCmdP->PhbNum) / (ushort)PORTS_PER_RTA;
+	 ** 16 port RTA note:
+	 ** Command rup packets coming from the RTA will have pkt->data[1] (which
+	 ** translates to PktCmdP->PhbNum) set to the host port number for the
+	 ** particular unit. To access the correct BaseSysPort for a 16 port RTA,
+	 ** we can use PhbNum to get the rup number for the appropriate 8 port
+	 ** block (for the first block, this should be equal to 'Rup').
+	 */
+	rup = RBYTE(PktCmdP->PhbNum) / (ushort) PORTS_PER_RTA;
 	UnixRupP = &HostP->UnixRups[rup];
-	SysPort = UnixRupP->BaseSysPort + 
-			(RBYTE(PktCmdP->PhbNum) % (ushort)PORTS_PER_RTA);
-	rio_dprintk (RIO_DEBUG_CMD, "Command on rup %d, port %d\n", rup, SysPort);
+	SysPort = UnixRupP->BaseSysPort + (RBYTE(PktCmdP->PhbNum) % (ushort) PORTS_PER_RTA);
+	rio_dprintk(RIO_DEBUG_CMD, "Command on rup %d, port %d\n", rup, SysPort);
 
 #ifdef CHECK
-	CheckRup( rup );
-	CheckUnixRupP( UnixRupP );
+	CheckRup(rup);
+	CheckUnixRupP(UnixRupP);
 #endif
-	if ( UnixRupP->BaseSysPort == NO_PORT ) {
-		rio_dprintk (RIO_DEBUG_CMD, "OBSCURE ERROR!\n");
-		rio_dprintk (RIO_DEBUG_CMD, "Diagnostics follow. Please WRITE THESE DOWN and report them to Specialix Technical Support\n");
-		rio_dprintk (RIO_DEBUG_CMD, "CONTROL information: Host number %d, name ``%s''\n", 
-			     HostP-p->RIOHosts, HostP->Name );
-		rio_dprintk (RIO_DEBUG_CMD, "CONTROL information: Rup number  0x%x\n", rup);
+	if (UnixRupP->BaseSysPort == NO_PORT) {
+		rio_dprintk(RIO_DEBUG_CMD, "OBSCURE ERROR!\n");
+		rio_dprintk(RIO_DEBUG_CMD, "Diagnostics follow. Please WRITE THESE DOWN and report them to Specialix Technical Support\n");
+		rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: Host number %d, name ``%s''\n", HostP - p->RIOHosts, HostP->Name);
+		rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: Rup number  0x%x\n", rup);
 
-		if ( Rup >= (ushort)MAX_RUP ) {
-			rio_dprintk (RIO_DEBUG_CMD, "CONTROL information: This is the RUP for RTA ``%s''\n",
-				     HostP->Mapping[Rup].Name);
+		if (Rup >= (ushort) MAX_RUP) {
+			rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: This is the RUP for RTA ``%s''\n", HostP->Mapping[Rup].Name);
 		} else
-			rio_dprintk (RIO_DEBUG_CMD, "CONTROL information: This is the RUP for link ``%c'' of host ``%s''\n", 
-				     ('A' + Rup - MAX_RUP), HostP->Name);
+			rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: This is the RUP for link ``%c'' of host ``%s''\n", ('A' + Rup - MAX_RUP), HostP->Name);
 
-		rio_dprintk (RIO_DEBUG_CMD, "PACKET information: Destination 0x%x:0x%x\n",
-			     PacketP->dest_unit, PacketP->dest_port );
-		rio_dprintk (RIO_DEBUG_CMD, "PACKET information: Source	  0x%x:0x%x\n",
-			     PacketP->src_unit, PacketP->src_port );
-		rio_dprintk (RIO_DEBUG_CMD, "PACKET information: Length	  0x%x (%d)\n", PacketP->len,PacketP->len );
-		rio_dprintk (RIO_DEBUG_CMD, "PACKET information: Control	 0x%x (%d)\n", PacketP->control, PacketP->control);
-		rio_dprintk (RIO_DEBUG_CMD, "PACKET information: Check	   0x%x (%d)\n", PacketP->csum, PacketP->csum );
-		rio_dprintk (RIO_DEBUG_CMD, "COMMAND information: Host Port Number 0x%x, "
-					"Command Code 0x%x\n", PktCmdP->PhbNum, PktCmdP->Command );
+		rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Destination 0x%x:0x%x\n", PacketP->dest_unit, PacketP->dest_port);
+		rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Source	  0x%x:0x%x\n", PacketP->src_unit, PacketP->src_port);
+		rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Length	  0x%x (%d)\n", PacketP->len, PacketP->len);
+		rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Control	 0x%x (%d)\n", PacketP->control, PacketP->control);
+		rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Check	   0x%x (%d)\n", PacketP->csum, PacketP->csum);
+		rio_dprintk(RIO_DEBUG_CMD, "COMMAND information: Host Port Number 0x%x, " "Command Code 0x%x\n", PktCmdP->PhbNum, PktCmdP->Command);
 		return TRUE;
 	}
-
 #ifdef CHECK
-	CheckSysPort( SysPort );
+	CheckSysPort(SysPort);
 #endif
-	PortP = p->RIOPortp[ SysPort ];
+	PortP = p->RIOPortp[SysPort];
 	rio_spin_lock_irqsave(&PortP->portSem, flags);
-	switch( RBYTE(PktCmdP->Command) ) {
-		case BREAK_RECEIVED:
-			rio_dprintk (RIO_DEBUG_CMD, "Received a break!\n");
-			/* If the current line disc. is not multi-threading and
-	   			the current processor is not the default, reset rup_intr
-	   			and return FALSE to ensure that the command packet is
-	   			not freed. */
-			/* Call tmgr HANGUP HERE */
-			/* Fix this later when every thing works !!!! RAMRAJ */
-			gs_got_break (&PortP->gs);
+	switch (RBYTE(PktCmdP->Command)) {
+	case BREAK_RECEIVED:
+		rio_dprintk(RIO_DEBUG_CMD, "Received a break!\n");
+		/* If the current line disc. is not multi-threading and
+		   the current processor is not the default, reset rup_intr
+		   and return FALSE to ensure that the command packet is
+		   not freed. */
+		/* Call tmgr HANGUP HERE */
+		/* Fix this later when every thing works !!!! RAMRAJ */
+		gs_got_break(&PortP->gs);
+		break;
+
+	case COMPLETE:
+		rio_dprintk(RIO_DEBUG_CMD, "Command complete on phb %d host %d\n", RBYTE(PktCmdP->PhbNum), HostP - p->RIOHosts);
+		subCommand = 1;
+		switch (RBYTE(PktCmdP->SubCommand)) {
+		case MEMDUMP:
+			rio_dprintk(RIO_DEBUG_CMD, "Memory dump cmd (0x%x) from addr 0x%x\n", RBYTE(PktCmdP->SubCommand), RWORD(PktCmdP->SubAddr));
 			break;
+		case READ_REGISTER:
+			rio_dprintk(RIO_DEBUG_CMD, "Read register (0x%x)\n", RWORD(PktCmdP->SubAddr));
+			p->CdRegister = (RBYTE(PktCmdP->ModemStatus) & MSVR1_HOST);
+			break;
+		default:
+			subCommand = 0;
+			break;
+		}
+		if (subCommand)
+			break;
+		rio_dprintk(RIO_DEBUG_CMD, "New status is 0x%x was 0x%x\n", RBYTE(PktCmdP->PortStatus), PortP->PortState);
+		if (PortP->PortState != RBYTE(PktCmdP->PortStatus)) {
+			rio_dprintk(RIO_DEBUG_CMD, "Mark status & wakeup\n");
+			PortP->PortState = RBYTE(PktCmdP->PortStatus);
+			/* What should we do here ...
+			   wakeup( &PortP->PortState );
+			 */
+		} else
+			rio_dprintk(RIO_DEBUG_CMD, "No change\n");
 
-		case COMPLETE:
-			rio_dprintk (RIO_DEBUG_CMD, "Command complete on phb %d host %d\n",
-			     RBYTE(PktCmdP->PhbNum), HostP-p->RIOHosts);
-			subCommand = 1;
-			switch (RBYTE(PktCmdP->SubCommand)) {
-				case MEMDUMP :
-			rio_dprintk (RIO_DEBUG_CMD, "Memory dump cmd (0x%x) from addr 0x%x\n",
-				     RBYTE(PktCmdP->SubCommand), RWORD(PktCmdP->SubAddr));
-					break;
-				case READ_REGISTER :
-			rio_dprintk (RIO_DEBUG_CMD, "Read register (0x%x)\n", RWORD(PktCmdP->SubAddr));
-					p->CdRegister = (RBYTE(PktCmdP->ModemStatus) & MSVR1_HOST);
-					break;
-				default :
-					subCommand = 0;
-				break;
-			}
-			if (subCommand)
-				break;
-			rio_dprintk (RIO_DEBUG_CMD, "New status is 0x%x was 0x%x\n",
-				     RBYTE(PktCmdP->PortStatus),PortP->PortState);
-			if (PortP->PortState != RBYTE(PktCmdP->PortStatus)) {
-				rio_dprintk (RIO_DEBUG_CMD, "Mark status & wakeup\n");
-				PortP->PortState = RBYTE(PktCmdP->PortStatus);
-				/* What should we do here ...
-				wakeup( &PortP->PortState );
-				*/
-		} else 
-			rio_dprintk (RIO_DEBUG_CMD, "No change\n");
-
-			/* FALLTHROUGH */
-		case MODEM_STATUS:
+		/* FALLTHROUGH */
+	case MODEM_STATUS:
+		/*
+		 ** Knock out the tbusy and tstop bits, as these are not relevant
+		 ** to the check for modem status change (they're just there because
+		 ** it's a convenient place to put them!).
+		 */
+		ReportedModemStatus = RBYTE(PktCmdP->ModemStatus);
+		if ((PortP->ModemState & MSVR1_HOST) == (ReportedModemStatus & MSVR1_HOST)) {
+			rio_dprintk(RIO_DEBUG_CMD, "Modem status unchanged 0x%x\n", PortP->ModemState);
 			/*
-			** Knock out the tbusy and tstop bits, as these are not relevant
-			** to the check for modem status change (they're just there because
-			** it's a convenient place to put them!).
-			*/
-			ReportedModemStatus = RBYTE(PktCmdP->ModemStatus);
-			if ((PortP->ModemState & MSVR1_HOST) ==
-					(ReportedModemStatus & MSVR1_HOST)) {
-				rio_dprintk (RIO_DEBUG_CMD, "Modem status unchanged 0x%x\n", PortP->ModemState);
-				/*
-				** Update ModemState just in case tbusy or tstop states have
-				** changed.
-				*/
-				PortP->ModemState = ReportedModemStatus;
-			}
-			else {
-				rio_dprintk (RIO_DEBUG_CMD, "Modem status change from 0x%x to 0x%x\n",
-				     PortP->ModemState, ReportedModemStatus);
-				PortP->ModemState = ReportedModemStatus;
+			 ** Update ModemState just in case tbusy or tstop states have
+			 ** changed.
+			 */
+			PortP->ModemState = ReportedModemStatus;
+		} else {
+			rio_dprintk(RIO_DEBUG_CMD, "Modem status change from 0x%x to 0x%x\n", PortP->ModemState, ReportedModemStatus);
+			PortP->ModemState = ReportedModemStatus;
 #ifdef MODEM_SUPPORT
-				if ( PortP->Mapped ) {
+			if (PortP->Mapped) {
 				/***********************************************************\
 				*************************************************************
 				***													   ***
@@ -525,68 +501,67 @@
 				*************************************************************
 				\***********************************************************/
 				/*
-				** If the device is a modem, then check the modem
-				** carrier.
-				*/
+				 ** If the device is a modem, then check the modem
+				 ** carrier.
+				 */
 				if (PortP->gs.tty == NULL)
 					break;
 				if (PortP->gs.tty->termios == NULL)
 					break;
-			  
-				if (!(PortP->gs.tty->termios->c_cflag & CLOCAL) &&
-				((PortP->State & (RIO_MOPEN|RIO_WOPEN)))) {
 
-					rio_dprintk (RIO_DEBUG_CMD, "Is there a Carrier?\n");
-			/*
-			** Is there a carrier?
-			*/
-					if ( PortP->ModemState & MSVR1_CD ) {
-			/*
-			** Has carrier just appeared?
-			*/
+				if (!(PortP->gs.tty->termios->c_cflag & CLOCAL) && ((PortP->State & (RIO_MOPEN | RIO_WOPEN)))) {
+
+					rio_dprintk(RIO_DEBUG_CMD, "Is there a Carrier?\n");
+					/*
+					 ** Is there a carrier?
+					 */
+					if (PortP->ModemState & MSVR1_CD) {
+						/*
+						 ** Has carrier just appeared?
+						 */
 						if (!(PortP->State & RIO_CARR_ON)) {
-							rio_dprintk (RIO_DEBUG_CMD, "Carrier just came up.\n");
+							rio_dprintk(RIO_DEBUG_CMD, "Carrier just came up.\n");
 							PortP->State |= RIO_CARR_ON;
-				/*
-				** wakeup anyone in WOPEN
-				*/
-							if (PortP->State & (PORT_ISOPEN | RIO_WOPEN) )
-								wake_up_interruptible (&PortP->gs.open_wait);
+							/*
+							 ** wakeup anyone in WOPEN
+							 */
+							if (PortP->State & (PORT_ISOPEN | RIO_WOPEN))
+								wake_up_interruptible(&PortP->gs.open_wait);
 #ifdef STATS
-				PortP->Stat.ModemOnCnt++;
+							PortP->Stat.ModemOnCnt++;
 #endif
-			}
+						}
 					} else {
-			/*
-			** Has carrier just dropped?
-			*/
+						/*
+						 ** Has carrier just dropped?
+						 */
 						if (PortP->State & RIO_CARR_ON) {
-							if (PortP->State & (PORT_ISOPEN|RIO_WOPEN|RIO_MOPEN))
-								tty_hangup (PortP->gs.tty);
+							if (PortP->State & (PORT_ISOPEN | RIO_WOPEN | RIO_MOPEN))
+								tty_hangup(PortP->gs.tty);
 							PortP->State &= ~RIO_CARR_ON;
-							rio_dprintk (RIO_DEBUG_CMD, "Carrirer just went down\n");
+							rio_dprintk(RIO_DEBUG_CMD, "Carrirer just went down\n");
 #ifdef STATS
-				PortP->Stat.ModemOffCnt++;
+							PortP->Stat.ModemOffCnt++;
 #endif
+						}
+					}
+				}
 			}
-			}
-		}
-		}
 #endif
-			}
-			break;
+		}
+		break;
 
-		default:
-			rio_dprintk (RIO_DEBUG_CMD, "Unknown command %d on CMD_RUP of host %d\n",
-			     RBYTE(PktCmdP->Command),HostP-p->RIOHosts);
-			break;
+	default:
+		rio_dprintk(RIO_DEBUG_CMD, "Unknown command %d on CMD_RUP of host %d\n", RBYTE(PktCmdP->Command), HostP - p->RIOHosts);
+		break;
 	}
 	rio_spin_unlock_irqrestore(&PortP->portSem, flags);
 
-	func_exit ();
+	func_exit();
 
 	return TRUE;
 }
+
 /*
 ** The command mechanism:
 **	Each rup has a chain of commands associated with it.
@@ -600,12 +575,11 @@
 /*
 ** Allocate an empty command block.
 */
-struct CmdBlk *
-RIOGetCmdBlk(void)
+struct CmdBlk *RIOGetCmdBlk(void)
 {
 	struct CmdBlk *CmdBlkP;
 
-	CmdBlkP = (struct CmdBlk *)sysbrk(sizeof(struct CmdBlk));
+	CmdBlkP = (struct CmdBlk *) sysbrk(sizeof(struct CmdBlk));
 	if (CmdBlkP)
 		bzero(CmdBlkP, sizeof(struct CmdBlk));
 
@@ -615,31 +589,29 @@
 /*
 ** Return a block to the head of the free list.
 */
-void
-RIOFreeCmdBlk(struct CmdBlk *CmdBlkP)
+void RIOFreeCmdBlk(struct CmdBlk *CmdBlkP)
 {
-	sysfree((void *)CmdBlkP, sizeof(struct CmdBlk));
+	sysfree((void *) CmdBlkP, sizeof(struct CmdBlk));
 }
 
 /*
 ** attach a command block to the list of commands to be performed for
 ** a given rup.
 */
-int
-RIOQueueCmdBlk(struct Host *HostP, uint Rup, struct CmdBlk *CmdBlkP)
+int RIOQueueCmdBlk(struct Host *HostP, uint Rup, struct CmdBlk *CmdBlkP)
 {
 	struct CmdBlk **Base;
 	struct UnixRup *UnixRupP;
 	unsigned long flags;
 
 #ifdef CHECK
-	CheckHostP( HostP );
-	CheckRup( Rup );
-	CheckCmdBlkP( CmdBlkP );
+	CheckHostP(HostP);
+	CheckRup(Rup);
+	CheckCmdBlkP(CmdBlkP);
 #endif
-	if ( Rup >= (ushort)(MAX_RUP+LINKS_PER_UNIT) ) {
-		rio_dprintk (RIO_DEBUG_CMD, "Illegal rup number %d in RIOQueueCmdBlk\n",Rup);
-		RIOFreeCmdBlk( CmdBlkP );
+	if (Rup >= (ushort) (MAX_RUP + LINKS_PER_UNIT)) {
+		rio_dprintk(RIO_DEBUG_CMD, "Illegal rup number %d in RIOQueueCmdBlk\n", Rup);
+		RIOFreeCmdBlk(CmdBlkP);
 		return RIO_FAIL;
 	}
 
@@ -648,57 +620,52 @@
 	rio_spin_lock_irqsave(&UnixRupP->RupLock, flags);
 
 	/*
-	** If the RUP is currently inactive, then put the request
-	** straight on the RUP....
-	*/
-	if ( (UnixRupP->CmdsWaitingP == NULL) && (UnixRupP->CmdPendingP == NULL) && 
-	     (RWORD(UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE ) &&
-		(CmdBlkP->PreFuncP ? (*CmdBlkP->PreFuncP)(CmdBlkP->PreArg,CmdBlkP)
-							:TRUE)) {
-		rio_dprintk (RIO_DEBUG_CMD, "RUP inactive-placing command straight on. Cmd byte is 0x%x\n",
-					     CmdBlkP->Packet.data[0]);
+	 ** If the RUP is currently inactive, then put the request
+	 ** straight on the RUP....
+	 */
+	if ((UnixRupP->CmdsWaitingP == NULL) && (UnixRupP->CmdPendingP == NULL) && (RWORD(UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE) && (CmdBlkP->PreFuncP ? (*CmdBlkP->PreFuncP) (CmdBlkP->PreArg, CmdBlkP)
+																	     : TRUE)) {
+		rio_dprintk(RIO_DEBUG_CMD, "RUP inactive-placing command straight on. Cmd byte is 0x%x\n", CmdBlkP->Packet.data[0]);
 
 		/*
-		** Whammy! blat that pack!
-		*/
-		HostP->Copy( (caddr_t)&CmdBlkP->Packet, 
-			RIO_PTR(HostP->Caddr, UnixRupP->RupP->txpkt ), sizeof(PKT) );
+		 ** Whammy! blat that pack!
+		 */
+		HostP->Copy((caddr_t) & CmdBlkP->Packet, RIO_PTR(HostP->Caddr, UnixRupP->RupP->txpkt), sizeof(PKT));
 
 		/*
-		** place command packet on the pending position.
-		*/
+		 ** place command packet on the pending position.
+		 */
 		UnixRupP->CmdPendingP = CmdBlkP;
 
 		/*
-		** set the command register
-		*/
-		WWORD(UnixRupP->RupP->txcontrol , TX_PACKET_READY);
+		 ** set the command register
+		 */
+		WWORD(UnixRupP->RupP->txcontrol, TX_PACKET_READY);
 
 		rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags);
 
 		return RIO_SUCCESS;
 	}
-	rio_dprintk (RIO_DEBUG_CMD, "RUP active - en-queing\n");
+	rio_dprintk(RIO_DEBUG_CMD, "RUP active - en-queing\n");
 
-	if ( UnixRupP->CmdsWaitingP != NULL)
-		rio_dprintk (RIO_DEBUG_CMD, "Rup active - command waiting\n");
-	if ( UnixRupP->CmdPendingP != NULL )
-		rio_dprintk (RIO_DEBUG_CMD, "Rup active - command pending\n");
-	if ( RWORD(UnixRupP->RupP->txcontrol) != TX_RUP_INACTIVE )
-		rio_dprintk (RIO_DEBUG_CMD, "Rup active - command rup not ready\n");
+	if (UnixRupP->CmdsWaitingP != NULL)
+		rio_dprintk(RIO_DEBUG_CMD, "Rup active - command waiting\n");
+	if (UnixRupP->CmdPendingP != NULL)
+		rio_dprintk(RIO_DEBUG_CMD, "Rup active - command pending\n");
+	if (RWORD(UnixRupP->RupP->txcontrol) != TX_RUP_INACTIVE)
+		rio_dprintk(RIO_DEBUG_CMD, "Rup active - command rup not ready\n");
 
 	Base = &UnixRupP->CmdsWaitingP;
 
-	rio_dprintk (RIO_DEBUG_CMD, "First try to queue cmdblk 0x%x at 0x%x\n", (int)CmdBlkP,(int)Base);
+	rio_dprintk(RIO_DEBUG_CMD, "First try to queue cmdblk 0x%x at 0x%x\n", (int) CmdBlkP, (int) Base);
 
-	while ( *Base ) {
-		rio_dprintk (RIO_DEBUG_CMD, "Command cmdblk 0x%x here\n", (int)(*Base));
+	while (*Base) {
+		rio_dprintk(RIO_DEBUG_CMD, "Command cmdblk 0x%x here\n", (int) (*Base));
 		Base = &((*Base)->NextP);
-		rio_dprintk (RIO_DEBUG_CMD, "Now try to queue cmd cmdblk 0x%x at 0x%x\n",
-					     (int)CmdBlkP,(int)Base);
+		rio_dprintk(RIO_DEBUG_CMD, "Now try to queue cmd cmdblk 0x%x at 0x%x\n", (int) CmdBlkP, (int) Base);
 	}
 
-	rio_dprintk (RIO_DEBUG_CMD, "Will queue cmdblk 0x%x at 0x%x\n",(int)CmdBlkP,(int)Base);
+	rio_dprintk(RIO_DEBUG_CMD, "Will queue cmdblk 0x%x at 0x%x\n", (int) CmdBlkP, (int) Base);
 
 	*Base = CmdBlkP;
 
@@ -713,8 +680,7 @@
 ** Here we go - if there is an empty rup, fill it!
 ** must be called at splrio() or higher.
 */
-void
-RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
+void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
 {
 	register struct CmdBlk *CmdBlkP;
 	register struct UnixRup *UnixRupP;
@@ -723,262 +689,246 @@
 	unsigned long flags;
 
 
-	Rup = MAX_RUP+LINKS_PER_UNIT;
+	Rup = MAX_RUP + LINKS_PER_UNIT;
 
-	do {	/* do this loop for each RUP */
+	do {			/* do this loop for each RUP */
 		/*
-		** locate the rup we are processing & lock it
-		*/
+		 ** locate the rup we are processing & lock it
+		 */
 		UnixRupP = &HostP->UnixRups[--Rup];
 
 		spin_lock_irqsave(&UnixRupP->RupLock, flags);
 
 		/*
-		** First check for incoming commands:
-		*/
-		if ( RWORD(UnixRupP->RupP->rxcontrol) != RX_RUP_INACTIVE ) {
+		 ** First check for incoming commands:
+		 */
+		if (RWORD(UnixRupP->RupP->rxcontrol) != RX_RUP_INACTIVE) {
 			int FreeMe;
 
-			PacketP =(PKT *)RIO_PTR(HostP->Caddr,RWORD(UnixRupP->RupP->rxpkt));
+			PacketP = (PKT *) RIO_PTR(HostP->Caddr, RWORD(UnixRupP->RupP->rxpkt));
 
-			ShowPacket( DBG_CMD, PacketP );
+			ShowPacket(DBG_CMD, PacketP);
 
-			switch ( RBYTE(PacketP->dest_port) ) {
-				case BOOT_RUP:
-					rio_dprintk (RIO_DEBUG_CMD, "Incoming Boot %s packet '%x'\n", 
-						RBYTE(PacketP->len) & 0x80 ? "Command":"Data", 
-							     RBYTE(PacketP->data[0])); 
-					rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags);
-					FreeMe= RIOBootRup(p, Rup,HostP,PacketP);
-					rio_spin_lock_irqsave(&UnixRupP->RupLock, flags);
-					break;
+			switch (RBYTE(PacketP->dest_port)) {
+			case BOOT_RUP:
+				rio_dprintk(RIO_DEBUG_CMD, "Incoming Boot %s packet '%x'\n", RBYTE(PacketP->len) & 0x80 ? "Command" : "Data", RBYTE(PacketP->data[0]));
+				rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags);
+				FreeMe = RIOBootRup(p, Rup, HostP, PacketP);
+				rio_spin_lock_irqsave(&UnixRupP->RupLock, flags);
+				break;
 
-				case COMMAND_RUP:
-					/*
-					** Free the RUP lock as loss of carrier causes a
-					** ttyflush which will (eventually) call another
-					** routine that uses the RUP lock.
-					*/
-					rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags);
-					FreeMe= RIOCommandRup(p, Rup,HostP,PacketP);
-					if (PacketP->data[5] == MEMDUMP) {
-						rio_dprintk (RIO_DEBUG_CMD, "Memdump from 0x%x complete\n",
-								     *(ushort *) &(PacketP->data[6]));
-						HostP->Copy( (caddr_t)&(PacketP->data[8]), 
-								(caddr_t)p->RIOMemDump, 32 );
-					}
-					rio_spin_lock_irqsave(&UnixRupP->RupLock, flags);
-					break;
+			case COMMAND_RUP:
+				/*
+				 ** Free the RUP lock as loss of carrier causes a
+				 ** ttyflush which will (eventually) call another
+				 ** routine that uses the RUP lock.
+				 */
+				rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags);
+				FreeMe = RIOCommandRup(p, Rup, HostP, PacketP);
+				if (PacketP->data[5] == MEMDUMP) {
+					rio_dprintk(RIO_DEBUG_CMD, "Memdump from 0x%x complete\n", *(ushort *) & (PacketP->data[6]));
+					HostP->Copy((caddr_t) & (PacketP->data[8]), (caddr_t) p->RIOMemDump, 32);
+				}
+				rio_spin_lock_irqsave(&UnixRupP->RupLock, flags);
+				break;
 
-				case ROUTE_RUP:
-					rio_spin_unlock_irqrestore( &UnixRupP->RupLock, flags);
-					FreeMe = RIORouteRup(p, Rup, HostP, PacketP );
-					rio_spin_lock_irqsave( &UnixRupP->RupLock, flags );
-					break;
+			case ROUTE_RUP:
+				rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags);
+				FreeMe = RIORouteRup(p, Rup, HostP, PacketP);
+				rio_spin_lock_irqsave(&UnixRupP->RupLock, flags);
+				break;
 
-				default:
-					rio_dprintk (RIO_DEBUG_CMD, "Unknown RUP %d\n", RBYTE(PacketP->dest_port));
-					FreeMe = 1;
-					break;
+			default:
+				rio_dprintk(RIO_DEBUG_CMD, "Unknown RUP %d\n", RBYTE(PacketP->dest_port));
+				FreeMe = 1;
+				break;
 			}
 
-			if ( FreeMe ) {
-				rio_dprintk (RIO_DEBUG_CMD, "Free processed incoming command packet\n");
-				put_free_end(HostP,PacketP);
+			if (FreeMe) {
+				rio_dprintk(RIO_DEBUG_CMD, "Free processed incoming command packet\n");
+				put_free_end(HostP, PacketP);
 
-				WWORD(UnixRupP->RupP->rxcontrol , RX_RUP_INACTIVE);
+				WWORD(UnixRupP->RupP->rxcontrol, RX_RUP_INACTIVE);
 
-				if ( RWORD(UnixRupP->RupP->handshake)==PHB_HANDSHAKE_SET ) {
-					rio_dprintk (RIO_DEBUG_CMD, "Handshake rup %d\n",Rup);
-					WWORD(UnixRupP->RupP->handshake,
-						PHB_HANDSHAKE_SET|PHB_HANDSHAKE_RESET);
+				if (RWORD(UnixRupP->RupP->handshake) == PHB_HANDSHAKE_SET) {
+					rio_dprintk(RIO_DEBUG_CMD, "Handshake rup %d\n", Rup);
+					WWORD(UnixRupP->RupP->handshake, PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET);
 				}
 			}
 		}
 
 		/*
-		** IF a command was running on the port, 
-		** and it has completed, then tidy it up.
-		*/
-		if ( (CmdBlkP = UnixRupP->CmdPendingP) && /* ASSIGN! */
-		     (RWORD(UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE)) {
+		 ** IF a command was running on the port,
+		 ** and it has completed, then tidy it up.
+		 */
+		if ((CmdBlkP = UnixRupP->CmdPendingP) &&	/* ASSIGN! */
+		    (RWORD(UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE)) {
 			/*
-			** we are idle.
-			** there is a command in pending.
-			** Therefore, this command has finished.
-			** So, wakeup whoever is waiting for it (and tell them
-			** what happened).
-			*/
-			if ( CmdBlkP->Packet.dest_port == BOOT_RUP )
-				rio_dprintk (RIO_DEBUG_CMD, "Free Boot %s Command Block '%x'\n", 
-						CmdBlkP->Packet.len & 0x80 ? "Command":"Data", 
-							     CmdBlkP->Packet.data[0]);
+			 ** we are idle.
+			 ** there is a command in pending.
+			 ** Therefore, this command has finished.
+			 ** So, wakeup whoever is waiting for it (and tell them
+			 ** what happened).
+			 */
+			if (CmdBlkP->Packet.dest_port == BOOT_RUP)
+				rio_dprintk(RIO_DEBUG_CMD, "Free Boot %s Command Block '%x'\n", CmdBlkP->Packet.len & 0x80 ? "Command" : "Data", CmdBlkP->Packet.data[0]);
 
-			rio_dprintk (RIO_DEBUG_CMD, "Command 0x%x completed\n",(int)CmdBlkP);
+			rio_dprintk(RIO_DEBUG_CMD, "Command 0x%x completed\n", (int) CmdBlkP);
 
 			/*
-			** Clear the Rup lock to prevent mutual exclusion.
-			*/
-			if ( CmdBlkP->PostFuncP ) {
+			 ** Clear the Rup lock to prevent mutual exclusion.
+			 */
+			if (CmdBlkP->PostFuncP) {
 				rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags);
-				(*CmdBlkP->PostFuncP) (CmdBlkP->PostArg,CmdBlkP);
+				(*CmdBlkP->PostFuncP) (CmdBlkP->PostArg, CmdBlkP);
 				rio_spin_lock_irqsave(&UnixRupP->RupLock, flags);
 			}
 
 			/*
-			** ....clear the pending flag....
-			*/
+			 ** ....clear the pending flag....
+			 */
 			UnixRupP->CmdPendingP = NULL;
 
 			/*
-			** ....and return the command block to the freelist.
-			*/
-			RIOFreeCmdBlk( CmdBlkP );
+			 ** ....and return the command block to the freelist.
+			 */
+			RIOFreeCmdBlk(CmdBlkP);
 		}
 
 		/*
-		** If there is a command for this rup, and the rup
-		** is idle, then process the command
-		*/
-		if ( (CmdBlkP = UnixRupP->CmdsWaitingP) && /* ASSIGN! */
-			(UnixRupP->CmdPendingP == NULL) &&
-		     (RWORD(UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE)) {
+		 ** If there is a command for this rup, and the rup
+		 ** is idle, then process the command
+		 */
+		if ((CmdBlkP = UnixRupP->CmdsWaitingP) &&	/* ASSIGN! */
+		    (UnixRupP->CmdPendingP == NULL) && (RWORD(UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE)) {
 			/*
-			** if the pre-function is non-zero, call it.
-			** If it returns RIO_FAIL then don't
-			** send this command yet!
-			*/
+			 ** if the pre-function is non-zero, call it.
+			 ** If it returns RIO_FAIL then don't
+			 ** send this command yet!
+			 */
 #ifdef CHECK
-			CheckCmdBlkP (CmdBlkP);
+			CheckCmdBlkP(CmdBlkP);
 #endif
-			if ( !(CmdBlkP->PreFuncP ?
-				(*CmdBlkP->PreFuncP)(CmdBlkP->PreArg, CmdBlkP) : TRUE)) {
-				rio_dprintk (RIO_DEBUG_CMD, "Not ready to start command 0x%x\n",(int)CmdBlkP);
-			}
-			else {
-				rio_dprintk (RIO_DEBUG_CMD, "Start new command 0x%x Cmd byte is 0x%x\n",
-							     (int)CmdBlkP, CmdBlkP->Packet.data[0]);
+			if (!(CmdBlkP->PreFuncP ? (*CmdBlkP->PreFuncP) (CmdBlkP->PreArg, CmdBlkP) : TRUE)) {
+				rio_dprintk(RIO_DEBUG_CMD, "Not ready to start command 0x%x\n", (int) CmdBlkP);
+			} else {
+				rio_dprintk(RIO_DEBUG_CMD, "Start new command 0x%x Cmd byte is 0x%x\n", (int) CmdBlkP, CmdBlkP->Packet.data[0]);
 				/*
-				** Whammy! blat that pack!
-				*/
+				 ** Whammy! blat that pack!
+				 */
 #ifdef CHECK
-				CheckPacketP ((PKT *)RIO_PTR(HostP->Caddr, UnixRupP->RupP->txpkt));
+				CheckPacketP((PKT *) RIO_PTR(HostP->Caddr, UnixRupP->RupP->txpkt));
 #endif
-				HostP->Copy( (caddr_t)&CmdBlkP->Packet, 
-					RIO_PTR(HostP->Caddr, UnixRupP->RupP->txpkt), sizeof(PKT));
+				HostP->Copy((caddr_t) & CmdBlkP->Packet, RIO_PTR(HostP->Caddr, UnixRupP->RupP->txpkt), sizeof(PKT));
 
 				/*
-				** remove the command from the rup command queue...
-				*/
+				 ** remove the command from the rup command queue...
+				 */
 				UnixRupP->CmdsWaitingP = CmdBlkP->NextP;
 
 				/*
-				** ...and place it on the pending position.
-				*/
+				 ** ...and place it on the pending position.
+				 */
 				UnixRupP->CmdPendingP = CmdBlkP;
 
 				/*
-				** set the command register
-				*/
-				WWORD(UnixRupP->RupP->txcontrol,TX_PACKET_READY);
+				 ** set the command register
+				 */
+				WWORD(UnixRupP->RupP->txcontrol, TX_PACKET_READY);
 
 				/*
-				** the command block will be freed
-				** when the command has been processed.
-				*/
+				 ** the command block will be freed
+				 ** when the command has been processed.
+				 */
 			}
 		}
 		spin_unlock_irqrestore(&UnixRupP->RupLock, flags);
-	} while ( Rup );
+	} while (Rup);
 }
 
-int
-RIOWFlushMark(int iPortP, struct CmdBlk *CmdBlkP)
+int RIOWFlushMark(int iPortP, struct CmdBlk *CmdBlkP)
 {
-	struct Port *	PortP = (struct Port *)iPortP;
+	struct Port *PortP = (struct Port *) iPortP;
 	unsigned long flags;
 
 	rio_spin_lock_irqsave(&PortP->portSem, flags);
 #ifdef CHECK
-	CheckPortP( PortP );
+	CheckPortP(PortP);
 #endif
 	PortP->WflushFlag++;
 	PortP->MagicFlags |= MAGIC_FLUSH;
 	rio_spin_unlock_irqrestore(&PortP->portSem, flags);
-	return RIOUnUse( iPortP, CmdBlkP );
+	return RIOUnUse(iPortP, CmdBlkP);
 }
 
-int
-RIORFlushEnable(int iPortP, struct CmdBlk *CmdBlkP)
+int RIORFlushEnable(int iPortP, struct CmdBlk *CmdBlkP)
 {
-	struct Port *	PortP = (struct Port *)iPortP;
+	struct Port *PortP = (struct Port *) iPortP;
 	PKT *PacketP;
 	unsigned long flags;
 
 	rio_spin_lock_irqsave(&PortP->portSem, flags);
 
-	while ( can_remove_receive(&PacketP, PortP) ) {
+	while (can_remove_receive(&PacketP, PortP)) {
 		remove_receive(PortP);
-		ShowPacket(DBG_PROC, PacketP );
-		put_free_end( PortP->HostP, PacketP );
+		ShowPacket(DBG_PROC, PacketP);
+		put_free_end(PortP->HostP, PacketP);
 	}
 
-	if ( RWORD(PortP->PhbP->handshake)==PHB_HANDSHAKE_SET ) {
+	if (RWORD(PortP->PhbP->handshake) == PHB_HANDSHAKE_SET) {
 		/*
-		** MAGIC! (Basically, handshake the RX buffer, so that
-		** the RTAs upstream can be re-enabled.)
-		*/
-		rio_dprintk (RIO_DEBUG_CMD, "Util: Set RX handshake bit\n");
-		WWORD(PortP->PhbP->handshake, PHB_HANDSHAKE_SET|PHB_HANDSHAKE_RESET);
+		 ** MAGIC! (Basically, handshake the RX buffer, so that
+		 ** the RTAs upstream can be re-enabled.)
+		 */
+		rio_dprintk(RIO_DEBUG_CMD, "Util: Set RX handshake bit\n");
+		WWORD(PortP->PhbP->handshake, PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET);
 	}
 	rio_spin_unlock_irqrestore(&PortP->portSem, flags);
-	return RIOUnUse( iPortP, CmdBlkP );
+	return RIOUnUse(iPortP, CmdBlkP);
 }
 
-int
-RIOUnUse(int iPortP, struct CmdBlk *CmdBlkP)
+int RIOUnUse(int iPortP, struct CmdBlk *CmdBlkP)
 {
-	struct Port *	PortP = (struct Port *)iPortP;
+	struct Port *PortP = (struct Port *) iPortP;
 	unsigned long flags;
 
 	rio_spin_lock_irqsave(&PortP->portSem, flags);
 
 #ifdef CHECK
-	CheckPortP( PortP );
+	CheckPortP(PortP);
 #endif
-	rio_dprintk (RIO_DEBUG_CMD, "Decrement in use count for port\n");
+	rio_dprintk(RIO_DEBUG_CMD, "Decrement in use count for port\n");
 
 	if (PortP->InUse) {
-		if ( --PortP->InUse != NOT_INUSE ) {
+		if (--PortP->InUse != NOT_INUSE) {
 			rio_spin_unlock_irqrestore(&PortP->portSem, flags);
 			return 0;
 		}
 	}
 	/*
-	** While PortP->InUse is set (i.e. a preemptive command has been sent to
-	** the RTA and is awaiting completion), any transmit data is prevented from
-	** being transferred from the write queue into the transmit packets
-	** (add_transmit) and no furthur transmit interrupt will be sent for that
-	** data. The next interrupt will occur up to 500ms later (RIOIntr is called
-	** twice a second as a saftey measure). This was the case when kermit was
-	** used to send data into a RIO port. After each packet was sent, TCFLSH
-	** was called to flush the read queue preemptively. PortP->InUse was
-	** incremented, thereby blocking the 6 byte acknowledgement packet
-	** transmitted back. This acknowledgment hung around for 500ms before
-	** being sent, thus reducing input performance substantially!.
-	** When PortP->InUse becomes NOT_INUSE, we must ensure that any data
-	** hanging around in the transmit buffer is sent immediately.
-	*/
+	 ** While PortP->InUse is set (i.e. a preemptive command has been sent to
+	 ** the RTA and is awaiting completion), any transmit data is prevented from
+	 ** being transferred from the write queue into the transmit packets
+	 ** (add_transmit) and no furthur transmit interrupt will be sent for that
+	 ** data. The next interrupt will occur up to 500ms later (RIOIntr is called
+	 ** twice a second as a saftey measure). This was the case when kermit was
+	 ** used to send data into a RIO port. After each packet was sent, TCFLSH
+	 ** was called to flush the read queue preemptively. PortP->InUse was
+	 ** incremented, thereby blocking the 6 byte acknowledgement packet
+	 ** transmitted back. This acknowledgment hung around for 500ms before
+	 ** being sent, thus reducing input performance substantially!.
+	 ** When PortP->InUse becomes NOT_INUSE, we must ensure that any data
+	 ** hanging around in the transmit buffer is sent immediately.
+	 */
 	WWORD(PortP->HostP->ParmMapP->tx_intr, 1);
 	/* What to do here ..
-	wakeup( (caddr_t)&(PortP->InUse) );
-	*/
+	   wakeup( (caddr_t)&(PortP->InUse) );
+	 */
 	rio_spin_unlock_irqrestore(&PortP->portSem, flags);
 	return 0;
 }
 
-void
-ShowPacket(uint Flags, struct PKT *PacketP)
+void ShowPacket(uint Flags, struct PKT *PacketP)
 {
 }
 
diff --git a/drivers/char/rio/rioctrl.c b/drivers/char/rio/rioctrl.c
index b4d1a23..0b7700d 100644
--- a/drivers/char/rio/rioctrl.c
+++ b/drivers/char/rio/rioctrl.c
@@ -82,16 +82,16 @@
 #include "rioioctl.h"
 
 
-static struct LpbReq	 LpbReq;
-static struct RupReq	 RupReq;
-static struct PortReq	PortReq;
-static struct HostReq	HostReq;
+static struct LpbReq LpbReq;
+static struct RupReq RupReq;
+static struct PortReq PortReq;
+static struct HostReq HostReq;
 static struct HostDpRam HostDpRam;
 static struct DebugCtrl DebugCtrl;
-static struct Map		 MapEnt;
+static struct Map MapEnt;
 static struct PortSetup PortSetup;
-static struct DownLoad	DownLoad;
-static struct SendPack  SendPack;
+static struct DownLoad DownLoad;
+static struct SendPack SendPack;
 /* static struct StreamInfo	StreamInfo; */
 /* static char modemtable[RIO_PORTS]; */
 static struct SpecialRupCmd SpecialRupCmd;
@@ -99,18 +99,18 @@
 static struct portStats portStats;
 
 static struct SubCmdStruct {
-	ushort	Host;
-	ushort	Rup;
-	ushort	Port;
-	ushort	Addr;
+	ushort Host;
+	ushort Rup;
+	ushort Port;
+	ushort Addr;
 } SubCmd;
 
 struct PortTty {
-	uint		port;
-	struct ttystatics	Tty;
+	uint port;
+	struct ttystatics Tty;
 };
 
-static struct PortTty	PortTty;
+static struct PortTty PortTty;
 typedef struct ttystatics TERMIO;
 
 /*
@@ -121,267 +121,264 @@
 ** The RIOBootCodeUNKNOWN entry is there to politely tell the calling
 ** process to bog off.
 */
-static int 
-(*RIOBootTable[MAX_PRODUCT])(struct rio_info *, struct DownLoad *) =
-{
-/* 0 */	RIOBootCodeHOST,	/* Host Card */
-/* 1 */	RIOBootCodeRTA,		/* RTA */
+static int
+ (*RIOBootTable[MAX_PRODUCT]) (struct rio_info *, struct DownLoad *) = {
+					/* 0 */ RIOBootCodeHOST,
+					/* Host Card */
+					/* 1 */ RIOBootCodeRTA,
+					/* RTA */
 };
 
 #define drv_makedev(maj, min) ((((uint) maj & 0xff) << 8) | ((uint) min & 0xff))
 
-int copyin (int arg, caddr_t dp, int siz)
+int copyin(int arg, caddr_t dp, int siz)
 {
-  int rv;
+	int rv;
 
-  rio_dprintk (RIO_DEBUG_CTRL, "Copying %d bytes from user %p to %p.\n", siz, (void *)arg, dp);
-  rv = copy_from_user (dp, (void *)arg, siz);
-  if (rv) return COPYFAIL;
-  else return rv;
+	rio_dprintk(RIO_DEBUG_CTRL, "Copying %d bytes from user %p to %p.\n", siz, (void *) arg, dp);
+	rv = copy_from_user(dp, (void *) arg, siz);
+	if (rv)
+		return COPYFAIL;
+	else
+		return rv;
 }
 
-static int copyout (caddr_t dp, int arg, int siz)
+static int copyout(caddr_t dp, int arg, int siz)
 {
-  int rv;
+	int rv;
 
-  rio_dprintk (RIO_DEBUG_CTRL, "Copying %d bytes to user %p from %p.\n", siz, (void *)arg, dp);
-  rv = copy_to_user ((void *)arg, dp, siz);
-  if (rv) return COPYFAIL;
-  else return rv;
+	rio_dprintk(RIO_DEBUG_CTRL, "Copying %d bytes to user %p from %p.\n", siz, (void *) arg, dp);
+	rv = copy_to_user((void *) arg, dp, siz);
+	if (rv)
+		return COPYFAIL;
+	else
+		return rv;
 }
 
-int
-riocontrol(p, dev, cmd, arg, su)
-struct rio_info	* p;
-dev_t		dev;
-int		cmd;
-caddr_t		arg;
-int		su;
+int riocontrol(p, dev, cmd, arg, su)
+struct rio_info *p;
+dev_t dev;
+int cmd;
+caddr_t arg;
+int su;
 {
-	uint	Host;	/* leave me unsigned! */
-	uint	port;	/* and me! */
-	struct Host	*HostP;
-	ushort	loop;
-	int		Entry;
-	struct Port	*PortP;
-	PKT	*PacketP;
-	int		retval = 0;
+	uint Host;		/* leave me unsigned! */
+	uint port;		/* and me! */
+	struct Host *HostP;
+	ushort loop;
+	int Entry;
+	struct Port *PortP;
+	PKT *PacketP;
+	int retval = 0;
 	unsigned long flags;
-	
-	func_enter ();
-	
+
+	func_enter();
+
 	/* Confuse the compiler to think that we've initialized these */
-	Host=0;
+	Host = 0;
 	PortP = NULL;
 
-	rio_dprintk (RIO_DEBUG_CTRL, "control ioctl cmd: 0x%x arg: 0x%x\n", cmd, (int)arg);
+	rio_dprintk(RIO_DEBUG_CTRL, "control ioctl cmd: 0x%x arg: 0x%x\n", cmd, (int) arg);
 
 	switch (cmd) {
 		/*
-		** RIO_SET_TIMER
-		**
-		** Change the value of the host card interrupt timer.
-		** If the host card number is -1 then all host cards are changed
-		** otherwise just the specified host card will be changed.
-		*/
-		case RIO_SET_TIMER:
-			rio_dprintk (RIO_DEBUG_CTRL, "RIO_SET_TIMER to %dms\n", (uint)arg);
-			{
-				int host, value;
-				host = (uint)arg >> 16;
-				value = (uint)arg & 0x0000ffff;
-				if (host == -1) {
-					for (host = 0; host < p->RIONumHosts; host++) {
-						if (p->RIOHosts[host].Flags == RC_RUNNING) {
-							WWORD(p->RIOHosts[host].ParmMapP->timer , value);
-						}
-					}
-				} else if (host >= p->RIONumHosts) {
-					return -EINVAL;
-				} else {
-					if ( p->RIOHosts[host].Flags == RC_RUNNING ) {
-						WWORD(p->RIOHosts[host].ParmMapP->timer , value);
+		 ** RIO_SET_TIMER
+		 **
+		 ** Change the value of the host card interrupt timer.
+		 ** If the host card number is -1 then all host cards are changed
+		 ** otherwise just the specified host card will be changed.
+		 */
+	case RIO_SET_TIMER:
+		rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET_TIMER to %dms\n", (uint) arg);
+		{
+			int host, value;
+			host = (uint) arg >> 16;
+			value = (uint) arg & 0x0000ffff;
+			if (host == -1) {
+				for (host = 0; host < p->RIONumHosts; host++) {
+					if (p->RIOHosts[host].Flags == RC_RUNNING) {
+						WWORD(p->RIOHosts[host].ParmMapP->timer, value);
 					}
 				}
-			}
-			return 0;
-
-		case RIO_IDENTIFY_DRIVER:
-			/*
-			** 15.10.1998 ARG - ESIL 0760 part fix
-			** Added driver ident string output.
-			**
-#ifndef __THIS_RELEASE__
-#warning Driver Version string not defined !
-#endif
-			cprintf("%s %s %s %s\n",
-				RIO_DRV_STR,
-				__THIS_RELEASE__,
-				__DATE__, __TIME__ );
-
-			return 0;
-
-		case RIO_DISPLAY_HOST_CFG:
-			**
-			** 15.10.1998 ARG - ESIL 0760 part fix
-			** Added driver host card ident string output.
-			**
-			** Note that the only types currently supported
-			** are ISA and PCI. Also this driver does not
-			** (yet) distinguish between the Old PCI card
-			** and the Jet PCI card. In fact I think this
-			** driver only supports JET PCI !
-			**
-
-			for (Host = 0; Host < p->RIONumHosts; Host++)
-			{
-				HostP = &(p->RIOHosts[Host]);
-
-				switch ( HostP->Type )
-				{
-				    case RIO_AT :
-					strcpy( host_type, RIO_AT_HOST_STR );
-					break;
-
-				    case RIO_PCI :
-					strcpy( host_type, RIO_PCI_HOST_STR );
-					break;
-
-				    default :
-					strcpy( host_type, "Unknown" );
-					break;
-				}
-
-				cprintf(
-				  "RIO Host %d - Type:%s Addr:%X IRQ:%d\n",
-					Host, host_type,
-					(uint)HostP->PaddrP,
-					(int)HostP->Ivec - 32  );
-			}
-			return 0;
-			**
-			*/
-
-		case RIO_FOAD_RTA:
-			rio_dprintk (RIO_DEBUG_CTRL, "RIO_FOAD_RTA\n");
-			return RIOCommandRta(p, (uint)arg, RIOFoadRta);
-
-		case RIO_ZOMBIE_RTA:
-			rio_dprintk (RIO_DEBUG_CTRL, "RIO_ZOMBIE_RTA\n");
-			return RIOCommandRta(p, (uint)arg, RIOZombieRta);
-
-		case RIO_IDENTIFY_RTA:
-			rio_dprintk (RIO_DEBUG_CTRL, "RIO_IDENTIFY_RTA\n");
-			return RIOIdentifyRta(p, arg);
-
-		case RIO_KILL_NEIGHBOUR:
-			rio_dprintk (RIO_DEBUG_CTRL, "RIO_KILL_NEIGHBOUR\n");
-			return RIOKillNeighbour(p, arg);
-
-		case SPECIAL_RUP_CMD:
-			{
-				struct CmdBlk *CmdBlkP;
-
-				rio_dprintk (RIO_DEBUG_CTRL, "SPECIAL_RUP_CMD\n");
-				if (copyin((int)arg, (caddr_t)&SpecialRupCmd, 
-							sizeof(SpecialRupCmd)) == COPYFAIL ) {
-					rio_dprintk (RIO_DEBUG_CTRL, "SPECIAL_RUP_CMD copy failed\n");
-					p->RIOError.Error = COPYIN_FAILED;
-		 			return -EFAULT;
-				}
-				CmdBlkP = RIOGetCmdBlk();
-				if ( !CmdBlkP ) {
-					rio_dprintk (RIO_DEBUG_CTRL, "SPECIAL_RUP_CMD GetCmdBlk failed\n");
-					return -ENXIO;
-				}
-				CmdBlkP->Packet = SpecialRupCmd.Packet;
-				if ( SpecialRupCmd.Host >= p->RIONumHosts )
-					SpecialRupCmd.Host = 0;
-					rio_dprintk (RIO_DEBUG_CTRL, "Queue special rup command for host %d rup %d\n",
-						SpecialRupCmd.Host, SpecialRupCmd.RupNum);
-					if (RIOQueueCmdBlk(&p->RIOHosts[SpecialRupCmd.Host], 
-							SpecialRupCmd.RupNum, CmdBlkP) == RIO_FAIL) {
-						cprintf("FAILED TO QUEUE SPECIAL RUP COMMAND\n");
-					}
-					return 0;
-				}
-
-			case RIO_DEBUG_MEM:
-#ifdef DEBUG_MEM_SUPPORT
-RIO_DEBUG_CTRL, 				if (su)
-					return rio_RIODebugMemory(RIO_DEBUG_CTRL, arg);
-				else
-#endif
-					return -EPERM;
-
-			case RIO_ALL_MODEM:
-				rio_dprintk (RIO_DEBUG_CTRL, "RIO_ALL_MODEM\n");
-				p->RIOError.Error = IOCTL_COMMAND_UNKNOWN;
+			} else if (host >= p->RIONumHosts) {
 				return -EINVAL;
-
-			case RIO_GET_TABLE:
-				/*
-				** Read the routing table from the device driver to user space
-				*/
-				rio_dprintk (RIO_DEBUG_CTRL, "RIO_GET_TABLE\n");
-
-				if ((retval = RIOApel(p)) != 0)
-		 			return retval;
-
-				if (copyout((caddr_t)p->RIOConnectTable, (int)arg,
-						TOTAL_MAP_ENTRIES*sizeof(struct Map)) == COPYFAIL) {
-		 			rio_dprintk (RIO_DEBUG_CTRL, "RIO_GET_TABLE copy failed\n");
-		 			p->RIOError.Error = COPYOUT_FAILED;
-		 			return -EFAULT;
+			} else {
+				if (p->RIOHosts[host].Flags == RC_RUNNING) {
+					WWORD(p->RIOHosts[host].ParmMapP->timer, value);
 				}
+			}
+		}
+		return 0;
 
-				{
-					int entry;
-					rio_dprintk (RIO_DEBUG_CTRL,  "*****\nMAP ENTRIES\n");
-					for ( entry=0; entry<TOTAL_MAP_ENTRIES; entry++ )
-					{
-					  if ((p->RIOConnectTable[entry].ID == 0) &&
-					      (p->RIOConnectTable[entry].HostUniqueNum == 0) &&
-					      (p->RIOConnectTable[entry].RtaUniqueNum == 0)) continue;
-					      
-						rio_dprintk (RIO_DEBUG_CTRL, "Map entry %d.HostUniqueNum = 0x%x\n", entry, p->RIOConnectTable[entry].HostUniqueNum );
-						rio_dprintk (RIO_DEBUG_CTRL, "Map entry %d.RtaUniqueNum = 0x%x\n", entry, p->RIOConnectTable[entry].RtaUniqueNum );
-						rio_dprintk (RIO_DEBUG_CTRL, "Map entry %d.ID = 0x%x\n", entry, p->RIOConnectTable[entry].ID );
-						rio_dprintk (RIO_DEBUG_CTRL, "Map entry %d.ID2 = 0x%x\n", entry, p->RIOConnectTable[entry].ID2 );
-						rio_dprintk (RIO_DEBUG_CTRL, "Map entry %d.Flags = 0x%x\n", entry, (int)p->RIOConnectTable[entry].Flags );
-						rio_dprintk (RIO_DEBUG_CTRL, "Map entry %d.SysPort = 0x%x\n", entry, (int)p->RIOConnectTable[entry].SysPort );
-						rio_dprintk (RIO_DEBUG_CTRL, "Map entry %d.Top[0].Unit = %x\n", entry, p->RIOConnectTable[entry].Topology[0].Unit );
-						rio_dprintk (RIO_DEBUG_CTRL, "Map entry %d.Top[0].Link = %x\n", entry, p->RIOConnectTable[entry].Topology[0].Link );
-						rio_dprintk (RIO_DEBUG_CTRL, "Map entry %d.Top[1].Unit = %x\n", entry, p->RIOConnectTable[entry].Topology[1].Unit );
-						rio_dprintk (RIO_DEBUG_CTRL, "Map entry %d.Top[1].Link = %x\n", entry, p->RIOConnectTable[entry].Topology[1].Link );
-						rio_dprintk (RIO_DEBUG_CTRL, "Map entry %d.Top[2].Unit = %x\n", entry, p->RIOConnectTable[entry].Topology[2].Unit );
-						rio_dprintk (RIO_DEBUG_CTRL, "Map entry %d.Top[2].Link = %x\n", entry, p->RIOConnectTable[entry].Topology[2].Link );
-						rio_dprintk (RIO_DEBUG_CTRL, "Map entry %d.Top[3].Unit = %x\n", entry, p->RIOConnectTable[entry].Topology[3].Unit );
-						rio_dprintk (RIO_DEBUG_CTRL, "Map entry %d.Top[4].Link = %x\n", entry, p->RIOConnectTable[entry].Topology[3].Link );
-						rio_dprintk (RIO_DEBUG_CTRL, "Map entry %d.Name = %s\n", entry, p->RIOConnectTable[entry].Name );
-					}
-					rio_dprintk (RIO_DEBUG_CTRL,  "*****\nEND MAP ENTRIES\n");
-				}
-				p->RIOQuickCheck = NOT_CHANGED;	/* a table has been gotten */
-				return 0;
+	case RIO_IDENTIFY_DRIVER:
+		/*
+		 ** 15.10.1998 ARG - ESIL 0760 part fix
+		 ** Added driver ident string output.
+		 **
+		 #ifndef __THIS_RELEASE__
+		 #warning Driver Version string not defined !
+		 #endif
+		 cprintf("%s %s %s %s\n",
+		 RIO_DRV_STR,
+		 __THIS_RELEASE__,
+		 __DATE__, __TIME__ );
 
-			case RIO_PUT_TABLE:
-				/*
-				** Write the routing table to the device driver from user space
-				*/
-				rio_dprintk (RIO_DEBUG_CTRL, "RIO_PUT_TABLE\n");
+		 return 0;
 
-				if ( !su ) {
-		 			rio_dprintk (RIO_DEBUG_CTRL, "RIO_PUT_TABLE !Root\n");
-		 			p->RIOError.Error = NOT_SUPER_USER;
-		 			return -EPERM;
-				}
-				if ( copyin((int)arg, (caddr_t)&p->RIOConnectTable[0], 
-					TOTAL_MAP_ENTRIES*sizeof(struct Map) ) == COPYFAIL ) {
-		 			rio_dprintk (RIO_DEBUG_CTRL, "RIO_PUT_TABLE copy failed\n");
-		 			p->RIOError.Error = COPYIN_FAILED;
-		 			return -EFAULT;
-				}
+		 case RIO_DISPLAY_HOST_CFG:
+		 **
+		 ** 15.10.1998 ARG - ESIL 0760 part fix
+		 ** Added driver host card ident string output.
+		 **
+		 ** Note that the only types currently supported
+		 ** are ISA and PCI. Also this driver does not
+		 ** (yet) distinguish between the Old PCI card
+		 ** and the Jet PCI card. In fact I think this
+		 ** driver only supports JET PCI !
+		 **
+
+		 for (Host = 0; Host < p->RIONumHosts; Host++)
+		 {
+		 HostP = &(p->RIOHosts[Host]);
+
+		 switch ( HostP->Type )
+		 {
+		 case RIO_AT :
+		 strcpy( host_type, RIO_AT_HOST_STR );
+		 break;
+
+		 case RIO_PCI :
+		 strcpy( host_type, RIO_PCI_HOST_STR );
+		 break;
+
+		 default :
+		 strcpy( host_type, "Unknown" );
+		 break;
+		 }
+
+		 cprintf(
+		 "RIO Host %d - Type:%s Addr:%X IRQ:%d\n",
+		 Host, host_type,
+		 (uint)HostP->PaddrP,
+		 (int)HostP->Ivec - 32  );
+		 }
+		 return 0;
+		 **
+		 */
+
+	case RIO_FOAD_RTA:
+		rio_dprintk(RIO_DEBUG_CTRL, "RIO_FOAD_RTA\n");
+		return RIOCommandRta(p, (uint) arg, RIOFoadRta);
+
+	case RIO_ZOMBIE_RTA:
+		rio_dprintk(RIO_DEBUG_CTRL, "RIO_ZOMBIE_RTA\n");
+		return RIOCommandRta(p, (uint) arg, RIOZombieRta);
+
+	case RIO_IDENTIFY_RTA:
+		rio_dprintk(RIO_DEBUG_CTRL, "RIO_IDENTIFY_RTA\n");
+		return RIOIdentifyRta(p, arg);
+
+	case RIO_KILL_NEIGHBOUR:
+		rio_dprintk(RIO_DEBUG_CTRL, "RIO_KILL_NEIGHBOUR\n");
+		return RIOKillNeighbour(p, arg);
+
+	case SPECIAL_RUP_CMD:
+		{
+			struct CmdBlk *CmdBlkP;
+
+			rio_dprintk(RIO_DEBUG_CTRL, "SPECIAL_RUP_CMD\n");
+			if (copyin((int) arg, (caddr_t) & SpecialRupCmd, sizeof(SpecialRupCmd)) == COPYFAIL) {
+				rio_dprintk(RIO_DEBUG_CTRL, "SPECIAL_RUP_CMD copy failed\n");
+				p->RIOError.Error = COPYIN_FAILED;
+				return -EFAULT;
+			}
+			CmdBlkP = RIOGetCmdBlk();
+			if (!CmdBlkP) {
+				rio_dprintk(RIO_DEBUG_CTRL, "SPECIAL_RUP_CMD GetCmdBlk failed\n");
+				return -ENXIO;
+			}
+			CmdBlkP->Packet = SpecialRupCmd.Packet;
+			if (SpecialRupCmd.Host >= p->RIONumHosts)
+				SpecialRupCmd.Host = 0;
+			rio_dprintk(RIO_DEBUG_CTRL, "Queue special rup command for host %d rup %d\n", SpecialRupCmd.Host, SpecialRupCmd.RupNum);
+			if (RIOQueueCmdBlk(&p->RIOHosts[SpecialRupCmd.Host], SpecialRupCmd.RupNum, CmdBlkP) == RIO_FAIL) {
+				cprintf("FAILED TO QUEUE SPECIAL RUP COMMAND\n");
+			}
+			return 0;
+		}
+
+	case RIO_DEBUG_MEM:
+#ifdef DEBUG_MEM_SUPPORT
+		RIO_DEBUG_CTRL, if (su)
+			return rio_RIODebugMemory(RIO_DEBUG_CTRL, arg);
+		else
+#endif
+			return -EPERM;
+
+	case RIO_ALL_MODEM:
+		rio_dprintk(RIO_DEBUG_CTRL, "RIO_ALL_MODEM\n");
+		p->RIOError.Error = IOCTL_COMMAND_UNKNOWN;
+		return -EINVAL;
+
+	case RIO_GET_TABLE:
+		/*
+		 ** Read the routing table from the device driver to user space
+		 */
+		rio_dprintk(RIO_DEBUG_CTRL, "RIO_GET_TABLE\n");
+
+		if ((retval = RIOApel(p)) != 0)
+			return retval;
+
+		if (copyout((caddr_t) p->RIOConnectTable, (int) arg, TOTAL_MAP_ENTRIES * sizeof(struct Map)) == COPYFAIL) {
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_GET_TABLE copy failed\n");
+			p->RIOError.Error = COPYOUT_FAILED;
+			return -EFAULT;
+		}
+
+		{
+			int entry;
+			rio_dprintk(RIO_DEBUG_CTRL, "*****\nMAP ENTRIES\n");
+			for (entry = 0; entry < TOTAL_MAP_ENTRIES; entry++) {
+				if ((p->RIOConnectTable[entry].ID == 0) && (p->RIOConnectTable[entry].HostUniqueNum == 0) && (p->RIOConnectTable[entry].RtaUniqueNum == 0))
+					continue;
+
+				rio_dprintk(RIO_DEBUG_CTRL, "Map entry %d.HostUniqueNum = 0x%x\n", entry, p->RIOConnectTable[entry].HostUniqueNum);
+				rio_dprintk(RIO_DEBUG_CTRL, "Map entry %d.RtaUniqueNum = 0x%x\n", entry, p->RIOConnectTable[entry].RtaUniqueNum);
+				rio_dprintk(RIO_DEBUG_CTRL, "Map entry %d.ID = 0x%x\n", entry, p->RIOConnectTable[entry].ID);
+				rio_dprintk(RIO_DEBUG_CTRL, "Map entry %d.ID2 = 0x%x\n", entry, p->RIOConnectTable[entry].ID2);
+				rio_dprintk(RIO_DEBUG_CTRL, "Map entry %d.Flags = 0x%x\n", entry, (int) p->RIOConnectTable[entry].Flags);
+				rio_dprintk(RIO_DEBUG_CTRL, "Map entry %d.SysPort = 0x%x\n", entry, (int) p->RIOConnectTable[entry].SysPort);
+				rio_dprintk(RIO_DEBUG_CTRL, "Map entry %d.Top[0].Unit = %x\n", entry, p->RIOConnectTable[entry].Topology[0].Unit);
+				rio_dprintk(RIO_DEBUG_CTRL, "Map entry %d.Top[0].Link = %x\n", entry, p->RIOConnectTable[entry].Topology[0].Link);
+				rio_dprintk(RIO_DEBUG_CTRL, "Map entry %d.Top[1].Unit = %x\n", entry, p->RIOConnectTable[entry].Topology[1].Unit);
+				rio_dprintk(RIO_DEBUG_CTRL, "Map entry %d.Top[1].Link = %x\n", entry, p->RIOConnectTable[entry].Topology[1].Link);
+				rio_dprintk(RIO_DEBUG_CTRL, "Map entry %d.Top[2].Unit = %x\n", entry, p->RIOConnectTable[entry].Topology[2].Unit);
+				rio_dprintk(RIO_DEBUG_CTRL, "Map entry %d.Top[2].Link = %x\n", entry, p->RIOConnectTable[entry].Topology[2].Link);
+				rio_dprintk(RIO_DEBUG_CTRL, "Map entry %d.Top[3].Unit = %x\n", entry, p->RIOConnectTable[entry].Topology[3].Unit);
+				rio_dprintk(RIO_DEBUG_CTRL, "Map entry %d.Top[4].Link = %x\n", entry, p->RIOConnectTable[entry].Topology[3].Link);
+				rio_dprintk(RIO_DEBUG_CTRL, "Map entry %d.Name = %s\n", entry, p->RIOConnectTable[entry].Name);
+			}
+			rio_dprintk(RIO_DEBUG_CTRL, "*****\nEND MAP ENTRIES\n");
+		}
+		p->RIOQuickCheck = NOT_CHANGED;	/* a table has been gotten */
+		return 0;
+
+	case RIO_PUT_TABLE:
+		/*
+		 ** Write the routing table to the device driver from user space
+		 */
+		rio_dprintk(RIO_DEBUG_CTRL, "RIO_PUT_TABLE\n");
+
+		if (!su) {
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_PUT_TABLE !Root\n");
+			p->RIOError.Error = NOT_SUPER_USER;
+			return -EPERM;
+		}
+		if (copyin((int) arg, (caddr_t) & p->RIOConnectTable[0], TOTAL_MAP_ENTRIES * sizeof(struct Map)) == COPYFAIL) {
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_PUT_TABLE copy failed\n");
+			p->RIOError.Error = COPYIN_FAILED;
+			return -EFAULT;
+		}
 /*
 ***********************************
 				{
@@ -409,1353 +406,1244 @@
 				}
 ***********************************
 */
-				return RIONewTable(p);
+		return RIONewTable(p);
 
-	 		case RIO_GET_BINDINGS :
-				/*
-				** Send bindings table, containing unique numbers of RTAs owned
-				** by this system to user space
-				*/
-				rio_dprintk (RIO_DEBUG_CTRL, "RIO_GET_BINDINGS\n");
+	case RIO_GET_BINDINGS:
+		/*
+		 ** Send bindings table, containing unique numbers of RTAs owned
+		 ** by this system to user space
+		 */
+		rio_dprintk(RIO_DEBUG_CTRL, "RIO_GET_BINDINGS\n");
 
-				if ( !su )
-				{
-		 			rio_dprintk (RIO_DEBUG_CTRL, "RIO_GET_BINDINGS !Root\n");
-		 			p->RIOError.Error = NOT_SUPER_USER;
-		 			return -EPERM;
-				}
-				if (copyout((caddr_t) p->RIOBindTab, (int)arg, 
-						(sizeof(ulong) * MAX_RTA_BINDINGS)) == COPYFAIL ) {
-		 			rio_dprintk (RIO_DEBUG_CTRL, "RIO_GET_BINDINGS copy failed\n");
-		 			p->RIOError.Error = COPYOUT_FAILED;
-		 			return -EFAULT;
-				}
-				return 0;
+		if (!su) {
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_GET_BINDINGS !Root\n");
+			p->RIOError.Error = NOT_SUPER_USER;
+			return -EPERM;
+		}
+		if (copyout((caddr_t) p->RIOBindTab, (int) arg, (sizeof(ulong) * MAX_RTA_BINDINGS)) == COPYFAIL) {
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_GET_BINDINGS copy failed\n");
+			p->RIOError.Error = COPYOUT_FAILED;
+			return -EFAULT;
+		}
+		return 0;
 
-	 		case RIO_PUT_BINDINGS :
+	case RIO_PUT_BINDINGS:
+		/*
+		 ** Receive a bindings table, containing unique numbers of RTAs owned
+		 ** by this system
+		 */
+		rio_dprintk(RIO_DEBUG_CTRL, "RIO_PUT_BINDINGS\n");
+
+		if (!su) {
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_PUT_BINDINGS !Root\n");
+			p->RIOError.Error = NOT_SUPER_USER;
+			return -EPERM;
+		}
+		if (copyin((int) arg, (caddr_t) & p->RIOBindTab[0], (sizeof(ulong) * MAX_RTA_BINDINGS)) == COPYFAIL) {
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_PUT_BINDINGS copy failed\n");
+			p->RIOError.Error = COPYIN_FAILED;
+			return -EFAULT;
+		}
+		return 0;
+
+	case RIO_BIND_RTA:
+		{
+			int EmptySlot = -1;
 			/*
-			** Receive a bindings table, containing unique numbers of RTAs owned
-			** by this system
-			*/
-				rio_dprintk (RIO_DEBUG_CTRL, "RIO_PUT_BINDINGS\n");
+			 ** Bind this RTA to host, so that it will be booted by
+			 ** host in 'boot owned RTAs' mode.
+			 */
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_BIND_RTA\n");
 
-				if ( !su )
-				{
-		 			rio_dprintk (RIO_DEBUG_CTRL, "RIO_PUT_BINDINGS !Root\n");
-		 			p->RIOError.Error = NOT_SUPER_USER;
-		 			return -EPERM;
-				}
-				if (copyin((int)arg, (caddr_t)&p->RIOBindTab[0], 
-						(sizeof(ulong) * MAX_RTA_BINDINGS))==COPYFAIL ) {
-		 			rio_dprintk (RIO_DEBUG_CTRL, "RIO_PUT_BINDINGS copy failed\n");
-		 			p->RIOError.Error = COPYIN_FAILED;
-		 			return -EFAULT;
-				}
-				return 0;
-
-			case RIO_BIND_RTA :
-				{
-					int	EmptySlot = -1;
+			if (!su) {
+				rio_dprintk(RIO_DEBUG_CTRL, "RIO_BIND_RTA !Root\n");
+				p->RIOError.Error = NOT_SUPER_USER;
+				return -EPERM;
+			}
+			for (Entry = 0; Entry < MAX_RTA_BINDINGS; Entry++) {
+				if ((EmptySlot == -1) && (p->RIOBindTab[Entry] == 0L))
+					EmptySlot = Entry;
+				else if (p->RIOBindTab[Entry] == (int) arg) {
 					/*
-					** Bind this RTA to host, so that it will be booted by 
-					** host in 'boot owned RTAs' mode.
-					*/
-					rio_dprintk (RIO_DEBUG_CTRL, "RIO_BIND_RTA\n");
-
-					if ( !su ) {
-		 				rio_dprintk (RIO_DEBUG_CTRL, "RIO_BIND_RTA !Root\n");
-		 				p->RIOError.Error = NOT_SUPER_USER;
-		 				return -EPERM;
-					}
-					for (Entry = 0; Entry < MAX_RTA_BINDINGS; Entry++) {
-		 				if ((EmptySlot == -1) && (p->RIOBindTab[Entry] == 0L))
-							EmptySlot = Entry;
-		 				else if (p->RIOBindTab[Entry] == (int) arg) {
-							/*
-							** Already exists - delete
-							*/
-							p->RIOBindTab[Entry] = 0L;
-							rio_dprintk (RIO_DEBUG_CTRL, "Removing Rta %x from p->RIOBindTab\n",
-		 												(int) arg);
-							return 0;
-		 				}
-					}
-					/*
-					** Dosen't exist - add
-					*/
-					if (EmptySlot != -1) {
-		 				p->RIOBindTab[EmptySlot] = (int) arg;
-		 				rio_dprintk (RIO_DEBUG_CTRL, "Adding Rta %x to p->RIOBindTab\n",
-		  					(int) arg);
-					}
-					else {
-		 				rio_dprintk (RIO_DEBUG_CTRL, "p->RIOBindTab full! - Rta %x not added\n",
-		  					(int) arg);
-		 				return -ENOMEM;
-					}
+					 ** Already exists - delete
+					 */
+					p->RIOBindTab[Entry] = 0L;
+					rio_dprintk(RIO_DEBUG_CTRL, "Removing Rta %x from p->RIOBindTab\n", (int) arg);
 					return 0;
 				}
-
-			case RIO_RESUME :
-				rio_dprintk (RIO_DEBUG_CTRL, "RIO_RESUME\n");
-				port = (uint) arg;
-				if ((port < 0) || (port > 511)) {
-		 			rio_dprintk (RIO_DEBUG_CTRL, "RIO_RESUME: Bad port number %d\n", port);
-		 			p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
-		 			return -EINVAL;
-				}
-				PortP = p->RIOPortp[port];
-				if (!PortP->Mapped) {
-		 			rio_dprintk (RIO_DEBUG_CTRL, "RIO_RESUME: Port %d not mapped\n", port);
-		 			p->RIOError.Error = PORT_NOT_MAPPED_INTO_SYSTEM;
-		 			return -EINVAL;
-				}
-				if (!(PortP->State & (RIO_LOPEN | RIO_MOPEN))) {
-					rio_dprintk (RIO_DEBUG_CTRL, "RIO_RESUME: Port %d not open\n", port);
-		 			return -EINVAL;
-				}
-
-				rio_spin_lock_irqsave(&PortP->portSem, flags);
-				if (RIOPreemptiveCmd(p, (p->RIOPortp[port]), RESUME) == 
-										RIO_FAIL) {
-					rio_dprintk (RIO_DEBUG_CTRL, "RIO_RESUME failed\n");
-					rio_spin_unlock_irqrestore(&PortP->portSem, flags);
-					return -EBUSY;
-				}
-				else {
-					rio_dprintk (RIO_DEBUG_CTRL, "RIO_RESUME: Port %d resumed\n", port);
-					PortP->State |= RIO_BUSY;
-				}
-				rio_spin_unlock_irqrestore(&PortP->portSem, flags);
-				return retval;
-
-			case RIO_ASSIGN_RTA:
-				rio_dprintk (RIO_DEBUG_CTRL, "RIO_ASSIGN_RTA\n");
-				if ( !su ) {
-					rio_dprintk (RIO_DEBUG_CTRL, "RIO_ASSIGN_RTA !Root\n");
-					p->RIOError.Error = NOT_SUPER_USER;
-					return -EPERM;
-				}
-				if (copyin((int)arg, (caddr_t)&MapEnt, sizeof(MapEnt))
-									== COPYFAIL) {
-					rio_dprintk (RIO_DEBUG_CTRL, "Copy from user space failed\n");
-					p->RIOError.Error = COPYIN_FAILED;
-					return -EFAULT;
-				}
-				return RIOAssignRta(p, &MapEnt);
-
-			case RIO_CHANGE_NAME:
-				rio_dprintk (RIO_DEBUG_CTRL, "RIO_CHANGE_NAME\n");
-				if ( !su ) {
-					rio_dprintk (RIO_DEBUG_CTRL, "RIO_CHANGE_NAME !Root\n");
-					p->RIOError.Error = NOT_SUPER_USER;
-					return -EPERM;
-				}
-				if (copyin((int)arg, (caddr_t)&MapEnt, sizeof(MapEnt))
-						== COPYFAIL) {
-					rio_dprintk (RIO_DEBUG_CTRL, "Copy from user space failed\n");
-					p->RIOError.Error = COPYIN_FAILED;
-					return -EFAULT;
-				}
-				return RIOChangeName(p, &MapEnt);
-
-			case RIO_DELETE_RTA:
-				rio_dprintk (RIO_DEBUG_CTRL, "RIO_DELETE_RTA\n");
-				if ( !su ) {
-		 			rio_dprintk (RIO_DEBUG_CTRL, "RIO_DELETE_RTA !Root\n");
-		 			p->RIOError.Error = NOT_SUPER_USER;
-		 			return -EPERM;
-				}
-				if (copyin((int)arg, (caddr_t)&MapEnt, sizeof(MapEnt))
-							== COPYFAIL ) {
-		 			rio_dprintk (RIO_DEBUG_CTRL, "Copy from data space failed\n");
-		 			p->RIOError.Error = COPYIN_FAILED;
-		 			return -EFAULT;
-				}
-				return RIODeleteRta(p, &MapEnt);
-
-			case RIO_QUICK_CHECK:
-				/*
-				** 09.12.1998 ARG - ESIL 0776 part fix
-				** A customer was using this to get the RTAs
-				** connect/disconnect status.
-				** RIOConCon() had been botched use RIOHalted
-				** to keep track of RTA connections and
-				** disconnections. That has been changed and
-				** RIORtaDisCons in the rio_info struct now
-				** does the job. So we need to return the value
-				** of RIORtaCons instead of RIOHalted.
-				**
-				if (copyout((caddr_t)&p->RIOHalted,(int)arg,
-							sizeof(uint))==COPYFAIL) {
-				**
-				*/
-
-				if (copyout((caddr_t)&p->RIORtaDisCons,(int)arg,
-							sizeof(uint))==COPYFAIL) {
-					p->RIOError.Error = COPYOUT_FAILED;
-					return -EFAULT;
-				}
-				return 0;
-
-			case RIO_LAST_ERROR:
-				if (copyout((caddr_t)&p->RIOError, (int)arg, 
-						sizeof(struct Error)) ==COPYFAIL )
-					return -EFAULT;
-				return 0;
-
-			case RIO_GET_LOG:
-				rio_dprintk (RIO_DEBUG_CTRL, "RIO_GET_LOG\n");
-#ifdef LOGGING
-				RIOGetLog(arg);
-				return 0;
-#else
-				return -EINVAL;
-#endif
-
-			case RIO_GET_MODTYPE:
-				if ( copyin( (int)arg, (caddr_t)&port, 
-									sizeof(uint)) == COPYFAIL )
-				{
-		 			p->RIOError.Error = COPYIN_FAILED;
-		 			return -EFAULT;
-				}
-				rio_dprintk (RIO_DEBUG_CTRL, "Get module type for port %d\n", port);
-				if ( port < 0 || port > 511 )
-				{
-		 			rio_dprintk (RIO_DEBUG_CTRL, "RIO_GET_MODTYPE: Bad port number %d\n", port);
-		 			p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
-		 			return -EINVAL;
-				}
-				PortP = (p->RIOPortp[port]);
-				if (!PortP->Mapped)
-				{
-		 			rio_dprintk (RIO_DEBUG_CTRL, "RIO_GET_MODTYPE: Port %d not mapped\n", port);
-		 			p->RIOError.Error = PORT_NOT_MAPPED_INTO_SYSTEM;
-		 			return -EINVAL;
-				}
-				/*
-				** Return module type of port
-				*/
-				port = PortP->HostP->UnixRups[PortP->RupNum].ModTypes;
-				if (copyout((caddr_t)&port, (int)arg, 
-							sizeof(uint)) == COPYFAIL) {
-		 			p->RIOError.Error = COPYOUT_FAILED;
-		 			return -EFAULT;
-				}
-				return(0);
+			}
 			/*
-			** 02.03.1999 ARG - ESIL 0820 fix
-			** We are no longer using "Boot Mode", so these ioctls
-			** are not required :
-			**
-	 		case RIO_GET_BOOT_MODE :
-				rio_dprint(RIO_DEBUG_CTRL, ("Get boot mode - %x\n", p->RIOBootMode));
-				**
-				** Return boot state of system - BOOT_ALL, BOOT_OWN or BOOT_NONE
-				**
-				if (copyout((caddr_t)&p->RIOBootMode, (int)arg, 
-						sizeof(p->RIOBootMode)) == COPYFAIL) {
-		 			p->RIOError.Error = COPYOUT_FAILED;
-		 			return -EFAULT;
-				}
-				return(0);
-			
- 			case RIO_SET_BOOT_MODE :
-				p->RIOBootMode = (uint) arg;
-				rio_dprint(RIO_DEBUG_CTRL, ("Set boot mode to 0x%x\n", p->RIOBootMode));
-				return(0);
-			**
-			** End ESIL 0820 fix
-			*/
+			 ** Dosen't exist - add
+			 */
+			if (EmptySlot != -1) {
+				p->RIOBindTab[EmptySlot] = (int) arg;
+				rio_dprintk(RIO_DEBUG_CTRL, "Adding Rta %x to p->RIOBindTab\n", (int) arg);
+			} else {
+				rio_dprintk(RIO_DEBUG_CTRL, "p->RIOBindTab full! - Rta %x not added\n", (int) arg);
+				return -ENOMEM;
+			}
+			return 0;
+		}
 
-	 		case RIO_BLOCK_OPENS:
-				rio_dprintk (RIO_DEBUG_CTRL, "Opens block until booted\n");
-				for ( Entry=0; Entry < RIO_PORTS; Entry++ ) {
-		 			rio_spin_lock_irqsave(&PortP->portSem, flags);
-		 			p->RIOPortp[Entry]->WaitUntilBooted = 1;
-		 			rio_spin_unlock_irqrestore(&PortP->portSem, flags);
-				}
-				return 0;
-			
-	 		case RIO_SETUP_PORTS:
-				rio_dprintk (RIO_DEBUG_CTRL, "Setup ports\n");
-				if (copyin((int)arg, (caddr_t)&PortSetup, sizeof(PortSetup)) 
-						== COPYFAIL ) {
-					 p->RIOError.Error = COPYIN_FAILED;
-					 rio_dprintk (RIO_DEBUG_CTRL, "EFAULT");
-					 return -EFAULT;
-				}
-				if ( PortSetup.From > PortSetup.To || 
-								PortSetup.To >= RIO_PORTS ) {
-					 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
-					 rio_dprintk (RIO_DEBUG_CTRL, "ENXIO");
-					 return -ENXIO;
-				}
-				if ( PortSetup.XpCps > p->RIOConf.MaxXpCps ||
-					 PortSetup.XpCps < p->RIOConf.MinXpCps ) {
-					 p->RIOError.Error = XPRINT_CPS_OUT_OF_RANGE;
-					 rio_dprintk (RIO_DEBUG_CTRL, "EINVAL");
-					 return -EINVAL;
-				}
-				if ( !p->RIOPortp ) {
-					 cprintf("No p->RIOPortp array!\n");
-					 rio_dprintk (RIO_DEBUG_CTRL, "No p->RIOPortp array!\n");
-					 return -EIO;
-				}
-				rio_dprintk (RIO_DEBUG_CTRL, "entering loop (%d %d)!\n", PortSetup.From, PortSetup.To);
-				for (loop=PortSetup.From; loop<=PortSetup.To; loop++) {
-				rio_dprintk (RIO_DEBUG_CTRL, "in loop (%d)!\n", loop);
-#if 0
-					PortP = p->RIOPortp[loop];
-					if ( !PortP->TtyP )
-						PortP->TtyP = &p->channel[loop];
+	case RIO_RESUME:
+		rio_dprintk(RIO_DEBUG_CTRL, "RIO_RESUME\n");
+		port = (uint) arg;
+		if ((port < 0) || (port > 511)) {
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_RESUME: Bad port number %d\n", port);
+			p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
+			return -EINVAL;
+		}
+		PortP = p->RIOPortp[port];
+		if (!PortP->Mapped) {
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_RESUME: Port %d not mapped\n", port);
+			p->RIOError.Error = PORT_NOT_MAPPED_INTO_SYSTEM;
+			return -EINVAL;
+		}
+		if (!(PortP->State & (RIO_LOPEN | RIO_MOPEN))) {
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_RESUME: Port %d not open\n", port);
+			return -EINVAL;
+		}
 
-		 				rio_spin_lock_irqsave(&PortP->portSem, flags);
-						if ( PortSetup.IxAny )
-							PortP->Config |= RIO_IXANY;
-						else
-							PortP->Config &= ~RIO_IXANY;
-						if ( PortSetup.IxOn )
-							PortP->Config |= RIO_IXON;
-						else
-							PortP->Config &= ~RIO_IXON;
-					 
-					 /*
-					 ** If the port needs to wait for all a processes output
-					 ** to drain before closing then this flag will be set.
-					 */
-					 	if (PortSetup.Drain) {
-							PortP->Config |= RIO_WAITDRAIN;
-					 	} else {
-							PortP->Config &= ~RIO_WAITDRAIN;
-					 	}
-					 /*
-					 ** Store settings if locking or unlocking port or if the
-					 ** port is not locked, when setting the store option.
-					 */
-					 if (PortP->Mapped &&
-						 ((PortSetup.Lock && !PortP->Lock) ||
-							(!PortP->Lock &&
-							(PortSetup.Store && !PortP->Store)))) {
-						PortP->StoredTty.iflag = PortP->TtyP->tm.c_iflag;
-						PortP->StoredTty.oflag = PortP->TtyP->tm.c_oflag;
-						PortP->StoredTty.cflag = PortP->TtyP->tm.c_cflag;
-						PortP->StoredTty.lflag = PortP->TtyP->tm.c_lflag;
-						PortP->StoredTty.line = PortP->TtyP->tm.c_line;
-						bcopy(PortP->TtyP->tm.c_cc, PortP->StoredTty.cc,
-					 		NCC + 5);
-					 }
-					 PortP->Lock = PortSetup.Lock;
-					 PortP->Store = PortSetup.Store;
-					 PortP->Xprint.XpCps = PortSetup.XpCps;
-					 bcopy(PortSetup.XpOn,PortP->Xprint.XpOn,MAX_XP_CTRL_LEN);
-					 bcopy(PortSetup.XpOff,PortP->Xprint.XpOff,MAX_XP_CTRL_LEN);
-					 PortP->Xprint.XpOn[MAX_XP_CTRL_LEN-1] = '\0';
-					 PortP->Xprint.XpOff[MAX_XP_CTRL_LEN-1] = '\0';
-					 PortP->Xprint.XpLen = RIOStrlen(PortP->Xprint.XpOn)+
-								RIOStrlen(PortP->Xprint.XpOff);
-					 rio_spin_unlock_irqrestore( &PortP->portSem , flags);
-#endif
-				}
-				rio_dprintk (RIO_DEBUG_CTRL, "after loop (%d)!\n", loop);
-				rio_dprintk (RIO_DEBUG_CTRL, "Retval:%x\n", retval);
-				return retval;
+		rio_spin_lock_irqsave(&PortP->portSem, flags);
+		if (RIOPreemptiveCmd(p, (p->RIOPortp[port]), RESUME) == RIO_FAIL) {
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_RESUME failed\n");
+			rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+			return -EBUSY;
+		} else {
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_RESUME: Port %d resumed\n", port);
+			PortP->State |= RIO_BUSY;
+		}
+		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+		return retval;
 
-			case RIO_GET_PORT_SETUP :
-				rio_dprintk (RIO_DEBUG_CTRL, "Get port setup\n");
-				if (copyin((int)arg, (caddr_t)&PortSetup, sizeof(PortSetup)) 
-							== COPYFAIL ) {
-					 p->RIOError.Error = COPYIN_FAILED;
-					 return -EFAULT;
-				}
-				if ( PortSetup.From >= RIO_PORTS ) {
-					 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
-					 return -ENXIO;
-				}
+	case RIO_ASSIGN_RTA:
+		rio_dprintk(RIO_DEBUG_CTRL, "RIO_ASSIGN_RTA\n");
+		if (!su) {
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_ASSIGN_RTA !Root\n");
+			p->RIOError.Error = NOT_SUPER_USER;
+			return -EPERM;
+		}
+		if (copyin((int) arg, (caddr_t) & MapEnt, sizeof(MapEnt))
+		    == COPYFAIL) {
+			rio_dprintk(RIO_DEBUG_CTRL, "Copy from user space failed\n");
+			p->RIOError.Error = COPYIN_FAILED;
+			return -EFAULT;
+		}
+		return RIOAssignRta(p, &MapEnt);
 
-				port = PortSetup.To = PortSetup.From;
-				PortSetup.IxAny = (p->RIOPortp[port]->Config & RIO_IXANY) ? 
-													1 : 0;
-				PortSetup.IxOn = (p->RIOPortp[port]->Config & RIO_IXON) ? 
-													1 : 0;
-				PortSetup.Drain = (p->RIOPortp[port]->Config & RIO_WAITDRAIN) ?
-												 	1 : 0;
-				PortSetup.Store = p->RIOPortp[port]->Store;
-				PortSetup.Lock = p->RIOPortp[port]->Lock;
-				PortSetup.XpCps = p->RIOPortp[port]->Xprint.XpCps;
-				bcopy(p->RIOPortp[port]->Xprint.XpOn, PortSetup.XpOn,
-													MAX_XP_CTRL_LEN);
-				bcopy(p->RIOPortp[port]->Xprint.XpOff, PortSetup.XpOff,
-													MAX_XP_CTRL_LEN);
-				PortSetup.XpOn[MAX_XP_CTRL_LEN-1] = '\0';
-				PortSetup.XpOff[MAX_XP_CTRL_LEN-1] = '\0';
+	case RIO_CHANGE_NAME:
+		rio_dprintk(RIO_DEBUG_CTRL, "RIO_CHANGE_NAME\n");
+		if (!su) {
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_CHANGE_NAME !Root\n");
+			p->RIOError.Error = NOT_SUPER_USER;
+			return -EPERM;
+		}
+		if (copyin((int) arg, (caddr_t) & MapEnt, sizeof(MapEnt))
+		    == COPYFAIL) {
+			rio_dprintk(RIO_DEBUG_CTRL, "Copy from user space failed\n");
+			p->RIOError.Error = COPYIN_FAILED;
+			return -EFAULT;
+		}
+		return RIOChangeName(p, &MapEnt);
 
-				if ( copyout((caddr_t)&PortSetup,(int)arg,sizeof(PortSetup))
-														==COPYFAIL ) {
-					 p->RIOError.Error = COPYOUT_FAILED;
-					 return -EFAULT;
-				}
-				return retval;
+	case RIO_DELETE_RTA:
+		rio_dprintk(RIO_DEBUG_CTRL, "RIO_DELETE_RTA\n");
+		if (!su) {
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_DELETE_RTA !Root\n");
+			p->RIOError.Error = NOT_SUPER_USER;
+			return -EPERM;
+		}
+		if (copyin((int) arg, (caddr_t) & MapEnt, sizeof(MapEnt))
+		    == COPYFAIL) {
+			rio_dprintk(RIO_DEBUG_CTRL, "Copy from data space failed\n");
+			p->RIOError.Error = COPYIN_FAILED;
+			return -EFAULT;
+		}
+		return RIODeleteRta(p, &MapEnt);
 
-			case RIO_GET_PORT_PARAMS :
-				rio_dprintk (RIO_DEBUG_CTRL, "Get port params\n");
-				if (copyin( (int)arg, (caddr_t)&PortParams,
-					sizeof(struct PortParams)) == COPYFAIL) {
-					p->RIOError.Error = COPYIN_FAILED;
-					return -EFAULT;
-				}
-				if (PortParams.Port >= RIO_PORTS) {
-					p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
-					return -ENXIO;
-				}
-				PortP = (p->RIOPortp[PortParams.Port]);
-				PortParams.Config = PortP->Config;
-				PortParams.State = PortP->State;
-				rio_dprintk (RIO_DEBUG_CTRL, "Port %d\n", PortParams.Port);
+	case RIO_QUICK_CHECK:
+		/*
+		 ** 09.12.1998 ARG - ESIL 0776 part fix
+		 ** A customer was using this to get the RTAs
+		 ** connect/disconnect status.
+		 ** RIOConCon() had been botched use RIOHalted
+		 ** to keep track of RTA connections and
+		 ** disconnections. That has been changed and
+		 ** RIORtaDisCons in the rio_info struct now
+		 ** does the job. So we need to return the value
+		 ** of RIORtaCons instead of RIOHalted.
+		 **
+		 if (copyout((caddr_t)&p->RIOHalted,(int)arg,
+		 sizeof(uint))==COPYFAIL) {
+		 **
+		 */
 
-				if (copyout((caddr_t)&PortParams, (int)arg, 
-						sizeof(struct PortParams)) == COPYFAIL ) {
-					 p->RIOError.Error = COPYOUT_FAILED;
-					 return -EFAULT;
-				}
-				return retval;
+		if (copyout((caddr_t) & p->RIORtaDisCons, (int) arg, sizeof(uint)) == COPYFAIL) {
+			p->RIOError.Error = COPYOUT_FAILED;
+			return -EFAULT;
+		}
+		return 0;
 
-			case RIO_GET_PORT_TTY :
-				rio_dprintk (RIO_DEBUG_CTRL, "Get port tty\n");
-				if (copyin((int)arg, (caddr_t)&PortTty, sizeof(struct PortTty)) 
-						== COPYFAIL) {
-					 p->RIOError.Error = COPYIN_FAILED;
-					 return -EFAULT;
-				}
-				if ( PortTty.port >= RIO_PORTS ) {
-					 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
-					 return -ENXIO;
-				}
+	case RIO_LAST_ERROR:
+		if (copyout((caddr_t) & p->RIOError, (int) arg, sizeof(struct Error)) == COPYFAIL)
+			return -EFAULT;
+		return 0;
 
-				rio_dprintk (RIO_DEBUG_CTRL, "Port %d\n", PortTty.port);
-				PortP = (p->RIOPortp[PortTty.port]);
-#if 0
-				PortTty.Tty.tm.c_iflag = PortP->TtyP->tm.c_iflag;
-				PortTty.Tty.tm.c_oflag = PortP->TtyP->tm.c_oflag;
-				PortTty.Tty.tm.c_cflag = PortP->TtyP->tm.c_cflag;
-				PortTty.Tty.tm.c_lflag = PortP->TtyP->tm.c_lflag;
-#endif
-				if (copyout((caddr_t)&PortTty, (int)arg, 
-							sizeof(struct PortTty)) == COPYFAIL) {
-					p->RIOError.Error = COPYOUT_FAILED;
-					return -EFAULT;
-				}
-				return retval;
-
-			case RIO_SET_PORT_TTY :
-				if (copyin((int)arg, (caddr_t)&PortTty, 
-						sizeof(struct PortTty)) == COPYFAIL) {
-					 p->RIOError.Error = COPYIN_FAILED;
-					 return -EFAULT;
-				}
-				rio_dprintk (RIO_DEBUG_CTRL, "Set port %d tty\n", PortTty.port);
-				if (PortTty.port >= (ushort) RIO_PORTS) {
-					 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
-					 return -ENXIO;
-				}
-				PortP = (p->RIOPortp[PortTty.port]);
-#if 0
-		 		rio_spin_lock_irqsave(&PortP->portSem, flags);
-				PortP->TtyP->tm.c_iflag = PortTty.Tty.tm.c_iflag;
-				PortP->TtyP->tm.c_oflag = PortTty.Tty.tm.c_oflag;
-				PortP->TtyP->tm.c_cflag = PortTty.Tty.tm.c_cflag;
-				PortP->TtyP->tm.c_lflag = PortTty.Tty.tm.c_lflag;
-				rio_spin_unlock_irqrestore( &PortP->portSem , flags);
+	case RIO_GET_LOG:
+		rio_dprintk(RIO_DEBUG_CTRL, "RIO_GET_LOG\n");
+#ifdef LOGGING
+		RIOGetLog(arg);
+		return 0;
+#else
+		return -EINVAL;
 #endif
 
-				RIOParam(PortP, CONFIG, PortP->State & RIO_MODEM, OK_TO_SLEEP);
-				return retval;
+	case RIO_GET_MODTYPE:
+		if (copyin((int) arg, (caddr_t) & port, sizeof(uint)) == COPYFAIL) {
+			p->RIOError.Error = COPYIN_FAILED;
+			return -EFAULT;
+		}
+		rio_dprintk(RIO_DEBUG_CTRL, "Get module type for port %d\n", port);
+		if (port < 0 || port > 511) {
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_GET_MODTYPE: Bad port number %d\n", port);
+			p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
+			return -EINVAL;
+		}
+		PortP = (p->RIOPortp[port]);
+		if (!PortP->Mapped) {
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_GET_MODTYPE: Port %d not mapped\n", port);
+			p->RIOError.Error = PORT_NOT_MAPPED_INTO_SYSTEM;
+			return -EINVAL;
+		}
+		/*
+		 ** Return module type of port
+		 */
+		port = PortP->HostP->UnixRups[PortP->RupNum].ModTypes;
+		if (copyout((caddr_t) & port, (int) arg, sizeof(uint)) == COPYFAIL) {
+			p->RIOError.Error = COPYOUT_FAILED;
+			return -EFAULT;
+		}
+		return (0);
+		/*
+		 ** 02.03.1999 ARG - ESIL 0820 fix
+		 ** We are no longer using "Boot Mode", so these ioctls
+		 ** are not required :
+		 **
+		 case RIO_GET_BOOT_MODE :
+		 rio_dprint(RIO_DEBUG_CTRL, ("Get boot mode - %x\n", p->RIOBootMode));
+		 **
+		 ** Return boot state of system - BOOT_ALL, BOOT_OWN or BOOT_NONE
+		 **
+		 if (copyout((caddr_t)&p->RIOBootMode, (int)arg,
+		 sizeof(p->RIOBootMode)) == COPYFAIL) {
+		 p->RIOError.Error = COPYOUT_FAILED;
+		 return -EFAULT;
+		 }
+		 return(0);
 
-			case RIO_SET_PORT_PARAMS :
-				rio_dprintk (RIO_DEBUG_CTRL, "Set port params\n");
-				if ( copyin((int)arg, (caddr_t)&PortParams, sizeof(PortParams))
-					== COPYFAIL ) {
-					 p->RIOError.Error = COPYIN_FAILED;
-					 return -EFAULT;
-				}
-				if (PortParams.Port >= (ushort) RIO_PORTS) {
-					 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
-					 return -ENXIO;
-				}
-				PortP = (p->RIOPortp[PortParams.Port]);
-		 		rio_spin_lock_irqsave(&PortP->portSem, flags);
-				PortP->Config = PortParams.Config;
-				rio_spin_unlock_irqrestore( &PortP->portSem , flags);
-				return retval;
+		 case RIO_SET_BOOT_MODE :
+		 p->RIOBootMode = (uint) arg;
+		 rio_dprint(RIO_DEBUG_CTRL, ("Set boot mode to 0x%x\n", p->RIOBootMode));
+		 return(0);
+		 **
+		 ** End ESIL 0820 fix
+		 */
 
-			case RIO_GET_PORT_STATS :
-				rio_dprintk (RIO_DEBUG_CTRL, "RIO_GET_PORT_STATS\n");
-				if ( copyin((int)arg, (caddr_t)&portStats, 
-						sizeof(struct portStats)) == COPYFAIL ) {
-					 p->RIOError.Error = COPYIN_FAILED;
-					 return -EFAULT;
-				}
-				if ( portStats.port >= RIO_PORTS ) {
-					 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
-					 return -ENXIO;
-				}
-				PortP = (p->RIOPortp[portStats.port]);
-				portStats.gather = PortP->statsGather;
-				portStats.txchars = PortP->txchars;
-				portStats.rxchars = PortP->rxchars;
-				portStats.opens = PortP->opens;
-				portStats.closes = PortP->closes;
-				portStats.ioctls = PortP->ioctls;
-				if ( copyout((caddr_t)&portStats, (int)arg, 
-							sizeof(struct portStats)) == COPYFAIL ) {
-					 p->RIOError.Error = COPYOUT_FAILED;
-					 return -EFAULT;
-				}
-				return retval;
+	case RIO_BLOCK_OPENS:
+		rio_dprintk(RIO_DEBUG_CTRL, "Opens block until booted\n");
+		for (Entry = 0; Entry < RIO_PORTS; Entry++) {
+			rio_spin_lock_irqsave(&PortP->portSem, flags);
+			p->RIOPortp[Entry]->WaitUntilBooted = 1;
+			rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+		}
+		return 0;
 
-			case RIO_RESET_PORT_STATS :
-				port = (uint) arg;
-				rio_dprintk (RIO_DEBUG_CTRL, "RIO_RESET_PORT_STATS\n");
-				if ( port >= RIO_PORTS ) {
-					 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
-					 return -ENXIO;
-				}
-				PortP = (p->RIOPortp[port]);
-				rio_spin_lock_irqsave(&PortP->portSem, flags);
-				PortP->txchars	= 0;
-				PortP->rxchars	= 0;
-				PortP->opens	= 0;
-				PortP->closes	= 0;
-				PortP->ioctls	= 0;
-				rio_spin_unlock_irqrestore(&PortP->portSem, flags);
-				return retval;
+	case RIO_SETUP_PORTS:
+		rio_dprintk(RIO_DEBUG_CTRL, "Setup ports\n");
+		if (copyin((int) arg, (caddr_t) & PortSetup, sizeof(PortSetup))
+		    == COPYFAIL) {
+			p->RIOError.Error = COPYIN_FAILED;
+			rio_dprintk(RIO_DEBUG_CTRL, "EFAULT");
+			return -EFAULT;
+		}
+		if (PortSetup.From > PortSetup.To || PortSetup.To >= RIO_PORTS) {
+			p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
+			rio_dprintk(RIO_DEBUG_CTRL, "ENXIO");
+			return -ENXIO;
+		}
+		if (PortSetup.XpCps > p->RIOConf.MaxXpCps || PortSetup.XpCps < p->RIOConf.MinXpCps) {
+			p->RIOError.Error = XPRINT_CPS_OUT_OF_RANGE;
+			rio_dprintk(RIO_DEBUG_CTRL, "EINVAL");
+			return -EINVAL;
+		}
+		if (!p->RIOPortp) {
+			cprintf("No p->RIOPortp array!\n");
+			rio_dprintk(RIO_DEBUG_CTRL, "No p->RIOPortp array!\n");
+			return -EIO;
+		}
+		rio_dprintk(RIO_DEBUG_CTRL, "entering loop (%d %d)!\n", PortSetup.From, PortSetup.To);
+		for (loop = PortSetup.From; loop <= PortSetup.To; loop++) {
+			rio_dprintk(RIO_DEBUG_CTRL, "in loop (%d)!\n", loop);
+#if 0
+			PortP = p->RIOPortp[loop];
+			if (!PortP->TtyP)
+				PortP->TtyP = &p->channel[loop];
 
-			case RIO_GATHER_PORT_STATS :
-				rio_dprintk (RIO_DEBUG_CTRL, "RIO_GATHER_PORT_STATS\n");
-				if ( copyin( (int)arg, (caddr_t)&portStats, 
-						sizeof(struct portStats)) == COPYFAIL ) {
-					 p->RIOError.Error = COPYIN_FAILED;
-					 return -EFAULT;
-				}
-				if ( portStats.port >= RIO_PORTS ) {
-					 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
-					 return -ENXIO;
-				}
-				PortP = (p->RIOPortp[portStats.port]);
-				rio_spin_lock_irqsave(&PortP->portSem, flags);
-				PortP->statsGather = portStats.gather;
-				rio_spin_unlock_irqrestore( &PortP->portSem , flags);
-				return retval;
+			rio_spin_lock_irqsave(&PortP->portSem, flags);
+			if (PortSetup.IxAny)
+				PortP->Config |= RIO_IXANY;
+			else
+				PortP->Config &= ~RIO_IXANY;
+			if (PortSetup.IxOn)
+				PortP->Config |= RIO_IXON;
+			else
+				PortP->Config &= ~RIO_IXON;
+
+			/*
+			 ** If the port needs to wait for all a processes output
+			 ** to drain before closing then this flag will be set.
+			 */
+			if (PortSetup.Drain) {
+				PortP->Config |= RIO_WAITDRAIN;
+			} else {
+				PortP->Config &= ~RIO_WAITDRAIN;
+			}
+			/*
+			 ** Store settings if locking or unlocking port or if the
+			 ** port is not locked, when setting the store option.
+			 */
+			if (PortP->Mapped && ((PortSetup.Lock && !PortP->Lock) || (!PortP->Lock && (PortSetup.Store && !PortP->Store)))) {
+				PortP->StoredTty.iflag = PortP->TtyP->tm.c_iflag;
+				PortP->StoredTty.oflag = PortP->TtyP->tm.c_oflag;
+				PortP->StoredTty.cflag = PortP->TtyP->tm.c_cflag;
+				PortP->StoredTty.lflag = PortP->TtyP->tm.c_lflag;
+				PortP->StoredTty.line = PortP->TtyP->tm.c_line;
+				bcopy(PortP->TtyP->tm.c_cc, PortP->StoredTty.cc, NCC + 5);
+			}
+			PortP->Lock = PortSetup.Lock;
+			PortP->Store = PortSetup.Store;
+			PortP->Xprint.XpCps = PortSetup.XpCps;
+			bcopy(PortSetup.XpOn, PortP->Xprint.XpOn, MAX_XP_CTRL_LEN);
+			bcopy(PortSetup.XpOff, PortP->Xprint.XpOff, MAX_XP_CTRL_LEN);
+			PortP->Xprint.XpOn[MAX_XP_CTRL_LEN - 1] = '\0';
+			PortP->Xprint.XpOff[MAX_XP_CTRL_LEN - 1] = '\0';
+			PortP->Xprint.XpLen = RIOStrlen(PortP->Xprint.XpOn) + RIOStrlen(PortP->Xprint.XpOff);
+			rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+#endif
+		}
+		rio_dprintk(RIO_DEBUG_CTRL, "after loop (%d)!\n", loop);
+		rio_dprintk(RIO_DEBUG_CTRL, "Retval:%x\n", retval);
+		return retval;
+
+	case RIO_GET_PORT_SETUP:
+		rio_dprintk(RIO_DEBUG_CTRL, "Get port setup\n");
+		if (copyin((int) arg, (caddr_t) & PortSetup, sizeof(PortSetup))
+		    == COPYFAIL) {
+			p->RIOError.Error = COPYIN_FAILED;
+			return -EFAULT;
+		}
+		if (PortSetup.From >= RIO_PORTS) {
+			p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
+			return -ENXIO;
+		}
+
+		port = PortSetup.To = PortSetup.From;
+		PortSetup.IxAny = (p->RIOPortp[port]->Config & RIO_IXANY) ? 1 : 0;
+		PortSetup.IxOn = (p->RIOPortp[port]->Config & RIO_IXON) ? 1 : 0;
+		PortSetup.Drain = (p->RIOPortp[port]->Config & RIO_WAITDRAIN) ? 1 : 0;
+		PortSetup.Store = p->RIOPortp[port]->Store;
+		PortSetup.Lock = p->RIOPortp[port]->Lock;
+		PortSetup.XpCps = p->RIOPortp[port]->Xprint.XpCps;
+		bcopy(p->RIOPortp[port]->Xprint.XpOn, PortSetup.XpOn, MAX_XP_CTRL_LEN);
+		bcopy(p->RIOPortp[port]->Xprint.XpOff, PortSetup.XpOff, MAX_XP_CTRL_LEN);
+		PortSetup.XpOn[MAX_XP_CTRL_LEN - 1] = '\0';
+		PortSetup.XpOff[MAX_XP_CTRL_LEN - 1] = '\0';
+
+		if (copyout((caddr_t) & PortSetup, (int) arg, sizeof(PortSetup))
+		    == COPYFAIL) {
+			p->RIOError.Error = COPYOUT_FAILED;
+			return -EFAULT;
+		}
+		return retval;
+
+	case RIO_GET_PORT_PARAMS:
+		rio_dprintk(RIO_DEBUG_CTRL, "Get port params\n");
+		if (copyin((int) arg, (caddr_t) & PortParams, sizeof(struct PortParams)) == COPYFAIL) {
+			p->RIOError.Error = COPYIN_FAILED;
+			return -EFAULT;
+		}
+		if (PortParams.Port >= RIO_PORTS) {
+			p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
+			return -ENXIO;
+		}
+		PortP = (p->RIOPortp[PortParams.Port]);
+		PortParams.Config = PortP->Config;
+		PortParams.State = PortP->State;
+		rio_dprintk(RIO_DEBUG_CTRL, "Port %d\n", PortParams.Port);
+
+		if (copyout((caddr_t) & PortParams, (int) arg, sizeof(struct PortParams)) == COPYFAIL) {
+			p->RIOError.Error = COPYOUT_FAILED;
+			return -EFAULT;
+		}
+		return retval;
+
+	case RIO_GET_PORT_TTY:
+		rio_dprintk(RIO_DEBUG_CTRL, "Get port tty\n");
+		if (copyin((int) arg, (caddr_t) & PortTty, sizeof(struct PortTty))
+		    == COPYFAIL) {
+			p->RIOError.Error = COPYIN_FAILED;
+			return -EFAULT;
+		}
+		if (PortTty.port >= RIO_PORTS) {
+			p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
+			return -ENXIO;
+		}
+
+		rio_dprintk(RIO_DEBUG_CTRL, "Port %d\n", PortTty.port);
+		PortP = (p->RIOPortp[PortTty.port]);
+#if 0
+		PortTty.Tty.tm.c_iflag = PortP->TtyP->tm.c_iflag;
+		PortTty.Tty.tm.c_oflag = PortP->TtyP->tm.c_oflag;
+		PortTty.Tty.tm.c_cflag = PortP->TtyP->tm.c_cflag;
+		PortTty.Tty.tm.c_lflag = PortP->TtyP->tm.c_lflag;
+#endif
+		if (copyout((caddr_t) & PortTty, (int) arg, sizeof(struct PortTty)) == COPYFAIL) {
+			p->RIOError.Error = COPYOUT_FAILED;
+			return -EFAULT;
+		}
+		return retval;
+
+	case RIO_SET_PORT_TTY:
+		if (copyin((int) arg, (caddr_t) & PortTty, sizeof(struct PortTty)) == COPYFAIL) {
+			p->RIOError.Error = COPYIN_FAILED;
+			return -EFAULT;
+		}
+		rio_dprintk(RIO_DEBUG_CTRL, "Set port %d tty\n", PortTty.port);
+		if (PortTty.port >= (ushort) RIO_PORTS) {
+			p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
+			return -ENXIO;
+		}
+		PortP = (p->RIOPortp[PortTty.port]);
+#if 0
+		rio_spin_lock_irqsave(&PortP->portSem, flags);
+		PortP->TtyP->tm.c_iflag = PortTty.Tty.tm.c_iflag;
+		PortP->TtyP->tm.c_oflag = PortTty.Tty.tm.c_oflag;
+		PortP->TtyP->tm.c_cflag = PortTty.Tty.tm.c_cflag;
+		PortP->TtyP->tm.c_lflag = PortTty.Tty.tm.c_lflag;
+		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+#endif
+
+		RIOParam(PortP, CONFIG, PortP->State & RIO_MODEM, OK_TO_SLEEP);
+		return retval;
+
+	case RIO_SET_PORT_PARAMS:
+		rio_dprintk(RIO_DEBUG_CTRL, "Set port params\n");
+		if (copyin((int) arg, (caddr_t) & PortParams, sizeof(PortParams))
+		    == COPYFAIL) {
+			p->RIOError.Error = COPYIN_FAILED;
+			return -EFAULT;
+		}
+		if (PortParams.Port >= (ushort) RIO_PORTS) {
+			p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
+			return -ENXIO;
+		}
+		PortP = (p->RIOPortp[PortParams.Port]);
+		rio_spin_lock_irqsave(&PortP->portSem, flags);
+		PortP->Config = PortParams.Config;
+		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+		return retval;
+
+	case RIO_GET_PORT_STATS:
+		rio_dprintk(RIO_DEBUG_CTRL, "RIO_GET_PORT_STATS\n");
+		if (copyin((int) arg, (caddr_t) & portStats, sizeof(struct portStats)) == COPYFAIL) {
+			p->RIOError.Error = COPYIN_FAILED;
+			return -EFAULT;
+		}
+		if (portStats.port >= RIO_PORTS) {
+			p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
+			return -ENXIO;
+		}
+		PortP = (p->RIOPortp[portStats.port]);
+		portStats.gather = PortP->statsGather;
+		portStats.txchars = PortP->txchars;
+		portStats.rxchars = PortP->rxchars;
+		portStats.opens = PortP->opens;
+		portStats.closes = PortP->closes;
+		portStats.ioctls = PortP->ioctls;
+		if (copyout((caddr_t) & portStats, (int) arg, sizeof(struct portStats)) == COPYFAIL) {
+			p->RIOError.Error = COPYOUT_FAILED;
+			return -EFAULT;
+		}
+		return retval;
+
+	case RIO_RESET_PORT_STATS:
+		port = (uint) arg;
+		rio_dprintk(RIO_DEBUG_CTRL, "RIO_RESET_PORT_STATS\n");
+		if (port >= RIO_PORTS) {
+			p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
+			return -ENXIO;
+		}
+		PortP = (p->RIOPortp[port]);
+		rio_spin_lock_irqsave(&PortP->portSem, flags);
+		PortP->txchars = 0;
+		PortP->rxchars = 0;
+		PortP->opens = 0;
+		PortP->closes = 0;
+		PortP->ioctls = 0;
+		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+		return retval;
+
+	case RIO_GATHER_PORT_STATS:
+		rio_dprintk(RIO_DEBUG_CTRL, "RIO_GATHER_PORT_STATS\n");
+		if (copyin((int) arg, (caddr_t) & portStats, sizeof(struct portStats)) == COPYFAIL) {
+			p->RIOError.Error = COPYIN_FAILED;
+			return -EFAULT;
+		}
+		if (portStats.port >= RIO_PORTS) {
+			p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
+			return -ENXIO;
+		}
+		PortP = (p->RIOPortp[portStats.port]);
+		rio_spin_lock_irqsave(&PortP->portSem, flags);
+		PortP->statsGather = portStats.gather;
+		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+		return retval;
 
 #ifdef DEBUG_SUPPORTED
-			case RIO_READ_LEVELS:
-				{
-					 int num;
-					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_READ_LEVELS\n");
-					 for ( num=0; RIODbInf[num].Flag; num++ ) ;
-					 rio_dprintk (RIO_DEBUG_CTRL, "%d levels to copy\n",num);
-					 if (copyout((caddr_t)RIODbInf,(int)arg,
-						sizeof(struct DbInf)*(num+1))==COPYFAIL) {
-						rio_dprintk (RIO_DEBUG_CTRL, "ReadLevels Copy failed\n");
-						p->RIOError.Error = COPYOUT_FAILED;
-						return -EFAULT;
-					 }
-					 rio_dprintk (RIO_DEBUG_CTRL, "%d levels to copied\n",num);
-					 return retval;
-				}
+	case RIO_READ_LEVELS:
+		{
+			int num;
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_READ_LEVELS\n");
+			for (num = 0; RIODbInf[num].Flag; num++);
+			rio_dprintk(RIO_DEBUG_CTRL, "%d levels to copy\n", num);
+			if (copyout((caddr_t) RIODbInf, (int) arg, sizeof(struct DbInf) * (num + 1)) == COPYFAIL) {
+				rio_dprintk(RIO_DEBUG_CTRL, "ReadLevels Copy failed\n");
+				p->RIOError.Error = COPYOUT_FAILED;
+				return -EFAULT;
+			}
+			rio_dprintk(RIO_DEBUG_CTRL, "%d levels to copied\n", num);
+			return retval;
+		}
 #endif
 
-			 case RIO_READ_CONFIG:
-				rio_dprintk (RIO_DEBUG_CTRL, "RIO_READ_CONFIG\n");
-				if (copyout((caddr_t)&p->RIOConf, (int)arg, 
-							sizeof(struct Conf)) ==COPYFAIL ) {
-					 p->RIOError.Error = COPYOUT_FAILED;
-					 return -EFAULT;
-				}
-				return retval;
+	case RIO_READ_CONFIG:
+		rio_dprintk(RIO_DEBUG_CTRL, "RIO_READ_CONFIG\n");
+		if (copyout((caddr_t) & p->RIOConf, (int) arg, sizeof(struct Conf)) == COPYFAIL) {
+			p->RIOError.Error = COPYOUT_FAILED;
+			return -EFAULT;
+		}
+		return retval;
 
-			case RIO_SET_CONFIG:
-				rio_dprintk (RIO_DEBUG_CTRL, "RIO_SET_CONFIG\n");
-				if ( !su ) {
-					 p->RIOError.Error = NOT_SUPER_USER;
-					 return -EPERM;
-				}
-				if ( copyin((int)arg, (caddr_t)&p->RIOConf, sizeof(struct Conf) )
-						==COPYFAIL ) {
-					 p->RIOError.Error = COPYIN_FAILED;
-					 return -EFAULT;
-				}
-				/*
-				** move a few value around
-				*/
-				for (Host=0; Host < p->RIONumHosts; Host++)
-					 if ( (p->RIOHosts[Host].Flags & RUN_STATE) == RC_RUNNING )
-					 	WWORD(p->RIOHosts[Host].ParmMapP->timer , 
-								p->RIOConf.Timer);
-				return retval;
+	case RIO_SET_CONFIG:
+		rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET_CONFIG\n");
+		if (!su) {
+			p->RIOError.Error = NOT_SUPER_USER;
+			return -EPERM;
+		}
+		if (copyin((int) arg, (caddr_t) & p->RIOConf, sizeof(struct Conf))
+		    == COPYFAIL) {
+			p->RIOError.Error = COPYIN_FAILED;
+			return -EFAULT;
+		}
+		/*
+		 ** move a few value around
+		 */
+		for (Host = 0; Host < p->RIONumHosts; Host++)
+			if ((p->RIOHosts[Host].Flags & RUN_STATE) == RC_RUNNING)
+				WWORD(p->RIOHosts[Host].ParmMapP->timer, p->RIOConf.Timer);
+		return retval;
 
-			case RIO_START_POLLER:
-				rio_dprintk (RIO_DEBUG_CTRL, "RIO_START_POLLER\n");
-				return -EINVAL;
+	case RIO_START_POLLER:
+		rio_dprintk(RIO_DEBUG_CTRL, "RIO_START_POLLER\n");
+		return -EINVAL;
 
-			case RIO_STOP_POLLER:
-				rio_dprintk (RIO_DEBUG_CTRL, "RIO_STOP_POLLER\n");
-				if ( !su ) {
-					 p->RIOError.Error = NOT_SUPER_USER;
-					 return -EPERM;
-				}
-				p->RIOPolling = NOT_POLLING;
-				return retval;
+	case RIO_STOP_POLLER:
+		rio_dprintk(RIO_DEBUG_CTRL, "RIO_STOP_POLLER\n");
+		if (!su) {
+			p->RIOError.Error = NOT_SUPER_USER;
+			return -EPERM;
+		}
+		p->RIOPolling = NOT_POLLING;
+		return retval;
 
-			case RIO_SETDEBUG:
-			case RIO_GETDEBUG:
-				rio_dprintk (RIO_DEBUG_CTRL, "RIO_SETDEBUG/RIO_GETDEBUG\n");
-				if ( copyin( (int)arg, (caddr_t)&DebugCtrl, sizeof(DebugCtrl) )
-							==COPYFAIL ) {
-					 p->RIOError.Error = COPYIN_FAILED;
-					 return -EFAULT;
+	case RIO_SETDEBUG:
+	case RIO_GETDEBUG:
+		rio_dprintk(RIO_DEBUG_CTRL, "RIO_SETDEBUG/RIO_GETDEBUG\n");
+		if (copyin((int) arg, (caddr_t) & DebugCtrl, sizeof(DebugCtrl))
+		    == COPYFAIL) {
+			p->RIOError.Error = COPYIN_FAILED;
+			return -EFAULT;
+		}
+		if (DebugCtrl.SysPort == NO_PORT) {
+			if (cmd == RIO_SETDEBUG) {
+				if (!su) {
+					p->RIOError.Error = NOT_SUPER_USER;
+					return -EPERM;
 				}
-				if ( DebugCtrl.SysPort == NO_PORT ) {
-					if ( cmd == RIO_SETDEBUG ) {
-						if ( !su ) {
-							p->RIOError.Error = NOT_SUPER_USER;
-							return -EPERM;
-						}
-						p->rio_debug = DebugCtrl.Debug;
-						p->RIODebugWait = DebugCtrl.Wait;
-						rio_dprintk (RIO_DEBUG_CTRL, "Set global debug to 0x%x set wait to 0x%x\n",
-							p->rio_debug,p->RIODebugWait);
-					}
-				 	else {
-						rio_dprintk (RIO_DEBUG_CTRL, "Get global debug 0x%x wait 0x%x\n",
-										p->rio_debug,p->RIODebugWait);
-						DebugCtrl.Debug = p->rio_debug;
-						DebugCtrl.Wait  = p->RIODebugWait;
-						if ( copyout((caddr_t)&DebugCtrl,(int)arg,
-								sizeof(DebugCtrl)) == COPYFAIL ) {
-							rio_dprintk (RIO_DEBUG_CTRL, "RIO_SET/GET DEBUG: bad port number %d\n",
-									DebugCtrl.SysPort);
-						 	p->RIOError.Error = COPYOUT_FAILED;
-						 	return -EFAULT;
-						}
-					}
+				p->rio_debug = DebugCtrl.Debug;
+				p->RIODebugWait = DebugCtrl.Wait;
+				rio_dprintk(RIO_DEBUG_CTRL, "Set global debug to 0x%x set wait to 0x%x\n", p->rio_debug, p->RIODebugWait);
+			} else {
+				rio_dprintk(RIO_DEBUG_CTRL, "Get global debug 0x%x wait 0x%x\n", p->rio_debug, p->RIODebugWait);
+				DebugCtrl.Debug = p->rio_debug;
+				DebugCtrl.Wait = p->RIODebugWait;
+				if (copyout((caddr_t) & DebugCtrl, (int) arg, sizeof(DebugCtrl)) == COPYFAIL) {
+					rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET/GET DEBUG: bad port number %d\n", DebugCtrl.SysPort);
+					p->RIOError.Error = COPYOUT_FAILED;
+					return -EFAULT;
 				}
-				else if ( DebugCtrl.SysPort >= RIO_PORTS && 
-							DebugCtrl.SysPort != NO_PORT ) {
-					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_SET/GET DEBUG: bad port number %d\n",
-									DebugCtrl.SysPort);
-					 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
-					 return -ENXIO;
-				}
-				else if ( cmd == RIO_SETDEBUG ) {
-					if ( !su ) {
-						p->RIOError.Error = NOT_SUPER_USER;
-						return -EPERM;
-					}
-					rio_spin_lock_irqsave(&PortP->portSem, flags);
-					p->RIOPortp[DebugCtrl.SysPort]->Debug = DebugCtrl.Debug;
-					rio_spin_unlock_irqrestore( &PortP->portSem , flags);
-					rio_dprintk (RIO_DEBUG_CTRL, "RIO_SETDEBUG 0x%x\n",
-								p->RIOPortp[DebugCtrl.SysPort]->Debug);
-				}
-				else {
-					rio_dprintk (RIO_DEBUG_CTRL, "RIO_GETDEBUG 0x%x\n",
-									 p->RIOPortp[DebugCtrl.SysPort]->Debug);
-					DebugCtrl.Debug = p->RIOPortp[DebugCtrl.SysPort]->Debug;
-					if ( copyout((caddr_t)&DebugCtrl,(int)arg,
-								sizeof(DebugCtrl))==COPYFAIL ) {
-						rio_dprintk (RIO_DEBUG_CTRL, "RIO_GETDEBUG: Bad copy to user space\n");
-						p->RIOError.Error = COPYOUT_FAILED;
-						return -EFAULT;
-					}
-				}
-				return retval;
+			}
+		} else if (DebugCtrl.SysPort >= RIO_PORTS && DebugCtrl.SysPort != NO_PORT) {
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET/GET DEBUG: bad port number %d\n", DebugCtrl.SysPort);
+			p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
+			return -ENXIO;
+		} else if (cmd == RIO_SETDEBUG) {
+			if (!su) {
+				p->RIOError.Error = NOT_SUPER_USER;
+				return -EPERM;
+			}
+			rio_spin_lock_irqsave(&PortP->portSem, flags);
+			p->RIOPortp[DebugCtrl.SysPort]->Debug = DebugCtrl.Debug;
+			rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_SETDEBUG 0x%x\n", p->RIOPortp[DebugCtrl.SysPort]->Debug);
+		} else {
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_GETDEBUG 0x%x\n", p->RIOPortp[DebugCtrl.SysPort]->Debug);
+			DebugCtrl.Debug = p->RIOPortp[DebugCtrl.SysPort]->Debug;
+			if (copyout((caddr_t) & DebugCtrl, (int) arg, sizeof(DebugCtrl)) == COPYFAIL) {
+				rio_dprintk(RIO_DEBUG_CTRL, "RIO_GETDEBUG: Bad copy to user space\n");
+				p->RIOError.Error = COPYOUT_FAILED;
+				return -EFAULT;
+			}
+		}
+		return retval;
 
-			case RIO_VERSID:
-				/*
-				** Enquire about the release and version.
-				** We return MAX_VERSION_LEN bytes, being a
-				** textual null terminated string.
-				*/
-				rio_dprintk (RIO_DEBUG_CTRL, "RIO_VERSID\n");
-				if ( copyout(	(caddr_t)RIOVersid(),
-						(int)arg,
-						sizeof(struct rioVersion) ) == COPYFAIL )
-				{
-					 rio_dprintk (RIO_DEBUG_CTRL,  "RIO_VERSID: Bad copy to user space (host=%d)\n", Host);
-					 p->RIOError.Error = COPYOUT_FAILED;
-					 return -EFAULT;
-				}
-				return retval;
+	case RIO_VERSID:
+		/*
+		 ** Enquire about the release and version.
+		 ** We return MAX_VERSION_LEN bytes, being a
+		 ** textual null terminated string.
+		 */
+		rio_dprintk(RIO_DEBUG_CTRL, "RIO_VERSID\n");
+		if (copyout((caddr_t) RIOVersid(), (int) arg, sizeof(struct rioVersion)) == COPYFAIL) {
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_VERSID: Bad copy to user space (host=%d)\n", Host);
+			p->RIOError.Error = COPYOUT_FAILED;
+			return -EFAULT;
+		}
+		return retval;
 
-			/*
-			** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-			** !! commented out previous 'RIO_VERSID' functionality !!
-			** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-			**
-			case RIO_VERSID:
-				**
-				** Enquire about the release and version.
-				** We return MAX_VERSION_LEN bytes, being a textual null
-				** terminated string.
-				**
-				rio_dprint(RIO_DEBUG_CTRL, ("RIO_VERSID\n"));
-				if (copyout((caddr_t)RIOVersid(), 
-						(int)arg, MAX_VERSION_LEN ) == COPYFAIL ) {
-					 rio_dprint(RIO_DEBUG_CTRL, ("RIO_VERSID: Bad copy to user space\n",Host));
-					 p->RIOError.Error = COPYOUT_FAILED;
-					 return -EFAULT;
-				}
-				return retval;
-			**
-			** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-			*/
+		/*
+		 ** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+		 ** !! commented out previous 'RIO_VERSID' functionality !!
+		 ** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+		 **
+		 case RIO_VERSID:
+		 **
+		 ** Enquire about the release and version.
+		 ** We return MAX_VERSION_LEN bytes, being a textual null
+		 ** terminated string.
+		 **
+		 rio_dprint(RIO_DEBUG_CTRL, ("RIO_VERSID\n"));
+		 if (copyout((caddr_t)RIOVersid(),
+		 (int)arg, MAX_VERSION_LEN ) == COPYFAIL ) {
+		 rio_dprint(RIO_DEBUG_CTRL, ("RIO_VERSID: Bad copy to user space\n",Host));
+		 p->RIOError.Error = COPYOUT_FAILED;
+		 return -EFAULT;
+		 }
+		 return retval;
+		 **
+		 ** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+		 */
 
-			case RIO_NUM_HOSTS:
-				/*
-				** Enquire as to the number of hosts located
-				** at init time.
-				*/
-				rio_dprintk (RIO_DEBUG_CTRL, "RIO_NUM_HOSTS\n");
-				if (copyout((caddr_t)&p->RIONumHosts, (int)arg, 
-							sizeof(p->RIONumHosts) )==COPYFAIL ) {
-					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_NUM_HOSTS: Bad copy to user space\n");
-					 p->RIOError.Error = COPYOUT_FAILED;
-					 return -EFAULT;
-				}
-				return retval;
+	case RIO_NUM_HOSTS:
+		/*
+		 ** Enquire as to the number of hosts located
+		 ** at init time.
+		 */
+		rio_dprintk(RIO_DEBUG_CTRL, "RIO_NUM_HOSTS\n");
+		if (copyout((caddr_t) & p->RIONumHosts, (int) arg, sizeof(p->RIONumHosts)) == COPYFAIL) {
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_NUM_HOSTS: Bad copy to user space\n");
+			p->RIOError.Error = COPYOUT_FAILED;
+			return -EFAULT;
+		}
+		return retval;
 
-			case RIO_HOST_FOAD:
-				/*
-				** Kill host. This may not be in the final version...
-				*/
-				rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_FOAD %d\n", (int)arg);
-				if ( !su ) {
-					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_FOAD: Not super user\n");
-					 p->RIOError.Error = NOT_SUPER_USER;
-					 return -EPERM;
-				}
-				p->RIOHalted = 1;
-				p->RIOSystemUp = 0;
+	case RIO_HOST_FOAD:
+		/*
+		 ** Kill host. This may not be in the final version...
+		 */
+		rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_FOAD %d\n", (int) arg);
+		if (!su) {
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_FOAD: Not super user\n");
+			p->RIOError.Error = NOT_SUPER_USER;
+			return -EPERM;
+		}
+		p->RIOHalted = 1;
+		p->RIOSystemUp = 0;
 
-				for ( Host=0; Host<p->RIONumHosts; Host++ ) {
-					 (void)RIOBoardTest( p->RIOHosts[Host].PaddrP, 
-						p->RIOHosts[Host].Caddr, p->RIOHosts[Host].Type, 
-								p->RIOHosts[Host].Slot );
-					 bzero( (caddr_t)&p->RIOHosts[Host].Flags, 
-							((int)&p->RIOHosts[Host].____end_marker____) -
-								 ((int)&p->RIOHosts[Host].Flags) );
-					 p->RIOHosts[Host].Flags  = RC_WAITING;
+		for (Host = 0; Host < p->RIONumHosts; Host++) {
+			(void) RIOBoardTest(p->RIOHosts[Host].PaddrP, p->RIOHosts[Host].Caddr, p->RIOHosts[Host].Type, p->RIOHosts[Host].Slot);
+			bzero((caddr_t) & p->RIOHosts[Host].Flags, ((int) &p->RIOHosts[Host].____end_marker____) - ((int) &p->RIOHosts[Host].Flags));
+			p->RIOHosts[Host].Flags = RC_WAITING;
 #if 0
-					 RIOSetupDataStructs(p);
+			RIOSetupDataStructs(p);
 #endif
-				}
-				RIOFoadWakeup(p);
-				p->RIONumBootPkts = 0;
-				p->RIOBooting = 0;
+		}
+		RIOFoadWakeup(p);
+		p->RIONumBootPkts = 0;
+		p->RIOBooting = 0;
 
 #ifdef RINGBUFFER_SUPPORT
-				for( loop=0; loop<RIO_PORTS; loop++ )
-					if ( p->RIOPortp[loop]->TxRingBuffer )
-						sysfree((void *)p->RIOPortp[loop]->TxRingBuffer, 
-							RIOBufferSize );
+		for (loop = 0; loop < RIO_PORTS; loop++)
+			if (p->RIOPortp[loop]->TxRingBuffer)
+				sysfree((void *) p->RIOPortp[loop]->TxRingBuffer, RIOBufferSize);
 #endif
 #if 0
-				bzero((caddr_t)&p->RIOPortp[0],RIO_PORTS*sizeof(struct Port));
+		bzero((caddr_t) & p->RIOPortp[0], RIO_PORTS * sizeof(struct Port));
 #else
-				printk ("HEEEEELP!\n");
+		printk("HEEEEELP!\n");
 #endif
 
-				for( loop=0; loop<RIO_PORTS; loop++ ) {
+		for (loop = 0; loop < RIO_PORTS; loop++) {
 #if 0
-					p->RIOPortp[loop]->TtyP = &p->channel[loop];
+			p->RIOPortp[loop]->TtyP = &p->channel[loop];
 #endif
-					
-					spin_lock_init(&p->RIOPortp[loop]->portSem);
-					p->RIOPortp[loop]->InUse = NOT_INUSE;
-				}
 
-				p->RIOSystemUp = 0;
-				return retval;
+			spin_lock_init(&p->RIOPortp[loop]->portSem);
+			p->RIOPortp[loop]->InUse = NOT_INUSE;
+		}
 
-			case RIO_DOWNLOAD:
-				rio_dprintk (RIO_DEBUG_CTRL, "RIO_DOWNLOAD\n");
-				if ( !su ) {
-					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_DOWNLOAD: Not super user\n");
-					 p->RIOError.Error = NOT_SUPER_USER;
-					 return -EPERM;
-				}
-				if ( copyin((int)arg, (caddr_t)&DownLoad, 
-							sizeof(DownLoad) )==COPYFAIL ) {
-					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_DOWNLOAD: Copy in from user space failed\n");
-					 p->RIOError.Error = COPYIN_FAILED;
-					 return -EFAULT;
-				}
-				rio_dprintk (RIO_DEBUG_CTRL, "Copied in download code for product code 0x%x\n",
-				    DownLoad.ProductCode);
+		p->RIOSystemUp = 0;
+		return retval;
 
-				/*
-				** It is important that the product code is an unsigned object!
-				*/
-				if ( DownLoad.ProductCode > MAX_PRODUCT ) {
-					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_DOWNLOAD: Bad product code %d passed\n",
-							DownLoad.ProductCode);
-					 p->RIOError.Error = NO_SUCH_PRODUCT;
-					 return -ENXIO;
-				}
-				/*
-				** do something!
-				*/
-				retval = (*(RIOBootTable[DownLoad.ProductCode]))(p, &DownLoad);
-										/* <-- Panic */
-				p->RIOHalted = 0;
-				/*
-				** and go back, content with a job well completed.
-				*/
-				return retval;
+	case RIO_DOWNLOAD:
+		rio_dprintk(RIO_DEBUG_CTRL, "RIO_DOWNLOAD\n");
+		if (!su) {
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_DOWNLOAD: Not super user\n");
+			p->RIOError.Error = NOT_SUPER_USER;
+			return -EPERM;
+		}
+		if (copyin((int) arg, (caddr_t) & DownLoad, sizeof(DownLoad)) == COPYFAIL) {
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_DOWNLOAD: Copy in from user space failed\n");
+			p->RIOError.Error = COPYIN_FAILED;
+			return -EFAULT;
+		}
+		rio_dprintk(RIO_DEBUG_CTRL, "Copied in download code for product code 0x%x\n", DownLoad.ProductCode);
 
-			case RIO_PARMS:
-				{
-					uint host;
+		/*
+		 ** It is important that the product code is an unsigned object!
+		 */
+		if (DownLoad.ProductCode > MAX_PRODUCT) {
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_DOWNLOAD: Bad product code %d passed\n", DownLoad.ProductCode);
+			p->RIOError.Error = NO_SUCH_PRODUCT;
+			return -ENXIO;
+		}
+		/*
+		 ** do something!
+		 */
+		retval = (*(RIOBootTable[DownLoad.ProductCode])) (p, &DownLoad);
+		/* <-- Panic */
+		p->RIOHalted = 0;
+		/*
+		 ** and go back, content with a job well completed.
+		 */
+		return retval;
 
-					if (copyin((int)arg, (caddr_t)&host, 
-							sizeof(host) ) == COPYFAIL ) {
-						rio_dprintk (RIO_DEBUG_CTRL, 
-							"RIO_HOST_REQ: Copy in from user space failed\n");
-						p->RIOError.Error = COPYIN_FAILED;
-						return -EFAULT;
-					}
-					/*
-					** Fetch the parmmap
-					*/
-					rio_dprintk (RIO_DEBUG_CTRL, "RIO_PARMS\n");
-					if ( copyout( (caddr_t)p->RIOHosts[host].ParmMapP, 
-								(int)arg, sizeof(PARM_MAP) )==COPYFAIL ) {
-						p->RIOError.Error = COPYOUT_FAILED;
-						rio_dprintk (RIO_DEBUG_CTRL, "RIO_PARMS: Copy out to user space failed\n");
-						return -EFAULT;
-					}
-				}
-				return retval;
+	case RIO_PARMS:
+		{
+			uint host;
 
-			case RIO_HOST_REQ:
-				rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_REQ\n");
-				if (copyin((int)arg, (caddr_t)&HostReq, 
-							sizeof(HostReq) )==COPYFAIL ) {
-					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_REQ: Copy in from user space failed\n");
-					 p->RIOError.Error = COPYIN_FAILED;
-					 return -EFAULT;
-				}
-				if ( HostReq.HostNum >= p->RIONumHosts ) {
-					 p->RIOError.Error = HOST_NUMBER_OUT_OF_RANGE;
-					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_REQ: Illegal host number %d\n",
-							HostReq.HostNum);
-					 return -ENXIO;
-				}
-				rio_dprintk (RIO_DEBUG_CTRL, "Request for host %d\n", HostReq.HostNum);
+			if (copyin((int) arg, (caddr_t) & host, sizeof(host)) == COPYFAIL) {
+				rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ: Copy in from user space failed\n");
+				p->RIOError.Error = COPYIN_FAILED;
+				return -EFAULT;
+			}
+			/*
+			 ** Fetch the parmmap
+			 */
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_PARMS\n");
+			if (copyout((caddr_t) p->RIOHosts[host].ParmMapP, (int) arg, sizeof(PARM_MAP)) == COPYFAIL) {
+				p->RIOError.Error = COPYOUT_FAILED;
+				rio_dprintk(RIO_DEBUG_CTRL, "RIO_PARMS: Copy out to user space failed\n");
+				return -EFAULT;
+			}
+		}
+		return retval;
 
-				if (copyout((caddr_t)&p->RIOHosts[HostReq.HostNum], 
-					(int)HostReq.HostP,sizeof(struct Host) ) == COPYFAIL) {
-					p->RIOError.Error = COPYOUT_FAILED;
-					rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_REQ: Bad copy to user space\n");
-					return -EFAULT;
-				}
-				return retval;
+	case RIO_HOST_REQ:
+		rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ\n");
+		if (copyin((int) arg, (caddr_t) & HostReq, sizeof(HostReq)) == COPYFAIL) {
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ: Copy in from user space failed\n");
+			p->RIOError.Error = COPYIN_FAILED;
+			return -EFAULT;
+		}
+		if (HostReq.HostNum >= p->RIONumHosts) {
+			p->RIOError.Error = HOST_NUMBER_OUT_OF_RANGE;
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ: Illegal host number %d\n", HostReq.HostNum);
+			return -ENXIO;
+		}
+		rio_dprintk(RIO_DEBUG_CTRL, "Request for host %d\n", HostReq.HostNum);
 
-			 case RIO_HOST_DPRAM:
-				rio_dprintk (RIO_DEBUG_CTRL, "Request for DPRAM\n");
-				if ( copyin( (int)arg, (caddr_t)&HostDpRam, 
-								sizeof(HostDpRam) )==COPYFAIL ) {
-					rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Copy in from user space failed\n");
-					p->RIOError.Error = COPYIN_FAILED;
-					return -EFAULT;
-				}
-				if ( HostDpRam.HostNum >= p->RIONumHosts ) {
-					p->RIOError.Error = HOST_NUMBER_OUT_OF_RANGE;
-					rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Illegal host number %d\n",
-										HostDpRam.HostNum);
-					return -ENXIO;
-				}
-				rio_dprintk (RIO_DEBUG_CTRL, "Request for host %d\n", HostDpRam.HostNum);
+		if (copyout((caddr_t) & p->RIOHosts[HostReq.HostNum], (int) HostReq.HostP, sizeof(struct Host)) == COPYFAIL) {
+			p->RIOError.Error = COPYOUT_FAILED;
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ: Bad copy to user space\n");
+			return -EFAULT;
+		}
+		return retval;
 
-				if (p->RIOHosts[HostDpRam.HostNum].Type == RIO_PCI) {
-					 int off;
-					 /* It's hardware like this that really gets on my tits. */
-					 static unsigned char copy[sizeof(struct DpRam)];
-					for ( off=0; off<sizeof(struct DpRam); off++ )
-						copy[off] = p->RIOHosts[HostDpRam.HostNum].Caddr[off];
-					if ( copyout( (caddr_t)copy, (int)HostDpRam.DpRamP, 
-							sizeof(struct DpRam) ) == COPYFAIL ) {
-						p->RIOError.Error = COPYOUT_FAILED;
-						rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Bad copy to user space\n");
-						return -EFAULT;
-					}
-				}
-				else if (copyout((caddr_t)p->RIOHosts[HostDpRam.HostNum].Caddr,
-					(int)HostDpRam.DpRamP, 
-						sizeof(struct DpRam) ) == COPYFAIL ) {
-					 p->RIOError.Error = COPYOUT_FAILED;
-					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Bad copy to user space\n");
-					 return -EFAULT;
-				}
-				return retval;
+	case RIO_HOST_DPRAM:
+		rio_dprintk(RIO_DEBUG_CTRL, "Request for DPRAM\n");
+		if (copyin((int) arg, (caddr_t) & HostDpRam, sizeof(HostDpRam)) == COPYFAIL) {
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Copy in from user space failed\n");
+			p->RIOError.Error = COPYIN_FAILED;
+			return -EFAULT;
+		}
+		if (HostDpRam.HostNum >= p->RIONumHosts) {
+			p->RIOError.Error = HOST_NUMBER_OUT_OF_RANGE;
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Illegal host number %d\n", HostDpRam.HostNum);
+			return -ENXIO;
+		}
+		rio_dprintk(RIO_DEBUG_CTRL, "Request for host %d\n", HostDpRam.HostNum);
 
-			 case RIO_SET_BUSY:
-				rio_dprintk (RIO_DEBUG_CTRL, "RIO_SET_BUSY\n");
-				if ( (int)arg < 0 || (int)arg > 511 ) {
-					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_SET_BUSY: Bad port number %d\n",(int)arg);
-					 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
-					 return -EINVAL;
-				}
-				rio_spin_lock_irqsave(&PortP->portSem, flags);
-				p->RIOPortp[(int)arg]->State |= RIO_BUSY;
-				rio_spin_unlock_irqrestore( &PortP->portSem , flags);
-				return retval;
+		if (p->RIOHosts[HostDpRam.HostNum].Type == RIO_PCI) {
+			int off;
+			/* It's hardware like this that really gets on my tits. */
+			static unsigned char copy[sizeof(struct DpRam)];
+			for (off = 0; off < sizeof(struct DpRam); off++)
+				copy[off] = p->RIOHosts[HostDpRam.HostNum].Caddr[off];
+			if (copyout((caddr_t) copy, (int) HostDpRam.DpRamP, sizeof(struct DpRam)) == COPYFAIL) {
+				p->RIOError.Error = COPYOUT_FAILED;
+				rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Bad copy to user space\n");
+				return -EFAULT;
+			}
+		} else if (copyout((caddr_t) p->RIOHosts[HostDpRam.HostNum].Caddr, (int) HostDpRam.DpRamP, sizeof(struct DpRam)) == COPYFAIL) {
+			p->RIOError.Error = COPYOUT_FAILED;
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Bad copy to user space\n");
+			return -EFAULT;
+		}
+		return retval;
 
-			 case RIO_HOST_PORT:
-				/*
-				** The daemon want port information
-				** (probably for debug reasons)
-				*/
-				rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_PORT\n");
-				if ( copyin((int)arg, (caddr_t)&PortReq, 
-					sizeof(PortReq) )==COPYFAIL ) {
-					rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_PORT: Copy in from user space failed\n");
-					p->RIOError.Error = COPYIN_FAILED;
-					return -EFAULT;
-				}
+	case RIO_SET_BUSY:
+		rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET_BUSY\n");
+		if ((int) arg < 0 || (int) arg > 511) {
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET_BUSY: Bad port number %d\n", (int) arg);
+			p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
+			return -EINVAL;
+		}
+		rio_spin_lock_irqsave(&PortP->portSem, flags);
+		p->RIOPortp[(int) arg]->State |= RIO_BUSY;
+		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+		return retval;
 
-				if (PortReq.SysPort >= RIO_PORTS) { /* SysPort is unsigned */
-					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_PORT: Illegal port number %d\n",
-											PortReq.SysPort);
-					 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
-					 return -ENXIO;
-				}
-				rio_dprintk (RIO_DEBUG_CTRL, "Request for port %d\n", PortReq.SysPort);
-				if (copyout((caddr_t)p->RIOPortp[PortReq.SysPort], 
-							 (int)PortReq.PortP,
-								sizeof(struct Port) ) == COPYFAIL) {
-					 p->RIOError.Error = COPYOUT_FAILED;
-					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_PORT: Bad copy to user space\n");
-					 return -EFAULT;
-				}
-				return retval;
+	case RIO_HOST_PORT:
+		/*
+		 ** The daemon want port information
+		 ** (probably for debug reasons)
+		 */
+		rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_PORT\n");
+		if (copyin((int) arg, (caddr_t) & PortReq, sizeof(PortReq)) == COPYFAIL) {
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_PORT: Copy in from user space failed\n");
+			p->RIOError.Error = COPYIN_FAILED;
+			return -EFAULT;
+		}
 
-			case RIO_HOST_RUP:
-				/*
-				** The daemon want rup information
-				** (probably for debug reasons)
-				*/
-				rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_RUP\n");
-				if (copyin((int)arg, (caddr_t)&RupReq, 
-						sizeof(RupReq) )==COPYFAIL ) {
-					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_RUP: Copy in from user space failed\n");
-					 p->RIOError.Error = COPYIN_FAILED;
-					 return -EFAULT;
-				}
-				if (RupReq.HostNum >= p->RIONumHosts) { /* host is unsigned */
-					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_RUP: Illegal host number %d\n",
-								RupReq.HostNum);
-					 p->RIOError.Error = HOST_NUMBER_OUT_OF_RANGE;
-					 return -ENXIO;
-				}
-				if ( RupReq.RupNum >= MAX_RUP+LINKS_PER_UNIT ) { /* eek! */
-					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_RUP: Illegal rup number %d\n",
-							RupReq.RupNum);
-					 p->RIOError.Error = RUP_NUMBER_OUT_OF_RANGE;
-					 return -EINVAL;
-				}
-				HostP = &p->RIOHosts[RupReq.HostNum];
+		if (PortReq.SysPort >= RIO_PORTS) {	/* SysPort is unsigned */
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_PORT: Illegal port number %d\n", PortReq.SysPort);
+			p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
+			return -ENXIO;
+		}
+		rio_dprintk(RIO_DEBUG_CTRL, "Request for port %d\n", PortReq.SysPort);
+		if (copyout((caddr_t) p->RIOPortp[PortReq.SysPort], (int) PortReq.PortP, sizeof(struct Port)) == COPYFAIL) {
+			p->RIOError.Error = COPYOUT_FAILED;
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_PORT: Bad copy to user space\n");
+			return -EFAULT;
+		}
+		return retval;
 
-				if ((HostP->Flags & RUN_STATE) != RC_RUNNING) {
-					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_RUP: Host %d not running\n",
-							RupReq.HostNum);
-					 p->RIOError.Error = HOST_NOT_RUNNING;
-					 return -EIO;
-				}
-				rio_dprintk (RIO_DEBUG_CTRL, "Request for rup %d from host %d\n",
-						RupReq.RupNum,RupReq.HostNum);
+	case RIO_HOST_RUP:
+		/*
+		 ** The daemon want rup information
+		 ** (probably for debug reasons)
+		 */
+		rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_RUP\n");
+		if (copyin((int) arg, (caddr_t) & RupReq, sizeof(RupReq)) == COPYFAIL) {
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_RUP: Copy in from user space failed\n");
+			p->RIOError.Error = COPYIN_FAILED;
+			return -EFAULT;
+		}
+		if (RupReq.HostNum >= p->RIONumHosts) {	/* host is unsigned */
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_RUP: Illegal host number %d\n", RupReq.HostNum);
+			p->RIOError.Error = HOST_NUMBER_OUT_OF_RANGE;
+			return -ENXIO;
+		}
+		if (RupReq.RupNum >= MAX_RUP + LINKS_PER_UNIT) {	/* eek! */
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_RUP: Illegal rup number %d\n", RupReq.RupNum);
+			p->RIOError.Error = RUP_NUMBER_OUT_OF_RANGE;
+			return -EINVAL;
+		}
+		HostP = &p->RIOHosts[RupReq.HostNum];
 
-				if (copyout((caddr_t)HostP->UnixRups[RupReq.RupNum].RupP,
-					(int)RupReq.RupP,sizeof(struct RUP) ) == COPYFAIL) {
-					p->RIOError.Error = COPYOUT_FAILED;
-					rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_RUP: Bad copy to user space\n");
-					return -EFAULT;
-				}
-				return retval;
+		if ((HostP->Flags & RUN_STATE) != RC_RUNNING) {
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_RUP: Host %d not running\n", RupReq.HostNum);
+			p->RIOError.Error = HOST_NOT_RUNNING;
+			return -EIO;
+		}
+		rio_dprintk(RIO_DEBUG_CTRL, "Request for rup %d from host %d\n", RupReq.RupNum, RupReq.HostNum);
 
-			case RIO_HOST_LPB:
-				/*
-				** The daemon want lpb information
-				** (probably for debug reasons)
-				*/
-				rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_LPB\n");
-				if (copyin((int)arg, (caddr_t)&LpbReq, 
-					sizeof(LpbReq) )==COPYFAIL ) {
-					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_LPB: Bad copy from user space\n");
-					 p->RIOError.Error = COPYIN_FAILED;
-					 return -EFAULT;
-				}
-				if (LpbReq.Host >= p->RIONumHosts) { /* host is unsigned */
-					rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_LPB: Illegal host number %d\n",
-							LpbReq.Host);
-					p->RIOError.Error = HOST_NUMBER_OUT_OF_RANGE;
-					return -ENXIO;
-				}
-				if ( LpbReq.Link >= LINKS_PER_UNIT ) { /* eek! */
-					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_LPB: Illegal link number %d\n",
-							LpbReq.Link);
-					 p->RIOError.Error = LINK_NUMBER_OUT_OF_RANGE;
-					 return -EINVAL;
-				}
-				HostP = &p->RIOHosts[LpbReq.Host];
+		if (copyout((caddr_t) HostP->UnixRups[RupReq.RupNum].RupP, (int) RupReq.RupP, sizeof(struct RUP)) == COPYFAIL) {
+			p->RIOError.Error = COPYOUT_FAILED;
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_RUP: Bad copy to user space\n");
+			return -EFAULT;
+		}
+		return retval;
 
-				if ( (HostP->Flags & RUN_STATE) != RC_RUNNING ) {
-					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_LPB: Host %d not running\n",
-						LpbReq.Host );
-					 p->RIOError.Error = HOST_NOT_RUNNING;
-					 return -EIO;
-				}
-				rio_dprintk (RIO_DEBUG_CTRL, "Request for lpb %d from host %d\n",
-					LpbReq.Link, LpbReq.Host);
+	case RIO_HOST_LPB:
+		/*
+		 ** The daemon want lpb information
+		 ** (probably for debug reasons)
+		 */
+		rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_LPB\n");
+		if (copyin((int) arg, (caddr_t) & LpbReq, sizeof(LpbReq)) == COPYFAIL) {
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_LPB: Bad copy from user space\n");
+			p->RIOError.Error = COPYIN_FAILED;
+			return -EFAULT;
+		}
+		if (LpbReq.Host >= p->RIONumHosts) {	/* host is unsigned */
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_LPB: Illegal host number %d\n", LpbReq.Host);
+			p->RIOError.Error = HOST_NUMBER_OUT_OF_RANGE;
+			return -ENXIO;
+		}
+		if (LpbReq.Link >= LINKS_PER_UNIT) {	/* eek! */
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_LPB: Illegal link number %d\n", LpbReq.Link);
+			p->RIOError.Error = LINK_NUMBER_OUT_OF_RANGE;
+			return -EINVAL;
+		}
+		HostP = &p->RIOHosts[LpbReq.Host];
 
-				if (copyout((caddr_t)&HostP->LinkStrP[LpbReq.Link],
-					(int)LpbReq.LpbP,sizeof(struct LPB) ) == COPYFAIL) {
-					rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_LPB: Bad copy to user space\n");
-					p->RIOError.Error = COPYOUT_FAILED;
-					return -EFAULT;
-				}
-				return retval;
+		if ((HostP->Flags & RUN_STATE) != RC_RUNNING) {
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_LPB: Host %d not running\n", LpbReq.Host);
+			p->RIOError.Error = HOST_NOT_RUNNING;
+			return -EIO;
+		}
+		rio_dprintk(RIO_DEBUG_CTRL, "Request for lpb %d from host %d\n", LpbReq.Link, LpbReq.Host);
 
-				/*
-				** Here 3 IOCTL's that allow us to change the way in which
-				** rio logs errors. send them just to syslog or send them
-				** to both syslog and console or send them to just the console.
-				**
-				** See RioStrBuf() in util.c for the other half.
-				*/
-			case RIO_SYSLOG_ONLY:
-				p->RIOPrintLogState = PRINT_TO_LOG;	/* Just syslog */
-				return 0;
+		if (copyout((caddr_t) & HostP->LinkStrP[LpbReq.Link], (int) LpbReq.LpbP, sizeof(struct LPB)) == COPYFAIL) {
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_LPB: Bad copy to user space\n");
+			p->RIOError.Error = COPYOUT_FAILED;
+			return -EFAULT;
+		}
+		return retval;
 
-			case RIO_SYSLOG_CONS:
-				p->RIOPrintLogState = PRINT_TO_LOG_CONS;/* syslog and console */
-				return 0;
+		/*
+		 ** Here 3 IOCTL's that allow us to change the way in which
+		 ** rio logs errors. send them just to syslog or send them
+		 ** to both syslog and console or send them to just the console.
+		 **
+		 ** See RioStrBuf() in util.c for the other half.
+		 */
+	case RIO_SYSLOG_ONLY:
+		p->RIOPrintLogState = PRINT_TO_LOG;	/* Just syslog */
+		return 0;
 
-			case RIO_CONS_ONLY:
-				p->RIOPrintLogState = PRINT_TO_CONS;	/* Just console */
-				return 0;
+	case RIO_SYSLOG_CONS:
+		p->RIOPrintLogState = PRINT_TO_LOG_CONS;	/* syslog and console */
+		return 0;
 
-			case RIO_SIGNALS_ON:
-				if ( p->RIOSignalProcess ) {
-					 p->RIOError.Error = SIGNALS_ALREADY_SET;
-					 return -EBUSY;
-				}
-				p->RIOSignalProcess = getpid();
-				p->RIOPrintDisabled = DONT_PRINT;
-				return retval;
+	case RIO_CONS_ONLY:
+		p->RIOPrintLogState = PRINT_TO_CONS;	/* Just console */
+		return 0;
 
-			case RIO_SIGNALS_OFF:
-				if ( p->RIOSignalProcess != getpid() ) {
-					 p->RIOError.Error = NOT_RECEIVING_PROCESS;
-					 return -EPERM;
-				}
-				rio_dprintk (RIO_DEBUG_CTRL, "Clear signal process to zero\n");
-				p->RIOSignalProcess = 0;
-				return retval;
+	case RIO_SIGNALS_ON:
+		if (p->RIOSignalProcess) {
+			p->RIOError.Error = SIGNALS_ALREADY_SET;
+			return -EBUSY;
+		}
+		p->RIOSignalProcess = getpid();
+		p->RIOPrintDisabled = DONT_PRINT;
+		return retval;
 
-			case RIO_SET_BYTE_MODE:
-				for ( Host=0; Host<p->RIONumHosts; Host++ )
-					 if ( p->RIOHosts[Host].Type == RIO_AT )
-						 p->RIOHosts[Host].Mode &= ~WORD_OPERATION;
-				return retval;
+	case RIO_SIGNALS_OFF:
+		if (p->RIOSignalProcess != getpid()) {
+			p->RIOError.Error = NOT_RECEIVING_PROCESS;
+			return -EPERM;
+		}
+		rio_dprintk(RIO_DEBUG_CTRL, "Clear signal process to zero\n");
+		p->RIOSignalProcess = 0;
+		return retval;
 
-			case RIO_SET_WORD_MODE:
-				for ( Host=0; Host<p->RIONumHosts; Host++ )
-					 if ( p->RIOHosts[Host].Type == RIO_AT )
-						 p->RIOHosts[Host].Mode |= WORD_OPERATION;
-				return retval;
+	case RIO_SET_BYTE_MODE:
+		for (Host = 0; Host < p->RIONumHosts; Host++)
+			if (p->RIOHosts[Host].Type == RIO_AT)
+				p->RIOHosts[Host].Mode &= ~WORD_OPERATION;
+		return retval;
 
-			case RIO_SET_FAST_BUS:
-				for ( Host=0; Host<p->RIONumHosts; Host++ )
-					 if ( p->RIOHosts[Host].Type == RIO_AT )
-						 p->RIOHosts[Host].Mode |= FAST_AT_BUS;
-				return retval;
+	case RIO_SET_WORD_MODE:
+		for (Host = 0; Host < p->RIONumHosts; Host++)
+			if (p->RIOHosts[Host].Type == RIO_AT)
+				p->RIOHosts[Host].Mode |= WORD_OPERATION;
+		return retval;
 
-			case RIO_SET_SLOW_BUS:
-				for ( Host=0; Host<p->RIONumHosts; Host++ )
-					 if ( p->RIOHosts[Host].Type == RIO_AT )
-						 p->RIOHosts[Host].Mode &= ~FAST_AT_BUS;
-				return retval;
+	case RIO_SET_FAST_BUS:
+		for (Host = 0; Host < p->RIONumHosts; Host++)
+			if (p->RIOHosts[Host].Type == RIO_AT)
+				p->RIOHosts[Host].Mode |= FAST_AT_BUS;
+		return retval;
 
-			case RIO_MAP_B50_TO_50:
-			case RIO_MAP_B50_TO_57600:
-			case RIO_MAP_B110_TO_110:
-			case RIO_MAP_B110_TO_115200:
-				rio_dprintk (RIO_DEBUG_CTRL, "Baud rate mapping\n");
-				port = (uint) arg;
-				if ( port < 0 || port > 511 ) {
-					 rio_dprintk (RIO_DEBUG_CTRL, "Baud rate mapping: Bad port number %d\n", port);
-					 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
-					 return -EINVAL;
-				}
-				rio_spin_lock_irqsave(&PortP->portSem, flags);
-				switch( cmd )
-				{
-					case RIO_MAP_B50_TO_50 :
-						p->RIOPortp[port]->Config |= RIO_MAP_50_TO_50;
-						break;
-					case RIO_MAP_B50_TO_57600 :
-						p->RIOPortp[port]->Config &= ~RIO_MAP_50_TO_50;
-						break;
-					case RIO_MAP_B110_TO_110 :
-						p->RIOPortp[port]->Config |= RIO_MAP_110_TO_110;
-						break;
-					case RIO_MAP_B110_TO_115200 :
-						p->RIOPortp[port]->Config &= ~RIO_MAP_110_TO_110;
-						break;
-				}
-				rio_spin_unlock_irqrestore( &PortP->portSem , flags);
-				return retval;
+	case RIO_SET_SLOW_BUS:
+		for (Host = 0; Host < p->RIONumHosts; Host++)
+			if (p->RIOHosts[Host].Type == RIO_AT)
+				p->RIOHosts[Host].Mode &= ~FAST_AT_BUS;
+		return retval;
 
-			case RIO_STREAM_INFO:
-				rio_dprintk (RIO_DEBUG_CTRL, "RIO_STREAM_INFO\n");
-				return -EINVAL;
+	case RIO_MAP_B50_TO_50:
+	case RIO_MAP_B50_TO_57600:
+	case RIO_MAP_B110_TO_110:
+	case RIO_MAP_B110_TO_115200:
+		rio_dprintk(RIO_DEBUG_CTRL, "Baud rate mapping\n");
+		port = (uint) arg;
+		if (port < 0 || port > 511) {
+			rio_dprintk(RIO_DEBUG_CTRL, "Baud rate mapping: Bad port number %d\n", port);
+			p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
+			return -EINVAL;
+		}
+		rio_spin_lock_irqsave(&PortP->portSem, flags);
+		switch (cmd) {
+		case RIO_MAP_B50_TO_50:
+			p->RIOPortp[port]->Config |= RIO_MAP_50_TO_50;
+			break;
+		case RIO_MAP_B50_TO_57600:
+			p->RIOPortp[port]->Config &= ~RIO_MAP_50_TO_50;
+			break;
+		case RIO_MAP_B110_TO_110:
+			p->RIOPortp[port]->Config |= RIO_MAP_110_TO_110;
+			break;
+		case RIO_MAP_B110_TO_115200:
+			p->RIOPortp[port]->Config &= ~RIO_MAP_110_TO_110;
+			break;
+		}
+		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+		return retval;
 
-			case RIO_SEND_PACKET:
-				rio_dprintk (RIO_DEBUG_CTRL, "RIO_SEND_PACKET\n");
-				if ( copyin( (int)arg, (caddr_t)&SendPack,
-									sizeof(SendPack) )==COPYFAIL ) {
-					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_SEND_PACKET: Bad copy from user space\n");
-					 p->RIOError.Error = COPYIN_FAILED;
-					 return -EFAULT;
-				}
-				if ( SendPack.PortNum >= 128 ) {
-					 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
-					 return -ENXIO;
-				}
+	case RIO_STREAM_INFO:
+		rio_dprintk(RIO_DEBUG_CTRL, "RIO_STREAM_INFO\n");
+		return -EINVAL;
 
-				PortP = p->RIOPortp[SendPack.PortNum];
-				rio_spin_lock_irqsave(&PortP->portSem, flags);
+	case RIO_SEND_PACKET:
+		rio_dprintk(RIO_DEBUG_CTRL, "RIO_SEND_PACKET\n");
+		if (copyin((int) arg, (caddr_t) & SendPack, sizeof(SendPack)) == COPYFAIL) {
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_SEND_PACKET: Bad copy from user space\n");
+			p->RIOError.Error = COPYIN_FAILED;
+			return -EFAULT;
+		}
+		if (SendPack.PortNum >= 128) {
+			p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
+			return -ENXIO;
+		}
 
-				if ( !can_add_transmit(&PacketP,PortP) ) {
-					 p->RIOError.Error = UNIT_IS_IN_USE;
-					 rio_spin_unlock_irqrestore( &PortP->portSem , flags);
-					 return -ENOSPC;
-				}
+		PortP = p->RIOPortp[SendPack.PortNum];
+		rio_spin_lock_irqsave(&PortP->portSem, flags);
 
-				for ( loop=0; loop<(ushort)(SendPack.Len & 127); loop++ )
-					 WBYTE(PacketP->data[loop], SendPack.Data[loop] );
+		if (!can_add_transmit(&PacketP, PortP)) {
+			p->RIOError.Error = UNIT_IS_IN_USE;
+			rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+			return -ENOSPC;
+		}
 
-				WBYTE(PacketP->len, SendPack.Len);
+		for (loop = 0; loop < (ushort) (SendPack.Len & 127); loop++)
+			WBYTE(PacketP->data[loop], SendPack.Data[loop]);
 
-				add_transmit( PortP );
-				/*
-				** Count characters transmitted for port statistics reporting
-				*/
-				if (PortP->statsGather)
-					 PortP->txchars += (SendPack.Len & 127);
-				rio_spin_unlock_irqrestore( &PortP->portSem , flags);
-				return retval;
+		WBYTE(PacketP->len, SendPack.Len);
 
-			case RIO_NO_MESG:
-				if ( su )
-					 p->RIONoMessage = 1;
-				return su ? 0 : -EPERM;
+		add_transmit(PortP);
+		/*
+		 ** Count characters transmitted for port statistics reporting
+		 */
+		if (PortP->statsGather)
+			PortP->txchars += (SendPack.Len & 127);
+		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+		return retval;
 
-			case RIO_MESG:
-				if ( su )
-					p->RIONoMessage = 0;
-				return su ? 0 : -EPERM;
+	case RIO_NO_MESG:
+		if (su)
+			p->RIONoMessage = 1;
+		return su ? 0 : -EPERM;
 
-			case RIO_WHAT_MESG:
-				if ( copyout( (caddr_t)&p->RIONoMessage, (int)arg, 
-					sizeof(p->RIONoMessage) )==COPYFAIL ) {
-					rio_dprintk (RIO_DEBUG_CTRL, "RIO_WHAT_MESG: Bad copy to user space\n");
-					p->RIOError.Error = COPYOUT_FAILED;
-					return -EFAULT;
-				}
-				return 0;
+	case RIO_MESG:
+		if (su)
+			p->RIONoMessage = 0;
+		return su ? 0 : -EPERM;
 
-			case RIO_MEM_DUMP :
-				if (copyin((int)arg, (caddr_t)&SubCmd, 
-						sizeof(struct SubCmdStruct)) == COPYFAIL) {
-					 p->RIOError.Error = COPYIN_FAILED;
-					 return -EFAULT;
-				}
-				rio_dprintk (RIO_DEBUG_CTRL, "RIO_MEM_DUMP host %d rup %d addr %x\n", 
-						SubCmd.Host, SubCmd.Rup, SubCmd.Addr);
+	case RIO_WHAT_MESG:
+		if (copyout((caddr_t) & p->RIONoMessage, (int) arg, sizeof(p->RIONoMessage)) == COPYFAIL) {
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_WHAT_MESG: Bad copy to user space\n");
+			p->RIOError.Error = COPYOUT_FAILED;
+			return -EFAULT;
+		}
+		return 0;
 
-				if (SubCmd.Rup >= MAX_RUP+LINKS_PER_UNIT ) {
-					 p->RIOError.Error = RUP_NUMBER_OUT_OF_RANGE;
-					 return -EINVAL;
-				}
+	case RIO_MEM_DUMP:
+		if (copyin((int) arg, (caddr_t) & SubCmd, sizeof(struct SubCmdStruct)) == COPYFAIL) {
+			p->RIOError.Error = COPYIN_FAILED;
+			return -EFAULT;
+		}
+		rio_dprintk(RIO_DEBUG_CTRL, "RIO_MEM_DUMP host %d rup %d addr %x\n", SubCmd.Host, SubCmd.Rup, SubCmd.Addr);
 
-				if (SubCmd.Host >= p->RIONumHosts ) {
-					 p->RIOError.Error = HOST_NUMBER_OUT_OF_RANGE;
-					 return -EINVAL;
-				}
+		if (SubCmd.Rup >= MAX_RUP + LINKS_PER_UNIT) {
+			p->RIOError.Error = RUP_NUMBER_OUT_OF_RANGE;
+			return -EINVAL;
+		}
 
-				port = p->RIOHosts[SubCmd.Host].
-								UnixRups[SubCmd.Rup].BaseSysPort;
+		if (SubCmd.Host >= p->RIONumHosts) {
+			p->RIOError.Error = HOST_NUMBER_OUT_OF_RANGE;
+			return -EINVAL;
+		}
 
-				PortP = p->RIOPortp[port];
+		port = p->RIOHosts[SubCmd.Host].UnixRups[SubCmd.Rup].BaseSysPort;
 
-				rio_spin_lock_irqsave(&PortP->portSem, flags);
+		PortP = p->RIOPortp[port];
 
-				if ( RIOPreemptiveCmd(p,  PortP, MEMDUMP ) == RIO_FAIL ) {
-					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_MEM_DUMP failed\n");
-					 rio_spin_unlock_irqrestore( &PortP->portSem , flags);
-					 return -EBUSY;
-				}
-				else
-					 PortP->State |= RIO_BUSY;
+		rio_spin_lock_irqsave(&PortP->portSem, flags);
 
-				rio_spin_unlock_irqrestore( &PortP->portSem , flags);
-				if ( copyout( (caddr_t)p->RIOMemDump, (int)arg, 
-							MEMDUMP_SIZE) == COPYFAIL ) {
-					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_MEM_DUMP copy failed\n");
-					 p->RIOError.Error = COPYOUT_FAILED;
-					 return -EFAULT;
-				}
-				return 0;
+		if (RIOPreemptiveCmd(p, PortP, MEMDUMP) == RIO_FAIL) {
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_MEM_DUMP failed\n");
+			rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+			return -EBUSY;
+		} else
+			PortP->State |= RIO_BUSY;
 
-			case RIO_TICK:
-				if ((int)arg < 0 || (int)arg >= p->RIONumHosts)
-					 return -EINVAL;
-				rio_dprintk (RIO_DEBUG_CTRL, "Set interrupt for host %d\n", (int)arg);
-				WBYTE(p->RIOHosts[(int)arg].SetInt , 0xff);
-				return 0;
+		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+		if (copyout((caddr_t) p->RIOMemDump, (int) arg, MEMDUMP_SIZE) == COPYFAIL) {
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_MEM_DUMP copy failed\n");
+			p->RIOError.Error = COPYOUT_FAILED;
+			return -EFAULT;
+		}
+		return 0;
 
-			case RIO_TOCK:
-				if ((int)arg < 0 || (int)arg >= p->RIONumHosts)
-					 return -EINVAL;
-				rio_dprintk (RIO_DEBUG_CTRL, "Clear interrupt for host %d\n", (int)arg);
-				WBYTE((p->RIOHosts[(int)arg].ResetInt) , 0xff);
-				return 0;
+	case RIO_TICK:
+		if ((int) arg < 0 || (int) arg >= p->RIONumHosts)
+			return -EINVAL;
+		rio_dprintk(RIO_DEBUG_CTRL, "Set interrupt for host %d\n", (int) arg);
+		WBYTE(p->RIOHosts[(int) arg].SetInt, 0xff);
+		return 0;
 
-			case RIO_READ_CHECK:
-				/* Check reads for pkts with data[0] the same */
-				p->RIOReadCheck = !p->RIOReadCheck;
-				if (copyout((caddr_t)&p->RIOReadCheck,(int)arg,
-							sizeof(uint))== COPYFAIL) {
-					 p->RIOError.Error = COPYOUT_FAILED;
-					 return -EFAULT;
-				}
-				return 0;
+	case RIO_TOCK:
+		if ((int) arg < 0 || (int) arg >= p->RIONumHosts)
+			return -EINVAL;
+		rio_dprintk(RIO_DEBUG_CTRL, "Clear interrupt for host %d\n", (int) arg);
+		WBYTE((p->RIOHosts[(int) arg].ResetInt), 0xff);
+		return 0;
 
-			case RIO_READ_REGISTER :
-				if (copyin((int)arg, (caddr_t)&SubCmd, 
-							sizeof(struct SubCmdStruct)) == COPYFAIL) {
-					 p->RIOError.Error = COPYIN_FAILED;
-					 return -EFAULT;
-				}
-				rio_dprintk (RIO_DEBUG_CTRL, "RIO_READ_REGISTER host %d rup %d port %d reg %x\n", 
-						SubCmd.Host, SubCmd.Rup, SubCmd.Port, SubCmd.Addr);
+	case RIO_READ_CHECK:
+		/* Check reads for pkts with data[0] the same */
+		p->RIOReadCheck = !p->RIOReadCheck;
+		if (copyout((caddr_t) & p->RIOReadCheck, (int) arg, sizeof(uint)) == COPYFAIL) {
+			p->RIOError.Error = COPYOUT_FAILED;
+			return -EFAULT;
+		}
+		return 0;
 
-				if (SubCmd.Port > 511) {
-					 rio_dprintk (RIO_DEBUG_CTRL, "Baud rate mapping: Bad port number %d\n", 
-								SubCmd.Port);
-					 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
-					 return -EINVAL;
-				}
+	case RIO_READ_REGISTER:
+		if (copyin((int) arg, (caddr_t) & SubCmd, sizeof(struct SubCmdStruct)) == COPYFAIL) {
+			p->RIOError.Error = COPYIN_FAILED;
+			return -EFAULT;
+		}
+		rio_dprintk(RIO_DEBUG_CTRL, "RIO_READ_REGISTER host %d rup %d port %d reg %x\n", SubCmd.Host, SubCmd.Rup, SubCmd.Port, SubCmd.Addr);
 
-				if (SubCmd.Rup >= MAX_RUP+LINKS_PER_UNIT ) {
-					 p->RIOError.Error = RUP_NUMBER_OUT_OF_RANGE;
-					 return -EINVAL;
-				}
+		if (SubCmd.Port > 511) {
+			rio_dprintk(RIO_DEBUG_CTRL, "Baud rate mapping: Bad port number %d\n", SubCmd.Port);
+			p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
+			return -EINVAL;
+		}
 
-				if (SubCmd.Host >= p->RIONumHosts ) {
-					 p->RIOError.Error = HOST_NUMBER_OUT_OF_RANGE;
-					 return -EINVAL;
-				}
+		if (SubCmd.Rup >= MAX_RUP + LINKS_PER_UNIT) {
+			p->RIOError.Error = RUP_NUMBER_OUT_OF_RANGE;
+			return -EINVAL;
+		}
 
-				port = p->RIOHosts[SubCmd.Host].
-						UnixRups[SubCmd.Rup].BaseSysPort + SubCmd.Port;
-				PortP = p->RIOPortp[port];
+		if (SubCmd.Host >= p->RIONumHosts) {
+			p->RIOError.Error = HOST_NUMBER_OUT_OF_RANGE;
+			return -EINVAL;
+		}
 
-				rio_spin_lock_irqsave(&PortP->portSem, flags);
+		port = p->RIOHosts[SubCmd.Host].UnixRups[SubCmd.Rup].BaseSysPort + SubCmd.Port;
+		PortP = p->RIOPortp[port];
 
-				if (RIOPreemptiveCmd(p, PortP, READ_REGISTER) == RIO_FAIL) {
-					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_READ_REGISTER failed\n");
-					 rio_spin_unlock_irqrestore( &PortP->portSem , flags);
-					 return -EBUSY;
-				}
-				else
-					 PortP->State |= RIO_BUSY;
+		rio_spin_lock_irqsave(&PortP->portSem, flags);
 
-				rio_spin_unlock_irqrestore( &PortP->portSem , flags);
-				if (copyout((caddr_t)&p->CdRegister, (int)arg, 
-							sizeof(uint)) == COPYFAIL ) {
-					 rio_dprintk (RIO_DEBUG_CTRL, "RIO_READ_REGISTER copy failed\n");
-					 p->RIOError.Error = COPYOUT_FAILED;
-					 return -EFAULT;
-				}
-				return 0;
-				/*
-				** rio_make_dev: given port number (0-511) ORed with port type
-				** (RIO_DEV_DIRECT, RIO_DEV_MODEM, RIO_DEV_XPRINT) return dev_t
-				** value to pass to mknod to create the correct device node.
-				*/
-			case RIO_MAKE_DEV:
-				{
-					uint port = (uint)arg & RIO_MODEM_MASK;
+		if (RIOPreemptiveCmd(p, PortP, READ_REGISTER) == RIO_FAIL) {
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_READ_REGISTER failed\n");
+			rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+			return -EBUSY;
+		} else
+			PortP->State |= RIO_BUSY;
 
-					switch ( (uint)arg & RIO_DEV_MASK ) {
-						case RIO_DEV_DIRECT:
-							arg = (caddr_t)drv_makedev(MAJOR(dev), port);
-							rio_dprintk (RIO_DEBUG_CTRL, "Makedev direct 0x%x is 0x%x\n",port, (int)arg);
-							return (int)arg;
-					 	case RIO_DEV_MODEM:
-							arg =  (caddr_t)drv_makedev(MAJOR(dev), (port|RIO_MODEM_BIT) );
-							rio_dprintk (RIO_DEBUG_CTRL, "Makedev modem 0x%x is 0x%x\n",port, (int)arg);
-							return (int)arg;
-						case RIO_DEV_XPRINT:
-							arg = (caddr_t)drv_makedev(MAJOR(dev), port);
-							rio_dprintk (RIO_DEBUG_CTRL, "Makedev printer 0x%x is 0x%x\n",port, (int)arg);
-							return (int)arg;
-					}
-					rio_dprintk (RIO_DEBUG_CTRL, "MAKE Device is called\n");
-					return -EINVAL;
-				}
-				/*
-				** rio_minor: given a dev_t from a stat() call, return
-				** the port number (0-511) ORed with the port type
-				** ( RIO_DEV_DIRECT, RIO_DEV_MODEM, RIO_DEV_XPRINT )
-				*/
-			case RIO_MINOR:
-				{
-					dev_t dv;
-					int mino;
+		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+		if (copyout((caddr_t) & p->CdRegister, (int) arg, sizeof(uint)) == COPYFAIL) {
+			rio_dprintk(RIO_DEBUG_CTRL, "RIO_READ_REGISTER copy failed\n");
+			p->RIOError.Error = COPYOUT_FAILED;
+			return -EFAULT;
+		}
+		return 0;
+		/*
+		 ** rio_make_dev: given port number (0-511) ORed with port type
+		 ** (RIO_DEV_DIRECT, RIO_DEV_MODEM, RIO_DEV_XPRINT) return dev_t
+		 ** value to pass to mknod to create the correct device node.
+		 */
+	case RIO_MAKE_DEV:
+		{
+			uint port = (uint) arg & RIO_MODEM_MASK;
 
-					dv = (dev_t)((int)arg);
-					mino = RIO_UNMODEM(dv);
+			switch ((uint) arg & RIO_DEV_MASK) {
+			case RIO_DEV_DIRECT:
+				arg = (caddr_t) drv_makedev(MAJOR(dev), port);
+				rio_dprintk(RIO_DEBUG_CTRL, "Makedev direct 0x%x is 0x%x\n", port, (int) arg);
+				return (int) arg;
+			case RIO_DEV_MODEM:
+				arg = (caddr_t) drv_makedev(MAJOR(dev), (port | RIO_MODEM_BIT));
+				rio_dprintk(RIO_DEBUG_CTRL, "Makedev modem 0x%x is 0x%x\n", port, (int) arg);
+				return (int) arg;
+			case RIO_DEV_XPRINT:
+				arg = (caddr_t) drv_makedev(MAJOR(dev), port);
+				rio_dprintk(RIO_DEBUG_CTRL, "Makedev printer 0x%x is 0x%x\n", port, (int) arg);
+				return (int) arg;
+			}
+			rio_dprintk(RIO_DEBUG_CTRL, "MAKE Device is called\n");
+			return -EINVAL;
+		}
+		/*
+		 ** rio_minor: given a dev_t from a stat() call, return
+		 ** the port number (0-511) ORed with the port type
+		 ** ( RIO_DEV_DIRECT, RIO_DEV_MODEM, RIO_DEV_XPRINT )
+		 */
+	case RIO_MINOR:
+		{
+			dev_t dv;
+			int mino;
 
-					if ( RIO_ISMODEM(dv) ) {
-						rio_dprintk (RIO_DEBUG_CTRL, "Minor for device 0x%x: modem %d\n", dv, mino);
-						arg = (caddr_t)(mino | RIO_DEV_MODEM);
-					}
-					else {
-						rio_dprintk (RIO_DEBUG_CTRL, "Minor for device 0x%x: direct %d\n", dv, mino);
-						arg = (caddr_t)(mino | RIO_DEV_DIRECT);
-					}
-					return (int)arg;
-				}
+			dv = (dev_t) ((int) arg);
+			mino = RIO_UNMODEM(dv);
+
+			if (RIO_ISMODEM(dv)) {
+				rio_dprintk(RIO_DEBUG_CTRL, "Minor for device 0x%x: modem %d\n", dv, mino);
+				arg = (caddr_t) (mino | RIO_DEV_MODEM);
+			} else {
+				rio_dprintk(RIO_DEBUG_CTRL, "Minor for device 0x%x: direct %d\n", dv, mino);
+				arg = (caddr_t) (mino | RIO_DEV_DIRECT);
+			}
+			return (int) arg;
+		}
 	}
-	rio_dprintk (RIO_DEBUG_CTRL, "INVALID DAEMON IOCTL 0x%x\n",cmd);
+	rio_dprintk(RIO_DEBUG_CTRL, "INVALID DAEMON IOCTL 0x%x\n", cmd);
 	p->RIOError.Error = IOCTL_COMMAND_UNKNOWN;
 
-	func_exit ();
+	func_exit();
 	return -EINVAL;
 }
 
 /*
 ** Pre-emptive commands go on RUPs and are only one byte long.
 */
-int
-RIOPreemptiveCmd(p, PortP, Cmd)
-struct rio_info *	p;
+int RIOPreemptiveCmd(p, PortP, Cmd)
+struct rio_info *p;
 struct Port *PortP;
 uchar Cmd;
 {
@@ -1766,104 +1654,99 @@
 	int port;
 
 #ifdef CHECK
-	CheckPortP( PortP );
+	CheckPortP(PortP);
 #endif
 
-	if ( PortP->State & RIO_DELETED ) {
-		rio_dprintk (RIO_DEBUG_CTRL, "Preemptive command to deleted RTA ignored\n");
+	if (PortP->State & RIO_DELETED) {
+		rio_dprintk(RIO_DEBUG_CTRL, "Preemptive command to deleted RTA ignored\n");
 		return RIO_FAIL;
 	}
 
-	if (((int)((char)PortP->InUse) == -1) || ! (CmdBlkP = RIOGetCmdBlk()) ) {
-		rio_dprintk (RIO_DEBUG_CTRL, "Cannot allocate command block for command %d on port %d\n",
-		       Cmd, PortP->PortNum);
+	if (((int) ((char) PortP->InUse) == -1) || !(CmdBlkP = RIOGetCmdBlk())) {
+		rio_dprintk(RIO_DEBUG_CTRL, "Cannot allocate command block for command %d on port %d\n", Cmd, PortP->PortNum);
 		return RIO_FAIL;
 	}
 
-	rio_dprintk (RIO_DEBUG_CTRL, "Command blk 0x%x - InUse now %d\n", 
-	       (int)CmdBlkP,PortP->InUse);
+	rio_dprintk(RIO_DEBUG_CTRL, "Command blk 0x%x - InUse now %d\n", (int) CmdBlkP, PortP->InUse);
 
-	PktCmdP = (struct PktCmd_M *)&CmdBlkP->Packet.data[0];
+	PktCmdP = (struct PktCmd_M *) &CmdBlkP->Packet.data[0];
 
-	CmdBlkP->Packet.src_unit  = 0;
+	CmdBlkP->Packet.src_unit = 0;
 	if (PortP->SecondBlock)
 		rup = PortP->ID2;
 	else
 		rup = PortP->RupNum;
 	CmdBlkP->Packet.dest_unit = rup;
-	CmdBlkP->Packet.src_port  = COMMAND_RUP;
+	CmdBlkP->Packet.src_port = COMMAND_RUP;
 	CmdBlkP->Packet.dest_port = COMMAND_RUP;
-	CmdBlkP->Packet.len	  = PKT_CMD_BIT | 2;
-	CmdBlkP->PostFuncP	= RIOUnUse;
-	CmdBlkP->PostArg	= (int)PortP;
-	PktCmdP->Command	= Cmd;
-	port				= PortP->HostPort % (ushort)PORTS_PER_RTA;
+	CmdBlkP->Packet.len = PKT_CMD_BIT | 2;
+	CmdBlkP->PostFuncP = RIOUnUse;
+	CmdBlkP->PostArg = (int) PortP;
+	PktCmdP->Command = Cmd;
+	port = PortP->HostPort % (ushort) PORTS_PER_RTA;
 	/*
-	** Index ports 8-15 for 2nd block of 16 port RTA.
-	*/
+	 ** Index ports 8-15 for 2nd block of 16 port RTA.
+	 */
 	if (PortP->SecondBlock)
 		port += (ushort) PORTS_PER_RTA;
-	PktCmdP->PhbNum	   = port;
+	PktCmdP->PhbNum = port;
 
-	switch ( Cmd ) {
-		case MEMDUMP:
-			rio_dprintk (RIO_DEBUG_CTRL, "Queue MEMDUMP command blk 0x%x (addr 0x%x)\n",
-			       (int)CmdBlkP, (int)SubCmd.Addr);
-			PktCmdP->SubCommand		= MEMDUMP;
-			PktCmdP->SubAddr		= SubCmd.Addr;
-			break;
-		case FCLOSE:
-			rio_dprintk (RIO_DEBUG_CTRL, "Queue FCLOSE command blk 0x%x\n",(int)CmdBlkP);
-			break;
-		case READ_REGISTER:
-			rio_dprintk (RIO_DEBUG_CTRL, "Queue READ_REGISTER (0x%x) command blk 0x%x\n",
-		 		(int)SubCmd.Addr, (int)CmdBlkP);
-			PktCmdP->SubCommand		= READ_REGISTER;
-			PktCmdP->SubAddr		= SubCmd.Addr;
-			break;
-		case RESUME:
-			rio_dprintk (RIO_DEBUG_CTRL, "Queue RESUME command blk 0x%x\n",(int)CmdBlkP);
-			break;
-		case RFLUSH:
-			rio_dprintk (RIO_DEBUG_CTRL, "Queue RFLUSH command blk 0x%x\n",(int)CmdBlkP);
-			CmdBlkP->PostFuncP = RIORFlushEnable;
-			break;
-		case SUSPEND:
-			rio_dprintk (RIO_DEBUG_CTRL, "Queue SUSPEND command blk 0x%x\n",(int)CmdBlkP);
-			break;
+	switch (Cmd) {
+	case MEMDUMP:
+		rio_dprintk(RIO_DEBUG_CTRL, "Queue MEMDUMP command blk 0x%x (addr 0x%x)\n", (int) CmdBlkP, (int) SubCmd.Addr);
+		PktCmdP->SubCommand = MEMDUMP;
+		PktCmdP->SubAddr = SubCmd.Addr;
+		break;
+	case FCLOSE:
+		rio_dprintk(RIO_DEBUG_CTRL, "Queue FCLOSE command blk 0x%x\n", (int) CmdBlkP);
+		break;
+	case READ_REGISTER:
+		rio_dprintk(RIO_DEBUG_CTRL, "Queue READ_REGISTER (0x%x) command blk 0x%x\n", (int) SubCmd.Addr, (int) CmdBlkP);
+		PktCmdP->SubCommand = READ_REGISTER;
+		PktCmdP->SubAddr = SubCmd.Addr;
+		break;
+	case RESUME:
+		rio_dprintk(RIO_DEBUG_CTRL, "Queue RESUME command blk 0x%x\n", (int) CmdBlkP);
+		break;
+	case RFLUSH:
+		rio_dprintk(RIO_DEBUG_CTRL, "Queue RFLUSH command blk 0x%x\n", (int) CmdBlkP);
+		CmdBlkP->PostFuncP = RIORFlushEnable;
+		break;
+	case SUSPEND:
+		rio_dprintk(RIO_DEBUG_CTRL, "Queue SUSPEND command blk 0x%x\n", (int) CmdBlkP);
+		break;
 
-		case MGET :
-			rio_dprintk (RIO_DEBUG_CTRL, "Queue MGET command blk 0x%x\n", (int)CmdBlkP);
-			break;
+	case MGET:
+		rio_dprintk(RIO_DEBUG_CTRL, "Queue MGET command blk 0x%x\n", (int) CmdBlkP);
+		break;
 
-		case MSET :
-		case MBIC :
-		case MBIS :
-			CmdBlkP->Packet.data[4] = (char) PortP->ModemLines;
-			rio_dprintk (RIO_DEBUG_CTRL, "Queue MSET/MBIC/MBIS command blk 0x%x\n", (int)CmdBlkP);
-			break;
+	case MSET:
+	case MBIC:
+	case MBIS:
+		CmdBlkP->Packet.data[4] = (char) PortP->ModemLines;
+		rio_dprintk(RIO_DEBUG_CTRL, "Queue MSET/MBIC/MBIS command blk 0x%x\n", (int) CmdBlkP);
+		break;
 
-		case WFLUSH:
-			/*
-			** If we have queued up the maximum number of Write flushes
-			** allowed then we should not bother sending any more to the
-			** RTA.
-			*/
-			if ((int)((char)PortP->WflushFlag) == (int)-1) {
-				rio_dprintk (RIO_DEBUG_CTRL, "Trashed WFLUSH, WflushFlag about to wrap!");
-				RIOFreeCmdBlk(CmdBlkP);
-				return(RIO_FAIL);
-			} else {
-				rio_dprintk (RIO_DEBUG_CTRL, "Queue WFLUSH command blk 0x%x\n",
-				       (int)CmdBlkP);
-				CmdBlkP->PostFuncP = RIOWFlushMark;
-			}
-			break;
+	case WFLUSH:
+		/*
+		 ** If we have queued up the maximum number of Write flushes
+		 ** allowed then we should not bother sending any more to the
+		 ** RTA.
+		 */
+		if ((int) ((char) PortP->WflushFlag) == (int) -1) {
+			rio_dprintk(RIO_DEBUG_CTRL, "Trashed WFLUSH, WflushFlag about to wrap!");
+			RIOFreeCmdBlk(CmdBlkP);
+			return (RIO_FAIL);
+		} else {
+			rio_dprintk(RIO_DEBUG_CTRL, "Queue WFLUSH command blk 0x%x\n", (int) CmdBlkP);
+			CmdBlkP->PostFuncP = RIOWFlushMark;
+		}
+		break;
 	}
 
 	PortP->InUse++;
 
-	Ret = RIOQueueCmdBlk( PortP->HostP, rup, CmdBlkP );
+	Ret = RIOQueueCmdBlk(PortP->HostP, rup, CmdBlkP);
 
 	return Ret;
 }
diff --git a/drivers/char/rio/riodrvr.h b/drivers/char/rio/riodrvr.h
index bc38ac5..663ee09 100644
--- a/drivers/char/rio/riodrvr.h
+++ b/drivers/char/rio/riodrvr.h
@@ -33,7 +33,7 @@
 #ifndef __riodrvr_h
 #define __riodrvr_h
 
-#include <asm/param.h>	/* for HZ */
+#include <asm/param.h>		/* for HZ */
 
 #ifdef SCCS_LABELS
 static char *_riodrvr_h_sccs_ = "@(#)riodrvr.h	1.3";
@@ -44,15 +44,15 @@
 
 
 struct rio_info {
-	int			mode;			/* Intr or polled, word/byte */
-	spinlock_t		RIOIntrSem;		/* Interrupt thread sem */
-	int			current_chan;		/* current channel */
-	int			RIOFailed;		/* Not initialised ? */
-	int			RIOInstallAttempts;	/* no. of rio-install() calls */
-	int			RIOLastPCISearch;	/* status of last search */
-	int			RIONumHosts;		/* Number of RIO Hosts */
-	struct Host		* RIOHosts;		/* RIO Host values */
-	struct Port		**RIOPortp;		/* RIO port values */
+	int mode;		/* Intr or polled, word/byte */
+	spinlock_t RIOIntrSem;	/* Interrupt thread sem */
+	int current_chan;	/* current channel */
+	int RIOFailed;		/* Not initialised ? */
+	int RIOInstallAttempts;	/* no. of rio-install() calls */
+	int RIOLastPCISearch;	/* status of last search */
+	int RIONumHosts;	/* Number of RIO Hosts */
+	struct Host *RIOHosts;	/* RIO Host values */
+	struct Port **RIOPortp;	/* RIO port values */
 /*
 ** 02.03.1999 ARG - ESIL 0820 fix
 ** We no longer use RIOBootMode
@@ -60,9 +60,9 @@
 	int			RIOBootMode;		* RIO boot mode *
 **
 */
-	int			RIOPrintDisabled;	/* RIO printing disabled ? */
-	int			RIOPrintLogState;	/* RIO printing state ? */
-	int			RIOPolling;		/* Polling ? */
+	int RIOPrintDisabled;	/* RIO printing disabled ? */
+	int RIOPrintLogState;	/* RIO printing state ? */
+	int RIOPolling;		/* Polling ? */
 /*
 ** 09.12.1998 ARG - ESIL 0776 part fix
 ** The 'RIO_QUICK_CHECK' ioctl was using RIOHalted.
@@ -70,61 +70,61 @@
 ** updated in RIOConCon() - to keep track of RTA connections/disconnections.
 ** 'RIO_QUICK_CHECK' now returns the value of RIORtaDisCons.
 */
-	int			RIOHalted;		/* halted ? */
-	int			RIORtaDisCons;		/* RTA connections/disconnections */
-	uint			RIOReadCheck;		/* Rio read check */
-	uint			RIONoMessage;		/* To display message or not */
-	uint			RIONumBootPkts;		/* how many packets for an RTA */
-	uint			RIOBootCount; 		/* size of RTA code */
-	uint			RIOBooting;		/* count of outstanding boots */
-	uint			RIOSystemUp;		/* Booted ?? */
-	uint			RIOCounting;		/* for counting interrupts */
-	uint			RIOIntCount;		/* # of intr since last check */
-	uint			RIOTxCount;		/* number of xmit intrs  */
-	uint			RIORxCount;		/* number of rx intrs */
-	uint			RIORupCount;		/* number of rup intrs */
-	int			RIXTimer; 
-	int			RIOBufferSize;		/* Buffersize */
-	int			RIOBufferMask;		/* Buffersize */
+	int RIOHalted;		/* halted ? */
+	int RIORtaDisCons;	/* RTA connections/disconnections */
+	uint RIOReadCheck;	/* Rio read check */
+	uint RIONoMessage;	/* To display message or not */
+	uint RIONumBootPkts;	/* how many packets for an RTA */
+	uint RIOBootCount;	/* size of RTA code */
+	uint RIOBooting;	/* count of outstanding boots */
+	uint RIOSystemUp;	/* Booted ?? */
+	uint RIOCounting;	/* for counting interrupts */
+	uint RIOIntCount;	/* # of intr since last check */
+	uint RIOTxCount;	/* number of xmit intrs  */
+	uint RIORxCount;	/* number of rx intrs */
+	uint RIORupCount;	/* number of rup intrs */
+	int RIXTimer;
+	int RIOBufferSize;	/* Buffersize */
+	int RIOBufferMask;	/* Buffersize */
 
-	int			RIOFirstMajor;		/* First host card's major no */
+	int RIOFirstMajor;	/* First host card's major no */
 
-	uint			RIOLastPortsMapped;	/* highest port number known */
-	uint			RIOFirstPortsMapped;	/* lowest port number known */
+	uint RIOLastPortsMapped;	/* highest port number known */
+	uint RIOFirstPortsMapped;	/* lowest port number known */
 
-	uint			RIOLastPortsBooted;	/* highest port number running */
-	uint			RIOFirstPortsBooted;	/* lowest port number running */
+	uint RIOLastPortsBooted;	/* highest port number running */
+	uint RIOFirstPortsBooted;	/* lowest port number running */
 
-	uint			RIOLastPortsOpened;	/* highest port number running */
-	uint			RIOFirstPortsOpened;	/* lowest port number running */
+	uint RIOLastPortsOpened;	/* highest port number running */
+	uint RIOFirstPortsOpened;	/* lowest port number running */
 
 	/* Flag to say that the topology information has been changed. */
-	uint			RIOQuickCheck; 
-	uint			CdRegister;		/* ??? */
-	int			RIOSignalProcess;	/* Signalling process */
-	int			rio_debug;		/* To debug ... */
-	int			RIODebugWait;		/* For what ??? */
-	int			tpri;			/* Thread prio */
-	int			tid;			/* Thread id */
-	uint			_RIO_Polled;		/* Counter for polling */
-	uint			_RIO_Interrupted;	/* Counter for interrupt */
-	int			intr_tid;		/* iointset return value */
-	int			TxEnSem;		/* TxEnable Semaphore */
+	uint RIOQuickCheck;
+	uint CdRegister;	/* ??? */
+	int RIOSignalProcess;	/* Signalling process */
+	int rio_debug;		/* To debug ... */
+	int RIODebugWait;	/* For what ??? */
+	int tpri;		/* Thread prio */
+	int tid;		/* Thread id */
+	uint _RIO_Polled;	/* Counter for polling */
+	uint _RIO_Interrupted;	/* Counter for interrupt */
+	int intr_tid;		/* iointset return value */
+	int TxEnSem;		/* TxEnable Semaphore */
 
 
-	struct Error		RIOError;		/* to Identify what went wrong */ 
-	struct Conf		RIOConf;		/* Configuration ??? */
-	struct ttystatics	channel[RIO_PORTS];	/* channel information */
-	char			RIOBootPackets[1+(SIXTY_FOUR_K/RTA_BOOT_DATA_SIZE)]
-								[RTA_BOOT_DATA_SIZE];
-	struct Map		RIOConnectTable[TOTAL_MAP_ENTRIES];
-	struct Map		RIOSavedTable[TOTAL_MAP_ENTRIES];
+	struct Error RIOError;	/* to Identify what went wrong */
+	struct Conf RIOConf;	/* Configuration ??? */
+	struct ttystatics channel[RIO_PORTS];	/* channel information */
+	char RIOBootPackets[1 + (SIXTY_FOUR_K / RTA_BOOT_DATA_SIZE)]
+	    [RTA_BOOT_DATA_SIZE];
+	struct Map RIOConnectTable[TOTAL_MAP_ENTRIES];
+	struct Map RIOSavedTable[TOTAL_MAP_ENTRIES];
 
 	/* RTA to host binding table for master/slave operation */
-	ulong			RIOBindTab[MAX_RTA_BINDINGS];
+	ulong RIOBindTab[MAX_RTA_BINDINGS];
 	/* RTA memory dump variable */
-	uchar			RIOMemDump[MEMDUMP_SIZE]; 
-	struct ModuleInfo 	RIOModuleTypes[MAX_MODULE_TYPES];
+	uchar RIOMemDump[MEMDUMP_SIZE];
+	struct ModuleInfo RIOModuleTypes[MAX_MODULE_TYPES];
 
 };
 
@@ -141,4 +141,4 @@
 #define WRBYTE(x,y)		*(volatile unsigned char *)((x)) = \
 					(unsigned char)(y)
 
-#endif	/* __riodrvr.h */
+#endif				/* __riodrvr.h */
diff --git a/drivers/char/rio/rioinfo.h b/drivers/char/rio/rioinfo.h
index e08421c..8de7966 100644
--- a/drivers/char/rio/rioinfo.h
+++ b/drivers/char/rio/rioinfo.h
@@ -41,29 +41,29 @@
 ** Host card data structure
 */
 struct RioHostInfo {
-	long	location;	/* RIO Card Base I/O address */
-	long	vector;		/* RIO Card IRQ vector */
-	int	bus;		/* ISA/EISA/MCA/PCI */
-	int	mode;		/* pointer to host mode - INTERRUPT / POLLED */
+	long location;		/* RIO Card Base I/O address */
+	long vector;		/* RIO Card IRQ vector */
+	int bus;		/* ISA/EISA/MCA/PCI */
+	int mode;		/* pointer to host mode - INTERRUPT / POLLED */
 	struct old_sgttyb
-		* Sg;		/* pointer to default term characteristics */
+	*Sg;			/* pointer to default term characteristics */
 };
 
 
 /* Mode in rio device info */
-#define INTERRUPTED_MODE	0x01		/* Interrupt is generated */
-#define POLLED_MODE		0x02		/* No interrupt */
-#define AUTO_MODE		0x03		/* Auto mode */
+#define INTERRUPTED_MODE	0x01	/* Interrupt is generated */
+#define POLLED_MODE		0x02	/* No interrupt */
+#define AUTO_MODE		0x03	/* Auto mode */
 
-#define WORD_ACCESS_MODE	0x10		/* Word Access Mode */
-#define BYTE_ACCESS_MODE	0x20		/* Byte Access Mode */
+#define WORD_ACCESS_MODE	0x10	/* Word Access Mode */
+#define BYTE_ACCESS_MODE	0x20	/* Byte Access Mode */
 
 
 /* Bus type that RIO supports */
-#define ISA_BUS			0x01		/* The card is ISA */
-#define EISA_BUS		0x02		/* The card is EISA */
-#define MCA_BUS			0x04		/* The card is MCA */
-#define PCI_BUS			0x08		/* The card is PCI */
+#define ISA_BUS			0x01	/* The card is ISA */
+#define EISA_BUS		0x02	/* The card is EISA */
+#define MCA_BUS			0x04	/* The card is MCA */
+#define PCI_BUS			0x08	/* The card is PCI */
 
 /*
 ** 11.11.1998 ARG - ESIL ???? part fix
@@ -93,4 +93,4 @@
 	'V' - '@'				/* literal next char */ \
 }
 
-#endif /* __rioinfo_h */
+#endif				/* __rioinfo_h */
diff --git a/drivers/char/rio/riointr.c b/drivers/char/rio/riointr.c
index ddda9c1..34d8787 100644
--- a/drivers/char/rio/riointr.c
+++ b/drivers/char/rio/riointr.c
@@ -88,99 +88,93 @@
 static void RIOReceive(struct rio_info *, struct Port *);
 
 
-static char *firstchars (char *p, int nch)
+static char *firstchars(char *p, int nch)
 {
-  static char buf[2][128];
-  static int t=0;
-  t = ! t;
-  memcpy (buf[t], p, nch);
-  buf[t][nch] = 0;
-  return buf[t];
+	static char buf[2][128];
+	static int t = 0;
+	t = !t;
+	memcpy(buf[t], p, nch);
+	buf[t][nch] = 0;
+	return buf[t];
 }
 
 
 #define	INCR( P, I )	((P) = (((P)+(I)) & p->RIOBufferMask))
 /* Enable and start the transmission of packets */
-void
-RIOTxEnable(en)
-char *		en;
+void RIOTxEnable(en)
+char *en;
 {
-  struct Port *	PortP;
-  struct rio_info *p;
-  struct tty_struct* tty;
-  int c;
-  struct PKT *	PacketP;
-  unsigned long flags;
+	struct Port *PortP;
+	struct rio_info *p;
+	struct tty_struct *tty;
+	int c;
+	struct PKT *PacketP;
+	unsigned long flags;
 
-  PortP = (struct Port *)en; 
-  p = (struct rio_info *)PortP->p;
-  tty = PortP->gs.tty;
+	PortP = (struct Port *) en;
+	p = (struct rio_info *) PortP->p;
+	tty = PortP->gs.tty;
 
 
-  rio_dprintk (RIO_DEBUG_INTR, "tx port %d: %d chars queued.\n", 
-	      PortP->PortNum, PortP->gs.xmit_cnt);
+	rio_dprintk(RIO_DEBUG_INTR, "tx port %d: %d chars queued.\n", PortP->PortNum, PortP->gs.xmit_cnt);
 
-  if (!PortP->gs.xmit_cnt) return;
-  
+	if (!PortP->gs.xmit_cnt)
+		return;
 
-  /* This routine is an order of magnitude simpler than the specialix
-     version. One of the disadvantages is that this version will send
-     an incomplete packet (usually 64 bytes instead of 72) once for
-     every 4k worth of data. Let's just say that this won't influence
-     performance significantly..... */
 
-  rio_spin_lock_irqsave(&PortP->portSem, flags);
+	/* This routine is an order of magnitude simpler than the specialix
+	   version. One of the disadvantages is that this version will send
+	   an incomplete packet (usually 64 bytes instead of 72) once for
+	   every 4k worth of data. Let's just say that this won't influence
+	   performance significantly..... */
 
-  while (can_add_transmit( &PacketP, PortP )) {
-    c = PortP->gs.xmit_cnt;
-    if (c > PKT_MAX_DATA_LEN) c = PKT_MAX_DATA_LEN;
+	rio_spin_lock_irqsave(&PortP->portSem, flags);
 
-    /* Don't copy past the end of the source buffer */
-    if (c > SERIAL_XMIT_SIZE - PortP->gs.xmit_tail) 
-      c = SERIAL_XMIT_SIZE - PortP->gs.xmit_tail;
+	while (can_add_transmit(&PacketP, PortP)) {
+		c = PortP->gs.xmit_cnt;
+		if (c > PKT_MAX_DATA_LEN)
+			c = PKT_MAX_DATA_LEN;
 
-    { int t;
-    t = (c > 10)?10:c;
-    
-    rio_dprintk (RIO_DEBUG_INTR, "rio: tx port %d: copying %d chars: %s - %s\n", 
-		 PortP->PortNum, c, 
-		 firstchars (PortP->gs.xmit_buf + PortP->gs.xmit_tail      , t),
-		 firstchars (PortP->gs.xmit_buf + PortP->gs.xmit_tail + c-t, t));
-    }
-    /* If for one reason or another, we can't copy more data, 
-       we're done! */
-    if (c == 0) break;
+		/* Don't copy past the end of the source buffer */
+		if (c > SERIAL_XMIT_SIZE - PortP->gs.xmit_tail)
+			c = SERIAL_XMIT_SIZE - PortP->gs.xmit_tail;
 
-    rio_memcpy_toio (PortP->HostP->Caddr, (caddr_t)PacketP->data, 
-		 PortP->gs.xmit_buf + PortP->gs.xmit_tail, c);
-    /*    udelay (1); */
+		{
+			int t;
+			t = (c > 10) ? 10 : c;
 
-    writeb (c, &(PacketP->len));
-    if (!( PortP->State & RIO_DELETED ) ) {
-      add_transmit ( PortP );
-      /*
-      ** Count chars tx'd for port statistics reporting
-      */
-      if ( PortP->statsGather )
-	PortP->txchars += c;
-    }
-    PortP->gs.xmit_tail = (PortP->gs.xmit_tail + c) & (SERIAL_XMIT_SIZE-1);
-    PortP->gs.xmit_cnt -= c;
-  }
+			rio_dprintk(RIO_DEBUG_INTR, "rio: tx port %d: copying %d chars: %s - %s\n", PortP->PortNum, c, firstchars(PortP->gs.xmit_buf + PortP->gs.xmit_tail, t), firstchars(PortP->gs.xmit_buf + PortP->gs.xmit_tail + c - t, t));
+		}
+		/* If for one reason or another, we can't copy more data,
+		   we're done! */
+		if (c == 0)
+			break;
 
-  rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+		rio_memcpy_toio(PortP->HostP->Caddr, (caddr_t) PacketP->data, PortP->gs.xmit_buf + PortP->gs.xmit_tail, c);
+		/*    udelay (1); */
 
-  if (PortP->gs.xmit_cnt <= (PortP->gs.wakeup_chars + 2*PKT_MAX_DATA_LEN)) {
-    rio_dprintk (RIO_DEBUG_INTR, "Waking up.... ldisc:%d (%d/%d)....",
-		 (int)(PortP->gs.tty->flags & (1 << TTY_DO_WRITE_WAKEUP)),
-		 PortP->gs.wakeup_chars, PortP->gs.xmit_cnt); 
-    if ((PortP->gs.tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
-	PortP->gs.tty->ldisc.write_wakeup)
-      (PortP->gs.tty->ldisc.write_wakeup)(PortP->gs.tty);
-    rio_dprintk (RIO_DEBUG_INTR, "(%d/%d)\n",
-		PortP->gs.wakeup_chars, PortP->gs.xmit_cnt); 
-    wake_up_interruptible(&PortP->gs.tty->write_wait);
-  }
+		writeb(c, &(PacketP->len));
+		if (!(PortP->State & RIO_DELETED)) {
+			add_transmit(PortP);
+			/*
+			 ** Count chars tx'd for port statistics reporting
+			 */
+			if (PortP->statsGather)
+				PortP->txchars += c;
+		}
+		PortP->gs.xmit_tail = (PortP->gs.xmit_tail + c) & (SERIAL_XMIT_SIZE - 1);
+		PortP->gs.xmit_cnt -= c;
+	}
+
+	rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+
+	if (PortP->gs.xmit_cnt <= (PortP->gs.wakeup_chars + 2 * PKT_MAX_DATA_LEN)) {
+		rio_dprintk(RIO_DEBUG_INTR, "Waking up.... ldisc:%d (%d/%d)....", (int) (PortP->gs.tty->flags & (1 << TTY_DO_WRITE_WAKEUP)), PortP->gs.wakeup_chars, PortP->gs.xmit_cnt);
+		if ((PortP->gs.tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && PortP->gs.tty->ldisc.write_wakeup)
+			(PortP->gs.tty->ldisc.write_wakeup) (PortP->gs.tty);
+		rio_dprintk(RIO_DEBUG_INTR, "(%d/%d)\n", PortP->gs.wakeup_chars, PortP->gs.xmit_cnt);
+		wake_up_interruptible(&PortP->gs.tty->write_wait);
+	}
 
 }
 
@@ -189,361 +183,349 @@
 ** RIO Host Service routine. Does all the work traditionally associated with an
 ** interrupt.
 */
-static int	RupIntr;
-static int	RxIntr;
-static int	TxIntr;
-void
-RIOServiceHost(p, HostP, From)
-struct rio_info *	p;
+static int RupIntr;
+static int RxIntr;
+static int TxIntr;
+void RIOServiceHost(p, HostP, From)
+struct rio_info *p;
 struct Host *HostP;
-int From; 
+int From;
 {
-  rio_spin_lock (&HostP->HostLock);
-  if ( (HostP->Flags & RUN_STATE) != RC_RUNNING ) { 
-    static int t =0;
-    rio_spin_unlock (&HostP->HostLock); 
-    if ((t++ % 200) == 0)
-      rio_dprintk (RIO_DEBUG_INTR, "Interrupt but host not running. flags=%x.\n", (int)HostP->Flags);
-    return;
-  }
-  rio_spin_unlock (&HostP->HostLock); 
-
-  if ( RWORD( HostP->ParmMapP->rup_intr ) ) {
-    WWORD( HostP->ParmMapP->rup_intr , 0 );
-    p->RIORupCount++;
-    RupIntr++;
-    rio_dprintk (RIO_DEBUG_INTR, "rio: RUP interrupt on host %d\n", HostP-p->RIOHosts);
-    RIOPollHostCommands(p, HostP );
-  }
-
-  if ( RWORD( HostP->ParmMapP->rx_intr ) ) {
-    int port;
-
-    WWORD( HostP->ParmMapP->rx_intr , 0 );
-    p->RIORxCount++;
-    RxIntr++;
-
-    rio_dprintk (RIO_DEBUG_INTR, "rio: RX interrupt on host %d\n", HostP-p->RIOHosts);
-    /*
-    ** Loop through every port. If the port is mapped into
-    ** the system ( i.e. has /dev/ttyXXXX associated ) then it is
-    ** worth checking. If the port isn't open, grab any packets
-    ** hanging on its receive queue and stuff them on the free
-    ** list; check for commands on the way.
-    */
-    for ( port=p->RIOFirstPortsBooted; 
-	  port<p->RIOLastPortsBooted+PORTS_PER_RTA; port++ ) {
-      struct Port *PortP = p->RIOPortp[port];
-      struct tty_struct *ttyP;
-      struct PKT *PacketP;
-		
-      /*
-      ** not mapped in - most of the RIOPortp[] information
-      ** has not been set up!
-      ** Optimise: ports come in bundles of eight.
-      */
-      if ( !PortP->Mapped ) {
-	port += 7;
-	continue; /* with the next port */
-      }
-
-      /*
-      ** If the host board isn't THIS host board, check the next one.
-      ** optimise: ports come in bundles of eight.
-      */
-      if ( PortP->HostP != HostP ) {
-	port += 7;
-	continue;
-      }
-
-      /*
-      ** Let us see - is the port open? If not, then don't service it.
-      */
-      if ( !( PortP->PortState & PORT_ISOPEN ) ) {
-	continue;
-      }
-
-      /*
-      ** find corresponding tty structure. The process of mapping
-      ** the ports puts these here.
-      */
-      ttyP = PortP->gs.tty;
-
-      /*
-      ** Lock the port before we begin working on it.
-      */
-      rio_spin_lock(&PortP->portSem);
-
-      /*
-      ** Process received data if there is any.
-      */
-      if ( can_remove_receive( &PacketP, PortP ) )
-	RIOReceive(p, PortP);
-
-      /*
-      ** If there is no data left to be read from the port, and
-      ** it's handshake bit is set, then we must clear the handshake,
-      ** so that that downstream RTA is re-enabled.
-      */
-      if ( !can_remove_receive( &PacketP, PortP ) && 
-	   ( RWORD( PortP->PhbP->handshake )==PHB_HANDSHAKE_SET ) ) {
-				/*
-				** MAGIC! ( Basically, handshake the RX buffer, so that
-				** the RTAs upstream can be re-enabled. )
-				*/
-	rio_dprintk (RIO_DEBUG_INTR, "Set RX handshake bit\n");
-	WWORD( PortP->PhbP->handshake, 
-	       PHB_HANDSHAKE_SET|PHB_HANDSHAKE_RESET );
-      }
-      rio_spin_unlock(&PortP->portSem);
-    }
-  }
-
-  if ( RWORD( HostP->ParmMapP->tx_intr ) ) {
-    int port;
-
-    WWORD( HostP->ParmMapP->tx_intr , 0);
-
-    p->RIOTxCount++;
-    TxIntr++;
-    rio_dprintk (RIO_DEBUG_INTR, "rio: TX interrupt on host %d\n", HostP-p->RIOHosts);
-
-    /*
-    ** Loop through every port.
-    ** If the port is mapped into the system ( i.e. has /dev/ttyXXXX
-    ** associated ) then it is worth checking.
-    */
-    for ( port=p->RIOFirstPortsBooted; 
-	  port<p->RIOLastPortsBooted+PORTS_PER_RTA; port++ ) {
-      struct Port *PortP = p->RIOPortp[port];
-      struct tty_struct *ttyP;
-      struct PKT *PacketP;
-
-      /*
-      ** not mapped in - most of the RIOPortp[] information
-      ** has not been set up!
-      */
-      if ( !PortP->Mapped ) {
-	port += 7;
-	continue; /* with the next port */
-      }
-
-      /*
-      ** If the host board isn't running, then its data structures
-      ** are no use to us - continue quietly.
-      */
-      if ( PortP->HostP != HostP ) {
-	port += 7;
-	continue; /* with the next port */
-      }
-
-      /*
-      ** Let us see - is the port open? If not, then don't service it.
-      */
-      if ( !( PortP->PortState & PORT_ISOPEN ) ) {
-	continue;
-      }
-
-      rio_dprintk (RIO_DEBUG_INTR, "rio: Looking into port %d.\n", port);
-      /*
-      ** Lock the port before we begin working on it.
-      */
-      rio_spin_lock(&PortP->portSem);
-
-      /*
-      ** If we can't add anything to the transmit queue, then
-      ** we need do none of this processing.
-      */
-      if ( !can_add_transmit( &PacketP, PortP ) ) {
-	rio_dprintk (RIO_DEBUG_INTR, "Can't add to port, so skipping.\n");
-	rio_spin_unlock(&PortP->portSem);
-	continue;
-      }
-
-      /*
-      ** find corresponding tty structure. The process of mapping
-      ** the ports puts these here.
-      */
-      ttyP = PortP->gs.tty;
-      /* If ttyP is NULL, the port is getting closed. Forget about it. */
-      if (!ttyP) {
-	rio_dprintk (RIO_DEBUG_INTR, "no tty, so skipping.\n");
-	rio_spin_unlock(&PortP->portSem);
-	continue;
-      }
-      /*
-      ** If there is more room available we start up the transmit
-      ** data process again. This can be direct I/O, if the cookmode
-      ** is set to COOK_RAW or COOK_MEDIUM, or will be a call to the
-      ** riotproc( T_OUTPUT ) if we are in COOK_WELL mode, to fetch
-      ** characters via the line discipline. We must always call
-      ** the line discipline,
-      ** so that user input characters can be echoed correctly.
-      **
-      ** ++++ Update +++++
-      ** With the advent of double buffering, we now see if
-      ** TxBufferOut-In is non-zero. If so, then we copy a packet
-      ** to the output place, and set it going. If this empties
-      ** the buffer, then we must issue a wakeup( ) on OUT.
-      ** If it frees space in the buffer then we must issue
-      ** a wakeup( ) on IN.
-      **
-      ** ++++ Extra! Extra! If PortP->WflushFlag is set, then we
-      ** have to send a WFLUSH command down the PHB, to mark the
-      ** end point of a WFLUSH. We also need to clear out any
-      ** data from the double buffer! ( note that WflushFlag is a
-      ** *count* of the number of WFLUSH commands outstanding! )
-      **
-      ** ++++ And there's more!
-      ** If an RTA is powered off, then on again, and rebooted,
-      ** whilst it has ports open, then we need to re-open the ports.
-      ** ( reasonable enough ). We can't do this when we spot the
-      ** re-boot, in interrupt time, because the queue is probably
-      ** full. So, when we come in here, we need to test if any
-      ** ports are in this condition, and re-open the port before
-      ** we try to send any more data to it. Now, the re-booted
-      ** RTA will be discarding packets from the PHB until it
-      ** receives this open packet, but don't worry tooo much
-      ** about that. The one thing that is interesting is the
-      ** combination of this effect and the WFLUSH effect!
-      */
-      /* For now don't handle RTA reboots. -- REW. 
-	 Reenabled. Otherwise RTA reboots didn't work. Duh. -- REW */
-      if ( PortP->MagicFlags ) {
-#if 1
-	if ( PortP->MagicFlags & MAGIC_REBOOT ) {
-	  /*
-	  ** well, the RTA has been rebooted, and there is room
-	  ** on its queue to add the open packet that is required.
-	  **
-	  ** The messy part of this line is trying to decide if
-	  ** we need to call the Param function as a tty or as
-	  ** a modem.
-	  ** DONT USE CLOCAL AS A TEST FOR THIS!
-	  **
-	  ** If we can't param the port, then move on to the
-	  ** next port.
-	  */
-	  PortP->InUse = NOT_INUSE;
-
-	  rio_spin_unlock(&PortP->portSem);
-	  if ( RIOParam(PortP, OPEN, ((PortP->Cor2Copy & 
-				       (COR2_RTSFLOW|COR2_CTSFLOW ) )== 
-				      (COR2_RTSFLOW|COR2_CTSFLOW ) ) ? 
-			TRUE : FALSE, DONT_SLEEP ) == RIO_FAIL ) {
-	    continue; /* with next port */
-	  }
-	  rio_spin_lock(&PortP->portSem);
-	  PortP->MagicFlags &= ~MAGIC_REBOOT;
+	rio_spin_lock(&HostP->HostLock);
+	if ((HostP->Flags & RUN_STATE) != RC_RUNNING) {
+		static int t = 0;
+		rio_spin_unlock(&HostP->HostLock);
+		if ((t++ % 200) == 0)
+			rio_dprintk(RIO_DEBUG_INTR, "Interrupt but host not running. flags=%x.\n", (int) HostP->Flags);
+		return;
 	}
+	rio_spin_unlock(&HostP->HostLock);
+
+	if (RWORD(HostP->ParmMapP->rup_intr)) {
+		WWORD(HostP->ParmMapP->rup_intr, 0);
+		p->RIORupCount++;
+		RupIntr++;
+		rio_dprintk(RIO_DEBUG_INTR, "rio: RUP interrupt on host %d\n", HostP - p->RIOHosts);
+		RIOPollHostCommands(p, HostP);
+	}
+
+	if (RWORD(HostP->ParmMapP->rx_intr)) {
+		int port;
+
+		WWORD(HostP->ParmMapP->rx_intr, 0);
+		p->RIORxCount++;
+		RxIntr++;
+
+		rio_dprintk(RIO_DEBUG_INTR, "rio: RX interrupt on host %d\n", HostP - p->RIOHosts);
+		/*
+		 ** Loop through every port. If the port is mapped into
+		 ** the system ( i.e. has /dev/ttyXXXX associated ) then it is
+		 ** worth checking. If the port isn't open, grab any packets
+		 ** hanging on its receive queue and stuff them on the free
+		 ** list; check for commands on the way.
+		 */
+		for (port = p->RIOFirstPortsBooted; port < p->RIOLastPortsBooted + PORTS_PER_RTA; port++) {
+			struct Port *PortP = p->RIOPortp[port];
+			struct tty_struct *ttyP;
+			struct PKT *PacketP;
+
+			/*
+			 ** not mapped in - most of the RIOPortp[] information
+			 ** has not been set up!
+			 ** Optimise: ports come in bundles of eight.
+			 */
+			if (!PortP->Mapped) {
+				port += 7;
+				continue;	/* with the next port */
+			}
+
+			/*
+			 ** If the host board isn't THIS host board, check the next one.
+			 ** optimise: ports come in bundles of eight.
+			 */
+			if (PortP->HostP != HostP) {
+				port += 7;
+				continue;
+			}
+
+			/*
+			 ** Let us see - is the port open? If not, then don't service it.
+			 */
+			if (!(PortP->PortState & PORT_ISOPEN)) {
+				continue;
+			}
+
+			/*
+			 ** find corresponding tty structure. The process of mapping
+			 ** the ports puts these here.
+			 */
+			ttyP = PortP->gs.tty;
+
+			/*
+			 ** Lock the port before we begin working on it.
+			 */
+			rio_spin_lock(&PortP->portSem);
+
+			/*
+			 ** Process received data if there is any.
+			 */
+			if (can_remove_receive(&PacketP, PortP))
+				RIOReceive(p, PortP);
+
+			/*
+			 ** If there is no data left to be read from the port, and
+			 ** it's handshake bit is set, then we must clear the handshake,
+			 ** so that that downstream RTA is re-enabled.
+			 */
+			if (!can_remove_receive(&PacketP, PortP) && (RWORD(PortP->PhbP->handshake) == PHB_HANDSHAKE_SET)) {
+				/*
+				 ** MAGIC! ( Basically, handshake the RX buffer, so that
+				 ** the RTAs upstream can be re-enabled. )
+				 */
+				rio_dprintk(RIO_DEBUG_INTR, "Set RX handshake bit\n");
+				WWORD(PortP->PhbP->handshake, PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET);
+			}
+			rio_spin_unlock(&PortP->portSem);
+		}
+	}
+
+	if (RWORD(HostP->ParmMapP->tx_intr)) {
+		int port;
+
+		WWORD(HostP->ParmMapP->tx_intr, 0);
+
+		p->RIOTxCount++;
+		TxIntr++;
+		rio_dprintk(RIO_DEBUG_INTR, "rio: TX interrupt on host %d\n", HostP - p->RIOHosts);
+
+		/*
+		 ** Loop through every port.
+		 ** If the port is mapped into the system ( i.e. has /dev/ttyXXXX
+		 ** associated ) then it is worth checking.
+		 */
+		for (port = p->RIOFirstPortsBooted; port < p->RIOLastPortsBooted + PORTS_PER_RTA; port++) {
+			struct Port *PortP = p->RIOPortp[port];
+			struct tty_struct *ttyP;
+			struct PKT *PacketP;
+
+			/*
+			 ** not mapped in - most of the RIOPortp[] information
+			 ** has not been set up!
+			 */
+			if (!PortP->Mapped) {
+				port += 7;
+				continue;	/* with the next port */
+			}
+
+			/*
+			 ** If the host board isn't running, then its data structures
+			 ** are no use to us - continue quietly.
+			 */
+			if (PortP->HostP != HostP) {
+				port += 7;
+				continue;	/* with the next port */
+			}
+
+			/*
+			 ** Let us see - is the port open? If not, then don't service it.
+			 */
+			if (!(PortP->PortState & PORT_ISOPEN)) {
+				continue;
+			}
+
+			rio_dprintk(RIO_DEBUG_INTR, "rio: Looking into port %d.\n", port);
+			/*
+			 ** Lock the port before we begin working on it.
+			 */
+			rio_spin_lock(&PortP->portSem);
+
+			/*
+			 ** If we can't add anything to the transmit queue, then
+			 ** we need do none of this processing.
+			 */
+			if (!can_add_transmit(&PacketP, PortP)) {
+				rio_dprintk(RIO_DEBUG_INTR, "Can't add to port, so skipping.\n");
+				rio_spin_unlock(&PortP->portSem);
+				continue;
+			}
+
+			/*
+			 ** find corresponding tty structure. The process of mapping
+			 ** the ports puts these here.
+			 */
+			ttyP = PortP->gs.tty;
+			/* If ttyP is NULL, the port is getting closed. Forget about it. */
+			if (!ttyP) {
+				rio_dprintk(RIO_DEBUG_INTR, "no tty, so skipping.\n");
+				rio_spin_unlock(&PortP->portSem);
+				continue;
+			}
+			/*
+			 ** If there is more room available we start up the transmit
+			 ** data process again. This can be direct I/O, if the cookmode
+			 ** is set to COOK_RAW or COOK_MEDIUM, or will be a call to the
+			 ** riotproc( T_OUTPUT ) if we are in COOK_WELL mode, to fetch
+			 ** characters via the line discipline. We must always call
+			 ** the line discipline,
+			 ** so that user input characters can be echoed correctly.
+			 **
+			 ** ++++ Update +++++
+			 ** With the advent of double buffering, we now see if
+			 ** TxBufferOut-In is non-zero. If so, then we copy a packet
+			 ** to the output place, and set it going. If this empties
+			 ** the buffer, then we must issue a wakeup( ) on OUT.
+			 ** If it frees space in the buffer then we must issue
+			 ** a wakeup( ) on IN.
+			 **
+			 ** ++++ Extra! Extra! If PortP->WflushFlag is set, then we
+			 ** have to send a WFLUSH command down the PHB, to mark the
+			 ** end point of a WFLUSH. We also need to clear out any
+			 ** data from the double buffer! ( note that WflushFlag is a
+			 ** *count* of the number of WFLUSH commands outstanding! )
+			 **
+			 ** ++++ And there's more!
+			 ** If an RTA is powered off, then on again, and rebooted,
+			 ** whilst it has ports open, then we need to re-open the ports.
+			 ** ( reasonable enough ). We can't do this when we spot the
+			 ** re-boot, in interrupt time, because the queue is probably
+			 ** full. So, when we come in here, we need to test if any
+			 ** ports are in this condition, and re-open the port before
+			 ** we try to send any more data to it. Now, the re-booted
+			 ** RTA will be discarding packets from the PHB until it
+			 ** receives this open packet, but don't worry tooo much
+			 ** about that. The one thing that is interesting is the
+			 ** combination of this effect and the WFLUSH effect!
+			 */
+			/* For now don't handle RTA reboots. -- REW.
+			   Reenabled. Otherwise RTA reboots didn't work. Duh. -- REW */
+			if (PortP->MagicFlags) {
+#if 1
+				if (PortP->MagicFlags & MAGIC_REBOOT) {
+					/*
+					 ** well, the RTA has been rebooted, and there is room
+					 ** on its queue to add the open packet that is required.
+					 **
+					 ** The messy part of this line is trying to decide if
+					 ** we need to call the Param function as a tty or as
+					 ** a modem.
+					 ** DONT USE CLOCAL AS A TEST FOR THIS!
+					 **
+					 ** If we can't param the port, then move on to the
+					 ** next port.
+					 */
+					PortP->InUse = NOT_INUSE;
+
+					rio_spin_unlock(&PortP->portSem);
+					if (RIOParam(PortP, OPEN, ((PortP->Cor2Copy & (COR2_RTSFLOW | COR2_CTSFLOW)) == (COR2_RTSFLOW | COR2_CTSFLOW)) ? TRUE : FALSE, DONT_SLEEP) == RIO_FAIL) {
+						continue;	/* with next port */
+					}
+					rio_spin_lock(&PortP->portSem);
+					PortP->MagicFlags &= ~MAGIC_REBOOT;
+				}
 #endif
 
-	/*
-	** As mentioned above, this is a tacky hack to cope
-	** with WFLUSH
-	*/
-	if ( PortP->WflushFlag ) {
-	  rio_dprintk (RIO_DEBUG_INTR, "Want to WFLUSH mark this port\n");
+				/*
+				 ** As mentioned above, this is a tacky hack to cope
+				 ** with WFLUSH
+				 */
+				if (PortP->WflushFlag) {
+					rio_dprintk(RIO_DEBUG_INTR, "Want to WFLUSH mark this port\n");
 
-	  if ( PortP->InUse )
-	    rio_dprintk (RIO_DEBUG_INTR, "FAILS - PORT IS IN USE\n");
+					if (PortP->InUse)
+						rio_dprintk(RIO_DEBUG_INTR, "FAILS - PORT IS IN USE\n");
+				}
+
+				while (PortP->WflushFlag && can_add_transmit(&PacketP, PortP) && (PortP->InUse == NOT_INUSE)) {
+					int p;
+					struct PktCmd *PktCmdP;
+
+					rio_dprintk(RIO_DEBUG_INTR, "Add WFLUSH marker to data queue\n");
+					/*
+					 ** make it look just like a WFLUSH command
+					 */
+					PktCmdP = (struct PktCmd *) &PacketP->data[0];
+
+					WBYTE(PktCmdP->Command, WFLUSH);
+
+					p = PortP->HostPort % (ushort) PORTS_PER_RTA;
+
+					/*
+					 ** If second block of ports for 16 port RTA, add 8
+					 ** to index 8-15.
+					 */
+					if (PortP->SecondBlock)
+						p += PORTS_PER_RTA;
+
+					WBYTE(PktCmdP->PhbNum, p);
+
+					/*
+					 ** to make debuggery easier
+					 */
+					WBYTE(PacketP->data[2], 'W');
+					WBYTE(PacketP->data[3], 'F');
+					WBYTE(PacketP->data[4], 'L');
+					WBYTE(PacketP->data[5], 'U');
+					WBYTE(PacketP->data[6], 'S');
+					WBYTE(PacketP->data[7], 'H');
+					WBYTE(PacketP->data[8], ' ');
+					WBYTE(PacketP->data[9], '0' + PortP->WflushFlag);
+					WBYTE(PacketP->data[10], ' ');
+					WBYTE(PacketP->data[11], ' ');
+					WBYTE(PacketP->data[12], '\0');
+
+					/*
+					 ** its two bytes long!
+					 */
+					WBYTE(PacketP->len, PKT_CMD_BIT | 2);
+
+					/*
+					 ** queue it!
+					 */
+					if (!(PortP->State & RIO_DELETED)) {
+						add_transmit(PortP);
+						/*
+						 ** Count chars tx'd for port statistics reporting
+						 */
+						if (PortP->statsGather)
+							PortP->txchars += 2;
+					}
+
+					if (--(PortP->WflushFlag) == 0) {
+						PortP->MagicFlags &= ~MAGIC_FLUSH;
+					}
+
+					rio_dprintk(RIO_DEBUG_INTR, "Wflush count now stands at %d\n", PortP->WflushFlag);
+				}
+				if (PortP->MagicFlags & MORE_OUTPUT_EYGOR) {
+					if (PortP->MagicFlags & MAGIC_FLUSH) {
+						PortP->MagicFlags |= MORE_OUTPUT_EYGOR;
+					} else {
+						if (!can_add_transmit(&PacketP, PortP)) {
+							rio_spin_unlock(&PortP->portSem);
+							continue;
+						}
+						rio_spin_unlock(&PortP->portSem);
+						RIOTxEnable((char *) PortP);
+						rio_spin_lock(&PortP->portSem);
+						PortP->MagicFlags &= ~MORE_OUTPUT_EYGOR;
+					}
+				}
+			}
+
+
+			/*
+			 ** If we can't add anything to the transmit queue, then
+			 ** we need do none of the remaining processing.
+			 */
+			if (!can_add_transmit(&PacketP, PortP)) {
+				rio_spin_unlock(&PortP->portSem);
+				continue;
+			}
+
+			rio_spin_unlock(&PortP->portSem);
+			RIOTxEnable((char *) PortP);
+		}
 	}
-				
-	while ( PortP->WflushFlag &&
-		can_add_transmit( &PacketP, PortP ) && 
-		( PortP->InUse == NOT_INUSE ) ) {
-	  int p;
-	  struct PktCmd *PktCmdP;
-
-	  rio_dprintk (RIO_DEBUG_INTR, "Add WFLUSH marker to data queue\n");
-	  /*
-	  ** make it look just like a WFLUSH command
-	  */
-	  PktCmdP = ( struct PktCmd * )&PacketP->data[0];
-
-	  WBYTE( PktCmdP->Command , WFLUSH );
-
-	  p =  PortP->HostPort % ( ushort )PORTS_PER_RTA;
-
-	  /*
-	  ** If second block of ports for 16 port RTA, add 8
-	  ** to index 8-15.
-	  */
-	  if ( PortP->SecondBlock )
-	    p += PORTS_PER_RTA;
-
-	  WBYTE( PktCmdP->PhbNum, p );
-
-	  /*
-	  ** to make debuggery easier
-	  */
-	  WBYTE( PacketP->data[ 2], 'W'  );
-	  WBYTE( PacketP->data[ 3], 'F'  );
-	  WBYTE( PacketP->data[ 4], 'L'  );
-	  WBYTE( PacketP->data[ 5], 'U'  );
-	  WBYTE( PacketP->data[ 6], 'S'  );
-	  WBYTE( PacketP->data[ 7], 'H'  );
-	  WBYTE( PacketP->data[ 8], ' '  );
-	  WBYTE( PacketP->data[ 9], '0'+PortP->WflushFlag );
-	  WBYTE( PacketP->data[10], ' '  );
-	  WBYTE( PacketP->data[11], ' '  );
-	  WBYTE( PacketP->data[12], '\0' );
-
-	  /*
-	  ** its two bytes long!
-	  */
-	  WBYTE( PacketP->len , PKT_CMD_BIT | 2 );
-
-	  /*
-	  ** queue it!
-	  */
-	  if ( !( PortP->State & RIO_DELETED ) ) {
-	    add_transmit( PortP );
-	    /*
-	    ** Count chars tx'd for port statistics reporting
-	    */
-	    if ( PortP->statsGather )
-	      PortP->txchars += 2;
-	  }
-
-	  if ( --( PortP->WflushFlag ) == 0 ) {
-	    PortP->MagicFlags &= ~MAGIC_FLUSH;
-	  }
-
-	  rio_dprintk (RIO_DEBUG_INTR, "Wflush count now stands at %d\n", 
-		 PortP->WflushFlag);
-	}
-	if ( PortP->MagicFlags & MORE_OUTPUT_EYGOR ) {
-	  if ( PortP->MagicFlags & MAGIC_FLUSH ) {
-	    PortP->MagicFlags |= MORE_OUTPUT_EYGOR;
-	  }
-	  else {
-	    if ( !can_add_transmit( &PacketP, PortP ) ) {
-	      rio_spin_unlock(&PortP->portSem);
-	      continue;
-	    }
-	    rio_spin_unlock(&PortP->portSem);
-	    RIOTxEnable((char *)PortP);
-	    rio_spin_lock(&PortP->portSem);
-	    PortP->MagicFlags &= ~MORE_OUTPUT_EYGOR;
-	  }
-	}
-      }
-
-
-      /*
-      ** If we can't add anything to the transmit queue, then
-      ** we need do none of the remaining processing.
-      */
-      if (!can_add_transmit( &PacketP, PortP ) ) {
-	rio_spin_unlock(&PortP->portSem);
-	continue;
-      }
-
-      rio_spin_unlock(&PortP->portSem);
-      RIOTxEnable((char *)PortP);
-    }
-  }
 }
 
 /*
@@ -551,176 +533,162 @@
 ** NB: Called with the tty locked. The spl from the lockb( ) is passed.
 ** we return the ttySpl level that we re-locked at.
 */
-static void
-RIOReceive(p, PortP)
-struct rio_info *	p;
-struct Port *		PortP;
+static void RIOReceive(p, PortP)
+struct rio_info *p;
+struct Port *PortP;
 {
-  struct tty_struct *TtyP;
-  register ushort transCount;
-  struct PKT *PacketP;
-  register uint	DataCnt;
-  uchar *	ptr;
-  unsigned char *buf;
-  int copied =0;
+	struct tty_struct *TtyP;
+	register ushort transCount;
+	struct PKT *PacketP;
+	register uint DataCnt;
+	uchar *ptr;
+	unsigned char *buf;
+	int copied = 0;
 
-  static int intCount, RxIntCnt;
+	static int intCount, RxIntCnt;
 
-  /*
-  ** The receive data process is to remove packets from the
-  ** PHB until there aren't any more or the current cblock
-  ** is full. When this occurs, there will be some left over
-  ** data in the packet, that we must do something with.
-  ** As we haven't unhooked the packet from the read list
-  ** yet, we can just leave the packet there, having first
-  ** made a note of how far we got. This means that we need
-  ** a pointer per port saying where we start taking the
-  ** data from - this will normally be zero, but when we
-  ** run out of space it will be set to the offset of the
-  ** next byte to copy from the packet data area. The packet
-  ** length field is decremented by the number of bytes that
-  ** we succesfully removed from the packet. When this reaches
-  ** zero, we reset the offset pointer to be zero, and free
-  ** the packet from the front of the queue.
-  */
+	/*
+	 ** The receive data process is to remove packets from the
+	 ** PHB until there aren't any more or the current cblock
+	 ** is full. When this occurs, there will be some left over
+	 ** data in the packet, that we must do something with.
+	 ** As we haven't unhooked the packet from the read list
+	 ** yet, we can just leave the packet there, having first
+	 ** made a note of how far we got. This means that we need
+	 ** a pointer per port saying where we start taking the
+	 ** data from - this will normally be zero, but when we
+	 ** run out of space it will be set to the offset of the
+	 ** next byte to copy from the packet data area. The packet
+	 ** length field is decremented by the number of bytes that
+	 ** we succesfully removed from the packet. When this reaches
+	 ** zero, we reset the offset pointer to be zero, and free
+	 ** the packet from the front of the queue.
+	 */
 
-  intCount++;
+	intCount++;
 
-  TtyP = PortP->gs.tty;
-  if (!TtyP) {
-    rio_dprintk (RIO_DEBUG_INTR, "RIOReceive: tty is null. \n");
-    return;
-  }
-
-  if (PortP->State & RIO_THROTTLE_RX) {
-    rio_dprintk (RIO_DEBUG_INTR, "RIOReceive: Throttled. Can't handle more input.\n");
-    return;
-  }
-
-  if ( PortP->State & RIO_DELETED )
-    {
-      while ( can_remove_receive( &PacketP, PortP ) )
-	{
-	  remove_receive( PortP );
-	  put_free_end( PortP->HostP, PacketP );
+	TtyP = PortP->gs.tty;
+	if (!TtyP) {
+		rio_dprintk(RIO_DEBUG_INTR, "RIOReceive: tty is null. \n");
+		return;
 	}
-    }
-  else
-    {
-      /*
-      ** loop, just so long as:
-      **   i ) there's some data ( i.e. can_remove_receive )
-      **  ii ) we haven't been blocked
-      ** iii ) there's somewhere to put the data
-      **  iv ) we haven't outstayed our welcome
-      */
-      transCount = 1;
-      while ( can_remove_receive(&PacketP, PortP)
-	      && transCount)
-	{
+
+	if (PortP->State & RIO_THROTTLE_RX) {
+		rio_dprintk(RIO_DEBUG_INTR, "RIOReceive: Throttled. Can't handle more input.\n");
+		return;
+	}
+
+	if (PortP->State & RIO_DELETED) {
+		while (can_remove_receive(&PacketP, PortP)) {
+			remove_receive(PortP);
+			put_free_end(PortP->HostP, PacketP);
+		}
+	} else {
+		/*
+		 ** loop, just so long as:
+		 **   i ) there's some data ( i.e. can_remove_receive )
+		 **  ii ) we haven't been blocked
+		 ** iii ) there's somewhere to put the data
+		 **  iv ) we haven't outstayed our welcome
+		 */
+		transCount = 1;
+		while (can_remove_receive(&PacketP, PortP)
+		       && transCount) {
 #ifdef STATS
-	  PortP->Stat.RxIntCnt++;
-#endif /* STATS */
-	  RxIntCnt++;
+			PortP->Stat.RxIntCnt++;
+#endif				/* STATS */
+			RxIntCnt++;
 
-	  /*
-	  ** check that it is not a command!
-	  */
-	  if ( PacketP->len & PKT_CMD_BIT ) {
-	    rio_dprintk (RIO_DEBUG_INTR, "RIO: unexpected command packet received on PHB\n");
-	    /*	    rio_dprint(RIO_DEBUG_INTR, (" sysport   = %d\n", p->RIOPortp->PortNum)); */
-	    rio_dprintk (RIO_DEBUG_INTR, " dest_unit = %d\n", PacketP->dest_unit);
-	    rio_dprintk (RIO_DEBUG_INTR, " dest_port = %d\n", PacketP->dest_port);
-	    rio_dprintk (RIO_DEBUG_INTR, " src_unit  = %d\n", PacketP->src_unit);
-	    rio_dprintk (RIO_DEBUG_INTR, " src_port  = %d\n", PacketP->src_port);
-	    rio_dprintk (RIO_DEBUG_INTR, " len	   = %d\n", PacketP->len);
-	    rio_dprintk (RIO_DEBUG_INTR, " control   = %d\n", PacketP->control);
-	    rio_dprintk (RIO_DEBUG_INTR, " csum	   = %d\n", PacketP->csum);
-	    rio_dprintk (RIO_DEBUG_INTR, "	 data bytes: ");
-	    for ( DataCnt=0; DataCnt<PKT_MAX_DATA_LEN; DataCnt++ )
-	      rio_dprintk (RIO_DEBUG_INTR, "%d\n", PacketP->data[DataCnt]);
-	    remove_receive( PortP );
-	    put_free_end( PortP->HostP, PacketP );
-	    continue; /* with next packet */
-	  }
+			/*
+			 ** check that it is not a command!
+			 */
+			if (PacketP->len & PKT_CMD_BIT) {
+				rio_dprintk(RIO_DEBUG_INTR, "RIO: unexpected command packet received on PHB\n");
+				/*      rio_dprint(RIO_DEBUG_INTR, (" sysport   = %d\n", p->RIOPortp->PortNum)); */
+				rio_dprintk(RIO_DEBUG_INTR, " dest_unit = %d\n", PacketP->dest_unit);
+				rio_dprintk(RIO_DEBUG_INTR, " dest_port = %d\n", PacketP->dest_port);
+				rio_dprintk(RIO_DEBUG_INTR, " src_unit  = %d\n", PacketP->src_unit);
+				rio_dprintk(RIO_DEBUG_INTR, " src_port  = %d\n", PacketP->src_port);
+				rio_dprintk(RIO_DEBUG_INTR, " len	   = %d\n", PacketP->len);
+				rio_dprintk(RIO_DEBUG_INTR, " control   = %d\n", PacketP->control);
+				rio_dprintk(RIO_DEBUG_INTR, " csum	   = %d\n", PacketP->csum);
+				rio_dprintk(RIO_DEBUG_INTR, "	 data bytes: ");
+				for (DataCnt = 0; DataCnt < PKT_MAX_DATA_LEN; DataCnt++)
+					rio_dprintk(RIO_DEBUG_INTR, "%d\n", PacketP->data[DataCnt]);
+				remove_receive(PortP);
+				put_free_end(PortP->HostP, PacketP);
+				continue;	/* with next packet */
+			}
 
-	  /*
-	  ** How many characters can we move 'upstream' ?
-	  **
-	  ** Determine the minimum of the amount of data
-	  ** available and the amount of space in which to
-	  ** put it.
-	  **
-	  ** 1.	Get the packet length by masking 'len'
-	  **	for only the length bits.
-	  ** 2.	Available space is [buffer size] - [space used]
-	  **
-	  ** Transfer count is the minimum of packet length
-	  ** and available space.
-	  */
-			
-	  transCount = tty_buffer_request_room(TtyP, PacketP->len & PKT_LEN_MASK);
-	  rio_dprintk (RIO_DEBUG_REC,  "port %d: Copy %d bytes\n", 
-				      PortP->PortNum, transCount);
-	  /*
-	  ** To use the following 'kkprintfs' for debugging - change the '#undef'
-	  ** to '#define', (this is the only place ___DEBUG_IT___ occurs in the
-	  ** driver).
-	  */
+			/*
+			 ** How many characters can we move 'upstream' ?
+			 **
+			 ** Determine the minimum of the amount of data
+			 ** available and the amount of space in which to
+			 ** put it.
+			 **
+			 ** 1.        Get the packet length by masking 'len'
+			 **   for only the length bits.
+			 ** 2.        Available space is [buffer size] - [space used]
+			 **
+			 ** Transfer count is the minimum of packet length
+			 ** and available space.
+			 */
+
+			transCount = tty_buffer_request_room(TtyP, PacketP->len & PKT_LEN_MASK);
+			rio_dprintk(RIO_DEBUG_REC, "port %d: Copy %d bytes\n", PortP->PortNum, transCount);
+			/*
+			 ** To use the following 'kkprintfs' for debugging - change the '#undef'
+			 ** to '#define', (this is the only place ___DEBUG_IT___ occurs in the
+			 ** driver).
+			 */
 #undef ___DEBUG_IT___
 #ifdef ___DEBUG_IT___
-	  kkprintf("I:%d R:%d P:%d Q:%d C:%d F:%x ",
-		   intCount,
-		   RxIntCnt,
-		   PortP->PortNum,
-		   TtyP->rxqueue.count,
-		   transCount,
-		   TtyP->flags );
+			kkprintf("I:%d R:%d P:%d Q:%d C:%d F:%x ", intCount, RxIntCnt, PortP->PortNum, TtyP->rxqueue.count, transCount, TtyP->flags);
 #endif
-	  ptr = (uchar *) PacketP->data + PortP->RxDataStart;
+			ptr = (uchar *) PacketP->data + PortP->RxDataStart;
 
-	  tty_prepare_flip_string(TtyP, &buf, transCount);
-	  rio_memcpy_fromio (buf, ptr, transCount);
+			tty_prepare_flip_string(TtyP, &buf, transCount);
+			rio_memcpy_fromio(buf, ptr, transCount);
 #ifdef STATS
-	  /*
-	  ** keep a count for statistical purposes
-	  */
-	  PortP->Stat.RxCharCnt	+= transCount;
+			/*
+			 ** keep a count for statistical purposes
+			 */
+			PortP->Stat.RxCharCnt += transCount;
 #endif
-	  PortP->RxDataStart	+= transCount;
-	  PacketP->len		-= transCount;
-	  copied += transCount;
+			PortP->RxDataStart += transCount;
+			PacketP->len -= transCount;
+			copied += transCount;
 
 
 #ifdef ___DEBUG_IT___
-	  kkprintf("T:%d L:%d\n", DataCnt, PacketP->len );
+			kkprintf("T:%d L:%d\n", DataCnt, PacketP->len);
 #endif
 
-	  if ( PacketP->len == 0 )
-	    {
+			if (PacketP->len == 0) {
 				/*
-				** If we have emptied the packet, then we can
-				** free it, and reset the start pointer for
-				** the next packet.
-				*/
-	      remove_receive( PortP );
-	      put_free_end( PortP->HostP, PacketP );
-	      PortP->RxDataStart = 0;
+				 ** If we have emptied the packet, then we can
+				 ** free it, and reset the start pointer for
+				 ** the next packet.
+				 */
+				remove_receive(PortP);
+				put_free_end(PortP->HostP, PacketP);
+				PortP->RxDataStart = 0;
 #ifdef STATS
 				/*
-				** more lies ( oops, I mean statistics )
-				*/
-	      PortP->Stat.RxPktCnt++;
-#endif /* STATS */
-	    }
+				 ** more lies ( oops, I mean statistics )
+				 */
+				PortP->Stat.RxPktCnt++;
+#endif				/* STATS */
+			}
+		}
 	}
-    }
-  if (copied) {
-    rio_dprintk (RIO_DEBUG_REC, "port %d: pushing tty flip buffer: %d total bytes copied.\n", PortP->PortNum, copied);
-    tty_flip_buffer_push (TtyP);
-  }
+	if (copied) {
+		rio_dprintk(RIO_DEBUG_REC, "port %d: pushing tty flip buffer: %d total bytes copied.\n", PortP->PortNum, copied);
+		tty_flip_buffer_push(TtyP);
+	}
 
-  return;
+	return;
 }
 
 #ifdef FUTURE_RELEASE
@@ -728,221 +696,210 @@
 ** The proc routine called by the line discipline to do the work for it.
 ** The proc routine works hand in hand with the interrupt routine.
 */
-int
-riotproc(p, tp, cmd, port)
-struct rio_info *	p;
+int riotproc(p, tp, cmd, port)
+struct rio_info *p;
 register struct ttystatics *tp;
 int cmd;
-int	port;
+int port;
 {
 	register struct Port *PortP;
 	int SysPort;
 	struct PKT *PacketP;
 
-	SysPort = port;	/* Believe me, it works. */
+	SysPort = port;		/* Believe me, it works. */
 
-	if ( SysPort < 0 || SysPort >= RIO_PORTS ) {
-		rio_dprintk (RIO_DEBUG_INTR, "Illegal port %d derived from TTY in riotproc()\n",SysPort);
+	if (SysPort < 0 || SysPort >= RIO_PORTS) {
+		rio_dprintk(RIO_DEBUG_INTR, "Illegal port %d derived from TTY in riotproc()\n", SysPort);
 		return 0;
 	}
 	PortP = p->RIOPortp[SysPort];
 
-	if ((uint)PortP->PhbP < (uint)PortP->Caddr || 
-			(uint)PortP->PhbP >= (uint)PortP->Caddr+SIXTY_FOUR_K ) {
-		rio_dprintk (RIO_DEBUG_INTR, "RIO: NULL or BAD PhbP on sys port %d in proc routine\n",
-							SysPort);
-		rio_dprintk (RIO_DEBUG_INTR, "	 PortP = 0x%x\n",PortP);
-		rio_dprintk (RIO_DEBUG_INTR, "	 PortP->PhbP = 0x%x\n",PortP->PhbP);
-		rio_dprintk (RIO_DEBUG_INTR, "	 PortP->Caddr = 0x%x\n",PortP->PhbP);
-		rio_dprintk (RIO_DEBUG_INTR, "	 PortP->HostPort = 0x%x\n",PortP->HostPort);
+	if ((uint) PortP->PhbP < (uint) PortP->Caddr || (uint) PortP->PhbP >= (uint) PortP->Caddr + SIXTY_FOUR_K) {
+		rio_dprintk(RIO_DEBUG_INTR, "RIO: NULL or BAD PhbP on sys port %d in proc routine\n", SysPort);
+		rio_dprintk(RIO_DEBUG_INTR, "	 PortP = 0x%x\n", PortP);
+		rio_dprintk(RIO_DEBUG_INTR, "	 PortP->PhbP = 0x%x\n", PortP->PhbP);
+		rio_dprintk(RIO_DEBUG_INTR, "	 PortP->Caddr = 0x%x\n", PortP->PhbP);
+		rio_dprintk(RIO_DEBUG_INTR, "	 PortP->HostPort = 0x%x\n", PortP->HostPort);
 		return 0;
 	}
 
-	switch(cmd) {
-		case T_WFLUSH:
-			rio_dprintk (RIO_DEBUG_INTR, "T_WFLUSH\n");
+	switch (cmd) {
+	case T_WFLUSH:
+		rio_dprintk(RIO_DEBUG_INTR, "T_WFLUSH\n");
+		/*
+		 ** Because of the spooky way the RIO works, we don't need
+		 ** to issue a flush command on any of the SET*F commands,
+		 ** as that causes trouble with getty and login, which issue
+		 ** these commands to incur a READ flush, and rely on the fact
+		 ** that the line discipline does a wait for drain for them.
+		 ** As the rio doesn't wait for drain, the write flush would
+		 ** destroy the Password: prompt. This isn't very friendly, so
+		 ** here we only issue a WFLUSH command if we are in the interrupt
+		 ** routine, or we aren't executing a SET*F command.
+		 */
+		if (PortP->HostP->InIntr || !PortP->FlushCmdBodge) {
 			/*
-			** Because of the spooky way the RIO works, we don't need
-			** to issue a flush command on any of the SET*F commands,
-			** as that causes trouble with getty and login, which issue
-			** these commands to incur a READ flush, and rely on the fact
-			** that the line discipline does a wait for drain for them.
-			** As the rio doesn't wait for drain, the write flush would
-			** destroy the Password: prompt. This isn't very friendly, so
-			** here we only issue a WFLUSH command if we are in the interrupt
-			** routine, or we aren't executing a SET*F command.
-			*/
-			if ( PortP->HostP->InIntr || !PortP->FlushCmdBodge ) {
-				/*
-				** form a wflush packet - 1 byte long, no data
-				*/
-				if ( PortP->State & RIO_DELETED ) {
-					rio_dprintk (RIO_DEBUG_INTR, "WFLUSH on deleted RTA\n");
-				}
-				else {
-					if ( RIOPreemptiveCmd(p, PortP, WFLUSH ) == RIO_FAIL ) {
-						rio_dprintk (RIO_DEBUG_INTR, "T_WFLUSH Command failed\n");
-					}
-					else
-						rio_dprintk (RIO_DEBUG_INTR, "T_WFLUSH Command\n");
-				}
-				/*
-				** WFLUSH operation - flush the data!
-				*/
-				PortP->TxBufferIn = PortP->TxBufferOut = 0;
-			}
-			else {
-				rio_dprintk (RIO_DEBUG_INTR, "T_WFLUSH Command ignored\n");
+			 ** form a wflush packet - 1 byte long, no data
+			 */
+			if (PortP->State & RIO_DELETED) {
+				rio_dprintk(RIO_DEBUG_INTR, "WFLUSH on deleted RTA\n");
+			} else {
+				if (RIOPreemptiveCmd(p, PortP, WFLUSH) == RIO_FAIL) {
+					rio_dprintk(RIO_DEBUG_INTR, "T_WFLUSH Command failed\n");
+				} else
+					rio_dprintk(RIO_DEBUG_INTR, "T_WFLUSH Command\n");
 			}
 			/*
-			** sort out the line discipline
-			*/
-			if (PortP->CookMode == COOK_WELL)
-				goto start;
-			break;
-	
-		case T_RESUME:
-			rio_dprintk (RIO_DEBUG_INTR, "T_RESUME\n");
-			/*
-			** send pre-emptive resume packet
-			*/
-			if ( PortP->State & RIO_DELETED ) {
-				rio_dprintk (RIO_DEBUG_INTR, "RESUME on deleted RTA\n");
+			 ** WFLUSH operation - flush the data!
+			 */
+			PortP->TxBufferIn = PortP->TxBufferOut = 0;
+		} else {
+			rio_dprintk(RIO_DEBUG_INTR, "T_WFLUSH Command ignored\n");
+		}
+		/*
+		 ** sort out the line discipline
+		 */
+		if (PortP->CookMode == COOK_WELL)
+			goto start;
+		break;
+
+	case T_RESUME:
+		rio_dprintk(RIO_DEBUG_INTR, "T_RESUME\n");
+		/*
+		 ** send pre-emptive resume packet
+		 */
+		if (PortP->State & RIO_DELETED) {
+			rio_dprintk(RIO_DEBUG_INTR, "RESUME on deleted RTA\n");
+		} else {
+			if (RIOPreemptiveCmd(p, PortP, RESUME) == RIO_FAIL) {
+				rio_dprintk(RIO_DEBUG_INTR, "T_RESUME Command failed\n");
 			}
-			else {
-				if ( RIOPreemptiveCmd(p, PortP, RESUME ) == RIO_FAIL ) {
-					rio_dprintk (RIO_DEBUG_INTR, "T_RESUME Command failed\n");
-				}
+		}
+		/*
+		 ** and re-start the sender software!
+		 */
+		if (PortP->CookMode == COOK_WELL)
+			goto start;
+		break;
+
+	case T_TIME:
+		rio_dprintk(RIO_DEBUG_INTR, "T_TIME\n");
+		/*
+		 ** T_TIME is called when xDLY is set in oflags and
+		 ** the line discipline timeout has expired. It's
+		 ** function in life is to clear the TIMEOUT flag
+		 ** and to re-start output to the port.
+		 */
+		/*
+		 ** Fall through and re-start output
+		 */
+	case T_OUTPUT:
+	      start:
+		if (PortP->MagicFlags & MAGIC_FLUSH) {
+			PortP->MagicFlags |= MORE_OUTPUT_EYGOR;
+			return 0;
+		}
+		RIOTxEnable((char *) PortP);
+		PortP->MagicFlags &= ~MORE_OUTPUT_EYGOR;
+		/*rio_dprint(RIO_DEBUG_INTR, PortP,DBG_PROC,"T_OUTPUT finished\n"); */
+		break;
+
+	case T_SUSPEND:
+		rio_dprintk(RIO_DEBUG_INTR, "T_SUSPEND\n");
+		/*
+		 ** send a suspend pre-emptive packet.
+		 */
+		if (PortP->State & RIO_DELETED) {
+			rio_dprintk(RIO_DEBUG_INTR, "SUSPEND deleted RTA\n");
+		} else {
+			if (RIOPreemptiveCmd(p, PortP, SUSPEND) == RIO_FAIL) {
+				rio_dprintk(RIO_DEBUG_INTR, "T_SUSPEND Command failed\n");
 			}
-			/*
-			** and re-start the sender software!
-			*/
-			if (PortP->CookMode == COOK_WELL)
-				goto start;
-			break;
-	
-		case T_TIME:
-			rio_dprintk (RIO_DEBUG_INTR, "T_TIME\n");
-			/*
-			** T_TIME is called when xDLY is set in oflags and
-			** the line discipline timeout has expired. It's
-			** function in life is to clear the TIMEOUT flag
-			** and to re-start output to the port.
-			*/
-			/*
-			** Fall through and re-start output
-			*/
-		case T_OUTPUT:
-start:
-			if ( PortP->MagicFlags & MAGIC_FLUSH ) {
-				PortP->MagicFlags |= MORE_OUTPUT_EYGOR;
+		}
+		/*
+		 ** done!
+		 */
+		break;
+
+	case T_BLOCK:
+		rio_dprintk(RIO_DEBUG_INTR, "T_BLOCK\n");
+		break;
+
+	case T_RFLUSH:
+		rio_dprintk(RIO_DEBUG_INTR, "T_RFLUSH\n");
+		if (PortP->State & RIO_DELETED) {
+			rio_dprintk(RIO_DEBUG_INTR, "RFLUSH on deleted RTA\n");
+			PortP->RxDataStart = 0;
+		} else {
+			if (RIOPreemptiveCmd(p, PortP, RFLUSH) == RIO_FAIL) {
+				rio_dprintk(RIO_DEBUG_INTR, "T_RFLUSH Command failed\n");
 				return 0;
 			}
-			RIOTxEnable((char *)PortP);
-			PortP->MagicFlags &= ~MORE_OUTPUT_EYGOR;
-			/*rio_dprint(RIO_DEBUG_INTR, PortP,DBG_PROC,"T_OUTPUT finished\n");*/
-			break;
-	
-		case T_SUSPEND:
-			rio_dprintk (RIO_DEBUG_INTR, "T_SUSPEND\n");
-			/*
-			** send a suspend pre-emptive packet.
-			*/
-			if ( PortP->State & RIO_DELETED ) {
-				rio_dprintk (RIO_DEBUG_INTR, "SUSPEND deleted RTA\n");
+			PortP->RxDataStart = 0;
+			while (can_remove_receive(&PacketP, PortP)) {
+				remove_receive(PortP);
+				ShowPacket(DBG_PROC, PacketP);
+				put_free_end(PortP->HostP, PacketP);
 			}
-			else {
-				if ( RIOPreemptiveCmd(p, PortP, SUSPEND ) == RIO_FAIL ) {
-					rio_dprintk (RIO_DEBUG_INTR, "T_SUSPEND Command failed\n");
-				}
+			if (PortP->PhbP->handshake == PHB_HANDSHAKE_SET) {
+				/*
+				 ** MAGIC!
+				 */
+				rio_dprintk(RIO_DEBUG_INTR, "Set receive handshake bit\n");
+				PortP->PhbP->handshake |= PHB_HANDSHAKE_RESET;
 			}
-			/*
-			** done!
-			*/
-			break;
-	
-		case T_BLOCK:
-			rio_dprintk (RIO_DEBUG_INTR, "T_BLOCK\n");
-			break;
-	
-		case T_RFLUSH:
-			rio_dprintk (RIO_DEBUG_INTR, "T_RFLUSH\n");
-			if ( PortP->State & RIO_DELETED ) {
-				rio_dprintk (RIO_DEBUG_INTR, "RFLUSH on deleted RTA\n");
-				PortP->RxDataStart = 0;
+		}
+		break;
+		/* FALLTHROUGH */
+	case T_UNBLOCK:
+		rio_dprintk(RIO_DEBUG_INTR, "T_UNBLOCK\n");
+		/*
+		 ** If there is any data to receive set a timeout to service it.
+		 */
+		RIOReceive(p, PortP);
+		break;
+
+	case T_BREAK:
+		rio_dprintk(RIO_DEBUG_INTR, "T_BREAK\n");
+		/*
+		 ** Send a break command. For Sys V
+		 ** this is a timed break, so we
+		 ** send a SBREAK[time] packet
+		 */
+		/*
+		 ** Build a BREAK command
+		 */
+		if (PortP->State & RIO_DELETED) {
+			rio_dprintk(RIO_DEBUG_INTR, "BREAK on deleted RTA\n");
+		} else {
+			if (RIOShortCommand(PortP, SBREAK, 2, p->RIOConf.BreakInterval) == RIO_FAIL) {
+				rio_dprintk(RIO_DEBUG_INTR, "SBREAK RIOShortCommand failed\n");
 			}
-			else {
-				if ( RIOPreemptiveCmd( p, PortP, RFLUSH ) == RIO_FAIL ) {
-					rio_dprintk (RIO_DEBUG_INTR, "T_RFLUSH Command failed\n");
-					return 0;
-				}
-				PortP->RxDataStart = 0;
-				while ( can_remove_receive(&PacketP, PortP) ) {
-					remove_receive(PortP);
-					ShowPacket(DBG_PROC, PacketP );
-					put_free_end(PortP->HostP, PacketP );
-				}
-				if ( PortP->PhbP->handshake == PHB_HANDSHAKE_SET ) {
-					/*
-					** MAGIC!
-					*/
-					rio_dprintk (RIO_DEBUG_INTR, "Set receive handshake bit\n");
-					PortP->PhbP->handshake |= PHB_HANDSHAKE_RESET;
-				}
-			}
-			break;
-			/* FALLTHROUGH */
-		case T_UNBLOCK:
-			rio_dprintk (RIO_DEBUG_INTR, "T_UNBLOCK\n");
-			/*
-			** If there is any data to receive set a timeout to service it.
-			*/
-			RIOReceive(p, PortP);
-			break;
-	
-		case T_BREAK:
-			rio_dprintk (RIO_DEBUG_INTR, "T_BREAK\n");
-			/*
-			** Send a break command. For Sys V
-			** this is a timed break, so we
-			** send a SBREAK[time] packet
-			*/
-			/*
-			** Build a BREAK command
-			*/
-			if ( PortP->State & RIO_DELETED ) {
-				rio_dprintk (RIO_DEBUG_INTR, "BREAK on deleted RTA\n");
-			}
-			else {
-				if (RIOShortCommand(PortP,SBREAK,2,
-								p->RIOConf.BreakInterval)==RIO_FAIL) {
-			   		rio_dprintk (RIO_DEBUG_INTR, "SBREAK RIOShortCommand failed\n");
-				}
-			}
-	
-			/*
-			** done!
-			*/
-			break;
-	
-		case T_INPUT:
-			rio_dprintk (RIO_DEBUG_INTR, "Proc T_INPUT called - I don't know what to do!\n");
-			break;
-		case T_PARM:
-			rio_dprintk (RIO_DEBUG_INTR, "Proc T_PARM called - I don't know what to do!\n");
-			break;
-	
-		case T_SWTCH:
-			rio_dprintk (RIO_DEBUG_INTR, "Proc T_SWTCH called - I don't know what to do!\n");
-			break;
-	
-		default:
-			rio_dprintk (RIO_DEBUG_INTR, "Proc UNKNOWN command %d\n",cmd);
+		}
+
+		/*
+		 ** done!
+		 */
+		break;
+
+	case T_INPUT:
+		rio_dprintk(RIO_DEBUG_INTR, "Proc T_INPUT called - I don't know what to do!\n");
+		break;
+	case T_PARM:
+		rio_dprintk(RIO_DEBUG_INTR, "Proc T_PARM called - I don't know what to do!\n");
+		break;
+
+	case T_SWTCH:
+		rio_dprintk(RIO_DEBUG_INTR, "Proc T_SWTCH called - I don't know what to do!\n");
+		break;
+
+	default:
+		rio_dprintk(RIO_DEBUG_INTR, "Proc UNKNOWN command %d\n", cmd);
 	}
 	/*
-	** T_OUTPUT returns without passing through this point!
-	*/
-	/*rio_dprint(RIO_DEBUG_INTR, PortP,DBG_PROC,"riotproc done\n");*/
-	return(0);
+	 ** T_OUTPUT returns without passing through this point!
+	 */
+	/*rio_dprint(RIO_DEBUG_INTR, PortP,DBG_PROC,"riotproc done\n"); */
+	return (0);
 }
 #endif
diff --git a/drivers/char/rio/rioioctl.h b/drivers/char/rio/rioioctl.h
index c3d6797..14b83fa 100644
--- a/drivers/char/rio/rioioctl.h
+++ b/drivers/char/rio/rioioctl.h
@@ -42,14 +42,14 @@
 */
 
 struct portStats {
-	int	port;
-	int	gather;
-	ulong	txchars;
-	ulong	rxchars;
-	ulong	opens;
-	ulong	closes;
-	ulong	ioctls;
-}; 
+	int port;
+	int gather;
+	ulong txchars;
+	ulong rxchars;
+	ulong opens;
+	ulong closes;
+	ulong ioctls;
+};
 
 
 #define rIOC	('r'<<8)
@@ -100,4 +100,4 @@
 #define RIO_RESET_PORT_STATS	(RIOC | 194)
 #define RIO_GET_PORT_STATS	(RIOC | 195)
 
-#endif	/* __rioioctl_h__ */
+#endif				/* __rioioctl_h__ */
diff --git a/drivers/char/rio/rioparam.c b/drivers/char/rio/rioparam.c
index f109163..4cc7f49 100644
--- a/drivers/char/rio/rioparam.c
+++ b/drivers/char/rio/rioparam.c
@@ -157,46 +157,44 @@
 ** NB. for MPX
 **	tty lock must NOT have been previously acquired.
 */
-int
-RIOParam(PortP, cmd, Modem, SleepFlag)
+int RIOParam(PortP, cmd, Modem, SleepFlag)
 struct Port *PortP;
 int cmd;
 int Modem;
-int SleepFlag; 
+int SleepFlag;
 {
 	register struct tty_struct *TtyP;
-	int	retval;
+	int retval;
 	register struct phb_param *phb_param_ptr;
 	PKT *PacketP;
 	int res;
-	uchar Cor1=0, Cor2=0, Cor4=0, Cor5=0;
-	uchar TxXon=0, TxXoff=0, RxXon=0, RxXoff=0;
-	uchar LNext=0, TxBaud=0, RxBaud=0;
-	int		retries = 0xff;
+	uchar Cor1 = 0, Cor2 = 0, Cor4 = 0, Cor5 = 0;
+	uchar TxXon = 0, TxXoff = 0, RxXon = 0, RxXoff = 0;
+	uchar LNext = 0, TxBaud = 0, RxBaud = 0;
+	int retries = 0xff;
 	unsigned long flags;
 
-	func_enter ();
+	func_enter();
 
 	TtyP = PortP->gs.tty;
 
-	rio_dprintk (RIO_DEBUG_PARAM, "RIOParam: Port:%d cmd:%d Modem:%d SleepFlag:%d Mapped: %d, tty=%p\n",
-	    PortP->PortNum, cmd, Modem, SleepFlag, PortP->Mapped, TtyP);
+	rio_dprintk(RIO_DEBUG_PARAM, "RIOParam: Port:%d cmd:%d Modem:%d SleepFlag:%d Mapped: %d, tty=%p\n", PortP->PortNum, cmd, Modem, SleepFlag, PortP->Mapped, TtyP);
 
 	if (!TtyP) {
-	  rio_dprintk (RIO_DEBUG_PARAM, "Can't call rioparam with null tty.\n");
+		rio_dprintk(RIO_DEBUG_PARAM, "Can't call rioparam with null tty.\n");
 
-	  func_exit ();
+		func_exit();
 
-	  return RIO_FAIL;
+		return RIO_FAIL;
 	}
-	rio_spin_lock_irqsave(&PortP->portSem, flags );
+	rio_spin_lock_irqsave(&PortP->portSem, flags);
 
 	if (cmd == OPEN) {
 		/*
-		** If the port is set to store or lock the parameters, and it is
-		** paramed with OPEN, we want to restore the saved port termio, but
-		** only if StoredTermio has been saved, i.e. NOT 1st open after reboot.
-		*/
+		 ** If the port is set to store or lock the parameters, and it is
+		 ** paramed with OPEN, we want to restore the saved port termio, but
+		 ** only if StoredTermio has been saved, i.e. NOT 1st open after reboot.
+		 */
 #if 0
 		if (PortP->FirstOpen) {
 			PortP->StoredTty.iflag = TtyP->tm.c_iflag;
@@ -207,9 +205,8 @@
 			for (i = 0; i < NCC + 5; i++)
 				PortP->StoredTty.cc[i] = TtyP->tm.c_cc[i];
 			PortP->FirstOpen = 0;
-		}
-		else if (PortP->Store || PortP->Lock) {
-			rio_dprintk (RIO_DEBUG_PARAM, "OPEN: Restoring stored/locked params\n");
+		} else if (PortP->Store || PortP->Lock) {
+			rio_dprintk(RIO_DEBUG_PARAM, "OPEN: Restoring stored/locked params\n");
 			TtyP->tm.c_iflag = PortP->StoredTty.iflag;
 			TtyP->tm.c_oflag = PortP->StoredTty.oflag;
 			TtyP->tm.c_cflag = PortP->StoredTty.cflag;
@@ -222,230 +219,222 @@
 	}
 
 	/*
-	** wait for space
-	*/
-	while ( !(res=can_add_transmit(&PacketP,PortP)) || 
-			(PortP->InUse != NOT_INUSE) ) {
-		if (retries -- <= 0) {
+	 ** wait for space
+	 */
+	while (!(res = can_add_transmit(&PacketP, PortP)) || (PortP->InUse != NOT_INUSE)) {
+		if (retries-- <= 0) {
 			break;
 		}
-		if ( PortP->InUse != NOT_INUSE ) {
-			rio_dprintk (RIO_DEBUG_PARAM, "Port IN_USE for pre-emptive command\n");
+		if (PortP->InUse != NOT_INUSE) {
+			rio_dprintk(RIO_DEBUG_PARAM, "Port IN_USE for pre-emptive command\n");
 		}
 
-		if ( !res ) {
-			rio_dprintk (RIO_DEBUG_PARAM, "Port has no space on transmit queue\n");
+		if (!res) {
+			rio_dprintk(RIO_DEBUG_PARAM, "Port has no space on transmit queue\n");
 		}
 
-		if ( SleepFlag != OK_TO_SLEEP ) {
-			rio_spin_unlock_irqrestore( &PortP->portSem, flags);
+		if (SleepFlag != OK_TO_SLEEP) {
+			rio_spin_unlock_irqrestore(&PortP->portSem, flags);
 			func_exit();
-			
+
 			return RIO_FAIL;
 		}
 
-		rio_dprintk (RIO_DEBUG_PARAM, "wait for can_add_transmit\n");
-		rio_spin_unlock_irqrestore( &PortP->portSem, flags);
+		rio_dprintk(RIO_DEBUG_PARAM, "wait for can_add_transmit\n");
+		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
 		retval = RIODelay(PortP, HUNDRED_MS);
-		rio_spin_lock_irqsave( &PortP->portSem, flags);
+		rio_spin_lock_irqsave(&PortP->portSem, flags);
 		if (retval == RIO_FAIL) {
-			rio_dprintk (RIO_DEBUG_PARAM, "wait for can_add_transmit broken by signal\n");
-			rio_spin_unlock_irqrestore( &PortP->portSem, flags);
+			rio_dprintk(RIO_DEBUG_PARAM, "wait for can_add_transmit broken by signal\n");
+			rio_spin_unlock_irqrestore(&PortP->portSem, flags);
 			pseterr(EINTR);
 			func_exit();
 
 			return RIO_FAIL;
 		}
-		if ( PortP->State & RIO_DELETED ) {
-			rio_spin_unlock_irqrestore( &PortP->portSem, flags);
-			func_exit ();
+		if (PortP->State & RIO_DELETED) {
+			rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+			func_exit();
 
 			return RIO_SUCCESS;
 		}
 	}
 
 	if (!res) {
-		rio_spin_unlock_irqrestore( &PortP->portSem, flags);
-		func_exit ();
+		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+		func_exit();
 
 		return RIO_FAIL;
 	}
 
-	rio_dprintk (RIO_DEBUG_PARAM, "can_add_transmit() returns %x\n",res);
-	rio_dprintk (RIO_DEBUG_PARAM, "Packet is 0x%x\n",(int) PacketP);
+	rio_dprintk(RIO_DEBUG_PARAM, "can_add_transmit() returns %x\n", res);
+	rio_dprintk(RIO_DEBUG_PARAM, "Packet is 0x%x\n", (int) PacketP);
 
-	phb_param_ptr = (struct phb_param *)PacketP->data;
+	phb_param_ptr = (struct phb_param *) PacketP->data;
 
 
 #if 0
 	/*
-	** COR 1
-	*/
-	if ( TtyP->tm.c_iflag & INPCK ) {
-		rio_dprintk (RIO_DEBUG_PARAM, "Parity checking on input enabled\n");
+	 ** COR 1
+	 */
+	if (TtyP->tm.c_iflag & INPCK) {
+		rio_dprintk(RIO_DEBUG_PARAM, "Parity checking on input enabled\n");
 		Cor1 |= COR1_INPCK;
 	}
 #endif
 
-	switch ( TtyP->termios->c_cflag & CSIZE ) {
-		case CS5:
+	switch (TtyP->termios->c_cflag & CSIZE) {
+	case CS5:
 		{
-			rio_dprintk (RIO_DEBUG_PARAM, "5 bit data\n");
+			rio_dprintk(RIO_DEBUG_PARAM, "5 bit data\n");
 			Cor1 |= COR1_5BITS;
 			break;
 		}
-		case CS6:
+	case CS6:
 		{
-			rio_dprintk (RIO_DEBUG_PARAM, "6 bit data\n");
+			rio_dprintk(RIO_DEBUG_PARAM, "6 bit data\n");
 			Cor1 |= COR1_6BITS;
 			break;
 		}
-		case CS7:
+	case CS7:
 		{
-			rio_dprintk (RIO_DEBUG_PARAM, "7 bit data\n");
+			rio_dprintk(RIO_DEBUG_PARAM, "7 bit data\n");
 			Cor1 |= COR1_7BITS;
 			break;
 		}
-		case CS8:
+	case CS8:
 		{
-			rio_dprintk (RIO_DEBUG_PARAM, "8 bit data\n");
+			rio_dprintk(RIO_DEBUG_PARAM, "8 bit data\n");
 			Cor1 |= COR1_8BITS;
 			break;
 		}
 	}
 
-	if ( TtyP->termios->c_cflag & CSTOPB ) {
-		rio_dprintk (RIO_DEBUG_PARAM, "2 stop bits\n");
+	if (TtyP->termios->c_cflag & CSTOPB) {
+		rio_dprintk(RIO_DEBUG_PARAM, "2 stop bits\n");
 		Cor1 |= COR1_2STOP;
-	}
-	else {
-		rio_dprintk (RIO_DEBUG_PARAM, "1 stop bit\n");
+	} else {
+		rio_dprintk(RIO_DEBUG_PARAM, "1 stop bit\n");
 		Cor1 |= COR1_1STOP;
 	}
 
-	if ( TtyP->termios->c_cflag & PARENB ) {
-		rio_dprintk (RIO_DEBUG_PARAM, "Enable parity\n");
+	if (TtyP->termios->c_cflag & PARENB) {
+		rio_dprintk(RIO_DEBUG_PARAM, "Enable parity\n");
 		Cor1 |= COR1_NORMAL;
-	}
-	else {
-		rio_dprintk (RIO_DEBUG_PARAM, "Disable parity\n");
+	} else {
+		rio_dprintk(RIO_DEBUG_PARAM, "Disable parity\n");
 		Cor1 |= COR1_NOP;
 	}
-	if ( TtyP->termios->c_cflag & PARODD ) {
-		rio_dprintk (RIO_DEBUG_PARAM, "Odd parity\n");
+	if (TtyP->termios->c_cflag & PARODD) {
+		rio_dprintk(RIO_DEBUG_PARAM, "Odd parity\n");
 		Cor1 |= COR1_ODD;
-	}
-	else {
-		rio_dprintk (RIO_DEBUG_PARAM, "Even parity\n");
-		Cor1 |= COR1_EVEN; 
+	} else {
+		rio_dprintk(RIO_DEBUG_PARAM, "Even parity\n");
+		Cor1 |= COR1_EVEN;
 	}
 
 	/*
-	** COR 2
-	*/
-	if ( TtyP->termios->c_iflag & IXON ) {
-		rio_dprintk (RIO_DEBUG_PARAM, "Enable start/stop output control\n");
+	 ** COR 2
+	 */
+	if (TtyP->termios->c_iflag & IXON) {
+		rio_dprintk(RIO_DEBUG_PARAM, "Enable start/stop output control\n");
 		Cor2 |= COR2_IXON;
-	}
-	else {
-		if ( PortP->Config & RIO_IXON ) {
-			rio_dprintk (RIO_DEBUG_PARAM, "Force enable start/stop output control\n");
+	} else {
+		if (PortP->Config & RIO_IXON) {
+			rio_dprintk(RIO_DEBUG_PARAM, "Force enable start/stop output control\n");
 			Cor2 |= COR2_IXON;
-		}
-		else
-			rio_dprintk (RIO_DEBUG_PARAM, "IXON has been disabled.\n");
+		} else
+			rio_dprintk(RIO_DEBUG_PARAM, "IXON has been disabled.\n");
 	}
 
 	if (TtyP->termios->c_iflag & IXANY) {
-		if ( PortP->Config & RIO_IXANY ) {
-			rio_dprintk (RIO_DEBUG_PARAM, "Enable any key to restart output\n");
+		if (PortP->Config & RIO_IXANY) {
+			rio_dprintk(RIO_DEBUG_PARAM, "Enable any key to restart output\n");
 			Cor2 |= COR2_IXANY;
-		}
-		else
-			rio_dprintk (RIO_DEBUG_PARAM, "IXANY has been disabled due to sanity reasons.\n");
+		} else
+			rio_dprintk(RIO_DEBUG_PARAM, "IXANY has been disabled due to sanity reasons.\n");
 	}
 
-	if ( TtyP->termios->c_iflag & IXOFF ) {
-		rio_dprintk (RIO_DEBUG_PARAM, "Enable start/stop input control 2\n");
+	if (TtyP->termios->c_iflag & IXOFF) {
+		rio_dprintk(RIO_DEBUG_PARAM, "Enable start/stop input control 2\n");
 		Cor2 |= COR2_IXOFF;
 	}
 
-	if ( TtyP->termios->c_cflag & HUPCL ) {
-		rio_dprintk (RIO_DEBUG_PARAM, "Hangup on last close\n");
+	if (TtyP->termios->c_cflag & HUPCL) {
+		rio_dprintk(RIO_DEBUG_PARAM, "Hangup on last close\n");
 		Cor2 |= COR2_HUPCL;
 	}
 
-	if ( C_CRTSCTS (TtyP)) {
-		rio_dprintk (RIO_DEBUG_PARAM, "Rx hardware flow control enabled\n");
+	if (C_CRTSCTS(TtyP)) {
+		rio_dprintk(RIO_DEBUG_PARAM, "Rx hardware flow control enabled\n");
 		Cor2 |= COR2_CTSFLOW;
 		Cor2 |= COR2_RTSFLOW;
 	} else {
-		rio_dprintk (RIO_DEBUG_PARAM, "Rx hardware flow control disabled\n");
+		rio_dprintk(RIO_DEBUG_PARAM, "Rx hardware flow control disabled\n");
 		Cor2 &= ~COR2_CTSFLOW;
 		Cor2 &= ~COR2_RTSFLOW;
 	}
 
 
-	if ( TtyP->termios->c_cflag & CLOCAL ) {
-		rio_dprintk (RIO_DEBUG_PARAM, "Local line\n");
-	}
-	else {
-		rio_dprintk (RIO_DEBUG_PARAM, "Possible Modem line\n");
+	if (TtyP->termios->c_cflag & CLOCAL) {
+		rio_dprintk(RIO_DEBUG_PARAM, "Local line\n");
+	} else {
+		rio_dprintk(RIO_DEBUG_PARAM, "Possible Modem line\n");
 	}
 
 	/*
-	** COR 4 (there is no COR 3)
-	*/
-	if ( TtyP->termios->c_iflag & IGNBRK ) {
-		rio_dprintk (RIO_DEBUG_PARAM, "Ignore break condition\n");
+	 ** COR 4 (there is no COR 3)
+	 */
+	if (TtyP->termios->c_iflag & IGNBRK) {
+		rio_dprintk(RIO_DEBUG_PARAM, "Ignore break condition\n");
 		Cor4 |= COR4_IGNBRK;
 	}
-	if ( !(TtyP->termios->c_iflag & BRKINT) ) {
-		rio_dprintk (RIO_DEBUG_PARAM, "Break generates NULL condition\n");
+	if (!(TtyP->termios->c_iflag & BRKINT)) {
+		rio_dprintk(RIO_DEBUG_PARAM, "Break generates NULL condition\n");
 		Cor4 |= COR4_NBRKINT;
 	} else {
-		rio_dprintk (RIO_DEBUG_PARAM, "Interrupt on	break condition\n");
+		rio_dprintk(RIO_DEBUG_PARAM, "Interrupt on	break condition\n");
 	}
 
-	if ( TtyP->termios->c_iflag & INLCR ) {
-		rio_dprintk (RIO_DEBUG_PARAM, "Map newline to carriage return on input\n");
+	if (TtyP->termios->c_iflag & INLCR) {
+		rio_dprintk(RIO_DEBUG_PARAM, "Map newline to carriage return on input\n");
 		Cor4 |= COR4_INLCR;
 	}
 
-	if ( TtyP->termios->c_iflag & IGNCR ) {
-		rio_dprintk (RIO_DEBUG_PARAM, "Ignore carriage return on input\n");
+	if (TtyP->termios->c_iflag & IGNCR) {
+		rio_dprintk(RIO_DEBUG_PARAM, "Ignore carriage return on input\n");
 		Cor4 |= COR4_IGNCR;
 	}
 
-	if ( TtyP->termios->c_iflag & ICRNL ) {
-		rio_dprintk (RIO_DEBUG_PARAM, "Map carriage return to newline on input\n");
+	if (TtyP->termios->c_iflag & ICRNL) {
+		rio_dprintk(RIO_DEBUG_PARAM, "Map carriage return to newline on input\n");
 		Cor4 |= COR4_ICRNL;
 	}
-	if ( TtyP->termios->c_iflag & IGNPAR ) {
-		rio_dprintk (RIO_DEBUG_PARAM, "Ignore characters with parity errors\n");
+	if (TtyP->termios->c_iflag & IGNPAR) {
+		rio_dprintk(RIO_DEBUG_PARAM, "Ignore characters with parity errors\n");
 		Cor4 |= COR4_IGNPAR;
 	}
-	if ( TtyP->termios->c_iflag & PARMRK ) {
-		rio_dprintk (RIO_DEBUG_PARAM, "Mark parity errors\n");
+	if (TtyP->termios->c_iflag & PARMRK) {
+		rio_dprintk(RIO_DEBUG_PARAM, "Mark parity errors\n");
 		Cor4 |= COR4_PARMRK;
 	}
 
 	/*
-	** Set the RAISEMOD flag to ensure that the modem lines are raised
-	** on reception of a config packet.
-	** The download code handles the zero baud condition.
-	*/
+	 ** Set the RAISEMOD flag to ensure that the modem lines are raised
+	 ** on reception of a config packet.
+	 ** The download code handles the zero baud condition.
+	 */
 	Cor4 |= COR4_RAISEMOD;
 
 	/*
-	** COR 5
-	*/
+	 ** COR 5
+	 */
 
 	Cor5 = COR5_CMOE;
 
 	/*
-	** Set to monitor tbusy/tstop (or not).
-	*/
+	 ** Set to monitor tbusy/tstop (or not).
+	 */
 
 	if (PortP->MonitorTstate)
 		Cor5 |= COR5_TSTATE_ON;
@@ -453,182 +442,195 @@
 		Cor5 |= COR5_TSTATE_OFF;
 
 	/*
-	** Could set LNE here if you wanted LNext processing. SVR4 will use it.
-	*/
-	if ( TtyP->termios->c_iflag & ISTRIP ) {
-		rio_dprintk (RIO_DEBUG_PARAM, "Strip input characters\n");
-		if (! (PortP->State & RIO_TRIAD_MODE)) {
+	 ** Could set LNE here if you wanted LNext processing. SVR4 will use it.
+	 */
+	if (TtyP->termios->c_iflag & ISTRIP) {
+		rio_dprintk(RIO_DEBUG_PARAM, "Strip input characters\n");
+		if (!(PortP->State & RIO_TRIAD_MODE)) {
 			Cor5 |= COR5_ISTRIP;
 		}
 	}
 
-	if ( TtyP->termios->c_oflag & ONLCR ) {
-		rio_dprintk (RIO_DEBUG_PARAM, "Map newline to carriage-return, newline on output\n");
-		if ( PortP->CookMode == COOK_MEDIUM )
+	if (TtyP->termios->c_oflag & ONLCR) {
+		rio_dprintk(RIO_DEBUG_PARAM, "Map newline to carriage-return, newline on output\n");
+		if (PortP->CookMode == COOK_MEDIUM)
 			Cor5 |= COR5_ONLCR;
 	}
-	if ( TtyP->termios->c_oflag & OCRNL ) {
-		rio_dprintk (RIO_DEBUG_PARAM, "Map carriage return to newline on output\n");
-		if ( PortP->CookMode == COOK_MEDIUM )
+	if (TtyP->termios->c_oflag & OCRNL) {
+		rio_dprintk(RIO_DEBUG_PARAM, "Map carriage return to newline on output\n");
+		if (PortP->CookMode == COOK_MEDIUM)
 			Cor5 |= COR5_OCRNL;
 	}
-	if ( ( TtyP->termios->c_oflag & TABDLY) == TAB3 ) {
-		rio_dprintk (RIO_DEBUG_PARAM, "Tab delay 3 set\n");
-		if ( PortP->CookMode == COOK_MEDIUM )
+	if ((TtyP->termios->c_oflag & TABDLY) == TAB3) {
+		rio_dprintk(RIO_DEBUG_PARAM, "Tab delay 3 set\n");
+		if (PortP->CookMode == COOK_MEDIUM)
 			Cor5 |= COR5_TAB3;
 	}
 
 	/*
-	** Flow control bytes.
-	*/
+	 ** Flow control bytes.
+	 */
 	TxXon = TtyP->termios->c_cc[VSTART];
 	TxXoff = TtyP->termios->c_cc[VSTOP];
 	RxXon = TtyP->termios->c_cc[VSTART];
 	RxXoff = TtyP->termios->c_cc[VSTOP];
 	/*
-	** LNEXT byte
-	*/
+	 ** LNEXT byte
+	 */
 	LNext = 0;
 
 	/*
-	** Baud rate bytes
-	*/
-	rio_dprintk (RIO_DEBUG_PARAM, "Mapping of rx/tx baud %x (%x)\n", 
-				     TtyP->termios->c_cflag, CBAUD);
+	 ** Baud rate bytes
+	 */
+	rio_dprintk(RIO_DEBUG_PARAM, "Mapping of rx/tx baud %x (%x)\n", TtyP->termios->c_cflag, CBAUD);
 
 	switch (TtyP->termios->c_cflag & CBAUD) {
 #define e(b) case B ## b : RxBaud = TxBaud = RIO_B ## b ;break
-	  e(50);e(75);e(110);e(134);e(150);e(200);e(300);e(600);e(1200);
-	  e(1800);e(2400);e(4800);e(9600);e(19200);e(38400);e(57600);
-	  e(115200); /* e(230400);e(460800); e(921600);  */
+		e(50);
+		e(75);
+		e(110);
+		e(134);
+		e(150);
+		e(200);
+		e(300);
+		e(600);
+		e(1200);
+		e(1800);
+		e(2400);
+		e(4800);
+		e(9600);
+		e(19200);
+		e(38400);
+		e(57600);
+		e(115200);	/* e(230400);e(460800); e(921600);  */
 	}
 
 	/* XXX MIssing conversion table. XXX */
-	/* 	 (TtyP->termios->c_cflag & V_CBAUD); */
+	/*       (TtyP->termios->c_cflag & V_CBAUD); */
 
-	rio_dprintk (RIO_DEBUG_PARAM, "tx baud 0x%x, rx baud 0x%x\n", TxBaud, RxBaud);
+	rio_dprintk(RIO_DEBUG_PARAM, "tx baud 0x%x, rx baud 0x%x\n", TxBaud, RxBaud);
 
 
 	/*
-	** Leftovers
-	*/
-	if ( TtyP->termios->c_cflag & CREAD )
-		rio_dprintk (RIO_DEBUG_PARAM, "Enable receiver\n");
+	 ** Leftovers
+	 */
+	if (TtyP->termios->c_cflag & CREAD)
+		rio_dprintk(RIO_DEBUG_PARAM, "Enable receiver\n");
 #ifdef RCV1EN
-	if ( TtyP->termios->c_cflag & RCV1EN )
-		rio_dprintk (RIO_DEBUG_PARAM, "RCV1EN (?)\n");
+	if (TtyP->termios->c_cflag & RCV1EN)
+		rio_dprintk(RIO_DEBUG_PARAM, "RCV1EN (?)\n");
 #endif
 #ifdef XMT1EN
-	if ( TtyP->termios->c_cflag & XMT1EN )
-		rio_dprintk (RIO_DEBUG_PARAM, "XMT1EN (?)\n");
+	if (TtyP->termios->c_cflag & XMT1EN)
+		rio_dprintk(RIO_DEBUG_PARAM, "XMT1EN (?)\n");
 #endif
 #if 0
-	if ( TtyP->termios->c_cflag & LOBLK )
-		rio_dprintk (RIO_DEBUG_PARAM, "LOBLK - JCL output blocks when not current\n");
+	if (TtyP->termios->c_cflag & LOBLK)
+		rio_dprintk(RIO_DEBUG_PARAM, "LOBLK - JCL output blocks when not current\n");
 #endif
-	if ( TtyP->termios->c_lflag & ISIG )
-		rio_dprintk (RIO_DEBUG_PARAM, "Input character signal generating enabled\n");
-	if ( TtyP->termios->c_lflag & ICANON )
-		rio_dprintk (RIO_DEBUG_PARAM, "Canonical input: erase and kill enabled\n");
-	if ( TtyP->termios->c_lflag & XCASE )
-		rio_dprintk (RIO_DEBUG_PARAM, "Canonical upper/lower presentation\n");
-	if ( TtyP->termios->c_lflag & ECHO )
-		rio_dprintk (RIO_DEBUG_PARAM, "Enable input echo\n");
-	if ( TtyP->termios->c_lflag & ECHOE )
-		rio_dprintk (RIO_DEBUG_PARAM, "Enable echo erase\n");
-	if ( TtyP->termios->c_lflag & ECHOK )
-		rio_dprintk (RIO_DEBUG_PARAM, "Enable echo kill\n");
-	if ( TtyP->termios->c_lflag & ECHONL )
-		rio_dprintk (RIO_DEBUG_PARAM, "Enable echo newline\n");
-	if ( TtyP->termios->c_lflag & NOFLSH )
-		rio_dprintk (RIO_DEBUG_PARAM, "Disable flush after interrupt or quit\n");
+	if (TtyP->termios->c_lflag & ISIG)
+		rio_dprintk(RIO_DEBUG_PARAM, "Input character signal generating enabled\n");
+	if (TtyP->termios->c_lflag & ICANON)
+		rio_dprintk(RIO_DEBUG_PARAM, "Canonical input: erase and kill enabled\n");
+	if (TtyP->termios->c_lflag & XCASE)
+		rio_dprintk(RIO_DEBUG_PARAM, "Canonical upper/lower presentation\n");
+	if (TtyP->termios->c_lflag & ECHO)
+		rio_dprintk(RIO_DEBUG_PARAM, "Enable input echo\n");
+	if (TtyP->termios->c_lflag & ECHOE)
+		rio_dprintk(RIO_DEBUG_PARAM, "Enable echo erase\n");
+	if (TtyP->termios->c_lflag & ECHOK)
+		rio_dprintk(RIO_DEBUG_PARAM, "Enable echo kill\n");
+	if (TtyP->termios->c_lflag & ECHONL)
+		rio_dprintk(RIO_DEBUG_PARAM, "Enable echo newline\n");
+	if (TtyP->termios->c_lflag & NOFLSH)
+		rio_dprintk(RIO_DEBUG_PARAM, "Disable flush after interrupt or quit\n");
 #ifdef TOSTOP
-	if ( TtyP->termios->c_lflag & TOSTOP )
-		rio_dprintk (RIO_DEBUG_PARAM, "Send SIGTTOU for background output\n");
+	if (TtyP->termios->c_lflag & TOSTOP)
+		rio_dprintk(RIO_DEBUG_PARAM, "Send SIGTTOU for background output\n");
 #endif
 #ifdef XCLUDE
-	if ( TtyP->termios->c_lflag & XCLUDE )
-		rio_dprintk (RIO_DEBUG_PARAM, "Exclusive use of this line\n");
+	if (TtyP->termios->c_lflag & XCLUDE)
+		rio_dprintk(RIO_DEBUG_PARAM, "Exclusive use of this line\n");
 #endif
-	if ( TtyP->termios->c_iflag & IUCLC )
-		rio_dprintk (RIO_DEBUG_PARAM, "Map uppercase to lowercase on input\n");
-	if ( TtyP->termios->c_oflag & OPOST )
-		rio_dprintk (RIO_DEBUG_PARAM, "Enable output post-processing\n");
-	if ( TtyP->termios->c_oflag & OLCUC )
-		rio_dprintk (RIO_DEBUG_PARAM, "Map lowercase to uppercase on output\n");
-	if ( TtyP->termios->c_oflag & ONOCR )
-		rio_dprintk (RIO_DEBUG_PARAM, "No carriage return output at column 0\n");
-	if ( TtyP->termios->c_oflag & ONLRET )
-		rio_dprintk (RIO_DEBUG_PARAM, "Newline performs carriage return function\n");
-	if ( TtyP->termios->c_oflag & OFILL )
-		rio_dprintk (RIO_DEBUG_PARAM, "Use fill characters for delay\n");
-	if ( TtyP->termios->c_oflag & OFDEL )
-		rio_dprintk (RIO_DEBUG_PARAM, "Fill character is DEL\n");
-	if ( TtyP->termios->c_oflag & NLDLY )
-		rio_dprintk (RIO_DEBUG_PARAM, "Newline delay set\n");
-	if ( TtyP->termios->c_oflag & CRDLY )
-		rio_dprintk (RIO_DEBUG_PARAM, "Carriage return delay set\n");
-	if ( TtyP->termios->c_oflag & TABDLY )
-		rio_dprintk (RIO_DEBUG_PARAM, "Tab delay set\n");
+	if (TtyP->termios->c_iflag & IUCLC)
+		rio_dprintk(RIO_DEBUG_PARAM, "Map uppercase to lowercase on input\n");
+	if (TtyP->termios->c_oflag & OPOST)
+		rio_dprintk(RIO_DEBUG_PARAM, "Enable output post-processing\n");
+	if (TtyP->termios->c_oflag & OLCUC)
+		rio_dprintk(RIO_DEBUG_PARAM, "Map lowercase to uppercase on output\n");
+	if (TtyP->termios->c_oflag & ONOCR)
+		rio_dprintk(RIO_DEBUG_PARAM, "No carriage return output at column 0\n");
+	if (TtyP->termios->c_oflag & ONLRET)
+		rio_dprintk(RIO_DEBUG_PARAM, "Newline performs carriage return function\n");
+	if (TtyP->termios->c_oflag & OFILL)
+		rio_dprintk(RIO_DEBUG_PARAM, "Use fill characters for delay\n");
+	if (TtyP->termios->c_oflag & OFDEL)
+		rio_dprintk(RIO_DEBUG_PARAM, "Fill character is DEL\n");
+	if (TtyP->termios->c_oflag & NLDLY)
+		rio_dprintk(RIO_DEBUG_PARAM, "Newline delay set\n");
+	if (TtyP->termios->c_oflag & CRDLY)
+		rio_dprintk(RIO_DEBUG_PARAM, "Carriage return delay set\n");
+	if (TtyP->termios->c_oflag & TABDLY)
+		rio_dprintk(RIO_DEBUG_PARAM, "Tab delay set\n");
 #if 0
-	if ( TtyP->termios->c_oflag & BSDLY )
-		rio_dprintk (RIO_DEBUG_PARAM, "Back-space delay set\n");
-	if ( TtyP->termios->c_oflag & VTDLY )
-		rio_dprintk (RIO_DEBUG_PARAM, "Vertical tab delay set\n");
-	if ( TtyP->termios->c_oflag & FFDLY )
-		rio_dprintk (RIO_DEBUG_PARAM, "Form-feed delay set\n");
+	if (TtyP->termios->c_oflag & BSDLY)
+		rio_dprintk(RIO_DEBUG_PARAM, "Back-space delay set\n");
+	if (TtyP->termios->c_oflag & VTDLY)
+		rio_dprintk(RIO_DEBUG_PARAM, "Vertical tab delay set\n");
+	if (TtyP->termios->c_oflag & FFDLY)
+		rio_dprintk(RIO_DEBUG_PARAM, "Form-feed delay set\n");
 #endif
 	/*
-	** These things are kind of useful in a later life!
-	*/
+	 ** These things are kind of useful in a later life!
+	 */
 	PortP->Cor2Copy = Cor2;
 
-	if ( PortP->State & RIO_DELETED ) {
-		rio_spin_unlock_irqrestore( &PortP->portSem, flags);
-		func_exit ();
+	if (PortP->State & RIO_DELETED) {
+		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+		func_exit();
 
 		return RIO_FAIL;
 	}
 
 	/*
-	** Actually write the info into the packet to be sent
-	*/
-	WBYTE(phb_param_ptr->Cmd,	cmd);
-	WBYTE(phb_param_ptr->Cor1,	 Cor1);
-	WBYTE(phb_param_ptr->Cor2,	 Cor2);
-	WBYTE(phb_param_ptr->Cor4,	 Cor4);
-	WBYTE(phb_param_ptr->Cor5,	 Cor5);
-	WBYTE(phb_param_ptr->TxXon,	TxXon);
-	WBYTE(phb_param_ptr->RxXon,	RxXon);
+	 ** Actually write the info into the packet to be sent
+	 */
+	WBYTE(phb_param_ptr->Cmd, cmd);
+	WBYTE(phb_param_ptr->Cor1, Cor1);
+	WBYTE(phb_param_ptr->Cor2, Cor2);
+	WBYTE(phb_param_ptr->Cor4, Cor4);
+	WBYTE(phb_param_ptr->Cor5, Cor5);
+	WBYTE(phb_param_ptr->TxXon, TxXon);
+	WBYTE(phb_param_ptr->RxXon, RxXon);
 	WBYTE(phb_param_ptr->TxXoff, TxXoff);
 	WBYTE(phb_param_ptr->RxXoff, RxXoff);
-	WBYTE(phb_param_ptr->LNext,	LNext);
+	WBYTE(phb_param_ptr->LNext, LNext);
 	WBYTE(phb_param_ptr->TxBaud, TxBaud);
 	WBYTE(phb_param_ptr->RxBaud, RxBaud);
 
 	/*
-	** Set the length/command field
-	*/
-	WBYTE(PacketP->len , 12 | PKT_CMD_BIT);
+	 ** Set the length/command field
+	 */
+	WBYTE(PacketP->len, 12 | PKT_CMD_BIT);
 
 	/*
-	** The packet is formed - now, whack it off
-	** to its final destination:
-	*/
+	 ** The packet is formed - now, whack it off
+	 ** to its final destination:
+	 */
 	add_transmit(PortP);
 	/*
-	** Count characters transmitted for port statistics reporting
-	*/
+	 ** Count characters transmitted for port statistics reporting
+	 */
 	if (PortP->statsGather)
 		PortP->txchars += 12;
 
-	rio_spin_unlock_irqrestore( &PortP->portSem, flags);
+	rio_spin_unlock_irqrestore(&PortP->portSem, flags);
 
-	rio_dprintk (RIO_DEBUG_PARAM, "add_transmit returned.\n");
+	rio_dprintk(RIO_DEBUG_PARAM, "add_transmit returned.\n");
 	/*
-	** job done.
-	*/
-	func_exit ();
+	 ** job done.
+	 */
+	func_exit();
 
 	return RIO_SUCCESS;
 }
@@ -638,16 +640,15 @@
 ** We can add another packet to a transmit queue if the packet pointer pointed
 ** to by the TxAdd pointer has PKT_IN_USE clear in its address.
 */
-int
-can_add_transmit(PktP, PortP)
+int can_add_transmit(PktP, PortP)
 PKT **PktP;
-struct Port *PortP; 
+struct Port *PortP;
 {
 	register PKT *tp;
 
-	*PktP = tp = (PKT *)RIO_PTR(PortP->Caddr,RWORD(*PortP->TxAdd));
+	*PktP = tp = (PKT *) RIO_PTR(PortP->Caddr, RWORD(*PortP->TxAdd));
 
-	return !((uint)tp & PKT_IN_USE);
+	return !((uint) tp & PKT_IN_USE);
 }
 
 /*
@@ -655,25 +656,22 @@
 ** and then move the TxAdd pointer along one position to point to the next
 ** packet pointer. You must wrap the pointer from the end back to the start.
 */
-void
-add_transmit(PortP)
-struct Port *PortP; 
+void add_transmit(PortP)
+struct Port *PortP;
 {
-  if (RWORD(*PortP->TxAdd) & PKT_IN_USE) {
-    rio_dprintk (RIO_DEBUG_PARAM, "add_transmit: Packet has been stolen!");
-  }
-	WWORD( *(ushort *)PortP->TxAdd, RWORD(*PortP->TxAdd) | PKT_IN_USE);
-	PortP->TxAdd = (PortP->TxAdd == PortP->TxEnd) ? PortP->TxStart : 
-					PortP->TxAdd + 1;
-	WWORD( PortP->PhbP->tx_add , RIO_OFF(PortP->Caddr,PortP->TxAdd) );
+	if (RWORD(*PortP->TxAdd) & PKT_IN_USE) {
+		rio_dprintk(RIO_DEBUG_PARAM, "add_transmit: Packet has been stolen!");
+	}
+	WWORD(*(ushort *) PortP->TxAdd, RWORD(*PortP->TxAdd) | PKT_IN_USE);
+	PortP->TxAdd = (PortP->TxAdd == PortP->TxEnd) ? PortP->TxStart : PortP->TxAdd + 1;
+	WWORD(PortP->PhbP->tx_add, RIO_OFF(PortP->Caddr, PortP->TxAdd));
 }
 
 /****************************************
  * Put a packet onto the end of the
  * free list
  ****************************************/
-void
-put_free_end(HostP, PktP)
+void put_free_end(HostP, PktP)
 struct Host *HostP;
 PKT *PktP;
 {
@@ -688,24 +686,23 @@
 	*
 	************************************************/
 
-	rio_dprintk (RIO_DEBUG_PFE,  "put_free_end(PktP=%x)\n",(int)PktP);
+	rio_dprintk(RIO_DEBUG_PFE, "put_free_end(PktP=%x)\n", (int) PktP);
 
-	if ((old_end=RWORD(HostP->ParmMapP->free_list_end)) != TPNULL) {
-		new_end = RIO_OFF(HostP->Caddr,PktP);
-		tmp_pointer = (FREE_LIST *)RIO_PTR(HostP->Caddr,old_end);
-		WWORD(tmp_pointer->next , new_end );
-		WWORD(((FREE_LIST *)PktP)->prev , old_end);
-		WWORD(((FREE_LIST *)PktP)->next , TPNULL);
+	if ((old_end = RWORD(HostP->ParmMapP->free_list_end)) != TPNULL) {
+		new_end = RIO_OFF(HostP->Caddr, PktP);
+		tmp_pointer = (FREE_LIST *) RIO_PTR(HostP->Caddr, old_end);
+		WWORD(tmp_pointer->next, new_end);
+		WWORD(((FREE_LIST *) PktP)->prev, old_end);
+		WWORD(((FREE_LIST *) PktP)->next, TPNULL);
 		WWORD(HostP->ParmMapP->free_list_end, new_end);
+	} else {		/* First packet on the free list this should never happen! */
+		rio_dprintk(RIO_DEBUG_PFE, "put_free_end(): This should never happen\n");
+		WWORD(HostP->ParmMapP->free_list_end, RIO_OFF(HostP->Caddr, PktP));
+		tmp_pointer = (FREE_LIST *) PktP;
+		WWORD(tmp_pointer->prev, TPNULL);
+		WWORD(tmp_pointer->next, TPNULL);
 	}
-	else {	/* First packet on the free list this should never happen! */
-		rio_dprintk (RIO_DEBUG_PFE, "put_free_end(): This should never happen\n");
-		WWORD(HostP->ParmMapP->free_list_end , RIO_OFF(HostP->Caddr,PktP));
-		tmp_pointer = (FREE_LIST *)PktP;
-		WWORD(tmp_pointer->prev , TPNULL);
-		WWORD(tmp_pointer->next , TPNULL);
-	}
-	rio_dprintk (RIO_DEBUG_CMD, "Before unlock: %p\n", &HostP->HostLock);
+	rio_dprintk(RIO_DEBUG_CMD, "Before unlock: %p\n", &HostP->HostLock);
 	rio_spin_unlock_irqrestore(&HostP->HostLock, flags);
 }
 
@@ -715,14 +712,12 @@
 ** relevant packet, [having cleared the PKT_IN_USE bit]. If PKT_IN_USE is clear,
 ** then can_remove_receive() returns 0.
 */
-int
-can_remove_receive(PktP, PortP)
+int can_remove_receive(PktP, PortP)
 PKT **PktP;
 struct Port *PortP;
 {
-	if ( RWORD(*PortP->RxRemove) & PKT_IN_USE) {
-		*PktP = (PKT *)RIO_PTR(PortP->Caddr,
-					RWORD(*PortP->RxRemove) & ~PKT_IN_USE);
+	if (RWORD(*PortP->RxRemove) & PKT_IN_USE) {
+		*PktP = (PKT *) RIO_PTR(PortP->Caddr, RWORD(*PortP->RxRemove) & ~PKT_IN_USE);
 		return 1;
 	}
 	return 0;
@@ -733,12 +728,10 @@
 ** and then bump the pointers. Once the pointers get to the end, they must
 ** be wrapped back to the start.
 */
-void
-remove_receive(PortP)
-struct Port *PortP; 
+void remove_receive(PortP)
+struct Port *PortP;
 {
-	WWORD( *PortP->RxRemove, RWORD(*PortP->RxRemove) & ~PKT_IN_USE );
-	PortP->RxRemove = (PortP->RxRemove == PortP->RxEnd) ? PortP->RxStart : 
-								PortP->RxRemove + 1;
-	WWORD( PortP->PhbP->rx_remove , RIO_OFF(PortP->Caddr, PortP->RxRemove) );
+	WWORD(*PortP->RxRemove, RWORD(*PortP->RxRemove) & ~PKT_IN_USE);
+	PortP->RxRemove = (PortP->RxRemove == PortP->RxEnd) ? PortP->RxStart : PortP->RxRemove + 1;
+	WWORD(PortP->PhbP->rx_remove, RIO_OFF(PortP->Caddr, PortP->RxRemove));
 }
diff --git a/drivers/char/rio/riopcicopy.c b/drivers/char/rio/riopcicopy.c
index 2ea99a6..535afaa 100644
--- a/drivers/char/rio/riopcicopy.c
+++ b/drivers/char/rio/riopcicopy.c
@@ -1,8 +1,8 @@
 
 /* Yeah. We have copyright on this one. Sure. */
 
-void rio_pcicopy( char *from, char *to, int amount)
+void rio_pcicopy(char *from, char *to, int amount)
 {
-  while ( amount-- )
-    *to++ = *from++;
+	while (amount--)
+		*to++ = *from++;
 }
diff --git a/drivers/char/rio/rioroute.c b/drivers/char/rio/rioroute.c
index e9564c9..0f4cd33 100644
--- a/drivers/char/rio/rioroute.c
+++ b/drivers/char/rio/rioroute.c
@@ -93,625 +93,517 @@
 ** Incoming on the ROUTE_RUP
 ** I wrote this while I was tired. Forgive me.
 */
-int RIORouteRup( struct rio_info *p, uint Rup, struct Host *HostP, PKT *PacketP )
+int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
 {
-  struct PktCmd *PktCmdP = (struct PktCmd *)PacketP->data;
-  struct PktCmd_M *PktReplyP;
-  struct CmdBlk *CmdBlkP;
-  struct Port *PortP;
-  struct Map *MapP;
-  struct Top *TopP;
-  int ThisLink, ThisLinkMin, ThisLinkMax;
-  int port;
-  int Mod, Mod1, Mod2;
-  ushort RtaType;
-  uint RtaUniq;
-  uint ThisUnit, ThisUnit2;	/* 2 ids to accommodate 16 port RTA */
-  uint OldUnit, NewUnit, OldLink, NewLink;
-  char *MyType, *MyName;
-  int Lies;
-  unsigned long flags;
+	struct PktCmd *PktCmdP = (struct PktCmd *) PacketP->data;
+	struct PktCmd_M *PktReplyP;
+	struct CmdBlk *CmdBlkP;
+	struct Port *PortP;
+	struct Map *MapP;
+	struct Top *TopP;
+	int ThisLink, ThisLinkMin, ThisLinkMax;
+	int port;
+	int Mod, Mod1, Mod2;
+	ushort RtaType;
+	uint RtaUniq;
+	uint ThisUnit, ThisUnit2;	/* 2 ids to accommodate 16 port RTA */
+	uint OldUnit, NewUnit, OldLink, NewLink;
+	char *MyType, *MyName;
+	int Lies;
+	unsigned long flags;
 
 #ifdef STACK
-    RIOStackCheck("RIORouteRup");
+	RIOStackCheck("RIORouteRup");
 #endif
 #ifdef CHECK
-    CheckPacketP(PacketP);
-    CheckHostP(HostP);
-    CheckRup(Rup);
-    CheckHost(Host);
+	CheckPacketP(PacketP);
+	CheckHostP(HostP);
+	CheckRup(Rup);
+	CheckHost(Host);
 #endif
-  /*
-  ** Is this unit telling us it's current link topology?
-  */
-  if ( RBYTE(PktCmdP->Command) == ROUTE_TOPOLOGY )
-  {
-    MapP = HostP->Mapping;
-
-    /*
-    ** The packet can be sent either by the host or by an RTA.
-    ** If it comes from the host, then we need to fill in the
-    ** Topology array in the host structure. If it came in
-    ** from an RTA then we need to fill in the Mapping structure's
-    ** Topology array for the unit.
-    */
-    if ( Rup >= (ushort)MAX_RUP )
-    {
-      ThisUnit = HOST_ID;
-      TopP = HostP->Topology;
-      MyType = "Host";
-      MyName = HostP->Name;
-      ThisLinkMin = ThisLinkMax = Rup - MAX_RUP;
-    }
-    else
-    {
-      ThisUnit = Rup+1;
-      TopP = HostP->Mapping[Rup].Topology;
-      MyType = "RTA";
-      MyName = HostP->Mapping[Rup].Name;
-      ThisLinkMin = 0;
-      ThisLinkMax = LINKS_PER_UNIT - 1;
-    }
-
-    /*
-    ** Lies will not be tolerated.
-    ** If any pair of links claim to be connected to the same
-    ** place, then ignore this packet completely.
-    */
-    Lies = 0;
-    for ( ThisLink=ThisLinkMin + 1; ThisLink <= ThisLinkMax; ThisLink++)
-    {
-      /*
-      ** it won't lie about network interconnect, total disconnects
-      ** and no-IDs. (or at least, it doesn't *matter* if it does)
-      */
-      if ( RBYTE(PktCmdP->RouteTopology[ThisLink].Unit) > (ushort)MAX_RUP )
-	  continue;
-
-      for ( NewLink=ThisLinkMin; NewLink < ThisLink; NewLink++ )
-      {
-        if ( (RBYTE(PktCmdP->RouteTopology[ThisLink].Unit) ==
-              RBYTE(PktCmdP->RouteTopology[NewLink].Unit)) &&
-	     (RBYTE(PktCmdP->RouteTopology[ThisLink].Link) ==
-              RBYTE(PktCmdP->RouteTopology[NewLink].Link)) )
-	{
-          Lies++;
-	}
-      }
-    }
-
-    if ( Lies )
-    {
-      rio_dprintk (RIO_DEBUG_ROUTE, "LIES! DAMN LIES! %d LIES!\n",Lies);
-      rio_dprintk (RIO_DEBUG_ROUTE, "%d:%c %d:%c %d:%c %d:%c\n",
-          RBYTE(PktCmdP->RouteTopology[0].Unit), 
-	  'A'+RBYTE(PktCmdP->RouteTopology[0].Link),
-          RBYTE(PktCmdP->RouteTopology[1].Unit),
-	  'A'+RBYTE(PktCmdP->RouteTopology[1].Link),
-          RBYTE(PktCmdP->RouteTopology[2].Unit),
-	  'A'+RBYTE(PktCmdP->RouteTopology[2].Link),
-          RBYTE(PktCmdP->RouteTopology[3].Unit),
-	  'A'+RBYTE(PktCmdP->RouteTopology[3].Link));
-      return TRUE;
-    }
-
-    /*
-    ** now, process each link.
-    */
-    for ( ThisLink=ThisLinkMin; ThisLink <= ThisLinkMax; ThisLink++)
-    {
-      /*
-      ** this is what it was connected to
-      */
-      OldUnit = TopP[ThisLink].Unit;
-      OldLink = TopP[ThisLink].Link;
-
-      /*
-      ** this is what it is now connected to
-      */
-      NewUnit = RBYTE(PktCmdP->RouteTopology[ThisLink].Unit);
-      NewLink = RBYTE(PktCmdP->RouteTopology[ThisLink].Link);
-
-      if ( OldUnit != NewUnit || OldLink != NewLink )
-      {
 	/*
-	** something has changed!
-	*/
+	 ** Is this unit telling us it's current link topology?
+	 */
+	if (RBYTE(PktCmdP->Command) == ROUTE_TOPOLOGY) {
+		MapP = HostP->Mapping;
 
-        if ( NewUnit > MAX_RUP &&
-	     NewUnit != ROUTE_DISCONNECT &&
-	     NewUnit != ROUTE_NO_ID &&
-	     NewUnit != ROUTE_INTERCONNECT )
-	{
-	    rio_dprintk (RIO_DEBUG_ROUTE, "I have a link from %s %s to unit %d:%d - I don't like it.\n",
-		  MyType,
-		  MyName,
-		  NewUnit,
-		  NewLink);
+		/*
+		 ** The packet can be sent either by the host or by an RTA.
+		 ** If it comes from the host, then we need to fill in the
+		 ** Topology array in the host structure. If it came in
+		 ** from an RTA then we need to fill in the Mapping structure's
+		 ** Topology array for the unit.
+		 */
+		if (Rup >= (ushort) MAX_RUP) {
+			ThisUnit = HOST_ID;
+			TopP = HostP->Topology;
+			MyType = "Host";
+			MyName = HostP->Name;
+			ThisLinkMin = ThisLinkMax = Rup - MAX_RUP;
+		} else {
+			ThisUnit = Rup + 1;
+			TopP = HostP->Mapping[Rup].Topology;
+			MyType = "RTA";
+			MyName = HostP->Mapping[Rup].Name;
+			ThisLinkMin = 0;
+			ThisLinkMax = LINKS_PER_UNIT - 1;
+		}
+
+		/*
+		 ** Lies will not be tolerated.
+		 ** If any pair of links claim to be connected to the same
+		 ** place, then ignore this packet completely.
+		 */
+		Lies = 0;
+		for (ThisLink = ThisLinkMin + 1; ThisLink <= ThisLinkMax; ThisLink++) {
+			/*
+			 ** it won't lie about network interconnect, total disconnects
+			 ** and no-IDs. (or at least, it doesn't *matter* if it does)
+			 */
+			if (RBYTE(PktCmdP->RouteTopology[ThisLink].Unit) > (ushort) MAX_RUP)
+				continue;
+
+			for (NewLink = ThisLinkMin; NewLink < ThisLink; NewLink++) {
+				if ((RBYTE(PktCmdP->RouteTopology[ThisLink].Unit) == RBYTE(PktCmdP->RouteTopology[NewLink].Unit)) && (RBYTE(PktCmdP->RouteTopology[ThisLink].Link) == RBYTE(PktCmdP->RouteTopology[NewLink].Link))) {
+					Lies++;
+				}
+			}
+		}
+
+		if (Lies) {
+			rio_dprintk(RIO_DEBUG_ROUTE, "LIES! DAMN LIES! %d LIES!\n", Lies);
+			rio_dprintk(RIO_DEBUG_ROUTE, "%d:%c %d:%c %d:%c %d:%c\n",
+				    RBYTE(PktCmdP->RouteTopology[0].Unit),
+				    'A' + RBYTE(PktCmdP->RouteTopology[0].Link),
+				    RBYTE(PktCmdP->RouteTopology[1].Unit),
+				    'A' + RBYTE(PktCmdP->RouteTopology[1].Link), RBYTE(PktCmdP->RouteTopology[2].Unit), 'A' + RBYTE(PktCmdP->RouteTopology[2].Link), RBYTE(PktCmdP->RouteTopology[3].Unit), 'A' + RBYTE(PktCmdP->RouteTopology[3].Link));
+			return TRUE;
+		}
+
+		/*
+		 ** now, process each link.
+		 */
+		for (ThisLink = ThisLinkMin; ThisLink <= ThisLinkMax; ThisLink++) {
+			/*
+			 ** this is what it was connected to
+			 */
+			OldUnit = TopP[ThisLink].Unit;
+			OldLink = TopP[ThisLink].Link;
+
+			/*
+			 ** this is what it is now connected to
+			 */
+			NewUnit = RBYTE(PktCmdP->RouteTopology[ThisLink].Unit);
+			NewLink = RBYTE(PktCmdP->RouteTopology[ThisLink].Link);
+
+			if (OldUnit != NewUnit || OldLink != NewLink) {
+				/*
+				 ** something has changed!
+				 */
+
+				if (NewUnit > MAX_RUP && NewUnit != ROUTE_DISCONNECT && NewUnit != ROUTE_NO_ID && NewUnit != ROUTE_INTERCONNECT) {
+					rio_dprintk(RIO_DEBUG_ROUTE, "I have a link from %s %s to unit %d:%d - I don't like it.\n", MyType, MyName, NewUnit, NewLink);
+				} else {
+					/*
+					 ** put the new values in
+					 */
+					TopP[ThisLink].Unit = NewUnit;
+					TopP[ThisLink].Link = NewLink;
+
+					RIOSetChange(p);
+
+					if (OldUnit <= MAX_RUP) {
+						/*
+						 ** If something has become bust, then re-enable them messages
+						 */
+						if (!p->RIONoMessage)
+							RIOConCon(p, HostP, ThisUnit, ThisLink, OldUnit, OldLink, DISCONNECT);
+					}
+
+					if ((NewUnit <= MAX_RUP) && !p->RIONoMessage)
+						RIOConCon(p, HostP, ThisUnit, ThisLink, NewUnit, NewLink, CONNECT);
+
+					if (NewUnit == ROUTE_NO_ID)
+						rio_dprintk(RIO_DEBUG_ROUTE, "%s %s (%c) is connected to an unconfigured unit.\n", MyType, MyName, 'A' + ThisLink);
+
+					if (NewUnit == ROUTE_INTERCONNECT) {
+						if (!p->RIONoMessage)
+							cprintf("%s '%s' (%c) is connected to another network.\n", MyType, MyName, 'A' + ThisLink);
+					}
+
+					/*
+					 ** perform an update for 'the other end', so that these messages
+					 ** only appears once. Only disconnect the other end if it is pointing
+					 ** at us!
+					 */
+					if (OldUnit == HOST_ID) {
+						if (HostP->Topology[OldLink].Unit == ThisUnit && HostP->Topology[OldLink].Link == ThisLink) {
+							rio_dprintk(RIO_DEBUG_ROUTE, "SETTING HOST (%c) TO DISCONNECTED!\n", OldLink + 'A');
+							HostP->Topology[OldLink].Unit = ROUTE_DISCONNECT;
+							HostP->Topology[OldLink].Link = NO_LINK;
+						} else {
+							rio_dprintk(RIO_DEBUG_ROUTE, "HOST(%c) WAS NOT CONNECTED TO %s (%c)!\n", OldLink + 'A', HostP->Mapping[ThisUnit - 1].Name, ThisLink + 'A');
+						}
+					} else if (OldUnit <= MAX_RUP) {
+						if (HostP->Mapping[OldUnit - 1].Topology[OldLink].Unit == ThisUnit && HostP->Mapping[OldUnit - 1].Topology[OldLink].Link == ThisLink) {
+							rio_dprintk(RIO_DEBUG_ROUTE, "SETTING RTA %s (%c) TO DISCONNECTED!\n", HostP->Mapping[OldUnit - 1].Name, OldLink + 'A');
+							HostP->Mapping[OldUnit - 1].Topology[OldLink].Unit = ROUTE_DISCONNECT;
+							HostP->Mapping[OldUnit - 1].Topology[OldLink].Link = NO_LINK;
+						} else {
+							rio_dprintk(RIO_DEBUG_ROUTE, "RTA %s (%c) WAS NOT CONNECTED TO %s (%c)\n", HostP->Mapping[OldUnit - 1].Name, OldLink + 'A', HostP->Mapping[ThisUnit - 1].Name, ThisLink + 'A');
+						}
+					}
+					if (NewUnit == HOST_ID) {
+						rio_dprintk(RIO_DEBUG_ROUTE, "MARKING HOST (%c) CONNECTED TO %s (%c)\n", NewLink + 'A', MyName, ThisLink + 'A');
+						HostP->Topology[NewLink].Unit = ThisUnit;
+						HostP->Topology[NewLink].Link = ThisLink;
+					} else if (NewUnit <= MAX_RUP) {
+						rio_dprintk(RIO_DEBUG_ROUTE, "MARKING RTA %s (%c) CONNECTED TO %s (%c)\n", HostP->Mapping[NewUnit - 1].Name, NewLink + 'A', MyName, ThisLink + 'A');
+						HostP->Mapping[NewUnit - 1].Topology[NewLink].Unit = ThisUnit;
+						HostP->Mapping[NewUnit - 1].Topology[NewLink].Link = ThisLink;
+					}
+				}
+				RIOSetChange(p);
+				RIOCheckIsolated(p, HostP, OldUnit);
+			}
+		}
+		return TRUE;
 	}
-	else
-	{
-	  /*
-	  ** put the new values in
-	  */
-	  TopP[ThisLink].Unit = NewUnit;
-	  TopP[ThisLink].Link = NewLink;
 
-	  RIOSetChange(p);
-
-	  if ( OldUnit <= MAX_RUP )
-	  {
-	    /*
-	    ** If something has become bust, then re-enable them messages
-	    */
-	    if (! p->RIONoMessage)
-		RIOConCon(p,HostP,ThisUnit,ThisLink,OldUnit,OldLink,DISCONNECT);
-	  }
-
-	  if ( ( NewUnit <= MAX_RUP ) && !p->RIONoMessage )
-	    RIOConCon(p,HostP,ThisUnit,ThisLink,NewUnit,NewLink,CONNECT);
-
-	  if ( NewUnit == ROUTE_NO_ID )
-	    rio_dprintk (RIO_DEBUG_ROUTE, "%s %s (%c) is connected to an unconfigured unit.\n",
-		    MyType,MyName,'A'+ThisLink);
-
-	  if ( NewUnit == ROUTE_INTERCONNECT )
-	  {
-	    if (! p->RIONoMessage)
-		cprintf("%s '%s' (%c) is connected to another network.\n", MyType,MyName,'A'+ThisLink);
-	  }
-
-	  /*
-	  ** perform an update for 'the other end', so that these messages
-	  ** only appears once. Only disconnect the other end if it is pointing
-	  ** at us!
-	  */
-	  if ( OldUnit == HOST_ID )
-	  {
-	    if ( HostP->Topology[OldLink].Unit == ThisUnit &&
-		 HostP->Topology[OldLink].Link == ThisLink )
-	    {
-	      rio_dprintk (RIO_DEBUG_ROUTE, "SETTING HOST (%c) TO DISCONNECTED!\n", OldLink+'A');
-	      HostP->Topology[OldLink].Unit = ROUTE_DISCONNECT;
-	      HostP->Topology[OldLink].Link = NO_LINK;
-	    }
-	    else
-	    {
-	      rio_dprintk (RIO_DEBUG_ROUTE, "HOST(%c) WAS NOT CONNECTED TO %s (%c)!\n",
-		    OldLink+'A',HostP->Mapping[ThisUnit-1].Name,ThisLink+'A');
-	    }
-	  }
-	  else if ( OldUnit <= MAX_RUP )
-	  {
-	    if ( HostP->Mapping[OldUnit-1].Topology[OldLink].Unit == ThisUnit &&
-	         HostP->Mapping[OldUnit-1].Topology[OldLink].Link == ThisLink )
-	    {
-	      rio_dprintk (RIO_DEBUG_ROUTE, "SETTING RTA %s (%c) TO DISCONNECTED!\n",
-				   HostP->Mapping[OldUnit-1].Name,OldLink+'A');
-	      HostP->Mapping[OldUnit-1].Topology[OldLink].Unit=ROUTE_DISCONNECT;
-	      HostP->Mapping[OldUnit-1].Topology[OldLink].Link=NO_LINK;
-	    }
-	    else
-	    {
-	      rio_dprintk (RIO_DEBUG_ROUTE, "RTA %s (%c) WAS NOT CONNECTED TO %s (%c)\n",
-			    HostP->Mapping[OldUnit-1].Name,OldLink+'A',
-			    HostP->Mapping[ThisUnit-1].Name,ThisLink+'A');
-	    }
-	  }
-	  if ( NewUnit == HOST_ID )
-	  {
-	    rio_dprintk (RIO_DEBUG_ROUTE, "MARKING HOST (%c) CONNECTED TO %s (%c)\n",
-				NewLink+'A',MyName,ThisLink+'A');
-	    HostP->Topology[NewLink].Unit = ThisUnit;
-	    HostP->Topology[NewLink].Link = ThisLink;
-	  }
-	  else if ( NewUnit <= MAX_RUP )
-	  {
-	    rio_dprintk (RIO_DEBUG_ROUTE, "MARKING RTA %s (%c) CONNECTED TO %s (%c)\n",
-	      HostP->Mapping[NewUnit-1].Name,NewLink+'A',MyName,ThisLink+'A');
-	    HostP->Mapping[NewUnit-1].Topology[NewLink].Unit=ThisUnit;
-	    HostP->Mapping[NewUnit-1].Topology[NewLink].Link=ThisLink;
-	  }
+	/*
+	 ** The only other command we recognise is a route_request command
+	 */
+	if (RBYTE(PktCmdP->Command) != ROUTE_REQUEST) {
+		rio_dprintk(RIO_DEBUG_ROUTE, "Unknown command %d received on rup %d host %d ROUTE_RUP\n", RBYTE(PktCmdP->Command), Rup, (int) HostP);
+		return TRUE;
 	}
-	RIOSetChange(p);
-	RIOCheckIsolated(p, HostP, OldUnit );
-      }
-    }
-    return TRUE;
-  }
 
-  /*
-  ** The only other command we recognise is a route_request command
-  */
-  if ( RBYTE(PktCmdP->Command) != ROUTE_REQUEST )
-  {
-    rio_dprintk (RIO_DEBUG_ROUTE, "Unknown command %d received on rup %d host %d ROUTE_RUP\n", 
-	   RBYTE(PktCmdP->Command),Rup,(int)HostP);
-    return TRUE;
-  }
-      
-  RtaUniq = (RBYTE(PktCmdP->UniqNum[0])) +
-	    (RBYTE(PktCmdP->UniqNum[1]) << 8) +
-	    (RBYTE(PktCmdP->UniqNum[2]) << 16) +
-	    (RBYTE(PktCmdP->UniqNum[3]) << 24);
+	RtaUniq = (RBYTE(PktCmdP->UniqNum[0])) + (RBYTE(PktCmdP->UniqNum[1]) << 8) + (RBYTE(PktCmdP->UniqNum[2]) << 16) + (RBYTE(PktCmdP->UniqNum[3]) << 24);
 
-  /*
-  ** Determine if 8 or 16 port RTA
-  */
-  RtaType = GetUnitType(RtaUniq);
+	/*
+	 ** Determine if 8 or 16 port RTA
+	 */
+	RtaType = GetUnitType(RtaUniq);
 
-  rio_dprintk (RIO_DEBUG_ROUTE, "Received a request for an ID for serial number %x\n", RtaUniq);
+	rio_dprintk(RIO_DEBUG_ROUTE, "Received a request for an ID for serial number %x\n", RtaUniq);
 
-  Mod = RBYTE(PktCmdP->ModuleTypes);
-  Mod1 = LONYBLE(Mod);
-  if (RtaType == TYPE_RTA16)
-  {
-    /*
-    ** Only one ident is set for a 16 port RTA. To make compatible
-    ** with 8 port, set 2nd ident in Mod2 to the same as Mod1.
-    */
-    Mod2 = Mod1;
-    rio_dprintk (RIO_DEBUG_ROUTE, "Backplane type is %s (all ports)\n",
-     p->RIOModuleTypes[Mod1].Name);
-  }
-  else
-  {
-    Mod2 = HINYBLE(Mod);
-    rio_dprintk (RIO_DEBUG_ROUTE, "Module types are %s (ports 0-3) and %s (ports 4-7)\n",
-     p->RIOModuleTypes[Mod1].Name, p->RIOModuleTypes[Mod2].Name);
-  }
-
-  if ( RtaUniq == 0xffffffff )
-  {
-      ShowPacket( DBG_SPECIAL, PacketP );
-  }
-
-  /*
-  ** try to unhook a command block from the command free list.
-  */
-  if ( !(CmdBlkP = RIOGetCmdBlk()) )
-  {
-    rio_dprintk (RIO_DEBUG_ROUTE, "No command blocks to route RTA! come back later.\n");
-    return 0;
-  }
-
-  /*
-  ** Fill in the default info on the command block
-  */
-  CmdBlkP->Packet.dest_unit = Rup;
-  CmdBlkP->Packet.dest_port = ROUTE_RUP;
-  CmdBlkP->Packet.src_unit = HOST_ID;
-  CmdBlkP->Packet.src_port = ROUTE_RUP;
-  CmdBlkP->Packet.len = PKT_CMD_BIT | 1;
-  CmdBlkP->PreFuncP = CmdBlkP->PostFuncP = NULL;
-  PktReplyP = (struct PktCmd_M *)CmdBlkP->Packet.data;
-
-  if (! RIOBootOk(p, HostP, RtaUniq))
-  {
-    rio_dprintk (RIO_DEBUG_ROUTE, "RTA %x tried to get an ID, but does not belong - FOAD it!\n",
-	  RtaUniq);
-    PktReplyP->Command = ROUTE_FOAD;
-    HostP->Copy("RT_FOAD", PktReplyP->CommandText, 7);
-    RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
-    return TRUE;
-  }
-
-  /*
-  ** Check to see if the RTA is configured for this host
-  */
-  for ( ThisUnit=0; ThisUnit<MAX_RUP; ThisUnit++ )
-  {
-    rio_dprintk (RIO_DEBUG_ROUTE, "Entry %d Flags=%s %s UniqueNum=0x%x\n",
-			ThisUnit,
-			HostP->Mapping[ThisUnit].Flags & SLOT_IN_USE ?
-					    "Slot-In-Use":"Not In Use",
-			HostP->Mapping[ThisUnit].Flags & SLOT_TENTATIVE ? 
-					    "Slot-Tentative":"Not Tentative",
-			HostP->Mapping[ThisUnit].RtaUniqueNum);
-
-    /*
-    ** We have an entry for it.
-    */
-    if ( (HostP->Mapping[ThisUnit].Flags & (SLOT_IN_USE | SLOT_TENTATIVE)) &&
-         (HostP->Mapping[ThisUnit].RtaUniqueNum == RtaUniq) )
-    {
-      if (RtaType == TYPE_RTA16)
-      {
-	  ThisUnit2 = HostP->Mapping[ThisUnit].ID2 - 1;
-          rio_dprintk (RIO_DEBUG_ROUTE, "Found unit 0x%x at slots %d+%d\n",
-					    RtaUniq,ThisUnit,ThisUnit2);
-      }
-      else
-          rio_dprintk (RIO_DEBUG_ROUTE, "Found unit 0x%x at slot %d\n",
-					    RtaUniq,ThisUnit);
-      /*
-      ** If we have no knowledge of booting it, then the host has
-      ** been re-booted, and so we must kill the RTA, so that it
-      ** will be booted again (potentially with new bins)
-      ** and it will then re-ask for an ID, which we will service.
-      */
-      if ( (HostP->Mapping[ThisUnit].Flags & SLOT_IN_USE) && 
-	  !(HostP->Mapping[ThisUnit].Flags & RTA_BOOTED) )
-      {
-	if ( !(HostP->Mapping[ThisUnit].Flags & MSG_DONE) )
-	{
-	    if ( !p->RIONoMessage )
-	        cprintf("RTA '%s' is being updated.\n",HostP->Mapping[ThisUnit].Name);
-	    HostP->Mapping[ThisUnit].Flags |= MSG_DONE;
+	Mod = RBYTE(PktCmdP->ModuleTypes);
+	Mod1 = LONYBLE(Mod);
+	if (RtaType == TYPE_RTA16) {
+		/*
+		 ** Only one ident is set for a 16 port RTA. To make compatible
+		 ** with 8 port, set 2nd ident in Mod2 to the same as Mod1.
+		 */
+		Mod2 = Mod1;
+		rio_dprintk(RIO_DEBUG_ROUTE, "Backplane type is %s (all ports)\n", p->RIOModuleTypes[Mod1].Name);
+	} else {
+		Mod2 = HINYBLE(Mod);
+		rio_dprintk(RIO_DEBUG_ROUTE, "Module types are %s (ports 0-3) and %s (ports 4-7)\n", p->RIOModuleTypes[Mod1].Name, p->RIOModuleTypes[Mod2].Name);
 	}
-	PktReplyP->Command = ROUTE_FOAD;
-	HostP->Copy("RT_FOAD",PktReplyP->CommandText,7);
+
+	if (RtaUniq == 0xffffffff) {
+		ShowPacket(DBG_SPECIAL, PacketP);
+	}
+
+	/*
+	 ** try to unhook a command block from the command free list.
+	 */
+	if (!(CmdBlkP = RIOGetCmdBlk())) {
+		rio_dprintk(RIO_DEBUG_ROUTE, "No command blocks to route RTA! come back later.\n");
+		return 0;
+	}
+
+	/*
+	 ** Fill in the default info on the command block
+	 */
+	CmdBlkP->Packet.dest_unit = Rup;
+	CmdBlkP->Packet.dest_port = ROUTE_RUP;
+	CmdBlkP->Packet.src_unit = HOST_ID;
+	CmdBlkP->Packet.src_port = ROUTE_RUP;
+	CmdBlkP->Packet.len = PKT_CMD_BIT | 1;
+	CmdBlkP->PreFuncP = CmdBlkP->PostFuncP = NULL;
+	PktReplyP = (struct PktCmd_M *) CmdBlkP->Packet.data;
+
+	if (!RIOBootOk(p, HostP, RtaUniq)) {
+		rio_dprintk(RIO_DEBUG_ROUTE, "RTA %x tried to get an ID, but does not belong - FOAD it!\n", RtaUniq);
+		PktReplyP->Command = ROUTE_FOAD;
+		HostP->Copy("RT_FOAD", PktReplyP->CommandText, 7);
+		RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
+		return TRUE;
+	}
+
+	/*
+	 ** Check to see if the RTA is configured for this host
+	 */
+	for (ThisUnit = 0; ThisUnit < MAX_RUP; ThisUnit++) {
+		rio_dprintk(RIO_DEBUG_ROUTE, "Entry %d Flags=%s %s UniqueNum=0x%x\n",
+			    ThisUnit, HostP->Mapping[ThisUnit].Flags & SLOT_IN_USE ? "Slot-In-Use" : "Not In Use", HostP->Mapping[ThisUnit].Flags & SLOT_TENTATIVE ? "Slot-Tentative" : "Not Tentative", HostP->Mapping[ThisUnit].RtaUniqueNum);
+
+		/*
+		 ** We have an entry for it.
+		 */
+		if ((HostP->Mapping[ThisUnit].Flags & (SLOT_IN_USE | SLOT_TENTATIVE)) && (HostP->Mapping[ThisUnit].RtaUniqueNum == RtaUniq)) {
+			if (RtaType == TYPE_RTA16) {
+				ThisUnit2 = HostP->Mapping[ThisUnit].ID2 - 1;
+				rio_dprintk(RIO_DEBUG_ROUTE, "Found unit 0x%x at slots %d+%d\n", RtaUniq, ThisUnit, ThisUnit2);
+			} else
+				rio_dprintk(RIO_DEBUG_ROUTE, "Found unit 0x%x at slot %d\n", RtaUniq, ThisUnit);
+			/*
+			 ** If we have no knowledge of booting it, then the host has
+			 ** been re-booted, and so we must kill the RTA, so that it
+			 ** will be booted again (potentially with new bins)
+			 ** and it will then re-ask for an ID, which we will service.
+			 */
+			if ((HostP->Mapping[ThisUnit].Flags & SLOT_IN_USE) && !(HostP->Mapping[ThisUnit].Flags & RTA_BOOTED)) {
+				if (!(HostP->Mapping[ThisUnit].Flags & MSG_DONE)) {
+					if (!p->RIONoMessage)
+						cprintf("RTA '%s' is being updated.\n", HostP->Mapping[ThisUnit].Name);
+					HostP->Mapping[ThisUnit].Flags |= MSG_DONE;
+				}
+				PktReplyP->Command = ROUTE_FOAD;
+				HostP->Copy("RT_FOAD", PktReplyP->CommandText, 7);
+				RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
+				return TRUE;
+			}
+
+			/*
+			 ** Send the ID (entry) to this RTA. The ID number is implicit as
+			 ** the offset into the table. It is worth noting at this stage
+			 ** that offset zero in the table contains the entries for the
+			 ** RTA with ID 1!!!!
+			 */
+			PktReplyP->Command = ROUTE_ALLOCATE;
+			PktReplyP->IDNum = ThisUnit + 1;
+			if (RtaType == TYPE_RTA16) {
+				if (HostP->Mapping[ThisUnit].Flags & SLOT_IN_USE)
+					/*
+					 ** Adjust the phb and tx pkt dest_units for 2nd block of 8
+					 ** only if the RTA has ports associated (SLOT_IN_USE)
+					 */
+					RIOFixPhbs(p, HostP, ThisUnit2);
+				PktReplyP->IDNum2 = ThisUnit2 + 1;
+				rio_dprintk(RIO_DEBUG_ROUTE, "RTA '%s' has been allocated IDs %d+%d\n", HostP->Mapping[ThisUnit].Name, PktReplyP->IDNum, PktReplyP->IDNum2);
+			} else {
+				PktReplyP->IDNum2 = ROUTE_NO_ID;
+				rio_dprintk(RIO_DEBUG_ROUTE, "RTA '%s' has been allocated ID %d\n", HostP->Mapping[ThisUnit].Name, PktReplyP->IDNum);
+			}
+			HostP->Copy("RT_ALLOCAT", PktReplyP->CommandText, 10);
+
+			RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
+
+			/*
+			 ** If this is a freshly booted RTA, then we need to re-open
+			 ** the ports, if any where open, so that data may once more
+			 ** flow around the system!
+			 */
+			if ((HostP->Mapping[ThisUnit].Flags & RTA_NEWBOOT) && (HostP->Mapping[ThisUnit].SysPort != NO_PORT)) {
+				/*
+				 ** look at the ports associated with this beast and
+				 ** see if any where open. If they was, then re-open
+				 ** them, using the info from the tty flags.
+				 */
+				for (port = 0; port < PORTS_PER_RTA; port++) {
+					PortP = p->RIOPortp[port + HostP->Mapping[ThisUnit].SysPort];
+					if (PortP->State & (RIO_MOPEN | RIO_LOPEN)) {
+						rio_dprintk(RIO_DEBUG_ROUTE, "Re-opened this port\n");
+						rio_spin_lock_irqsave(&PortP->portSem, flags);
+						PortP->MagicFlags |= MAGIC_REBOOT;
+						rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+					}
+				}
+				if (RtaType == TYPE_RTA16) {
+					for (port = 0; port < PORTS_PER_RTA; port++) {
+						PortP = p->RIOPortp[port + HostP->Mapping[ThisUnit2].SysPort];
+						if (PortP->State & (RIO_MOPEN | RIO_LOPEN)) {
+							rio_dprintk(RIO_DEBUG_ROUTE, "Re-opened this port\n");
+							rio_spin_lock_irqsave(&PortP->portSem, flags);
+							PortP->MagicFlags |= MAGIC_REBOOT;
+							rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+						}
+					}
+				}
+			}
+
+			/*
+			 ** keep a copy of the module types!
+			 */
+			HostP->UnixRups[ThisUnit].ModTypes = Mod;
+			if (RtaType == TYPE_RTA16)
+				HostP->UnixRups[ThisUnit2].ModTypes = Mod;
+
+			/*
+			 ** If either of the modules on this unit is read-only or write-only
+			 ** or none-xprint, then we need to transfer that info over to the
+			 ** relevant ports.
+			 */
+			if (HostP->Mapping[ThisUnit].SysPort != NO_PORT) {
+				for (port = 0; port < PORTS_PER_MODULE; port++) {
+					p->RIOPortp[port + HostP->Mapping[ThisUnit].SysPort]->Config &= ~RIO_NOMASK;
+					p->RIOPortp[port + HostP->Mapping[ThisUnit].SysPort]->Config |= p->RIOModuleTypes[Mod1].Flags[port];
+					p->RIOPortp[port + PORTS_PER_MODULE + HostP->Mapping[ThisUnit].SysPort]->Config &= ~RIO_NOMASK;
+					p->RIOPortp[port + PORTS_PER_MODULE + HostP->Mapping[ThisUnit].SysPort]->Config |= p->RIOModuleTypes[Mod2].Flags[port];
+				}
+				if (RtaType == TYPE_RTA16) {
+					for (port = 0; port < PORTS_PER_MODULE; port++) {
+						p->RIOPortp[port + HostP->Mapping[ThisUnit2].SysPort]->Config &= ~RIO_NOMASK;
+						p->RIOPortp[port + HostP->Mapping[ThisUnit2].SysPort]->Config |= p->RIOModuleTypes[Mod1].Flags[port];
+						p->RIOPortp[port + PORTS_PER_MODULE + HostP->Mapping[ThisUnit2].SysPort]->Config &= ~RIO_NOMASK;
+						p->RIOPortp[port + PORTS_PER_MODULE + HostP->Mapping[ThisUnit2].SysPort]->Config |= p->RIOModuleTypes[Mod2].Flags[port];
+					}
+				}
+			}
+
+			/*
+			 ** Job done, get on with the interrupts!
+			 */
+			return TRUE;
+		}
+	}
+	/*
+	 ** There is no table entry for this RTA at all.
+	 **
+	 ** Lets check to see if we actually booted this unit - if not,
+	 ** then we reset it and it will go round the loop of being booted
+	 ** we can then worry about trying to fit it into the table.
+	 */
+	for (ThisUnit = 0; ThisUnit < HostP->NumExtraBooted; ThisUnit++)
+		if (HostP->ExtraUnits[ThisUnit] == RtaUniq)
+			break;
+	if (ThisUnit == HostP->NumExtraBooted && ThisUnit != MAX_EXTRA_UNITS) {
+		/*
+		 ** if the unit wasn't in the table, and the table wasn't full, then
+		 ** we reset the unit, because we didn't boot it.
+		 ** However, if the table is full, it could be that we did boot
+		 ** this unit, and so we won't reboot it, because it isn't really
+		 ** all that disasterous to keep the old bins in most cases. This
+		 ** is a rather tacky feature, but we are on the edge of reallity
+		 ** here, because the implication is that someone has connected
+		 ** 16+MAX_EXTRA_UNITS onto one host.
+		 */
+		static int UnknownMesgDone = 0;
+
+		if (!UnknownMesgDone) {
+			if (!p->RIONoMessage)
+				cprintf("One or more unknown RTAs are being updated.\n");
+			UnknownMesgDone = 1;
+		}
+
+		PktReplyP->Command = ROUTE_FOAD;
+		HostP->Copy("RT_FOAD", PktReplyP->CommandText, 7);
+	} else {
+		/*
+		 ** we did boot it (as an extra), and there may now be a table
+		 ** slot free (because of a delete), so we will try to make
+		 ** a tentative entry for it, so that the configurator can see it
+		 ** and fill in the details for us.
+		 */
+		if (RtaType == TYPE_RTA16) {
+			if (RIOFindFreeID(p, HostP, &ThisUnit, &ThisUnit2) == 0) {
+				RIODefaultName(p, HostP, ThisUnit);
+				FillSlot(ThisUnit, ThisUnit2, RtaUniq, HostP);
+			}
+		} else {
+			if (RIOFindFreeID(p, HostP, &ThisUnit, NULL) == 0) {
+				RIODefaultName(p, HostP, ThisUnit);
+				FillSlot(ThisUnit, 0, RtaUniq, HostP);
+			}
+		}
+		PktReplyP->Command = ROUTE_USED;
+		HostP->Copy("RT_USED", PktReplyP->CommandText, 7);
+	}
 	RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
 	return TRUE;
-      }
-
-      /*
-      ** Send the ID (entry) to this RTA. The ID number is implicit as
-      ** the offset into the table. It is worth noting at this stage
-      ** that offset zero in the table contains the entries for the
-      ** RTA with ID 1!!!!
-      */
-      PktReplyP->Command = ROUTE_ALLOCATE;
-      PktReplyP->IDNum   = ThisUnit+1;
-      if (RtaType == TYPE_RTA16)
-      {
-        if (HostP->Mapping[ThisUnit].Flags & SLOT_IN_USE)
-	    /*
-	    ** Adjust the phb and tx pkt dest_units for 2nd block of 8
-	    ** only if the RTA has ports associated (SLOT_IN_USE)
-	    */
-	    RIOFixPhbs(p, HostP, ThisUnit2);
-	    PktReplyP->IDNum2  = ThisUnit2+1;
-	    rio_dprintk (RIO_DEBUG_ROUTE, "RTA '%s' has been allocated IDs %d+%d\n",
-	          HostP->Mapping[ThisUnit].Name, PktReplyP->IDNum, PktReplyP->IDNum2);
-      }
-      else
-      {
-	    PktReplyP->IDNum2 = ROUTE_NO_ID;
-	    rio_dprintk (RIO_DEBUG_ROUTE, "RTA '%s' has been allocated ID %d\n",
-	          HostP->Mapping[ThisUnit].Name,PktReplyP->IDNum);
-      }
-      HostP->Copy("RT_ALLOCAT",PktReplyP->CommandText,10);
-
-      RIOQueueCmdBlk( HostP, Rup, CmdBlkP);
-
-      /*
-      ** If this is a freshly booted RTA, then we need to re-open
-      ** the ports, if any where open, so that data may once more
-      ** flow around the system!
-      */
-      if ( (HostP->Mapping[ThisUnit].Flags & RTA_NEWBOOT) &&
-	   (HostP->Mapping[ThisUnit].SysPort != NO_PORT) )
-      {
-	/*
-	** look at the ports associated with this beast and
-	** see if any where open. If they was, then re-open
-	** them, using the info from the tty flags.
-	*/
-	for ( port=0; port<PORTS_PER_RTA; port++ )
-	{
-	  PortP = p->RIOPortp[port+HostP->Mapping[ThisUnit].SysPort];
-	  if ( PortP->State & (RIO_MOPEN|RIO_LOPEN) )
-	  {
-	    rio_dprintk (RIO_DEBUG_ROUTE, "Re-opened this port\n");
-	    rio_spin_lock_irqsave(&PortP->portSem, flags);
-	    PortP->MagicFlags |= MAGIC_REBOOT;
-	    rio_spin_unlock_irqrestore(&PortP->portSem, flags);
-	  }
-	}
-	if (RtaType == TYPE_RTA16)
-	{
-	  for ( port=0; port<PORTS_PER_RTA; port++ )
-	  {
-	    PortP = p->RIOPortp[port+HostP->Mapping[ThisUnit2].SysPort];
-	    if ( PortP->State & (RIO_MOPEN|RIO_LOPEN) )
-	    {
-	      rio_dprintk (RIO_DEBUG_ROUTE, "Re-opened this port\n");
-	      rio_spin_lock_irqsave(&PortP->portSem, flags);
-	      PortP->MagicFlags |= MAGIC_REBOOT;
-	      rio_spin_unlock_irqrestore(&PortP->portSem, flags);
-	    }
-	  }
-	}
-      }
-
-      /*
-      ** keep a copy of the module types!
-      */
-      HostP->UnixRups[ThisUnit].ModTypes = Mod;
-      if (RtaType == TYPE_RTA16)
-	      HostP->UnixRups[ThisUnit2].ModTypes = Mod;
-
-      /*
-      ** If either of the modules on this unit is read-only or write-only
-      ** or none-xprint, then we need to transfer that info over to the
-      ** relevant ports.
-      */
-      if ( HostP->Mapping[ThisUnit].SysPort != NO_PORT )
-      {
-        for ( port=0; port<PORTS_PER_MODULE; port++ )
-	{
-	  p->RIOPortp[port+HostP->Mapping[ThisUnit].SysPort]->Config &= ~RIO_NOMASK;
-	  p->RIOPortp[port+HostP->Mapping[ThisUnit].SysPort]->Config |=
-	   p->RIOModuleTypes[Mod1].Flags[port];
-	  p->RIOPortp[port+PORTS_PER_MODULE+HostP->Mapping[ThisUnit].SysPort]->Config &= ~RIO_NOMASK;
-	  p->RIOPortp[port+PORTS_PER_MODULE+HostP->Mapping[ThisUnit].SysPort]->Config |= p->RIOModuleTypes[Mod2].Flags[port];
-	}
-	if (RtaType == TYPE_RTA16)
-	{
-          for ( port=0; port<PORTS_PER_MODULE; port++ )
-	  {
-	    p->RIOPortp[port+HostP->Mapping[ThisUnit2].SysPort]->Config &= ~RIO_NOMASK;
-	    p->RIOPortp[port+HostP->Mapping[ThisUnit2].SysPort]->Config |= p->RIOModuleTypes[Mod1].Flags[port];
-	    p->RIOPortp[port+PORTS_PER_MODULE+HostP->Mapping[ThisUnit2].SysPort]->Config &= ~RIO_NOMASK;
-	    p->RIOPortp[port+PORTS_PER_MODULE+HostP->Mapping[ThisUnit2].SysPort]->Config |= p->RIOModuleTypes[Mod2].Flags[port];
-          }
-	}
-      }
-
-      /*
-      ** Job done, get on with the interrupts!
-      */
-      return TRUE;
-    }
-  }
-  /*
-  ** There is no table entry for this RTA at all.
-  **
-  ** Lets check to see if we actually booted this unit - if not,
-  ** then we reset it and it will go round the loop of being booted
-  ** we can then worry about trying to fit it into the table.
-  */
-  for ( ThisUnit=0; ThisUnit<HostP->NumExtraBooted; ThisUnit++ )
-    if ( HostP->ExtraUnits[ThisUnit] == RtaUniq )
-      break;
-  if ( ThisUnit == HostP->NumExtraBooted && ThisUnit != MAX_EXTRA_UNITS )
-  {
-    /*
-    ** if the unit wasn't in the table, and the table wasn't full, then
-    ** we reset the unit, because we didn't boot it.
-    ** However, if the table is full, it could be that we did boot
-    ** this unit, and so we won't reboot it, because it isn't really
-    ** all that disasterous to keep the old bins in most cases. This
-    ** is a rather tacky feature, but we are on the edge of reallity
-    ** here, because the implication is that someone has connected
-    ** 16+MAX_EXTRA_UNITS onto one host.
-    */
-    static int UnknownMesgDone = 0;
-
-    if ( !UnknownMesgDone )
-    {
-	if (! p->RIONoMessage)
-	    cprintf("One or more unknown RTAs are being updated.\n");
-	UnknownMesgDone = 1;
-    }
-
-    PktReplyP->Command = ROUTE_FOAD;
-    HostP->Copy("RT_FOAD",PktReplyP->CommandText,7);
-  }
-  else
-  {
-    /*
-    ** we did boot it (as an extra), and there may now be a table
-    ** slot free (because of a delete), so we will try to make
-    ** a tentative entry for it, so that the configurator can see it
-    ** and fill in the details for us.
-    */
-    if (RtaType == TYPE_RTA16)
-    {
-	if (RIOFindFreeID(p, HostP, &ThisUnit, &ThisUnit2) == 0)
-	{
-	    RIODefaultName(p, HostP, ThisUnit);
-	    FillSlot(ThisUnit, ThisUnit2, RtaUniq, HostP);
-	}
-    }
-    else
-    {
-	if (RIOFindFreeID(p, HostP, &ThisUnit, NULL) == 0)
-	{
-	    RIODefaultName(p, HostP, ThisUnit);
-	    FillSlot(ThisUnit, 0, RtaUniq, HostP);
-	}
-    }
-    PktReplyP->Command = ROUTE_USED;
-    HostP->Copy("RT_USED",PktReplyP->CommandText,7);
-  }
-  RIOQueueCmdBlk( HostP, Rup, CmdBlkP);
-  return TRUE;
 }
 
 
-void
-RIOFixPhbs(p, HostP, unit)
+void RIOFixPhbs(p, HostP, unit)
 struct rio_info *p;
 struct Host *HostP;
 uint unit;
 {
-	ushort			link, port;
-	struct Port		*PortP;
+	ushort link, port;
+	struct Port *PortP;
 	unsigned long flags;
 	int PortN = HostP->Mapping[unit].SysPort;
 
-	rio_dprintk (RIO_DEBUG_ROUTE, "RIOFixPhbs unit %d sysport %d\n", unit, PortN);
+	rio_dprintk(RIO_DEBUG_ROUTE, "RIOFixPhbs unit %d sysport %d\n", unit, PortN);
 
 	if (PortN != -1) {
-		ushort		dest_unit = HostP->Mapping[unit].ID2;
+		ushort dest_unit = HostP->Mapping[unit].ID2;
 
 		/*
-		** Get the link number used for the 1st 8 phbs on this unit.
-		*/
+		 ** Get the link number used for the 1st 8 phbs on this unit.
+		 */
 		PortP = p->RIOPortp[HostP->Mapping[dest_unit - 1].SysPort];
 
 		link = RWORD(PortP->PhbP->link);
 
 		for (port = 0; port < PORTS_PER_RTA; port++, PortN++) {
-			ushort		dest_port = port + 8;
+			ushort dest_port = port + 8;
 #if 0
-			uint		PktInt;
+			uint PktInt;
 #endif
-			WORD		*TxPktP;
-			PKT		*Pkt;
+			WORD *TxPktP;
+			PKT *Pkt;
 
 			PortP = p->RIOPortp[PortN];
 
 			rio_spin_lock_irqsave(&PortP->portSem, flags);
 			/*
-			** If RTA is not powered on, the tx packets will be
-			** unset, so go no further.
-			*/
+			 ** If RTA is not powered on, the tx packets will be
+			 ** unset, so go no further.
+			 */
 			if (PortP->TxStart == 0) {
-					rio_dprintk (RIO_DEBUG_ROUTE, "Tx pkts not set up yet\n");
-					rio_spin_unlock_irqrestore(&PortP->portSem, flags);
-					break;
+				rio_dprintk(RIO_DEBUG_ROUTE, "Tx pkts not set up yet\n");
+				rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+				break;
 			}
 
 			/*
-			** For the second slot of a 16 port RTA, the driver needs to
-			** sort out the phb to port mappings. The dest_unit for this
-			** group of 8 phbs is set to the dest_unit of the accompanying
-			** 8 port block. The dest_port of the second unit is set to
-			** be in the range 8-15 (i.e. 8 is added). Thus, for a 16 port
-			** RTA with IDs 5 and 6, traffic bound for port 6 of unit 6
-			** (being the second map ID) will be sent to dest_unit 5, port
-			** 14. When this RTA is deleted, dest_unit for ID 6 will be
-			** restored, and the dest_port will be reduced by 8.
-			** Transmit packets also have a destination field which needs
-			** adjusting in the same manner.
-			** Note that the unit/port bytes in 'dest' are swapped.
-			** We also need to adjust the phb and rup link numbers for the
-			** second block of 8 ttys.
-			*/
+			 ** For the second slot of a 16 port RTA, the driver needs to
+			 ** sort out the phb to port mappings. The dest_unit for this
+			 ** group of 8 phbs is set to the dest_unit of the accompanying
+			 ** 8 port block. The dest_port of the second unit is set to
+			 ** be in the range 8-15 (i.e. 8 is added). Thus, for a 16 port
+			 ** RTA with IDs 5 and 6, traffic bound for port 6 of unit 6
+			 ** (being the second map ID) will be sent to dest_unit 5, port
+			 ** 14. When this RTA is deleted, dest_unit for ID 6 will be
+			 ** restored, and the dest_port will be reduced by 8.
+			 ** Transmit packets also have a destination field which needs
+			 ** adjusting in the same manner.
+			 ** Note that the unit/port bytes in 'dest' are swapped.
+			 ** We also need to adjust the phb and rup link numbers for the
+			 ** second block of 8 ttys.
+			 */
 			for (TxPktP = PortP->TxStart; TxPktP <= PortP->TxEnd; TxPktP++) {
 				/*
-				** *TxPktP is the pointer to the transmit packet on the host
-				** card. This needs to be translated into a 32 bit pointer
-				** so it can be accessed from the driver.
-				*/
-				Pkt = (PKT *) RIO_PTR(HostP->Caddr,RINDW(TxPktP));
+				 ** *TxPktP is the pointer to the transmit packet on the host
+				 ** card. This needs to be translated into a 32 bit pointer
+				 ** so it can be accessed from the driver.
+				 */
+				Pkt = (PKT *) RIO_PTR(HostP->Caddr, RINDW(TxPktP));
 
 				/*
-				** If the packet is used, reset it.
-				*/
-				Pkt = (PKT *)((uint)Pkt & ~PKT_IN_USE);
+				 ** If the packet is used, reset it.
+				 */
+				Pkt = (PKT *) ((uint) Pkt & ~PKT_IN_USE);
 				WBYTE(Pkt->dest_unit, dest_unit);
 				WBYTE(Pkt->dest_port, dest_port);
 			}
-			rio_dprintk (RIO_DEBUG_ROUTE, "phb dest: Old %x:%x New %x:%x\n",
-					RWORD(PortP->PhbP->destination) & 0xff,
-					(RWORD(PortP->PhbP->destination) >> 8) & 0xff,
-					dest_unit, dest_port);
+			rio_dprintk(RIO_DEBUG_ROUTE, "phb dest: Old %x:%x New %x:%x\n", RWORD(PortP->PhbP->destination) & 0xff, (RWORD(PortP->PhbP->destination) >> 8) & 0xff, dest_unit, dest_port);
 			WWORD(PortP->PhbP->destination, dest_unit + (dest_port << 8));
 			WWORD(PortP->PhbP->link, link);
 
 			rio_spin_unlock_irqrestore(&PortP->portSem, flags);
 		}
 		/*
-		** Now make sure the range of ports to be serviced includes
-		** the 2nd 8 on this 16 port RTA.
-		*/
-		if (link > 3) return;
+		 ** Now make sure the range of ports to be serviced includes
+		 ** the 2nd 8 on this 16 port RTA.
+		 */
+		if (link > 3)
+			return;
 		if (((unit * 8) + 7) > RWORD(HostP->LinkStrP[link].last_port)) {
-			rio_dprintk (RIO_DEBUG_ROUTE, "last port on host link %d: %d\n", link, (unit * 8) + 7);
+			rio_dprintk(RIO_DEBUG_ROUTE, "last port on host link %d: %d\n", link, (unit * 8) + 7);
 			WWORD(HostP->LinkStrP[link].last_port, (unit * 8) + 7);
 		}
 	}
@@ -723,9 +615,8 @@
 ** the world about it. This is done to ensure that the configurator
 ** only gets up-to-date information about what is going on.
 */
-static int
-RIOCheckIsolated(p, HostP, UnitId)
-struct rio_info *	p;
+static int RIOCheckIsolated(p, HostP, UnitId)
+struct rio_info *p;
 struct Host *HostP;
 uint UnitId;
 {
@@ -733,16 +624,16 @@
 	rio_spin_lock_irqsave(&HostP->HostLock, flags);
 
 #ifdef CHECK
-	CheckHostP( HostP );
-	CheckUnitId( UnitId );
+	CheckHostP(HostP);
+	CheckUnitId(UnitId);
 #endif
-	if ( RIOCheck( HostP, UnitId ) ) {
-		rio_dprintk (RIO_DEBUG_ROUTE, "Unit %d is NOT isolated\n", UnitId);
+	if (RIOCheck(HostP, UnitId)) {
+		rio_dprintk(RIO_DEBUG_ROUTE, "Unit %d is NOT isolated\n", UnitId);
 		rio_spin_unlock_irqrestore(&HostP->HostLock, flags);
-		return(0);
+		return (0);
 	}
 
-	RIOIsolate(p, HostP, UnitId );
+	RIOIsolate(p, HostP, UnitId);
 	RIOSetChange(p);
 	rio_spin_unlock_irqrestore(&HostP->HostLock, flags);
 	return 1;
@@ -753,85 +644,83 @@
 ** all the units attached to it. This will mean that the entire
 ** subnet will re-introduce itself.
 */
-static int
-RIOIsolate(p, HostP, UnitId)
-struct rio_info *	p;
-struct Host *		HostP;
-uint UnitId; 
+static int RIOIsolate(p, HostP, UnitId)
+struct rio_info *p;
+struct Host *HostP;
+uint UnitId;
 {
 	uint link, unit;
 
 #ifdef CHECK
-	CheckHostP( HostP );
-	CheckUnitId( UnitId );
+	CheckHostP(HostP);
+	CheckUnitId(UnitId);
 #endif
 	UnitId--;		/* this trick relies on the Unit Id being UNSIGNED! */
 
-	if ( UnitId >= MAX_RUP )	/* dontcha just lurv unsigned maths! */
-		return(0);
+	if (UnitId >= MAX_RUP)	/* dontcha just lurv unsigned maths! */
+		return (0);
 
-	if ( HostP->Mapping[UnitId].Flags & BEEN_HERE )
-		return(0);
+	if (HostP->Mapping[UnitId].Flags & BEEN_HERE)
+		return (0);
 
 	HostP->Mapping[UnitId].Flags |= BEEN_HERE;
 
-	if ( p->RIOPrintDisabled == DO_PRINT )
-		rio_dprintk (RIO_DEBUG_ROUTE, "RIOMesgIsolated %s", HostP->Mapping[UnitId].Name);
+	if (p->RIOPrintDisabled == DO_PRINT)
+		rio_dprintk(RIO_DEBUG_ROUTE, "RIOMesgIsolated %s", HostP->Mapping[UnitId].Name);
 
-	for ( link=0; link<LINKS_PER_UNIT; link++) {
+	for (link = 0; link < LINKS_PER_UNIT; link++) {
 		unit = HostP->Mapping[UnitId].Topology[link].Unit;
 		HostP->Mapping[UnitId].Topology[link].Unit = ROUTE_DISCONNECT;
 		HostP->Mapping[UnitId].Topology[link].Link = NO_LINK;
-		RIOIsolate(p, HostP, unit );
+		RIOIsolate(p, HostP, unit);
 	}
 	HostP->Mapping[UnitId].Flags &= ~BEEN_HERE;
 	return 1;
 }
 
-static int
-RIOCheck(HostP, UnitId)
+static int RIOCheck(HostP, UnitId)
 struct Host *HostP;
 uint UnitId;
 {
-  unsigned char link;
+	unsigned char link;
 
 #ifdef CHECK
-	CheckHostP( HostP );
-	CheckUnitId( UnitId );
+	CheckHostP(HostP);
+	CheckUnitId(UnitId);
 #endif
 /* 	rio_dprint(RIO_DEBUG_ROUTE, ("Check to see if unit %d has a route to the host\n",UnitId)); */
-	rio_dprintk (RIO_DEBUG_ROUTE, "RIOCheck : UnitID = %d\n", UnitId);
+	rio_dprintk(RIO_DEBUG_ROUTE, "RIOCheck : UnitID = %d\n", UnitId);
 
-	if ( UnitId == HOST_ID ) {
+	if (UnitId == HOST_ID) {
 		/* rio_dprint(RIO_DEBUG_ROUTE, ("Unit %d is NOT isolated - it IS the host!\n", UnitId)); */
 		return 1;
 	}
 
 	UnitId--;
 
-	if ( UnitId >= MAX_RUP ) {
+	if (UnitId >= MAX_RUP) {
 		/* rio_dprint(RIO_DEBUG_ROUTE, ("Unit %d - ignored.\n", UnitId)); */
 		return 0;
 	}
 
-	for ( link=0; link<LINKS_PER_UNIT; link++ ) {
-		if ( HostP->Mapping[UnitId].Topology[link].Unit==HOST_ID ) {
+	for (link = 0; link < LINKS_PER_UNIT; link++) {
+		if (HostP->Mapping[UnitId].Topology[link].Unit == HOST_ID) {
 			/* rio_dprint(RIO_DEBUG_ROUTE, ("Unit %d is connected directly to host via link (%c).\n", 
-						UnitId, 'A'+link)); */
+			   UnitId, 'A'+link)); */
 			return 1;
 		}
 	}
 
-	if ( HostP->Mapping[UnitId].Flags & BEEN_HERE ) {
+	if (HostP->Mapping[UnitId].Flags & BEEN_HERE) {
 		/* rio_dprint(RIO_DEBUG_ROUTE, ("Been to Unit %d before - ignoring\n", UnitId)); */
 		return 0;
 	}
 
 	HostP->Mapping[UnitId].Flags |= BEEN_HERE;
 
-	for ( link=0; link < LINKS_PER_UNIT; link++ ) {
+	for (link = 0; link < LINKS_PER_UNIT; link++) {
 		/* rio_dprint(RIO_DEBUG_ROUTE, ("Unit %d check link (%c)\n", UnitId,'A'+link)); */
-		if ( RIOCheck( HostP, HostP->Mapping[UnitId].Topology[link].Unit ) ) {
+		if (RIOCheck(HostP, HostP->Mapping[UnitId].Topology[link].Unit)) {
 			/* rio_dprint(RIO_DEBUG_ROUTE, ("Unit %d is connected to something that knows the host via link (%c)\n", UnitId,link+'A')); */
 			HostP->Mapping[UnitId].Flags &= ~BEEN_HERE;
 			return 1;
@@ -841,7 +730,7 @@
 	HostP->Mapping[UnitId].Flags &= ~BEEN_HERE;
 
 	/* rio_dprint(RIO_DEBUG_ROUTE, ("Unit %d DOESNT KNOW THE HOST!\n", UnitId)); */
-	
+
 	return 0;
 }
 
@@ -849,61 +738,57 @@
 ** Returns the type of unit (host, 16/8 port RTA)
 */
 
-uint
-GetUnitType(Uniq)
+uint GetUnitType(Uniq)
 uint Uniq;
 {
-	switch ( (Uniq >> 28) & 0xf)
-	{
-		case RIO_AT:
-		case RIO_MCA:
-		case RIO_EISA:
-		case RIO_PCI:
-			rio_dprintk (RIO_DEBUG_ROUTE, "Unit type: Host\n");
-			return(TYPE_HOST);
-		case RIO_RTA_16:
-			rio_dprintk (RIO_DEBUG_ROUTE, "Unit type: 16 port RTA\n");
-			return(TYPE_RTA16);
-		case RIO_RTA:
-			rio_dprintk (RIO_DEBUG_ROUTE, "Unit type: 8 port RTA\n");
-			return(TYPE_RTA8);
-		default :
-			rio_dprintk (RIO_DEBUG_ROUTE, "Unit type: Unrecognised\n");
-			return(99);
+	switch ((Uniq >> 28) & 0xf) {
+	case RIO_AT:
+	case RIO_MCA:
+	case RIO_EISA:
+	case RIO_PCI:
+		rio_dprintk(RIO_DEBUG_ROUTE, "Unit type: Host\n");
+		return (TYPE_HOST);
+	case RIO_RTA_16:
+		rio_dprintk(RIO_DEBUG_ROUTE, "Unit type: 16 port RTA\n");
+		return (TYPE_RTA16);
+	case RIO_RTA:
+		rio_dprintk(RIO_DEBUG_ROUTE, "Unit type: 8 port RTA\n");
+		return (TYPE_RTA8);
+	default:
+		rio_dprintk(RIO_DEBUG_ROUTE, "Unit type: Unrecognised\n");
+		return (99);
 	}
 }
 
-int
-RIOSetChange(p)
-struct rio_info *	p;
+int RIOSetChange(p)
+struct rio_info *p;
 {
-	if ( p->RIOQuickCheck != NOT_CHANGED )
-		return(0);
+	if (p->RIOQuickCheck != NOT_CHANGED)
+		return (0);
 	p->RIOQuickCheck = CHANGED;
-	if ( p->RIOSignalProcess ) {
-		rio_dprintk (RIO_DEBUG_ROUTE, "Send SIG-HUP");
+	if (p->RIOSignalProcess) {
+		rio_dprintk(RIO_DEBUG_ROUTE, "Send SIG-HUP");
 		/*
-		psignal( RIOSignalProcess, SIGHUP );
-		*/
+		   psignal( RIOSignalProcess, SIGHUP );
+		 */
 	}
-	return(0);
+	return (0);
 }
 
-static void
-RIOConCon(p, HostP, FromId, FromLink, ToId, ToLink, Change)
-struct rio_info *	p;
+static void RIOConCon(p, HostP, FromId, FromLink, ToId, ToLink, Change)
+struct rio_info *p;
 struct Host *HostP;
 uint FromId;
 uint FromLink;
 uint ToId;
 uint ToLink;
-int Change; 
+int Change;
 {
-    char *FromName;
-    char *FromType;
-    char *ToName;
-    char *ToType;
-    unsigned int tp;
+	char *FromName;
+	char *FromType;
+	char *ToName;
+	char *ToType;
+	unsigned int tp;
 
 /*
 ** 15.10.1998 ARG - ESIL 0759
@@ -932,38 +817,32 @@
 ** rio_info struct - RIORtaDisCons (RIO RTA connections) keeps track of RTA
 ** connections and disconnections. 
 */
-    if (Change == CONNECT) {
-		if (p->RIORtaDisCons) p->RIORtaDisCons--;
-	 }
-	 else {
+	if (Change == CONNECT) {
+		if (p->RIORtaDisCons)
+			p->RIORtaDisCons--;
+	} else {
 		p->RIORtaDisCons++;
-	 }
+	}
 
-    if ( p->RIOPrintDisabled == DONT_PRINT )
+	if (p->RIOPrintDisabled == DONT_PRINT)
 		return;
 
-    if ( FromId > ToId ) {
+	if (FromId > ToId) {
 		tp = FromId;
 		FromId = ToId;
 		ToId = tp;
 		tp = FromLink;
 		FromLink = ToLink;
 		ToLink = tp;
-    }
+	}
 
-    FromName = FromId ? HostP->Mapping[FromId-1].Name : HostP->Name;
-    FromType = FromId ? "RTA" : "HOST";
-    ToName = ToId ? HostP->Mapping[ToId-1].Name : HostP->Name;
-    ToType = ToId ? "RTA" : "HOST";
+	FromName = FromId ? HostP->Mapping[FromId - 1].Name : HostP->Name;
+	FromType = FromId ? "RTA" : "HOST";
+	ToName = ToId ? HostP->Mapping[ToId - 1].Name : HostP->Name;
+	ToType = ToId ? "RTA" : "HOST";
 
-    rio_dprintk (RIO_DEBUG_ROUTE, "Link between %s '%s' (%c) and %s '%s' (%c) %s.\n",
-			    FromType, FromName, 'A'+FromLink,
-			    ToType,   ToName,   'A'+ToLink,
-			    (Change==CONNECT) ? "established" : "disconnected");
-    cprintf("Link between %s '%s' (%c) and %s '%s' (%c) %s.\n",
-			    FromType, FromName, 'A'+FromLink,
-			    ToType,   ToName,   'A'+ToLink,
-			    (Change==CONNECT) ? "established" : "disconnected");
+	rio_dprintk(RIO_DEBUG_ROUTE, "Link between %s '%s' (%c) and %s '%s' (%c) %s.\n", FromType, FromName, 'A' + FromLink, ToType, ToName, 'A' + ToLink, (Change == CONNECT) ? "established" : "disconnected");
+	cprintf("Link between %s '%s' (%c) and %s '%s' (%c) %s.\n", FromType, FromName, 'A' + FromLink, ToType, ToName, 'A' + ToLink, (Change == CONNECT) ? "established" : "disconnected");
 }
 
 /*
@@ -972,24 +851,21 @@
 ** Delete and RTA entry from the saved table given to us
 ** by the configuration program.
 */
-static int
-RIORemoveFromSavedTable(struct rio_info *p, struct Map *pMap)
+static int RIORemoveFromSavedTable(struct rio_info *p, struct Map *pMap)
 {
-    int		entry;
+	int entry;
 
-    /*
-    ** We loop for all entries even after finding an entry and
-    ** zeroing it because we may have two entries to delete if
-    ** it's a 16 port RTA.
-    */
-    for (entry = 0; entry < TOTAL_MAP_ENTRIES; entry++)
-    {
-	if (p->RIOSavedTable[entry].RtaUniqueNum == pMap->RtaUniqueNum)
-	{
-	    bzero((caddr_t)&p->RIOSavedTable[entry], sizeof(struct Map));
+	/*
+	 ** We loop for all entries even after finding an entry and
+	 ** zeroing it because we may have two entries to delete if
+	 ** it's a 16 port RTA.
+	 */
+	for (entry = 0; entry < TOTAL_MAP_ENTRIES; entry++) {
+		if (p->RIOSavedTable[entry].RtaUniqueNum == pMap->RtaUniqueNum) {
+			bzero((caddr_t) & p->RIOSavedTable[entry], sizeof(struct Map));
+		}
 	}
-    }
-    return 0;
+	return 0;
 }
 
 
@@ -999,64 +875,58 @@
 ** Scan the unit links to and return zero if the unit is completely
 ** disconnected.
 */
-static int
-RIOFreeDisconnected(struct rio_info *p, struct Host *HostP, int unit)
+static int RIOFreeDisconnected(struct rio_info *p, struct Host *HostP, int unit)
 {
-    int		link;
+	int link;
 
 
-    rio_dprintk (RIO_DEBUG_ROUTE, "RIOFreeDisconnect unit %d\n", unit);
-    /*
-    ** If the slot is tentative and does not belong to the
-    ** second half of a 16 port RTA then scan to see if
-    ** is disconnected.
-    */
-    for (link = 0; link < LINKS_PER_UNIT; link++)
-    {
-	if (HostP->Mapping[unit].Topology[link].Unit != ROUTE_DISCONNECT)
-	    break;
-    }
+	rio_dprintk(RIO_DEBUG_ROUTE, "RIOFreeDisconnect unit %d\n", unit);
+	/*
+	 ** If the slot is tentative and does not belong to the
+	 ** second half of a 16 port RTA then scan to see if
+	 ** is disconnected.
+	 */
+	for (link = 0; link < LINKS_PER_UNIT; link++) {
+		if (HostP->Mapping[unit].Topology[link].Unit != ROUTE_DISCONNECT)
+			break;
+	}
 
-    /*
-    ** If not all links are disconnected then we can forget about it.
-    */
-    if (link < LINKS_PER_UNIT)
-	    return 1;
+	/*
+	 ** If not all links are disconnected then we can forget about it.
+	 */
+	if (link < LINKS_PER_UNIT)
+		return 1;
 
 #ifdef NEED_TO_FIX_THIS
-    /* Ok so all the links are disconnected. But we may have only just
-    ** made this slot tentative and not yet received a topology update.
-    ** Lets check how long ago we made it tentative.
-    */
-    rio_dprintk (RIO_DEBUG_ROUTE, "Just about to check LBOLT on entry %d\n", unit);
-    if (drv_getparm(LBOLT, (ulong_t *) &current_time))
-        rio_dprintk (RIO_DEBUG_ROUTE, "drv_getparm(LBOLT,....) Failed.\n");
+	/* Ok so all the links are disconnected. But we may have only just
+	 ** made this slot tentative and not yet received a topology update.
+	 ** Lets check how long ago we made it tentative.
+	 */
+	rio_dprintk(RIO_DEBUG_ROUTE, "Just about to check LBOLT on entry %d\n", unit);
+	if (drv_getparm(LBOLT, (ulong_t *) & current_time))
+		rio_dprintk(RIO_DEBUG_ROUTE, "drv_getparm(LBOLT,....) Failed.\n");
 
-    elapse_time = current_time - TentTime[unit];
-    rio_dprintk (RIO_DEBUG_ROUTE, "elapse %d = current %d - tent %d (%d usec)\n",
-        elapse_time, current_time, TentTime[unit], drv_hztousec(elapse_time));
-    if (drv_hztousec(elapse_time) < WAIT_TO_FINISH)
-    {
-      rio_dprintk (RIO_DEBUG_ROUTE, "Skipping slot %d, not timed out yet %d\n",
-            unit, drv_hztousec(elapse_time));
-        return 1;
-    }
+	elapse_time = current_time - TentTime[unit];
+	rio_dprintk(RIO_DEBUG_ROUTE, "elapse %d = current %d - tent %d (%d usec)\n", elapse_time, current_time, TentTime[unit], drv_hztousec(elapse_time));
+	if (drv_hztousec(elapse_time) < WAIT_TO_FINISH) {
+		rio_dprintk(RIO_DEBUG_ROUTE, "Skipping slot %d, not timed out yet %d\n", unit, drv_hztousec(elapse_time));
+		return 1;
+	}
 #endif
 
-    /*
-    ** We have found an usable slot.
-    ** If it is half of a 16 port RTA then delete the other half.
-    */
-    if (HostP->Mapping[unit].ID2 != 0)
-    {
-	int nOther = (HostP->Mapping[unit].ID2) -1;
+	/*
+	 ** We have found an usable slot.
+	 ** If it is half of a 16 port RTA then delete the other half.
+	 */
+	if (HostP->Mapping[unit].ID2 != 0) {
+		int nOther = (HostP->Mapping[unit].ID2) - 1;
 
-	rio_dprintk (RIO_DEBUG_ROUTE, "RioFreedis second slot %d.\n", nOther);
-	bzero((caddr_t)&HostP->Mapping[nOther], sizeof(struct Map));
-    }
-    RIORemoveFromSavedTable(p, &HostP->Mapping[unit]);
+		rio_dprintk(RIO_DEBUG_ROUTE, "RioFreedis second slot %d.\n", nOther);
+		bzero((caddr_t) & HostP->Mapping[nOther], sizeof(struct Map));
+	}
+	RIORemoveFromSavedTable(p, &HostP->Mapping[unit]);
 
-    return 0;
+	return 0;
 }
 
 
@@ -1066,150 +936,134 @@
 ** This function scans the given host table for either one
 ** or two free unit ID's.
 */
-int
-RIOFindFreeID(struct rio_info *p, struct Host *HostP, uint *pID1, uint *pID2)
+int RIOFindFreeID(struct rio_info *p, struct Host *HostP, uint * pID1, uint * pID2)
 {
-    int unit,tempID;
+	int unit, tempID;
 
-    /*
-    ** Initialise the ID's to MAX_RUP.
-    ** We do this to make the loop for setting the ID's as simple as
-    ** possible.
-    */
-    *pID1 = MAX_RUP;
-    if (pID2 != NULL)
-	*pID2 = MAX_RUP;
-
-    /*
-    ** Scan all entries of the host mapping table for free slots.
-    ** We scan for free slots first and then if that is not successful
-    ** we start all over again looking for tentative slots we can re-use.
-    */
-    for (unit = 0; unit < MAX_RUP; unit++)
-    {
-	rio_dprintk (RIO_DEBUG_ROUTE, "Scanning unit %d\n",unit);
 	/*
-	** If the flags are zero then the slot is empty.
-	*/
-	if (HostP->Mapping[unit].Flags == 0)
-	{
-	    rio_dprintk (RIO_DEBUG_ROUTE, "      This slot is empty.\n");
-	    /*
-	    ** If we haven't allocated the first ID then do it now.
-	    */
-	    if (*pID1 == MAX_RUP)
-	    {
-		rio_dprintk (RIO_DEBUG_ROUTE, "Make tentative entry for first unit %d\n", unit);
-		*pID1 = unit;
+	 ** Initialise the ID's to MAX_RUP.
+	 ** We do this to make the loop for setting the ID's as simple as
+	 ** possible.
+	 */
+	*pID1 = MAX_RUP;
+	if (pID2 != NULL)
+		*pID2 = MAX_RUP;
 
+	/*
+	 ** Scan all entries of the host mapping table for free slots.
+	 ** We scan for free slots first and then if that is not successful
+	 ** we start all over again looking for tentative slots we can re-use.
+	 */
+	for (unit = 0; unit < MAX_RUP; unit++) {
+		rio_dprintk(RIO_DEBUG_ROUTE, "Scanning unit %d\n", unit);
 		/*
-		** If the second ID is not needed then we can return
-		** now.
-		*/
-		if (pID2 == NULL)
-		    return 0;
-	    }
-	    else
-	    {
-		/*
-		** Allocate the second slot and return.
-		*/
-		rio_dprintk (RIO_DEBUG_ROUTE, "Make tentative entry for second unit %d\n", unit);
-		*pID2 = unit;
-		return 0;
-	    }
-	}
-    }
+		 ** If the flags are zero then the slot is empty.
+		 */
+		if (HostP->Mapping[unit].Flags == 0) {
+			rio_dprintk(RIO_DEBUG_ROUTE, "      This slot is empty.\n");
+			/*
+			 ** If we haven't allocated the first ID then do it now.
+			 */
+			if (*pID1 == MAX_RUP) {
+				rio_dprintk(RIO_DEBUG_ROUTE, "Make tentative entry for first unit %d\n", unit);
+				*pID1 = unit;
 
-    /*
-    ** If we manage to come out of the free slot loop then we
-    ** need to start all over again looking for tentative slots
-    ** that we can re-use.
-    */
-    rio_dprintk (RIO_DEBUG_ROUTE, "Starting to scan for tentative slots\n");
-    for (unit = 0; unit < MAX_RUP; unit++)
-    {
-	if (((HostP->Mapping[unit].Flags & SLOT_TENTATIVE) ||
-	                       (HostP->Mapping[unit].Flags == 0))  && ! 
-	   (HostP->Mapping[unit].Flags & RTA16_SECOND_SLOT ))
-	{
-	    rio_dprintk (RIO_DEBUG_ROUTE, "    Slot %d looks promising.\n",unit);
-
-	    if(unit == *pID1)
-	    {
-	    	rio_dprintk (RIO_DEBUG_ROUTE, "    No it isn't, its the 1st half\n");
-		continue;
-	    }
-
-	    /*
-	    ** Slot is Tentative or Empty, but not a tentative second 
-	    ** slot of a 16 porter.
-	    ** Attempt to free up this slot (and its parnter if
-	    ** it is a 16 port slot. The second slot will become
-	    ** empty after a call to RIOFreeDisconnected so thats why
-	    ** we look for empty slots above  as well).
-	    */
-	    if (HostP->Mapping[unit].Flags != 0) 
-	    	if (RIOFreeDisconnected(p, HostP, unit) != 0)
-			    continue;
-	    /*
-	    ** If we haven't allocated the first ID then do it now.
-	    */
-	    if (*pID1 == MAX_RUP)
-	    {
-		rio_dprintk (RIO_DEBUG_ROUTE, "Grab tentative entry for first unit %d\n", unit);
-		*pID1 = unit;
-
-		/*
-		** Clear out this slot now that we intend to use it.
-		*/
-		bzero(&HostP->Mapping[unit], sizeof(struct Map));
-
-		/*
-		** If the second ID is not needed then we can return
-		** now.
-		*/
-		if (pID2 == NULL)
-		    return 0;
-	    }
-	    else
-	    {
-		/*
-		** Allocate the second slot and return.
-		*/
-		rio_dprintk (RIO_DEBUG_ROUTE, "Grab tentative/empty  entry for second unit %d\n",
-		      unit);
-		*pID2 = unit;
-
-		/*
-		** Clear out this slot now that we intend to use it.
-		*/
-		bzero(&HostP->Mapping[unit], sizeof(struct Map));
-
-		/* At this point under the right(wrong?) conditions
-		** we may have a first unit ID being higher than the
-		** second unit ID. This is a bad idea if we are about
-		** to fill the slots with a 16 port RTA.
-		** Better check and swap them over.
-		*/
-
-		if (*pID1 > *pID2)
-		{
-			rio_dprintk (RIO_DEBUG_ROUTE, "Swapping IDS %d %d\n", *pID1, *pID2);
-			tempID = *pID1;
-			*pID1 = *pID2;
-			*pID2 = tempID;
+				/*
+				 ** If the second ID is not needed then we can return
+				 ** now.
+				 */
+				if (pID2 == NULL)
+					return 0;
+			} else {
+				/*
+				 ** Allocate the second slot and return.
+				 */
+				rio_dprintk(RIO_DEBUG_ROUTE, "Make tentative entry for second unit %d\n", unit);
+				*pID2 = unit;
+				return 0;
+			}
 		}
-		return 0;
-	    }
 	}
-    }
 
-    /*
-    ** If we manage to get to the end of the second loop then we
-    ** can give up and return a failure.
-    */
-    return 1;
+	/*
+	 ** If we manage to come out of the free slot loop then we
+	 ** need to start all over again looking for tentative slots
+	 ** that we can re-use.
+	 */
+	rio_dprintk(RIO_DEBUG_ROUTE, "Starting to scan for tentative slots\n");
+	for (unit = 0; unit < MAX_RUP; unit++) {
+		if (((HostP->Mapping[unit].Flags & SLOT_TENTATIVE) || (HostP->Mapping[unit].Flags == 0)) && !(HostP->Mapping[unit].Flags & RTA16_SECOND_SLOT)) {
+			rio_dprintk(RIO_DEBUG_ROUTE, "    Slot %d looks promising.\n", unit);
+
+			if (unit == *pID1) {
+				rio_dprintk(RIO_DEBUG_ROUTE, "    No it isn't, its the 1st half\n");
+				continue;
+			}
+
+			/*
+			 ** Slot is Tentative or Empty, but not a tentative second
+			 ** slot of a 16 porter.
+			 ** Attempt to free up this slot (and its parnter if
+			 ** it is a 16 port slot. The second slot will become
+			 ** empty after a call to RIOFreeDisconnected so thats why
+			 ** we look for empty slots above  as well).
+			 */
+			if (HostP->Mapping[unit].Flags != 0)
+				if (RIOFreeDisconnected(p, HostP, unit) != 0)
+					continue;
+			/*
+			 ** If we haven't allocated the first ID then do it now.
+			 */
+			if (*pID1 == MAX_RUP) {
+				rio_dprintk(RIO_DEBUG_ROUTE, "Grab tentative entry for first unit %d\n", unit);
+				*pID1 = unit;
+
+				/*
+				 ** Clear out this slot now that we intend to use it.
+				 */
+				bzero(&HostP->Mapping[unit], sizeof(struct Map));
+
+				/*
+				 ** If the second ID is not needed then we can return
+				 ** now.
+				 */
+				if (pID2 == NULL)
+					return 0;
+			} else {
+				/*
+				 ** Allocate the second slot and return.
+				 */
+				rio_dprintk(RIO_DEBUG_ROUTE, "Grab tentative/empty  entry for second unit %d\n", unit);
+				*pID2 = unit;
+
+				/*
+				 ** Clear out this slot now that we intend to use it.
+				 */
+				bzero(&HostP->Mapping[unit], sizeof(struct Map));
+
+				/* At this point under the right(wrong?) conditions
+				 ** we may have a first unit ID being higher than the
+				 ** second unit ID. This is a bad idea if we are about
+				 ** to fill the slots with a 16 port RTA.
+				 ** Better check and swap them over.
+				 */
+
+				if (*pID1 > *pID2) {
+					rio_dprintk(RIO_DEBUG_ROUTE, "Swapping IDS %d %d\n", *pID1, *pID2);
+					tempID = *pID1;
+					*pID1 = *pID2;
+					*pID2 = tempID;
+				}
+				return 0;
+			}
+		}
+	}
+
+	/*
+	 ** If we manage to get to the end of the second loop then we
+	 ** can give up and return a failure.
+	 */
+	return 1;
 }
 
 
diff --git a/drivers/char/rio/riospace.h b/drivers/char/rio/riospace.h
index 32b09b0..534f1f5 100644
--- a/drivers/char/rio/riospace.h
+++ b/drivers/char/rio/riospace.h
@@ -47,9 +47,8 @@
 ** In particular, it won't be able to see changes to RIO_SLOTS
 */
 
-struct Conf
-{
-	char         Locator[24];
+struct Conf {
+	char Locator[24];
 	unsigned int StartupTime;
 	unsigned int SlowCook;
 	unsigned int IntrPollTime;
@@ -59,8 +58,8 @@
 	unsigned int HostLoadBase;
 	unsigned int XpHz;
 	unsigned int XpCps;
-	char         *XpOn;
-	char         *XpOff;
+	char *XpOn;
+	char *XpOff;
 	unsigned int MaxXpCps;
 	unsigned int MinXpCps;
 	unsigned int SpinCmds;
@@ -74,7 +73,7 @@
 
 /*
 **	Board types - these MUST correspond to product codes!
-*/ 
+*/
 #define	RIO_EMPTY	0x0
 #define	RIO_EISA	0x3
 #define	RIO_RTA_16	0x9
@@ -86,18 +85,16 @@
 /*
 **	Board data structure. This is used for configuration info
 */
-struct	Brd
-{
-    unsigned char Type;	/* RIO_EISA, RIO_MCA, RIO_AT, RIO_EMPTY... */
-    unsigned char Ivec;	/* POLLED or ivec number */
-    unsigned char Mode;	/* Control stuff, see below */
+struct Brd {
+	unsigned char Type;	/* RIO_EISA, RIO_MCA, RIO_AT, RIO_EMPTY... */
+	unsigned char Ivec;	/* POLLED or ivec number */
+	unsigned char Mode;	/* Control stuff, see below */
 };
 
-struct	Board
-{
-    char       Locator[RIO_LOCATOR_LEN];
-    int        NumSlots;
-    struct Brd Boards[MAX_RIO_BOARDS];
+struct Board {
+	char Locator[RIO_LOCATOR_LEN];
+	int NumSlots;
+	struct Brd Boards[MAX_RIO_BOARDS];
 };
 
 #define	BOOT_FROM_LINK		0x00
@@ -158,4 +155,4 @@
 
 #define	DBG_ALWAYS	0x80000000
 
-#endif /* __rio_riospace_h__ */
+#endif				/* __rio_riospace_h__ */
diff --git a/drivers/char/rio/riotable.c b/drivers/char/rio/riotable.c
index e45bc27..42c3dffc 100644
--- a/drivers/char/rio/riotable.c
+++ b/drivers/char/rio/riotable.c
@@ -91,9 +91,8 @@
 ** A configuration table has been loaded. It is now up to us
 ** to sort it out and use the information contained therein.
 */
-int
-RIONewTable(p)
-struct rio_info *	p;
+int RIONewTable(p)
+struct rio_info *p;
 {
 	int Host, Host1, Host2, NameIsUnique, Entry, SubEnt;
 	struct Map *MapP;
@@ -103,26 +102,26 @@
 	char *cptr;
 
 	/*
-	** We have been sent a new table to install. We need to break
-	** it down into little bits and spread it around a bit to see
-	** what we have got.
-	*/
+	 ** We have been sent a new table to install. We need to break
+	 ** it down into little bits and spread it around a bit to see
+	 ** what we have got.
+	 */
 	/*
-	** Things to check:
-	** (things marked 'xx' aren't checked any more!)
-	** (1)	That there are no booted Hosts/RTAs out there.
-	** (2)	That the names are properly formed
-	** (3)	That blank entries really are.
-	** xx (4)	That hosts mentioned in the table actually exist. xx
-	** (5)	That the IDs are unique (per host).
-	** (6)	That host IDs are zero
-	** (7)	That port numbers are valid
-	** (8)	That port numbers aren't duplicated
-	** (9)	That names aren't duplicated
-	** xx (10) That hosts that actually exist are mentioned in the table. xx
-	*/
-	rio_dprintk (RIO_DEBUG_TABLE, "RIONewTable: entering(1)\n"); 
-	if ( p->RIOSystemUp ) {		/* (1) */
+	 ** Things to check:
+	 ** (things marked 'xx' aren't checked any more!)
+	 ** (1) That there are no booted Hosts/RTAs out there.
+	 ** (2) That the names are properly formed
+	 ** (3) That blank entries really are.
+	 ** xx (4)      That hosts mentioned in the table actually exist. xx
+	 ** (5) That the IDs are unique (per host).
+	 ** (6) That host IDs are zero
+	 ** (7) That port numbers are valid
+	 ** (8) That port numbers aren't duplicated
+	 ** (9) That names aren't duplicated
+	 ** xx (10) That hosts that actually exist are mentioned in the table. xx
+	 */
+	rio_dprintk(RIO_DEBUG_TABLE, "RIONewTable: entering(1)\n");
+	if (p->RIOSystemUp) {	/* (1) */
 		p->RIOError.Error = HOST_HAS_ALREADY_BEEN_BOOTED;
 		return -EBUSY;
 	}
@@ -131,19 +130,19 @@
 	p->RIOError.Entry = -1;
 	p->RIOError.Other = -1;
 
-	for ( Entry=0; Entry<TOTAL_MAP_ENTRIES; Entry++ ) {
+	for (Entry = 0; Entry < TOTAL_MAP_ENTRIES; Entry++) {
 		MapP = &p->RIOConnectTable[Entry];
 		if ((MapP->Flags & RTA16_SECOND_SLOT) == 0) {
-			rio_dprintk (RIO_DEBUG_TABLE, "RIONewTable: entering(2)\n");
-			cptr = MapP->Name;		/* (2) */
-			cptr[MAX_NAME_LEN-1]='\0';
-			if ( cptr[0]=='\0' ) {
-				bcopy(MapP->RtaUniqueNum?"RTA	NN":"HOST NN",MapP->Name,8);
-				MapP->Name[5] = '0'+Entry/10;
-				MapP->Name[6] = '0'+Entry%10;
+			rio_dprintk(RIO_DEBUG_TABLE, "RIONewTable: entering(2)\n");
+			cptr = MapP->Name;	/* (2) */
+			cptr[MAX_NAME_LEN - 1] = '\0';
+			if (cptr[0] == '\0') {
+				bcopy(MapP->RtaUniqueNum ? "RTA	NN" : "HOST NN", MapP->Name, 8);
+				MapP->Name[5] = '0' + Entry / 10;
+				MapP->Name[6] = '0' + Entry % 10;
 			}
-			while ( *cptr ) {
-				if ( *cptr<' ' || *cptr>'~' ) {
+			while (*cptr) {
+				if (*cptr < ' ' || *cptr > '~') {
 					p->RIOError.Error = BAD_CHARACTER_IN_NAME;
 					p->RIOError.Entry = Entry;
 					return -ENXIO;
@@ -153,133 +152,119 @@
 		}
 
 		/*
-		** If the entry saved was a tentative entry then just forget
-		** about it.
-		*/
-		if ( MapP->Flags & SLOT_TENTATIVE ) {
+		 ** If the entry saved was a tentative entry then just forget
+		 ** about it.
+		 */
+		if (MapP->Flags & SLOT_TENTATIVE) {
 			MapP->HostUniqueNum = 0;
 			MapP->RtaUniqueNum = 0;
 			continue;
 		}
 
-		rio_dprintk (RIO_DEBUG_TABLE, "RIONewTable: entering(3)\n");
-		if ( !MapP->RtaUniqueNum && !MapP->HostUniqueNum ) { /* (3) */
-			if ( MapP->ID || MapP->SysPort || MapP->Flags ) {
-				rio_dprintk (RIO_DEBUG_TABLE, "%s pretending to be empty but isn't\n",MapP->Name);
+		rio_dprintk(RIO_DEBUG_TABLE, "RIONewTable: entering(3)\n");
+		if (!MapP->RtaUniqueNum && !MapP->HostUniqueNum) {	/* (3) */
+			if (MapP->ID || MapP->SysPort || MapP->Flags) {
+				rio_dprintk(RIO_DEBUG_TABLE, "%s pretending to be empty but isn't\n", MapP->Name);
 				p->RIOError.Error = TABLE_ENTRY_ISNT_PROPERLY_NULL;
 				p->RIOError.Entry = Entry;
 				return -ENXIO;
 			}
-			rio_dprintk (RIO_DEBUG_TABLE, "!RIO: Daemon: test (3) passes\n");
+			rio_dprintk(RIO_DEBUG_TABLE, "!RIO: Daemon: test (3) passes\n");
 			continue;
 		}
 
-		rio_dprintk (RIO_DEBUG_TABLE, "RIONewTable: entering(4)\n");
-		for ( Host=0; Host<p->RIONumHosts; Host++ ) { /* (4) */
-			if ( p->RIOHosts[Host].UniqueNum==MapP->HostUniqueNum ) {
+		rio_dprintk(RIO_DEBUG_TABLE, "RIONewTable: entering(4)\n");
+		for (Host = 0; Host < p->RIONumHosts; Host++) {	/* (4) */
+			if (p->RIOHosts[Host].UniqueNum == MapP->HostUniqueNum) {
 				HostP = &p->RIOHosts[Host];
 				/*
-				** having done the lookup, we don't really want to do
-				** it again, so hang the host number in a safe place
-				*/
+				 ** having done the lookup, we don't really want to do
+				 ** it again, so hang the host number in a safe place
+				 */
 				MapP->Topology[0].Unit = Host;
 				break;
 			}
 		}
 
-		if ( Host >= p->RIONumHosts ) {
-			rio_dprintk (RIO_DEBUG_TABLE, "RTA %s has unknown host unique number 0x%x\n",
-									MapP->Name, MapP->HostUniqueNum);
+		if (Host >= p->RIONumHosts) {
+			rio_dprintk(RIO_DEBUG_TABLE, "RTA %s has unknown host unique number 0x%x\n", MapP->Name, MapP->HostUniqueNum);
 			MapP->HostUniqueNum = 0;
-			/* MapP->RtaUniqueNum	= 0; */
-			/* MapP->ID			= 0; */
-			/* MapP->Flags		 = 0; */
-			/* MapP->SysPort		 = 0; */
-			/* MapP->Name[0]		 = 0; */
+			/* MapP->RtaUniqueNum   = 0; */
+			/* MapP->ID                     = 0; */
+			/* MapP->Flags           = 0; */
+			/* MapP->SysPort                 = 0; */
+			/* MapP->Name[0]                 = 0; */
 			continue;
 		}
 
-		rio_dprintk (RIO_DEBUG_TABLE, "RIONewTable: entering(5)\n"); 
-		if ( MapP->RtaUniqueNum ) { /* (5) */
-			if ( !MapP->ID ) {
-				rio_dprintk (RIO_DEBUG_TABLE, "RIO: RTA %s has been allocated an ID of zero!\n",
-							MapP->Name);
-				p->RIOError.Error		 = ZERO_RTA_ID;
+		rio_dprintk(RIO_DEBUG_TABLE, "RIONewTable: entering(5)\n");
+		if (MapP->RtaUniqueNum) {	/* (5) */
+			if (!MapP->ID) {
+				rio_dprintk(RIO_DEBUG_TABLE, "RIO: RTA %s has been allocated an ID of zero!\n", MapP->Name);
+				p->RIOError.Error = ZERO_RTA_ID;
 				p->RIOError.Entry = Entry;
 				return -ENXIO;
 			}
-			if ( MapP->ID > MAX_RUP ) {
-				rio_dprintk (RIO_DEBUG_TABLE, "RIO: RTA %s has been allocated an invalid ID %d\n",
-							MapP->Name, MapP->ID);
+			if (MapP->ID > MAX_RUP) {
+				rio_dprintk(RIO_DEBUG_TABLE, "RIO: RTA %s has been allocated an invalid ID %d\n", MapP->Name, MapP->ID);
 				p->RIOError.Error = ID_NUMBER_OUT_OF_RANGE;
 				p->RIOError.Entry = Entry;
 				return -ENXIO;
 			}
-			for ( SubEnt=0; SubEnt<Entry; SubEnt++ ) {
-				if ( MapP->HostUniqueNum == 
-						p->RIOConnectTable[SubEnt].HostUniqueNum && 
-						MapP->ID == p->RIOConnectTable[SubEnt].ID ) {
-					rio_dprintk (RIO_DEBUG_TABLE, "Dupl. ID number allocated to RTA %s and RTA %s\n",
-							MapP->Name, p->RIOConnectTable[SubEnt].Name);
+			for (SubEnt = 0; SubEnt < Entry; SubEnt++) {
+				if (MapP->HostUniqueNum == p->RIOConnectTable[SubEnt].HostUniqueNum && MapP->ID == p->RIOConnectTable[SubEnt].ID) {
+					rio_dprintk(RIO_DEBUG_TABLE, "Dupl. ID number allocated to RTA %s and RTA %s\n", MapP->Name, p->RIOConnectTable[SubEnt].Name);
 					p->RIOError.Error = DUPLICATED_RTA_ID;
 					p->RIOError.Entry = Entry;
 					p->RIOError.Other = SubEnt;
 					return -ENXIO;
 				}
 				/*
-				** If the RtaUniqueNum is the same, it may be looking at both
-				** entries for a 16 port RTA, so check the ids
-				*/
-				if ((MapP->RtaUniqueNum == 
-						p->RIOConnectTable[SubEnt].RtaUniqueNum)
-				 		&& (MapP->ID2 != p->RIOConnectTable[SubEnt].ID)) {
-					rio_dprintk (RIO_DEBUG_TABLE, "RTA %s has duplicate unique number\n",MapP->Name);
-					rio_dprintk (RIO_DEBUG_TABLE, "RTA %s has duplicate unique number\n",
-										p->RIOConnectTable[SubEnt].Name);
+				 ** If the RtaUniqueNum is the same, it may be looking at both
+				 ** entries for a 16 port RTA, so check the ids
+				 */
+				if ((MapP->RtaUniqueNum == p->RIOConnectTable[SubEnt].RtaUniqueNum)
+				    && (MapP->ID2 != p->RIOConnectTable[SubEnt].ID)) {
+					rio_dprintk(RIO_DEBUG_TABLE, "RTA %s has duplicate unique number\n", MapP->Name);
+					rio_dprintk(RIO_DEBUG_TABLE, "RTA %s has duplicate unique number\n", p->RIOConnectTable[SubEnt].Name);
 					p->RIOError.Error = DUPLICATE_UNIQUE_NUMBER;
 					p->RIOError.Entry = Entry;
 					p->RIOError.Other = SubEnt;
 					return -ENXIO;
 				}
 			}
-			rio_dprintk (RIO_DEBUG_TABLE, "RIONewTable: entering(7a)\n"); 
+			rio_dprintk(RIO_DEBUG_TABLE, "RIONewTable: entering(7a)\n");
 			/* (7a) */
-			if ((MapP->SysPort != NO_PORT)&&(MapP->SysPort % PORTS_PER_RTA)) {
-				rio_dprintk (RIO_DEBUG_TABLE, "TTY Port number %d-RTA %s is not a multiple of %d!\n",
-					(int)MapP->SysPort,MapP->Name, PORTS_PER_RTA);
+			if ((MapP->SysPort != NO_PORT) && (MapP->SysPort % PORTS_PER_RTA)) {
+				rio_dprintk(RIO_DEBUG_TABLE, "TTY Port number %d-RTA %s is not a multiple of %d!\n", (int) MapP->SysPort, MapP->Name, PORTS_PER_RTA);
 				p->RIOError.Error = TTY_NUMBER_OUT_OF_RANGE;
 				p->RIOError.Entry = Entry;
 				return -ENXIO;
 			}
-			rio_dprintk (RIO_DEBUG_TABLE, "RIONewTable: entering(7b)\n"); 
+			rio_dprintk(RIO_DEBUG_TABLE, "RIONewTable: entering(7b)\n");
 			/* (7b) */
-			if ((MapP->SysPort != NO_PORT)&&(MapP->SysPort >= RIO_PORTS)) {
-				rio_dprintk (RIO_DEBUG_TABLE, "TTY Port number %d for RTA %s is too big\n",
-							(int)MapP->SysPort, MapP->Name);
+			if ((MapP->SysPort != NO_PORT) && (MapP->SysPort >= RIO_PORTS)) {
+				rio_dprintk(RIO_DEBUG_TABLE, "TTY Port number %d for RTA %s is too big\n", (int) MapP->SysPort, MapP->Name);
 				p->RIOError.Error = TTY_NUMBER_OUT_OF_RANGE;
 				p->RIOError.Entry = Entry;
 				return -ENXIO;
 			}
-			for ( SubEnt=0; SubEnt<Entry; SubEnt++ ) {
-				if ( p->RIOConnectTable[SubEnt].Flags & RTA16_SECOND_SLOT )
-						continue;
-				if ( p->RIOConnectTable[SubEnt].RtaUniqueNum ) {
-					rio_dprintk (RIO_DEBUG_TABLE, "RIONewTable: entering(8)\n"); 
+			for (SubEnt = 0; SubEnt < Entry; SubEnt++) {
+				if (p->RIOConnectTable[SubEnt].Flags & RTA16_SECOND_SLOT)
+					continue;
+				if (p->RIOConnectTable[SubEnt].RtaUniqueNum) {
+					rio_dprintk(RIO_DEBUG_TABLE, "RIONewTable: entering(8)\n");
 					/* (8) */
-					if ( (MapP->SysPort != NO_PORT) && (MapP->SysPort == 
-									p->RIOConnectTable[SubEnt].SysPort) ) {
-						rio_dprintk (RIO_DEBUG_TABLE, "RTA %s:same TTY port # as RTA %s (%d)\n",
-							MapP->Name, p->RIOConnectTable[SubEnt].Name,
-							(int)MapP->SysPort);
+					if ((MapP->SysPort != NO_PORT) && (MapP->SysPort == p->RIOConnectTable[SubEnt].SysPort)) {
+						rio_dprintk(RIO_DEBUG_TABLE, "RTA %s:same TTY port # as RTA %s (%d)\n", MapP->Name, p->RIOConnectTable[SubEnt].Name, (int) MapP->SysPort);
 						p->RIOError.Error = TTY_NUMBER_IN_USE;
 						p->RIOError.Entry = Entry;
 						p->RIOError.Other = SubEnt;
 						return -ENXIO;
 					}
-					rio_dprintk (RIO_DEBUG_TABLE, "RIONewTable: entering(9)\n"); 
-					if (strcmp(MapP->Name,
-							p->RIOConnectTable[SubEnt].Name)==0 && !(MapP->Flags & RTA16_SECOND_SLOT)) { /* (9) */
-						rio_dprintk (RIO_DEBUG_TABLE, "RTA name %s used twice\n", MapP->Name);
+					rio_dprintk(RIO_DEBUG_TABLE, "RIONewTable: entering(9)\n");
+					if (strcmp(MapP->Name, p->RIOConnectTable[SubEnt].Name) == 0 && !(MapP->Flags & RTA16_SECOND_SLOT)) {	/* (9) */
+						rio_dprintk(RIO_DEBUG_TABLE, "RTA name %s used twice\n", MapP->Name);
 						p->RIOError.Error = NAME_USED_TWICE;
 						p->RIOError.Entry = Entry;
 						p->RIOError.Other = SubEnt;
@@ -287,19 +272,16 @@
 					}
 				}
 			}
-		}
-		else { /* (6) */
-			rio_dprintk (RIO_DEBUG_TABLE, "RIONewTable: entering(6)\n"); 
-			if ( MapP->ID ) {
-				rio_dprintk (RIO_DEBUG_TABLE, "RIO:HOST %s has been allocated ID that isn't zero!\n",
-					MapP->Name);
+		} else {	/* (6) */
+			rio_dprintk(RIO_DEBUG_TABLE, "RIONewTable: entering(6)\n");
+			if (MapP->ID) {
+				rio_dprintk(RIO_DEBUG_TABLE, "RIO:HOST %s has been allocated ID that isn't zero!\n", MapP->Name);
 				p->RIOError.Error = HOST_ID_NOT_ZERO;
 				p->RIOError.Entry = Entry;
 				return -ENXIO;
 			}
-			if ( MapP->SysPort != NO_PORT ) {
-				rio_dprintk (RIO_DEBUG_TABLE, "RIO: HOST %s has been allocated port numbers!\n",
-					MapP->Name);
+			if (MapP->SysPort != NO_PORT) {
+				rio_dprintk(RIO_DEBUG_TABLE, "RIO: HOST %s has been allocated port numbers!\n", MapP->Name);
 				p->RIOError.Error = HOST_SYSPORT_BAD;
 				p->RIOError.Entry = Entry;
 				return -ENXIO;
@@ -308,106 +290,101 @@
 	}
 
 	/*
-	** wow! if we get here then it's a goody!
-	*/
+	 ** wow! if we get here then it's a goody!
+	 */
 
 	/*
-	** Zero the (old) entries for each host...
-	*/
-	for ( Host=0; Host<RIO_HOSTS; Host++ ) {
-		for ( Entry=0; Entry<MAX_RUP; Entry++ ) {
-			bzero((caddr_t)&p->RIOHosts[Host].Mapping[Entry], 
-											sizeof(struct Map));
+	 ** Zero the (old) entries for each host...
+	 */
+	for (Host = 0; Host < RIO_HOSTS; Host++) {
+		for (Entry = 0; Entry < MAX_RUP; Entry++) {
+			bzero((caddr_t) & p->RIOHosts[Host].Mapping[Entry], sizeof(struct Map));
 		}
-		bzero((caddr_t)&p->RIOHosts[Host].Name[0],
-								sizeof(p->RIOHosts[Host].Name) );
+		bzero((caddr_t) & p->RIOHosts[Host].Name[0], sizeof(p->RIOHosts[Host].Name));
 	}
 
 	/*
-	** Copy in the new table entries
-	*/
-	for ( Entry=0; Entry< TOTAL_MAP_ENTRIES; Entry++ ) {
-		rio_dprintk (RIO_DEBUG_TABLE, "RIONewTable: Copy table for Host entry %d\n", Entry);
+	 ** Copy in the new table entries
+	 */
+	for (Entry = 0; Entry < TOTAL_MAP_ENTRIES; Entry++) {
+		rio_dprintk(RIO_DEBUG_TABLE, "RIONewTable: Copy table for Host entry %d\n", Entry);
 		MapP = &p->RIOConnectTable[Entry];
 
 		/*
-		** Now, if it is an empty slot ignore it!
-		*/
-		if ( MapP->HostUniqueNum==0 )
+		 ** Now, if it is an empty slot ignore it!
+		 */
+		if (MapP->HostUniqueNum == 0)
 			continue;
 
 		/*
-		** we saved the host number earlier, so grab it back
-		*/
+		 ** we saved the host number earlier, so grab it back
+		 */
 		HostP = &p->RIOHosts[MapP->Topology[0].Unit];
 
 		/*
-		** If it is a host, then we only need to fill in the name field.
-		*/
-		if ( MapP->ID==0 ) {
-			rio_dprintk (RIO_DEBUG_TABLE, "Host entry found. Name %s\n", MapP->Name);
-			bcopy(MapP->Name,HostP->Name,MAX_NAME_LEN);
+		 ** If it is a host, then we only need to fill in the name field.
+		 */
+		if (MapP->ID == 0) {
+			rio_dprintk(RIO_DEBUG_TABLE, "Host entry found. Name %s\n", MapP->Name);
+			bcopy(MapP->Name, HostP->Name, MAX_NAME_LEN);
 			continue;
 		}
 
 		/*
-		** Its an RTA entry, so fill in the host mapping entries for it
-		** and the port mapping entries. Notice that entry zero is for
-		** ID one.
-		*/
-		HostMapP = &HostP->Mapping[MapP->ID-1];
+		 ** Its an RTA entry, so fill in the host mapping entries for it
+		 ** and the port mapping entries. Notice that entry zero is for
+		 ** ID one.
+		 */
+		HostMapP = &HostP->Mapping[MapP->ID - 1];
 
 		if (MapP->Flags & SLOT_IN_USE) {
-			rio_dprintk (RIO_DEBUG_TABLE, "Rta entry found. Name %s\n", MapP->Name);
+			rio_dprintk(RIO_DEBUG_TABLE, "Rta entry found. Name %s\n", MapP->Name);
 			/*
-			** structure assign, then sort out the bits we shouldn't have done
-			*/
+			 ** structure assign, then sort out the bits we shouldn't have done
+			 */
 			*HostMapP = *MapP;
 
 			HostMapP->Flags = SLOT_IN_USE;
 			if (MapP->Flags & RTA16_SECOND_SLOT)
 				HostMapP->Flags |= RTA16_SECOND_SLOT;
 
-			RIOReMapPorts(p, HostP, HostMapP );
-		}
-		else {
-			rio_dprintk (RIO_DEBUG_TABLE, "TENTATIVE Rta entry found. Name %s\n", MapP->Name);
+			RIOReMapPorts(p, HostP, HostMapP);
+		} else {
+			rio_dprintk(RIO_DEBUG_TABLE, "TENTATIVE Rta entry found. Name %s\n", MapP->Name);
 		}
 	}
 
-	for ( Entry=0; Entry< TOTAL_MAP_ENTRIES; Entry++ ) {
+	for (Entry = 0; Entry < TOTAL_MAP_ENTRIES; Entry++) {
 		p->RIOSavedTable[Entry] = p->RIOConnectTable[Entry];
 	}
 
-	for ( Host=0; Host<p->RIONumHosts; Host++ ) {
-		for ( SubEnt=0; SubEnt<LINKS_PER_UNIT; SubEnt++ ) {
+	for (Host = 0; Host < p->RIONumHosts; Host++) {
+		for (SubEnt = 0; SubEnt < LINKS_PER_UNIT; SubEnt++) {
 			p->RIOHosts[Host].Topology[SubEnt].Unit = ROUTE_DISCONNECT;
 			p->RIOHosts[Host].Topology[SubEnt].Link = NO_LINK;
 		}
-		for ( Entry=0; Entry<MAX_RUP; Entry++ ) {
-			for ( SubEnt=0; SubEnt<LINKS_PER_UNIT; SubEnt++ ) {
-				p->RIOHosts[Host].Mapping[Entry].Topology[SubEnt].Unit = 
-								ROUTE_DISCONNECT;
-				p->RIOHosts[Host].Mapping[Entry].Topology[SubEnt].Link = 
-								NO_LINK;
+		for (Entry = 0; Entry < MAX_RUP; Entry++) {
+			for (SubEnt = 0; SubEnt < LINKS_PER_UNIT; SubEnt++) {
+				p->RIOHosts[Host].Mapping[Entry].Topology[SubEnt].Unit = ROUTE_DISCONNECT;
+				p->RIOHosts[Host].Mapping[Entry].Topology[SubEnt].Link = NO_LINK;
 			}
 		}
-		if ( !p->RIOHosts[Host].Name[0] ) {
-			bcopy("HOST 1",p->RIOHosts[Host].Name,7);
+		if (!p->RIOHosts[Host].Name[0]) {
+			bcopy("HOST 1", p->RIOHosts[Host].Name, 7);
 			p->RIOHosts[Host].Name[5] += Host;
 		}
 		/*
-		** Check that default name assigned is unique.
-		*/
+		 ** Check that default name assigned is unique.
+		 */
 		Host1 = Host;
 		NameIsUnique = 0;
 		while (!NameIsUnique) {
 			NameIsUnique = 1;
-			for ( Host2=0; Host2<p->RIONumHosts; Host2++ ) {
+			for (Host2 = 0; Host2 < p->RIONumHosts; Host2++) {
 				if (Host2 == Host)
 					continue;
 				if (strcmp(p->RIOHosts[Host].Name, p->RIOHosts[Host2].Name)
-									 == 0) {
+				    == 0) {
 					NameIsUnique = 0;
 					Host1++;
 					if (Host1 >= p->RIONumHosts)
@@ -417,15 +394,14 @@
 			}
 		}
 		/*
-		** Rename host if name already used.
-		*/
-		if (Host1 != Host)
-		{
-			rio_dprintk (RIO_DEBUG_TABLE, "Default name %s already used\n", p->RIOHosts[Host].Name);
-			bcopy("HOST 1",p->RIOHosts[Host].Name,7);
+		 ** Rename host if name already used.
+		 */
+		if (Host1 != Host) {
+			rio_dprintk(RIO_DEBUG_TABLE, "Default name %s already used\n", p->RIOHosts[Host].Name);
+			bcopy("HOST 1", p->RIOHosts[Host].Name, 7);
 			p->RIOHosts[Host].Name[5] += Host1;
 		}
-		rio_dprintk (RIO_DEBUG_TABLE, "Assigning default name %s\n", p->RIOHosts[Host].Name);
+		rio_dprintk(RIO_DEBUG_TABLE, "Assigning default name %s\n", p->RIOHosts[Host].Name);
 	}
 	return 0;
 }
@@ -434,9 +410,8 @@
 ** User process needs the config table - build it from first
 ** principles.
 */
-int
-RIOApel(p)
-struct rio_info *	p;
+int RIOApel(p)
+struct rio_info *p;
 {
 	int Host;
 	int link;
@@ -446,35 +421,34 @@
 	struct Host *HostP;
 	long oldspl;
 
-	disable(oldspl);		/* strange but true! */
- 
-	rio_dprintk (RIO_DEBUG_TABLE, "Generating a table to return to config.rio\n");
+	disable(oldspl);	/* strange but true! */
 
-	bzero((caddr_t)&p->RIOConnectTable[0], 
-					sizeof(struct Map) * TOTAL_MAP_ENTRIES );
+	rio_dprintk(RIO_DEBUG_TABLE, "Generating a table to return to config.rio\n");
 
-	for ( Host=0; Host<RIO_HOSTS; Host++ ) {
-		rio_dprintk (RIO_DEBUG_TABLE, "Processing host %d\n", Host);
+	bzero((caddr_t) & p->RIOConnectTable[0], sizeof(struct Map) * TOTAL_MAP_ENTRIES);
+
+	for (Host = 0; Host < RIO_HOSTS; Host++) {
+		rio_dprintk(RIO_DEBUG_TABLE, "Processing host %d\n", Host);
 		HostP = &p->RIOHosts[Host];
 		MapP = &p->RIOConnectTable[Next++];
 		MapP->HostUniqueNum = HostP->UniqueNum;
-		if ( (HostP->Flags & RUN_STATE) != RC_RUNNING )
+		if ((HostP->Flags & RUN_STATE) != RC_RUNNING)
 			continue;
 		MapP->RtaUniqueNum = 0;
 		MapP->ID = 0;
 		MapP->Flags = SLOT_IN_USE;
 		MapP->SysPort = NO_PORT;
-		for ( link=0; link<LINKS_PER_UNIT; link++ )
+		for (link = 0; link < LINKS_PER_UNIT; link++)
 			MapP->Topology[link] = HostP->Topology[link];
-		bcopy(HostP->Name,MapP->Name,MAX_NAME_LEN);
-		for ( Rup=0; Rup<MAX_RUP; Rup++ ) {
-			if ( HostP->Mapping[Rup].Flags & (SLOT_IN_USE|SLOT_TENTATIVE) ) {
+		bcopy(HostP->Name, MapP->Name, MAX_NAME_LEN);
+		for (Rup = 0; Rup < MAX_RUP; Rup++) {
+			if (HostP->Mapping[Rup].Flags & (SLOT_IN_USE | SLOT_TENTATIVE)) {
 				p->RIOConnectTable[Next] = HostP->Mapping[Rup];
-				if ( HostP->Mapping[Rup].Flags & SLOT_IN_USE)
+				if (HostP->Mapping[Rup].Flags & SLOT_IN_USE)
 					p->RIOConnectTable[Next].Flags |= SLOT_IN_USE;
-				if ( HostP->Mapping[Rup].Flags & SLOT_TENTATIVE)
+				if (HostP->Mapping[Rup].Flags & SLOT_TENTATIVE)
 					p->RIOConnectTable[Next].Flags |= SLOT_TENTATIVE;
-				if ( HostP->Mapping[Rup].Flags & RTA16_SECOND_SLOT )
+				if (HostP->Mapping[Rup].Flags & RTA16_SECOND_SLOT)
 					p->RIOConnectTable[Next].Flags |= RTA16_SECOND_SLOT;
 				Next++;
 			}
@@ -489,8 +463,7 @@
 ** if the entry is suitably inactive, then we can gob on it and remove
 ** it from the table.
 */
-int
-RIODeleteRta(p, MapP)
+int RIODeleteRta(p, MapP)
 struct rio_info *p;
 struct Map *MapP;
 {
@@ -502,110 +475,98 @@
 	int work_done = 0;
 	unsigned long lock_flags, sem_flags;
 
-	rio_dprintk (RIO_DEBUG_TABLE, "Delete entry on host %x, rta %x\n",
-								MapP->HostUniqueNum, MapP->RtaUniqueNum);
+	rio_dprintk(RIO_DEBUG_TABLE, "Delete entry on host %x, rta %x\n", MapP->HostUniqueNum, MapP->RtaUniqueNum);
 
-	for ( host=0; host < p->RIONumHosts; host++ ) {
+	for (host = 0; host < p->RIONumHosts; host++) {
 		HostP = &p->RIOHosts[host];
 
-		rio_spin_lock_irqsave( &HostP->HostLock, lock_flags );
+		rio_spin_lock_irqsave(&HostP->HostLock, lock_flags);
 
-		if ( (HostP->Flags & RUN_STATE) != RC_RUNNING ) {
+		if ((HostP->Flags & RUN_STATE) != RC_RUNNING) {
 			rio_spin_unlock_irqrestore(&HostP->HostLock, lock_flags);
 			continue;
 		}
 
-		for ( entry=0; entry<MAX_RUP; entry++ ) {
-			if ( MapP->RtaUniqueNum == HostP->Mapping[entry].RtaUniqueNum ) {
+		for (entry = 0; entry < MAX_RUP; entry++) {
+			if (MapP->RtaUniqueNum == HostP->Mapping[entry].RtaUniqueNum) {
 				HostMapP = &HostP->Mapping[entry];
-				rio_dprintk (RIO_DEBUG_TABLE, "Found entry offset %d on host %s\n", 
-						entry, HostP->Name);
+				rio_dprintk(RIO_DEBUG_TABLE, "Found entry offset %d on host %s\n", entry, HostP->Name);
 
 				/*
-				** Check all four links of the unit are disconnected
-				*/
-				for ( link=0; link< LINKS_PER_UNIT; link++ ) {
-					if ( HostMapP->Topology[link].Unit != ROUTE_DISCONNECT ) {
-						rio_dprintk (RIO_DEBUG_TABLE, "Entry is in use and cannot be deleted!\n");
+				 ** Check all four links of the unit are disconnected
+				 */
+				for (link = 0; link < LINKS_PER_UNIT; link++) {
+					if (HostMapP->Topology[link].Unit != ROUTE_DISCONNECT) {
+						rio_dprintk(RIO_DEBUG_TABLE, "Entry is in use and cannot be deleted!\n");
 						p->RIOError.Error = UNIT_IS_IN_USE;
-						rio_spin_unlock_irqrestore( &HostP->HostLock, lock_flags);
+						rio_spin_unlock_irqrestore(&HostP->HostLock, lock_flags);
 						return -EBUSY;
 					}
 				}
 				/*
-				** Slot has been allocated, BUT not booted/routed/
-				** connected/selected or anything else-ed
-				*/
+				 ** Slot has been allocated, BUT not booted/routed/
+				 ** connected/selected or anything else-ed
+				 */
 				SysPort = HostMapP->SysPort;
 
-				if ( SysPort != NO_PORT ) {
-					for (port=SysPort; port < SysPort+PORTS_PER_RTA; port++) {
+				if (SysPort != NO_PORT) {
+					for (port = SysPort; port < SysPort + PORTS_PER_RTA; port++) {
 						PortP = p->RIOPortp[port];
-						rio_dprintk (RIO_DEBUG_TABLE, "Unmap port\n");
+						rio_dprintk(RIO_DEBUG_TABLE, "Unmap port\n");
 
-						rio_spin_lock_irqsave( &PortP->portSem, sem_flags );
+						rio_spin_lock_irqsave(&PortP->portSem, sem_flags);
 
 						PortP->Mapped = 0;
 
-						if ( PortP->State & (RIO_MOPEN|RIO_LOPEN) ) {
+						if (PortP->State & (RIO_MOPEN | RIO_LOPEN)) {
 
-							rio_dprintk (RIO_DEBUG_TABLE, "Gob on port\n");
+							rio_dprintk(RIO_DEBUG_TABLE, "Gob on port\n");
 							PortP->TxBufferIn = PortP->TxBufferOut = 0;
 							/* What should I do 
-							wakeup( &PortP->TxBufferIn );
-							wakeup( &PortP->TxBufferOut);
-							*/
+							   wakeup( &PortP->TxBufferIn );
+							   wakeup( &PortP->TxBufferOut);
+							 */
 							PortP->InUse = NOT_INUSE;
 							/* What should I do 
-							wakeup( &PortP->InUse );
-							signal(PortP->TtyP->t_pgrp,SIGKILL);
-							ttyflush(PortP->TtyP,(FREAD|FWRITE));
-							*/
+							   wakeup( &PortP->InUse );
+							   signal(PortP->TtyP->t_pgrp,SIGKILL);
+							   ttyflush(PortP->TtyP,(FREAD|FWRITE));
+							 */
 							PortP->State |= RIO_CLOSING | RIO_DELETED;
 						}
 
 						/*
-						** For the second slot of a 16 port RTA, the
-						** driver needs to reset the changes made to
-						** the phb to port mappings in RIORouteRup.
-						*/
+						 ** For the second slot of a 16 port RTA, the
+						 ** driver needs to reset the changes made to
+						 ** the phb to port mappings in RIORouteRup.
+						 */
 						if (PortP->SecondBlock) {
 							ushort dest_unit = HostMapP->ID;
 							ushort dest_port = port - SysPort;
-							WORD	 *TxPktP;
-							PKT	*Pkt;
+							WORD *TxPktP;
+							PKT *Pkt;
 
-							for (TxPktP = PortP->TxStart;
-								TxPktP <= PortP->TxEnd; TxPktP++) {
+							for (TxPktP = PortP->TxStart; TxPktP <= PortP->TxEnd; TxPktP++) {
 								/*
-								** *TxPktP is the pointer to the
-								** transmit packet on the host card.
-								** This needs to be translated into
-								** a 32 bit pointer so it can be
-								** accessed from the driver.
-								*/
-								Pkt = (PKT *) RIO_PTR(HostP->Caddr,
-								 	RWORD(*TxPktP));
-								rio_dprintk (RIO_DEBUG_TABLE, 
-						"Tx packet (%x) destination: Old %x:%x New %x:%x\n",
-								 *TxPktP, Pkt->dest_unit,
-								 Pkt->dest_port, dest_unit, dest_port);
+								 ** *TxPktP is the pointer to the
+								 ** transmit packet on the host card.
+								 ** This needs to be translated into
+								 ** a 32 bit pointer so it can be
+								 ** accessed from the driver.
+								 */
+								Pkt = (PKT *) RIO_PTR(HostP->Caddr, RWORD(*TxPktP));
+								rio_dprintk(RIO_DEBUG_TABLE, "Tx packet (%x) destination: Old %x:%x New %x:%x\n", *TxPktP, Pkt->dest_unit, Pkt->dest_port, dest_unit, dest_port);
 								WWORD(Pkt->dest_unit, dest_unit);
 								WWORD(Pkt->dest_port, dest_port);
 							}
-							rio_dprintk (RIO_DEBUG_TABLE, 
-						"Port %d phb destination: Old %x:%x New %x:%x\n",
-							 port, PortP->PhbP->destination & 0xff,
-							 (PortP->PhbP->destination >> 8) & 0xff,
-							 dest_unit, dest_port);
-							WWORD(PortP->PhbP->destination,
-							 dest_unit + (dest_port << 8));
+							rio_dprintk(RIO_DEBUG_TABLE, "Port %d phb destination: Old %x:%x New %x:%x\n", port, PortP->PhbP->destination & 0xff, (PortP->PhbP->destination >> 8) & 0xff, dest_unit, dest_port);
+							WWORD(PortP->PhbP->destination, dest_unit + (dest_port << 8));
 						}
 						rio_spin_unlock_irqrestore(&PortP->portSem, sem_flags);
 					}
 				}
-				rio_dprintk (RIO_DEBUG_TABLE, "Entry nulled.\n");
-				bzero((char *)HostMapP,sizeof(struct Map));
+				rio_dprintk(RIO_DEBUG_TABLE, "Entry nulled.\n");
+				bzero((char *) HostMapP, sizeof(struct Map));
 				work_done++;
 			}
 		}
@@ -613,203 +574,178 @@
 	}
 
 	/* XXXXX lock me up */
-	for ( entry=0; entry< TOTAL_MAP_ENTRIES; entry++ ) {
-		if ( p->RIOSavedTable[entry].RtaUniqueNum == MapP->RtaUniqueNum ) {
-			bzero((char *)&p->RIOSavedTable[entry],sizeof(struct Map));
+	for (entry = 0; entry < TOTAL_MAP_ENTRIES; entry++) {
+		if (p->RIOSavedTable[entry].RtaUniqueNum == MapP->RtaUniqueNum) {
+			bzero((char *) &p->RIOSavedTable[entry], sizeof(struct Map));
 			work_done++;
 		}
-		if ( p->RIOConnectTable[entry].RtaUniqueNum == MapP->RtaUniqueNum ) {
-			bzero((char *)&p->RIOConnectTable[entry],sizeof(struct Map));
+		if (p->RIOConnectTable[entry].RtaUniqueNum == MapP->RtaUniqueNum) {
+			bzero((char *) &p->RIOConnectTable[entry], sizeof(struct Map));
 			work_done++;
 		}
 	}
-	if ( work_done )
+	if (work_done)
 		return 0;
 
-	rio_dprintk (RIO_DEBUG_TABLE, "Couldn't find entry to be deleted\n");
+	rio_dprintk(RIO_DEBUG_TABLE, "Couldn't find entry to be deleted\n");
 	p->RIOError.Error = COULDNT_FIND_ENTRY;
 	return -ENXIO;
 }
 
-int RIOAssignRta( struct rio_info *p, struct Map *MapP )
+int RIOAssignRta(struct rio_info *p, struct Map *MapP)
 {
-    int host;
-    struct Map *HostMapP;
-    char *sptr;
-    int	link;
+	int host;
+	struct Map *HostMapP;
+	char *sptr;
+	int link;
 
 
-    rio_dprintk (RIO_DEBUG_TABLE, "Assign entry on host %x, rta %x, ID %d, Sysport %d\n",
-				MapP->HostUniqueNum,MapP->RtaUniqueNum,
-				MapP->ID, (int)MapP->SysPort);
+	rio_dprintk(RIO_DEBUG_TABLE, "Assign entry on host %x, rta %x, ID %d, Sysport %d\n", MapP->HostUniqueNum, MapP->RtaUniqueNum, MapP->ID, (int) MapP->SysPort);
 
-    if ((MapP->ID != (ushort)-1) &&
-	((int)MapP->ID < (int)1 || (int)MapP->ID > MAX_RUP ))
-    {
-	rio_dprintk (RIO_DEBUG_TABLE, "Bad ID in map entry!\n");
-	p->RIOError.Error = ID_NUMBER_OUT_OF_RANGE;
-	return -EINVAL;
-    }
-    if (MapP->RtaUniqueNum == 0)
-    {
-	rio_dprintk (RIO_DEBUG_TABLE, "Rta Unique number zero!\n");
-	p->RIOError.Error = RTA_UNIQUE_NUMBER_ZERO;
-	return -EINVAL;
-    }
-    if ( (MapP->SysPort != NO_PORT) && (MapP->SysPort % PORTS_PER_RTA) )
-    {
-	rio_dprintk (RIO_DEBUG_TABLE, "Port %d not multiple of %d!\n",(int)MapP->SysPort,PORTS_PER_RTA);
-	p->RIOError.Error = TTY_NUMBER_OUT_OF_RANGE;
-	return -EINVAL;
-    }
-    if ( (MapP->SysPort != NO_PORT) && (MapP->SysPort >= RIO_PORTS) )
-    {
-	rio_dprintk (RIO_DEBUG_TABLE, "Port %d not valid!\n",(int)MapP->SysPort);
-	p->RIOError.Error = TTY_NUMBER_OUT_OF_RANGE;
-	return -EINVAL;
-    }
-
-    /*
-    ** Copy the name across to the map entry.
-    */
-    MapP->Name[MAX_NAME_LEN-1] = '\0';
-    sptr = MapP->Name;
-    while ( *sptr )
-    {
-    if ( *sptr<' ' || *sptr>'~' )
-    {
-	rio_dprintk (RIO_DEBUG_TABLE, "Name entry contains non-printing characters!\n");
-	p->RIOError.Error = BAD_CHARACTER_IN_NAME;
-	return -EINVAL;
-    }
-    sptr++;
-    }
-
-    for ( host=0; host < p->RIONumHosts; host++ )
-    {
-	if ( MapP->HostUniqueNum == p->RIOHosts[host].UniqueNum )
-	{
-	    if ( (p->RIOHosts[host].Flags & RUN_STATE) != RC_RUNNING )
-	    {
-		p->RIOError.Error = HOST_NOT_RUNNING;
-		return -ENXIO;
-	    }
-
-	    /*
-	    ** Now we have a host we need to allocate an ID
-	    ** if the entry does not already have one.
-	    */
-	    if (MapP->ID == (ushort)-1)
-	    {
-		int nNewID;
-
-		rio_dprintk (RIO_DEBUG_TABLE, "Attempting to get a new ID for rta \"%s\"\n",
-		      MapP->Name);
-		/*
-		** The idea here is to allow RTA's to be assigned
-		** before they actually appear on the network.
-		** This allows the addition of RTA's without having
-		** to plug them in.
-		** What we do is:
-		**  - Find a free ID and allocate it to the RTA.
-		**  - If this map entry is the second half of a
-		**    16 port entry then find the other half and
-		**    make sure the 2 cross reference each other.
-		*/
-		if (RIOFindFreeID(p, &p->RIOHosts[host], &nNewID, NULL) != 0)
-		{
-		    p->RIOError.Error = COULDNT_FIND_ENTRY;
-		    return -EBUSY;
-		}
-		MapP->ID = (ushort)nNewID + 1;
-		rio_dprintk (RIO_DEBUG_TABLE, "Allocated ID %d for this new RTA.\n", MapP->ID);
-		HostMapP = &p->RIOHosts[host].Mapping[nNewID];
-		HostMapP->RtaUniqueNum = MapP->RtaUniqueNum;
-		HostMapP->HostUniqueNum = MapP->HostUniqueNum;
-		HostMapP->ID = MapP->ID;
-		for (link = 0; link < LINKS_PER_UNIT; link++)
-		{
-		    HostMapP->Topology[link].Unit = ROUTE_DISCONNECT;
-		    HostMapP->Topology[link].Link = NO_LINK;
-		}
-		if (MapP->Flags & RTA16_SECOND_SLOT)
-		{
-		    int unit;
-
-		    for (unit = 0; unit < MAX_RUP; unit++)
-			if (p->RIOHosts[host].Mapping[unit].RtaUniqueNum ==
-			    MapP->RtaUniqueNum)
-			    break;
-		    if (unit == MAX_RUP)
-		    {
-			p->RIOError.Error = COULDNT_FIND_ENTRY;
-			return -EBUSY;
-		    }
-		    HostMapP->Flags |= RTA16_SECOND_SLOT;
-		    HostMapP->ID2 = MapP->ID2 = p->RIOHosts[host].Mapping[unit].ID;
-		    p->RIOHosts[host].Mapping[unit].ID2 = MapP->ID;
-		    rio_dprintk (RIO_DEBUG_TABLE, "Cross referenced id %d to ID %d.\n",
-			  MapP->ID,
-			  p->RIOHosts[host].Mapping[unit].ID);
-		}
-	    }
-
-	    HostMapP = &p->RIOHosts[host].Mapping[MapP->ID-1];
-
-	    if ( HostMapP->Flags & SLOT_IN_USE )
-	    {
-		rio_dprintk (RIO_DEBUG_TABLE, "Map table slot for ID %d is already in use.\n", MapP->ID);
-		p->RIOError.Error = ID_ALREADY_IN_USE;
-		return -EBUSY;
-	    }
-
-	    /*
-	    ** Assign the sys ports and the name, and mark the slot as
-	    ** being in use.
-	    */
-	    HostMapP->SysPort = MapP->SysPort;
-	    if ((MapP->Flags & RTA16_SECOND_SLOT) == 0)
-	      CCOPY( MapP->Name, HostMapP->Name, MAX_NAME_LEN );
-	    HostMapP->Flags = SLOT_IN_USE | RTA_BOOTED;
-#ifdef NEED_TO_FIX
-	    RIO_SV_BROADCAST(p->RIOHosts[host].svFlags[MapP->ID-1]);
-#endif
-	    if (MapP->Flags & RTA16_SECOND_SLOT)
-		HostMapP->Flags |= RTA16_SECOND_SLOT;
-
-	    RIOReMapPorts( p, &p->RIOHosts[host], HostMapP );
-	    /*
-	    ** Adjust 2nd block of 8 phbs
-	    */
-	    if (MapP->Flags & RTA16_SECOND_SLOT)
-		RIOFixPhbs(p, &p->RIOHosts[host], HostMapP->ID - 1);
-
-	    if ( HostMapP->SysPort != NO_PORT )
-	    {
-		if ( HostMapP->SysPort < p->RIOFirstPortsBooted )
-		    p->RIOFirstPortsBooted = HostMapP->SysPort;
-		if ( HostMapP->SysPort > p->RIOLastPortsBooted )
-		    p->RIOLastPortsBooted = HostMapP->SysPort;
-	    }
-	    if (MapP->Flags & RTA16_SECOND_SLOT)
-	        rio_dprintk (RIO_DEBUG_TABLE, "Second map of RTA %s added to configuration\n",
-		 p->RIOHosts[host].Mapping[MapP->ID2 - 1].Name);
-	    else
-	        rio_dprintk (RIO_DEBUG_TABLE, "RTA %s added to configuration\n", MapP->Name);
-	    return 0;
+	if ((MapP->ID != (ushort) - 1) && ((int) MapP->ID < (int) 1 || (int) MapP->ID > MAX_RUP)) {
+		rio_dprintk(RIO_DEBUG_TABLE, "Bad ID in map entry!\n");
+		p->RIOError.Error = ID_NUMBER_OUT_OF_RANGE;
+		return -EINVAL;
 	}
-    }
-    p->RIOError.Error = UNKNOWN_HOST_NUMBER;
-    rio_dprintk (RIO_DEBUG_TABLE, "Unknown host %x\n", MapP->HostUniqueNum);
-    return -ENXIO;
+	if (MapP->RtaUniqueNum == 0) {
+		rio_dprintk(RIO_DEBUG_TABLE, "Rta Unique number zero!\n");
+		p->RIOError.Error = RTA_UNIQUE_NUMBER_ZERO;
+		return -EINVAL;
+	}
+	if ((MapP->SysPort != NO_PORT) && (MapP->SysPort % PORTS_PER_RTA)) {
+		rio_dprintk(RIO_DEBUG_TABLE, "Port %d not multiple of %d!\n", (int) MapP->SysPort, PORTS_PER_RTA);
+		p->RIOError.Error = TTY_NUMBER_OUT_OF_RANGE;
+		return -EINVAL;
+	}
+	if ((MapP->SysPort != NO_PORT) && (MapP->SysPort >= RIO_PORTS)) {
+		rio_dprintk(RIO_DEBUG_TABLE, "Port %d not valid!\n", (int) MapP->SysPort);
+		p->RIOError.Error = TTY_NUMBER_OUT_OF_RANGE;
+		return -EINVAL;
+	}
+
+	/*
+	 ** Copy the name across to the map entry.
+	 */
+	MapP->Name[MAX_NAME_LEN - 1] = '\0';
+	sptr = MapP->Name;
+	while (*sptr) {
+		if (*sptr < ' ' || *sptr > '~') {
+			rio_dprintk(RIO_DEBUG_TABLE, "Name entry contains non-printing characters!\n");
+			p->RIOError.Error = BAD_CHARACTER_IN_NAME;
+			return -EINVAL;
+		}
+		sptr++;
+	}
+
+	for (host = 0; host < p->RIONumHosts; host++) {
+		if (MapP->HostUniqueNum == p->RIOHosts[host].UniqueNum) {
+			if ((p->RIOHosts[host].Flags & RUN_STATE) != RC_RUNNING) {
+				p->RIOError.Error = HOST_NOT_RUNNING;
+				return -ENXIO;
+			}
+
+			/*
+			 ** Now we have a host we need to allocate an ID
+			 ** if the entry does not already have one.
+			 */
+			if (MapP->ID == (ushort) - 1) {
+				int nNewID;
+
+				rio_dprintk(RIO_DEBUG_TABLE, "Attempting to get a new ID for rta \"%s\"\n", MapP->Name);
+				/*
+				 ** The idea here is to allow RTA's to be assigned
+				 ** before they actually appear on the network.
+				 ** This allows the addition of RTA's without having
+				 ** to plug them in.
+				 ** What we do is:
+				 **  - Find a free ID and allocate it to the RTA.
+				 **  - If this map entry is the second half of a
+				 **    16 port entry then find the other half and
+				 **    make sure the 2 cross reference each other.
+				 */
+				if (RIOFindFreeID(p, &p->RIOHosts[host], &nNewID, NULL) != 0) {
+					p->RIOError.Error = COULDNT_FIND_ENTRY;
+					return -EBUSY;
+				}
+				MapP->ID = (ushort) nNewID + 1;
+				rio_dprintk(RIO_DEBUG_TABLE, "Allocated ID %d for this new RTA.\n", MapP->ID);
+				HostMapP = &p->RIOHosts[host].Mapping[nNewID];
+				HostMapP->RtaUniqueNum = MapP->RtaUniqueNum;
+				HostMapP->HostUniqueNum = MapP->HostUniqueNum;
+				HostMapP->ID = MapP->ID;
+				for (link = 0; link < LINKS_PER_UNIT; link++) {
+					HostMapP->Topology[link].Unit = ROUTE_DISCONNECT;
+					HostMapP->Topology[link].Link = NO_LINK;
+				}
+				if (MapP->Flags & RTA16_SECOND_SLOT) {
+					int unit;
+
+					for (unit = 0; unit < MAX_RUP; unit++)
+						if (p->RIOHosts[host].Mapping[unit].RtaUniqueNum == MapP->RtaUniqueNum)
+							break;
+					if (unit == MAX_RUP) {
+						p->RIOError.Error = COULDNT_FIND_ENTRY;
+						return -EBUSY;
+					}
+					HostMapP->Flags |= RTA16_SECOND_SLOT;
+					HostMapP->ID2 = MapP->ID2 = p->RIOHosts[host].Mapping[unit].ID;
+					p->RIOHosts[host].Mapping[unit].ID2 = MapP->ID;
+					rio_dprintk(RIO_DEBUG_TABLE, "Cross referenced id %d to ID %d.\n", MapP->ID, p->RIOHosts[host].Mapping[unit].ID);
+				}
+			}
+
+			HostMapP = &p->RIOHosts[host].Mapping[MapP->ID - 1];
+
+			if (HostMapP->Flags & SLOT_IN_USE) {
+				rio_dprintk(RIO_DEBUG_TABLE, "Map table slot for ID %d is already in use.\n", MapP->ID);
+				p->RIOError.Error = ID_ALREADY_IN_USE;
+				return -EBUSY;
+			}
+
+			/*
+			 ** Assign the sys ports and the name, and mark the slot as
+			 ** being in use.
+			 */
+			HostMapP->SysPort = MapP->SysPort;
+			if ((MapP->Flags & RTA16_SECOND_SLOT) == 0)
+				CCOPY(MapP->Name, HostMapP->Name, MAX_NAME_LEN);
+			HostMapP->Flags = SLOT_IN_USE | RTA_BOOTED;
+#ifdef NEED_TO_FIX
+			RIO_SV_BROADCAST(p->RIOHosts[host].svFlags[MapP->ID - 1]);
+#endif
+			if (MapP->Flags & RTA16_SECOND_SLOT)
+				HostMapP->Flags |= RTA16_SECOND_SLOT;
+
+			RIOReMapPorts(p, &p->RIOHosts[host], HostMapP);
+			/*
+			 ** Adjust 2nd block of 8 phbs
+			 */
+			if (MapP->Flags & RTA16_SECOND_SLOT)
+				RIOFixPhbs(p, &p->RIOHosts[host], HostMapP->ID - 1);
+
+			if (HostMapP->SysPort != NO_PORT) {
+				if (HostMapP->SysPort < p->RIOFirstPortsBooted)
+					p->RIOFirstPortsBooted = HostMapP->SysPort;
+				if (HostMapP->SysPort > p->RIOLastPortsBooted)
+					p->RIOLastPortsBooted = HostMapP->SysPort;
+			}
+			if (MapP->Flags & RTA16_SECOND_SLOT)
+				rio_dprintk(RIO_DEBUG_TABLE, "Second map of RTA %s added to configuration\n", p->RIOHosts[host].Mapping[MapP->ID2 - 1].Name);
+			else
+				rio_dprintk(RIO_DEBUG_TABLE, "RTA %s added to configuration\n", MapP->Name);
+			return 0;
+		}
+	}
+	p->RIOError.Error = UNKNOWN_HOST_NUMBER;
+	rio_dprintk(RIO_DEBUG_TABLE, "Unknown host %x\n", MapP->HostUniqueNum);
+	return -ENXIO;
 }
 
 
-int
-RIOReMapPorts(p, HostP, HostMapP)
-struct rio_info *	p;
+int RIOReMapPorts(p, HostP, HostMapP)
+struct rio_info *p;
 struct Host *HostP;
-struct Map *HostMapP; 
+struct Map *HostMapP;
 {
 	register struct Port *PortP;
 	uint SubEnt;
@@ -819,135 +755,127 @@
 	unsigned long flags;
 
 #ifdef CHECK
-	CheckHostP( HostP );
-	CheckHostMapP( HostMapP );
+	CheckHostP(HostP);
+	CheckHostMapP(HostMapP);
 #endif
 
-	rio_dprintk (RIO_DEBUG_TABLE, "Mapping sysport %d to id %d\n", (int)HostMapP->SysPort, HostMapP->ID);
+	rio_dprintk(RIO_DEBUG_TABLE, "Mapping sysport %d to id %d\n", (int) HostMapP->SysPort, HostMapP->ID);
 
 	/*
-	** We need to tell the UnixRups which sysport the rup corresponds to
-	*/
-	HostP->UnixRups[HostMapP->ID-1].BaseSysPort = HostMapP->SysPort;
+	 ** We need to tell the UnixRups which sysport the rup corresponds to
+	 */
+	HostP->UnixRups[HostMapP->ID - 1].BaseSysPort = HostMapP->SysPort;
 
-	if ( HostMapP->SysPort == NO_PORT )
-		return(0);
+	if (HostMapP->SysPort == NO_PORT)
+		return (0);
 
 	RtaType = GetUnitType(HostMapP->RtaUniqueNum);
-	rio_dprintk (RIO_DEBUG_TABLE, "Mapping sysport %d-%d\n",
-				(int)HostMapP->SysPort, (int)HostMapP->SysPort+PORTS_PER_RTA-1);
+	rio_dprintk(RIO_DEBUG_TABLE, "Mapping sysport %d-%d\n", (int) HostMapP->SysPort, (int) HostMapP->SysPort + PORTS_PER_RTA - 1);
 
 	/*
-	** now map each of its eight ports
-	*/
-	for ( SubEnt=0; SubEnt<PORTS_PER_RTA; SubEnt++) {
-	  rio_dprintk (RIO_DEBUG_TABLE, "subent = %d, HostMapP->SysPort = %d\n", 
-		  SubEnt, (int)HostMapP->SysPort);
-		SysPort = HostMapP->SysPort+SubEnt;		/* portnumber within system */
-					/* portnumber on host */
-		
-		HostPort = (HostMapP->ID-1)*PORTS_PER_RTA+SubEnt; 
+	 ** now map each of its eight ports
+	 */
+	for (SubEnt = 0; SubEnt < PORTS_PER_RTA; SubEnt++) {
+		rio_dprintk(RIO_DEBUG_TABLE, "subent = %d, HostMapP->SysPort = %d\n", SubEnt, (int) HostMapP->SysPort);
+		SysPort = HostMapP->SysPort + SubEnt;	/* portnumber within system */
+		/* portnumber on host */
 
-		rio_dprintk (RIO_DEBUG_TABLE, "c1 p = %p, p->rioPortp = %p\n", p, p->RIOPortp);
+		HostPort = (HostMapP->ID - 1) * PORTS_PER_RTA + SubEnt;
+
+		rio_dprintk(RIO_DEBUG_TABLE, "c1 p = %p, p->rioPortp = %p\n", p, p->RIOPortp);
 		PortP = p->RIOPortp[SysPort];
 #if 0
-		PortP->TtyP	= &p->channel[SysPort];
+		PortP->TtyP = &p->channel[SysPort];
 #endif
-		rio_dprintk (RIO_DEBUG_TABLE, "Map port\n");
+		rio_dprintk(RIO_DEBUG_TABLE, "Map port\n");
 
 		/*
-		** Point at all the real neat data structures
-		*/
+		 ** Point at all the real neat data structures
+		 */
 		rio_spin_lock_irqsave(&PortP->portSem, flags);
 		PortP->HostP = HostP;
 		PortP->Caddr = HostP->Caddr;
 
 		/*
-		** The PhbP cannot be filled in yet
-		** unless the host has been booted
-		*/
+		 ** The PhbP cannot be filled in yet
+		 ** unless the host has been booted
+		 */
 		if ((HostP->Flags & RUN_STATE) == RC_RUNNING) {
 			struct PHB *PhbP = PortP->PhbP = &HostP->PhbP[HostPort];
-			PortP->TxAdd =(WORD *)RIO_PTR(HostP->Caddr,RWORD(PhbP->tx_add));
-			PortP->TxStart =(WORD *)RIO_PTR(HostP->Caddr,RWORD(PhbP->tx_start));
-			PortP->TxEnd =(WORD *)RIO_PTR(HostP->Caddr,RWORD(PhbP->tx_end));
-			PortP->RxRemove=(WORD *)RIO_PTR(HostP->Caddr,
-									RWORD(PhbP->rx_remove));
-			PortP->RxStart =(WORD *)RIO_PTR(HostP->Caddr,RWORD(PhbP->rx_start));
-			PortP->RxEnd =(WORD *)RIO_PTR(HostP->Caddr,RWORD(PhbP->rx_end));
-		}
-		else
+			PortP->TxAdd = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->tx_add));
+			PortP->TxStart = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->tx_start));
+			PortP->TxEnd = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->tx_end));
+			PortP->RxRemove = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->rx_remove));
+			PortP->RxStart = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->rx_start));
+			PortP->RxEnd = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->rx_end));
+		} else
 			PortP->PhbP = NULL;
 
 		/*
-		** port related flags
-		*/
-		PortP->HostPort	= HostPort;
+		 ** port related flags
+		 */
+		PortP->HostPort = HostPort;
 		/*
-		** For each part of a 16 port RTA, RupNum is ID - 1.
-		*/
+		 ** For each part of a 16 port RTA, RupNum is ID - 1.
+		 */
 		PortP->RupNum = HostMapP->ID - 1;
 		if (HostMapP->Flags & RTA16_SECOND_SLOT) {
-			PortP->ID2			 = HostMapP->ID2 - 1;
-			PortP->SecondBlock	 = TRUE;
-		}
-		else {
-			PortP->ID2			 = 0;
-			PortP->SecondBlock	 = FALSE;
-		}
-		PortP->RtaUniqueNum	= HostMapP->RtaUniqueNum;
-
-		/*
-		** If the port was already mapped then thats all we need to do.
-		*/
-		if (PortP->Mapped) {
-			rio_spin_unlock_irqrestore( &PortP->portSem, flags);
-			continue;
-		}
-		else HostMapP->Flags &= ~RTA_NEWBOOT;
-
-		PortP->State		 = 0;
-		PortP->Config		= 0;
-		/*
-		** Check out the module type - if it is special (read only etc.)
-		** then we need to set flags in the PortP->Config.
-		** Note: For 16 port RTA, all ports are of the same type.
-		*/
-		if (RtaType == TYPE_RTA16) {
-			PortP->Config |= p->RIOModuleTypes[HostP->UnixRups
-				[HostMapP->ID-1].ModTypes].Flags[SubEnt % PORTS_PER_MODULE];
+			PortP->ID2 = HostMapP->ID2 - 1;
+			PortP->SecondBlock = TRUE;
 		} else {
-			if ( SubEnt < PORTS_PER_MODULE )
-				PortP->Config |= p->RIOModuleTypes[LONYBLE(HostP->UnixRups
-				[HostMapP->ID-1].ModTypes)].Flags[SubEnt % PORTS_PER_MODULE];
+			PortP->ID2 = 0;
+			PortP->SecondBlock = FALSE;
+		}
+		PortP->RtaUniqueNum = HostMapP->RtaUniqueNum;
+
+		/*
+		 ** If the port was already mapped then thats all we need to do.
+		 */
+		if (PortP->Mapped) {
+			rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+			continue;
+		} else
+			HostMapP->Flags &= ~RTA_NEWBOOT;
+
+		PortP->State = 0;
+		PortP->Config = 0;
+		/*
+		 ** Check out the module type - if it is special (read only etc.)
+		 ** then we need to set flags in the PortP->Config.
+		 ** Note: For 16 port RTA, all ports are of the same type.
+		 */
+		if (RtaType == TYPE_RTA16) {
+			PortP->Config |= p->RIOModuleTypes[HostP->UnixRups[HostMapP->ID - 1].ModTypes].Flags[SubEnt % PORTS_PER_MODULE];
+		} else {
+			if (SubEnt < PORTS_PER_MODULE)
+				PortP->Config |= p->RIOModuleTypes[LONYBLE(HostP->UnixRups[HostMapP->ID - 1].ModTypes)].Flags[SubEnt % PORTS_PER_MODULE];
 			else
-				PortP->Config |= p->RIOModuleTypes[HINYBLE(HostP->UnixRups
-				[HostMapP->ID-1].ModTypes)].Flags[SubEnt % PORTS_PER_MODULE];
+				PortP->Config |= p->RIOModuleTypes[HINYBLE(HostP->UnixRups[HostMapP->ID - 1].ModTypes)].Flags[SubEnt % PORTS_PER_MODULE];
 		}
 
 		/*
-		** more port related flags
-		*/
-		PortP->PortState	= 0;
-		PortP->ModemLines	= 0;
-		PortP->ModemState	= 0;
-		PortP->CookMode		= COOK_WELL;
-		PortP->ParamSem		= 0;
-		PortP->FlushCmdBodge= 0;
-		PortP->WflushFlag	= 0;
-		PortP->MagicFlags	= 0;
-		PortP->Lock			= 0;
-		PortP->Store		= 0;
-		PortP->FirstOpen	= 1;
+		 ** more port related flags
+		 */
+		PortP->PortState = 0;
+		PortP->ModemLines = 0;
+		PortP->ModemState = 0;
+		PortP->CookMode = COOK_WELL;
+		PortP->ParamSem = 0;
+		PortP->FlushCmdBodge = 0;
+		PortP->WflushFlag = 0;
+		PortP->MagicFlags = 0;
+		PortP->Lock = 0;
+		PortP->Store = 0;
+		PortP->FirstOpen = 1;
 
 		/*
-		** Buffers 'n things
-		*/
-		PortP->RxDataStart	= 0;
-		PortP->Cor2Copy	 = 0;
-		PortP->Name		 = &HostMapP->Name[0];
+		 ** Buffers 'n things
+		 */
+		PortP->RxDataStart = 0;
+		PortP->Cor2Copy = 0;
+		PortP->Name = &HostMapP->Name[0];
 #ifdef STATS
-		bzero( (caddr_t)&PortP->Stat, sizeof(struct RIOStats) );
+		bzero((caddr_t) & PortP->Stat, sizeof(struct RIOStats));
 #endif
 		PortP->statsGather = 0;
 		PortP->txchars = 0;
@@ -955,90 +883,87 @@
 		PortP->opens = 0;
 		PortP->closes = 0;
 		PortP->ioctls = 0;
-		if ( PortP->TxRingBuffer )
-			bzero( PortP->TxRingBuffer, p->RIOBufferSize );
-		else if ( p->RIOBufferSize ) {
+		if (PortP->TxRingBuffer)
+			bzero(PortP->TxRingBuffer, p->RIOBufferSize);
+		else if (p->RIOBufferSize) {
 			PortP->TxRingBuffer = sysbrk(p->RIOBufferSize);
-			bzero( PortP->TxRingBuffer, p->RIOBufferSize );
+			bzero(PortP->TxRingBuffer, p->RIOBufferSize);
 		}
-		PortP->TxBufferOut	= 0;
-		PortP->TxBufferIn	 = 0;
-		PortP->Debug		= 0;
+		PortP->TxBufferOut = 0;
+		PortP->TxBufferIn = 0;
+		PortP->Debug = 0;
 		/*
-		** LastRxTgl stores the state of the rx toggle bit for this
-		** port, to be compared with the state of the next pkt received.
-		** If the same, we have received the same rx pkt from the RTA
-		** twice. Initialise to a value not equal to PHB_RX_TGL or 0.
-		*/
-		PortP->LastRxTgl	= ~(uchar)PHB_RX_TGL;
+		 ** LastRxTgl stores the state of the rx toggle bit for this
+		 ** port, to be compared with the state of the next pkt received.
+		 ** If the same, we have received the same rx pkt from the RTA
+		 ** twice. Initialise to a value not equal to PHB_RX_TGL or 0.
+		 */
+		PortP->LastRxTgl = ~(uchar) PHB_RX_TGL;
 
 		/*
-		** and mark the port as usable
-		*/
+		 ** and mark the port as usable
+		 */
 		PortP->Mapped = 1;
 		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
 	}
-	if ( HostMapP->SysPort < p->RIOFirstPortsMapped )
+	if (HostMapP->SysPort < p->RIOFirstPortsMapped)
 		p->RIOFirstPortsMapped = HostMapP->SysPort;
-	if ( HostMapP->SysPort > p->RIOLastPortsMapped )
+	if (HostMapP->SysPort > p->RIOLastPortsMapped)
 		p->RIOLastPortsMapped = HostMapP->SysPort;
 
 	return 0;
 }
 
-int
-RIOChangeName(p, MapP)
+int RIOChangeName(p, MapP)
 struct rio_info *p;
-struct Map* MapP; 
+struct Map *MapP;
 {
 	int host;
 	struct Map *HostMapP;
 	char *sptr;
 
-	rio_dprintk (RIO_DEBUG_TABLE, "Change name entry on host %x, rta %x, ID %d, Sysport %d\n",
-								MapP->HostUniqueNum,MapP->RtaUniqueNum,
-								MapP->ID, (int)MapP->SysPort);
+	rio_dprintk(RIO_DEBUG_TABLE, "Change name entry on host %x, rta %x, ID %d, Sysport %d\n", MapP->HostUniqueNum, MapP->RtaUniqueNum, MapP->ID, (int) MapP->SysPort);
 
-	if ( MapP->ID > MAX_RUP ) {
-		rio_dprintk (RIO_DEBUG_TABLE, "Bad ID in map entry!\n");
+	if (MapP->ID > MAX_RUP) {
+		rio_dprintk(RIO_DEBUG_TABLE, "Bad ID in map entry!\n");
 		p->RIOError.Error = ID_NUMBER_OUT_OF_RANGE;
 		return -EINVAL;
 	}
 
-	MapP->Name[MAX_NAME_LEN-1] = '\0';
+	MapP->Name[MAX_NAME_LEN - 1] = '\0';
 	sptr = MapP->Name;
 
-	while ( *sptr ) {
-		if ( *sptr<' ' || *sptr>'~' ) {
-			rio_dprintk (RIO_DEBUG_TABLE, "Name entry contains non-printing characters!\n");
+	while (*sptr) {
+		if (*sptr < ' ' || *sptr > '~') {
+			rio_dprintk(RIO_DEBUG_TABLE, "Name entry contains non-printing characters!\n");
 			p->RIOError.Error = BAD_CHARACTER_IN_NAME;
 			return -EINVAL;
 		}
 		sptr++;
 	}
 
-	for ( host=0; host < p->RIONumHosts; host++ ) {
-		if ( MapP->HostUniqueNum == p->RIOHosts[host].UniqueNum ) {
-			if ( (p->RIOHosts[host].Flags & RUN_STATE) != RC_RUNNING ) {
+	for (host = 0; host < p->RIONumHosts; host++) {
+		if (MapP->HostUniqueNum == p->RIOHosts[host].UniqueNum) {
+			if ((p->RIOHosts[host].Flags & RUN_STATE) != RC_RUNNING) {
 				p->RIOError.Error = HOST_NOT_RUNNING;
 				return -ENXIO;
 			}
-			if ( MapP->ID==0 ) {
-				CCOPY( MapP->Name, p->RIOHosts[host].Name, MAX_NAME_LEN );
+			if (MapP->ID == 0) {
+				CCOPY(MapP->Name, p->RIOHosts[host].Name, MAX_NAME_LEN);
 				return 0;
 			}
 
-			HostMapP = &p->RIOHosts[host].Mapping[MapP->ID-1];
+			HostMapP = &p->RIOHosts[host].Mapping[MapP->ID - 1];
 
-			if ( HostMapP->RtaUniqueNum != MapP->RtaUniqueNum ) {
+			if (HostMapP->RtaUniqueNum != MapP->RtaUniqueNum) {
 				p->RIOError.Error = RTA_NUMBER_WRONG;
 				return -ENXIO;
 			}
-			CCOPY( MapP->Name, HostMapP->Name, MAX_NAME_LEN );
+			CCOPY(MapP->Name, HostMapP->Name, MAX_NAME_LEN);
 			return 0;
 		}
 	}
 	p->RIOError.Error = UNKNOWN_HOST_NUMBER;
-	rio_dprintk (RIO_DEBUG_TABLE, "Unknown host %x\n", MapP->HostUniqueNum);
+	rio_dprintk(RIO_DEBUG_TABLE, "Unknown host %x\n", MapP->HostUniqueNum);
 	return -ENXIO;
 }
diff --git a/drivers/char/rio/riotime.h b/drivers/char/rio/riotime.h
index 66d52bc..35e01cd 100644
--- a/drivers/char/rio/riotime.h
+++ b/drivers/char/rio/riotime.h
@@ -40,7 +40,7 @@
 
 #ifndef lint
 #ifdef SCCS
-static char *_rio_riotime_h_sccs = "@(#)riotime.h	1.1" ;
+static char *_rio_riotime_h_sccs = "@(#)riotime.h	1.1";
 #endif
 #endif
 
@@ -52,7 +52,7 @@
 /**************************************
  * Convert a RIO tick (1/10th second)
  * into transputer low priority ticks
- *************************************/ 
+ *************************************/
 #define RioTimeToLow(time) (time*(100000 / 64))
 #define RioLowToTime(time) ((time*64)/100000)
 
diff --git a/drivers/char/rio/riotty.c b/drivers/char/rio/riotty.c
index 78a321a..5894a25 100644
--- a/drivers/char/rio/riotty.c
+++ b/drivers/char/rio/riotty.c
@@ -90,21 +90,19 @@
 #include "sam.h"
 
 #if 0
-static void ttyseth_pv(struct Port *, struct ttystatics *, 
-				struct termios *sg, int);
+static void ttyseth_pv(struct Port *, struct ttystatics *, struct termios *sg, int);
 #endif
 
 static void RIOClearUp(struct Port *PortP);
-int RIOShortCommand(struct rio_info *p, struct Port *PortP, 
-			   int command, int len, int arg);
+int RIOShortCommand(struct rio_info *p, struct Port *PortP, int command, int len, int arg);
 
 #if 0
 static int RIOCookMode(struct ttystatics *);
 #endif
 
-extern int	conv_vb[];	/* now defined in ttymgr.c */
-extern int	conv_bv[];	/* now defined in ttymgr.c */
- 
+extern int conv_vb[];		/* now defined in ttymgr.c */
+extern int conv_bv[];		/* now defined in ttymgr.c */
+
 /*
 ** 16.09.1998 ARG - Fix to build riotty.k.o for Modular Kernel Support
 **
@@ -117,27 +115,25 @@
 #endif
 
 #ifdef NEED_THIS2
-static struct old_sgttyb 
-default_sg = 
-{ 
-	B19200, B19200,				/* input and output speed */ 
-	'H' - '@',					/* erase char */ 
-	-1,							/* 2nd erase char */ 
-	'U' - '@',					/* kill char */ 
-	ECHO | CRMOD,				/* mode */ 
-	'C' - '@',					/* interrupt character */ 
-	'\\' - '@',					/* quit char */ 
-	'Q' - '@',					/* start char */
-	'S' - '@',					/* stop char */ 
-	'D' - '@',					/* EOF */
-	-1,							/* brk */
-	(LCRTBS | LCRTERA | LCRTKIL | LCTLECH),	/* local mode word */ 
-	'Z' - '@',					/* process stop */
-	'Y' - '@',					/* delayed stop */
-	'R' - '@',					/* reprint line */ 
-	'O' - '@',					/* flush output */
-	'W' - '@',					/* word erase */
-	'V' - '@'					/* literal next char */
+static struct old_sgttyb default_sg = {
+	B19200, B19200,		/* input and output speed */
+	'H' - '@',		/* erase char */
+	-1,			/* 2nd erase char */
+	'U' - '@',		/* kill char */
+	ECHO | CRMOD,		/* mode */
+	'C' - '@',		/* interrupt character */
+	'\\' - '@',		/* quit char */
+	'Q' - '@',		/* start char */
+	'S' - '@',		/* stop char */
+	'D' - '@',		/* EOF */
+	-1,			/* brk */
+	(LCRTBS | LCRTERA | LCRTKIL | LCTLECH),	/* local mode word */
+	'Z' - '@',		/* process stop */
+	'Y' - '@',		/* delayed stop */
+	'R' - '@',		/* reprint line */
+	'O' - '@',		/* flush output */
+	'W' - '@',		/* word erase */
+	'V' - '@'		/* literal next char */
 };
 #endif
 
@@ -145,62 +141,59 @@
 extern struct rio_info *p;
 
 
-int
-riotopen(struct tty_struct * tty, struct file * filp)
+int riotopen(struct tty_struct *tty, struct file *filp)
 {
 	register uint SysPort;
 	int Modem;
 	int repeat_this = 250;
-	struct Port *PortP;		 /* pointer to the port structure */
+	struct Port *PortP;	/* pointer to the port structure */
 	unsigned long flags;
 	int retval = 0;
 
-	func_enter ();
+	func_enter();
 
 	/* Make sure driver_data is NULL in case the rio isn't booted jet. Else gs_close
 	   is going to oops.
-	*/
+	 */
 	tty->driver_data = NULL;
-        
-	SysPort = rio_minor(tty);
-	Modem   = rio_ismodem(tty);
 
-	if ( p->RIOFailed ) {
-		rio_dprintk (RIO_DEBUG_TTY, "System initialisation failed\n");
+	SysPort = rio_minor(tty);
+	Modem = rio_ismodem(tty);
+
+	if (p->RIOFailed) {
+		rio_dprintk(RIO_DEBUG_TTY, "System initialisation failed\n");
 		pseterr(ENXIO);
-		func_exit ();
+		func_exit();
 		return -ENXIO;
 	}
 
-	rio_dprintk (RIO_DEBUG_TTY, "port open SysPort %d (%s) (mapped:%d)\n",
-	       SysPort,  Modem ? "Modem" : "tty",
-				   p->RIOPortp[SysPort]->Mapped);
+	rio_dprintk(RIO_DEBUG_TTY, "port open SysPort %d (%s) (mapped:%d)\n", SysPort, Modem ? "Modem" : "tty", p->RIOPortp[SysPort]->Mapped);
 
 	/*
-	** Validate that we have received a legitimate request.
-	** Currently, just check that we are opening a port on
-	** a host card that actually exists, and that the port
-	** has been mapped onto a host.
-	*/
+	 ** Validate that we have received a legitimate request.
+	 ** Currently, just check that we are opening a port on
+	 ** a host card that actually exists, and that the port
+	 ** has been mapped onto a host.
+	 */
 	if (SysPort >= RIO_PORTS) {	/* out of range ? */
-		rio_dprintk (RIO_DEBUG_TTY, "Illegal port number %d\n",SysPort);
+		rio_dprintk(RIO_DEBUG_TTY, "Illegal port number %d\n", SysPort);
 		pseterr(ENXIO);
 		func_exit();
 		return -ENXIO;
 	}
 
 	/*
-	** Grab pointer to the port stucture
-	*/
+	 ** Grab pointer to the port stucture
+	 */
 	PortP = p->RIOPortp[SysPort];	/* Get control struc */
-	rio_dprintk (RIO_DEBUG_TTY, "PortP: %p\n", PortP);
-	if ( !PortP->Mapped ) {	/* we aren't mapped yet! */
+	rio_dprintk(RIO_DEBUG_TTY, "PortP: %p\n", PortP);
+	if (!PortP->Mapped) {	/* we aren't mapped yet! */
 		/*
-		** The system doesn't know which RTA this port
-		** corresponds to.
-		*/
-		rio_dprintk (RIO_DEBUG_TTY, "port not mapped into system\n");
-		func_exit ();
+		 ** The system doesn't know which RTA this port
+		 ** corresponds to.
+		 */
+		rio_dprintk(RIO_DEBUG_TTY, "port not mapped into system\n");
+		func_exit();
 		pseterr(ENXIO);
 		return -ENXIO;
 	}
@@ -210,132 +203,131 @@
 	PortP->gs.tty = tty;
 	PortP->gs.count++;
 
-	rio_dprintk (RIO_DEBUG_TTY, "%d bytes in tx buffer\n",
-				   PortP->gs.xmit_cnt);
+	rio_dprintk(RIO_DEBUG_TTY, "%d bytes in tx buffer\n", PortP->gs.xmit_cnt);
 
-	retval = gs_init_port (&PortP->gs);
+	retval = gs_init_port(&PortP->gs);
 	if (retval) {
 		PortP->gs.count--;
 		return -ENXIO;
 	}
 	/*
-	** If the host hasn't been booted yet, then 
-	** fail
-	*/
-	if ( (PortP->HostP->Flags & RUN_STATE) != RC_RUNNING ) {
-		rio_dprintk (RIO_DEBUG_TTY, "Host not running\n");
+	 ** If the host hasn't been booted yet, then
+	 ** fail
+	 */
+	if ((PortP->HostP->Flags & RUN_STATE) != RC_RUNNING) {
+		rio_dprintk(RIO_DEBUG_TTY, "Host not running\n");
 		pseterr(ENXIO);
-		func_exit ();
+		func_exit();
 		return -ENXIO;
 	}
 
 	/*
-	** If the RTA has not booted yet and the user has choosen to block
-	** until the RTA is present then we must spin here waiting for
-	** the RTA to boot.
-	*/
+	 ** If the RTA has not booted yet and the user has choosen to block
+	 ** until the RTA is present then we must spin here waiting for
+	 ** the RTA to boot.
+	 */
 #if 0
 	if (!(PortP->HostP->Mapping[PortP->RupNum].Flags & RTA_BOOTED)) {
 		if (PortP->WaitUntilBooted) {
-			rio_dprintk (RIO_DEBUG_TTY, "Waiting for RTA to boot\n");
+			rio_dprintk(RIO_DEBUG_TTY, "Waiting for RTA to boot\n");
 			do {
 				if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) {
-					rio_dprintk (RIO_DEBUG_TTY, "RTA EINTR in delay \n");
-					func_exit ();
+					rio_dprintk(RIO_DEBUG_TTY, "RTA EINTR in delay \n");
+					func_exit();
 					return -EINTR;
 				}
-				if (repeat_this -- <= 0) {
-					rio_dprintk (RIO_DEBUG_TTY, "Waiting for RTA to boot timeout\n");
-					RIOPreemptiveCmd(p, PortP, FCLOSE ); 
+				if (repeat_this-- <= 0) {
+					rio_dprintk(RIO_DEBUG_TTY, "Waiting for RTA to boot timeout\n");
+					RIOPreemptiveCmd(p, PortP, FCLOSE);
 					pseterr(EINTR);
-					func_exit ();
+					func_exit();
 					return -EIO;
 				}
-			} while(!(PortP->HostP->Mapping[PortP->RupNum].Flags & RTA_BOOTED));
-			rio_dprintk (RIO_DEBUG_TTY, "RTA has been booted\n");
+			} while (!(PortP->HostP->Mapping[PortP->RupNum].Flags & RTA_BOOTED));
+			rio_dprintk(RIO_DEBUG_TTY, "RTA has been booted\n");
 		} else {
-			rio_dprintk (RIO_DEBUG_TTY, "RTA never booted\n");
+			rio_dprintk(RIO_DEBUG_TTY, "RTA never booted\n");
 			pseterr(ENXIO);
-			func_exit ();
+			func_exit();
 			return 0;
 		}
 	}
 #else
 	/* I find the above code a bit hairy. I find the below code
-           easier to read and shorter. Now, if it works too that would
+	   easier to read and shorter. Now, if it works too that would
 	   be great... -- REW 
-	*/
-	rio_dprintk (RIO_DEBUG_TTY, "Checking if RTA has booted... \n");
+	 */
+	rio_dprintk(RIO_DEBUG_TTY, "Checking if RTA has booted... \n");
 	while (!(PortP->HostP->Mapping[PortP->RupNum].Flags & RTA_BOOTED)) {
-	  if (!PortP->WaitUntilBooted) {
-	    rio_dprintk (RIO_DEBUG_TTY, "RTA never booted\n");
-	    func_exit ();
-	    return -ENXIO;
-	  }
+		if (!PortP->WaitUntilBooted) {
+			rio_dprintk(RIO_DEBUG_TTY, "RTA never booted\n");
+			func_exit();
+			return -ENXIO;
+		}
 
-	  /* Under Linux you'd normally use a wait instead of this
-	     busy-waiting. I'll stick with the old implementation for
-	     now. --REW 
-	  */
-	  if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) {
-	    rio_dprintk (RIO_DEBUG_TTY, "RTA_wait_for_boot: EINTR in delay \n");
-	    func_exit ();
-	    return -EINTR;
-	  }
-	  if (repeat_this -- <= 0) {
-	    rio_dprintk (RIO_DEBUG_TTY, "Waiting for RTA to boot timeout\n");
-	    func_exit ();
-	    return -EIO;
-	  }
+		/* Under Linux you'd normally use a wait instead of this
+		   busy-waiting. I'll stick with the old implementation for
+		   now. --REW
+		 */
+		if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) {
+			rio_dprintk(RIO_DEBUG_TTY, "RTA_wait_for_boot: EINTR in delay \n");
+			func_exit();
+			return -EINTR;
+		}
+		if (repeat_this-- <= 0) {
+			rio_dprintk(RIO_DEBUG_TTY, "Waiting for RTA to boot timeout\n");
+			func_exit();
+			return -EIO;
+		}
 	}
-	rio_dprintk (RIO_DEBUG_TTY, "RTA has been booted\n");
+	rio_dprintk(RIO_DEBUG_TTY, "RTA has been booted\n");
 #endif
 #if 0
-	tp =  PortP->TtyP;		/* get tty struct */
+	tp = PortP->TtyP;	/* get tty struct */
 #endif
 	rio_spin_lock_irqsave(&PortP->portSem, flags);
-	if ( p->RIOHalted ) {
+	if (p->RIOHalted) {
 		goto bombout;
 	}
 #if 0
 	retval = gs_init_port(&PortP->gs);
-	if (retval){
-		func_exit ();
+	if (retval) {
+		func_exit();
 		return retval;
 	}
 #endif
 
 	/*
-	** If the port is in the final throws of being closed,
-	** we should wait here (politely), waiting
-	** for it to finish, so that it doesn't close us!
-	*/
-	while ( (PortP->State & RIO_CLOSING) && !p->RIOHalted ) {
-		rio_dprintk (RIO_DEBUG_TTY, "Waiting for RIO_CLOSING to go away\n");
-		if (repeat_this -- <= 0) {
-			rio_dprintk (RIO_DEBUG_TTY, "Waiting for not idle closed broken by signal\n");
-			RIOPreemptiveCmd(p, PortP, FCLOSE ); 
+	 ** If the port is in the final throws of being closed,
+	 ** we should wait here (politely), waiting
+	 ** for it to finish, so that it doesn't close us!
+	 */
+	while ((PortP->State & RIO_CLOSING) && !p->RIOHalted) {
+		rio_dprintk(RIO_DEBUG_TTY, "Waiting for RIO_CLOSING to go away\n");
+		if (repeat_this-- <= 0) {
+			rio_dprintk(RIO_DEBUG_TTY, "Waiting for not idle closed broken by signal\n");
+			RIOPreemptiveCmd(p, PortP, FCLOSE);
 			retval = -EINTR;
 			goto bombout;
 		}
 		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
 		if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) {
-			rio_spin_lock_irqsave(&PortP->portSem, flags); 
+			rio_spin_lock_irqsave(&PortP->portSem, flags);
 			retval = -EINTR;
 			goto bombout;
 		}
-		rio_spin_lock_irqsave(&PortP->portSem, flags); 
+		rio_spin_lock_irqsave(&PortP->portSem, flags);
 	}
 
-	if ( !PortP->Mapped ) {
-		rio_dprintk (RIO_DEBUG_TTY, "Port unmapped while closing!\n");
+	if (!PortP->Mapped) {
+		rio_dprintk(RIO_DEBUG_TTY, "Port unmapped while closing!\n");
 		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
 		retval = -ENXIO;
-		func_exit ();
+		func_exit();
 		return retval;
 	}
 
-	if ( p->RIOHalted ) {
+	if (p->RIOHalted) {
 		goto bombout;
 	}
 
@@ -346,16 +338,16 @@
 */
 	/* Uh? Suppose I turn these on and then another process opens
 	   the port again? The flags get cleared! Not good. -- REW */
-	if ( !(PortP->State & (RIO_LOPEN | RIO_MOPEN)) ) {
-		PortP->Config &= ~(RIO_CTSFLOW|RIO_RTSFLOW);
+	if (!(PortP->State & (RIO_LOPEN | RIO_MOPEN))) {
+		PortP->Config &= ~(RIO_CTSFLOW | RIO_RTSFLOW);
 	}
 
 	if (!(PortP->firstOpen)) {	/* First time ? */
-		rio_dprintk (RIO_DEBUG_TTY, "First open for this port\n");
-	
+		rio_dprintk(RIO_DEBUG_TTY, "First open for this port\n");
+
 
 		PortP->firstOpen++;
-		PortP->CookMode = 0; /* XXX RIOCookMode(tp); */
+		PortP->CookMode = 0;	/* XXX RIOCookMode(tp); */
 		PortP->InUse = NOT_INUSE;
 
 		/* Tentative fix for bug PR27. Didn't work. */
@@ -363,26 +355,26 @@
 
 		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
 #ifdef NEED_THIS
-		ttyseth(PortP, tp, (struct old_sgttyb *)&default_sg);
+		ttyseth(PortP, tp, (struct old_sgttyb *) &default_sg);
 #endif
 
 		/* Someone explain to me why this delay/config is
-                   here. If I read the docs correctly the "open"
-                   command piggybacks the parameters immediately. 
+		   here. If I read the docs correctly the "open"
+		   command piggybacks the parameters immediately.
 		   -- REW */
-		RIOParam(PortP,OPEN,Modem,OK_TO_SLEEP);		/* Open the port */
+		RIOParam(PortP, OPEN, Modem, OK_TO_SLEEP);	/* Open the port */
 #if 0
 		/* This delay of 1 second was annoying. I removed it. -- REW */
-		RIODelay(PortP, HUNDRED_MS*10);
-		RIOParam(PortP,CONFIG,Modem,OK_TO_SLEEP);	/* Config the port */
+		RIODelay(PortP, HUNDRED_MS * 10);
+		RIOParam(PortP, CONFIG, Modem, OK_TO_SLEEP);	/* Config the port */
 #endif
 		rio_spin_lock_irqsave(&PortP->portSem, flags);
 
 		/*
-		** wait for the port to be not closed.
-		*/
-		while ( !(PortP->PortState & PORT_ISOPEN) && !p->RIOHalted ) {
-			rio_dprintk (RIO_DEBUG_TTY, "Waiting for PORT_ISOPEN-currently %x\n",PortP->PortState);
+		 ** wait for the port to be not closed.
+		 */
+		while (!(PortP->PortState & PORT_ISOPEN) && !p->RIOHalted) {
+			rio_dprintk(RIO_DEBUG_TTY, "Waiting for PORT_ISOPEN-currently %x\n", PortP->PortState);
 /*
 ** 15.10.1998 ARG - ESIL 0759
 ** (Part) fix for port being trashed when opened whilst RTA "disconnected"
@@ -399,115 +391,109 @@
 */
 			rio_spin_unlock_irqrestore(&PortP->portSem, flags);
 			if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) {
-				rio_dprintk (RIO_DEBUG_TTY, "Waiting for open to finish broken by signal\n");
-				RIOPreemptiveCmd(p, PortP, FCLOSE );
-				func_exit ();
+				rio_dprintk(RIO_DEBUG_TTY, "Waiting for open to finish broken by signal\n");
+				RIOPreemptiveCmd(p, PortP, FCLOSE);
+				func_exit();
 				return -EINTR;
 			}
 			rio_spin_lock_irqsave(&PortP->portSem, flags);
 		}
 
-		if ( p->RIOHalted ) {
-		  retval = -EIO;
-bombout:
-		  /* 			RIOClearUp( PortP ); */
+		if (p->RIOHalted) {
+			retval = -EIO;
+		      bombout:
+			/*                    RIOClearUp( PortP ); */
 			rio_spin_unlock_irqrestore(&PortP->portSem, flags);
 			return retval;
 		}
-		rio_dprintk (RIO_DEBUG_TTY, "PORT_ISOPEN found\n");
+		rio_dprintk(RIO_DEBUG_TTY, "PORT_ISOPEN found\n");
 	}
-
-#ifdef MODEM_SUPPORT 
+#ifdef MODEM_SUPPORT
 	if (Modem) {
-		rio_dprintk (RIO_DEBUG_TTY, "Modem - test for carrier\n");
+		rio_dprintk(RIO_DEBUG_TTY, "Modem - test for carrier\n");
 		/*
-		** ACTION
-		** insert test for carrier here. -- ???
-		** I already see that test here. What's the deal? -- REW
-		*/
-		if ((PortP->gs.tty->termios->c_cflag & CLOCAL) || (PortP->ModemState & MSVR1_CD))
-		{
-			rio_dprintk (RIO_DEBUG_TTY, "open(%d) Modem carr on\n", SysPort);
+		 ** ACTION
+		 ** insert test for carrier here. -- ???
+		 ** I already see that test here. What's the deal? -- REW
+		 */
+		if ((PortP->gs.tty->termios->c_cflag & CLOCAL) || (PortP->ModemState & MSVR1_CD)) {
+			rio_dprintk(RIO_DEBUG_TTY, "open(%d) Modem carr on\n", SysPort);
 			/*
-			tp->tm.c_state |= CARR_ON;
-			wakeup((caddr_t) &tp->tm.c_canq);
-			*/
+			   tp->tm.c_state |= CARR_ON;
+			   wakeup((caddr_t) &tp->tm.c_canq);
+			 */
 			PortP->State |= RIO_CARR_ON;
-			wake_up_interruptible (&PortP->gs.open_wait);
-		}
-		else /* no carrier - wait for DCD */
-		{
-		  /*
-			while (!(PortP->gs.tty->termios->c_state & CARR_ON) && 
-			       !(filp->f_flags & O_NONBLOCK) && !p->RIOHalted )
-		  */
-			while (!(PortP->State & RIO_CARR_ON) && 
-			       !(filp->f_flags & O_NONBLOCK) && !p->RIOHalted ) {
+			wake_up_interruptible(&PortP->gs.open_wait);
+		} else {	/* no carrier - wait for DCD */
 
-				rio_dprintk (RIO_DEBUG_TTY, "open(%d) sleeping for carr on\n",SysPort);
+			/*
+			   while (!(PortP->gs.tty->termios->c_state & CARR_ON) &&
+			   !(filp->f_flags & O_NONBLOCK) && !p->RIOHalted )
+			 */
+			while (!(PortP->State & RIO_CARR_ON) && !(filp->f_flags & O_NONBLOCK) && !p->RIOHalted) {
+
+				rio_dprintk(RIO_DEBUG_TTY, "open(%d) sleeping for carr on\n", SysPort);
 				/*
-				PortP->gs.tty->termios->c_state |= WOPEN;
-				*/
+				   PortP->gs.tty->termios->c_state |= WOPEN;
+				 */
 				PortP->State |= RIO_WOPEN;
 				rio_spin_unlock_irqrestore(&PortP->portSem, flags);
-				if (RIODelay (PortP, HUNDRED_MS) == RIO_FAIL)
+				if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL)
 #if 0
-				if ( sleep((caddr_t)&tp->tm.c_canqo, TTIPRI|PCATCH))
+					if (sleep((caddr_t) & tp->tm.c_canqo, TTIPRI | PCATCH))
 #endif
-				{
-					/*
-					** ACTION: verify that this is a good thing
-					** to do here. -- ???
-					** I think it's OK. -- REW
-					*/
-					rio_dprintk (RIO_DEBUG_TTY, "open(%d) sleeping for carr broken by signal\n",
-					       SysPort);
-					RIOPreemptiveCmd( p, PortP, FCLOSE );
-					/*
-					tp->tm.c_state &= ~WOPEN;
-					*/
-					PortP->State &= ~RIO_WOPEN;
-					rio_spin_unlock_irqrestore(&PortP->portSem, flags);
-					func_exit ();
-					return -EINTR;
-				}
+					{
+						/*
+						 ** ACTION: verify that this is a good thing
+						 ** to do here. -- ???
+						 ** I think it's OK. -- REW
+						 */
+						rio_dprintk(RIO_DEBUG_TTY, "open(%d) sleeping for carr broken by signal\n", SysPort);
+						RIOPreemptiveCmd(p, PortP, FCLOSE);
+						/*
+						   tp->tm.c_state &= ~WOPEN;
+						 */
+						PortP->State &= ~RIO_WOPEN;
+						rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+						func_exit();
+						return -EINTR;
+					}
 			}
 			PortP->State &= ~RIO_WOPEN;
 		}
-		if ( p->RIOHalted )
+		if (p->RIOHalted)
 			goto bombout;
-		rio_dprintk (RIO_DEBUG_TTY, "Setting RIO_MOPEN\n");
+		rio_dprintk(RIO_DEBUG_TTY, "Setting RIO_MOPEN\n");
 		PortP->State |= RIO_MOPEN;
-	}
-	else
+	} else
 #endif
 	{
 		/*
-		** ACTION
-		** Direct line open - force carrier (will probably mean
-		** that sleeping Modem line fubar)
-		*/
+		 ** ACTION
+		 ** Direct line open - force carrier (will probably mean
+		 ** that sleeping Modem line fubar)
+		 */
 		PortP->State |= RIO_LOPEN;
 	}
 
-	if ( p->RIOHalted ) {
+	if (p->RIOHalted) {
 		goto bombout;
 	}
 
-	rio_dprintk (RIO_DEBUG_TTY, "high level open done\n");
+	rio_dprintk(RIO_DEBUG_TTY, "high level open done\n");
 
 #ifdef STATS
 	PortP->Stat.OpenCnt++;
 #endif
 	/*
-	** Count opens for port statistics reporting
-	*/
+	 ** Count opens for port statistics reporting
+	 */
 	if (PortP->statsGather)
 		PortP->opens++;
 
 	rio_spin_unlock_irqrestore(&PortP->portSem, flags);
-	rio_dprintk (RIO_DEBUG_TTY, "Returning from open\n");
-	func_exit ();
+	rio_dprintk(RIO_DEBUG_TTY, "Returning from open\n");
+	func_exit();
 	return 0;
 }
 
@@ -516,36 +502,35 @@
 ** The operating system thinks that this is last close for the device.
 ** As there are two interfaces to the port (Modem and tty), we need to
 ** check that both are closed before we close the device.
-*/ 
-int
-riotclose(void  *ptr)
+*/
+int riotclose(void *ptr)
 {
 #if 0
 	register uint SysPort = dev;
-	struct ttystatics *tp;		/* pointer to our ttystruct */
+	struct ttystatics *tp;	/* pointer to our ttystruct */
 #endif
 	struct Port *PortP = ptr;	/* pointer to the port structure */
 	int deleted = 0;
-	int	try = -1; /* Disable the timeouts by setting them to -1 */
-	int	repeat_this = -1; /* Congrats to those having 15 years of 
-				     uptime! (You get to break the driver.) */
+	int try = -1;		/* Disable the timeouts by setting them to -1 */
+	int repeat_this = -1;	/* Congrats to those having 15 years of
+				   uptime! (You get to break the driver.) */
 	unsigned long end_time;
-	struct tty_struct * tty;
+	struct tty_struct *tty;
 	unsigned long flags;
 	int Modem;
 	int rv = 0;
-	
-	rio_dprintk (RIO_DEBUG_TTY, "port close SysPort %d\n",PortP->PortNum);
+
+	rio_dprintk(RIO_DEBUG_TTY, "port close SysPort %d\n", PortP->PortNum);
 
 	/* PortP = p->RIOPortp[SysPort]; */
-	rio_dprintk (RIO_DEBUG_TTY, "Port is at address 0x%x\n",(int)PortP);
-	/* tp = PortP->TtyP;*/			/* Get tty */
+	rio_dprintk(RIO_DEBUG_TTY, "Port is at address 0x%x\n", (int) PortP);
+	/* tp = PortP->TtyP; *//* Get tty */
 	tty = PortP->gs.tty;
-	rio_dprintk (RIO_DEBUG_TTY, "TTY is at address 0x%x\n",(int)tty);
+	rio_dprintk(RIO_DEBUG_TTY, "TTY is at address 0x%x\n", (int) tty);
 
-	if (PortP->gs.closing_wait) 
+	if (PortP->gs.closing_wait)
 		end_time = jiffies + PortP->gs.closing_wait;
-	else 
+	else
 		end_time = jiffies + MAX_SCHEDULE_TIMEOUT;
 
 	Modem = rio_ismodem(tty);
@@ -553,48 +538,48 @@
 	/* What F.CKING cache? Even then, a higly idle multiprocessor,
 	   system with large caches this won't work . Better find out when 
 	   this doesn't work asap, and fix the cause.  -- REW */
-	
-	RIODelay(PortP, HUNDRED_MS*10);	/* To flush the cache */
+
+	RIODelay(PortP, HUNDRED_MS * 10);	/* To flush the cache */
 #endif
 	rio_spin_lock_irqsave(&PortP->portSem, flags);
 
 	/*
-	** Setting this flag will make any process trying to open
-	** this port block until we are complete closing it.
-	*/
+	 ** Setting this flag will make any process trying to open
+	 ** this port block until we are complete closing it.
+	 */
 	PortP->State |= RIO_CLOSING;
 
-	if ( (PortP->State & RIO_DELETED) ) {
-		rio_dprintk (RIO_DEBUG_TTY, "Close on deleted RTA\n");
+	if ((PortP->State & RIO_DELETED)) {
+		rio_dprintk(RIO_DEBUG_TTY, "Close on deleted RTA\n");
 		deleted = 1;
 	}
-	
-	if ( p->RIOHalted ) {
-		RIOClearUp( PortP );
+
+	if (p->RIOHalted) {
+		RIOClearUp(PortP);
 		rv = -EIO;
 		goto close_end;
 	}
 
-	rio_dprintk (RIO_DEBUG_TTY, "Clear bits\n");
+	rio_dprintk(RIO_DEBUG_TTY, "Clear bits\n");
 	/*
-	** clear the open bits for this device
-	*/
+	 ** clear the open bits for this device
+	 */
 	PortP->State &= (Modem ? ~RIO_MOPEN : ~RIO_LOPEN);
 	PortP->State &= ~RIO_CARR_ON;
 	PortP->ModemState &= ~MSVR1_CD;
 	/*
-	** If the device was open as both a Modem and a tty line
-	** then we need to wimp out here, as the port has not really
-	** been finally closed (gee, whizz!) The test here uses the
-	** bit for the OTHER mode of operation, to see if THAT is
-	** still active!
-	*/
-	if ( (PortP->State & (RIO_LOPEN|RIO_MOPEN)) ) {
+	 ** If the device was open as both a Modem and a tty line
+	 ** then we need to wimp out here, as the port has not really
+	 ** been finally closed (gee, whizz!) The test here uses the
+	 ** bit for the OTHER mode of operation, to see if THAT is
+	 ** still active!
+	 */
+	if ((PortP->State & (RIO_LOPEN | RIO_MOPEN))) {
 		/*
-		** The port is still open for the other task -
-		** return, pretending that we are still active.
-		*/
-		rio_dprintk (RIO_DEBUG_TTY, "Channel %d still open !\n",PortP->PortNum);
+		 ** The port is still open for the other task -
+		 ** return, pretending that we are still active.
+		 */
+		rio_dprintk(RIO_DEBUG_TTY, "Channel %d still open !\n", PortP->PortNum);
 		PortP->State &= ~RIO_CLOSING;
 		if (PortP->firstOpen)
 			PortP->firstOpen--;
@@ -602,48 +587,47 @@
 		return -EIO;
 	}
 
-	rio_dprintk (RIO_DEBUG_TTY, "Closing down - everything must go!\n");
+	rio_dprintk(RIO_DEBUG_TTY, "Closing down - everything must go!\n");
 
 	PortP->State &= ~RIO_DYNOROD;
 
 	/*
-	** This is where we wait for the port
-	** to drain down before closing. Bye-bye....
-	** (We never meant to do this)
-	*/
-	rio_dprintk (RIO_DEBUG_TTY, "Timeout 1 starts\n");
+	 ** This is where we wait for the port
+	 ** to drain down before closing. Bye-bye....
+	 ** (We never meant to do this)
+	 */
+	rio_dprintk(RIO_DEBUG_TTY, "Timeout 1 starts\n");
 
 	if (!deleted)
-	while ( (PortP->InUse != NOT_INUSE) && !p->RIOHalted && 
-		(PortP->TxBufferIn != PortP->TxBufferOut) ) {
-		cprintf("Need to flush the ttyport\n");
-		if (repeat_this -- <= 0) {
-			rv = -EINTR;
-			rio_dprintk (RIO_DEBUG_TTY, "Waiting for not idle closed broken by signal\n");
-			RIOPreemptiveCmd(p, PortP, FCLOSE);
-			goto close_end;
-		}
-		rio_dprintk (RIO_DEBUG_TTY, "Calling timeout to flush in closing\n");
-		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
-		if (RIODelay_ni(PortP, HUNDRED_MS*10) == RIO_FAIL) {
-			rio_dprintk (RIO_DEBUG_TTY, "RTA EINTR in delay \n");
-			rv = -EINTR;
+		while ((PortP->InUse != NOT_INUSE) && !p->RIOHalted && (PortP->TxBufferIn != PortP->TxBufferOut)) {
+			cprintf("Need to flush the ttyport\n");
+			if (repeat_this-- <= 0) {
+				rv = -EINTR;
+				rio_dprintk(RIO_DEBUG_TTY, "Waiting for not idle closed broken by signal\n");
+				RIOPreemptiveCmd(p, PortP, FCLOSE);
+				goto close_end;
+			}
+			rio_dprintk(RIO_DEBUG_TTY, "Calling timeout to flush in closing\n");
+			rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+			if (RIODelay_ni(PortP, HUNDRED_MS * 10) == RIO_FAIL) {
+				rio_dprintk(RIO_DEBUG_TTY, "RTA EINTR in delay \n");
+				rv = -EINTR;
+				rio_spin_lock_irqsave(&PortP->portSem, flags);
+				goto close_end;
+			}
 			rio_spin_lock_irqsave(&PortP->portSem, flags);
-			goto close_end;
 		}
-		rio_spin_lock_irqsave(&PortP->portSem, flags);
-	}
 
 	PortP->TxBufferIn = PortP->TxBufferOut = 0;
 	repeat_this = 0xff;
 
 	PortP->InUse = 0;
-	if ( (PortP->State & (RIO_LOPEN|RIO_MOPEN)) ) {
+	if ((PortP->State & (RIO_LOPEN | RIO_MOPEN))) {
 		/*
-		** The port has been re-opened for the other task -
-		** return, pretending that we are still active.
-		*/
-		rio_dprintk (RIO_DEBUG_TTY, "Channel %d re-open!\n", PortP->PortNum);
+		 ** The port has been re-opened for the other task -
+		 ** return, pretending that we are still active.
+		 */
+		rio_dprintk(RIO_DEBUG_TTY, "Channel %d re-open!\n", PortP->PortNum);
 		PortP->State &= ~RIO_CLOSING;
 		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
 		if (PortP->firstOpen)
@@ -651,8 +635,8 @@
 		return -EIO;
 	}
 
-	if ( p->RIOHalted ) {
-		RIOClearUp( PortP );
+	if (p->RIOHalted) {
+		RIOClearUp(PortP);
 		goto close_end;
 	}
 
@@ -665,57 +649,56 @@
 	}
 
 	if (!deleted)
-	  while (try && (PortP->PortState & PORT_ISOPEN)) {
-	        try--;
-		if (time_after (jiffies, end_time)) {
-		  rio_dprintk (RIO_DEBUG_TTY, "Run out of tries - force the bugger shut!\n" );
-		  RIOPreemptiveCmd(p, PortP,FCLOSE);
-		  break;
-		}
-		rio_dprintk (RIO_DEBUG_TTY, "Close: PortState:ISOPEN is %d\n", 
-					   PortP->PortState & PORT_ISOPEN);
+		while (try && (PortP->PortState & PORT_ISOPEN)) {
+			try--;
+			if (time_after(jiffies, end_time)) {
+				rio_dprintk(RIO_DEBUG_TTY, "Run out of tries - force the bugger shut!\n");
+				RIOPreemptiveCmd(p, PortP, FCLOSE);
+				break;
+			}
+			rio_dprintk(RIO_DEBUG_TTY, "Close: PortState:ISOPEN is %d\n", PortP->PortState & PORT_ISOPEN);
 
-		if ( p->RIOHalted ) {
-			RIOClearUp( PortP );
-			goto close_end;
+			if (p->RIOHalted) {
+				RIOClearUp(PortP);
+				goto close_end;
+			}
+			if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) {
+				rio_dprintk(RIO_DEBUG_TTY, "RTA EINTR in delay \n");
+				RIOPreemptiveCmd(p, PortP, FCLOSE);
+				break;
+			}
 		}
-		if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) {
-			rio_dprintk (RIO_DEBUG_TTY, "RTA EINTR in delay \n");
-			RIOPreemptiveCmd(p, PortP,FCLOSE);
-			break;
-		}
-	}
 	rio_spin_lock_irqsave(&PortP->portSem, flags);
-	rio_dprintk (RIO_DEBUG_TTY, "Close: try was %d on completion\n", try );
- 
+	rio_dprintk(RIO_DEBUG_TTY, "Close: try was %d on completion\n", try);
+
 	/* RIOPreemptiveCmd(p, PortP, FCLOSE); */
 
 /*
 ** 15.10.1998 ARG - ESIL 0761 part fix
 ** RIO has it's own CTSFLOW and RTSFLOW flags in 'Config' in the port structure,** we need to make sure that the flags are clear when the port is opened.
 */
-	PortP->Config &= ~(RIO_CTSFLOW|RIO_RTSFLOW);
+	PortP->Config &= ~(RIO_CTSFLOW | RIO_RTSFLOW);
 
 #ifdef STATS
 	PortP->Stat.CloseCnt++;
 #endif
 	/*
-	** Count opens for port statistics reporting
-	*/
+	 ** Count opens for port statistics reporting
+	 */
 	if (PortP->statsGather)
 		PortP->closes++;
 
-close_end:
+      close_end:
 	/* XXX: Why would a "DELETED" flag be reset here? I'd have
 	   thought that a "deleted" flag means that the port was
 	   permanently gone, but here we can make it reappear by it
 	   being in close during the "deletion".
-	*/
-	PortP->State &= ~(RIO_CLOSING|RIO_DELETED);
+	 */
+	PortP->State &= ~(RIO_CLOSING | RIO_DELETED);
 	if (PortP->firstOpen)
 		PortP->firstOpen--;
 	rio_spin_unlock_irqrestore(&PortP->portSem, flags);
-	rio_dprintk (RIO_DEBUG_TTY, "Return from close\n");
+	rio_dprintk(RIO_DEBUG_TTY, "Return from close\n");
 	return rv;
 }
 
@@ -728,52 +711,50 @@
 ** COOK_MEDIUM if the card can do all the processing necessary.
 */
 #if 0
-static int
-RIOCookMode(struct ttystatics *tp)
+static int RIOCookMode(struct ttystatics *tp)
 {
 	/*
-	** We can't handle tm.c_mstate != 0 on SCO
-	** We can't handle mapping
-	** We can't handle non-ttwrite line disc.
-	** We can't handle lflag XCASE
-	** We can handle oflag OPOST & (OCRNL, ONLCR, TAB3)
-	*/
+	 ** We can't handle tm.c_mstate != 0 on SCO
+	 ** We can't handle mapping
+	 ** We can't handle non-ttwrite line disc.
+	 ** We can't handle lflag XCASE
+	 ** We can handle oflag OPOST & (OCRNL, ONLCR, TAB3)
+	 */
 
 #ifdef CHECK
-	CheckTtyP( tp );
+	CheckTtyP(tp);
 #endif
 	if (!(tp->tm.c_oflag & OPOST))	/* No post processing */
 		return COOK_RAW;	/* Raw mode o/p */
 
-	if ( tp->tm.c_lflag & XCASE )
+	if (tp->tm.c_lflag & XCASE)
 		return COOK_WELL;	/* Use line disc */
 
-	if (tp->tm.c_oflag & ~(OPOST | ONLCR | OCRNL | TAB3 ) )
+	if (tp->tm.c_oflag & ~(OPOST | ONLCR | OCRNL | TAB3))
 		return COOK_WELL;	/* Use line disc for strange modes */
 
-	if ( tp->tm.c_oflag == OPOST )	/* If only OPOST is set, do RAW */
+	if (tp->tm.c_oflag == OPOST)	/* If only OPOST is set, do RAW */
 		return COOK_RAW;
 
 	/*
-	** So, we need to output process!
-	*/
+	 ** So, we need to output process!
+	 */
 	return COOK_MEDIUM;
 }
 #endif
 
-static void
-RIOClearUp(PortP)
+static void RIOClearUp(PortP)
 struct Port *PortP;
 {
-	rio_dprintk (RIO_DEBUG_TTY, "RIOHalted set\n");
-	PortP->Config = 0;	  /* Direct semaphore */
+	rio_dprintk(RIO_DEBUG_TTY, "RIOHalted set\n");
+	PortP->Config = 0;	/* Direct semaphore */
 	PortP->PortState = 0;
 	PortP->firstOpen = 0;
 	PortP->FlushCmdBodge = 0;
 	PortP->ModemState = PortP->CookMode = 0;
 	PortP->Mapped = 0;
 	PortP->WflushFlag = 0;
-	PortP->MagicFlags	= 0;
+	PortP->MagicFlags = 0;
 	PortP->RxDataStart = 0;
 	PortP->TxBufferIn = 0;
 	PortP->TxBufferOut = 0;
@@ -788,33 +769,31 @@
 ** Other values of len aren't allowed, and will cause
 ** a panic.
 */
-int RIOShortCommand(struct rio_info *p, struct Port *PortP,
-		int command, int len, int arg)
+int RIOShortCommand(struct rio_info *p, struct Port *PortP, int command, int len, int arg)
 {
 	PKT *PacketP;
-	int		retries = 20; /* at 10 per second -> 2 seconds */
+	int retries = 20;	/* at 10 per second -> 2 seconds */
 	unsigned long flags;
 
-	rio_dprintk (RIO_DEBUG_TTY, "entering shortcommand.\n");
+	rio_dprintk(RIO_DEBUG_TTY, "entering shortcommand.\n");
 #ifdef CHECK
-	CheckPortP( PortP );
-	if ( len < 1 || len > 2 )
-		cprintf(("STUPID LENGTH %d\n",len));
+	CheckPortP(PortP);
+	if (len < 1 || len > 2)
+		cprintf(("STUPID LENGTH %d\n", len));
 #endif
 
-	if ( PortP->State & RIO_DELETED ) {
-		rio_dprintk (RIO_DEBUG_TTY, "Short command to deleted RTA ignored\n");
+	if (PortP->State & RIO_DELETED) {
+		rio_dprintk(RIO_DEBUG_TTY, "Short command to deleted RTA ignored\n");
 		return RIO_FAIL;
 	}
 	rio_spin_lock_irqsave(&PortP->portSem, flags);
 
 	/*
-	** If the port is in use for pre-emptive command, then wait for it to 
-	** be free again.
-	*/
-	while ( (PortP->InUse != NOT_INUSE) && !p->RIOHalted ) {
-		rio_dprintk (RIO_DEBUG_TTY, "Waiting for not in use (%d)\n", 
-					   retries);
+	 ** If the port is in use for pre-emptive command, then wait for it to
+	 ** be free again.
+	 */
+	while ((PortP->InUse != NOT_INUSE) && !p->RIOHalted) {
+		rio_dprintk(RIO_DEBUG_TTY, "Waiting for not in use (%d)\n", retries);
 		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
 		if (retries-- <= 0) {
 			return RIO_FAIL;
@@ -824,47 +803,47 @@
 		}
 		rio_spin_lock_irqsave(&PortP->portSem, flags);
 	}
-	if ( PortP->State & RIO_DELETED ) {
-		rio_dprintk (RIO_DEBUG_TTY, "Short command to deleted RTA ignored\n");
+	if (PortP->State & RIO_DELETED) {
+		rio_dprintk(RIO_DEBUG_TTY, "Short command to deleted RTA ignored\n");
 		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
 		return RIO_FAIL;
 	}
 
-	while ( !can_add_transmit(&PacketP,PortP) && !p->RIOHalted ) {
-		rio_dprintk (RIO_DEBUG_TTY, "Waiting to add short command to queue (%d)\n", retries);
+	while (!can_add_transmit(&PacketP, PortP) && !p->RIOHalted) {
+		rio_dprintk(RIO_DEBUG_TTY, "Waiting to add short command to queue (%d)\n", retries);
 		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
 		if (retries-- <= 0) {
-		  rio_dprintk (RIO_DEBUG_TTY, "out of tries. Failing\n");
+			rio_dprintk(RIO_DEBUG_TTY, "out of tries. Failing\n");
 			return RIO_FAIL;
 		}
-		if ( RIODelay_ni(PortP, HUNDRED_MS)==RIO_FAIL ) {
+		if (RIODelay_ni(PortP, HUNDRED_MS) == RIO_FAIL) {
 			return RIO_FAIL;
 		}
 		rio_spin_lock_irqsave(&PortP->portSem, flags);
 	}
 
-	if ( p->RIOHalted ) {
+	if (p->RIOHalted) {
 		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
 		return RIO_FAIL;
 	}
 
 	/*
-	** set the command byte and the argument byte
-	*/
-	WBYTE(PacketP->data[0] , command);
+	 ** set the command byte and the argument byte
+	 */
+	WBYTE(PacketP->data[0], command);
 
-	if ( len==2 )
-		WBYTE(PacketP->data[1] , arg);
+	if (len == 2)
+		WBYTE(PacketP->data[1], arg);
 
 	/*
-	** set the length of the packet and set the command bit.
-	*/
-	WBYTE(PacketP->len , PKT_CMD_BIT | len);
+	 ** set the length of the packet and set the command bit.
+	 */
+	WBYTE(PacketP->len, PKT_CMD_BIT | len);
 
 	add_transmit(PortP);
 	/*
-	** Count characters transmitted for port statistics reporting
-	*/
+	 ** Count characters transmitted for port statistics reporting
+	 */
 	if (PortP->statsGather)
 		PortP->txchars += len;
 
@@ -878,28 +857,26 @@
 ** This is an ioctl interface. This is the twentieth century. You know what
 ** its all about.
 */
-int
-riotioctl(struct rio_info *p, struct tty_struct *tty, int cmd, caddr_t arg)
+int riotioctl(struct rio_info *p, struct tty_struct *tty, int cmd, caddr_t arg)
 {
-	register struct		Port *PortP;
-	register struct		ttystatics *tp;
-	int					current;
-	int					ParamSemIncremented = 0;
-	int					old_oflag, old_cflag, old_iflag, changed, oldcook;
-	int					i;
-	unsigned char		sio_regs[5];		/* Here be magic */
-	short				vpix_cflag;
-	short				divisor;
-	int					baud;
-	uint				SysPort = rio_minor(tty);
-	int				Modem = rio_ismodem(tty);
-	int					ioctl_processed;
+	register struct Port *PortP;
+	register struct ttystatics *tp;
+	int current;
+	int ParamSemIncremented = 0;
+	int old_oflag, old_cflag, old_iflag, changed, oldcook;
+	int i;
+	unsigned char sio_regs[5];	/* Here be magic */
+	short vpix_cflag;
+	short divisor;
+	int baud;
+	uint SysPort = rio_minor(tty);
+	int Modem = rio_ismodem(tty);
+	int ioctl_processed;
 
-	rio_dprintk (RIO_DEBUG_TTY, "port ioctl SysPort %d command 0x%x argument 0x%x %s\n",
-			SysPort, cmd, arg, Modem?"Modem":"tty") ;
+	rio_dprintk(RIO_DEBUG_TTY, "port ioctl SysPort %d command 0x%x argument 0x%x %s\n", SysPort, cmd, arg, Modem ? "Modem" : "tty");
 
-	if ( SysPort >= RIO_PORTS ) {
-		rio_dprintk (RIO_DEBUG_TTY, "Bad port number %d\n", SysPort);
+	if (SysPort >= RIO_PORTS) {
+		rio_dprintk(RIO_DEBUG_TTY, "Bad port number %d\n", SysPort);
 		return -ENXIO;
 	}
 
@@ -912,205 +889,195 @@
 	PortP->Stat.IoctlCnt++;
 #endif
 
-	if ( PortP->State & RIO_DELETED ) {
+	if (PortP->State & RIO_DELETED) {
 		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
 		return -EIO;
 	}
 
 
-	if ( p->RIOHalted ) {
-		RIOClearUp( PortP );
+	if (p->RIOHalted) {
+		RIOClearUp(PortP);
 		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
 		return -EIO;
 	}
 
 	/*
-	** Count ioctls for port statistics reporting
-	*/
+	 ** Count ioctls for port statistics reporting
+	 */
 	if (PortP->statsGather)
 		PortP->ioctls++;
 
 	/*
-	** Specialix RIO Ioctl calls
-	*/
+	 ** Specialix RIO Ioctl calls
+	 */
 	switch (cmd) {
 
-		case TCRIOTRIAD:
-			if ( arg )
-				PortP->State |= RIO_TRIAD_MODE;
-			else
-				PortP->State &= ~RIO_TRIAD_MODE;
-			/*
-			** Normally, when istrip is set on a port, a config is
-			** sent to the RTA instructing the CD1400 to do the
-			** stripping. In TRIAD mode, the interrupt receive routine
-			** must do the stripping instead, since it has to detect
-			** an 8 bit function key sequence. If istrip is set with
-			** TRIAD mode on(off), and 8 bit data is being read by
-			** the port, the user then turns TRIAD mode off(on), the RTA
-			** must be reconfigured (not) to do the stripping.
-			** Hence we call RIOParam here.
-			*/
-			rio_spin_unlock_irqrestore(&PortP->portSem, flags);
-			RIOParam(PortP,CONFIG,Modem,OK_TO_SLEEP);	
-			return 0;
+	case TCRIOTRIAD:
+		if (arg)
+			PortP->State |= RIO_TRIAD_MODE;
+		else
+			PortP->State &= ~RIO_TRIAD_MODE;
+		/*
+		 ** Normally, when istrip is set on a port, a config is
+		 ** sent to the RTA instructing the CD1400 to do the
+		 ** stripping. In TRIAD mode, the interrupt receive routine
+		 ** must do the stripping instead, since it has to detect
+		 ** an 8 bit function key sequence. If istrip is set with
+		 ** TRIAD mode on(off), and 8 bit data is being read by
+		 ** the port, the user then turns TRIAD mode off(on), the RTA
+		 ** must be reconfigured (not) to do the stripping.
+		 ** Hence we call RIOParam here.
+		 */
+		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+		RIOParam(PortP, CONFIG, Modem, OK_TO_SLEEP);
+		return 0;
 
-		case TCRIOTSTATE:
-			rio_dprintk (RIO_DEBUG_TTY, "tbusy/tstop monitoring %sabled\n",
-		 		arg ? "en" : "dis");
-			/* MonitorTstate = 0 ;*/
-			rio_spin_unlock_irqrestore(&PortP->portSem, flags);
-			RIOParam(PortP, CONFIG, Modem, OK_TO_SLEEP);
-			return 0;
+	case TCRIOTSTATE:
+		rio_dprintk(RIO_DEBUG_TTY, "tbusy/tstop monitoring %sabled\n", arg ? "en" : "dis");
+		/* MonitorTstate = 0 ; */
+		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+		RIOParam(PortP, CONFIG, Modem, OK_TO_SLEEP);
+		return 0;
 
-		case TCRIOSTATE: /* current state of Modem input pins */
-			rio_dprintk (RIO_DEBUG_TTY, "TCRIOSTATE\n");
-			if (RIOPreemptiveCmd(p, PortP, MGET) == RIO_FAIL)
-				rio_dprintk (RIO_DEBUG_TTY, "TCRIOSTATE command failed\n");
-			PortP->State |= RIO_BUSY;
-			current = PortP->ModemState;
-			if ( copyout((caddr_t)&current, (int)arg,
-							sizeof(current))==COPYFAIL ) {
-				rio_dprintk (RIO_DEBUG_TTY, "Copyout failed\n");
-				rio_spin_unlock_irqrestore(&PortP->portSem, flags);
-				pseterr(EFAULT);
-			}
+	case TCRIOSTATE:	/* current state of Modem input pins */
+		rio_dprintk(RIO_DEBUG_TTY, "TCRIOSTATE\n");
+		if (RIOPreemptiveCmd(p, PortP, MGET) == RIO_FAIL)
+			rio_dprintk(RIO_DEBUG_TTY, "TCRIOSTATE command failed\n");
+		PortP->State |= RIO_BUSY;
+		current = PortP->ModemState;
+		if (copyout((caddr_t) & current, (int) arg, sizeof(current)) == COPYFAIL) {
+			rio_dprintk(RIO_DEBUG_TTY, "Copyout failed\n");
 			rio_spin_unlock_irqrestore(&PortP->portSem, flags);
-			return 0;
+			pseterr(EFAULT);
+		}
+		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+		return 0;
 
-		case TCRIOMBIS:		/* Set modem lines */
-		case TCRIOMBIC:		/* Clear modem lines */
-			rio_dprintk (RIO_DEBUG_TTY, "TCRIOMBIS/TCRIOMBIC\n");
-			if (cmd == TCRIOMBIS) {
-				uint		state;
-				state = (uint)arg;
-				PortP->ModemState |= (ushort)state;
-				PortP->ModemLines = (ulong) arg;
-				if (RIOPreemptiveCmd(p, PortP, MBIS) == RIO_FAIL)
-					rio_dprintk (RIO_DEBUG_TTY, 
-					 "TCRIOMBIS command failed\n");
-			}
-			else {
-				uint		state;
+	case TCRIOMBIS:	/* Set modem lines */
+	case TCRIOMBIC:	/* Clear modem lines */
+		rio_dprintk(RIO_DEBUG_TTY, "TCRIOMBIS/TCRIOMBIC\n");
+		if (cmd == TCRIOMBIS) {
+			uint state;
+			state = (uint) arg;
+			PortP->ModemState |= (ushort) state;
+			PortP->ModemLines = (ulong) arg;
+			if (RIOPreemptiveCmd(p, PortP, MBIS) == RIO_FAIL)
+				rio_dprintk(RIO_DEBUG_TTY, "TCRIOMBIS command failed\n");
+		} else {
+			uint state;
 
-				state = (uint)arg;
-				PortP->ModemState &= ~(ushort)state;
-				PortP->ModemLines = (ulong) arg;
-				if (RIOPreemptiveCmd(p, PortP, MBIC) == RIO_FAIL)
-					rio_dprintk (RIO_DEBUG_TTY, "TCRIOMBIC command failed\n");
-			}
-			PortP->State |= RIO_BUSY;
+			state = (uint) arg;
+			PortP->ModemState &= ~(ushort) state;
+			PortP->ModemLines = (ulong) arg;
+			if (RIOPreemptiveCmd(p, PortP, MBIC) == RIO_FAIL)
+				rio_dprintk(RIO_DEBUG_TTY, "TCRIOMBIC command failed\n");
+		}
+		PortP->State |= RIO_BUSY;
+		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+		return 0;
+
+	case TCRIOXPON:	/* set Xprint ON string */
+		rio_dprintk(RIO_DEBUG_TTY, "TCRIOXPON\n");
+		if (copyin((int) arg, (caddr_t) PortP->Xprint.XpOn, MAX_XP_CTRL_LEN) == COPYFAIL) {
+			rio_dprintk(RIO_DEBUG_TTY, "Copyin failed\n");
+			PortP->Xprint.XpOn[0] = '\0';
 			rio_spin_unlock_irqrestore(&PortP->portSem, flags);
-			return 0;
+			pseterr(EFAULT);
+		}
+		PortP->Xprint.XpOn[MAX_XP_CTRL_LEN - 1] = '\0';
+		PortP->Xprint.XpLen = strlen(PortP->Xprint.XpOn) + strlen(PortP->Xprint.XpOff);
+		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+		return 0;
 
-		case TCRIOXPON: /* set Xprint ON string */
-			rio_dprintk (RIO_DEBUG_TTY, "TCRIOXPON\n");
-			if ( copyin((int)arg, (caddr_t)PortP->Xprint.XpOn,
-						MAX_XP_CTRL_LEN)==COPYFAIL ) {
-				rio_dprintk (RIO_DEBUG_TTY, "Copyin failed\n");
-				PortP->Xprint.XpOn[0] = '\0';
-				rio_spin_unlock_irqrestore(&PortP->portSem, flags);
-				pseterr(EFAULT);
-			}
-			PortP->Xprint.XpOn[MAX_XP_CTRL_LEN-1] = '\0';
-			PortP->Xprint.XpLen = strlen(PortP->Xprint.XpOn)+
-												strlen(PortP->Xprint.XpOff);
+	case TCRIOXPOFF:	/* set Xprint OFF string */
+		rio_dprintk(RIO_DEBUG_TTY, "TCRIOXPOFF\n");
+		if (copyin((int) arg, (caddr_t) PortP->Xprint.XpOff, MAX_XP_CTRL_LEN) == COPYFAIL) {
+			rio_dprintk(RIO_DEBUG_TTY, "Copyin failed\n");
+			PortP->Xprint.XpOff[0] = '\0';
 			rio_spin_unlock_irqrestore(&PortP->portSem, flags);
-			return 0;
+			pseterr(EFAULT);
+		}
+		PortP->Xprint.XpOff[MAX_XP_CTRL_LEN - 1] = '\0';
+		PortP->Xprint.XpLen = strlen(PortP->Xprint.XpOn) + strlen(PortP->Xprint.XpOff);
+		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+		return 0;
 
-		case TCRIOXPOFF: /* set Xprint OFF string */
-			rio_dprintk (RIO_DEBUG_TTY, "TCRIOXPOFF\n");
-			if ( copyin( (int)arg, (caddr_t)PortP->Xprint.XpOff,
-						MAX_XP_CTRL_LEN)==COPYFAIL ) {
-				rio_dprintk (RIO_DEBUG_TTY, "Copyin failed\n");
-				PortP->Xprint.XpOff[0] = '\0';
-				rio_spin_unlock_irqrestore(&PortP->portSem, flags);
-				pseterr(EFAULT);
-			}
-			PortP->Xprint.XpOff[MAX_XP_CTRL_LEN-1] = '\0';
-			PortP->Xprint.XpLen = strlen(PortP->Xprint.XpOn)+
-										strlen(PortP->Xprint.XpOff);
+	case TCRIOXPCPS:	/* set Xprint CPS string */
+		rio_dprintk(RIO_DEBUG_TTY, "TCRIOXPCPS\n");
+		if ((uint) arg > p->RIOConf.MaxXpCps || (uint) arg < p->RIOConf.MinXpCps) {
+			rio_dprintk(RIO_DEBUG_TTY, "%d CPS out of range\n", arg);
 			rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+			pseterr(EINVAL);
 			return 0;
+		}
+		PortP->Xprint.XpCps = (uint) arg;
+		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+		return 0;
 
-		case TCRIOXPCPS: /* set Xprint CPS string */
-			rio_dprintk (RIO_DEBUG_TTY, "TCRIOXPCPS\n");
-			if ( (uint)arg > p->RIOConf.MaxXpCps || 
-					(uint)arg < p->RIOConf.MinXpCps ) {
-				rio_dprintk (RIO_DEBUG_TTY, "%d CPS out of range\n",arg);
-				rio_spin_unlock_irqrestore(&PortP->portSem, flags);
-				pseterr(EINVAL);
-				return 0;
-			}
-			PortP->Xprint.XpCps = (uint)arg;
+	case TCRIOXPRINT:
+		rio_dprintk(RIO_DEBUG_TTY, "TCRIOXPRINT\n");
+		if (copyout((caddr_t) & PortP->Xprint, (int) arg, sizeof(struct Xprint)) == COPYFAIL) {
 			rio_spin_unlock_irqrestore(&PortP->portSem, flags);
-			return 0;
+			pseterr(EFAULT);
+		}
+		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+		return 0;
 
-		case TCRIOXPRINT:
-			rio_dprintk (RIO_DEBUG_TTY, "TCRIOXPRINT\n");
-			if ( copyout((caddr_t)&PortP->Xprint, (int)arg,
-					sizeof(struct Xprint))==COPYFAIL ) {
-			        rio_spin_unlock_irqrestore(&PortP->portSem, flags);
-				pseterr(EFAULT);
-			}
-			rio_spin_unlock_irqrestore(&PortP->portSem, flags);
-			return 0;
+	case TCRIOIXANYON:
+		rio_dprintk(RIO_DEBUG_TTY, "TCRIOIXANYON\n");
+		PortP->Config |= RIO_IXANY;
+		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+		return 0;
 
-		case TCRIOIXANYON:
-			rio_dprintk (RIO_DEBUG_TTY, "TCRIOIXANYON\n");
-			PortP->Config |= RIO_IXANY;
-			rio_spin_unlock_irqrestore(&PortP->portSem, flags);
-			return 0;
+	case TCRIOIXANYOFF:
+		rio_dprintk(RIO_DEBUG_TTY, "TCRIOIXANYOFF\n");
+		PortP->Config &= ~RIO_IXANY;
+		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+		return 0;
 
-		case TCRIOIXANYOFF:
-			rio_dprintk (RIO_DEBUG_TTY, "TCRIOIXANYOFF\n");
-			PortP->Config &= ~RIO_IXANY;
-			rio_spin_unlock_irqrestore(&PortP->portSem, flags);
-			return 0;
+	case TCRIOIXONON:
+		rio_dprintk(RIO_DEBUG_TTY, "TCRIOIXONON\n");
+		PortP->Config |= RIO_IXON;
+		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+		return 0;
 
-		case TCRIOIXONON:
-			rio_dprintk (RIO_DEBUG_TTY, "TCRIOIXONON\n");
-			PortP->Config |= RIO_IXON;
-			rio_spin_unlock_irqrestore(&PortP->portSem, flags);
-			return 0;
-
-		case TCRIOIXONOFF:
-			rio_dprintk (RIO_DEBUG_TTY, "TCRIOIXONOFF\n");
-			PortP->Config &= ~RIO_IXON;
-			rio_spin_unlock_irqrestore(&PortP->portSem, flags);
-			return 0;
+	case TCRIOIXONOFF:
+		rio_dprintk(RIO_DEBUG_TTY, "TCRIOIXONOFF\n");
+		PortP->Config &= ~RIO_IXON;
+		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+		return 0;
 
 /*
 ** 15.10.1998 ARG - ESIL 0761 part fix
 ** Added support for CTS and RTS flow control ioctls :
 */
-		case TCRIOCTSFLOWEN:
-			rio_dprintk (RIO_DEBUG_TTY, "TCRIOCTSFLOWEN\n");
-			PortP->Config |= RIO_CTSFLOW;
-			rio_spin_unlock_irqrestore(&PortP->portSem, flags);
-			RIOParam(PortP,CONFIG,Modem,OK_TO_SLEEP);	
-			return 0;
+	case TCRIOCTSFLOWEN:
+		rio_dprintk(RIO_DEBUG_TTY, "TCRIOCTSFLOWEN\n");
+		PortP->Config |= RIO_CTSFLOW;
+		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+		RIOParam(PortP, CONFIG, Modem, OK_TO_SLEEP);
+		return 0;
 
-		case TCRIOCTSFLOWDIS:
-			rio_dprintk (RIO_DEBUG_TTY, "TCRIOCTSFLOWDIS\n");
-			PortP->Config &= ~RIO_CTSFLOW;
-			rio_spin_unlock_irqrestore(&PortP->portSem, flags);
-			RIOParam(PortP,CONFIG,Modem,OK_TO_SLEEP);	
-			return 0;
+	case TCRIOCTSFLOWDIS:
+		rio_dprintk(RIO_DEBUG_TTY, "TCRIOCTSFLOWDIS\n");
+		PortP->Config &= ~RIO_CTSFLOW;
+		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+		RIOParam(PortP, CONFIG, Modem, OK_TO_SLEEP);
+		return 0;
 
-		case TCRIORTSFLOWEN:
-			rio_dprintk (RIO_DEBUG_TTY, "TCRIORTSFLOWEN\n");
-			PortP->Config |= RIO_RTSFLOW;
-			rio_spin_unlock_irqrestore(&PortP->portSem, flags);
-			RIOParam(PortP,CONFIG,Modem,OK_TO_SLEEP);	
-			return 0;
+	case TCRIORTSFLOWEN:
+		rio_dprintk(RIO_DEBUG_TTY, "TCRIORTSFLOWEN\n");
+		PortP->Config |= RIO_RTSFLOW;
+		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+		RIOParam(PortP, CONFIG, Modem, OK_TO_SLEEP);
+		return 0;
 
-		case TCRIORTSFLOWDIS:
-			rio_dprintk (RIO_DEBUG_TTY, "TCRIORTSFLOWDIS\n");
-			PortP->Config &= ~RIO_RTSFLOW;
-			rio_spin_unlock_irqrestore(&PortP->portSem, flags);
-			RIOParam(PortP,CONFIG,Modem,OK_TO_SLEEP);	
-			return 0;
+	case TCRIORTSFLOWDIS:
+		rio_dprintk(RIO_DEBUG_TTY, "TCRIORTSFLOWDIS\n");
+		PortP->Config &= ~RIO_RTSFLOW;
+		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+		RIOParam(PortP, CONFIG, Modem, OK_TO_SLEEP);
+		return 0;
 
 /* end ESIL 0761 part fix */
 
@@ -1119,35 +1086,35 @@
 
 	/* Lynx IOCTLS */
 	switch (cmd) {
-		case TIOCSETP:
-		case TIOCSETN:
-		case OTIOCSETP:
-		case OTIOCSETN:
-			ioctl_processed++;
-			ttyseth(PortP, tp, (struct old_sgttyb *)arg);
-			break;
-		case TCSETA:
-		case TCSETAW:
-		case TCSETAF:
-			ioctl_processed++;
-			rio_dprintk (RIO_DEBUG_TTY, "NON POSIX ioctl\n");
-			ttyseth_pv(PortP, tp, (struct termios *)arg, 0);
-			break;
-		case TCSETAP:	/* posix tcsetattr() */
-		case TCSETAWP:	/* posix tcsetattr() */
-		case TCSETAFP:	/* posix tcsetattr() */
-			rio_dprintk (RIO_DEBUG_TTY, "NON POSIX SYSV ioctl\n");
-			ttyseth_pv(PortP, tp, (struct termios *)arg, 1);
-			ioctl_processed++;
-			break;
+	case TIOCSETP:
+	case TIOCSETN:
+	case OTIOCSETP:
+	case OTIOCSETN:
+		ioctl_processed++;
+		ttyseth(PortP, tp, (struct old_sgttyb *) arg);
+		break;
+	case TCSETA:
+	case TCSETAW:
+	case TCSETAF:
+		ioctl_processed++;
+		rio_dprintk(RIO_DEBUG_TTY, "NON POSIX ioctl\n");
+		ttyseth_pv(PortP, tp, (struct termios *) arg, 0);
+		break;
+	case TCSETAP:		/* posix tcsetattr() */
+	case TCSETAWP:		/* posix tcsetattr() */
+	case TCSETAFP:		/* posix tcsetattr() */
+		rio_dprintk(RIO_DEBUG_TTY, "NON POSIX SYSV ioctl\n");
+		ttyseth_pv(PortP, tp, (struct termios *) arg, 1);
+		ioctl_processed++;
+		break;
 	}
 
 	/*
-	** If its any of the commands that require the port to be in the
-	** non-busy state wait until all output has drained 
-	*/
+	 ** If its any of the commands that require the port to be in the
+	 ** non-busy state wait until all output has drained
+	 */
 	if (!ioctl_processed)
-	switch(cmd) {
+		switch (cmd) {
 		case TCSETAW:
 		case TCSETAF:
 		case TCSETA:
@@ -1171,29 +1138,29 @@
 #endif
 		case TIOCSETD:
 		case TIOCSETN:
-			rio_dprintk (RIO_DEBUG_TTY, "wait for non-BUSY, semaphore set\n");
+			rio_dprintk(RIO_DEBUG_TTY, "wait for non-BUSY, semaphore set\n");
 			/*
-			** Wait for drain here, at least as far as the double buffer
-			** being empty.
-			*/
+			 ** Wait for drain here, at least as far as the double buffer
+			 ** being empty.
+			 */
 			/* XXX Does the above comment mean that this has
 			   still to be implemented? -- REW */
 			/* XXX Is the locking OK together with locking
-                           in txenable? (Deadlock?) -- REW */
-			
-			RIOTxEnable((char *)PortP);
+			   in txenable? (Deadlock?) -- REW */
+
+			RIOTxEnable((char *) PortP);
 			break;
 		default:
 			break;
-	}
+		}
 
 	old_cflag = tp->tm.c_cflag;
 	old_iflag = tp->tm.c_iflag;
 	old_oflag = tp->tm.c_oflag;
 	oldcook = PortP->CookMode;
 
-	if ( p->RIOHalted ) {
-		RIOClearUp( PortP );
+	if (p->RIOHalted) {
+		RIOClearUp(PortP);
 		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
 		pseterr(EIO);
 		return 0;
@@ -1202,10 +1169,10 @@
 	PortP->FlushCmdBodge = 0;
 
 	/*
-	** If the port is locked, and it is reconfigured, we want
-	** to restore the state of the tty structure so the change is NOT
-	** made.
-	*/
+	 ** If the port is locked, and it is reconfigured, we want
+	 ** to restore the state of the tty structure so the change is NOT
+	 ** made.
+	 */
 	if (PortP->Lock) {
 		tp->tm.c_iflag = PortP->StoredTty.iflag;
 		tp->tm.c_oflag = PortP->StoredTty.oflag;
@@ -1214,13 +1181,12 @@
 		tp->tm.c_line = PortP->StoredTty.line;
 		for (i = 0; i < NCC + 1; i++)
 			tp->tm.c_cc[i] = PortP->StoredTty.cc[i];
-	}
-	else {
+	} else {
 		/*
-		** If the port is set to store the parameters, and it is
-		** reconfigured, we want to save the current tty struct so it
-		** may be restored on the next open.
-		*/
+		 ** If the port is set to store the parameters, and it is
+		 ** reconfigured, we want to save the current tty struct so it
+		 ** may be restored on the next open.
+		 */
 		if (PortP->Store) {
 			PortP->StoredTty.iflag = tp->tm.c_iflag;
 			PortP->StoredTty.oflag = tp->tm.c_oflag;
@@ -1232,44 +1198,41 @@
 		}
 	}
 
-	changed = (tp->tm.c_cflag != old_cflag) ||
-				(tp->tm.c_iflag != old_iflag) ||
-				(tp->tm.c_oflag != old_oflag);
+	changed = (tp->tm.c_cflag != old_cflag) || (tp->tm.c_iflag != old_iflag) || (tp->tm.c_oflag != old_oflag);
 
 	PortP->CookMode = RIOCookMode(tp);	/* Set new cooking mode */
 
-	rio_dprintk (RIO_DEBUG_TTY, "RIOIoctl changed %d newcook %d oldcook %d\n",
-			changed,PortP->CookMode,oldcook);
+	rio_dprintk(RIO_DEBUG_TTY, "RIOIoctl changed %d newcook %d oldcook %d\n", changed, PortP->CookMode, oldcook);
 
 #ifdef MODEM_SUPPORT
 	/*
-	** kludge to force CARR_ON if CLOCAL set
-	*/
-	if ((tp->tm.c_cflag & CLOCAL) || (PortP->ModemState & MSVR1_CD))	{
+	 ** kludge to force CARR_ON if CLOCAL set
+	 */
+	if ((tp->tm.c_cflag & CLOCAL) || (PortP->ModemState & MSVR1_CD)) {
 		tp->tm.c_state |= CARR_ON;
-		wakeup ((caddr_t)&tp->tm.c_canq);
+		wakeup((caddr_t) & tp->tm.c_canq);
 	}
 #endif
 
-	if ( p->RIOHalted ) {
-		RIOClearUp( PortP );
+	if (p->RIOHalted) {
+		RIOClearUp(PortP);
 		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
 		pseterr(EIO);
 		return 0;
 	}
 	/*
-	** Re-configure if modes or cooking have changed
-	*/
+	 ** Re-configure if modes or cooking have changed
+	 */
 	if (changed || oldcook != PortP->CookMode || (ioctl_processed)) {
 		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
-		rio_dprintk (RIO_DEBUG_TTY, "Ioctl changing the PORT settings\n");
-		RIOParam(PortP,CONFIG,Modem,OK_TO_SLEEP);	
+		rio_dprintk(RIO_DEBUG_TTY, "Ioctl changing the PORT settings\n");
+		RIOParam(PortP, CONFIG, Modem, OK_TO_SLEEP);
 		rio_spin_lock_irqsave(&PortP->portSem, flags);
 	}
 
 	if (p->RIOHalted) {
 		rio_spin_unlock_irqrestore(&PortP->portSem, flags);
-		RIOClearUp( PortP );
+		RIOClearUp(PortP);
 		pseterr(EIO);
 		return 0;
 	}
@@ -1280,36 +1243,32 @@
 /*
 	ttyseth -- set hardware dependent tty settings
 */
-void
-ttyseth(PortP, s, sg)
-struct Port *		PortP;
-struct ttystatics *		s;
+void ttyseth(PortP, s, sg)
+struct Port *PortP;
+struct ttystatics *s;
 struct old_sgttyb *sg;
 {
-	struct old_sgttyb *	tsg;
+	struct old_sgttyb *tsg;
 	struct termios *tp = &s->tm;
 
 	tsg = &s->sg;
 
-	if (sg->sg_flags & (EVENP|ODDP))  {
+	if (sg->sg_flags & (EVENP | ODDP)) {
 		tp->c_cflag &= PARENB;
 		if (sg->sg_flags & EVENP) {
 			if (sg->sg_flags & ODDP) {
 				tp->c_cflag &= V_CS7;
 				tp->c_cflag &= ~PARENB;
-			}
-			else {
+			} else {
 				tp->c_cflag &= V_CS7;
 				tp->c_cflag &= PARENB;
 				tp->c_cflag &= PARODD;
 			}
-		}
-		else if (sg->sg_flags & ODDP) {
+		} else if (sg->sg_flags & ODDP) {
 			tp->c_cflag &= V_CS7;
 			tp->c_cflag &= PARENB;
 			tp->c_cflag &= PARODD;
-		}
-		else {
+		} else {
 			tp->c_cflag &= V_CS7;
 			tp->c_cflag &= PARENB;
 		}
@@ -1320,16 +1279,16 @@
  * I will have to use separate sets of flags to store them in the 
  * Port structure.
  */
-	if ( !sg->sg_ospeed )
+	if (!sg->sg_ospeed)
 		sg->sg_ospeed = sg->sg_ispeed;
 	else
 		sg->sg_ispeed = sg->sg_ospeed;
-	if (sg->sg_ispeed > V_EXTB ) 
+	if (sg->sg_ispeed > V_EXTB)
 		sg->sg_ispeed = V_EXTB;
 	if (sg->sg_ispeed < V_B0)
 		sg->sg_ispeed = V_B0;
 	*tsg = *sg;
-   tp->c_cflag = (tp->c_cflag & ~V_CBAUD) | conv_bv[(int)sg->sg_ispeed];
+	tp->c_cflag = (tp->c_cflag & ~V_CBAUD) | conv_bv[(int) sg->sg_ispeed];
 }
 
 /*
@@ -1338,36 +1297,33 @@
 				sysv = 0 => (POSIX):	 struct termios *sg
 				sysv != 0 => (System V): struct termio *sg
 */
-static void
-ttyseth_pv(PortP, s, sg, sysv)
+static void ttyseth_pv(PortP, s, sg, sysv)
 struct Port *PortP;
 struct ttystatics *s;
 struct termios *sg;
 int sysv;
 {
-    int speed;
-    unsigned char csize;
-    unsigned char cread;
-    unsigned int lcr_flags;
-    int ps;
- 
-    if (sysv) {
-        /* sg points to a System V termio structure */
-        csize = ((struct termio *)sg)->c_cflag & CSIZE;
-        cread = ((struct termio *)sg)->c_cflag & CREAD;
-        speed = conv_vb[((struct termio *)sg)->c_cflag & V_CBAUD];
-    }
-    else {
-        /* sg points to a POSIX termios structure */
-        csize = sg->c_cflag & CSIZE;
-        cread = sg->c_cflag & CREAD;
-        speed = conv_vb[sg->c_cflag & V_CBAUD];
-    }
-    if (s->sg.sg_ispeed != speed || s->sg.sg_ospeed != speed) {
-        s->sg.sg_ispeed = speed;
-        s->sg.sg_ospeed = speed;
-        s->tm.c_cflag = (s->tm.c_cflag & ~V_CBAUD) |
-                         conv_bv[(int)s->sg.sg_ispeed];
-    }
+	int speed;
+	unsigned char csize;
+	unsigned char cread;
+	unsigned int lcr_flags;
+	int ps;
+
+	if (sysv) {
+		/* sg points to a System V termio structure */
+		csize = ((struct termio *) sg)->c_cflag & CSIZE;
+		cread = ((struct termio *) sg)->c_cflag & CREAD;
+		speed = conv_vb[((struct termio *) sg)->c_cflag & V_CBAUD];
+	} else {
+		/* sg points to a POSIX termios structure */
+		csize = sg->c_cflag & CSIZE;
+		cread = sg->c_cflag & CREAD;
+		speed = conv_vb[sg->c_cflag & V_CBAUD];
+	}
+	if (s->sg.sg_ispeed != speed || s->sg.sg_ospeed != speed) {
+		s->sg.sg_ispeed = speed;
+		s->sg.sg_ospeed = speed;
+		s->tm.c_cflag = (s->tm.c_cflag & ~V_CBAUD) | conv_bv[(int) s->sg.sg_ispeed];
+	}
 }
 #endif
diff --git a/drivers/char/rio/riotypes.h b/drivers/char/rio/riotypes.h
index 1c7c42c..9b67e24 100644
--- a/drivers/char/rio/riotypes.h
+++ b/drivers/char/rio/riotypes.h
@@ -89,47 +89,46 @@
 typedef RIO_POINTER ushort_ptr;
 #endif
 
-#else /* not INKERNEL */
-typedef unsigned char   BYTE;
-typedef unsigned short  WORD;
-typedef unsigned long   DWORD;
-typedef short           NUMBER;
-typedef short           *NUMBER_ptr;
-typedef unsigned short  *WORD_ptr;
-typedef unsigned char   *BYTE_ptr;
-typedef unsigned char   uchar ;
-typedef unsigned short  ushort ;
-typedef unsigned int    uint ;
-typedef unsigned long   ulong ;
-typedef unsigned char   u_char ;
-typedef unsigned short  u_short ;
-typedef unsigned int    u_int ;
-typedef unsigned long   u_long ;
-typedef unsigned short  ERROR ;
-typedef unsigned long ID ;
-typedef char             *char_ptr;
-typedef Channel          *Channel_ptr;
+#else				/* not INKERNEL */
+typedef unsigned char BYTE;
+typedef unsigned short WORD;
+typedef unsigned long DWORD;
+typedef short NUMBER;
+typedef short *NUMBER_ptr;
+typedef unsigned short *WORD_ptr;
+typedef unsigned char *BYTE_ptr;
+typedef unsigned char uchar;
+typedef unsigned short ushort;
+typedef unsigned int uint;
+typedef unsigned long ulong;
+typedef unsigned char u_char;
+typedef unsigned short u_short;
+typedef unsigned int u_int;
+typedef unsigned long u_long;
+typedef unsigned short ERROR;
+typedef unsigned long ID;
+typedef char *char_ptr;
+typedef Channel *Channel_ptr;
 typedef struct FREE_LIST *FREE_LIST_ptr;
 typedef struct FREE_LIST **FREE_LIST_ptr_ptr;
-typedef struct LPB       *LPB_ptr;
-typedef struct Process   *Process_ptr;
-typedef struct PHB       *PHB_ptr;
-typedef struct PKT       *PKT_ptr;
-typedef struct PKT       **PKT_ptr_ptr;
-typedef struct Q_BUF     *Q_BUF_ptr;
-typedef struct Q_BUF     **Q_BUF_ptr_ptr;
+typedef struct LPB *LPB_ptr;
+typedef struct Process *Process_ptr;
+typedef struct PHB *PHB_ptr;
+typedef struct PKT *PKT_ptr;
+typedef struct PKT **PKT_ptr_ptr;
+typedef struct Q_BUF *Q_BUF_ptr;
+typedef struct Q_BUF **Q_BUF_ptr_ptr;
 typedef struct ROUTE_STR *ROUTE_STR_ptr;
-typedef struct RUP       *RUP_ptr;
-typedef short            *short_ptr;
-typedef u_short          *u_short_ptr;
-typedef ushort           *ushort_ptr;
-typedef struct PKT	 PKT;
-typedef struct LPB	 LPB;
-typedef struct RUP	 RUP;
+typedef struct RUP *RUP_ptr;
+typedef short *short_ptr;
+typedef u_short *u_short_ptr;
+typedef ushort *ushort_ptr;
+typedef struct PKT PKT;
+typedef struct LPB LPB;
+typedef struct RUP RUP;
 #endif
 
 
-#endif /* __riotypes__ */
+#endif				/* __riotypes__ */
 
 /*********** end of file ***********/
-
diff --git a/drivers/char/rio/riowinif.h b/drivers/char/rio/riowinif.h
index 18a4f14..f802d75 100644
--- a/drivers/char/rio/riowinif.h
+++ b/drivers/char/rio/riowinif.h
@@ -40,7 +40,7 @@
 
 */
 
-#ifndef	_riowinif_h				/* If RIOWINDIF.H not already defined */
+#ifndef	_riowinif_h		/* If RIOWINDIF.H not already defined */
 #define	_riowinif_h    1
 
 /*****************************************************************************
@@ -60,42 +60,41 @@
 /* The PARM_MAP structure defines global values relating to the Host Card / RTA
    and is the main structure from which all other structures are referenced. */
 
-typedef	struct	_PARM_MAP
-{
-	_u16	phb_ptr;		/* 0x00 Pointer to the PHB array */
-	_u16	phb_num_ptr;		/* 0x02 Ptr to Number of PHB's */
-	_u16	free_list;		/* 0x04 Free List pointer */
-	_u16	free_list_end;		/* 0x06 Free List End pointer */
-	_u16	q_free_list_ptr;	/* 0x08 Ptr to Q_BUF variable */
-	_u16	unit_id_ptr;		/* 0x0A Unit Id */
-	_u16	link_str_ptr;		/* 0x0C Link Structure Array */
-	_u16	bootloader_1;		/* 0x0E 1st Stage Boot Loader */
-	_u16	bootloader_2;		/* 0x10 2nd Stage Boot Loader */
-	_u16	port_route_map_ptr;	/* 0x12 Port Route Map */
-	_u16	route_ptr;		/* 0x14 Route Map */
-	_u16	map_present;		/* 0x16 Route Map present */
-	_u16	pkt_num;		/* 0x18 Total number of packets */
-	_u16	q_num;			/* 0x1A Total number of Q packets */
-	_u16	buffers_per_port;	/* 0x1C Number of buffers per port */
-	_u16	heap_size;		/* 0x1E Initial size of heap */
-	_u16	heap_left;		/* 0x20 Current Heap left */
-	_u16	error;			/* 0x22 Error code */
-	_u16	tx_max;			/* 0x24 Max number of tx pkts per phb */
-	_u16	rx_max;			/* 0x26 Max number of rx pkts per phb */
-	_u16	rx_limit;		/* 0x28 For high / low watermarks */
-	_u16	links;			/* 0x2A Links to use */
-	_u16	timer;			/* 0x2C Interrupts per second */
-	_u16	rups;			/* 0x2E Pointer to the RUPs */
-	_u16	max_phb;		/* 0x30 Mostly for debugging */
-	_u16	living;			/* 0x32 Just increments!! */
-	_u16	init_done;		/* 0x34 Initialisation over */
-	_u16	booting_link;		/* 0x36 */
-	_u16	idle_count;		/* 0x38 Idle time counter */
-	_u16	busy_count;		/* 0x3A Busy counter */
-	_u16	idle_control;		/* 0x3C Control Idle Process */
-	_u16	tx_intr;		/* 0x3E TX interrupt pending */
-	_u16	rx_intr;		/* 0x40 RX interrupt pending */
-	_u16	rup_intr;		/* 0x42 RUP interrupt pending */
+typedef struct _PARM_MAP {
+	_u16 phb_ptr;		/* 0x00 Pointer to the PHB array */
+	_u16 phb_num_ptr;	/* 0x02 Ptr to Number of PHB's */
+	_u16 free_list;		/* 0x04 Free List pointer */
+	_u16 free_list_end;	/* 0x06 Free List End pointer */
+	_u16 q_free_list_ptr;	/* 0x08 Ptr to Q_BUF variable */
+	_u16 unit_id_ptr;	/* 0x0A Unit Id */
+	_u16 link_str_ptr;	/* 0x0C Link Structure Array */
+	_u16 bootloader_1;	/* 0x0E 1st Stage Boot Loader */
+	_u16 bootloader_2;	/* 0x10 2nd Stage Boot Loader */
+	_u16 port_route_map_ptr;	/* 0x12 Port Route Map */
+	_u16 route_ptr;		/* 0x14 Route Map */
+	_u16 map_present;	/* 0x16 Route Map present */
+	_u16 pkt_num;		/* 0x18 Total number of packets */
+	_u16 q_num;		/* 0x1A Total number of Q packets */
+	_u16 buffers_per_port;	/* 0x1C Number of buffers per port */
+	_u16 heap_size;		/* 0x1E Initial size of heap */
+	_u16 heap_left;		/* 0x20 Current Heap left */
+	_u16 error;		/* 0x22 Error code */
+	_u16 tx_max;		/* 0x24 Max number of tx pkts per phb */
+	_u16 rx_max;		/* 0x26 Max number of rx pkts per phb */
+	_u16 rx_limit;		/* 0x28 For high / low watermarks */
+	_u16 links;		/* 0x2A Links to use */
+	_u16 timer;		/* 0x2C Interrupts per second */
+	_u16 rups;		/* 0x2E Pointer to the RUPs */
+	_u16 max_phb;		/* 0x30 Mostly for debugging */
+	_u16 living;		/* 0x32 Just increments!! */
+	_u16 init_done;		/* 0x34 Initialisation over */
+	_u16 booting_link;	/* 0x36 */
+	_u16 idle_count;	/* 0x38 Idle time counter */
+	_u16 busy_count;	/* 0x3A Busy counter */
+	_u16 idle_control;	/* 0x3C Control Idle Process */
+	_u16 tx_intr;		/* 0x3E TX interrupt pending */
+	_u16 rx_intr;		/* 0x40 RX interrupt pending */
+	_u16 rup_intr;		/* 0x42 RUP interrupt pending */
 
 } PARM_MAP;
 
@@ -184,45 +183,44 @@
    attached to the system and there is normally an array of MAX_RUPS (=16) structures
    in a host card, defined by PARM_MAP->rup. */
 
-typedef	struct	_RUP
-{
-	_u16		txpkt;			/* 0x00 Outgoing packet */
-	_u16		rxpkt;			/* 0x02 ncoming packet */
-	_u16		link;			/* 0x04 Which link to send packet down ? */
-	_u8		rup_dest_unit[2];	/* 0x06 Destination Unit */
-	_u16		handshake;		/* 0x08 Handshaking */
-	_u16		timeout;		/* 0x0A Timeout */
-	_u16		status;			/* 0x0C Status */
-	_u16		txcontrol;		/* 0x0E Transmit control */
-	_u16		rxcontrol;		/* 0x10 Receive control */
+typedef struct _RUP {
+	_u16 txpkt;		/* 0x00 Outgoing packet */
+	_u16 rxpkt;		/* 0x02 ncoming packet */
+	_u16 link;		/* 0x04 Which link to send packet down ? */
+	_u8 rup_dest_unit[2];	/* 0x06 Destination Unit */
+	_u16 handshake;		/* 0x08 Handshaking */
+	_u16 timeout;		/* 0x0A Timeout */
+	_u16 status;		/* 0x0C Status */
+	_u16 txcontrol;		/* 0x0E Transmit control */
+	_u16 rxcontrol;		/* 0x10 Receive control */
 
 } RUP;
 
 /* Same thing again, but defined as offsets... */
 
-#define	RUP_txpkt		0x00		/* 0x00 Outgoing packet */
-#define	RUP_rxpkt		0x02		/* 0x02 Incoming packet */
-#define	RUP_link		0x04		/* 0x04 Which link to send packet down ? */
-#define	RUP_rup_dest_unit	0x06		/* 0x06 Destination Unit */
-#define	RUP_handshake		0x08		/* 0x08 Handshaking */
-#define	RUP_timeout		0x0A		/* 0x0A Timeout */
-#define	RUP_status		0x0C		/* 0x0C Status */
-#define	RUP_txcontrol		0x0E		/* 0x0E Transmit control */
-#define	RUP_rxcontrol		0x10		/* 0x10 Receive control */
-#define	sizeof_RUP		0x12		/* structure size = 0x12 */
+#define	RUP_txpkt		0x00	/* 0x00 Outgoing packet */
+#define	RUP_rxpkt		0x02	/* 0x02 Incoming packet */
+#define	RUP_link		0x04	/* 0x04 Which link to send packet down ? */
+#define	RUP_rup_dest_unit	0x06	/* 0x06 Destination Unit */
+#define	RUP_handshake		0x08	/* 0x08 Handshaking */
+#define	RUP_timeout		0x0A	/* 0x0A Timeout */
+#define	RUP_status		0x0C	/* 0x0C Status */
+#define	RUP_txcontrol		0x0E	/* 0x0E Transmit control */
+#define	RUP_rxcontrol		0x10	/* 0x10 Receive control */
+#define	sizeof_RUP		0x12	/* structure size = 0x12 */
 
 #define MAX_RUP			16
 
 /* RUP.txcontrol definitions... */
-#define	TX_RUP_INACTIVE		0		/* Nothing to transmit */
-#define	TX_PACKET_READY		1		/* Transmit packet ready */
-#define	TX_LOCK_RUP		2		/* Transmit side locked */
+#define	TX_RUP_INACTIVE		0	/* Nothing to transmit */
+#define	TX_PACKET_READY		1	/* Transmit packet ready */
+#define	TX_LOCK_RUP		2	/* Transmit side locked */
 
 /* RUP.txcontrol definitions... */
-#define	RX_RUP_INACTIVE		0		/* Nothing received */
-#define	RX_PACKET_READY		1		/* Packet received */
+#define	RX_RUP_INACTIVE		0	/* Nothing received */
+#define	RX_PACKET_READY		1	/* Packet received */
 
-#define	RUP_NO_OWNER		0xFF		/* RUP not owned by any process */
+#define	RUP_NO_OWNER		0xFF	/* RUP not owned by any process */
 
 /*****************************************************************************
 **********************************         ***********************************
@@ -234,52 +232,51 @@
    to the system and there is normally an array of MAX_PHBS (=128) structures
    in a host card, defined by PARM_MAP->phb_ptr and PARM_MAP->phb_num_ptr. */
 
-typedef	struct	_PHB
-{
-	_u16		source;			/* 0x00 Location of the PHB in the host card */
-	_u16		handshake;		/* 0x02 Used to manage receive packet flow control */
-	_u16		status;			/* 0x04 Internal port transmit/receive status */
-	_u16		timeout;		/* 0x06 Time period to wait for an ACK */
-	_u16		link;			/* 0x08 The host link associated with the PHB */
-	_u16		destination;		/* 0x0A Location of the remote port on the network */
+typedef struct _PHB {
+	_u16 source;		/* 0x00 Location of the PHB in the host card */
+	_u16 handshake;		/* 0x02 Used to manage receive packet flow control */
+	_u16 status;		/* 0x04 Internal port transmit/receive status */
+	_u16 timeout;		/* 0x06 Time period to wait for an ACK */
+	_u16 link;		/* 0x08 The host link associated with the PHB */
+	_u16 destination;	/* 0x0A Location of the remote port on the network */
 
-	_u16		tx_start;		/* 0x0C first entry in the packet array for transmit packets */
-	_u16		tx_end;			/* 0x0E last entry in the packet array for transmit packets */
-	_u16		tx_add;			/* 0x10 position in the packet array for new transmit packets */
-	_u16		tx_remove;		/* 0x12 current position in the packet pointer array */
+	_u16 tx_start;		/* 0x0C first entry in the packet array for transmit packets */
+	_u16 tx_end;		/* 0x0E last entry in the packet array for transmit packets */
+	_u16 tx_add;		/* 0x10 position in the packet array for new transmit packets */
+	_u16 tx_remove;		/* 0x12 current position in the packet pointer array */
 
-	_u16		rx_start;		/* 0x14 first entry in the packet array for receive packets */
-	_u16		rx_end;			/* 0x16 last entry in the packet array for receive packets */
-	_u16		rx_add;			/* 0x18 position in the packet array for new receive packets */
-	_u16		rx_remove;		/* 0x1A current position in the packet pointer array */
+	_u16 rx_start;		/* 0x14 first entry in the packet array for receive packets */
+	_u16 rx_end;		/* 0x16 last entry in the packet array for receive packets */
+	_u16 rx_add;		/* 0x18 position in the packet array for new receive packets */
+	_u16 rx_remove;		/* 0x1A current position in the packet pointer array */
 
 } PHB;
 
 /* Same thing again, but defined as offsets... */
 
-#define	PHB_source		0x00		/* 0x00 Location of the PHB in the host card */
-#define	PHB_handshake		0x02		/* 0x02 Used to manage receive packet flow control */
-#define	PHB_status		0x04		/* 0x04 Internal port transmit/receive status */
-#define	PHB_timeout		0x06		/* 0x06 Time period to wait for an ACK */
-#define	PHB_link		0x08		/* 0x08 The host link associated with the PHB */
-#define	PHB_destination		0x0A		/* 0x0A Location of the remote port on the network */
-#define	PHB_tx_start		0x0C		/* 0x0C first entry in the packet array for transmit packets */
-#define	PHB_tx_end		0x0E		/* 0x0E last entry in the packet array for transmit packets */
-#define	PHB_tx_add		0x10		/* 0x10 position in the packet array for new transmit packets */
-#define	PHB_tx_remove		0x12		/* 0x12 current position in the packet pointer array */
-#define	PHB_rx_start		0x14		/* 0x14 first entry in the packet array for receive packets */
-#define	PHB_rx_end		0x16		/* 0x16 last entry in the packet array for receive packets */
-#define	PHB_rx_add		0x18		/* 0x18 position in the packet array for new receive packets */
-#define	PHB_rx_remove		0x1A		/* 0x1A current position in the packet pointer array */
-#define	sizeof_PHB		0x1C		/* structure size = 0x1C */
+#define	PHB_source		0x00	/* 0x00 Location of the PHB in the host card */
+#define	PHB_handshake		0x02	/* 0x02 Used to manage receive packet flow control */
+#define	PHB_status		0x04	/* 0x04 Internal port transmit/receive status */
+#define	PHB_timeout		0x06	/* 0x06 Time period to wait for an ACK */
+#define	PHB_link		0x08	/* 0x08 The host link associated with the PHB */
+#define	PHB_destination		0x0A	/* 0x0A Location of the remote port on the network */
+#define	PHB_tx_start		0x0C	/* 0x0C first entry in the packet array for transmit packets */
+#define	PHB_tx_end		0x0E	/* 0x0E last entry in the packet array for transmit packets */
+#define	PHB_tx_add		0x10	/* 0x10 position in the packet array for new transmit packets */
+#define	PHB_tx_remove		0x12	/* 0x12 current position in the packet pointer array */
+#define	PHB_rx_start		0x14	/* 0x14 first entry in the packet array for receive packets */
+#define	PHB_rx_end		0x16	/* 0x16 last entry in the packet array for receive packets */
+#define	PHB_rx_add		0x18	/* 0x18 position in the packet array for new receive packets */
+#define	PHB_rx_remove		0x1A	/* 0x1A current position in the packet pointer array */
+#define	sizeof_PHB		0x1C	/* structure size = 0x1C */
 
 /* PHB.handshake definitions... */
-#define	PHB_HANDSHAKE_SET	0x0001		/* Set by LRT */
-#define	PHB_HANDSHAKE_RESET	0x0002		/* Set by ISR / driver */
+#define	PHB_HANDSHAKE_SET	0x0001	/* Set by LRT */
+#define	PHB_HANDSHAKE_RESET	0x0002	/* Set by ISR / driver */
 #define	PHB_HANDSHAKE_FLAGS	(PHB_HANDSHAKE_RESET|PHB_HANDSHAKE_SET)
 						/* Reset by ltt */
 
-#define	MAX_PHB			128		/* range 0-127 */
+#define	MAX_PHB			128	/* range 0-127 */
 
 /*****************************************************************************
 **********************************         ***********************************
@@ -291,86 +288,85 @@
    and there is normally an array of MAX_LINKS (=4) structures in a host card,
    defined by PARM_MAP->link_str_ptr. */
 
-typedef	struct	_LPB
-{
-	_u16		link_number;		/* 0x00 Link Number */
-	_u16		in_ch;			/* 0x02 Link In Channel */
-	_u16		out_ch;			/* 0x04 Link Out Channel */
-	_u8		attached_serial[4];	/* 0x06 Attached serial number */
-	_u8		attached_host_serial[4];/* 0x0A Serial number of Host who booted other end */
-	_u16		descheduled;		/* 0x0E Currently Descheduled */
-	_u16		state;			/* 0x10 Current state */
-	_u16		send_poll;		/* 0x12 Send a Poll Packet */
-	_u16		ltt_p;			/* 0x14 Process Descriptor */
-	_u16		lrt_p;			/* 0x16 Process Descriptor */
-	_u16		lrt_status;		/* 0x18 Current lrt status */
-	_u16		ltt_status;		/* 0x1A Current ltt status */
-	_u16		timeout;		/* 0x1C Timeout value */
-	_u16		topology;		/* 0x1E Topology bits */
-	_u16		mon_ltt;		/* 0x20 */
-	_u16		mon_lrt;		/* 0x22 */
-	_u16		num_pkts;		/* 0x24 */
-	_u16		add_packet_list;	/* 0x26 Add packets to here */
-	_u16		remove_packet_list;	/* 0x28 Send packets from here */
+typedef struct _LPB {
+	_u16 link_number;	/* 0x00 Link Number */
+	_u16 in_ch;		/* 0x02 Link In Channel */
+	_u16 out_ch;		/* 0x04 Link Out Channel */
+	_u8 attached_serial[4];	/* 0x06 Attached serial number */
+	_u8 attached_host_serial[4];	/* 0x0A Serial number of Host who booted other end */
+	_u16 descheduled;	/* 0x0E Currently Descheduled */
+	_u16 state;		/* 0x10 Current state */
+	_u16 send_poll;		/* 0x12 Send a Poll Packet */
+	_u16 ltt_p;		/* 0x14 Process Descriptor */
+	_u16 lrt_p;		/* 0x16 Process Descriptor */
+	_u16 lrt_status;	/* 0x18 Current lrt status */
+	_u16 ltt_status;	/* 0x1A Current ltt status */
+	_u16 timeout;		/* 0x1C Timeout value */
+	_u16 topology;		/* 0x1E Topology bits */
+	_u16 mon_ltt;		/* 0x20 */
+	_u16 mon_lrt;		/* 0x22 */
+	_u16 num_pkts;		/* 0x24 */
+	_u16 add_packet_list;	/* 0x26 Add packets to here */
+	_u16 remove_packet_list;	/* 0x28 Send packets from here */
 
-	_u16		lrt_fail_chan;		/* 0x2A Lrt's failure channel */
-	_u16		ltt_fail_chan;		/* 0x2C Ltt's failure channel */
+	_u16 lrt_fail_chan;	/* 0x2A Lrt's failure channel */
+	_u16 ltt_fail_chan;	/* 0x2C Ltt's failure channel */
 
-	RUP		rup;			/* 0x2E RUP structure for HOST to driver comms */
-	RUP		link_rup;		/* 0x40 RUP for the link (POLL, topology etc.) */
-	_u16		attached_link;		/* 0x52 Number of attached link */
-	_u16		csum_errors;		/* 0x54 csum errors */
-	_u16		num_disconnects;	/* 0x56 number of disconnects */
-	_u16		num_sync_rcvd;		/* 0x58 # sync's received */
-	_u16		num_sync_rqst;		/* 0x5A # sync requests */
-	_u16		num_tx;			/* 0x5C Num pkts sent */
-	_u16		num_rx;			/* 0x5E Num pkts received */
-	_u16		module_attached;	/* 0x60 Module tpyes of attached */
-	_u16		led_timeout;		/* 0x62 LED timeout */
-	_u16		first_port;		/* 0x64 First port to service */
-	_u16		last_port;		/* 0x66 Last port to service */
+	RUP rup;		/* 0x2E RUP structure for HOST to driver comms */
+	RUP link_rup;		/* 0x40 RUP for the link (POLL, topology etc.) */
+	_u16 attached_link;	/* 0x52 Number of attached link */
+	_u16 csum_errors;	/* 0x54 csum errors */
+	_u16 num_disconnects;	/* 0x56 number of disconnects */
+	_u16 num_sync_rcvd;	/* 0x58 # sync's received */
+	_u16 num_sync_rqst;	/* 0x5A # sync requests */
+	_u16 num_tx;		/* 0x5C Num pkts sent */
+	_u16 num_rx;		/* 0x5E Num pkts received */
+	_u16 module_attached;	/* 0x60 Module tpyes of attached */
+	_u16 led_timeout;	/* 0x62 LED timeout */
+	_u16 first_port;	/* 0x64 First port to service */
+	_u16 last_port;		/* 0x66 Last port to service */
 
 } LPB;
 
 /* Same thing again, but defined as offsets... */
 
-#define	LPB_link_number		0x00		/* 0x00 Link Number */
-#define	LPB_in_ch		0x02		/* 0x02 Link In Channel */
-#define	LPB_out_ch		0x04		/* 0x04 Link Out Channel */
-#define	LPB_attached_serial	0x06		/* 0x06 Attached serial number */
-#define	LPB_attached_host_serial 0x0A		/* 0x0A Serial number of Host who booted other end */
-#define	LPB_descheduled		0x0E		/* 0x0E Currently Descheduled */
-#define	LPB_state		0x10		/* 0x10 Current state */
-#define	LPB_send_poll		0x12		/* 0x12 Send a Poll Packet */
-#define	LPB_ltt_p		0x14		/* 0x14 Process Descriptor */
-#define	LPB_lrt_p		0x16		/* 0x16 Process Descriptor */
-#define	LPB_lrt_status		0x18		/* 0x18 Current lrt status */
-#define	LPB_ltt_status		0x1A		/* 0x1A Current ltt status */
-#define	LPB_timeout		0x1C		/* 0x1C Timeout value */
-#define	LPB_topology		0x1E		/* 0x1E Topology bits */
-#define	LPB_mon_ltt		0x20		/* 0x20 */
-#define	LPB_mon_lrt		0x22		/* 0x22 */
-#define	LPB_num_pkts		0x24		/* 0x24 */
-#define	LPB_add_packet_list	0x26		/* 0x26 Add packets to here */
-#define	LPB_remove_packet_list	0x28		/* 0x28 Send packets from here */
-#define	LPB_lrt_fail_chan	0x2A		/* 0x2A Lrt's failure channel */
-#define	LPB_ltt_fail_chan	0x2C		/* 0x2C Ltt's failure channel */
-#define	LPB_rup			0x2E		/* 0x2E RUP structure for HOST to driver comms */
-#define	LPB_link_rup		0x40		/* 0x40 RUP for the link (POLL, topology etc.) */
-#define	LPB_attached_link	0x52		/* 0x52 Number of attached link */
-#define	LPB_csum_errors		0x54		/* 0x54 csum errors */
-#define	LPB_num_disconnects	0x56		/* 0x56 number of disconnects */
-#define	LPB_num_sync_rcvd	0x58		/* 0x58 # sync's received */
-#define	LPB_num_sync_rqst	0x5A		/* 0x5A # sync requests */
-#define	LPB_num_tx		0x5C		/* 0x5C Num pkts sent */
-#define	LPB_num_rx		0x5E		/* 0x5E Num pkts received */
-#define	LPB_module_attached	0x60		/* 0x60 Module tpyes of attached */
-#define	LPB_led_timeout		0x62		/* 0x62 LED timeout */
-#define	LPB_first_port		0x64		/* 0x64 First port to service */
-#define	LPB_last_port		0x66		/* 0x66 Last port to service */
-#define	sizeof_LPB		0x68		/* structure size = 0x68 */
+#define	LPB_link_number		0x00	/* 0x00 Link Number */
+#define	LPB_in_ch		0x02	/* 0x02 Link In Channel */
+#define	LPB_out_ch		0x04	/* 0x04 Link Out Channel */
+#define	LPB_attached_serial	0x06	/* 0x06 Attached serial number */
+#define	LPB_attached_host_serial 0x0A	/* 0x0A Serial number of Host who booted other end */
+#define	LPB_descheduled		0x0E	/* 0x0E Currently Descheduled */
+#define	LPB_state		0x10	/* 0x10 Current state */
+#define	LPB_send_poll		0x12	/* 0x12 Send a Poll Packet */
+#define	LPB_ltt_p		0x14	/* 0x14 Process Descriptor */
+#define	LPB_lrt_p		0x16	/* 0x16 Process Descriptor */
+#define	LPB_lrt_status		0x18	/* 0x18 Current lrt status */
+#define	LPB_ltt_status		0x1A	/* 0x1A Current ltt status */
+#define	LPB_timeout		0x1C	/* 0x1C Timeout value */
+#define	LPB_topology		0x1E	/* 0x1E Topology bits */
+#define	LPB_mon_ltt		0x20	/* 0x20 */
+#define	LPB_mon_lrt		0x22	/* 0x22 */
+#define	LPB_num_pkts		0x24	/* 0x24 */
+#define	LPB_add_packet_list	0x26	/* 0x26 Add packets to here */
+#define	LPB_remove_packet_list	0x28	/* 0x28 Send packets from here */
+#define	LPB_lrt_fail_chan	0x2A	/* 0x2A Lrt's failure channel */
+#define	LPB_ltt_fail_chan	0x2C	/* 0x2C Ltt's failure channel */
+#define	LPB_rup			0x2E	/* 0x2E RUP structure for HOST to driver comms */
+#define	LPB_link_rup		0x40	/* 0x40 RUP for the link (POLL, topology etc.) */
+#define	LPB_attached_link	0x52	/* 0x52 Number of attached link */
+#define	LPB_csum_errors		0x54	/* 0x54 csum errors */
+#define	LPB_num_disconnects	0x56	/* 0x56 number of disconnects */
+#define	LPB_num_sync_rcvd	0x58	/* 0x58 # sync's received */
+#define	LPB_num_sync_rqst	0x5A	/* 0x5A # sync requests */
+#define	LPB_num_tx		0x5C	/* 0x5C Num pkts sent */
+#define	LPB_num_rx		0x5E	/* 0x5E Num pkts received */
+#define	LPB_module_attached	0x60	/* 0x60 Module tpyes of attached */
+#define	LPB_led_timeout		0x62	/* 0x62 LED timeout */
+#define	LPB_first_port		0x64	/* 0x64 First port to service */
+#define	LPB_last_port		0x66	/* 0x66 Last port to service */
+#define	sizeof_LPB		0x68	/* structure size = 0x68 */
 
-#define	LINKS_PER_UNIT		4		/* number of links from a host */
+#define	LINKS_PER_UNIT		4	/* number of links from a host */
 
 /*****************************************************************************
 ********************************               *******************************
@@ -380,17 +376,16 @@
 
 /* Used to overlay packet headers when allocating/freeing packets from the free list */
 
-typedef	struct	_FREE_LIST
-{
-	_u16		next;			/* 0x00 offset of next list item */
-	_u16		prev;			/* 0x02 offset of previous list item */
+typedef struct _FREE_LIST {
+	_u16 next;		/* 0x00 offset of next list item */
+	_u16 prev;		/* 0x02 offset of previous list item */
 
 } FREE_LIST;
 
 /* Same thing again, but defined as offsets... */
 
-#define	FL_next			0x00		/* 0x00 offset of next list item */
-#define	FL_prev			0x02		/* 0x02 offset of previous list item */
+#define	FL_next			0x00	/* 0x00 offset of next list item */
+#define	FL_prev			0x02	/* 0x02 offset of previous list item */
 
 /*****************************************************************************
 **********************************         ***********************************
@@ -401,32 +396,31 @@
 /* The PKT is the main unit of communication between Host Cards and RTAs across
    the RIO network.  */
 
-#define PKT_MAX_DATA_LEN   72			/* Size of packet data */
+#define PKT_MAX_DATA_LEN   72	/* Size of packet data */
 
-typedef	struct	_PKT
-{
-	_u8		dest_unit;		/* 0x00 Destination Unit Id */
-	_u8		dest_port;		/* 0x01 Destination Port */
-	_u8		src_unit;		/* 0x02 Source Unit Id */
-	_u8		src_port;		/* 0x03 Source Port */
-	_u8		len;			/* 0x04 Length (in bytes) of data field */
-	_u8		control;		/* 0x05 */
-	_u8		data[PKT_MAX_DATA_LEN];	/* 0x06 Actual data */
-	_u16		csum;			/* 0x4E C-SUM */
+typedef struct _PKT {
+	_u8 dest_unit;		/* 0x00 Destination Unit Id */
+	_u8 dest_port;		/* 0x01 Destination Port */
+	_u8 src_unit;		/* 0x02 Source Unit Id */
+	_u8 src_port;		/* 0x03 Source Port */
+	_u8 len;		/* 0x04 Length (in bytes) of data field */
+	_u8 control;		/* 0x05 */
+	_u8 data[PKT_MAX_DATA_LEN];	/* 0x06 Actual data */
+	_u16 csum;		/* 0x4E C-SUM */
 
 } PKT;
 
 /* Same thing again, but defined as offsets... */
 
-#define	PKT_dest_unit		0x00		/* 0x00 Destination Unit Id */
-#define	PKT_dest_port		0x01		/* 0x01 Destination Port */
-#define	PKT_src_unit		0x02		/* 0x02 Source Unit Id */
-#define	PKT_src_port		0x03		/* 0x03 Source Port */
-#define	PKT_len			0x04		/* 0x04 Length (in bytes) of data field */
-#define	PKT_control		0x05		/* 0x05 */
-#define	PKT_data		0x06		/* 0x06 Actual data */
-#define	PKT_csum		0x4E		/* 0x4E C-SUM */
-#define	sizeof_PKT		0x50		/* structure size = 0x50 */
+#define	PKT_dest_unit		0x00	/* 0x00 Destination Unit Id */
+#define	PKT_dest_port		0x01	/* 0x01 Destination Port */
+#define	PKT_src_unit		0x02	/* 0x02 Source Unit Id */
+#define	PKT_src_port		0x03	/* 0x03 Source Port */
+#define	PKT_len			0x04	/* 0x04 Length (in bytes) of data field */
+#define	PKT_control		0x05	/* 0x05 */
+#define	PKT_data		0x06	/* 0x06 Actual data */
+#define	PKT_csum		0x4E	/* 0x4E C-SUM */
+#define	sizeof_PKT		0x50	/* structure size = 0x50 */
 
 /* PKT.len definitions... */
 #define	PKT_CMD_BIT		0x80
@@ -449,38 +443,38 @@
 /* The following definitions and structures define the control packets sent
    between the driver and RIO Ports, RTAs and Host Cards. */
 
-#define	PRE_EMPTIVE		0x80			/* Pre-emptive command (sent via port's RUP) */
+#define	PRE_EMPTIVE		0x80	/* Pre-emptive command (sent via port's RUP) */
 
 /* "in-band" and "pre-emptive" port commands... */
-#define	OPEN			0x00			/* Driver->RIO Open a port */
-#define	CONFIG			0x01			/* Driver->RIO Configure a port */
-#define	MOPEN			0x02			/* Driver->RIO Modem open (wait for DCD) */
-#define	CLOSE			0x03			/* Driver->RIO Close a port */
+#define	OPEN			0x00	/* Driver->RIO Open a port */
+#define	CONFIG			0x01	/* Driver->RIO Configure a port */
+#define	MOPEN			0x02	/* Driver->RIO Modem open (wait for DCD) */
+#define	CLOSE			0x03	/* Driver->RIO Close a port */
 #define	WFLUSH			(0x04|PRE_EMPTIVE)	/* Driver->RIO Write flush */
 #define	RFLUSH			(0x05|PRE_EMPTIVE)	/* Driver->RIO Read flush */
 #define	RESUME			(0x06|PRE_EMPTIVE)	/* Driver->RIO Behave as if XON received */
-#define	SBREAK			0x07			/* Driver->RIO Start break */
-#define	EBREAK			0x08			/* Driver->RIO End break */
+#define	SBREAK			0x07	/* Driver->RIO Start break */
+#define	EBREAK			0x08	/* Driver->RIO End break */
 #define	SUSPEND			(0x09|PRE_EMPTIVE)	/* Driver->RIO Behave as if XOFF received */
 #define	FCLOSE			(0x0A|PRE_EMPTIVE)	/* Driver->RIO Force close */
-#define	XPRINT			0x0B			/* Driver->RIO Xprint packet */
+#define	XPRINT			0x0B	/* Driver->RIO Xprint packet */
 #define	MBIS			(0x0C|PRE_EMPTIVE)	/* Driver->RIO Set modem lines */
 #define	MBIC			(0x0D|PRE_EMPTIVE)	/* Driver->RIO Clear modem lines */
 #define	MSET			(0x0E|PRE_EMPTIVE)	/* Driver->RIO Set modem lines */
-#define	PCLOSE			0x0F			/* Driver->RIO Pseudo close */
+#define	PCLOSE			0x0F	/* Driver->RIO Pseudo close */
 #define	MGET			(0x10|PRE_EMPTIVE)	/* Driver->RIO Force update of modem status */
 #define	MEMDUMP			(0x11|PRE_EMPTIVE)	/* Driver->RIO DEBUG request for RTA memory */
 #define	READ_REGISTER		(0x12|PRE_EMPTIVE)	/* Driver->RIO DEBUG read CD1400 register */
 
 /* Remote Unit Port (RUP) packet definitions... (specified in PKT.dest_unit and PKT.src_unit) */
-#define	SYNC_RUP		0xFF			/* Download internal */
-#define	COMMAND_RUP		0xFE			/* Command ack/status */
-#define	ERROR_RUP		0xFD			/* Download internal */
-#define	POLL_RUP		0xFC			/* Download internal */
-#define	BOOT_RUP		0xFB			/* Used to boot RTAs */
-#define	ROUTE_RUP		0xFA			/* Used to specify routing/topology */
-#define	STATUS_RUP		0xF9			/* Not used */
-#define	POWER_RUP		0xF8			/* Download internal */
+#define	SYNC_RUP		0xFF	/* Download internal */
+#define	COMMAND_RUP		0xFE	/* Command ack/status */
+#define	ERROR_RUP		0xFD	/* Download internal */
+#define	POLL_RUP		0xFC	/* Download internal */
+#define	BOOT_RUP		0xFB	/* Used to boot RTAs */
+#define	ROUTE_RUP		0xFA	/* Used to specify routing/topology */
+#define	STATUS_RUP		0xF9	/* Not used */
+#define	POWER_RUP		0xF8	/* Download internal */
 
 /* COMMAND_RUP definitions... */
 #define	COMPLETE		(0x20|PRE_EMPTIVE)	/* RIO->Driver Command complete */
@@ -488,24 +482,24 @@
 #define	MODEM_STATUS		(0x22|PRE_EMPTIVE)	/* RIO->Driver Modem status change */
 
 /* BOOT_RUP definitions... */
-#define	BOOT_REQUEST		0x00			/* RIO->Driver Request for boot */
-#define	BOOT_ABORT		0x01			/* Driver->RIO Abort a boot */
-#define	BOOT_SEQUENCE		0x02			/* Driver->RIO Packet with firmware details */
-#define	BOOT_COMPLETED		0x03			/* RIO->Driver Boot completed */
-#define IFOAD			0x2F			/* Driver->RIO Shutdown/Reboot RTA (Fall Over And Die) */
-#define	IDENTIFY		0x30			/* Driver->RIO Identify RTA */
-#define	ZOMBIE			0x31			/* Driver->RIO Shutdown/Flash LEDs */
-#define	UFOAD			0x32			/* Driver->RIO Shutdown/Reboot neighbouring RTA */
-#define IWAIT			0x33			/* Driver->RIO Pause booting process */
+#define	BOOT_REQUEST		0x00	/* RIO->Driver Request for boot */
+#define	BOOT_ABORT		0x01	/* Driver->RIO Abort a boot */
+#define	BOOT_SEQUENCE		0x02	/* Driver->RIO Packet with firmware details */
+#define	BOOT_COMPLETED		0x03	/* RIO->Driver Boot completed */
+#define IFOAD			0x2F	/* Driver->RIO Shutdown/Reboot RTA (Fall Over And Die) */
+#define	IDENTIFY		0x30	/* Driver->RIO Identify RTA */
+#define	ZOMBIE			0x31	/* Driver->RIO Shutdown/Flash LEDs */
+#define	UFOAD			0x32	/* Driver->RIO Shutdown/Reboot neighbouring RTA */
+#define IWAIT			0x33	/* Driver->RIO Pause booting process */
 
 /* ROUTE_RUP definitions... */
-#define	ROUTE_REQUEST		0x00			/* RIO->Driver Request an ID */
-#define	ROUTE_FOAD		0x01			/* Driver->RIO Shutdown/reboot RTA */
-#define	ROUTE_ALREADY		0x02			/* Driver->RIO Not used */
-#define	ROUTE_USED		0x03			/* Driver->RIO Not used */
-#define	ROUTE_ALLOCATE		0x04			/* Driver->RIO Allocate RTA RUP numbers */
-#define	ROUTE_REQ_TOP		0x05			/* Driver->RIO Not used */
-#define ROUTE_TOPOLOGY		0x06			/* RIO->Driver Route/Topology status */
+#define	ROUTE_REQUEST		0x00	/* RIO->Driver Request an ID */
+#define	ROUTE_FOAD		0x01	/* Driver->RIO Shutdown/reboot RTA */
+#define	ROUTE_ALREADY		0x02	/* Driver->RIO Not used */
+#define	ROUTE_USED		0x03	/* Driver->RIO Not used */
+#define	ROUTE_ALLOCATE		0x04	/* Driver->RIO Allocate RTA RUP numbers */
+#define	ROUTE_REQ_TOP		0x05	/* Driver->RIO Not used */
+#define ROUTE_TOPOLOGY		0x06	/* RIO->Driver Route/Topology status */
 
 /*****************************************************************************
 **********************************          **********************************
@@ -518,89 +512,89 @@
    Sent to open a port. 
    Structure of configuration info used with OPEN, CONFIG and MOPEN packets... */
 
-#define	PKT_Cmd			(PKT_Data+0)		/* Command code */
-#define	PKT_Cor1		(PKT_Data+1)		/* Channel Option Register 1 */
-#define	PKT_Cor2		(PKT_Data+2)		/* Channel Option Register 2 */
-#define	PKT_Cor4		(PKT_Data+3)		/* Channel Option Register 4 */
-#define	PKT_Cor5		(PKT_Data+4)		/* Channel Option Register 5 */
-#define	PKT_TxXon		(PKT_Data+5)		/* Transmit XON character */
-#define	PKT_TxXoff		(PKT_Data+6)		/* Transmit XOFF character */
-#define	PKT_RxXon		(PKT_Data+7)		/* Receive XON character */
-#define	PKT_RxXoff		(PKT_Data+8)		/* Receive XOFF character */
-#define	PKT_Lnext		(PKT_Data+9)		/* Lnext character */
-#define	PKT_TxBaud		(PKT_Data+10)		/* Transmit baud rate */
-#define	PKT_RxBaud		(PKT_Data+11)		/* Receive baud rate */
+#define	PKT_Cmd			(PKT_Data+0)	/* Command code */
+#define	PKT_Cor1		(PKT_Data+1)	/* Channel Option Register 1 */
+#define	PKT_Cor2		(PKT_Data+2)	/* Channel Option Register 2 */
+#define	PKT_Cor4		(PKT_Data+3)	/* Channel Option Register 4 */
+#define	PKT_Cor5		(PKT_Data+4)	/* Channel Option Register 5 */
+#define	PKT_TxXon		(PKT_Data+5)	/* Transmit XON character */
+#define	PKT_TxXoff		(PKT_Data+6)	/* Transmit XOFF character */
+#define	PKT_RxXon		(PKT_Data+7)	/* Receive XON character */
+#define	PKT_RxXoff		(PKT_Data+8)	/* Receive XOFF character */
+#define	PKT_Lnext		(PKT_Data+9)	/* Lnext character */
+#define	PKT_TxBaud		(PKT_Data+10)	/* Transmit baud rate */
+#define	PKT_RxBaud		(PKT_Data+11)	/* Receive baud rate */
 
 /* COR1 definitions... */
-#define	COR1_PARITY		0xE0			/* Parity mask */
-#define	COR1_NONE		0x00			/* No parity */
-#define	COR1_SPACE		0x20			/* Space parity */
-#define	COR1_EVEN		0x40			/* Even parity */
-#define	COR1_MARK		0xA0			/* Mark parity */
-#define	COR1_ODD		0xC0			/* Odd parity */
+#define	COR1_PARITY		0xE0	/* Parity mask */
+#define	COR1_NONE		0x00	/* No parity */
+#define	COR1_SPACE		0x20	/* Space parity */
+#define	COR1_EVEN		0x40	/* Even parity */
+#define	COR1_MARK		0xA0	/* Mark parity */
+#define	COR1_ODD		0xC0	/* Odd parity */
 
-#define	COR1_STOPBITS		0x0C			/* Stop bits mask */
-#define	COR1_STOP1		0x00			/* 1 stop bit */
-#define	COR1_STOP1_5		0x04			/* 1.5 stop bits */
-#define	COR1_STOP2		0x08			/* 2 stop bits */
+#define	COR1_STOPBITS		0x0C	/* Stop bits mask */
+#define	COR1_STOP1		0x00	/* 1 stop bit */
+#define	COR1_STOP1_5		0x04	/* 1.5 stop bits */
+#define	COR1_STOP2		0x08	/* 2 stop bits */
 
-#define	COR1_DATABITS		0x03			/* Data bits mask */
-#define	COR1_DATA5		0x00			/* 5 data bits */
-#define	COR1_DATA6		0x01			/* 6 data bits */
-#define	COR1_DATA7		0x02			/* 7 data bits */
-#define	COR1_DATA8		0x03			/* 8 data bits */
+#define	COR1_DATABITS		0x03	/* Data bits mask */
+#define	COR1_DATA5		0x00	/* 5 data bits */
+#define	COR1_DATA6		0x01	/* 6 data bits */
+#define	COR1_DATA7		0x02	/* 7 data bits */
+#define	COR1_DATA8		0x03	/* 8 data bits */
 
 /* COR2 definitions... */
-#define	COR2_XON_TXFLOW		0x40			/* XON/XOFF Transmit Flow */
-#define	COR2_XANY_TXFLOW	0xC0			/* XON/XANY Transmit Flow */
-#define	COR2_HUPCL		0x20			/* Hang Up On Close */
-#define	COR2_DSR_TXFLOW		0x08			/* DSR Transmit Flow Control */
-#define	COR2_RTS_RXFLOW		0x04			/* RTS Receive Flow Control */
-#define	COR2_CTS_TXFLOW		0x02			/* CTS Transmit Flow Control */
-#define	COR2_XON_RXFLOW		0x01			/* XON/XOFF Receive Flow */
+#define	COR2_XON_TXFLOW		0x40	/* XON/XOFF Transmit Flow */
+#define	COR2_XANY_TXFLOW	0xC0	/* XON/XANY Transmit Flow */
+#define	COR2_HUPCL		0x20	/* Hang Up On Close */
+#define	COR2_DSR_TXFLOW		0x08	/* DSR Transmit Flow Control */
+#define	COR2_RTS_RXFLOW		0x04	/* RTS Receive Flow Control */
+#define	COR2_CTS_TXFLOW		0x02	/* CTS Transmit Flow Control */
+#define	COR2_XON_RXFLOW		0x01	/* XON/XOFF Receive Flow */
 
 /* COR4 definition... */
-#define	COR4_IGNCR		0x80			/* Discard received CR */
-#define	COR4_ICRNL		0x40			/* Map received CR -> NL */
-#define	COR4_INLCR		0x20			/* Map received NL -> CR */
-#define	COR4_IGNBRK		0x10			/* Ignore Received Break */
-#define	COR4_NBRKINT		0x08			/* No interrupt on rx Break */
-#define	COR4_IGNPAR		0x04			/* ignore rx parity error chars */
-#define	COR4_PARMRK		0x02			/* Mark rx parity error chars */
-#define	COR4_RAISEMOD		0x01			/* Raise modem lines on !0 baud */
+#define	COR4_IGNCR		0x80	/* Discard received CR */
+#define	COR4_ICRNL		0x40	/* Map received CR -> NL */
+#define	COR4_INLCR		0x20	/* Map received NL -> CR */
+#define	COR4_IGNBRK		0x10	/* Ignore Received Break */
+#define	COR4_NBRKINT		0x08	/* No interrupt on rx Break */
+#define	COR4_IGNPAR		0x04	/* ignore rx parity error chars */
+#define	COR4_PARMRK		0x02	/* Mark rx parity error chars */
+#define	COR4_RAISEMOD		0x01	/* Raise modem lines on !0 baud */
 
 /* COR5 definitions... */
-#define	COR5_ISTRIP		0x80			/* Strip input chars to 7 bits */
-#define	COR5_LNE		0x40			/* Enable LNEXT processing */
-#define	COR5_CMOE		0x20			/* Match good & error characters */
-#define	COR5_TAB3		0x10			/* TAB3 mode */
-#define	COR5_TSTATE_ON		0x08			/* Enable tbusy/tstop monitoring */
-#define	COR5_TSTATE_OFF		0x04			/* Disable tbusy/tstop monitoring */
-#define	COR5_ONLCR		0x02			/* NL -> CR NL on output */
-#define	COR5_OCRNL		0x01			/* CR -> NL on output */
+#define	COR5_ISTRIP		0x80	/* Strip input chars to 7 bits */
+#define	COR5_LNE		0x40	/* Enable LNEXT processing */
+#define	COR5_CMOE		0x20	/* Match good & error characters */
+#define	COR5_TAB3		0x10	/* TAB3 mode */
+#define	COR5_TSTATE_ON		0x08	/* Enable tbusy/tstop monitoring */
+#define	COR5_TSTATE_OFF		0x04	/* Disable tbusy/tstop monitoring */
+#define	COR5_ONLCR		0x02	/* NL -> CR NL on output */
+#define	COR5_OCRNL		0x01	/* CR -> NL on output */
 
 /* RxBaud and TxBaud definitions... */
-#define	RIO_B0			0x00			/* RTS / DTR signals dropped */
-#define	RIO_B50			0x01			/* 50 baud */
-#define	RIO_B75			0x02			/* 75 baud */
-#define	RIO_B110		0x03			/* 110 baud */
-#define	RIO_B134		0x04			/* 134.5 baud */
-#define	RIO_B150		0x05			/* 150 baud */
-#define	RIO_B200		0x06			/* 200 baud */
-#define	RIO_B300		0x07			/* 300 baud */
-#define	RIO_B600		0x08			/* 600 baud */
-#define	RIO_B1200		0x09			/* 1200 baud */
-#define	RIO_B1800		0x0A			/* 1800 baud */
-#define	RIO_B2400		0x0B			/* 2400 baud */
-#define	RIO_B4800		0x0C			/* 4800 baud */
-#define	RIO_B9600		0x0D			/* 9600 baud */
-#define	RIO_B19200		0x0E			/* 19200 baud */
-#define	RIO_B38400		0x0F			/* 38400 baud */
-#define	RIO_B56000		0x10			/* 56000 baud */
-#define	RIO_B57600		0x11			/* 57600 baud */
-#define	RIO_B64000		0x12			/* 64000 baud */
-#define	RIO_B115200		0x13			/* 115200 baud */
-#define	RIO_B2000		0x14			/* 2000 baud */
+#define	RIO_B0			0x00	/* RTS / DTR signals dropped */
+#define	RIO_B50			0x01	/* 50 baud */
+#define	RIO_B75			0x02	/* 75 baud */
+#define	RIO_B110		0x03	/* 110 baud */
+#define	RIO_B134		0x04	/* 134.5 baud */
+#define	RIO_B150		0x05	/* 150 baud */
+#define	RIO_B200		0x06	/* 200 baud */
+#define	RIO_B300		0x07	/* 300 baud */
+#define	RIO_B600		0x08	/* 600 baud */
+#define	RIO_B1200		0x09	/* 1200 baud */
+#define	RIO_B1800		0x0A	/* 1800 baud */
+#define	RIO_B2400		0x0B	/* 2400 baud */
+#define	RIO_B4800		0x0C	/* 4800 baud */
+#define	RIO_B9600		0x0D	/* 9600 baud */
+#define	RIO_B19200		0x0E	/* 19200 baud */
+#define	RIO_B38400		0x0F	/* 38400 baud */
+#define	RIO_B56000		0x10	/* 56000 baud */
+#define	RIO_B57600		0x11	/* 57600 baud */
+#define	RIO_B64000		0x12	/* 64000 baud */
+#define	RIO_B115200		0x13	/* 115200 baud */
+#define	RIO_B2000		0x14	/* 2000 baud */
 
 /*****************************************************************************
 *********************************            *********************************
@@ -636,7 +630,7 @@
    No parameters.
  */
 #if 0
-#define	PKT_Cmd			(PKT_Data+0)		/* Command code */
+#define	PKT_Cmd			(PKT_Data+0)	/* Command code */
 #endif
 /*****************************************************************************
 *********************************            *********************************
@@ -653,9 +647,9 @@
    write flushing previously started by a pre-emptive WFLUSH packet. (in-band)
    */
 #if 0
-#define	PKT_Cmd			(PKT_Data+0)		/* Command code */
+#define	PKT_Cmd			(PKT_Data+0)	/* Command code */
 #endif
-#define	PKT_PhbNum		(PKT_Data+1)		/* Port number wrt RTA */
+#define	PKT_PhbNum		(PKT_Data+1)	/* Port number wrt RTA */
 
 /*****************************************************************************
 *********************************            *********************************
@@ -669,8 +663,8 @@
    packets of a port.
    */
 #if 0
-#define	PKT_Cmd			(PKT_Data+0)		/* Command code */
-#define	PKT_PhbNum		(PKT_Data+1)		/* Port number wrt RTA */
+#define	PKT_Cmd			(PKT_Data+0)	/* Command code */
+#define	PKT_PhbNum		(PKT_Data+1)	/* Port number wrt RTA */
 #endif
 
 /*****************************************************************************
@@ -685,8 +679,8 @@
    transmission of data if blocked by XOFF.  (as if XON had been received)
    */
 #if 0
-#define	PKT_Cmd			(PKT_Data+0)		/* Command code */
-#define	PKT_PhbNum		(PKT_Data+1)		/* Port number wrt RTA */
+#define	PKT_Cmd			(PKT_Data+0)	/* Command code */
+#define	PKT_PhbNum		(PKT_Data+1)	/* Port number wrt RTA */
 #endif
 
 /*****************************************************************************
@@ -707,9 +701,9 @@
    specified number of mS.
    */
 #if 0
-#define	PKT_Cmd			(PKT_Data+0)		/* Command code */
+#define	PKT_Cmd			(PKT_Data+0)	/* Command code */
 #endif
-#define	PKT_BreakDelay		(PKT_Data+1)		/* Break delay in mS */
+#define	PKT_BreakDelay		(PKT_Data+1)	/* Break delay in mS */
 
 /*****************************************************************************
 *********************************            *********************************
@@ -736,8 +730,8 @@
    transmission of data.  (as if XOFF had been received)
    */
 #if 0
-#define	PKT_Cmd			(PKT_Data+0)		/* Command code */
-#define	PKT_PhbNum		(PKT_Data+1)		/* Port number wrt RTA */
+#define	PKT_Cmd			(PKT_Data+0)	/* Command code */
+#define	PKT_PhbNum		(PKT_Data+1)	/* Port number wrt RTA */
 #endif
 
 /*****************************************************************************
@@ -753,8 +747,8 @@
    modem signals if the COR5_HUPCL (Hang Up On Close) flag is set.
    */
 #if 0
-#define	PKT_Cmd			(PKT_Data+0)		/* Command code */
-#define	PKT_PhbNum		(PKT_Data+1)		/* Port number wrt RTA */
+#define	PKT_Cmd			(PKT_Data+0)	/* Command code */
+#define	PKT_PhbNum		(PKT_Data+1)	/* Port number wrt RTA */
 #endif
 
 /*****************************************************************************
@@ -774,8 +768,8 @@
    -	Transparent Print Stop Sequence.
    */
 #if 0
-#define	PKT_Cmd			(PKT_Data+0)		/* Command code */
-#define	PKT_PhbNum		(PKT_Data+1)		/* Port number wrt RTA */
+#define	PKT_Cmd			(PKT_Data+0)	/* Command code */
+#define	PKT_PhbNum		(PKT_Data+1)	/* Port number wrt RTA */
 #endif
 
 /*****************************************************************************
@@ -789,14 +783,14 @@
    MBIS is sent pre-emptively from the driver to set a port's modem signals.
    */
 #if 0
-#define	PKT_Cmd			(PKT_Data+0)		/* Command code */
-#define	PKT_PhbNum		(PKT_Data+1)		/* Port number wrt RTA */
+#define	PKT_Cmd			(PKT_Data+0)	/* Command code */
+#define	PKT_PhbNum		(PKT_Data+1)	/* Port number wrt RTA */
 #endif
-#define	PKT_ModemSet		(PKT_Data+4)		/* Modem set signals mask */
+#define	PKT_ModemSet		(PKT_Data+4)	/* Modem set signals mask */
 
 /* ModemSet definitions... */
-#define	MBIS_RTS		0x01			/* RTS modem signal */
-#define	MBIS_DTR		0x02			/* DTR modem signal */
+#define	MBIS_RTS		0x01	/* RTS modem signal */
+#define	MBIS_DTR		0x02	/* DTR modem signal */
 
 /*****************************************************************************
 **********************************          **********************************
@@ -808,16 +802,16 @@
 
    MBIC is sent pre-emptively from the driver to clear a port's modem signals.
    */
-#if 0   
-#define	PKT_Cmd			(PKT_Data+0)		/* Command code */
-#define	PKT_PhbNum		(PKT_Data+1)		/* Port number wrt RTA */
+#if 0
+#define	PKT_Cmd			(PKT_Data+0)	/* Command code */
+#define	PKT_PhbNum		(PKT_Data+1)	/* Port number wrt RTA */
 #endif
 
-#define	PKT_ModemClear		(PKT_Data+4)		/* Modem clear signals mask */
+#define	PKT_ModemClear		(PKT_Data+4)	/* Modem clear signals mask */
 
 /* ModemClear definitions... */
-#define	MBIC_RTS		0x01			/* RTS modem signal */
-#define	MBIC_DTR		0x02			/* DTR modem signal */
+#define	MBIC_RTS		0x01	/* RTS modem signal */
+#define	MBIC_DTR		0x02	/* DTR modem signal */
 
 /*****************************************************************************
 **********************************          **********************************
@@ -829,15 +823,15 @@
 
    MSET is sent pre-emptively from the driver to set/clear a port's modem signals. */
 #if 0
-#define	PKT_Cmd			(PKT_Data+0)		/* Command code */
-#define	PKT_PhbNum		(PKT_Data+1)		/* Port number wrt RTA */
+#define	PKT_Cmd			(PKT_Data+0)	/* Command code */
+#define	PKT_PhbNum		(PKT_Data+1)	/* Port number wrt RTA */
 #endif
 
-#define	PKT_ModemSet		(PKT_Data+4)		/* Modem set signals mask */
+#define	PKT_ModemSet		(PKT_Data+4)	/* Modem set signals mask */
 
 /* ModemSet definitions... */
-#define	MSET_RTS		0x01			/* RTS modem signal */
-#define	MSET_DTR		0x02			/* DTR modem signal */
+#define	MSET_RTS		0x01	/* RTS modem signal */
+#define	MSET_DTR		0x02	/* DTR modem signal */
 
 /*****************************************************************************
 *********************************            *********************************
@@ -853,7 +847,7 @@
    port's transmit / receive and modem signals will be left enabled and the
    port marked internally as Pseudo Closed. */
 
-#define	PKT_Cmd			(PKT_Data+0)		/* Command code */
+#define	PKT_Cmd			(PKT_Data+0)	/* Command code */
 
 /*****************************************************************************
 **********************************          **********************************
@@ -865,8 +859,8 @@
 
    MGET is sent pre-emptively from the driver to request the port's current modem signals. */
 
-#define	PKT_Cmd			(PKT_Data+0)		/* Command code */
-#define	PKT_PhbNum		(PKT_Data+1)		/* Port number wrt RTA */
+#define	PKT_Cmd			(PKT_Data+0)	/* Command code */
+#define	PKT_PhbNum		(PKT_Data+1)	/* Port number wrt RTA */
 
 /*****************************************************************************
 *********************************             ********************************
@@ -880,11 +874,11 @@
    of the specified port's RTA address space.
    */
 #if 0
-#define	PKT_Cmd			(PKT_Data+0)		/* Command code */
+#define	PKT_Cmd			(PKT_Data+0)	/* Command code */
 #endif
-#define	PKT_PhbNum		(PKT_Data+1)		/* Port number wrt RTA */
-#define	PKT_SubCmd		(PKT_Data+5)		/* Sub Command */
-#define	PKT_Address		(PKT_Data+6)		/* Requested address */
+#define	PKT_PhbNum		(PKT_Data+1)	/* Port number wrt RTA */
+#define	PKT_SubCmd		(PKT_Data+5)	/* Sub Command */
+#define	PKT_Address		(PKT_Data+6)	/* Requested address */
 
 /*****************************************************************************
 ******************************                   *****************************
@@ -898,11 +892,11 @@
    of the CD1400 register specified in address.
    */
 #if 0
-#define	PKT_Cmd			(PKT_Data+0)		/* Command code */
+#define	PKT_Cmd			(PKT_Data+0)	/* Command code */
 #endif
-#define	PKT_PhbNum		(PKT_Data+1)		/* Port number wrt RTA */
-#define	PKT_SubCmd		(PKT_Data+5)		/* Sub Command */
-#define	PKT_Address		(PKT_Data+6)		/* Requested address */
+#define	PKT_PhbNum		(PKT_Data+1)	/* Port number wrt RTA */
+#define	PKT_SubCmd		(PKT_Data+5)	/* Sub Command */
+#define	PKT_Address		(PKT_Data+6)	/* Requested address */
 
 /*****************************************************************************
 ************************                            **************************
@@ -916,33 +910,33 @@
    packets, except MEMDUMP and READ_REGISTER.
    */
 #if 0
-#define	PKT_Cmd			(PKT_Data+0)		/* Command code */
+#define	PKT_Cmd			(PKT_Data+0)	/* Command code */
 #endif
-#define	PKT_PhbNum		(PKT_Data+1)		/* Port number wrt RTA */
-#define	PKT_Cmd2		(PKT_Data+2)		/* Command code copy */
-#define	PKT_ModemStatus		(PKT_Data+3)		/* Modem signal status */
-#define	PKT_PortStatus		(PKT_Data+4)		/* Port signal status */
-#define	PKT_SubCmd		(PKT_Data+5)		/* Sub Command */
+#define	PKT_PhbNum		(PKT_Data+1)	/* Port number wrt RTA */
+#define	PKT_Cmd2		(PKT_Data+2)	/* Command code copy */
+#define	PKT_ModemStatus		(PKT_Data+3)	/* Modem signal status */
+#define	PKT_PortStatus		(PKT_Data+4)	/* Port signal status */
+#define	PKT_SubCmd		(PKT_Data+5)	/* Sub Command */
 
 /* ModemStatus definitions... */
-#define	MODEM_DSR		0x80			/* Data Set Ready modem state */
-#define	MODEM_CTS		0x40			/* Clear To Send modem state */
-#define	MODEM_RI		0x20			/* Ring Indicate modem state */
-#define	MODEM_CD		0x10			/* Carrier Detect modem state */
-#define	MODEM_TSTOP		0x08			/* Transmit Stopped state */
-#define	MODEM_TEMPTY		0x04			/* Transmit Empty state */
-#define	MODEM_DTR		0x02			/* DTR modem output state */
-#define	MODEM_RTS		0x01			/* RTS modem output state */
+#define	MODEM_DSR		0x80	/* Data Set Ready modem state */
+#define	MODEM_CTS		0x40	/* Clear To Send modem state */
+#define	MODEM_RI		0x20	/* Ring Indicate modem state */
+#define	MODEM_CD		0x10	/* Carrier Detect modem state */
+#define	MODEM_TSTOP		0x08	/* Transmit Stopped state */
+#define	MODEM_TEMPTY		0x04	/* Transmit Empty state */
+#define	MODEM_DTR		0x02	/* DTR modem output state */
+#define	MODEM_RTS		0x01	/* RTS modem output state */
 
 /* PortStatus definitions... */
-#define	PORT_ISOPEN		0x01			/* Port open ? */
-#define	PORT_HUPCL		0x02			/* Hangup on close? */
-#define	PORT_MOPENPEND		0x04			/* Modem open pending */
-#define	PORT_ISPARALLEL		0x08			/* Parallel port */
-#define	PORT_BREAK		0x10			/* Port on break */
-#define	PORT_STATUSPEND		0020			/* Status packet pending */
-#define	PORT_BREAKPEND		0x40			/* Break packet pending */
-#define	PORT_MODEMPEND		0x80			/* Modem status packet pending */
+#define	PORT_ISOPEN		0x01	/* Port open ? */
+#define	PORT_HUPCL		0x02	/* Hangup on close? */
+#define	PORT_MOPENPEND		0x04	/* Modem open pending */
+#define	PORT_ISPARALLEL		0x08	/* Parallel port */
+#define	PORT_BREAK		0x10	/* Port on break */
+#define	PORT_STATUSPEND		0020	/* Status packet pending */
+#define	PORT_BREAKPEND		0x40	/* Break packet pending */
+#define	PORT_MODEMPEND		0x80	/* Modem status packet pending */
 
 /*****************************************************************************
 ************************                            **************************
@@ -956,35 +950,35 @@
    packets, except MEMDUMP and READ_REGISTER.
    */
 #if 0
-#define	PKT_Cmd			(PKT_Data+0)		/* Command code */
-#define	PKT_PhbNum		(PKT_Data+1)		/* Port number wrt RTA */
-#define	PKT_Cmd2		(PKT_Data+2)		/* Command code copy */
+#define	PKT_Cmd			(PKT_Data+0)	/* Command code */
+#define	PKT_PhbNum		(PKT_Data+1)	/* Port number wrt RTA */
+#define	PKT_Cmd2		(PKT_Data+2)	/* Command code copy */
 #endif
-#define	PKT_ModemStatus		(PKT_Data+3)		/* Modem signal status */
-#define	PKT_PortStatus		(PKT_Data+4)		/* Port signal status */
+#define	PKT_ModemStatus		(PKT_Data+3)	/* Modem signal status */
+#define	PKT_PortStatus		(PKT_Data+4)	/* Port signal status */
 #if 0
-#define	PKT_SubCmd		(PKT_Data+5)		/* Sub Command */
+#define	PKT_SubCmd		(PKT_Data+5)	/* Sub Command */
 #endif
 
 /* ModemStatus definitions... */
-#define	MODEM_DSR		0x80			/* Data Set Ready modem state */
-#define	MODEM_CTS		0x40			/* Clear To Send modem state */
-#define	MODEM_RI		0x20			/* Ring Indicate modem state */
-#define	MODEM_CD		0x10			/* Carrier Detect modem state */
-#define	MODEM_TSTOP		0x08			/* Transmit Stopped state */
-#define	MODEM_TEMPTY		0x04			/* Transmit Empty state */
-#define	MODEM_DTR		0x02			/* DTR modem output state */
-#define	MODEM_RTS		0x01			/* RTS modem output state */
+#define	MODEM_DSR		0x80	/* Data Set Ready modem state */
+#define	MODEM_CTS		0x40	/* Clear To Send modem state */
+#define	MODEM_RI		0x20	/* Ring Indicate modem state */
+#define	MODEM_CD		0x10	/* Carrier Detect modem state */
+#define	MODEM_TSTOP		0x08	/* Transmit Stopped state */
+#define	MODEM_TEMPTY		0x04	/* Transmit Empty state */
+#define	MODEM_DTR		0x02	/* DTR modem output state */
+#define	MODEM_RTS		0x01	/* RTS modem output state */
 
 /* PortStatus definitions... */
-#define	PORT_ISOPEN		0x01			/* Port open ? */
-#define	PORT_HUPCL		0x02			/* Hangup on close? */
-#define	PORT_MOPENPEND		0x04			/* Modem open pending */
-#define	PORT_ISPARALLEL		0x08			/* Parallel port */
-#define	PORT_BREAK		0x10			/* Port on break */
-#define	PORT_STATUSPEND		0020			/* Status packet pending */
-#define	PORT_BREAKPEND		0x40			/* Break packet pending */
-#define	PORT_MODEMPEND		0x80			/* Modem status packet pending */
+#define	PORT_ISOPEN		0x01	/* Port open ? */
+#define	PORT_HUPCL		0x02	/* Hangup on close? */
+#define	PORT_MOPENPEND		0x04	/* Modem open pending */
+#define	PORT_ISPARALLEL		0x08	/* Parallel port */
+#define	PORT_BREAK		0x10	/* Port on break */
+#define	PORT_STATUSPEND		0020	/* Status packet pending */
+#define	PORT_BREAKPEND		0x40	/* Break packet pending */
+#define	PORT_MODEMPEND		0x80	/* Modem status packet pending */
 
 /*****************************************************************************
 ********************                                      ********************
@@ -998,15 +992,15 @@
    port I/O control command packet.
    */
 #if 0
-#define	PKT_Cmd			(PKT_Data+0)		/* Command code */
-#define	PKT_PhbNum		(PKT_Data+1)		/* Port number wrt RTA */
-#define	PKT_Cmd2		(PKT_Data+2)		/* Command code copy */
-#define	PKT_ModemStatus		(PKT_Data+3)		/* Modem signal status */
-#define	PKT_PortStatus		(PKT_Data+4)		/* Port signal status */
-#define	PKT_SubCmd		(PKT_Data+5)		/* Sub Command */
-#define	PKT_Address		(PKT_Data+6)		/* Requested address */
+#define	PKT_Cmd			(PKT_Data+0)	/* Command code */
+#define	PKT_PhbNum		(PKT_Data+1)	/* Port number wrt RTA */
+#define	PKT_Cmd2		(PKT_Data+2)	/* Command code copy */
+#define	PKT_ModemStatus		(PKT_Data+3)	/* Modem signal status */
+#define	PKT_PortStatus		(PKT_Data+4)	/* Port signal status */
+#define	PKT_SubCmd		(PKT_Data+5)	/* Sub Command */
+#define	PKT_Address		(PKT_Data+6)	/* Requested address */
 #endif
-#define	PKT_Dump		(PKT_Data+8)		/* 32bytes of requested dump data */
+#define	PKT_Dump		(PKT_Data+8)	/* 32bytes of requested dump data */
 
 /*****************************************************************************
 *****************                                            *****************
@@ -1020,14 +1014,14 @@
    READ_REGISTER port I/O control command packet.
    */
 #if 0
-#define	PKT_Cmd			(PKT_Data+0)		/*Command code */
-#define	PKT_PhbNum		(PKT_Data+1)		/*Port number wrt RTA */
-#define	PKT_Cmd2		(PKT_Data+2)		/* Command code copy */
+#define	PKT_Cmd			(PKT_Data+0)	/*Command code */
+#define	PKT_PhbNum		(PKT_Data+1)	/*Port number wrt RTA */
+#define	PKT_Cmd2		(PKT_Data+2)	/* Command code copy */
 #endif
-#define	PKT_RegisterValue	(PKT_Data+3)		/* Modem signal status */
+#define	PKT_RegisterValue	(PKT_Data+3)	/* Modem signal status */
 #if 0
-#define	PKT_PortStatus		(PKT_Data+4)		/* Port signal status */
-#define	PKT_SubCmd		(PKT_Data+5)		/* Sub Command */
+#define	PKT_PortStatus		(PKT_Data+4)	/* Port signal status */
+#define	PKT_SubCmd		(PKT_Data+5)	/* Sub Command */
 #endif
 
 /*****************************************************************************
@@ -1041,9 +1035,9 @@
    COMMAND_RUP - BREAK_RECEIVED packets are sent when the port detects a receive BREAK signal.
    */
 #if 0
-#define	PKT_Cmd			(PKT_Data+0)		/* Command code */
-#define	PKT_PhbNum		(PKT_Data+1)		/* Port number wrt RTA */
-#define	PKT_Cmd2		(PKT_Data+2)		/* Command code copy */
+#define	PKT_Cmd			(PKT_Data+0)	/* Command code */
+#define	PKT_PhbNum		(PKT_Data+1)	/* Port number wrt RTA */
+#define	PKT_Cmd2		(PKT_Data+2)	/* Command code copy */
 #endif
 
 /*****************************************************************************
@@ -1059,10 +1053,10 @@
 
    */
 #if 0
-#define	PKT_Cmd			(PKT_Data+0)		/* Command code */
-#define	PKT_PhbNum		(PKT_Data+1)		/* Port number wrt RTA */
-#define	PKT_Cmd2		(PKT_Data+2)		/* Command code copy */
-#define	PKT_ModemStatus		(PKT_Data+3)		/* Modem signal status */
+#define	PKT_Cmd			(PKT_Data+0)	/* Command code */
+#define	PKT_PhbNum		(PKT_Data+1)	/* Port number wrt RTA */
+#define	PKT_Cmd2		(PKT_Data+2)	/* Command code copy */
+#define	PKT_ModemStatus		(PKT_Data+3)	/* Modem signal status */
 #endif
 
 /*****************************************************************************
@@ -1077,7 +1071,7 @@
    firmware code to load onto attached RTAs.
    */
 #if 0
-#define	PKT_Cmd			(PKT_Data+0)		/* Command code */
+#define	PKT_Cmd			(PKT_Data+0)	/* Command code */
 #endif
 
 /*****************************************************************************
@@ -1092,12 +1086,12 @@
    to a BOOT_RUP - BOOT_REQUEST packet.
    */
 #if 0
-#define	PKT_Cmd			(PKT_Data+0)		/* Command code */
+#define	PKT_Cmd			(PKT_Data+0)	/* Command code */
 #endif
-#define	PKT_NumPackets		(PKT_Data+2)		/* Packets required to load firmware */
-#define	PKT_LoadBase		(PKT_Data+4)		/* RTA firmware load address */
-#define	PKT_CodeSize		(PKT_Data+6)		/* Size of firmware in bytes */
-#define	PKT_CmdString		(PKT_Data+8)		/* Command string */
+#define	PKT_NumPackets		(PKT_Data+2)	/* Packets required to load firmware */
+#define	PKT_LoadBase		(PKT_Data+4)	/* RTA firmware load address */
+#define	PKT_CodeSize		(PKT_Data+6)	/* Size of firmware in bytes */
+#define	PKT_CmdString		(PKT_Data+8)	/* Command string */
 
 /*****************************************************************************
 ************************                               ***********************
@@ -1111,10 +1105,10 @@
    RTA firmware has completed.
    */
 #if 0
-#define	PKT_Cmd			(PKT_Data+0)		/* Command code */
+#define	PKT_Cmd			(PKT_Data+0)	/* Command code */
 #endif
-#define	PKT_LinkNumber		(PKT_Data+1)		/* Link number RTA booted on */
-#define	PKT_SerialNumber	(PKT_Data+2)		/* 4 byte serial number */
+#define	PKT_LinkNumber		(PKT_Data+1)	/* Link number RTA booted on */
+#define	PKT_SerialNumber	(PKT_Data+2)	/* 4 byte serial number */
 
 /*****************************************************************************
 ************************                               ***********************
@@ -1127,7 +1121,7 @@
    BOOT_RUP packet without the PKT_CMD_BIT set in the PKT->len field is sent
    from RIO to the Driver as a request for a firmware boot packet. */
 
-#define	PKT_SequenceNumber	(PKT_Data+0)		/* Packet sequence number */
+#define	PKT_SequenceNumber	(PKT_Data+0)	/* Packet sequence number */
 
 /*****************************************************************************
 ***********************                                ***********************
@@ -1141,9 +1135,9 @@
    packet with the 70 bytes of the requested sequence.
    */
 #if 0
-#define	PKT_SequenceNumber	(PKT_Data+0)		/* Packet sequence number */
+#define	PKT_SequenceNumber	(PKT_Data+0)	/* Packet sequence number */
 #endif
-#define	PKT_FirmwarePacket	(PKT_Data+2)		/* Firmware packet */
+#define	PKT_FirmwarePacket	(PKT_Data+2)	/* Firmware packet */
 
 /*****************************************************************************
 ****************************                      ****************************
@@ -1157,10 +1151,10 @@
    RTA to shut down and reboot.
    */
 #if 0
-#define	PKT_Cmd			(PKT_Data+0)		/* Command code */
+#define	PKT_Cmd			(PKT_Data+0)	/* Command code */
 #endif
-#define	PKT_IfoadId1		(PKT_Data+2)		/* IFOAD Id 1 */
-#define	PKT_IfoadId2		(PKT_Data+3)		/* IFOAD Id 2 */
+#define	PKT_IfoadId1		(PKT_Data+2)	/* IFOAD Id 1 */
+#define	PKT_IfoadId2		(PKT_Data+3)	/* IFOAD Id 2 */
 
 #define	IFOADID1		0xAD
 #define	IFOADID2		0xF0
@@ -1177,9 +1171,9 @@
    RTA to flash its LEDs for a period of time.
    */
 #if 0
-#define	PKT_Cmd			(PKT_Data+0)		/* Command code */
+#define	PKT_Cmd			(PKT_Data+0)	/* Command code */
 #endif
-#define	PKT_IdentifyId		(PKT_Data+2)		/* defines pattern to flash */
+#define	PKT_IdentifyId		(PKT_Data+2)	/* defines pattern to flash */
 
 /*****************************************************************************
 ****************************                       ***************************
@@ -1193,10 +1187,10 @@
    RTA to shut down and flash it's LEDs.
    */
 #if 0
-#define	PKT_Cmd			(PKT_Data+0)		/* Command code */
+#define	PKT_Cmd			(PKT_Data+0)	/* Command code */
 #endif
-#define	PKT_ZombieId1		(PKT_Data+2)		/* ZOMBIE Id 1 */
-#define	PKT_ZombieId2		(PKT_Data+3)		/* ZOMBIE Id 2 */
+#define	PKT_ZombieId1		(PKT_Data+2)	/* ZOMBIE Id 1 */
+#define	PKT_ZombieId2		(PKT_Data+3)	/* ZOMBIE Id 2 */
 
 #define	ZOMBIEID1		0x52
 #define	ZOMBIEID2		0x21
@@ -1213,11 +1207,11 @@
    to ask it's neighbouring RTA to shut down and reboot.
    */
 #if 0
-#define	PKT_Cmd			(PKT_Data+0)		/* Command code */
-#define	PKT_LinkNumber		(PKT_Data+1)		/* Link number of RTA to UFOAD */
+#define	PKT_Cmd			(PKT_Data+0)	/* Command code */
+#define	PKT_LinkNumber		(PKT_Data+1)	/* Link number of RTA to UFOAD */
 #endif
-#define	PKT_UfoadId1		(PKT_Data+2)		/* UFOAD Id 1 */
-#define	PKT_UfoadId2		(PKT_Data+3)		/* UFOAD Id 2 */
+#define	PKT_UfoadId1		(PKT_Data+2)	/* UFOAD Id 1 */
+#define	PKT_UfoadId2		(PKT_Data+3)	/* UFOAD Id 2 */
 
 #define	UFOADID1		0x1E
 #define	UFOADID2		0x0D
@@ -1234,11 +1228,11 @@
    to pause booting on the specified link for 30 seconds.
    */
 #if 0
-#define	PKT_Cmd			(PKT_Data+0)		/* Command code */
-#define	PKT_LinkNumber		(PKT_Data+1)		/* Link number of RTA to UFOAD */
+#define	PKT_Cmd			(PKT_Data+0)	/* Command code */
+#define	PKT_LinkNumber		(PKT_Data+1)	/* Link number of RTA to UFOAD */
 #endif
-#define	PKT_IwaitId1		(PKT_Data+2)		/* IWAIT Id 1 */
-#define	PKT_IwaitId2		(PKT_Data+3)		/* IWAIT Id 2 */
+#define	PKT_IwaitId1		(PKT_Data+2)	/* IWAIT Id 1 */
+#define	PKT_IwaitId2		(PKT_Data+3)	/* IWAIT Id 2 */
 
 #define	IWAITID1		0xDE
 #define	IWAITID2		0xB1
@@ -1255,20 +1249,20 @@
    RTA to a Driver to request an ID (RUP or unit number).
    */
 #if 0
-#define	PKT_Cmd			(PKT_Data+0)		/* Command code */
+#define	PKT_Cmd			(PKT_Data+0)	/* Command code */
 #endif
-#define	PKT_SerialNumber	(PKT_Data+2)		/* 4 byte serial number */
-#define	PKT_ModuleTypes		(PKT_Data+6)		/* RTA Module types */
+#define	PKT_SerialNumber	(PKT_Data+2)	/* 4 byte serial number */
+#define	PKT_ModuleTypes		(PKT_Data+6)	/* RTA Module types */
 
 /* ModuleTypes definitions... */
-#define	MOD_BLANK		0x0F			/* Blank plate attached */
-#define	MOD_RS232DB25		0x00			/* RS232 DB25 connector */
-#define	MOD_RS232RJ45		0x01			/* RS232 RJ45 connector */
-#define	MOD_RS422DB25		0x02			/* RS422 DB25 connector */
-#define	MOD_RS485DB25		0x03			/* RS485 DB25 connector */
-#define	MOD_PARALLEL		0x04			/* Centronics parallel */
+#define	MOD_BLANK		0x0F	/* Blank plate attached */
+#define	MOD_RS232DB25		0x00	/* RS232 DB25 connector */
+#define	MOD_RS232RJ45		0x01	/* RS232 RJ45 connector */
+#define	MOD_RS422DB25		0x02	/* RS422 DB25 connector */
+#define	MOD_RS485DB25		0x03	/* RS485 DB25 connector */
+#define	MOD_PARALLEL		0x04	/* Centronics parallel */
 
-#define	MOD2			0x08			/* Set to indicate Rev2 module */
+#define	MOD2			0x08	/* Set to indicate Rev2 module */
 
 /*****************************************************************************
 *************************                            *************************
@@ -1282,9 +1276,9 @@
    packet to cause the RTA to "Fall Over And Die"., i.e. shutdown and reboot.
    */
 #if 0
-#define	PKT_Cmd			(PKT_Data+0)		/* Command code */
+#define	PKT_Cmd			(PKT_Data+0)	/* Command code */
 #endif
-#define	PKT_RouteCmdString	(PKT_Data+2)		/* Command string */
+#define	PKT_RouteCmdString	(PKT_Data+2)	/* Command string */
 
 /*****************************************************************************
 ***********************                                ***********************
@@ -1298,13 +1292,13 @@
    packet to allocate the RTA's Id number (RUP number 1..16)
    */
 #if 0
-#define	PKT_Cmd			(PKT_Data+0)		/* Command code */
+#define	PKT_Cmd			(PKT_Data+0)	/* Command code */
 #endif
-#define	PKT_IdNum		(PKT_Data+1)		/* RUP number for ports 1..8 */
+#define	PKT_IdNum		(PKT_Data+1)	/* RUP number for ports 1..8 */
 #if 0
-#define	PKT_RouteCmdString	(PKT_Data+2)		/* Command string */
+#define	PKT_RouteCmdString	(PKT_Data+2)	/* Command string */
 #endif
-#define	PKT_IdNum2		(PKT_Data+0x17)		/* RUP number for ports 9..16 */
+#define	PKT_IdNum2		(PKT_Data+0x17)	/* RUP number for ports 9..16 */
 
 /*****************************************************************************
 ***********************                                ***********************
@@ -1318,18 +1312,18 @@
    current link status.
    */
 #if 0
-#define	PKT_Cmd			(PKT_Data+0)		/* Command code */
+#define	PKT_Cmd			(PKT_Data+0)	/* Command code */
 #endif
-#define	PKT_Link1Rup		(PKT_Data+2)		/* Link 1 RUP number */
-#define	PKT_Link1Link		(PKT_Data+3)		/* Link 1 link number */
-#define	PKT_Link2Rup		(PKT_Data+4)		/* Link 2 RUP number */
-#define	PKT_Link2Link		(PKT_Data+5)		/* Link 2 link number */
-#define	PKT_Link3Rup		(PKT_Data+6)		/* Link 3 RUP number */
-#define	PKT_Link3Link		(PKT_Data+7)		/* Link 3 link number */
-#define	PKT_Link4Rup		(PKT_Data+8)		/* Link 4 RUP number */
-#define	PKT_Link4Link		(PKT_Data+9)		/* Link 4 link number */
-#define	PKT_RtaVpdProm		(PKT_Data+10)		/* 32 bytes of RTA VPD PROM Contents */
+#define	PKT_Link1Rup		(PKT_Data+2)	/* Link 1 RUP number */
+#define	PKT_Link1Link		(PKT_Data+3)	/* Link 1 link number */
+#define	PKT_Link2Rup		(PKT_Data+4)	/* Link 2 RUP number */
+#define	PKT_Link2Link		(PKT_Data+5)	/* Link 2 link number */
+#define	PKT_Link3Rup		(PKT_Data+6)	/* Link 3 RUP number */
+#define	PKT_Link3Link		(PKT_Data+7)	/* Link 3 link number */
+#define	PKT_Link4Rup		(PKT_Data+8)	/* Link 4 RUP number */
+#define	PKT_Link4Link		(PKT_Data+9)	/* Link 4 link number */
+#define	PKT_RtaVpdProm		(PKT_Data+10)	/* 32 bytes of RTA VPD PROM Contents */
 
-#endif						/* _sxwinif_h */
+#endif				/* _sxwinif_h */
 
 /* End of RIOWINIF.H */
diff --git a/drivers/char/rio/riscos.h b/drivers/char/rio/riscos.h
index 7685cc1..60d66d0 100644
--- a/drivers/char/rio/riscos.h
+++ b/drivers/char/rio/riscos.h
@@ -60,4 +60,4 @@
 #define RINDW(A)	(*(ushort *)(A))
 #define WINDW(A,V)	(*(ushort *)(A)=(ushort)(V))
 
-#endif /* __rio_riscos_h__ */
+#endif				/* __rio_riscos_h__ */
diff --git a/drivers/char/rio/rom.h b/drivers/char/rio/rom.h
index ee79b8e..58a7843 100644
--- a/drivers/char/rio/rom.h
+++ b/drivers/char/rio/rom.h
@@ -39,19 +39,19 @@
 
 #ifndef lint
 #ifdef SCCS
-static char *_rio_rom_h_sccs = "@(#)rom.h	1.1" ;
+static char *_rio_rom_h_sccs = "@(#)rom.h	1.1";
 #endif
 #endif
 
-typedef struct  ROM  ROM ;
-struct  ROM  {
-                 u_short    slx ;
-                 char       pcb_letter_rev ;
-                 char       pcb_number_rev ;
-                 char       serial[4] ;
-                 char       year ;
-                 char       week ;
-             } ;
+typedef struct ROM ROM;
+struct ROM {
+	u_short slx;
+	char pcb_letter_rev;
+	char pcb_number_rev;
+	char serial[4];
+	char year;
+	char week;
+};
 
 #endif
 
@@ -60,5 +60,3 @@
 #define ROM_LENGTH  0x20
 
 /*********** end of file ***********/
-
-
diff --git a/drivers/char/rio/route.h b/drivers/char/rio/route.h
index c42dbb9..769744e 100644
--- a/drivers/char/rio/route.h
+++ b/drivers/char/rio/route.h
@@ -44,26 +44,26 @@
 #endif
 
 #define MAX_LINKS 4
-#define MAX_NODES 17                          /* Maximum nodes in a subnet */
-#define NODE_BYTES ((MAX_NODES / 8) + 1)      /* Number of bytes needed for
-                                                 1 bit per node */
-#define ROUTE_DATA_SIZE  (NODE_BYTES + 2)     /* Number of bytes for complete 
-                                                 info about cost etc. */
+#define MAX_NODES 17		/* Maximum nodes in a subnet */
+#define NODE_BYTES ((MAX_NODES / 8) + 1)	/* Number of bytes needed for
+						   1 bit per node */
+#define ROUTE_DATA_SIZE  (NODE_BYTES + 2)	/* Number of bytes for complete
+						   info about cost etc. */
 #define ROUTES_PER_PACKET ((PKT_MAX_DATA_LEN -2)/ ROUTE_DATA_SIZE)
-                                              /* Number of nodes we can squeeze
-                                                 into one packet */
+					      /* Number of nodes we can squeeze
+					         into one packet */
 #define MAX_TOPOLOGY_PACKETS (MAX_NODES / ROUTES_PER_PACKET + 1)
 /************************************************
  * Define the types of command for the ROUTE RUP.
  ************************************************/
-#define ROUTE_REQUEST    0                    /* Request an ID */
-#define ROUTE_FOAD       1                    /* Kill the RTA */
-#define ROUTE_ALREADY    2                    /* ID given already */
-#define ROUTE_USED       3                    /* All ID's used */
-#define ROUTE_ALLOCATE   4                    /* Here it is */
-#define ROUTE_REQ_TOP    5                    /* I bet you didn't expect....
-                                                 the Topological Inquisition */
-#define ROUTE_TOPOLOGY   6                    /* Topology request answered FD */
+#define ROUTE_REQUEST    0	/* Request an ID */
+#define ROUTE_FOAD       1	/* Kill the RTA */
+#define ROUTE_ALREADY    2	/* ID given already */
+#define ROUTE_USED       3	/* All ID's used */
+#define ROUTE_ALLOCATE   4	/* Here it is */
+#define ROUTE_REQ_TOP    5	/* I bet you didn't expect....
+				   the Topological Inquisition */
+#define ROUTE_TOPOLOGY   6	/* Topology request answered FD */
 /*******************************************************************
  * Define the Route Map Structure
  *
@@ -72,22 +72,22 @@
  ******************************************************************/
 typedef struct COST_ROUTE COST_ROUTE;
 struct COST_ROUTE {
-                      unsigned char cost;        /* Cost down this link */
-                      unsigned char route[NODE_BYTES]; /* Nodes thorough this route */
-                  } ;
+	unsigned char cost;	/* Cost down this link */
+	unsigned char route[NODE_BYTES];	/* Nodes thorough this route */
+};
 
-typedef struct ROUTE_STR ROUTE_STR ;
-struct  ROUTE_STR {
-                      COST_ROUTE cost_route[MAX_LINKS];
-                                                /* cost / route for this link */
-                      ushort favoured;          /* favoured link */
-                  } ;
+typedef struct ROUTE_STR ROUTE_STR;
+struct ROUTE_STR {
+	COST_ROUTE cost_route[MAX_LINKS];
+	/* cost / route for this link */
+	ushort favoured;	/* favoured link */
+};
 
 
-#define NO_LINK            (short) 5      /* Link unattached */
-#define ROUTE_NO_ID        (short) 100    /* No Id */
-#define ROUTE_DISCONNECT   (ushort) 0xff  /* Not connected */
-#define ROUTE_INTERCONNECT (ushort) 0x40  /* Sub-net interconnect */
+#define NO_LINK            (short) 5	/* Link unattached */
+#define ROUTE_NO_ID        (short) 100	/* No Id */
+#define ROUTE_DISCONNECT   (ushort) 0xff	/* Not connected */
+#define ROUTE_INTERCONNECT (ushort) 0x40	/* Sub-net interconnect */
 
 
 #define SYNC_RUP         (ushort) 255
@@ -99,10 +99,9 @@
 #define STATUS_RUP       (ushort) 249
 #define POWER_RUP        (ushort) 248
 
-#define HIGHEST_RUP      (ushort) 255   /* Set to Top one */
-#define LOWEST_RUP       (ushort) 248   /* Set to bottom one */
+#define HIGHEST_RUP      (ushort) 255	/* Set to Top one */
+#define LOWEST_RUP       (ushort) 248	/* Set to bottom one */
 
 #endif
 
 /*********** end of file ***********/
-
diff --git a/drivers/char/rio/rtahw.h b/drivers/char/rio/rtahw.h
index 0686011..e6c2cdf 100644
--- a/drivers/char/rio/rtahw.h
+++ b/drivers/char/rio/rtahw.h
@@ -37,7 +37,7 @@
 
 #ifndef lint
 #ifdef SCCS_LABELS
-static char *_rio_rtahw_h_sccs = "@(#)rtahw.h	1.5" ;
+static char *_rio_rtahw_h_sccs = "@(#)rtahw.h	1.5";
 #endif
 #endif
 
@@ -58,12 +58,12 @@
 ** Define the different types of modules we can have
 */
 enum module {
-    MOD_BLANK		= 0x0f,		/* Blank plate attached */
-    MOD_RS232DB25	= 0x00,		/* RS232 DB25 connector */
-    MOD_RS232RJ45	= 0x01,		/* RS232 RJ45 connector */
-    MOD_RS422DB25	= 0x02,		/* RS422 DB25 connector */
-    MOD_RS485DB25	= 0x03,		/* RS485 DB25 connector */
-    MOD_PARALLEL	= 0x04		/* Centronics parallel */
+	MOD_BLANK = 0x0f,	/* Blank plate attached */
+	MOD_RS232DB25 = 0x00,	/* RS232 DB25 connector */
+	MOD_RS232RJ45 = 0x01,	/* RS232 RJ45 connector */
+	MOD_RS422DB25 = 0x02,	/* RS422 DB25 connector */
+	MOD_RS485DB25 = 0x03,	/* RS485 DB25 connector */
+	MOD_PARALLEL = 0x04	/* Centronics parallel */
 };
 
 #define TYPE_HOST	0
diff --git a/drivers/char/rio/rup.h b/drivers/char/rio/rup.h
index b9d2bc0..8d44fec 100644
--- a/drivers/char/rio/rup.h
+++ b/drivers/char/rio/rup.h
@@ -44,39 +44,38 @@
 #endif
 
 #if defined( HOST ) || defined( INKERNEL )
-#define MAX_RUP          ((short) 16) 
+#define MAX_RUP          ((short) 16)
 #endif
 #ifdef RTA
 #define MAX_RUP          ((short) 1)
 #endif
 
-#define PKTS_PER_RUP     ((short) 2)     /* They are always used in pairs */
+#define PKTS_PER_RUP     ((short) 2)	/* They are always used in pairs */
 
 /*************************************************
  * Define all the  packet request stuff
  ************************************************/
-#define TX_RUP_INACTIVE          0        /* Nothing to transmit */
-#define TX_PACKET_READY          1        /* Transmit packet ready */
-#define TX_LOCK_RUP              2        /* Transmit side locked */
+#define TX_RUP_INACTIVE          0	/* Nothing to transmit */
+#define TX_PACKET_READY          1	/* Transmit packet ready */
+#define TX_LOCK_RUP              2	/* Transmit side locked */
 
-#define RX_RUP_INACTIVE          0        /* Nothing received */
-#define RX_PACKET_READY          1        /* Packet received */
+#define RX_RUP_INACTIVE          0	/* Nothing received */
+#define RX_PACKET_READY          1	/* Packet received */
 
-#define RUP_NO_OWNER             0xff     /* RUP not owned by any process */
+#define RUP_NO_OWNER             0xff	/* RUP not owned by any process */
 
 struct RUP {
-             PKT_ptr    txpkt;            /* Outgoing packet */
-             PKT_ptr    rxpkt;            /* Incoming packet */
-             WORD       link;             /* Which link to send down? */
-             BYTE       rup_dest_unit[2]; /* Destination unit */
-             WORD       handshake;        /* For handshaking */
-             WORD       timeout;          /* Timeout */
-             WORD       status;           /* Status */
-             WORD       txcontrol;        /* Transmit control */
-             WORD       rxcontrol;        /* Receive control */
-           };
- 
+	PKT_ptr txpkt;		/* Outgoing packet */
+	PKT_ptr rxpkt;		/* Incoming packet */
+	WORD link;		/* Which link to send down? */
+	BYTE rup_dest_unit[2];	/* Destination unit */
+	WORD handshake;		/* For handshaking */
+	WORD timeout;		/* Timeout */
+	WORD status;		/* Status */
+	WORD txcontrol;		/* Transmit control */
+	WORD rxcontrol;		/* Receive control */
+};
+
 #endif
 
 /*********** end of file ***********/
-
diff --git a/drivers/char/rio/rupstat.h b/drivers/char/rio/rupstat.h
index b4aafaf..56d828c 100644
--- a/drivers/char/rio/rupstat.h
+++ b/drivers/char/rio/rupstat.h
@@ -39,7 +39,7 @@
 
 #ifndef lint
 #ifdef SCCS_LABELS
-static char *_rio_rupstat_h_sccs = "@(#)rupstat.h	1.1" ;
+static char *_rio_rupstat_h_sccs = "@(#)rupstat.h	1.1";
 #endif
 #endif
 
@@ -48,4 +48,3 @@
 #define    STATUS_TOPOLOGY    2
 
 #endif
-
diff --git a/drivers/char/rio/sam.h b/drivers/char/rio/sam.h
index c1accb8..3149405 100644
--- a/drivers/char/rio/sam.h
+++ b/drivers/char/rio/sam.h
@@ -60,15 +60,12 @@
 #define RX    FALSE
 
 
-typedef struct FREE_LIST FREE_LIST ;
-struct FREE_LIST   {
-                       FREE_LIST_ptr next ;
-                       FREE_LIST_ptr prev ;
-                   } ;
+typedef struct FREE_LIST FREE_LIST;
+struct FREE_LIST {
+	FREE_LIST_ptr next;
+	FREE_LIST_ptr prev;
+};
 
 
 #endif
 /*********** end of file ***********/
-
-
-
diff --git a/drivers/char/rio/selftest.h b/drivers/char/rio/selftest.h
index deae487..7a3dba3 100644
--- a/drivers/char/rio/selftest.h
+++ b/drivers/char/rio/selftest.h
@@ -38,36 +38,36 @@
 ** selftest on a booting RTA.
 */
 typedef struct {
-    short		magic;			/* Identifies packet type */
-    int			test;			/* Test number, see below */
-    unsigned int	result;			/* Result value */
-    unsigned int	dataIn;
-    unsigned int	dataOut;
-}selftestStruct;
+	short magic;		/* Identifies packet type */
+	int test;		/* Test number, see below */
+	unsigned int result;	/* Result value */
+	unsigned int dataIn;
+	unsigned int dataOut;
+} selftestStruct;
 
 /*
 ** The different tests are identified by the following data values.
 */
 enum test {
-    TESTS_COMPLETE	= 0x00,
-    MEMTEST_ADDR	= 0x01,
-    MEMTEST_BIT		= 0x02,
-    MEMTEST_FILL	= 0x03,
-    MEMTEST_DATABUS	= 0x04,
-    MEMTEST_ADDRBUS	= 0x05,
-    CD1400_INIT		= 0x10,
-    CD1400_LOOP		= 0x11,
-    CD1400_INTERRUPT    = 0x12
+	TESTS_COMPLETE = 0x00,
+	MEMTEST_ADDR = 0x01,
+	MEMTEST_BIT = 0x02,
+	MEMTEST_FILL = 0x03,
+	MEMTEST_DATABUS = 0x04,
+	MEMTEST_ADDRBUS = 0x05,
+	CD1400_INIT = 0x10,
+	CD1400_LOOP = 0x11,
+	CD1400_INTERRUPT = 0x12
 };
 
 enum result {
-    E_PORT		= 0x10,
-    E_TX		= 0x11,
-    E_RX		= 0x12,
-    E_EXCEPT		= 0x13,
-    E_COMPARE		= 0x14,
-    E_MODEM		= 0x15,
-    E_TIMEOUT		= 0x16,
-    E_INTERRUPT         = 0x17
+	E_PORT = 0x10,
+	E_TX = 0x11,
+	E_RX = 0x12,
+	E_EXCEPT = 0x13,
+	E_COMPARE = 0x14,
+	E_MODEM = 0x15,
+	E_TIMEOUT = 0x16,
+	E_INTERRUPT = 0x17
 };
-#endif	/* _selftests_h_ */
+#endif				/* _selftests_h_ */
diff --git a/drivers/char/rio/space.h b/drivers/char/rio/space.h
index 72398d3..1f12690 100644
--- a/drivers/char/rio/space.h
+++ b/drivers/char/rio/space.h
@@ -42,4 +42,4 @@
 extern int rio_limits[];
 extern int rio_vects[];
 
-#endif /* __rio_space_h__ */
+#endif				/* __rio_space_h__ */
diff --git a/drivers/char/rio/sysmap.h b/drivers/char/rio/sysmap.h
index fdc7313..e1c6f11 100644
--- a/drivers/char/rio/sysmap.h
+++ b/drivers/char/rio/sysmap.h
@@ -37,27 +37,26 @@
 
 #ifndef lint
 #ifdef SCCS_LABELS
-static char *_rio_sysmap_h_sccs = "@(#)sysmap.h	1.1" ;
+static char *_rio_sysmap_h_sccs = "@(#)sysmap.h	1.1";
 #endif
 #endif
 
-#define SYSTEM_MAP_LEN     64           /* Len of System Map array */
+#define SYSTEM_MAP_LEN     64	/* Len of System Map array */
 
 
-typedef struct SYS_MAP        SYS_MAP ;
-typedef struct SYS_MAP_LINK   SYS_MAP_LINK ;
+typedef struct SYS_MAP SYS_MAP;
+typedef struct SYS_MAP_LINK SYS_MAP_LINK;
 
 struct SYS_MAP_LINK {
-                        short id ;          /* Unit Id */
-                        short link ;        /* Id's Link */
-                        short been_here ;   /* Used by map_gen */
-                    } ;
+	short id;		/* Unit Id */
+	short link;		/* Id's Link */
+	short been_here;	/* Used by map_gen */
+};
 
 struct SYS_MAP {
-                   char         serial_num[4] ;
-                   SYS_MAP_LINK link[4] ;
-               } ;
+	char serial_num[4];
+	SYS_MAP_LINK link[4];
+};
 
 
 /*********** end of file ***********/
-
diff --git a/drivers/char/rio/timeouts.h b/drivers/char/rio/timeouts.h
index 11b3133..a8b5be3 100644
--- a/drivers/char/rio/timeouts.h
+++ b/drivers/char/rio/timeouts.h
@@ -37,15 +37,14 @@
 
 #ifndef lint
 #ifdef SCCS_LABELS
-static char *_rio_defaults_h_sccs = "@(#)timeouts.h	1.3" ;
+static char *_rio_defaults_h_sccs = "@(#)timeouts.h	1.3";
 #endif
 #endif
 
-#define MILLISECOND           (int) (1000/64)   /* 15.625 low ticks */
-#define SECOND                (int) 15625       /* Low priority ticks */
+#define MILLISECOND           (int) (1000/64)	/* 15.625 low ticks */
+#define SECOND                (int) 15625	/* Low priority ticks */
 
 #define TX_TIMEOUT          (int) (200 * MILLISECOND)
 
 
 /*********** end of file ***********/
-
diff --git a/drivers/char/rio/top.h b/drivers/char/rio/top.h
index 255c40d..d15a11d 100644
--- a/drivers/char/rio/top.h
+++ b/drivers/char/rio/top.h
@@ -40,10 +40,9 @@
 /*
 ** Topology information
 */
-struct Top
-{
-    uchar Unit;
-    uchar Link;
+struct Top {
+	uchar Unit;
+	uchar Link;
 };
 
-#endif /* __rio_top_h__ */
+#endif				/* __rio_top_h__ */
diff --git a/drivers/char/rio/typdef.h b/drivers/char/rio/typdef.h
index 2cb9dd6..185b889 100644
--- a/drivers/char/rio/typdef.h
+++ b/drivers/char/rio/typdef.h
@@ -45,11 +45,11 @@
 ** These types are ONLY to be used for refering to data structures
 ** on the RIO Host card!
 */
-typedef	volatile unsigned char	BYTE;
-typedef volatile unsigned short	WORD;
-typedef volatile unsigned int	DWORD;
-typedef	volatile unsigned short RIOP;
-typedef	volatile short          NUMBER;
+typedef volatile unsigned char BYTE;
+typedef volatile unsigned short WORD;
+typedef volatile unsigned int DWORD;
+typedef volatile unsigned short RIOP;
+typedef volatile short NUMBER;
 
 
 /*
@@ -59,13 +59,13 @@
 ** are here only to make the source compile.
 */
 /* typedef unsigned int	uint; */
-typedef unsigned long	ulong_t;
-typedef unsigned short	ushort_t;
-typedef unsigned char	uchar_t;
-typedef unsigned char	queue_t;
-typedef unsigned char	mblk_t;
-typedef	unsigned int 	paddr_t;
-typedef unsigned char   uchar;
+typedef unsigned long ulong_t;
+typedef unsigned short ushort_t;
+typedef unsigned char uchar_t;
+typedef unsigned char queue_t;
+typedef unsigned char mblk_t;
+typedef unsigned int paddr_t;
+typedef unsigned char uchar;
 
 #define	TPNULL	((ushort)(0x8000))
 
@@ -73,10 +73,10 @@
 /*
 ** RIO structures defined in other include files.
 */
-typedef struct PKT	 	PKT;
-typedef struct LPB	 	LPB;
-typedef struct RUP	 	RUP;
-typedef struct Port		Port;
-typedef struct DpRam		DpRam;
+typedef struct PKT PKT;
+typedef struct LPB LPB;
+typedef struct RUP RUP;
+typedef struct Port Port;
+typedef struct DpRam DpRam;
 
-#endif /* __rio_typdef_h__ */
+#endif				/* __rio_typdef_h__ */
diff --git a/drivers/char/rio/unixrup.h b/drivers/char/rio/unixrup.h
index eddf862..a126c7c 100644
--- a/drivers/char/rio/unixrup.h
+++ b/drivers/char/rio/unixrup.h
@@ -41,16 +41,15 @@
 **    UnixRup data structure. This contains pointers to actual RUPs on the
 **    host card, and all the command/boot control stuff.
 */
-struct    UnixRup
-{
-    struct CmdBlk    *CmdsWaitingP;	/* Commands waiting to be done */
-    struct CmdBlk    *CmdPendingP;	/* The command currently being sent */
-    struct RUP       *RupP;		/* the Rup to send it to */
-    uint             Id;		/* Id number */
-    uint             BaseSysPort;	/* SysPort of first tty on this RTA */
-    uint             ModTypes;		/* Modules on this RTA */
-    spinlock_t	     RupLock;		/* Lock structure for MPX */
-/*    struct lockb     RupLock;	*/	/* Lock structure for MPX */
+struct UnixRup {
+	struct CmdBlk *CmdsWaitingP;	/* Commands waiting to be done */
+	struct CmdBlk *CmdPendingP;	/* The command currently being sent */
+	struct RUP *RupP;	/* the Rup to send it to */
+	uint Id;		/* Id number */
+	uint BaseSysPort;	/* SysPort of first tty on this RTA */
+	uint ModTypes;		/* Modules on this RTA */
+	spinlock_t RupLock;	/* Lock structure for MPX */
+	/*    struct lockb     RupLock;	*//* Lock structure for MPX */
 };
 
-#endif /* __rio_unixrup_h__ */
+#endif				/* __rio_unixrup_h__ */
diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c
index a7f099f..7cac6d0 100644
--- a/drivers/char/rtc.c
+++ b/drivers/char/rtc.c
@@ -46,10 +46,10 @@
  *      1.11a   Daniele Bellucci: Audit create_proc_read_entry in rtc_init
  *	1.12	Venkatesh Pallipadi: Hooks for emulating rtc on HPET base-timer
  *		CONFIG_HPET_EMULATE_RTC
- *
+ *	1.12ac	Alan Cox: Allow read access to the day of week register
  */
 
-#define RTC_VERSION		"1.12"
+#define RTC_VERSION		"1.12ac"
 
 #define RTC_IO_EXTENT	0x8
 
@@ -1250,9 +1250,9 @@
 
 	/*
 	 * Only the values that we read from the RTC are set. We leave
-	 * tm_wday, tm_yday and tm_isdst untouched. Even though the
-	 * RTC has RTC_DAY_OF_WEEK, we ignore it, as it is only updated
-	 * by the RTC when initially set to a non-zero value.
+	 * tm_wday, tm_yday and tm_isdst untouched. Note that while the
+	 * RTC has RTC_DAY_OF_WEEK, we should usually ignore it, as it is
+	 * only updated by the RTC when initially set to a non-zero value.
 	 */
 	spin_lock_irq(&rtc_lock);
 	rtc_tm->tm_sec = CMOS_READ(RTC_SECONDS);
@@ -1261,6 +1261,9 @@
 	rtc_tm->tm_mday = CMOS_READ(RTC_DAY_OF_MONTH);
 	rtc_tm->tm_mon = CMOS_READ(RTC_MONTH);
 	rtc_tm->tm_year = CMOS_READ(RTC_YEAR);
+	/* Only set from 2.6.16 onwards */
+	rtc_tm->tm_wday = CMOS_READ(RTC_DAY_OF_WEEK);
+
 #ifdef CONFIG_MACH_DECSTATION
 	real_year = CMOS_READ(RTC_DEC_YEAR);
 #endif
@@ -1275,6 +1278,7 @@
 		BCD_TO_BIN(rtc_tm->tm_mday);
 		BCD_TO_BIN(rtc_tm->tm_mon);
 		BCD_TO_BIN(rtc_tm->tm_year);
+		BCD_TO_BIN(rtc_tm->tm_wday);
 	}
 
 #ifdef CONFIG_MACH_DECSTATION
diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c
index 79c81de..07c9be6 100644
--- a/drivers/char/synclink_gt.c
+++ b/drivers/char/synclink_gt.c
@@ -1,5 +1,5 @@
 /*
- * $Id: synclink_gt.c,v 4.20 2005/11/08 19:51:55 paulkf Exp $
+ * $Id: synclink_gt.c,v 4.22 2006/01/09 20:16:06 paulkf Exp $
  *
  * Device driver for Microgate SyncLink GT serial adapters.
  *
@@ -92,7 +92,7 @@
  * module identification
  */
 static char *driver_name     = "SyncLink GT";
-static char *driver_version  = "$Revision: 4.20 $";
+static char *driver_version  = "$Revision: 4.22 $";
 static char *tty_driver_name = "synclink_gt";
 static char *tty_dev_prefix  = "ttySLG";
 MODULE_LICENSE("GPL");
@@ -288,7 +288,6 @@
 
 	unsigned char __iomem * reg_addr;  /* memory mapped registers address */
 	u32 phys_reg_addr;
-	u32 reg_offset;
 	int reg_addr_requested;
 
 	MGSL_PARAMS params;       /* communications parameters */
@@ -2976,14 +2975,13 @@
 	else
 		info->reg_addr_requested = 1;
 
-	info->reg_addr = ioremap(info->phys_reg_addr, PAGE_SIZE);
+	info->reg_addr = ioremap(info->phys_reg_addr, SLGT_REG_SIZE);
 	if (!info->reg_addr) {
 		DBGERR(("%s cant map device registers, addr=%08X\n",
 			info->device_name, info->phys_reg_addr));
 		info->init_error = DiagStatus_CantAssignPciResources;
 		goto errout;
 	}
-	info->reg_addr += info->reg_offset;
 	return 0;
 
 errout:
@@ -3004,7 +3002,7 @@
 	}
 
 	if (info->reg_addr) {
-		iounmap(info->reg_addr - info->reg_offset);
+		iounmap(info->reg_addr);
 		info->reg_addr = NULL;
 	}
 }
@@ -3108,12 +3106,6 @@
 		info->irq_level = pdev->irq;
 		info->phys_reg_addr = pci_resource_start(pdev,0);
 
-		/* veremap works on page boundaries
-		 * map full page starting at the page boundary
-		 */
-		info->reg_offset    = info->phys_reg_addr & (PAGE_SIZE-1);
-		info->phys_reg_addr &= ~(PAGE_SIZE-1);
-
 		info->bus_type = MGSL_BUS_TYPE_PCI;
 		info->irq_flags = SA_SHIRQ;
 
diff --git a/drivers/char/tlclk.c b/drivers/char/tlclk.c
index 12167c0..bc56df8a 100644
--- a/drivers/char/tlclk.c
+++ b/drivers/char/tlclk.c
@@ -211,7 +211,7 @@
 	result = request_irq(telclk_interrupt, &tlclk_interrupt,
 			     SA_INTERRUPT, "telco_clock", tlclk_interrupt);
 	if (result == -EBUSY) {
-		printk(KERN_ERR "telco_clock: Interrupt can't be reserved!\n");
+		printk(KERN_ERR "tlclk: Interrupt can't be reserved.\n");
 		return -EBUSY;
 	}
 	inb(TLCLK_REG6);	/* Clear interrupt events */
@@ -741,7 +741,7 @@
 
 	ret = register_chrdev(tlclk_major, "telco_clock", &tlclk_fops);
 	if (ret < 0) {
-		printk(KERN_ERR "telco_clock: can't get major! %d\n", tlclk_major);
+		printk(KERN_ERR "tlclk: can't get major %d.\n", tlclk_major);
 		return ret;
 	}
 	alarm_events = kzalloc( sizeof(struct tlclk_alarms), GFP_KERNEL);
@@ -750,7 +750,7 @@
 
 	/* Read telecom clock IRQ number (Set by BIOS) */
 	if (!request_region(TLCLK_BASE, 8, "telco_clock")) {
-		printk(KERN_ERR "tlclk: request_region failed! 0x%X\n",
+		printk(KERN_ERR "tlclk: request_region 0x%X failed.\n",
 			TLCLK_BASE);
 		ret = -EBUSY;
 		goto out2;
@@ -758,7 +758,7 @@
 	telclk_interrupt = (inb(TLCLK_REG7) & 0x0f);
 
 	if (0x0F == telclk_interrupt ) { /* not MCPBL0010 ? */
-		printk(KERN_ERR "telclk_interrup = 0x%x non-mcpbl0010 hw\n",
+		printk(KERN_ERR "telclk_interrup = 0x%x non-mcpbl0010 hw.\n",
 			telclk_interrupt);
 		ret = -ENXIO;
 		goto out3;
@@ -768,7 +768,7 @@
 
 	ret = misc_register(&tlclk_miscdev);
 	if (ret < 0) {
-		printk(KERN_ERR " misc_register retruns %d\n", ret);
+		printk(KERN_ERR "tlclk: misc_register returns %d.\n", ret);
 		ret = -EBUSY;
 		goto out3;
 	}
@@ -776,8 +776,7 @@
 	tlclk_device = platform_device_register_simple("telco_clock",
 				-1, NULL, 0);
 	if (!tlclk_device) {
-		printk(KERN_ERR " platform_device_register retruns 0x%X\n",
-			(unsigned int) tlclk_device);
+		printk(KERN_ERR "tlclk: platform_device_register failed.\n");
 		ret = -EBUSY;
 		goto out4;
 	}
@@ -785,7 +784,7 @@
 	ret = sysfs_create_group(&tlclk_device->dev.kobj,
 			&tlclk_attribute_group);
 	if (ret) {
-		printk(KERN_ERR "failed to create sysfs device attributes\n");
+		printk(KERN_ERR "tlclk: failed to create sysfs device attributes.\n");
 		sysfs_remove_group(&tlclk_device->dev.kobj,
 			&tlclk_attribute_group);
 		goto out5;
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 1eda82b..eb8b5be 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -312,7 +312,7 @@
 
 int tty_buffer_request_room(struct tty_struct *tty, size_t size)
 {
-	struct tty_buffer *b = tty->buf.head, *n;
+	struct tty_buffer *b = tty->buf.tail, *n;
 	int left = 0;
 
 	/* OPTIMISATION: We could keep a per tty "zero" sized buffer to
@@ -326,7 +326,6 @@
 	n = tty_buffer_find(tty, size);
 	if(n == NULL)
 		return left;
-	n->next = b;
 	if(b != NULL)
 		b->next = n;
 	else
@@ -2751,6 +2750,8 @@
 	spin_lock_irqsave(&tty->read_lock, flags);
 	while((tbuf = tty->buf.head) != NULL) {
 		tty->buf.head = tbuf->next;
+		if (tty->buf.head == NULL)
+			tty->buf.tail = NULL;
 		spin_unlock_irqrestore(&tty->read_lock, flags);
 		/* printk("Process buffer %p for %d\n", tbuf, tbuf->used); */
 		disc->receive_buf(tty, tbuf->char_buf_ptr,
@@ -2759,7 +2760,6 @@
 		spin_lock_irqsave(&tty->read_lock, flags);
 		tty_buffer_free(tty, tbuf);
 	}
-	tty->buf.tail = NULL;
 	spin_unlock_irqrestore(&tty->read_lock, flags);
 out:
 	tty_ldisc_deref(disc);
diff --git a/drivers/char/viocons.c b/drivers/char/viocons.c
index cb82ebf..faee5e7 100644
--- a/drivers/char/viocons.c
+++ b/drivers/char/viocons.c
@@ -131,7 +131,7 @@
 
 static struct tty_driver *viotty_driver;
 
-void hvlog(char *fmt, ...)
+static void hvlog(char *fmt, ...)
 {
 	int i;
 	unsigned long flags;
@@ -147,7 +147,7 @@
 	spin_unlock_irqrestore(&consoleloglock, flags);
 }
 
-void hvlogOutput(const char *buf, int count)
+static void hvlogOutput(const char *buf, int count)
 {
 	unsigned long flags;
 	int begin;
@@ -904,6 +904,7 @@
 	struct viocharlpevent *cevent = (struct viocharlpevent *)event;
 	struct port_info *pi;
 	int index;
+	int num_pushed;
 	u8 port = cevent->virtual_device;
 
 	if (port >= VTTY_PORTS) {
@@ -964,6 +965,7 @@
 	 * functionality will only work if built into the kernel and
 	 * then only if sysrq is enabled through the proc filesystem.
 	 */
+	num_pushed = 0;
 	for (index = 0; index < cevent->len; index++) {
 #ifdef CONFIG_MAGIC_SYSRQ
 		if (sysrq_enabled) {
@@ -997,11 +999,10 @@
 			printk(VIOCONS_KERN_WARN "input buffer overflow!\n");
 			break;
 		}
+		num_pushed++;
 	}
 
-	/* if cevent->len == 0 then no data was added to the buffer and flip.count == 0 */
-	if (tty->flip.count)
-		/* The next call resets flip.count when the data is flushed. */
+	if (num_pushed)
 		tty_flip_buffer_push(tty);
 }
 
diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
index bda5bce..343379f 100644
--- a/drivers/firmware/efivars.c
+++ b/drivers/firmware/efivars.c
@@ -65,11 +65,11 @@
  *   v0.01 release to linux-ia64@linuxia64.org
  */
 
+#include <linux/capability.h>
 #include <linux/config.h>
 #include <linux/types.h>
 #include <linux/errno.h>
 #include <linux/init.h>
-#include <linux/sched.h>		/* for capable() */
 #include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/string.h>
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index f7490a015..362b335 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -154,8 +154,10 @@
 	__s32 value;
 };
 
+/* Note to the author of this code: did it ever occur to
+   you why the ifdefs are needed? Think about it again. -AK */
 #ifdef CONFIG_X86_64
-#  define COMPAT_TEST test_thread_flag(TIF_IA32)
+#  define COMPAT_TEST is_compat_task()
 #elif defined(CONFIG_IA64)
 #  define COMPAT_TEST IS_IA32_PROCESS(ia64_task_regs(current))
 #elif defined(CONFIG_S390)
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index ef47edc..5c15f3e 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -1397,7 +1397,7 @@
 
 	  To compile this driver as a module, choose M here and read
 	  <file:Documentation/networking/net-modules.txt>.  The module will be
-	  called cs89x.
+	  called cs89x0.
 
 config TC35815
 	tristate "TOSHIBA TC35815 Ethernet support"
diff --git a/drivers/net/cs89x0.c b/drivers/net/cs89x0.c
index 907c010..e2cfde7 100644
--- a/drivers/net/cs89x0.c
+++ b/drivers/net/cs89x0.c
@@ -100,7 +100,7 @@
  * Note that even if DMA is turned off we still support the 'dma' and  'use_dma'
  * module options so we don't break any startup scripts.
  */
-#ifndef CONFIG_ARCH_IXDP2X01
+#ifndef CONFIG_ISA_DMA_API
 #define ALLOW_DMA	0
 #else
 #define ALLOW_DMA	1
diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
index 166bca7..b80318f 100644
--- a/drivers/oprofile/event_buffer.c
+++ b/drivers/oprofile/event_buffer.c
@@ -15,6 +15,7 @@
 #include <linux/vmalloc.h>
 #include <linux/oprofile.h>
 #include <linux/sched.h>
+#include <linux/capability.h>
 #include <linux/dcookies.h>
 #include <linux/fs.h>
 #include <asm/uaccess.h>
diff --git a/drivers/parisc/led.c b/drivers/parisc/led.c
index f357d3f..3627a2d 100644
--- a/drivers/parisc/led.c
+++ b/drivers/parisc/led.c
@@ -30,6 +30,7 @@
 #include <linux/types.h>
 #include <linux/ioport.h>
 #include <linux/utsname.h>
+#include <linux/capability.h>
 #include <linux/delay.h>
 #include <linux/netdevice.h>
 #include <linux/inetdevice.h>
diff --git a/drivers/parisc/pdc_stable.c b/drivers/parisc/pdc_stable.c
index 38bdca2..42a3c54 100644
--- a/drivers/parisc/pdc_stable.c
+++ b/drivers/parisc/pdc_stable.c
@@ -42,9 +42,9 @@
 
 #include <linux/module.h>
 #include <linux/init.h>
-#include <linux/sched.h>		/* for capable() */
 #include <linux/kernel.h>
 #include <linux/string.h>
+#include <linux/capability.h>
 #include <linux/ctype.h>
 #include <linux/sysfs.h>
 #include <linux/kobject.h>
diff --git a/fs/attr.c b/fs/attr.c
index d63e509..97de946 100644
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -10,6 +10,7 @@
 #include <linux/mm.h>
 #include <linux/string.h>
 #include <linux/smp_lock.h>
+#include <linux/capability.h>
 #include <linux/fsnotify.h>
 #include <linux/fcntl.h>
 #include <linux/quotaops.h>
diff --git a/fs/autofs/root.c b/fs/autofs/root.c
index 808134a..870e2cf 100644
--- a/fs/autofs/root.c
+++ b/fs/autofs/root.c
@@ -10,6 +10,7 @@
  *
  * ------------------------------------------------------------------------- */
 
+#include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/stat.h>
 #include <linux/param.h>
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c
index 14aa702..e93a7ae 100644
--- a/fs/autofs4/root.c
+++ b/fs/autofs4/root.c
@@ -12,6 +12,7 @@
  *
  * ------------------------------------------------------------------------- */
 
+#include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/stat.h>
 #include <linux/param.h>
diff --git a/fs/buffer.c b/fs/buffer.c
index 6466bc8a..b9bb7ad 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -26,6 +26,7 @@
 #include <linux/percpu.h>
 #include <linux/slab.h>
 #include <linux/smp_lock.h>
+#include <linux/capability.h>
 #include <linux/blkdev.h>
 #include <linux/file.h>
 #include <linux/quotaops.h>
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 890bc30f..f0b7256 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -14,6 +14,7 @@
 #include <linux/types.h>
 #include <linux/compat.h>
 #include <linux/kernel.h>
+#include <linux/capability.h>
 #include <linux/compiler.h>
 #include <linux/sched.h>
 #include <linux/smp.h>
@@ -915,6 +916,40 @@
 	return err;
 }
 
+struct compat_sg_req_info { /* used by SG_GET_REQUEST_TABLE ioctl() */
+	char req_state;
+	char orphan;
+	char sg_io_owned;
+	char problem;
+	int pack_id;
+	compat_uptr_t usr_ptr;
+	unsigned int duration;
+	int unused;
+};
+
+static int sg_grt_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
+{
+	int err, i;
+	sg_req_info_t *r;
+	struct compat_sg_req_info *o = (struct compat_sg_req_info *)arg;
+	r = compat_alloc_user_space(sizeof(sg_req_info_t)*SG_MAX_QUEUE);
+	err = sys_ioctl(fd,cmd,(unsigned long)r);
+	if (err < 0)
+		return err;
+	for (i = 0; i < SG_MAX_QUEUE; i++) {
+		void __user *ptr;
+		int d;
+
+		if (copy_in_user(o + i, r + i, offsetof(sg_req_info_t, usr_ptr)) ||
+		    get_user(ptr, &r[i].usr_ptr) ||
+		    get_user(d, &r[i].duration) ||
+		    put_user((u32)(unsigned long)(ptr), &o[i].usr_ptr) ||
+		    put_user(d, &o[i].duration))
+			return -EFAULT;
+	}
+	return err;
+}
+
 struct sock_fprog32 {
 	unsigned short	len;
 	compat_caddr_t	filter;
@@ -2793,6 +2828,7 @@
 HANDLE_IOCTL(FDGETFDCSTAT32, fd_ioctl_trans)
 HANDLE_IOCTL(FDWERRORGET32, fd_ioctl_trans)
 HANDLE_IOCTL(SG_IO,sg_ioctl_trans)
+HANDLE_IOCTL(SG_GET_REQUEST_TABLE, sg_grt_trans)
 HANDLE_IOCTL(PPPIOCGIDLE32, ppp_ioctl_trans)
 HANDLE_IOCTL(PPPIOCSCOMPRESS32, ppp_ioctl_trans)
 HANDLE_IOCTL(PPPIOCSPASS32, ppp_sock_fprog_ioctl_trans)
diff --git a/fs/dcookies.c b/fs/dcookies.c
index 02aa0dd..f8274a8 100644
--- a/fs/dcookies.c
+++ b/fs/dcookies.c
@@ -18,6 +18,7 @@
 #include <linux/slab.h>
 #include <linux/list.h>
 #include <linux/mount.h>
+#include <linux/capability.h>
 #include <linux/dcache.h>
 #include <linux/mm.h>
 #include <linux/errno.h>
diff --git a/fs/dquot.c b/fs/dquot.c
index cb6d5bf..1966c89 100644
--- a/fs/dquot.c
+++ b/fs/dquot.c
@@ -77,6 +77,7 @@
 #include <linux/kmod.h>
 #include <linux/namei.h>
 #include <linux/buffer_head.h>
+#include <linux/capability.h>
 #include <linux/quotaops.h>
 
 #include <asm/uaccess.h>
diff --git a/fs/ext2/acl.c b/fs/ext2/acl.c
index 239133d..35acc43 100644
--- a/fs/ext2/acl.c
+++ b/fs/ext2/acl.c
@@ -4,6 +4,7 @@
  * Copyright (C) 2001-2003 Andreas Gruenbacher, <agruen@suse.de>
  */
 
+#include <linux/capability.h>
 #include <linux/init.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
index bb69080..2c00953 100644
--- a/fs/ext2/balloc.c
+++ b/fs/ext2/balloc.c
@@ -16,6 +16,7 @@
 #include <linux/quotaops.h>
 #include <linux/sched.h>
 #include <linux/buffer_head.h>
+#include <linux/capability.h>
 
 /*
  * balloc.c contains the blocks allocation and deallocation routines
diff --git a/fs/ext2/ioctl.c b/fs/ext2/ioctl.c
index 709d867..3ca9afd 100644
--- a/fs/ext2/ioctl.c
+++ b/fs/ext2/ioctl.c
@@ -8,6 +8,7 @@
  */
 
 #include "ext2.h"
+#include <linux/capability.h>
 #include <linux/time.h>
 #include <linux/sched.h>
 #include <asm/current.h>
diff --git a/fs/ext2/xattr_trusted.c b/fs/ext2/xattr_trusted.c
index 2c072bf..f28a6a4 100644
--- a/fs/ext2/xattr_trusted.c
+++ b/fs/ext2/xattr_trusted.c
@@ -7,6 +7,7 @@
 
 #include <linux/module.h>
 #include <linux/string.h>
+#include <linux/capability.h>
 #include <linux/fs.h>
 #include <linux/smp_lock.h>
 #include <linux/ext2_fs.h>
diff --git a/fs/ext3/acl.c b/fs/ext3/acl.c
index 9ed132c..47a9da2 100644
--- a/fs/ext3/acl.c
+++ b/fs/ext3/acl.c
@@ -7,6 +7,7 @@
 #include <linux/init.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
+#include <linux/capability.h>
 #include <linux/fs.h>
 #include <linux/ext3_jbd.h>
 #include <linux/ext3_fs.h>
diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
index c6393fb..6250fcd 100644
--- a/fs/ext3/balloc.c
+++ b/fs/ext3/balloc.c
@@ -13,6 +13,7 @@
 
 #include <linux/config.h>
 #include <linux/time.h>
+#include <linux/capability.h>
 #include <linux/fs.h>
 #include <linux/jbd.h>
 #include <linux/ext3_fs.h>
diff --git a/fs/ext3/ioctl.c b/fs/ext3/ioctl.c
index 706d686..556cd55 100644
--- a/fs/ext3/ioctl.c
+++ b/fs/ext3/ioctl.c
@@ -9,6 +9,7 @@
 
 #include <linux/fs.h>
 #include <linux/jbd.h>
+#include <linux/capability.h>
 #include <linux/ext3_fs.h>
 #include <linux/ext3_jbd.h>
 #include <linux/time.h>
diff --git a/fs/ext3/xattr_trusted.c b/fs/ext3/xattr_trusted.c
index 7c693c9..86d91f1 100644
--- a/fs/ext3/xattr_trusted.c
+++ b/fs/ext3/xattr_trusted.c
@@ -7,6 +7,7 @@
 
 #include <linux/module.h>
 #include <linux/string.h>
+#include <linux/capability.h>
 #include <linux/fs.h>
 #include <linux/smp_lock.h>
 #include <linux/ext3_jbd.h>
diff --git a/fs/fat/file.c b/fs/fat/file.c
index d30876c..e99c5a7 100644
--- a/fs/fat/file.c
+++ b/fs/fat/file.c
@@ -6,6 +6,7 @@
  *  regular file handling primitives for fat-based filesystems
  */
 
+#include <linux/capability.h>
 #include <linux/module.h>
 #include <linux/time.h>
 #include <linux/msdos_fs.h>
diff --git a/fs/fcntl.c b/fs/fcntl.c
index 9903bde..d0767fe 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -9,6 +9,7 @@
 #include <linux/mm.h>
 #include <linux/fs.h>
 #include <linux/file.h>
+#include <linux/capability.h>
 #include <linux/dnotify.h>
 #include <linux/smp_lock.h>
 #include <linux/slab.h>
diff --git a/fs/file_table.c b/fs/file_table.c
index 6142250..768b581 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -16,6 +16,7 @@
 #include <linux/eventpoll.h>
 #include <linux/rcupdate.h>
 #include <linux/mount.h>
+#include <linux/capability.h>
 #include <linux/cdev.h>
 #include <linux/fsnotify.h>
 
diff --git a/fs/hfsplus/ioctl.c b/fs/hfsplus/ioctl.c
index e07aa09..13cf848 100644
--- a/fs/hfsplus/ioctl.c
+++ b/fs/hfsplus/ioctl.c
@@ -12,6 +12,7 @@
  * hfsplus ioctls
  */
 
+#include <linux/capability.h>
 #include <linux/fs.h>
 #include <linux/sched.h>
 #include <linux/xattr.h>
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index ff1b7d1..ab4c3a9 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -18,6 +18,7 @@
 #include <linux/highmem.h>
 #include <linux/init.h>
 #include <linux/string.h>
+#include <linux/capability.h>
 #include <linux/backing-dev.h>
 #include <linux/hugetlb.h>
 #include <linux/pagevec.h>
diff --git a/fs/ioctl.c b/fs/ioctl.c
index 5692091..f8aeec3 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -8,6 +8,7 @@
 #include <linux/syscalls.h>
 #include <linux/mm.h>
 #include <linux/smp_lock.h>
+#include <linux/capability.h>
 #include <linux/file.h>
 #include <linux/fs.h>
 #include <linux/security.h>
diff --git a/fs/ioprio.c b/fs/ioprio.c
index 4bf1c63..ca77008 100644
--- a/fs/ioprio.c
+++ b/fs/ioprio.c
@@ -22,6 +22,7 @@
 #include <linux/kernel.h>
 #include <linux/ioprio.h>
 #include <linux/blkdev.h>
+#include <linux/capability.h>
 #include <linux/syscalls.h>
 
 static int set_task_ioprio(struct task_struct *task, int ioprio)
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c
index d0fcc5f..09e5d10 100644
--- a/fs/jffs2/fs.c
+++ b/fs/jffs2/fs.c
@@ -11,6 +11,7 @@
  *
  */
 
+#include <linux/capability.h>
 #include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
diff --git a/fs/jfs/xattr.c b/fs/jfs/xattr.c
index 952da5f..f23048f 100644
--- a/fs/jfs/xattr.c
+++ b/fs/jfs/xattr.c
@@ -17,6 +17,7 @@
  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
+#include <linux/capability.h>
 #include <linux/fs.h>
 #include <linux/xattr.h>
 #include <linux/posix_acl_xattr.h>
diff --git a/fs/namei.c b/fs/namei.c
index 0a8f073..1e5746e 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -28,6 +28,7 @@
 #include <linux/syscalls.h>
 #include <linux/mount.h>
 #include <linux/audit.h>
+#include <linux/capability.h>
 #include <linux/file.h>
 #include <asm/namei.h>
 #include <asm/uaccess.h>
diff --git a/fs/namespace.c b/fs/namespace.c
index 2ca6145..8bc15b3 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -16,6 +16,7 @@
 #include <linux/init.h>
 #include <linux/quotaops.h>
 #include <linux/acct.h>
+#include <linux/capability.h>
 #include <linux/module.h>
 #include <linux/seq_file.h>
 #include <linux/namespace.h>
diff --git a/fs/ncpfs/ioctl.c b/fs/ncpfs/ioctl.c
index fd3efdc..d6e0c08 100644
--- a/fs/ncpfs/ioctl.c
+++ b/fs/ncpfs/ioctl.c
@@ -10,6 +10,7 @@
 #include <linux/config.h>
 
 #include <asm/uaccess.h>
+#include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/fs.h>
 #include <linux/ioctl.h>
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index ca5f9f9..eaf33ca 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -23,6 +23,7 @@
  * Boston, MA 021110-1307, USA.
  */
 
+#include <linux/capability.h>
 #include <linux/fs.h>
 #include <linux/types.h>
 #include <linux/slab.h>
diff --git a/fs/open.c b/fs/open.c
index a3b3a9b..8e20c1f 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -16,6 +16,7 @@
 #include <linux/tty.h>
 #include <linux/namei.h>
 #include <linux/backing-dev.h>
+#include <linux/capability.h>
 #include <linux/security.h>
 #include <linux/mount.h>
 #include <linux/vfs.h>
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 634355e..20feb75 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -55,6 +55,7 @@
 #include <linux/proc_fs.h>
 #include <linux/stat.h>
 #include <linux/init.h>
+#include <linux/capability.h>
 #include <linux/file.h>
 #include <linux/string.h>
 #include <linux/seq_file.h>
diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
index 1c7da98..adc2cd9 100644
--- a/fs/proc/kcore.c
+++ b/fs/proc/kcore.c
@@ -14,6 +14,7 @@
 #include <linux/proc_fs.h>
 #include <linux/user.h>
 #include <linux/a.out.h>
+#include <linux/capability.h>
 #include <linux/elf.h>
 #include <linux/elfcore.h>
 #include <linux/vmalloc.h>
diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
index 124e354..4063fb3 100644
--- a/fs/proc/vmcore.c
+++ b/fs/proc/vmcore.c
@@ -41,7 +41,7 @@
 
 /* Reads a page from the oldmem device from given offset. */
 static ssize_t read_from_oldmem(char *buf, size_t count,
-			     loff_t *ppos, int userbuf)
+				u64 *ppos, int userbuf)
 {
 	unsigned long pfn, offset;
 	size_t nr_bytes;
diff --git a/fs/quota.c b/fs/quota.c
index d14d872..ba9e0bf 100644
--- a/fs/quota.c
+++ b/fs/quota.c
@@ -15,6 +15,7 @@
 #include <linux/security.h>
 #include <linux/syscalls.h>
 #include <linux/buffer_head.h>
+#include <linux/capability.h>
 #include <linux/quotaops.h>
 
 /* Check validity of generic quotactl commands */
diff --git a/fs/reiserfs/ioctl.c b/fs/reiserfs/ioctl.c
index ba8bf8d..745c881 100644
--- a/fs/reiserfs/ioctl.c
+++ b/fs/reiserfs/ioctl.c
@@ -2,6 +2,7 @@
  * Copyright 2000 by Hans Reiser, licensing governed by reiserfs/README
  */
 
+#include <linux/capability.h>
 #include <linux/fs.h>
 #include <linux/reiserfs_fs.h>
 #include <linux/time.h>
diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c
index 3f17ef8..4491fcf 100644
--- a/fs/reiserfs/journal.c
+++ b/fs/reiserfs/journal.c
@@ -3925,10 +3925,13 @@
 		flush = 1;
 	}
 #ifdef REISERFS_PREALLOCATE
-	/* quota ops might need to nest, setup the journal_info pointer for them */
+	/* quota ops might need to nest, setup the journal_info pointer for them
+	 * and raise the refcount so that it is > 0. */
 	current->journal_info = th;
+	th->t_refcount++;
 	reiserfs_discard_all_prealloc(th);	/* it should not involve new blocks into
 						 * the transaction */
+	th->t_refcount--;
 	current->journal_info = th->t_handle_save;
 #endif
 
diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
index 6f99e01..cc061bf 100644
--- a/fs/reiserfs/xattr.c
+++ b/fs/reiserfs/xattr.c
@@ -30,6 +30,7 @@
  */
 
 #include <linux/reiserfs_fs.h>
+#include <linux/capability.h>
 #include <linux/dcache.h>
 #include <linux/namei.h>
 #include <linux/errno.h>
diff --git a/fs/reiserfs/xattr_acl.c b/fs/reiserfs/xattr_acl.c
index 2dc9535..43de3ba 100644
--- a/fs/reiserfs/xattr_acl.c
+++ b/fs/reiserfs/xattr_acl.c
@@ -1,3 +1,4 @@
+#include <linux/capability.h>
 #include <linux/fs.h>
 #include <linux/posix_acl.h>
 #include <linux/reiserfs_fs.h>
diff --git a/fs/reiserfs/xattr_trusted.c b/fs/reiserfs/xattr_trusted.c
index 2501f7e..024a938 100644
--- a/fs/reiserfs/xattr_trusted.c
+++ b/fs/reiserfs/xattr_trusted.c
@@ -1,4 +1,5 @@
 #include <linux/reiserfs_fs.h>
+#include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/fs.h>
 #include <linux/pagemap.h>
diff --git a/fs/smbfs/proc.c b/fs/smbfs/proc.c
index d6baec0..b1b878b 100644
--- a/fs/smbfs/proc.c
+++ b/fs/smbfs/proc.c
@@ -8,6 +8,7 @@
  */
 
 #include <linux/types.h>
+#include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/slab.h>
 #include <linux/fs.h>
diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c
index c313321..689f7bc 100644
--- a/fs/sysfs/inode.c
+++ b/fs/sysfs/inode.c
@@ -11,6 +11,7 @@
 #include <linux/pagemap.h>
 #include <linux/namei.h>
 #include <linux/backing-dev.h>
+#include <linux/capability.h>
 #include "sysfs.h"
 
 extern struct super_block * sysfs_sb;
diff --git a/fs/udf/file.c b/fs/udf/file.c
index 8a38828..a6f2acc 100644
--- a/fs/udf/file.c
+++ b/fs/udf/file.c
@@ -31,6 +31,7 @@
 #include <asm/uaccess.h>
 #include <linux/kernel.h>
 #include <linux/string.h> /* memset */
+#include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/smp_lock.h>
 #include <linux/pagemap.h>
diff --git a/fs/ufs/balloc.c b/fs/ufs/balloc.c
index faf1512..a9f4421 100644
--- a/fs/ufs/balloc.c
+++ b/fs/ufs/balloc.c
@@ -13,6 +13,7 @@
 #include <linux/string.h>
 #include <linux/quotaops.h>
 #include <linux/buffer_head.h>
+#include <linux/capability.h>
 #include <linux/sched.h>
 #include <linux/bitops.h>
 #include <asm/byteorder.h>
diff --git a/fs/xfs/linux-2.6/xfs_cred.h b/fs/xfs/linux-2.6/xfs_cred.h
index 4af4910..e7f3da6 100644
--- a/fs/xfs/linux-2.6/xfs_cred.h
+++ b/fs/xfs/linux-2.6/xfs_cred.h
@@ -18,6 +18,8 @@
 #ifndef __XFS_CRED_H__
 #define __XFS_CRED_H__
 
+#include <linux/capability.h>
+
 /*
  * Credentials
  */
@@ -27,7 +29,7 @@
 
 extern struct cred *sys_cred;
 
-/* this is a hack.. (assums sys_cred is the only cred_t in the system) */
+/* this is a hack.. (assumes sys_cred is the only cred_t in the system) */
 static __inline int capable_cred(cred_t *cr, int cid)
 {
 	return (cr == sys_cred) ? 1 : capable(cid);
diff --git a/fs/xfs/linux-2.6/xfs_ioctl.c b/fs/xfs/linux-2.6/xfs_ioctl.c
index f98c5be..21667ba 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl.c
+++ b/fs/xfs/linux-2.6/xfs_ioctl.c
@@ -52,6 +52,7 @@
 #include "xfs_dfrag.h"
 #include "xfs_fsops.h"
 
+#include <linux/capability.h>
 #include <linux/dcache.h>
 #include <linux/mount.h>
 #include <linux/namei.h>
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c
index 97fb147..9b8ee34 100644
--- a/fs/xfs/linux-2.6/xfs_iops.c
+++ b/fs/xfs/linux-2.6/xfs_iops.c
@@ -51,6 +51,7 @@
 #include "xfs_buf_item.h"
 #include "xfs_utils.h"
 
+#include <linux/capability.h>
 #include <linux/xattr.h>
 #include <linux/namei.h>
 
diff --git a/fs/xfs/quota/xfs_qm_syscalls.c b/fs/xfs/quota/xfs_qm_syscalls.c
index 86a1d09..6768843 100644
--- a/fs/xfs/quota/xfs_qm_syscalls.c
+++ b/fs/xfs/quota/xfs_qm_syscalls.c
@@ -15,6 +15,9 @@
  * along with this program; if not, write the Free Software Foundation,
  * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
+
+#include <linux/capability.h>
+
 #include "xfs.h"
 #include "xfs_fs.h"
 #include "xfs_bit.h"
diff --git a/fs/xfs/xfs_acl.c b/fs/xfs/xfs_acl.c
index cc9c91b..4ff0f4e 100644
--- a/fs/xfs/xfs_acl.c
+++ b/fs/xfs/xfs_acl.c
@@ -36,6 +36,7 @@
 #include "xfs_mac.h"
 #include "xfs_attr.h"
 
+#include <linux/capability.h>
 #include <linux/posix_acl_xattr.h>
 
 STATIC int	xfs_acl_setmode(vnode_t *, xfs_acl_t *, int *);
diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/xfs_attr.c
index 1a11c2b..e5e91e9 100644
--- a/fs/xfs/xfs_attr.c
+++ b/fs/xfs/xfs_attr.c
@@ -15,6 +15,9 @@
  * along with this program; if not, write the Free Software Foundation,
  * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
+
+#include <linux/capability.h>
+
 #include "xfs.h"
 #include "xfs_fs.h"
 #include "xfs_types.h"
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index e03fa2a..e92cacd 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -15,6 +15,9 @@
  * along with this program; if not, write the Free Software Foundation,
  * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
+
+#include <linux/capability.h>
+
 #include "xfs.h"
 #include "xfs_fs.h"
 #include "xfs_types.h"
diff --git a/include/asm-generic/mutex-dec.h b/include/asm-generic/mutex-dec.h
index 74b18cd..40c6d1f 100644
--- a/include/asm-generic/mutex-dec.h
+++ b/include/asm-generic/mutex-dec.h
@@ -97,7 +97,7 @@
 	 * the mutex state would be.
 	 */
 #ifdef __HAVE_ARCH_CMPXCHG
-	if (likely(atomic_cmpxchg(count, 1, 0)) == 1) {
+	if (likely(atomic_cmpxchg(count, 1, 0) == 1)) {
 		smp_mb();
 		return 1;
 	}
diff --git a/include/asm-h8300/page.h b/include/asm-h8300/page.h
index e8c02b8..cd35b1c 100644
--- a/include/asm-h8300/page.h
+++ b/include/asm-h8300/page.h
@@ -13,12 +13,6 @@
 
 #include <asm/setup.h>
 
-#if !defined(CONFIG_SMALL_TASKS) && PAGE_SHIFT < 13
-#define KTHREAD_SIZE (8192)
-#else
-#define KTHREAD_SIZE PAGE_SIZE
-#endif
- 
 #ifndef __ASSEMBLY__
  
 #define get_user_page(vaddr)		__get_free_page(GFP_KERNEL)
diff --git a/include/asm-i386/apic.h b/include/asm-i386/apic.h
index 8c454aa..d30b857 100644
--- a/include/asm-i386/apic.h
+++ b/include/asm-i386/apic.h
@@ -132,6 +132,11 @@
 
 extern int disable_timer_pin_1;
 
+void smp_send_timer_broadcast_ipi(struct pt_regs *regs);
+void switch_APIC_timer_to_ipi(void *cpumask);
+void switch_ipi_to_APIC_timer(void *cpumask);
+#define ARCH_APICTIMER_STOPS_ON_C3	1
+
 #else /* !CONFIG_X86_LOCAL_APIC */
 static inline void lapic_shutdown(void) { }
 
diff --git a/include/asm-i386/bitops.h b/include/asm-i386/bitops.h
index 65679ac..fe0819f 100644
--- a/include/asm-i386/bitops.h
+++ b/include/asm-i386/bitops.h
@@ -43,7 +43,7 @@
 {
 	__asm__ __volatile__( LOCK_PREFIX
 		"btsl %1,%0"
-		:"=m" (ADDR)
+		:"+m" (ADDR)
 		:"Ir" (nr));
 }
 
@@ -60,7 +60,7 @@
 {
 	__asm__(
 		"btsl %1,%0"
-		:"=m" (ADDR)
+		:"+m" (ADDR)
 		:"Ir" (nr));
 }
 
@@ -78,7 +78,7 @@
 {
 	__asm__ __volatile__( LOCK_PREFIX
 		"btrl %1,%0"
-		:"=m" (ADDR)
+		:"+m" (ADDR)
 		:"Ir" (nr));
 }
 
@@ -86,7 +86,7 @@
 {
 	__asm__ __volatile__(
 		"btrl %1,%0"
-		:"=m" (ADDR)
+		:"+m" (ADDR)
 		:"Ir" (nr));
 }
 #define smp_mb__before_clear_bit()	barrier()
@@ -105,7 +105,7 @@
 {
 	__asm__ __volatile__(
 		"btcl %1,%0"
-		:"=m" (ADDR)
+		:"+m" (ADDR)
 		:"Ir" (nr));
 }
 
@@ -123,7 +123,7 @@
 {
 	__asm__ __volatile__( LOCK_PREFIX
 		"btcl %1,%0"
-		:"=m" (ADDR)
+		:"+m" (ADDR)
 		:"Ir" (nr));
 }
 
@@ -142,7 +142,7 @@
 
 	__asm__ __volatile__( LOCK_PREFIX
 		"btsl %2,%1\n\tsbbl %0,%0"
-		:"=r" (oldbit),"=m" (ADDR)
+		:"=r" (oldbit),"+m" (ADDR)
 		:"Ir" (nr) : "memory");
 	return oldbit;
 }
@@ -162,7 +162,7 @@
 
 	__asm__(
 		"btsl %2,%1\n\tsbbl %0,%0"
-		:"=r" (oldbit),"=m" (ADDR)
+		:"=r" (oldbit),"+m" (ADDR)
 		:"Ir" (nr));
 	return oldbit;
 }
@@ -182,7 +182,7 @@
 
 	__asm__ __volatile__( LOCK_PREFIX
 		"btrl %2,%1\n\tsbbl %0,%0"
-		:"=r" (oldbit),"=m" (ADDR)
+		:"=r" (oldbit),"+m" (ADDR)
 		:"Ir" (nr) : "memory");
 	return oldbit;
 }
@@ -202,7 +202,7 @@
 
 	__asm__(
 		"btrl %2,%1\n\tsbbl %0,%0"
-		:"=r" (oldbit),"=m" (ADDR)
+		:"=r" (oldbit),"+m" (ADDR)
 		:"Ir" (nr));
 	return oldbit;
 }
@@ -214,7 +214,7 @@
 
 	__asm__ __volatile__(
 		"btcl %2,%1\n\tsbbl %0,%0"
-		:"=r" (oldbit),"=m" (ADDR)
+		:"=r" (oldbit),"+m" (ADDR)
 		:"Ir" (nr) : "memory");
 	return oldbit;
 }
@@ -233,7 +233,7 @@
 
 	__asm__ __volatile__( LOCK_PREFIX
 		"btcl %2,%1\n\tsbbl %0,%0"
-		:"=r" (oldbit),"=m" (ADDR)
+		:"=r" (oldbit),"+m" (ADDR)
 		:"Ir" (nr) : "memory");
 	return oldbit;
 }
diff --git a/include/asm-i386/cpufeature.h b/include/asm-i386/cpufeature.h
index ff1187e..c4ec2a4 100644
--- a/include/asm-i386/cpufeature.h
+++ b/include/asm-i386/cpufeature.h
@@ -69,6 +69,7 @@
 #define X86_FEATURE_K7		(3*32+ 5) /* Athlon */
 #define X86_FEATURE_P3		(3*32+ 6) /* P3 */
 #define X86_FEATURE_P4		(3*32+ 7) /* P4 */
+#define X86_FEATURE_CONSTANT_TSC (3*32+ 8) /* TSC ticks at a constant rate */
 
 /* Intel-defined CPU features, CPUID level 0x00000001 (ecx), word 4 */
 #define X86_FEATURE_XMM3	(4*32+ 0) /* Streaming SIMD Extensions-3 */
diff --git a/include/asm-i386/dma-mapping.h b/include/asm-i386/dma-mapping.h
index 6c37a9a..9cf20ca 100644
--- a/include/asm-i386/dma-mapping.h
+++ b/include/asm-i386/dma-mapping.h
@@ -6,6 +6,7 @@
 #include <asm/cache.h>
 #include <asm/io.h>
 #include <asm/scatterlist.h>
+#include <asm/bug.h>
 
 #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
 #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
@@ -20,7 +21,9 @@
 dma_map_single(struct device *dev, void *ptr, size_t size,
 	       enum dma_data_direction direction)
 {
-	BUG_ON(direction == DMA_NONE);
+	if (direction == DMA_NONE)
+		BUG();
+	WARN_ON(size == 0);
 	flush_write_buffers();
 	return virt_to_phys(ptr);
 }
@@ -29,7 +32,8 @@
 dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
 		 enum dma_data_direction direction)
 {
-	BUG_ON(direction == DMA_NONE);
+	if (direction == DMA_NONE)
+		BUG();
 }
 
 static inline int
@@ -38,7 +42,9 @@
 {
 	int i;
 
-	BUG_ON(direction == DMA_NONE);
+	if (direction == DMA_NONE)
+		BUG();
+	WARN_ON(nents == 0 || sg[0].length == 0);
 
 	for (i = 0; i < nents; i++ ) {
 		BUG_ON(!sg[i].page);
diff --git a/include/asm-i386/io.h b/include/asm-i386/io.h
index 7babb97..03233c2 100644
--- a/include/asm-i386/io.h
+++ b/include/asm-i386/io.h
@@ -131,6 +131,11 @@
 extern void *bt_ioremap(unsigned long offset, unsigned long size);
 extern void bt_iounmap(void *addr, unsigned long size);
 
+/* Use early IO mappings for DMI because it's initialized early */
+#define dmi_ioremap bt_ioremap
+#define dmi_iounmap bt_iounmap
+#define dmi_alloc alloc_bootmem
+
 /*
  * ISA I/O bus memory addresses are 1:1 with the physical address.
  */
diff --git a/include/asm-i386/mach-default/mach_ipi.h b/include/asm-i386/mach-default/mach_ipi.h
index cc756a6..a1d0072 100644
--- a/include/asm-i386/mach-default/mach_ipi.h
+++ b/include/asm-i386/mach-default/mach_ipi.h
@@ -15,11 +15,9 @@
 {
 	if (no_broadcast) {
 		cpumask_t mask = cpu_online_map;
-		int this_cpu = get_cpu();
 
-		cpu_clear(this_cpu, mask);
+		cpu_clear(smp_processor_id(), mask);
 		send_IPI_mask(mask, vector);
-		put_cpu();
 	} else
 		__send_IPI_shortcut(APIC_DEST_ALLBUT, vector);
 }
diff --git a/include/asm-i386/mutex.h b/include/asm-i386/mutex.h
index c657d4b..9b2199e 100644
--- a/include/asm-i386/mutex.h
+++ b/include/asm-i386/mutex.h
@@ -125,7 +125,7 @@
 	 * the mutex state would be.
 	 */
 #ifdef __HAVE_ARCH_CMPXCHG
-	if (likely(atomic_cmpxchg(count, 1, 0)) == 1)
+	if (likely(atomic_cmpxchg(count, 1, 0) == 1))
 		return 1;
 	return 0;
 #else
diff --git a/include/asm-i386/processor.h b/include/asm-i386/processor.h
index 5c96cf6..13ecf66 100644
--- a/include/asm-i386/processor.h
+++ b/include/asm-i386/processor.h
@@ -61,9 +61,11 @@
 	int 	x86_cache_size;  /* in KB - valid for CPUS which support this
 				    call  */
 	int 	x86_cache_alignment;	/* In bytes */
-	int	fdiv_bug;
-	int	f00f_bug;
-	int	coma_bug;
+	char	fdiv_bug;
+	char	f00f_bug;
+	char	coma_bug;
+	char	pad0;
+	int	x86_power;
 	unsigned long loops_per_jiffy;
 	unsigned char x86_max_cores;	/* cpuid returned max cores value */
 	unsigned char booted_cores;	/* number of cores as seen by OS */
@@ -279,9 +281,11 @@
 	outb((data), 0x23); \
 } while (0)
 
-static inline void serialize_cpu(void)
+/* Stop speculative execution */
+static inline void sync_core(void)
 {
-	 __asm__ __volatile__ ("cpuid" : : : "ax", "bx", "cx", "dx");
+	int tmp;
+	asm volatile("cpuid" : "=a" (tmp) : "0" (1) : "ebx","ecx","edx","memory");
 }
 
 static inline void __monitor(const void *eax, unsigned long ecx,
diff --git a/include/asm-powerpc/paca.h b/include/asm-powerpc/paca.h
index 3ae52d9..a64b4d4 100644
--- a/include/asm-powerpc/paca.h
+++ b/include/asm-powerpc/paca.h
@@ -65,6 +65,7 @@
 	u64 stab_real;			/* Absolute address of segment table */
 	u64 stab_addr;			/* Virtual address of segment table */
 	void *emergency_sp;		/* pointer to emergency stack */
+	u64 data_offset;		/* per cpu data offset */
 	s16 hw_cpu_id;			/* Physical processor number */
 	u8 cpu_start;			/* At startup, processor spins until */
 					/* this becomes non-zero. */
diff --git a/include/asm-powerpc/page.h b/include/asm-powerpc/page.h
index 76d7cb4..0b82df4 100644
--- a/include/asm-powerpc/page.h
+++ b/include/asm-powerpc/page.h
@@ -178,7 +178,7 @@
 #define pmd_val(x)	(x)
 #define __pmd(x)	(x)
 
-#ifndef CONFIG_PPC_64K_PAGES
+#if defined(CONFIG_PPC64) && !defined(CONFIG_PPC_64K_PAGES)
 typedef unsigned long pud_t;
 #define pud_val(x)	(x)
 #define __pud(x)	(x)
diff --git a/include/asm-powerpc/parport.h b/include/asm-powerpc/parport.h
index 897e49a..3fca21d 100644
--- a/include/asm-powerpc/parport.h
+++ b/include/asm-powerpc/parport.h
@@ -10,10 +10,34 @@
 #define _ASM_POWERPC_PARPORT_H
 #ifdef __KERNEL__
 
-static int __devinit parport_pc_find_isa_ports (int autoirq, int autodma);
+#include <asm/prom.h>
+
+extern struct parport *parport_pc_probe_port (unsigned long int base,
+                                              unsigned long int base_hi,
+                                              int irq, int dma,
+                                              struct pci_dev *dev);
+
 static int __devinit parport_pc_find_nonpci_ports (int autoirq, int autodma)
 {
-	return parport_pc_find_isa_ports (autoirq, autodma);
+	struct device_node *np;
+	u32 *prop;
+	u32 io1, io2;
+	int propsize;
+	int count = 0;
+	for (np = NULL; (np = of_find_compatible_node(np,
+						      "parallel",
+						      "pnpPNP,400")) != NULL;) {
+		prop = (u32 *)get_property(np, "reg", &propsize);
+		if (!prop || propsize > 6*sizeof(u32))
+			continue;
+		io1 = prop[1]; io2 = prop[2];
+		prop = (u32 *)get_property(np, "interrupts", NULL);
+		if (!prop)
+			continue;
+		if (parport_pc_probe_port(io1, io2, prop[0], autodma, NULL) != NULL)
+			count++;
+	}
+	return count;
 }
 
 #endif /* __KERNEL__ */
diff --git a/include/asm-powerpc/percpu.h b/include/asm-powerpc/percpu.h
index 06a959d..e31922c 100644
--- a/include/asm-powerpc/percpu.h
+++ b/include/asm-powerpc/percpu.h
@@ -1 +1,57 @@
+#ifndef _ASM_POWERPC_PERCPU_H_
+#define _ASM_POWERPC_PERCPU_H_
+#ifdef __powerpc64__
+#include <linux/compiler.h>
+
+/*
+ * Same as asm-generic/percpu.h, except that we store the per cpu offset
+ * in the paca. Based on the x86-64 implementation.
+ */
+
+#ifdef CONFIG_SMP
+
+#include <asm/paca.h>
+
+#define __per_cpu_offset(cpu) (paca[cpu].data_offset)
+#define __my_cpu_offset() get_paca()->data_offset
+
+/* Separate out the type, so (int[3], foo) works. */
+#define DEFINE_PER_CPU(type, name) \
+    __attribute__((__section__(".data.percpu"))) __typeof__(type) per_cpu__##name
+
+/* var is in discarded region: offset to particular copy we want */
+#define per_cpu(var, cpu) (*RELOC_HIDE(&per_cpu__##var, __per_cpu_offset(cpu)))
+#define __get_cpu_var(var) (*RELOC_HIDE(&per_cpu__##var, __my_cpu_offset()))
+
+/* A macro to avoid #include hell... */
+#define percpu_modcopy(pcpudst, src, size)			\
+do {								\
+	unsigned int __i;					\
+	for (__i = 0; __i < NR_CPUS; __i++)			\
+		if (cpu_possible(__i))				\
+			memcpy((pcpudst)+__per_cpu_offset(__i),	\
+			       (src), (size));			\
+} while (0)
+
+extern void setup_per_cpu_areas(void);
+
+#else /* ! SMP */
+
+#define DEFINE_PER_CPU(type, name) \
+    __typeof__(type) per_cpu__##name
+
+#define per_cpu(var, cpu)			(*((void)(cpu), &per_cpu__##var))
+#define __get_cpu_var(var)			per_cpu__##var
+
+#endif	/* SMP */
+
+#define DECLARE_PER_CPU(type, name) extern __typeof__(type) per_cpu__##name
+
+#define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var)
+#define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var)
+
+#else
 #include <asm-generic/percpu.h>
+#endif
+
+#endif /* _ASM_POWERPC_PERCPU_H_ */
diff --git a/include/asm-powerpc/rtas.h b/include/asm-powerpc/rtas.h
index 3428889..f43c683 100644
--- a/include/asm-powerpc/rtas.h
+++ b/include/asm-powerpc/rtas.h
@@ -161,7 +161,6 @@
 extern void enter_rtas(unsigned long);
 extern int rtas_token(const char *service);
 extern int rtas_call(int token, int, int, int *, ...);
-extern void call_rtas_display_status(unsigned char);
 extern void rtas_restart(char *cmd);
 extern void rtas_power_off(void);
 extern void rtas_halt(void);
diff --git a/include/asm-powerpc/udbg.h b/include/asm-powerpc/udbg.h
index 479f2d8..5c4236c 100644
--- a/include/asm-powerpc/udbg.h
+++ b/include/asm-powerpc/udbg.h
@@ -1,5 +1,5 @@
 /*
- * c 2001 PPC 64 Team, IBM Corp
+ * (c) 2001, 2006 IBM Corporation.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -36,5 +36,12 @@
 extern int udbg_adb_init(int force_btext);
 extern void udbg_adb_init_early(void);
 
+extern void __init udbg_early_init(void);
+extern void __init udbg_init_debug_lpar(void);
+extern void __init udbg_init_pmac_realmode(void);
+extern void __init udbg_init_maple_realmode(void);
+extern void __init udbg_init_iseries(void);
+extern void __init udbg_init_rtas(void);
+
 #endif /* __KERNEL__ */
 #endif /* _ASM_POWERPC_UDBG_H */
diff --git a/include/asm-x86_64/apic.h b/include/asm-x86_64/apic.h
index 5647b7d..4f6a4dc 100644
--- a/include/asm-x86_64/apic.h
+++ b/include/asm-x86_64/apic.h
@@ -42,11 +42,6 @@
 	*((volatile unsigned int *)(APIC_BASE+reg)) = v;
 }
 
-static __inline void apic_write_atomic(unsigned long reg, unsigned int v)
-{
-	xchg((volatile unsigned int *)(APIC_BASE+reg), v);
-}
-
 static __inline unsigned int apic_read(unsigned long reg)
 {
 	return *((volatile unsigned int *)(APIC_BASE+reg));
@@ -57,10 +52,6 @@
 	while ( apic_read( APIC_ICR ) & APIC_ICR_BUSY );
 }
 
-#define FORCE_READ_AROUND_WRITE 0
-#define apic_read_around(x)
-#define apic_write_around(x,y) apic_write((x),(y))
-
 static inline void ack_APIC_irq(void)
 {
 	/*
@@ -71,7 +62,7 @@
 	 */
 
 	/* Docs say use 0 for future compatibility */
-	apic_write_around(APIC_EOI, 0);
+	apic_write(APIC_EOI, 0);
 }
 
 extern int get_maxlvt (void);
@@ -113,6 +104,12 @@
 
 extern void setup_threshold_lvt(unsigned long lvt_off);
 
+void smp_send_timer_broadcast_ipi(void);
+void switch_APIC_timer_to_ipi(void *cpumask);
+void switch_ipi_to_APIC_timer(void *cpumask);
+
+#define ARCH_APICTIMER_STOPS_ON_C3	1
+
 #endif /* CONFIG_X86_LOCAL_APIC */
 
 extern unsigned boot_cpu_id;
diff --git a/include/asm-x86_64/apicdef.h b/include/asm-x86_64/apicdef.h
index fb1c99a..decaa2d 100644
--- a/include/asm-x86_64/apicdef.h
+++ b/include/asm-x86_64/apicdef.h
@@ -13,6 +13,7 @@
 #define		APIC_ID		0x20
 #define			APIC_ID_MASK		(0xFFu<<24)
 #define			GET_APIC_ID(x)		(((x)>>24)&0xFFu)
+#define			SET_APIC_ID(x)		(((x)<<24))
 #define		APIC_LVR	0x30
 #define			APIC_LVR_MASK		0xFF00FF
 #define			GET_APIC_VERSION(x)	((x)&0xFFu)
diff --git a/include/asm-x86_64/atomic.h b/include/asm-x86_64/atomic.h
index 6b54023..4b5cd55 100644
--- a/include/asm-x86_64/atomic.h
+++ b/include/asm-x86_64/atomic.h
@@ -2,6 +2,7 @@
 #define __ARCH_X86_64_ATOMIC__
 
 #include <linux/config.h>
+#include <asm/types.h>
 
 /* atomic_t should be 32 bit signed type */
 
diff --git a/include/asm-x86_64/bitops.h b/include/asm-x86_64/bitops.h
index a4d5d09..eb4df23 100644
--- a/include/asm-x86_64/bitops.h
+++ b/include/asm-x86_64/bitops.h
@@ -29,7 +29,7 @@
 {
 	__asm__ __volatile__( LOCK_PREFIX
 		"btsl %1,%0"
-		:"=m" (ADDR)
+		:"+m" (ADDR)
 		:"dIr" (nr) : "memory");
 }
 
@@ -46,7 +46,7 @@
 {
 	__asm__ volatile(
 		"btsl %1,%0"
-		:"=m" (ADDR)
+		:"+m" (ADDR)
 		:"dIr" (nr) : "memory");
 }
 
@@ -64,7 +64,7 @@
 {
 	__asm__ __volatile__( LOCK_PREFIX
 		"btrl %1,%0"
-		:"=m" (ADDR)
+		:"+m" (ADDR)
 		:"dIr" (nr));
 }
 
@@ -72,7 +72,7 @@
 {
 	__asm__ __volatile__(
 		"btrl %1,%0"
-		:"=m" (ADDR)
+		:"+m" (ADDR)
 		:"dIr" (nr));
 }
 
@@ -92,7 +92,7 @@
 {
 	__asm__ __volatile__(
 		"btcl %1,%0"
-		:"=m" (ADDR)
+		:"+m" (ADDR)
 		:"dIr" (nr));
 }
 
@@ -109,7 +109,7 @@
 {
 	__asm__ __volatile__( LOCK_PREFIX
 		"btcl %1,%0"
-		:"=m" (ADDR)
+		:"+m" (ADDR)
 		:"dIr" (nr));
 }
 
@@ -127,7 +127,7 @@
 
 	__asm__ __volatile__( LOCK_PREFIX
 		"btsl %2,%1\n\tsbbl %0,%0"
-		:"=r" (oldbit),"=m" (ADDR)
+		:"=r" (oldbit),"+m" (ADDR)
 		:"dIr" (nr) : "memory");
 	return oldbit;
 }
@@ -147,7 +147,7 @@
 
 	__asm__(
 		"btsl %2,%1\n\tsbbl %0,%0"
-		:"=r" (oldbit),"=m" (ADDR)
+		:"=r" (oldbit),"+m" (ADDR)
 		:"dIr" (nr));
 	return oldbit;
 }
@@ -166,7 +166,7 @@
 
 	__asm__ __volatile__( LOCK_PREFIX
 		"btrl %2,%1\n\tsbbl %0,%0"
-		:"=r" (oldbit),"=m" (ADDR)
+		:"=r" (oldbit),"+m" (ADDR)
 		:"dIr" (nr) : "memory");
 	return oldbit;
 }
@@ -186,7 +186,7 @@
 
 	__asm__(
 		"btrl %2,%1\n\tsbbl %0,%0"
-		:"=r" (oldbit),"=m" (ADDR)
+		:"=r" (oldbit),"+m" (ADDR)
 		:"dIr" (nr));
 	return oldbit;
 }
@@ -198,7 +198,7 @@
 
 	__asm__ __volatile__(
 		"btcl %2,%1\n\tsbbl %0,%0"
-		:"=r" (oldbit),"=m" (ADDR)
+		:"=r" (oldbit),"+m" (ADDR)
 		:"dIr" (nr) : "memory");
 	return oldbit;
 }
@@ -217,7 +217,7 @@
 
 	__asm__ __volatile__( LOCK_PREFIX
 		"btcl %2,%1\n\tsbbl %0,%0"
-		:"=r" (oldbit),"=m" (ADDR)
+		:"=r" (oldbit),"+m" (ADDR)
 		:"dIr" (nr) : "memory");
 	return oldbit;
 }
@@ -397,6 +397,22 @@
 }
 
 /**
+ * fls - find last bit set
+ * @x: the word to search
+ *
+ * This is defined the same way as ffs.
+ */
+static __inline__ int fls(int x)
+{
+	int r;
+
+	__asm__("bsrl %1,%0\n\t"
+		"cmovzl %2,%0"
+		: "=&r" (r) : "rm" (x), "rm" (-1));
+	return r+1;
+}
+
+/**
  * hweightN - returns the hamming weight of a N-bit word
  * @x: the word to weigh
  *
@@ -434,9 +450,6 @@
 #define minix_find_first_zero_bit(addr,size) \
 	find_first_zero_bit((void*)addr,size)
 
-/* find last set bit */
-#define fls(x) generic_fls(x)
-
 #endif /* __KERNEL__ */
 
 #endif /* _X86_64_BITOPS_H */
diff --git a/include/asm-x86_64/cache.h b/include/asm-x86_64/cache.h
index b4a2401..263f0a2 100644
--- a/include/asm-x86_64/cache.h
+++ b/include/asm-x86_64/cache.h
@@ -10,4 +10,16 @@
 #define L1_CACHE_SHIFT	(CONFIG_X86_L1_CACHE_SHIFT)
 #define L1_CACHE_BYTES	(1 << L1_CACHE_SHIFT)
 
+#ifdef CONFIG_X86_VSMP
+
+/* vSMP Internode cacheline shift */
+#define INTERNODE_CACHE_SHIFT (12)
+#ifdef CONFIG_SMP
+#define __cacheline_aligned_in_smp					\
+       __attribute__((__aligned__(1 << (INTERNODE_CACHE_SHIFT))))         \
+       __attribute__((__section__(".data.page_aligned")))
+#endif
+
+#endif
+
 #endif
diff --git a/include/asm-x86_64/compat.h b/include/asm-x86_64/compat.h
index f0155c3..3863a7d 100644
--- a/include/asm-x86_64/compat.h
+++ b/include/asm-x86_64/compat.h
@@ -202,4 +202,9 @@
 	return (void __user *)regs->rsp - len; 
 }
 
+static inline int is_compat_task(void)
+{
+	return current_thread_info()->status & TS_COMPAT;
+}
+
 #endif /* _ASM_X86_64_COMPAT_H */
diff --git a/include/asm-x86_64/cpufeature.h b/include/asm-x86_64/cpufeature.h
index aea308c..41c0ac8 100644
--- a/include/asm-x86_64/cpufeature.h
+++ b/include/asm-x86_64/cpufeature.h
@@ -61,8 +61,9 @@
 #define X86_FEATURE_K6_MTRR	(3*32+ 1) /* AMD K6 nonstandard MTRRs */
 #define X86_FEATURE_CYRIX_ARR	(3*32+ 2) /* Cyrix ARRs (= MTRRs) */
 #define X86_FEATURE_CENTAUR_MCR	(3*32+ 3) /* Centaur MCRs (= MTRRs) */
-#define X86_FEATURE_K8_C	(3*32+ 4) /* C stepping K8 */
+/* 4 free */
 #define X86_FEATURE_CONSTANT_TSC (3*32+5) /* TSC runs at constant rate */
+#define X86_FEATURE_SYNC_RDTSC  (3*32+6)  /* RDTSC syncs CPU core */
 
 /* Intel-defined CPU features, CPUID level 0x00000001 (ecx), word 4 */
 #define X86_FEATURE_XMM3	(4*32+ 0) /* Streaming SIMD Extensions-3 */
diff --git a/include/asm-x86_64/desc.h b/include/asm-x86_64/desc.h
index 3376486..eb7723a 100644
--- a/include/asm-x86_64/desc.h
+++ b/include/asm-x86_64/desc.h
@@ -25,7 +25,7 @@
 	unsigned int a,b;
 }; 	
 
-extern struct desc_struct cpu_gdt_table[NR_CPUS][GDT_ENTRIES];
+extern struct desc_struct cpu_gdt_table[GDT_ENTRIES];
 
 enum { 
 	GATE_INTERRUPT = 0xE, 
@@ -79,6 +79,9 @@
 extern struct gate_struct idt_table[]; 
 extern struct desc_ptr cpu_gdt_descr[];
 
+/* the cpu gdt accessor */
+#define cpu_gdt(_cpu) ((struct desc_struct *)cpu_gdt_descr[_cpu].address)
+
 static inline void _set_gate(void *adr, unsigned type, unsigned long func, unsigned dpl, unsigned ist)  
 {
 	struct gate_struct s; 	
@@ -114,6 +117,11 @@
 	_set_gate(&idt_table[nr], GATE_INTERRUPT, (unsigned long) func, 3, 0); 
 } 
 
+static inline void set_system_gate_ist(int nr, void *func, unsigned ist)
+{
+	_set_gate(&idt_table[nr], GATE_INTERRUPT, (unsigned long) func, 3, ist);
+}
+
 static inline void set_tssldt_descriptor(void *ptr, unsigned long tss, unsigned type, 
 					 unsigned size) 
 { 
@@ -139,20 +147,20 @@
 	 * -1? seg base+limit should be pointing to the address of the
 	 * last valid byte
 	 */
-	set_tssldt_descriptor(&cpu_gdt_table[cpu][GDT_ENTRY_TSS],
+	set_tssldt_descriptor(&cpu_gdt(cpu)[GDT_ENTRY_TSS],
 		(unsigned long)addr, DESC_TSS,
 		IO_BITMAP_OFFSET + IO_BITMAP_BYTES + sizeof(unsigned long) - 1);
 } 
 
 static inline void set_ldt_desc(unsigned cpu, void *addr, int size)
 { 
-	set_tssldt_descriptor(&cpu_gdt_table[cpu][GDT_ENTRY_LDT], (unsigned long)addr, 
+	set_tssldt_descriptor(&cpu_gdt(cpu)[GDT_ENTRY_LDT], (unsigned long)addr,
 			      DESC_LDT, size * 8 - 1);
 }
 
 static inline void set_seg_base(unsigned cpu, int entry, void *base)
 { 
-	struct desc_struct *d = &cpu_gdt_table[cpu][entry];
+	struct desc_struct *d = &cpu_gdt(cpu)[entry];
 	u32 addr = (u32)(u64)base;
 	BUG_ON((u64)base >> 32); 
 	d->base0 = addr & 0xffff;
@@ -194,7 +202,7 @@
 
 static inline void load_TLS(struct thread_struct *t, unsigned int cpu)
 {
-	u64 *gdt = (u64 *)(cpu_gdt_table[cpu] + GDT_ENTRY_TLS_MIN);
+	u64 *gdt = (u64 *)(cpu_gdt(cpu) + GDT_ENTRY_TLS_MIN);
 	gdt[0] = t->tls_array[0];
 	gdt[1] = t->tls_array[1];
 	gdt[2] = t->tls_array[2];
diff --git a/include/asm-x86_64/dma-mapping.h b/include/asm-x86_64/dma-mapping.h
index 36d16df..49a81a6 100644
--- a/include/asm-x86_64/dma-mapping.h
+++ b/include/asm-x86_64/dma-mapping.h
@@ -12,155 +12,176 @@
 #include <asm/io.h>
 #include <asm/swiotlb.h>
 
+struct dma_mapping_ops {
+	int             (*mapping_error)(dma_addr_t dma_addr);
+	void*           (*alloc_coherent)(struct device *dev, size_t size,
+                                dma_addr_t *dma_handle, gfp_t gfp);
+	void            (*free_coherent)(struct device *dev, size_t size,
+                                void *vaddr, dma_addr_t dma_handle);
+	dma_addr_t      (*map_single)(struct device *hwdev, void *ptr,
+                                size_t size, int direction);
+	/* like map_single, but doesn't check the device mask */
+	dma_addr_t      (*map_simple)(struct device *hwdev, char *ptr,
+                                size_t size, int direction);
+	void            (*unmap_single)(struct device *dev, dma_addr_t addr,
+		                size_t size, int direction);
+	void            (*sync_single_for_cpu)(struct device *hwdev,
+		                dma_addr_t dma_handle, size_t size,
+				int direction);
+	void            (*sync_single_for_device)(struct device *hwdev,
+                                dma_addr_t dma_handle, size_t size,
+				int direction);
+	void            (*sync_single_range_for_cpu)(struct device *hwdev,
+                                dma_addr_t dma_handle, unsigned long offset,
+		                size_t size, int direction);
+	void            (*sync_single_range_for_device)(struct device *hwdev,
+				dma_addr_t dma_handle, unsigned long offset,
+		                size_t size, int direction);
+	void            (*sync_sg_for_cpu)(struct device *hwdev,
+                                struct scatterlist *sg, int nelems,
+				int direction);
+	void            (*sync_sg_for_device)(struct device *hwdev,
+				struct scatterlist *sg, int nelems,
+				int direction);
+	int             (*map_sg)(struct device *hwdev, struct scatterlist *sg,
+		                int nents, int direction);
+	void            (*unmap_sg)(struct device *hwdev,
+				struct scatterlist *sg, int nents,
+				int direction);
+	int             (*dma_supported)(struct device *hwdev, u64 mask);
+	int		is_phys;
+};
+
 extern dma_addr_t bad_dma_address;
-#define dma_mapping_error(x) \
-	(swiotlb ? swiotlb_dma_mapping_error(x) : ((x) == bad_dma_address))
+extern struct dma_mapping_ops* dma_ops;
+extern int iommu_merge;
 
-void *dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
-			 gfp_t gfp);
-void dma_free_coherent(struct device *dev, size_t size, void *vaddr,
-			 dma_addr_t dma_handle);
-
-#ifdef CONFIG_GART_IOMMU
-
-extern dma_addr_t dma_map_single(struct device *hwdev, void *ptr, size_t size,
-				 int direction);
-extern void dma_unmap_single(struct device *dev, dma_addr_t addr,size_t size,
-			     int direction);
-
-#else
-
-/* No IOMMU */
-
-static inline dma_addr_t dma_map_single(struct device *hwdev, void *ptr,
-					size_t size, int direction)
+static inline int dma_mapping_error(dma_addr_t dma_addr)
 {
-	dma_addr_t addr;
+	if (dma_ops->mapping_error)
+		return dma_ops->mapping_error(dma_addr);
 
-	if (direction == DMA_NONE)
-		out_of_line_bug();
-	addr = virt_to_bus(ptr);
-
-	if ((addr+size) & ~*hwdev->dma_mask)
-		out_of_line_bug();
-	return addr;
+	return (dma_addr == bad_dma_address);
 }
 
-static inline void dma_unmap_single(struct device *hwdev, dma_addr_t dma_addr,
-				    size_t size, int direction)
+extern void *dma_alloc_coherent(struct device *dev, size_t size,
+				dma_addr_t *dma_handle, gfp_t gfp);
+extern void dma_free_coherent(struct device *dev, size_t size, void *vaddr,
+			      dma_addr_t dma_handle);
+
+static inline dma_addr_t
+dma_map_single(struct device *hwdev, void *ptr, size_t size,
+	       int direction)
 {
-	if (direction == DMA_NONE)
-		out_of_line_bug();
-	/* Nothing to do */
+	return dma_ops->map_single(hwdev, ptr, size, direction);
 }
 
-#endif
+static inline void
+dma_unmap_single(struct device *dev, dma_addr_t addr,size_t size,
+		 int direction)
+{
+	dma_ops->unmap_single(dev, addr, size, direction);
+}
 
 #define dma_map_page(dev,page,offset,size,dir) \
 	dma_map_single((dev), page_address(page)+(offset), (size), (dir))
 
-static inline void dma_sync_single_for_cpu(struct device *hwdev,
-					       dma_addr_t dma_handle,
-					       size_t size, int direction)
-{
-	if (direction == DMA_NONE)
-		out_of_line_bug();
-
-	if (swiotlb)
-		return swiotlb_sync_single_for_cpu(hwdev,dma_handle,size,direction);
-
-	flush_write_buffers();
-}
-
-static inline void dma_sync_single_for_device(struct device *hwdev,
-						  dma_addr_t dma_handle,
-						  size_t size, int direction)
-{
-        if (direction == DMA_NONE)
-		out_of_line_bug();
-
-	if (swiotlb)
-		return swiotlb_sync_single_for_device(hwdev,dma_handle,size,direction);
-
-	flush_write_buffers();
-}
-
-static inline void dma_sync_single_range_for_cpu(struct device *hwdev,
-						 dma_addr_t dma_handle,
-						 unsigned long offset,
-						 size_t size, int direction)
-{
-	if (direction == DMA_NONE)
-		out_of_line_bug();
-
-	if (swiotlb)
-		return swiotlb_sync_single_range_for_cpu(hwdev,dma_handle,offset,size,direction);
-
-	flush_write_buffers();
-}
-
-static inline void dma_sync_single_range_for_device(struct device *hwdev,
-						    dma_addr_t dma_handle,
-						    unsigned long offset,
-						    size_t size, int direction)
-{
-        if (direction == DMA_NONE)
-		out_of_line_bug();
-
-	if (swiotlb)
-		return swiotlb_sync_single_range_for_device(hwdev,dma_handle,offset,size,direction);
-
-	flush_write_buffers();
-}
-
-static inline void dma_sync_sg_for_cpu(struct device *hwdev,
-				       struct scatterlist *sg,
-				       int nelems, int direction)
-{
-	if (direction == DMA_NONE)
-		out_of_line_bug();
-
-	if (swiotlb)
-		return swiotlb_sync_sg_for_cpu(hwdev,sg,nelems,direction);
-
-	flush_write_buffers();
-}
-
-static inline void dma_sync_sg_for_device(struct device *hwdev,
-					  struct scatterlist *sg,
-					  int nelems, int direction)
-{
-	if (direction == DMA_NONE)
-		out_of_line_bug();
-
-	if (swiotlb)
-		return swiotlb_sync_sg_for_device(hwdev,sg,nelems,direction);
-
-	flush_write_buffers();
-}
-
-extern int dma_map_sg(struct device *hwdev, struct scatterlist *sg,
-		      int nents, int direction);
-extern void dma_unmap_sg(struct device *hwdev, struct scatterlist *sg,
-			 int nents, int direction);
-
 #define dma_unmap_page dma_unmap_single
 
-extern int dma_supported(struct device *hwdev, u64 mask);
-extern int dma_get_cache_alignment(void);
-#define dma_is_consistent(h) 1
-
-static inline int dma_set_mask(struct device *dev, u64 mask)
+static inline void
+dma_sync_single_for_cpu(struct device *hwdev, dma_addr_t dma_handle,
+			size_t size, int direction)
 {
-	if (!dev->dma_mask || !dma_supported(dev, mask))
-		return -EIO;
-	*dev->dma_mask = mask;
-	return 0;
+	if (dma_ops->sync_single_for_cpu)
+		dma_ops->sync_single_for_cpu(hwdev, dma_handle, size,
+					     direction);
+	flush_write_buffers();
 }
 
-static inline void dma_cache_sync(void *vaddr, size_t size, enum dma_data_direction dir)
+static inline void
+dma_sync_single_for_device(struct device *hwdev, dma_addr_t dma_handle,
+			   size_t size, int direction)
+{
+	if (dma_ops->sync_single_for_device)
+		dma_ops->sync_single_for_device(hwdev, dma_handle, size,
+						direction);
+	flush_write_buffers();
+}
+
+static inline void
+dma_sync_single_range_for_cpu(struct device *hwdev, dma_addr_t dma_handle,
+			      unsigned long offset, size_t size, int direction)
+{
+	if (dma_ops->sync_single_range_for_cpu) {
+		dma_ops->sync_single_range_for_cpu(hwdev, dma_handle, offset, size, direction);
+	}
+
+	flush_write_buffers();
+}
+
+static inline void
+dma_sync_single_range_for_device(struct device *hwdev, dma_addr_t dma_handle,
+				 unsigned long offset, size_t size, int direction)
+{
+	if (dma_ops->sync_single_range_for_device)
+		dma_ops->sync_single_range_for_device(hwdev, dma_handle,
+						      offset, size, direction);
+
+	flush_write_buffers();
+}
+
+static inline void
+dma_sync_sg_for_cpu(struct device *hwdev, struct scatterlist *sg,
+		    int nelems, int direction)
+{
+	if (dma_ops->sync_sg_for_cpu)
+		dma_ops->sync_sg_for_cpu(hwdev, sg, nelems, direction);
+	flush_write_buffers();
+}
+
+static inline void
+dma_sync_sg_for_device(struct device *hwdev, struct scatterlist *sg,
+		       int nelems, int direction)
+{
+	if (dma_ops->sync_sg_for_device) {
+		dma_ops->sync_sg_for_device(hwdev, sg, nelems, direction);
+	}
+
+	flush_write_buffers();
+}
+
+static inline int
+dma_map_sg(struct device *hwdev, struct scatterlist *sg, int nents, int direction)
+{
+	return dma_ops->map_sg(hwdev, sg, nents, direction);
+}
+
+static inline void
+dma_unmap_sg(struct device *hwdev, struct scatterlist *sg, int nents,
+	     int direction)
+{
+	dma_ops->unmap_sg(hwdev, sg, nents, direction);
+}
+
+extern int dma_supported(struct device *hwdev, u64 mask);
+
+/* same for gart, swiotlb, and nommu */
+static inline int dma_get_cache_alignment(void)
+{
+	return boot_cpu_data.x86_clflush_size;
+}
+
+#define dma_is_consistent(h) 1
+
+extern int dma_set_mask(struct device *dev, u64 mask);
+
+static inline void
+dma_cache_sync(void *vaddr, size_t size, enum dma_data_direction dir)
 {
 	flush_write_buffers();
 }
 
-#endif
+extern struct device fallback_dev;
+extern int panic_on_overflow;
+
+#endif /* _X8664_DMA_MAPPING_H */
diff --git a/include/asm-x86_64/dwarf2.h b/include/asm-x86_64/dwarf2.h
index 582757f..07654bd 100644
--- a/include/asm-x86_64/dwarf2.h
+++ b/include/asm-x86_64/dwarf2.h
@@ -14,7 +14,7 @@
    away for older version. 
  */
 
-#ifdef CONFIG_DEBUG_INFO
+#ifdef CONFIG_UNWIND_INFO
 
 #define CFI_STARTPROC .cfi_startproc
 #define CFI_ENDPROC .cfi_endproc
@@ -28,6 +28,7 @@
 #define CFI_RESTORE .cfi_restore
 #define CFI_REMEMBER_STATE .cfi_remember_state
 #define CFI_RESTORE_STATE .cfi_restore_state
+#define CFI_UNDEFINED .cfi_undefined
 
 #else
 
@@ -44,6 +45,7 @@
 #define CFI_RESTORE	#
 #define CFI_REMEMBER_STATE	#
 #define CFI_RESTORE_STATE	#
+#define CFI_UNDEFINED	#
 
 #endif
 
diff --git a/include/asm-x86_64/gart-mapping.h b/include/asm-x86_64/gart-mapping.h
new file mode 100644
index 0000000..ada497b
--- /dev/null
+++ b/include/asm-x86_64/gart-mapping.h
@@ -0,0 +1,16 @@
+#ifndef _X8664_GART_MAPPING_H
+#define _X8664_GART_MAPPING_H 1
+
+#include <linux/types.h>
+#include <asm/types.h>
+
+struct device;
+
+extern void*
+gart_alloc_coherent(struct device *dev, size_t size,
+        dma_addr_t *dma_handle, gfp_t gfp);
+
+extern int
+gart_dma_supported(struct device *hwdev, u64 mask);
+
+#endif /* _X8664_GART_MAPPING_H */
diff --git a/include/asm-x86_64/hw_irq.h b/include/asm-x86_64/hw_irq.h
index c14a8c7..0df1715 100644
--- a/include/asm-x86_64/hw_irq.h
+++ b/include/asm-x86_64/hw_irq.h
@@ -46,18 +46,18 @@
  *  some of the following vectors are 'rare', they are merged
  *  into a single vector (CALL_FUNCTION_VECTOR) to save vector space.
  *  TLB, reschedule and local APIC vectors are performance-critical.
- *
- *  Vectors 0xf0-0xf9 are free (reserved for future Linux use).
  */
 #define SPURIOUS_APIC_VECTOR	0xff
 #define ERROR_APIC_VECTOR	0xfe
 #define RESCHEDULE_VECTOR	0xfd
 #define CALL_FUNCTION_VECTOR	0xfc
-#define KDB_VECTOR		0xfb	/* reserved for KDB */
+/* fb free - please don't readd KDB here because it's useless
+   (hint - think what a NMI bit does to a vector) */
 #define THERMAL_APIC_VECTOR	0xfa
 #define THRESHOLD_APIC_VECTOR   0xf9
-#define INVALIDATE_TLB_VECTOR_END	0xf8
-#define INVALIDATE_TLB_VECTOR_START	0xf0	/* f0-f8 used for TLB flush */
+/* f8 free */
+#define INVALIDATE_TLB_VECTOR_END	0xf7
+#define INVALIDATE_TLB_VECTOR_START	0xf0	/* f0-f7 used for TLB flush */
 
 #define NUM_INVALIDATE_TLB_VECTORS	8
 
diff --git a/include/asm-x86_64/i387.h b/include/asm-x86_64/i387.h
index aa39cfd..57f7e14 100644
--- a/include/asm-x86_64/i387.h
+++ b/include/asm-x86_64/i387.h
@@ -75,7 +75,8 @@
 static inline int restore_fpu_checking(struct i387_fxsave_struct *fx) 
 { 
 	int err;
-	asm volatile("1:  rex64 ; fxrstor (%[fx])\n\t"
+
+	asm volatile("1:  rex64/fxrstor (%[fx])\n\t"
 		     "2:\n"
 		     ".section .fixup,\"ax\"\n"
 		     "3:  movl $-1,%[err]\n"
@@ -86,7 +87,11 @@
 		     "   .quad  1b,3b\n"
 		     ".previous"
 		     : [err] "=r" (err)
-		     : [fx] "r" (fx), "0" (0)); 
+#if 0 /* See comment in __fxsave_clear() below. */
+		     : [fx] "r" (fx), "m" (*fx), "0" (0));
+#else
+		     : [fx] "cdaSDb" (fx), "m" (*fx), "0" (0));
+#endif
 	if (unlikely(err))
 		init_fpu(current);
 	return err;
@@ -95,7 +100,8 @@
 static inline int save_i387_checking(struct i387_fxsave_struct __user *fx) 
 { 
 	int err;
-	asm volatile("1:  rex64 ; fxsave (%[fx])\n\t"
+
+	asm volatile("1:  rex64/fxsave (%[fx])\n\t"
 		     "2:\n"
 		     ".section .fixup,\"ax\"\n"
 		     "3:  movl $-1,%[err]\n"
@@ -105,20 +111,53 @@
 		     "   .align 8\n"
 		     "   .quad  1b,3b\n"
 		     ".previous"
-		     : [err] "=r" (err)
-		     : [fx] "r" (fx), "0" (0)); 
+		     : [err] "=r" (err), "=m" (*fx)
+#if 0 /* See comment in __fxsave_clear() below. */
+		     : [fx] "r" (fx), "0" (0));
+#else
+		     : [fx] "cdaSDb" (fx), "0" (0));
+#endif
 	if (unlikely(err))
 		__clear_user(fx, sizeof(struct i387_fxsave_struct));
 	return err;
 } 
 
+static inline void __fxsave_clear(struct task_struct *tsk)
+{
+	/* Using "rex64; fxsave %0" is broken because, if the memory operand
+	   uses any extended registers for addressing, a second REX prefix
+	   will be generated (to the assembler, rex64 followed by semicolon
+	   is a separate instruction), and hence the 64-bitness is lost. */
+#if 0
+	/* Using "fxsaveq %0" would be the ideal choice, but is only supported
+	   starting with gas 2.16. */
+	__asm__ __volatile__("fxsaveq %0"
+			     : "=m" (tsk->thread.i387.fxsave));
+#elif 0
+	/* Using, as a workaround, the properly prefixed form below isn't
+	   accepted by any binutils version so far released, complaining that
+	   the same type of prefix is used twice if an extended register is
+	   needed for addressing (fix submitted to mainline 2005-11-21). */
+	__asm__ __volatile__("rex64/fxsave %0"
+			     : "=m" (tsk->thread.i387.fxsave));
+#else
+	/* This, however, we can work around by forcing the compiler to select
+	   an addressing mode that doesn't require extended registers. */
+	__asm__ __volatile__("rex64/fxsave %P2(%1)"
+			     : "=m" (tsk->thread.i387.fxsave)
+			     : "cdaSDb" (tsk),
+				"i" (offsetof(__typeof__(*tsk),
+					      thread.i387.fxsave)));
+#endif
+	__asm__ __volatile__("fnclex");
+}
+
 static inline void kernel_fpu_begin(void)
 {
 	struct thread_info *me = current_thread_info();
 	preempt_disable();
-	if (me->status & TS_USEDFPU) { 
-		asm volatile("rex64 ; fxsave %0 ; fnclex"
-			      : "=m" (me->task->thread.i387.fxsave));
+	if (me->status & TS_USEDFPU) {
+		__fxsave_clear(me->task);
 		me->status &= ~TS_USEDFPU;
 		return;
 	}
@@ -133,8 +172,7 @@
 
 static inline void save_init_fpu( struct task_struct *tsk )
 {
-	asm volatile( "rex64 ; fxsave %0 ; fnclex"
-		      : "=m" (tsk->thread.i387.fxsave));
+ 	__fxsave_clear(tsk);
 	tsk->thread_info->status &= ~TS_USEDFPU;
 	stts();
 }
diff --git a/include/asm-x86_64/idle.h b/include/asm-x86_64/idle.h
new file mode 100644
index 0000000..6bd47dc
--- /dev/null
+++ b/include/asm-x86_64/idle.h
@@ -0,0 +1,14 @@
+#ifndef _ASM_X86_64_IDLE_H
+#define _ASM_X86_64_IDLE_H 1
+
+#define IDLE_START 1
+#define IDLE_END 2
+
+struct notifier_block;
+void idle_notifier_register(struct notifier_block *n);
+void idle_notifier_unregister(struct notifier_block *n);
+
+void enter_idle(void);
+void exit_idle(void);
+
+#endif
diff --git a/include/asm-x86_64/io.h b/include/asm-x86_64/io.h
index 52ff269..9dac18d 100644
--- a/include/asm-x86_64/io.h
+++ b/include/asm-x86_64/io.h
@@ -143,6 +143,11 @@
 extern void __iomem * ioremap_nocache (unsigned long offset, unsigned long size);
 extern void iounmap(volatile void __iomem *addr);
 
+/* Use normal IO mappings for DMI */
+#define dmi_ioremap ioremap
+#define dmi_iounmap(x,l) iounmap(x)
+#define dmi_alloc(l) kmalloc(l, GFP_ATOMIC)
+
 /*
  * ISA I/O bus memory addresses are 1:1 with the physical address.
  */
diff --git a/include/asm-x86_64/ipi.h b/include/asm-x86_64/ipi.h
index 022e9d3..2a5c162 100644
--- a/include/asm-x86_64/ipi.h
+++ b/include/asm-x86_64/ipi.h
@@ -38,10 +38,6 @@
 		icr |= APIC_DM_FIXED | vector;
 		break;
 	case NMI_VECTOR:
-		/*
-		 * Setup KDB IPI to be delivered as an NMI
-		 */
-	case KDB_VECTOR:
 		icr |= APIC_DM_NMI;
 		break;
 	}
diff --git a/include/asm-x86_64/kdebug.h b/include/asm-x86_64/kdebug.h
index f604e84..b9ed4c0 100644
--- a/include/asm-x86_64/kdebug.h
+++ b/include/asm-x86_64/kdebug.h
@@ -35,9 +35,16 @@
 	DIE_PAGE_FAULT,
 }; 
 	
-static inline int notify_die(enum die_val val,char *str,struct pt_regs *regs,long err,int trap, int sig)
-{ 
-	struct die_args args = { .regs=regs, .str=str, .err=err, .trapnr=trap,.signr=sig }; 
+static inline int notify_die(enum die_val val, const char *str,
+			struct pt_regs *regs, long err, int trap, int sig)
+{
+	struct die_args args = {
+		.regs = regs,
+		.str = str,
+		.err = err,
+		.trapnr = trap,
+		.signr = sig
+	};
 	return notifier_call_chain(&die_chain, val, &args); 
 } 
 
diff --git a/include/asm-x86_64/mmu_context.h b/include/asm-x86_64/mmu_context.h
index b630d52..16e4be4 100644
--- a/include/asm-x86_64/mmu_context.h
+++ b/include/asm-x86_64/mmu_context.h
@@ -15,18 +15,13 @@
 int init_new_context(struct task_struct *tsk, struct mm_struct *mm);
 void destroy_context(struct mm_struct *mm);
 
-#ifdef CONFIG_SMP
-
 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
 {
+#ifdef CONFIG_SMP
 	if (read_pda(mmu_state) == TLBSTATE_OK) 
 		write_pda(mmu_state, TLBSTATE_LAZY);
-}
-#else
-static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
-{
-}
 #endif
+}
 
 static inline void load_cr3(pgd_t *pgd)
 {
diff --git a/include/asm-x86_64/mmzone.h b/include/asm-x86_64/mmzone.h
index 69baaa8..972c935 100644
--- a/include/asm-x86_64/mmzone.h
+++ b/include/asm-x86_64/mmzone.h
@@ -36,22 +36,12 @@
 				 NODE_DATA(nid)->node_spanned_pages)
 
 #ifdef CONFIG_DISCONTIGMEM
-
 #define pfn_to_nid(pfn) phys_to_nid((unsigned long)(pfn) << PAGE_SHIFT)
 #define kvaddr_to_nid(kaddr)	phys_to_nid(__pa(kaddr))
 
-/* Requires pfn_valid(pfn) to be true */
-#define pfn_to_page(pfn) ({ \
-	int nid = phys_to_nid(((unsigned long)(pfn)) << PAGE_SHIFT); 	\
-	((pfn) - node_start_pfn(nid)) + NODE_DATA(nid)->node_mem_map;	\
-})
-
-#define page_to_pfn(page) \
-	(long)(((page) - page_zone(page)->zone_mem_map) + page_zone(page)->zone_start_pfn)
-
-#define pfn_valid(pfn) ((pfn) >= num_physpages ? 0 : \
-			({ u8 nid__ = pfn_to_nid(pfn); \
-			   nid__ != 0xff && (pfn) >= node_start_pfn(nid__) && (pfn) < node_end_pfn(nid__); }))
+extern struct page *pfn_to_page(unsigned long pfn);
+extern unsigned long page_to_pfn(struct page *page);
+extern int pfn_valid(unsigned long pfn);
 #endif
 
 #define local_mapnr(kvaddr) \
diff --git a/include/asm-x86_64/mutex.h b/include/asm-x86_64/mutex.h
index 818abfd..11fbee2 100644
--- a/include/asm-x86_64/mutex.h
+++ b/include/asm-x86_64/mutex.h
@@ -104,7 +104,7 @@
 static inline int
 __mutex_fastpath_trylock(atomic_t *count, int (*fail_fn)(atomic_t *))
 {
-	if (likely(atomic_cmpxchg(count, 1, 0)) == 1)
+	if (likely(atomic_cmpxchg(count, 1, 0) == 1))
 		return 1;
 	else
 		return 0;
diff --git a/include/asm-x86_64/numa.h b/include/asm-x86_64/numa.h
index d51e56f..34e434c 100644
--- a/include/asm-x86_64/numa.h
+++ b/include/asm-x86_64/numa.h
@@ -20,6 +20,11 @@
 extern void numa_set_node(int cpu, int node);
 
 extern unsigned char apicid_to_node[256];
+#ifdef CONFIG_NUMA
+extern void __init init_cpu_to_node(void);
+#else
+#define init_cpu_to_node() do {} while (0)
+#endif
 
 #define NUMA_NO_NODE 0xff
 
diff --git a/include/asm-x86_64/page.h b/include/asm-x86_64/page.h
index 06e489f..dcbb4fc 100644
--- a/include/asm-x86_64/page.h
+++ b/include/asm-x86_64/page.h
@@ -14,13 +14,18 @@
 #define PHYSICAL_PAGE_MASK	(~(PAGE_SIZE-1) & __PHYSICAL_MASK)
 
 #define THREAD_ORDER 1 
-#ifdef __ASSEMBLY__
-#define THREAD_SIZE  (1 << (PAGE_SHIFT + THREAD_ORDER))
-#else
-#define THREAD_SIZE  (1UL << (PAGE_SHIFT + THREAD_ORDER))
-#endif
+#define THREAD_SIZE  (PAGE_SIZE << THREAD_ORDER)
 #define CURRENT_MASK (~(THREAD_SIZE-1))
 
+#define EXCEPTION_STACK_ORDER 0
+#define EXCEPTION_STKSZ (PAGE_SIZE << EXCEPTION_STACK_ORDER)
+
+#define DEBUG_STACK_ORDER EXCEPTION_STACK_ORDER
+#define DEBUG_STKSZ (PAGE_SIZE << DEBUG_STACK_ORDER)
+
+#define IRQSTACK_ORDER 2
+#define IRQSTACKSIZE (PAGE_SIZE << IRQSTACK_ORDER)
+
 #define LARGE_PAGE_MASK (~(LARGE_PAGE_SIZE-1))
 #define LARGE_PAGE_SIZE (1UL << PMD_SHIFT)
 
diff --git a/include/asm-x86_64/pci.h b/include/asm-x86_64/pci.h
index eeb3088..fd03e15 100644
--- a/include/asm-x86_64/pci.h
+++ b/include/asm-x86_64/pci.h
@@ -42,18 +42,20 @@
 #include <asm/scatterlist.h>
 #include <linux/string.h>
 #include <asm/page.h>
+#include <linux/dma-mapping.h> /* for have_iommu */
 
 extern int iommu_setup(char *opt);
 
-#ifdef CONFIG_GART_IOMMU
 /* The PCI address space does equal the physical memory
  * address space.  The networking and block device layers use
  * this boolean for bounce buffer decisions
  *
- * On AMD64 it mostly equals, but we set it to zero to tell some subsystems
- * that an IOMMU is available.
+ * On AMD64 it mostly equals, but we set it to zero if a hardware
+ * IOMMU (gart) of sotware IOMMU (swiotlb) is available.
  */
-#define PCI_DMA_BUS_IS_PHYS	(no_iommu ? 1 : 0)
+#define PCI_DMA_BUS_IS_PHYS (dma_ops->is_phys)
+
+#ifdef CONFIG_GART_IOMMU
 
 /*
  * x86-64 always supports DAC, but sometimes it is useful to force
@@ -79,7 +81,6 @@
 #else
 /* No IOMMU */
 
-#define PCI_DMA_BUS_IS_PHYS	1
 #define pci_dac_dma_supported(pci_dev, mask)    1
 
 #define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
diff --git a/include/asm-x86_64/pda.h b/include/asm-x86_64/pda.h
index 8733ccf..c7ab38a 100644
--- a/include/asm-x86_64/pda.h
+++ b/include/asm-x86_64/pda.h
@@ -5,6 +5,7 @@
 #include <linux/stddef.h>
 #include <linux/types.h>
 #include <linux/cache.h>
+#include <asm/page.h>
 
 /* Per processor datastructure. %gs points to it while the kernel runs */ 
 struct x8664_pda {
@@ -12,6 +13,9 @@
 	unsigned long data_offset;	/* Per cpu data offset from linker address */
 	unsigned long kernelstack;  /* top of kernel stack for current */ 
 	unsigned long oldrsp; 	    /* user rsp for system call */
+#if DEBUG_STKSZ > EXCEPTION_STKSZ
+	unsigned long debugstack;   /* #DB/#BP stack. */
+#endif
         int irqcount;		    /* Irq nesting counter. Starts with -1 */  	
 	int cpunumber;		    /* Logical CPU number */
 	char *irqstackptr;	/* top of irqstack */
@@ -23,11 +27,10 @@
 	unsigned apic_timer_irqs;
 } ____cacheline_aligned_in_smp;
 
+extern struct x8664_pda *_cpu_pda[];
+extern struct x8664_pda boot_cpu_pda[];
 
-#define IRQSTACK_ORDER 2
-#define IRQSTACKSIZE (PAGE_SIZE << IRQSTACK_ORDER) 
-
-extern struct x8664_pda cpu_pda[];
+#define cpu_pda(i) (_cpu_pda[i])
 
 /* 
  * There is no fast way to get the base address of the PDA, all the accesses
diff --git a/include/asm-x86_64/percpu.h b/include/asm-x86_64/percpu.h
index 9c71855..29a6b04 100644
--- a/include/asm-x86_64/percpu.h
+++ b/include/asm-x86_64/percpu.h
@@ -11,7 +11,7 @@
 
 #include <asm/pda.h>
 
-#define __per_cpu_offset(cpu) (cpu_pda[cpu].data_offset)
+#define __per_cpu_offset(cpu) (cpu_pda(cpu)->data_offset)
 #define __my_cpu_offset() read_pda(data_offset)
 
 /* Separate out the type, so (int[3], foo) works. */
diff --git a/include/asm-x86_64/pgtable.h b/include/asm-x86_64/pgtable.h
index 02888d7..8fbf4dd 100644
--- a/include/asm-x86_64/pgtable.h
+++ b/include/asm-x86_64/pgtable.h
@@ -267,25 +267,25 @@
  */
 #define __LARGE_PTE (_PAGE_PSE|_PAGE_PRESENT)
 static inline int pte_user(pte_t pte)		{ return pte_val(pte) & _PAGE_USER; }
-extern inline int pte_read(pte_t pte)		{ return pte_val(pte) & _PAGE_USER; }
-extern inline int pte_exec(pte_t pte)		{ return pte_val(pte) & _PAGE_USER; }
-extern inline int pte_dirty(pte_t pte)		{ return pte_val(pte) & _PAGE_DIRTY; }
-extern inline int pte_young(pte_t pte)		{ return pte_val(pte) & _PAGE_ACCESSED; }
-extern inline int pte_write(pte_t pte)		{ return pte_val(pte) & _PAGE_RW; }
+static inline int pte_read(pte_t pte)		{ return pte_val(pte) & _PAGE_USER; }
+static inline int pte_exec(pte_t pte)		{ return pte_val(pte) & _PAGE_USER; }
+static inline int pte_dirty(pte_t pte)		{ return pte_val(pte) & _PAGE_DIRTY; }
+static inline int pte_young(pte_t pte)		{ return pte_val(pte) & _PAGE_ACCESSED; }
+static inline int pte_write(pte_t pte)		{ return pte_val(pte) & _PAGE_RW; }
 static inline int pte_file(pte_t pte)		{ return pte_val(pte) & _PAGE_FILE; }
 static inline int pte_huge(pte_t pte)		{ return (pte_val(pte) & __LARGE_PTE) == __LARGE_PTE; }
 
-extern inline pte_t pte_rdprotect(pte_t pte)	{ set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_USER)); return pte; }
-extern inline pte_t pte_exprotect(pte_t pte)	{ set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_USER)); return pte; }
-extern inline pte_t pte_mkclean(pte_t pte)	{ set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_DIRTY)); return pte; }
-extern inline pte_t pte_mkold(pte_t pte)	{ set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_ACCESSED)); return pte; }
-extern inline pte_t pte_wrprotect(pte_t pte)	{ set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_RW)); return pte; }
-extern inline pte_t pte_mkread(pte_t pte)	{ set_pte(&pte, __pte(pte_val(pte) | _PAGE_USER)); return pte; }
-extern inline pte_t pte_mkexec(pte_t pte)	{ set_pte(&pte, __pte(pte_val(pte) | _PAGE_USER)); return pte; }
-extern inline pte_t pte_mkdirty(pte_t pte)	{ set_pte(&pte, __pte(pte_val(pte) | _PAGE_DIRTY)); return pte; }
-extern inline pte_t pte_mkyoung(pte_t pte)	{ set_pte(&pte, __pte(pte_val(pte) | _PAGE_ACCESSED)); return pte; }
-extern inline pte_t pte_mkwrite(pte_t pte)	{ set_pte(&pte, __pte(pte_val(pte) | _PAGE_RW)); return pte; }
-extern inline pte_t pte_mkhuge(pte_t pte)	{ set_pte(&pte, __pte(pte_val(pte) | __LARGE_PTE)); return pte; }
+static inline pte_t pte_rdprotect(pte_t pte)	{ set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_USER)); return pte; }
+static inline pte_t pte_exprotect(pte_t pte)	{ set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_USER)); return pte; }
+static inline pte_t pte_mkclean(pte_t pte)	{ set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_DIRTY)); return pte; }
+static inline pte_t pte_mkold(pte_t pte)	{ set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_ACCESSED)); return pte; }
+static inline pte_t pte_wrprotect(pte_t pte)	{ set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_RW)); return pte; }
+static inline pte_t pte_mkread(pte_t pte)	{ set_pte(&pte, __pte(pte_val(pte) | _PAGE_USER)); return pte; }
+static inline pte_t pte_mkexec(pte_t pte)	{ set_pte(&pte, __pte(pte_val(pte) | _PAGE_USER)); return pte; }
+static inline pte_t pte_mkdirty(pte_t pte)	{ set_pte(&pte, __pte(pte_val(pte) | _PAGE_DIRTY)); return pte; }
+static inline pte_t pte_mkyoung(pte_t pte)	{ set_pte(&pte, __pte(pte_val(pte) | _PAGE_ACCESSED)); return pte; }
+static inline pte_t pte_mkwrite(pte_t pte)	{ set_pte(&pte, __pte(pte_val(pte) | _PAGE_RW)); return pte; }
+static inline pte_t pte_mkhuge(pte_t pte)	{ set_pte(&pte, __pte(pte_val(pte) | __LARGE_PTE)); return pte; }
 
 struct vm_area_struct;
 
diff --git a/include/asm-x86_64/processor.h b/include/asm-x86_64/processor.h
index 4861246..394dd72 100644
--- a/include/asm-x86_64/processor.h
+++ b/include/asm-x86_64/processor.h
@@ -227,7 +227,13 @@
 extern struct cpuinfo_x86 boot_cpu_data;
 DECLARE_PER_CPU(struct tss_struct,init_tss);
 
+#ifdef CONFIG_X86_VSMP
+#define ARCH_MIN_TASKALIGN	(1 << INTERNODE_CACHE_SHIFT)
+#define ARCH_MIN_MMSTRUCT_ALIGN	(1 << INTERNODE_CACHE_SHIFT)
+#else
 #define ARCH_MIN_TASKALIGN	16
+#define ARCH_MIN_MMSTRUCT_ALIGN	0
+#endif
 
 struct thread_struct {
 	unsigned long	rsp0;
@@ -273,8 +279,6 @@
 #define DEBUG_STACK 4 
 #define MCE_STACK 5
 #define N_EXCEPTION_STACKS 5  /* hw limit: 7 */
-#define EXCEPTION_STKSZ (PAGE_SIZE << EXCEPTION_STACK_ORDER)
-#define EXCEPTION_STACK_ORDER 0 
 
 #define start_thread(regs,new_rip,new_rsp) do { \
 	asm volatile("movl %0,%%fs; movl %0,%%es; movl %0,%%ds": :"r" (0));	 \
diff --git a/include/asm-x86_64/proto.h b/include/asm-x86_64/proto.h
index 3450108..115e496 100644
--- a/include/asm-x86_64/proto.h
+++ b/include/asm-x86_64/proto.h
@@ -67,8 +67,6 @@
 
 extern unsigned long end_pfn_map; 
 
-extern cpumask_t cpu_initialized;
-
 extern void show_trace(unsigned long * rsp);
 extern void show_registers(struct pt_regs *regs);
 
@@ -91,8 +89,12 @@
 
 extern int unhandled_signal(struct task_struct *tsk, int sig);
 
+extern int unsynchronized_tsc(void);
+
 extern void select_idle_routine(const struct cpuinfo_x86 *c);
-extern void swiotlb_init(void);
+
+extern void gart_parse_options(char *);
+extern void __init no_iommu_init(void);
 
 extern unsigned long table_start, table_end;
 
@@ -106,12 +108,17 @@
 extern int acpi_ht;
 extern int acpi_disabled;
 
+#ifdef CONFIG_GART_IOMMU
 extern int fallback_aper_order;
 extern int fallback_aper_force;
 extern int iommu_aperture;
-extern int iommu_aperture_disabled;
 extern int iommu_aperture_allowed;
+extern int iommu_aperture_disabled;
 extern int fix_aperture;
+#else
+#define iommu_aperture 0
+#define iommu_aperture_allowed 0
+#endif
 extern int force_iommu;
 
 extern int reboot_force;
diff --git a/include/asm-x86_64/segment.h b/include/asm-x86_64/segment.h
index 44adaf1..d4bed33 100644
--- a/include/asm-x86_64/segment.h
+++ b/include/asm-x86_64/segment.h
@@ -19,15 +19,13 @@
 #define __USER_DS     0x2b   /* 5*8+3 */ 
 #define __USER_CS     0x33   /* 6*8+3 */ 
 #define __USER32_DS	__USER_DS 
-#define __KERNEL16_CS	(GDT_ENTRY_KERNELCS16 * 8)
-#define __KERNEL_COMPAT32_CS   0x8
 
 #define GDT_ENTRY_TLS 1
 #define GDT_ENTRY_TSS 8	/* needs two entries */
 #define GDT_ENTRY_LDT 10 /* needs two entries */
 #define GDT_ENTRY_TLS_MIN 12
 #define GDT_ENTRY_TLS_MAX 14
-#define GDT_ENTRY_KERNELCS16 15
+/* 15 free */
 
 #define GDT_ENTRY_TLS_ENTRIES 3
 
diff --git a/include/asm-x86_64/smp.h b/include/asm-x86_64/smp.h
index d030409..9ccbb2c 100644
--- a/include/asm-x86_64/smp.h
+++ b/include/asm-x86_64/smp.h
@@ -35,6 +35,7 @@
 extern cpumask_t cpu_possible_map;
 extern cpumask_t cpu_online_map;
 extern cpumask_t cpu_callout_map;
+extern cpumask_t cpu_initialized;
 
 /*
  * Private routines/data
diff --git a/include/asm-x86_64/swiotlb.h b/include/asm-x86_64/swiotlb.h
index dddf1b2..60757ef 100644
--- a/include/asm-x86_64/swiotlb.h
+++ b/include/asm-x86_64/swiotlb.h
@@ -3,10 +3,14 @@
 
 #include <linux/config.h>
 
+#include <asm/dma-mapping.h>
+
 /* SWIOTLB interface */
 
-extern dma_addr_t swiotlb_map_single(struct device *hwdev, void *ptr, size_t size,
-				      int dir);
+extern dma_addr_t swiotlb_map_single(struct device *hwdev, void *ptr,
+				     size_t size, int dir);
+extern void *swiotlb_alloc_coherent(struct device *hwdev, size_t size,
+                       dma_addr_t *dma_handle, gfp_t flags);
 extern void swiotlb_unmap_single(struct device *hwdev, dma_addr_t dev_addr,
 				  size_t size, int dir);
 extern void swiotlb_sync_single_for_cpu(struct device *hwdev,
@@ -34,10 +38,10 @@
 extern void swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sg,
 			 int nents, int direction);
 extern int swiotlb_dma_mapping_error(dma_addr_t dma_addr);
-extern void *swiotlb_alloc_coherent (struct device *hwdev, size_t size,
-				     dma_addr_t *dma_handle, gfp_t flags);
 extern void swiotlb_free_coherent (struct device *hwdev, size_t size,
 				   void *vaddr, dma_addr_t dma_handle);
+extern int swiotlb_dma_supported(struct device *hwdev, u64 mask);
+extern void swiotlb_init(void);
 
 #ifdef CONFIG_SWIOTLB
 extern int swiotlb;
@@ -45,4 +49,6 @@
 #define swiotlb 0
 #endif
 
-#endif
+extern void pci_swiotlb_init(void);
+
+#endif /* _ASM_SWTIOLB_H */
diff --git a/include/asm-x86_64/system.h b/include/asm-x86_64/system.h
index b34cc2e..38c1e8a 100644
--- a/include/asm-x86_64/system.h
+++ b/include/asm-x86_64/system.h
@@ -20,8 +20,8 @@
 #define __RESTORE(reg,offset) "movq (14-" #offset ")*8(%%rsp),%%" #reg "\n\t"
 
 /* frame pointer must be last for get_wchan */
-#define SAVE_CONTEXT    "pushfq ; pushq %%rbp ; movq %%rsi,%%rbp\n\t"
-#define RESTORE_CONTEXT "movq %%rbp,%%rsi ; popq %%rbp ; popfq\n\t" 
+#define SAVE_CONTEXT    "pushq %%rbp ; movq %%rsi,%%rbp\n\t"
+#define RESTORE_CONTEXT "movq %%rbp,%%rsi ; popq %%rbp\n\t"
 
 #define __EXTRA_CLOBBER  \
 	,"rcx","rbx","rdx","r8","r9","r10","r11","r12","r13","r14","r15"
@@ -137,6 +137,21 @@
 		      "663:\n\t" newinstr "\n664:\n"   /* replacement */ \
 		      ".previous" :: "i" (feature), ##input)
 
+/* Like alternative_input, but with a single output argument */
+#define alternative_io(oldinstr, newinstr, feature, output, input...) \
+	asm volatile ("661:\n\t" oldinstr "\n662:\n"			\
+		      ".section .altinstructions,\"a\"\n"		\
+		      "  .align 8\n"					\
+		      "  .quad 661b\n"            /* label */		\
+		      "  .quad 663f\n"		  /* new instruction */	\
+		      "  .byte %c[feat]\n"        /* feature bit */	\
+		      "  .byte 662b-661b\n"       /* sourcelen */	\
+		      "  .byte 664f-663f\n"       /* replacementlen */	\
+		      ".previous\n"					\
+		      ".section .altinstr_replacement,\"ax\"\n"		\
+		      "663:\n\t" newinstr "\n664:\n"   /* replacement */ \
+		      ".previous" : output : [feat] "i" (feature), ##input)
+
 /*
  * Clear and set 'TS' bit respectively
  */
@@ -311,8 +326,25 @@
 /* interrupt control.. */
 #define local_save_flags(x)	do { warn_if_not_ulong(x); __asm__ __volatile__("# save_flags \n\t pushfq ; popq %q0":"=g" (x): /* no input */ :"memory"); } while (0)
 #define local_irq_restore(x) 	__asm__ __volatile__("# restore_flags \n\t pushq %0 ; popfq": /* no output */ :"g" (x):"memory", "cc")
+
+#ifdef CONFIG_X86_VSMP
+/* Interrupt control for VSMP  architecture */
+#define local_irq_disable()	do { unsigned long flags; local_save_flags(flags); local_irq_restore((flags & ~(1 << 9)) | (1 << 18)); } while (0)
+#define local_irq_enable()	do { unsigned long flags; local_save_flags(flags); local_irq_restore((flags | (1 << 9)) & ~(1 << 18)); } while (0)
+
+#define irqs_disabled()					\
+({							\
+	unsigned long flags;				\
+	local_save_flags(flags);			\
+	(flags & (1<<18)) || !(flags & (1<<9));		\
+})
+
+/* For spinlocks etc */
+#define local_irq_save(x)	do { local_save_flags(x); local_irq_restore((x & ~(1 << 9)) | (1 << 18)); } while (0)
+#else  /* CONFIG_X86_VSMP */
 #define local_irq_disable() 	__asm__ __volatile__("cli": : :"memory")
 #define local_irq_enable()	__asm__ __volatile__("sti": : :"memory")
+
 /* used in the idle loop; sti takes one instruction cycle to complete */
 #define safe_halt()		__asm__ __volatile__("sti; hlt": : :"memory")
 /* used when interrupts are already enabled or to shutdown the processor */
@@ -327,16 +359,10 @@
 
 /* For spinlocks etc */
 #define local_irq_save(x) 	do { warn_if_not_ulong(x); __asm__ __volatile__("# local_irq_save \n\t pushfq ; popq %0 ; cli":"=g" (x): /* no input */ :"memory"); } while (0)
+#endif
 
 void cpu_idle_wait(void);
 
-/*
- * disable hlt during certain critical i/o operations
- */
-#define HAVE_DISABLE_HLT
-void disable_hlt(void);
-void enable_hlt(void);
-
 extern unsigned long arch_align_stack(unsigned long sp);
 
 #endif
diff --git a/include/asm-x86_64/thread_info.h b/include/asm-x86_64/thread_info.h
index 08eb6e4..eb7c5fd 100644
--- a/include/asm-x86_64/thread_info.h
+++ b/include/asm-x86_64/thread_info.h
@@ -138,6 +138,7 @@
  * have to worry about atomic accesses.
  */
 #define TS_USEDFPU		0x0001	/* FPU was used by this task this quantum (SMP) */
+#define TS_COMPAT		0x0002	/* 32bit syscall active */
 
 #endif /* __KERNEL__ */
 
diff --git a/include/asm-x86_64/timex.h b/include/asm-x86_64/timex.h
index f971f45..f18443f 100644
--- a/include/asm-x86_64/timex.h
+++ b/include/asm-x86_64/timex.h
@@ -10,6 +10,9 @@
 #include <asm/msr.h>
 #include <asm/vsyscall.h>
 #include <asm/hpet.h>
+#include <asm/system.h>
+#include <asm/processor.h>
+#include <linux/compiler.h>
 
 #define CLOCK_TICK_RATE	PIT_TICK_RATE	/* Underlying HZ */
 
@@ -23,6 +26,19 @@
 	return ret;
 }
 
+/* Like get_cycles, but make sure the CPU is synchronized. */
+static __always_inline cycles_t get_cycles_sync(void)
+{
+	unsigned long long ret;
+	unsigned eax;
+	/* Don't do an additional sync on CPUs where we know
+	   RDTSC is already synchronous. */
+	alternative_io(ASM_NOP2, "cpuid", X86_FEATURE_SYNC_RDTSC,
+			  "=a" (eax), "0" (1) : "ebx","ecx","edx","memory");
+	rdtscll(ret);
+	return ret;
+}
+
 extern unsigned int cpu_khz;
 
 extern int read_current_timer(unsigned long *timer_value);
diff --git a/include/asm-x86_64/uaccess.h b/include/asm-x86_64/uaccess.h
index 1bb8b8a..2892c4b 100644
--- a/include/asm-x86_64/uaccess.h
+++ b/include/asm-x86_64/uaccess.h
@@ -348,6 +348,7 @@
 long strncpy_from_user(char *dst, const char __user *src, long count);
 long __strncpy_from_user(char *dst, const char __user *src, long count);
 long strnlen_user(const char __user *str, long n);
+long __strnlen_user(const char __user *str, long n);
 long strlen_user(const char __user *str);
 unsigned long clear_user(void __user *mem, unsigned long len);
 unsigned long __clear_user(void __user *mem, unsigned long len);
diff --git a/include/asm-x86_64/vsyscall.h b/include/asm-x86_64/vsyscall.h
index 438a3f5..a85e16f 100644
--- a/include/asm-x86_64/vsyscall.h
+++ b/include/asm-x86_64/vsyscall.h
@@ -36,8 +36,8 @@
 	int mode;
 };
 
-#define hpet_readl(a)           readl((void *)fix_to_virt(FIX_HPET_BASE) + a)
-#define hpet_writel(d,a)        writel(d, (void *)fix_to_virt(FIX_HPET_BASE) + a)
+#define hpet_readl(a)           readl((const void __iomem *)fix_to_virt(FIX_HPET_BASE) + a)
+#define hpet_writel(d,a)        writel(d, (void __iomem *)fix_to_virt(FIX_HPET_BASE) + a)
 
 /* vsyscall space (readonly) */
 extern struct vxtime_data __vxtime;
diff --git a/include/linux/capability.h b/include/linux/capability.h
index 6b46189..5a23ce7 100644
--- a/include/linux/capability.h
+++ b/include/linux/capability.h
@@ -43,6 +43,7 @@
 #ifdef __KERNEL__
 
 #include <linux/spinlock.h>
+#include <asm/current.h>
 
 /* #define STRICT_CAP_T_TYPECHECKS */
 
@@ -356,6 +357,8 @@
 
 #define cap_is_fs_cap(c)     (CAP_TO_MASK(c) & CAP_FS_MASK)
 
+extern int capable(int cap);
+
 #endif /* __KERNEL__ */
 
 #endif /* !_LINUX_CAPABILITY_H */
diff --git a/include/linux/dmi.h b/include/linux/dmi.h
index 05f4132..2e6bbe0 100644
--- a/include/linux/dmi.h
+++ b/include/linux/dmi.h
@@ -2,6 +2,7 @@
 #define __DMI_H__
 
 #include <linux/list.h>
+#include <linux/config.h>
 
 enum dmi_field {
 	DMI_NONE,
@@ -60,12 +61,14 @@
 	void *device_data;	/* Type specific data */
 };
 
-#if defined(CONFIG_X86_32)
+#ifdef CONFIG_DMI
 
 extern int dmi_check_system(struct dmi_system_id *list);
 extern char * dmi_get_system_info(int field);
 extern struct dmi_device * dmi_find_device(int type, const char *name,
 	struct dmi_device *from);
+extern void dmi_scan_machine(void);
+
 #else
 
 static inline int dmi_check_system(struct dmi_system_id *list) { return 0; }
diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index 8b2eab9..20f9148 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -57,6 +57,7 @@
 			__GFP_NOFAIL|__GFP_NORETRY|__GFP_NO_GROW|__GFP_COMP| \
 			__GFP_NOMEMALLOC|__GFP_HARDWALL)
 
+/* GFP_ATOMIC means both !wait (__GFP_WAIT not set) and use emergency pool */
 #define GFP_ATOMIC	(__GFP_HIGH)
 #define GFP_NOIO	(__GFP_WAIT)
 #define GFP_NOFS	(__GFP_WAIT | __GFP_IO)
@@ -109,6 +110,10 @@
 	if (unlikely(order >= MAX_ORDER))
 		return NULL;
 
+	/* Unknown node is current node */
+	if (nid < 0)
+		nid = numa_node_id();
+
 	return __alloc_pages(gfp_mask, order,
 		NODE_DATA(nid)->node_zonelists + gfp_zone(gfp_mask));
 }
diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
index 10005bc..669756b 100644
--- a/include/linux/kprobes.h
+++ b/include/linux/kprobes.h
@@ -68,6 +68,9 @@
 	/* list of kprobes for multi-handler support */
 	struct list_head list;
 
+	/* Indicates that the corresponding module has been ref counted */
+	unsigned int mod_refcounted;
+
 	/*count the number of times this probe was temporarily disarmed */
 	unsigned long nmissed;
 
diff --git a/include/linux/mm.h b/include/linux/mm.h
index e53d2c6..c643016 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -3,6 +3,7 @@
 
 #include <linux/sched.h>
 #include <linux/errno.h>
+#include <linux/capability.h>
 
 #ifdef __KERNEL__
 
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 7e4ae6a..34cbefd 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -98,7 +98,7 @@
 
 /*
  * On machines where it is needed (eg PCs) we divide physical memory
- * into multiple physical zones. On a PC we have 4 zones:
+ * into multiple physical zones. On a 32bit PC we have 4 zones:
  *
  * ZONE_DMA	  < 16 MB	ISA DMA capable memory
  * ZONE_DMA32	     0 MB 	Empty
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index f55c98a..7fb397e 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -2152,6 +2152,9 @@
 #define PCI_DEVICE_ID_INTEL_IXP2800	0x9004
 #define PCI_DEVICE_ID_INTEL_S21152BB	0xb152
 
+#define PCI_VENDOR_ID_SCALEMP		0x8686
+#define PCI_DEVICE_ID_SCALEMP_VSMP_CTL	0x1010
+
 #define PCI_VENDOR_ID_COMPUTONE		0x8e0e
 #define PCI_DEVICE_ID_COMPUTONE_IP2EX	0x0291
 #define PCI_DEVICE_ID_COMPUTONE_PG	0x0302
diff --git a/include/linux/sched.h b/include/linux/sched.h
index c4ee35d..3b74c4b 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1112,21 +1112,6 @@
 		: on_sig_stack(sp) ? SS_ONSTACK : 0);
 }
 
-
-#ifdef CONFIG_SECURITY
-/* code is in security.c */
-extern int capable(int cap);
-#else
-static inline int capable(int cap)
-{
-	if (cap_raised(current->cap_effective, cap)) {
-		current->flags |= PF_SUPERPRIV;
-		return 1;
-	}
-	return 0;
-}
-#endif
-
 /*
  * Routines for handling mm_structs
  */
diff --git a/init/Kconfig b/init/Kconfig
index 9bdd549..25f4d74 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -326,15 +326,6 @@
           option for embedded systems with no facilities for reporting errors.
           Just say Y.
 
-config DOUBLEFAULT
-	depends X86
-	default y if X86
-	bool "Enable doublefault exception handler" if EMBEDDED
-	help
-          This option allows trapping of rare doublefault exceptions that
-          would otherwise cause a system to silently reboot. Disabling this
-          option saves about 4k.
-
 config ELF_CORE
 	default y
 	bool "Enable ELF core dumps" if EMBEDDED
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index a8aa615..4e776f9 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -11,6 +11,7 @@
  * This file is released under the GPL.
  */
 
+#include <linux/capability.h>
 #include <linux/init.h>
 #include <linux/pagemap.h>
 #include <linux/file.h>
diff --git a/ipc/msg.c b/ipc/msg.c
index d035bd2..a91b647 100644
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -15,6 +15,7 @@
  * (c) 1999 Manfred Spraul <manfreds@colorfullife.com>
  */
 
+#include <linux/capability.h>
 #include <linux/config.h>
 #include <linux/slab.h>
 #include <linux/msg.h>
diff --git a/ipc/sem.c b/ipc/sem.c
index cb5bb2a..46bb8a6 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -73,6 +73,7 @@
 #include <linux/security.h>
 #include <linux/syscalls.h>
 #include <linux/audit.h>
+#include <linux/capability.h>
 #include <linux/seq_file.h>
 #include <asm/uaccess.h>
 #include "util.h"
diff --git a/ipc/shm.c b/ipc/shm.c
index 0b92e87..4c28d2d 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -27,6 +27,7 @@
 #include <linux/security.h>
 #include <linux/syscalls.h>
 #include <linux/audit.h>
+#include <linux/capability.h>
 #include <linux/ptrace.h>
 #include <linux/seq_file.h>
 
diff --git a/ipc/util.c b/ipc/util.c
index 23f1cec..38b9a0a 100644
--- a/ipc/util.c
+++ b/ipc/util.c
@@ -20,6 +20,7 @@
 #include <linux/smp_lock.h>
 #include <linux/vmalloc.h>
 #include <linux/slab.h>
+#include <linux/capability.h>
 #include <linux/highuid.h>
 #include <linux/security.h>
 #include <linux/rcupdate.h>
diff --git a/kernel/acct.c b/kernel/acct.c
index 38d57fa..065d8b4 100644
--- a/kernel/acct.c
+++ b/kernel/acct.c
@@ -47,6 +47,7 @@
 #include <linux/mm.h>
 #include <linux/slab.h>
 #include <linux/acct.h>
+#include <linux/capability.h>
 #include <linux/file.h>
 #include <linux/tty.h>
 #include <linux/security.h>
diff --git a/kernel/capability.c b/kernel/capability.c
index 8986a37..bfa3c92 100644
--- a/kernel/capability.c
+++ b/kernel/capability.c
@@ -7,6 +7,7 @@
  * 30 May 2002:	Cleanup, Robert M. Love <rml@tech9.net>
  */ 
 
+#include <linux/capability.h>
 #include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/security.h>
diff --git a/kernel/exit.c b/kernel/exit.c
index 8027228..f8e609f 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -10,6 +10,7 @@
 #include <linux/interrupt.h>
 #include <linux/smp_lock.h>
 #include <linux/module.h>
+#include <linux/capability.h>
 #include <linux/completion.h>
 #include <linux/personality.h>
 #include <linux/tty.h>
diff --git a/kernel/fork.c b/kernel/fork.c
index 3bdcab4..4ae8cfc 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -28,6 +28,7 @@
 #include <linux/binfmts.h>
 #include <linux/mman.h>
 #include <linux/fs.h>
+#include <linux/capability.h>
 #include <linux/cpu.h>
 #include <linux/cpuset.h>
 #include <linux/security.h>
@@ -1297,6 +1298,10 @@
 	return pid;
 }
 
+#ifndef ARCH_MIN_MMSTRUCT_ALIGN
+#define ARCH_MIN_MMSTRUCT_ALIGN 0
+#endif
+
 void __init proc_caches_init(void)
 {
 	sighand_cachep = kmem_cache_create("sighand_cache",
@@ -1315,6 +1320,6 @@
 			sizeof(struct vm_area_struct), 0,
 			SLAB_PANIC, NULL, NULL);
 	mm_cachep = kmem_cache_create("mm_struct",
-			sizeof(struct mm_struct), 0,
+			sizeof(struct mm_struct), ARCH_MIN_MMSTRUCT_ALIGN,
 			SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL, NULL);
 }
diff --git a/kernel/kexec.c b/kernel/kexec.c
index de14416..bf39d28 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -6,6 +6,7 @@
  * Version 2.  See the file COPYING for more details.
  */
 
+#include <linux/capability.h>
 #include <linux/mm.h>
 #include <linux/file.h>
 #include <linux/slab.h>
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 34a885b..3ea6325 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -449,19 +449,32 @@
 	return 0;
 }
 
-int __kprobes register_kprobe(struct kprobe *p)
+static int __kprobes __register_kprobe(struct kprobe *p,
+	unsigned long called_from)
 {
 	int ret = 0;
 	struct kprobe *old_p;
-	struct module *mod;
+	struct module *probed_mod;
 
 	if ((!kernel_text_address((unsigned long) p->addr)) ||
 		in_kprobes_functions((unsigned long) p->addr))
 		return -EINVAL;
 
-	if ((mod = module_text_address((unsigned long) p->addr)) &&
-			(unlikely(!try_module_get(mod))))
-		return -EINVAL;
+	p->mod_refcounted = 0;
+	/* Check are we probing a module */
+	if ((probed_mod = module_text_address((unsigned long) p->addr))) {
+		struct module *calling_mod = module_text_address(called_from);
+		/* We must allow modules to probe themself and
+		 * in this case avoid incrementing the module refcount,
+		 * so as to allow unloading of self probing modules.
+		 */
+		if (calling_mod && (calling_mod != probed_mod)) {
+			if (unlikely(!try_module_get(probed_mod)))
+				return -EINVAL;
+			p->mod_refcounted = 1;
+		} else
+			probed_mod = NULL;
+	}
 
 	p->nmissed = 0;
 	down(&kprobe_mutex);
@@ -483,11 +496,17 @@
 out:
 	up(&kprobe_mutex);
 
-	if (ret && mod)
-		module_put(mod);
+	if (ret && probed_mod)
+		module_put(probed_mod);
 	return ret;
 }
 
+int __kprobes register_kprobe(struct kprobe *p)
+{
+	return __register_kprobe(p,
+		(unsigned long)__builtin_return_address(0));
+}
+
 void __kprobes unregister_kprobe(struct kprobe *p)
 {
 	struct module *mod;
@@ -524,7 +543,8 @@
 	up(&kprobe_mutex);
 
 	synchronize_sched();
-	if ((mod = module_text_address((unsigned long)p->addr)))
+	if (p->mod_refcounted &&
+	    (mod = module_text_address((unsigned long)p->addr)))
 		module_put(mod);
 
 	if (cleanup_p) {
@@ -547,7 +567,8 @@
 	jp->kp.pre_handler = setjmp_pre_handler;
 	jp->kp.break_handler = longjmp_break_handler;
 
-	return register_kprobe(&jp->kp);
+	return __register_kprobe(&jp->kp,
+		(unsigned long)__builtin_return_address(0));
 }
 
 void __kprobes unregister_jprobe(struct jprobe *jp)
@@ -587,7 +608,8 @@
 
 	rp->nmissed = 0;
 	/* Establish function entry probe point */
-	if ((ret = register_kprobe(&rp->kp)) != 0)
+	if ((ret = __register_kprobe(&rp->kp,
+		(unsigned long)__builtin_return_address(0))) != 0)
 		free_rp_inst(rp);
 	return ret;
 }
diff --git a/kernel/module.c b/kernel/module.c
index e427604..618ed6e 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -28,6 +28,7 @@
 #include <linux/syscalls.h>
 #include <linux/fcntl.h>
 #include <linux/rcupdate.h>
+#include <linux/capability.h>
 #include <linux/cpu.h>
 #include <linux/moduleparam.h>
 #include <linux/errno.h>
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index cceaf09..5f33cdb 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -7,6 +7,7 @@
  * to continually duplicate across every architecture.
  */
 
+#include <linux/capability.h>
 #include <linux/module.h>
 #include <linux/sched.h>
 #include <linux/errno.h>
diff --git a/kernel/sched.c b/kernel/sched.c
index 34a945b..c0c60c9 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -27,6 +27,7 @@
 #include <linux/smp_lock.h>
 #include <asm/mmu_context.h>
 #include <linux/interrupt.h>
+#include <linux/capability.h>
 #include <linux/completion.h>
 #include <linux/kernel_stat.h>
 #include <linux/security.h>
@@ -3979,12 +3980,12 @@
  * method, such as ACPI for e.g.
  */
 
-cpumask_t cpu_present_map;
+cpumask_t cpu_present_map __read_mostly;
 EXPORT_SYMBOL(cpu_present_map);
 
 #ifndef CONFIG_SMP
-cpumask_t cpu_online_map = CPU_MASK_ALL;
-cpumask_t cpu_possible_map = CPU_MASK_ALL;
+cpumask_t cpu_online_map __read_mostly = CPU_MASK_ALL;
+cpumask_t cpu_possible_map __read_mostly = CPU_MASK_ALL;
 #endif
 
 long sched_getaffinity(pid_t pid, cpumask_t *mask)
diff --git a/kernel/signal.c b/kernel/signal.c
index 08aa5b2..1da2e74 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -25,6 +25,7 @@
 #include <linux/posix-timers.h>
 #include <linux/signal.h>
 #include <linux/audit.h>
+#include <linux/capability.h>
 #include <asm/param.h>
 #include <asm/uaccess.h>
 #include <asm/unistd.h>
diff --git a/kernel/sys.c b/kernel/sys.c
index b6941e0..d09cac2 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -19,6 +19,7 @@
 #include <linux/kernel.h>
 #include <linux/kexec.h>
 #include <linux/workqueue.h>
+#include <linux/capability.h>
 #include <linux/device.h>
 #include <linux/key.h>
 #include <linux/times.h>
@@ -223,6 +224,18 @@
 
 EXPORT_SYMBOL(unregister_reboot_notifier);
 
+#ifndef CONFIG_SECURITY
+int capable(int cap)
+{
+        if (cap_raised(current->cap_effective, cap)) {
+	       current->flags |= PF_SUPERPRIV;
+	       return 1;
+        }
+        return 0;
+}
+EXPORT_SYMBOL(capable);
+#endif
+
 static int set_one_prio(struct task_struct *p, int niceval, int error)
 {
 	int no_nice;
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 03b0598..62d4d95 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -25,6 +25,7 @@
 #include <linux/slab.h>
 #include <linux/sysctl.h>
 #include <linux/proc_fs.h>
+#include <linux/capability.h>
 #include <linux/ctype.h>
 #include <linux/utsname.h>
 #include <linux/capability.h>
diff --git a/kernel/time.c b/kernel/time.c
index 169e832..7477b1d 100644
--- a/kernel/time.c
+++ b/kernel/time.c
@@ -29,6 +29,7 @@
 
 #include <linux/module.h>
 #include <linux/timex.h>
+#include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/smp_lock.h>
 #include <linux/syscalls.h>
diff --git a/kernel/uid16.c b/kernel/uid16.c
index f669941..aa25605 100644
--- a/kernel/uid16.c
+++ b/kernel/uid16.c
@@ -10,6 +10,7 @@
 #include <linux/notifier.h>
 #include <linux/reboot.h>
 #include <linux/prctl.h>
+#include <linux/capability.h>
 #include <linux/init.h>
 #include <linux/highuid.h>
 #include <linux/security.h>
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index 3b48205..0af497b 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -463,7 +463,7 @@
 		 */
 		dma_addr_t handle;
 		handle = swiotlb_map_single(NULL, NULL, size, DMA_FROM_DEVICE);
-		if (dma_mapping_error(handle))
+		if (swiotlb_dma_mapping_error(handle))
 			return NULL;
 
 		ret = phys_to_virt(handle);
diff --git a/mm/filemap.c b/mm/filemap.c
index 96de772..a965b6b 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -15,6 +15,7 @@
 #include <linux/compiler.h>
 #include <linux/fs.h>
 #include <linux/aio.h>
+#include <linux/capability.h>
 #include <linux/kernel_stat.h>
 #include <linux/mm.h>
 #include <linux/swap.h>
diff --git a/mm/mlock.c b/mm/mlock.c
index 4ae3a46..b90c595 100644
--- a/mm/mlock.c
+++ b/mm/mlock.c
@@ -5,6 +5,7 @@
  *  (C) Copyright 2002 Christoph Hellwig
  */
 
+#include <linux/capability.h>
 #include <linux/mman.h>
 #include <linux/mm.h>
 #include <linux/mempolicy.h>
diff --git a/mm/mmap.c b/mm/mmap.c
index 64ba4db..47556d2 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -13,6 +13,7 @@
 #include <linux/pagemap.h>
 #include <linux/swap.h>
 #include <linux/syscalls.h>
+#include <linux/capability.h>
 #include <linux/init.h>
 #include <linux/file.h>
 #include <linux/fs.h>
diff --git a/mm/mremap.c b/mm/mremap.c
index ddaeee9..1903bdf 100644
--- a/mm/mremap.c
+++ b/mm/mremap.c
@@ -13,6 +13,7 @@
 #include <linux/shm.h>
 #include <linux/mman.h>
 #include <linux/swap.h>
+#include <linux/capability.h>
 #include <linux/fs.h>
 #include <linux/highmem.h>
 #include <linux/security.h>
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 8e36353..d41a066 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -137,9 +137,9 @@
 static void bad_page(struct page *page)
 {
 	printk(KERN_EMERG "Bad page state in process '%s'\n"
-		"page:%p flags:0x%0*lx mapping:%p mapcount:%d count:%d\n"
-		"Trying to fix it up, but a reboot is needed\n"
-		"Backtrace:\n",
+		KERN_EMERG "page:%p flags:0x%0*lx mapping:%p mapcount:%d count:%d\n"
+		KERN_EMERG "Trying to fix it up, but a reboot is needed\n"
+		KERN_EMERG "Backtrace:\n",
 		current->comm, page, (int)(2*sizeof(unsigned long)),
 		(unsigned long)page->flags, page->mapping,
 		page_mapcount(page), page_count(page));
@@ -931,7 +931,8 @@
 	 *
 	 * The caller may dip into page reserves a bit more if the caller
 	 * cannot run direct reclaim, or if the caller has realtime scheduling
-	 * policy.
+	 * policy or is asking for __GFP_HIGH memory.  GFP_ATOMIC requests will
+	 * set both ALLOC_HARDER (!wait) and ALLOC_HIGH (__GFP_HIGH).
 	 */
 	alloc_flags = ALLOC_WMARK_MIN;
 	if ((unlikely(rt_task(p)) && !in_interrupt()) || !wait)
diff --git a/mm/swapfile.c b/mm/swapfile.c
index d8a5afc..957fef4 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -25,6 +25,7 @@
 #include <linux/rmap.h>
 #include <linux/security.h>
 #include <linux/backing-dev.h>
+#include <linux/capability.h>
 #include <linux/syscalls.h>
 
 #include <asm/pgtable.h>
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 67465b6..fa76220 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -19,6 +19,7 @@
  */
 
 #include <asm/uaccess.h> /* for copy_from_user */
+#include <linux/capability.h>
 #include <linux/module.h>
 #include <linux/netdevice.h>
 #include <linux/skbuff.h>
diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c
index a5144e4..697ac55e 100644
--- a/net/appletalk/ddp.c
+++ b/net/appletalk/ddp.c
@@ -52,6 +52,7 @@
  */
 
 #include <linux/config.h>
+#include <linux/capability.h>
 #include <linux/module.h>
 #include <linux/if_arp.h>
 #include <linux/termios.h>	/* For TIOCOUTQ/INQ */
diff --git a/net/atm/br2684.c b/net/atm/br2684.c
index 1dafa9c..680ccb1 100644
--- a/net/atm/br2684.c
+++ b/net/atm/br2684.c
@@ -18,6 +18,7 @@
 #include <net/arp.h>
 #include <linux/atm.h>
 #include <linux/atmdev.h>
+#include <linux/capability.h>
 #include <linux/seq_file.h>
 
 #include <linux/atmbr2684.h>
diff --git a/net/atm/clip.c b/net/atm/clip.c
index 4f54c9a..73370de 100644
--- a/net/atm/clip.c
+++ b/net/atm/clip.c
@@ -19,6 +19,7 @@
 #include <linux/atmdev.h>
 #include <linux/atmclip.h>
 #include <linux/atmarp.h>
+#include <linux/capability.h>
 #include <linux/ip.h> /* for net/route.h */
 #include <linux/in.h> /* for struct sockaddr_in */
 #include <linux/if.h> /* for IFF_UP */
diff --git a/net/atm/ioctl.c b/net/atm/ioctl.c
index a150198..eb109af 100644
--- a/net/atm/ioctl.c
+++ b/net/atm/ioctl.c
@@ -12,6 +12,7 @@
 #include <linux/atmdev.h>
 #include <linux/atmclip.h>	/* CLIP_*ENCAP */
 #include <linux/atmarp.h>	/* manifest constants */
+#include <linux/capability.h>
 #include <linux/sonet.h>	/* for ioctls */
 #include <linux/atmsvc.h>
 #include <linux/atmmpc.h>
diff --git a/net/atm/lec.c b/net/atm/lec.c
index eea0513..c4fc722 100644
--- a/net/atm/lec.c
+++ b/net/atm/lec.c
@@ -7,6 +7,7 @@
 #include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/bitops.h>
+#include <linux/capability.h>
 
 /* We are ethernet device */
 #include <linux/if_ether.h>
@@ -1811,8 +1812,7 @@
 {
         struct lec_arp_table *to_return;
 
-        to_return = (struct lec_arp_table *) kmalloc(sizeof(struct lec_arp_table),
-						     GFP_ATOMIC);
+        to_return = kmalloc(sizeof(struct lec_arp_table), GFP_ATOMIC);
         if (!to_return) {
                 printk("LEC: Arp entry kmalloc failed\n");
                 return NULL;
diff --git a/net/atm/mpc.c b/net/atm/mpc.c
index 36b7ae3..c304ef1 100644
--- a/net/atm/mpc.c
+++ b/net/atm/mpc.c
@@ -3,6 +3,7 @@
 #include <linux/timer.h>
 #include <linux/init.h>
 #include <linux/bitops.h>
+#include <linux/capability.h>
 #include <linux/seq_file.h>
 
 /* We are an ethernet device */
diff --git a/net/atm/pppoatm.c b/net/atm/pppoatm.c
index 58f4a2b..1489067 100644
--- a/net/atm/pppoatm.c
+++ b/net/atm/pppoatm.c
@@ -39,6 +39,7 @@
 #include <linux/skbuff.h>
 #include <linux/atm.h>
 #include <linux/atmdev.h>
+#include <linux/capability.h>
 #include <linux/ppp_defs.h>
 #include <linux/if_ppp.h>
 #include <linux/ppp_channel.h>
diff --git a/net/atm/raw.c b/net/atm/raw.c
index 4a0466e..3e57b17 100644
--- a/net/atm/raw.c
+++ b/net/atm/raw.c
@@ -6,6 +6,7 @@
 #include <linux/module.h>
 #include <linux/sched.h>
 #include <linux/atmdev.h>
+#include <linux/capability.h>
 #include <linux/kernel.h>
 #include <linux/skbuff.h>
 #include <linux/mm.h>
diff --git a/net/atm/resources.c b/net/atm/resources.c
index c8c459f..2241905 100644
--- a/net/atm/resources.c
+++ b/net/atm/resources.c
@@ -16,6 +16,7 @@
 #include <linux/kernel.h> /* for barrier */
 #include <linux/module.h>
 #include <linux/bitops.h>
+#include <linux/capability.h>
 #include <linux/delay.h>
 #include <net/sock.h>	 /* for struct sock */
 
diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
index e8753c7..dbf9b47 100644
--- a/net/ax25/af_ax25.c
+++ b/net/ax25/af_ax25.c
@@ -14,6 +14,7 @@
  * Copyright (C) Frederic Rible F1OAT (frible@teaser.fr)
  */
 #include <linux/config.h>
+#include <linux/capability.h>
 #include <linux/module.h>
 #include <linux/errno.h>
 #include <linux/types.h>
diff --git a/net/ax25/ax25_route.c b/net/ax25/ax25_route.c
index b1e945bd..f04f863 100644
--- a/net/ax25/ax25_route.c
+++ b/net/ax25/ax25_route.c
@@ -11,6 +11,8 @@
  * Copyright (C) Hans-Joachim Hetscher DD8NE (dd8ne@bnv-bamberg.de)
  * Copyright (C) Frederic Rible F1OAT (frible@teaser.fr)
  */
+
+#include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/types.h>
 #include <linux/socket.h>
diff --git a/net/ax25/ax25_uid.c b/net/ax25/ax25_uid.c
index d53cc86..b8b5854 100644
--- a/net/ax25/ax25_uid.c
+++ b/net/ax25/ax25_uid.c
@@ -6,6 +6,8 @@
  *
  * Copyright (C) Jonathan Naylor G4KLX (g4klx@g4klx.demon.co.uk)
  */
+
+#include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/types.h>
 #include <linux/socket.h>
diff --git a/net/bluetooth/bnep/sock.c b/net/bluetooth/bnep/sock.c
index ccbaf69..2bfe796 100644
--- a/net/bluetooth/bnep/sock.c
+++ b/net/bluetooth/bnep/sock.c
@@ -32,6 +32,7 @@
 #include <linux/module.h>
 
 #include <linux/types.h>
+#include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
diff --git a/net/bluetooth/cmtp/sock.c b/net/bluetooth/cmtp/sock.c
index 5e22343..8f8fad2 100644
--- a/net/bluetooth/cmtp/sock.c
+++ b/net/bluetooth/cmtp/sock.c
@@ -24,6 +24,7 @@
 #include <linux/module.h>
 
 #include <linux/types.h>
+#include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index 84e6c93..bdb6458 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -28,6 +28,7 @@
 #include <linux/module.h>
 
 #include <linux/types.h>
+#include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
diff --git a/net/bluetooth/hidp/sock.c b/net/bluetooth/hidp/sock.c
index 8f8dd93..b8f6776 100644
--- a/net/bluetooth/hidp/sock.c
+++ b/net/bluetooth/hidp/sock.c
@@ -24,6 +24,7 @@
 #include <linux/module.h>
 
 #include <linux/types.h>
+#include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
index 7f0781e..f6b4a80 100644
--- a/net/bluetooth/l2cap.c
+++ b/net/bluetooth/l2cap.c
@@ -28,6 +28,7 @@
 #include <linux/module.h>
 
 #include <linux/types.h>
+#include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
index f57cde7..74368f7 100644
--- a/net/bluetooth/rfcomm/tty.c
+++ b/net/bluetooth/rfcomm/tty.c
@@ -34,6 +34,7 @@
 #include <linux/tty_driver.h>
 #include <linux/tty_flip.h>
 
+#include <linux/capability.h>
 #include <linux/slab.h>
 #include <linux/skbuff.h>
 
diff --git a/net/bridge/br_ioctl.c b/net/bridge/br_ioctl.c
index b8ce14b..159fb84 100644
--- a/net/bridge/br_ioctl.c
+++ b/net/bridge/br_ioctl.c
@@ -13,6 +13,7 @@
  *	2 of the License, or (at your option) any later version.
  */
 
+#include <linux/capability.h>
 #include <linux/kernel.h>
 #include <linux/if_bridge.h>
 #include <linux/netdevice.h>
diff --git a/net/bridge/br_sysfs_br.c b/net/bridge/br_sysfs_br.c
index 98cf53c..6f577f1 100644
--- a/net/bridge/br_sysfs_br.c
+++ b/net/bridge/br_sysfs_br.c
@@ -11,6 +11,7 @@
  *	2 of the License, or (at your option) any later version.
  */
 
+#include <linux/capability.h>
 #include <linux/kernel.h>
 #include <linux/netdevice.h>
 #include <linux/if_bridge.h>
diff --git a/net/bridge/br_sysfs_if.c b/net/bridge/br_sysfs_if.c
index 2ebdc23..0ac0355 100644
--- a/net/bridge/br_sysfs_if.c
+++ b/net/bridge/br_sysfs_if.c
@@ -11,6 +11,7 @@
  *	2 of the License, or (at your option) any later version.
  */
 
+#include <linux/capability.h>
 #include <linux/kernel.h>
 #include <linux/netdevice.h>
 #include <linux/if_bridge.h>
diff --git a/net/bridge/netfilter/ebt_stp.c b/net/bridge/netfilter/ebt_stp.c
index 9d2ef4f..0248c67 100644
--- a/net/bridge/netfilter/ebt_stp.c
+++ b/net/bridge/netfilter/ebt_stp.c
@@ -10,6 +10,7 @@
 
 #include <linux/netfilter_bridge/ebtables.h>
 #include <linux/netfilter_bridge/ebt_stp.h>
+#include <linux/etherdevice.h>
 #include <linux/module.h>
 
 #define BPDU_TYPE_CONFIG 0
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
index f8ffbf6..00729b3 100644
--- a/net/bridge/netfilter/ebtables.c
+++ b/net/bridge/netfilter/ebtables.c
@@ -944,7 +944,7 @@
 	if (countersize)
 		memset(newinfo->counters, 0, countersize);
 
-	newinfo->entries = (char *)vmalloc(tmp.entries_size);
+	newinfo->entries = vmalloc(tmp.entries_size);
 	if (!newinfo->entries) {
 		ret = -ENOMEM;
 		goto free_newinfo;
@@ -1146,7 +1146,7 @@
 	if (!newinfo)
 		return -ENOMEM;
 
-	newinfo->entries = (char *)vmalloc(table->table->entries_size);
+	newinfo->entries = vmalloc(table->table->entries_size);
 	if (!(newinfo->entries))
 		goto free_newinfo;
 
diff --git a/net/core/dev.c b/net/core/dev.c
index bf66b11..fd070a0 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -75,6 +75,7 @@
 #include <asm/uaccess.h>
 #include <asm/system.h>
 #include <linux/bitops.h>
+#include <linux/capability.h>
 #include <linux/config.h>
 #include <linux/cpu.h>
 #include <linux/types.h>
diff --git a/net/core/dev_mcast.c b/net/core/dev_mcast.c
index cb530ee..05d60850 100644
--- a/net/core/dev_mcast.c
+++ b/net/core/dev_mcast.c
@@ -158,7 +158,7 @@
 	int err = 0;
 	struct dev_mc_list *dmi, *dmi1;
 
-	dmi1 = (struct dev_mc_list *)kmalloc(sizeof(*dmi), GFP_ATOMIC);
+	dmi1 = kmalloc(sizeof(*dmi), GFP_ATOMIC);
 
 	spin_lock_bh(&dev->xmit_lock);
 	for (dmi = dev->mc_list; dmi != NULL; dmi = dmi->next) {
diff --git a/net/core/dv.c b/net/core/dv.c
index c5deb36..cf58140 100644
--- a/net/core/dv.c
+++ b/net/core/dv.c
@@ -24,6 +24,7 @@
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
+#include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/init.h>
 #include <net/dst.h>
@@ -457,7 +458,7 @@
 	unsigned char			*skb_data_end = skb->data + skb->len;
 
 	/* Packet is already aimed at us, return */
-	if (!compare_ether_addr(eth, skb->dev->dev_addr))
+	if (!compare_ether_addr(eth->h_dest, skb->dev->dev_addr))
 		return;
 	
 	/* proto is not IP, do nothing */
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 0350586..e6f7610 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -11,6 +11,7 @@
 
 #include <linux/module.h>
 #include <linux/types.h>
+#include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/ethtool.h>
 #include <linux/netdevice.h>
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 58adaf2..e8b2acb 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -9,6 +9,7 @@
  *	2 of the License, or (at your option) any later version.
  */
 
+#include <linux/capability.h>
 #include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/netdevice.h>
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 631056d..3906312 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -116,13 +116,13 @@
 #include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
-#include <linux/sched.h>
 #include <linux/unistd.h>
 #include <linux/string.h>
 #include <linux/ptrace.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
 #include <linux/interrupt.h>
+#include <linux/capability.h>
 #include <linux/delay.h>
 #include <linux/timer.h>
 #include <linux/init.h>
diff --git a/net/core/scm.c b/net/core/scm.c
index e887d19..649d01e 100644
--- a/net/core/scm.c
+++ b/net/core/scm.c
@@ -11,6 +11,7 @@
 
 #include <linux/module.h>
 #include <linux/signal.h>
+#include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/sched.h>
 #include <linux/mm.h>
diff --git a/net/core/sock.c b/net/core/sock.c
index 6465b0e..6e00811 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -91,6 +91,7 @@
  *		2 of the License, or (at your option) any later version.
  */
 
+#include <linux/capability.h>
 #include <linux/config.h>
 #include <linux/errno.h>
 #include <linux/types.h>
diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
index 78ec534..ce4aaf9 100644
--- a/net/decnet/af_decnet.c
+++ b/net/decnet/af_decnet.c
@@ -122,6 +122,7 @@
 #include <net/flow.h>
 #include <asm/system.h>
 #include <asm/ioctls.h>
+#include <linux/capability.h>
 #include <linux/mm.h>
 #include <linux/interrupt.h>
 #include <linux/proc_fs.h>
diff --git a/net/decnet/dn_dev.c b/net/decnet/dn_dev.c
index 5610bb1..efbead8 100644
--- a/net/decnet/dn_dev.c
+++ b/net/decnet/dn_dev.c
@@ -25,6 +25,7 @@
  */
 
 #include <linux/config.h>
+#include <linux/capability.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/init.h>
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 966a071..97c276f 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -79,6 +79,7 @@
 #include <linux/string.h>
 #include <linux/sockios.h>
 #include <linux/net.h>
+#include <linux/capability.h>
 #include <linux/fcntl.h>
 #include <linux/mm.h>
 #include <linux/interrupt.h>
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index 3743208..accdefe 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -79,6 +79,7 @@
 #include <linux/string.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
+#include <linux/capability.h>
 #include <linux/config.h>
 #include <linux/socket.h>
 #include <linux/sockios.h>
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 7b9bb28..95b9d81 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -32,6 +32,7 @@
 #include <asm/uaccess.h>
 #include <asm/system.h>
 #include <linux/bitops.h>
+#include <linux/capability.h>
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index 18f5e50..5b25fc0 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -20,6 +20,7 @@
 #include <asm/uaccess.h>
 #include <asm/system.h>
 #include <linux/bitops.h>
+#include <linux/capability.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index 3475811..192092b 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -975,7 +975,7 @@
 	 * for deleted items allows change reports to use common code with
 	 * non-deleted or query-response MCA's.
 	 */
-	pmc = (struct ip_mc_list *)kmalloc(sizeof(*pmc), GFP_KERNEL);
+	pmc = kmalloc(sizeof(*pmc), GFP_KERNEL);
 	if (!pmc)
 		return;
 	memset(pmc, 0, sizeof(*pmc));
@@ -1155,7 +1155,7 @@
 		}
 	}
 
-	im = (struct ip_mc_list *)kmalloc(sizeof(*im), GFP_KERNEL);
+	im = kmalloc(sizeof(*im), GFP_KERNEL);
 	if (!im)
 		goto out;
 
@@ -1476,7 +1476,7 @@
 		psf_prev = psf;
 	}
 	if (!psf) {
-		psf = (struct ip_sf_list *)kmalloc(sizeof(*psf), GFP_ATOMIC);
+		psf = kmalloc(sizeof(*psf), GFP_ATOMIC);
 		if (!psf)
 			return -ENOBUFS;
 		memset(psf, 0, sizeof(*psf));
@@ -1659,7 +1659,7 @@
 	err = -ENOBUFS;
 	if (count >= sysctl_igmp_max_memberships)
 		goto done;
-	iml = (struct ip_mc_socklist *)sock_kmalloc(sk,sizeof(*iml),GFP_KERNEL);
+	iml = sock_kmalloc(sk,sizeof(*iml),GFP_KERNEL);
 	if (iml == NULL)
 		goto done;
 
@@ -1823,8 +1823,7 @@
 
 		if (psl)
 			count += psl->sl_max;
-		newpsl = (struct ip_sf_socklist *)sock_kmalloc(sk,
-			IP_SFLSIZE(count), GFP_KERNEL);
+		newpsl = sock_kmalloc(sk, IP_SFLSIZE(count), GFP_KERNEL);
 		if (!newpsl) {
 			err = -ENOBUFS;
 			goto done;
@@ -1907,8 +1906,8 @@
 		goto done;
 	}
 	if (msf->imsf_numsrc) {
-		newpsl = (struct ip_sf_socklist *)sock_kmalloc(sk,
-				IP_SFLSIZE(msf->imsf_numsrc), GFP_KERNEL);
+		newpsl = sock_kmalloc(sk, IP_SFLSIZE(msf->imsf_numsrc),
+							   GFP_KERNEL);
 		if (!newpsl) {
 			err = -ENOBUFS;
 			goto done;
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 1e93eaf..abe2392 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -10,6 +10,7 @@
  *
  */
 
+#include <linux/capability.h>
 #include <linux/config.h>
 #include <linux/module.h>
 #include <linux/types.h>
diff --git a/net/ipv4/ip_options.c b/net/ipv4/ip_options.c
index d3f6c46..9bebad0 100644
--- a/net/ipv4/ip_options.c
+++ b/net/ipv4/ip_options.c
@@ -11,6 +11,7 @@
  *		
  */
 
+#include <linux/capability.h>
 #include <linux/module.h>
 #include <linux/types.h>
 #include <asm/uaccess.h>
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index 6986e11..2bf8d78 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -621,7 +621,7 @@
 				err = -ENOBUFS;
 				break;
 			}
-			msf = (struct ip_msfilter *)kmalloc(optlen, GFP_KERNEL);
+			msf = kmalloc(optlen, GFP_KERNEL);
 			if (msf == 0) {
 				err = -ENOBUFS;
 				break;
@@ -778,7 +778,7 @@
 				err = -ENOBUFS;
 				break;
 			}
-			gsf = (struct group_filter *)kmalloc(optlen,GFP_KERNEL);
+			gsf = kmalloc(optlen,GFP_KERNEL);
 			if (gsf == 0) {
 				err = -ENOBUFS;
 				break;
@@ -798,7 +798,7 @@
 				goto mc_msf_out;
 			}
 			msize = IP_MSFILTER_SIZE(gsf->gf_numsrc);
-			msf = (struct ip_msfilter *)kmalloc(msize,GFP_KERNEL);
+			msf = kmalloc(msize,GFP_KERNEL);
 			if (msf == 0) {
 				err = -ENOBUFS;
 				goto mc_msf_out;
diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
index bc5ca23..e5cbe72 100644
--- a/net/ipv4/ipip.c
+++ b/net/ipv4/ipip.c
@@ -93,6 +93,7 @@
  */
 
  
+#include <linux/capability.h>
 #include <linux/config.h>
 #include <linux/module.h>
 #include <linux/types.h>
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index f58ac98..5c94c22 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -33,6 +33,7 @@
 #include <asm/uaccess.h>
 #include <linux/types.h>
 #include <linux/sched.h>
+#include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/timer.h>
 #include <linux/mm.h>
diff --git a/net/ipv4/ipvs/ip_vs_ctl.c b/net/ipv4/ipvs/ip_vs_ctl.c
index c935c50..7f0288b 100644
--- a/net/ipv4/ipvs/ip_vs_ctl.c
+++ b/net/ipv4/ipvs/ip_vs_ctl.c
@@ -23,6 +23,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/types.h>
+#include <linux/capability.h>
 #include <linux/fs.h>
 #include <linux/sysctl.h>
 #include <linux/proc_fs.h>
diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
index bba1563..b6d5284 100644
--- a/net/ipv4/netfilter/arp_tables.c
+++ b/net/ipv4/netfilter/arp_tables.c
@@ -13,6 +13,7 @@
 #include <linux/kernel.h>
 #include <linux/skbuff.h>
 #include <linux/netdevice.h>
+#include <linux/capability.h>
 #include <linux/if_arp.h>
 #include <linux/kmod.h>
 #include <linux/vmalloc.h>
diff --git a/net/ipv4/netfilter/ip_conntrack_helper_pptp.c b/net/ipv4/netfilter/ip_conntrack_helper_pptp.c
index 4108a5e..d716bba 100644
--- a/net/ipv4/netfilter/ip_conntrack_helper_pptp.c
+++ b/net/ipv4/netfilter/ip_conntrack_helper_pptp.c
@@ -762,7 +762,7 @@
 	.help = conntrack_pptp_help
 };
 
-extern void __exit ip_ct_proto_gre_fini(void);
+extern void ip_ct_proto_gre_fini(void);
 extern int __init ip_ct_proto_gre_init(void);
 
 /* ip_conntrack_pptp initialization */
diff --git a/net/ipv4/netfilter/ip_conntrack_proto_gre.c b/net/ipv4/netfilter/ip_conntrack_proto_gre.c
index 57956de..c777abf 100644
--- a/net/ipv4/netfilter/ip_conntrack_proto_gre.c
+++ b/net/ipv4/netfilter/ip_conntrack_proto_gre.c
@@ -309,7 +309,10 @@
 	return ip_conntrack_protocol_register(&gre);
 }
 
-void __exit ip_ct_proto_gre_fini(void)
+/* This cannot be __exit, as it is invoked from ip_conntrack_helper_pptp.c's
+ * init() code on errors.
+ */
+void ip_ct_proto_gre_fini(void)
 {
 	struct list_head *pos, *n;
 
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
index 2a26d16..877bc96 100644
--- a/net/ipv4/netfilter/ip_tables.c
+++ b/net/ipv4/netfilter/ip_tables.c
@@ -14,6 +14,7 @@
  */
 #include <linux/config.h>
 #include <linux/cache.h>
+#include <linux/capability.h>
 #include <linux/skbuff.h>
 #include <linux/kmod.h>
 #include <linux/vmalloc.h>
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index e53e421..7129d42 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -58,6 +58,7 @@
 #ifdef CONFIG_SYSCTL
 #include <linux/sysctl.h>
 #endif
+#include <linux/capability.h>
 #include <linux/delay.h>
 #include <linux/notifier.h>
 #include <linux/string.h>
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index 25c3fe5..064ffab 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -22,6 +22,7 @@
 
 
 #include <linux/module.h>
+#include <linux/capability.h>
 #include <linux/config.h>
 #include <linux/errno.h>
 #include <linux/types.h>
diff --git a/net/ipv6/anycast.c b/net/ipv6/anycast.c
index 6b72940..65e73ac 100644
--- a/net/ipv6/anycast.c
+++ b/net/ipv6/anycast.c
@@ -13,6 +13,7 @@
  *      2 of the License, or (at your option) any later version.
  */
 
+#include <linux/capability.h>
 #include <linux/config.h>
 #include <linux/module.h>
 #include <linux/errno.h>
diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
index c4a3a99..99a6eb2 100644
--- a/net/ipv6/datagram.c
+++ b/net/ipv6/datagram.c
@@ -13,6 +13,7 @@
  *      2 of the License, or (at your option) any later version.
  */
 
+#include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c
index 89d12b4..964ad9d 100644
--- a/net/ipv6/ip6_flowlabel.c
+++ b/net/ipv6/ip6_flowlabel.c
@@ -9,6 +9,7 @@
  *	Authors:	Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
  */
 
+#include <linux/capability.h>
 #include <linux/config.h>
 #include <linux/errno.h>
 #include <linux/types.h>
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index c3c2bf6..92ead3c 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -21,6 +21,7 @@
 
 #include <linux/config.h>
 #include <linux/module.h>
+#include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/types.h>
 #include <linux/sockios.h>
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index c63868d..f7142ba 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -26,6 +26,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/capability.h>
 #include <linux/config.h>
 #include <linux/errno.h>
 #include <linux/types.h>
@@ -549,7 +550,7 @@
 			retv = -ENOBUFS;
 			break;
 		}
-		gsf = (struct group_filter *)kmalloc(optlen,GFP_KERNEL);
+		gsf = kmalloc(optlen,GFP_KERNEL);
 		if (gsf == 0) {
 			retv = -ENOBUFS;
 			break;
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index 1cf305a..cc3e9f5 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -449,8 +449,7 @@
 
 		if (psl)
 			count += psl->sl_max;
-		newpsl = (struct ip6_sf_socklist *)sock_kmalloc(sk,
-			IP6_SFLSIZE(count), GFP_ATOMIC);
+		newpsl = sock_kmalloc(sk, IP6_SFLSIZE(count), GFP_ATOMIC);
 		if (!newpsl) {
 			err = -ENOBUFS;
 			goto done;
@@ -535,8 +534,8 @@
 		goto done;
 	}
 	if (gsf->gf_numsrc) {
-		newpsl = (struct ip6_sf_socklist *)sock_kmalloc(sk,
-				IP6_SFLSIZE(gsf->gf_numsrc), GFP_ATOMIC);
+		newpsl = sock_kmalloc(sk, IP6_SFLSIZE(gsf->gf_numsrc),
+							  GFP_ATOMIC);
 		if (!newpsl) {
 			err = -ENOBUFS;
 			goto done;
@@ -768,7 +767,7 @@
 	 * for deleted items allows change reports to use common code with
 	 * non-deleted or query-response MCA's.
 	 */
-	pmc = (struct ifmcaddr6 *)kmalloc(sizeof(*pmc), GFP_ATOMIC);
+	pmc = kmalloc(sizeof(*pmc), GFP_ATOMIC);
 	if (!pmc)
 		return;
 	memset(pmc, 0, sizeof(*pmc));
@@ -1937,7 +1936,7 @@
 		psf_prev = psf;
 	}
 	if (!psf) {
-		psf = (struct ip6_sf_list *)kmalloc(sizeof(*psf), GFP_ATOMIC);
+		psf = kmalloc(sizeof(*psf), GFP_ATOMIC);
 		if (!psf)
 			return -ENOBUFS;
 		memset(psf, 0, sizeof(*psf));
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
index 925b42d4..1390370 100644
--- a/net/ipv6/netfilter/ip6_tables.c
+++ b/net/ipv6/netfilter/ip6_tables.c
@@ -14,6 +14,8 @@
  * 06 Jun 2002 Andras Kis-Szabo <kisza@sch.bme.hu>
  *      - new extension header parser code
  */
+
+#include <linux/capability.h>
 #include <linux/config.h>
 #include <linux/in.h>
 #include <linux/skbuff.h>
diff --git a/net/ipv6/netfilter/ip6t_mac.c b/net/ipv6/netfilter/ip6t_mac.c
index ae0b092..c848152 100644
--- a/net/ipv6/netfilter/ip6t_mac.c
+++ b/net/ipv6/netfilter/ip6t_mac.c
@@ -11,6 +11,7 @@
 #include <linux/module.h>
 #include <linux/skbuff.h>
 #include <linux/if_ether.h>
+#include <linux/etherdevice.h>
 
 #include <linux/netfilter_ipv6/ip6t_mac.h>
 #include <linux/netfilter_ipv6/ip6_tables.h>
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 66140f1..e0d3ad0 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -24,6 +24,7 @@
  *		reachable.  otherwise, round-robin the list.
  */
 
+#include <linux/capability.h>
 #include <linux/config.h>
 #include <linux/errno.h>
 #include <linux/types.h>
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 0dae48a..c2d3e17 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -20,6 +20,7 @@
 
 #include <linux/config.h>
 #include <linux/module.h>
+#include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/types.h>
 #include <linux/socket.h>
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index a25f4e8..66d0400 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -67,6 +67,9 @@
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 
+/* Socket used for sending RSTs and ACKs */
+static struct socket *tcp6_socket;
+
 static void	tcp_v6_send_reset(struct sk_buff *skb);
 static void	tcp_v6_reqsk_send_ack(struct sk_buff *skb, struct request_sock *req);
 static void	tcp_v6_send_check(struct sock *sk, int len, 
@@ -611,7 +614,7 @@
 	if (!ip6_dst_lookup(NULL, &buff->dst, &fl)) {
 
 		if (xfrm_lookup(&buff->dst, &fl, NULL, 0) >= 0) {
-			ip6_xmit(NULL, buff, &fl, NULL, 0);
+			ip6_xmit(tcp6_socket->sk, buff, &fl, NULL, 0);
 			TCP_INC_STATS_BH(TCP_MIB_OUTSEGS);
 			TCP_INC_STATS_BH(TCP_MIB_OUTRSTS);
 			return;
@@ -675,7 +678,7 @@
 
 	if (!ip6_dst_lookup(NULL, &buff->dst, &fl)) {
 		if (xfrm_lookup(&buff->dst, &fl, NULL, 0) >= 0) {
-			ip6_xmit(NULL, buff, &fl, NULL, 0);
+			ip6_xmit(tcp6_socket->sk, buff, &fl, NULL, 0);
 			TCP_INC_STATS_BH(TCP_MIB_OUTSEGS);
 			return;
 		}
@@ -1600,8 +1603,21 @@
 
 void __init tcpv6_init(void)
 {
+	int err;
+
 	/* register inet6 protocol */
 	if (inet6_add_protocol(&tcpv6_protocol, IPPROTO_TCP) < 0)
 		printk(KERN_ERR "tcpv6_init: Could not register protocol\n");
 	inet6_register_protosw(&tcpv6_protosw);
+
+	err = sock_create_kern(PF_INET6, SOCK_RAW, IPPROTO_TCP, &tcp6_socket);
+	if (err < 0)
+		panic("Failed to create the TCPv6 control socket.\n");
+	tcp6_socket->sk->sk_allocation = GFP_ATOMIC;
+
+	/* Unhash it so that IP input processing does not even
+	 * see it, we do not wish this socket to see incoming
+	 * packets.
+	 */
+	tcp6_socket->sk->sk_prot->unhash(tcp6_socket->sk);
 }
diff --git a/net/ipx/af_ipx.c b/net/ipx/af_ipx.c
index 0dc519b..0fb513a 100644
--- a/net/ipx/af_ipx.c
+++ b/net/ipx/af_ipx.c
@@ -29,6 +29,7 @@
  */
 
 #include <linux/config.h>
+#include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/if_arp.h>
 #include <linux/if_ether.h>
diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c
index fbfa967..7594456 100644
--- a/net/irda/af_irda.c
+++ b/net/irda/af_irda.c
@@ -43,6 +43,7 @@
  ********************************************************************/
 
 #include <linux/config.h>
+#include <linux/capability.h>
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/socket.h>
diff --git a/net/irda/irda_device.c b/net/irda/irda_device.c
index 70543d8..890bac0 100644
--- a/net/irda/irda_device.c
+++ b/net/irda/irda_device.c
@@ -33,6 +33,7 @@
 #include <linux/string.h>
 #include <linux/proc_fs.h>
 #include <linux/skbuff.h>
+#include <linux/capability.h>
 #include <linux/if.h>
 #include <linux/if_ether.h>
 #include <linux/if_arp.h>
diff --git a/net/irda/irias_object.c b/net/irda/irias_object.c
index 75f2666..c6d169f 100644
--- a/net/irda/irias_object.c
+++ b/net/irda/irias_object.c
@@ -82,8 +82,7 @@
 
 	IRDA_DEBUG( 4, "%s()\n", __FUNCTION__);
 
-	obj = (struct ias_object *) kmalloc(sizeof(struct ias_object),
-					    GFP_ATOMIC);
+	obj = kmalloc(sizeof(struct ias_object), GFP_ATOMIC);
 	if (obj == NULL) {
 		IRDA_WARNING("%s(), Unable to allocate object!\n",
 			     __FUNCTION__);
@@ -348,8 +347,7 @@
 	IRDA_ASSERT(obj->magic == IAS_OBJECT_MAGIC, return;);
 	IRDA_ASSERT(name != NULL, return;);
 
-	attrib = (struct ias_attrib *) kmalloc(sizeof(struct ias_attrib),
-					       GFP_ATOMIC);
+	attrib = kmalloc(sizeof(struct ias_attrib), GFP_ATOMIC);
 	if (attrib == NULL) {
 		IRDA_WARNING("%s: Unable to allocate attribute!\n",
 			     __FUNCTION__);
@@ -385,8 +383,7 @@
 	IRDA_ASSERT(name != NULL, return;);
 	IRDA_ASSERT(octets != NULL, return;);
 
-	attrib = (struct ias_attrib *) kmalloc(sizeof(struct ias_attrib),
-					       GFP_ATOMIC);
+	attrib = kmalloc(sizeof(struct ias_attrib), GFP_ATOMIC);
 	if (attrib == NULL) {
 		IRDA_WARNING("%s: Unable to allocate attribute!\n",
 			     __FUNCTION__);
@@ -420,8 +417,7 @@
 	IRDA_ASSERT(name != NULL, return;);
 	IRDA_ASSERT(value != NULL, return;);
 
-	attrib = (struct ias_attrib *) kmalloc(sizeof( struct ias_attrib),
-					       GFP_ATOMIC);
+	attrib = kmalloc(sizeof( struct ias_attrib), GFP_ATOMIC);
 	if (attrib == NULL) {
 		IRDA_WARNING("%s: Unable to allocate attribute!\n",
 			     __FUNCTION__);
diff --git a/net/irda/irnet/irnet.h b/net/irda/irnet/irnet.h
index b391cb3..e4fe1e8 100644
--- a/net/irda/irnet/irnet.h
+++ b/net/irda/irnet/irnet.h
@@ -248,6 +248,7 @@
 #include <linux/netdevice.h>
 #include <linux/miscdevice.h>
 #include <linux/poll.h>
+#include <linux/capability.h>
 #include <linux/config.h>
 #include <linux/ctype.h>	/* isspace() */
 #include <asm/uaccess.h>
diff --git a/net/key/af_key.c b/net/key/af_key.c
index 4c2f6d6..43f1ce7 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -15,6 +15,7 @@
  */
 
 #include <linux/config.h>
+#include <linux/capability.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/socket.h>
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index bb50c8a..2101b45 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -24,6 +24,7 @@
 #include <linux/config.h>
 #include <linux/module.h>
 
+#include <linux/capability.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/signal.h>
diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
index 63b0e4a..d44981f 100644
--- a/net/netrom/af_netrom.c
+++ b/net/netrom/af_netrom.c
@@ -11,6 +11,7 @@
 #include <linux/config.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
+#include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/types.h>
 #include <linux/socket.h>
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index f69e5ed..ee93abc 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -53,6 +53,7 @@
 #include <linux/types.h>
 #include <linux/sched.h>
 #include <linux/mm.h>
+#include <linux/capability.h>
 #include <linux/fcntl.h>
 #include <linux/socket.h>
 #include <linux/in.h>
@@ -1237,7 +1238,7 @@
 		goto done;
 
 	err = -ENOBUFS;
-	i = (struct packet_mclist *)kmalloc(sizeof(*i), GFP_KERNEL);
+	i = kmalloc(sizeof(*i), GFP_KERNEL);
 	if (i == NULL)
 		goto done;
 
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c
index 63090be..ea65396 100644
--- a/net/rose/af_rose.c
+++ b/net/rose/af_rose.c
@@ -9,7 +9,9 @@
  * Copyright (C) Terry Dawson VK2KTJ (terry@animats.net)
  * Copyright (C) Tomi Manninen OH2BNS (oh2bns@sral.fi)
  */
+
 #include <linux/config.h>
+#include <linux/capability.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/init.h>
diff --git a/net/sched/Kconfig b/net/sched/Kconfig
index 55cd532..8a260d4 100644
--- a/net/sched/Kconfig
+++ b/net/sched/Kconfig
@@ -411,7 +411,7 @@
 	tristate "Metadata"
 	depends on NET_EMATCH
 	---help---
-	  Say Y here if you want to be ablt to classify packets based on
+	  Say Y here if you want to be able to classify packets based on
 	  metadata such as load average, netfilter attributes, socket
 	  attributes and routing decisions.
 
diff --git a/net/sched/ematch.c b/net/sched/ematch.c
index 64b047c..5cb956b 100644
--- a/net/sched/ematch.c
+++ b/net/sched/ematch.c
@@ -92,7 +92,6 @@
 #include <linux/rtnetlink.h>
 #include <linux/skbuff.h>
 #include <net/pkt_cls.h>
-#include <config/net/ematch/stack.h>
 
 static LIST_HEAD(ematch_ops);
 static DEFINE_RWLOCK(ematch_mod_lock);
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index f9573eb..556c495 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -1287,7 +1287,7 @@
 			- (bodysize % SCTP_COOKIE_MULTIPLE);
 	*cookie_len = headersize + bodysize;
 
-	retval = (sctp_cookie_param_t *)kmalloc(*cookie_len, GFP_ATOMIC);
+	retval = kmalloc(*cookie_len, GFP_ATOMIC);
 
 	if (!retval) {
 		*cookie_len = 0;
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index fc04d18..c98ee37 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -63,6 +63,7 @@
 #include <linux/wait.h>
 #include <linux/time.h>
 #include <linux/ip.h>
+#include <linux/capability.h>
 #include <linux/fcntl.h>
 #include <linux/poll.h>
 #include <linux/init.h>
@@ -860,7 +861,7 @@
 		return -EFAULT;
 
 	/* Alloc space for the address array in kernel memory.  */
-	kaddrs = (struct sockaddr *)kmalloc(addrs_size, GFP_KERNEL);
+	kaddrs = kmalloc(addrs_size, GFP_KERNEL);
 	if (unlikely(!kaddrs))
 		return -ENOMEM;
 
@@ -1150,7 +1151,7 @@
 		return -EFAULT;
 
 	/* Alloc space for the address array in kernel memory.  */
-	kaddrs = (struct sockaddr *)kmalloc(addrs_size, GFP_KERNEL);
+	kaddrs = kmalloc(addrs_size, GFP_KERNEL);
 	if (unlikely(!kaddrs))
 		return -ENOMEM;
 
diff --git a/net/socket.c b/net/socket.c
index 06fa217..b38a263 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -993,7 +993,7 @@
 
 	if (on)
 	{
-		fna=(struct fasync_struct *)kmalloc(sizeof(struct fasync_struct), GFP_KERNEL);
+		fna = kmalloc(sizeof(struct fasync_struct), GFP_KERNEL);
 		if(fna==NULL)
 			return -ENOMEM;
 	}
diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c
index 8c77560..9ac1b8c2 100644
--- a/net/sunrpc/auth.c
+++ b/net/sunrpc/auth.c
@@ -94,7 +94,7 @@
 	struct rpc_cred_cache *new;
 	int i;
 
-	new = (struct rpc_cred_cache *)kmalloc(sizeof(*new), GFP_KERNEL);
+	new = kmalloc(sizeof(*new), GFP_KERNEL);
 	if (!new)
 		return -ENOMEM;
 	for (i = 0; i < RPC_CREDCACHE_NR; i++)
diff --git a/net/sunrpc/auth_unix.c b/net/sunrpc/auth_unix.c
index 890fb5e..1b3ed4f 100644
--- a/net/sunrpc/auth_unix.c
+++ b/net/sunrpc/auth_unix.c
@@ -70,7 +70,7 @@
 	dprintk("RPC:      allocating UNIX cred for uid %d gid %d\n",
 				acred->uid, acred->gid);
 
-	if (!(cred = (struct unx_cred *) kmalloc(sizeof(*cred), GFP_KERNEL)))
+	if (!(cred = kmalloc(sizeof(*cred), GFP_KERNEL)))
 		return ERR_PTR(-ENOMEM);
 
 	atomic_set(&cred->uc_count, 1);
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 4cef7fa..d2f0550 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -118,7 +118,7 @@
 		goto out_err;
 
 	err = -ENOMEM;
-	clnt = (struct rpc_clnt *) kmalloc(sizeof(*clnt), GFP_KERNEL);
+	clnt = kmalloc(sizeof(*clnt), GFP_KERNEL);
 	if (!clnt)
 		goto out_err;
 	memset(clnt, 0, sizeof(*clnt));
@@ -225,7 +225,7 @@
 {
 	struct rpc_clnt *new;
 
-	new = (struct rpc_clnt *)kmalloc(sizeof(*new), GFP_KERNEL);
+	new = kmalloc(sizeof(*new), GFP_KERNEL);
 	if (!new)
 		goto out_no_clnt;
 	memcpy(new, clnt, sizeof(*new));
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index a8bd34d..b08419e 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -32,7 +32,7 @@
 	int vers;
 	unsigned int xdrsize;
 
-	if (!(serv = (struct svc_serv *) kmalloc(sizeof(*serv), GFP_KERNEL)))
+	if (!(serv = kmalloc(sizeof(*serv), GFP_KERNEL)))
 		return NULL;
 	memset(serv, 0, sizeof(*serv));
 	serv->sv_name      = prog->pg_name;
diff --git a/net/wanrouter/af_wanpipe.c b/net/wanrouter/af_wanpipe.c
index 7a43ae4..8b9bf4a 100644
--- a/net/wanrouter/af_wanpipe.c
+++ b/net/wanrouter/af_wanpipe.c
@@ -36,6 +36,7 @@
 #include <linux/types.h>
 #include <linux/sched.h>
 #include <linux/mm.h>
+#include <linux/capability.h>
 #include <linux/fcntl.h>
 #include <linux/socket.h>
 #include <linux/in.h>
diff --git a/net/wanrouter/wanmain.c b/net/wanrouter/wanmain.c
index bcf7b3f..c34833d 100644
--- a/net/wanrouter/wanmain.c
+++ b/net/wanrouter/wanmain.c
@@ -44,6 +44,7 @@
 
 #include <linux/config.h>
 #include <linux/stddef.h>	/* offsetof(), etc. */
+#include <linux/capability.h>
 #include <linux/errno.h>	/* return codes */
 #include <linux/kernel.h>
 #include <linux/init.h>
diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c
index bfabaf9..72b6ff3 100644
--- a/net/x25/af_x25.c
+++ b/net/x25/af_x25.c
@@ -37,6 +37,7 @@
 
 #include <linux/config.h>
 #include <linux/module.h>
+#include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
diff --git a/security/commoncap.c b/security/commoncap.c
index 04c12f5..8a6e097 100644
--- a/security/commoncap.c
+++ b/security/commoncap.c
@@ -7,6 +7,7 @@
  *
  */
 
+#include <linux/capability.h>
 #include <linux/config.h>
 #include <linux/module.h>
 #include <linux/init.h>
diff --git a/security/dummy.c b/security/dummy.c
index a15c547..f1a5bd9 100644
--- a/security/dummy.c
+++ b/security/dummy.c
@@ -14,6 +14,7 @@
 
 #undef DEBUG
 
+#include <linux/capability.h>
 #include <linux/config.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
index 3d2ebae..90db5c7 100644
--- a/security/keys/keyctl.c
+++ b/security/keys/keyctl.c
@@ -16,6 +16,7 @@
 #include <linux/syscalls.h>
 #include <linux/keyctl.h>
 #include <linux/fs.h>
+#include <linux/capability.h>
 #include <linux/err.h>
 #include <asm/uaccess.h>
 #include "internal.h"
diff --git a/security/security.c b/security/security.c
index ed5fb80..f693e1f 100644
--- a/security/security.c
+++ b/security/security.c
@@ -11,6 +11,7 @@
  *	(at your option) any later version.
  */
 
+#include <linux/capability.h>
 #include <linux/config.h>
 #include <linux/module.h>
 #include <linux/init.h>
diff --git a/sound/oss/i810_audio.c b/sound/oss/i810_audio.c
index 4600cd6..abc242a 100644
--- a/sound/oss/i810_audio.c
+++ b/sound/oss/i810_audio.c
@@ -312,7 +312,8 @@
 	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, INTELICH4},
 	{PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_18,
 	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, INTELICH4},
-
+	{PCI_VENDOR_ID_NVIDIA,  PCI_DEVICE_ID_NVIDIA_CK804_AUDIO,
+	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, NVIDIA_NFORCE},
 	{0,}
 };
 
@@ -3427,7 +3428,6 @@
 		release_mem_region(card->ac97base_mmio_phys, 512);
 		release_mem_region(card->iobase_mmio_phys, 256);
 	}
-out_pio:	
 	release_region(card->ac97base, 256);
 out_region2:
 	release_region(card->iobase, 64);
diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c
index 1a90339..5098372 100644
--- a/sound/pci/emu10k1/emufx.c
+++ b/sound/pci/emu10k1/emufx.c
@@ -27,6 +27,7 @@
 
 #include <sound/driver.h>
 #include <linux/pci.h>
+#include <linux/capability.h>
 #include <linux/delay.h>
 #include <linux/slab.h>
 #include <linux/vmalloc.h>