## Automatically generated incremental diff
## From:   linux-2.2.19-pre7
## To:     linux-2.2.19-pre8
## Robot:  $Id: make-incremental-diff,v 1.6 2001/12/04 04:41:15 hpa Exp $

diff -urN linux-2.2.19-pre7/CREDITS linux/CREDITS
--- linux-2.2.19-pre7/CREDITS	Mon Dec  3 20:58:26 2001
+++ linux/CREDITS	Mon Dec  3 20:58:53 2001
@@ -521,13 +521,9 @@
 S: Belgium
 
 N: Cort Dougan
-E: cort@cs.nmt.edu
-W: http://www.cs.nmt.edu/~cort/
+E: cort@fsmlabs.com
+W: http://www.fsmlabs.com/linuxppcbk.html
 D: PowerPC
-S: Computer Science Department
-S: New Mexico Tech
-S: Socorro, New Mexico 87801
-S: USA
 
 N: Oleg Drokin
 E: green@ccssu.crimea.ua
diff -urN linux-2.2.19-pre7/Documentation/Configure.help linux/Documentation/Configure.help
--- linux-2.2.19-pre7/Documentation/Configure.help	Mon Dec  3 20:58:26 2001
+++ linux/Documentation/Configure.help	Mon Dec  3 20:58:53 2001
@@ -6232,6 +6232,37 @@
   say M here and read Documentation/modules.txt. This is recommended.
   The module will be called rtl8139.o.
 
+Alternative RealTek 8139 driver (8139too) support
+CONFIG_RTL8139TOO
+  This is a sophisticated, multi platform driver for RealTek 8139x
+  based Fast Ethernet cards. It tries to work around several not
+  well documented hardware bugs in these chips and is also
+  usually faster than the original driver. However, 8129 is not
+  supported.
+  If you are sure you have a RTL8139-based card, choose this driver.
+  You can find more information in the Ethernet-HOWTO, available by
+  anonymous FTP from ftp://metalab.unc.edu/pub/Linux/docs/HOWTO .
+
+  If you want to compile this driver as a module ( = code which can be
+  inserted in and removed from the running kernel whenever you want),
+  say M here and read Documentation/modules.txt. This is recommended.
+  The module will be called rtl8139too.o .
+
+Use PIO instead of MMIO
+CONFIG_8139TOO_PIO
+  This instructs the driver to use PIO (only on i386 architecture)
+  instead of memory mapped IO. This can possibly solve some problems
+  in case your mainboard has memory consistency issues. If unsure,
+  say n.
+
+Support for automatic channel equalization
+CONFIG_8139TOO_TUNE_TWISTER
+  This implements a function which might come in handy in case
+  you are using low quality on long cabling. It tries to match
+  the transceiver to the cable characteristics. This is experimental
+  since hardly documented by the manufacturer.
+  If unsure, say n.
+
 SiS 900/7016 support
 CONFIG_SIS900
   This is a driver for the Fast Ethernet PCI network cards based on
diff -urN linux-2.2.19-pre7/Documentation/powerpc/00-INDEX linux/Documentation/powerpc/00-INDEX
--- linux-2.2.19-pre7/Documentation/powerpc/00-INDEX	Sat Oct 10 09:53:24 1998
+++ linux/Documentation/powerpc/00-INDEX	Mon Dec  3 20:58:53 2001
@@ -1,7 +1,7 @@
 Index of files in Documentation/powerpc.  If you think something about
 Linux/PPC needs an entry here, needs correction or you've written one
 please mail me.
-                                        Cort Dougan (cort@cs.nmt.edu)
+                                        Cort Dougan (cort@fsmlabs.com)
 
 00-INDEX
 	- this file
diff -urN linux-2.2.19-pre7/Documentation/powerpc/ppc_htab.txt linux/Documentation/powerpc/ppc_htab.txt
--- linux-2.2.19-pre7/Documentation/powerpc/ppc_htab.txt	Wed Mar 10 21:49:10 1999
+++ linux/Documentation/powerpc/ppc_htab.txt	Mon Dec  3 20:58:53 2001
@@ -2,7 +2,7 @@
 =====================================================================
 
 This document and the related code was written by me (Cort Dougan), please
-email me (cort@cs.nmt.edu) if you have questions, comments or corrections.
+email me (cort@fsmlabs.com) if you have questions, comments or corrections.
 
 Last Change: 2.16.98
 
diff -urN linux-2.2.19-pre7/Documentation/powerpc/smp.txt linux/Documentation/powerpc/smp.txt
--- linux-2.2.19-pre7/Documentation/powerpc/smp.txt	Thu Apr 29 12:39:07 1999
+++ linux/Documentation/powerpc/smp.txt	Mon Dec  3 20:58:53 2001
@@ -2,7 +2,7 @@
 =====================================================================
 
 This document and the related code was written by me
-(Cort Dougan, cort@cs.nmt.edu) please email me if you have questions,
+(Cort Dougan, cort@fsmlabs.com) please email me if you have questions,
 comments or corrections.
 
 Last Change: 3.31.99
diff -urN linux-2.2.19-pre7/Documentation/powerpc/sound.txt linux/Documentation/powerpc/sound.txt
--- linux-2.2.19-pre7/Documentation/powerpc/sound.txt	Mon Aug  9 12:04:57 1999
+++ linux/Documentation/powerpc/sound.txt	Mon Dec  3 20:58:53 2001
@@ -1,7 +1,7 @@
             Information about PowerPC Sound support
 =====================================================================
 
-Please mail me (Cort Dougan, cort@cs.nmt.edu) if you have questions,
+Please mail me (Cort Dougan, cort@fsmlabs.com) if you have questions,
 comments or corrections.
 
 Last Change: 6.16.99
diff -urN linux-2.2.19-pre7/Documentation/powerpc/zImage_layout.txt linux/Documentation/powerpc/zImage_layout.txt
--- linux-2.2.19-pre7/Documentation/powerpc/zImage_layout.txt	Sat Oct 10 09:53:24 1998
+++ linux/Documentation/powerpc/zImage_layout.txt	Mon Dec  3 20:58:53 2001
@@ -1,7 +1,7 @@
           Information about the Linux/PPC kernel images
 =====================================================================
 
-Please mail me me (Cort Dougan, cort@cs.nmt.edu) if you have questions,
+Please mail me me (Cort Dougan, cort@fsmlabs.com) if you have questions,
 comments or corrections.
 
 This document is meant to answer several questions I've had about how
diff -urN linux-2.2.19-pre7/MAINTAINERS linux/MAINTAINERS
--- linux-2.2.19-pre7/MAINTAINERS	Mon Dec  3 20:58:26 2001
+++ linux/MAINTAINERS	Mon Dec  3 20:58:53 2001
@@ -87,6 +87,12 @@
 L:	linux-hams@vger.kernel.org
 S:	Maintained
 
+8139too NETWORK DRIVER
+P:	Jeff Garzik, Jens David (Linux-2.2 port)
+M:	dg1kjd@afthd.tu-darmstadt.de
+L:	linux-net@vger.rutgers.edu
+S:	Maintained
+
 8390 NETWORK DRIVERS [WD80x3/SMC-ELITE, SMC-ULTRA, NE2000, 3C503, etc.]
 P:	Paul Gortmaker
 M:	p_gortmaker@yahoo.com
@@ -586,8 +592,8 @@
 
 LINUX FOR POWERPC (PREP)
 P:	Cort Dougan
-M:	cort@cs.nmt.edu
-W:	http://linuxppc.cs.nmt.edu/
+M:	cort@fsmlabs.com
+W:	http://www.fsmlabs.com/linuxppcbk.html
 S:	Maintained
 
 LINUX FOR POWER MACINTOSH
diff -urN linux-2.2.19-pre7/Makefile linux/Makefile
--- linux-2.2.19-pre7/Makefile	Mon Dec  3 20:58:26 2001
+++ linux/Makefile	Mon Dec  3 20:58:53 2001
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 2
 SUBLEVEL = 19
-EXTRAVERSION = pre7
+EXTRAVERSION = pre8
 
 ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/)
 
diff -urN linux-2.2.19-pre7/arch/alpha/kernel/sys_nautilus.c linux/arch/alpha/kernel/sys_nautilus.c
--- linux-2.2.19-pre7/arch/alpha/kernel/sys_nautilus.c	Wed Jun  7 14:26:42 2000
+++ linux/arch/alpha/kernel/sys_nautilus.c	Mon Dec  3 20:58:53 2001
@@ -111,7 +111,7 @@
 
 	switch(mode) {
         case LINUX_REBOOT_CMD_HALT:
-		printk("Press Reset bottun");
+		printk("Press Reset button");
 		break;
 	case LINUX_REBOOT_CMD_RESTART:
 		{
diff -urN linux-2.2.19-pre7/arch/i386/boot/setup.S linux/arch/i386/boot/setup.S
--- linux-2.2.19-pre7/arch/i386/boot/setup.S	Mon Dec  3 20:58:26 2001
+++ linux/arch/i386/boot/setup.S	Mon Dec  3 20:58:53 2001
@@ -578,46 +578,44 @@
 	lgdt	gdt_48		! load gdt with whatever appropriate
 
 ! that was painless, now we enable A20
-
-! if this is SC410 or a few other bits we need to do it with the 'fast' method
-
-        in      al,#0x92        ! read "System Control Port A"
-        or      al,#0x02        ! Set "Alternate Gate A20" - Bit
-        out     #0x92,al        ! write "System Control Port A"
+	call	empty_8042
 
 ! do it the normal way too, so as not to upset normal machines
-
-	call	empty_8042
 	mov	al,#0xD1		! command write
 	out	#0x64,al
 	call	empty_8042
+
 	mov	al,#0xDF		! A20 on
 	out	#0x60,al
 	call	empty_8042
 
+! if this is SC410 or a few other bits we need to do it with the 'fast' method
+!
+!	You must preserve the other bits here. Otherwise embarrasing things
+!	like laptops powering off on boot happen. Corrected version by Kira
+!	Brown from Linux 2.2
+
+        in      al,#0x92        ! read "System Control Port A"
+        or      al,#0x02        ! Set "Alternate Gate A20" - Bit
+        out     #0x92,al        ! write "System Control Port A"
+
 ! wait until a20 really *is* enabled; it can take a fair amount of
 ! time on certain systems; Toshiba Tecras are known to have this
-! problem.  The memory location used here is the int 0x1f vector,
-! which should be safe to use; any *unused* memory location < 0xfff0
-! should work here.  
-
-#define	TEST_ADDR 0x7c
+! problem.  The memory location used here (0x200) is the int 0x80
+! vector, which should be safe to use.
 
-	push	ds
 	xor	ax,ax			! segment 0x0000
-	mov	ds,ax
+	mov	fs,ax
 	dec	ax			! segment 0xffff (HMA)
 	mov	gs,ax
-	mov	bx,[TEST_ADDR]		! we want to restore the value later
 a20_wait:
-	inc	ax
-	mov	[TEST_ADDR],ax
+	inc	ax			! unused memory location <0xfff0
+	seg	fs
+	mov	[0x200],ax		! we use the "int 0x80" vector
 	seg	gs
-	cmp	ax,[TEST_ADDR+0x10]
+	cmp	ax,[0x210]		! and its corresponding HMA addr
 	je	a20_wait		! loop until no longer aliased
-	mov	[TEST_ADDR],bx		! restore original value
-	pop	ds
-		
+
 ! make sure any possible coprocessor is properly reset..
 
 	xor	ax,ax
@@ -797,10 +795,17 @@
 !
 ! Some machines have delusions that the keyboard buffer is always full
 ! with no keyboard attached...
+!
+! If there is no keyboard controller, we will usually get 0xff
+! to all the reads.  With each IO taking a microsecond and
+! a timeout of 100,000 iterations, this can take about half a
+! second ("delay" == outb to port 0x80). That should be ok,
+! and should also be plenty of time for a real keyboard controller
+! to empty.
 
 empty_8042:
        push    ecx
-       mov     ecx,#0xFFFFFF
+       mov     ecx,#100000
 
 empty_8042_loop:
        dec     ecx
@@ -840,7 +845,7 @@
 ! Delay is needed after doing I/O
 !
 delay:
-	.word	0x00eb			! jmp $+2
+	out	#0x80,al
 	ret
 
 !
diff -urN linux-2.2.19-pre7/arch/i386/kernel/Makefile linux/arch/i386/kernel/Makefile
--- linux-2.2.19-pre7/arch/i386/kernel/Makefile	Sun Dec 10 16:49:41 2000
+++ linux/arch/i386/kernel/Makefile	Mon Dec  3 20:58:53 2001
@@ -15,8 +15,8 @@
 O_TARGET := kernel.o
 O_OBJS   := process.o signal.o entry.o traps.o irq.o vm86.o \
             ptrace.o ioport.o ldt.o setup.o time.o sys_i386.o \
-	    bluesmoke.o dmi_scan.o
-OX_OBJS  := i386_ksyms.o
+	    bluesmoke.o
+OX_OBJS  := i386_ksyms.o dmi_scan.o
 MX_OBJS  :=
 
 ifdef CONFIG_PCI
diff -urN linux-2.2.19-pre7/arch/ppc/config.in linux/arch/ppc/config.in
--- linux-2.2.19-pre7/arch/ppc/config.in	Sun Dec 10 16:49:41 2000
+++ linux/arch/ppc/config.in	Mon Dec  3 20:58:53 2001
@@ -176,22 +176,23 @@
 
 mainmenu_option next_comment
 comment 'Mac device drivers'
-if [ "$CONFIG_INPUT_KEYBDEV" = "y" -o "$CONFIG_INPUT_MOUSEDEV" = "y" ]; then
-   bool 'Use input layer for ADB keyboard and mouse' CONFIG_INPUT_ADBHID
-fi
+
+bool 'Use input layer for ADB keyboard and mouse' CONFIG_INPUT_ADBHID
 if [ "$CONFIG_INPUT_ADBHID" = "y" ]; then
-   define_bool CONFIG_MAC_HID y
-   bool '  Support for ADB raw keycodes' CONFIG_MAC_ADBKEYCODES
-   bool '  Support for mouse button 2+3 emulation' CONFIG_MAC_EMUMOUSEBTN
+  define_bool CONFIG_INPUT_KEYBDEV $CONFIG_INPUT_ADBHID $CONFIG_VT
+  define_bool CONFIG_INPUT_MOUSEDEV $CONFIG_INPUT_ADBHID
+  define_bool CONFIG_MAC_HID y
+  bool '  Support for ADB raw keycodes' CONFIG_MAC_ADBKEYCODES
+  bool '  Support for mouse button 2+3 emulation' CONFIG_MAC_EMUMOUSEBTN
 else
-   bool 'Support for ADB keyboard (old driver)' CONFIG_MAC_KEYBOARD
-   bool 'Support for ADB mouse (old driver)' CONFIG_ADBMOUSE
+  bool 'Support for ADB keyboard (old driver)' CONFIG_MAC_KEYBOARD
+  bool 'Support for ADB mouse (old driver)' CONFIG_ADBMOUSE
 fi
 tristate 'Support for /dev/rtc' CONFIG_PPC_RTC
 bool 'Support for PowerMac floppy' CONFIG_MAC_FLOPPY
 tristate 'Support for PowerMac serial ports' CONFIG_MAC_SERIAL
 if [ "$CONFIG_MAC_SERIAL" = "y" ]; then
-   bool '   Support for console on serial port' CONFIG_SERIAL_CONSOLE
+  bool '   Support for console on serial port' CONFIG_SERIAL_CONSOLE
 fi
 endmenu
 
diff -urN linux-2.2.19-pre7/arch/ppc/kernel/ppc_ksyms.c linux/arch/ppc/kernel/ppc_ksyms.c
--- linux-2.2.19-pre7/arch/ppc/kernel/ppc_ksyms.c	Sun Dec 10 16:49:41 2000
+++ linux/arch/ppc/kernel/ppc_ksyms.c	Mon Dec  3 20:58:53 2001
@@ -5,30 +5,24 @@
 #include <linux/sched.h>
 #include <linux/string.h>
 #include <linux/interrupt.h>
+#include <linux/smp_lock.h>
 #include <linux/vt_kern.h>
 #include <linux/nvram.h>
 
-#include <asm/page.h>
 #include <asm/semaphore.h>
 #include <asm/processor.h>
 #include <asm/uaccess.h>
-#include <asm/io.h>
 #include <asm/ide.h>
-#include <asm/atomic.h>
-#include <asm/bitops.h>
 #include <asm/checksum.h>
 #include <asm/pgtable.h>
 #include <asm/adb.h>
 #include <asm/cuda.h>
 #include <asm/pmu.h>
 #include <asm/prom.h>
-#include <asm/system.h>
 #include <asm/pci-bridge.h>
 #include <asm/irq.h>
 #include <asm/feature.h>
-#include <asm/spinlock.h>
 #include <asm/dma.h>
-#include <asm/machdep.h>
 #include <asm/nvram.h>
 #include <asm/time.h>
 
@@ -179,10 +173,10 @@
 #endif
 
 #ifdef __SMP__
-EXPORT_SYMBOL(__global_cli);
-EXPORT_SYMBOL(__global_sti);
-EXPORT_SYMBOL(__global_save_flags);
-EXPORT_SYMBOL(__global_restore_flags);
+EXPORT_SYMBOL(cpu_data);
+EXPORT_SYMBOL(kernel_flag);
+EXPORT_SYMBOL(cpu_number_map);
+EXPORT_SYMBOL(smp_num_cpus);
 EXPORT_SYMBOL(_spin_lock);
 EXPORT_SYMBOL(_spin_unlock);
 EXPORT_SYMBOL(spin_trylock);
@@ -190,6 +184,17 @@
 EXPORT_SYMBOL(_read_unlock);
 EXPORT_SYMBOL(_write_lock);
 EXPORT_SYMBOL(_write_unlock);
+
+/* Global SMP irq stuff */
+EXPORT_SYMBOL(synchronize_irq);
+EXPORT_SYMBOL(synchronize_bh);
+EXPORT_SYMBOL(global_bh_count);
+EXPORT_SYMBOL(global_bh_lock);
+EXPORT_SYMBOL(global_irq_holder);
+EXPORT_SYMBOL(__global_cli);
+EXPORT_SYMBOL(__global_sti);
+EXPORT_SYMBOL(__global_save_flags);
+EXPORT_SYMBOL(__global_restore_flags);
 #endif /* __SMP__ */
 
 EXPORT_SYMBOL(_machine);
diff -urN linux-2.2.19-pre7/arch/sparc/kernel/systbls.S linux/arch/sparc/kernel/systbls.S
--- linux-2.2.19-pre7/arch/sparc/kernel/systbls.S	Wed May  3 17:16:32 2000
+++ linux/arch/sparc/kernel/systbls.S	Mon Dec  3 20:58:53 2001
@@ -1,4 +1,4 @@
-/* $Id: systbls.S,v 1.83.2.2 2000/03/24 00:03:18 davem Exp $
+/* $Id: systbls.S,v 1.83.2.3 2001/01/11 15:44:37 davem Exp $
  * systbls.S: System call entry point tables for OS compatibility.
  *            The native Linux system call table lives here also.
  *
@@ -26,7 +26,7 @@
 /*25*/	.long sys_time, sys_ptrace, sys_alarm, sys_sigaltstack, sys_pause
 /*30*/	.long sys_utime, sys_nis_syscall, sys_nis_syscall, sys_access, sys_nice
 /*35*/	.long sys_nis_syscall, sys_sync, sys_kill, sys_newstat, sys_sendfile
-/*40*/	.long sys_newlstat, sys_dup, sys_pipe, sys_times, sys_nis_syscall
+/*40*/	.long sys_newlstat, sys_dup, sys_pipe, sys_times, sys_lfs_syscall
 /*45*/	.long sys_umount, sys_setgid, sys_getgid, sys_signal, sys_geteuid
 /*50*/	.long sys_getegid, sys_acct, sys_nis_syscall, sys_nis_syscall, sys_ioctl
 /*55*/	.long sys_reboot, sys_lfs_syscall, sys_symlink, sys_readlink, sys_execve
@@ -49,7 +49,7 @@
 /*140*/	.long sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_getrlimit
 /*145*/	.long sys_setrlimit, sys_nis_syscall, sys_prctl, sys_pciconfig_read, sys_pciconfig_write
 /*150*/	.long sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_poll, sys_nis_syscall
-/*155*/	.long sys_nis_syscall, sys_nis_syscall, sys_statfs, sys_fstatfs, sys_oldumount
+/*155*/	.long sys_lfs_syscall, sys_nis_syscall, sys_statfs, sys_fstatfs, sys_oldumount
 /*160*/	.long sys_nis_syscall, sys_nis_syscall, sys_getdomainname, sys_setdomainname, sys_nis_syscall
 /*165*/	.long sys_quotactl, sys_nis_syscall, sys_mount, sys_ustat, sys_nis_syscall
 /*170*/	.long sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_getdents
diff -urN linux-2.2.19-pre7/arch/sparc64/kernel/systbls.S linux/arch/sparc64/kernel/systbls.S
--- linux-2.2.19-pre7/arch/sparc64/kernel/systbls.S	Sun Dec 10 16:49:41 2000
+++ linux/arch/sparc64/kernel/systbls.S	Mon Dec  3 20:58:53 2001
@@ -1,4 +1,4 @@
-/* $Id: systbls.S,v 1.53.2.5 2000/08/23 04:18:26 davem Exp $
+/* $Id: systbls.S,v 1.53.2.6 2001/01/11 15:44:37 davem Exp $
  * systbls.S: System call entry point tables for OS compatibility.
  *            The native Linux system call table lives here also.
  *
@@ -27,7 +27,7 @@
 /*25*/	.word sys_time, sys_ptrace, sys_alarm, sys32_sigaltstack, sys32_pause
 /*30*/	.word sys32_utime, sys_nis_syscall, sys_nis_syscall, sys_access, sys_nice
 	.word sys_nis_syscall, sys_sync, sys_kill, sys32_newstat, sys32_sendfile
-/*40*/	.word sys32_newlstat, sys_dup, sys_pipe, sys32_times, sys_nis_syscall
+/*40*/	.word sys32_newlstat, sys_dup, sys_pipe, sys32_times, sys_lfs_syscall
 	.word sys_umount, sys_setgid, sys_getgid, sys_signal, sys_geteuid
 /*50*/	.word sys_getegid, sys_acct, sys_nis_syscall, sys_nis_syscall, sys32_ioctl
 	.word sys_reboot, sys_lfs_syscall, sys_symlink, sys_readlink, sys32_execve
@@ -50,7 +50,7 @@
 /*140*/	.word sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys32_getrlimit
 	.word sys32_setrlimit, sys_nis_syscall, sys32_prctl, sys32_pciconfig_read, sys32_pciconfig_write
 /*150*/	.word sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_poll, sys_nis_syscall
-	.word sys_nis_syscall, sys_nis_syscall, sys32_statfs, sys32_fstatfs, sys_oldumount
+	.word sys_lfs_syscall, sys_nis_syscall, sys32_statfs, sys32_fstatfs, sys_oldumount
 /*160*/	.word sys_nis_syscall, sys_nis_syscall, sys_getdomainname, sys_setdomainname, sys_nis_syscall
 	.word sys32_quotactl, sys_nis_syscall, sys32_mount, sys_ustat, sys_nis_syscall
 /*170*/	.word sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys32_getdents
diff -urN linux-2.2.19-pre7/drivers/char/serial.c linux/drivers/char/serial.c
--- linux-2.2.19-pre7/drivers/char/serial.c	Wed Jun  7 14:26:42 2000
+++ linux/drivers/char/serial.c	Mon Dec  3 20:58:53 2001
@@ -2622,7 +2622,7 @@
 	tty->driver_data = info;
 	info->tty = tty;
 	if (serial_paranoia_check(info, tty->device, "rs_open")) {
-		/* MOD_DEC_USE_COUNT; "info->tty" will cause this */
+		MOD_DEC_USE_COUNT;
 		return -ENODEV;
 	}
 
@@ -2635,7 +2635,7 @@
 	if (!tmp_buf) {
 		page = get_free_page(GFP_KERNEL);
 		if (!page) {
-			/* MOD_DEC_USE_COUNT; "info->tty" will cause this? */
+			MOD_DEC_USE_COUNT;
 			return -ENOMEM;
 		}
 		if (tmp_buf)
@@ -2651,7 +2651,7 @@
 	    (info->flags & ASYNC_CLOSING)) {
 		if (info->flags & ASYNC_CLOSING)
 			interruptible_sleep_on(&info->close_wait);
-		/* MOD_DEC_USE_COUNT; "info->tty" will cause this? */
+		MOD_DEC_USE_COUNT;
 #ifdef SERIAL_DO_RESTART
 		return ((info->flags & ASYNC_HUP_NOTIFY) ?
 			-EAGAIN : -ERESTARTSYS);
@@ -2665,13 +2665,13 @@
 	 */
 	retval = startup(info);
 	if (retval) {
-		/* MOD_DEC_USE_COUNT; "info->tty" will cause this? */
+		MOD_DEC_USE_COUNT;
 		return retval;
 	}
 
 	retval = block_til_ready(tty, filp, info);
 	if (retval) {
-		/* MOD_DEC_USE_COUNT; "info->tty" will cause this? */
+		MOD_DEC_USE_COUNT;
 #ifdef SERIAL_DEBUG_OPEN
 		printk("rs_open returning after block_til_ready with %d\n",
 		       retval);
diff -urN linux-2.2.19-pre7/drivers/char/tty_io.c linux/drivers/char/tty_io.c
--- linux-2.2.19-pre7/drivers/char/tty_io.c	Sun Dec 10 16:49:42 2000
+++ linux/drivers/char/tty_io.c	Mon Dec  3 20:58:53 2001
@@ -54,6 +54,9 @@
  *
  * Added support for a Unix98-style ptmx device.
  *      -- C. Scott Ananian <cananian@alumni.princeton.edu>, 14-Jan-1998
+ *
+ * Don't call close after a failed open.
+ *	-- Maciej W. Rozycki <macro@ds2.pg.gda.pl>, 21-Jan-2001
  */
 
 #include <linux/config.h>
@@ -1009,7 +1012,7 @@
  * WSH 09/09/97: rewritten to avoid some nasty race conditions that could
  * lead to double frees or releasing memory still in use.
  */
-static void release_dev(struct file * filp)
+static void release_dev(struct file * filp, int do_close)
 {
 	struct tty_struct *tty, *o_tty;
 	int	pty_master, tty_closing, o_tty_closing, do_sleep;
@@ -1087,7 +1090,7 @@
 	}
 #endif
 
-	if (tty->driver.close)
+	if (do_close && tty->driver.close)
 		tty->driver.close(tty, filp);
 
 	/*
@@ -1258,7 +1261,7 @@
 static int tty_open(struct inode * inode, struct file * filp)
 {
 	struct tty_struct *tty;
-	int noctty, retval;
+	int noctty, retval, open_ok;
 	kdev_t device;
 	unsigned short saved_flags;
 	char	buf[64];
@@ -1340,9 +1343,12 @@
 #ifdef TTY_DEBUG_HANGUP
 	printk("opening %s...", tty_name(tty, buf));
 #endif
-	if (tty->driver.open)
+	open_ok = 0;
+	if (tty->driver.open) {
 		retval = tty->driver.open(tty, filp);
-	else
+		if (!retval)
+			open_ok = 1;
+	} else
 		retval = -ENODEV;
 	filp->f_flags = saved_flags;
 
@@ -1355,7 +1361,7 @@
 		       tty_name(tty, buf));
 #endif
 
-		release_dev(filp);
+		release_dev(filp, open_ok);
 		if (retval != -ERESTARTSYS)
 			return retval;
 		if (signal_pending(current))
@@ -1394,7 +1400,7 @@
 
 static int tty_release(struct inode * inode, struct file * filp)
 {
-	release_dev(filp);
+	release_dev(filp, 1);
 	return 0;
 }
 
diff -urN linux-2.2.19-pre7/drivers/i2o/i2o_block.c linux/drivers/i2o/i2o_block.c
--- linux-2.2.19-pre7/drivers/i2o/i2o_block.c	Mon Sep  4 10:39:18 2000
+++ linux/drivers/i2o/i2o_block.c	Mon Dec  3 20:58:53 2001
@@ -22,6 +22,14 @@
  *				Removed queue walk, fixed for 64bitness.
  *		Boji T Kannanthanam:
  *				Support for dynamic device creation/deletion
+ *				Set the I2O Block devices to be detected in 
+ *				increasing order of TIDs during boot.
+ *				Search and set the I2O block device that we 
+ *				boot off from  as the first device to be 
+ *				claimed (as /dev/i2o/hda)
+ *				Properly attach/detach I2O gendisk structure 
+ *				from the system gendisk list. The I2O block
+ *				devices now appear in /proc/partitions.
  *	To do:
  *		Multiple majors
  *		Serial number scanning to find duplicates for FC multipathing
@@ -1538,14 +1546,14 @@
 static struct gendisk i2ob_gendisk = 
 {
 	MAJOR_NR,
-	"i2ohd",
+	"i2o/hd",
 	4,
 	1<<4,
 	MAX_I2OB,
 	i2ob_geninit,
 	i2ob,
 	i2ob_sizes,
-	0,
+	MAX_I2OB,
 	NULL,
 	NULL
 };
@@ -1654,6 +1662,13 @@
 	 */
 	i2ob_probe();
 
+	/*
+ 	 *      Adding i2ob_gendisk into the gendisk list.
+	 */
+
+	i2ob_gendisk.next = gendisk_head;
+	gendisk_head = &i2ob_gendisk;
+
 	return 0;
 }
 
@@ -1665,7 +1680,7 @@
 
 void cleanup_module(void)
 {
-	struct gendisk **gdp;
+	struct gendisk *gdp;
 	int i;
 	
 	 /*
@@ -1713,9 +1728,17 @@
 	 *	Why isnt register/unregister gendisk in the kernel ???
 	 */
 
-	for (gdp = &gendisk_head; *gdp; gdp = &((*gdp)->next))
-		if (*gdp == &i2ob_gendisk)
-			break;
+	if (gendisk_head == &i2ob_gendisk) {
+		gendisk_head = i2ob_gendisk.next;
+		}
+	else {
+		for (gdp = gendisk_head; gdp; gdp = gdp->next)
+			if (gdp->next == &i2ob_gendisk)
+			{
+				gdp->next = i2ob_gendisk.next;
+				break;
+			}
+	}
 
 }
 #endif
diff -urN linux-2.2.19-pre7/drivers/isdn/avmb1/avm_cs.c linux/drivers/isdn/avmb1/avm_cs.c
--- linux-2.2.19-pre7/drivers/isdn/avmb1/avm_cs.c	Mon Dec  3 20:58:26 2001
+++ linux/drivers/isdn/avmb1/avm_cs.c	Mon Dec  3 20:58:53 2001
@@ -145,9 +145,7 @@
     /* The io structure describes IO port mapping */
     link->io.NumPorts1 = 16;
     link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
-    link->io.NumPorts2 = 16;
-    link->io.Attributes2 = IO_DATA_PATH_WIDTH_16;
-    link->io.IOAddrLines = 5;
+    link->io.NumPorts2 = 0;
 
     /* Interrupt setup */
     link->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
@@ -233,9 +231,9 @@
     /* Unlink device structure, free pieces */
     *linkp = link->next;
     if (link->priv) {
-	kfree_s(link->priv, sizeof(local_info_t));
+	kfree(link->priv);
     }
-    kfree_s(link, sizeof(struct dev_link_t));
+    kfree(link);
     
 } /* avmcs_detach */
 
@@ -329,9 +327,10 @@
 		link->conf.ConfigIndex = cf->index;
 		link->io.BasePort1 = cf->io.win[0].base;
 		link->io.NumPorts1 = cf->io.win[0].len;
+		link->io.NumPorts2 = 0;
                 printk(KERN_INFO "avm_cs: testing i/o %#x-%#x\n",
 			link->io.BasePort1,
-		        link->io.BasePort1+link->io.NumPorts1);
+		        link->io.BasePort1+link->io.NumPorts1-1);
 		i = CardServices(RequestIO, link->handle, &link->io);
 		if (i == CS_SUCCESS) goto found_port;
 	    }
diff -urN linux-2.2.19-pre7/drivers/isdn/avmb1/b1dma.c linux/drivers/isdn/avmb1/b1dma.c
--- linux-2.2.19-pre7/drivers/isdn/avmb1/b1dma.c	Mon Dec  3 20:58:26 2001
+++ linux/drivers/isdn/avmb1/b1dma.c	Mon Dec  3 20:58:53 2001
@@ -622,11 +622,6 @@
 	if ((status & TX_TC_INT) != 0) {
 		card->csr &= ~EN_TX_TC_INT;
 	        b1dma_dispatch_tx(card);
-	} else if (card->csr & EN_TX_TC_INT) {
-		if (b1dmainmeml(card->mbase+AMCC_TXLEN) == 0) {
-			card->csr &= ~EN_TX_TC_INT;
-			b1dma_dispatch_tx(card);
-		}
 	}
 	b1dmaoutmeml(card->mbase+AMCC_INTCSR, card->csr);
 }
diff -urN linux-2.2.19-pre7/drivers/isdn/avmb1/b1pci.c linux/drivers/isdn/avmb1/b1pci.c
--- linux-2.2.19-pre7/drivers/isdn/avmb1/b1pci.c	Mon Dec  3 20:58:26 2001
+++ linux/drivers/isdn/avmb1/b1pci.c	Mon Dec  3 20:58:53 2001
@@ -328,10 +328,13 @@
 	avmctrl_info *cinfo;
 	int retval;
 
+	MOD_INC_USE_COUNT;
+
 	card = (avmcard *) kmalloc(sizeof(avmcard), GFP_ATOMIC);
 
 	if (!card) {
 		printk(KERN_WARNING "%s: no memory.\n", driver->name);
+	        MOD_DEC_USE_COUNT;
 		return -ENOMEM;
 	}
 	memset(card, 0, sizeof(avmcard));
@@ -339,6 +342,7 @@
 	if (!card->dma) {
 		printk(KERN_WARNING "%s: no memory.\n", driver->name);
 		kfree(card);
+	        MOD_DEC_USE_COUNT;
 		return -ENOMEM;
 	}
 	memset(card->dma, 0, sizeof(avmcard_dmainfo));
@@ -347,6 +351,7 @@
 		printk(KERN_WARNING "%s: no memory.\n", driver->name);
 		kfree(card->dma);
 		kfree(card);
+	        MOD_DEC_USE_COUNT;
 		return -ENOMEM;
 	}
 	memset(cinfo, 0, sizeof(avmctrl_info));
@@ -365,6 +370,7 @@
 	        kfree(card->ctrlinfo);
 		kfree(card->dma);
 		kfree(card);
+	        MOD_DEC_USE_COUNT;
 		return -EBUSY;
 	}
 
@@ -379,6 +385,7 @@
 	        kfree(card->ctrlinfo);
 		kfree(card->dma);
 		kfree(card);
+	        MOD_DEC_USE_COUNT;
 		return -EIO;
 	}
 
@@ -391,6 +398,7 @@
 	        kfree(card->ctrlinfo);
 		kfree(card->dma);
 		kfree(card);
+	        MOD_DEC_USE_COUNT;
 		return -EIO;
 	}
 	b1dma_reset(card);
@@ -407,6 +415,7 @@
 	        kfree(card->ctrlinfo);
 		kfree(card->dma);
 		kfree(card);
+	        MOD_DEC_USE_COUNT;
 		return -EBUSY;
 	}
 
@@ -419,6 +428,7 @@
 	        kfree(card->ctrlinfo);
 		kfree(card->dma);
 		kfree(card);
+	        MOD_DEC_USE_COUNT;
 		return -EBUSY;
 	}
 	card->cardnr = cinfo->capi_ctrl->cnr;
@@ -429,8 +439,6 @@
 		"%s: AVM B1 PCI V4 at i/o %#x, irq %d, mem %#lx, revision %d (dma)\n",
 		driver->name, card->port, card->irq,
 		card->membase, card->revision);
-
-	MOD_INC_USE_COUNT;
 
 	return 0;
 }
diff -urN linux-2.2.19-pre7/drivers/isdn/avmb1/capidrv.c linux/drivers/isdn/avmb1/capidrv.c
--- linux-2.2.19-pre7/drivers/isdn/avmb1/capidrv.c	Mon Dec  3 20:58:26 2001
+++ linux/drivers/isdn/avmb1/capidrv.c	Mon Dec  3 20:58:53 2001
@@ -397,16 +397,16 @@
 	}
 }
 
-static _cstruct b1config_sync_v110(__u16 rate)
+static _cstruct b1config_async_v110(__u16 rate)
 {
 	/* CAPI-Spec "B1 Configuration" */
 	static unsigned char buf[9];
 	buf[0] = 8; /* len */
 	/* maximum bitrate */
 	buf[1] = rate & 0xff; buf[2] = (rate >> 8) & 0xff;
-	buf[3] = buf[4] = 0; /* reserved, bits per character */
-	buf[5] = buf[6] = 0; /* reserved, parity */
-	buf[7] = buf[9] = 0; /* reserved, stop bits */
+	buf[3] = 8; buf[4] = 0; /* 8 bits per character */
+	buf[5] = 0; buf[6] = 0; /* parity none */
+	buf[7] = 0; buf[8] = 0; /* 1 stop bit */
 	return buf;
 }
 
@@ -421,11 +421,11 @@
 	default:
 		return 0;
         case ISDN_PROTO_L2_V11096:
-	    return b1config_sync_v110(9600);
+	    return b1config_async_v110(9600);
         case ISDN_PROTO_L2_V11019:
-	    return b1config_sync_v110(19200);
+	    return b1config_async_v110(19200);
         case ISDN_PROTO_L2_V11038:
-	    return b1config_sync_v110(38400);
+	    return b1config_async_v110(38400);
 	}
 }
 
diff -urN linux-2.2.19-pre7/drivers/isdn/avmb1/capifs.c linux/drivers/isdn/avmb1/capifs.c
--- linux-2.2.19-pre7/drivers/isdn/avmb1/capifs.c	Mon Dec  3 20:58:26 2001
+++ linux/drivers/isdn/avmb1/capifs.c	Mon Dec  3 20:58:53 2001
@@ -51,22 +51,19 @@
 #include <linux/param.h>
 #include <linux/module.h>
 #include <linux/string.h>
-#include <linux/fs.h>
 #include <linux/init.h>
 #include <linux/kdev_t.h>
 #include <linux/kernel.h>
 #include <linux/locks.h>
 #include <linux/major.h>
 #include <linux/malloc.h>
-#include <linux/stat.h>
-#include <linux/tty.h>
 #include <linux/ctype.h>
 #include <asm/bitops.h>
 #include <asm/uaccess.h>
 
 MODULE_AUTHOR("Carsten Paeth <calle@calle.de>");
 
-static char *revision = "$Revision: 1.7 $";
+static char *revision = "$Revision: 1.14.6.1 $";
 
 struct capifs_ncci {
 	struct inode *inode;
@@ -109,11 +106,9 @@
 };
 
 struct inode_operations capifs_root_inode_operations = {
-	&capifs_root_operations, /* file operations */
+	default_file_ops: &capifs_root_operations, /* file operations */
 	lookup: capifs_root_lookup,
 };
-
-struct inode_operations capifs_inode_operations;
 
 static struct dentry_operations capifs_dentry_operations = {
 	d_revalidate: capifs_revalidate,
diff -urN linux-2.2.19-pre7/drivers/isdn/hisax/netjet.c linux/drivers/isdn/hisax/netjet.c
--- linux-2.2.19-pre7/drivers/isdn/hisax/netjet.c	Mon Dec  3 20:58:26 2001
+++ linux/drivers/isdn/hisax/netjet.c	Mon Dec  3 20:58:53 2001
@@ -19,17 +19,10 @@
 #include <linux/pci.h>
 #include <linux/interrupt.h>
 #include <linux/ppp_defs.h>
+#include <asm/io.h>
 #include "netjet.h"
 
-#ifndef bus_to_virt
-#define bus_to_virt (u_int *)
-#endif
-
-#ifndef virt_to_bus
-#define virt_to_bus (u_int)
-#endif
-
-const char *NETjet_revision = "$Revision: 1.20 $";
+const char *NETjet_revision = "$Revision: 1.24.6.2 $";
 
 /* Interface functions */
 
diff -urN linux-2.2.19-pre7/drivers/macintosh/mac_hid.c linux/drivers/macintosh/mac_hid.c
--- linux-2.2.19-pre7/drivers/macintosh/mac_hid.c	Sun Dec 10 16:49:42 2000
+++ linux/drivers/macintosh/mac_hid.c	Mon Dec  3 20:58:53 2001
@@ -184,8 +184,6 @@
 
 int mac_hid_kbd_translate(unsigned char keycode, unsigned char *keycodep,
 			  char raw_mode);
-static int mac_hid_sysctl_keycodes(ctl_table *ctl, int write, struct file * filp,
-				   void *buffer, size_t *lenp);
 char mac_hid_kbd_unexpected_up(unsigned char keycode);
 
 static int keyboard_lock_keycodes = 0;
@@ -194,6 +192,8 @@
 int keyboard_sends_linux_keycodes = 1;
 #endif /* CONFIG_MAC_ADBKEYCODES */
 
+static int mac_hid_sysctl_keycodes(ctl_table *ctl, int write, struct file * filp,
+				   void *buffer, size_t *lenp);
 
 static unsigned char e0_keys[128] = {
 	0, 0, 0, KEY_KPCOMMA, 0, KEY_INTL3, 0, 0,		/* 0x00-0x07 */
@@ -225,22 +225,25 @@
 
 extern void pckbd_init_hw(void);
 
-#if defined CONFIG_SYSCTL && (defined(CONFIG_MAC_ADBKEYCODES) || defined(CONFIG_MAC_EMUMOUSEBTN))
+#ifdef CONFIG_SYSCTL
 /* file(s) in /proc/sys/dev/mac_hid */
 ctl_table mac_hid_files[] =
 {
-#ifdef CONFIG_MAC_ADBKEYCODES
   {
+    /* Leave it available when ADB keycodes are disabled for the sanity of
+     * distro installers...
+     */
     DEV_MAC_HID_KEYBOARD_SENDS_LINUX_KEYCODES,
     "keyboard_sends_linux_keycodes", &keyboard_sends_linux_keycodes, sizeof(int),
     0644, NULL, &mac_hid_sysctl_keycodes
   },
+#ifdef CONFIG_MAC_ADBKEYCODES
   {
     DEV_MAC_HID_KEYBOARD_LOCK_KEYCODES,
     "keyboard_lock_keycodes", &keyboard_lock_keycodes, sizeof(int),
     0644, NULL, &proc_dointvec
   },
-#endif
+#endif /* CONFIG_MAC_ADBKEYCODES */
 #ifdef CONFIG_MAC_EMUMOUSEBTN
   {
     DEV_MAC_HID_MOUSE_BUTTON_EMULATION,
@@ -257,7 +260,7 @@
     "mouse_button3_keycode", &mouse_button3_keycode, sizeof(int),
     0644, NULL, &proc_dointvec
   },
-#endif
+#endif /* CONFIG_MAC_EMUMOUSEBTN */
   { 0 }
 };
 
@@ -277,11 +280,13 @@
 
 static struct ctl_table_header *mac_hid_sysctl_header;
 
-#ifdef CONFIG_MAC_ADBKEYCODES
 static
 int mac_hid_sysctl_keycodes(ctl_table *ctl, int write, struct file * filp,
 			    void *buffer, size_t *lenp)
 {
+#ifndef CONFIG_MAC_ADBKEYCODES
+	return write ? 0 : proc_dointvec(ctl, write, filp, buffer, lenp);
+#else /* CONFIG_MAC_ADBKEYCODES */
 	int val = keyboard_sends_linux_keycodes;
 	int ret = 0;
 
@@ -293,14 +298,14 @@
 	    && keyboard_sends_linux_keycodes != val) {
 		if (!keyboard_sends_linux_keycodes) {
 #ifdef CONFIG_MAGIC_SYSRQ
-			ppc_md.ppc_kbd_sysrq_xlate   = mac_hid_kbd_sysrq_xlate;
+			ppc_md.sysrq_xlate   = mac_hid_kbd_sysrq_xlate;
 			SYSRQ_KEY                = 0x69;
 #endif
 			memcpy(pc_key_maps_save, key_maps, sizeof(key_maps));
 			memcpy(key_maps, mac_key_maps_save, sizeof(key_maps));
 		} else {
 #ifdef CONFIG_MAGIC_SYSRQ
-			ppc_md.ppc_kbd_sysrq_xlate   = pckbd_sysrq_xlate;
+			ppc_md.sysrq_xlate   = pckbd_sysrq_xlate;
 			SYSRQ_KEY                = 0x54;
 #endif
 			memcpy(mac_key_maps_save, key_maps, sizeof(key_maps));
@@ -309,8 +314,8 @@
 	}
 
 	return ret;
+#endif /* CONFIG_MAC_ADBKEYCODES */
 }
-#endif
 #endif /* endif CONFIG_SYSCTL */
 
 int mac_hid_kbd_translate(unsigned char scancode, unsigned char *keycode,
@@ -486,7 +491,7 @@
 		pckbd_init_hw();
 #endif
 
-#if defined(CONFIG_SYSCTL) && (defined(CONFIG_MAC_ADBKEYCODES) || defined(CONFIG_MAC_EMUMOUSEBTN))
+#ifdef CONFIG_SYSCTL
 	mac_hid_sysctl_header = register_sysctl_table(mac_hid_root_dir, 1);
 #endif /* CONFIG_SYSCTL */
 }
diff -urN linux-2.2.19-pre7/drivers/net/8139too.c linux/drivers/net/8139too.c
--- linux-2.2.19-pre7/drivers/net/8139too.c	Sun Dec 10 16:49:42 2000
+++ linux/drivers/net/8139too.c	Mon Dec  3 20:58:53 2001
@@ -45,7 +45,7 @@
 		Tigran Aivazian - bug fixes, skbuff free cleanup
 
 		Martin Mares - suggestions for PCI cleanup
-		
+
 		David S. Miller - PCI DMA and softnet updates
 
 		Ernst Gill - fixes ported from BSD driver
@@ -54,12 +54,12 @@
 			posted MMIO write bugginess
 
 		Gerard Sharp - bug fix, testing and feedback
-		
+
 		David Ford - Rx ring wrap fix
-		
+
 		Dan DeMaggio - swapped RTL8139 cards with me, and allowed me
 		to find and fix a crucial bug on older chipsets.
-		
+
 		Donald Becker/Chris Butterworth/Marcus Westergren -
 		Noticed various Rx packet size-related buglets.
 
@@ -70,6 +70,10 @@
 		Martin Dennett - incredibly helpful insight on undocumented
 		features of the 8139 chips
 
+		Jean-Jacques Michel - bug fix
+		
+		Tobias Ringström - Rx interrupt status checking suggestion
+
 	Submitting bug reports:
 
 		"rtl8139-diag -mmmaaavvveefN" output
@@ -130,6 +134,7 @@
 
 */
 
+#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/pci.h>
@@ -137,19 +142,22 @@
 #include <linux/ioport.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
+#include <linux/rtnetlink.h>
 #include <linux/delay.h>
 #include <asm/io.h>
 
 
-#define RTL8139_VERSION "0.9.10-2.2"
-#define RTL8139_MODULE_NAME "8139too"
-#define RTL8139_DRIVER_NAME   RTL8139_MODULE_NAME " FastEthernet driver " RTL8139_VERSION
+#define RTL8139_VERSION "0.9.12-2.2"
+#define MODNAME "8139too"
+#define RTL8139_DRIVER_NAME   MODNAME " FastEthernet driver " RTL8139_VERSION
 #define RTL8139_AUTHOR "Jeff Garzik <jgarzik@mandrakesoft.com>"
-#define PFX RTL8139_MODULE_NAME ": "
+#define PFX MODNAME ": "
 
 
-/* define to 1 to enable PIO instead of MMIO */
-#undef USE_IO_OPS
+/* enable PIO instead of MMIO, if CONFIG_8139TOO_PIO is selected */
+#ifdef CONFIG_8139TOO_PIO
+#define USE_IO_OPS 1
+#endif
 
 /* define to 1 to enable copious debugging info */
 #undef RTL8139_DEBUG
@@ -215,7 +223,7 @@
 #define PCI_USES_MEM		2
 #define PCI_USES_MASTER 	4
 
-static inline unsigned int pci_calc_resource_flags(unsigned int flags)
+static inline unsigned int rtl8139_pci_calc_resource_flags(unsigned int flags)
 {
 	if (flags & PCI_BASE_ADDRESS_SPACE_IO)
 		return IORESOURCE_IO;
@@ -256,23 +264,22 @@
 			sz = ~(sz & PCI_BASE_ADDRESS_IO_MASK) & 0xffff;
 		}
 		res->end = res->start + (unsigned long) sz;
-		res->flags |= (l & 0xf) | pci_calc_resource_flags(l);
+		res->flags |= (l & 0xf) | rtl8139_pci_calc_resource_flags(l);
 	}
 }
 
-#define pci_resource_start(dev_priv,bar)	((dev_priv)->rtl8139_pci_resource[(bar)].start)
-#define pci_resource_end(dev_priv,bar)	((dev_priv)->rtl8139_pci_resource[(bar)].end)
-#define pci_resource_flags(dev_priv,bar)	((dev_priv)->rtl8139_pci_resource[(bar)].flags)
-#define pci_resource_len(dev_priv,bar) \
-	((pci_resource_start((dev_priv),(bar)) == 0 &&	\
-	  pci_resource_end((dev_priv),(bar)) ==		\
-	  pci_resource_start((dev_priv),(bar))) ? 0 :	\
+#define rtl8139_pci_resource_start(dev_priv,bar)	((dev_priv)->rtl8139_pci_resource[(bar)].start)
+#define rtl8139_pci_resource_end(dev_priv,bar)	((dev_priv)->rtl8139_pci_resource[(bar)].end)
+#define rtl8139_pci_resource_flags(dev_priv,bar)	((dev_priv)->rtl8139_pci_resource[(bar)].flags)
+#define rtl8139_pci_resource_len(dev_priv,bar) \
+	((rtl8139_pci_resource_start((dev_priv),(bar)) == 0 &&	\
+	  rtl8139_pci_resource_end((dev_priv),(bar)) ==		\
+	  rtl8139_pci_resource_start((dev_priv),(bar))) ? 0 :	\
 	  						\
-	 (pci_resource_end((dev_priv),(bar)) -		\
-	  pci_resource_start((dev_priv),(bar)) + 1))
-
-#define arraysize(x)            (sizeof(x)/sizeof(*(x)))
+	 (rtl8139_pci_resource_end((dev_priv),(bar)) -		\
+	  rtl8139_pci_resource_start((dev_priv),(bar)) + 1))
 
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
 
 /* A few user-configurable values. */
 /* media options */
@@ -295,8 +302,11 @@
 /* Number of Tx descriptor registers. */
 #define NUM_TX_DESC	4
 
+/* max supported ethernet frame size -- must be at least (dev->mtu+14+4).*/
+#define MAX_ETH_FRAME_SIZE	1536
+
 /* Size of the Tx bounce buffers -- must be at least (dev->mtu+14+4). */
-#define TX_BUF_SIZE	1536
+#define TX_BUF_SIZE	MAX_ETH_FRAME_SIZE
 #define TX_BUF_TOT_LEN	(TX_BUF_SIZE * NUM_TX_DESC)
 
 /* PCI Tuning Parameters
@@ -561,17 +571,17 @@
 	  0x40,
 	  0xf0fe0040, /* XXX copied from RTL8139A, verify */
 	},
-	
+
 	{ "RTL-8139 rev K",
 	  0x60,
 	  0xf0fe0040,
 	},
-	
+
 	{ "RTL-8139A",
 	  0x70,
 	  0xf0fe0040,
 	},
-	
+
 	{ "RTL-8139B",
 	  0x78,
 	  0xf0fc0040
@@ -597,12 +607,11 @@
 	struct pci_dev *pci_dev;
 	struct resource rtl8139_pci_resource[4];
 	struct net_device_stats stats;
-	struct timer_list timer;	/* Media selection timer. */
 	unsigned char *rx_ring;
 	unsigned int cur_rx;	/* Index into the Rx buffer of next Rx pkt. */
 	unsigned int tx_flag;
-	atomic_t cur_tx;
-	atomic_t dirty_tx;
+	unsigned int cur_tx;
+	unsigned int dirty_tx;
 	/* The saved address of a sent-in-place packet/buffer, for skfree(). */
 	struct ring_info tx_info[NUM_TX_DESC];
 	unsigned char *tx_buf[NUM_TX_DESC];	/* Tx bounce buffers */
@@ -619,6 +628,9 @@
 	unsigned int mediasense:1;	/* Media sensing in progress. */
 	spinlock_t lock;
 	chip_t chipset;
+	pid_t thr_pid;
+	wait_queue_head_t thr_wait;
+	struct semaphore thr_exited;
 };
 
 
@@ -628,7 +640,7 @@
 static int mdio_read (struct device *dev, int phy_id, int location);
 static void mdio_write (struct device *dev, int phy_id, int location,
 			int val);
-static void rtl8139_timer (unsigned long data);
+static int rtl8139_thread (void *data);
 static void rtl8139_tx_timeout (struct device *dev);
 static void rtl8139_init_ring (struct device *dev);
 static int rtl8139_start_xmit (struct sk_buff *skb,
@@ -642,12 +654,11 @@
 static void rtl8139_set_rx_mode (struct device *dev);
 static void rtl8139_hw_start (struct device *dev);
 
-
 #ifdef USE_IO_OPS
 
 #define RTL_R8(reg)		inb (((unsigned long)ioaddr) + (reg))
 #define RTL_R16(reg)		inw (((unsigned long)ioaddr) + (reg))
-#define RTL_R32(reg)		inl (((unsigned long)ioaddr) + (reg))
+#define RTL_R32(reg)		((unsigned long) inl (((unsigned long)ioaddr) + (reg)))
 #define RTL_W8(reg, val8)	outb ((val8), ((unsigned long)ioaddr) + (reg))
 #define RTL_W16(reg, val16)	outw ((val16), ((unsigned long)ioaddr) + (reg))
 #define RTL_W32(reg, val32)	outl ((val32), ((unsigned long)ioaddr) + (reg))
@@ -695,12 +706,12 @@
 /* read MMIO register */
 #define RTL_R8(reg)		readb (ioaddr + (reg))
 #define RTL_R16(reg)		readw (ioaddr + (reg))
-#define RTL_R32(reg)		readl (ioaddr + (reg))
+#define RTL_R32(reg)		((unsigned long) readl (ioaddr + (reg)))
 
 #endif /* USE_IO_OPS */
 
 
-static const u16 rtl8139_intr_mask = 
+static const u16 rtl8139_intr_mask =
 	PCIErr | PCSTimeout | RxUnderrun | RxOverflow | RxFIFOOver |
 	TxErr | TxOK | RxErr | RxOK;
 
@@ -742,15 +753,15 @@
 
 	rtl8139_read_pci_resources(pdev, &tp->rtl8139_pci_resource[0]);
 
-	pio_start = pci_resource_start (tp, 0);
-	pio_end = pci_resource_end (tp, 0);
-	pio_flags = pci_resource_flags (tp, 0);
-	pio_len = pci_resource_len (tp, 0);
-
-	mmio_start = pci_resource_start (tp, 1);
-	mmio_end = pci_resource_end (tp, 1);
-	mmio_flags = pci_resource_flags (tp, 1);
-	mmio_len = pci_resource_len (tp, 1);
+	pio_start = rtl8139_pci_resource_start (tp, 0);
+	pio_end = rtl8139_pci_resource_end (tp, 0);
+	pio_flags = rtl8139_pci_resource_flags (tp, 0);
+	pio_len = rtl8139_pci_resource_len (tp, 0);
+
+	mmio_start = rtl8139_pci_resource_start (tp, 1);
+	mmio_end = rtl8139_pci_resource_end (tp, 1);
+	mmio_flags = rtl8139_pci_resource_flags (tp, 1);
+	mmio_len = rtl8139_pci_resource_len (tp, 1);
 
 	/* set this immediately, we need to know before
 	 * we talk to the chip directly */
@@ -765,17 +776,16 @@
 		rc = -ENODEV;
 		goto err_out;
 	}
-	
+
 	/* make sure PCI base addr 1 is MMIO */
 	if (!(mmio_flags & IORESOURCE_MEM)) {
 		printk (KERN_ERR PFX "region #1 not an MMIO resource, aborting\n");
 		rc = -ENODEV;
 		goto err_out;
 	}
-	
+
 	/* check for weird/broken PCI region reporting */
-	if ((pio_len != mmio_len) ||
-	    (pio_len < RTL_MIN_IO_SIZE) ||
+	if ((pio_len < RTL_MIN_IO_SIZE) ||
 	    (mmio_len < RTL_MIN_IO_SIZE)) {
 		printk (KERN_ERR PFX "Invalid PCI region size(s), aborting\n");
 		rc = -ENODEV;
@@ -838,7 +848,7 @@
 	assert (inb (pio_start+TxConfig) == readb (ioaddr+TxConfig));
 	assert (inb (pio_start+RxConfig) == readb (ioaddr+RxConfig));
 #endif /* !USE_IO_OPS */
-	
+
 	/* make sure chip thinks PIO and MMIO are enabled */
 	tmp8 = RTL_R8 (Config1);
 	if ((tmp8 & Cfg1_PIO) == 0) {
@@ -851,10 +861,10 @@
 		rc = -EIO;
 		goto err_out_iounmap;
 	}
-	
+
 	/* identify chip attached to board */
 	tmp = RTL_R8 (ChipVersion);
-	for (i = arraysize (rtl_chip_info) - 1; i >= 0; i--)
+	for (i = ARRAY_SIZE (rtl_chip_info) - 1; i >= 0; i--)
 		if (tmp == rtl_chip_info[i].version) {
 			tp->chipset = i;
 			goto match;
@@ -863,7 +873,7 @@
 	/* if unknown chip, assume array element #0, original RTL-8139 in this case */
 	printk (KERN_DEBUG PFX "PCI device %08lX: unknown chip version, assuming RTL-8139\n",
 		(unsigned long) pdev);
-	printk (KERN_DEBUG PFX "PCI device %08lX: TxConfig = 0x%x\n", (unsigned long) pdev, RTL_R32 (TxConfig));
+	printk (KERN_DEBUG PFX "PCI device %08lX: TxConfig = 0x%lx\n", (unsigned long) pdev, RTL_R32 (TxConfig));
 	tp->chipset = 0;
 
 match:
@@ -871,11 +881,11 @@
 		tmp,
 		tp->chipset,
 		rtl_chip_info[tp->chipset].name);
-	
+
 	DPRINTK ("EXIT, returning 0\n");
 	*ioaddr_out = ioaddr;
 	*dev_out = dev;
-	return 0;	
+	return 0;
 
 err_out_iounmap:
 	assert (ioaddr > 0);
@@ -901,7 +911,7 @@
 	u8 tmp;
 
 	DPRINTK ("ENTER\n");
-	
+
 	assert (pdev != NULL);
 	assert (ent != NULL);
 
@@ -912,9 +922,9 @@
 		DPRINTK ("EXIT, returning %d\n", i);
 		return i;
 	}
-	
+
 	tp = dev->priv;
-	
+
 	assert (ioaddr != NULL);
 	assert (dev != NULL);
 	assert (tp != NULL);
@@ -944,7 +954,9 @@
 	tp->pci_dev = pdev;
 	tp->board = ent->board;
 	tp->mmio_addr = ioaddr;
-	tp->lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init (&tp->lock);
+	init_waitqueue_head (&tp->thr_wait);
+	init_MUTEX_LOCKED (&tp->thr_exited);
 
 	tp->phys[0] = 32;
 
@@ -974,7 +986,7 @@
 	RTL_W8_F (HltClk, 'H');	/* 'R' would leave the clock running. */
 
 	/* The lower four bits are the media type. */
-	option = (board_idx > 7) ? 0 : media[board_idx];
+	option = (board_idx >= ARRAY_SIZE(media)) ? 0 : media[board_idx];
 	if (option > 0) {
 		tp->full_duplex = (option & 0x200) ? 1 : 0;
 		tp->default_port = option & 15;
@@ -1017,8 +1029,8 @@
 	iounmap (np->mmio_addr);
 #endif /* !USE_IO_OPS */
 
-	release_region (pci_resource_start (np, 0),
-			pci_resource_len (np, 0));
+	release_region (rtl8139_pci_resource_start (np, 0),
+			rtl8139_pci_resource_len (np, 0));
 #ifndef RTL8139_NDEBUG
 	/* poison memory before freeing */
 	memset (dev, 0xBC,
@@ -1143,7 +1155,7 @@
 
 static int mdio_read (struct device *dev, int phy_id, int location)
 {
-	struct rtl8139_private *tp = (struct rtl8139_private *) dev->priv;
+	struct rtl8139_private *tp = dev->priv;
 	void *mdio_addr = tp->mmio_addr + Config4;
 	int mii_cmd = (0xf6 << 10) | (phy_id << 5) | location;
 	int retval = 0;
@@ -1186,7 +1198,7 @@
 static void mdio_write (struct device *dev, int phy_id, int location,
 			int value)
 {
-	struct rtl8139_private *tp = (struct rtl8139_private *) dev->priv;
+	struct rtl8139_private *tp = dev->priv;
 	void *mdio_addr = tp->mmio_addr + Config4;
 	int mii_cmd =
 	    (0x5002 << 16) | (phy_id << 23) | (location << 18) | value;
@@ -1229,7 +1241,7 @@
 
 static int rtl8139_open (struct device *dev)
 {
-	struct rtl8139_private *tp = (struct rtl8139_private *) dev->priv;
+	struct rtl8139_private *tp = dev->priv;
 	int retval;
 #ifdef RTL8139_DEBUG
 	void *ioaddr = tp->mmio_addr;
@@ -1237,12 +1249,9 @@
 
 	DPRINTK ("ENTER\n");
 
-	MOD_INC_USE_COUNT;
-
 	retval = request_irq (dev->irq, rtl8139_interrupt, SA_SHIRQ, dev->name, dev);
 	if (retval) {
 		DPRINTK ("EXIT, returning %d\n", retval);
-		MOD_DEC_USE_COUNT;
 		return retval;
 	}
 
@@ -1258,13 +1267,13 @@
 		if (tp->rx_ring) kfree(tp->rx_ring);
 
 		DPRINTK ("EXIT, returning -ENOMEM\n");
-		MOD_DEC_USE_COUNT;
 		return -ENOMEM;
-		
+
 	}
-	
+
 	tp->full_duplex = tp->duplex_lock;
 	tp->tx_flag = (TX_FIFO_THRESH << 11) & 0x003f0000;
+	tp->twistie = 1;
 
 	rtl8139_init_ring (dev);
 	rtl8139_hw_start (dev);
@@ -1275,13 +1284,10 @@
 			dev->irq, RTL_R8 (MediaStatus),
 			tp->full_duplex ? "full" : "half");
 
-	/* Set the timer to switch to check for link beat and perhaps switch
-	   to an alternate media type. */
-	init_timer (&tp->timer);
-	tp->timer.expires = jiffies + 3 * HZ;
-	tp->timer.data = (unsigned long) dev;
-	tp->timer.function = &rtl8139_timer;
-	add_timer (&tp->timer);
+	tp->thr_pid = kernel_thread (rtl8139_thread, dev, CLONE_FS | CLONE_FILES);
+	if (tp->thr_pid < 0)
+		printk (KERN_WARNING "%s: unable to start kernel thread\n",
+			dev->name);
 
 	DPRINTK ("EXIT, returning 0\n");
 	return 0;
@@ -1291,13 +1297,13 @@
 /* Start the hardware at open or resume. */
 static void rtl8139_hw_start (struct device *dev)
 {
-	struct rtl8139_private *tp = (struct rtl8139_private *) dev->priv;
+	struct rtl8139_private *tp = dev->priv;
 	void *ioaddr = tp->mmio_addr;
 	u32 i;
 	u8 tmp;
 
 	DPRINTK ("ENTER\n");
-	
+
 	/* Soft reset the chip. */
 	RTL_W8 (ChipCmd, (RTL_R8 (ChipCmd) & ChipCmdClear) | CmdReset);
 	udelay (100);
@@ -1341,9 +1347,9 @@
 	if (tp->chipset >= CH_8139B) {
 		tmp = RTL_R8 (Config4) & ~(1<<2);
 		/* chip will clear Rx FIFO overflow automatically */
-		tmp |= (1<<7);  
+		tmp |= (1<<7);
 		RTL_W8 (Config4, tmp);
-	
+
 		/* disable magic packet scanning, which is enabled
 		 * when PM is enabled above (Config1) */
 		RTL_W8 (Config3, RTL_R8 (Config3) & ~(1<<5));
@@ -1383,14 +1389,14 @@
 /* Initialize the Rx and Tx rings, along with various 'dev' bits. */
 static void rtl8139_init_ring (struct device *dev)
 {
-	struct rtl8139_private *tp = (struct rtl8139_private *) dev->priv;
+	struct rtl8139_private *tp = dev->priv;
 	int i;
 
 	DPRINTK ("ENTER\n");
 
 	tp->cur_rx = 0;
-	atomic_set (&tp->cur_tx, 0);
-	atomic_set (&tp->dirty_tx, 0);
+	tp->cur_tx = 0;
+	tp->dirty_tx = 0;
 
 	for (i = 0; i < NUM_TX_DESC; i++) {
 		tp->tx_info[i].skb = NULL;
@@ -1401,7 +1407,10 @@
 }
 
 
-#ifndef RTL_TUNE_TWISTER
+/* This must be global for CONFIG_8139TOO_TUNE_TWISTER case */
+static int next_tick = 3 * HZ;
+
+#ifndef CONFIG_8139TOO_TUNE_TWISTER
 static inline void rtl8139_tune_twister (struct device *dev,
 				  struct rtl8139_private *tp) {}
 #else
@@ -1409,6 +1418,7 @@
 				  struct rtl8139_private *tp)
 {
 	int linkcase;
+	void *ioaddr = tp->mmio_addr;
 
 	DPRINTK ("ENTER\n");
 
@@ -1492,15 +1502,13 @@
 
 	DPRINTK ("EXIT\n");
 }
-#endif /* RTL_TUNE_TWISTER */
+#endif /* CONFIG_8139TOO_TUNE_TWISTER */
 
 
-static void rtl8139_timer (unsigned long data)
+static inline void rtl8139_thread_iter (struct device *dev,
+					struct rtl8139_private *tp,
+					void *ioaddr)
 {
-	struct device *dev = (struct device *) data;
-	struct rtl8139_private *tp = (struct rtl8139_private *) dev->priv;
-	void *ioaddr = tp->mmio_addr;
-	int next_tick = 60 * HZ;
 	int mii_reg5;
 
 	mii_reg5 = mdio_read (dev, tp->phys[0], 5);
@@ -1521,6 +1529,8 @@
 		}
 	}
 
+	next_tick = HZ * 60;
+
 	rtl8139_tune_twister (dev, tp);
 
 	DPRINTK ("%s: Media selection tick, Link partner %4.4x.\n",
@@ -1533,18 +1543,62 @@
 	DPRINTK ("%s:  Chip config %2.2x %2.2x.\n",
 		 dev->name, RTL_R8 (Config0),
 		 RTL_R8 (Config1));
+}
+
+
+static int rtl8139_thread (void *data)
+{
+	struct device *dev = (struct device *) data;
+	struct rtl8139_private *tp = (struct rtl8139_private *) dev->priv;
+	unsigned long timeout;
+
+	daemonize ();
+	sprintf (current->comm, "k8139d-%s", dev->name);
+
+	while (1) {
+		timeout = next_tick;
+		do {
+			timeout = interruptible_sleep_on_timeout (&tp->thr_wait, timeout);
+		} while (!signal_pending (current) && (timeout > 0));
+
+		if (signal_pending (current))
+			break;
 
-	tp->timer.expires = jiffies + next_tick;
-	add_timer (&tp->timer);
+		rtnl_lock ();
+		rtl8139_thread_iter (dev, tp, tp->mmio_addr);
+		rtnl_unlock ();
+	}
+
+	up (&tp->thr_exited);
+	return 0;
+}
+
+
+static void rtl8139_tx_clear (struct rtl8139_private *tp)
+{
+	int i;
+
+	tp->cur_tx = 0;
+	tp->dirty_tx = 0;
+
+	/* Dump the unsent Tx packets. */
+	for (i = 0; i < NUM_TX_DESC; i++) {
+		struct ring_info *rp = &tp->tx_info[i];
+		if (rp->skb) {
+			dev_kfree_skb (rp->skb);
+			rp->skb = NULL;
+			tp->stats.tx_dropped++;
+		}
+	}
 }
 
 
 static void rtl8139_tx_timeout (struct device *dev)
 {
-	struct rtl8139_private *tp = (struct rtl8139_private *) dev->priv;
+	struct rtl8139_private *tp = dev->priv;
 	void *ioaddr = tp->mmio_addr;
 	int i;
-	unsigned long flags;
+	u8 tmp8;
 
 	DPRINTK ("%s: Transmit timeout, status %2.2x %4.4x "
 		 "media %2.2x.\n", dev->name,
@@ -1552,46 +1606,36 @@
 		 RTL_R16 (IntrStatus),
 		 RTL_R8 (MediaStatus));
 
+	/* disable Tx ASAP, if not already */
+	tmp8 = RTL_R8 (ChipCmd);
+	if (tmp8 & CmdTxEnb)
+		RTL_W8 (ChipCmd, tmp8 & ~CmdTxEnb);
+
 	/* Disable interrupts by clearing the interrupt mask. */
 	RTL_W16 (IntrMask, 0x0000);
 
 	/* Emit info to figure out what went wrong. */
         printk (KERN_DEBUG "%s: Tx queue start entry %d  dirty entry %d.\n",
-		dev->name, atomic_read (&tp->cur_tx),
-		atomic_read (&tp->dirty_tx));
+		dev->name, tp->cur_tx, tp->dirty_tx);
 	for (i = 0; i < NUM_TX_DESC; i++)
-		printk (KERN_DEBUG "%s:  Tx descriptor %d is %8.8x.%s\n",
+		printk (KERN_DEBUG "%s:  Tx descriptor %d is %8.8lx.%s\n",
 			dev->name, i, RTL_R32 (TxStatus0 + (i * 4)),
-			i == atomic_read (&tp->dirty_tx) % NUM_TX_DESC ?
+			i == tp->dirty_tx % NUM_TX_DESC ?
 				" (queue head)" : "");
 
-	spin_lock_irqsave (&tp->lock, flags);
-
 	/* Stop a shared interrupt from scavenging while we are. */
-	atomic_set (&tp->cur_tx, 0);
-	atomic_set (&tp->dirty_tx, 0);
-
-	/* Dump the unsent Tx packets. */
-	for (i = 0; i < NUM_TX_DESC; i++) {
-		struct ring_info *rp = &tp->tx_info[i];
-		if (rp->skb) {
-			dev_kfree_skb (rp->skb);
-			rp->skb = NULL;
-			tp->stats.tx_dropped++;
-		}
-	}
-	
-	spin_unlock_irqrestore (&tp->lock, flags);
+	spin_lock_irq (&tp->lock);
+	rtl8139_tx_clear (tp);
+	spin_unlock_irq (&tp->lock);
 
 	/* ...and finally, reset everything */
 	rtl8139_hw_start (dev);
 }
 
 
-
 static int rtl8139_start_xmit (struct sk_buff *skb, struct device *dev)
 {
-	struct rtl8139_private *tp = (struct rtl8139_private *) dev->priv;
+	struct rtl8139_private *tp = dev->priv;
 	void *ioaddr = tp->mmio_addr;
 	int entry;
 
@@ -1602,20 +1646,28 @@
 	}
 
 	/* Calculate the next Tx descriptor entry. */
-	entry = atomic_read (&tp->cur_tx) % NUM_TX_DESC;
+	entry = tp->cur_tx % NUM_TX_DESC;
 
 	assert (tp->tx_info[entry].skb == NULL);
 
 	tp->tx_info[entry].skb = skb;
-	memcpy (tp->tx_buf[entry], skb->data, skb->len);
+	if ((long) skb->data & 3) {      /* Must use alignment buffer. */
+		/* tp->tx_info[entry].mapping = 0 */
+		memcpy (tp->tx_buf[entry], skb->data, skb->len);
+		RTL_W32 (TxAddr0 + (entry * 4),
+			 tp->tx_bufs_dma + (tp->tx_buf[entry] - tp->tx_bufs));
+	} else {
+		RTL_W32 (TxAddr0 + (entry * 4), virt_to_bus(skb->data));
+	}
 
 	/* Note: the chip doesn't have auto-pad! */
 	RTL_W32 (TxStatus0 + (entry * sizeof(u32)),
 		 tp->tx_flag | (skb->len >= ETH_ZLEN ? skb->len : ETH_ZLEN));
 
 	dev->trans_start = jiffies;
-	atomic_inc (&tp->cur_tx);
-	if ((atomic_read (&tp->cur_tx) - atomic_read (&tp->dirty_tx)) >= NUM_TX_DESC)
+	tp->cur_tx++;
+	mb();
+	if ((tp->cur_tx - NUM_TX_DESC) == tp->dirty_tx)
 		netif_stop_queue (dev);
 
 	DPRINTK ("%s: Queued Tx packet at %p size %u to slot %d.\n",
@@ -1625,24 +1677,24 @@
 }
 
 
-static inline void rtl8139_tx_interrupt (struct device *dev,
+static void rtl8139_tx_interrupt (struct device *dev,
 					 struct rtl8139_private *tp,
 					 void *ioaddr)
 {
-	unsigned int dirty_tx;
+	unsigned int dirty_tx, tx_left;
 
 	assert (dev != NULL);
 	assert (tp != NULL);
 	assert (ioaddr != NULL);
-	
-	dirty_tx = atomic_read (&tp->dirty_tx);
 
-	while ((atomic_read (&tp->cur_tx) - dirty_tx) > 0) {
+	dirty_tx = tp->dirty_tx;
+	tx_left = tp->cur_tx - dirty_tx;
+	while (tx_left > 0) {
 		int entry = dirty_tx % NUM_TX_DESC;
 		int txstatus;
 
 		txstatus = RTL_R32 (TxStatus0 + (entry * sizeof (u32)));
-		
+
 		if (!(txstatus & (TxStatOK | TxUnderrun | TxAborted)))
 			break;	/* It still hasn't been Txed */
 
@@ -1675,26 +1727,29 @@
 			tp->stats.tx_bytes += txstatus & 0x7ff;
 			tp->stats.tx_packets++;
 		}
-
 		dev_kfree_skb_irq (tp->tx_info[entry].skb);
 		tp->tx_info[entry].skb = NULL;
+
 		dirty_tx++;
-		if (netif_queue_stopped (dev) &&
-		    (atomic_read (&tp->cur_tx) - dirty_tx < NUM_TX_DESC))
-			netif_wake_queue (dev);
-		mark_bh(NET_BH);
+		tx_left--;
 	}
 
 #ifndef RTL8139_NDEBUG
-	if (atomic_read (&tp->cur_tx) - dirty_tx > NUM_TX_DESC) {
+	if (tp->cur_tx - dirty_tx > NUM_TX_DESC) {
 		printk (KERN_ERR
 		  "%s: Out-of-sync dirty pointer, %d vs. %d.\n",
-		     dev->name, dirty_tx, atomic_read (&tp->cur_tx));
+		     dev->name, dirty_tx, tp->cur_tx);
 		dirty_tx += NUM_TX_DESC;
 	}
 #endif /* RTL8139_NDEBUG */
 
-	atomic_set (&tp->dirty_tx, dirty_tx);
+	/* only wake the queue if we did work, and the queue is stopped */
+	if (tp->dirty_tx != dirty_tx) {
+		tp->dirty_tx = dirty_tx;
+		mb();
+		if (netif_queue_stopped (dev))
+			netif_wake_queue (dev);
+	}
 }
 
 /* TODO: clean this up!  Rx reset need not be this intensive */
@@ -1769,10 +1824,15 @@
 
 	while ((RTL_R8 (ChipCmd) & RxBufEmpty) == 0) {
 		int ring_offset = cur_rx % RX_BUF_LEN;
-		u32 rx_status = le32_to_cpu (*(u32 *) (rx_ring + ring_offset));
-		int rx_size = rx_status >> 16;
+		u32 rx_status;
+		unsigned int rx_size;
+		unsigned int pkt_size;
 		struct sk_buff *skb;
-		int pkt_size = rx_size - 4;
+
+		/* read size+status of next frame from DMA ring buffer */
+		rx_status = le32_to_cpu (*(u32 *) (rx_ring + ring_offset));
+		rx_size = rx_status >> 16;
+		pkt_size = rx_size - 4;
 
 		DPRINTK ("%s:  rtl8139_rx() status %4.4x, size %4.4x,"
 			 " cur %4.4x.\n", dev->name, rx_status,
@@ -1800,11 +1860,13 @@
 		if (rx_size == 0xfff0)
 			break;
 
-		/* if Rx err received, Rx process gets reset, so
-		 * we abort any further Rx processing
+		/* If Rx err or invalid rx_size/rx_status received
+		 * (which happens if we get lost in the ring),
+		 * Rx process gets reset, so we abort any further
+		 * Rx processing.
 		 */
-		if (rx_status &
-		    (RxBadSymbol | RxRunt | RxTooLong | RxCRCErr | RxBadAlign)) {
+		if ((rx_size > (MAX_ETH_FRAME_SIZE+4)) ||
+		    (!(rx_status & RxStatusOK))) {
 			rtl8139_rx_err (rx_status, dev, tp, ioaddr);
 			return;
 		}
@@ -1819,24 +1881,24 @@
 		 */
 
 		skb = dev_alloc_skb (pkt_size + 2);
-		if (skb == NULL) {
+		if (skb) {
+			skb->dev = dev;
+			skb_reserve (skb, 2);	/* 16 byte align the IP fields. */
+
+			eth_copy_and_sum (skb, &rx_ring[ring_offset + 4], pkt_size, 0);
+			skb_put (skb, pkt_size);
+
+			skb->protocol = eth_type_trans (skb, dev);
+			netif_rx (skb);
+			mark_bh(NET_BH);
+			tp->stats.rx_bytes += pkt_size ;
+			tp->stats.rx_packets++;
+		} else {
 			printk (KERN_WARNING
 				"%s: Memory squeeze, dropping packet.\n",
 				dev->name);
 			tp->stats.rx_dropped++;
-			break;
 		}
-		skb->dev = dev;
-		skb_reserve (skb, 2);	/* 16 byte align the IP fields. */
-
-		eth_copy_and_sum (skb, &rx_ring[ring_offset + 4], pkt_size, 0);
-		skb_put (skb, pkt_size);
-
-		skb->protocol = eth_type_trans (skb, dev);
-		netif_rx (skb);
-		mark_bh(NET_BH);
-		tp->stats.rx_bytes += pkt_size ;
-		tp->stats.rx_packets++;
 
 		cur_rx = (cur_rx + rx_size + 4 + 3) & ~3;
 		RTL_W16_F (RxBufPtr, cur_rx - 16);
@@ -1858,11 +1920,11 @@
 {
 	printk (KERN_DEBUG "%s: Abnormal interrupt, status %8.8x.\n",
 		dev->name, status);
-		 
+
 	assert (dev != NULL);
 	assert (tp != NULL);
 	assert (ioaddr != NULL);
-	
+
 	/* Update the error count. */
 	tp->stats.rx_missed_errors += RTL_R32 (RxMissed);
 	RTL_W32 (RxMissed, 0);
@@ -1877,9 +1939,12 @@
 			tp->full_duplex = duplex;
 			RTL_W8 (Cfg9346, Cfg9346_Unlock);
 			RTL_W8 (Config1, tp->full_duplex ? 0x60 : 0x20);
+			RTL_W8 (Cfg9346, Cfg9346_Lock);
 		}
 		status &= ~RxUnderrun;
 	}
+
+	/* XXX along with rtl8139_rx_err, are we double-counting errors? */
 	if (status &
 	    (RxUnderrun | RxOverflow | RxErr | RxFIFOOver))
 		tp->stats.rx_errors++;
@@ -1909,20 +1974,20 @@
 			       struct pt_regs *regs)
 {
 	struct device *dev = (struct device *) dev_instance;
-	struct rtl8139_private *tp = (struct rtl8139_private *) dev->priv;
+	struct rtl8139_private *tp = dev->priv;
 	int boguscnt = max_interrupt_work;
 	void *ioaddr = tp->mmio_addr;
 	int status = 0, link_changed = 0; /* avoid bogus "uninit" warning */
 
 	spin_lock (&tp->lock);
-	
+
 	do {
 		status = RTL_R16 (IntrStatus);
 
 		/* h/w no longer present (hotplug?) or major error, bail */
 		if (status == 0xFFFF)
 			break;
-		
+
 		/* Acknowledge all of the current interrupt sources ASAP, but
 		   an first get an additional status bit from CSCR. */
 		if (status & RxUnderrun)
@@ -1983,7 +2048,7 @@
 	}
 
 	spin_unlock (&tp->lock);
-	
+
 	DPRINTK ("%s: exiting interrupt, intr_status=%#4.4x.\n",
 		 dev->name, RTL_R16 (IntrStatus));
 }
@@ -1991,41 +2056,51 @@
 
 static int rtl8139_close (struct device *dev)
 {
-	struct rtl8139_private *tp = (struct rtl8139_private *) dev->priv;
+	struct rtl8139_private *tp = dev->priv;
 	void *ioaddr = tp->mmio_addr;
 	int i;
-	unsigned long flags;
+	int ret = 0;
 
 	DPRINTK ("ENTER\n");
 
 	netif_stop_queue (dev);
 	dev->start = 0;
+	if (tp->thr_pid >= 0) {
+		ret = kill_proc (tp->thr_pid, SIGTERM, 1);
+		if (ret) {
+			printk (KERN_ERR "%s: unable to signal thread\n", dev->name);
+			return ret;
+		}
+		down (&tp->thr_exited);
+	}
 
 	DPRINTK ("%s: Shutting down ethercard, status was 0x%4.4x.\n",
 			dev->name, RTL_R16 (IntrStatus));
 
-	del_timer (&tp->timer);
-	
-	spin_lock_irqsave (&tp->lock, flags);
-
-	/* Disable interrupts by clearing the interrupt mask. */
-	RTL_W16 (IntrMask, 0x0000);
+	spin_lock_irq(&tp->lock);
 
 	/* Stop the chip's Tx and Rx DMA processes. */
 	RTL_W8 (ChipCmd, (RTL_R8 (ChipCmd) & ChipCmdClear));
 
+	/* Disable interrupts by clearing the interrupt mask. */
+	RTL_W16 (IntrMask, 0x0000);
+
 	/* Update the error counts. */
 	tp->stats.rx_missed_errors += RTL_R32 (RxMissed);
 	RTL_W32 (RxMissed, 0);
 
-	spin_unlock_irqrestore (&tp->lock, flags);
-	
+	spin_unlock_irq (&tp->lock);
+
+	synchronize_irq ();
+
 	/* snooze for a small bit */
 	if (current->need_resched)
 		schedule ();
 
 	free_irq (dev->irq, dev);
 
+	rtl8139_tx_clear (tp);
+
 	for (i = 0; i < NUM_TX_DESC; i++) {
 		struct sk_buff *skb = tp->tx_info[i].skb;
 
@@ -2046,8 +2121,6 @@
 	RTL_W8 (Config1, 0x03);
 	RTL_W8 (HltClk, 'H');	/* 'R' would leave the clock running. */
 
-	MOD_DEC_USE_COUNT;
-
 	DPRINTK ("EXIT\n");
 	return 0;
 }
@@ -2055,9 +2128,8 @@
 
 static int mii_ioctl (struct device *dev, struct ifreq *rq, int cmd)
 {
-	struct rtl8139_private *tp = (struct rtl8139_private *) dev->priv;
+	struct rtl8139_private *tp = dev->priv;
 	u16 *data = (u16 *) & rq->ifr_data;
-	unsigned long flags;
 	int rc = 0;
 
 	DPRINTK ("ENTER\n");
@@ -2068,9 +2140,7 @@
 		/* Fall Through */
 
 	case SIOCDEVPRIVATE + 1:	/* Read the specified MII register. */
-		spin_lock_irqsave (&tp->lock, flags);
 		data[3] = mdio_read (dev, data[0], data[1] & 0x1f);
-		spin_unlock_irqrestore (&tp->lock, flags);
 		break;
 
 	case SIOCDEVPRIVATE + 2:	/* Write the specified MII register */
@@ -2079,9 +2149,7 @@
 			break;
 		}
 
-		spin_lock_irqsave (&tp->lock, flags);
 		mdio_write (dev, data[0], data[1] & 0x1f, data[2]);
-		spin_unlock_irqrestore (&tp->lock, flags);
 		break;
 
 	default:
@@ -2096,22 +2164,14 @@
 
 static struct net_device_stats *rtl8139_get_stats (struct device *dev)
 {
-	struct rtl8139_private *tp = (struct rtl8139_private *) dev->priv;
+	struct rtl8139_private *tp = dev->priv;
 	void *ioaddr = tp->mmio_addr;
 
 	DPRINTK ("ENTER\n");
 
-	assert (tp != NULL);
-
 	if (netif_running(dev)) {
-		unsigned long flags;
-
-		spin_lock_irqsave (&tp->lock, flags);
-
 		tp->stats.rx_missed_errors += RTL_R32 (RxMissed);
 		RTL_W32 (RxMissed, 0);
-
-		spin_unlock_irqrestore (&tp->lock, flags);
 	}
 
 	DPRINTK ("EXIT\n");
@@ -2146,7 +2206,7 @@
 
 static void rtl8139_set_rx_mode (struct device *dev)
 {
-	struct rtl8139_private *tp = (struct rtl8139_private *) dev->priv;
+	struct rtl8139_private *tp = dev->priv;
 	void *ioaddr = tp->mmio_addr;
 	u32 mc_filter[2];	/* Multicast hash filter */
 	int i, rx_mode;
@@ -2180,7 +2240,7 @@
 			set_bit (ether_crc (ETH_ALEN, mclist->dmi_addr) >> 26,
 				 mc_filter);
 	}
-	
+
 	spin_lock_irq (&tp->lock);
 
 	/* We can safely update without stopping the chip. */
@@ -2231,7 +2291,6 @@
 MODULE_DESCRIPTION ("RealTek RTL-8139 Fast Ethernet driver");
 MODULE_PARM (multicast_filter_limit, "i");
 MODULE_PARM (max_interrupt_work, "i");
-MODULE_PARM (debug, "i");
 MODULE_PARM (media, "1-" __MODULE_STRING(8) "i");
 
 int init_module(void)
diff -urN linux-2.2.19-pre7/drivers/net/Config.in linux/drivers/net/Config.in
--- linux-2.2.19-pre7/drivers/net/Config.in	Mon Dec  3 20:58:26 2001
+++ linux/drivers/net/Config.in	Mon Dec  3 20:58:53 2001
@@ -101,7 +101,11 @@
       tristate 'RealTek 8129/8139 (not 8019/8029!) support' CONFIG_RTL8139
   fi
   if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
-      tristate 'RealTek 8139too driver support' CONFIG_RTL8139TOO
+      tristate 'Alternative RealTek 8139 driver (8139too) support' CONFIG_RTL8139TOO
+      if [ "$CONFIG_RTL8139TOO" != "n" ]; then
+          bool '  Use PIO instead of MMIO' CONFIG_8139TOO_PIO
+          bool '  Support for automatic channel equalization' CONFIG_8139TOO_TUNE_TWISTER
+      fi
   fi
   bool 'Other ISA cards' CONFIG_NET_ISA
   if [ "$CONFIG_NET_ISA" = "y" ]; then
diff -urN linux-2.2.19-pre7/drivers/net/sis900.c linux/drivers/net/sis900.c
--- linux-2.2.19-pre7/drivers/net/sis900.c	Sun Dec 10 16:49:42 2000
+++ linux/drivers/net/sis900.c	Mon Dec  3 20:58:53 2001
@@ -1,6 +1,6 @@
 /* sis900.c: A SiS 900/7016 PCI Fast Ethernet driver for Linux.
    Copyright 1999 Silicon Integrated System Corporation 
-   Revision:	1.06.05	Aug 24 2000
+   Revision:	1.06.07	Jan. 8 2001
 
    Modified from the driver which is originally written by Donald Becker.
    
@@ -18,6 +18,8 @@
    preliminary Rev. 1.0 Jan. 18, 1998
    http://www.sis.com.tw/support/databook.htm
 
+   Rev 1.06.07 Jan.  8 2001 Lei-Chun Chang added RTL8201 PHY support
+   Rev 1.06.06 Sep.  6 2000 Lei-Chun Chang added ICS1893 PHY support
    Rev 1.06.05 Aug. 22 2000 Lei-Chun Chang (lcchang@sis.com.tw) modified 630E equalier workaroung rule
    Rev 1.06.03 Dec. 23 1999 Ollie Lho Third release
    Rev 1.06.02 Nov. 23 1999 Ollie Lho bug in mac probing fixed
@@ -51,7 +53,7 @@
 #include "sis900.h"
 
 static const char *version =
-"sis900.c: v1.06.05  08/24/00\n";
+"sis900.c: v1.06.07  01/08/01\n";
 
 static int max_interrupt_work = 20;
 static int multicast_filter_limit = 128;
@@ -82,6 +84,8 @@
 
 static void sis900_read_mode(struct device *net_dev, int phy_addr, int *speed, int *duplex);
 static void amd79c901_read_mode(struct device *net_dev, int phy_addr, int *speed, int *duplex);
+static void ics1893_read_mode(struct device *net_dev, int phy_addr, int *speed, int *duplex);
+static void rtl8201_read_mode(struct device *net_dev, int phy_addr, int *speed, int *duplex);
 
 static struct mii_chip_info {
 	const char * name;
@@ -93,6 +97,8 @@
 	{"SiS 7014 Physical Layer Solution", 0x0016, 0xf830,sis900_read_mode},
 	{"AMD 79C901 10BASE-T PHY",  0x0000, 0x35b9, amd79c901_read_mode},
 	{"AMD 79C901 HomePNA PHY",   0x0000, 0x35c8, amd79c901_read_mode},
+	{"ICS 1893 Integrated PHYceiver"   , 0x0015, 0xf441,ics1893_read_mode},
+	{"RTL 8201 10/100Mbps Phyceiver"   , 0x0000, 0x8201,rtl8201_read_mode},
 	{0,},
 };
 
@@ -299,12 +305,10 @@
 		return NULL;
 
 	pci_read_config_byte(pci_dev, PCI_CLASS_REVISION, &revision);
-	if (revision == SIS630E_REV)
+	if (revision == SIS630E_REV || revision == SIS630EA1_REV)
 		ret = sis630e_get_mac_addr(pci_dev, net_dev);
-	else if (revision == SIS630EA1_REV) {
+	else if (revision == SIS630S_REV)
 		ret = sis630e_get_mac_addr(pci_dev, net_dev);
-		printk(KERN_INFO "using 630ea1\n");
-	}
 	else
 		ret = sis900_get_mac_addr(pci_dev, net_dev);
 
@@ -381,7 +385,8 @@
 
 		/* search our mii table for the current mii */ 
 		for (i = 0; mii_chip_table[i].phy_id1; i++)
-			if (phy_id0 == mii_chip_table[i].phy_id0) {
+			if (phy_id0 == mii_chip_table[i].phy_id0 &&
+			    phy_id1 == mii_chip_table[i].phy_id1) {
 				struct mii_phy * mii_phy;
 
 				printk(KERN_INFO
@@ -956,6 +961,71 @@
 			printk(KERN_INFO "%s: Media Link Off\n", net_dev->name);
 	}
 }
+/* ICS1893 PHY use Quick Poll Detailed Status Register to get its status */
+static void ics1893_read_mode(struct device *net_dev, int phy_addr, int *speed, int *duplex)
+{
+	int i = 0;
+	u32 status;
+
+	/* MII_QPDSTS is Latched, read twice in succession will reflect the current state */
+	for (i = 0; i < 2; i++)
+		status = mdio_read(net_dev, phy_addr, MII_QPDSTS);
+
+	if (status & MII_STSICS_SPD)
+		*speed = HW_SPEED_100_MBPS;
+	else
+		*speed = HW_SPEED_10_MBPS;
+
+	if (status & MII_STSICS_DPLX)
+		*duplex = FDX_CAPABLE_FULL_SELECTED;
+	else
+		*duplex = FDX_CAPABLE_HALF_SELECTED;
+
+	if (status & MII_STSICS_LINKSTS)
+		printk(KERN_INFO "%s: Media Link On %s %s-duplex \n",
+		       net_dev->name,
+		       *speed == HW_SPEED_100_MBPS ?
+		       "100mbps" : "10mbps",
+		       *duplex == FDX_CAPABLE_FULL_SELECTED ?
+		       "full" : "half");
+	else
+		printk(KERN_INFO "%s: Media Link Off\n", net_dev->name);
+}
+
+static void rtl8201_read_mode(struct device *net_dev, int phy_addr, int *speed, int *duplex)
+{
+	u32 status;
+
+	status = mdio_read(net_dev, phy_addr, MII_STATUS);
+
+	if (status & MII_STAT_CAN_TX_FDX) {
+		*speed = HW_SPEED_100_MBPS;
+		*duplex = FDX_CAPABLE_FULL_SELECTED;
+	}
+	else if (status & MII_STAT_CAN_TX) {
+		*speed = HW_SPEED_100_MBPS;
+		*duplex = FDX_CAPABLE_HALF_SELECTED;
+	}
+	else if (status & MII_STAT_CAN_T_FDX) {
+		*speed = HW_SPEED_10_MBPS;
+		*duplex = FDX_CAPABLE_FULL_SELECTED;
+	}
+	else if (status & MII_STAT_CAN_T) {
+		*speed = HW_SPEED_10_MBPS;
+		*duplex = FDX_CAPABLE_HALF_SELECTED;
+	}
+
+	if (status & MII_STAT_LINK)
+		printk(KERN_INFO "%s: Media Link On %s %s-duplex \n",
+		       net_dev->name,
+		       *speed == HW_SPEED_100_MBPS ?
+		       "100mbps" : "10mbps",
+		       *duplex == FDX_CAPABLE_FULL_SELECTED ?
+		       "full" : "half");
+	else
+		printk(KERN_INFO "%s: Media Link Off\n", net_dev->name);
+}
+
 static void sis900_tx_timeout(struct device *net_dev)
 {
 	struct sis900_private *sis_priv = (struct sis900_private *)net_dev->priv;
diff -urN linux-2.2.19-pre7/drivers/net/sis900.h linux/drivers/net/sis900.h
--- linux-2.2.19-pre7/drivers/net/sis900.h	Sun Dec 10 16:49:42 2000
+++ linux/drivers/net/sis900.h	Mon Dec  3 20:58:53 2001
@@ -168,6 +168,12 @@
 	MII_MASK    = 0x0013, MII_RESV    = 0x0014
 };
 
+/* mii registers specific to ICS 1893 */
+enum ics_mii_registers {
+	MII_EXTCTRL  = 0x0010, MII_QPDSTS = 0x0011, MII_10BTOP = 0x0012,
+	MII_EXTCTRL2 = 0x0013
+};
+
 /* mii registers specific to AMD 79C901 */
 enum amd_mii_registers {
 	MII_STATUS_SUMMARY = 0x0018
@@ -212,13 +218,19 @@
 	MII_STSOUT_SPD       = 0x0080, MII_STSOUT_DPLX = 0x0040
 };
 
+enum mii_stsics_register_bits {
+	MII_STSICS_SPD  = 0x8000, MII_STSICS_DPLX = 0x4000,
+	MII_STSICS_LINKSTS = 0x0001
+};
+
 enum mii_stssum_register_bits {
 	MII_STSSUM_LINK = 0x0008, MII_STSSUM_DPLX = 0x0004,
 	MII_STSSUM_AUTO = 0x0002, MII_STSSUM_SPD  = 0x0001
 };
 
 enum sis630_revision_id {
-	SIS630E_REV = 0x81, SIS630EA1_REV = 0x83
+	SIS630E_REV = 0x81, SIS630EA1_REV = 0x83,
+	SIS630S_REV = 0x82
 };
 
 #define FDX_CAPABLE_DUPLEX_UNKNOWN      0
diff -urN linux-2.2.19-pre7/drivers/s390/net/ctc.c linux/drivers/s390/net/ctc.c
--- linux-2.2.19-pre7/drivers/s390/net/ctc.c	Sun Dec 10 16:49:42 2000
+++ linux/drivers/s390/net/ctc.c	Mon Dec  3 20:58:53 2001
@@ -276,8 +276,6 @@
 typedef struct net_device  net_device;
 #else
 typedef struct device  net_device;
-typedef struct wait_queue* wait_queue_head_t;
-#define init_waitqueue_head(nothing)
 #endif
 
 struct adapterlist{ 
diff -urN linux-2.2.19-pre7/drivers/usb/Config.in linux/drivers/usb/Config.in
--- linux-2.2.19-pre7/drivers/usb/Config.in	Mon Dec  3 20:58:27 2001
+++ linux/drivers/usb/Config.in	Mon Dec  3 20:59:00 2001
@@ -36,16 +36,23 @@
    dep_tristate '  USB Printer support' CONFIG_USB_PRINTER $CONFIG_USB
 
    comment 'USB Human Interface Devices (HID)'
-   if [ "$CONFIG_INPUT" = "n" ]; then
-      comment '  Input core support is needed for USB HID'
-   else
-      dep_tristate '  USB Human Interface Device (full HID) support' CONFIG_USB_HID $CONFIG_USB $CONFIG_INPUT
-      if [ "$CONFIG_USB_HID" != "y" ]; then
-         dep_tristate '  USB HIDBP Keyboard (basic) support' CONFIG_USB_KBD $CONFIG_USB $CONFIG_INPUT
-         dep_tristate '  USB HIDBP Mouse (basic) support' CONFIG_USB_MOUSE $CONFIG_USB $CONFIG_INPUT
-      fi
-      dep_tristate '  Wacom Intuos/Graphire tablet support' CONFIG_USB_WACOM $CONFIG_USB $CONFIG_INPUT
+   dep_tristate '  USB Human Interface Device (full HID) support' CONFIG_USB_HID $CONFIG_USB
+   if [ "$CONFIG_USB_HID" != "y" ]; then
+      dep_tristate '  USB HIDBP Keyboard (basic) support' CONFIG_USB_KBD $CONFIG_USB
+      dep_tristate '  USB HIDBP Mouse (basic) support' CONFIG_USB_MOUSE $CONFIG_USB
    fi
+   if [ "$CONFIG_VT" = "y" ]; then
+      dep_tristate '  Keyboard support' CONFIG_INPUT_KEYBDEV $CONFIG_USB $CONFIG_USB_HID
+   fi
+   dep_tristate '  Mouse support' CONFIG_INPUT_MOUSEDEV $CONFIG_USB $CONFIG_USB_HID
+   if [ "$CONFIG_INPUT_MOUSEDEV" != "n" ]; then
+      int '   Horizontal screen resolution' CONFIG_INPUT_MOUSEDEV_SCREEN_X 1024
+      int '   Vertical screen resolution' CONFIG_INPUT_MOUSEDEV_SCREEN_Y 768
+   fi
+   dep_tristate '  Joystick support' CONFIG_INPUT_JOYDEV $CONFIG_USB $CONFIG_USB_HID
+   dep_tristate '  Logitech WingMan Force joystick support' CONFIG_USB_WMFORCE $CONFIG_USB $CONFIG_USB_HID
+   dep_tristate '  Wacom Intuos/Graphire tablet support' CONFIG_USB_WACOM $CONFIG_USB $CONFIG_USB_HID
+   dep_tristate '  Event interface support' CONFIG_INPUT_EVDEV $CONFIG_USB $CONFIG_USB_HID
 
    comment 'USB Imaging devices'
    dep_tristate '  USB Kodak DC-2xx Camera support' CONFIG_USB_DC2XX $CONFIG_USB
diff -urN linux-2.2.19-pre7/drivers/usb/acm.c linux/drivers/usb/acm.c
--- linux-2.2.19-pre7/drivers/usb/acm.c	Sun Dec 10 16:49:43 2000
+++ linux/drivers/usb/acm.c	Mon Dec  3 20:59:00 2001
@@ -503,12 +503,12 @@
 		if (ifdata->bInterfaceClass != 10 || ifdata->bNumEndpoints != 2) {
 			ifcom = cfacm->interface[1].altsetting + 0;
 			ifdata = cfacm->interface[0].altsetting + 0;
-			if (ifdata->bInterfaceClass != 10 || ifdata->bNumEndpoints != 2)
+			if (ifdata->bInterfaceClass != 10 || ifdata->bNumEndpoints < 2)
 				continue;
 		}
 
 		if (ifcom->bInterfaceClass != 2 || ifcom->bInterfaceSubClass != 2 ||
-		    ifcom->bInterfaceProtocol != 1 || ifcom->bNumEndpoints != 1)
+		    ifcom->bInterfaceProtocol != 1 || ifcom->bNumEndpoints < 1)
 			continue;
 
 		epctrl = ifcom->endpoint + 0;
diff -urN linux-2.2.19-pre7/drivers/usb/keybdev.c linux/drivers/usb/keybdev.c
--- linux-2.2.19-pre7/drivers/usb/keybdev.c	Sun Dec 10 16:49:43 2000
+++ linux/drivers/usb/keybdev.c	Mon Dec  3 20:59:01 2001
@@ -60,6 +60,7 @@
 };
 
 #ifdef CONFIG_INPUT_ADBHID
+#ifdef CONFIG_MAC_ADBKEYCODES
 extern int mac_hid_keyboard_sends_linux_keycodes(void);
 
 static unsigned char mac_keycodes[256] = {
@@ -76,19 +77,20 @@
 	  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
 	  0,  0,  0,  0,  0, 94,  0, 93,  0,  0,  0,  0,  0,  0,104,102
 };
-
-#ifdef CONFIG_INPUT_MOUSEDEV
+#endif /* CONFIG_MAC_ADBKEYCODES */
+#ifdef CONFIG_MAC_EMUMOUSEBTN
 extern int mac_hid_mouse_emulate_buttons(int, unsigned int, int);
-#endif /* CONFIG_INPUT_MOUSEDEV */
+#endif /* CONFIG_MAC_EMUMOUSEBTN */
 #endif /* CONFIG_INPUT_ADBHID */
 
 static int emulate_raw(unsigned int keycode, int down)
 {
 #ifdef CONFIG_INPUT_ADBHID
-#ifdef CONFIG_INPUT_MOUSEDEV
+#ifdef CONFIG_MAC_EMUMOUSEBTN
 	if (mac_hid_mouse_emulate_buttons(1, keycode, down))
 		return 0;
-#endif /* CONFIG_INPUT_MOUSEDEV */
+#endif /* CONFIG_MAC_EMUMOUSEBTN */
+#ifdef CONFIG_MAC_ADBKEYCODES
 	if (!mac_hid_keyboard_sends_linux_keycodes()) {
 		if (keycode > 255 || !mac_keycodes[keycode])
 			return -1;
@@ -97,6 +99,7 @@
 
 		return 0;
 	}
+#endif /* CONFIG_MAC_ADBKEYCODES */
 #endif /* CONFIG_INPUT_ADBHID */
 	if (keycode > 255 || !x86_keycodes[keycode])
 		return -1; 
diff -urN linux-2.2.19-pre7/drivers/usb/usb.c linux/drivers/usb/usb.c
--- linux-2.2.19-pre7/drivers/usb/usb.c	Mon Dec  3 20:58:27 2001
+++ linux/drivers/usb/usb.c	Mon Dec  3 20:59:01 2001
@@ -296,11 +296,13 @@
 	else
 		dev->bus->bandwidth_int_reqs++;
 	urb->bandwidth = bustime;
-	
-	dbg("bw_alloc increased by %d to %d for %d requesters",
+
+#ifdef USB_BANDWIDTH_MESSAGES
+	dbg("bandwidth alloc increased by %d to %d for %d requesters",
 		bustime,
 		dev->bus->bandwidth_allocated,
 		dev->bus->bandwidth_int_reqs + dev->bus->bandwidth_isoc_reqs);
+#endif
 }
 
 /*
@@ -316,10 +318,12 @@
 	else
 		dev->bus->bandwidth_int_reqs--;
 
-	dbg("bw_alloc reduced by %d to %d for %d requesters",
+#ifdef USB_BANDWIDTH_MESSAGES
+	dbg("bandwidth alloc reduced by %d to %d for %d requesters",
 		urb->bandwidth,
 		dev->bus->bandwidth_allocated,
 		dev->bus->bandwidth_int_reqs + dev->bus->bandwidth_isoc_reqs);
+#endif
 	urb->bandwidth = 0;
 }
 
diff -urN linux-2.2.19-pre7/drivers/video/tgafb.c linux/drivers/video/tgafb.c
--- linux-2.2.19-pre7/drivers/video/tgafb.c	Mon Aug  9 12:04:40 1999
+++ linux/drivers/video/tgafb.c	Mon Dec  3 20:59:01 2001
@@ -59,7 +59,7 @@
 static int current_par_valid = 0;
 static struct display disp;
 
-static char __initdata default_fontname[40] = { 0 };
+static char default_fontname[40] __initdata = { 0 };
 static struct fb_var_screeninfo default_var;
 static int default_var_valid = 0;
 
@@ -1083,6 +1083,11 @@
 	fb_info.gen.info.modename);
 }
 
+    /*
+     *  Modularisation
+     */
+
+#ifdef MODULE
 
     /*
      *  Cleanup
@@ -1093,12 +1098,6 @@
     unregister_framebuffer(info);
 }
 
-
-    /*
-     *  Modularisation
-     */
-
-#ifdef MODULE
 int init_module(void)
 {
     tgafb_init();
@@ -1107,7 +1106,7 @@
 
 void cleanup_module(void)
 {
-    tgafb_cleanup(void);
+    tgafb_cleanup(&fb_info.gen.info);
 }
 #endif /* MODULE */
 
diff -urN linux-2.2.19-pre7/fs/lockd/svcsubs.c linux/fs/lockd/svcsubs.c
--- linux-2.2.19-pre7/fs/lockd/svcsubs.c	Sun Dec 10 16:49:44 2000
+++ linux/fs/lockd/svcsubs.c	Mon Dec  3 20:59:01 2001
@@ -44,6 +44,10 @@
  * Note that we open the file O_RDONLY even when creating write locks.
  * This is not quite right, but for now, we assume the client performs
  * the proper R/W checking.
+ *
+ * BEWARE:
+ * The cast to struct knfs_fh in this routine, imposes an alignment
+ * requirement on (struct nfs_fh)->data for some platforms.
  */
 u32
 nlm_lookup_file(struct svc_rqst *rqstp, struct nlm_file **result,
@@ -63,8 +67,7 @@
 	down(&nlm_file_sema);
 
 	for (file = nlm_files[hash]; file; file = file->f_next) {
-		if (file->f_handle.fh_dcookie == fh->fh_dcookie &&
-		    !memcmp(&file->f_handle, fh, sizeof(*fh)))
+		if (!memcmp(&file->f_handle, fh, sizeof(*fh)))
 			goto found;
 	}
 
diff -urN linux-2.2.19-pre7/include/asm-alpha/smp.h linux/include/asm-alpha/smp.h
--- linux-2.2.19-pre7/include/asm-alpha/smp.h	Sun Dec 10 16:49:44 2000
+++ linux/include/asm-alpha/smp.h	Mon Dec  3 20:59:01 2001
@@ -4,6 +4,7 @@
 #ifdef __SMP__
 
 #include <linux/tasks.h>
+#include <linux/sched.h>
 #include <asm/init.h>
 #include <asm/pal.h>
 
diff -urN linux-2.2.19-pre7/include/asm-sparc/unistd.h linux/include/asm-sparc/unistd.h
--- linux-2.2.19-pre7/include/asm-sparc/unistd.h	Thu Apr 22 19:24:52 1999
+++ linux/include/asm-sparc/unistd.h	Mon Dec  3 20:59:01 2001
@@ -1,4 +1,4 @@
-/* $Id: unistd.h,v 1.55 1999/04/07 17:14:15 davem Exp $ */
+/* $Id: unistd.h,v 1.55.2.1 2001/01/11 15:44:37 davem Exp $ */
 #ifndef _SPARC_UNISTD_H
 #define _SPARC_UNISTD_H
 
@@ -59,7 +59,7 @@
 #define __NR_dup                 41 /* Common                                      */
 #define __NR_pipe                42 /* Common                                      */
 #define __NR_times               43 /* Implemented via getrusage() in SunOS        */
-/* #define __NR_profil           44    Common                                      */
+/* #define __NR_getuid32         44    Linux Sparc32 Specific                      */
 #define __NR_umount2             45 /* Linux Specific                              */
 #define __NR_setgid              46 /* Implemented via setregid() in SunOS         */
 #define __NR_getgid              47 /* Common                                      */
@@ -170,7 +170,7 @@
 /* #define __NR_putmsg          152    SunOS Specific                              */
 #define __NR_poll               153 /* Common                                      */
 /* #define __NR_ni_syscall      154    ENOSYS under SunOS                          */
-/* #define __NR_nfssvc          155    SunOS Specific                              */
+/* #define __NR_fcntl64         155    Linux Sparc32 Specific                      */
 /* #define __NR_getdirentries   156    SunOS Specific                              */
 #define __NR_statfs             157 /* Common                                      */
 #define __NR_fstatfs            158 /* Common                                      */
diff -urN linux-2.2.19-pre7/include/asm-sparc64/unistd.h linux/include/asm-sparc64/unistd.h
--- linux-2.2.19-pre7/include/asm-sparc64/unistd.h	Thu Apr 22 19:24:52 1999
+++ linux/include/asm-sparc64/unistd.h	Mon Dec  3 20:59:01 2001
@@ -1,4 +1,4 @@
-/* $Id: unistd.h,v 1.28 1999/04/07 17:14:19 davem Exp $ */
+/* $Id: unistd.h,v 1.28.2.1 2001/01/11 15:44:37 davem Exp $ */
 #ifndef _SPARC64_UNISTD_H
 #define _SPARC64_UNISTD_H
 
@@ -59,7 +59,7 @@
 #define __NR_dup                 41 /* Common                                      */
 #define __NR_pipe                42 /* Common                                      */
 #define __NR_times               43 /* Implemented via getrusage() in SunOS        */
-/* #define __NR_profil           44    Common                                      */
+/* #define __NR_getuid32         44    Linux Sparc32 Specific                      */
 #define __NR_umount2             45 /* Linux Specific                              */
 #define __NR_setgid              46 /* Implemented via setregid() in SunOS         */
 #define __NR_getgid              47 /* Common                                      */
@@ -170,7 +170,7 @@
 /* #define __NR_putmsg          152    SunOS Specific                              */
 #define __NR_poll               153 /* Common                                      */
 /* #define __NR_ni_syscall      154    ENOSYS under SunOS                          */
-/* #define __NR_nfssvc          155    SunOS Specific                              */
+/* #define __NR_fcntl64         155    Linux Sparc32 Specific                      */
 /* #define __NR_getdirentries   156    SunOS Specific                              */
 #define __NR_statfs             157 /* Common                                      */
 #define __NR_fstatfs            158 /* Common                                      */
diff -urN linux-2.2.19-pre7/include/linux/nfs.h linux/include/linux/nfs.h
--- linux-2.2.19-pre7/include/linux/nfs.h	Mon Dec  3 20:58:27 2001
+++ linux/include/linux/nfs.h	Mon Dec  3 20:59:01 2001
@@ -95,7 +95,7 @@
 #define NFS_MAXFHSIZE		64
 struct nfs_fh {
 	unsigned int		size;
-	unsigned char		data[NFS_MAXFHSIZE];
+	unsigned int		data[NFS_MAXFHSIZE / sizeof(unsigned int)];
 };
 
 enum nfs3_stable_how {
diff -urN linux-2.2.19-pre7/include/linux/nfs3.h linux/include/linux/nfs3.h
--- linux-2.2.19-pre7/include/linux/nfs3.h	Sun Dec 10 16:49:44 2000
+++ linux/include/linux/nfs3.h	Mon Dec  3 20:59:01 2001
@@ -58,6 +58,11 @@
 	NF3BAD  = 8
 };
 
+struct nfs3_fh {
+	unsigned short		size;
+	unsigned char		data[NFS3_FHSIZE];
+};
+
 #define NFS3_VERSION		3
 #define NFS3PROC_NULL		0
 #define NFS3PROC_GETATTR	1
diff -urN linux-2.2.19-pre7/include/linux/nfs_mount.h linux/include/linux/nfs_mount.h
--- linux-2.2.19-pre7/include/linux/nfs_mount.h	Sun Dec 10 16:49:44 2000
+++ linux/include/linux/nfs_mount.h	Mon Dec  3 20:59:01 2001
@@ -8,9 +8,9 @@
  *
  *  structure passed from user-space to kernel-space during an nfs mount
  */
-#include <linux/nfs.h>
+#include <linux/in.h>
 #include <linux/nfs2.h>
-#include <linux/nfs_fs.h>
+#include <linux/nfs3.h>
 
 /*
  * WARNING!  Do not delete or change the order of these fields.  If
@@ -42,7 +42,7 @@
 	char		hostname[256];		/* 1 */
 	int		namlen;			/* 2 */
 	unsigned int	bsize;			/* 3 */
-	struct nfs_fh	root;			/* 4 */
+	struct nfs3_fh	root;			/* 4 */
 };
 
 /* bits in the flags field */
diff -urN linux-2.2.19-pre7/net/ipv4/icmp.c linux/net/ipv4/icmp.c
--- linux-2.2.19-pre7/net/ipv4/icmp.c	Sun Dec 10 16:49:44 2000
+++ linux/net/ipv4/icmp.c	Mon Dec  3 20:59:01 2001
@@ -989,13 +989,21 @@
 
 int icmp_chkaddr(struct sk_buff *skb)
 {
-	struct icmphdr *icmph=(struct icmphdr *)(skb->nh.raw + skb->nh.iph->ihl*4);
+	unsigned short size = skb->nh.iph->ihl*4;
+	unsigned short clen = ntohs(skb->nh.iph->tot_len) - size;
+	struct icmphdr *icmph=(struct icmphdr *)(skb->nh.raw + size);
 	struct iphdr *iph = (struct iphdr *) (icmph + 1);
-	void (*handler)(struct icmphdr *icmph, struct sk_buff *skb, int len) = icmp_pointers[icmph->type].handler;
+	void (*handler)(struct icmphdr *icmph, struct sk_buff *skb, int len);
 
+	if (clen < sizeof(struct icmphdr)) return 0;
+	handler = icmp_pointers[icmph->type].handler;
 	if (handler == icmp_unreach || handler == icmp_redirect) {
 		struct sock *sk;
-
+		
+		clen -= sizeof(struct icmphdr);
+		if (clen < sizeof(struct iphdr) ||
+			clen < iph->ihl * 4 + sizeof(struct udphdr))
+			return 0;
 		switch (iph->protocol) {
 		case IPPROTO_TCP:
 			{
diff -urN linux-2.2.19-pre7/net/ipv4/igmp.c linux/net/ipv4/igmp.c
--- linux-2.2.19-pre7/net/ipv4/igmp.c	Mon Aug  9 12:05:10 1999
+++ linux/net/ipv4/igmp.c	Mon Dec  3 20:59:01 2001
@@ -8,7 +8,7 @@
  *	the older version didn't come out right using gcc 2.5.8, the newer one
  *	seems to fall out with gcc 2.6.2.
  *
- *	Version: $Id: igmp.c,v 1.30.2.1 1999/07/23 15:29:22 davem Exp $
+ *	Version: $Id: igmp.c,v 1.30.2.2 2001/01/10 10:04:07 davem Exp $
  *
  *	Authors:
  *		Alan Cox <Alan.Cox@linux.org>
@@ -442,8 +442,8 @@
 	im->timer.function=&igmp_timer_expire;
 	im->unsolicit_count = IGMP_Unsolicited_Report_Count;
 	im->reporter = 0;
-	im->loaded = 0;
 #endif
+	im->loaded = 0;
 	im->next=in_dev->mc_list;
 	in_dev->mc_list=im;
 	igmp_group_added(im);
diff -urN linux-2.2.19-pre7/net/ipv4/ip_masq.c linux/net/ipv4/ip_masq.c
--- linux-2.2.19-pre7/net/ipv4/ip_masq.c	Mon Dec  3 20:58:27 2001
+++ linux/net/ipv4/ip_masq.c	Mon Dec  3 20:59:01 2001
@@ -1487,6 +1487,7 @@
 	__u16	        *pptr;	/* port numbers from TCP/UDP contained header */
 	struct ip_masq	*ms;
 	unsigned short   len   = ntohs(iph->tot_len) - (iph->ihl * 4);
+	unsigned short	clen, csize;
 
  	IP_MASQ_DEBUG(2, "Incoming forward ICMP (%d,%d) %X -> %X\n",
 	        icmph->type, ntohs(icmp_id(icmph)),
@@ -1576,16 +1577,22 @@
 		return 0;
 
 	/* Now find the contained IP header */
+	clen = len - sizeof(struct icmphdr);
+	if (clen < sizeof(struct iphdr)) return -1;
 	ciph = (struct iphdr *) (icmph + 1);
+	csize = ciph->ihl << 2;
+	if (clen < csize) return -1;
 
 #ifdef CONFIG_IP_MASQUERADE_ICMP
 	if (ciph->protocol == IPPROTO_ICMP) {
 		/*
 		 * This section handles ICMP errors for ICMP packets
 		 */
-		struct icmphdr  *cicmph = (struct icmphdr *)((char *)ciph + 
-							     (ciph->ihl<<2));
+		struct icmphdr  *cicmph;
 
+		if (clen < csize + sizeof(struct icmphdr)) return -1;
+
+		cicmph = (struct icmphdr *)((char *)ciph + csize);
 
 		IP_MASQ_DEBUG(2, "fw icmp/icmp rcv %X->%X id %d type %d\n",
 		       ntohl(ciph->saddr),
@@ -1637,12 +1644,15 @@
 	if ((ciph->protocol != IPPROTO_UDP) && (ciph->protocol != IPPROTO_TCP))
 		return 0;
 
+	/* This is a hack: we need at least the TCP/UDP ports */
+	if (clen < csize + sizeof(struct udphdr)) return -1;
+
 	/*
 	 * Find the ports involved - this packet was
 	 * incoming so the ports are right way round
 	 * (but reversed relative to outer IP header!)
 	 */
-	pptr = (__u16 *)&(((char *)ciph)[ciph->ihl*4]);
+	pptr = (__u16 *)&(((char *)ciph)[csize]);
 #if 0
 	if (ntohs(pptr[1]) < PORT_MASQ_BEGIN ||
  	    ntohs(pptr[1]) > PORT_MASQ_END)
@@ -1745,6 +1755,7 @@
 	__u16	        *pptr;	/* port numbers from TCP/UDP contained header */
 	struct ip_masq	*ms;
 	unsigned short   len   = ntohs(iph->tot_len) - (iph->ihl * 4);
+	unsigned short	clen, csize;
 
 
  	IP_MASQ_DEBUG(2, "icmp in/rev (%d,%d) %X -> %X\n",
@@ -1819,7 +1830,11 @@
 	 * Now find the contained IP header
 	 */
 
+	clen = len - sizeof(struct icmphdr);
+	if (clen < sizeof(struct iphdr)) return -1;
 	ciph = (struct iphdr *) (icmph + 1);
+	csize = ciph->ihl << 2;
+	if (clen < csize) return -1;
 
 #ifdef CONFIG_IP_MASQUERADE_ICMP
 	if (ciph->protocol == IPPROTO_ICMP) {
@@ -1828,9 +1843,11 @@
 		 *
 		 * First get a new ICMP header structure out of the IP packet
 		 */
-		struct icmphdr  *cicmph = (struct icmphdr *)((char *)ciph + 
-							     (ciph->ihl<<2));
+		struct icmphdr  *cicmph;
 
+		if (clen < csize + sizeof(struct icmphdr)) return -1;
+
+		cicmph = (struct icmphdr *)((char *)ciph +  csize);
 
 		IP_MASQ_DEBUG(2, "rv icmp/icmp rcv %X->%X id %d type %d\n",
 		       ntohl(ciph->saddr),
@@ -1889,11 +1906,14 @@
 	    (ciph->protocol != IPPROTO_TCP))
 		return 0;
 
+	/* This is a hack: we need at least the TCP/UDP ports */
+	if (clen < csize + sizeof(struct udphdr)) return -1;
+
 	/*
 	 * Find the ports involved - remember this packet was
 	 * *outgoing* so the ports are reversed (and addresses)
 	 */
-	pptr = (__u16 *)&(((char *)ciph)[ciph->ihl*4]);
+	pptr = (__u16 *)&(((char *)ciph)[csize]);
 	if (ntohs(pptr[0]) < PORT_MASQ_BEGIN ||
  	    ntohs(pptr[0]) > PORT_MASQ_END)
  		return 0;
diff -urN linux-2.2.19-pre7/net/ipv4/tcp_ipv4.c linux/net/ipv4/tcp_ipv4.c
--- linux-2.2.19-pre7/net/ipv4/tcp_ipv4.c	Sun Dec 10 16:49:44 2000
+++ linux/net/ipv4/tcp_ipv4.c	Mon Dec  3 20:59:01 2001
@@ -1109,6 +1109,8 @@
 	struct tcphdr *th = (struct tcphdr *)(skb->nh.raw + iph->ihl*4);
 	struct sock *sk;
 
+	if (ntohs(iph->tot_len) - iph->ihl*4 < sizeof(struct tcphdr))
+		return 0;
 	sk = tcp_v4_lookup(iph->saddr, th->source, iph->daddr,
 			   th->dest, skb->dev->ifindex);
 
diff -urN linux-2.2.19-pre7/net/ipv4/udp.c linux/net/ipv4/udp.c
--- linux-2.2.19-pre7/net/ipv4/udp.c	Wed Jun  7 14:26:44 2000
+++ linux/net/ipv4/udp.c	Mon Dec  3 20:59:01 2001
@@ -159,7 +159,7 @@
 		next:
 		}
 		result = best;
-		for(;; result += UDP_HTABLE_SIZE) {
+		for(i = 0; i < (1 << 16)/UDP_HTABLE_SIZE; i++, result += UDP_HTABLE_SIZE) {
 			if (result > sysctl_local_port_range[1])
 				result = sysctl_local_port_range[0]
 					+ ((result - sysctl_local_port_range[0]) &
@@ -167,6 +167,8 @@
 			if (!udp_lport_inuse(result))
 				break;
 		}
+		if (i >= (1 << 16) / UDP_HTABLE_SIZE)
+			goto fail;
 gotit:
 		udp_port_rover = snum = result;
 	} else {
@@ -1044,6 +1046,8 @@
 	struct udphdr *uh = (struct udphdr *)(skb->nh.raw + iph->ihl*4);
 	struct sock *sk;
 
+	if (ntohs(iph->tot_len) - iph->ihl*4 < sizeof(struct udphdr))
+		return 0;
 	sk = udp_v4_lookup(iph->saddr, uh->source, iph->daddr, uh->dest, skb->dev->ifindex);
 	if (!sk)
 		return 0;
diff -urN linux-2.2.19-pre7/scripts/lxdialog/checklist.c linux/scripts/lxdialog/checklist.c
--- linux-2.2.19-pre7/scripts/lxdialog/checklist.c	Mon Feb  1 12:03:20 1999
+++ linux/scripts/lxdialog/checklist.c	Mon Dec  3 20:59:03 2001
@@ -51,6 +51,10 @@
     mvwaddch(win, choice, item_x, item[0]);
     wattrset (win, selected ? item_selected_attr : item_attr);
     waddstr (win, (char *)item+1);
+    if (selected) {
+	wmove (win, choice, check_x+1);
+	wrefresh (win);
+    }
 }
 
 /*
@@ -104,8 +108,8 @@
     print_button (dialog, "Select", y, x, selected == 0);
     print_button (dialog, " Help ", y, x + 14, selected == 1);
 
-    wmove(dialog, y, x+1 + 14*selected);
-    wrefresh (dialog);
+    /*    wmove(dialog, y, x+1 + 14*selected);
+    wrefresh (dialog);*/
 }
 
 /*
@@ -215,7 +219,7 @@
     print_buttons(dialog, height, width, 0);
 
     while (key != ESC) {
-	key = wgetch (dialog);
+	key = wgetch (list);
 
     	for (i = 0; i < max_choice; i++)
             if (toupper(key) == toupper(items[(scroll+i)*3+1][0]))
@@ -245,7 +249,7 @@
     		    print_arrows(dialog, choice, item_no, scroll,
 				box_y, box_x + check_x + 5, list_height);
 
-		    wrefresh (dialog);
+		    wnoutrefresh (dialog);
 
 		    continue;	/* wait for another key press */
 		} else
@@ -273,7 +277,7 @@
     		    print_arrows(dialog, choice, item_no, scroll,
 				box_y, box_x + check_x + 5, list_height);
 
-		    wrefresh (dialog);
+		    wnoutrefresh (dialog);
 
 		    continue;	/* wait for another key press */
 		} else
@@ -288,7 +292,7 @@
 		print_item (list, items[(scroll + choice) * 3 + 1],
 			    status[scroll + choice], choice, TRUE);
 		wnoutrefresh (list);
-		wrefresh (dialog);
+		wnoutrefresh (dialog);
 	    }
 	    continue;		/* wait for another key press */
 	}
@@ -306,7 +310,7 @@
 			? 1 : (button > 1 ? 0 : button);
 
 	    print_buttons(dialog, height, width, button);
-	    wrefresh (dialog);
+	    wnoutrefresh (dialog);
 	    break;
 	case 'S':
 	case 's':
@@ -329,7 +333,7 @@
 		    }
 		}
 		wnoutrefresh (list);
-		wrefresh (dialog);
+		wnoutrefresh (dialog);
             
 		for (i = 0; i < item_no; i++) {
 		    if (status[i]) {
diff -urN linux-2.2.19-pre7/scripts/lxdialog/menubox.c linux/scripts/lxdialog/menubox.c
--- linux-2.2.19-pre7/scripts/lxdialog/menubox.c	Mon Feb  1 12:03:20 1999
+++ linux/scripts/lxdialog/menubox.c	Mon Dec  3 20:59:03 2001
@@ -91,6 +91,10 @@
     	wattrset (win, selected ? tag_key_selected_attr : tag_key_attr);
     	mvwaddch(win, choice, item_x+j, menu_item[j]);
     }
+    if (selected) {
+wmove (win, choice, item_x+1);
+wrefresh (win);
+    }
 }
 
 /*
@@ -267,9 +271,11 @@
 		 box_y, box_x+item_x+1, menu_height);
 
     print_buttons (dialog, height, width, 0);
+    wmove (menu, choice, item_x+1);
+    wrefresh (menu);
 
     while (key != ESC) {
-	key = wgetch(dialog);
+	key = wgetch(menu);
 
 	if (key < 256 && isalpha(key)) key = tolower(key);
 
@@ -372,8 +378,8 @@
             print_arrows(dialog, item_no, scroll,
                          box_y, box_x+item_x+1, menu_height);
 
-            wnoutrefresh (menu);
-            wrefresh (dialog);
+            wnoutrefresh (dialog);
+            wrefresh (menu);
 
 	    continue;		/* wait for another key press */
         }
@@ -386,7 +392,7 @@
 			? 2 : (button > 2 ? 0 : button);
 
 	    print_buttons(dialog, height, width, button);
-	    wrefresh (dialog);
+	    wrefresh (menu);
 	    break;
 	case ' ':
 	case 's':
