## Automatically generated incremental diff
## From:   linux-2.4.9-pre4
## To:     linux-2.4.9
## Robot:  $Id: make-incremental-diff,v 1.8 2001/12/04 06:05:04 hpa Exp $

diff -urN linux-2.4.9-pre4/Documentation/DMA-mapping.txt linux/Documentation/DMA-mapping.txt
--- linux-2.4.9-pre4/Documentation/DMA-mapping.txt	Sat May 19 17:43:05 2001
+++ linux/Documentation/DMA-mapping.txt	Mon Dec  3 23:03:37 2001
@@ -180,6 +180,19 @@
   to memory is immediately visible to the device, and vice
   versa.  Consistent mappings guarantee this.
 
+  IMPORTANT: Consistent DMA memory does not preclude the usage of
+             proper memory barriers.  The cpu may reorder stores to
+	     consistent memory just as it may normal memory.  Example:
+	     if it is important for the device to see the first word
+	     of a descriptor updated before the second, you must do
+	     something like:
+
+		desc->word0 = address;
+		wmb();
+		desc->word1 = DESC_VALID;
+
+             in order to get correct behavior on all platforms.
+
 - Streaming DMA mappings which are usually mapped for one DMA transfer,
   unmapped right after it (unless you use pci_dma_sync below) and for which
   hardware can optimize for sequential accesses.
diff -urN linux-2.4.9-pre4/Makefile linux/Makefile
--- linux-2.4.9-pre4/Makefile	Mon Dec  3 23:03:28 2001
+++ linux/Makefile	Mon Dec  3 23:03:37 2001
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 4
 SUBLEVEL = 9
-EXTRAVERSION =-pre4
+EXTRAVERSION =
 
 KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 
diff -urN linux-2.4.9-pre4/arch/cris/drivers/usb-host.c linux/arch/cris/drivers/usb-host.c
--- linux-2.4.9-pre4/arch/cris/drivers/usb-host.c	Wed Jul  4 11:50:39 2001
+++ linux/arch/cris/drivers/usb-host.c	Mon Dec  3 23:03:37 2001
@@ -2258,11 +2258,11 @@
 	case RH_GET_DESCRIPTOR:
 		switch ((wValue & 0xff00) >> 8) {
 		case (0x01):	/* device descriptor */
-			len = min (leni, min (sizeof (root_hub_dev_des), wLength));
+			len = min(unsigned int, leni, min(unsigned int, sizeof (root_hub_dev_des), wLength));
 			memcpy (data, root_hub_dev_des, len);
 			OK (len);
 		case (0x02):	/* configuration descriptor */
-			len = min (leni, min (sizeof (root_hub_config_des), wLength));
+			len = min(unsigned int, leni, min(unsigned int, sizeof (root_hub_config_des), wLength));
 			memcpy (data, root_hub_config_des, len);
 			OK (len);
 		case (0x03):	/* string descriptors */
@@ -2270,7 +2270,7 @@
 						   0xff, "ETRAX 100LX",
 						   data, wLength);
 			if (len > 0) {
-				OK (min (leni, len));
+				OK(min(int, leni, len));
 			} else 
 				stat = -EPIPE;
 		}
@@ -2278,7 +2278,7 @@
 		
 	case RH_GET_DESCRIPTOR | RH_CLASS:
 		root_hub_hub_des[2] = hc->rh.numports;
-		len = min (leni, min (sizeof (root_hub_hub_des), wLength));
+		len = min(unsigned int, leni, min(unsigned int, sizeof (root_hub_hub_des), wLength));
 		memcpy (data, root_hub_hub_des, len);
 		OK (len);
 		
diff -urN linux-2.4.9-pre4/arch/cris/drivers/usb-host.h linux/arch/cris/drivers/usb-host.h
--- linux-2.4.9-pre4/arch/cris/drivers/usb-host.h	Fri Apr  6 10:42:55 2001
+++ linux/arch/cris/drivers/usb-host.h	Mon Dec  3 23:03:37 2001
@@ -146,8 +146,6 @@
 #define RH_REQ_ERR                 -1
 #define RH_NACK                    0x00
 
-#define min(a,b) (((a)<(b))?(a):(b))
-
 /* Field definitions for */
 
 #define USB_IN_command__eol__BITNR      0 /* command macros */
diff -urN linux-2.4.9-pre4/arch/i386/kernel/i386_ksyms.c linux/arch/i386/kernel/i386_ksyms.c
--- linux-2.4.9-pre4/arch/i386/kernel/i386_ksyms.c	Mon Jul  2 14:49:24 2001
+++ linux/arch/i386/kernel/i386_ksyms.c	Mon Dec  3 23:03:37 2001
@@ -161,3 +161,7 @@
 #ifdef CONFIG_X86_PAE
 EXPORT_SYMBOL(empty_zero_page);
 #endif
+
+#ifdef CONFIG_HAVE_DEC_LOCK
+EXPORT_SYMBOL(atomic_dec_and_lock);
+#endif
diff -urN linux-2.4.9-pre4/arch/sparc/kernel/head.S linux/arch/sparc/kernel/head.S
--- linux-2.4.9-pre4/arch/sparc/kernel/head.S	Tue May  1 20:59:24 2001
+++ linux/arch/sparc/kernel/head.S	Mon Dec  3 23:03:37 2001
@@ -1,4 +1,4 @@
-/* $Id: head.S,v 1.104 2001/04/27 07:02:41 davem Exp $
+/* $Id: head.S,v 1.105 2001/08/12 09:08:56 davem Exp $
  * head.S: The initial boot code for the Sparc port of Linux.
  *
  * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
@@ -160,7 +160,7 @@
 t_bad7e:BAD_TRAP(0x7e) BAD_TRAP(0x7f)
 t_sunos:SUNOS_SYSCALL_TRAP                  /* SunOS System Call             */
 t_sbkpt:BREAKPOINT_TRAP                     /* Software Breakpoint/KGDB      */
-t_divz:	BAD_TRAP(0x82)                      /* Divide by zero trap           */
+t_divz:	TRAP_ENTRY(0x82, do_hw_divzero)     /* Divide by zero trap           */
 t_flwin:TRAP_ENTRY(0x83, do_flush_windows)  /* Flush Windows Trap            */
 t_clwin:BAD_TRAP(0x84)                      /* Clean Windows Trap            */
 t_rchk:	BAD_TRAP(0x85)                      /* Range Check                   */
@@ -245,7 +245,7 @@
 	BAD_TRAP(0x7e) BAD_TRAP(0x7f)
 	SUNOS_SYSCALL_TRAP 
 	BREAKPOINT_TRAP
-	BAD_TRAP(0x82)
+	TRAP_ENTRY(0x82, do_hw_divzero)
 	TRAP_ENTRY(0x83, do_flush_windows) BAD_TRAP(0x84) BAD_TRAP(0x85)
 	BAD_TRAP(0x86) BAD_TRAP(0x87) SOLARIS_SYSCALL_TRAP
 	NETBSD_SYSCALL_TRAP BAD_TRAP(0x8a) BAD_TRAP(0x8b) BAD_TRAP(0x8c)
@@ -313,7 +313,7 @@
 	BAD_TRAP(0x7e) BAD_TRAP(0x7f)
 	SUNOS_SYSCALL_TRAP 
 	BREAKPOINT_TRAP
-	BAD_TRAP(0x82)
+	TRAP_ENTRY(0x82, do_hw_divzero)
 	TRAP_ENTRY(0x83, do_flush_windows) BAD_TRAP(0x84) BAD_TRAP(0x85)
 	BAD_TRAP(0x86) BAD_TRAP(0x87) SOLARIS_SYSCALL_TRAP
 	NETBSD_SYSCALL_TRAP BAD_TRAP(0x8a) BAD_TRAP(0x8b) BAD_TRAP(0x8c)
@@ -381,7 +381,7 @@
 	BAD_TRAP(0x7e) BAD_TRAP(0x7f)
 	SUNOS_SYSCALL_TRAP  
 	BREAKPOINT_TRAP
-	BAD_TRAP(0x82)
+	TRAP_ENTRY(0x82, do_hw_divzero)
 	TRAP_ENTRY(0x83, do_flush_windows) BAD_TRAP(0x84) BAD_TRAP(0x85)
 	BAD_TRAP(0x86) BAD_TRAP(0x87) SOLARIS_SYSCALL_TRAP
 	NETBSD_SYSCALL_TRAP BAD_TRAP(0x8a) BAD_TRAP(0x8b) BAD_TRAP(0x8c)
diff -urN linux-2.4.9-pre4/arch/sparc/kernel/sys_sunos.c linux/arch/sparc/kernel/sys_sunos.c
--- linux-2.4.9-pre4/arch/sparc/kernel/sys_sunos.c	Mon Dec  3 23:03:28 2001
+++ linux/arch/sparc/kernel/sys_sunos.c	Mon Dec  3 23:03:37 2001
@@ -1,4 +1,4 @@
-/* $Id: sys_sunos.c,v 1.134 2001/04/27 07:02:42 davem Exp $
+/* $Id: sys_sunos.c,v 1.135 2001/08/13 14:40:10 davem Exp $
  * sys_sunos.c: SunOS specific syscall compatibility support.
  *
  * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
diff -urN linux-2.4.9-pre4/arch/sparc64/defconfig linux/arch/sparc64/defconfig
--- linux-2.4.9-pre4/arch/sparc64/defconfig	Mon Dec  3 23:03:28 2001
+++ linux/arch/sparc64/defconfig	Mon Dec  3 23:03:37 2001
@@ -661,8 +661,10 @@
 # Sound
 #
 CONFIG_SOUND=m
+CONFIG_SOUND_BT878=m
 # CONFIG_SOUND_CMPCI is not set
 # CONFIG_SOUND_EMU10K1 is not set
+# CONFIG_MIDI_EMU10K1 is not set
 # CONFIG_SOUND_FUSION is not set
 # CONFIG_SOUND_CS4281 is not set
 # CONFIG_SOUND_ES1370 is not set
@@ -671,6 +673,7 @@
 # CONFIG_SOUND_MAESTRO is not set
 # CONFIG_SOUND_MAESTRO3 is not set
 # CONFIG_SOUND_ICH is not set
+# CONFIG_SOUND_RME96XX is not set
 # CONFIG_SOUND_SONICVIBES is not set
 CONFIG_SOUND_TRIDENT=m
 # CONFIG_SOUND_MSNDCLAS is not set
diff -urN linux-2.4.9-pre4/arch/sparc64/kernel/dtlb_backend.S linux/arch/sparc64/kernel/dtlb_backend.S
--- linux-2.4.9-pre4/arch/sparc64/kernel/dtlb_backend.S	Mon Dec  3 23:03:28 2001
+++ linux/arch/sparc64/kernel/dtlb_backend.S	Mon Dec  3 23:03:37 2001
@@ -1,4 +1,4 @@
-/* $Id: dtlb_backend.S,v 1.11 2001/08/08 08:01:28 davem Exp $
+/* $Id: dtlb_backend.S,v 1.12 2001/08/13 20:41:54 kanoj Exp $
  * dtlb_backend.S: Back end to DTLB miss replacement strategy.
  *                 This is included directly into the trap table.
  *
@@ -23,7 +23,7 @@
 	ldxa		[%g1 + %g1] ASI_DMMU, %g4	! Get TAG_ACCESS
 	add		%g3, %g3, %g5			! Compute VPTE base
 	cmp		%g4, %g5			! VPTE miss?
-	blu,pn		%xcc, .-0x4004			! Fall to tl0 miss
+	blu,pn		%xcc, from_tl1_trap		! Fall to tl0 miss
 	 andcc		%g4, TAG_CONTEXT_BITS, %g5	! From Nucleus? (for tl0 miss)
 	sllx		%g6, VPTE_SHIFT, %g4		! Position TAG_ACCESS
 	or		%g4, %g5, %g4			! Prepare TAG_ACCESS
@@ -57,10 +57,9 @@
 	stxa		%g5, [%g0] ASI_DTLB_DATA_IN	! Load VPTE into TLB
 	stxa		%g4, [%g1 + %g1] ASI_DMMU	! Restore previous TAG_ACCESS
 	retry						! Load PTE once again
-vpte_noent:
-	mov		TLB_SFSR, %g1			! Restore %g1 value
-	stxa		%g4, [%g1 + %g1] ASI_DMMU	! Restore previous TAG_ACCESS
-	done						! Slick trick
+	nop
+	nop
+	nop
 
 #undef TAG_CONTEXT_BITS
 #undef VPTE_SHIFT
diff -urN linux-2.4.9-pre4/arch/sparc64/kernel/dtlb_base.S linux/arch/sparc64/kernel/dtlb_base.S
--- linux-2.4.9-pre4/arch/sparc64/kernel/dtlb_base.S	Sun Mar 25 18:14:21 2001
+++ linux/arch/sparc64/kernel/dtlb_base.S	Mon Dec  3 23:03:37 2001
@@ -1,4 +1,4 @@
-/* $Id: dtlb_base.S,v 1.9 2001/03/22 00:12:32 davem Exp $
+/* $Id: dtlb_base.S,v 1.10 2001/08/13 20:41:54 kanoj Exp $
  * dtlb_base.S:	Front end to DTLB miss replacement strategy.
  *              This is included directly into the trap table.
  *
@@ -51,6 +51,7 @@
 /* DTLB ** ICACHE line 1: Quick user TLB misses		*/
 	ldxa		[%g1 + %g1] ASI_DMMU, %g4	! Get TAG_ACCESS
 	andcc		%g4, TAG_CONTEXT_BITS, %g0	! From Nucleus?
+from_tl1_trap:
 	be,pn		%xcc, 3f			! Yep, special processing
 	 srax		%g4, VPTE_SHIFT, %g6		! Create VPTE offset
 	ldxa		[%g3 + %g6] ASI_S, %g5		! Load VPTE
diff -urN linux-2.4.9-pre4/arch/sparc64/kernel/entry.S linux/arch/sparc64/kernel/entry.S
--- linux-2.4.9-pre4/arch/sparc64/kernel/entry.S	Thu Apr 12 12:10:25 2001
+++ linux/arch/sparc64/kernel/entry.S	Mon Dec  3 23:03:37 2001
@@ -1,4 +1,4 @@
-/* $Id: entry.S,v 1.128 2001/03/28 10:56:34 davem Exp $
+/* $Id: entry.S,v 1.129 2001/08/13 20:41:54 kanoj Exp $
  * arch/sparc64/kernel/entry.S:  Sparc64 trap low-level entry points.
  *
  * Copyright (C) 1995,1997 David S. Miller (davem@caip.rutgers.edu)
@@ -39,6 +39,11 @@
 	or		%g5, %lo(0), %g5		! This is patched too
 	ba,pt		%xcc, sparc64_kpte_continue	! Part of dtlb_backend
 	 add		%g1, %g1, %g1			! Finish PMD offset adjustment
+
+vpte_noent:
+	mov		TLB_SFSR, %g1			! Restore %g1 value
+	stxa		%g4, [%g1 + %g1] ASI_DMMU	! Restore previous TAG_ACCESS
+	done						! Slick trick
 
 	/* This is trivial with the new code... */
 	.globl		do_fpdis
diff -urN linux-2.4.9-pre4/arch/sparc64/kernel/pci_common.c linux/arch/sparc64/kernel/pci_common.c
--- linux-2.4.9-pre4/arch/sparc64/kernel/pci_common.c	Fri Jun 29 19:38:26 2001
+++ linux/arch/sparc64/kernel/pci_common.c	Mon Dec  3 23:03:37 2001
@@ -1,4 +1,4 @@
-/* $Id: pci_common.c,v 1.26 2001/06/28 01:32:18 davem Exp $
+/* $Id: pci_common.c,v 1.27 2001/08/12 13:18:22 davem Exp $
  * pci_common.c: PCI controller common support.
  *
  * Copyright (C) 1999 David S. Miller (davem@redhat.com)
@@ -723,12 +723,12 @@
 		 * ranges. -DaveM
  		 */
 		if (pdev->bus->number == pbm->pci_first_busno) {
-			slot = (pdev->devfn >> 3) - 1;
+			slot = (pdev->devfn >> 3) - pbm->pci_first_slot;
 		} else {
 			/* Underneath a bridge, use slot number of parent
 			 * bridge.
 			 */
-			slot = (pdev->bus->self->devfn >> 3) - 1;
+			slot = (pdev->bus->self->devfn >> 3) - pbm->pci_first_slot;
 		}
 		slot = slot << 2;
 
diff -urN linux-2.4.9-pre4/arch/sparc64/kernel/pci_psycho.c linux/arch/sparc64/kernel/pci_psycho.c
--- linux-2.4.9-pre4/arch/sparc64/kernel/pci_psycho.c	Wed Jun 20 21:00:55 2001
+++ linux/arch/sparc64/kernel/pci_psycho.c	Mon Dec  3 23:03:37 2001
@@ -1,4 +1,4 @@
-/* $Id: pci_psycho.c,v 1.26 2001/06/13 06:34:30 davem Exp $
+/* $Id: pci_psycho.c,v 1.27 2001/08/12 13:18:23 davem Exp $
  * pci_psycho.c: PSYCHO/U2P specific PCI controller support.
  *
  * Copyright (C) 1997, 1998, 1999 David S. Miller (davem@caipfs.rutgers.edu)
@@ -1477,14 +1477,23 @@
 {
 	unsigned int busrange[2];
 	struct pci_pbm_info *pbm;
-	int err;
+	char namebuf[64];
+	int err, len;
 
 	if (is_pbm_a) {
 		pbm = &p->pbm_A;
+		pbm->pci_first_slot = 1;
 		pbm->io_space.start = p->controller_regs + PSYCHO_IOSPACE_A;
 		pbm->mem_space.start = p->controller_regs + PSYCHO_MEMSPACE_A;
 	} else {
 		pbm = &p->pbm_B;
+		pbm->pci_first_slot = 1;
+		len = prom_getproperty(prom_root_node, "name",
+				       namebuf, sizeof(namebuf));
+		if (len > 0) {
+			if (!strcmp(namebuf, "SUNW,Ultra-1-Engine"))
+				pbm->pci_first_slot = 2;
+		}
 		pbm->io_space.start = p->controller_regs + PSYCHO_IOSPACE_B;
 		pbm->mem_space.start = p->controller_regs + PSYCHO_MEMSPACE_B;
 	}
diff -urN linux-2.4.9-pre4/arch/sparc64/kernel/pci_sabre.c linux/arch/sparc64/kernel/pci_sabre.c
--- linux-2.4.9-pre4/arch/sparc64/kernel/pci_sabre.c	Wed Jun 20 21:00:55 2001
+++ linux/arch/sparc64/kernel/pci_sabre.c	Mon Dec  3 23:03:37 2001
@@ -1,4 +1,4 @@
-/* $Id: pci_sabre.c,v 1.37 2001/06/13 06:34:30 davem Exp $
+/* $Id: pci_sabre.c,v 1.38 2001/08/12 13:18:23 davem Exp $
  * pci_sabre.c: Sabre specific PCI controller support.
  *
  * Copyright (C) 1997, 1998, 1999 David S. Miller (davem@caipfs.rutgers.edu)
@@ -1395,6 +1395,7 @@
 			pbm = &p->pbm_A;
 		pbm->parent = p;
 		pbm->prom_node = node;
+		pbm->pci_first_slot = 1;
 		pbm->pci_first_busno = busrange[0];
 		pbm->pci_last_busno = busrange[1];
 		for (err = pbm->pci_first_busno;
diff -urN linux-2.4.9-pre4/arch/sparc64/kernel/pci_schizo.c linux/arch/sparc64/kernel/pci_schizo.c
--- linux-2.4.9-pre4/arch/sparc64/kernel/pci_schizo.c	Wed Jun 20 21:00:55 2001
+++ linux/arch/sparc64/kernel/pci_schizo.c	Mon Dec  3 23:03:37 2001
@@ -1,4 +1,4 @@
-/* $Id: pci_schizo.c,v 1.19 2001/06/20 21:31:00 davem Exp $
+/* $Id: pci_schizo.c,v 1.20 2001/08/12 13:18:23 davem Exp $
  * pci_schizo.c: SCHIZO specific PCI controller support.
  *
  * Copyright (C) 2001 David S. Miller (davem@redhat.com)
@@ -1684,6 +1684,7 @@
 
 	pbm->parent = p;
 	pbm->prom_node = prom_node;
+	pbm->pci_first_slot = 1;
 	prom_getstring(prom_node, "name",
 		       pbm->prom_name,
 		       sizeof(pbm->prom_name));
diff -urN linux-2.4.9-pre4/arch/sparc64/kernel/sparc64_ksyms.c linux/arch/sparc64/kernel/sparc64_ksyms.c
--- linux-2.4.9-pre4/arch/sparc64/kernel/sparc64_ksyms.c	Mon Jun 11 19:15:27 2001
+++ linux/arch/sparc64/kernel/sparc64_ksyms.c	Mon Dec  3 23:03:37 2001
@@ -163,6 +163,7 @@
 /* Atomic counter implementation. */
 EXPORT_SYMBOL(__atomic_add);
 EXPORT_SYMBOL(__atomic_sub);
+EXPORT_SYMBOL(atomic_dec_and_lock);
 
 /* Atomic bit operations. */
 EXPORT_SYMBOL(___test_and_set_bit);
diff -urN linux-2.4.9-pre4/arch/sparc64/kernel/sys_sparc32.c linux/arch/sparc64/kernel/sys_sparc32.c
--- linux-2.4.9-pre4/arch/sparc64/kernel/sys_sparc32.c	Mon Dec  3 23:03:28 2001
+++ linux/arch/sparc64/kernel/sys_sparc32.c	Mon Dec  3 23:03:37 2001
@@ -1,4 +1,4 @@
-/* $Id: sys_sparc32.c,v 1.177 2001/06/10 06:48:46 davem Exp $
+/* $Id: sys_sparc32.c,v 1.178 2001/08/13 14:40:07 davem Exp $
  * sys_sparc32.c: Conversion between 32bit and 64bit native syscalls.
  *
  * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
diff -urN linux-2.4.9-pre4/arch/sparc64/kernel/sys_sunos32.c linux/arch/sparc64/kernel/sys_sunos32.c
--- linux-2.4.9-pre4/arch/sparc64/kernel/sys_sunos32.c	Mon Dec  3 23:03:28 2001
+++ linux/arch/sparc64/kernel/sys_sunos32.c	Mon Dec  3 23:03:37 2001
@@ -1,4 +1,4 @@
-/* $Id: sys_sunos32.c,v 1.60 2001/04/27 07:02:42 davem Exp $
+/* $Id: sys_sunos32.c,v 1.61 2001/08/13 14:40:07 davem Exp $
  * sys_sunos32.c: SunOS binary compatability layer on sparc64.
  *
  * Copyright (C) 1995, 1996, 1997 David S. Miller (davem@caip.rutgers.edu)
diff -urN linux-2.4.9-pre4/arch/sparc64/kernel/ttable.S linux/arch/sparc64/kernel/ttable.S
--- linux-2.4.9-pre4/arch/sparc64/kernel/ttable.S	Thu Apr 12 12:10:25 2001
+++ linux/arch/sparc64/kernel/ttable.S	Mon Dec  3 23:03:37 2001
@@ -1,4 +1,4 @@
-/* $Id: ttable.S,v 1.33 2001/03/28 10:56:34 davem Exp $
+/* $Id: ttable.S,v 1.34 2001/08/12 09:08:56 davem Exp $
  * ttable.S: Sparc V9 Trap Table(s) with SpitFire/Cheetah extensions.
  *
  * Copyright (C) 1996, 2001 David S. Miller (davem@caip.rutgers.edu)
@@ -106,7 +106,7 @@
 tl0_f7o:	FILL_7_OTHER
 tl0_sunos:	SUNOS_SYSCALL_TRAP
 tl0_bkpt:	BREAKPOINT_TRAP
-tl0_resv102:	BTRAP(0x102)
+tl0_divz:	TRAP(do_div0)
 tl0_flushw:	FLUSH_WINDOW_TRAP
 tl0_resv104:	BTRAP(0x104) BTRAP(0x105) BTRAP(0x106) BTRAP(0x107)
 		.globl tl0_solaris
diff -urN linux-2.4.9-pre4/arch/sparc64/solaris/timod.c linux/arch/sparc64/solaris/timod.c
--- linux-2.4.9-pre4/arch/sparc64/solaris/timod.c	Thu Apr 19 08:38:49 2001
+++ linux/arch/sparc64/solaris/timod.c	Mon Dec  3 23:03:37 2001
@@ -1,4 +1,4 @@
-/* $Id: timod.c,v 1.11 2001/04/14 21:12:01 davem Exp $
+/* $Id: timod.c,v 1.15 2001/08/13 18:56:10 davem Exp $
  * timod.c: timod emulation.
  *
  * Copyright (C) 1998 Patrik Rak (prak3264@ss1000.ms.mff.cuni.cz)
@@ -699,10 +699,7 @@
 	}
 	if (ctl_maxlen >= 0 && sock->pfirst) {
 		struct T_primsg *it = sock->pfirst;
-#ifndef min
-#define min(a,b) ((a)<(b)?(a):(b))
-#endif
-		int l = min(ctl_maxlen, it->length);
+		int l = min(int, ctl_maxlen, it->length);
 		SCHECK_MAGIC((char*)((u64)(((char *)&it->type)+sock->offset+it->length+7)&~7),MKCTL_MAGIC);
 		SOLD("purting ctl data");
 		if(copy_to_user(ctl_buf,
@@ -815,7 +812,7 @@
 	filp->f_flags |= O_NONBLOCK;
 	SOLD("calling recvfrom");
 	sys_recvfrom = (int (*)(int, void *, size_t, unsigned, struct sockaddr *, int *))SYS(recvfrom);
-	error = sys_recvfrom(fd, data_buf, min(0,data_maxlen), 0, (struct sockaddr*)tmpbuf, ctl_len);
+	error = sys_recvfrom(fd, data_buf, data_maxlen, 0, (struct sockaddr*)tmpbuf, ctl_len);
 	filp->f_flags = oldflags;
 	if (error < 0)
 		return error;
diff -urN linux-2.4.9-pre4/drivers/acorn/scsi/acornscsi.c linux/drivers/acorn/scsi/acornscsi.c
--- linux-2.4.9-pre4/drivers/acorn/scsi/acornscsi.c	Wed Jun 27 14:12:04 2001
+++ linux/drivers/acorn/scsi/acornscsi.c	Mon Dec  3 23:03:37 2001
@@ -1059,7 +1059,7 @@
     /*
      * Allocate some buffer space, limited to half the buffer size
      */
-    length = min(host->scsi.SCp.this_residual, DMAC_BUFFER_SIZE / 2);
+    length = min(unsigned int, host->scsi.SCp.this_residual, DMAC_BUFFER_SIZE / 2);
     if (length) {
 	host->dma.start_addr = address = host->dma.free_addr;
 	host->dma.free_addr = (host->dma.free_addr + length) &
@@ -1187,7 +1187,7 @@
     /*
      * Allocate some buffer space, limited to half the on-board RAM size
      */
-    length = min(host->scsi.SCp.this_residual, DMAC_BUFFER_SIZE / 2);
+    length = min(unsigned int, host->scsi.SCp.this_residual, DMAC_BUFFER_SIZE / 2);
     if (length) {
 	host->dma.start_addr = address = host->dma.free_addr;
 	host->dma.free_addr = (host->dma.free_addr + length) &
@@ -1656,8 +1656,8 @@
 		 * to be in operation AFTER the target leaves message out phase.
 		 */
 		acornscsi_sbic_issuecmd(host, CMND_ASSERTATN);
-		period = max(message[3], sdtr_period / 4);
-		length = min(message[4], sdtr_size);
+		period = max(unsigned int, message[3], sdtr_period / 4);
+		length = min(unsigned int, message[4], sdtr_size);
 		msgqueue_addmsg(&host->scsi.msgs, 5, EXTENDED_MESSAGE, 3,
 				 EXTENDED_SDTR, period, length);
 		host->device[host->SCpnt->target].sync_xfer =
diff -urN linux-2.4.9-pre4/drivers/acorn/scsi/acornscsi.h linux/drivers/acorn/scsi/acornscsi.h
--- linux-2.4.9-pre4/drivers/acorn/scsi/acornscsi.h	Wed Jun 27 14:12:04 2001
+++ linux/drivers/acorn/scsi/acornscsi.h	Mon Dec  3 23:03:37 2001
@@ -183,9 +183,6 @@
 #define MASK_ON		(MASKREG_M3|MASKREG_M2|MASKREG_M1|MASKREG_M0)
 #define MASK_OFF	(MASKREG_M3|MASKREG_M2|MASKREG_M1)
 
-#define min(x,y) ((x) < (y) ? (x) : (y))
-#define max(x,y) ((x) < (y) ? (y) : (x))
-
 /*
  * SCSI driver phases
  */
diff -urN linux-2.4.9-pre4/drivers/block/acsi.c linux/drivers/block/acsi.c
--- linux-2.4.9-pre4/drivers/block/acsi.c	Sat Apr 28 11:27:53 2001
+++ linux/drivers/block/acsi.c	Mon Dec  3 23:03:37 2001
@@ -292,9 +292,6 @@
 		cmd[4] = (len);							\
 	} while(0)
 
-#define min(a,b)	(((a)<(b))?(a):(b))
-
-
 /* ACSI errors (from REQUEST SENSE); There are two tables, one for the
  * old Atari disks and one for SCSI on ACSI disks.
  */
diff -urN linux-2.4.9-pre4/drivers/cdrom/cdrom.c linux/drivers/cdrom/cdrom.c
--- linux-2.4.9-pre4/drivers/cdrom/cdrom.c	Wed Jul 11 14:55:41 2001
+++ linux/drivers/cdrom/cdrom.c	Mon Dec  3 23:03:37 2001
@@ -2246,8 +2246,13 @@
 	if ((ret = cdo->generic_packet(cdi, &cgc)))
 		return ret;
 	
-	cgc.cmd[8] = cgc.buflen = be16_to_cpu(ti->track_information_length) +
+	cgc.buflen = be16_to_cpu(ti->track_information_length) +
 		     sizeof(ti->track_information_length);
+
+	if (cgc.buflen > sizeof(track_information))
+		cgc.buflen = sizeof(track_information);
+
+	cgc.cmd[8] = cgc.buflen;
 	return cdo->generic_packet(cdi, &cgc);
 }
 
diff -urN linux-2.4.9-pre4/drivers/char/agp/agp.h linux/drivers/char/agp/agp.h
--- linux-2.4.9-pre4/drivers/char/agp/agp.h	Mon Jul  2 15:27:56 2001
+++ linux/drivers/char/agp/agp.h	Mon Dec  3 23:03:37 2001
@@ -142,10 +142,6 @@
 #define A_IDXFIX()	(A_SIZE_FIX(agp_bridge.aperture_sizes) + i)
 #define MAXKEY		(4096 * 32)
 
-#ifndef min
-#define min(a,b)	(((a)<(b))?(a):(b))
-#endif
-
 #define AGPGART_MODULE_NAME	"agpgart"
 #define PFX			AGPGART_MODULE_NAME ": "
 
diff -urN linux-2.4.9-pre4/drivers/char/agp/agpgart_be.c linux/drivers/char/agp/agpgart_be.c
--- linux-2.4.9-pre4/drivers/char/agp/agpgart_be.c	Mon Dec  3 23:03:28 2001
+++ linux/drivers/char/agp/agpgart_be.c	Mon Dec  3 23:03:37 2001
@@ -428,8 +428,8 @@
 			/* adjust RQ depth */
 			command =
 			    ((command & ~0xff000000) |
-			     min((mode & 0xff000000),
-				 min((command & 0xff000000),
+			     min(u32, (mode & 0xff000000),
+				 min(u32, (command & 0xff000000),
 				     (scratch & 0xff000000))));
 
 			/* disable SBA if it's not supported */
@@ -2657,8 +2657,8 @@
 			/* adjust RQ depth */
 			command =
 			    ((command & ~0xff000000) |
-			     min((mode & 0xff000000),
-				 min((command & 0xff000000),
+			     min(u32, (mode & 0xff000000),
+				 min(u32, (command & 0xff000000),
 				     (scratch & 0xff000000))));
 
 			/* disable SBA if it's not supported */
diff -urN linux-2.4.9-pre4/drivers/char/cyclades.c linux/drivers/char/cyclades.c
--- linux-2.4.9-pre4/drivers/char/cyclades.c	Wed Jun 27 17:10:55 2001
+++ linux/drivers/char/cyclades.c	Mon Dec  3 23:03:37 2001
@@ -628,8 +628,6 @@
 #define PAUSE ;
 #endif
 
-#define cy_min(a,b) (((a)<(b))?(a):(b))
-
 /*
  * Include section 
  */
@@ -1631,8 +1629,8 @@
 	       for performance, but because of buffer boundaries, there
 	       may be several steps to the operation */
 	    while(0 < (small_count = 
-		       cy_min((rx_bufsize - new_rx_get),
-		       cy_min((TTY_FLIPBUF_SIZE - tty->flip.count), char_count))
+		       min(unsigned int, (rx_bufsize - new_rx_get),
+		       min(unsigned int, (TTY_FLIPBUF_SIZE - tty->flip.count), char_count))
 		 )) {
 		memcpy_fromio(tty->flip.char_buf_ptr,
 			      (char *)(cinfo->base_addr
@@ -1726,9 +1724,9 @@
 	}
 #ifdef BLOCKMOVE
 	while(0 < (small_count = 
-		   cy_min((tx_bufsize - tx_put),
-		   cy_min ((SERIAL_XMIT_SIZE - info->xmit_tail),
-			cy_min(info->xmit_cnt, char_count))))){
+		   min(unsigned int, (tx_bufsize - tx_put),
+		       min(unsigned int, (SERIAL_XMIT_SIZE - info->xmit_tail),
+			   min(unsigned int, info->xmit_cnt, char_count))))) {
 
 	    memcpy_toio((char *)(cinfo->base_addr + tx_bufaddr + tx_put),
 			&info->xmit_buf[info->xmit_tail],
diff -urN linux-2.4.9-pre4/drivers/char/dsp56k.c linux/drivers/char/dsp56k.c
--- linux-2.4.9-pre4/drivers/char/dsp56k.c	Sun Jul 15 16:15:44 2001
+++ linux/drivers/char/dsp56k.c	Mon Dec  3 23:03:37 2001
@@ -59,9 +59,6 @@
 #define DSP56K_TRANSMIT		(dsp56k_host_interface.isr & DSP56K_ISR_TXDE)
 #define DSP56K_RECEIVE		(dsp56k_host_interface.isr & DSP56K_ISR_RXDF)
 
-#define max(a,b) ((a) > (b) ? (a) : (b))
-#define min(a,b) ((a) < (b) ? (a) : (b))
-
 #define wait_some(n) \
 { \
 	set_current_state(TASK_INTERRUPTIBLE); \
@@ -72,7 +69,7 @@
 { \
 	long i, t, m; \
 	while (count > 0) { \
-		m = min(count, maxio); \
+		m = min(unsigned long, count, maxio); \
 		for (i = 0; i < m; i++) { \
 			for (t = 0; t < timeout && !ENABLE; t++) \
 				wait_some(HZ/50); \
diff -urN linux-2.4.9-pre4/drivers/char/dz.c linux/drivers/char/dz.c
--- linux-2.4.9-pre4/drivers/char/dz.c	Wed Jul  4 14:41:33 2001
+++ linux/drivers/char/dz.c	Mon Dec  3 23:03:37 2001
@@ -1279,7 +1279,8 @@
 
 int __init dz_init(void)
 {
-  int i, flags;
+  int i;
+  unsigned long flags;
   struct dz_serial *info;
 
   /* Setup base handler, and timer table. */
diff -urN linux-2.4.9-pre4/drivers/char/n_r3964.c linux/drivers/char/n_r3964.c
--- linux-2.4.9-pre4/drivers/char/n_r3964.c	Wed Jun 27 14:13:01 2001
+++ linux/drivers/char/n_r3964.c	Mon Dec  3 23:03:37 2001
@@ -1421,7 +1421,7 @@
    int pid=current->pid;
    struct r3964_client_info *pClient;
    struct r3964_message *pMsg=NULL;
-   unsigned int flags;
+   unsigned long flags;
    int result = POLLOUT;
 
    TRACE_L("POLL");
diff -urN linux-2.4.9-pre4/drivers/char/ppdev.c linux/drivers/char/ppdev.c
--- linux-2.4.9-pre4/drivers/char/ppdev.c	Mon Dec  3 23:03:28 2001
+++ linux/drivers/char/ppdev.c	Mon Dec  3 23:03:37 2001
@@ -71,10 +71,6 @@
 #define PP_VERSION "ppdev: user-space parallel port driver"
 #define CHRDEV "ppdev"
 
-#ifndef min
-#define min(a,b) ((a) < (b) ? (a) : (b))
-#endif
-
 struct pp_struct {
 	struct pardevice * pdev;
 	wait_queue_head_t irq_wait;
@@ -122,7 +118,7 @@
 		return -EINVAL;
 	}
 
-	kbuffer = kmalloc (min (count, PP_BUFFER_SIZE), GFP_KERNEL);
+	kbuffer = kmalloc(min(unsigned int, count, PP_BUFFER_SIZE), GFP_KERNEL);
 	if (!kbuffer) {
 		return -ENOMEM;
 	}
@@ -130,7 +126,7 @@
 	mode = pport->ieee1284.mode & ~(IEEE1284_DEVICEID | IEEE1284_ADDR);
 
 	while (bytes_read < count) {
-		ssize_t need = min(count - bytes_read, PP_BUFFER_SIZE);
+		ssize_t need = min(unsigned long, count - bytes_read, PP_BUFFER_SIZE);
 
 		if (mode == IEEE1284_MODE_EPP) {
 			/* various specials for EPP mode */
@@ -202,7 +198,7 @@
 		return -EINVAL;
 	}
 
-	kbuffer = kmalloc (min (count, PP_BUFFER_SIZE), GFP_KERNEL);
+	kbuffer = kmalloc(min(unsigned int, count, PP_BUFFER_SIZE), GFP_KERNEL);
 	if (!kbuffer) {
 		return -ENOMEM;
 	}
@@ -210,7 +206,7 @@
 	mode = pport->ieee1284.mode & ~(IEEE1284_DEVICEID | IEEE1284_ADDR);
 
 	while (bytes_written < count) {
-		ssize_t n = min(count - bytes_written, PP_BUFFER_SIZE);
+		ssize_t n = min(unsigned long, count - bytes_written, PP_BUFFER_SIZE);
 
 		if (copy_from_user (kbuffer, buf + bytes_written, n)) {
 			bytes_written = -EFAULT;
diff -urN linux-2.4.9-pre4/drivers/char/rio/rio.h linux/drivers/char/rio/rio.h
--- linux-2.4.9-pre4/drivers/char/rio/rio.h	Fri Feb 16 16:02:36 2001
+++ linux/drivers/char/rio/rio.h	Mon Dec  3 23:03:37 2001
@@ -210,16 +210,6 @@
 #define RIO_PORT(DEV,FIRST_MAJ)	( (major(DEV) - FIRST_MAJ) * PORTS_PER_HOST) \
 					+ minor(DEV)
 
-/*
-**	Min and Max
-*/
-#ifndef min
-#define	min(A,B)	((A)<(B)?(A):(B))
-#endif
-#ifndef max
-#define	max(A,B)	((A)>(B)?(A):(B))
-#endif
-
 #define	splrio	spltty
 
 #define	RIO_IPL	5
diff -urN linux-2.4.9-pre4/drivers/char/rio/riointr.c linux/drivers/char/rio/riointr.c
--- linux-2.4.9-pre4/drivers/char/rio/riointr.c	Fri Feb  9 11:30:23 2001
+++ linux/drivers/char/rio/riointr.c	Mon Dec  3 23:03:37 2001
@@ -819,7 +819,7 @@
 	  ** and available space.
 	  */
 			
-	  transCount = min(PacketP->len & PKT_LEN_MASK,
+	  transCount = min(unsigned int, PacketP->len & PKT_LEN_MASK,
 			   TTY_FLIPBUF_SIZE - TtyP->flip.count);
 	  rio_dprintk (RIO_DEBUG_REC,  "port %d: Copy %d bytes\n", 
 				      PortP->PortNum, transCount);
diff -urN linux-2.4.9-pre4/drivers/i2o/i2o_block.c linux/drivers/i2o/i2o_block.c
--- linux-2.4.9-pre4/drivers/i2o/i2o_block.c	Mon Dec  3 23:03:28 2001
+++ linux/drivers/i2o/i2o_block.c	Mon Dec  3 23:03:37 2001
@@ -713,7 +713,7 @@
 static int i2ob_evt(void *dummy)
 {
 	unsigned int evt;
-	unsigned int flags;
+	unsigned long flags;
 	int unit;
 	int i;
 	//The only event that has data is the SCSI_SMART event.
@@ -1698,7 +1698,7 @@
 {	
 	int unit = 0;
 	int i = 0;
-	int flags;
+	unsigned long flags;
 
 	spin_lock_irqsave(&io_request_lock, flags);
 
diff -urN linux-2.4.9-pre4/drivers/i2o/i2o_config.c linux/drivers/i2o/i2o_config.c
--- linux-2.4.9-pre4/drivers/i2o/i2o_config.c	Mon Dec  3 23:03:28 2001
+++ linux/drivers/i2o/i2o_config.c	Mon Dec  3 23:03:37 2001
@@ -790,7 +790,7 @@
 	struct i2o_cfg_info *p = NULL;
 	struct i2o_evt_get *uget = (struct i2o_evt_get*)arg;
 	struct i2o_evt_get kget;
-	unsigned int flags;
+	unsigned long flags;
 
 	for(p = open_files; p; p = p->next)
 		if(p->q_id == id)
@@ -819,7 +819,7 @@
 {
 	struct i2o_cfg_info *tmp = 
 		(struct i2o_cfg_info *)kmalloc(sizeof(struct i2o_cfg_info), GFP_KERNEL);
-	unsigned int flags;
+	unsigned long flags;
 
 	if(!tmp)
 		return -ENOMEM;
@@ -845,7 +845,7 @@
 {
 	u32 id = (u32)file->private_data;
 	struct i2o_cfg_info *p1, *p2;
-	unsigned int flags;
+	unsigned long flags;
 
 	lock_kernel();
 	p1 = p2 = NULL;
diff -urN linux-2.4.9-pre4/drivers/i2o/i2o_core.c linux/drivers/i2o/i2o_core.c
--- linux-2.4.9-pre4/drivers/i2o/i2o_core.c	Mon Dec  3 23:03:28 2001
+++ linux/drivers/i2o/i2o_core.c	Mon Dec  3 23:03:37 2001
@@ -890,7 +890,7 @@
 	struct reply_info *reply = (struct reply_info *) reply_data;
 	u32 *msg = reply->msg;
 	struct i2o_controller *c = NULL;
-	int flags;
+	unsigned long flags;
 
 	lock_kernel();
 	daemonize();
@@ -2535,7 +2535,7 @@
 	DECLARE_WAIT_QUEUE_HEAD(wq_i2o_post);
 	int complete = 0;
 	int status;
-	int flags = 0;
+	unsigned long flags = 0;
 	struct i2o_post_wait_data *wait_data =
 		kmalloc(sizeof(struct i2o_post_wait_data), GFP_KERNEL);
 
diff -urN linux-2.4.9-pre4/drivers/ide/hpt366.c linux/drivers/ide/hpt366.c
--- linux-2.4.9-pre4/drivers/ide/hpt366.c	Wed Jun 27 17:10:55 2001
+++ linux/drivers/ide/hpt366.c	Mon Dec  3 23:03:37 2001
@@ -60,6 +60,11 @@
 	"IBM-DTLA-305040",
 	"IBM-DTLA-305030",
 	"IBM-DTLA-305020",
+	"IC35L010AVER07-0",
+	"IC35L020AVER07-0",
+	"IC35L030AVER07-0",
+	"IC35L040AVER07-0",
+	"IC35L060AVER07-0",
 	"WDC AC310200R",
 	NULL
 };
@@ -74,6 +79,11 @@
 	"IBM-DTLA-305040",
 	"IBM-DTLA-305030",
 	"IBM-DTLA-305020",
+	"IC35L010AVER07-0",
+	"IC35L020AVER07-0",
+	"IC35L030AVER07-0",
+	"IC35L040AVER07-0",
+	"IC35L060AVER07-0",
 	"WDC AC310200R",
 	NULL
 };
diff -urN linux-2.4.9-pre4/drivers/ide/ide-cd.c linux/drivers/ide/ide-cd.c
--- linux-2.4.9-pre4/drivers/ide/ide-cd.c	Mon Dec  3 23:03:28 2001
+++ linux/drivers/ide/ide-cd.c	Mon Dec  3 23:03:37 2001
@@ -1885,7 +1885,7 @@
 	return cdrom_queue_packet_command (drive, &pc);
 }
 
-static int cdrom_read_capacity(ide_drive_t *drive, unsigned *capacity,
+static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity,
 			       struct request_sense *sense)
 {
 	struct {
@@ -2927,7 +2927,7 @@
 static
 unsigned long ide_cdrom_capacity (ide_drive_t *drive)
 {
-	unsigned capacity;
+	unsigned long capacity;
 
 	if (cdrom_read_capacity(drive, &capacity, NULL))
 		return 0;
diff -urN linux-2.4.9-pre4/drivers/ide/ide-cd.h linux/drivers/ide/ide-cd.h
--- linux-2.4.9-pre4/drivers/ide/ide-cd.h	Mon Dec  3 23:03:28 2001
+++ linux/drivers/ide/ide-cd.h	Mon Dec  3 23:03:37 2001
@@ -150,7 +150,7 @@
 struct atapi_toc {
 	int    last_session_lba;
 	int    xa_flag;
-	unsigned capacity;
+	unsigned long capacity;
 	struct atapi_toc_header hdr;
 	struct atapi_toc_entry  ent[MAX_TRACKS+1];
 	  /* One extra for the leadout. */
diff -urN linux-2.4.9-pre4/drivers/ieee1394/nodemgr.c linux/drivers/ieee1394/nodemgr.c
--- linux-2.4.9-pre4/drivers/ieee1394/nodemgr.c	Mon Dec  3 23:03:29 2001
+++ linux/drivers/ieee1394/nodemgr.c	Mon Dec  3 23:03:38 2001
@@ -358,7 +358,7 @@
         nodeid_t nodeid = LOCAL_BUS;
 	quadlet_t buffer[5], quad;
 	octlet_t base = CSR_REGISTER_BASE + CSR_CONFIG_ROM;
-	int flags;
+	unsigned long flags;
 
 	/* We need to detect when the ConfigROM's generation has changed,
 	 * so we only update the node's info when it needs to be.  */
@@ -508,7 +508,7 @@
 static void nodemgr_add_host(struct hpsb_host *host)
 {
 	struct host_info *hi = kmalloc (sizeof (struct host_info), GFP_KERNEL);
-	int flags;
+	unsigned long flags;
 
 	if (!hi) {
 		HPSB_ERR ("Out of memory in Node Manager");
@@ -532,7 +532,7 @@
 {
 	struct list_head *lh;
 	struct host_info *hi = NULL;
-	int flags;
+	unsigned long flags;
 
 	spin_lock_irqsave (&host_info_lock, flags);
 	list_for_each(lh, &host_info_list) {
@@ -561,7 +561,7 @@
 	struct list_head *lh;
 	struct host_info *hi = NULL;
 	struct node_entry *ne;
-	int flags;
+	unsigned long flags;
 
 	/* Make sure we have no active scans */
 	flush_scheduled_tasks();
diff -urN linux-2.4.9-pre4/drivers/ieee1394/ohci1394.c linux/drivers/ieee1394/ohci1394.c
--- linux-2.4.9-pre4/drivers/ieee1394/ohci1394.c	Mon Dec  3 23:03:29 2001
+++ linux/drivers/ieee1394/ohci1394.c	Mon Dec  3 23:03:38 2001
@@ -200,7 +200,8 @@
 
 static u8 get_phy_reg(struct ti_ohci *ohci, u8 addr) 
 {
-	int i, flags;
+	int i;
+	unsigned long flags;
 	quadlet_t r;
 
 	spin_lock_irqsave (&ohci->phy_reg_lock, flags);
@@ -227,7 +228,8 @@
 
 static void set_phy_reg(struct ti_ohci *ohci, u8 addr, u8 data)
 {
-	int i, flags;
+	int i;
+	unsigned long flags;
 	u32 r;
 
 	spin_lock_irqsave (&ohci->phy_reg_lock, flags);
@@ -1078,7 +1080,8 @@
 	quadlet_t event, node_id;
 	struct ti_ohci *ohci = (struct ti_ohci *)dev_id;
 	struct hpsb_host *host = ohci->host;
-	int phyid = -1, isroot = 0, flags;
+	int phyid = -1, isroot = 0;
+	unsigned long flags;
 
 	/* Read the interrupt event register. We don't clear the bus reset
 	 * here. We wait till we get a selfid complete interrupt and clear
@@ -1343,7 +1346,8 @@
 	struct ti_ohci *ohci = (struct ti_ohci*)(d->ohci);
 	unsigned int split_left, idx, offset, rescount;
 	unsigned char tcode;
-	int length, bytes_left, ack, flags;
+	int length, bytes_left, ack;
+	unsigned long flags;
 	quadlet_t *buf_ptr;
 	char *split_ptr;
 	char msg[256];
diff -urN linux-2.4.9-pre4/drivers/ieee1394/sbp2.c linux/drivers/ieee1394/sbp2.c
--- linux-2.4.9-pre4/drivers/ieee1394/sbp2.c	Mon Dec  3 23:03:29 2001
+++ linux/drivers/ieee1394/sbp2.c	Mon Dec  3 23:03:38 2001
@@ -965,7 +965,7 @@
 static void sbp2_add_host(struct hpsb_host *host)
 {
 	struct sbp2scsi_host_info *hi;
-	unsigned int flags;
+	unsigned long flags;
 
 	SBP2_DEBUG("sbp2: sbp2_add_host");
 
@@ -1048,7 +1048,7 @@
 {
 	struct sbp2scsi_host_info *hi;
 	int i;
-	unsigned int flags;
+	unsigned long flags;
 
 	SBP2_DEBUG("sbp2: sbp2_remove_host");
 
diff -urN linux-2.4.9-pre4/drivers/ieee1394/video1394.c linux/drivers/ieee1394/video1394.c
--- linux-2.4.9-pre4/drivers/ieee1394/video1394.c	Mon Dec  3 23:03:29 2001
+++ linux/drivers/ieee1394/video1394.c	Mon Dec  3 23:03:38 2001
@@ -1313,7 +1313,8 @@
 {
 	struct video_card *video = NULL;
 	struct ti_ohci *ohci;
-	int res = -EINVAL, flags;
+	int res = -EINVAL;
+	unsigned long flags;
 	struct list_head *lh;
 
         spin_lock_irqsave(&video1394_cards_lock, flags);
@@ -1350,7 +1351,8 @@
 
 static int video1394_open(struct inode *inode, struct file *file)
 {
-	int i = MINOR(inode->i_rdev), flags;
+	int i = MINOR(inode->i_rdev);
+	unsigned long flags;
 	struct video_card *video = NULL;
 	struct list_head *lh;
 
@@ -1380,7 +1382,8 @@
 	struct video_card *video = NULL;
 	struct ti_ohci *ohci;
 	u64 mask;
-	int i, flags;
+	int i;
+	unsigned long flags;
 	struct list_head *lh;
 
         spin_lock_irqsave(&video1394_cards_lock, flags);
@@ -1446,7 +1449,8 @@
 static void irq_handler(int card, quadlet_t isoRecvIntEvent, 
 		 quadlet_t isoXmitIntEvent)
 {
-	int i, flags;
+	int i;
+	unsigned long flags;
 	struct video_card *video = NULL;
 	struct list_head *lh;
 
@@ -1495,7 +1499,7 @@
 static int video1394_init(struct ti_ohci *ohci)
 {
 	struct video_card *video = kmalloc(sizeof(struct video_card), GFP_KERNEL);
-	int flags;
+	unsigned long flags;
 	char name[16];
 
 	if (video == NULL) {
@@ -1555,7 +1559,8 @@
 /* Must be called under spinlock */
 static void remove_card(struct video_card *video)
 {
-	int i, flags;
+	int i;
+	unsigned long flags;
 
 	ohci1394_unregister_video(video->ohci, &video_tmpl);
 
@@ -1586,7 +1591,7 @@
 static void video1394_remove_host (struct hpsb_host *host)
 {
 	struct ti_ohci *ohci;
-	int flags;
+	unsigned long flags;
 	struct list_head *lh;
 
 	/* We only work with the OHCI-1394 driver */
diff -urN linux-2.4.9-pre4/drivers/md/lvm-snap.c linux/drivers/md/lvm-snap.c
--- linux-2.4.9-pre4/drivers/md/lvm-snap.c	Fri Apr 27 14:23:25 2001
+++ linux/drivers/md/lvm-snap.c	Mon Dec  3 23:03:38 2001
@@ -386,8 +386,8 @@
 
 	blksize_org = lvm_get_blksize(org_phys_dev);
 	blksize_snap = lvm_get_blksize(snap_phys_dev);
-	max_blksize = max(blksize_org, blksize_snap);
-	min_blksize = min(blksize_org, blksize_snap);
+	max_blksize = max(int, blksize_org, blksize_snap);
+	min_blksize = min(int, blksize_org, blksize_snap);
 	max_sectors = KIO_MAX_SECTORS * (min_blksize>>9);
 
 	if (chunk_size % (max_blksize>>9))
@@ -395,7 +395,7 @@
 
 	while (chunk_size)
 	{
-		nr_sectors = min(chunk_size, max_sectors);
+		nr_sectors = min(int, chunk_size, max_sectors);
 		chunk_size -= nr_sectors;
 
 		iobuf->length = nr_sectors << 9;
@@ -503,7 +503,7 @@
 
 	buckets = lv->lv_remap_end;
 	max_buckets = calc_max_buckets();
-	buckets = min(buckets, max_buckets);
+	buckets = min(unsigned long, buckets, max_buckets);
 	while (buckets & (buckets-1))
 		buckets &= (buckets-1);
 
diff -urN linux-2.4.9-pre4/drivers/mtd/devices/docecc.c linux/drivers/mtd/devices/docecc.c
--- linux-2.4.9-pre4/drivers/mtd/devices/docecc.c	Tue Jun 12 10:30:27 2001
+++ linux/drivers/mtd/devices/docecc.c	Mon Dec  3 23:03:38 2001
@@ -80,8 +80,6 @@
   return x;
 }
 
-#define	min(a,b)	((a) < (b) ? (a) : (b))
-
 #define	CLEAR(a,n) {\
 int ci;\
 for(ci=(n)-1;ci >=0;ci--)\
@@ -404,7 +402,7 @@
     den = 0;
     
     /* lambda[i+1] for i even is the formal derivative lambda_pr of lambda[i] */
-    for (i = min(deg_lambda,NN-KK-1) & ~1; i >= 0; i -=2) {
+    for (i = min(int, deg_lambda,NN-KK-1) & ~1; i >= 0; i -=2) {
       if(lambda[i+1] != A0)
 	den ^= Alpha_to[modnn(lambda[i+1] + i * root[j])];
     }
diff -urN linux-2.4.9-pre4/drivers/net/acenic.c linux/drivers/net/acenic.c
--- linux-2.4.9-pre4/drivers/net/acenic.c	Wed Jul  4 14:41:33 2001
+++ linux/drivers/net/acenic.c	Mon Dec  3 23:03:38 2001
@@ -157,10 +157,6 @@
 #define __devinit	__init
 #endif
 
-#ifndef min
-#define min(a,b)	(((a)<(b))?(a):(b))
-#endif
-
 #ifndef SMP_CACHE_BYTES
 #define SMP_CACHE_BYTES	L1_CACHE_BYTES
 #endif
@@ -2999,8 +2995,8 @@
 		return;
 
 	while (size > 0) {
-		tsize = min(((~dest & (ACE_WINDOW_SIZE - 1)) + 1),
-			    min(size, ACE_WINDOW_SIZE));
+		tsize = min(u32, ((~dest & (ACE_WINDOW_SIZE - 1)) + 1),
+			    min(u32, size, ACE_WINDOW_SIZE));
 		tdest = (unsigned long)&regs->Window +
 			(dest & (ACE_WINDOW_SIZE - 1));
 		writel(dest & ~(ACE_WINDOW_SIZE - 1), &regs->WinBase);
@@ -3030,8 +3026,8 @@
 		return;
 
 	while (size > 0) {
-		tsize = min(((~dest & (ACE_WINDOW_SIZE - 1)) + 1),
-			    min(size, ACE_WINDOW_SIZE));
+		tsize = min(u32, ((~dest & (ACE_WINDOW_SIZE - 1)) + 1),
+			    min(u32, size, ACE_WINDOW_SIZE));
 		tdest = (unsigned long)&regs->Window +
 			(dest & (ACE_WINDOW_SIZE - 1));
 		writel(dest & ~(ACE_WINDOW_SIZE - 1), &regs->WinBase);
diff -urN linux-2.4.9-pre4/drivers/net/de600.c linux/drivers/net/de600.c
--- linux-2.4.9-pre4/drivers/net/de600.c	Tue Jul 17 18:53:55 2001
+++ linux/drivers/net/de600.c	Mon Dec  3 23:03:38 2001
@@ -801,7 +801,6 @@
  * This differs from the standard function, that can return an
  * arbitrarily small window!
  */
-#define min(a,b)	((a)<(b)?(a):(b))
 static unsigned long
 de600_rspace(struct sock *sk)
 {
@@ -815,7 +814,7 @@
  */
 
 	if (atomic_read(&sk->rmem_alloc) >= sk->rcvbuf-2*DE600_MIN_WINDOW) return(0);
-	amt = min((sk->rcvbuf-atomic_read(&sk->rmem_alloc))/2/*-DE600_MIN_WINDOW*/, DE600_MAX_WINDOW);
+	amt = min(int, (sk->rcvbuf-atomic_read(&sk->rmem_alloc))/2/*-DE600_MIN_WINDOW*/, DE600_MAX_WINDOW);
 	if (amt < 0) return(0);
 	return(amt);
   }
diff -urN linux-2.4.9-pre4/drivers/net/dgrs.c linux/drivers/net/dgrs.c
--- linux-2.4.9-pre4/drivers/net/dgrs.c	Wed Jun 20 21:00:55 2001
+++ linux/drivers/net/dgrs.c	Mon Dec  3 23:03:38 2001
@@ -693,7 +693,6 @@
 	I596_RBD	*rbdp;
 	int		count;
 	int		i, len, amt;
-#	define		mymin(A,B)	( (A) < (B) ? (A) : (B) )
 
 	/*
 	 *	Determine 0th priv and dev structure pointers
@@ -734,7 +733,7 @@
 			goto no_resources;
 		}
 
-		amt = mymin(len, rbdp->size - count);
+		amt = min(unsigned int, len, rbdp->size - count);
 		memcpy( (char *) S2H(rbdp->buf) + count, skb->data + i, amt);
 		i += amt;
 		count += amt;
diff -urN linux-2.4.9-pre4/drivers/net/hamradio/baycom_epp.c linux/drivers/net/hamradio/baycom_epp.c
--- linux-2.4.9-pre4/drivers/net/hamradio/baycom_epp.c	Wed Apr 18 14:40:06 2001
+++ linux/drivers/net/hamradio/baycom_epp.c	Mon Dec  3 23:03:38 2001
@@ -246,11 +246,6 @@
 
 /* --------------------------------------------------------------------- */
 
-#define min(a, b) (((a) < (b)) ? (a) : (b))
-#define max(a, b) (((a) > (b)) ? (a) : (b))
-
-/* --------------------------------------------------------------------- */
-
 #define KISS_VERBOSE
 
 /* --------------------------------------------------------------------- */
@@ -615,7 +610,7 @@
 	while (cnt > 0) {
 		switch (bc->hdlctx.state) {
 		case tx_keyup:
-			i = min(cnt, bc->hdlctx.flags);
+			i = min(int, cnt, bc->hdlctx.flags);
 			cnt -= i;
 			bc->hdlctx.flags -= i;
 			if (bc->hdlctx.flags <= 0)
@@ -638,7 +633,7 @@
 					break;
 				}
 			}
-			i = min(cnt, bc->hdlctx.bufcnt);
+			i = min(int, cnt, bc->hdlctx.bufcnt);
 			bc->hdlctx.bufcnt -= i;
 			cnt -= i;
 			if (i != pp->ops->epp_write_data(pp, bc->hdlctx.bufptr, i, 0))
@@ -652,7 +647,7 @@
 				bc->hdlctx.state = tx_data;
 				break;
 			}
-			i = min(cnt, bc->hdlctx.flags);
+			i = min(int, cnt, bc->hdlctx.flags);
 			if (i) {
 				cnt -= i;
 				bc->hdlctx.flags -= i;
@@ -669,7 +664,7 @@
 		default:  /* fall through */
 			if (bc->hdlctx.calibrate <= 0)
 				return 0;
-			i = min(cnt, bc->hdlctx.calibrate);
+			i = min(int, cnt, bc->hdlctx.calibrate);
 			cnt -= i;
 			bc->hdlctx.calibrate -= i;
 			memset(tmp, 0, sizeof(tmp));
diff -urN linux-2.4.9-pre4/drivers/net/hamradio/baycom_par.c linux/drivers/net/hamradio/baycom_par.c
--- linux-2.4.9-pre4/drivers/net/hamradio/baycom_par.c	Wed Apr 18 14:40:05 2001
+++ linux/drivers/net/hamradio/baycom_par.c	Mon Dec  3 23:03:38 2001
@@ -157,11 +157,6 @@
 
 /* --------------------------------------------------------------------- */
 
-#define min(a, b) (((a) < (b)) ? (a) : (b))
-#define max(a, b) (((a) > (b)) ? (a) : (b))
-
-/* --------------------------------------------------------------------- */
-
 static void __inline__ baycom_int_freq(struct baycom_state *bc)
 {
 #ifdef BAYCOM_DEBUG
diff -urN linux-2.4.9-pre4/drivers/net/hamradio/baycom_ser_fdx.c linux/drivers/net/hamradio/baycom_ser_fdx.c
--- linux-2.4.9-pre4/drivers/net/hamradio/baycom_ser_fdx.c	Wed Apr 18 14:40:05 2001
+++ linux/drivers/net/hamradio/baycom_ser_fdx.c	Mon Dec  3 23:03:38 2001
@@ -152,11 +152,6 @@
 
 /* --------------------------------------------------------------------- */
 
-#define min(a, b) (((a) < (b)) ? (a) : (b))
-#define max(a, b) (((a) > (b)) ? (a) : (b))
-
-/* --------------------------------------------------------------------- */
-
 static void inline baycom_int_freq(struct baycom_state *bc)
 {
 #ifdef BAYCOM_DEBUG
diff -urN linux-2.4.9-pre4/drivers/net/hamradio/baycom_ser_hdx.c linux/drivers/net/hamradio/baycom_ser_hdx.c
--- linux-2.4.9-pre4/drivers/net/hamradio/baycom_ser_hdx.c	Wed Apr 18 14:40:05 2001
+++ linux/drivers/net/hamradio/baycom_ser_hdx.c	Mon Dec  3 23:03:38 2001
@@ -143,11 +143,6 @@
 
 /* --------------------------------------------------------------------- */
 
-#define min(a, b) (((a) < (b)) ? (a) : (b))
-#define max(a, b) (((a) > (b)) ? (a) : (b))
-
-/* --------------------------------------------------------------------- */
-
 static void inline baycom_int_freq(struct baycom_state *bc)
 {
 #ifdef BAYCOM_DEBUG
diff -urN linux-2.4.9-pre4/drivers/net/hamradio/hdlcdrv.c linux/drivers/net/hamradio/hdlcdrv.c
--- linux-2.4.9-pre4/drivers/net/hamradio/hdlcdrv.c	Wed Apr 18 14:40:06 2001
+++ linux/drivers/net/hamradio/hdlcdrv.c	Mon Dec  3 23:03:38 2001
@@ -95,11 +95,6 @@
 #define PARAM_RETURN    255
 
 /* --------------------------------------------------------------------- */
-
-#define min(a, b) (((a) < (b)) ? (a) : (b))
-#define max(a, b) (((a) > (b)) ? (a) : (b))
-
-/* --------------------------------------------------------------------- */
 /*
  * the CRC routines are stolen from WAMPES
  * by Dieter Deyke
diff -urN linux-2.4.9-pre4/drivers/net/hamradio/soundmodem/sm.h linux/drivers/net/hamradio/soundmodem/sm.h
--- linux-2.4.9-pre4/drivers/net/hamradio/soundmodem/sm.h	Wed Jun 27 17:10:55 2001
+++ linux/drivers/net/hamradio/soundmodem/sm.h	Mon Dec  3 23:03:38 2001
@@ -150,11 +150,6 @@
 
 /* --------------------------------------------------------------------- */
 
-#define min(a, b) (((a) < (b)) ? (a) : (b))
-#define max(a, b) (((a) > (b)) ? (a) : (b))
-
-/* --------------------------------------------------------------------- */
-
 extern const char sm_drvname[];
 extern const char sm_drvinfo[];
 
diff -urN linux-2.4.9-pre4/drivers/net/sk98lin/skproc.c linux/drivers/net/sk98lin/skproc.c
--- linux-2.4.9-pre4/drivers/net/sk98lin/skproc.c	Tue Aug  7 08:30:50 2001
+++ linux/drivers/net/sk98lin/skproc.c	Mon Dec  3 23:03:38 2001
@@ -293,7 +293,7 @@
 	if (buffer_length >= len - offset) {
 		*eof = 1;
 	}
-	return (min(buffer_length, len - offset));
+	return (min(int, buffer_length, len - offset));
 }
 
 
diff -urN linux-2.4.9-pre4/drivers/net/sungem.c linux/drivers/net/sungem.c
--- linux-2.4.9-pre4/drivers/net/sungem.c	Tue Aug  7 08:30:50 2001
+++ linux/drivers/net/sungem.c	Mon Dec  3 23:03:38 2001
@@ -1,4 +1,4 @@
-/* $Id: sungem.c,v 1.18 2001/08/06 13:34:47 davem Exp $
+/* $Id: sungem.c,v 1.19 2001/08/13 14:40:07 davem Exp $
  * sungem.c: Sun GEM ethernet driver.
  *
  * Copyright (C) 2000, 2001 David S. Miller (davem@redhat.com)
@@ -558,7 +558,7 @@
 			skb = copy_skb;
 		}
 
-		skb->csum = ((status & RXDCTRL_TCPCSUM) ^ 0xffff);
+		skb->csum = ntohs((status & RXDCTRL_TCPCSUM) ^ 0xffff);
 		skb->ip_summed = CHECKSUM_HW;
 		skb->protocol = eth_type_trans(skb, gp->dev);
 		netif_rx(skb);
diff -urN linux-2.4.9-pre4/drivers/net/sunhme.c linux/drivers/net/sunhme.c
--- linux-2.4.9-pre4/drivers/net/sunhme.c	Sat Jul 28 12:12:37 2001
+++ linux/drivers/net/sunhme.c	Mon Dec  3 23:03:38 2001
@@ -1,4 +1,4 @@
-/* $Id: sunhme.c,v 1.121 2001/07/27 10:22:57 davem Exp $
+/* $Id: sunhme.c,v 1.122 2001/08/13 14:40:07 davem Exp $
  * sunhme.c: Sparc HME/BigMac 10/100baseT half/full duplex auto switching,
  *           auto carrier detecting ethernet driver.  Also known as the
  *           "Happy Meal Ethernet" found on SunSwift SBUS cards.
@@ -2109,7 +2109,7 @@
 		}
 
 		/* This card is _fucking_ hot... */
-		skb->csum = (csum ^ 0xffff);
+		skb->csum = ntohs(csum ^ 0xffff);
 		skb->ip_summed = CHECKSUM_HW;
 
 		RXD(("len=%d csum=%4x]", len, csum));
diff -urN linux-2.4.9-pre4/drivers/net/wan/comx-hw-comx.c linux/drivers/net/wan/comx-hw-comx.c
--- linux-2.4.9-pre4/drivers/net/wan/comx-hw-comx.c	Tue May 22 10:23:16 2001
+++ linux/drivers/net/wan/comx-hw-comx.c	Mon Dec  3 23:03:38 2001
@@ -1044,7 +1044,7 @@
 		if (!(page = (char *)__get_free_page(GFP_KERNEL))) {
 			return -ENOMEM;
 		}
-		if(copy_from_user(page, buffer, count = (min(count, PAGE_SIZE))))
+		if(copy_from_user(page, buffer, count = (min(int, count, PAGE_SIZE))))
 		{
 			count = -EFAULT;
 			goto out;
@@ -1182,8 +1182,10 @@
 			len = sprintf(page, "external\n");
 		}
 	} else if (strcmp(file->name, FILENAME_FIRMWARE) == 0) {
-		len = min(FILE_PAGESIZE, min(count, 
-			hw->firmware ? (hw->firmware->len - off) :  0));
+		len = min(int, FILE_PAGESIZE,
+			  min(int, count, 
+			      hw->firmware ?
+			      (hw->firmware->len - off) : 0));
 		if (len < 0) {
 			len = 0;
 		}
@@ -1203,7 +1205,7 @@
 	if (count >= len - off) {
 		*eof = 1;
 	}
-	return(min(count, len - off));
+	return min(int, count, len - off);
 }
 
 /* Called on echo comx >boardtype */
diff -urN linux-2.4.9-pre4/drivers/net/wan/comx-hw-locomx.c linux/drivers/net/wan/comx-hw-locomx.c
--- linux-2.4.9-pre4/drivers/net/wan/comx-hw-locomx.c	Mon Sep 18 15:02:03 2000
+++ linux/drivers/net/wan/comx-hw-locomx.c	Mon Dec  3 23:03:38 2001
@@ -324,7 +324,7 @@
 	if (count >= len - off) {
 		*eof = 1;
 	}
-	return ( min(count, len - off) );
+	return min(int, count, len - off);
 }
 
 static int locomx_write_proc(struct file *file, const char *buffer,
@@ -339,7 +339,7 @@
 		return -ENOMEM;
 	}
 
-	copy_from_user(page, buffer, count = min(count, PAGE_SIZE));
+	copy_from_user(page, buffer, count = min(unsigned long, count, PAGE_SIZE));
 	if (*(page + count - 1) == '\n') {
 		*(page + count - 1) = 0;
 	}
diff -urN linux-2.4.9-pre4/drivers/net/wan/comx-hw-mixcom.c linux/drivers/net/wan/comx-hw-mixcom.c
--- linux-2.4.9-pre4/drivers/net/wan/comx-hw-mixcom.c	Wed Jun 27 17:10:55 2001
+++ linux/drivers/net/wan/comx-hw-mixcom.c	Mon Dec  3 23:03:38 2001
@@ -121,7 +121,7 @@
 
 
 	outsb(dev->base_addr + HSCX_FIFO,
-        	&(hw->sending->data[hw->tx_ptr]), min(to_send, 32));
+        	&(hw->sending->data[hw->tx_ptr]), min(unsigned int, to_send, 32));
 	if (to_send <= 32) {
         	hscx_cmd(dev, HSCX_XTF | HSCX_XME);
 	        kfree_skb(hw->sending);
@@ -696,7 +696,7 @@
 	}
 	*start = page + off;
 	if (count >= len - off) *eof = 1;
-	return ( min(count, len - off) );
+	return min(int, count, len - off);
 }
 
 
@@ -763,7 +763,7 @@
 		return -ENOMEM;
 	}
 
-	copy_from_user(page, buffer, count = min(count, PAGE_SIZE));
+	copy_from_user(page, buffer, count = min(unsigned long, count, PAGE_SIZE));
 	if (*(page + count - 1) == '\n') {
 		*(page + count - 1) = 0;
 	}
diff -urN linux-2.4.9-pre4/drivers/net/wan/comx-proto-fr.c linux/drivers/net/wan/comx-proto-fr.c
--- linux-2.4.9-pre4/drivers/net/wan/comx-proto-fr.c	Wed Jun 27 17:10:55 2001
+++ linux/drivers/net/wan/comx-proto-fr.c	Mon Dec  3 23:03:38 2001
@@ -634,7 +634,7 @@
 
 	*start = page + off;
 	if (count >= len - off) *eof = 1;
-	return ( min(count, len - off) );
+	return min(int, count, len - off);
 }
 
 static int fr_write_proc(struct file *file, const char *buffer, 
diff -urN linux-2.4.9-pre4/drivers/net/wan/comx-proto-lapb.c linux/drivers/net/wan/comx-proto-lapb.c
--- linux-2.4.9-pre4/drivers/net/wan/comx-proto-lapb.c	Sat Mar  3 10:55:48 2001
+++ linux/drivers/net/wan/comx-proto-lapb.c	Mon Dec  3 23:03:38 2001
@@ -212,7 +212,7 @@
 	if (count >= len - off) {
 		*eof = 1;
 	}
-	return ( min(count, len - off) );
+	return min(int, count, len - off);
 }
 
 static int comxlapb_write_proc(struct file *file, const char *buffer, 
diff -urN linux-2.4.9-pre4/drivers/net/wan/comx.c linux/drivers/net/wan/comx.c
--- linux-2.4.9-pre4/drivers/net/wan/comx.c	Tue May 22 10:23:16 2001
+++ linux/drivers/net/wan/comx.c	Mon Dec  3 23:03:38 2001
@@ -151,8 +151,8 @@
 		int free = (ch->debug_start - ch->debug_end + ch->debug_size) 
 			% ch->debug_size;
 
-		to_copy = min( free ? free : ch->debug_size, 
-			min (ch->debug_size - ch->debug_end, len) );
+		to_copy = min(int, free ? free : ch->debug_size, 
+			      min(int, ch->debug_size - ch->debug_end, len));
 		memcpy(ch->debug_area + ch->debug_end, str, to_copy);
 		str += to_copy;
 		len -= to_copy;
@@ -567,7 +567,7 @@
 	if (count >= len - off) {
 		*eof = 1;
 	}
-	return( min(count, len - off) );
+	return min(int, count, len - off);
 }
 
 
@@ -597,7 +597,7 @@
 	if (count >= len - off) {
 		*eof = 1;
 	}
-	return( min(count, len - off) );
+	return min(int, count, len - off);
 }
 
 
diff -urN linux-2.4.9-pre4/drivers/net/wan/comx.h linux/drivers/net/wan/comx.h
--- linux-2.4.9-pre4/drivers/net/wan/comx.h	Mon Dec 11 13:38:29 2000
+++ linux/drivers/net/wan/comx.h	Mon Dec  3 23:03:38 2001
@@ -190,14 +190,6 @@
 #endif
 
 
-#ifndef min
-#define min(a,b)		((a) > (b) ? (b) : (a))
-#endif
-#ifndef max
-#define max(a,b)		((a) > (b) ? (a) : (b))
-#endif
-
-
 #define COMX_CHANNEL(dev) ((struct comx_channel*)dev->priv)
 
 #define TWIN(dev) (COMX_CHANNEL(dev)->twin)
diff -urN linux-2.4.9-pre4/drivers/net/wan/cycx_main.c linux/drivers/net/wan/cycx_main.c
--- linux-2.4.9-pre4/drivers/net/wan/cycx_main.c	Tue May 22 10:23:16 2001
+++ linux/drivers/net/wan/cycx_main.c	Mon Dec  3 23:03:38 2001
@@ -111,8 +111,8 @@
 		fullname, DRV_VERSION, DRV_RELEASE, copyright);
 
 	/* Verify number of cards and allocate adapter data space */
-	ncards = min(ncards, MAX_CARDS);
-	ncards = max(ncards, 1);
+	ncards = min(int, ncards, MAX_CARDS);
+	ncards = max(int, ncards, 1);
 	card_array = kmalloc(sizeof(cycx_t) * ncards, GFP_KERNEL);
 	if (!card_array)
 		goto out;
diff -urN linux-2.4.9-pre4/drivers/net/wan/cycx_x25.c linux/drivers/net/wan/cycx_x25.c
--- linux-2.4.9-pre4/drivers/net/wan/cycx_x25.c	Wed Apr 18 14:40:06 2001
+++ linux/drivers/net/wan/cycx_x25.c	Mon Dec  3 23:03:38 2001
@@ -260,13 +260,13 @@
 	        cfg.flags = 0;      /* FIXME just reset the 2nd bit */
 
 	if (conf->u.x25.hi_pvc) {
-		card->u.x.hi_pvc = min(conf->u.x25.hi_pvc, 4095);
-		card->u.x.lo_pvc = min(conf->u.x25.lo_pvc, card->u.x.hi_pvc);
+		card->u.x.hi_pvc = min(unsigned int, conf->u.x25.hi_pvc, 4095);
+		card->u.x.lo_pvc = min(unsigned int, conf->u.x25.lo_pvc, card->u.x.hi_pvc);
 	}
 
 	if (conf->u.x25.hi_svc) {
-		card->u.x.hi_svc = min(conf->u.x25.hi_svc, 4095);
-		card->u.x.lo_svc = min(conf->u.x25.lo_svc, card->u.x.hi_svc);
+		card->u.x.hi_svc = min(unsigned int, conf->u.x25.hi_svc, 4095);
+		card->u.x.lo_svc = min(unsigned int, conf->u.x25.lo_svc, card->u.x.hi_svc);
 	}
 
 	if (card->u.x.lo_pvc == 255)
@@ -277,25 +277,25 @@
 	cfg.nvc = card->u.x.hi_svc - card->u.x.lo_svc + 1 + cfg.npvc;
 
 	if (conf->u.x25.hdlc_window)
-		cfg.n2win = min(conf->u.x25.hdlc_window, 7);
+		cfg.n2win = min(unsigned int, conf->u.x25.hdlc_window, 7);
 
 	if (conf->u.x25.pkt_window)
-		cfg.n3win = min(conf->u.x25.pkt_window, 7);
+		cfg.n3win = min(unsigned int, conf->u.x25.pkt_window, 7);
 
 	if (conf->u.x25.t1)
-		cfg.t1 = min(conf->u.x25.t1, 30);
+		cfg.t1 = min(unsigned int, conf->u.x25.t1, 30);
 
 	if (conf->u.x25.t2)
-		cfg.t2 = min(conf->u.x25.t2, 30);
+		cfg.t2 = min(unsigned int, conf->u.x25.t2, 30);
 
 	if (conf->u.x25.t11_t21)
-		cfg.t21 = min(conf->u.x25.t11_t21, 30);
+		cfg.t21 = min(unsigned int, conf->u.x25.t11_t21, 30);
 
 	if (conf->u.x25.t13_t23)
-		cfg.t23 = min(conf->u.x25.t13_t23, 30);
+		cfg.t23 = min(unsigned int, conf->u.x25.t13_t23, 30);
 
 	if (conf->u.x25.n2)
-		cfg.n2 = min(conf->u.x25.n2, 30);
+		cfg.n2 = min(unsigned int, conf->u.x25.n2, 30);
 
 	/* initialize adapter */
 	if (x25_configure(card, &cfg))
diff -urN linux-2.4.9-pre4/drivers/net/wan/sbni.c linux/drivers/net/wan/sbni.c
--- linux-2.4.9-pre4/drivers/net/wan/sbni.c	Mon Dec  3 23:03:29 2001
+++ linux/drivers/net/wan/sbni.c	Mon Dec  3 23:03:38 2001
@@ -659,7 +659,7 @@
 	struct net_local  *nl    = (struct net_local *) dev->priv;
 	struct sk_buff    *skb	 = nl->tx_buf_p;
 
-	unsigned  len = min( skb->len - nl->outpos, nl->framelen );
+	unsigned  len = min(unsigned int, skb->len - nl->outpos, nl->framelen);
 
 	outsb( dev->base_addr + DAT, skb->data + nl->outpos, len );
 	*crc_p = calc_crc32( *crc_p, skb->data + nl->outpos, len );
@@ -760,8 +760,9 @@
 			nl->outpos += nl->framelen;
 
 			if( --nl->tx_frameno )
-				nl->framelen = min( nl->maxframe,
-					nl->tx_buf_p->len - nl->outpos );
+				nl->framelen = min(unsigned int,
+						   nl->maxframe,
+						   nl->tx_buf_p->len - nl->outpos);
 			else
 				send_complete( nl ),
 #ifdef CONFIG_SBNI_MULTILINE
diff -urN linux-2.4.9-pre4/drivers/net/wan/sbni.h linux/drivers/net/wan/sbni.h
--- linux-2.4.9-pre4/drivers/net/wan/sbni.h	Wed Jul 25 14:12:02 2001
+++ linux/drivers/net/wan/sbni.h	Mon Dec  3 23:03:38 2001
@@ -137,7 +137,5 @@
 #define __initdata
 #endif
 
-#define min( x, y )	( (x) < (y)  ?  (x)  :  (y) )
-
 #endif
 
diff -urN linux-2.4.9-pre4/drivers/net/wan/sdla_chdlc.c linux/drivers/net/wan/sdla_chdlc.c
--- linux-2.4.9-pre4/drivers/net/wan/sdla_chdlc.c	Mon Dec  3 23:03:29 2001
+++ linux/drivers/net/wan/sdla_chdlc.c	Mon Dec  3 23:03:38 2001
@@ -505,13 +505,13 @@
 		/* For Primary Port 0 */
 		card->wandev.mtu =
 			(conf->mtu >= MIN_LGTH_CHDLC_DATA_CFG) ?
-			min(conf->mtu, PRI_MAX_NO_DATA_BYTES_IN_FRAME) :
+			min(unsigned int, conf->mtu, PRI_MAX_NO_DATA_BYTES_IN_FRAME) :
 			CHDLC_DFLT_DATA_LEN;
 	} else if(port_num == WANOPT_SEC) { 
 		/* For Secondary Port 1 */
 		card->wandev.mtu =
 			(conf->mtu >= MIN_LGTH_CHDLC_DATA_CFG) ?
-			min(conf->mtu, SEC_MAX_NO_DATA_BYTES_IN_FRAME) :
+			min(unsigned int, conf->mtu, SEC_MAX_NO_DATA_BYTES_IN_FRAME) :
 			CHDLC_DFLT_DATA_LEN;
 	}
 
@@ -827,19 +827,19 @@
 			card->u.c.kpalv_tx =
 				((conf->keepalive_tx_tmr - MIN_Tx_KPALV_TIMER)
 				>= 0) ?
-	   			min(conf->keepalive_tx_tmr,MAX_Tx_KPALV_TIMER) :
+	   			min(unsigned int, conf->keepalive_tx_tmr,MAX_Tx_KPALV_TIMER) :
 				DEFAULT_Tx_KPALV_TIMER;
 
 			card->u.c.kpalv_rx =
 		   		((conf->keepalive_rx_tmr - MIN_Rx_KPALV_TIMER)
 				>= 0) ?
-	   			min(conf->keepalive_rx_tmr,MAX_Rx_KPALV_TIMER) :
+	   			min(unsigned int, conf->keepalive_rx_tmr,MAX_Rx_KPALV_TIMER) :
 				DEFAULT_Rx_KPALV_TIMER;
 
 			card->u.c.kpalv_err =
 		   		((conf->keepalive_err_margin-MIN_KPALV_ERR_TOL)
 				>= 0) ?
-	   			min(conf->keepalive_err_margin,
+	   			min(unsigned int, conf->keepalive_err_margin,
 				MAX_KPALV_ERR_TOL) : 
 	   			DEFAULT_KPALV_ERR_TOL;
 		}
@@ -847,7 +847,7 @@
 		/* Setup slarp timer to control delay between slarps */
 		card->u.c.slarp_timer = 
 			((conf->slarp_timer - MIN_SLARP_REQ_TIMER) >= 0) ?
-			min (conf->slarp_timer, MAX_SLARP_REQ_TIMER) :
+			min(unsigned int, conf->slarp_timer, MAX_SLARP_REQ_TIMER) :
 			DEFAULT_SLARP_REQ_TIMER;
 
 #ifdef LINUX_2_0
diff -urN linux-2.4.9-pre4/drivers/net/wan/sdla_fr.c linux/drivers/net/wan/sdla_fr.c
--- linux-2.4.9-pre4/drivers/net/wan/sdla_fr.c	Mon Dec  3 23:03:29 2001
+++ linux/drivers/net/wan/sdla_fr.c	Mon Dec  3 23:03:38 2001
@@ -548,10 +548,10 @@
 	/* Adjust configuration */
 	conf->mtu += FR_HEADER_LEN;
 	conf->mtu = (conf->mtu >= MIN_LGTH_FR_DATA_CFG) ?
-			min(conf->mtu, FR_MAX_NO_DATA_BYTES_IN_FRAME) :
+			min(unsigned int, conf->mtu, FR_MAX_NO_DATA_BYTES_IN_FRAME) :
                         FR_CHANNEL_MTU + FR_HEADER_LEN;
      
-	conf->bps = min(conf->bps, 2048000);
+	conf->bps = min(unsigned int, conf->bps, 2048000);
 
 	/* Initialze the configuration structure sent to the board to zero */
 	memset(&u.cfg, 0, sizeof(u.cfg));
@@ -618,7 +618,7 @@
 		 * command in fr_configure() routine. 
 		 */
 
-		card->u.f.dlci_num  = min(max(conf->u.fr.dlci_num, 1), 100);
+		card->u.f.dlci_num  = min(unsigned int, max(unsigned int, conf->u.fr.dlci_num, 1), 100);
 	
 		for ( i = 0; i < card->u.f.dlci_num; i++) {
 
@@ -635,27 +635,27 @@
 		u.cfg.port |= 0x0002;
 
 	if (conf->u.fr.t391)
-		u.cfg.t391 = min(conf->u.fr.t391, 30);
+		u.cfg.t391 = min(unsigned int, conf->u.fr.t391, 30);
 	else
 		u.cfg.t391 = 5;
 
 	if (conf->u.fr.t392)
-		u.cfg.t392 = min(conf->u.fr.t392, 30);
+		u.cfg.t392 = min(unsigned int, conf->u.fr.t392, 30);
 	else
 		u.cfg.t392 = 15;
 
 	if (conf->u.fr.n391)
-		u.cfg.n391 = min(conf->u.fr.n391, 255);
+		u.cfg.n391 = min(unsigned int, conf->u.fr.n391, 255);
 	else
 		u.cfg.n391 = 2;
 
 	if (conf->u.fr.n392)
-		u.cfg.n392 = min(conf->u.fr.n392, 10);
+		u.cfg.n392 = min(unsigned int, conf->u.fr.n392, 10);
 	else
 		u.cfg.n392 = 3;	
 
 	if (conf->u.fr.n393)
-		u.cfg.n393 = min(conf->u.fr.n393, 10);
+		u.cfg.n393 = min(unsigned int, conf->u.fr.n393, 10);
 	else
 		u.cfg.n393 = 4;
 
@@ -952,7 +952,8 @@
          */
 	if (conf->cir) {
 
-		chan->cir = max( 1, min( conf->cir, 512 ) );
+		chan->cir = max(unsigned int, 1,
+				min(unsigned int, conf->cir, 512));
 		chan->cir_status = CIR_ENABLED; 
 
 		
@@ -963,7 +964,8 @@
 		chan->bc = chan->cir;
 
 		if (conf->be){
-			chan->be = max( 0, min( conf->be, 511) ); 
+			chan->be = max(unsigned int,
+				       0, min(unsigned int, conf->be, 511));
 		}else{	
 			conf->be = 0;
 		}
diff -urN linux-2.4.9-pre4/drivers/net/wan/sdla_ppp.c linux/drivers/net/wan/sdla_ppp.c
--- linux-2.4.9-pre4/drivers/net/wan/sdla_ppp.c	Mon Dec  3 23:03:29 2001
+++ linux/drivers/net/wan/sdla_ppp.c	Mon Dec  3 23:03:38 2001
@@ -400,7 +400,7 @@
 	printk(KERN_INFO "%s: running PPP firmware v%s\n",card->devname, u.str); 
 	/* Adjust configuration and set defaults */
 	card->wandev.mtu = (conf->mtu) ?
-		min(conf->mtu, PPP_MAX_MTU) : PPP_DFLT_MTU;
+		min(unsigned int, conf->mtu, PPP_MAX_MTU) : PPP_DFLT_MTU;
 
 	card->wandev.bps	= conf->bps;
 	card->wandev.interface	= conf->interface;
@@ -629,7 +629,7 @@
 	
 	dev->init = &if_init;
 	dev->priv = ppp_priv_area;
-	dev->mtu = min(dev->mtu, card->wandev.mtu);
+	dev->mtu = min(unsigned int, dev->mtu, card->wandev.mtu);
 
 	/* Initialize the polling task routine */
 #ifndef LINUX_2_4
diff -urN linux-2.4.9-pre4/drivers/net/wan/sdla_x25.c linux/drivers/net/wan/sdla_x25.c
--- linux-2.4.9-pre4/drivers/net/wan/sdla_x25.c	Mon Dec  3 23:03:29 2001
+++ linux/drivers/net/wan/sdla_x25.c	Mon Dec  3 23:03:38 2001
@@ -653,13 +653,13 @@
 	u.cfg.defPktSize = u.cfg.pktMTU = card->wandev.mtu;
 
 	if (conf->u.x25.hi_pvc){
-		card->u.x.hi_pvc = min(conf->u.x25.hi_pvc, MAX_LCN_NUM);
-		card->u.x.lo_pvc = min(conf->u.x25.lo_pvc, card->u.x.hi_pvc);
+		card->u.x.hi_pvc = min(unsigned int, conf->u.x25.hi_pvc, MAX_LCN_NUM);
+		card->u.x.lo_pvc = min(unsigned int, conf->u.x25.lo_pvc, card->u.x.hi_pvc);
 	}
 
 	if (conf->u.x25.hi_svc){
-		card->u.x.hi_svc = min(conf->u.x25.hi_svc, MAX_LCN_NUM);
-		card->u.x.lo_svc = min(conf->u.x25.lo_svc, card->u.x.hi_svc);
+		card->u.x.hi_svc = min(unsigned int, conf->u.x25.hi_svc, MAX_LCN_NUM);
+		card->u.x.lo_svc = min(unsigned int, conf->u.x25.lo_svc, card->u.x.hi_svc);
 	}
 
 	/* Figure out the total number of channels to configure */
@@ -684,38 +684,38 @@
 	u.cfg.hiTwoWaySVC = card->u.x.hi_svc;
 
 	if (conf->u.x25.hdlc_window)
-		u.cfg.hdlcWindow = min(conf->u.x25.hdlc_window, 7);
+		u.cfg.hdlcWindow = min(unsigned int, conf->u.x25.hdlc_window, 7);
 	if (conf->u.x25.pkt_window)
-		u.cfg.pktWindow = min(conf->u.x25.pkt_window, 7);
+		u.cfg.pktWindow = min(unsigned int, conf->u.x25.pkt_window, 7);
 
 	if (conf->u.x25.t1)
-		u.cfg.t1 = min(conf->u.x25.t1, 30);
+		u.cfg.t1 = min(unsigned int, conf->u.x25.t1, 30);
 	if (conf->u.x25.t2)
-		u.cfg.t2 = min(conf->u.x25.t2, 29);
+		u.cfg.t2 = min(unsigned int, conf->u.x25.t2, 29);
 	if (conf->u.x25.t4)
-		u.cfg.t4 = min(conf->u.x25.t4, 240);
+		u.cfg.t4 = min(unsigned int, conf->u.x25.t4, 240);
 	if (conf->u.x25.n2)
-		u.cfg.n2 = min(conf->u.x25.n2, 30);
+		u.cfg.n2 = min(unsigned int, conf->u.x25.n2, 30);
 
 	if (conf->u.x25.t10_t20)
-		u.cfg.t10t20 = min(conf->u.x25.t10_t20,255);
+		u.cfg.t10t20 = min(unsigned int, conf->u.x25.t10_t20,255);
 	if (conf->u.x25.t11_t21)
-		u.cfg.t11t21 = min(conf->u.x25.t11_t21,255);
+		u.cfg.t11t21 = min(unsigned int, conf->u.x25.t11_t21,255);
 	if (conf->u.x25.t12_t22)
-		u.cfg.t12t22 = min(conf->u.x25.t12_t22,255);
+		u.cfg.t12t22 = min(unsigned int, conf->u.x25.t12_t22,255);
 	if (conf->u.x25.t13_t23)	
-		u.cfg.t13t23 = min(conf->u.x25.t13_t23,255);
+		u.cfg.t13t23 = min(unsigned int, conf->u.x25.t13_t23,255);
 	if (conf->u.x25.t16_t26)
-		u.cfg.t16t26 = min(conf->u.x25.t16_t26, 255);
+		u.cfg.t16t26 = min(unsigned int, conf->u.x25.t16_t26, 255);
 	if (conf->u.x25.t28)
-		u.cfg.t28 = min(conf->u.x25.t28, 255);
+		u.cfg.t28 = min(unsigned int, conf->u.x25.t28, 255);
 
 	if (conf->u.x25.r10_r20)
-		u.cfg.r10r20 = min(conf->u.x25.r10_r20,250);
+		u.cfg.r10r20 = min(unsigned int, conf->u.x25.r10_r20,250);
 	if (conf->u.x25.r12_r22)
-		u.cfg.r12r22 = min(conf->u.x25.r12_r22,250);
+		u.cfg.r12r22 = min(unsigned int, conf->u.x25.r12_r22,250);
 	if (conf->u.x25.r13_r23)
-		u.cfg.r13r23 = min(conf->u.x25.r13_r23,250);
+		u.cfg.r13r23 = min(unsigned int, conf->u.x25.r13_r23,250);
 
 
 	if (conf->u.x25.ccitt_compat)
diff -urN linux-2.4.9-pre4/drivers/net/wan/wanpipe_multppp.c linux/drivers/net/wan/wanpipe_multppp.c
--- linux-2.4.9-pre4/drivers/net/wan/wanpipe_multppp.c	Mon Dec  3 23:03:29 2001
+++ linux/drivers/net/wan/wanpipe_multppp.c	Mon Dec  3 23:03:38 2001
@@ -375,13 +375,13 @@
 		/* For Primary Port 0 */
 		card->wandev.mtu =
 			(conf->mtu >= MIN_LGTH_CHDLC_DATA_CFG) ?
-			min(conf->mtu, PRI_MAX_NO_DATA_BYTES_IN_FRAME) :
+			min(unsigned int, conf->mtu, PRI_MAX_NO_DATA_BYTES_IN_FRAME) :
 			CHDLC_DFLT_DATA_LEN;
 	} else if(port_num == WANOPT_SEC) { 
 		/* For Secondary Port 1 */
 		card->wandev.mtu =
 			(conf->mtu >= MIN_LGTH_CHDLC_DATA_CFG) ?
-			min(conf->mtu, SEC_MAX_NO_DATA_BYTES_IN_FRAME) :
+			min(unsigned int, conf->mtu, SEC_MAX_NO_DATA_BYTES_IN_FRAME) :
 			CHDLC_DFLT_DATA_LEN;
 	}
 
diff -urN linux-2.4.9-pre4/drivers/net/wireless/airo.c linux/drivers/net/wireless/airo.c
--- linux-2.4.9-pre4/drivers/net/wireless/airo.c	Tue Jul 17 18:53:55 2001
+++ linux/drivers/net/wireless/airo.c	Mon Dec  3 23:03:38 2001
@@ -259,8 +259,6 @@
 
 #include <asm/uaccess.h>
 
-#define min(x,y) ((x<y)?x:y)
-
 /* This is a kind of sloppy hack to get this information to OUT4500 and
    IN4500.  I would be extremely interested in the situation where this
    doesnt work though!!! */
@@ -1755,7 +1753,7 @@
 	// read the rid length field
 	bap_read(ai, pBuf, 2, BAP1);
 	// length for remaining part of rid
-	len = min(len, le16_to_cpu(*(u16*)pBuf)) - 2;
+	len = min(unsigned int, len, le16_to_cpu(*(u16*)pBuf)) - 2;
 	
 	if ( len <= 2 ) {
 		printk( KERN_ERR 
@@ -3998,7 +3996,8 @@
 	 * 9/22/2000 Honor user given length
 	 */
 
-	if (copy_to_user(comp->data, iobuf, min (comp->len, sizeof(iobuf))))
+	if (copy_to_user(comp->data, iobuf,
+			 min(unsigned int, comp->len, sizeof(iobuf))))
 		return -EFAULT;
 	return 0;
 }
@@ -4057,7 +4056,8 @@
 
 		PC4500_readrid(dev->priv,ridcode,iobuf,sizeof(iobuf));
 
-		if (copy_to_user(comp->data,iobuf,min(comp->len,sizeof(iobuf))))
+		if (copy_to_user(comp->data, iobuf,
+				 min(unsigned int, comp->len, sizeof(iobuf))))
 			return -EFAULT;
 		return 0;
 
diff -urN linux-2.4.9-pre4/drivers/net/wireless/airport.c linux/drivers/net/wireless/airport.c
--- linux-2.4.9-pre4/drivers/net/wireless/airport.c	Mon May  7 19:42:14 2001
+++ linux/drivers/net/wireless/airport.c	Mon Dec  3 23:03:38 2001
@@ -1,4 +1,4 @@
-/* airport.c 0.05
+/* airport.c 0.06f
  *
  * A driver for "Hermes" chipset based Apple Airport wireless
  * card.
@@ -32,6 +32,10 @@
 #include "hermes.h"
 #include "orinoco.h"
 
+static const char version[] __initdata = "airport.c 0.06f (Benjamin Herrenschmidt <benh@kernel.crashing.org>)";
+MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>");
+MODULE_DESCRIPTION("Driver for the Apple Airport wireless card.");
+
 typedef struct dldwd_card {
 	struct device_node* node;
 	int irq_requested;
@@ -40,8 +44,6 @@
 	struct dldwd_priv priv;
 } dldwd_card_t;
 
-static char *version = "airport.c 0.05 (Benjamin Herrenschmidt <benh@kernel.crashing.org>)";
-
 /*
  * Function prototypes
  */
@@ -186,7 +188,7 @@
 		printk(KERN_ERR "airport: register_netdev() failed\n");
 		goto failed;
 	}
-	printk(KERN_INFO "airport: card registered for interface %s\n", ndev->name);
+	printk(KERN_DEBUG "airport: card registered for interface %s\n", ndev->name);
 	card->ndev_registered = 1;
 
 	SET_MODULE_OWNER(ndev);
@@ -242,7 +244,7 @@
 {
 	struct device_node* airport_node;
 
-	printk(KERN_INFO "%s\n", version);
+	printk(KERN_DEBUG "%s\n", version);
 
 	MOD_INC_USE_COUNT;
 
diff -urN linux-2.4.9-pre4/drivers/net/wireless/hermes.c linux/drivers/net/wireless/hermes.c
--- linux-2.4.9-pre4/drivers/net/wireless/hermes.c	Mon Jun 11 19:15:27 2001
+++ linux/drivers/net/wireless/hermes.c	Mon Dec  3 23:03:38 2001
@@ -3,21 +3,19 @@
  * Driver core for the "Hermes" wireless MAC controller, as used in
  * the Lucent Orinoco and Cabletron RoamAbout cards. It should also
  * work on the hfa3841 and hfa3842 MAC controller chips used in the
- * Prism I & II chipsets.
+ * Prism II chipsets.
  *
  * This is not a complete driver, just low-level access routines for
  * the MAC controller itself.
  *
  * Based on the prism2 driver from Absolute Value Systems' linux-wlan
  * project, the Linux wvlan_cs driver, Lucent's HCF-Light
- * (wvlan_hcf.c) library, and the NetBSD wireless driver.
+ * (wvlan_hcf.c) library, and the NetBSD wireless driver (in no
+ * particular order).
  *
  * Copyright (C) 2000, David Gibson, Linuxcare Australia <hermes@gibson.dropbear.id.au>
  * 
- * This file distributed under the GPL, version 2.
- */
-
-static const char *version = "hermes.c: 12 Dec 2000 David Gibson <hermes@gibson.dropbear.id.au>";
+ * This file distributed under the GPL, version 2.  */
 
 #include <linux/module.h>
 #include <linux/types.h>
@@ -32,6 +30,10 @@
 
 #include "hermes.h"
 
+static const char version[] __initdata = "hermes.c: 1 Aug 2001 David Gibson <hermes@gibson.dropbear.id.au>";
+MODULE_DESCRIPTION("Low-level driver helper for Lucent Hermes chipset and Prism II HFA384x wireless MAC controller");
+MODULE_AUTHOR("David Gibson <hermes@gibson.dropbear.id.au>");
+
 /* These are maximum timeouts. Most often, card wil react much faster */
 #define CMD_BUSY_TIMEOUT (100) /* In iterations of ~1us */
 #define CMD_INIT_TIMEOUT (50000) /* in iterations of ~10us */
@@ -70,10 +72,6 @@
 static int hermes_issue_cmd(hermes_t *hw, uint16_t cmd, uint16_t param0);
 
 /*
- * Internal inline functions
- */
-
-/*
  * Internal functions
  */
 
@@ -87,7 +85,6 @@
 static int hermes_issue_cmd(hermes_t *hw, uint16_t cmd, uint16_t param0)
 {
 	uint16_t reg;
-/*  	unsigned long k = CMD_BUSY_TIMEOUT; */
 
 	/* First check that the command register is not busy */
 	reg = hermes_read_regn(hw, CMD);
@@ -124,9 +121,12 @@
 	hermes_write_regn(hw, INTEN, 0);
 	hermes_write_regn(hw, EVACK, 0xffff);
 
-	/* Because we hope we can reset the card even if it gets into
-	   a stupid state, we actually wait to see if the command
-	   register will unbusy itself */
+	/* Normally it's a "can't happen" for the command register to
+           be busy when we go to issue a command because we are
+           serializing all commands.  However we want to have some
+           chance of resetting the card even if it gets into a stupid
+           state, so we actually wait to see if the command register
+           will unbusy itself here. */
 	k = CMD_BUSY_TIMEOUT;
 	reg = hermes_read_regn(hw, CMD);
 	while (k && (reg & HERMES_CMD_BUSY)) {
@@ -139,8 +139,8 @@
 		reg = hermes_read_regn(hw, CMD);
 	}
 	
-	/* No need to explicitly handle the timeout - hermes_issue_cmd() will
-	   probably return -EBUSY */
+	/* No need to explicitly handle the timeout - if we've timed
+	   out hermes_issue_cmd() will probably return -EBUSY below */
 
 	/* According to the documentation, EVSTAT may contain
 	   obsolete event occurrence information.  We have to acknowledge
@@ -503,7 +503,7 @@
 
 static int __init init_hermes(void)
 {
-	printk(KERN_INFO "%s\n", version);
+	printk(KERN_DEBUG "%s\n", version);
 
 	return 0;
 }
diff -urN linux-2.4.9-pre4/drivers/net/wireless/hermes.h linux/drivers/net/wireless/hermes.h
--- linux-2.4.9-pre4/drivers/net/wireless/hermes.h	Mon Jun 11 19:15:27 2001
+++ linux/drivers/net/wireless/hermes.h	Mon Dec  3 23:03:38 2001
@@ -101,7 +101,7 @@
 #define		HERMES_STATUS_CMDCODE		(0x003f)
 
 /*
- * OFFSET refister bitmasks
+ * OFFSET register bitmasks
  */
 #define		HERMES_OFFSET_BUSY		(0x8000)
 #define		HERMES_OFFSET_ERR		(0x4000)
diff -urN linux-2.4.9-pre4/drivers/net/wireless/orinoco.c linux/drivers/net/wireless/orinoco.c
--- linux-2.4.9-pre4/drivers/net/wireless/orinoco.c	Mon Jun 11 19:15:27 2001
+++ linux/drivers/net/wireless/orinoco.c	Mon Dec  3 23:03:38 2001
@@ -1,4 +1,4 @@
-/* orinoco.c 0.06	- (formerly known as dldwd_cs.c and orinoco_cs.c)
+/* orinoco.c 0.06f	- (formerly known as dldwd_cs.c and orinoco_cs.c)
  *
  * A driver for "Hermes" chipset based PCMCIA wireless adaptors, such
  * as the Lucent WavelanIEEE/Orinoco cards and their OEM (Cabletron/
@@ -33,10 +33,10 @@
  * Reserved.
  *
  * Alternatively, the contents of this file may be used under the
- * terms of the GNU Public License version 2 (the "GPL"), in which
- * case the provisions of the GPL are applicable instead of the above.
- * If you wish to allow the use of your version of this file only
- * under the terms of the GPL and not to allow others to use your
+ * terms of the GNU General Public License version 2 (the "GPL"), in
+ * which case the provisions of the GPL are applicable instead of the
+ * above.  If you wish to allow the use of your version of this file
+ * only under the terms of the GPL and not to allow others to use your
  * version of this file under the MPL, indicate your decision by
  * deleting the provisions above and replace them with the notice and
  * other provisions required by the GPL.  If you do not delete the
@@ -166,6 +166,24 @@
  * v0.06b -> v0.06c - 29/5/2001 - Jean II
  *	o Show first spy address in /proc/net/wireless for IBSS mode as well
  *
+ * v0.06c -> v0.06d - 6/7/2001 - David Gibson
+ *      o Change a bunch of KERN_INFO messages to KERN_DEBUG, as per Linus'
+ *        wishes to reduce the number of unecessary messages.
+ *	o Removed bogus message on CRC error.
+ *	o Merged fixeds for v0.08 Prism 2 firmware from William Waghorn
+ *	  <willwaghorn@yahoo.co.uk>
+ *	o Slight cleanup/re-arrangement of firmware detection code.
+ *
+ * v0.06d -> v0.06e - 1/8/2001 - David Gibson
+ *	o Removed some redundant global initializers (orinoco_cs.c).
+ *	o Added some module metadataa
+ *
+ * v0.06e -> v0.06f - 14/8/2001 - David Gibson
+ *	o Wording fix to license
+ *	o Added a 'use_alternate_encaps' module parameter for APs which need an oui of
+ *	  00:00:00.  We really need a better way of handling this, but the module flag
+ *	  is better than nothing for now.
+ *
  * TODO - Jean II
  *	o inline functions (lot's of candidate, need to reorder code)
  *	o Test PrismII/Symbol cards & firmware versions
@@ -202,7 +220,9 @@
 #include "hermes.h"
 #include "orinoco.h"
 
-static char *version = "orinoco.c 0.06c (David Gibson <hermes@gibson.dropbear.id.au> and others)";
+static const char version[] __initdata = "orinoco.c 0.06f (David Gibson <hermes@gibson.dropbear.id.au> and others)";
+MODULE_AUTHOR("David Gibson <hermes@gibson.dropbear.id.au>");
+MODULE_DESCRIPTION("Driver for Lucent Orinoco, Prism II based and similar wireless cards");
 
 /* Level of debugging. Used in the macros in orinoco.h */
 #ifdef ORINOCO_DEBUG
@@ -210,6 +230,11 @@
 MODULE_PARM(dldwd_debug, "i");
 #endif
 
+/* FIXME: We need a better way of handling this */
+/* Set this flag to use 00:00:00 for the encapsulation oui instead of 00:00:F8 */
+static int use_alternate_encaps; /* =0 */
+MODULE_PARM(use_alternate_encaps, "i");
+
 const long channel_frequency[] = {
 	2412, 2417, 2422, 2427, 2432, 2437, 2442,
 	2447, 2452, 2457, 2462, 2467, 2472, 2484
@@ -274,6 +299,9 @@
 struct p8022_hdr encaps_hdr = {
 	0xaa, 0xaa, 0x03, {0x00, 0x00, 0xf8}
 };
+struct p8022_hdr alternate_encaps_hdr = {
+	0xaa, 0xaa, 0x03, {0x00, 0x00, 0x00}
+};
 
 /*
  * Function prototypes
@@ -396,6 +424,7 @@
 				priv->port_type = 4;
 			else
 				priv->port_type = 1;
+			priv->port_type = priv->ibss_port;
 			priv->allow_ibss = 1;
 		}
 		break;
@@ -1050,8 +1079,7 @@
 	if (status & HERMES_RXSTAT_ERR) {
 		if ((status & HERMES_RXSTAT_ERR) == HERMES_RXSTAT_BADCRC) {
 			stats->rx_crc_errors++;
-			printk(KERN_WARNING "%s: Bad CRC on Rx. Frame dropped.\n",
-			       dev->name);
+			DEBUG(1, "%s: Bad CRC on Rx. Frame dropped.\n", dev->name);
 			show_rx_frame(&hdr);
 		} else if ((status & HERMES_RXSTAT_ERR)
 			   == HERMES_RXSTAT_UNDECRYPTABLE) {
@@ -1198,34 +1226,14 @@
 /* 	hermes_write_regn(hw, ALLOCFID, 0); */
 }
 
-/*
- * struct net_device methods
- */
-
-int
-dldwd_init(struct net_device *dev)
+static void determine_firmware(struct net_device *dev)
 {
 	dldwd_priv_t *priv = dev->priv;
 	hermes_t *hw = &priv->hw;
-	int err = 0;
-	hermes_id_t nickbuf;
-	uint16_t reclen;
-	int len;
-	char *vendor_str;
+	int err;
 	uint32_t firmver;
+	char *vendor_str;
 
-	TRACE_ENTER("dldwd");
-	
-	dldwd_lock(priv);
-
-	/* Do standard firmware reset */
-	err = hermes_reset(hw);
-	if (err != 0) {
-		printk(KERN_ERR "%s: failed to reset hardware (err = %d)\n",
-		       dev->name, err);
-		goto out;
-	}
-	
 	/* Get the firmware version */
 	err = hermes_read_staidentity(hw, USER_BAP, &priv->firmware_info);
 	if (err) {
@@ -1361,18 +1369,54 @@
 		priv->has_pm = 0;
 		priv->has_preamble = 0;
 	}
+	
+	if (priv->firmware_type == FIRMWARE_TYPE_SYMBOL)
+		priv->ibss_port = 4;
+	else if ( (priv->firmware_type == FIRMWARE_TYPE_PRISM2) && (firmver >= 0x00008) )
+		priv->ibss_port = 0;
+	else
+		priv->ibss_port = 1;
 
-	printk(KERN_INFO "%s: Firmware ID %02X vendor 0x%x (%s) version %d.%02d\n",
+	printk(KERN_DEBUG "%s: Firmware ID %02X vendor 0x%x (%s) version %d.%02d\n",
 	       dev->name, priv->firmware_info.id, priv->firmware_info.vendor,
 	       vendor_str, priv->firmware_info.major, priv->firmware_info.minor);
+}
+
+/*
+ * struct net_device methods
+ */
+
+int
+dldwd_init(struct net_device *dev)
+{
+	dldwd_priv_t *priv = dev->priv;
+	hermes_t *hw = &priv->hw;
+	int err = 0;
+	hermes_id_t nickbuf;
+	uint16_t reclen;
+	int len;
+
+	TRACE_ENTER("dldwd");
+	
+	dldwd_lock(priv);
+
+	/* Do standard firmware reset */
+	err = hermes_reset(hw);
+	if (err != 0) {
+		printk(KERN_ERR "%s: failed to reset hardware (err = %d)\n",
+		       dev->name, err);
+		goto out;
+	}
+
+	determine_firmware(dev);
 
 	if (priv->has_port3)
-		printk(KERN_INFO "%s: Ad-hoc demo mode supported.\n", dev->name);
+		printk(KERN_DEBUG "%s: Ad-hoc demo mode supported.\n", dev->name);
 	if (priv->has_ibss)
-		printk(KERN_INFO "%s: IEEE standard IBSS ad-hoc mode supported.\n",
+		printk(KERN_DEBUG "%s: IEEE standard IBSS ad-hoc mode supported.\n",
 		       dev->name);
 	if (priv->has_wep) {
-		printk(KERN_INFO "%s: WEP supported, ", dev->name);
+		printk(KERN_DEBUG "%s: WEP supported, ", dev->name);
 		if (priv->has_big_wep)
 			printk("\"128\"-bit key.\n");
 		else
@@ -1388,7 +1432,7 @@
 		goto out;
 	}
 
-	printk(KERN_INFO "%s: MAC address %02X:%02X:%02X:%02X:%02X:%02X\n",
+	printk(KERN_DEBUG "%s: MAC address %02X:%02X:%02X:%02X:%02X:%02X\n",
 	       dev->name, dev->dev_addr[0], dev->dev_addr[1],
 	       dev->dev_addr[2], dev->dev_addr[3], dev->dev_addr[4],
 	       dev->dev_addr[5]);
@@ -1408,7 +1452,7 @@
 	memcpy(priv->nick, &nickbuf.val, len);
 	priv->nick[len] = '\0';
 
-	printk(KERN_INFO "%s: Station name \"%s\"\n", dev->name, priv->nick);
+	printk(KERN_DEBUG "%s: Station name \"%s\"\n", dev->name, priv->nick);
 
 	/* Get allowed channels */
 	err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CHANNEL_LIST, &priv->channel_mask);
@@ -1482,7 +1526,7 @@
 	priv->wep_on = 0;
 	priv->tx_key = 0;
 
-	printk(KERN_INFO "%s: ready\n", dev->name);
+	printk(KERN_DEBUG "%s: ready\n", dev->name);
 
  out:
 	dldwd_unlock(priv);
@@ -1668,7 +1712,11 @@
 		hdr.p8023.h_proto = htons(data_len + ENCAPS_OVERHEAD);
 		
 		/* 802.2 header */
-		memcpy(&hdr.p8022, &encaps_hdr, sizeof(encaps_hdr));
+		/* FIXME: ugh, what a hack for the 00:00:00 APs.  Need to find a better way */
+		if (use_alternate_encaps)
+			memcpy(&hdr.p8022, &alternate_encaps_hdr, sizeof(alternate_encaps_hdr));
+		else
+			memcpy(&hdr.p8022, &encaps_hdr, sizeof(encaps_hdr));
 
 		hdr.ethertype = eh->h_proto;
 		err  = hermes_bap_pwrite(hw, USER_BAP, &hdr, sizeof(hdr),
@@ -2546,6 +2594,33 @@
 }
 #endif /* WIRELESS_EXT > 10 */
 
+static int dldwd_ioctl_setibssport(struct net_device *dev, struct iwreq *wrq)
+{
+	dldwd_priv_t *priv = dev->priv;
+	int val = *( (int *) wrq->u.name );
+
+	dldwd_lock(priv);
+	priv->ibss_port = val ;
+
+	/* Actually update the mode we are using */
+	set_port_type(priv);
+
+	dldwd_unlock(priv);
+	return 0;
+}
+
+static int dldwd_ioctl_getibssport(struct net_device *dev, struct iwreq *wrq)
+{
+	dldwd_priv_t *priv = dev->priv;
+	int *val = (int *)wrq->u.name;
+
+	dldwd_lock(priv);
+	*val = priv->ibss_port;
+	dldwd_unlock(priv);
+
+	return 0;
+}
+
 static int dldwd_ioctl_setport3(struct net_device *dev, struct iwreq *wrq)
 {
 	dldwd_priv_t *priv = dev->priv;
@@ -2941,7 +3016,13 @@
 				  0, "set_preamble" },
 				{ SIOCDEVPRIVATE + 0x5, 0,
 				  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
-				  "get_preamble" }
+				  "get_preamble" },
+				{ SIOCDEVPRIVATE + 0x6,
+				  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
+				  0, "set_ibssport" },
+				{ SIOCDEVPRIVATE + 0x7, 0,
+				  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
+				  "get_ibssport" }
 			};
 
 			err = verify_area(VERIFY_WRITE, wrq->u.data.pointer, sizeof(privtab));
@@ -3038,6 +3119,25 @@
 		} else
 			err = -EOPNOTSUPP;
 		break;
+	case SIOCDEVPRIVATE + 0x6: /* set_ibssport */
+		DEBUG(1, "%s: SIOCDEVPRIVATE + 0x6 (set_ibssport)\n",
+		      dev->name);
+		if (! capable(CAP_NET_ADMIN)) {
+			err = -EPERM;
+			break;
+		}
+
+		err = dldwd_ioctl_setibssport(dev, wrq);
+		if (! err)
+			changed = 1;
+		break;
+
+	case SIOCDEVPRIVATE + 0x7: /* get_ibssport */
+		DEBUG(1, "%s: SIOCDEVPRIVATE + 0x7 (get_ibssport)\n",
+		      dev->name);
+		err = dldwd_ioctl_getibssport(dev, wrq);
+		break;
+
 
 	default:
 		err = -EOPNOTSUPP;
@@ -3601,7 +3701,7 @@
 
 	err = dldwd_proc_init();
 
-	printk(KERN_INFO "%s\n", version);
+	printk(KERN_DEBUG "%s\n", version);
 
 	return 0;
 }
diff -urN linux-2.4.9-pre4/drivers/net/wireless/orinoco.h linux/drivers/net/wireless/orinoco.h
--- linux-2.4.9-pre4/drivers/net/wireless/orinoco.h	Mon Jun 11 19:15:27 2001
+++ linux/drivers/net/wireless/orinoco.h	Mon Dec  3 23:03:38 2001
@@ -69,7 +69,7 @@
 #define FIRMWARE_TYPE_LUCENT 1
 #define FIRMWARE_TYPE_PRISM2 2
 #define FIRMWARE_TYPE_SYMBOL 3
-	int has_ibss, has_port3, prefer_port3, has_ibss_any;
+	int has_ibss, has_port3, prefer_port3, has_ibss_any, ibss_port;
 	int has_wep, has_big_wep;
 	int has_mwo;
 	int has_pm;
@@ -107,10 +107,10 @@
 
 /*====================================================================*/
 
-extern int dldwd_debug;
 extern struct list_head dldwd_instances;
 
 #ifdef ORINOCO_DEBUG
+extern int dldwd_debug;
 #define DEBUG(n, args...) if (dldwd_debug>(n)) printk(KERN_DEBUG args)
 #define DEBUGMORE(n, args...) do { if (dldwd_debug>(n)) printk(args); } while (0)
 #else
diff -urN linux-2.4.9-pre4/drivers/net/wireless/orinoco_cs.c linux/drivers/net/wireless/orinoco_cs.c
--- linux-2.4.9-pre4/drivers/net/wireless/orinoco_cs.c	Mon Jul  2 14:03:04 2001
+++ linux/drivers/net/wireless/orinoco_cs.c	Mon Dec  3 23:03:38 2001
@@ -1,4 +1,4 @@
-/* orinoco_cs.c 0.06	- (formerly known as dldwd_cs.c)
+/* orinoco_cs.c 0.06f	- (formerly known as dldwd_cs.c)
  *
  * A driver for "Hermes" chipset based PCMCIA wireless adaptors, such
  * as the Lucent WavelanIEEE/Orinoco cards and their OEM (Cabletron/
@@ -40,20 +40,12 @@
 #include "hermes.h"
 #include "orinoco.h"
 
-/* Pcmcia specific structure */
-typedef struct dldwd_card {
-	dev_link_t link;
-	dev_node_t node;
-	int instance;
-
-	/* Common structure (fully included), see orinoco.h */
-	struct dldwd_priv  priv;
-} dldwd_card_t;
+/*====================================================================*/
 
-static char version[] __initdata =
-"orinoco_cs.c 0.06 (David Gibson <hermes@gibson.dropbear.id.au> and others)";
+static const char version[] __initdata = "orinoco_cs.c 0.06f (David Gibson <hermes@gibson.dropbear.id.au> and others)";
 
-/*====================================================================*/
+MODULE_AUTHOR("David Gibson <hermes@gibson.dropbear.id.au>");
+MODULE_DESCRIPTION("Driver for PCMCIA Lucent Orinoco, Prism II based and similar wireless cards");
 
 /* Parameters that can be set with 'insmod' */
 
@@ -66,13 +58,24 @@
 static int reset_cor = 0;
 /* Some D-Link cards have buggy CIS. They do work at 5v properly, but
  * don't have any CIS entry for it. This workaround it... */
-static int ignore_cis_vcc = 0;
+static int ignore_cis_vcc; /* = 0 */
 
 MODULE_PARM(irq_mask, "i");
 MODULE_PARM(irq_list, "1-4i");
 MODULE_PARM(reset_cor, "i");
 MODULE_PARM(ignore_cis_vcc, "i");
 
+
+/* Pcmcia specific structure */
+typedef struct dldwd_card {
+	dev_link_t link;
+	dev_node_t node;
+	int instance;
+
+	/* Common structure (fully included), see orinoco.h */
+	struct dldwd_priv  priv;
+} dldwd_card_t;
+
 /*
  * Function prototypes
  */
@@ -108,8 +111,8 @@
    device numbers are used to derive the corresponding array index.
 */
 
-static dev_link_t *dev_list;
-static int num_instances;
+static dev_link_t *dev_list; /* = NULL */
+static int num_instances; /* = 0 */
 
 /*====================================================================*/
 
@@ -595,7 +598,7 @@
 	strcpy(card->node.dev_name, ndev->name);
 
 	/* Finally, report what we've done */
-	printk(KERN_INFO "%s: index 0x%02x: Vcc %d.%d",
+	printk(KERN_DEBUG "%s: index 0x%02x: Vcc %d.%d",
 	       ndev->name, link->conf.ConfigIndex,
 	       link->conf.Vcc / 10, link->conf.Vcc % 10);
 	if (link->conf.Vpp1)
@@ -777,8 +780,8 @@
 
 	TRACE_ENTER("dldwd");
 
-	printk(KERN_INFO "dldwd: David's Less Dodgy WaveLAN/IEEE Driver\n"
-	       KERN_INFO "%s\n", version);
+	printk(KERN_DEBUG "dldwd: David's Less Dodgy WaveLAN/IEEE Driver\n"
+	       KERN_DEBUG "%s\n", version);
 
 	CardServices(GetCardServicesInfo, &serv);
 	if (serv.Revision != CS_RELEASE_CODE) {
diff -urN linux-2.4.9-pre4/drivers/s390/net/iucv.c linux/drivers/s390/net/iucv.c
--- linux-2.4.9-pre4/drivers/s390/net/iucv.c	Wed Jul 25 14:12:02 2001
+++ linux/drivers/s390/net/iucv.c	Mon Dec  3 23:03:38 2001
@@ -39,13 +39,6 @@
 #include <asm/s390_ext.h>
 #include <asm/ebcdic.h>
 
-#ifndef min
-#define min(a,b) (((a)<(b))?(a):(b))
-#endif
-#ifndef max
-#define max(a,b) (((a)>(b))?(a):(b))
-#endif
-
 #ifdef DEBUG
 #undef KERN_INFO
 #undef KERN_DEBUG
@@ -1316,7 +1309,7 @@
 			if (residual_buffer)
 				*residual_buffer = parm.ipbfadr1;
 		} else {
-			moved = min (buflen, 8);
+			moved = min(unsigned int, buflen, 8);
 
 			memcpy ((char *) buffer,
 				(char *) &parm.ipbfadr1, moved);
@@ -1409,7 +1402,8 @@
 
 			while ((moved < 8) && (moved < buflen)) {
 				dyn_len =
-				    min ((buffer + i)->length, need_to_move);
+				    min(unsigned int,
+					(buffer + i)->length, need_to_move);
 
 				memcpy ((char *)((ulong)((buffer + i)->address)),
 					((char *) &parm.ipbfadr1) + moved,
diff -urN linux-2.4.9-pre4/drivers/s390/net/netiucv.c linux/drivers/s390/net/netiucv.c
--- linux-2.4.9-pre4/drivers/s390/net/netiucv.c	Wed Jul 25 14:12:02 2001
+++ linux/drivers/s390/net/netiucv.c	Mon Dec  3 23:03:38 2001
@@ -91,7 +91,6 @@
 #include <linux/init.h>		/* __setup()                    */
 #include <asm/string.h>		/* memset, memcpy, etc.         */
 #include "iucv.h"
-#define min(a,b) (a < b) ? a : b
 
 #if defined( DEBUG )
 #undef KERN_INFO
@@ -828,7 +827,8 @@
 	net_device *dev;
 
 	memset (iucv_userid[devnumber], ' ', 8);
-	memcpy (iucv_userid[devnumber], userid, min (strlen (userid), 8));
+	memcpy (iucv_userid[devnumber], userid,
+		min(unsigned int, strlen(userid), 8));
 	dev = &iucv_netdev[devnumber];
 	sprintf (dev->name, "iucv%i", devnumber);
 
diff -urN linux-2.4.9-pre4/drivers/sbus/audio/audio.c linux/drivers/sbus/audio/audio.c
--- linux-2.4.9-pre4/drivers/sbus/audio/audio.c	Mon Dec  3 23:03:29 2001
+++ linux/drivers/sbus/audio/audio.c	Mon Dec  3 23:03:38 2001
@@ -1,4 +1,4 @@
-/* $Id: audio.c,v 1.60 2001/05/21 09:05:05 davem Exp $
+/* $Id: audio.c,v 1.61 2001/08/13 14:40:12 davem Exp $
  * drivers/sbus/audio/audio.c
  *
  * Copyright 1996 Thomas K. Dyas (tdyas@noc.rutgers.edu)
diff -urN linux-2.4.9-pre4/drivers/sbus/char/aurora.c linux/drivers/sbus/char/aurora.c
--- linux-2.4.9-pre4/drivers/sbus/char/aurora.c	Mon Dec  3 23:03:29 2001
+++ linux/drivers/sbus/char/aurora.c	Mon Dec  3 23:03:38 2001
@@ -1,4 +1,4 @@
-/*	$Id: aurora.c,v 1.14 2001/06/29 23:07:37 davem Exp $
+/*	$Id: aurora.c,v 1.15 2001/08/13 14:40:08 davem Exp $
  *	linux/drivers/sbus/char/aurora.c -- Aurora multiport driver
  *
  *	Copyright (c) 1999 by Oliver Aldulea (oli at bv dot ro)
diff -urN linux-2.4.9-pre4/drivers/sbus/char/pcikbd.c linux/drivers/sbus/char/pcikbd.c
--- linux-2.4.9-pre4/drivers/sbus/char/pcikbd.c	Wed Jun 20 21:00:55 2001
+++ linux/drivers/sbus/char/pcikbd.c	Mon Dec  3 23:03:38 2001
@@ -1,4 +1,4 @@
-/* $Id: pcikbd.c,v 1.58 2001/06/10 06:51:03 davem Exp $
+/* $Id: pcikbd.c,v 1.59 2001/08/13 14:40:08 davem Exp $
  * pcikbd.c: Ultra/AX PC keyboard support.
  *
  * Copyright (C) 1997  Eddie C. Dost  (ecd@skynet.be)
@@ -476,6 +476,11 @@
 		return;
 	if (!send_data(KBD_CMD_SET_LEDS) || !send_data(leds))
 		send_data(KBD_CMD_ENABLE);
+}
+
+int pcikbd_rate(struct kbd_repeat *rep)
+{
+	return -EIO;
 }
 
 static int pcikbd_wait_for_input(void)
diff -urN linux-2.4.9-pre4/drivers/sbus/char/rtc.c linux/drivers/sbus/char/rtc.c
--- linux-2.4.9-pre4/drivers/sbus/char/rtc.c	Mon Dec  3 23:03:29 2001
+++ linux/drivers/sbus/char/rtc.c	Mon Dec  3 23:03:38 2001
@@ -1,4 +1,4 @@
-/* $Id: rtc.c,v 1.26 2001/03/14 09:30:31 davem Exp $
+/* $Id: rtc.c,v 1.27 2001/08/13 14:40:08 davem Exp $
  *
  * Linux/SPARC Real Time Clock Driver
  * Copyright (C) 1996 Thomas K. Dyas (tdyas@eden.rutgers.edu)
diff -urN linux-2.4.9-pre4/drivers/sbus/char/uctrl.c linux/drivers/sbus/char/uctrl.c
--- linux-2.4.9-pre4/drivers/sbus/char/uctrl.c	Mon Dec  3 23:03:29 2001
+++ linux/drivers/sbus/char/uctrl.c	Mon Dec  3 23:03:38 2001
@@ -1,4 +1,4 @@
-/* $Id: uctrl.c,v 1.10 2001/02/13 01:17:00 davem Exp $
+/* $Id: uctrl.c,v 1.11 2001/08/13 14:40:08 davem Exp $
  * uctrl.c: TS102 Microcontroller interface on Tadpole Sparcbook 3
  *
  * Copyright 1999 Derrick J Brashear (shadow@dementia.org)
diff -urN linux-2.4.9-pre4/drivers/scsi/3w-xxxx.c linux/drivers/scsi/3w-xxxx.c
--- linux-2.4.9-pre4/drivers/scsi/3w-xxxx.c	Wed Jun 27 17:10:55 2001
+++ linux/drivers/scsi/3w-xxxx.c	Mon Dec  3 23:03:38 2001
@@ -1202,15 +1202,14 @@
 	int do_attention_interrupt=0;
 	int do_host_interrupt=0;
 	int do_command_interrupt=0;
-	int flags = 0;
-	int flags2 = 0;
+	unsigned long flags = 0;
 	TW_Command *command_packet;
 	if (test_and_set_bit(TW_IN_INTR, &tw_dev->flags))
 		return;
 	spin_lock_irqsave(&io_request_lock, flags);
 
 	if (tw_dev->tw_pci_dev->irq == irq) {
-		spin_lock_irqsave(&tw_dev->tw_lock, flags2);
+		spin_lock(&tw_dev->tw_lock);
 		dprintk(KERN_NOTICE "3w-xxxx: tw_interrupt()\n");
 
 		/* Read the registers */
@@ -1349,7 +1348,7 @@
 				}
 			}
 		}
-		spin_unlock_irqrestore(&tw_dev->tw_lock, flags2);
+		spin_unlock(&tw_dev->tw_lock);
 	}
 	spin_unlock_irqrestore(&io_request_lock, flags);
 	clear_bit(TW_IN_INTR, &tw_dev->flags);
@@ -1918,7 +1917,7 @@
 	unsigned char *command = SCpnt->cmnd;
 	int request_id = 0;
 	int error = 0;
-	int flags = 0;
+	unsigned long flags = 0;
 	TW_Device_Extension *tw_dev = (TW_Device_Extension *)SCpnt->host->hostdata;
 
 	if (tw_dev == NULL) {
diff -urN linux-2.4.9-pre4/drivers/scsi/eata_generic.h linux/drivers/scsi/eata_generic.h
--- linux-2.4.9-pre4/drivers/scsi/eata_generic.h	Mon Oct 28 14:31:24 1996
+++ linux/drivers/scsi/eata_generic.h	Mon Dec  3 23:03:38 2001
@@ -25,8 +25,6 @@
 #define FALSE 0
 #endif
 
-#define min(a,b) ((a<b)?(a):(b))
-
 #define R_LIMIT 0x20000
 
 #define MAXISA	   4
diff -urN linux-2.4.9-pre4/drivers/scsi/eata_pio.c linux/drivers/scsi/eata_pio.c
--- linux-2.4.9-pre4/drivers/scsi/eata_pio.c	Fri Feb  9 11:30:23 2001
+++ linux/drivers/scsi/eata_pio.c	Mon Dec  3 23:03:38 2001
@@ -161,7 +161,7 @@
 			    IncStat(&cmd->SCp,1);
 			    odd=FALSE;
 			}
-			x=min(z,cmd->SCp.this_residual/2);
+			x=min(unsigned int,z,cmd->SCp.this_residual/2);
 			insw(base+HA_RDATA,cmd->SCp.ptr,x);
 			z-=x; 
 			IncStat(&cmd->SCp,2*x);
@@ -191,7 +191,7 @@
 			    z--; 
 			    odd=FALSE; 
 			}
-			x=min(z,cmd->SCp.this_residual/2);
+			x=min(unsigned int,z,cmd->SCp.this_residual/2);
 			outsw(base+HA_RDATA,cmd->SCp.ptr,x);
 			z-=x; 
 			IncStat(&cmd->SCp,2*x);
diff -urN linux-2.4.9-pre4/drivers/scsi/ips.c linux/drivers/scsi/ips.c
--- linux-2.4.9-pre4/drivers/scsi/ips.c	Sat May 19 17:43:06 2001
+++ linux/drivers/scsi/ips.c	Mon Dec  3 23:03:38 2001
@@ -1416,7 +1416,7 @@
 ips_eh_reset(Scsi_Cmnd *SC) {
    int                   ret;
    int                   i;
-   u32                   cpu_flags;
+   unsigned long         cpu_flags;
    ips_ha_t             *ha;
    ips_scb_t            *scb;
    ips_copp_wait_item_t *item;
@@ -1607,7 +1607,7 @@
 int
 ips_queue(Scsi_Cmnd *SC, void (*done) (Scsi_Cmnd *)) {
    ips_ha_t         *ha;
-   u32               cpu_flags;
+   unsigned long     cpu_flags;
    DECLARE_MUTEX_LOCKED(sem);
 
    METHOD_TRACE("ips_queue", 1);
@@ -1854,7 +1854,7 @@
 void
 do_ipsintr(int irq, void *dev_id, struct pt_regs *regs) {
    ips_ha_t         *ha;
-   u32               cpu_flags;
+   unsigned long     cpu_flags;
 
    METHOD_TRACE("do_ipsintr", 2);
 
@@ -1909,7 +1909,7 @@
    ips_scb_t        *scb;
    IPS_STATUS        cstatus;
    int               intrstatus;
-   u32               cpu_flags;
+   unsigned long     cpu_flags;
 
    METHOD_TRACE("ips_intr", 2);
 
@@ -1981,7 +1981,7 @@
    ips_scb_t        *scb;
    IPS_STATUS        cstatus;
    int               intrstatus;
-   u32               cpu_flags;
+   unsigned long     cpu_flags;
 
    METHOD_TRACE("ips_intr_morpheus", 2);
 
@@ -3548,8 +3548,8 @@
    ips_copp_wait_item_t *item;
    int                   ret;
    int                   intr_status;
-   u32                   cpu_flags;
-   u32                   cpu_flags2;
+   unsigned long         cpu_flags;
+   unsigned long         cpu_flags2;
 
    METHOD_TRACE("ips_next", 1);
 
@@ -4403,7 +4403,7 @@
 static void
 ips_done(ips_ha_t *ha, ips_scb_t *scb) {
    int ret;
-   u32 cpu_flags;
+   unsigned long cpu_flags;
 
    METHOD_TRACE("ips_done", 1);
 
@@ -5520,7 +5520,7 @@
 static ips_scb_t *
 ips_getscb(ips_ha_t *ha) {
    ips_scb_t     *scb;
-   u32            cpu_flags;
+   unsigned long  cpu_flags;
 
    METHOD_TRACE("ips_getscb", 1);
 
@@ -5554,7 +5554,7 @@
 /****************************************************************************/
 static void
 ips_freescb(ips_ha_t *ha, ips_scb_t *scb) {
-   u32          cpu_flags;
+   unsigned long cpu_flags;
 
    METHOD_TRACE("ips_freescb", 1);
 
@@ -5967,7 +5967,7 @@
 static int
 ips_reset_copperhead(ips_ha_t *ha) {
    int reset_counter;
-   u32 cpu_flags;
+   unsigned long cpu_flags;
 
    METHOD_TRACE("ips_reset_copperhead", 1);
 
@@ -6012,7 +6012,7 @@
 static int
 ips_reset_copperhead_memio(ips_ha_t *ha) {
    int reset_counter;
-   u32 cpu_flags;
+   unsigned long cpu_flags;
 
    METHOD_TRACE("ips_reset_copperhead_memio", 1);
 
@@ -6058,7 +6058,7 @@
 ips_reset_morpheus(ips_ha_t *ha) {
    int reset_counter;
    u8  junk;
-   u32 cpu_flags;
+   unsigned long cpu_flags;
 
    METHOD_TRACE("ips_reset_morpheus", 1);
 
@@ -6237,7 +6237,7 @@
 ips_issue_copperhead(ips_ha_t *ha, ips_scb_t *scb) {
    u32       TimeOut;
    u16       val;
-   u32       cpu_flags;
+   unsigned long       cpu_flags;
 
    METHOD_TRACE("ips_issue_copperhead", 1);
 
@@ -6300,7 +6300,7 @@
 ips_issue_copperhead_memio(ips_ha_t *ha, ips_scb_t *scb) {
    u32       TimeOut;
    u32       val;
-   u32       cpu_flags;
+   unsigned long cpu_flags;
 
    METHOD_TRACE("ips_issue_copperhead_memio", 1);
 
@@ -6361,7 +6361,7 @@
 /****************************************************************************/
 static int
 ips_issue_i2o(ips_ha_t *ha, ips_scb_t *scb) {
-   u32       cpu_flags;
+   unsigned long cpu_flags;
 
    METHOD_TRACE("ips_issue_i2o", 1);
 
@@ -6401,7 +6401,7 @@
 /****************************************************************************/
 static int
 ips_issue_i2o_memio(ips_ha_t *ha, ips_scb_t *scb) {
-   u32       cpu_flags;
+   unsigned long cpu_flags;
 
    METHOD_TRACE("ips_issue_i2o_memio", 1);
 
diff -urN linux-2.4.9-pre4/drivers/scsi/scsi_ioctl.c linux/drivers/scsi/scsi_ioctl.c
--- linux-2.4.9-pre4/drivers/scsi/scsi_ioctl.c	Thu Jul  5 11:28:17 2001
+++ linux/drivers/scsi/scsi_ioctl.c	Mon Dec  3 23:03:38 2001
@@ -34,8 +34,6 @@
 
 #define MAX_BUF PAGE_SIZE
 
-#define max(a,b) (((a) > (b)) ? (a) : (b))
-
 /*
  * If we are told to probe a host, we will return 0 if  the host is not
  * present, 1 if the host is present, and will return an identifying
diff -urN linux-2.4.9-pre4/drivers/scsi/sr_ioctl.c linux/drivers/scsi/sr_ioctl.c
--- linux-2.4.9-pre4/drivers/scsi/sr_ioctl.c	Thu Jul  5 11:28:17 2001
+++ linux/drivers/scsi/sr_ioctl.c	Mon Dec  3 23:03:38 2001
@@ -545,7 +545,7 @@
 
 	switch (cmd) {
 	case BLKGETSIZE:
-		return put_user(scsi_CDs[target].capacity >> 1, (long *) arg);
+		return put_user(scsi_CDs[target].capacity, (long *) arg);
 	case BLKROSET:
 	case BLKROGET:
 	case BLKRASET:
diff -urN linux-2.4.9-pre4/drivers/sound/btaudio.c linux/drivers/sound/btaudio.c
--- linux-2.4.9-pre4/drivers/sound/btaudio.c	Mon Dec  3 23:03:29 2001
+++ linux/drivers/sound/btaudio.c	Mon Dec  3 23:03:38 2001
@@ -32,7 +32,9 @@
 #include <linux/poll.h>
 #include <linux/sound.h>
 #include <linux/soundcard.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
+#include <asm/io.h>
 
 
 /* mmio access */
@@ -850,7 +852,7 @@
 	/* init hw */
         btwrite(0, REG_GPIO_DMA_CTL);
         btwrite(0, REG_INT_MASK);
-        btwrite(~0x0UL, REG_INT_STAT);
+        btwrite(~(u32)0x0, REG_INT_STAT);
 	pci_set_master(pci_dev);
 
 	if ((rc = request_irq(bta->irq, btaudio_irq, SA_SHIRQ|SA_INTERRUPT,
@@ -902,7 +904,7 @@
 	/* turn off all DMA / IRQs */
         btand(~15, REG_GPIO_DMA_CTL);
         btwrite(0, REG_INT_MASK);
-        btwrite(~0x0UL, REG_INT_STAT);
+        btwrite(~(u32)0x0, REG_INT_STAT);
 
 	/* unregister devices */
 	unregister_sound_dsp(bta->dsp_dev);
diff -urN linux-2.4.9-pre4/drivers/sound/dmasound/dmasound.h linux/drivers/sound/dmasound/dmasound.h
--- linux-2.4.9-pre4/drivers/sound/dmasound/dmasound.h	Tue Nov  7 10:59:43 2000
+++ linux/drivers/sound/dmasound/dmasound.h	Mon Dec  3 23:03:38 2001
@@ -47,7 +47,6 @@
 #define MAX_BUFSIZE		128	/* Limit for Amiga in KB */
 
 
-#define min(x, y)	((x) < (y) ? (x) : (y))
 #define le2be16(x)	(((x)<<8 & 0xff00) | ((x)>>8 & 0x00ff))
 #define le2be16dbl(x)	(((x)<<8 & 0xff00ff00) | ((x)>>8 & 0x00ff00ff))
 
diff -urN linux-2.4.9-pre4/drivers/sound/dmasound/dmasound_atari.c linux/drivers/sound/dmasound/dmasound_atari.c
--- linux-2.4.9-pre4/drivers/sound/dmasound/dmasound_atari.c	Mon Nov 27 17:57:34 2000
+++ linux/drivers/sound/dmasound/dmasound_atari.c	Mon Dec  3 23:03:38 2001
@@ -154,7 +154,7 @@
 	ssize_t count, used;
 	u_char *p = &frame[*frameUsed];
 
-	count = min(userCount, frameLeft);
+	count = min(unsigned long, userCount, frameLeft);
 	if (dmasound.soft.stereo)
 		count &= ~1;
 	used = count;
@@ -177,7 +177,7 @@
 	ssize_t count, used;
 	void *p = &frame[*frameUsed];
 
-	count = min(userCount, frameLeft);
+	count = min(unsigned long, userCount, frameLeft);
 	if (dmasound.soft.stereo)
 		count &= ~1;
 	used = count;
@@ -196,7 +196,7 @@
 
 	if (!dmasound.soft.stereo) {
 		u_char *p = &frame[*frameUsed];
-		count = min(userCount, frameLeft);
+		count = min(unsigned long, userCount, frameLeft);
 		used = count;
 		while (count > 0) {
 			u_char data;
@@ -207,7 +207,7 @@
 		}
 	} else {
 		u_short *p = (u_short *)&frame[*frameUsed];
-		count = min(userCount, frameLeft)>>1;
+		count = min(unsigned long, userCount, frameLeft)>>1;
 		used = count*2;
 		while (count > 0) {
 			u_short data;
@@ -230,7 +230,7 @@
 
 	if (!dmasound.soft.stereo) {
 		u_short *p = (u_short *)&frame[*frameUsed];
-		count = min(userCount, frameLeft)>>1;
+		count = min(unsigned long, userCount, frameLeft)>>1;
 		used = count*2;
 		while (count > 0) {
 			u_short data;
@@ -243,7 +243,7 @@
 		*frameUsed += used*2;
 	} else {
 		void *p = (u_short *)&frame[*frameUsed];
-		count = min(userCount, frameLeft) & ~3;
+		count = min(unsigned long, userCount, frameLeft) & ~3;
 		used = count;
 		if (copy_from_user(p, userPtr, count))
 			return -EFAULT;
@@ -261,7 +261,7 @@
 
 	if (!dmasound.soft.stereo) {
 		u_short *p = (u_short *)&frame[*frameUsed];
-		count = min(userCount, frameLeft)>>1;
+		count = min(unsigned long, userCount, frameLeft)>>1;
 		used = count*2;
 		while (count > 0) {
 			u_short data;
@@ -275,7 +275,7 @@
 		*frameUsed += used*2;
 	} else {
 		u_long *p = (u_long *)&frame[*frameUsed];
-		count = min(userCount, frameLeft)>>2;
+		count = min(unsigned long, userCount, frameLeft)>>2;
 		used = count*4;
 		while (count > 0) {
 			u_long data;
@@ -299,7 +299,7 @@
 	count = frameLeft;
 	if (!dmasound.soft.stereo) {
 		u_short *p = (u_short *)&frame[*frameUsed];
-		count = min(userCount, frameLeft)>>1;
+		count = min(unsigned long, userCount, frameLeft)>>1;
 		used = count*2;
 		while (count > 0) {
 			u_short data;
@@ -313,7 +313,7 @@
 		*frameUsed += used*2;
 	} else {
 		u_long *p = (u_long *)&frame[*frameUsed];
-		count = min(userCount, frameLeft)>>2;
+		count = min(unsigned long, userCount, frameLeft)>>2;
 		used = count*4;
 		while (count > 0) {
 			u_long data;
@@ -338,7 +338,7 @@
 	count = frameLeft;
 	if (!dmasound.soft.stereo) {
 		u_short *p = (u_short *)&frame[*frameUsed];
-		count = min(userCount, frameLeft)>>1;
+		count = min(unsigned long, userCount, frameLeft)>>1;
 		used = count*2;
 		while (count > 0) {
 			u_short data;
@@ -351,7 +351,7 @@
 		*frameUsed += used*2;
 	} else {
 		u_long *p = (u_long *)&frame[*frameUsed];
-		count = min(userCount, frameLeft)>>2;
+		count = min(unsigned long, userCount, frameLeft)>>2;
 		used = count;
 		while (count > 0) {
 			u_long data;
diff -urN linux-2.4.9-pre4/drivers/sound/dmasound/dmasound_awacs.c linux/drivers/sound/dmasound/dmasound_awacs.c
--- linux-2.4.9-pre4/drivers/sound/dmasound/dmasound_awacs.c	Fri Feb  9 11:30:23 2001
+++ linux/drivers/sound/dmasound/dmasound_awacs.c	Mon Dec  3 23:03:38 2001
@@ -267,7 +267,7 @@
 	frameLeft >>= 2;
 	if (stereo)
 		userCount >>= 1;
-	used = count = min(userCount, frameLeft);
+	used = count = min(unsigned long, userCount, frameLeft);
 	while (count > 0) {
 		u_char data;
 		if (get_user(data, userPtr++))
@@ -298,7 +298,7 @@
 	frameLeft >>= 2;
 	if (stereo)
 		userCount >>= 1;
-	used = count = min(userCount, frameLeft);
+	used = count = min(unsigned long, userCount, frameLeft);
 	while (count > 0) {
 		u_char data;
 		if (get_user(data, userPtr++))
@@ -329,7 +329,7 @@
 	frameLeft >>= 2;
 	if (stereo)
 		userCount >>= 1;
-	used = count = min(userCount, frameLeft);
+	used = count = min(unsigned long, userCount, frameLeft);
 	while (count > 0) {
 		u_char data;
 		if (get_user(data, userPtr++))
@@ -359,7 +359,7 @@
 
 	frameLeft >>= 2;
 	userCount >>= (stereo? 2: 1);
-	used = count = min(userCount, frameLeft);
+	used = count = min(unsigned long, userCount, frameLeft);
 	if (!stereo) {
 		short *up = (short *) userPtr;
 		while (count > 0) {
@@ -390,7 +390,7 @@
 
 	frameLeft >>= 2;
 	userCount >>= (stereo? 2: 1);
-	used = count = min(userCount, frameLeft);
+	used = count = min(unsigned long, userCount, frameLeft);
 	while (count > 0) {
 		int data;
 		if (get_user(data, up++))
@@ -648,7 +648,7 @@
 	frameLeft >>= 2;
 	if (stereo)
 		userCount >>= 1;
-	used = count = min(userCount, frameLeft);
+	used = count = min(unsigned long, userCount, frameLeft);
 	while (count > 0) {
 		u_char data;
 
@@ -681,7 +681,7 @@
 	frameLeft >>= 2;
 	if (stereo)
 		userCount >>= 1;
-	used = count = min(userCount, frameLeft);
+	used = count = min(unsigned long, userCount, frameLeft);
 	while (count > 0) {
 		u_char data;
 
@@ -713,7 +713,7 @@
 
 	frameLeft >>= 2;
 	userCount >>= (stereo? 2: 1);
-	used = count = min(userCount, frameLeft);
+	used = count = min(unsigned long, userCount, frameLeft);
 	if (!stereo) {
 		short *up = (short *) userPtr;
 		while (count > 0) {
@@ -744,7 +744,7 @@
 
 	frameLeft >>= 2;
 	userCount >>= (stereo? 2: 1);
-	used = count = min(userCount, frameLeft);
+	used = count = min(unsigned long, userCount, frameLeft);
 	while (count > 0) {
 		int data;
 
diff -urN linux-2.4.9-pre4/drivers/sound/dmasound/dmasound_paula.c linux/drivers/sound/dmasound/dmasound_paula.c
--- linux-2.4.9-pre4/drivers/sound/dmasound/dmasound_paula.c	Mon Nov 27 17:57:34 2000
+++ linux/drivers/sound/dmasound/dmasound_paula.c	Mon Dec  3 23:03:38 2001
@@ -155,14 +155,14 @@
 
 	if (!dmasound.soft.stereo) {
 		void *p = &frame[*frameUsed];
-		count = min(userCount, frameLeft) & ~1;
+		count = min(unsigned long, userCount, frameLeft) & ~1;
 		used = count;
 		if (copy_from_user(p, userPtr, count))
 			return -EFAULT;
 	} else {
 		u_char *left = &frame[*frameUsed>>1];
 		u_char *right = left+write_sq_block_size_half;
-		count = min(userCount, frameLeft)>>1 & ~1;
+		count = min(unsigned long, userCount, frameLeft)>>1 & ~1;
 		used = count*2;
 		while (count > 0) {
 			if (get_user(*left++, userPtr++)
@@ -189,7 +189,7 @@
 									\
 	if (!dmasound.soft.stereo) {					\
 		u_char *p = &frame[*frameUsed];				\
-		count = min(userCount, frameLeft) & ~1;			\
+		count = min(unsigned long, userCount, frameLeft) & ~1;	\
 		used = count;						\
 		while (count > 0) {					\
 			u_char data;					\
@@ -201,7 +201,7 @@
 	} else {							\
 		u_char *left = &frame[*frameUsed>>1];			\
 		u_char *right = left+write_sq_block_size_half;		\
-		count = min(userCount, frameLeft)>>1 & ~1;		\
+		count = min(unsigned long, userCount, frameLeft)>>1 & ~1;\
 		used = count*2;						\
 		while (count > 0) {					\
 			u_char data;					\
@@ -242,7 +242,7 @@
 	if (!dmasound.soft.stereo) {					\
 		u_char *high = &frame[*frameUsed>>1];			\
 		u_char *low = high+write_sq_block_size_half;		\
-		count = min(userCount, frameLeft)>>1 & ~1;		\
+		count = min(unsigned long, userCount, frameLeft)>>1 & ~1;\
 		used = count*2;						\
 		while (count > 0) {					\
 			if (get_user(data, ((u_short *)userPtr)++))	\
@@ -257,7 +257,7 @@
 		u_char *leftl = lefth+write_sq_block_size_quarter;	\
 		u_char *righth = lefth+write_sq_block_size_half;	\
 		u_char *rightl = righth+write_sq_block_size_quarter;	\
-		count = min(userCount, frameLeft)>>2 & ~1;		\
+		count = min(unsigned long, userCount, frameLeft)>>2 & ~1;\
 		used = count*4;						\
 		while (count > 0) {					\
 			if (get_user(data, ((u_short *)userPtr)++))	\
diff -urN linux-2.4.9-pre4/drivers/sound/dmasound/dmasound_q40.c linux/drivers/sound/dmasound/dmasound_q40.c
--- linux-2.4.9-pre4/drivers/sound/dmasound/dmasound_q40.c	Fri Feb  9 11:30:23 2001
+++ linux/drivers/sound/dmasound/dmasound_q40.c	Mon Dec  3 23:03:38 2001
@@ -58,7 +58,7 @@
 	ssize_t count, used;
 	u_char *p = (u_char *) &frame[*frameUsed];
 
-	used = count = min(userCount, frameLeft);
+	used = count = min(unsigned long, userCount, frameLeft);
 	if (copy_from_user(p,userPtr,count))
 	  return -EFAULT;
 	while (count > 0) {
@@ -84,7 +84,7 @@
 	frameLeft >>= 1;
 	if (stereo)
 		userCount >>= 1;
-	used = count = min(userCount, frameLeft);
+	used = count = min(unsigned long, userCount, frameLeft);
 	while (count > 0) {
 		u_char data;
 		if (get_user(data, userPtr++))
@@ -112,7 +112,7 @@
 	ssize_t count, used;
 	u_char *p = (u_char *) &frame[*frameUsed];
 
-	used = count = min(userCount, frameLeft);
+	used = count = min(unsigned long, userCount, frameLeft);
 	if (copy_from_user(p,userPtr,count))
 	  return -EFAULT;
 	while (count > 0) {
@@ -136,7 +136,7 @@
 	frameLeft >>= 1;
 	if (stereo)
 		userCount >>= 1;
-	used = count = min(userCount, frameLeft);
+	used = count = min(unsigned long, userCount, frameLeft);
 	while (count > 0) {
 		u_char data;
 		if (get_user(data, userPtr++))
@@ -164,7 +164,7 @@
 	ssize_t count, used;
 	u_char *p = (u_char *) &frame[*frameUsed];
 
-	used = count = min(userCount, frameLeft);
+	used = count = min(unsigned long, userCount, frameLeft);
 	if (copy_from_user(p,userPtr,count))
 	  return -EFAULT;
 	*frameUsed += used;
@@ -184,7 +184,7 @@
 	frameLeft >>= 1;
 	if (stereo)
 		userCount >>= 1;
-	used = count = min(userCount, frameLeft);
+	used = count = min(unsigned long, userCount, frameLeft);
 	while (count > 0) {
 		u_char data;
 		if (get_user(data, userPtr++))
diff -urN linux-2.4.9-pre4/drivers/sound/emu10k1/audio.c linux/drivers/sound/emu10k1/audio.c
--- linux-2.4.9-pre4/drivers/sound/emu10k1/audio.c	Mon Dec  3 23:03:29 2001
+++ linux/drivers/sound/emu10k1/audio.c	Mon Dec  3 23:03:38 2001
@@ -115,7 +115,7 @@
 
 		if ((bytestocopy >= wiinst->buffer.fragment_size)
 		    || (bytestocopy >= count)) {
-			bytestocopy = min(bytestocopy, count);
+			bytestocopy = min(u32, bytestocopy, count);
 
 			emu10k1_wavein_xferdata(wiinst, (u8 *) buffer, &bytestocopy);
 
@@ -215,7 +215,7 @@
 		if ((bytestocopy >= woinst->buffer.fragment_size)
 		    || (bytestocopy >= count)) {
 
-			bytestocopy = min(bytestocopy, count);
+			bytestocopy = min(u32, bytestocopy, count);
 
 			emu10k1_waveout_xferdata(woinst, (u8 *) buffer, &bytestocopy);
 
diff -urN linux-2.4.9-pre4/drivers/sound/emu10k1/cardwi.c linux/drivers/sound/emu10k1/cardwi.c
--- linux-2.4.9-pre4/drivers/sound/emu10k1/cardwi.c	Fri Aug 10 21:02:18 2001
+++ linux/drivers/sound/emu10k1/cardwi.c	Mon Dec  3 23:03:38 2001
@@ -325,7 +325,7 @@
 	u32 sizetocopy, sizetocopy_now, start;
 	unsigned long flags;
 
-	sizetocopy = min(buffer->size, *size);
+	sizetocopy = min(u32, buffer->size, *size);
 	*size = sizetocopy;
 
 	if (!sizetocopy)
diff -urN linux-2.4.9-pre4/drivers/sound/emu10k1/cardwo.c linux/drivers/sound/emu10k1/cardwo.c
--- linux-2.4.9-pre4/drivers/sound/emu10k1/cardwo.c	Fri Aug 10 21:02:18 2001
+++ linux/drivers/sound/emu10k1/cardwo.c	Mon Dec  3 23:03:38 2001
@@ -581,7 +581,7 @@
 	u32 sizetocopy, sizetocopy_now, start;
 	unsigned long flags;
 
-	sizetocopy = min(buffer->size, *size);
+	sizetocopy = min(u32, buffer->size, *size);
 	*size = sizetocopy;
 
 	if (!sizetocopy)
diff -urN linux-2.4.9-pre4/drivers/sound/emu10k1/hwaccess.h linux/drivers/sound/emu10k1/hwaccess.h
--- linux-2.4.9-pre4/drivers/sound/emu10k1/hwaccess.h	Fri Aug 10 21:02:18 2001
+++ linux/drivers/sound/emu10k1/hwaccess.h	Mon Dec  3 23:03:38 2001
@@ -53,8 +53,6 @@
 #define FLAGS_AVAILABLE     0x0001
 #define FLAGS_READY         0x0002
 
-#define min(x,y) ((x) < (y)) ? (x) : (y)
-
 struct memhandle
 {
 	dma_addr_t dma_handle;
diff -urN linux-2.4.9-pre4/drivers/telephony/ixj.c linux/drivers/telephony/ixj.c
--- linux-2.4.9-pre4/drivers/telephony/ixj.c	Wed Jun 27 17:10:55 2001
+++ linux/drivers/telephony/ixj.c	Mon Dec  3 23:03:38 2001
@@ -1844,14 +1844,15 @@
 	remove_wait_queue(&j->read_q, &wait);
 	set_current_state(TASK_RUNNING);
 	/* Don't ever copy more than the user asks */
-	i = copy_to_user(buf, j->read_buffer, min(length, j->read_buffer_size));
+	i = copy_to_user(buf, j->read_buffer,
+			 min(unsigned int, length, j->read_buffer_size));
 	j->read_buffer_ready = 0;
 	if (i) {
 		j->flags.inread = 0;
 		return -EFAULT;
 	} else {
 		j->flags.inread = 0;
-		return min(length, j->read_buffer_size);
+		return min(unsigned int, length, j->read_buffer_size);
 	}
 }
 
@@ -1934,13 +1935,14 @@
 	remove_wait_queue(&j->write_q, &wait);
 	if (j->write_buffer_wp + count >= j->write_buffer_end)
 		j->write_buffer_wp = j->write_buffer;
-	i = copy_from_user(j->write_buffer_wp, buf, min(count, j->write_buffer_size));
+	i = copy_from_user(j->write_buffer_wp, buf,
+			   min(unsigned int, count, j->write_buffer_size));
 	if (i) {
 		j->flags.inwrite = 0;
 		return -EFAULT;
 	}
 	j->flags.inwrite = 0;
-	return min(count, j->write_buffer_size);
+	return min(unsigned int, count, j->write_buffer_size);
 }
 
 ssize_t ixj_enhanced_write(struct file * file_p, const char *buf, size_t count, loff_t * ppos)
diff -urN linux-2.4.9-pre4/drivers/telephony/ixj.h linux/drivers/telephony/ixj.h
--- linux-2.4.9-pre4/drivers/telephony/ixj.h	Sun Feb  4 10:05:29 2001
+++ linux/drivers/telephony/ixj.h	Mon Dec  3 23:03:38 2001
@@ -54,13 +54,6 @@
 #define TRUE 1
 #define FALSE 0
 
-#ifndef min
-#define min(a,b) (((a)<(b))?(a):(b))
-#endif
-#ifndef max
-#define max(a,b) (((a)>(b))?(a):(b))
-#endif
-
 /******************************************************************************
 *
 *  This structure when unioned with the structures below makes simple byte
diff -urN linux-2.4.9-pre4/drivers/usb/devio.c linux/drivers/usb/devio.c
--- linux-2.4.9-pre4/drivers/usb/devio.c	Thu Jul 12 14:22:29 2001
+++ linux/drivers/usb/devio.c	Mon Dec  3 23:03:38 2001
@@ -1082,7 +1082,7 @@
 		if (retval == 0)
 			/* ifno might usefully be passed ... */
 			retval = ifp->driver->ioctl (ps->dev, ctrl.ioctl_code, buf);
-			/* size = min (size, retval)? */
+			/* size = min(int, size, retval)? */
 	}
 
 	/* cleanup and return */
diff -urN linux-2.4.9-pre4/drivers/usb/serial/io_usbvend.h linux/drivers/usb/serial/io_usbvend.h
--- linux-2.4.9-pre4/drivers/usb/serial/io_usbvend.h	Mon Mar 19 17:21:54 2001
+++ linux/drivers/usb/serial/io_usbvend.h	Mon Dec  3 23:03:38 2001
@@ -115,7 +115,7 @@
 
 // TxCredits value below which driver won't bother sending (to prevent too many small writes).
 // Send only if above 25%
-#define EDGE_FW_GET_TX_CREDITS_SEND_THRESHOLD(InitialCredit)	(max( ((InitialCredit) / 4), EDGE_FW_BULK_MAX_PACKET_SIZE ))
+#define EDGE_FW_GET_TX_CREDITS_SEND_THRESHOLD(InitialCredit)	(max(int, ((InitialCredit) / 4), EDGE_FW_BULK_MAX_PACKET_SIZE))
 
 #define	EDGE_FW_BULK_MAX_PACKET_SIZE		64	// Max Packet Size for Bulk In Endpoint (EP1)
 #define EDGE_FW_BULK_READ_BUFFER_SIZE		1024	// Size to use for Bulk reads
diff -urN linux-2.4.9-pre4/drivers/usb/storage/datafab.c linux/drivers/usb/storage/datafab.c
--- linux-2.4.9-pre4/drivers/usb/storage/datafab.c	Sun Jul 29 21:11:50 2001
+++ linux/drivers/usb/storage/datafab.c	Mon Dec  3 23:03:38 2001
@@ -204,7 +204,7 @@
 
 	do {
 		// loop, never allocate or transfer more than 64k at once (min(128k, 255*info->ssize) is the real limit)
-		len = min(totallen, 65536);
+		len = min(int, totallen, 65536);
 
 		if (use_sg) {
 			sg = (struct scatterlist *) dest;
@@ -329,7 +329,7 @@
 
 	do {
 		// loop, never allocate or transfer more than 64k at once (min(128k, 255*info->ssize) is the real limit)
-		len = min(totallen, 65536);
+		len = min(int, totallen, 65536);
 
 		if (use_sg) {
 			sg = (struct scatterlist *) src;
diff -urN linux-2.4.9-pre4/drivers/usb/storage/datafab.h linux/drivers/usb/storage/datafab.h
--- linux-2.4.9-pre4/drivers/usb/storage/datafab.h	Sun Jul 29 21:11:50 2001
+++ linux/drivers/usb/storage/datafab.h	Mon Dec  3 23:03:38 2001
@@ -24,8 +24,6 @@
 #ifndef _USB_DATAFAB_MDCFE_B_H
 #define _USB_DATAFAB_MDCFE_B_H
 
-#define min(a,b) (((a)<(b))?(a):(b))  // this is defined in tons of header files, i wish it had a standard single definition...
-
 extern int datafab_transport(Scsi_Cmnd *srb, struct us_data *us);
 
 struct datafab_info {
diff -urN linux-2.4.9-pre4/drivers/usb/storage/jumpshot.c linux/drivers/usb/storage/jumpshot.c
--- linux-2.4.9-pre4/drivers/usb/storage/jumpshot.c	Sun Jul 29 21:11:50 2001
+++ linux/drivers/usb/storage/jumpshot.c	Mon Dec  3 23:03:38 2001
@@ -280,7 +280,7 @@
 
 	do {
                // loop, never allocate or transfer more than 64k at once (min(128k, 255*info->ssize) is the real limit)
-                len = min(totallen, 65536);
+                len = min(int, totallen, 65536);
 
                 if (use_sg) {
                         sg = (struct scatterlist *) dest;
@@ -395,7 +395,7 @@
 
 	do {
                 // loop, never allocate or transfer more than 64k at once (min(128k, 255*info->ssize) is the real limit)
-                len = min(totallen, 65536);
+                len = min(int, totallen, 65536);
 
                 if (use_sg) {
                         sg = (struct scatterlist *) src;
diff -urN linux-2.4.9-pre4/drivers/usb/storage/jumpshot.h linux/drivers/usb/storage/jumpshot.h
--- linux-2.4.9-pre4/drivers/usb/storage/jumpshot.h	Sun Jul 29 21:11:50 2001
+++ linux/drivers/usb/storage/jumpshot.h	Mon Dec  3 23:03:38 2001
@@ -24,8 +24,6 @@
 #ifndef _USB_JUMPSHOT_H
 #define _USB_JUMPSHOT_H
 
-#define min(a,b) (((a)<(b))?(a):(b))  // this is defined in tons of header files, i wish it had a standar single definition...
-
 extern int jumpshot_transport(Scsi_Cmnd *srb, struct us_data *us);
 
 struct jumpshot_info {
diff -urN linux-2.4.9-pre4/drivers/usb/uhci.c linux/drivers/usb/uhci.c
--- linux-2.4.9-pre4/drivers/usb/uhci.c	Wed Jul  4 15:43:05 2001
+++ linux/drivers/usb/uhci.c	Mon Dec  3 23:03:38 2001
@@ -98,8 +98,6 @@
 static void suspend_hc(struct uhci *uhci);
 static void wakeup_hc(struct uhci *uhci);
 
-#define min(a,b) (((a)<(b))?(a):(b))
-
 /* If a transfer is still active after this much time, turn off FSBR */
 #define IDLE_TIMEOUT	(HZ / 20)	/* 50 ms */
 
@@ -2133,11 +2131,15 @@
 	case RH_GET_DESCRIPTOR:
 		switch ((wValue & 0xff00) >> 8) {
 		case 0x01:	/* device descriptor */
-			len = min(leni, min(sizeof(root_hub_dev_des), wLength));
+			len = min(unsigned int, leni,
+				  min(unsigned int,
+				      sizeof(root_hub_dev_des), wLength));
 			memcpy(data, root_hub_dev_des, len);
 			OK(len);
 		case 0x02:	/* configuration descriptor */
-			len = min(leni, min(sizeof(root_hub_config_des), wLength));
+			len = min(unsigned int, leni,
+				  min(unsigned int,
+				      sizeof(root_hub_config_des), wLength));
 			memcpy (data, root_hub_config_des, len);
 			OK(len);
 		case 0x03:	/* string descriptors */
@@ -2145,14 +2147,15 @@
 				uhci->io_addr, "UHCI-alt",
 				data, wLength);
 			if (len > 0) {
-				OK (min (leni, len));
+				OK(min(int, leni, len));
 			} else 
 				stat = -EPIPE;
 		}
 		break;
 	case RH_GET_DESCRIPTOR | RH_CLASS:
 		root_hub_hub_des[2] = uhci->rh.numports;
-		len = min(leni, min(sizeof(root_hub_hub_des), wLength));
+		len = min(unsigned int, leni,
+			  min(unsigned int, sizeof(root_hub_hub_des), wLength));
 		memcpy(data, root_hub_hub_des, len);
 		OK(len);
 	case RH_GET_CONFIGURATION:
diff -urN linux-2.4.9-pre4/drivers/usb/usb-ohci.c linux/drivers/usb/usb-ohci.c
--- linux-2.4.9-pre4/drivers/usb/usb-ohci.c	Tue Jul 24 14:20:56 2001
+++ linux/drivers/usb/usb-ohci.c	Mon Dec  3 23:03:38 2001
@@ -1805,7 +1805,9 @@
 	len = i/8 + 1;
   
 	if (ret > 0) { 
-		memcpy (rh_data, data, min (len, min (rh_len, sizeof(data))));
+		memcpy(rh_data, data,
+		       min(unsigned int, len,
+			   min(unsigned int, rh_len, sizeof(data))));
 		return len;
 	}
 	return 0;
@@ -1987,10 +1989,18 @@
 		case RH_GET_DESCRIPTOR:
 			switch ((wValue & 0xff00) >> 8) {
 				case (0x01): /* device descriptor */
-					len = min (leni, min (sizeof (root_hub_dev_des), wLength));
+					len = min(unsigned int,
+						  leni,
+						  min(unsigned int,
+						      sizeof (root_hub_dev_des),
+						      wLength));
 					data_buf = root_hub_dev_des; OK(len);
 				case (0x02): /* configuration descriptor */
-					len = min (leni, min (sizeof (root_hub_config_des), wLength));
+					len = min(unsigned int,
+						  leni,
+						  min(unsigned int,
+						      sizeof (root_hub_config_des),
+						      wLength));
 					data_buf = root_hub_config_des; OK(len);
 				case (0x03): /* string descriptors */
 					len = usb_root_hub_string (wValue & 0xff,
@@ -1998,7 +2008,7 @@
 						data, wLength);
 					if (len > 0) {
 						data_buf = data;
-						OK (min (leni, len));
+						OK(min(int, leni, len));
 					}
 					// else fallthrough
 				default: 
@@ -2033,7 +2043,8 @@
 				data_buf [10] = data_buf [9] = 0xff;
 			    }
 				
-			    len = min (leni, min (data_buf [0], wLength));
+			    len = min(unsigned int, leni,
+				      min(unsigned int, data_buf [0], wLength));
 			    OK (len);
 			}
  
@@ -2050,7 +2061,7 @@
 	// ohci_dump_roothub (ohci, 0);
 #endif
 
-	len = min(len, leni);
+	len = min(int, len, leni);
 	if (data != data_buf)
 	    memcpy (data, data_buf, len);
   	urb->actual_length = len;
diff -urN linux-2.4.9-pre4/drivers/usb/usb-ohci.h linux/drivers/usb/usb-ohci.h
--- linux-2.4.9-pre4/drivers/usb/usb-ohci.h	Tue Jul 24 14:20:56 2001
+++ linux/drivers/usb/usb-ohci.h	Mon Dec  3 23:03:38 2001
@@ -329,9 +329,6 @@
 #define	RH_A_NOCP	(1 << 12)		/* no over current protection */
 #define	RH_A_POTPGT	(0xff << 24)		/* power on to power good time */
 
-#define min(a,b) (((a)<(b))?(a):(b))  
- 
-
 /* urb */
 typedef struct 
 {
diff -urN linux-2.4.9-pre4/drivers/usb/usb-uhci.c linux/drivers/usb/usb-uhci.c
--- linux-2.4.9-pre4/drivers/usb/usb-uhci.c	Wed Jun 27 13:15:17 2001
+++ linux/drivers/usb/usb-uhci.c	Mon Dec  3 23:03:38 2001
@@ -2159,11 +2159,15 @@
 	case RH_GET_DESCRIPTOR:
 		switch ((wValue & 0xff00) >> 8) {
 		case (0x01):	/* device descriptor */
-			len = min (leni, min (sizeof (root_hub_dev_des), wLength));
+			len = min(unsigned int, leni,
+				  min(unsigned int,
+				      sizeof (root_hub_dev_des), wLength));
 			memcpy (data, root_hub_dev_des, len);
 			OK (len);
 		case (0x02):	/* configuration descriptor */
-			len = min (leni, min (sizeof (root_hub_config_des), wLength));
+			len = min(unsigned int, leni,
+				  min(unsigned int,
+				      sizeof (root_hub_config_des), wLength));
 			memcpy (data, root_hub_config_des, len);
 			OK (len);
 		case (0x03):	/* string descriptors */
@@ -2171,7 +2175,7 @@
 			        uhci->io_addr, "UHCI",
 				data, wLength);
 			if (len > 0) {
-				OK (min (leni, len));
+				OK(min(int, leni, len));
 			} else 
 				stat = -EPIPE;
 		}
@@ -2179,7 +2183,8 @@
 
 	case RH_GET_DESCRIPTOR | RH_CLASS:
 		root_hub_hub_des[2] = uhci->rh.numports;
-		len = min (leni, min (sizeof (root_hub_hub_des), wLength));
+		len = min(unsigned int, leni,
+			  min(unsigned int, sizeof (root_hub_hub_des), wLength));
 		memcpy (data, root_hub_hub_des, len);
 		OK (len);
 
diff -urN linux-2.4.9-pre4/drivers/usb/usb-uhci.h linux/drivers/usb/usb-uhci.h
--- linux-2.4.9-pre4/drivers/usb/usb-uhci.h	Wed May 16 10:31:27 2001
+++ linux/drivers/usb/usb-uhci.h	Mon Dec  3 23:03:38 2001
@@ -282,6 +282,4 @@
 #define RH_REQ_ERR                 -1
 #define RH_NACK                    0x00
 
-#define min(a,b) (((a)<(b))?(a):(b))
-
 #endif
diff -urN linux-2.4.9-pre4/drivers/video/amifb.c linux/drivers/video/amifb.c
--- linux-2.4.9-pre4/drivers/video/amifb.c	Wed Apr 18 11:49:12 2001
+++ linux/drivers/video/amifb.c	Mon Dec  3 23:03:38 2001
@@ -592,9 +592,6 @@
 	((((long)((unsigned long long)x1 >> 8) % x2) << 8) / x2))
 #endif
 
-#define min(a, b)	((a) < (b) ? (a) : (b))
-#define max(a, b)	((a) > (b) ? (a) : (b))
-
 #define highw(x)	((u_long)(x)>>16 & 0xffff)
 #define loww(x)		((u_long)(x) & 0xffff)
 
diff -urN linux-2.4.9-pre4/drivers/video/cyberfb.h linux/drivers/video/cyberfb.h
--- linux-2.4.9-pre4/drivers/video/cyberfb.h	Mon Aug  9 11:39:38 1999
+++ linux/drivers/video/cyberfb.h	Mon Dec  3 23:03:38 2001
@@ -100,14 +100,6 @@
 
 /**************************************************/
 
-#ifndef min
-#define min(a,b)	((a) < (b) ? (a) : (b))
-#endif /* !min */
-
-#ifndef max
-#define max(a,b)	((a) > (b) ? (a) : (b))
-#endif /* !max */
-
 /* support for a BitBlt operation. The op-codes are identical
    to X11 GCs */
 #define	GRFBBOPclear		0x0	/* 0 */
diff -urN linux-2.4.9-pre4/fs/buffer.c linux/fs/buffer.c
--- linux-2.4.9-pre4/fs/buffer.c	Mon Dec  3 23:03:29 2001
+++ linux/fs/buffer.c	Mon Dec  3 23:03:38 2001
@@ -794,6 +794,17 @@
 		goto retry;
 }
 
+static void free_more_memory(void)
+{
+	balance_dirty(NODEV);
+	page_launder(GFP_NOFS, 0);		
+	wakeup_bdflush();
+	wakeup_kswapd();
+	current->policy |= SCHED_YIELD;
+	__set_current_state(TASK_RUNNING);
+	schedule();
+}
+
 /*
  * We used to try various strange things. Let's not.
  * We'll just try to balance dirty buffers, and possibly
@@ -802,15 +813,8 @@
  */
 static void refill_freelist(int size)
 {
-	if (!grow_buffers(size)) {
-		balance_dirty(NODEV);
-		page_launder(GFP_NOFS, 0);		
-		wakeup_bdflush();
-		wakeup_kswapd();
-		current->policy |= SCHED_YIELD;
-		__set_current_state(TASK_RUNNING);
-		schedule();
-	}
+	if (!grow_buffers(size))
+		free_more_memory();
 }
 
 void init_buffer(struct buffer_head *bh, bh_end_io_t *handler, void *private)
@@ -1408,9 +1412,7 @@
 	 */
 	run_task_queue(&tq_disk);
 
-	current->policy |= SCHED_YIELD;
-	__set_current_state(TASK_RUNNING);
-	schedule();
+	free_more_memory();
 	goto try_again;
 }
 
diff -urN linux-2.4.9-pre4/fs/coda/upcall.c linux/fs/coda/upcall.c
--- linux-2.4.9-pre4/fs/coda/upcall.c	Wed Apr 25 16:18:54 2001
+++ linux/fs/coda/upcall.c	Mon Dec  3 23:03:38 2001
@@ -69,17 +69,9 @@
         outsize = insize; \
 } while (0)
 
-static inline int max(int a, int b) 
-{
-	if ( a > b )
-		return a; 
-	else
-		return b;
-}
-
 #define INSIZE(tag) sizeof(struct coda_ ## tag ## _in)
 #define OUTSIZE(tag) sizeof(struct coda_ ## tag ## _out)
-#define SIZE(tag)  max(INSIZE(tag), OUTSIZE(tag))
+#define SIZE(tag)  max(unsigned int, INSIZE(tag), OUTSIZE(tag))
 
 
 /* the upcalls */
@@ -159,7 +151,7 @@
 	int offset;
 
 	offset = INSIZE(lookup);
-        insize = max(offset + length +1, OUTSIZE(lookup));
+        insize = max(unsigned int, offset + length +1, OUTSIZE(lookup));
 	UPARG(CODA_LOOKUP);
 
         inp->coda_lookup.VFid = *fid;
@@ -275,7 +267,7 @@
         int offset;
 
 	offset = INSIZE(mkdir);
-	insize = max(offset + length + 1, OUTSIZE(mkdir));
+	insize = max(unsigned int, offset + length + 1, OUTSIZE(mkdir));
 	UPARG(CODA_MKDIR);
 
         inp->coda_mkdir.VFid = *dirfid;
@@ -306,7 +298,7 @@
 	int offset, s;
 	
 	offset = INSIZE(rename);
-	insize = max(offset + new_length + old_length + 8,
+	insize = max(unsigned int, offset + new_length + old_length + 8,
 		     OUTSIZE(rename)); 
  	UPARG(CODA_RENAME);
 
@@ -344,7 +336,7 @@
         int offset;
 
         offset = INSIZE(create);
-	insize = max(offset + length + 1, OUTSIZE(create));
+	insize = max(unsigned int, offset + length + 1, OUTSIZE(create));
 	UPARG(CODA_CREATE);
 
         inp->coda_create.VFid = *dirfid;
@@ -376,7 +368,7 @@
         int offset;
 
         offset = INSIZE(rmdir);
-	insize = max(offset + length + 1, OUTSIZE(rmdir));
+	insize = max(unsigned int, offset + length + 1, OUTSIZE(rmdir));
 	UPARG(CODA_RMDIR);
 
         inp->coda_rmdir.VFid = *dirfid;
@@ -398,7 +390,7 @@
         int error=0, insize, outsize, offset;
 
         offset = INSIZE(remove);
-	insize = max(offset + length + 1, OUTSIZE(remove));
+	insize = max(unsigned int, offset + length + 1, OUTSIZE(remove));
 	UPARG(CODA_REMOVE);
 
         inp->coda_remove.VFid = *dirfid;
@@ -421,7 +413,8 @@
         int retlen;
         char *result;
         
-	insize = max(INSIZE(readlink), OUTSIZE(readlink)+ *length + 1);
+	insize = max(unsigned int,
+		     INSIZE(readlink), OUTSIZE(readlink)+ *length + 1);
 	UPARG(CODA_READLINK);
 
         inp->coda_readlink.VFid = *fid;
@@ -455,7 +448,7 @@
         int offset;
 
 	offset = INSIZE(link);
-	insize = max(offset  + len + 1, OUTSIZE(link));
+	insize = max(unsigned int, offset  + len + 1, OUTSIZE(link));
         UPARG(CODA_LINK);
 
         inp->coda_link.sourceFid = *fid;
@@ -484,7 +477,7 @@
         int offset, s;
 
         offset = INSIZE(symlink);
-	insize = max(offset + len + symlen + 8, OUTSIZE(symlink));
+	insize = max(unsigned int, offset + len + symlen + 8, OUTSIZE(symlink));
 	UPARG(CODA_SYMLINK);
         
         /*        inp->coda_symlink.attr = *tva; XXXXXX */ 
@@ -624,7 +617,7 @@
         union outputArgs *outp;
         int insize, outsize, error;
         
-	insize = max(INSIZE(statfs), OUTSIZE(statfs));
+	insize = max(unsigned int, INSIZE(statfs), OUTSIZE(statfs));
 	UPARG(CODA_STATFS);
 
         error = coda_upcall(coda_sbp(sb), insize, &outsize, inp);
diff -urN linux-2.4.9-pre4/fs/fat/cache.c linux/fs/fat/cache.c
--- linux-2.4.9-pre4/fs/fat/cache.c	Mon Dec  3 23:03:29 2001
+++ linux/fs/fat/cache.c	Thu May 24 15:36:33 2001
@@ -15,6 +15,8 @@
 #include <linux/stat.h>
 #include <linux/fat_cvf.h>
 
+#include "msbuffer.h"
+
 #if 0
 #  define PRINTK(x) printk x
 #else
diff -urN linux-2.4.9-pre4/fs/fat/dir.c linux/fs/fat/dir.c
--- linux-2.4.9-pre4/fs/fat/dir.c	Wed Apr 18 11:49:12 2001
+++ linux/fs/fat/dir.c	Mon Dec  3 23:03:38 2001
@@ -590,7 +590,7 @@
 	void * buf,
 	const char * name,
 	int name_len,
-	off_t offset,
+	loff_t offset,
 	ino_t ino,
 	unsigned int d_type)
 {
diff -urN linux-2.4.9-pre4/fs/jffs/inode-v23.c linux/fs/jffs/inode-v23.c
--- linux-2.4.9-pre4/fs/jffs/inode-v23.c	Mon Dec  3 23:03:29 2001
+++ linux/fs/jffs/inode-v23.c	Mon Dec  3 23:03:38 2001
@@ -718,7 +718,7 @@
 
 	offset = page->index << PAGE_CACHE_SHIFT;
 	if (offset < inode->i_size) {
-		read_len = jffs_min(inode->i_size - offset, PAGE_SIZE);
+		read_len = min(long, inode->i_size - offset, PAGE_SIZE);
 		r = jffs_read_data(f, buf, offset, read_len);
 		if (r == read_len) {
 			if (read_len < PAGE_SIZE) {
@@ -1373,7 +1373,9 @@
 		goto out_isem;
 	}
 	
-	thiscount = jffs_min(c->fmc->max_chunk_size - sizeof(struct jffs_raw_inode), count);
+	thiscount = min(unsigned int,
+			c->fmc->max_chunk_size - sizeof(struct jffs_raw_inode),
+			count);
 
 	if (!(vbuf = kmalloc(thiscount, GFP_KERNEL))) {
 		D(printk("jffs_file_write(): failed to allocate bounce buffer. Fix me to use page cache\n"));
@@ -1437,7 +1439,8 @@
 		raw_inode.deleted = 0;
 		
 		if (pos < f->size) {
-			node->removed_size = raw_inode.rsize = jffs_min(thiscount, f->size - pos);
+			node->removed_size = raw_inode.rsize =
+				min(unsigned int, thiscount, f->size - pos);
 			
 			/* If this node is going entirely over the top of old data, 
 			   we can allow it to go into the reserved space, because 
@@ -1479,7 +1482,9 @@
 
 		D3(printk("jffs_file_write(): new f_pos %ld.\n", (long)pos));
 
-		thiscount = jffs_min(c->fmc->max_chunk_size - sizeof(struct jffs_raw_inode), count);
+		thiscount = min(unsigned int,
+			c->fmc->max_chunk_size - sizeof(struct jffs_raw_inode),
+			count);
 	}
  out:
 	D3(printk (KERN_NOTICE "file_write(): up biglock\n"));
diff -urN linux-2.4.9-pre4/fs/jffs/intrep.c linux/fs/jffs/intrep.c
--- linux-2.4.9-pre4/fs/jffs/intrep.c	Mon Dec  3 23:03:29 2001
+++ linux/fs/jffs/intrep.c	Mon Dec  3 23:03:38 2001
@@ -292,21 +292,6 @@
 	return 0;
 }
 
-
-inline int
-jffs_min(int a, int b)
-{
-	return (a < b ? a : b);
-}
-
-
-inline int
-jffs_max(int a, int b)
-{
-	return (a > b ? a : b);
-}
-
-
 /* This routine calculates checksums in JFFS.  */
 __u32
 jffs_checksum(const void *data, int size)
@@ -1624,7 +1609,7 @@
 		  "version: %u, node_offset: %u\n",
 		  f->name, node->ino, node->version, node_offset));
 
-	r = jffs_min(avail, max_size);
+	r = min(u32, avail, max_size);
 	D3(printk(KERN_NOTICE "jffs_get_node_data\n"));
 	flash_safe_read(fmc->mtd, pos, buf, r);
 
@@ -1677,8 +1662,8 @@
 		int r;
 		if (!node->fm) {
 			/* This node does not refer to real data.  */
-			r = jffs_min(size - read_data,
-				     node->data_size - node_offset);
+			r = min(u32, size - read_data,
+				node->data_size - node_offset);
 			memset(&buf[read_data], 0, r);
 		}
 		else if ((r = jffs_get_node_data(f, node, &buf[read_data],
@@ -1919,8 +1904,8 @@
 		else {
 			/* No.  No need to split the node.  Just remove
 			   the end of the node.  */
-			int r = jffs_min(n->data_offset + n->data_size
-					 - offset, remove_size);
+			int r = min(u32, n->data_offset + n->data_size
+				    - offset, remove_size);
 			n->data_size -= r;
 			remove_size -= r;
 			n = n->range_next;
@@ -2475,7 +2460,7 @@
 		}
 
 		while (size) {
-			__u32 s = jffs_min(size, PAGE_SIZE);
+			__u32 s = min(int, size, PAGE_SIZE);
 			if ((r = jffs_read_data(f, (char *)page,
 						offset, s)) < s) {
 				free_page((unsigned long)page);
@@ -2836,7 +2821,7 @@
 				printk("JFFS: Erase failed! pos = 0x%lx\n",
 				       (long)pos);
 				jffs_hexdump(fmc->mtd, pos,
-					     jffs_min(256, end - pos));
+					     min(u32, 256, end - pos));
 				err = -1;
 				break;
 			}
diff -urN linux-2.4.9-pre4/fs/jffs/intrep.h linux/fs/jffs/intrep.h
--- linux-2.4.9-pre4/fs/jffs/intrep.h	Mon Dec 11 13:26:54 2000
+++ linux/fs/jffs/intrep.h	Mon Dec  3 23:03:38 2001
@@ -17,8 +17,6 @@
 #ifndef __LINUX_JFFS_INTREP_H__
 #define __LINUX_JFFS_INTREP_H__
 #include "jffs_fm.h"
-inline int jffs_min(int a, int b);
-inline int jffs_max(int a, int b);
 __u32 jffs_checksum(const void *data, int size);
 
 void jffs_cleanup_control(struct jffs_control *c);
diff -urN linux-2.4.9-pre4/fs/ncpfs/file.c linux/fs/ncpfs/file.c
--- linux-2.4.9-pre4/fs/ncpfs/file.c	Mon Dec  3 23:03:29 2001
+++ linux/fs/ncpfs/file.c	Mon Dec  3 23:03:38 2001
@@ -22,11 +22,6 @@
 #include <linux/ncp_fs.h>
 #include "ncplib_kernel.h"
 
-static inline unsigned int min(unsigned int a, unsigned int b)
-{
-	return a < b ? a : b;
-}
-
 static int ncp_fsync(struct file *file, struct dentry *dentry, int datasync)
 {
 	return 0;
@@ -157,8 +152,9 @@
 	/* First read in as much as possible for each bufsize. */
 	while (already_read < count) {
 		int read_this_time;
-		size_t to_read = min(bufsize - (pos % bufsize),
-				  count - already_read);
+		size_t to_read = min(unsigned int,
+				     bufsize - (pos % bufsize),
+				     count - already_read);
 
 		error = ncp_read_bounce(NCP_SERVER(inode),
 			 	NCP_FINFO(inode)->file_handle,
@@ -238,8 +234,9 @@
 	}
 	while (already_written < count) {
 		int written_this_time;
-		size_t to_write = min(bufsize - (pos % bufsize),
-				   count - already_written);
+		size_t to_write = min(unsigned int,
+				      bufsize - (pos % bufsize),
+				      count - already_written);
 
 		if (copy_from_user(bouncebuffer, buf, to_write)) {
 			errno = -EFAULT;
diff -urN linux-2.4.9-pre4/fs/ncpfs/mmap.c linux/fs/ncpfs/mmap.c
--- linux-2.4.9-pre4/fs/ncpfs/mmap.c	Fri Mar  2 15:15:12 2001
+++ linux/fs/ncpfs/mmap.c	Mon Dec  3 23:03:38 2001
@@ -22,11 +22,6 @@
 #include <asm/uaccess.h>
 #include <asm/system.h>
 
-static inline int min(int a, int b)
-{
-	return a < b ? a : b;
-}
-
 /*
  * Fill in the supplied page for mmap
  */
@@ -66,7 +61,7 @@
 
 			to_read = bufsize - (pos % bufsize);
 
-			to_read = min(to_read, count - already_read);
+			to_read = min(unsigned int, to_read, count - already_read);
 
 			if (ncp_read_kernel(NCP_SERVER(inode),
 				     NCP_FINFO(inode)->file_handle,
diff -urN linux-2.4.9-pre4/fs/ncpfs/ncplib_kernel.c linux/fs/ncpfs/ncplib_kernel.c
--- linux-2.4.9-pre4/fs/ncpfs/ncplib_kernel.c	Tue Nov 14 13:16:33 2000
+++ linux/fs/ncpfs/ncplib_kernel.c	Mon Dec  3 23:03:38 2001
@@ -13,11 +13,6 @@
 
 #include "ncplib_kernel.h"
 
-static inline int min(int a, int b)
-{
-	return a < b ? a : b;
-}
-
 static inline void assert_server_locked(struct ncp_server *server)
 {
 	if (server->lock == 0) {
@@ -132,7 +127,7 @@
 		ncp_unlock_server(server);
 		return result;
 	}
-	*target = min(ntohs(ncp_reply_word(server, 0)), size);
+	*target = min(unsigned int, ntohs(ncp_reply_word(server, 0)), size);
 
 	ncp_unlock_server(server);
 	return 0;
@@ -163,7 +158,8 @@
 
 	/* NCP over UDP returns 0 (!!!) */
 	result = ntohs(ncp_reply_word(server, 0));
-	if (result >= NCP_BLOCK_SIZE) size=min(result, size);
+	if (result >= NCP_BLOCK_SIZE)
+		size = min(int, result, size);
 	*ret_size = size;
 	*ret_options = ncp_reply_byte(server, 4);
 
diff -urN linux-2.4.9-pre4/fs/ncpfs/ncpsign_kernel.c linux/fs/ncpfs/ncpsign_kernel.c
--- linux-2.4.9-pre4/fs/ncpfs/ncpsign_kernel.c	Mon Mar 30 16:40:37 1998
+++ linux/fs/ncpfs/ncpsign_kernel.c	Mon Dec  3 23:03:38 2001
@@ -52,8 +52,6 @@
 #define PUT_LE32(p,v) DSET_LH(p,0,v)
 #endif
 
-#define min(a,b) ((a)<(b)?(a):(b))
-
 static void nwsign(char *r_data1, char *r_data2, char *outdata) {
  int i;
  unsigned int w0,w1,w2,w3;
@@ -102,7 +100,7 @@
  memcpy(data,server->sign_root,8);
  PUT_LE32(data+8,(*size));
  memcpy(data+12,server->packet+sizeof(struct ncp_request_header)-1,
-  min((*size)-sizeof(struct ncp_request_header)+1,52));
+  min(unsigned int,(*size)-sizeof(struct ncp_request_header)+1,52));
 
  nwsign(server->sign_last,data,server->sign_last);
 
diff -urN linux-2.4.9-pre4/fs/nfs/file.c linux/fs/nfs/file.c
--- linux-2.4.9-pre4/fs/nfs/file.c	Mon Dec  3 23:03:29 2001
+++ linux/fs/nfs/file.c	Mon Dec  3 23:03:38 2001
@@ -39,7 +39,6 @@
 static ssize_t nfs_file_write(struct file *, const char *, size_t, loff_t *);
 static int  nfs_file_flush(struct file *);
 static int  nfs_fsync(struct file *, struct dentry *dentry, int datasync);
-static int  nfs_file_release(struct inode *, struct file *);
 
 struct file_operations nfs_file_operations = {
 	llseek:		generic_file_llseek,
@@ -48,7 +47,7 @@
 	mmap:		nfs_file_mmap,
 	open:		nfs_open,
 	flush:		nfs_file_flush,
-	release:	nfs_file_release,
+	release:	nfs_release,
 	fsync:		nfs_fsync,
 	lock:		nfs_lock,
 };
@@ -87,13 +86,6 @@
 		file->f_error = 0;
 	}
 	return status;
-}
-
-static int
-nfs_file_release(struct inode *inode, struct file *file)
-{
-	filemap_fdatasync(inode->i_mapping);
-	return nfs_release(inode,file);
 }
 
 static ssize_t
diff -urN linux-2.4.9-pre4/fs/nfs/inode.c linux/fs/nfs/inode.c
--- linux-2.4.9-pre4/fs/nfs/inode.c	Wed Jun 27 14:02:29 2001
+++ linux/fs/nfs/inode.c	Mon Dec  3 23:03:38 2001
@@ -48,6 +48,7 @@
 static void nfs_write_inode(struct inode *,int);
 static void nfs_delete_inode(struct inode *);
 static void nfs_put_super(struct super_block *);
+static void nfs_clear_inode(struct inode *);
 static void nfs_umount_begin(struct super_block *);
 static int  nfs_statfs(struct super_block *, struct statfs *);
 
@@ -57,6 +58,7 @@
 	delete_inode:	nfs_delete_inode,
 	put_super:	nfs_put_super,
 	statfs:		nfs_statfs,
+	clear_inode:	nfs_clear_inode,
 	umount_begin:	nfs_umount_begin,
 };
 
@@ -141,6 +143,19 @@
 	clear_inode(inode);
 }
 
+/*
+ * For the moment, the only task for the NFS clear_inode method is to
+ * release the mmap credential
+ */
+static void
+nfs_clear_inode(struct inode *inode)
+{
+	struct rpc_cred *cred = NFS_I(inode)->mm_cred;
+
+	if (cred)
+		put_rpccred(cred);
+}
+
 void
 nfs_put_super(struct super_block *sb)
 {
@@ -600,7 +615,6 @@
 		inode->i_ctime = nfs_time_to_secs(fattr->ctime);
 		NFS_CACHE_CTIME(inode) = fattr->ctime;
 		NFS_CACHE_MTIME(inode) = fattr->mtime;
-		NFS_CACHE_ATIME(inode) = fattr->atime;
 		NFS_CACHE_ISIZE(inode) = fattr->size;
 		NFS_ATTRTIMEO(inode) = NFS_MINATTRTIMEO(inode);
 		NFS_ATTRTIMEO_UPDATE(inode) = jiffies;
@@ -794,6 +808,21 @@
 }
 
 /*
+ * Ensure that mmap has a recent RPC credential for use when writing out
+ * shared pages
+ */
+static inline void
+nfs_set_mmcred(struct inode *inode, struct rpc_cred *cred)
+{
+	struct rpc_cred **p = &NFS_I(inode)->mm_cred,
+			*oldcred = *p;
+
+	*p = get_rpccred(cred);
+	if (oldcred)
+		put_rpccred(oldcred);
+}
+
+/*
  * These are probably going to contain hooks for
  * allocating and releasing RPC credentials for
  * the file. I'll have to think about Tronds patch
@@ -808,20 +837,20 @@
 	auth = NFS_CLIENT(inode)->cl_auth;
 	cred = rpcauth_lookupcred(auth, 0);
 	filp->private_data = cred;
+	if (filp->f_mode & FMODE_WRITE)
+		nfs_set_mmcred(inode, cred);
 	unlock_kernel();
 	return 0;
 }
 
 int nfs_release(struct inode *inode, struct file *filp)
 {
-	struct rpc_auth *auth;
 	struct rpc_cred *cred;
 
 	lock_kernel();
-	auth = NFS_CLIENT(inode)->cl_auth;
 	cred = nfs_file_cred(filp);
 	if (cred)
-		rpcauth_releasecred(auth, cred);
+		put_rpccred(cred);
 	unlock_kernel();
 	return 0;
 }
@@ -976,7 +1005,6 @@
 	NFS_CACHE_CTIME(inode) = fattr->ctime;
 	inode->i_ctime = nfs_time_to_secs(fattr->ctime);
 
-	NFS_CACHE_ATIME(inode) = fattr->atime;
 	inode->i_atime = nfs_time_to_secs(fattr->atime);
 
 	NFS_CACHE_MTIME(inode) = new_mtime;
diff -urN linux-2.4.9-pre4/fs/nfs/unlink.c linux/fs/nfs/unlink.c
--- linux-2.4.9-pre4/fs/nfs/unlink.c	Fri Feb  9 11:29:44 2001
+++ linux/fs/nfs/unlink.c	Mon Dec  3 23:03:38 2001
@@ -128,7 +128,7 @@
 	dir_i = dir->d_inode;
 	nfs_zap_caches(dir_i);
 	NFS_PROTO(dir_i)->unlink_done(dir, &task->tk_msg);
-	rpcauth_releasecred(task->tk_auth, data->cred);
+	put_rpccred(data->cred);
 	data->cred = NULL;
 	dput(dir);
 }
diff -urN linux-2.4.9-pre4/fs/nfs/write.c linux/fs/nfs/write.c
--- linux-2.4.9-pre4/fs/nfs/write.c	Wed Jun 27 14:02:29 2001
+++ linux/fs/nfs/write.c	Mon Dec  3 23:03:38 2001
@@ -181,7 +181,9 @@
 
 
 	if (file)
-		cred = nfs_file_cred(file);
+		cred = get_rpccred(nfs_file_cred(file));
+	if (!cred)
+		cred = get_rpccred(NFS_I(inode)->mm_cred);
 
 	dprintk("NFS:      nfs_writepage_sync(%x/%Ld %d@%Ld)\n",
 		inode->i_dev, (long long)NFS_FILEID(inode),
@@ -226,6 +228,8 @@
 
 io_error:
 	kunmap(page);
+	if (cred)
+		put_rpccred(cred);
 
 	return written? written : result;
 }
@@ -241,6 +245,9 @@
 	status = (IS_ERR(req)) ? PTR_ERR(req) : 0;
 	if (status < 0)
 		goto out;
+	if (!req->wb_cred)
+		req->wb_cred = get_rpccred(NFS_I(inode)->mm_cred);
+	nfs_unlock_request(req);
 	nfs_release_request(req);
 	nfs_strategy(inode);
  out:
@@ -557,13 +564,11 @@
 	req->wb_bytes   = count;
 	req->wb_file    = file;
 
-	/* If we have a struct file, use its cached credentials
-	 * else cache the current process' credentials. */
+	/* If we have a struct file, use its cached credentials */
 	if (file) {
 		get_file(file);
 		req->wb_cred	= nfs_file_cred(file);
-	} else
-		req->wb_cred = rpcauth_lookupcred(NFS_CLIENT(inode)->cl_auth, 0);
+	}
 	req->wb_inode   = inode;
 	req->wb_count   = 1;
 
@@ -608,8 +613,8 @@
 	/* Release struct file or cached credential */
 	if (req->wb_file)
 		fput(req->wb_file);
-	else
-		rpcauth_releasecred(NFS_CLIENT(inode)->cl_auth, req->wb_cred);
+	else if (req->wb_cred)
+		put_rpccred(req->wb_cred);
 	page_cache_release(page);
 	nfs_page_free(req);
 	/* wake up anyone waiting to allocate a request */
@@ -927,8 +932,6 @@
 	if (end > rqend)
 		req->wb_bytes = end - req->wb_offset;
 
-	nfs_unlock_request(req);
-
 	return req;
 }
 
@@ -1049,6 +1052,7 @@
 		goto done;
 
 	status = 0;
+	nfs_unlock_request(req);
 	/* If we wrote past the end of the page.
 	 * Call the strategy routine so it can send out a bunch
 	 * of requests.
diff -urN linux-2.4.9-pre4/fs/ntfs/attr.c linux/fs/ntfs/attr.c
--- linux-2.4.9-pre4/fs/ntfs/attr.c	Mon Jul 16 15:14:10 2001
+++ linux/fs/ntfs/attr.c	Mon Dec  3 23:03:38 2001
@@ -148,7 +148,7 @@
 					"attribute non-resident. Bug!\n");
 				return -EINVAL;
 			}
-			m = memcmp(value, a->d.data, min(value_len, a->size));
+			m = memcmp(value, a->d.data, min(int, value_len, a->size));
 			if (m > 0)
 				continue;
 			if (m < 0) {
@@ -379,7 +379,7 @@
 				ntfs_bzero((char*)attr->d.data + oldsize,
 					   newsize - oldsize);
 			ntfs_memcpy((char*)attr->d.data, v,
-				    min(newsize, oldsize));
+				    min(s64, newsize, oldsize));
 		} else
 			attr->d.data = 0;
 		ntfs_free(v);
@@ -668,7 +668,7 @@
 	if (!sparse)
 		return -ENOMEM;
 	while (size) {
-		int i = min(size, 512);
+		int i = min(int, size, 512);
 		dest->fn_put(dest, sparse, i);
 		size -= i;
 	}
@@ -723,7 +723,7 @@
 			__s64 l1;
 			if ((len - (s_vcn - vcn)) & 15)
 				ntfs_error("Unexpected sparse chunk size.");
-			l1 = chunk = min(((__s64)(vcn + len) << clustersizebits)
+			l1 = chunk = min(s64, ((__s64)(vcn + len) << clustersizebits)
 								- offset, l);
 			error = ntfs_read_zero(dest, l1);
 			if (error)
@@ -742,13 +742,13 @@
 			comp1 = comp;
 			do {
 				io.param = comp1;
-				l1 = min(len - max(s_vcn - vcn, 0), 16 - got);
+				l1 = min(int, len - max(int, s_vcn - vcn, 0), 16 - got);
 				io.size = (__s64)l1 << clustersizebits;
 				error = ntfs_getput_clusters(ino->vol, cl1, 0,
 					       		     &io);
 				if (error)
 					goto out;
-				if (l1 + max(s_vcn - vcn, 0) == len) {
+				if (l1 + max(int, s_vcn - vcn, 0) == len) {
 					rnum++;
 					rl++;
 					vcn += len;
@@ -779,8 +779,8 @@
 				comp1 = decomp;
 			}
 			offs1 = offset - ((__s64)s_vcn << clustersizebits);
-			chunk = min((16 << clustersizebits) - offs1, chunk);
-			chunk = min(l, chunk);
+			chunk = min(s64, (16 << clustersizebits) - offs1, chunk);
+			chunk = min(s64, l, chunk);
 			dest->fn_put(dest, comp1 + offs1, chunk);
 		}
 		l -= chunk;
diff -urN linux-2.4.9-pre4/fs/ntfs/fs.c linux/fs/ntfs/fs.c
--- linux-2.4.9-pre4/fs/ntfs/fs.c	Mon Dec  3 23:03:29 2001
+++ linux/fs/ntfs/fs.c	Mon Dec  3 23:03:38 2001
@@ -1048,12 +1048,12 @@
 	set_blocksize(sb->s_dev, sb->s_blocksize);
 	ntfs_debug(DEBUG_OTHER, "set_blocksize\n");
 	/* Allocate an MFT record (MFT record can be smaller than a cluster). */
-	if (!(vol->mft = ntfs_malloc(max(vol->mft_record_size,
-							 vol->cluster_size))))
+	if (!(vol->mft = ntfs_malloc(max(int, vol->mft_record_size,
+					 vol->cluster_size))))
 		goto ntfs_read_super_unl;
 
 	/* Read at least the MFT record for $Mft. */
-	for (i = 0; i < max(vol->mft_clusters_per_record, 1); i++) {
+	for (i = 0; i < max(int, vol->mft_clusters_per_record, 1); i++) {
 		if (!(bh = bread(sb->s_dev, vol->mft_lcn + i,
 							  vol->cluster_size))) {
 			ntfs_error("Could not read $Mft record 0\n");
diff -urN linux-2.4.9-pre4/fs/ntfs/inode.c linux/fs/ntfs/inode.c
--- linux-2.4.9-pre4/fs/ntfs/inode.c	Mon Jul 23 16:23:58 2001
+++ linux/fs/ntfs/inode.c	Mon Dec  3 23:03:38 2001
@@ -105,7 +105,7 @@
 		 * will fall back to the minimal size allocation below. (AIA) */
 		block = vol->mft_record_size;
 		blockbits = vol->mft_record_size_bits;
-		size = max(size >> 10, mdata->size + vol->mft_record_size);
+		size = max(s64, size >> 10, mdata->size + vol->mft_record_size);
 		size = (__s64)((size + block - 1) >> blockbits) << blockbits;
 		/* Require this to be a single chunk. */
 		error = ntfs_extend_attr(vol->mft_ino, mdata, &size,
@@ -394,7 +394,7 @@
 		io.fn_put = ntfs_put;
 		io.fn_get = 0;
 		io.param = buf + delta;
-		io.size = len = min(datasize, 1024 - delta);
+		io.size = len = min(int, datasize, 1024 - delta);
 		ntfs_debug(DEBUG_FILE2, "load_attributes %x: len = %i\n",
 						ino->i_number, len);
 		ntfs_debug(DEBUG_FILE2, "load_attributes %x: delta = %i\n",
@@ -729,7 +729,7 @@
 		cluster = attr->d.r.runlist[rnum].cluster;
 		len = attr->d.r.runlist[rnum].len;
 		s_cluster = cluster + s_vcn - vcn;
-		chunk = min(((__s64)(vcn + len) << clustersizebits) - offset,
+		chunk = min(s64, ((__s64)(vcn + len) << clustersizebits) - offset,
 									l);
 		dest->size = chunk;
 		error = ntfs_getput_clusters(ino->vol, s_cluster, offset -
diff -urN linux-2.4.9-pre4/fs/ntfs/macros.h linux/fs/ntfs/macros.h
--- linux-2.4.9-pre4/fs/ntfs/macros.h	Mon Jul 16 15:14:10 2001
+++ linux/fs/ntfs/macros.h	Mon Dec  3 23:03:38 2001
@@ -11,12 +11,6 @@
 #define NTFS_INO2VOL(ino)	(&((ino)->i_sb->u.ntfs_sb))
 #define NTFS_LINO2NINO(ino)     (&((ino)->u.ntfs_i))
 
-/* Classical min and max macros still missing in standard headers... */
-#ifndef min
-#define min(a,b)	((a) <= (b) ? (a) : (b))
-#define max(a,b)	((a) >= (b) ? (a) : (b))
-#endif
-
 #define IS_MAGIC(a,b)		(*(int*)(a) == *(int*)(b))
 #define IS_MFT_RECORD(a)	IS_MAGIC((a),"FILE")
 #define IS_INDEX_RECORD(a)	IS_MAGIC((a),"INDX")
diff -urN linux-2.4.9-pre4/fs/ntfs/support.c linux/fs/ntfs/support.c
--- linux-2.4.9-pre4/fs/ntfs/support.c	Mon Dec  3 23:03:29 2001
+++ linux/fs/ntfs/support.c	Mon Dec  3 23:03:38 2001
@@ -180,7 +180,7 @@
 			error = -EIO;
 			goto error_ret;
 		}
-		to_copy = min(vol->cluster_size - start_offs, length);
+		to_copy = min(unsigned int, vol->cluster_size - start_offs, length);
 		lock_buffer(bh);
 		if (buf->do_read) {
 			buf->fn_put(buf, bh->b_data + start_offs, to_copy);
diff -urN linux-2.4.9-pre4/fs/ntfs/unistr.c linux/fs/ntfs/unistr.c
--- linux-2.4.9-pre4/fs/ntfs/unistr.c	Mon Jul 16 15:14:10 2001
+++ linux/fs/ntfs/unistr.c	Mon Dec  3 23:03:38 2001
@@ -96,7 +96,7 @@
 	__u32 cnt;
 	wchar_t c1, c2;
 
-	for (cnt = 0; cnt < min(name1_len, name2_len); ++cnt)
+	for (cnt = 0; cnt < min(unsigned int, name1_len, name2_len); ++cnt)
 	{
 		c1 = le16_to_cpu(*name1++);
 		c2 = le16_to_cpu(*name2++);
diff -urN linux-2.4.9-pre4/fs/romfs/inode.c linux/fs/romfs/inode.c
--- linux-2.4.9-pre4/fs/romfs/inode.c	Fri Apr 13 20:26:07 2001
+++ linux/fs/romfs/inode.c	Mon Dec  3 23:03:38 2001
@@ -76,11 +76,6 @@
 
 #include <asm/uaccess.h>
 
-static int inline min(int a, int b)
-{
-	return a<b ? a : b;
-}
-
 static __s32
 romfs_checksum(void *data, int size)
 {
@@ -129,7 +124,7 @@
 				"%s.\n", kdevname(dev));
 		goto out;
 	}
-	if (romfs_checksum(rsb, min(sz,512))) {
+	if (romfs_checksum(rsb, min(int, sz, 512))) {
 		printk ("romfs: bad initial checksum on dev "
 			"%s.\n", kdevname(dev));
 		goto out;
@@ -198,7 +193,7 @@
 		return -1;		/* error */
 
 	avail = ROMBSIZE - (offset & ROMBMASK);
-	maxsize = min(count, avail);
+	maxsize = min(unsigned long, count, avail);
 	res = strnlen(((char *)bh->b_data)+(offset&ROMBMASK), maxsize);
 	brelse(bh);
 
@@ -211,7 +206,7 @@
 		bh = bread(i->i_dev, offset>>ROMBSBITS, ROMBSIZE);
 		if (!bh)
 			return -1;
-		maxsize = min(count-res, ROMBSIZE);
+		maxsize = min(unsigned long, count - res, ROMBSIZE);
 		avail = strnlen(bh->b_data, maxsize);
 		res += avail;
 		brelse(bh);
@@ -236,7 +231,7 @@
 		return -1;		/* error */
 
 	avail = ROMBSIZE - (offset & ROMBMASK);
-	maxsize = min(count, avail);
+	maxsize = min(unsigned long, count, avail);
 	memcpy(dest, ((char *)bh->b_data) + (offset & ROMBMASK), maxsize);
 	brelse(bh);
 
@@ -249,7 +244,7 @@
 		bh = bread(i->i_dev, offset>>ROMBSBITS, ROMBSIZE);
 		if (!bh)
 			return -1;
-		maxsize = min(count-res, ROMBSIZE);
+		maxsize = min(unsigned long, count - res, ROMBSIZE);
 		memcpy(dest, bh->b_data, maxsize);
 		brelse(bh);
 		res += maxsize;
@@ -413,7 +408,7 @@
 	offset = page->index << PAGE_CACHE_SHIFT;
 	if (offset < inode->i_size) {
 		avail = inode->i_size-offset;
-		readlen = min(avail, PAGE_SIZE);
+		readlen = min(unsigned long, avail, PAGE_SIZE);
 		if (romfs_copyfrom(inode, buf, inode->u.romfs_i.i_dataoffset+offset, readlen) == readlen) {
 			if (readlen < PAGE_SIZE) {
 				memset(buf + readlen,0,PAGE_SIZE-readlen);
diff -urN linux-2.4.9-pre4/fs/ufs/balloc.c linux/fs/ufs/balloc.c
--- linux-2.4.9-pre4/fs/ufs/balloc.c	Tue Sep  5 14:07:30 2000
+++ linux/fs/ufs/balloc.c	Mon Dec  3 23:03:38 2001
@@ -312,7 +312,7 @@
 			*p = SWAB32(result);
 			*err = 0;
 			inode->i_blocks += count << uspi->s_nspfshift;
-			inode->u.ufs_i.i_lastfrag = max (inode->u.ufs_i.i_lastfrag, fragment + count);
+			inode->u.ufs_i.i_lastfrag = max(u32, inode->u.ufs_i.i_lastfrag, fragment + count);
 			NULLIFY_FRAGMENTS
 		}
 		unlock_super(sb);
@@ -327,7 +327,7 @@
 	if (result) {
 		*err = 0;
 		inode->i_blocks += count << uspi->s_nspfshift;
-		inode->u.ufs_i.i_lastfrag = max (inode->u.ufs_i.i_lastfrag, fragment + count);
+		inode->u.ufs_i.i_lastfrag = max(u32, inode->u.ufs_i.i_lastfrag, fragment + count);
 		NULLIFY_FRAGMENTS
 		unlock_super(sb);
 		UFSD(("EXIT, result %u\n", result))
@@ -380,7 +380,7 @@
 		*p = SWAB32(result);
 		*err = 0;
 		inode->i_blocks += count << uspi->s_nspfshift;
-		inode->u.ufs_i.i_lastfrag = max (inode->u.ufs_i.i_lastfrag, fragment + count);
+		inode->u.ufs_i.i_lastfrag = max(u32, inode->u.ufs_i.i_lastfrag, fragment + count);
 		NULLIFY_FRAGMENTS
 		unlock_super(sb);
 		if (newcount < request)
diff -urN linux-2.4.9-pre4/fs/ufs/truncate.c linux/fs/ufs/truncate.c
--- linux-2.4.9-pre4/fs/ufs/truncate.c	Tue Mar  6 19:44:37 2001
+++ linux/fs/ufs/truncate.c	Mon Dec  3 23:03:38 2001
@@ -88,7 +88,7 @@
 	retry = 0;
 	
 	frag1 = DIRECT_FRAGMENT;
-	frag4 = min (UFS_NDIR_FRAGMENT, inode->u.ufs_i.i_lastfrag);
+	frag4 = min(u32, UFS_NDIR_FRAGMENT, inode->u.ufs_i.i_lastfrag);
 	frag2 = ((frag1 & uspi->s_fpbmask) ? ((frag1 | uspi->s_fpbmask) + 1) : frag1);
 	frag3 = frag4 & ~uspi->s_fpbmask;
 	block1 = block2 = 0;
diff -urN linux-2.4.9-pre4/fs/ufs/util.c linux/fs/ufs/util.c
--- linux-2.4.9-pre4/fs/ufs/util.c	Fri Feb  9 11:29:44 2001
+++ linux/fs/ufs/util.c	Mon Dec  3 23:03:38 2001
@@ -166,11 +166,11 @@
 	unsigned char * mem, struct ufs_buffer_head * ubh, unsigned size)
 {
 	unsigned len, bhno;
-	if ( size > (ubh->count << uspi->s_fshift) )
+	if (size > (ubh->count << uspi->s_fshift))
 		size = ubh->count << uspi->s_fshift;
 	bhno = 0;
-	while ( size ) {
-		len = min (size, uspi->s_fsize);
+	while (size) {
+		len = min(unsigned int, size, uspi->s_fsize);
 		memcpy (mem, ubh->bh[bhno]->b_data, len);
 		mem += uspi->s_fsize;
 		size -= len;
@@ -182,11 +182,11 @@
 	struct ufs_buffer_head * ubh, unsigned char * mem, unsigned size)
 {
 	unsigned len, bhno;
-	if ( size > (ubh->count << uspi->s_fshift) )
+	if (size > (ubh->count << uspi->s_fshift))
 		size = ubh->count << uspi->s_fshift;
 	bhno = 0;
-	while ( size ) {
-		len = min (size, uspi->s_fsize);
+	while (size) {
+		len = min(unsigned int, size, uspi->s_fsize);
 		memcpy (ubh->bh[bhno]->b_data, mem, len);
 		mem += uspi->s_fsize;
 		size -= len;
diff -urN linux-2.4.9-pre4/fs/ufs/util.h linux/fs/ufs/util.h
--- linux-2.4.9-pre4/fs/ufs/util.h	Mon Dec 11 13:26:44 2000
+++ linux/fs/ufs/util.h	Mon Dec  3 23:03:38 2001
@@ -14,10 +14,6 @@
  * some useful macros
  */
 #define in_range(b,first,len)	((b)>=(first)&&(b)<(first)+(len))
-#define min(x,y)		((x)<(y)?(x):(y))
-#define max(x,y)		((x)>(y)?(x):(y))
-
-
 
 /*
  * macros used for retyping
@@ -335,7 +331,7 @@
 	base = offset >> uspi->s_bpfshift;
 	offset &= uspi->s_bpfmask;
 	for (;;) {
-		count = min (size + offset, uspi->s_bpf);
+		count = min(unsigned int, size + offset, uspi->s_bpf);
 		size -= count - offset;
 		pos = ext2_find_next_zero_bit (ubh->bh[base]->b_data, count, offset);
 		if (pos < count || !size)
@@ -382,7 +378,8 @@
 	base = start >> uspi->s_bpfshift;
 	start &= uspi->s_bpfmask;
 	for (;;) {
-		count = min (size + (uspi->s_bpf - start), uspi->s_bpf)
+		count = min(unsigned int,
+			    size + (uspi->s_bpf - start), uspi->s_bpf)
 			- (uspi->s_bpf - start);
 		size -= count;
 		pos = find_last_zero_bit (ubh->bh[base]->b_data,
diff -urN linux-2.4.9-pre4/include/asm-sparc/hw_irq.h linux/include/asm-sparc/hw_irq.h
--- linux-2.4.9-pre4/include/asm-sparc/hw_irq.h	Wed Dec 31 16:00:00 1969
+++ linux/include/asm-sparc/hw_irq.h	Mon Dec  3 23:03:38 2001
@@ -0,0 +1,6 @@
+#ifndef __ASM_SPARC_HW_IRQ_H
+#define __ASM_SPARC_HW_IRQ_H
+
+/* Dummy include. */
+
+#endif
diff -urN linux-2.4.9-pre4/include/asm-sparc64/hw_irq.h linux/include/asm-sparc64/hw_irq.h
--- linux-2.4.9-pre4/include/asm-sparc64/hw_irq.h	Wed Dec 31 16:00:00 1969
+++ linux/include/asm-sparc64/hw_irq.h	Mon Dec  3 23:03:38 2001
@@ -0,0 +1,6 @@
+#ifndef __ASM_SPARC64_HW_IRQ_H
+#define __ASM_SPARC64_HW_IRQ_H
+
+/* Dummy include. */
+
+#endif
diff -urN linux-2.4.9-pre4/include/asm-sparc64/keyboard.h linux/include/asm-sparc64/keyboard.h
--- linux-2.4.9-pre4/include/asm-sparc64/keyboard.h	Wed Apr 28 08:47:39 1999
+++ linux/include/asm-sparc64/keyboard.h	Mon Dec  3 23:03:38 2001
@@ -1,4 +1,4 @@
-/* $Id: keyboard.h,v 1.3 1999/04/28 11:59:12 davem Exp $
+/* $Id: keyboard.h,v 1.4 2001/08/13 14:40:07 davem Exp $
  * linux/include/asm-sparc64/keyboard.h
  *
  * Created Aug 29 1997 by Eddie C. Dost (ecd@skynet.be)
@@ -13,6 +13,9 @@
 
 #ifdef __KERNEL__
 
+#include <linux/kernel.h>
+#include <linux/kd.h>
+
 #define KEYBOARD_IRQ			1
 #define DISABLE_KBD_DURING_INTERRUPTS	0
 
@@ -22,6 +25,7 @@
 			    char raw_mode);
 extern char pcikbd_unexpected_up(unsigned char keycode);
 extern void pcikbd_leds(unsigned char leds);
+extern int pcikbd_rate(struct kbd_repeat *rep);
 extern void pcikbd_init_hw(void);
 extern unsigned char pcikbd_sysrq_xlate[128];
 
@@ -30,6 +34,7 @@
 #define kbd_translate			pcikbd_translate
 #define kbd_unexpected_up		pcikbd_unexpected_up
 #define kbd_leds			pcikbd_leds
+#define kbd_rate			pcikbd_rate
 #define kbd_init_hw			pcikbd_init_hw
 #define kbd_sysrq_xlate			pcikbd_sysrq_xlate
 #define kbd_init			pcikbd_init
diff -urN linux-2.4.9-pre4/include/asm-sparc64/mmu_context.h linux/include/asm-sparc64/mmu_context.h
--- linux-2.4.9-pre4/include/asm-sparc64/mmu_context.h	Mon Dec  3 23:03:29 2001
+++ linux/include/asm-sparc64/mmu_context.h	Mon Dec  3 23:03:38 2001
@@ -1,4 +1,4 @@
-/* $Id: mmu_context.h,v 1.49 2001/08/09 21:10:20 davem Exp $ */
+/* $Id: mmu_context.h,v 1.50 2001/08/13 20:24:34 kanoj Exp $ */
 #ifndef __SPARC64_MMU_CONTEXT_H
 #define __SPARC64_MMU_CONTEXT_H
 
@@ -9,6 +9,7 @@
 #include <linux/spinlock.h>
 #include <asm/system.h>
 #include <asm/spitfire.h>
+#include <asm/page.h>
 
 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk, unsigned cpu)
 {
@@ -18,7 +19,19 @@
 extern unsigned long tlb_context_cache;
 extern unsigned long mmu_context_bmap[];
 
-#define CTX_VERSION_SHIFT	(PAGE_SHIFT - 3)
+/*
+ * For the 8k pagesize kernel, use only 10 hw context bits to optimize some shifts in
+ * the fast tlbmiss handlers, instead of all 13 bits (specifically for vpte offset
+ * calculation). For other pagesizes, this optimization in the tlbhandlers can not be 
+ * done; but still, all 13 bits can not be used because the tlb handlers use "andcc"
+ * instruction which sign extends 13 bit arguments.
+ */
+#if PAGE_SHIFT == 13
+#define CTX_VERSION_SHIFT	10
+#else
+#define CTX_VERSION_SHIFT	12
+#endif
+
 #define CTX_VERSION_MASK	((~0UL) << CTX_VERSION_SHIFT)
 #define CTX_FIRST_VERSION	((1UL << CTX_VERSION_SHIFT) + 1UL)
 #define CTX_VALID(__ctx)	\
diff -urN linux-2.4.9-pre4/include/asm-sparc64/pbm.h linux/include/asm-sparc64/pbm.h
--- linux-2.4.9-pre4/include/asm-sparc64/pbm.h	Wed May 16 10:31:27 2001
+++ linux/include/asm-sparc64/pbm.h	Mon Dec  3 23:03:38 2001
@@ -1,4 +1,4 @@
-/* $Id: pbm.h,v 1.26 2001/05/15 08:54:30 davem Exp $
+/* $Id: pbm.h,v 1.27 2001/08/12 13:18:23 davem Exp $
  * pbm.h: UltraSparc PCI controller software state.
  *
  * Copyright (C) 1997, 1998, 1999 David S. Miller (davem@redhat.com)
@@ -156,6 +156,9 @@
 
 	/* IOMMU state, potentially shared by both PBM segments. */
 	struct pci_iommu		*iommu;
+
+	/* PCI slot mapping. */
+	unsigned int			pci_first_slot;
 
 	/* Now things for the actual PCI bus probes. */
 	unsigned int			pci_first_busno;
diff -urN linux-2.4.9-pre4/include/asm-sparc64/pgtable.h linux/include/asm-sparc64/pgtable.h
--- linux-2.4.9-pre4/include/asm-sparc64/pgtable.h	Fri Apr 13 20:15:55 2001
+++ linux/include/asm-sparc64/pgtable.h	Mon Dec  3 23:03:38 2001
@@ -1,4 +1,4 @@
-/* $Id: pgtable.h,v 1.140 2001/04/12 22:41:15 davem Exp $
+/* $Id: pgtable.h,v 1.141 2001/08/13 20:24:34 kanoj Exp $
  * pgtable.h: SpitFire page table operations.
  *
  * Copyright 1996,1997 David S. Miller (davem@caip.rutgers.edu)
@@ -16,6 +16,7 @@
 #include <asm/asi.h>
 #include <asm/mmu_context.h>
 #include <asm/system.h>
+#include <asm/page.h>
 
 #ifndef __ASSEMBLY__
 
@@ -31,14 +32,26 @@
  * XXX cheetah's full 64-bit virtual address space, ie. no more hole
  * XXX in the middle like on spitfire. -DaveM
  */
+/*
+ * Given a virtual address, the lowest PAGE_SHIFT bits determine offset
+ * into the page; the next higher PAGE_SHIFT-3 bits determine the pte#
+ * in the proper pagetable (the -3 is from the 8 byte ptes, and each page
+ * table is a single page long). The next higher PMD_BITS determine pmd# 
+ * in the proper pmdtable (where we must have PMD_BITS <= (PAGE_SHIFT-2) 
+ * since the pmd entries are 4 bytes, and each pmd page is a single page 
+ * long). Finally, the higher few bits determine pgde#.
+ */
+
+#define VA_BITS 	44
 
 /* PMD_SHIFT determines the size of the area a second-level page table can map */
 #define PMD_SHIFT	(PAGE_SHIFT + (PAGE_SHIFT-3))
 #define PMD_SIZE	(1UL << PMD_SHIFT)
 #define PMD_MASK	(~(PMD_SIZE-1))
+#define PMD_BITS	11
 
 /* PGDIR_SHIFT determines what a third-level page table entry can map */
-#define PGDIR_SHIFT	(PAGE_SHIFT + (PAGE_SHIFT-3) + (PAGE_SHIFT-2))
+#define PGDIR_SHIFT	(PAGE_SHIFT + (PAGE_SHIFT-3) + PMD_BITS)
 #define PGDIR_SIZE	(1UL << PGDIR_SHIFT)
 #define PGDIR_MASK	(~(PGDIR_SIZE-1))
 
@@ -48,12 +61,12 @@
 /* We the first one in this file, what we export to the kernel
  * is different so we can optimize correctly for 32-bit tasks.
  */
-#define REAL_PTRS_PER_PMD	(1UL << (PAGE_SHIFT-2))
+#define REAL_PTRS_PER_PMD	(1UL << PMD_BITS)
 #define PTRS_PER_PMD		((const int)((current->thread.flags & SPARC_FLAG_32BIT) ? \
-				 (REAL_PTRS_PER_PMD >> 2) : (REAL_PTRS_PER_PMD)))
+				 (1UL << (32 - (PAGE_SHIFT-3) - PAGE_SHIFT)) : (REAL_PTRS_PER_PMD)))
 
 /* We cannot use the top 16G because VPTE table lives there. */
-#define PTRS_PER_PGD		((1UL << (PAGE_SHIFT-3))-1)
+#define PTRS_PER_PGD		((1UL << (VA_BITS - PAGE_SHIFT - (PAGE_SHIFT-3) - PMD_BITS))-1)
 
 /* Kernel has a separate 44bit address space. */
 #define USER_PTRS_PER_PGD	((const int)((current->thread.flags & SPARC_FLAG_32BIT) ? \
@@ -62,7 +75,6 @@
 
 #define PTE_TABLE_SIZE	0x2000	/* 1024 entries 8 bytes each */
 #define PMD_TABLE_SIZE	0x2000	/* 2048 entries 4 bytes each */
-#define PGD_TABLE_SIZE	0x1000	/* 1024 entries 4 bytes each */
 
 /* NOTE: TLB miss handlers depend heavily upon where this is. */
 #define VMALLOC_START		0x0000000140000000UL
diff -urN linux-2.4.9-pre4/include/linux/cyclomx.h linux/include/linux/cyclomx.h
--- linux-2.4.9-pre4/include/linux/cyclomx.h	Mon Dec 11 13:00:10 2000
+++ linux/include/linux/cyclomx.h	Mon Dec  3 23:03:38 2001
@@ -37,13 +37,6 @@
 #include <linux/cycx_x25.h>
 #endif
 
-#ifndef	min
-#define min(a,b) (((a)<(b))?(a):(b))
-#endif
-#ifndef	max
-#define max(a,b) (((a)>(b))?(a):(b))
-#endif
-
 #define	is_digit(ch) (((ch)>=(unsigned)'0'&&(ch)<=(unsigned)'9')?1:0)
 
 /* Adapter Data Space.
diff -urN linux-2.4.9-pre4/include/linux/kernel.h linux/include/linux/kernel.h
--- linux-2.4.9-pre4/include/linux/kernel.h	Mon Dec  3 23:03:29 2001
+++ linux/include/linux/kernel.h	Mon Dec  3 23:03:38 2001
@@ -112,6 +112,11 @@
 	((unsigned char *)&addr)[1], \
 	((unsigned char *)&addr)[0]
 
+#define min(type,x,y) \
+	({ type __x = (x), __y = (y); __x < __y ? __x: __y; })
+#define max(type,x,y) \
+	({ type __x = (x), __y = (y); __x > __y ? __x: __y; })
+
 #endif /* __KERNEL__ */
 
 #define SI_LOAD_SHIFT	16
diff -urN linux-2.4.9-pre4/include/linux/lvm.h linux/include/linux/lvm.h
--- linux-2.4.9-pre4/include/linux/lvm.h	Wed Jul 11 16:35:37 2001
+++ linux/include/linux/lvm.h	Mon Dec  3 23:03:38 2001
@@ -131,13 +131,6 @@
 
 #define	LVM_DIR_PREFIX	"/dev/"
 
-#ifndef min
-#define min(a,b) (((a)<(b))?(a):(b))
-#endif
-#ifndef max
-#define max(a,b) (((a)>(b))?(a):(b))
-#endif
-
 /* set the default structure version */
 #if ( LVM_STRUCT_VERSION == 1)
 #define pv_t pv_v2_t
diff -urN linux-2.4.9-pre4/include/linux/mtd/cfi.h linux/include/linux/mtd/cfi.h
--- linux-2.4.9-pre4/include/linux/mtd/cfi.h	Fri Jul 20 12:50:24 2001
+++ linux/include/linux/mtd/cfi.h	Mon Dec  3 23:03:38 2001
@@ -365,10 +365,6 @@
 	}
 }
 
-#ifndef min
-#define min(x,y) ( (x)<(y)?(x):(y) )
-#endif
-
 static inline void cfi_udelay(int us)
 {
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
diff -urN linux-2.4.9-pre4/include/linux/nfs_fs.h linux/include/linux/nfs_fs.h
--- linux-2.4.9-pre4/include/linux/nfs_fs.h	Fri Aug 10 18:14:53 2001
+++ linux/include/linux/nfs_fs.h	Mon Dec  3 23:03:38 2001
@@ -63,6 +63,11 @@
  */
 #define NFS_SUPER_MAGIC			0x6969
 
+static inline struct nfs_inode_info *NFS_I(struct inode *inode)
+{
+	return &inode->u.nfs_i;
+}
+
 #define NFS_FH(inode)			(&(inode)->u.nfs_i.fh)
 #define NFS_SERVER(inode)		(&(inode)->i_sb->u.nfs_sb.s_server)
 #define NFS_CLIENT(inode)		(NFS_SERVER(inode)->client)
@@ -74,7 +79,6 @@
 #define NFS_READTIME(inode)		((inode)->u.nfs_i.read_cache_jiffies)
 #define NFS_CACHE_CTIME(inode)		((inode)->u.nfs_i.read_cache_ctime)
 #define NFS_CACHE_MTIME(inode)		((inode)->u.nfs_i.read_cache_mtime)
-#define NFS_CACHE_ATIME(inode)		((inode)->u.nfs_i.read_cache_atime)
 #define NFS_CACHE_ISIZE(inode)		((inode)->u.nfs_i.read_cache_isize)
 #define NFS_NEXTSCAN(inode)		((inode)->u.nfs_i.nextscan)
 #define NFS_CACHEINV(inode) \
diff -urN linux-2.4.9-pre4/include/linux/nfs_fs_i.h linux/include/linux/nfs_fs_i.h
--- linux-2.4.9-pre4/include/linux/nfs_fs_i.h	Mon Feb 19 17:13:00 2001
+++ linux/include/linux/nfs_fs_i.h	Mon Dec  3 23:03:38 2001
@@ -45,7 +45,6 @@
 	unsigned long		read_cache_jiffies;
 	__u64			read_cache_ctime;
 	__u64			read_cache_mtime;
-	__u64			read_cache_atime;
 	__u64			read_cache_isize;
 	unsigned long		attrtimeo;
 	unsigned long		attrtimeo_timestamp;
@@ -73,6 +72,9 @@
 	struct inode		*hash_next,
 				*hash_prev;
 	unsigned long		nextscan;
+
+	/* Credentials for shared mmap */
+	struct rpc_cred		*mm_cred;
 };
 
 /*
diff -urN linux-2.4.9-pre4/include/linux/sunrpc/auth.h linux/include/linux/sunrpc/auth.h
--- linux-2.4.9-pre4/include/linux/sunrpc/auth.h	Fri Aug 10 18:13:47 2001
+++ linux/include/linux/sunrpc/auth.h	Mon Dec  3 23:03:38 2001
@@ -14,6 +14,8 @@
 #include <linux/config.h>
 #include <linux/sunrpc/sched.h>
 
+#include <asm/atomic.h>
+
 /* size of the nodename buffer */
 #define UNX_MAXNODENAME	32
 
@@ -22,8 +24,10 @@
  */
 struct rpc_cred {
 	struct rpc_cred *	cr_next;	/* linked list */
+	struct rpc_auth *	cr_auth;
+	struct rpc_credops *	cr_ops;
 	unsigned long		cr_expire;	/* when to gc */
-	unsigned short		cr_count;	/* ref count */
+	atomic_t		cr_count;	/* ref count */
 	unsigned short		cr_flags;	/* various flags */
 #ifdef RPC_DEBUG
 	unsigned long		cr_magic;	/* 0x0f4aa4f0 */
@@ -71,6 +75,9 @@
 	void			(*destroy)(struct rpc_auth *);
 
 	struct rpc_cred *	(*crcreate)(int);
+};
+
+struct rpc_credops {
 	void			(*crdestroy)(struct rpc_cred *);
 
 	int			(*crmatch)(struct rpc_cred *, int);
@@ -92,8 +99,7 @@
 struct rpc_cred *	rpcauth_lookupcred(struct rpc_auth *, int);
 struct rpc_cred *	rpcauth_bindcred(struct rpc_task *);
 void			rpcauth_holdcred(struct rpc_task *);
-void			rpcauth_releasecred(struct rpc_auth *,
-					    struct rpc_cred *);
+void			put_rpccred(struct rpc_cred *);
 void			rpcauth_unbindcred(struct rpc_task *);
 int			rpcauth_matchcred(struct rpc_auth *,
 					  struct rpc_cred *, int);
@@ -106,6 +112,13 @@
 void			rpcauth_free_credcache(struct rpc_auth *);
 void			rpcauth_insert_credcache(struct rpc_auth *,
 						struct rpc_cred *);
+
+static inline
+struct rpc_cred *	get_rpccred(struct rpc_cred *cred)
+{
+	atomic_inc(&cred->cr_count);
+	return cred;
+}
 
 #endif /* __KERNEL__ */
 #endif /* _LINUX_SUNRPC_AUTH_H */
diff -urN linux-2.4.9-pre4/include/linux/swap.h linux/include/linux/swap.h
--- linux-2.4.9-pre4/include/linux/swap.h	Mon Dec  3 23:03:29 2001
+++ linux/include/linux/swap.h	Mon Dec  3 23:03:38 2001
@@ -256,9 +256,9 @@
  * 64 (1 << INACTIVE_SHIFT) seconds.
  */
 #define INACTIVE_SHIFT 6
-#define inactive_min(a,b) ((a) < (b) ? (a) : (b))
-#define inactive_target inactive_min((memory_pressure >> INACTIVE_SHIFT), \
-		(num_physpages / 4))
+#define inactive_target min(unsigned long, \
+			    (memory_pressure >> INACTIVE_SHIFT), \
+			    (num_physpages / 4))
 
 /*
  * Ugly ugly ugly HACK to make sure the inactive lists
diff -urN linux-2.4.9-pre4/include/linux/wanpipe.h linux/include/linux/wanpipe.h
--- linux-2.4.9-pre4/include/linux/wanpipe.h	Thu Apr 12 12:11:39 2001
+++ linux/include/linux/wanpipe.h	Mon Dec  3 23:03:38 2001
@@ -332,13 +332,6 @@
 #include <linux/tty_flip.h>
 
 
-#ifndef	min
-#define min(a,b) (((a)<(b))?(a):(b))
-#endif
-#ifndef	max
-#define max(a,b) (((a)>(b))?(a):(b))
-#endif
-
 #define	is_digit(ch) (((ch)>=(unsigned)'0'&&(ch)<=(unsigned)'9')?1:0)
 #define	is_alpha(ch) ((((ch)>=(unsigned)'a'&&(ch)<=(unsigned)'z')||\
 	 	  ((ch)>=(unsigned)'A'&&(ch)<=(unsigned)'Z'))?1:0)
diff -urN linux-2.4.9-pre4/include/net/sock.h linux/include/net/sock.h
--- linux-2.4.9-pre4/include/net/sock.h	Fri Aug 10 18:14:18 2001
+++ linux/include/net/sock.h	Mon Dec  3 23:03:38 2001
@@ -803,26 +803,6 @@
 #define bh_lock_sock(__sk)	spin_lock(&((__sk)->lock.slock))
 #define bh_unlock_sock(__sk)	spin_unlock(&((__sk)->lock.slock))
 
-/*
- *	This might not be the most appropriate place for this two	 
- *	but since they are used by a lot of the net related code
- *	at least they get declared on a include that is common to all
- */
-
-static __inline__ int min(unsigned int a, unsigned int b)
-{
-	if (a > b)
-		a = b; 
-	return a;
-}
-
-static __inline__ int max(unsigned int a, unsigned int b)
-{
-	if (a < b)
-		a = b;
-	return a;
-}
-
 extern struct sock *		sk_alloc(int family, int priority, int zero_it);
 extern void			sk_free(struct sock *sk);
 
@@ -1265,7 +1245,7 @@
 
 static inline int sock_rcvlowat(struct sock *sk, int waitall, int len)
 {
-	return (waitall ? len : min(sk->rcvlowat, len)) ? : 1;
+	return (waitall ? len : min(int, sk->rcvlowat, len)) ? : 1;
 }
 
 /* Alas, with timeout socket operations are not restartable.
diff -urN linux-2.4.9-pre4/include/net/tcp.h linux/include/net/tcp.h
--- linux-2.4.9-pre4/include/net/tcp.h	Fri Aug 10 18:15:10 2001
+++ linux/include/net/tcp.h	Mon Dec  3 23:03:38 2001
@@ -919,11 +919,14 @@
 static inline void tcp_initialize_rcv_mss(struct sock *sk)
 {
 	struct tcp_opt *tp = &sk->tp_pinfo.af_tcp;
-	int hint = min(tp->advmss, tp->mss_cache);
+	unsigned int hint = min(unsigned int, tp->advmss, tp->mss_cache);
 
-	hint = min(hint, tp->rcv_wnd/2);
+	hint = min(unsigned int, hint, tp->rcv_wnd/2);
 		
-	tp->ack.rcv_mss = max(min(hint, TCP_MIN_RCVMSS), TCP_MIN_MSS);
+	tp->ack.rcv_mss = max(unsigned int,
+			      min(unsigned int,
+				  hint, TCP_MIN_RCVMSS),
+			      TCP_MIN_MSS);
 }
 
 static __inline__ void __tcp_fast_path_on(struct tcp_opt *tp, u32 snd_wnd)
@@ -1074,7 +1077,7 @@
  */
 static inline __u32 tcp_recalc_ssthresh(struct tcp_opt *tp)
 {
-	return max(tp->snd_cwnd>>1, 2);
+	return max(u32, tp->snd_cwnd >> 1, 2);
 }
 
 /* If cwnd > ssthresh, we may raise ssthresh to be half-way to cwnd.
@@ -1086,7 +1089,9 @@
 	if ((1<<tp->ca_state)&(TCPF_CA_CWR|TCPF_CA_Recovery))
 		return tp->snd_ssthresh;
 	else
-		return max(tp->snd_ssthresh, (tp->snd_cwnd>>1)+(tp->snd_cwnd>>2));
+		return max(u32, tp->snd_ssthresh,
+			   ((tp->snd_cwnd >> 1) +
+			    (tp->snd_cwnd >> 2)));
 }
 
 static inline void tcp_sync_left_out(struct tcp_opt *tp)
@@ -1121,7 +1126,8 @@
 {
 	tp->undo_marker = 0;
 	tp->snd_ssthresh = tcp_recalc_ssthresh(tp);
-	tp->snd_cwnd = min(tp->snd_cwnd, tcp_packets_in_flight(tp)+1);
+	tp->snd_cwnd = min(u32, tp->snd_cwnd,
+			   tcp_packets_in_flight(tp) + 1);
 	tp->snd_cwnd_cnt = 0;
 	tp->high_seq = tp->snd_nxt;
 	tp->snd_cwnd_stamp = tcp_time_stamp;
@@ -1486,12 +1492,12 @@
 {
 	/* If no clamp set the clamp to the max possible scaled window */
 	if (*window_clamp == 0)
-		(*window_clamp) = (65535<<14);
-	space = min(*window_clamp,space);
+		(*window_clamp) = (65535 << 14);
+	space = min(u32, *window_clamp, space);
 
 	/* Quantize space offering to a multiple of mss if possible. */
 	if (space > mss)
-		space = (space/mss)*mss;
+		space = (space / mss) * mss;
 
 	/* NOTE: offering an initial window larger than 32767
 	 * will break some buggy TCP stacks. We try to be nice.
@@ -1499,7 +1505,7 @@
 	 * our initial window offering to 32k. There should also
 	 * be a sysctl option to stop being nice.
 	 */
-	(*rcv_wnd) = min(space, MAX_TCP_WINDOW);
+	(*rcv_wnd) = min(int, space, MAX_TCP_WINDOW);
 	(*rcv_wscale) = 0;
 	if (wscale_ok) {
 		/* See RFC1323 for an explanation of the limit to 14 */
@@ -1508,7 +1514,7 @@
 			(*rcv_wscale)++;
 		}
 		if (*rcv_wscale && sysctl_tcp_app_win && space>=mss &&
-		    space - max((space>>sysctl_tcp_app_win), mss>>*rcv_wscale) < 65536/2)
+		    space - max(unsigned int, (space>>sysctl_tcp_app_win), mss>>*rcv_wscale) < 65536/2)
 			(*rcv_wscale)--;
 	}
 
@@ -1526,7 +1532,7 @@
 			*rcv_wnd = init_cwnd*mss;
 	}
 	/* Set the clamp no higher than max representable value */
-	(*window_clamp) = min(65535<<(*rcv_wscale),*window_clamp);
+	(*window_clamp) = min(u32, 65535 << (*rcv_wscale), *window_clamp);
 }
 
 static inline int tcp_win_from_space(int space)
@@ -1692,8 +1698,8 @@
 static inline void tcp_moderate_sndbuf(struct sock *sk)
 {
 	if (!(sk->userlocks&SOCK_SNDBUF_LOCK)) {
-		sk->sndbuf = min(sk->sndbuf, sk->wmem_queued/2);
-		sk->sndbuf = max(sk->sndbuf, SOCK_MIN_SNDBUF);
+		sk->sndbuf = min(int, sk->sndbuf, sk->wmem_queued/2);
+		sk->sndbuf = max(int, sk->sndbuf, SOCK_MIN_SNDBUF);
 	}
 }
 
diff -urN linux-2.4.9-pre4/mm/filemap.c linux/mm/filemap.c
--- linux-2.4.9-pre4/mm/filemap.c	Mon Dec  3 23:03:29 2001
+++ linux/mm/filemap.c	Mon Dec  3 23:03:38 2001
@@ -45,12 +45,12 @@
 unsigned int page_hash_bits;
 struct page **page_hash_table;
 
-spinlock_t pagecache_lock = SPIN_LOCK_UNLOCKED;
+spinlock_t __cacheline_aligned pagecache_lock = SPIN_LOCK_UNLOCKED;
 /*
  * NOTE: to avoid deadlocking you must never acquire the pagecache_lock with
  *       the pagemap_lru_lock held.
  */
-spinlock_t pagemap_lru_lock = SPIN_LOCK_UNLOCKED;
+spinlock_t __cacheline_aligned pagemap_lru_lock = SPIN_LOCK_UNLOCKED;
 
 #define CLUSTER_PAGES		(1 << page_cluster)
 #define CLUSTER_OFFSET(x)	(((x) >> page_cluster) << page_cluster)
diff -urN linux-2.4.9-pre4/mm/highmem.c linux/mm/highmem.c
--- linux-2.4.9-pre4/mm/highmem.c	Tue Aug  7 00:18:00 2001
+++ linux/mm/highmem.c	Mon Dec  3 23:03:38 2001
@@ -46,7 +46,7 @@
 
 	for (i = 0; i < LAST_PKMAP; i++) {
 		struct page *page;
-		pte_t pte;
+
 		/*
 		 * zero means we don't have anything to do,
 		 * >1 means that it is still in use. Only
@@ -56,10 +56,21 @@
 		if (pkmap_count[i] != 1)
 			continue;
 		pkmap_count[i] = 0;
-		pte = ptep_get_and_clear(pkmap_page_table+i);
-		if (pte_none(pte))
+
+		/* sanity check */
+		if (pte_none(pkmap_page_table[i]))
 			BUG();
-		page = pte_page(pte);
+
+		/*
+		 * Don't need an atomic fetch-and-clear op here;
+		 * no-one has the page mapped, and cannot get at
+		 * its virtual address (and hence PTE) without first
+		 * getting the kmap_lock (which is held here).
+		 * So no dangers, even with speculative execution.
+		 */
+		page = pte_page(pkmap_page_table[i]);
+		pte_clear(&pkmap_page_table[i]);
+
 		page->virtual = NULL;
 	}
 	flush_tlb_all();
@@ -139,6 +150,7 @@
 {
 	unsigned long vaddr;
 	unsigned long nr;
+	int need_wakeup;
 
 	spin_lock(&kmap_lock);
 	vaddr = (unsigned long) page->virtual;
@@ -150,13 +162,28 @@
 	 * A count must never go down to zero
 	 * without a TLB flush!
 	 */
+	need_wakeup = 0;
 	switch (--pkmap_count[nr]) {
 	case 0:
 		BUG();
 	case 1:
-		wake_up(&pkmap_map_wait);
+		/*
+		 * Avoid an unnecessary wake_up() function call.
+		 * The common case is pkmap_count[] == 1, but
+		 * no waiters.
+		 * The tasks queued in the wait-queue are guarded
+		 * by both the lock in the wait-queue-head and by
+		 * the kmap_lock.  As the kmap_lock is held here,
+		 * no need for the wait-queue-head's lock.  Simply
+		 * test if the queue is empty.
+		 */
+		need_wakeup = waitqueue_active(&pkmap_map_wait);
 	}
 	spin_unlock(&kmap_lock);
+
+	/* do wake-up, if needed, race-free outside of the spin lock */
+	if (need_wakeup)
+		wake_up(&pkmap_map_wait);
 }
 
 #define POOL_SIZE 32
@@ -182,20 +209,12 @@
 {
 	struct page *p_from;
 	char *vfrom;
-	unsigned long flags;
 
 	p_from = from->b_page;
 
-	/*
-	 * Since this can be executed from IRQ context, reentrance
-	 * on the same CPU must be avoided:
-	 */
-	__save_flags(flags);
-	__cli();
 	vfrom = kmap_atomic(p_from, KM_BOUNCE_WRITE);
 	memcpy(to->b_data, vfrom + bh_offset(from), to->b_size);
 	kunmap_atomic(vfrom, KM_BOUNCE_WRITE);
-	__restore_flags(flags);
 }
 
 static inline void copy_to_high_bh_irq (struct buffer_head *to,
diff -urN linux-2.4.9-pre4/mm/vmscan.c linux/mm/vmscan.c
--- linux-2.4.9-pre4/mm/vmscan.c	Mon Dec  3 23:03:29 2001
+++ linux/mm/vmscan.c	Mon Dec  3 23:03:38 2001
@@ -788,6 +788,9 @@
 			zone_t *zone = pgdat->node_zones + i;
 			unsigned int inactive;
 
+			if (!zone->size)
+				continue;
+
 			inactive  = zone->inactive_dirty_pages;
 			inactive += zone->inactive_clean_pages;
 			inactive += zone->free_pages;
diff -urN linux-2.4.9-pre4/net/appletalk/ddp.c linux/net/appletalk/ddp.c
--- linux-2.4.9-pre4/net/appletalk/ddp.c	Thu Apr 12 12:11:39 2001
+++ linux/net/appletalk/ddp.c	Mon Dec  3 23:03:38 2001
@@ -113,8 +113,6 @@
 struct datalink_proto *ddp_dl, *aarp_dl;
 static struct proto_ops atalk_dgram_ops;
 
-#define min(a,b)	(((a)<(b))?(a):(b))
-
 /**************************************************************************\
 *                                                                          *
 * Handlers for the socket list.                                            *
@@ -1392,7 +1390,7 @@
 
 	/* Trim buffer in case of stray trailing data */
 	origlen = skb->len;
-	skb_trim(skb, min(skb->len, ddphv.deh_len));
+	skb_trim(skb, min(unsigned int, skb->len, ddphv.deh_len));
 
 	/*
 	 * Size check to see if ddp->deh_len was crap
@@ -1457,7 +1455,7 @@
 		}
 
                 /* Fix up skb->len field */
-                skb_trim(skb, min(origlen, rt->dev->hard_header_len +
+                skb_trim(skb, min(unsigned int, origlen, rt->dev->hard_header_len +
 			ddp_dl->header_length + ddphv.deh_len));
 
 		/* Mend the byte order */
diff -urN linux-2.4.9-pre4/net/ax25/af_ax25.c linux/net/ax25/af_ax25.c
--- linux-2.4.9-pre4/net/ax25/af_ax25.c	Thu Apr 12 12:11:39 2001
+++ linux/net/ax25/af_ax25.c	Mon Dec  3 23:03:38 2001
@@ -751,7 +751,7 @@
 		return -EFAULT;
 
 	valptr = (void *) &val;
-	length = min(maxlen, sizeof(int));
+	length = min(unsigned int, maxlen, sizeof(int));
 
 	switch (optname) {
 		case AX25_WINDOW:
@@ -803,7 +803,7 @@
 
 			if (ax25_dev != NULL && ax25_dev->dev != NULL) {
 				strncpy(devname, ax25_dev->dev->name, IFNAMSIZ);
-				length = min(strlen(ax25_dev->dev->name)+1, maxlen);
+				length = min(unsigned int, strlen(ax25_dev->dev->name)+1, maxlen);
 				devname[length-1] = '\0';
 			} else {
 				*devname = '\0';
diff -urN linux-2.4.9-pre4/net/bridge/br_device.c linux/net/bridge/br_device.c
--- linux-2.4.9-pre4/net/bridge/br_device.c	Mon Jun 11 19:15:27 2001
+++ linux/net/bridge/br_device.c	Mon Dec  3 23:03:38 2001
@@ -5,7 +5,7 @@
  *	Authors:
  *	Lennert Buytenhek		<buytenh@gnu.org>
  *
- *	$Id: br_device.c,v 1.4 2001/06/01 09:28:28 davem Exp $
+ *	$Id: br_device.c,v 1.5 2001/08/14 22:05:57 davem Exp $
  *
  *	This program is free software; you can redistribute it and/or
  *	modify it under the terms of the GNU General Public License
@@ -53,7 +53,8 @@
 	br->statistics.tx_packets++;
 	br->statistics.tx_bytes += skb->len;
 
-	dest = skb->data;
+	dest = skb->mac.raw = skb->data;
+	skb_pull(skb, ETH_HLEN);
 
 	if (dest[0] & 1) {
 		br_flood_deliver(br, skb, 0);
diff -urN linux-2.4.9-pre4/net/bridge/br_forward.c linux/net/bridge/br_forward.c
--- linux-2.4.9-pre4/net/bridge/br_forward.c	Mon Jun 11 19:15:27 2001
+++ linux/net/bridge/br_forward.c	Mon Dec  3 23:03:38 2001
@@ -5,7 +5,7 @@
  *	Authors:
  *	Lennert Buytenhek		<buytenh@gnu.org>
  *
- *	$Id: br_forward.c,v 1.3 2001/06/01 09:28:28 davem Exp $
+ *	$Id: br_forward.c,v 1.4 2001/08/14 22:05:57 davem Exp $
  *
  *	This program is free software; you can redistribute it and/or
  *	modify it under the terms of the GNU General Public License
@@ -30,10 +30,18 @@
 	return 1;
 }
 
+static int __dev_queue_push_xmit(struct sk_buff *skb)
+{
+	skb_push(skb, ETH_HLEN);
+	dev_queue_xmit(skb);
+
+	return 0;
+}
+
 static int __br_forward_finish(struct sk_buff *skb)
 {
 	NF_HOOK(PF_BRIDGE, NF_BR_POST_ROUTING, skb, NULL, skb->dev,
-			dev_queue_xmit);
+			__dev_queue_push_xmit);
 
 	return 0;
 }
diff -urN linux-2.4.9-pre4/net/bridge/br_input.c linux/net/bridge/br_input.c
--- linux-2.4.9-pre4/net/bridge/br_input.c	Mon Jun 11 19:15:27 2001
+++ linux/net/bridge/br_input.c	Mon Dec  3 23:03:38 2001
@@ -5,7 +5,7 @@
  *	Authors:
  *	Lennert Buytenhek		<buytenh@gnu.org>
  *
- *	$Id: br_input.c,v 1.8 2001/06/01 09:28:28 davem Exp $
+ *	$Id: br_input.c,v 1.9 2001/08/14 22:05:57 davem Exp $
  *
  *	This program is free software; you can redistribute it and/or
  *	modify it under the terms of the GNU General Public License
@@ -39,7 +39,7 @@
 	indev = skb->dev;
 	skb->dev = &br->dev;
 	skb->pkt_type = PACKET_HOST;
-	skb_pull(skb, skb->mac.raw - skb->data);
+	skb_push(skb, ETH_HLEN);
 	skb->protocol = eth_type_trans(skb, &br->dev);
 
 	NF_HOOK(PF_BRIDGE, NF_BR_LOCAL_IN, skb, indev, NULL,
@@ -63,8 +63,6 @@
 	if (!(br->dev.flags & IFF_UP) ||
 	    p->state == BR_STATE_DISABLED)
 		goto freeandout;
-
-	skb_push(skb, skb->data - skb->mac.raw);
 
 	if (br->dev.flags & IFF_PROMISC) {
 		struct sk_buff *skb2;
diff -urN linux-2.4.9-pre4/net/core/iovec.c linux/net/core/iovec.c
--- linux-2.4.9-pre4/net/core/iovec.c	Thu Apr 12 12:11:39 2001
+++ linux/net/core/iovec.c	Mon Dec  3 23:03:38 2001
@@ -87,7 +87,7 @@
 	{
 		if(iov->iov_len)
 		{
-			int copy = min(iov->iov_len, len);
+			int copy = min(unsigned int, iov->iov_len, len);
 			if (copy_to_user(iov->iov_base, kdata, copy))
 				goto out;
 			kdata+=copy;
@@ -114,7 +114,7 @@
 	{
 		if(iov->iov_len)
 		{
-			int copy = min(iov->iov_len, len);
+			int copy = min(unsigned int, iov->iov_len, len);
 			memcpy(iov->iov_base, kdata, copy);
 			kdata+=copy;
 			len-=copy;
@@ -140,7 +140,7 @@
 	{
 		if(iov->iov_len)
 		{
-			int copy = min(len, iov->iov_len);
+			int copy = min(unsigned int, len, iov->iov_len);
 			if (copy_from_user(kdata, iov->iov_base, copy))
 				goto out;
 			len-=copy;
@@ -175,7 +175,7 @@
 	while (len > 0)
 	{
 		u8 *base = iov->iov_base + offset;
-		int copy = min(len, iov->iov_len - offset);
+		int copy = min(unsigned int, len, iov->iov_len - offset);
 
 		offset = 0;
 		if (copy_from_user(kdata, base, copy))
@@ -214,7 +214,7 @@
 	while (len > 0)
 	{
 		u8 *base = iov->iov_base + offset;
-		unsigned int copy = min(len, iov->iov_len - offset);
+		int copy = min(unsigned int, len, iov->iov_len - offset);
 
 		offset = 0;
 		/* There is a remnant from previous iov. */
diff -urN linux-2.4.9-pre4/net/ipv4/ip_sockglue.c linux/net/ipv4/ip_sockglue.c
--- linux-2.4.9-pre4/net/ipv4/ip_sockglue.c	Thu Apr 12 12:11:39 2001
+++ linux/net/ipv4/ip_sockglue.c	Mon Dec  3 23:03:38 2001
@@ -5,7 +5,7 @@
  *
  *		The IP to API glue.
  *		
- * Version:	$Id: ip_sockglue.c,v 1.56 2001/02/18 09:07:58 davem Exp $
+ * Version:	$Id: ip_sockglue.c,v 1.59 2001/08/13 18:56:12 davem Exp $
  *
  * Authors:	see ip.c
  *
@@ -43,8 +43,6 @@
 #include <linux/errqueue.h>
 #include <asm/uaccess.h>
 
-#define MAX(a,b) ((a)>(b)?(a):(b))
-
 #define IP_CMSG_PKTINFO		1
 #define IP_CMSG_TTL		2
 #define IP_CMSG_TOS		4
@@ -685,7 +683,7 @@
 
 				ip_options_undo(opt);
 
-				len=min(len, opt->optlen);
+				len = min(unsigned int, len, opt->optlen);
 				if(put_user(len, optlen))
 					return -EFAULT;
 				if(copy_to_user(optval, opt->__data, len))
@@ -746,7 +744,7 @@
 		case IP_MULTICAST_IF:
 		{
 			struct in_addr addr;
-			len = min(len,sizeof(struct in_addr));
+			len = min(unsigned int, len, sizeof(struct in_addr));
 			addr.s_addr = sk->protinfo.af_inet.mc_addr;
 			release_sock(sk);
 
@@ -810,7 +808,7 @@
 		if(copy_to_user(optval,&ucval,1))
 			return -EFAULT;
 	} else {
-		len=min(sizeof(int),len);
+		len = min(unsigned int, sizeof(int), len);
 		if(put_user(len, optlen))
 			return -EFAULT;
 		if(copy_to_user(optval,&val,len))
diff -urN linux-2.4.9-pre4/net/ipv4/ipmr.c linux/net/ipv4/ipmr.c
--- linux-2.4.9-pre4/net/ipv4/ipmr.c	Fri Jun 29 19:38:26 2001
+++ linux/net/ipv4/ipmr.c	Mon Dec  3 23:03:38 2001
@@ -9,7 +9,7 @@
  *	as published by the Free Software Foundation; either version
  *	2 of the License, or (at your option) any later version.
  *
- *	Version: $Id: ipmr.c,v 1.60 2001/06/29 21:33:22 davem Exp $
+ *	Version: $Id: ipmr.c,v 1.63 2001/08/13 18:56:12 davem Exp $
  *
  *	Fixes:
  *	Michael Chastain	:	Incorrect size of copying.
@@ -976,11 +976,11 @@
 	   optname!=MRT_ASSERT)
 		return -ENOPROTOOPT;
 
-	if(get_user(olr, optlen))
+	if (get_user(olr, optlen))
 		return -EFAULT;
 
-	olr=min(olr,sizeof(int));
-	if(olr<0)
+	olr = min(unsigned int, olr, sizeof(int));
+	if (olr < 0)
 		return -EINVAL;
 		
 	if(put_user(olr,optlen))
diff -urN linux-2.4.9-pre4/net/ipv4/netfilter/ipchains_core.c linux/net/ipv4/netfilter/ipchains_core.c
--- linux-2.4.9-pre4/net/ipv4/netfilter/ipchains_core.c	Thu Apr 12 12:11:39 2001
+++ linux/net/ipv4/netfilter/ipchains_core.c	Mon Dec  3 23:03:38 2001
@@ -534,7 +534,7 @@
 	}
 	if (f->ipfw.fw_flg & IP_FW_F_NETLINK) {
 #if defined(CONFIG_NETLINK_DEV) || defined(CONFIG_NETLINK_DEV_MODULE)
-		size_t len = min(f->ipfw.fw_outputsize, ntohs(ip->tot_len))
+		size_t len = min(unsigned int, f->ipfw.fw_outputsize, ntohs(ip->tot_len))
 			+ sizeof(__u32) + sizeof(skb->nfmark) + IFNAMSIZ;
 		struct sk_buff *outskb=alloc_skb(len, GFP_ATOMIC);
 
diff -urN linux-2.4.9-pre4/net/ipv4/netfilter/ipfwadm_core.c linux/net/ipv4/netfilter/ipfwadm_core.c
--- linux-2.4.9-pre4/net/ipv4/netfilter/ipfwadm_core.c	Mon Jun 11 19:15:27 2001
+++ linux/net/ipv4/netfilter/ipfwadm_core.c	Mon Dec  3 23:03:38 2001
@@ -20,7 +20,7 @@
  *	license in recognition of the original copyright.
  *				-- Alan Cox.
  *
- *	$Id: ipfwadm_core.c,v 1.5 2001/06/01 14:56:53 davem Exp $
+ *	$Id: ipfwadm_core.c,v 1.8 2001/08/13 18:56:12 davem Exp $
  *
  *	Ported from BSD to Linux,
  *		Alan Cox 22/Nov/1994.
@@ -648,7 +648,9 @@
 			struct sk_buff *skb=alloc_skb(128, GFP_ATOMIC);
 			if(skb)
 			{
-				int len=min(128,ntohs(ip->tot_len));
+				int len = min(unsigned int,
+					      128, ntohs(ip->tot_len));
+
 				skb_put(skb,len);
 				memcpy(skb->data,ip,len);
 				if(netlink_post(NETLINK_FIREWALL, skb))
diff -urN linux-2.4.9-pre4/net/ipv4/route.c linux/net/ipv4/route.c
--- linux-2.4.9-pre4/net/ipv4/route.c	Thu Jul 19 18:11:13 2001
+++ linux/net/ipv4/route.c	Mon Dec  3 23:03:38 2001
@@ -5,7 +5,7 @@
  *
  *		ROUTE - implementation of the IP router.
  *
- * Version:	$Id: route.c,v 1.95 2001/07/10 22:32:51 davem Exp $
+ * Version:	$Id: route.c,v 1.98 2001/08/13 18:56:12 davem Exp $
  *
  * Authors:	Ross Biro, <bir7@leland.Stanford.Edu>
  *		Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
@@ -515,14 +515,14 @@
 			equilibrium = ipv4_dst_ops.gc_thresh;
 		goal = atomic_read(&ipv4_dst_ops.entries) - equilibrium;
 		if (goal > 0) {
-			equilibrium += min(goal / 2, rt_hash_mask + 1);
+			equilibrium += min(unsigned int, goal / 2, rt_hash_mask + 1);
 			goal = atomic_read(&ipv4_dst_ops.entries) - equilibrium;
 		}
 	} else {
 		/* We are in dangerous area. Try to reduce cache really
 		 * aggressively.
 		 */
-		goal = max(goal / 2, rt_hash_mask + 1);
+		goal = max(unsigned int, goal / 2, rt_hash_mask + 1);
 		equilibrium = atomic_read(&ipv4_dst_ops.entries) - goal;
 	}
 
@@ -1207,8 +1207,8 @@
 	if (rt->u.dst.pmtu > IP_MAX_MTU)
 		rt->u.dst.pmtu = IP_MAX_MTU;
 	if (rt->u.dst.advmss == 0)
-		rt->u.dst.advmss = max(rt->u.dst.dev->mtu - 40,
-					ip_rt_min_advmss);
+		rt->u.dst.advmss = max(unsigned int, rt->u.dst.dev->mtu - 40,
+				       ip_rt_min_advmss);
 	if (rt->u.dst.advmss > 65535 - 40)
 		rt->u.dst.advmss = 65535 - 40;
 
diff -urN linux-2.4.9-pre4/net/ipv4/tcp.c linux/net/ipv4/tcp.c
--- linux-2.4.9-pre4/net/ipv4/tcp.c	Wed May 16 10:31:27 2001
+++ linux/net/ipv4/tcp.c	Mon Dec  3 23:03:38 2001
@@ -5,7 +5,7 @@
  *
  *		Implementation of the Transmission Control Protocol(TCP).
  *
- * Version:	$Id: tcp.c,v 1.205 2001/05/05 22:25:30 davem Exp $
+ * Version:	$Id: tcp.c,v 1.208 2001/08/13 18:56:12 davem Exp $
  *
  * Authors:	Ross Biro, <bir7@leland.Stanford.Edu>
  *		Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
@@ -852,7 +852,7 @@
 
 		page = pages[poffset/PAGE_SIZE];
 		offset = poffset % PAGE_SIZE;
-		size = min(psize, PAGE_SIZE-offset);
+		size = min(unsigned int, psize, PAGE_SIZE-offset);
 
 		if (tp->send_head==NULL || (copy = mss_now - skb->len) <= 0) {
 new_segment:
@@ -2326,7 +2326,7 @@
 	if(get_user(len,optlen))
 		return -EFAULT;
 
-	len = min(len, sizeof(int));
+	len = min(unsigned int, len, sizeof(int));
 	
 	if(len < 0)
 		return -EINVAL;
@@ -2421,7 +2421,7 @@
 		info.tcpi_advmss = tp->advmss;
 		info.tcpi_reordering = tp->reordering;
 
-		len = min(len, sizeof(info));
+		len = min(unsigned int, len, sizeof(info));
 		if(put_user(len, optlen))
 			return -EFAULT;
 		if(copy_to_user(optval, &info,len))
diff -urN linux-2.4.9-pre4/net/ipv4/tcp_input.c linux/net/ipv4/tcp_input.c
--- linux-2.4.9-pre4/net/ipv4/tcp_input.c	Mon Jun 11 19:15:27 2001
+++ linux/net/ipv4/tcp_input.c	Mon Dec  3 23:03:38 2001
@@ -5,7 +5,7 @@
  *
  *		Implementation of the Transmission Control Protocol(TCP).
  *
- * Version:	$Id: tcp_input.c,v 1.232 2001/05/24 22:32:49 davem Exp $
+ * Version:	$Id: tcp_input.c,v 1.235 2001/08/13 18:56:12 davem Exp $
  *
  * Authors:	Ross Biro, <bir7@leland.Stanford.Edu>
  *		Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
@@ -168,7 +168,7 @@
 	if (quickacks==0)
 		quickacks=2;
 	if (quickacks > tp->ack.quick)
-		tp->ack.quick = min(quickacks, TCP_MAX_QUICKACKS);
+		tp->ack.quick = min(unsigned int, quickacks, TCP_MAX_QUICKACKS);
 }
 
 void tcp_enter_quickack_mode(struct tcp_opt *tp)
@@ -198,7 +198,7 @@
 	int sndmem = tp->mss_clamp+MAX_TCP_HEADER+16+sizeof(struct sk_buff);
 
 	if (sk->sndbuf < 3*sndmem)
-		sk->sndbuf = min(3*sndmem, sysctl_tcp_wmem[2]);
+		sk->sndbuf = min(int, 3*sndmem, sysctl_tcp_wmem[2]);
 }
 
 /* 2. Tuning advertised window (window_clamp, rcv_ssthresh)
@@ -262,7 +262,7 @@
 			incr = __tcp_grow_window(sk, tp, skb);
 
 		if (incr) {
-			tp->rcv_ssthresh = min(tp->rcv_ssthresh + incr, tp->window_clamp);
+			tp->rcv_ssthresh = min(u32, tp->rcv_ssthresh + incr, tp->window_clamp);
 			tp->ack.quick |= 1;
 		}
 	}
@@ -282,7 +282,7 @@
 	while (tcp_win_from_space(rcvmem) < tp->advmss)
 		rcvmem += 128;
 	if (sk->rcvbuf < 4*rcvmem)
-		sk->rcvbuf = min(4*rcvmem, sysctl_tcp_rmem[2]);
+		sk->rcvbuf = min(int, 4*rcvmem, sysctl_tcp_rmem[2]);
 }
 
 /* 4. Try to fixup all. It is made iimediately after connection enters
@@ -304,16 +304,16 @@
 		tp->window_clamp = maxwin;
 
 		if (sysctl_tcp_app_win && maxwin>4*tp->advmss)
-			tp->window_clamp = max(maxwin-(maxwin>>sysctl_tcp_app_win), 4*tp->advmss);
+			tp->window_clamp = max(u32, maxwin-(maxwin>>sysctl_tcp_app_win), 4*tp->advmss);
 	}
 
 	/* Force reservation of one segment. */
 	if (sysctl_tcp_app_win &&
 	    tp->window_clamp > 2*tp->advmss &&
 	    tp->window_clamp + tp->advmss > maxwin)
-		tp->window_clamp = max(2*tp->advmss, maxwin-tp->advmss);
+		tp->window_clamp = max(u32, 2*tp->advmss, maxwin-tp->advmss);
 
-	tp->rcv_ssthresh = min(tp->rcv_ssthresh, tp->window_clamp);
+	tp->rcv_ssthresh = min(u32, tp->rcv_ssthresh, tp->window_clamp);
 	tp->snd_cwnd_stamp = tcp_time_stamp;
 }
 
@@ -338,7 +338,7 @@
 		    !(sk->userlocks&SOCK_RCVBUF_LOCK) &&
 		    !tcp_memory_pressure &&
 		    atomic_read(&tcp_memory_allocated) < sysctl_tcp_mem[0])
-			sk->rcvbuf = min(atomic_read(&sk->rmem_alloc), sysctl_tcp_rmem[2]);
+			sk->rcvbuf = min(int, atomic_read(&sk->rmem_alloc), sysctl_tcp_rmem[2]);
 	}
 	if (atomic_read(&sk->rmem_alloc) > sk->rcvbuf) {
 		app_win += ofo_win;
@@ -346,11 +346,11 @@
 			app_win >>= 1;
 		if (app_win > tp->ack.rcv_mss)
 			app_win -= tp->ack.rcv_mss;
-		app_win = max(app_win, 2*tp->advmss);
+		app_win = max(unsigned int, app_win, 2*tp->advmss);
 
 		if (!ofo_win)
-			tp->window_clamp = min(tp->window_clamp, app_win);
-		tp->rcv_ssthresh = min(tp->window_clamp, 2*tp->advmss);
+			tp->window_clamp = min(u32, tp->window_clamp, app_win);
+		tp->rcv_ssthresh = min(u32, tp->window_clamp, 2*tp->advmss);
 	}
 }
 
@@ -472,7 +472,7 @@
 		/* no previous measure. */
 		tp->srtt = m<<3;	/* take the measured time to be rtt */
 		tp->mdev = m<<2;	/* make sure rto = 3*rtt */
-		tp->mdev_max = tp->rttvar = max(tp->mdev, TCP_RTO_MIN);
+		tp->mdev_max = tp->rttvar = max(u32, tp->mdev, TCP_RTO_MIN);
 		tp->rtt_seq = tp->snd_nxt;
 	}
 }
@@ -575,7 +575,7 @@
 			   tp->ca_state == TCP_CA_Open) {
 			/* Cong. avoidance phase, cwnd is reliable. */
 			if (!(dst->mxlock&(1<<RTAX_SSTHRESH)))
-				dst->ssthresh = max(tp->snd_cwnd>>1, tp->snd_ssthresh);
+				dst->ssthresh = max(u32, tp->snd_cwnd>>1, tp->snd_ssthresh);
 			if (!(dst->mxlock&(1<<RTAX_CWND)))
 				dst->cwnd = (dst->cwnd + tp->snd_cwnd)>>1;
 		} else {
@@ -617,7 +617,7 @@
 	else if (cwnd > tp->snd_ssthresh)
 		cwnd = tp->snd_ssthresh;
 
-	return min(cwnd, tp->snd_cwnd_clamp);
+	return min(u32, cwnd, tp->snd_cwnd_clamp);
 }
 
 /* Initialize metrics on socket. */
@@ -668,7 +668,7 @@
 		tp->srtt = dst->rtt;
 	if (dst->rttvar > tp->mdev) {
 		tp->mdev = dst->rttvar;
-		tp->mdev_max = tp->rttvar = max(tp->mdev, TCP_RTO_MIN);
+		tp->mdev_max = tp->rttvar = max(u32, tp->mdev, TCP_RTO_MIN);
 	}
 	tcp_set_rto(tp);
 	tcp_bound_rto(tp);
@@ -693,7 +693,7 @@
 static void tcp_update_reordering(struct tcp_opt *tp, int metric, int ts)
 {
 	if (metric > tp->reordering) {
-		tp->reordering = min(TCP_MAX_REORDERING, metric);
+		tp->reordering = min(unsigned int, TCP_MAX_REORDERING, metric);
 
 		/* This exciting event is worth to be remembered. 8) */
 		if (ts)
@@ -848,12 +848,12 @@
 				if (sacked&TCPCB_RETRANS) {
 					if ((dup_sack && in_sack) &&
 					    (sacked&TCPCB_SACKED_ACKED))
-						reord = min(fack_count, reord);
+						reord = min(int, fack_count, reord);
 				} else {
 					/* If it was in a hole, we detected reordering. */
 					if (fack_count < prior_fackets &&
 					    !(sacked&TCPCB_SACKED_ACKED))
-						reord = min(fack_count, reord);
+						reord = min(int, fack_count, reord);
 				}
 
 				/* Nothing to do; acked frame is about to be dropped. */
@@ -885,7 +885,7 @@
 					 */
 					if (!(sacked & TCPCB_RETRANS) &&
 					    fack_count < prior_fackets)
-						reord = min(fack_count, reord);
+						reord = min(int, fack_count, reord);
 
 					if (sacked & TCPCB_LOST) {
 						TCP_SKB_CB(skb)->sacked &= ~TCPCB_LOST;
@@ -901,7 +901,7 @@
 					tp->fackets_out = fack_count;
 			} else {
 				if (dup_sack && (sacked&TCPCB_RETRANS))
-					reord = min(fack_count, reord);
+					reord = min(int, fack_count, reord);
 			}
 
 			/* D-SACK. We can detect redundant retransmission
@@ -1019,7 +1019,7 @@
 	}
 	tcp_sync_left_out(tp);
 
-	tp->reordering = min(tp->reordering, sysctl_tcp_reordering);
+	tp->reordering = min(unsigned int, tp->reordering, sysctl_tcp_reordering);
 	tp->ca_state = TCP_CA_Loss;
 	tp->high_seq = tp->snd_nxt;
 	TCP_ECN_queue_cwr(tp);
@@ -1177,7 +1177,7 @@
 	 * recovery more?
 	 */
 	if (tp->packets_out <= tp->reordering &&
-	    tp->sacked_out >= max(tp->packets_out/2, sysctl_tcp_reordering) &&
+	    tp->sacked_out >= max(u32, tp->packets_out/2, sysctl_tcp_reordering) &&
 	    !tcp_may_send_now(sk, tp)) {
 		/* We have nothing to send. This connection is limited
 		 * either by receiver window or by application.
@@ -1194,7 +1194,9 @@
  */
 static void tcp_check_reno_reordering(struct tcp_opt *tp, int addend)
 {
-	int holes = min(max(tp->lost_out, 1), tp->packets_out);
+	u32 holes = min(unsigned int,
+			max(unsigned int, tp->lost_out, 1),
+			tp->packets_out);
 
 	if (tp->sacked_out + holes > tp->packets_out) {
 		tp->sacked_out = tp->packets_out - holes;
@@ -1289,7 +1291,7 @@
  */
 static __inline__ void tcp_moderate_cwnd(struct tcp_opt *tp)
 {
-	tp->snd_cwnd = min(tp->snd_cwnd,
+	tp->snd_cwnd = min(u32, tp->snd_cwnd,
 			   tcp_packets_in_flight(tp)+tcp_max_burst(tp));
 	tp->snd_cwnd_stamp = tcp_time_stamp;
 }
@@ -1306,7 +1308,7 @@
 	if (decr && tp->snd_cwnd > tp->snd_ssthresh/2)
 		tp->snd_cwnd -= decr;
 
-	tp->snd_cwnd = min(tp->snd_cwnd, tcp_packets_in_flight(tp)+1);
+	tp->snd_cwnd = min(u32, tp->snd_cwnd, tcp_packets_in_flight(tp)+1);
 	tp->snd_cwnd_stamp = tcp_time_stamp;
 }
 
@@ -1338,13 +1340,15 @@
 static void tcp_undo_cwr(struct tcp_opt *tp, int undo)
 {
 	if (tp->prior_ssthresh) {
-		tp->snd_cwnd = max(tp->snd_cwnd, tp->snd_ssthresh<<1);
+		tp->snd_cwnd = max(unsigned int,
+				   tp->snd_cwnd, tp->snd_ssthresh<<1);
+
 		if (undo && tp->prior_ssthresh > tp->snd_ssthresh) {
 			tp->snd_ssthresh = tp->prior_ssthresh;
 			TCP_ECN_withdraw_cwr(tp);
 		}
 	} else {
-		tp->snd_cwnd = max(tp->snd_cwnd, tp->snd_ssthresh);
+		tp->snd_cwnd = max(unsigned int, tp->snd_cwnd, tp->snd_ssthresh);
 	}
 	tcp_moderate_cwnd(tp);
 	tp->snd_cwnd_stamp = tcp_time_stamp;
@@ -1446,7 +1450,7 @@
 
 static __inline__ void tcp_complete_cwr(struct tcp_opt *tp)
 {
-	tp->snd_cwnd = min(tp->snd_cwnd, tp->snd_ssthresh);
+	tp->snd_cwnd = min(u32, tp->snd_cwnd, tp->snd_ssthresh);
 	tp->snd_cwnd_stamp = tcp_time_stamp;
 }
 
@@ -1832,7 +1836,7 @@
 		 */
 	} else {
 		tcp_reset_xmit_timer(sk, TCP_TIME_PROBE0,
-				     min(tp->rto << tp->backoff, TCP_RTO_MAX));
+				     min(u32, tp->rto << tp->backoff, TCP_RTO_MAX));
 	}
 }
 
@@ -2319,7 +2323,7 @@
 		tp->dsack = 1;
 		tp->duplicate_sack[0].start_seq = seq;
 		tp->duplicate_sack[0].end_seq = end_seq;
-		tp->eff_sacks = min(tp->num_sacks+1, 4-tp->tstamp_ok);
+		tp->eff_sacks = min(unsigned int, tp->num_sacks+1, 4-tp->tstamp_ok);
 	}
 }
 
@@ -2372,7 +2376,7 @@
 			 * Decrease num_sacks.
 			 */
 			tp->num_sacks--;
-			tp->eff_sacks = min(tp->num_sacks+tp->dsack, 4-tp->tstamp_ok);
+			tp->eff_sacks = min(unsigned int, tp->num_sacks+tp->dsack, 4-tp->tstamp_ok);
 			for(i=this_sack; i < tp->num_sacks; i++)
 				sp[i] = sp[i+1];
 			continue;
@@ -2434,7 +2438,7 @@
 	sp->start_seq = seq;
 	sp->end_seq = end_seq;
 	tp->num_sacks++;
-	tp->eff_sacks = min(tp->num_sacks+tp->dsack, 4-tp->tstamp_ok);
+	tp->eff_sacks = min(unsigned int, tp->num_sacks+tp->dsack, 4-tp->tstamp_ok);
 }
 
 /* RCV.NXT advances, some SACKs should be eaten. */
@@ -2471,7 +2475,7 @@
 	}
 	if (num_sacks != tp->num_sacks) {
 		tp->num_sacks = num_sacks;
-		tp->eff_sacks = min(tp->num_sacks+tp->dsack, 4-tp->tstamp_ok);
+		tp->eff_sacks = min(unsigned int, tp->num_sacks+tp->dsack, 4-tp->tstamp_ok);
 	}
 }
 
@@ -2537,7 +2541,7 @@
 
 	if (tp->dsack) {
 		tp->dsack = 0;
-		tp->eff_sacks = min(tp->num_sacks, 4-tp->tstamp_ok);
+		tp->eff_sacks = min(unsigned int, tp->num_sacks, 4-tp->tstamp_ok);
 	}
 
 	/*  Queue data for delivery to the user.
@@ -2554,7 +2558,7 @@
 		    tp->ucopy.len &&
 		    sk->lock.users &&
 		    !tp->urg_data) {
-			int chunk = min(skb->len, tp->ucopy.len);
+			int chunk = min(unsigned int, skb->len, tp->ucopy.len);
 
 			__set_current_state(TASK_RUNNING);
 
@@ -2803,7 +2807,7 @@
 
 			if (offset < 0) BUG();
 			if (size > 0) {
-				size = min(copy, size);
+				size = min(int, copy, size);
 				if (skb_copy_bits(skb, offset, skb_put(nskb, size), size))
 					BUG();
 				TCP_SKB_CB(nskb)->end_seq += size;
@@ -2882,7 +2886,7 @@
 	if (atomic_read(&sk->rmem_alloc) >= sk->rcvbuf)
 		tcp_clamp_window(sk, tp);
 	else if (tcp_memory_pressure)
-		tp->rcv_ssthresh = min(tp->rcv_ssthresh, 4*tp->advmss);
+		tp->rcv_ssthresh = min(u32, tp->rcv_ssthresh, 4*tp->advmss);
 
 	tcp_collapse_ofo_queue(sk);
 	tcp_collapse(sk, sk->receive_queue.next,
@@ -2937,7 +2941,7 @@
 	if (tp->ca_state == TCP_CA_Open &&
 	    sk->socket && !test_bit(SOCK_NOSPACE, &sk->socket->flags)) {
 		/* Limited by application or receiver window. */
-		u32 win_used = max(tp->snd_cwnd_used, 2);
+		u32 win_used = max(u32, tp->snd_cwnd_used, 2);
 		if (win_used < tp->snd_cwnd) {
 			tp->snd_ssthresh = tcp_current_ssthresh(tp);
 			tp->snd_cwnd = (tp->snd_cwnd+win_used)>>1;
@@ -2963,10 +2967,10 @@
 		int sndmem, demanded;
 
 		sndmem = tp->mss_clamp+MAX_TCP_HEADER+16+sizeof(struct sk_buff);
-		demanded = max(tp->snd_cwnd, tp->reordering+1);
+		demanded = max(unsigned int, tp->snd_cwnd, tp->reordering+1);
 		sndmem *= 2*demanded;
 		if (sndmem > sk->sndbuf)
-			sk->sndbuf = min(sndmem, sysctl_tcp_wmem[2]);
+			sk->sndbuf = min(int, sndmem, sysctl_tcp_wmem[2]);
 		tp->snd_cwnd_stamp = tcp_time_stamp;
 	}
 
@@ -3516,7 +3520,7 @@
 
 		if (tp->wscale_ok == 0) {
 			tp->snd_wscale = tp->rcv_wscale = 0;
-			tp->window_clamp = min(tp->window_clamp,65535);
+			tp->window_clamp = min(u32, tp->window_clamp, 65535);
 		}
 
 		if (tp->saw_tstamp) {
diff -urN linux-2.4.9-pre4/net/ipv4/tcp_minisocks.c linux/net/ipv4/tcp_minisocks.c
--- linux-2.4.9-pre4/net/ipv4/tcp_minisocks.c	Tue Aug  7 08:30:50 2001
+++ linux/net/ipv4/tcp_minisocks.c	Mon Dec  3 23:03:38 2001
@@ -5,7 +5,7 @@
  *
  *		Implementation of the Transmission Control Protocol(TCP).
  *
- * Version:	$Id: tcp_minisocks.c,v 1.11 2001/08/03 14:27:25 davem Exp $
+ * Version:	$Id: tcp_minisocks.c,v 1.12 2001/08/13 18:56:13 davem Exp $
  *
  * Authors:	Ross Biro, <bir7@leland.Stanford.Edu>
  *		Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
@@ -766,7 +766,7 @@
 			newtp->rcv_wscale = req->rcv_wscale;
 		} else {
 			newtp->snd_wscale = newtp->rcv_wscale = 0;
-			newtp->window_clamp = min(newtp->window_clamp,65535);
+			newtp->window_clamp = min(u32, newtp->window_clamp, 65535);
 		}
 		newtp->snd_wnd = ntohs(skb->h.th->window) << newtp->snd_wscale;
 		newtp->max_window = newtp->snd_wnd;
diff -urN linux-2.4.9-pre4/net/ipv4/tcp_output.c linux/net/ipv4/tcp_output.c
--- linux-2.4.9-pre4/net/ipv4/tcp_output.c	Tue Jul 10 16:11:43 2001
+++ linux/net/ipv4/tcp_output.c	Mon Dec  3 23:03:38 2001
@@ -5,7 +5,7 @@
  *
  *		Implementation of the Transmission Control Protocol(TCP).
  *
- * Version:	$Id: tcp_output.c,v 1.137 2001/06/29 21:11:28 davem Exp $
+ * Version:	$Id: tcp_output.c,v 1.140 2001/08/13 18:56:12 davem Exp $
  *
  * Authors:	Ross Biro, <bir7@leland.Stanford.Edu>
  *		Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
@@ -105,11 +105,11 @@
 	u32 cwnd = tp->snd_cwnd;
 
 	tp->snd_ssthresh = tcp_current_ssthresh(tp);
-	restart_cwnd = min(restart_cwnd, cwnd);
+	restart_cwnd = min(u32, restart_cwnd, cwnd);
 
 	while ((delta -= tp->rto) > 0 && cwnd > restart_cwnd)
 		cwnd >>= 1;
-	tp->snd_cwnd = max(cwnd, restart_cwnd);
+	tp->snd_cwnd = max(u32, cwnd, restart_cwnd);
 	tp->snd_cwnd_stamp = tcp_time_stamp;
 	tp->snd_cwnd_used = 0;
 }
@@ -526,7 +526,7 @@
 
 	/* Bound mss with half of window */
 	if (tp->max_window && mss_now > (tp->max_window>>1))
-		mss_now = max((tp->max_window>>1), 68 - tp->tcp_header_len);
+		mss_now = max(u32, (tp->max_window>>1), 68 - tp->tcp_header_len);
 
 	/* And store cached results */
 	tp->pmtu_cookie = pmtu;
@@ -651,7 +651,7 @@
 	 */
 	int mss = tp->ack.rcv_mss;
 	int free_space = tcp_space(sk);
-	int full_space = min(tp->window_clamp, tcp_full_space(sk));
+	int full_space = min(unsigned int, tp->window_clamp, tcp_full_space(sk));
 	int window;
 
 	if (mss > full_space)
@@ -661,7 +661,7 @@
 		tp->ack.quick = 0;
 
 		if (tcp_memory_pressure)
-			tp->rcv_ssthresh = min(tp->rcv_ssthresh, 4*tp->advmss);
+			tp->rcv_ssthresh = min(u32, tp->rcv_ssthresh, 4*tp->advmss);
 
 		if (free_space < mss)
 			return 0;
@@ -817,7 +817,7 @@
 	/* Do not sent more than we queued. 1/4 is reserved for possible
 	 * copying overhead: frgagmentation, tunneling, mangling etc.
 	 */
-	if (atomic_read(&sk->wmem_alloc) > min(sk->wmem_queued+(sk->wmem_queued>>2),sk->sndbuf))
+	if (atomic_read(&sk->wmem_alloc) > min(int, sk->wmem_queued+(sk->wmem_queued>>2),sk->sndbuf))
 		return -EAGAIN;
 
 	/* If receiver has shrunk his window, and skb is out of
@@ -1264,13 +1264,13 @@
 		 * directly.
 		 */
 		if (tp->srtt) {
-			int rtt = max(tp->srtt>>3, TCP_DELACK_MIN);
+			int rtt = max(unsigned int, tp->srtt>>3, TCP_DELACK_MIN);
 
 			if (rtt < max_ato)
 				max_ato = rtt;
 		}
 
-		ato = min(ato, max_ato);
+		ato = min(int, ato, max_ato);
 	}
 
 	/* Stay within the limit we were given */
@@ -1386,7 +1386,7 @@
 			 */
 			if (seg_size < TCP_SKB_CB(skb)->end_seq - TCP_SKB_CB(skb)->seq ||
 			    skb->len > mss) {
-				seg_size = min(seg_size, mss);
+				seg_size = min(int, seg_size, mss);
 				TCP_SKB_CB(skb)->flags |= TCPCB_FLAG_PSH;
 				if (tcp_fragment(sk, skb, seg_size))
 					return -1;
@@ -1429,7 +1429,7 @@
 		tp->backoff++;
 		tp->probes_out++;
 		tcp_reset_xmit_timer (sk, TCP_TIME_PROBE0, 
-				      min(tp->rto << tp->backoff, TCP_RTO_MAX));
+				      min(u32, tp->rto << tp->backoff, TCP_RTO_MAX));
 	} else {
 		/* If packet was not sent due to local congestion,
 		 * do not backoff and do not remember probes_out.
@@ -1440,6 +1440,6 @@
 		if (!tp->probes_out)
 			tp->probes_out=1;
 		tcp_reset_xmit_timer (sk, TCP_TIME_PROBE0, 
-				      min(tp->rto << tp->backoff, TCP_RESOURCE_PROBE_INTERVAL));
+				      min(unsigned int, tp->rto << tp->backoff, TCP_RESOURCE_PROBE_INTERVAL));
 	}
 }
diff -urN linux-2.4.9-pre4/net/ipv4/tcp_timer.c linux/net/ipv4/tcp_timer.c
--- linux-2.4.9-pre4/net/ipv4/tcp_timer.c	Thu Apr 12 12:11:39 2001
+++ linux/net/ipv4/tcp_timer.c	Mon Dec  3 23:03:38 2001
@@ -5,7 +5,7 @@
  *
  *		Implementation of the Transmission Control Protocol(TCP).
  *
- * Version:	$Id: tcp_timer.c,v 1.83 2001/03/07 22:00:57 davem Exp $
+ * Version:	$Id: tcp_timer.c,v 1.85 2001/08/13 18:56:12 davem Exp $
  *
  * Authors:	Ross Biro, <bir7@leland.Stanford.Edu>
  *		Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
@@ -248,7 +248,7 @@
 	if (tcp_ack_scheduled(tp)) {
 		if (!tp->ack.pingpong) {
 			/* Delayed ACK missed: inflate ATO. */
-			tp->ack.ato = min(tp->ack.ato<<1, tp->rto);
+			tp->ack.ato = min(u32, tp->ack.ato << 1, tp->rto);
 		} else {
 			/* Delayed ACK missed: leave pingpong mode and
 			 * deflate ATO.
@@ -381,7 +381,7 @@
 		if (!tp->retransmits)
 			tp->retransmits=1;
 		tcp_reset_xmit_timer(sk, TCP_TIME_RETRANS,
-				     min(tp->rto, TCP_RESOURCE_PROBE_INTERVAL));
+				     min(u32, tp->rto, TCP_RESOURCE_PROBE_INTERVAL));
 		goto out;
 	}
 
@@ -404,7 +404,7 @@
 	tp->retransmits++;
 
 out_reset_timer:
-	tp->rto = min(tp->rto << 1, TCP_RTO_MAX);
+	tp->rto = min(u32, tp->rto << 1, TCP_RTO_MAX);
 	tcp_reset_xmit_timer(sk, TCP_TIME_RETRANS, tp->rto);
 	if (tp->retransmits > sysctl_tcp_retries1)
 		__sk_dst_reset(sk);
@@ -517,7 +517,8 @@
 
 					if (req->retrans++ == 0)
 						lopt->qlen_young--;
-					timeo = min((TCP_TIMEOUT_INIT << req->retrans),
+					timeo = min(unsigned long,
+						    (TCP_TIMEOUT_INIT << req->retrans),
 						    TCP_RTO_MAX);
 					req->expires = now + timeo;
 					reqp = &req->dl_next;
diff -urN linux-2.4.9-pre4/net/ipv6/icmp.c linux/net/ipv6/icmp.c
--- linux-2.4.9-pre4/net/ipv6/icmp.c	Wed Jun 20 21:00:55 2001
+++ linux/net/ipv6/icmp.c	Mon Dec  3 23:03:38 2001
@@ -5,7 +5,7 @@
  *	Authors:
  *	Pedro Roque		<roque@di.fc.ul.pt>
  *
- *	$Id: icmp.c,v 1.32 2001/06/10 09:20:07 davem Exp $
+ *	$Id: icmp.c,v 1.35 2001/08/13 18:56:13 davem Exp $
  *
  *	Based on net/ipv4/icmp.c
  *
@@ -365,7 +365,7 @@
 	msg.daddr = &hdr->saddr;
 
 	len = skb->len - msg.offset + sizeof(struct icmp6hdr);
-	len = min(len, IPV6_MIN_MTU - sizeof(struct ipv6hdr));
+	len = min(unsigned int, len, IPV6_MIN_MTU - sizeof(struct ipv6hdr));
 
 	if (len < 0) {
 		printk(KERN_DEBUG "icmp: len problem\n");
diff -urN linux-2.4.9-pre4/net/ipv6/ipv6_sockglue.c linux/net/ipv6/ipv6_sockglue.c
--- linux-2.4.9-pre4/net/ipv6/ipv6_sockglue.c	Sun Mar 25 18:14:25 2001
+++ linux/net/ipv6/ipv6_sockglue.c	Mon Dec  3 23:03:38 2001
@@ -7,7 +7,7 @@
  *
  *	Based on linux/net/ipv4/ip_sockglue.c
  *
- *	$Id: ipv6_sockglue.c,v 1.36 2001/02/26 05:59:07 davem Exp $
+ *	$Id: ipv6_sockglue.c,v 1.39 2001/08/13 18:56:13 davem Exp $
  *
  *	This program is free software; you can redistribute it and/or
  *      modify it under the terms of the GNU General Public License
@@ -535,7 +535,7 @@
 		return -EINVAL;
 #endif
 	}
-	len=min(sizeof(int),len);
+	len = min(unsigned int, sizeof(int), len);
 	if(put_user(len, optlen))
 		return -EFAULT;
 	if(copy_to_user(optval,&val,len))
diff -urN linux-2.4.9-pre4/net/ipv6/mcast.c linux/net/ipv6/mcast.c
--- linux-2.4.9-pre4/net/ipv6/mcast.c	Thu Apr 26 22:17:26 2001
+++ linux/net/ipv6/mcast.c	Mon Dec  3 23:03:38 2001
@@ -5,7 +5,7 @@
  *	Authors:
  *	Pedro Roque		<roque@di.fc.ul.pt>	
  *
- *	$Id: mcast.c,v 1.37 2001/04/25 20:46:34 davem Exp $
+ *	$Id: mcast.c,v 1.38 2001/08/15 07:36:31 davem Exp $
  *
  *	Based on linux/ipv4/igmp.c and linux/ipv4/ip_sockglue.c 
  *
@@ -90,7 +90,6 @@
 
 	mc_lst->next = NULL;
 	memcpy(&mc_lst->addr, addr, sizeof(struct in6_addr));
-	mc_lst->ifindex = ifindex;
 
 	if (ifindex == 0) {
 		struct rt6_info *rt;
@@ -107,6 +106,8 @@
 		sock_kfree_s(sk, mc_lst, sizeof(*mc_lst));
 		return -ENODEV;
 	}
+
+	mc_lst->ifindex = dev->ifindex;
 
 	/*
 	 *	now add/increase the group membership on the device
diff -urN linux-2.4.9-pre4/net/ipv6/ndisc.c linux/net/ipv6/ndisc.c
--- linux-2.4.9-pre4/net/ipv6/ndisc.c	Wed May 16 10:31:27 2001
+++ linux/net/ipv6/ndisc.c	Mon Dec  3 23:03:38 2001
@@ -846,7 +846,8 @@
 		}
 	}
 
-	rd_len = min(IPV6_MIN_MTU-sizeof(struct ipv6hdr)-len, skb->len + 8);
+	rd_len = min(unsigned int,
+		     IPV6_MIN_MTU-sizeof(struct ipv6hdr)-len, skb->len + 8);
 	rd_len &= ~0x7;
 	len += rd_len;
 
diff -urN linux-2.4.9-pre4/net/ipv6/raw.c linux/net/ipv6/raw.c
--- linux-2.4.9-pre4/net/ipv6/raw.c	Thu Jun 14 14:16:58 2001
+++ linux/net/ipv6/raw.c	Mon Dec  3 23:03:38 2001
@@ -7,7 +7,7 @@
  *
  *	Adapted from linux/net/ipv4/raw.c
  *
- *	$Id: raw.c,v 1.46 2001/06/05 11:36:55 davem Exp $
+ *	$Id: raw.c,v 1.49 2001/08/13 18:56:13 davem Exp $
  *
  *	Fixes:
  *	Hideaki YOSHIFUJI	:	sin6_scope_id support
@@ -699,7 +699,7 @@
 		return -ENOPROTOOPT;
 	}
 
-	len=min(sizeof(int),len);
+	len = min(unsigned int, sizeof(int), len);
 
 	if (put_user(len, optlen))
 		return -EFAULT;
diff -urN linux-2.4.9-pre4/net/ipv6/route.c linux/net/ipv6/route.c
--- linux-2.4.9-pre4/net/ipv6/route.c	Wed May 16 10:31:27 2001
+++ linux/net/ipv6/route.c	Mon Dec  3 23:03:38 2001
@@ -5,7 +5,7 @@
  *	Authors:
  *	Pedro Roque		<roque@di.fc.ul.pt>	
  *
- *	$Id: route.c,v 1.51 2001/05/03 07:02:47 davem Exp $
+ *	$Id: route.c,v 1.54 2001/08/13 18:56:13 davem Exp $
  *
  *	This program is free software; you can redistribute it and/or
  *      modify it under the terms of the GNU General Public License
@@ -785,7 +785,7 @@
 
 install_route:
 	rt->u.dst.pmtu = ipv6_get_mtu(dev);
-	rt->u.dst.advmss = max(rt->u.dst.pmtu - 60, ip6_rt_min_advmss);
+	rt->u.dst.advmss = max(unsigned int, rt->u.dst.pmtu - 60, ip6_rt_min_advmss);
 	/* Maximal non-jumbo IPv6 payload is 65535 and corresponding
 	   MSS is 65535 - tcp_header_size. 65535 is also valid and
 	   means: "any MSS, rely only on pmtu discovery"
@@ -944,7 +944,7 @@
 	nrt->rt6i_nexthop = neigh_clone(neigh);
 	/* Reset pmtu, it may be better */
 	nrt->u.dst.pmtu = ipv6_get_mtu(neigh->dev);
-	nrt->u.dst.advmss = max(nrt->u.dst.pmtu - 60, ip6_rt_min_advmss);
+	nrt->u.dst.advmss = max(unsigned int, nrt->u.dst.pmtu - 60, ip6_rt_min_advmss);
 	if (rt->u.dst.advmss > 65535-20)
 		rt->u.dst.advmss = 65535;
 	nrt->rt6i_hoplimit = ipv6_get_hoplimit(neigh->dev);
@@ -1199,7 +1199,7 @@
 	rt->u.dst.output = ip6_output;
 	rt->rt6i_dev = dev_get_by_name("lo");
 	rt->u.dst.pmtu = ipv6_get_mtu(rt->rt6i_dev);
-	rt->u.dst.advmss = max(rt->u.dst.pmtu - 60, ip6_rt_min_advmss);
+	rt->u.dst.advmss = max(unsigned int, rt->u.dst.pmtu - 60, ip6_rt_min_advmss);
 	if (rt->u.dst.advmss > 65535-20)
 		rt->u.dst.advmss = 65535;
 	rt->rt6i_hoplimit = ipv6_get_hoplimit(rt->rt6i_dev);
@@ -1390,7 +1390,7 @@
 	    rt->u.dst.pmtu > arg->mtu &&
 	    !(rt->u.dst.mxlock&(1<<RTAX_MTU)))
 		rt->u.dst.pmtu = arg->mtu;
-	rt->u.dst.advmss = max(arg->mtu - 60, ip6_rt_min_advmss);
+	rt->u.dst.advmss = max(unsigned int, arg->mtu - 60, ip6_rt_min_advmss);
 	if (rt->u.dst.advmss > 65535-20)
 		rt->u.dst.advmss = 65535;
 	return 0;
diff -urN linux-2.4.9-pre4/net/ipx/af_ipx.c linux/net/ipx/af_ipx.c
--- linux-2.4.9-pre4/net/ipx/af_ipx.c	Wed May 16 10:31:27 2001
+++ linux/net/ipx/af_ipx.c	Mon Dec  3 23:03:38 2001
@@ -1890,7 +1890,7 @@
 	if (get_user(len, optlen))
 		goto out;
 
-	len = min(len, sizeof(int));
+	len = min(unsigned int, len, sizeof(int));
 	ret = -EINVAL;
 	if(len < 0)
 		goto out;
diff -urN linux-2.4.9-pre4/net/irda/af_irda.c linux/net/irda/af_irda.c
--- linux-2.4.9-pre4/net/irda/af_irda.c	Wed Jul  4 11:50:38 2001
+++ linux/net/irda/af_irda.c	Mon Dec  3 23:03:38 2001
@@ -1400,7 +1400,7 @@
 			continue;
 		}
 
-		chunk = min(skb->len, size);
+		chunk = min(unsigned int, skb->len, size);
 		if (memcpy_toiovec(msg->msg_iov, skb->data, chunk)) {
 			skb_queue_head(&sk->receive_queue, skb);
 			if (copied == 0)
diff -urN linux-2.4.9-pre4/net/khttpd/datasending.c linux/net/khttpd/datasending.c
--- linux-2.4.9-pre4/net/khttpd/datasending.c	Fri Nov 17 11:36:27 2000
+++ linux/net/khttpd/datasending.c	Mon Dec  3 23:03:38 2001
@@ -105,8 +105,8 @@
 		
 		Space = sock_wspace(CurrentRequest->sock->sk);
 		
-		ReadSize = min(4*4096,CurrentRequest->FileLength - CurrentRequest->BytesSent);
-		ReadSize = min(ReadSize , Space );
+		ReadSize = min(int, 4 * 4096, CurrentRequest->FileLength - CurrentRequest->BytesSent);
+		ReadSize = min(int, ReadSize, Space);
 
 		if (ReadSize>0)
 		{			
diff -urN linux-2.4.9-pre4/net/khttpd/prototypes.h linux/net/khttpd/prototypes.h
--- linux-2.4.9-pre4/net/khttpd/prototypes.h	Mon Dec 11 13:32:10 2000
+++ linux/net/khttpd/prototypes.h	Mon Dec  3 23:03:38 2001
@@ -19,17 +19,6 @@
 
 #define CONFIG_KHTTPD_NUMCPU 16    /* Maximum number of threads */
 
-/* the TCP/IP stack defines a __BROKEN__ set of min/max functions !! */
-/* So we better define our own.                                      */
-
-/* Broken means: working on unsigned data only, which is not acceptable
- 		 for kHTTPd and probably a lot of other functions. */
-
-#undef min
-#undef max
-#define min(a,b)  ( (a) < (b) ? (a) : (b) )
-#define max(a,b)  ( (a) > (b) ? (a) : (b) )
-
 #ifdef OOPSTRACE
 #define EnterFunction(x)   printk("Enter: %s, %s line %i\n",x,__FILE__,__LINE__)
 #define LeaveFunction(x)   printk("Leave: %s, %s line %i\n",x,__FILE__,__LINE__)
diff -urN linux-2.4.9-pre4/net/khttpd/rfc.c linux/net/khttpd/rfc.c
--- linux-2.4.9-pre4/net/khttpd/rfc.c	Sun Mar 25 18:14:25 2001
+++ linux/net/khttpd/rfc.c	Mon Dec  3 23:03:38 2001
@@ -326,9 +326,9 @@
 			
 			strncpy(Head->FileName,sysctl_khttpd_docroot,sizeof(Head->FileName));
 			PrefixLen = strlen(sysctl_khttpd_docroot);
-			Head->FileNameLength = min(255,tmp-Buffer+PrefixLen);		
+			Head->FileNameLength = min(unsigned int, 255, tmp - Buffer + PrefixLen);		
 			
-			strncat(Head->FileName,Buffer,min(255-PrefixLen,tmp-Buffer));
+			strncat(Head->FileName,Buffer,min(unsigned int, 255 - PrefixLen, tmp - Buffer));
 					
 			Buffer=EOL+1;	
 #ifdef BENCHMARK
@@ -341,7 +341,7 @@
 		{
 			Buffer+=19;
 			
-			strncpy(Head->IMS,Buffer,min(127,EOL-Buffer-1));
+			strncpy(Head->IMS,Buffer,min(unsigned int, 127,EOL-Buffer-1));
 					
 			Buffer=EOL+1;	
 			continue;
@@ -351,7 +351,7 @@
 		{
 			Buffer+=12;
 			
-			strncpy(Head->Agent,Buffer,min(127,EOL-Buffer-1));
+			strncpy(Head->Agent,Buffer,min(unsigned int, 127,EOL-Buffer-1));
 					
 			Buffer=EOL+1;	
 			continue;
@@ -362,7 +362,7 @@
 		{
 			Buffer+=6;
 			
-			strncpy(Head->Host,Buffer,min(127,EOL-Buffer-1));
+			strncpy(Head->Host,Buffer,min(unsigned int, 127,EOL-Buffer-1));
 					
 			Buffer=EOL+1;	
 			continue;
diff -urN linux-2.4.9-pre4/net/khttpd/waitheaders.c linux/net/khttpd/waitheaders.c
--- linux-2.4.9-pre4/net/khttpd/waitheaders.c	Sun Apr  2 15:53:28 2000
+++ linux/net/khttpd/waitheaders.c	Mon Dec  3 23:03:38 2001
@@ -244,7 +244,7 @@
 		Request->Time       = Request->filp->f_dentry->d_inode->i_mtime;
 		Request->IMS_Time   = mimeTime_to_UnixTime(Request->IMS);
 		sprintf(Request->LengthS,"%i",Request->FileLength);
-		time_Unix2RFC(min(Request->Time,CurrentTime_i),Request->TimeS);
+		time_Unix2RFC(min(unsigned int, Request->Time,CurrentTime_i),Request->TimeS);
    	        /* The min() is required by rfc1945, section 10.10:
    	           It is not allowed to send a filetime in the future */
 
diff -urN linux-2.4.9-pre4/net/netrom/af_netrom.c linux/net/netrom/af_netrom.c
--- linux-2.4.9-pre4/net/netrom/af_netrom.c	Thu Apr 19 08:38:50 2001
+++ linux/net/netrom/af_netrom.c	Mon Dec  3 23:03:38 2001
@@ -435,7 +435,7 @@
 			return -ENOPROTOOPT;
 	}
 
-	len = min(len, sizeof(int));
+	len = min(unsigned int, len, sizeof(int));
 
 	if (put_user(len, optlen))
 		return -EFAULT;
diff -urN linux-2.4.9-pre4/net/rose/af_rose.c linux/net/rose/af_rose.c
--- linux-2.4.9-pre4/net/rose/af_rose.c	Thu Apr 19 08:38:50 2001
+++ linux/net/rose/af_rose.c	Mon Dec  3 23:03:38 2001
@@ -508,7 +508,7 @@
 			return -ENOPROTOOPT;
 	}
 
-	len = min(len, sizeof(int));
+	len = min(unsigned int, len, sizeof(int));
 
 	if (put_user(len, optlen))
 		return -EFAULT;
diff -urN linux-2.4.9-pre4/net/sched/sch_tbf.c linux/net/sched/sch_tbf.c
--- linux-2.4.9-pre4/net/sched/sch_tbf.c	Sun Mar 25 18:14:25 2001
+++ linux/net/sched/sch_tbf.c	Mon Dec  3 23:03:38 2001
@@ -227,7 +227,7 @@
 		}
 
 		if (!netif_queue_stopped(sch->dev)) {
-			long delay = PSCHED_US2JIFFIE(max(-toks, -ptoks));
+			long delay = PSCHED_US2JIFFIE(max(long, -toks, -ptoks));
 
 			if (delay == 0)
 				delay = 1;
diff -urN linux-2.4.9-pre4/net/sunrpc/auth.c linux/net/sunrpc/auth.c
--- linux-2.4.9-pre4/net/sunrpc/auth.c	Fri Feb  9 11:29:44 2001
+++ linux/net/sunrpc/auth.c	Mon Dec  3 23:03:38 2001
@@ -81,42 +81,61 @@
 	auth->au_nextgc = jiffies + (auth->au_expire >> 1);
 }
 
+/*
+ * Destroy an unreferenced credential
+ */
 static inline void
-rpcauth_crdestroy(struct rpc_auth *auth, struct rpc_cred *cred)
+rpcauth_crdestroy(struct rpc_cred *cred)
 {
 #ifdef RPC_DEBUG
 	if (cred->cr_magic != RPCAUTH_CRED_MAGIC)
 		BUG();
 	cred->cr_magic = 0;
+	if (atomic_read(&cred->cr_count) || cred->cr_auth)
+		BUG();
 #endif
-	if (auth->au_ops->crdestroy)
-		auth->au_ops->crdestroy(cred);
-	else
-		rpc_free(cred);
+	cred->cr_ops->crdestroy(cred);
 }
 
 /*
- * Clear the RPC credential cache
+ * Destroy a list of credentials
+ */
+static inline
+void rpcauth_destroy_credlist(struct rpc_cred *head)
+{
+	struct rpc_cred *cred;
+
+	while ((cred = head) != NULL) {
+		head = cred->cr_next;
+		rpcauth_crdestroy(cred);
+	}
+}
+
+/*
+ * Clear the RPC credential cache, and delete those credentials
+ * that are not referenced.
  */
 void
 rpcauth_free_credcache(struct rpc_auth *auth)
 {
-	struct rpc_cred	**q, *cred;
-	void		(*destroy)(struct rpc_cred *);
+	struct rpc_cred	**q, *cred, *free = NULL;
 	int		i;
 
-	if (!(destroy = auth->au_ops->crdestroy))
-		destroy = (void (*)(struct rpc_cred *)) rpc_free;
-
 	spin_lock(&rpc_credcache_lock);
 	for (i = 0; i < RPC_CREDCACHE_NR; i++) {
 		q = &auth->au_credcache[i];
 		while ((cred = *q) != NULL) {
 			*q = cred->cr_next;
-			destroy(cred);
+			cred->cr_auth = NULL;
+			if (atomic_read(&cred->cr_count) == 0) {
+				cred->cr_next = free;
+				free = cred;
+			} else
+				cred->cr_next = NULL;
 		}
 	}
 	spin_unlock(&rpc_credcache_lock);
+	rpcauth_destroy_credlist(free);
 }
 
 /*
@@ -133,9 +152,10 @@
 	for (i = 0; i < RPC_CREDCACHE_NR; i++) {
 		q = &auth->au_credcache[i];
 		while ((cred = *q) != NULL) {
-			if (!cred->cr_count &&
+			if (!atomic_read(&cred->cr_count) &&
 			    time_before(cred->cr_expire, jiffies)) {
 				*q = cred->cr_next;
+				cred->cr_auth = NULL;
 				cred->cr_next = free;
 				free = cred;
 				continue;
@@ -144,10 +164,7 @@
 		}
 	}
 	spin_unlock(&rpc_credcache_lock);
-	while ((cred = free) != NULL) {
-		free = cred->cr_next;
-		rpcauth_crdestroy(auth, cred);
-	}
+	rpcauth_destroy_credlist(free);
 	auth->au_nextgc = jiffies + auth->au_expire;
 }
 
@@ -163,8 +180,8 @@
 	spin_lock(&rpc_credcache_lock);
 	cred->cr_next = auth->au_credcache[nr];
 	auth->au_credcache[nr] = cred;
-	cred->cr_count++;
-	cred->cr_expire = jiffies + auth->au_expire;
+	cred->cr_auth = auth;
+	get_rpccred(cred);
 	spin_unlock(&rpc_credcache_lock);
 }
 
@@ -187,7 +204,7 @@
 	q = &auth->au_credcache[nr];
 	while ((cred = *q) != NULL) {
 		if (!(cred->cr_flags & RPCAUTH_CRED_DEAD) &&
-		    auth->au_ops->crmatch(cred, taskflags)) {
+		    cred->cr_ops->crmatch(cred, taskflags)) {
 			*q = cred->cr_next;
 			break;
 		}
@@ -213,23 +230,23 @@
  * Remove cred handle from cache
  */
 static void
-rpcauth_remove_credcache(struct rpc_auth *auth, struct rpc_cred *cred)
+rpcauth_remove_credcache(struct rpc_cred *cred)
 {
+	struct rpc_auth *auth = cred->cr_auth;
 	struct rpc_cred	**q, *cr;
 	int		nr;
 
 	nr = (cred->cr_uid & RPC_CREDCACHE_MASK);
-	spin_lock(&rpc_credcache_lock);
 	q = &auth->au_credcache[nr];
 	while ((cr = *q) != NULL) {
 		if (cred == cr) {
 			*q = cred->cr_next;
 			cred->cr_next = NULL;
+			cred->cr_auth = NULL;
 			break;
 		}
 		q = &cred->cr_next;
 	}
-	spin_unlock(&rpc_credcache_lock);
 }
 
 struct rpc_cred *
@@ -258,7 +275,7 @@
 {
 	dprintk("RPC:     matching %s cred %d\n",
 		auth->au_ops->au_name, taskflags);
-	return auth->au_ops->crmatch(cred, taskflags);
+	return cred->cr_ops->crmatch(cred, taskflags);
 }
 
 void
@@ -266,26 +283,25 @@
 {
 	dprintk("RPC: %4d holding %s cred %p\n",
 		task->tk_pid, task->tk_auth->au_ops->au_name, task->tk_msg.rpc_cred);
-	if (task->tk_msg.rpc_cred) {
-		spin_lock(&rpc_credcache_lock);
-		task->tk_msg.rpc_cred->cr_count++;
-		task->tk_msg.rpc_cred->cr_expire = jiffies + task->tk_auth->au_expire;
-		spin_unlock(&rpc_credcache_lock);
-	}
+	if (task->tk_msg.rpc_cred)
+		get_rpccred(task->tk_msg.rpc_cred);
 }
 
 void
-rpcauth_releasecred(struct rpc_auth *auth, struct rpc_cred *cred)
+put_rpccred(struct rpc_cred *cred)
 {
-	spin_lock(&rpc_credcache_lock);
-	if (cred != NULL && cred->cr_count > 0) {
-		if (!--cred->cr_count && (cred->cr_flags & RPCAUTH_CRED_DEAD)) {
-			spin_unlock(&rpc_credcache_lock);
-			rpcauth_remove_credcache(auth, cred);
-			rpcauth_crdestroy(auth, cred);
-			return;
-		}
+	if (!atomic_dec_and_lock(&cred->cr_count, &rpc_credcache_lock))
+		return;
+
+	if (cred->cr_auth && cred->cr_flags & RPCAUTH_CRED_DEAD)
+		rpcauth_remove_credcache(cred);
+
+	if (!cred->cr_auth) {
+		spin_unlock(&rpc_credcache_lock);
+		rpcauth_crdestroy(cred);
+		return;
 	}
+	cred->cr_expire = jiffies + cred->cr_auth->au_expire;
 	spin_unlock(&rpc_credcache_lock);
 }
 
@@ -298,7 +314,7 @@
 	dprintk("RPC: %4d releasing %s cred %p\n",
 		task->tk_pid, auth->au_ops->au_name, cred);
 
-	rpcauth_releasecred(auth, cred);
+	put_rpccred(cred);
 	task->tk_msg.rpc_cred = NULL;
 }
 
@@ -306,10 +322,11 @@
 rpcauth_marshcred(struct rpc_task *task, u32 *p)
 {
 	struct rpc_auth	*auth = task->tk_auth;
+	struct rpc_cred	*cred = task->tk_msg.rpc_cred;
 
 	dprintk("RPC: %4d marshaling %s cred %p\n",
-		task->tk_pid, auth->au_ops->au_name, task->tk_msg.rpc_cred);
-	return auth->au_ops->crmarshal(task, p,
+		task->tk_pid, auth->au_ops->au_name, cred);
+	return cred->cr_ops->crmarshal(task, p,
 				task->tk_flags & RPC_CALL_REALUID);
 }
 
@@ -317,20 +334,22 @@
 rpcauth_checkverf(struct rpc_task *task, u32 *p)
 {
 	struct rpc_auth	*auth = task->tk_auth;
+	struct rpc_cred	*cred = task->tk_msg.rpc_cred;
 
 	dprintk("RPC: %4d validating %s cred %p\n",
-		task->tk_pid, auth->au_ops->au_name, task->tk_msg.rpc_cred);
-	return auth->au_ops->crvalidate(task, p);
+		task->tk_pid, auth->au_ops->au_name, cred);
+	return cred->cr_ops->crvalidate(task, p);
 }
 
 int
 rpcauth_refreshcred(struct rpc_task *task)
 {
 	struct rpc_auth	*auth = task->tk_auth;
+	struct rpc_cred	*cred = task->tk_msg.rpc_cred;
 
 	dprintk("RPC: %4d refreshing %s cred %p\n",
-		task->tk_pid, auth->au_ops->au_name, task->tk_msg.rpc_cred);
-	task->tk_status = auth->au_ops->crrefresh(task);
+		task->tk_pid, auth->au_ops->au_name, cred);
+	task->tk_status = cred->cr_ops->crrefresh(task);
 	return task->tk_status;
 }
 
diff -urN linux-2.4.9-pre4/net/sunrpc/auth_null.c linux/net/sunrpc/auth_null.c
--- linux-2.4.9-pre4/net/sunrpc/auth_null.c	Fri Feb  9 11:29:44 2001
+++ linux/net/sunrpc/auth_null.c	Mon Dec  3 23:03:38 2001
@@ -17,6 +17,8 @@
 # define RPCDBG_FACILITY	RPCDBG_AUTH
 #endif
 
+static struct rpc_credops	null_credops;
+
 static struct rpc_auth *
 nul_create(struct rpc_clnt *clnt)
 {
@@ -52,9 +54,10 @@
 
 	if (!(cred = (struct rpc_cred *) rpc_allocate(flags, sizeof(*cred))))
 		return NULL;
-	cred->cr_count = 0;
+	atomic_set(&cred->cr_count, 0);
 	cred->cr_flags = RPCAUTH_CRED_UPTODATE;
 	cred->cr_uid = current->uid;
+	cred->cr_ops = &null_credops;
 
 	return cred;
 }
@@ -124,7 +127,11 @@
 #endif
 	nul_create,
 	nul_destroy,
-	nul_create_cred,
+	nul_create_cred
+};
+
+static
+struct rpc_credops	null_credops = {
 	nul_destroy_cred,
 	nul_match,
 	nul_marshal,
diff -urN linux-2.4.9-pre4/net/sunrpc/auth_unix.c linux/net/sunrpc/auth_unix.c
--- linux-2.4.9-pre4/net/sunrpc/auth_unix.c	Fri Feb  9 11:29:44 2001
+++ linux/net/sunrpc/auth_unix.c	Mon Dec  3 23:03:38 2001
@@ -33,6 +33,8 @@
 # define RPCDBG_FACILITY	RPCDBG_AUTH
 #endif
 
+static struct rpc_credops	unix_credops;
+
 static struct rpc_auth *
 unx_create(struct rpc_clnt *clnt)
 {
@@ -71,7 +73,7 @@
 	if (!(cred = (struct unx_cred *) rpc_allocate(flags, sizeof(*cred))))
 		return NULL;
 
-	cred->uc_count = 0;
+	atomic_set(&cred->uc_count, 0);
 	cred->uc_flags = RPCAUTH_CRED_UPTODATE;
 	if (flags & RPC_TASK_ROOTCREDS) {
 		cred->uc_uid = cred->uc_fsuid = 0;
@@ -91,6 +93,7 @@
 		if (i < NFS_NGROUPS)
 		  cred->uc_gids[i] = NOGROUP;
 	}
+	cred->uc_base.cr_ops = &unix_credops;
 
 	return (struct rpc_cred *) cred;
 }
@@ -106,7 +109,7 @@
 	if (!(cred = (struct unx_cred *) rpc_malloc(task, sizeof(*cred))))
 		return NULL;
 
-	cred->uc_count = 1;
+	atomic_set(&cred->uc_count, 1);
 	cred->uc_flags = RPCAUTH_CRED_DEAD|RPCAUTH_CRED_UPTODATE;
 	cred->uc_uid   = uid;
 	cred->uc_gid   = gid;
@@ -236,7 +239,11 @@
 #endif
 	unx_create,
 	unx_destroy,
-	unx_create_cred,
+	unx_create_cred
+};
+
+static
+struct rpc_credops	unix_credops = {
 	unx_destroy_cred,
 	unx_match,
 	unx_marshal,
diff -urN linux-2.4.9-pre4/net/sunrpc/sunrpc_syms.c linux/net/sunrpc/sunrpc_syms.c
--- linux-2.4.9-pre4/net/sunrpc/sunrpc_syms.c	Thu Jan 11 15:53:02 2001
+++ linux/net/sunrpc/sunrpc_syms.c	Mon Dec  3 23:03:38 2001
@@ -65,7 +65,7 @@
 EXPORT_SYMBOL(rpcauth_lookupcred);
 EXPORT_SYMBOL(rpcauth_bindcred);
 EXPORT_SYMBOL(rpcauth_matchcred);
-EXPORT_SYMBOL(rpcauth_releasecred);
+EXPORT_SYMBOL(put_rpccred);
 
 /* RPC server stuff */
 EXPORT_SYMBOL(svc_create);
diff -urN linux-2.4.9-pre4/net/sunrpc/xprt.c linux/net/sunrpc/xprt.c
--- linux-2.4.9-pre4/net/sunrpc/xprt.c	Thu Apr 12 12:11:39 2001
+++ linux/net/sunrpc/xprt.c	Mon Dec  3 23:03:38 2001
@@ -84,11 +84,6 @@
 # define RPCDBG_FACILITY	RPCDBG_XPRT
 #endif
 
-#ifndef MAX
-# define MAX(a, b)	((a) > (b)? (a) : (b))
-# define MIN(a, b)	((a) < (b)? (a) : (b))
-#endif
-
 /*
  * Local functions
  */
@@ -749,7 +744,7 @@
 
 	if (xprt->tcp_copied >= sizeof(xprt->tcp_xid) || !avail)
 		goto done;
-	want = MIN(sizeof(xprt->tcp_xid) - xprt->tcp_copied, avail);
+	want = min(unsigned int, sizeof(xprt->tcp_xid) - xprt->tcp_copied, avail);
 	do {
 		dprintk("RPC:      reading xid (%d bytes)\n", want);
 		riov.iov_base = ((u8*) &xprt->tcp_xid) + xprt->tcp_copied;
@@ -776,7 +771,7 @@
 
 	if (req->rq_rlen <= xprt->tcp_copied || !avail)
 		goto done;
-	want = MIN(req->rq_rlen - xprt->tcp_copied, avail);
+	want = min(unsigned int, req->rq_rlen - xprt->tcp_copied, avail);
 	do {
 		dprintk("RPC: %4d TCP receiving %d bytes\n",
 			req->rq_task->tk_pid, want);
@@ -810,7 +805,7 @@
 	int		want, result = 0;
 
 	while (avail) {
-		want = MIN(avail, sizeof(dummy));
+		want = min(unsigned int, avail, sizeof(dummy));
 		riov.iov_base = dummy;
 		riov.iov_len  = want;
 		dprintk("RPC:      TCP skipping %d bytes\n", want);
@@ -1072,7 +1067,7 @@
 
 
 	/* Wait until we have enough socket memory */
-	if (sock_wspace(sk) < min(sk->sndbuf,XPRT_MIN_WRITE_SPACE))
+	if (sock_wspace(sk) < min(int, sk->sndbuf,XPRT_MIN_WRITE_SPACE))
 		return;
 
 	if (!xprt_test_and_set_wspace(xprt)) {
diff -urN linux-2.4.9-pre4/net/unix/af_unix.c linux/net/unix/af_unix.c
--- linux-2.4.9-pre4/net/unix/af_unix.c	Sat Jul 28 12:12:38 2001
+++ linux/net/unix/af_unix.c	Mon Dec  3 23:03:38 2001
@@ -8,7 +8,7 @@
  *		as published by the Free Software Foundation; either version
  *		2 of the License, or (at your option) any later version.
  *
- * Version:	$Id: af_unix.c,v 1.118 2001/07/18 07:52:37 davem Exp $
+ * Version:	$Id: af_unix.c,v 1.121 2001/08/13 18:56:13 davem Exp $
  *
  * Fixes:
  *		Linus Torvalds	:	Assorted bug cures.
@@ -111,8 +111,6 @@
 
 #include <asm/checksum.h>
 
-#define min(a,b)	(((a)<(b))?(a):(b))
-
 int sysctl_unix_max_dgram_qlen = 10;
 
 unix_socket *unix_socket_table[UNIX_HASH_SIZE+1];
@@ -1338,7 +1336,7 @@
 		 *	fallback size buffer which is under a page and will
 		 *	succeed. [Alan]
 		 */
-		size = min(size, skb_tailroom(skb));
+		size = min(int, size, skb_tailroom(skb));
 
 		memcpy(UNIXCREDS(skb), &scm->creds, sizeof(struct ucred));
 		if (scm->fp)
@@ -1570,7 +1568,7 @@
 			sunaddr = NULL;
 		}
 
-		chunk = min(skb->len, size);
+		chunk = min(unsigned int, skb->len, size);
 		if (memcpy_toiovec(msg->msg_iov, skb->data, chunk)) {
 			skb_queue_head(&sk->receive_queue, skb);
 			if (copied == 0)
diff -urN linux-2.4.9-pre4/net/wanrouter/wanmain.c linux/net/wanrouter/wanmain.c
--- linux-2.4.9-pre4/net/wanrouter/wanmain.c	Mon Dec  3 23:03:29 2001
+++ linux/net/wanrouter/wanmain.c	Mon Dec  3 23:03:38 2001
@@ -139,17 +139,6 @@
 
 
 /*
- * 	Defines and Macros 
- */
-
-#ifndef	min
-#define min(a,b) (((a)<(b))?(a):(b))
-#endif
-#ifndef	max
-#define max(a,b) (((a)>(b))?(a):(b))
-#endif
-
-/*
  * 	Function Prototypes 
  */
 
diff -urN linux-2.4.9-pre4/net/wanrouter/wanproc.c linux/net/wanrouter/wanproc.c
--- linux-2.4.9-pre4/net/wanrouter/wanproc.c	Mon Dec  3 23:03:29 2001
+++ linux/net/wanrouter/wanproc.c	Mon Dec  3 23:03:38 2001
@@ -46,13 +46,6 @@
 
 /****** Defines and Macros **************************************************/
 
-#ifndef	min
-#define min(a,b) (((a)<(b))?(a):(b))
-#endif
-#ifndef	max
-#define max(a,b) (((a)>(b))?(a):(b))
-#endif
-
 #define	PROC_BUFSZ	4000	/* buffer size for printing proc info */
 
 #define PROT_DECODE(prot) ((prot == WANCONFIG_FR) ? " FR" :\
@@ -266,7 +259,7 @@
 		pos = dent->get_info(page, dent->data, 0, 0);
 		offs = file->f_pos;
 		if (offs < pos) {
-			len = min(pos - offs, count);
+			len = min(unsigned int, pos - offs, count);
 			if (copy_to_user(buf, (page + offs), len)) {
 				kfree(page);
 				return -EFAULT;
@@ -812,7 +805,7 @@
 		pos = dent->get_info(page, dent->data, 0, 0, 0);
 		offs = file->f_pos;
 		if (offs < pos) {
-			len = min(pos - offs, count);
+			len = min(unsigned int, pos - offs, count);
 			if (copy_to_user(buf, (page + offs), len)) {
 				kfree(page);
 				return -EFAULT;
@@ -848,7 +841,7 @@
 		pos = dent->get_info(page, dent->data, 0, 0, 0);
 		offs = file->f_pos;
 		if (offs < pos) {
-			len = min(pos - offs, count);
+			len = min(unsigned int, pos - offs, count);
 			memcpy_tofs((void*)buf, (void*)(page + offs), len);
 			file->f_pos += len;
 		}
diff -urN linux-2.4.9-pre4/net/x25/af_x25.c linux/net/x25/af_x25.c
--- linux-2.4.9-pre4/net/x25/af_x25.c	Thu Apr 12 12:11:39 2001
+++ linux/net/x25/af_x25.c	Mon Dec  3 23:03:38 2001
@@ -407,7 +407,7 @@
 			return -ENOPROTOOPT;
 	}
 
-	len = min(len, sizeof(int));
+	len = min(unsigned int, len, sizeof(int));
 
 	if (len < 0)
 		return -EINVAL;
