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

diff -urN linux-2.4.10-pre7/Documentation/sysctl/vm.txt linux/Documentation/sysctl/vm.txt
--- linux-2.4.10-pre7/Documentation/sysctl/vm.txt	Wed Mar 14 14:39:07 2001
+++ linux/Documentation/sysctl/vm.txt	Mon Dec  3 23:09:18 2001
@@ -33,32 +33,29 @@
 This file controls the operation of the bdflush kernel
 daemon. The source code to this struct can be found in
 linux/fs/buffer.c. It currently contains 9 integer values,
-of which 6 are actually used by the kernel.
+of which 4 are actually used by the kernel.
 
 From linux/fs/buffer.c:
 --------------------------------------------------------------
-union bdflush_param{
-    struct {
-        int nfract;      /* Percentage of buffer cache dirty to
-                            activate bdflush */
-        int ndirty;      /* Maximum number of dirty blocks to
-                            write out per wake-cycle */
-        int nrefill;     /* Number of clean buffers to try to
-                            obtain each time we call refill */
-        int nref_dirt;   /* Dirty buffer threshold for activating
-                            bdflush when trying to refill buffers. */
-        int dummy1;      /* unused */
-        int age_buffer;  /* Time for normal buffer to age before
-                            we flush it */
-        int age_super;   /* Time for superblock to age before we
-                            flush it */
-        int dummy2;      /* unused */
-        int dummy3;      /* unused */
-    } b_un;
-    unsigned int data[N_PARAM];
-} bdf_prm = {{40, 500, 64, 256, 15, 30*HZ, 5*HZ, 1884, 2}};
+union bdflush_param {
+	struct {
+		int nfract;	/* Percentage of buffer cache dirty to 
+				   activate bdflush */
+		int dummy1;	/* old "ndirty" */
+		int dummy2;	/* old "nrefill" */
+		int dummy3;	/* unused */
+		int interval;	/* jiffies delay between kupdate flushes */
+		int age_buffer;	/* Time for normal buffer to age */
+		int nfract_sync;/* Percentage of buffer cache dirty to 
+				   activate bdflush synchronously */
+		int dummy4;	/* unused */
+		int dummy5;	/* unused */
+	} b_un;
+	unsigned int data[N_PARAM];
+} bdf_prm = {{30, 64, 64, 256, 5*HZ, 30*HZ, 60, 0, 0}};
 --------------------------------------------------------------
 
+int nfract:
 The first parameter governs the maximum number of dirty
 buffers in the buffer cache. Dirty means that the contents
 of the buffer still have to be written to disk (as opposed
@@ -66,32 +63,31 @@
 Setting this to a high value means that Linux can delay disk
 writes for a long time, but it also means that it will have
 to do a lot of I/O at once when memory becomes short. A low
-value will spread out disk I/O more evenly.
-
-The second parameter (ndirty) gives the maximum number of
-dirty buffers that bdflush can write to the disk in one time.
-A high value will mean delayed, bursty I/O, while a small
-value can lead to memory shortage when bdflush isn't woken
-up often enough...
-
-The third parameter (nrefill) is the number of buffers that
-bdflush will add to the list of free buffers when
-refill_freelist() is called. It is necessary to allocate free
-buffers beforehand, since the buffers often are of a different
-size than memory pages and some bookkeeping needs to be done
-beforehand. The higher the number, the more memory will be
-wasted and the less often refill_freelist() will need to run.
-
-When refill_freelist() comes across more than nref_dirt dirty
-buffers, it will wake up bdflush.
-
-Finally, the age_buffer and age_super parameters govern the
-maximum time Linux waits before writing out a dirty buffer
-to disk. The value is expressed in jiffies (clockticks), the
-number of jiffies per second is 100, except on Alpha machines
-(1024). Age_buffer is the maximum age for data blocks, while
-age_super is for filesystem metadata.
-
+value will spread out disk I/O more evenly, at the cost of
+more frequent I/O operations.  The default value is 30%,
+the minimum is 0%, and the maximum is 100%.
+
+int interval:
+The fifth parameter, interval, is the minimum rate at
+which kupdate will wake and flush.  The value is expressed in
+jiffies (clockticks), the number of jiffies per second is
+normally 100 (Alpha is 1024). Thus, x*HZ is x seconds.  The
+default value is 5 seconds, the minimum is 0 seconds, and the
+maximum is 600 seconds.
+
+int age_buffer:
+The sixth parameter, age_buffer, governs the maximum time
+Linux waits before writing out a dirty buffer to disk.  The
+value is in jiffies.  The default value is 30 seconds,
+the minimum is 1 second, and the maximum 6,000 seconds.
+
+int nfract_sync:
+The seventh parameter, nfract_sync, governs the percentage
+of buffer cache that is dirty before bdflush activates
+synchronously.  This can be viewed as the hard limit before
+bdflush forces buffers to disk.  The default is 60%, the
+minimum is 0%, and the maximum is 100%.
+ 
 ==============================================================
 buffermem:
 
diff -urN linux-2.4.10-pre7/Makefile linux/Makefile
--- linux-2.4.10-pre7/Makefile	Mon Dec  3 23:09:08 2001
+++ linux/Makefile	Mon Dec  3 23:09:18 2001
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 4
 SUBLEVEL = 10
-EXTRAVERSION =-pre7
+EXTRAVERSION =-pre8
 
 KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 
diff -urN linux-2.4.10-pre7/arch/arm/kernel/arthur.c linux/arch/arm/kernel/arthur.c
--- linux-2.4.10-pre7/arch/arm/kernel/arthur.c	Mon Dec  3 23:09:08 2001
+++ linux/arch/arm/kernel/arthur.c	Mon Dec  3 23:09:18 2001
@@ -65,7 +65,7 @@
 
 static struct exec_domain arthur_exec_domain = {
 	"Arthur",	/* name */
-	(lcall7_func)arthur_lcall7,
+	arthur_lcall7,
 	PER_RISCOS, PER_RISCOS,
 	arthur_to_linux_signals,
 	linux_to_arthur_signals,
diff -urN linux-2.4.10-pre7/arch/arm/kernel/traps.c linux/arch/arm/kernel/traps.c
--- linux-2.4.10-pre7/arch/arm/kernel/traps.c	Sun Aug 12 11:13:59 2001
+++ linux/arch/arm/kernel/traps.c	Mon Dec  3 23:09:18 2001
@@ -19,6 +19,7 @@
 #include <linux/sched.h>
 #include <linux/mm.h>
 #include <linux/spinlock.h>
+#include <linux/personality.h>
 #include <linux/ptrace.h>
 #include <linux/elf.h>
 #include <linux/init.h>
diff -urN linux-2.4.10-pre7/arch/cris/drivers/usb-host.c linux/arch/cris/drivers/usb-host.c
--- linux-2.4.10-pre7/arch/cris/drivers/usb-host.c	Wed Aug 15 01:22:15 2001
+++ linux/arch/cris/drivers/usb-host.c	Mon Dec  3 23:09:18 2001
@@ -2258,11 +2258,11 @@
 	case RH_GET_DESCRIPTOR:
 		switch ((wValue & 0xff00) >> 8) {
 		case (0x01):	/* device descriptor */
-			len = min(unsigned int, leni, min(unsigned int, sizeof (root_hub_dev_des), wLength));
+			len = min_t(unsigned int, leni, min_t(unsigned int, sizeof (root_hub_dev_des), wLength));
 			memcpy (data, root_hub_dev_des, len);
 			OK (len);
 		case (0x02):	/* configuration descriptor */
-			len = min(unsigned int, leni, min(unsigned int, sizeof (root_hub_config_des), wLength));
+			len = min_t(unsigned int, leni, min_t(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(int, leni, len));
+				OK(min_t(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(unsigned int, leni, min(unsigned int, sizeof (root_hub_hub_des), wLength));
+		len = min_t(unsigned int, leni, min_t(unsigned int, sizeof (root_hub_hub_des), wLength));
 		memcpy (data, root_hub_hub_des, len);
 		OK (len);
 		
diff -urN linux-2.4.10-pre7/arch/i386/kernel/i386_ksyms.c linux/arch/i386/kernel/i386_ksyms.c
--- linux-2.4.10-pre7/arch/i386/kernel/i386_ksyms.c	Thu Aug 16 09:39:37 2001
+++ linux/arch/i386/kernel/i386_ksyms.c	Mon Dec  3 23:09:18 2001
@@ -72,7 +72,7 @@
 EXPORT_SYMBOL(apm_info);
 EXPORT_SYMBOL(gdt);
 
-#ifdef CONFIG_IO_DEBUG
+#ifdef CONFIG_DEBUG_IOVIRT
 EXPORT_SYMBOL(__io_virt_debug);
 #endif
 
diff -urN linux-2.4.10-pre7/arch/i386/kernel/signal.c linux/arch/i386/kernel/signal.c
--- linux-2.4.10-pre7/arch/i386/kernel/signal.c	Wed Jul  4 14:41:33 2001
+++ linux/arch/i386/kernel/signal.c	Mon Dec  3 23:09:18 2001
@@ -19,6 +19,7 @@
 #include <linux/unistd.h>
 #include <linux/stddef.h>
 #include <linux/tty.h>
+#include <linux/personality.h>
 #include <asm/ucontext.h>
 #include <asm/uaccess.h>
 #include <asm/i387.h>
diff -urN linux-2.4.10-pre7/arch/i386/lib/Makefile linux/arch/i386/lib/Makefile
--- linux-2.4.10-pre7/arch/i386/lib/Makefile	Mon Jul  2 16:15:33 2001
+++ linux/arch/i386/lib/Makefile	Mon Dec  3 23:09:18 2001
@@ -13,5 +13,6 @@
 
 obj-$(CONFIG_X86_USE_3DNOW) += mmx.o
 obj-$(CONFIG_HAVE_DEC_LOCK) += dec_and_lock.o
+obj-$(CONFIG_DEBUG_IOVIRT)  += iodebug.o
 
 include $(TOPDIR)/Rules.make
diff -urN linux-2.4.10-pre7/arch/sparc64/solaris/misc.c linux/arch/sparc64/solaris/misc.c
--- linux-2.4.10-pre7/arch/sparc64/solaris/misc.c	Sun Mar 25 18:14:21 2001
+++ linux/arch/sparc64/solaris/misc.c	Mon Dec  3 23:09:18 2001
@@ -709,7 +709,7 @@
 
 struct exec_domain solaris_exec_domain = {
 	"Solaris",
-	(lcall7_func)NULL,
+	NULL,
 	1, 1,	/* PER_SVR4 personality */
 	solaris_to_linux_signals,
 	linux_to_solaris_signals,
diff -urN linux-2.4.10-pre7/arch/sparc64/solaris/timod.c linux/arch/sparc64/solaris/timod.c
--- linux-2.4.10-pre7/arch/sparc64/solaris/timod.c	Wed Aug 15 01:22:15 2001
+++ linux/arch/sparc64/solaris/timod.c	Mon Dec  3 23:09:18 2001
@@ -699,7 +699,7 @@
 	}
 	if (ctl_maxlen >= 0 && sock->pfirst) {
 		struct T_primsg *it = sock->pfirst;
-		int l = min(int, ctl_maxlen, it->length);
+		int l = min_t(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,
diff -urN linux-2.4.10-pre7/drivers/acorn/block/mfmhd.c linux/drivers/acorn/block/mfmhd.c
--- linux-2.4.10-pre7/drivers/acorn/block/mfmhd.c	Mon Dec  3 23:09:08 2001
+++ linux/drivers/acorn/block/mfmhd.c	Mon Dec  3 23:09:18 2001
@@ -1210,6 +1210,8 @@
 
 	case BLKGETSIZE:
 		return put_user (mfm[minor].nr_sects, (long *)arg);
+	case BLKGETSIZE64:
+		return put_user ((u64)mfm[minor].nr_sects << 9, (u64 *)arg);
 
 	case BLKFRASET:
 		if (!capable(CAP_SYS_ADMIN))
diff -urN linux-2.4.10-pre7/drivers/acorn/scsi/acornscsi.c linux/drivers/acorn/scsi/acornscsi.c
--- linux-2.4.10-pre7/drivers/acorn/scsi/acornscsi.c	Wed Aug 15 01:22:15 2001
+++ linux/drivers/acorn/scsi/acornscsi.c	Mon Dec  3 23:09:18 2001
@@ -1059,7 +1059,7 @@
     /*
      * Allocate some buffer space, limited to half the buffer size
      */
-    length = min(unsigned int, host->scsi.SCp.this_residual, DMAC_BUFFER_SIZE / 2);
+    length = min_t(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(unsigned int, host->scsi.SCp.this_residual, DMAC_BUFFER_SIZE / 2);
+    length = min_t(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(unsigned int, message[3], sdtr_period / 4);
-		length = min(unsigned int, message[4], sdtr_size);
+		period = max_t(unsigned int, message[3], sdtr_period / 4);
+		length = min_t(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.10-pre7/drivers/block/DAC960.c linux/drivers/block/DAC960.c
--- linux-2.4.10-pre7/drivers/block/DAC960.c	Mon Dec  3 23:09:08 2001
+++ linux/drivers/block/DAC960.c	Mon Dec  3 23:09:18 2001
@@ -5074,10 +5074,12 @@
 			   sizeof(DiskGeometry_T)) ? -EFAULT : 0);
     case BLKGETSIZE:
       /* Get Device Size. */
-      if ((long *) Argument == NULL) return -EINVAL;
       return put_user(Controller->GenericDiskInfo.part[MINOR(Inode->i_rdev)]
 						 .nr_sects,
 		      (long *) Argument);
+    case BLKGETSIZE64:
+      return put_user((u64)Controller->GenericDiskInfo.part[MINOR(Inode->i_rdev)].nr_sects << 9,
+		      (u64 *) Argument);
     case BLKRAGET:
     case BLKRASET:
     case BLKFLSBUF:
diff -urN linux-2.4.10-pre7/drivers/block/acsi.c linux/drivers/block/acsi.c
--- linux-2.4.10-pre7/drivers/block/acsi.c	Mon Dec  3 23:09:08 2001
+++ linux/drivers/block/acsi.c	Mon Dec  3 23:09:18 2001
@@ -1138,6 +1138,10 @@
 		return put_user(acsi_part[MINOR(inode->i_rdev)].nr_sects,
 				(long *) arg);
 
+	  case BLKGETSIZE64:   /* Return device size */
+		return put_user((u64)acsi_part[MINOR(inode->i_rdev)].nr_sects << 9,
+				(u64 *) arg);
+
 	  case BLKROSET:
 	  case BLKROGET:
 	  case BLKFLSBUF:
diff -urN linux-2.4.10-pre7/drivers/block/amiflop.c linux/drivers/block/amiflop.c
--- linux-2.4.10-pre7/drivers/block/amiflop.c	Sat Apr 28 11:27:53 2001
+++ linux/drivers/block/amiflop.c	Mon Dec  3 23:09:18 2001
@@ -1556,6 +1556,9 @@
 	case BLKGETSIZE:
 		return put_user(unit[drive].blocks,(long *)param);
 		break;
+	case BLKGETSIZE64:
+		return put_user((u64)unit[drive].blocks << 9, (u64 *)param);
+		break;
 	case FDSETPRM:
 	case FDDEFPRM:
 		return -EINVAL;
diff -urN linux-2.4.10-pre7/drivers/block/blkpg.c linux/drivers/block/blkpg.c
--- linux-2.4.10-pre7/drivers/block/blkpg.c	Mon Dec  3 23:09:08 2001
+++ linux/drivers/block/blkpg.c	Mon Dec  3 23:09:18 2001
@@ -239,6 +239,7 @@
 		case BLKGETSIZE:
 			/* Today get_gendisk() requires a linear scan;
 			   add this when dev has pointer type. */
+			/* add BLKGETSIZE64 too */
 			g = get_gendisk(dev);
 			if (!g)
 				longval = 0;
diff -urN linux-2.4.10-pre7/drivers/block/cciss.c linux/drivers/block/cciss.c
--- linux-2.4.10-pre7/drivers/block/cciss.c	Mon Dec  3 23:09:08 2001
+++ linux/drivers/block/cciss.c	Mon Dec  3 23:09:18 2001
@@ -400,8 +400,10 @@
 		put_user(hba[ctlr]->hd[MINOR(inode->i_rdev)].start_sect, &geo->start);
 		return 0;
 	case BLKGETSIZE:
-		if (!arg) return -EINVAL;
 		put_user(hba[ctlr]->hd[MINOR(inode->i_rdev)].nr_sects, (long*)arg);
+		return 0;
+	case BLKGETSIZE64:
+		put_user((u64)hba[ctlr]->hd[MINOR(inode->i_rdev)].nr_sects << 9, (u64*)arg);
 		return 0;
 	case BLKRRPART:
 		return revalidate_logvol(inode->i_rdev, 1);
diff -urN linux-2.4.10-pre7/drivers/block/cpqarray.c linux/drivers/block/cpqarray.c
--- linux-2.4.10-pre7/drivers/block/cpqarray.c	Mon Dec  3 23:09:08 2001
+++ linux/drivers/block/cpqarray.c	Mon Dec  3 23:09:18 2001
@@ -1216,9 +1216,9 @@
 	case IDAGETDRVINFO:
 		return copy_to_user(&io->c.drv,&hba[ctlr]->drv[dsk],sizeof(drv_info_t));
 	case BLKGETSIZE:
-		if (!arg) return -EINVAL;
-		put_user(ida[(ctlr<<CTLR_SHIFT)+MINOR(inode->i_rdev)].nr_sects, (long*)arg);
-		return 0;
+		return put_user(ida[(ctlr<<CTLR_SHIFT)+MINOR(inode->i_rdev)].nr_sects, (long*)arg);
+	case BLKGETSIZE64:
+		return put_user((u64)(ida[(ctlr<<CTLR_SHIFT)+MINOR(inode->i_rdev)].nr_sects) << 9, (u64*)arg);
 	case BLKRRPART:
 		return revalidate_logvol(inode->i_rdev, 1);
 	case IDAPASSTHRU:
diff -urN linux-2.4.10-pre7/drivers/block/floppy.c linux/drivers/block/floppy.c
--- linux-2.4.10-pre7/drivers/block/floppy.c	Mon Dec  3 23:09:08 2001
+++ linux/drivers/block/floppy.c	Mon Dec  3 23:09:18 2001
@@ -3497,6 +3497,10 @@
 		case BLKGETSIZE:
 			ECALL(get_floppy_geometry(drive, type, &g));
 			return put_user(g->size, (long *) param);
+
+		case BLKGETSIZE64:
+			ECALL(get_floppy_geometry(drive, type, &g));
+			return put_user((u64)g->size << 9, (u64 *) param);
 		/* BLKRRPART is not defined as floppies don't have
 		 * partition tables */
 	}
diff -urN linux-2.4.10-pre7/drivers/block/loop.c linux/drivers/block/loop.c
--- linux-2.4.10-pre7/drivers/block/loop.c	Mon Dec  3 23:09:08 2001
+++ linux/drivers/block/loop.c	Mon Dec  3 23:09:18 2001
@@ -849,11 +849,14 @@
 			err = -ENXIO;
 			break;
 		}
-		if (!arg) {
-			err = -EINVAL;
+		err = put_user(loop_sizes[lo->lo_number] << 1, (long *) arg);
+		break;
+	case BLKGETSIZE64:
+		if (lo->lo_state != Lo_bound) {
+			err = -ENXIO;
 			break;
 		}
-		err = put_user(loop_sizes[lo->lo_number] << 1, (long *) arg);
+		err = put_user((u64)loop_sizes[lo->lo_number] << 10, (u64*)arg);
 		break;
 	case BLKBSZGET:
 	case BLKBSZSET:
diff -urN linux-2.4.10-pre7/drivers/block/nbd.c linux/drivers/block/nbd.c
--- linux-2.4.10-pre7/drivers/block/nbd.c	Fri Jun 29 16:15:41 2001
+++ linux/drivers/block/nbd.c	Mon Dec  3 23:09:18 2001
@@ -446,6 +446,8 @@
 #endif
 	case BLKGETSIZE:
 		return put_user(nbd_bytesizes[dev] >> 9, (long *) arg);
+	case BLKGETSIZE64:
+		return put_user((u64)nbd_bytesizes[dev], (u64 *) arg);
 	}
 	return -EINVAL;
 }
diff -urN linux-2.4.10-pre7/drivers/block/paride/pd.c linux/drivers/block/paride/pd.c
--- linux-2.4.10-pre7/drivers/block/paride/pd.c	Mon Dec  3 23:09:08 2001
+++ linux/drivers/block/paride/pd.c	Mon Dec  3 23:09:18 2001
@@ -287,6 +287,7 @@
 static struct hd_struct pd_hd[PD_DEVS];
 static int pd_sizes[PD_DEVS];
 static int pd_blocksizes[PD_DEVS];
+static int pd_maxsectors[PD_DEVS];
 
 #define PD_NAMELEN	8
 
@@ -382,56 +383,6 @@
 	}
 }
 
-static inline int pd_new_segment(request_queue_t *q, struct request *req, int max_segments)
-{
-	if (max_segments > cluster)
-		max_segments = cluster;
-
-	if (req->nr_segments < max_segments) {
-		req->nr_segments++;
-		return 1;
-	}
-	return 0;
-}
-
-static int pd_back_merge_fn(request_queue_t *q, struct request *req, 
-			    struct buffer_head *bh, int max_segments)
-{
-	if (req->bhtail->b_data + req->bhtail->b_size == bh->b_data)
-		return 1;
-	return pd_new_segment(q, req, max_segments);
-}
-
-static int pd_front_merge_fn(request_queue_t *q, struct request *req, 
-			     struct buffer_head *bh, int max_segments)
-{
-	if (bh->b_data + bh->b_size == req->bh->b_data)
-		return 1;
-	return pd_new_segment(q, req, max_segments);
-}
-
-static int pd_merge_requests_fn(request_queue_t *q, struct request *req,
-				struct request *next, int max_segments)
-{
-	int total_segments = req->nr_segments + next->nr_segments;
-	int same_segment;
-
-	if (max_segments > cluster)
-		max_segments = cluster;
-
-	same_segment = 0;
-	if (req->bhtail->b_data + req->bhtail->b_size == next->bh->b_data) {
-		total_segments--;
-		same_segment = 1;
-	}
-    
-	if (total_segments > max_segments)
-		return 0;
-
-	req->nr_segments = total_segments;
-	return 1;
-}
-
 int pd_init (void)
 
 {       int i;
@@ -445,9 +396,6 @@
         }
 	q = BLK_DEFAULT_QUEUE(MAJOR_NR);
 	blk_init_queue(q, DEVICE_REQUEST);
-	q->back_merge_fn = pd_back_merge_fn;
-	q->front_merge_fn = pd_front_merge_fn;
-	q->merge_requests_fn = pd_merge_requests_fn;
         read_ahead[MAJOR_NR] = 8;       /* 8 sector (4kB) read ahead */
         
 	pd_gendisk.major = major;
@@ -457,6 +405,9 @@
 	for(i=0;i<PD_DEVS;i++) pd_blocksizes[i] = 1024;
 	blksize_size[MAJOR_NR] = pd_blocksizes;
 
+	for(i=0;i<PD_DEVS;i++) pd_maxsectors[i] = cluster;
+	max_sectors[MAJOR_NR] = pd_maxsectors;
+
 	printk("%s: %s version %s, major %d, cluster %d, nice %d\n",
 		name,name,PD_VERSION,major,cluster,nice);
 	pd_init_units();
@@ -531,6 +482,8 @@
                 if (err) return (err);
                 put_user(pd_hd[dev].nr_sects,(long *) arg);
                 return (0);
+            case BLKGETSIZE64:
+                return put_user((u64)pd_hd[dev].nr_sects << 9, (u64 *)arg);
             case BLKRRPART:
 		if (!capable(CAP_SYS_ADMIN))
 			return -EACCES;
@@ -639,6 +592,11 @@
 
         devfs_unregister_blkdev(MAJOR_NR,name);
 	del_gendisk(&pd_gendisk);
+
+	for (unit=0;unit<PD_UNITS;unit++) 
+	   if (PD.present) pi_release(PI);
+
+	max_sectors[MAJOR_NR] = NULL;
 }
 
 #endif
diff -urN linux-2.4.10-pre7/drivers/block/paride/pf.c linux/drivers/block/paride/pf.c
--- linux-2.4.10-pre7/drivers/block/paride/pf.c	Sun Feb  4 10:05:29 2001
+++ linux/drivers/block/paride/pf.c	Mon Dec  3 23:09:18 2001
@@ -482,11 +482,9 @@
                 put_user(0,(long *)&geo->start);
                 return 0;
             case BLKGETSIZE:
-                if (!arg) return -EINVAL;
-                err = verify_area(VERIFY_WRITE,(long *) arg,sizeof(long));
-                if (err) return (err);
-                put_user(PF.capacity,(long *) arg);
-                return (0);
+                return put_user(PF.capacity,(long *) arg);
+            case BLKGETSIZE64:
+                return put_user((u64)PF.capacity << 9,(u64 *)arg);
 	    case BLKROSET:
 	    case BLKROGET:
 	    case BLKRASET:
diff -urN linux-2.4.10-pre7/drivers/block/ps2esdi.c linux/drivers/block/ps2esdi.c
--- linux-2.4.10-pre7/drivers/block/ps2esdi.c	Mon Dec  3 23:09:08 2001
+++ linux/drivers/block/ps2esdi.c	Mon Dec  3 23:09:18 2001
@@ -1114,6 +1114,9 @@
 			}
 			break;
 
+		case BLKGETSIZE64:
+			return put_user((u64)ps2esdi[MINOR(inode->i_rdev)].nr_sects << 9, (u64 *) arg);
+
 		case BLKRRPART:
                         if (!capable(CAP_SYS_ADMIN)) 
 				return -EACCES;
diff -urN linux-2.4.10-pre7/drivers/block/rd.c linux/drivers/block/rd.c
--- linux-2.4.10-pre7/drivers/block/rd.c	Mon Dec  3 23:09:08 2001
+++ linux/drivers/block/rd.c	Mon Dec  3 23:09:18 2001
@@ -269,6 +269,9 @@
 			if (!arg)  return -EINVAL;
 			return put_user(rd_kbsize[minor] << 1, (long *) arg);
 
+         	case BLKGETSIZE64:
+			return put_user((u64)rd_kbsize[minor] << 10, (u64*)arg);
+
 		case BLKROSET:
 		case BLKROGET:
 		case BLKSSZGET:
diff -urN linux-2.4.10-pre7/drivers/block/xd.c linux/drivers/block/xd.c
--- linux-2.4.10-pre7/drivers/block/xd.c	Mon Dec  3 23:09:08 2001
+++ linux/drivers/block/xd.c	Mon Dec  3 23:09:18 2001
@@ -337,6 +337,8 @@
 		case BLKGETSIZE:
 			if (!arg) return -EINVAL;
 			return put_user(xd_struct[MINOR(inode->i_rdev)].nr_sects,(long *) arg);
+		case BLKGETSIZE64:
+			return put_user((u64)xd_struct[MINOR(inode->i_rdev)].nr_sects << 9, (u64 *)arg);
 		case HDIO_SET_DMA:
 			if (!capable(CAP_SYS_ADMIN)) return -EACCES;
 			if (xdc_busy) return -EBUSY;
diff -urN linux-2.4.10-pre7/drivers/char/agp/agpgart_be.c linux/drivers/char/agp/agpgart_be.c
--- linux-2.4.10-pre7/drivers/char/agp/agpgart_be.c	Mon Dec  3 23:09:08 2001
+++ linux/drivers/char/agp/agpgart_be.c	Mon Dec  3 23:09:18 2001
@@ -437,8 +437,8 @@
 			/* adjust RQ depth */
 			command =
 			    ((command & ~0xff000000) |
-			     min(u32, (mode & 0xff000000),
-				 min(u32, (command & 0xff000000),
+			     min_t(u32, (mode & 0xff000000),
+				 min_t(u32, (command & 0xff000000),
 				     (scratch & 0xff000000))));
 
 			/* disable SBA if it's not supported */
@@ -2674,8 +2674,8 @@
 			/* adjust RQ depth */
 			command =
 			    ((command & ~0xff000000) |
-			     min(u32, (mode & 0xff000000),
-				 min(u32, (command & 0xff000000),
+			     min_t(u32, (mode & 0xff000000),
+				 min_t(u32, (command & 0xff000000),
 				     (scratch & 0xff000000))));
 
 			/* disable SBA if it's not supported */
diff -urN linux-2.4.10-pre7/drivers/char/cyclades.c linux/drivers/char/cyclades.c
--- linux-2.4.10-pre7/drivers/char/cyclades.c	Wed Aug 15 01:22:15 2001
+++ linux/drivers/char/cyclades.c	Mon Dec  3 23:09:18 2001
@@ -1629,8 +1629,8 @@
 	       for performance, but because of buffer boundaries, there
 	       may be several steps to the operation */
 	    while(0 < (small_count = 
-		       min(unsigned int, (rx_bufsize - new_rx_get),
-		       min(unsigned int, (TTY_FLIPBUF_SIZE - tty->flip.count), char_count))
+		       min_t(unsigned int, (rx_bufsize - new_rx_get),
+		       min_t(unsigned int, (TTY_FLIPBUF_SIZE - tty->flip.count), char_count))
 		 )) {
 		memcpy_fromio(tty->flip.char_buf_ptr,
 			      (char *)(cinfo->base_addr
@@ -1724,9 +1724,9 @@
 	}
 #ifdef BLOCKMOVE
 	while(0 < (small_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))))) {
+		   min_t(unsigned int, (tx_bufsize - tx_put),
+		       min_t(unsigned int, (SERIAL_XMIT_SIZE - info->xmit_tail),
+			   min_t(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.10-pre7/drivers/char/dsp56k.c linux/drivers/char/dsp56k.c
--- linux-2.4.10-pre7/drivers/char/dsp56k.c	Mon Dec  3 23:09:08 2001
+++ linux/drivers/char/dsp56k.c	Mon Dec  3 23:09:18 2001
@@ -69,7 +69,7 @@
 { \
 	long i, t, m; \
 	while (count > 0) { \
-		m = min(unsigned long, count, maxio); \
+		m = min_t(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.10-pre7/drivers/char/ppdev.c linux/drivers/char/ppdev.c
--- linux-2.4.10-pre7/drivers/char/ppdev.c	Wed Aug 15 01:22:15 2001
+++ linux/drivers/char/ppdev.c	Mon Dec  3 23:09:18 2001
@@ -118,7 +118,7 @@
 		return -EINVAL;
 	}
 
-	kbuffer = kmalloc(min(unsigned int, count, PP_BUFFER_SIZE), GFP_KERNEL);
+	kbuffer = kmalloc(min_t(size_t, count, PP_BUFFER_SIZE), GFP_KERNEL);
 	if (!kbuffer) {
 		return -ENOMEM;
 	}
@@ -126,7 +126,7 @@
 	mode = pport->ieee1284.mode & ~(IEEE1284_DEVICEID | IEEE1284_ADDR);
 
 	while (bytes_read < count) {
-		ssize_t need = min(unsigned long, count - bytes_read, PP_BUFFER_SIZE);
+		ssize_t need = min_t(unsigned long, count - bytes_read, PP_BUFFER_SIZE);
 
 		if (mode == IEEE1284_MODE_EPP) {
 			/* various specials for EPP mode */
@@ -198,7 +198,7 @@
 		return -EINVAL;
 	}
 
-	kbuffer = kmalloc(min(unsigned int, count, PP_BUFFER_SIZE), GFP_KERNEL);
+	kbuffer = kmalloc(min_t(size_t, count, PP_BUFFER_SIZE), GFP_KERNEL);
 	if (!kbuffer) {
 		return -ENOMEM;
 	}
@@ -206,7 +206,7 @@
 	mode = pport->ieee1284.mode & ~(IEEE1284_DEVICEID | IEEE1284_ADDR);
 
 	while (bytes_written < count) {
-		ssize_t n = min(unsigned long, count - bytes_written, PP_BUFFER_SIZE);
+		ssize_t n = min_t(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.10-pre7/drivers/char/rio/riointr.c linux/drivers/char/rio/riointr.c
--- linux-2.4.10-pre7/drivers/char/rio/riointr.c	Wed Aug 15 01:22:15 2001
+++ linux/drivers/char/rio/riointr.c	Mon Dec  3 23:09:18 2001
@@ -819,7 +819,7 @@
 	  ** and available space.
 	  */
 			
-	  transCount = min(unsigned int, PacketP->len & PKT_LEN_MASK,
+	  transCount = min_t(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.10-pre7/drivers/i2o/i2o_block.c linux/drivers/i2o/i2o_block.c
--- linux-2.4.10-pre7/drivers/i2o/i2o_block.c	Mon Dec  3 23:09:08 2001
+++ linux/drivers/i2o/i2o_block.c	Mon Dec  3 23:09:19 2001
@@ -1141,6 +1141,8 @@
 	switch (cmd) {
 		case BLKGETSIZE:
 			return put_user(i2ob[minor].nr_sects, (long *) arg);
+		case BLKGETSIZE64:
+			return put_user((u64)i2ob[minor].nr_sects << 9, (u64 *)arg);
 
 		case HDIO_GETGEO:
 		{
diff -urN linux-2.4.10-pre7/drivers/ide/hd.c linux/drivers/ide/hd.c
--- linux-2.4.10-pre7/drivers/ide/hd.c	Mon Dec  3 23:09:08 2001
+++ linux/drivers/ide/hd.c	Mon Dec  3 23:09:19 2001
@@ -639,9 +639,11 @@
 		}
 
          	case BLKGETSIZE:   /* Return device size */
-			if (!arg)  return -EINVAL;
 			return put_user(hd[MINOR(inode->i_rdev)].nr_sects, 
 					(long *) arg);
+         	case BLKGETSIZE64:
+			return put_user((u64)hd[MINOR(inode->i_rdev)].nr_sects << 9, 
+					(u64 *) arg);
 
 		case BLKRRPART: /* Re-read partition tables */
 			if (!capable(CAP_SYS_ADMIN))
diff -urN linux-2.4.10-pre7/drivers/ide/ide.c linux/drivers/ide/ide.c
--- linux-2.4.10-pre7/drivers/ide/ide.c	Mon Dec  3 23:09:08 2001
+++ linux/drivers/ide/ide.c	Mon Dec  3 23:09:19 2001
@@ -2660,6 +2660,8 @@
 
 	 	case BLKGETSIZE:   /* Return device size */
 			return put_user(drive->part[MINOR(inode->i_rdev)&PARTN_MASK].nr_sects, (long *) arg);
+	 	case BLKGETSIZE64:
+			return put_user((u64)drive->part[MINOR(inode->i_rdev)&PARTN_MASK].nr_sects << 9, (u64 *) arg);
 
 		case BLKRRPART: /* Re-read partition tables */
 			if (!capable(CAP_SYS_ADMIN)) return -EACCES;
diff -urN linux-2.4.10-pre7/drivers/md/lvm-snap.c linux/drivers/md/lvm-snap.c
--- linux-2.4.10-pre7/drivers/md/lvm-snap.c	Wed Aug 15 01:22:15 2001
+++ linux/drivers/md/lvm-snap.c	Mon Dec  3 23:09:19 2001
@@ -386,8 +386,8 @@
 
 	blksize_org = lvm_get_blksize(org_phys_dev);
 	blksize_snap = lvm_get_blksize(snap_phys_dev);
-	max_blksize = max(int, blksize_org, blksize_snap);
-	min_blksize = min(int, blksize_org, blksize_snap);
+	max_blksize = max(blksize_org, blksize_snap);
+	min_blksize = min(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(int, chunk_size, max_sectors);
+		nr_sectors = min(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(unsigned long, buckets, max_buckets);
+	buckets = min(buckets, max_buckets);
 	while (buckets & (buckets-1))
 		buckets &= (buckets-1);
 
diff -urN linux-2.4.10-pre7/drivers/md/lvm.c linux/drivers/md/lvm.c
--- linux-2.4.10-pre7/drivers/md/lvm.c	Mon Dec  3 23:09:08 2001
+++ linux/drivers/md/lvm.c	Mon Dec  3 23:09:19 2001
@@ -877,6 +877,11 @@
 			return -EFAULT;
 		break;
 
+	case BLKGETSIZE64:
+		if (put_user((u64)lv_ptr->lv_size << 9, (u64 *)arg))
+			return -EFAULT;
+		break;
+
 
 	case BLKFLSBUF:
 		/* flush buffer cache */
diff -urN linux-2.4.10-pre7/drivers/md/md.c linux/drivers/md/md.c
--- linux-2.4.10-pre7/drivers/md/md.c	Mon Dec  3 23:09:08 2001
+++ linux/drivers/md/md.c	Mon Dec  3 23:09:19 2001
@@ -2478,6 +2478,11 @@
 						(long *) arg);
 			goto done;
 
+		case BLKGETSIZE64:   /* Return device size */
+			err = md_put_user((u64)md_hd_struct[minor].nr_sects << 9,
+						(u64 *) arg);
+			goto done;
+
 		case BLKRAGET:
 		case BLKRASET:
 		case BLKFLSBUF:
diff -urN linux-2.4.10-pre7/drivers/mtd/devices/docecc.c linux/drivers/mtd/devices/docecc.c
--- linux-2.4.10-pre7/drivers/mtd/devices/docecc.c	Wed Aug 15 01:22:15 2001
+++ linux/drivers/mtd/devices/docecc.c	Mon Dec  3 23:09:19 2001
@@ -402,7 +402,7 @@
     den = 0;
     
     /* lambda[i+1] for i even is the formal derivative lambda_pr of lambda[i] */
-    for (i = min(int, deg_lambda,NN-KK-1) & ~1; i >= 0; i -=2) {
+    for (i = min_t(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.10-pre7/drivers/mtd/ftl.c linux/drivers/mtd/ftl.c
--- linux-2.4.10-pre7/drivers/mtd/ftl.c	Mon Dec  3 23:09:08 2001
+++ linux/drivers/mtd/ftl.c	Mon Dec  3 23:09:19 2001
@@ -1174,10 +1174,10 @@
 	put_user(ftl_hd[minor].start_sect, (u_long *)&geo->start);
 	break;
     case BLKGETSIZE:
-	ret = verify_area(VERIFY_WRITE, (long *)arg, sizeof(long));
-	if (ret) return ret;
-	put_user(ftl_hd[minor].nr_sects, 
-		 (long *)arg);
+	ret = put_user(ftl_hd[minor].nr_sects, (long *)arg);
+	break;
+    case BLKGETSIZE64:
+	ret = put_user((u64)ftl_hd[minor].nr_sects << 9, (u64 *)arg);
 	break;
     case BLKRRPART:
 	ret = ftl_reread_partitions(minor);
diff -urN linux-2.4.10-pre7/drivers/mtd/mtdblock.c linux/drivers/mtd/mtdblock.c
--- linux-2.4.10-pre7/drivers/mtd/mtdblock.c	Sat Apr 28 11:27:54 2001
+++ linux/drivers/mtd/mtdblock.c	Mon Dec  3 23:09:19 2001
@@ -529,10 +529,9 @@
 
 	switch (cmd) {
 	case BLKGETSIZE:   /* Return device size */
-		if (!arg)
-			return -EFAULT;
-		return put_user((mtdblk->mtd->size >> 9),
-                                (long *) arg)?-EFAULT:0;
+		return put_user((mtdblk->mtd->size >> 9), (long *) arg);
+	case BLKGETSIZE64:
+		return put_user((u64)mtdblk->mtd->size, (u64 *)arg);
 		
 	case BLKFLSBUF:
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
diff -urN linux-2.4.10-pre7/drivers/mtd/mtdblock_ro.c linux/drivers/mtd/mtdblock_ro.c
--- linux-2.4.10-pre7/drivers/mtd/mtdblock_ro.c	Tue Jun 12 10:30:27 2001
+++ linux/drivers/mtd/mtdblock_ro.c	Mon Dec  3 23:09:19 2001
@@ -211,9 +211,9 @@
 
 	switch (cmd) {
 	case BLKGETSIZE:   /* Return device size */
-		if (!arg)  return -EFAULT;
-		return Put_user((mtd->size >> 9),
-                                (long *) arg);
+		return put_user((mtd->size >> 9), (long *) arg);
+	case BLKGETSIZE64:
+		return put_user((u64)mtd->size, (u64 *)arg);
 		
 	case BLKFLSBUF:
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
diff -urN linux-2.4.10-pre7/drivers/mtd/nftlcore.c linux/drivers/mtd/nftlcore.c
--- linux-2.4.10-pre7/drivers/mtd/nftlcore.c	Mon Dec  3 23:09:08 2001
+++ linux/drivers/mtd/nftlcore.c	Mon Dec  3 23:09:19 2001
@@ -791,9 +791,11 @@
 		return copy_to_user((void *)arg, &g, sizeof g) ? -EFAULT : 0;
 	}
 	case BLKGETSIZE:   /* Return device size */
-		if (!arg) return -EINVAL;
 		return put_user(part_table[MINOR(inode->i_rdev)].nr_sects,
                                 (long *) arg);
+	case BLKGETSIZE64:
+		return put_user((u64)part_table[MINOR(inode->i_rdev)].nr_sects << 9,
+                                (u64 *)arg);
 		
 	case BLKFLSBUF:
 		if (!capable(CAP_SYS_ADMIN)) return -EACCES;
diff -urN linux-2.4.10-pre7/drivers/net/acenic.c linux/drivers/net/acenic.c
--- linux-2.4.10-pre7/drivers/net/acenic.c	Wed Aug 15 01:22:15 2001
+++ linux/drivers/net/acenic.c	Mon Dec  3 23:09:19 2001
@@ -2995,8 +2995,8 @@
 		return;
 
 	while (size > 0) {
-		tsize = min(u32, ((~dest & (ACE_WINDOW_SIZE - 1)) + 1),
-			    min(u32, size, ACE_WINDOW_SIZE));
+		tsize = min_t(u32, ((~dest & (ACE_WINDOW_SIZE - 1)) + 1),
+			    min_t(u32, size, ACE_WINDOW_SIZE));
 		tdest = (unsigned long)&regs->Window +
 			(dest & (ACE_WINDOW_SIZE - 1));
 		writel(dest & ~(ACE_WINDOW_SIZE - 1), &regs->WinBase);
@@ -3026,8 +3026,8 @@
 		return;
 
 	while (size > 0) {
-		tsize = min(u32, ((~dest & (ACE_WINDOW_SIZE - 1)) + 1),
-			    min(u32, size, ACE_WINDOW_SIZE));
+		tsize = min_t(u32, ((~dest & (ACE_WINDOW_SIZE - 1)) + 1),
+			    min_t(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.10-pre7/drivers/net/de600.c linux/drivers/net/de600.c
--- linux-2.4.10-pre7/drivers/net/de600.c	Wed Aug 15 01:22:15 2001
+++ linux/drivers/net/de600.c	Mon Dec  3 23:09:19 2001
@@ -814,7 +814,7 @@
  */
 
 	if (atomic_read(&sk->rmem_alloc) >= sk->rcvbuf-2*DE600_MIN_WINDOW) return(0);
-	amt = min(int, (sk->rcvbuf-atomic_read(&sk->rmem_alloc))/2/*-DE600_MIN_WINDOW*/, DE600_MAX_WINDOW);
+	amt = min_t(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.10-pre7/drivers/net/dgrs.c linux/drivers/net/dgrs.c
--- linux-2.4.10-pre7/drivers/net/dgrs.c	Mon Dec  3 23:09:08 2001
+++ linux/drivers/net/dgrs.c	Mon Dec  3 23:09:19 2001
@@ -733,7 +733,7 @@
 			goto no_resources;
 		}
 
-		amt = min(unsigned int, len, rbdp->size - count);
+		amt = min_t(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.10-pre7/drivers/net/hamradio/baycom_epp.c linux/drivers/net/hamradio/baycom_epp.c
--- linux-2.4.10-pre7/drivers/net/hamradio/baycom_epp.c	Wed Aug 15 01:22:15 2001
+++ linux/drivers/net/hamradio/baycom_epp.c	Mon Dec  3 23:09:19 2001
@@ -610,7 +610,7 @@
 	while (cnt > 0) {
 		switch (bc->hdlctx.state) {
 		case tx_keyup:
-			i = min(int, cnt, bc->hdlctx.flags);
+			i = min_t(int, cnt, bc->hdlctx.flags);
 			cnt -= i;
 			bc->hdlctx.flags -= i;
 			if (bc->hdlctx.flags <= 0)
@@ -633,7 +633,7 @@
 					break;
 				}
 			}
-			i = min(int, cnt, bc->hdlctx.bufcnt);
+			i = min_t(int, cnt, bc->hdlctx.bufcnt);
 			bc->hdlctx.bufcnt -= i;
 			cnt -= i;
 			if (i != pp->ops->epp_write_data(pp, bc->hdlctx.bufptr, i, 0))
@@ -647,7 +647,7 @@
 				bc->hdlctx.state = tx_data;
 				break;
 			}
-			i = min(int, cnt, bc->hdlctx.flags);
+			i = min_t(int, cnt, bc->hdlctx.flags);
 			if (i) {
 				cnt -= i;
 				bc->hdlctx.flags -= i;
@@ -664,7 +664,7 @@
 		default:  /* fall through */
 			if (bc->hdlctx.calibrate <= 0)
 				return 0;
-			i = min(int, cnt, bc->hdlctx.calibrate);
+			i = min_t(int, cnt, bc->hdlctx.calibrate);
 			cnt -= i;
 			bc->hdlctx.calibrate -= i;
 			memset(tmp, 0, sizeof(tmp));
diff -urN linux-2.4.10-pre7/drivers/net/sk98lin/skproc.c linux/drivers/net/sk98lin/skproc.c
--- linux-2.4.10-pre7/drivers/net/sk98lin/skproc.c	Wed Aug 15 01:22:15 2001
+++ linux/drivers/net/sk98lin/skproc.c	Mon Dec  3 23:09:19 2001
@@ -293,7 +293,7 @@
 	if (buffer_length >= len - offset) {
 		*eof = 1;
 	}
-	return (min(int, buffer_length, len - offset));
+	return (min_t(int, buffer_length, len - offset));
 }
 
 
diff -urN linux-2.4.10-pre7/drivers/net/wan/comx-hw-comx.c linux/drivers/net/wan/comx-hw-comx.c
--- linux-2.4.10-pre7/drivers/net/wan/comx-hw-comx.c	Wed Aug 15 01:22:15 2001
+++ linux/drivers/net/wan/comx-hw-comx.c	Mon Dec  3 23:09:19 2001
@@ -1044,7 +1044,7 @@
 		if (!(page = (char *)__get_free_page(GFP_KERNEL))) {
 			return -ENOMEM;
 		}
-		if(copy_from_user(page, buffer, count = (min(int, count, PAGE_SIZE))))
+		if(copy_from_user(page, buffer, count = (min_t(int, count, PAGE_SIZE))))
 		{
 			count = -EFAULT;
 			goto out;
@@ -1182,8 +1182,8 @@
 			len = sprintf(page, "external\n");
 		}
 	} else if (strcmp(file->name, FILENAME_FIRMWARE) == 0) {
-		len = min(int, FILE_PAGESIZE,
-			  min(int, count, 
+		len = min_t(int, FILE_PAGESIZE,
+			  min_t(int, count, 
 			      hw->firmware ?
 			      (hw->firmware->len - off) : 0));
 		if (len < 0) {
@@ -1205,7 +1205,7 @@
 	if (count >= len - off) {
 		*eof = 1;
 	}
-	return min(int, count, len - off);
+	return min_t(int, count, len - off);
 }
 
 /* Called on echo comx >boardtype */
diff -urN linux-2.4.10-pre7/drivers/net/wan/comx-hw-locomx.c linux/drivers/net/wan/comx-hw-locomx.c
--- linux-2.4.10-pre7/drivers/net/wan/comx-hw-locomx.c	Wed Aug 15 01:22:15 2001
+++ linux/drivers/net/wan/comx-hw-locomx.c	Mon Dec  3 23:09:19 2001
@@ -324,7 +324,7 @@
 	if (count >= len - off) {
 		*eof = 1;
 	}
-	return min(int, count, len - off);
+	return min_t(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(unsigned long, count, PAGE_SIZE));
+	copy_from_user(page, buffer, count = min_t(unsigned long, count, PAGE_SIZE));
 	if (*(page + count - 1) == '\n') {
 		*(page + count - 1) = 0;
 	}
diff -urN linux-2.4.10-pre7/drivers/net/wan/comx-hw-mixcom.c linux/drivers/net/wan/comx-hw-mixcom.c
--- linux-2.4.10-pre7/drivers/net/wan/comx-hw-mixcom.c	Wed Aug 15 01:22:15 2001
+++ linux/drivers/net/wan/comx-hw-mixcom.c	Mon Dec  3 23:09:19 2001
@@ -121,7 +121,7 @@
 
 
 	outsb(dev->base_addr + HSCX_FIFO,
-        	&(hw->sending->data[hw->tx_ptr]), min(unsigned int, to_send, 32));
+        	&(hw->sending->data[hw->tx_ptr]), min_t(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(int, count, len - off);
+	return min_t(int, count, len - off);
 }
 
 
@@ -763,7 +763,7 @@
 		return -ENOMEM;
 	}
 
-	copy_from_user(page, buffer, count = min(unsigned long, count, PAGE_SIZE));
+	copy_from_user(page, buffer, count = min_t(unsigned long, count, PAGE_SIZE));
 	if (*(page + count - 1) == '\n') {
 		*(page + count - 1) = 0;
 	}
diff -urN linux-2.4.10-pre7/drivers/net/wan/comx-proto-fr.c linux/drivers/net/wan/comx-proto-fr.c
--- linux-2.4.10-pre7/drivers/net/wan/comx-proto-fr.c	Wed Aug 15 01:22:15 2001
+++ linux/drivers/net/wan/comx-proto-fr.c	Mon Dec  3 23:09:19 2001
@@ -634,7 +634,7 @@
 
 	*start = page + off;
 	if (count >= len - off) *eof = 1;
-	return min(int, count, len - off);
+	return min_t(int, count, len - off);
 }
 
 static int fr_write_proc(struct file *file, const char *buffer, 
diff -urN linux-2.4.10-pre7/drivers/net/wan/comx-proto-lapb.c linux/drivers/net/wan/comx-proto-lapb.c
--- linux-2.4.10-pre7/drivers/net/wan/comx-proto-lapb.c	Wed Aug 15 01:22:15 2001
+++ linux/drivers/net/wan/comx-proto-lapb.c	Mon Dec  3 23:09:19 2001
@@ -212,7 +212,7 @@
 	if (count >= len - off) {
 		*eof = 1;
 	}
-	return min(int, count, len - off);
+	return min_t(int, count, len - off);
 }
 
 static int comxlapb_write_proc(struct file *file, const char *buffer, 
diff -urN linux-2.4.10-pre7/drivers/net/wan/comx.c linux/drivers/net/wan/comx.c
--- linux-2.4.10-pre7/drivers/net/wan/comx.c	Wed Aug 15 01:22:15 2001
+++ linux/drivers/net/wan/comx.c	Mon Dec  3 23:09:19 2001
@@ -151,8 +151,8 @@
 		int free = (ch->debug_start - ch->debug_end + ch->debug_size) 
 			% ch->debug_size;
 
-		to_copy = min(int, free ? free : ch->debug_size, 
-			      min(int, ch->debug_size - ch->debug_end, len));
+		to_copy = min_t(int, free ? free : ch->debug_size, 
+			      min_t(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(int, count, len - off);
+	return min_t(int, count, len - off);
 }
 
 
@@ -597,7 +597,7 @@
 	if (count >= len - off) {
 		*eof = 1;
 	}
-	return min(int, count, len - off);
+	return min_t(int, count, len - off);
 }
 
 
diff -urN linux-2.4.10-pre7/drivers/net/wan/cycx_main.c linux/drivers/net/wan/cycx_main.c
--- linux-2.4.10-pre7/drivers/net/wan/cycx_main.c	Wed Aug 15 01:22:15 2001
+++ linux/drivers/net/wan/cycx_main.c	Mon Dec  3 23:09:19 2001
@@ -111,8 +111,8 @@
 		fullname, DRV_VERSION, DRV_RELEASE, copyright);
 
 	/* Verify number of cards and allocate adapter data space */
-	ncards = min(int, ncards, MAX_CARDS);
-	ncards = max(int, ncards, 1);
+	ncards = min_t(int, ncards, MAX_CARDS);
+	ncards = max_t(int, ncards, 1);
 	card_array = kmalloc(sizeof(cycx_t) * ncards, GFP_KERNEL);
 	if (!card_array)
 		goto out;
diff -urN linux-2.4.10-pre7/drivers/net/wan/cycx_x25.c linux/drivers/net/wan/cycx_x25.c
--- linux-2.4.10-pre7/drivers/net/wan/cycx_x25.c	Wed Aug 15 01:22:15 2001
+++ linux/drivers/net/wan/cycx_x25.c	Mon Dec  3 23:09:19 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(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);
+		card->u.x.hi_pvc = min_t(unsigned int, conf->u.x25.hi_pvc, 4095);
+		card->u.x.lo_pvc = min_t(unsigned int, conf->u.x25.lo_pvc, card->u.x.hi_pvc);
 	}
 
 	if (conf->u.x25.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);
+		card->u.x.hi_svc = min_t(unsigned int, conf->u.x25.hi_svc, 4095);
+		card->u.x.lo_svc = min_t(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(unsigned int, conf->u.x25.hdlc_window, 7);
+		cfg.n2win = min_t(unsigned int, conf->u.x25.hdlc_window, 7);
 
 	if (conf->u.x25.pkt_window)
-		cfg.n3win = min(unsigned int, conf->u.x25.pkt_window, 7);
+		cfg.n3win = min_t(unsigned int, conf->u.x25.pkt_window, 7);
 
 	if (conf->u.x25.t1)
-		cfg.t1 = min(unsigned int, conf->u.x25.t1, 30);
+		cfg.t1 = min_t(unsigned int, conf->u.x25.t1, 30);
 
 	if (conf->u.x25.t2)
-		cfg.t2 = min(unsigned int, conf->u.x25.t2, 30);
+		cfg.t2 = min_t(unsigned int, conf->u.x25.t2, 30);
 
 	if (conf->u.x25.t11_t21)
-		cfg.t21 = min(unsigned int, conf->u.x25.t11_t21, 30);
+		cfg.t21 = min_t(unsigned int, conf->u.x25.t11_t21, 30);
 
 	if (conf->u.x25.t13_t23)
-		cfg.t23 = min(unsigned int, conf->u.x25.t13_t23, 30);
+		cfg.t23 = min_t(unsigned int, conf->u.x25.t13_t23, 30);
 
 	if (conf->u.x25.n2)
-		cfg.n2 = min(unsigned int, conf->u.x25.n2, 30);
+		cfg.n2 = min_t(unsigned int, conf->u.x25.n2, 30);
 
 	/* initialize adapter */
 	if (x25_configure(card, &cfg))
diff -urN linux-2.4.10-pre7/drivers/net/wan/sbni.c linux/drivers/net/wan/sbni.c
--- linux-2.4.10-pre7/drivers/net/wan/sbni.c	Mon Dec  3 23:09:09 2001
+++ linux/drivers/net/wan/sbni.c	Mon Dec  3 23:09:19 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(unsigned int, skb->len - nl->outpos, nl->framelen);
+	unsigned  len = min_t(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,7 +760,7 @@
 			nl->outpos += nl->framelen;
 
 			if( --nl->tx_frameno )
-				nl->framelen = min(unsigned int,
+				nl->framelen = min_t(unsigned int,
 						   nl->maxframe,
 						   nl->tx_buf_p->len - nl->outpos);
 			else
diff -urN linux-2.4.10-pre7/drivers/net/wan/sdla_chdlc.c linux/drivers/net/wan/sdla_chdlc.c
--- linux-2.4.10-pre7/drivers/net/wan/sdla_chdlc.c	Mon Dec  3 23:09:09 2001
+++ linux/drivers/net/wan/sdla_chdlc.c	Mon Dec  3 23:09:19 2001
@@ -506,13 +506,13 @@
 		/* For Primary Port 0 */
 		card->wandev.mtu =
 			(conf->mtu >= MIN_LGTH_CHDLC_DATA_CFG) ?
-			min(unsigned int, conf->mtu, PRI_MAX_NO_DATA_BYTES_IN_FRAME) :
+			min_t(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(unsigned int, conf->mtu, SEC_MAX_NO_DATA_BYTES_IN_FRAME) :
+			min_t(unsigned int, conf->mtu, SEC_MAX_NO_DATA_BYTES_IN_FRAME) :
 			CHDLC_DFLT_DATA_LEN;
 	}
 
@@ -828,19 +828,19 @@
 			card->u.c.kpalv_tx =
 				((conf->keepalive_tx_tmr - MIN_Tx_KPALV_TIMER)
 				>= 0) ?
-	   			min(unsigned int, conf->keepalive_tx_tmr,MAX_Tx_KPALV_TIMER) :
+	   			min_t(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(unsigned int, conf->keepalive_rx_tmr,MAX_Rx_KPALV_TIMER) :
+	   			min_t(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(unsigned int, conf->keepalive_err_margin,
+	   			min_t(unsigned int, conf->keepalive_err_margin,
 				MAX_KPALV_ERR_TOL) : 
 	   			DEFAULT_KPALV_ERR_TOL;
 		}
@@ -848,7 +848,7 @@
 		/* Setup slarp timer to control delay between slarps */
 		card->u.c.slarp_timer = 
 			((conf->slarp_timer - MIN_SLARP_REQ_TIMER) >= 0) ?
-			min(unsigned int, conf->slarp_timer, MAX_SLARP_REQ_TIMER) :
+			min_t(unsigned int, conf->slarp_timer, MAX_SLARP_REQ_TIMER) :
 			DEFAULT_SLARP_REQ_TIMER;
 
 #ifdef LINUX_2_0
diff -urN linux-2.4.10-pre7/drivers/net/wan/sdla_fr.c linux/drivers/net/wan/sdla_fr.c
--- linux-2.4.10-pre7/drivers/net/wan/sdla_fr.c	Mon Dec  3 23:09:09 2001
+++ linux/drivers/net/wan/sdla_fr.c	Mon Dec  3 23:09:19 2001
@@ -549,10 +549,10 @@
 	/* Adjust configuration */
 	conf->mtu += FR_HEADER_LEN;
 	conf->mtu = (conf->mtu >= MIN_LGTH_FR_DATA_CFG) ?
-			min(unsigned int, conf->mtu, FR_MAX_NO_DATA_BYTES_IN_FRAME) :
+			min_t(unsigned int, conf->mtu, FR_MAX_NO_DATA_BYTES_IN_FRAME) :
                         FR_CHANNEL_MTU + FR_HEADER_LEN;
      
-	conf->bps = min(unsigned int, conf->bps, 2048000);
+	conf->bps = min_t(unsigned int, conf->bps, 2048000);
 
 	/* Initialze the configuration structure sent to the board to zero */
 	memset(&u.cfg, 0, sizeof(u.cfg));
@@ -619,7 +619,7 @@
 		 * command in fr_configure() routine. 
 		 */
 
-		card->u.f.dlci_num  = min(unsigned int, max(unsigned int, conf->u.fr.dlci_num, 1), 100);
+		card->u.f.dlci_num  = min_t(unsigned int, max_t(unsigned int, conf->u.fr.dlci_num, 1), 100);
 	
 		for ( i = 0; i < card->u.f.dlci_num; i++) {
 
@@ -636,27 +636,27 @@
 		u.cfg.port |= 0x0002;
 
 	if (conf->u.fr.t391)
-		u.cfg.t391 = min(unsigned int, conf->u.fr.t391, 30);
+		u.cfg.t391 = min_t(unsigned int, conf->u.fr.t391, 30);
 	else
 		u.cfg.t391 = 5;
 
 	if (conf->u.fr.t392)
-		u.cfg.t392 = min(unsigned int, conf->u.fr.t392, 30);
+		u.cfg.t392 = min_t(unsigned int, conf->u.fr.t392, 30);
 	else
 		u.cfg.t392 = 15;
 
 	if (conf->u.fr.n391)
-		u.cfg.n391 = min(unsigned int, conf->u.fr.n391, 255);
+		u.cfg.n391 = min_t(unsigned int, conf->u.fr.n391, 255);
 	else
 		u.cfg.n391 = 2;
 
 	if (conf->u.fr.n392)
-		u.cfg.n392 = min(unsigned int, conf->u.fr.n392, 10);
+		u.cfg.n392 = min_t(unsigned int, conf->u.fr.n392, 10);
 	else
 		u.cfg.n392 = 3;	
 
 	if (conf->u.fr.n393)
-		u.cfg.n393 = min(unsigned int, conf->u.fr.n393, 10);
+		u.cfg.n393 = min_t(unsigned int, conf->u.fr.n393, 10);
 	else
 		u.cfg.n393 = 4;
 
@@ -953,8 +953,8 @@
          */
 	if (conf->cir) {
 
-		chan->cir = max(unsigned int, 1,
-				min(unsigned int, conf->cir, 512));
+		chan->cir = max_t(unsigned int, 1,
+				min_t(unsigned int, conf->cir, 512));
 		chan->cir_status = CIR_ENABLED; 
 
 		
@@ -965,8 +965,8 @@
 		chan->bc = chan->cir;
 
 		if (conf->be){
-			chan->be = max(unsigned int,
-				       0, min(unsigned int, conf->be, 511));
+			chan->be = max_t(unsigned int,
+				       0, min_t(unsigned int, conf->be, 511));
 		}else{	
 			conf->be = 0;
 		}
diff -urN linux-2.4.10-pre7/drivers/net/wan/sdla_ppp.c linux/drivers/net/wan/sdla_ppp.c
--- linux-2.4.10-pre7/drivers/net/wan/sdla_ppp.c	Mon Dec  3 23:09:09 2001
+++ linux/drivers/net/wan/sdla_ppp.c	Mon Dec  3 23:09:19 2001
@@ -401,7 +401,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(unsigned int, conf->mtu, PPP_MAX_MTU) : PPP_DFLT_MTU;
+		min_t(unsigned int, conf->mtu, PPP_MAX_MTU) : PPP_DFLT_MTU;
 
 	card->wandev.bps	= conf->bps;
 	card->wandev.interface	= conf->interface;
@@ -630,7 +630,7 @@
 	
 	dev->init = &if_init;
 	dev->priv = ppp_priv_area;
-	dev->mtu = min(unsigned int, dev->mtu, card->wandev.mtu);
+	dev->mtu = min_t(unsigned int, dev->mtu, card->wandev.mtu);
 
 	/* Initialize the polling task routine */
 #ifndef LINUX_2_4
diff -urN linux-2.4.10-pre7/drivers/net/wan/sdla_x25.c linux/drivers/net/wan/sdla_x25.c
--- linux-2.4.10-pre7/drivers/net/wan/sdla_x25.c	Mon Dec  3 23:09:09 2001
+++ linux/drivers/net/wan/sdla_x25.c	Mon Dec  3 23:09:19 2001
@@ -654,13 +654,13 @@
 	u.cfg.defPktSize = u.cfg.pktMTU = card->wandev.mtu;
 
 	if (conf->u.x25.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);
+		card->u.x.hi_pvc = min_t(unsigned int, conf->u.x25.hi_pvc, MAX_LCN_NUM);
+		card->u.x.lo_pvc = min_t(unsigned int, conf->u.x25.lo_pvc, card->u.x.hi_pvc);
 	}
 
 	if (conf->u.x25.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);
+		card->u.x.hi_svc = min_t(unsigned int, conf->u.x25.hi_svc, MAX_LCN_NUM);
+		card->u.x.lo_svc = min_t(unsigned int, conf->u.x25.lo_svc, card->u.x.hi_svc);
 	}
 
 	/* Figure out the total number of channels to configure */
@@ -685,38 +685,38 @@
 	u.cfg.hiTwoWaySVC = card->u.x.hi_svc;
 
 	if (conf->u.x25.hdlc_window)
-		u.cfg.hdlcWindow = min(unsigned int, conf->u.x25.hdlc_window, 7);
+		u.cfg.hdlcWindow = min_t(unsigned int, conf->u.x25.hdlc_window, 7);
 	if (conf->u.x25.pkt_window)
-		u.cfg.pktWindow = min(unsigned int, conf->u.x25.pkt_window, 7);
+		u.cfg.pktWindow = min_t(unsigned int, conf->u.x25.pkt_window, 7);
 
 	if (conf->u.x25.t1)
-		u.cfg.t1 = min(unsigned int, conf->u.x25.t1, 30);
+		u.cfg.t1 = min_t(unsigned int, conf->u.x25.t1, 30);
 	if (conf->u.x25.t2)
-		u.cfg.t2 = min(unsigned int, conf->u.x25.t2, 29);
+		u.cfg.t2 = min_t(unsigned int, conf->u.x25.t2, 29);
 	if (conf->u.x25.t4)
-		u.cfg.t4 = min(unsigned int, conf->u.x25.t4, 240);
+		u.cfg.t4 = min_t(unsigned int, conf->u.x25.t4, 240);
 	if (conf->u.x25.n2)
-		u.cfg.n2 = min(unsigned int, conf->u.x25.n2, 30);
+		u.cfg.n2 = min_t(unsigned int, conf->u.x25.n2, 30);
 
 	if (conf->u.x25.t10_t20)
-		u.cfg.t10t20 = min(unsigned int, conf->u.x25.t10_t20,255);
+		u.cfg.t10t20 = min_t(unsigned int, conf->u.x25.t10_t20,255);
 	if (conf->u.x25.t11_t21)
-		u.cfg.t11t21 = min(unsigned int, conf->u.x25.t11_t21,255);
+		u.cfg.t11t21 = min_t(unsigned int, conf->u.x25.t11_t21,255);
 	if (conf->u.x25.t12_t22)
-		u.cfg.t12t22 = min(unsigned int, conf->u.x25.t12_t22,255);
+		u.cfg.t12t22 = min_t(unsigned int, conf->u.x25.t12_t22,255);
 	if (conf->u.x25.t13_t23)	
-		u.cfg.t13t23 = min(unsigned int, conf->u.x25.t13_t23,255);
+		u.cfg.t13t23 = min_t(unsigned int, conf->u.x25.t13_t23,255);
 	if (conf->u.x25.t16_t26)
-		u.cfg.t16t26 = min(unsigned int, conf->u.x25.t16_t26, 255);
+		u.cfg.t16t26 = min_t(unsigned int, conf->u.x25.t16_t26, 255);
 	if (conf->u.x25.t28)
-		u.cfg.t28 = min(unsigned int, conf->u.x25.t28, 255);
+		u.cfg.t28 = min_t(unsigned int, conf->u.x25.t28, 255);
 
 	if (conf->u.x25.r10_r20)
-		u.cfg.r10r20 = min(unsigned int, conf->u.x25.r10_r20,250);
+		u.cfg.r10r20 = min_t(unsigned int, conf->u.x25.r10_r20,250);
 	if (conf->u.x25.r12_r22)
-		u.cfg.r12r22 = min(unsigned int, conf->u.x25.r12_r22,250);
+		u.cfg.r12r22 = min_t(unsigned int, conf->u.x25.r12_r22,250);
 	if (conf->u.x25.r13_r23)
-		u.cfg.r13r23 = min(unsigned int, conf->u.x25.r13_r23,250);
+		u.cfg.r13r23 = min_t(unsigned int, conf->u.x25.r13_r23,250);
 
 
 	if (conf->u.x25.ccitt_compat)
diff -urN linux-2.4.10-pre7/drivers/net/wan/wanpipe_multppp.c linux/drivers/net/wan/wanpipe_multppp.c
--- linux-2.4.10-pre7/drivers/net/wan/wanpipe_multppp.c	Mon Dec  3 23:09:09 2001
+++ linux/drivers/net/wan/wanpipe_multppp.c	Mon Dec  3 23:09:19 2001
@@ -376,13 +376,13 @@
 		/* For Primary Port 0 */
 		card->wandev.mtu =
 			(conf->mtu >= MIN_LGTH_CHDLC_DATA_CFG) ?
-			min(unsigned int, conf->mtu, PRI_MAX_NO_DATA_BYTES_IN_FRAME) :
+			min_t(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(unsigned int, conf->mtu, SEC_MAX_NO_DATA_BYTES_IN_FRAME) :
+			min_t(unsigned int, conf->mtu, SEC_MAX_NO_DATA_BYTES_IN_FRAME) :
 			CHDLC_DFLT_DATA_LEN;
 	}
 
diff -urN linux-2.4.10-pre7/drivers/net/wireless/airo.c linux/drivers/net/wireless/airo.c
--- linux-2.4.10-pre7/drivers/net/wireless/airo.c	Wed Aug 15 01:22:16 2001
+++ linux/drivers/net/wireless/airo.c	Mon Dec  3 23:09:19 2001
@@ -1753,7 +1753,7 @@
 	// read the rid length field
 	bap_read(ai, pBuf, 2, BAP1);
 	// length for remaining part of rid
-	len = min(unsigned int, len, le16_to_cpu(*(u16*)pBuf)) - 2;
+	len = min_t(unsigned int, len, le16_to_cpu(*(u16*)pBuf)) - 2;
 	
 	if ( len <= 2 ) {
 		printk( KERN_ERR 
@@ -3997,7 +3997,7 @@
 	 */
 
 	if (copy_to_user(comp->data, iobuf,
-			 min(unsigned int, comp->len, sizeof(iobuf))))
+			 min_t(unsigned int, comp->len, sizeof(iobuf))))
 		return -EFAULT;
 	return 0;
 }
@@ -4057,7 +4057,7 @@
 		PC4500_readrid(dev->priv,ridcode,iobuf,sizeof(iobuf));
 
 		if (copy_to_user(comp->data, iobuf,
-				 min(unsigned int, comp->len, sizeof(iobuf))))
+				 min_t(unsigned int, comp->len, sizeof(iobuf))))
 			return -EFAULT;
 		return 0;
 
diff -urN linux-2.4.10-pre7/drivers/s390/block/dasd.c linux/drivers/s390/block/dasd.c
--- linux-2.4.10-pre7/drivers/s390/block/dasd.c	Mon Dec  3 23:09:09 2001
+++ linux/drivers/s390/block/dasd.c	Mon Dec  3 23:09:19 2001
@@ -2175,11 +2175,13 @@
 	case BLKGETSIZE:{	/* Return device size */
 			long blocks = major_info->gendisk.sizes 
                                       [MINOR (inp->i_rdev)] << 1;
-			rc =
-			    copy_to_user ((long *) data, &blocks,
-					  sizeof (long));
-			if (rc)
-				rc = -EFAULT;
+			rc = put_user(blocks, (long *)arg);
+			break;
+		}
+	case BLKGETSIZE64:{
+			u64 blocks = major_info->gendisk.sizes 
+                                      [MINOR (inp->i_rdev)];
+			rc = put_user(blocks << 10, (u64 *)arg);
 			break;
 		}
 	case BLKRRPART:{
diff -urN linux-2.4.10-pre7/drivers/s390/block/xpram.c linux/drivers/s390/block/xpram.c
--- linux-2.4.10-pre7/drivers/s390/block/xpram.c	Mon Dec  3 23:09:09 2001
+++ linux/drivers/s390/block/xpram.c	Mon Dec  3 23:09:19 2001
@@ -647,14 +647,14 @@
 
 	case BLKGETSIZE:  /* 0x1260 */
 		/* Return the device size, expressed in sectors */
-		if (!arg) return -EINVAL; /* NULL pointer: not valid */
-		err= 0; /* verify_area_20(VERIFY_WRITE, (long *) arg, sizeof(long)); 
-			 *  if (err) return err;
-			 */
-		put_user ( 1024* xpram_sizes[MINOR(inode->i_rdev)]
+		return put_user( 1024* xpram_sizes[MINOR(inode->i_rdev)]
                            / XPRAM_SOFTSECT,
 			   (long *) arg);
-		return 0;
+
+	case BLKGETSIZE64:
+		return put_user( (u64)(1024* xpram_sizes[MINOR(inode->i_rdev)]
+                           / XPRAM_SOFTSECT) << 9,
+			   (u64 *) arg);
 
 	case BLKFLSBUF: /* flush, 0x1261 */
 		fsync_dev(inode->i_rdev);
diff -urN linux-2.4.10-pre7/drivers/s390/net/iucv.c linux/drivers/s390/net/iucv.c
--- linux-2.4.10-pre7/drivers/s390/net/iucv.c	Wed Aug 15 01:22:16 2001
+++ linux/drivers/s390/net/iucv.c	Mon Dec  3 23:09:19 2001
@@ -1309,7 +1309,7 @@
 			if (residual_buffer)
 				*residual_buffer = parm.ipbfadr1;
 		} else {
-			moved = min(unsigned int, buflen, 8);
+			moved = min_t(unsigned int, buflen, 8);
 
 			memcpy ((char *) buffer,
 				(char *) &parm.ipbfadr1, moved);
@@ -1402,7 +1402,7 @@
 
 			while ((moved < 8) && (moved < buflen)) {
 				dyn_len =
-				    min(unsigned int,
+				    min_t(unsigned int,
 					(buffer + i)->length, need_to_move);
 
 				memcpy ((char *)((ulong)((buffer + i)->address)),
diff -urN linux-2.4.10-pre7/drivers/s390/net/netiucv.c linux/drivers/s390/net/netiucv.c
--- linux-2.4.10-pre7/drivers/s390/net/netiucv.c	Wed Aug 15 01:22:16 2001
+++ linux/drivers/s390/net/netiucv.c	Mon Dec  3 23:09:19 2001
@@ -828,7 +828,7 @@
 
 	memset (iucv_userid[devnumber], ' ', 8);
 	memcpy (iucv_userid[devnumber], userid,
-		min(unsigned int, strlen(userid), 8));
+		min_t(unsigned int, strlen(userid), 8));
 	dev = &iucv_netdev[devnumber];
 	sprintf (dev->name, "iucv%i", devnumber);
 
diff -urN linux-2.4.10-pre7/drivers/sbus/char/jsflash.c linux/drivers/sbus/char/jsflash.c
--- linux-2.4.10-pre7/drivers/sbus/char/jsflash.c	Fri Feb  9 11:30:23 2001
+++ linux/drivers/sbus/char/jsflash.c	Mon Dec  3 23:09:19 2001
@@ -454,6 +454,8 @@
 	switch (cmd) {
 	case BLKGETSIZE:
 		return put_user(jsfd_bytesizes[dev] >> 9, (long *) arg);
+	case BLKGETSIZE64:
+		return put_user(jsfd_bytesizes[dev], (u64 *) arg);
 
 #if 0
 	case BLKROSET:
diff -urN linux-2.4.10-pre7/drivers/scsi/eata_pio.c linux/drivers/scsi/eata_pio.c
--- linux-2.4.10-pre7/drivers/scsi/eata_pio.c	Wed Aug 15 01:22:16 2001
+++ linux/drivers/scsi/eata_pio.c	Mon Dec  3 23:09:19 2001
@@ -161,7 +161,7 @@
 			    IncStat(&cmd->SCp,1);
 			    odd=FALSE;
 			}
-			x=min(unsigned int,z,cmd->SCp.this_residual/2);
+			x=min_t(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(unsigned int,z,cmd->SCp.this_residual/2);
+			x=min_t(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.10-pre7/drivers/scsi/sd.c linux/drivers/scsi/sd.c
--- linux-2.4.10-pre7/drivers/scsi/sd.c	Mon Dec  3 23:09:09 2001
+++ linux/drivers/scsi/sd.c	Mon Dec  3 23:09:19 2001
@@ -90,6 +90,7 @@
 static int *sd_sizes;
 static int *sd_blocksizes;
 static int *sd_hardsizes;	/* Hardware sector size */
+static int *sd_max_sectors;
 
 static int check_scsidisk_media_change(kdev_t);
 static int fop_revalidate_scsidisk(kdev_t);
@@ -227,9 +228,9 @@
 			return 0;
 		}
 		case BLKGETSIZE:   /* Return device size */
-			if (!arg)
-				return -EINVAL;
 			return put_user(sd[SD_PARTITION(inode->i_rdev)].nr_sects, (long *) arg);
+		case BLKGETSIZE64:
+			return put_user((u64)sd[SD_PARTITION(inode->i_rdev)].nr_sects << 9, (u64 *)arg);
 
 		case BLKROSET:
 		case BLKROGET:
@@ -1100,15 +1101,30 @@
 	if (!sd_hardsizes)
 		goto cleanup_blocksizes;
 
+	sd_max_sectors = kmalloc((sd_template.dev_max << 4) * sizeof(int), GFP_ATOMIC);
+	if (!sd_max_sectors)
+		goto cleanup_max_sectors;
+
 	for (i = 0; i < sd_template.dev_max << 4; i++) {
 		sd_blocksizes[i] = 1024;
 		sd_hardsizes[i] = 512;
+		/*
+		 * Allow lowlevel device drivers to generate 512k large scsi
+		 * commands if they know what they're doing and they ask for it
+		 * explicitly via the SHpnt->max_sectors API.
+		 */
+		sd_max_sectors[i] = MAX_SEGMENTS*8;
 	}
 
 	for (i = 0; i < N_USED_SD_MAJORS; i++) {
 		blksize_size[SD_MAJOR(i)] = sd_blocksizes + i * (SCSI_DISKS_PER_MAJOR << 4);
 		hardsect_size[SD_MAJOR(i)] = sd_hardsizes + i * (SCSI_DISKS_PER_MAJOR << 4);
+		max_sectors[SD_MAJOR(i)] = sd_max_sectors + i * (SCSI_DISKS_PER_MAJOR << 4);
 	}
+	/*
+	 * FIXME: should unregister blksize_size, hardsect_size and max_sectors when
+	 * the module is unloaded.
+	 */
 	sd = kmalloc((sd_template.dev_max << 4) *
 					  sizeof(struct hd_struct),
 					  GFP_ATOMIC);
@@ -1158,6 +1174,8 @@
 cleanup_sd_gendisks:
 	kfree(sd);
 cleanup_sd:
+	kfree(sd_max_sectors);
+cleanup_max_sectors:
 	kfree(sd_hardsizes);
 cleanup_blocksizes:
 	kfree(sd_blocksizes);
diff -urN linux-2.4.10-pre7/drivers/scsi/sr_ioctl.c linux/drivers/scsi/sr_ioctl.c
--- linux-2.4.10-pre7/drivers/scsi/sr_ioctl.c	Wed Aug 15 09:51:27 2001
+++ linux/drivers/scsi/sr_ioctl.c	Mon Dec  3 23:09:19 2001
@@ -546,6 +546,8 @@
 	switch (cmd) {
 	case BLKGETSIZE:
 		return put_user(scsi_CDs[target].capacity, (long *) arg);
+	case BLKGETSIZE64:
+		return put_user((u64)scsi_CDs[target].capacity << 9, (u64 *)arg);
 	case BLKROSET:
 	case BLKROGET:
 	case BLKRASET:
diff -urN linux-2.4.10-pre7/drivers/scsi/sym53c8xx.h linux/drivers/scsi/sym53c8xx.h
--- linux-2.4.10-pre7/drivers/scsi/sym53c8xx.h	Wed Aug 15 14:23:24 2001
+++ linux/drivers/scsi/sym53c8xx.h	Mon Dec  3 23:09:19 2001
@@ -96,6 +96,7 @@
 			this_id:        7,			\
 			sg_tablesize:   SCSI_NCR_SG_TABLESIZE,	\
 			cmd_per_lun:    SCSI_NCR_CMD_PER_LUN,	\
+			max_sectors:    MAX_SEGMENTS*8,		\
 			use_clustering: DISABLE_CLUSTERING} 
 
 #else
diff -urN linux-2.4.10-pre7/drivers/sound/dmasound/dmasound_atari.c linux/drivers/sound/dmasound/dmasound_atari.c
--- linux-2.4.10-pre7/drivers/sound/dmasound/dmasound_atari.c	Wed Aug 15 01:22:16 2001
+++ linux/drivers/sound/dmasound/dmasound_atari.c	Mon Dec  3 23:09:19 2001
@@ -154,7 +154,7 @@
 	ssize_t count, used;
 	u_char *p = &frame[*frameUsed];
 
-	count = min(unsigned long, userCount, frameLeft);
+	count = min_t(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(unsigned long, userCount, frameLeft);
+	count = min_t(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(unsigned long, userCount, frameLeft);
+		count = min_t(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(unsigned long, userCount, frameLeft)>>1;
+		count = min_t(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(unsigned long, userCount, frameLeft)>>1;
+		count = min_t(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(unsigned long, userCount, frameLeft) & ~3;
+		count = min_t(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(unsigned long, userCount, frameLeft)>>1;
+		count = min_t(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(unsigned long, userCount, frameLeft)>>2;
+		count = min_t(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(unsigned long, userCount, frameLeft)>>1;
+		count = min_t(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(unsigned long, userCount, frameLeft)>>2;
+		count = min_t(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(unsigned long, userCount, frameLeft)>>1;
+		count = min_t(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(unsigned long, userCount, frameLeft)>>2;
+		count = min_t(unsigned long, userCount, frameLeft)>>2;
 		used = count;
 		while (count > 0) {
 			u_long data;
diff -urN linux-2.4.10-pre7/drivers/sound/dmasound/dmasound_awacs.c linux/drivers/sound/dmasound/dmasound_awacs.c
--- linux-2.4.10-pre7/drivers/sound/dmasound/dmasound_awacs.c	Wed Aug 15 01:22:16 2001
+++ linux/drivers/sound/dmasound/dmasound_awacs.c	Mon Dec  3 23:09:19 2001
@@ -267,7 +267,7 @@
 	frameLeft >>= 2;
 	if (stereo)
 		userCount >>= 1;
-	used = count = min(unsigned long, userCount, frameLeft);
+	used = count = min_t(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(unsigned long, userCount, frameLeft);
+	used = count = min_t(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(unsigned long, userCount, frameLeft);
+	used = count = min_t(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(unsigned long, userCount, frameLeft);
+	used = count = min_t(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(unsigned long, userCount, frameLeft);
+	used = count = min_t(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(unsigned long, userCount, frameLeft);
+	used = count = min_t(unsigned long, userCount, frameLeft);
 	while (count > 0) {
 		u_char data;
 
@@ -681,7 +681,7 @@
 	frameLeft >>= 2;
 	if (stereo)
 		userCount >>= 1;
-	used = count = min(unsigned long, userCount, frameLeft);
+	used = count = min_t(unsigned long, userCount, frameLeft);
 	while (count > 0) {
 		u_char data;
 
@@ -713,7 +713,7 @@
 
 	frameLeft >>= 2;
 	userCount >>= (stereo? 2: 1);
-	used = count = min(unsigned long, userCount, frameLeft);
+	used = count = min_t(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(unsigned long, userCount, frameLeft);
+	used = count = min_t(unsigned long, userCount, frameLeft);
 	while (count > 0) {
 		int data;
 
diff -urN linux-2.4.10-pre7/drivers/sound/dmasound/dmasound_paula.c linux/drivers/sound/dmasound/dmasound_paula.c
--- linux-2.4.10-pre7/drivers/sound/dmasound/dmasound_paula.c	Wed Aug 15 01:22:16 2001
+++ linux/drivers/sound/dmasound/dmasound_paula.c	Mon Dec  3 23:09:19 2001
@@ -155,14 +155,14 @@
 
 	if (!dmasound.soft.stereo) {
 		void *p = &frame[*frameUsed];
-		count = min(unsigned long, userCount, frameLeft) & ~1;
+		count = min_t(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(unsigned long, userCount, frameLeft)>>1 & ~1;
+		count = min_t(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(unsigned long, userCount, frameLeft) & ~1;	\
+		count = min_t(size_t, 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(unsigned long, userCount, frameLeft)>>1 & ~1;\
+		count = min_t(size_t, 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(unsigned long, userCount, frameLeft)>>1 & ~1;\
+		count = min_t(size_t, 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(unsigned long, userCount, frameLeft)>>2 & ~1;\
+		count = min_t(size_t, userCount, frameLeft)>>2 & ~1;	\
 		used = count*4;						\
 		while (count > 0) {					\
 			if (get_user(data, ((u_short *)userPtr)++))	\
diff -urN linux-2.4.10-pre7/drivers/sound/dmasound/dmasound_q40.c linux/drivers/sound/dmasound/dmasound_q40.c
--- linux-2.4.10-pre7/drivers/sound/dmasound/dmasound_q40.c	Wed Aug 15 01:22:16 2001
+++ linux/drivers/sound/dmasound/dmasound_q40.c	Mon Dec  3 23:09:19 2001
@@ -58,7 +58,7 @@
 	ssize_t count, used;
 	u_char *p = (u_char *) &frame[*frameUsed];
 
-	used = count = min(unsigned long, userCount, frameLeft);
+	used = count = min_t(size_t, 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(unsigned long, userCount, frameLeft);
+	used = count = min_t(size_t, 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(unsigned long, userCount, frameLeft);
+	used = count = min_t(size_t, 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(unsigned long, userCount, frameLeft);
+	used = count = min_t(size_t, 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(unsigned long, userCount, frameLeft);
+	used = count = min_t(size_t, 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(unsigned long, userCount, frameLeft);
+	used = count = min_t(size_t, userCount, frameLeft);
 	while (count > 0) {
 		u_char data;
 		if (get_user(data, userPtr++))
diff -urN linux-2.4.10-pre7/drivers/sound/emu10k1/audio.c linux/drivers/sound/emu10k1/audio.c
--- linux-2.4.10-pre7/drivers/sound/emu10k1/audio.c	Wed Aug 15 01:22:16 2001
+++ linux/drivers/sound/emu10k1/audio.c	Mon Dec  3 23:09:19 2001
@@ -115,7 +115,7 @@
 
 		if ((bytestocopy >= wiinst->buffer.fragment_size)
 		    || (bytestocopy >= count)) {
-			bytestocopy = min(u32, bytestocopy, count);
+			bytestocopy = min_t(u32, bytestocopy, count);
 
 			emu10k1_wavein_xferdata(wiinst, (u8 *) buffer, &bytestocopy);
 
@@ -215,7 +215,7 @@
 		if ((bytestocopy >= woinst->buffer.fragment_size)
 		    || (bytestocopy >= count)) {
 
-			bytestocopy = min(u32, bytestocopy, count);
+			bytestocopy = min_t(u32, bytestocopy, count);
 
 			emu10k1_waveout_xferdata(woinst, (u8 *) buffer, &bytestocopy);
 
diff -urN linux-2.4.10-pre7/drivers/sound/emu10k1/cardwi.c linux/drivers/sound/emu10k1/cardwi.c
--- linux-2.4.10-pre7/drivers/sound/emu10k1/cardwi.c	Wed Aug 15 01:22:16 2001
+++ linux/drivers/sound/emu10k1/cardwi.c	Mon Dec  3 23:09:19 2001
@@ -325,7 +325,7 @@
 	u32 sizetocopy, sizetocopy_now, start;
 	unsigned long flags;
 
-	sizetocopy = min(u32, buffer->size, *size);
+	sizetocopy = min_t(u32, buffer->size, *size);
 	*size = sizetocopy;
 
 	if (!sizetocopy)
diff -urN linux-2.4.10-pre7/drivers/sound/emu10k1/cardwo.c linux/drivers/sound/emu10k1/cardwo.c
--- linux-2.4.10-pre7/drivers/sound/emu10k1/cardwo.c	Wed Aug 15 01:22:16 2001
+++ linux/drivers/sound/emu10k1/cardwo.c	Mon Dec  3 23:09:19 2001
@@ -581,7 +581,7 @@
 	u32 sizetocopy, sizetocopy_now, start;
 	unsigned long flags;
 
-	sizetocopy = min(u32, buffer->size, *size);
+	sizetocopy = min_t(u32, buffer->size, *size);
 	*size = sizetocopy;
 
 	if (!sizetocopy)
diff -urN linux-2.4.10-pre7/drivers/usb/bluetooth.c linux/drivers/usb/bluetooth.c
--- linux-2.4.10-pre7/drivers/usb/bluetooth.c	Mon Dec  3 23:09:09 2001
+++ linux/drivers/usb/bluetooth.c	Mon Dec  3 23:09:19 2001
@@ -517,7 +517,7 @@
 				}
 				
 
-				buffer_size = min (int, count, bluetooth->bulk_out_buffer_size);
+				buffer_size = min_t (int, count, bluetooth->bulk_out_buffer_size);
 				memcpy (urb->transfer_buffer, current_position, buffer_size);
 
 				/* build up our urb */
diff -urN linux-2.4.10-pre7/drivers/usb/devio.c linux/drivers/usb/devio.c
--- linux-2.4.10-pre7/drivers/usb/devio.c	Mon Dec  3 23:09:09 2001
+++ linux/drivers/usb/devio.c	Mon Dec  3 23:09:19 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(int, size, retval)? */
+			/* size = min_t(int, size, retval)? */
 	}
 
 	/* cleanup and return */
diff -urN linux-2.4.10-pre7/drivers/usb/serial/digi_acceleport.c linux/drivers/usb/serial/digi_acceleport.c
--- linux-2.4.10-pre7/drivers/usb/serial/digi_acceleport.c	Mon Dec  3 23:09:09 2001
+++ linux/drivers/usb/serial/digi_acceleport.c	Mon Dec  3 23:09:19 2001
@@ -670,7 +670,7 @@
 		}
 
 		/* len must be a multiple of 4, so commands are not split */
-		len = min(int, count, oob_port->bulk_out_size );
+		len = min_t(int, count, oob_port->bulk_out_size );
 		if( len > 4 )
 			len &= ~3;
 
@@ -747,7 +747,7 @@
 		/* len must be a multiple of 4 and small enough to */
 		/* guarantee the write will send buffered data first, */
 		/* so commands are in order with data and not split */
-		len = min(int, count, port->bulk_out_size-2-priv->dp_out_buf_len );
+		len = min_t(int, count, port->bulk_out_size-2-priv->dp_out_buf_len );
 		if( len > 4 )
 			len &= ~3;
 
@@ -951,7 +951,7 @@
 	spin_lock_irqsave( &priv->dp_port_lock, flags );
 
 	/* send any buffered chars from throttle time on to tty subsystem */
-	len = min(int, priv->dp_in_buf_len, TTY_FLIPBUF_SIZE - tty->flip.count );
+	len = min_t(int, priv->dp_in_buf_len, TTY_FLIPBUF_SIZE - tty->flip.count );
 	if( len > 0 ) {
 		memcpy( tty->flip.char_buf_ptr, priv->dp_in_buf, len );
 		memcpy( tty->flip.flag_buf_ptr, priv->dp_in_flag_buf, len );
@@ -1272,7 +1272,7 @@
 priv->dp_port_num, count, from_user, in_interrupt() );
 
 	/* copy user data (which can sleep) before getting spin lock */
-	count = min(int, 64, min(int, count, port->bulk_out_size-2 ) );
+	count = min_t(int, 64, min_t(int, count, port->bulk_out_size-2 ) );
 	if( from_user && copy_from_user( user_buf, buf, count ) ) {
 		return( -EFAULT );
 	}
@@ -1303,7 +1303,7 @@
 
 	/* allow space for any buffered data and for new data, up to */
 	/* transfer buffer size - 2 (for command and length bytes) */
-	new_len = min(int, count, port->bulk_out_size-2-priv->dp_out_buf_len );
+	new_len = min_t(int, count, port->bulk_out_size-2-priv->dp_out_buf_len );
 	data_len = new_len + priv->dp_out_buf_len;
 
 	if( data_len == 0 ) {
@@ -1929,7 +1929,7 @@
 
 		if( throttled ) {
 
-			len = min( int, len,
+			len = min_t( int, len,
 				DIGI_IN_BUF_SIZE - priv->dp_in_buf_len );
 
 			if( len > 0 ) {
@@ -1942,7 +1942,7 @@
 
 		} else {
 
-			len = min( int, len, TTY_FLIPBUF_SIZE - tty->flip.count );
+			len = min_t( int, len, TTY_FLIPBUF_SIZE - tty->flip.count );
 
 			if( len > 0 ) {
 				memcpy( tty->flip.char_buf_ptr, data, len );
diff -urN linux-2.4.10-pre7/drivers/usb/serial/empeg.c linux/drivers/usb/serial/empeg.c
--- linux-2.4.10-pre7/drivers/usb/serial/empeg.c	Mon Dec  3 23:09:09 2001
+++ linux/drivers/usb/serial/empeg.c	Mon Dec  3 23:09:19 2001
@@ -276,7 +276,7 @@
 			}
 		}
 
-		transfer_size = min (int, count, URB_TRANSFER_BUFFER_SIZE);
+		transfer_size = min_t (int, count, URB_TRANSFER_BUFFER_SIZE);
 
 		if (from_user) {
 			if (copy_from_user (urb->transfer_buffer, current_position, transfer_size)) {
diff -urN linux-2.4.10-pre7/drivers/usb/serial/io_edgeport.c linux/drivers/usb/serial/io_edgeport.c
--- linux-2.4.10-pre7/drivers/usb/serial/io_edgeport.c	Mon Dec  3 23:09:09 2001
+++ linux/drivers/usb/serial/io_edgeport.c	Mon Dec  3 23:09:19 2001
@@ -1311,7 +1311,7 @@
 	fifo = &edge_port->txfifo;
 
 	// calculate number of bytes to put in fifo
-	copySize = min (int, count, (edge_port->txCredits - fifo->count));
+	copySize = min_t (int, count, (edge_port->txCredits - fifo->count));
 
 	dbg(__FUNCTION__"(%d) of %d byte(s) Fifo room  %d -- will copy %d bytes", 
 	    port->number, count, edge_port->txCredits - fifo->count, copySize);
@@ -1329,7 +1329,7 @@
 	// then copy the reset from the start of the buffer 
 
 	bytesleft = fifo->size - fifo->head;
-	firsthalf = min (int, bytesleft, copySize);
+	firsthalf = min_t (int, bytesleft, copySize);
 	dbg (__FUNCTION__" - copy %d bytes of %d into fifo ", firsthalf, bytesleft);
 
 	/* now copy our data */
@@ -1454,7 +1454,7 @@
 
 	/* now copy our data */
 	bytesleft =  fifo->size - fifo->tail;
-	firsthalf = min (int, bytesleft, count);
+	firsthalf = min_t (int, bytesleft, count);
 	memcpy(&buffer[2], &fifo->fifo[fifo->tail], firsthalf);
 	fifo->tail  += firsthalf;
 	fifo->count -= firsthalf;
diff -urN linux-2.4.10-pre7/drivers/usb/serial/io_usbvend.h linux/drivers/usb/serial/io_usbvend.h
--- linux-2.4.10-pre7/drivers/usb/serial/io_usbvend.h	Wed Aug 15 01:22:16 2001
+++ linux/drivers/usb/serial/io_usbvend.h	Mon Dec  3 23:09:19 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(int, ((InitialCredit) / 4), EDGE_FW_BULK_MAX_PACKET_SIZE))
+#define EDGE_FW_GET_TX_CREDITS_SEND_THRESHOLD(InitialCredit)	(max_t(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.10-pre7/drivers/usb/serial/usbserial.c linux/drivers/usb/serial/usbserial.c
--- linux-2.4.10-pre7/drivers/usb/serial/usbserial.c	Mon Dec  3 23:09:09 2001
+++ linux/drivers/usb/serial/usbserial.c	Mon Dec  3 23:09:19 2001
@@ -1259,9 +1259,9 @@
 
 	/* initialize some parts of the port structures */
 	/* we don't use num_ports here cauz some devices have more endpoint pairs than ports */
-	max_endpoints = max(int, num_bulk_in, num_bulk_out);
-	max_endpoints = max(int, max_endpoints, num_interrupt_in);
-	max_endpoints = max(int, max_endpoints, serial->num_ports);
+	max_endpoints = max_t(int, num_bulk_in, num_bulk_out);
+	max_endpoints = max_t(int, max_endpoints, num_interrupt_in);
+	max_endpoints = max_t(int, max_endpoints, serial->num_ports);
 	dbg (__FUNCTION__ " - setting up %d port structures for this device", max_endpoints);
 	for (i = 0; i < max_endpoints; ++i) {
 		port = &serial->port[i];
diff -urN linux-2.4.10-pre7/drivers/usb/serial/visor.c linux/drivers/usb/serial/visor.c
--- linux-2.4.10-pre7/drivers/usb/serial/visor.c	Mon Dec  3 23:09:09 2001
+++ linux/drivers/usb/serial/visor.c	Mon Dec  3 23:09:19 2001
@@ -441,7 +441,7 @@
 			}
 		}
 		
-		transfer_size = min (int, count, URB_TRANSFER_BUFFER_SIZE);
+		transfer_size = min_t (int, count, URB_TRANSFER_BUFFER_SIZE);
 		if (from_user) {
 			if (copy_from_user (urb->transfer_buffer, current_position, transfer_size)) {
 				bytes_sent = -EFAULT;
diff -urN linux-2.4.10-pre7/drivers/usb/storage/datafab.c linux/drivers/usb/storage/datafab.c
--- linux-2.4.10-pre7/drivers/usb/storage/datafab.c	Wed Aug 15 01:22:16 2001
+++ linux/drivers/usb/storage/datafab.c	Mon Dec  3 23:09:19 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(int, totallen, 65536);
+		len = min_t(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(int, totallen, 65536);
+		len = min_t(int, totallen, 65536);
 
 		if (use_sg) {
 			sg = (struct scatterlist *) src;
diff -urN linux-2.4.10-pre7/drivers/usb/storage/jumpshot.c linux/drivers/usb/storage/jumpshot.c
--- linux-2.4.10-pre7/drivers/usb/storage/jumpshot.c	Wed Aug 15 01:22:16 2001
+++ linux/drivers/usb/storage/jumpshot.c	Mon Dec  3 23:09:19 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(int, totallen, 65536);
+                len = min_t(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(int, totallen, 65536);
+                len = min_t(int, totallen, 65536);
 
                 if (use_sg) {
                         sg = (struct scatterlist *) src;
diff -urN linux-2.4.10-pre7/drivers/usb/uhci.c linux/drivers/usb/uhci.c
--- linux-2.4.10-pre7/drivers/usb/uhci.c	Wed Aug 15 01:22:16 2001
+++ linux/drivers/usb/uhci.c	Mon Dec  3 23:09:19 2001
@@ -2131,14 +2131,14 @@
 	case RH_GET_DESCRIPTOR:
 		switch ((wValue & 0xff00) >> 8) {
 		case 0x01:	/* device descriptor */
-			len = min(unsigned int, leni,
-				  min(unsigned int,
+			len = min_t(unsigned int, leni,
+				  min_t(unsigned int,
 				      sizeof(root_hub_dev_des), wLength));
 			memcpy(data, root_hub_dev_des, len);
 			OK(len);
 		case 0x02:	/* configuration descriptor */
-			len = min(unsigned int, leni,
-				  min(unsigned int,
+			len = min_t(unsigned int, leni,
+				  min_t(unsigned int,
 				      sizeof(root_hub_config_des), wLength));
 			memcpy (data, root_hub_config_des, len);
 			OK(len);
@@ -2147,15 +2147,15 @@
 				uhci->io_addr, "UHCI-alt",
 				data, wLength);
 			if (len > 0) {
-				OK(min(int, leni, len));
+				OK(min_t(int, leni, len));
 			} else 
 				stat = -EPIPE;
 		}
 		break;
 	case RH_GET_DESCRIPTOR | RH_CLASS:
 		root_hub_hub_des[2] = uhci->rh.numports;
-		len = min(unsigned int, leni,
-			  min(unsigned int, sizeof(root_hub_hub_des), wLength));
+		len = min_t(unsigned int, leni,
+			  min_t(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.10-pre7/drivers/usb/usb-ohci.c linux/drivers/usb/usb-ohci.c
--- linux-2.4.10-pre7/drivers/usb/usb-ohci.c	Wed Aug 15 01:22:16 2001
+++ linux/drivers/usb/usb-ohci.c	Mon Dec  3 23:09:19 2001
@@ -1806,8 +1806,8 @@
   
 	if (ret > 0) { 
 		memcpy(rh_data, data,
-		       min(unsigned int, len,
-			   min(unsigned int, rh_len, sizeof(data))));
+		       min_t(unsigned int, len,
+			   min_t(unsigned int, rh_len, sizeof(data))));
 		return len;
 	}
 	return 0;
@@ -1989,16 +1989,16 @@
 		case RH_GET_DESCRIPTOR:
 			switch ((wValue & 0xff00) >> 8) {
 				case (0x01): /* device descriptor */
-					len = min(unsigned int,
+					len = min_t(unsigned int,
 						  leni,
-						  min(unsigned int,
+						  min_t(unsigned int,
 						      sizeof (root_hub_dev_des),
 						      wLength));
 					data_buf = root_hub_dev_des; OK(len);
 				case (0x02): /* configuration descriptor */
-					len = min(unsigned int,
+					len = min_t(unsigned int,
 						  leni,
-						  min(unsigned int,
+						  min_t(unsigned int,
 						      sizeof (root_hub_config_des),
 						      wLength));
 					data_buf = root_hub_config_des; OK(len);
@@ -2008,7 +2008,7 @@
 						data, wLength);
 					if (len > 0) {
 						data_buf = data;
-						OK(min(int, leni, len));
+						OK(min_t(int, leni, len));
 					}
 					// else fallthrough
 				default: 
@@ -2043,8 +2043,8 @@
 				data_buf [10] = data_buf [9] = 0xff;
 			    }
 				
-			    len = min(unsigned int, leni,
-				      min(unsigned int, data_buf [0], wLength));
+			    len = min_t(unsigned int, leni,
+				      min_t(unsigned int, data_buf [0], wLength));
 			    OK (len);
 			}
  
@@ -2061,7 +2061,7 @@
 	// ohci_dump_roothub (ohci, 0);
 #endif
 
-	len = min(int, len, leni);
+	len = min_t(int, len, leni);
 	if (data != data_buf)
 	    memcpy (data, data_buf, len);
   	urb->actual_length = len;
diff -urN linux-2.4.10-pre7/drivers/usb/usb-uhci.c linux/drivers/usb/usb-uhci.c
--- linux-2.4.10-pre7/drivers/usb/usb-uhci.c	Mon Dec  3 23:09:09 2001
+++ linux/drivers/usb/usb-uhci.c	Mon Dec  3 23:09:19 2001
@@ -2111,14 +2111,14 @@
 	case RH_GET_DESCRIPTOR:
 		switch ((wValue & 0xff00) >> 8) {
 		case (0x01):	/* device descriptor */
-			len = min(unsigned int, leni,
-				  min(unsigned int,
+			len = min_t(unsigned int, leni,
+				  min_t(unsigned int,
 				      sizeof (root_hub_dev_des), wLength));
 			memcpy (data, root_hub_dev_des, len);
 			OK (len);
 		case (0x02):	/* configuration descriptor */
-			len = min(unsigned int, leni,
-				  min(unsigned int,
+			len = min_t(unsigned int, leni,
+				  min_t(unsigned int,
 				      sizeof (root_hub_config_des), wLength));
 			memcpy (data, root_hub_config_des, len);
 			OK (len);
@@ -2127,7 +2127,7 @@
 			        uhci->io_addr, "UHCI",
 				data, wLength);
 			if (len > 0) {
-				OK(min(int, leni, len));
+				OK(min_t(int, leni, len));
 			} else 
 				stat = -EPIPE;
 		}
@@ -2135,8 +2135,8 @@
 
 	case RH_GET_DESCRIPTOR | RH_CLASS:
 		root_hub_hub_des[2] = uhci->rh.numports;
-		len = min(unsigned int, leni,
-			  min(unsigned int, sizeof (root_hub_hub_des), wLength));
+		len = min_t(unsigned int, leni,
+			  min_t(unsigned int, sizeof (root_hub_hub_des), wLength));
 		memcpy (data, root_hub_hub_des, len);
 		OK (len);
 
diff -urN linux-2.4.10-pre7/fs/adfs/inode.c linux/fs/adfs/inode.c
--- linux-2.4.10-pre7/fs/adfs/inode.c	Mon Dec  3 23:09:09 2001
+++ linux/fs/adfs/inode.c	Mon Dec  3 23:09:19 2001
@@ -319,7 +319,11 @@
 		goto out;
 
 	if (ia_valid & ATTR_SIZE)
-		vmtruncate(inode, attr->ia_size);
+		error = vmtruncate(inode, attr->ia_size);
+
+	if (error)
+		goto out;
+
 	if (ia_valid & ATTR_MTIME) {
 		inode->i_mtime = attr->ia_mtime;
 		adfs_unix2adfs_time(inode, attr->ia_mtime);
diff -urN linux-2.4.10-pre7/fs/attr.c linux/fs/attr.c
--- linux-2.4.10-pre7/fs/attr.c	Mon Oct 16 13:00:53 2000
+++ linux/fs/attr.c	Mon Dec  3 23:09:19 2001
@@ -57,16 +57,21 @@
 	return retval;
 }
 
-void inode_setattr(struct inode * inode, struct iattr * attr)
+int inode_setattr(struct inode * inode, struct iattr * attr)
 {
 	unsigned int ia_valid = attr->ia_valid;
+	int error = 0;
+
+	if (ia_valid & ATTR_SIZE) {
+		error = vmtruncate(inode, attr->ia_size);
+		if (error)
+			goto out;
+	}
 
 	if (ia_valid & ATTR_UID)
 		inode->i_uid = attr->ia_uid;
 	if (ia_valid & ATTR_GID)
 		inode->i_gid = attr->ia_gid;
-	if (ia_valid & ATTR_SIZE)
-		vmtruncate(inode, attr->ia_size);
 	if (ia_valid & ATTR_ATIME)
 		inode->i_atime = attr->ia_atime;
 	if (ia_valid & ATTR_MTIME)
@@ -79,6 +84,8 @@
 			inode->i_mode &= ~S_ISGID;
 	}
 	mark_inode_dirty(inode);
+out:
+	return error;
 }
 
 static int setattr_mask(unsigned int ia_valid)
diff -urN linux-2.4.10-pre7/fs/buffer.c linux/fs/buffer.c
--- linux-2.4.10-pre7/fs/buffer.c	Mon Dec  3 23:09:09 2001
+++ linux/fs/buffer.c	Mon Dec  3 23:09:19 2001
@@ -103,7 +103,8 @@
 atomic_t buffermem_pages = ATOMIC_INIT(0);
 
 /* Here is the parameter block for the bdflush process. If you add or
- * remove any of the parameters, make sure to update kernel/sysctl.c.
+ * remove any of the parameters, make sure to update kernel/sysctl.c
+ * and the documentation at linux/Documentation/sysctl/vm.txt.
  */
 
 #define N_PARAM 9
diff -urN linux-2.4.10-pre7/fs/coda/upcall.c linux/fs/coda/upcall.c
--- linux-2.4.10-pre7/fs/coda/upcall.c	Wed Aug 15 01:22:16 2001
+++ linux/fs/coda/upcall.c	Mon Dec  3 23:09:19 2001
@@ -71,7 +71,7 @@
 
 #define INSIZE(tag) sizeof(struct coda_ ## tag ## _in)
 #define OUTSIZE(tag) sizeof(struct coda_ ## tag ## _out)
-#define SIZE(tag)  max(unsigned int, INSIZE(tag), OUTSIZE(tag))
+#define SIZE(tag)  max_t(unsigned int, INSIZE(tag), OUTSIZE(tag))
 
 
 /* the upcalls */
@@ -151,7 +151,7 @@
 	int offset;
 
 	offset = INSIZE(lookup);
-        insize = max(unsigned int, offset + length +1, OUTSIZE(lookup));
+        insize = max_t(unsigned int, offset + length +1, OUTSIZE(lookup));
 	UPARG(CODA_LOOKUP);
 
         inp->coda_lookup.VFid = *fid;
@@ -267,7 +267,7 @@
         int offset;
 
 	offset = INSIZE(mkdir);
-	insize = max(unsigned int, offset + length + 1, OUTSIZE(mkdir));
+	insize = max_t(unsigned int, offset + length + 1, OUTSIZE(mkdir));
 	UPARG(CODA_MKDIR);
 
         inp->coda_mkdir.VFid = *dirfid;
@@ -298,7 +298,7 @@
 	int offset, s;
 	
 	offset = INSIZE(rename);
-	insize = max(unsigned int, offset + new_length + old_length + 8,
+	insize = max_t(unsigned int, offset + new_length + old_length + 8,
 		     OUTSIZE(rename)); 
  	UPARG(CODA_RENAME);
 
@@ -336,7 +336,7 @@
         int offset;
 
         offset = INSIZE(create);
-	insize = max(unsigned int, offset + length + 1, OUTSIZE(create));
+	insize = max_t(unsigned int, offset + length + 1, OUTSIZE(create));
 	UPARG(CODA_CREATE);
 
         inp->coda_create.VFid = *dirfid;
@@ -368,7 +368,7 @@
         int offset;
 
         offset = INSIZE(rmdir);
-	insize = max(unsigned int, offset + length + 1, OUTSIZE(rmdir));
+	insize = max_t(unsigned int, offset + length + 1, OUTSIZE(rmdir));
 	UPARG(CODA_RMDIR);
 
         inp->coda_rmdir.VFid = *dirfid;
@@ -390,7 +390,7 @@
         int error=0, insize, outsize, offset;
 
         offset = INSIZE(remove);
-	insize = max(unsigned int, offset + length + 1, OUTSIZE(remove));
+	insize = max_t(unsigned int, offset + length + 1, OUTSIZE(remove));
 	UPARG(CODA_REMOVE);
 
         inp->coda_remove.VFid = *dirfid;
@@ -413,7 +413,7 @@
         int retlen;
         char *result;
         
-	insize = max(unsigned int,
+	insize = max_t(unsigned int,
 		     INSIZE(readlink), OUTSIZE(readlink)+ *length + 1);
 	UPARG(CODA_READLINK);
 
@@ -448,7 +448,7 @@
         int offset;
 
 	offset = INSIZE(link);
-	insize = max(unsigned int, offset  + len + 1, OUTSIZE(link));
+	insize = max_t(unsigned int, offset  + len + 1, OUTSIZE(link));
         UPARG(CODA_LINK);
 
         inp->coda_link.sourceFid = *fid;
@@ -477,7 +477,7 @@
         int offset, s;
 
         offset = INSIZE(symlink);
-	insize = max(unsigned int, offset + len + symlen + 8, OUTSIZE(symlink));
+	insize = max_t(unsigned int, offset + len + symlen + 8, OUTSIZE(symlink));
 	UPARG(CODA_SYMLINK);
         
         /*        inp->coda_symlink.attr = *tva; XXXXXX */ 
@@ -617,7 +617,7 @@
         union outputArgs *outp;
         int insize, outsize, error;
         
-	insize = max(unsigned int, INSIZE(statfs), OUTSIZE(statfs));
+	insize = max_t(unsigned int, INSIZE(statfs), OUTSIZE(statfs));
 	UPARG(CODA_STATFS);
 
         error = coda_upcall(coda_sbp(sb), insize, &outsize, inp);
diff -urN linux-2.4.10-pre7/fs/hfs/file_cap.c linux/fs/hfs/file_cap.c
--- linux-2.4.10-pre7/fs/hfs/file_cap.c	Sun Aug 12 10:56:56 2001
+++ linux/fs/hfs/file_cap.c	Mon Dec  3 23:09:19 2001
@@ -27,7 +27,7 @@
 
 /*================ Forward declarations ================*/
 static loff_t      cap_info_llseek(struct file *, loff_t,
-				   int);
+                                   int);
 static hfs_rwret_t cap_info_read(struct file *, char *,
 				 hfs_rwarg_t, loff_t *);
 static hfs_rwret_t cap_info_write(struct file *, const char *,
diff -urN linux-2.4.10-pre7/fs/hfs/inode.c linux/fs/hfs/inode.c
--- linux-2.4.10-pre7/fs/hfs/inode.c	Tue Feb 13 14:13:45 2001
+++ linux/fs/hfs/inode.c	Mon Dec  3 23:09:19 2001
@@ -169,7 +169,9 @@
 			attr->ia_valid &= ~ATTR_SIZE;
 		}
 	}
-	inode_setattr(inode, attr);
+	error = inode_setattr(inode, attr);
+	if (error)
+		return error;
 
 	/* We wouldn't want to mess with the sizes of the other fork */
 	attr->ia_valid &= ~ATTR_SIZE;
diff -urN linux-2.4.10-pre7/fs/hpfs/inode.c linux/fs/hpfs/inode.c
--- linux-2.4.10-pre7/fs/hpfs/inode.c	Sun Aug 12 17:37:53 2001
+++ linux/fs/hpfs/inode.c	Mon Dec  3 23:09:19 2001
@@ -300,10 +300,12 @@
 {
 	struct inode *inode = dentry->d_inode;
 	int error;
-	if ((attr->ia_valid & ATTR_SIZE) && attr->ia_size > inode->i_size) return -EINVAL;
+	if ((attr->ia_valid & ATTR_SIZE) && attr->ia_size > inode->i_size) 
+		return -EINVAL;
 	if (inode->i_sb->s_hpfs_root == inode->i_ino) return -EINVAL;
 	if ((error = inode_change_ok(inode, attr))) return error;
-	inode_setattr(inode, attr);
+	error = inode_setattr(inode, attr);
+	if (error) return error;
 	hpfs_write_inode(inode);
 	return 0;
 }
diff -urN linux-2.4.10-pre7/fs/isofs/rock.c linux/fs/isofs/rock.c
--- linux-2.4.10-pre7/fs/isofs/rock.c	Sun Aug 12 10:56:56 2001
+++ linux/fs/isofs/rock.c	Mon Dec  3 23:09:19 2001
@@ -454,7 +454,6 @@
    if ((inode->i_sb->u.isofs_sb.s_rock_offset==-1)
        &&(inode->i_sb->u.isofs_sb.s_rock==2))
      {
-	printk(KERN_DEBUG"scanning for RockRidge behind XA attributes\n");
 	result=parse_rock_ridge_inode_internal(de,inode,14);
      };
    return result;
diff -urN linux-2.4.10-pre7/fs/jffs/inode-v23.c linux/fs/jffs/inode-v23.c
--- linux-2.4.10-pre7/fs/jffs/inode-v23.c	Wed Aug 15 01:22:16 2001
+++ linux/fs/jffs/inode-v23.c	Mon Dec  3 23:09:19 2001
@@ -718,7 +718,7 @@
 
 	offset = page->index << PAGE_CACHE_SHIFT;
 	if (offset < inode->i_size) {
-		read_len = min(long, inode->i_size - offset, PAGE_SIZE);
+		read_len = min_t(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,7 @@
 		goto out_isem;
 	}
 	
-	thiscount = min(unsigned int,
+	thiscount = min_t(unsigned int,
 			c->fmc->max_chunk_size - sizeof(struct jffs_raw_inode),
 			count);
 
@@ -1440,7 +1440,7 @@
 		
 		if (pos < f->size) {
 			node->removed_size = raw_inode.rsize =
-				min(unsigned int, thiscount, f->size - pos);
+				min_t(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 
@@ -1482,7 +1482,7 @@
 
 		D3(printk("jffs_file_write(): new f_pos %ld.\n", (long)pos));
 
-		thiscount = min(unsigned int,
+		thiscount = min_t(unsigned int,
 			c->fmc->max_chunk_size - sizeof(struct jffs_raw_inode),
 			count);
 	}
diff -urN linux-2.4.10-pre7/fs/jffs/intrep.c linux/fs/jffs/intrep.c
--- linux-2.4.10-pre7/fs/jffs/intrep.c	Wed Aug 15 01:22:16 2001
+++ linux/fs/jffs/intrep.c	Mon Dec  3 23:09:19 2001
@@ -1609,7 +1609,7 @@
 		  "version: %u, node_offset: %u\n",
 		  f->name, node->ino, node->version, node_offset));
 
-	r = min(u32, avail, max_size);
+	r = min_t(u32, avail, max_size);
 	D3(printk(KERN_NOTICE "jffs_get_node_data\n"));
 	flash_safe_read(fmc->mtd, pos, buf, r);
 
@@ -1662,7 +1662,7 @@
 		int r;
 		if (!node->fm) {
 			/* This node does not refer to real data.  */
-			r = min(u32, size - read_data,
+			r = min_t(u32, size - read_data,
 				node->data_size - node_offset);
 			memset(&buf[read_data], 0, r);
 		}
@@ -1904,7 +1904,7 @@
 		else {
 			/* No.  No need to split the node.  Just remove
 			   the end of the node.  */
-			int r = min(u32, n->data_offset + n->data_size
+			int r = min_t(u32, n->data_offset + n->data_size
 				    - offset, remove_size);
 			n->data_size -= r;
 			remove_size -= r;
@@ -2460,7 +2460,7 @@
 		}
 
 		while (size) {
-			__u32 s = min(int, size, PAGE_SIZE);
+			__u32 s = min_t(int, size, PAGE_SIZE);
 			if ((r = jffs_read_data(f, (char *)page,
 						offset, s)) < s) {
 				free_page((unsigned long)page);
@@ -2821,7 +2821,7 @@
 				printk("JFFS: Erase failed! pos = 0x%lx\n",
 				       (long)pos);
 				jffs_hexdump(fmc->mtd, pos,
-					     min(u32, 256, end - pos));
+					     min_t(u32, 256, end - pos));
 				err = -1;
 				break;
 			}
diff -urN linux-2.4.10-pre7/fs/namei.c linux/fs/namei.c
--- linux-2.4.10-pre7/fs/namei.c	Mon Dec  3 23:09:09 2001
+++ linux/fs/namei.c	Mon Dec  3 23:09:19 2001
@@ -21,6 +21,7 @@
 #include <linux/pagemap.h>
 #include <linux/dnotify.h>
 #include <linux/smp_lock.h>
+#include <linux/personality.h>
 
 #include <asm/namei.h>
 #include <asm/uaccess.h>
diff -urN linux-2.4.10-pre7/fs/ncpfs/file.c linux/fs/ncpfs/file.c
--- linux-2.4.10-pre7/fs/ncpfs/file.c	Wed Aug 15 01:22:16 2001
+++ linux/fs/ncpfs/file.c	Mon Dec  3 23:09:19 2001
@@ -152,7 +152,7 @@
 	/* First read in as much as possible for each bufsize. */
 	while (already_read < count) {
 		int read_this_time;
-		size_t to_read = min(unsigned int,
+		size_t to_read = min_t(unsigned int,
 				     bufsize - (pos % bufsize),
 				     count - already_read);
 
@@ -234,7 +234,7 @@
 	}
 	while (already_written < count) {
 		int written_this_time;
-		size_t to_write = min(unsigned int,
+		size_t to_write = min_t(unsigned int,
 				      bufsize - (pos % bufsize),
 				      count - already_written);
 
diff -urN linux-2.4.10-pre7/fs/ncpfs/inode.c linux/fs/ncpfs/inode.c
--- linux-2.4.10-pre7/fs/ncpfs/inode.c	Tue Apr 17 23:16:39 2001
+++ linux/fs/ncpfs/inode.c	Mon Dec  3 23:09:19 2001
@@ -692,7 +692,7 @@
 		ncp_inode_close(inode);
 		result = ncp_make_closed(inode);
 		if (!result)
-			vmtruncate(inode, attr->ia_size);
+			result = vmtruncate(inode, attr->ia_size);
 	}
 out:
 	return result;
diff -urN linux-2.4.10-pre7/fs/ncpfs/ioctl.c linux/fs/ncpfs/ioctl.c
--- linux-2.4.10-pre7/fs/ncpfs/ioctl.c	Mon Dec 11 12:59:28 2000
+++ linux/fs/ncpfs/ioctl.c	Mon Dec  3 23:09:19 2001
@@ -378,7 +378,7 @@
 		}
 		{
 			struct ncp_objectname_ioctl user;
-			int outl;
+			size_t outl;
 
 			if (copy_from_user(&user, 
 					   (struct ncp_objectname_ioctl*)arg,
@@ -448,7 +448,7 @@
 		}
 		{
 			struct ncp_privatedata_ioctl user;
-			int outl;
+			size_t outl;
 
 			if (copy_from_user(&user, 
 					   (struct ncp_privatedata_ioctl*)arg,
diff -urN linux-2.4.10-pre7/fs/ncpfs/mmap.c linux/fs/ncpfs/mmap.c
--- linux-2.4.10-pre7/fs/ncpfs/mmap.c	Wed Aug 15 01:22:16 2001
+++ linux/fs/ncpfs/mmap.c	Mon Dec  3 23:09:19 2001
@@ -61,7 +61,7 @@
 
 			to_read = bufsize - (pos % bufsize);
 
-			to_read = min(unsigned int, to_read, count - already_read);
+			to_read = min_t(unsigned int, to_read, count - already_read);
 
 			if (ncp_read_kernel(NCP_SERVER(inode),
 				     NCP_FINFO(inode)->file_handle,
diff -urN linux-2.4.10-pre7/fs/ncpfs/ncplib_kernel.c linux/fs/ncpfs/ncplib_kernel.c
--- linux-2.4.10-pre7/fs/ncpfs/ncplib_kernel.c	Wed Aug 15 01:22:16 2001
+++ linux/fs/ncpfs/ncplib_kernel.c	Mon Dec  3 23:09:19 2001
@@ -127,7 +127,7 @@
 		ncp_unlock_server(server);
 		return result;
 	}
-	*target = min(unsigned int, ntohs(ncp_reply_word(server, 0)), size);
+	*target = min_t(unsigned int, ntohs(ncp_reply_word(server, 0)), size);
 
 	ncp_unlock_server(server);
 	return 0;
@@ -159,7 +159,7 @@
 	/* NCP over UDP returns 0 (!!!) */
 	result = ntohs(ncp_reply_word(server, 0));
 	if (result >= NCP_BLOCK_SIZE)
-		size = min(int, result, size);
+		size = min(result, size);
 	*ret_size = size;
 	*ret_options = ncp_reply_byte(server, 4);
 
diff -urN linux-2.4.10-pre7/fs/ncpfs/ncpsign_kernel.c linux/fs/ncpfs/ncpsign_kernel.c
--- linux-2.4.10-pre7/fs/ncpfs/ncpsign_kernel.c	Wed Aug 15 01:22:16 2001
+++ linux/fs/ncpfs/ncpsign_kernel.c	Mon Dec  3 23:09:19 2001
@@ -100,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(unsigned int,(*size)-sizeof(struct ncp_request_header)+1,52));
+  min_t(unsigned int,(*size)-sizeof(struct ncp_request_header)+1,52));
 
  nwsign(server->sign_last,data,server->sign_last);
 
diff -urN linux-2.4.10-pre7/fs/romfs/inode.c linux/fs/romfs/inode.c
--- linux-2.4.10-pre7/fs/romfs/inode.c	Wed Aug 15 01:22:17 2001
+++ linux/fs/romfs/inode.c	Mon Dec  3 23:09:20 2001
@@ -124,7 +124,7 @@
 				"%s.\n", kdevname(dev));
 		goto out;
 	}
-	if (romfs_checksum(rsb, min(int, sz, 512))) {
+	if (romfs_checksum(rsb, min_t(int, sz, 512))) {
 		printk ("romfs: bad initial checksum on dev "
 			"%s.\n", kdevname(dev));
 		goto out;
@@ -193,7 +193,7 @@
 		return -1;		/* error */
 
 	avail = ROMBSIZE - (offset & ROMBMASK);
-	maxsize = min(unsigned long, count, avail);
+	maxsize = min_t(unsigned long, count, avail);
 	res = strnlen(((char *)bh->b_data)+(offset&ROMBMASK), maxsize);
 	brelse(bh);
 
@@ -206,7 +206,7 @@
 		bh = bread(i->i_dev, offset>>ROMBSBITS, ROMBSIZE);
 		if (!bh)
 			return -1;
-		maxsize = min(unsigned long, count - res, ROMBSIZE);
+		maxsize = min_t(unsigned long, count - res, ROMBSIZE);
 		avail = strnlen(bh->b_data, maxsize);
 		res += avail;
 		brelse(bh);
@@ -231,7 +231,7 @@
 		return -1;		/* error */
 
 	avail = ROMBSIZE - (offset & ROMBMASK);
-	maxsize = min(unsigned long, count, avail);
+	maxsize = min_t(unsigned long, count, avail);
 	memcpy(dest, ((char *)bh->b_data) + (offset & ROMBMASK), maxsize);
 	brelse(bh);
 
@@ -244,7 +244,7 @@
 		bh = bread(i->i_dev, offset>>ROMBSBITS, ROMBSIZE);
 		if (!bh)
 			return -1;
-		maxsize = min(unsigned long, count - res, ROMBSIZE);
+		maxsize = min_t(unsigned long, count - res, ROMBSIZE);
 		memcpy(dest, bh->b_data, maxsize);
 		brelse(bh);
 		res += maxsize;
@@ -408,7 +408,7 @@
 	offset = page->index << PAGE_CACHE_SHIFT;
 	if (offset < inode->i_size) {
 		avail = inode->i_size-offset;
-		readlen = min(unsigned long, avail, PAGE_SIZE);
+		readlen = min_t(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.10-pre7/fs/select.c linux/fs/select.c
--- linux-2.4.10-pre7/fs/select.c	Tue Aug 14 18:47:51 2001
+++ linux/fs/select.c	Mon Dec  3 23:09:20 2001
@@ -17,6 +17,7 @@
 #include <linux/slab.h>
 #include <linux/smp_lock.h>
 #include <linux/poll.h>
+#include <linux/personality.h> /* for STICKY_TIMEOUTS */
 #include <linux/file.h>
 
 #include <asm/uaccess.h>
diff -urN linux-2.4.10-pre7/fs/smbfs/inode.c linux/fs/smbfs/inode.c
--- linux-2.4.10-pre7/fs/smbfs/inode.c	Wed Jun 20 16:07:57 2001
+++ linux/fs/smbfs/inode.c	Mon Dec  3 23:09:20 2001
@@ -544,7 +544,9 @@
 					 attr->ia_size);
 		if (error)
 			goto out;
-		vmtruncate(inode, attr->ia_size);
+		error = vmtruncate(inode, attr->ia_size);
+		if (error)
+			goto out;
 		refresh = 1;
 	}
 
diff -urN linux-2.4.10-pre7/fs/sysv/inode.c linux/fs/sysv/inode.c
--- linux-2.4.10-pre7/fs/sysv/inode.c	Mon Dec  3 23:09:09 2001
+++ linux/fs/sysv/inode.c	Mon Dec  3 23:09:20 2001
@@ -198,8 +198,7 @@
 			if (attr->ia_mode == COH_KLUDGE_SYMLINK_MODE)
 				attr->ia_mode = COH_KLUDGE_NOT_SYMLINK;
 
-	inode_setattr(inode, attr);
-	return 0;
+	return inode_setattr(inode, attr);
 }
 
 static struct buffer_head * sysv_update_inode(struct inode * inode)
diff -urN linux-2.4.10-pre7/fs/ufs/balloc.c linux/fs/ufs/balloc.c
--- linux-2.4.10-pre7/fs/ufs/balloc.c	Wed Aug 15 01:22:17 2001
+++ linux/fs/ufs/balloc.c	Mon Dec  3 23:09:20 2001
@@ -312,7 +312,7 @@
 			*p = SWAB32(result);
 			*err = 0;
 			inode->i_blocks += count << uspi->s_nspfshift;
-			inode->u.ufs_i.i_lastfrag = max(u32, inode->u.ufs_i.i_lastfrag, fragment + count);
+			inode->u.ufs_i.i_lastfrag = max_t(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(u32, inode->u.ufs_i.i_lastfrag, fragment + count);
+		inode->u.ufs_i.i_lastfrag = max_t(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(u32, inode->u.ufs_i.i_lastfrag, fragment + count);
+		inode->u.ufs_i.i_lastfrag = max_t(u32, inode->u.ufs_i.i_lastfrag, fragment + count);
 		NULLIFY_FRAGMENTS
 		unlock_super(sb);
 		if (newcount < request)
diff -urN linux-2.4.10-pre7/fs/ufs/truncate.c linux/fs/ufs/truncate.c
--- linux-2.4.10-pre7/fs/ufs/truncate.c	Wed Aug 15 01:22:17 2001
+++ linux/fs/ufs/truncate.c	Mon Dec  3 23:09:20 2001
@@ -88,7 +88,7 @@
 	retry = 0;
 	
 	frag1 = DIRECT_FRAGMENT;
-	frag4 = min(u32, UFS_NDIR_FRAGMENT, inode->u.ufs_i.i_lastfrag);
+	frag4 = min_t(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.10-pre7/fs/ufs/util.c linux/fs/ufs/util.c
--- linux-2.4.10-pre7/fs/ufs/util.c	Wed Aug 15 01:22:17 2001
+++ linux/fs/ufs/util.c	Mon Dec  3 23:09:20 2001
@@ -170,7 +170,7 @@
 		size = ubh->count << uspi->s_fshift;
 	bhno = 0;
 	while (size) {
-		len = min(unsigned int, size, uspi->s_fsize);
+		len = min_t(unsigned int, size, uspi->s_fsize);
 		memcpy (mem, ubh->bh[bhno]->b_data, len);
 		mem += uspi->s_fsize;
 		size -= len;
@@ -186,7 +186,7 @@
 		size = ubh->count << uspi->s_fshift;
 	bhno = 0;
 	while (size) {
-		len = min(unsigned int, size, uspi->s_fsize);
+		len = min_t(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.10-pre7/fs/ufs/util.h linux/fs/ufs/util.h
--- linux-2.4.10-pre7/fs/ufs/util.h	Wed Aug 15 01:22:17 2001
+++ linux/fs/ufs/util.h	Mon Dec  3 23:09:20 2001
@@ -331,7 +331,7 @@
 	base = offset >> uspi->s_bpfshift;
 	offset &= uspi->s_bpfmask;
 	for (;;) {
-		count = min(unsigned int, size + offset, uspi->s_bpf);
+		count = min_t(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)
@@ -378,7 +378,7 @@
 	base = start >> uspi->s_bpfshift;
 	start &= uspi->s_bpfmask;
 	for (;;) {
-		count = min(unsigned int,
+		count = min_t(unsigned int,
 			    size + (uspi->s_bpf - start), uspi->s_bpf)
 			- (uspi->s_bpf - start);
 		size -= count;
diff -urN linux-2.4.10-pre7/fs/umsdos/inode.c linux/fs/umsdos/inode.c
--- linux-2.4.10-pre7/fs/umsdos/inode.c	Mon Dec  3 23:09:09 2001
+++ linux/fs/umsdos/inode.c	Mon Dec  3 23:09:20 2001
@@ -211,7 +211,7 @@
 	ret = umsdos_notify_change_locked(dentry, attr);
 	up(&dir->i_sem);
 	if (ret == 0)
-		inode_setattr (inode, attr);
+		ret = inode_setattr (inode, attr);
 out:
 	if (old_dentry)
 		dput (dentry);	/* if we had to use fake dentry for hardlinks, dput() it now */
diff -urN linux-2.4.10-pre7/include/asm-i386/io.h linux/include/asm-i386/io.h
--- linux-2.4.10-pre7/include/asm-i386/io.h	Wed Aug 15 14:21:13 2001
+++ linux/include/asm-i386/io.h	Mon Dec  3 23:09:20 2001
@@ -1,6 +1,8 @@
 #ifndef _ASM_IO_H
 #define _ASM_IO_H
 
+#include <linux/config.h>
+
 /*
  * This file contains the definitions for the x86 IO instructions
  * inb/inw/inl/outb/outw/outl and the "string versions" of the same
@@ -111,7 +113,7 @@
  * Temporary debugging check to catch old code using
  * unmapped ISA addresses. Will be removed in 2.4.
  */
-#if 0
+#if CONFIG_DEBUG_IOVIRT
   extern void *__io_virt_debug(unsigned long x, const char *file, int line);
   extern unsigned long __io_phys_debug(unsigned long x, const char *file, int line);
   #define __io_virt(x) __io_virt_debug((unsigned long)(x), __FILE__, __LINE__)
diff -urN linux-2.4.10-pre7/include/asm-i386/processor.h linux/include/asm-i386/processor.h
--- linux-2.4.10-pre7/include/asm-i386/processor.h	Wed Aug 15 14:21:11 2001
+++ linux/include/asm-i386/processor.h	Mon Dec  3 23:09:20 2001
@@ -477,4 +477,32 @@
 	__asm__ __volatile__("rep;nop");
 }
 
+/* Prefetch instructions for Pentium III and AMD Athlon */
+#ifdef 	CONFIG_MPENTIUMIII
+
+#define ARCH_HAS_PREFETCH
+extern inline void prefetch(const void *x)
+{
+	__asm__ __volatile__ ("prefetchnta (%0)" : : "r"(x));
+}
+
+#elif CONFIG_X86_USE_3DNOW
+
+#define ARCH_HAS_PREFETCH
+#define ARCH_HAS_PREFETCHW
+#define ARCH_HAS_SPINLOCK_PREFETCH
+
+extern inline void prefetch(const void *x)
+{
+	 __asm__ __volatile__ ("prefetch (%0)" : : "r"(x));
+}
+
+extern inline void prefetchw(const void *x)
+{
+	 __asm__ __volatile__ ("prefetchw (%0)" : : "r"(x));
+}
+#define spin_lock_prefetch(x)	prefetchw(x)
+
+#endif
+
 #endif /* __ASM_I386_PROCESSOR_H */
diff -urN linux-2.4.10-pre7/include/asm-i386/spinlock.h linux/include/asm-i386/spinlock.h
--- linux-2.4.10-pre7/include/asm-i386/spinlock.h	Wed Aug 15 14:21:11 2001
+++ linux/include/asm-i386/spinlock.h	Mon Dec  3 23:09:20 2001
@@ -4,6 +4,7 @@
 #include <asm/atomic.h>
 #include <asm/rwlock.h>
 #include <asm/page.h>
+#include <linux/config.h>
 
 extern int printk(const char * fmt, ...)
 	__attribute__ ((format (printf, 1, 2)));
@@ -12,7 +13,11 @@
  * initialize their spinlocks properly, tsk tsk.
  * Remember to turn this off in 2.4. -ben
  */
+#if defined(CONFIG_DEBUG_SPINLOCK)
+#define SPINLOCK_DEBUG	1
+#else
 #define SPINLOCK_DEBUG	0
+#endif
 
 /*
  * Your basic SMP spinlocks, allowing only a single CPU anywhere
diff -urN linux-2.4.10-pre7/include/asm-i386/uaccess.h linux/include/asm-i386/uaccess.h
--- linux-2.4.10-pre7/include/asm-i386/uaccess.h	Wed Aug 15 14:21:12 2001
+++ linux/include/asm-i386/uaccess.h	Mon Dec  3 23:09:20 2001
@@ -126,6 +126,7 @@
 extern void __put_user_1(void);
 extern void __put_user_2(void);
 extern void __put_user_4(void);
+extern void __put_user_8(void);
 
 extern void __put_user_bad(void);
 
@@ -154,6 +155,23 @@
 	__pu_err;					\
 })							
 
+#define __put_user_u64(x, addr, err)				\
+	__asm__ __volatile__(					\
+		"1:	movl %%eax,0(%2)\n"			\
+		"2:	movl %%edx,4(%2)\n"			\
+		"3:\n"						\
+		".section .fixup,\"ax\"\n"			\
+		"4:	movl %3,%0\n"				\
+		"	jmp 3b\n"				\
+		".previous\n"					\
+		".section __ex_table,\"a\"\n"			\
+		"	.align 4\n"				\
+		"	.long 1b,4b\n"				\
+		"	.long 2b,4b\n"				\
+		".previous"					\
+		: "=r"(err)					\
+		: "A" (x), "r" (addr), "i"(-EFAULT), "0"(err))
+
 #define __put_user_size(x,ptr,size,retval)				\
 do {									\
 	retval = 0;							\
@@ -161,6 +179,7 @@
 	  case 1: __put_user_asm(x,ptr,retval,"b","b","iq"); break;	\
 	  case 2: __put_user_asm(x,ptr,retval,"w","w","ir"); break;	\
 	  case 4: __put_user_asm(x,ptr,retval,"l","","ir"); break;	\
+	  case 8: __put_user_u64(x,ptr,retval); break;			\
 	  default: __put_user_bad();					\
 	}								\
 } while (0)
diff -urN linux-2.4.10-pre7/include/linux/ac97_codec.h linux/include/linux/ac97_codec.h
--- linux-2.4.10-pre7/include/linux/ac97_codec.h	Mon Dec  3 23:09:09 2001
+++ linux/include/linux/ac97_codec.h	Mon Dec  3 23:09:20 2001
@@ -36,7 +36,10 @@
 #define AC97_PCM_MIC_ADC_RATE     0x0034       /* PCM MIC ADC Rate */
 #define AC97_CENTER_LFE_MASTER    0x0036       /* Center + LFE Master Volume */
 #define AC97_SURROUND_MASTER      0x0038       /* Surround (Rear) Master Volume */
-#define AC97_RESERVED_3A          0x003A       /* Reserved */
+#define AC97_RESERVED_3A          0x003A       /* Reserved in AC '97 < 2.2 */
+
+/* AC'97 2.2 */
+#define AC97_SPDIF_CONTROL        0x003A       /* S/PDIF Control */
 
 /* range 0x3c-0x58 - MODEM */
 #define AC97_EXTENDED_MODEM_ID    0x003C
@@ -86,6 +89,40 @@
 #define AC97_GP_3D                0x2000       /* 3D Enhancement 1=on */
 #define AC97_GP_ST                0x4000       /* Stereo Enhancement 1=on */
 #define AC97_GP_POP               0x8000       /* Pcm Out Path, 0=pre 3D, 1=post 3D */
+
+/* extended audio status and control bit defines */
+#define AC97_EA_VRA               0x0001       /* Variable bit rate enable bit */
+#define AC97_EA_DRA               0x0002       /* Double-rate audio enable bit */
+#define AC97_EA_SPDIF             0x0004       /* S/PDIF Enable bit */
+#define AC97_EA_VRM               0x0008       /* Variable bit rate for MIC enable bit */
+#define AC97_EA_CDAC              0x0040       /* PCM Center DAC is ready (Read only) */
+#define AC97_EA_SDAC              0x0040       /* PCM Surround DACs are ready (Read only) */
+#define AC97_EA_LDAC              0x0080       /* PCM LFE DAC is ready (Read only) */
+#define AC97_EA_MDAC              0x0100       /* MIC ADC is ready (Read only) */
+#define AC97_EA_SPCV              0x0400       /* S/PDIF configuration valid (Read only) */
+#define AC97_EA_PRI               0x0800       /* Turns the PCM Center DAC off */
+#define AC97_EA_PRJ               0x1000       /* Turns the PCM Surround DACs off */
+#define AC97_EA_PRK               0x2000       /* Turns the PCM LFE DAC off */
+#define AC97_EA_PRL               0x4000       /* Turns the MIC ADC off */
+#define AC97_EA_SLOT_MASK         0xffcf       /* Mask for slot assignment bits */
+#define AC97_EA_SPSA_3_4          0x0000       /* Slot assigned to 3 & 4 */
+#define AC97_EA_SPSA_7_8          0x0010       /* Slot assigned to 7 & 8 */
+#define AC97_EA_SPSA_6_9          0x0020       /* Slot assigned to 6 & 9 */
+#define AC97_EA_SPSA_10_11        0x0030       /* Slot assigned to 10 & 11 */
+
+/* S/PDIF control bit defines */
+#define AC97_SC_PRO               0x0001       /* Professional status */
+#define AC97_SC_NAUDIO            0x0002       /* Non audio stream */
+#define AC97_SC_COPY              0x0004       /* Copyright status */
+#define AC97_SC_PRE               0x0008       /* Preemphasis status */
+#define AC97_SC_CC_MASK           0x07f0       /* Category Code mask */
+#define AC97_SC_L                 0x0800       /* Generation Level status */
+#define AC97_SC_SPSR_MASK         0xcfff       /* S/PDIF Sample Rate bits */
+#define AC97_SC_SPSR_44K          0x0000       /* Use 44.1kHz Sample rate */
+#define AC97_SC_SPSR_48K          0x2000       /* Use 48kHz Sample rate */
+#define AC97_SC_SPSR_32K          0x3000       /* Use 32kHz Sample rate */
+#define AC97_SC_DRS               0x4000       /* Double Rate S/PDIF */
+#define AC97_SC_V                 0x8000       /* Validity status */
 
 /* powerdown control and status bit defines */
 
diff -urN linux-2.4.10-pre7/include/linux/fs.h linux/include/linux/fs.h
--- linux-2.4.10-pre7/include/linux/fs.h	Mon Dec  3 23:09:09 2001
+++ linux/include/linux/fs.h	Mon Dec  3 23:09:20 2001
@@ -167,7 +167,7 @@
 #define BLKROSET   _IO(0x12,93)	/* set device read-only (0 = read-write) */
 #define BLKROGET   _IO(0x12,94)	/* get read-only status (0 = read_write) */
 #define BLKRRPART  _IO(0x12,95)	/* re-read partition table */
-#define BLKGETSIZE _IO(0x12,96)	/* return device size */
+#define BLKGETSIZE _IO(0x12,96)	/* return device size /512 (long *arg) */
 #define BLKFLSBUF  _IO(0x12,97)	/* flush buffer cache */
 #define BLKRASET   _IO(0x12,98)	/* Set read ahead for block device */
 #define BLKRAGET   _IO(0x12,99)	/* get current read ahead setting */
@@ -186,6 +186,7 @@
 /* A jump here: 108-111 have been used for various private purposes. */
 #define BLKBSZGET  _IOR(0x12,112,sizeof(int))
 #define BLKBSZSET  _IOW(0x12,113,sizeof(int))
+#define BLKGETSIZE64 _IOR(0x12,114,sizeof(u64))	/* return device size in bytes (u64 *arg) */
 
 #define BMAP_IOCTL 1		/* obsolete - kept for compatibility */
 #define FIBMAP	   _IO(0x00,1)	/* bmap access */
@@ -1397,7 +1398,7 @@
 extern int generic_osync_inode(struct inode *, int);
 
 extern int inode_change_ok(struct inode *, struct iattr *);
-extern void inode_setattr(struct inode *, struct iattr *);
+extern int inode_setattr(struct inode *, struct iattr *);
 
 /*
  * Common dentry functions for inclusion in the VFS
diff -urN linux-2.4.10-pre7/include/linux/kernel.h linux/include/linux/kernel.h
--- linux-2.4.10-pre7/include/linux/kernel.h	Mon Dec  3 23:09:09 2001
+++ linux/include/linux/kernel.h	Mon Dec  3 23:09:20 2001
@@ -115,9 +115,32 @@
 	((unsigned char *)&addr)[1], \
 	((unsigned char *)&addr)[0]
 
-#define min(type,x,y) \
+/*
+ * min()/max() macros that also do
+ * strict type-checking.. See the
+ * "unnecessary" pointer comparison.
+ */
+#define min(x,y) ({ \
+	const typeof(x) _x = (x);	\
+	const typeof(y) _y = (y);	\
+	(void) (&_x == &_y);		\
+	_x < _y ? _x : _y; })
+
+#define max(x,y) ({ \
+	const typeof(x) _x = (x);	\
+	const typeof(y) _y = (y);	\
+	(void) (&_x == &_y);		\
+	_x > _y ? _x : _y; })
+
+/*
+ * ..and if you can't take the strict
+ * types, you can specify one yourself.
+ *
+ * Or not use min/max at all, of course.
+ */
+#define min_t(type,x,y) \
 	({ type __x = (x); type __y = (y); __x < __y ? __x: __y; })
-#define max(type,x,y) \
+#define max_t(type,x,y) \
 	({ type __x = (x); type __y = (y); __x > __y ? __x: __y; })
 
 #endif /* __KERNEL__ */
diff -urN linux-2.4.10-pre7/include/linux/mm.h linux/include/linux/mm.h
--- linux-2.4.10-pre7/include/linux/mm.h	Mon Dec  3 23:09:09 2001
+++ linux/include/linux/mm.h	Mon Dec  3 23:09:20 2001
@@ -434,7 +434,7 @@
 extern int remap_page_range(unsigned long from, unsigned long to, unsigned long size, pgprot_t prot);
 extern int zeromap_page_range(unsigned long from, unsigned long size, pgprot_t prot);
 
-extern void vmtruncate(struct inode * inode, loff_t offset);
+extern int vmtruncate(struct inode * inode, loff_t offset);
 extern pmd_t *FASTCALL(__pmd_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address));
 extern pte_t *FASTCALL(pte_alloc(struct mm_struct *mm, pmd_t *pmd, unsigned long address));
 extern int handle_mm_fault(struct mm_struct *mm,struct vm_area_struct *vma, unsigned long address, int write_access);
diff -urN linux-2.4.10-pre7/include/linux/personality.h linux/include/linux/personality.h
--- linux-2.4.10-pre7/include/linux/personality.h	Mon Dec 11 12:49:54 2000
+++ linux/include/linux/personality.h	Mon Dec  3 23:09:20 2001
@@ -1,68 +1,126 @@
-#ifndef _PERSONALITY_H
-#define _PERSONALITY_H
+#ifndef _LINUX_PERSONALITY_H
+#define _LINUX_PERSONALITY_H
 
-#include <linux/linkage.h>
-#include <linux/ptrace.h>
-#include <asm/current.h>
-
-/* Flags for bug emulation. These occupy the top three bytes. */
-#define STICKY_TIMEOUTS		0x4000000
-#define WHOLE_SECONDS		0x2000000
-#define ADDR_LIMIT_32BIT	0x0800000
-
-/* Personality types. These go in the low byte. Avoid using the top bit,
- * it will conflict with error returns.
- */
-#define PER_MASK		(0x00ff)
-#define PER_LINUX		(0x0000)
-#define PER_LINUX_32BIT		(0x0000 | ADDR_LIMIT_32BIT)
-#define PER_SVR4		(0x0001 | STICKY_TIMEOUTS)
-#define PER_SVR3		(0x0002 | STICKY_TIMEOUTS)
-#define PER_SCOSVR3		(0x0003 | STICKY_TIMEOUTS | WHOLE_SECONDS)
-#define PER_WYSEV386		(0x0004 | STICKY_TIMEOUTS)
-#define PER_ISCR4		(0x0005 | STICKY_TIMEOUTS)
-#define PER_BSD			(0x0006)
-#define PER_SUNOS		(PER_BSD | STICKY_TIMEOUTS)
-#define PER_XENIX		(0x0007 | STICKY_TIMEOUTS)
-#define PER_LINUX32		(0x0008)
-#define PER_IRIX32              (0x0009 | STICKY_TIMEOUTS) /* IRIX5 32-bit     */
-#define PER_IRIXN32             (0x000a | STICKY_TIMEOUTS) /* IRIX6 new 32-bit */
-#define PER_IRIX64              (0x000b | STICKY_TIMEOUTS) /* IRIX6 64-bit     */
-#define PER_RISCOS		(0x000c)
-#define PER_SOLARIS		(0x000d | STICKY_TIMEOUTS)
-
-/* Prototype for an lcall7 syscall handler. */
-typedef void (*lcall7_func)(int, struct pt_regs *);
-
-
-/* Description of an execution domain - personality range supported,
- * lcall7 syscall handler, start up / shut down functions etc.
- * N.B. The name and lcall7 handler must be where they are since the
- * offset of the handler is hard coded in kernel/sys_call.S.
+/*
+ * Handling of different ABIs (personalities).
  */
+
+struct exec_domain;
+struct pt_regs;
+
+extern int		register_exec_domain(struct exec_domain *);
+extern int		unregister_exec_domain(struct exec_domain *);
+extern int		__set_personality(unsigned long);
+
+
+/*
+ * Sysctl variables related to binary emulation.
+ */
+extern unsigned long abi_defhandler_coff;
+extern unsigned long abi_defhandler_elf;
+extern unsigned long abi_defhandler_lcall7;
+extern unsigned long abi_defhandler_libcso;
+extern int abi_fake_utsname;
+
+
+/*
+ * Flags for bug emulation.
+ *
+ * These occupy the top three bytes.
+ */
+enum {
+	MMAP_PAGE_ZERO =	0x0100000,
+	ADDR_LIMIT_32BIT =	0x0800000,
+	SHORT_INODE =		0x1000000,
+	WHOLE_SECONDS =		0x2000000,
+	STICKY_TIMEOUTS	=	0x4000000,
+};
+
+/*
+ * Personality types.
+ *
+ * These go in the low byte.  Avoid using the top bit, it will
+ * conflict with error returns.
+ */
+enum {
+	PER_LINUX =		0x0000,
+	PER_LINUX_32BIT =	0x0000 | ADDR_LIMIT_32BIT,
+	PER_SVR4 =		0x0001 | STICKY_TIMEOUTS | MMAP_PAGE_ZERO,
+	PER_SVR3 =		0x0002 | STICKY_TIMEOUTS | SHORT_INODE,
+	PER_SCOSVR3 =		0x0003 | STICKY_TIMEOUTS |
+					 WHOLE_SECONDS | SHORT_INODE,
+	PER_OSR5 =		0x0003 | STICKY_TIMEOUTS | WHOLE_SECONDS,
+	PER_WYSEV386 =		0x0004 | STICKY_TIMEOUTS | SHORT_INODE,
+	PER_ISCR4 =		0x0005 | STICKY_TIMEOUTS,
+	PER_BSD =		0x0006,
+	PER_SUNOS =		0x0006 | STICKY_TIMEOUTS,
+	PER_XENIX =		0x0007 | STICKY_TIMEOUTS | SHORT_INODE,
+	PER_LINUX32 =		0x0008,
+	PER_IRIX32 =		0x0009 | STICKY_TIMEOUTS,/* IRIX5 32-bit */
+	PER_IRIXN32 =		0x000a | STICKY_TIMEOUTS,/* IRIX6 new 32-bit */
+	PER_IRIX64 =		0x000b | STICKY_TIMEOUTS,/* IRIX6 64-bit */
+	PER_RISCOS =		0x000c,
+	PER_SOLARIS =		0x000d | STICKY_TIMEOUTS,
+	PER_UW7 =		0x000e | STICKY_TIMEOUTS | MMAP_PAGE_ZERO,
+	PER_MASK =		0x00ff,
+};
+
+
+/*
+ * Description of an execution domain.
+ * 
+ * The first two members are refernced from assembly source
+ * and should stay where they are unless explicitly needed.
+ */
+typedef void (*handler_t)(int, struct pt_regs *);
+
 struct exec_domain {
-	const char *name;
-	lcall7_func handler;
-	unsigned char pers_low, pers_high;
-	unsigned long * signal_map;
-	unsigned long * signal_invmap;
-	struct module * module;
-	struct exec_domain *next;
+	const char		*name;		/* name of the execdomain */
+	handler_t		handler;	/* handler for syscalls */
+	unsigned char		pers_low;	/* lowest personality */
+	unsigned char		pers_high;	/* highest personality */
+	unsigned long		*signal_map;	/* signal mapping */
+	unsigned long		*signal_invmap;	/* reverse signal mapping */
+	struct map_segment	*err_map;	/* error mapping */
+	struct map_segment	*socktype_map;	/* socket type mapping */
+	struct map_segment	*sockopt_map;	/* socket option mapping */
+	struct map_segment	*af_map;	/* address family mapping */
+	struct module		*module;	/* module context of the ed. */
+	struct exec_domain	*next;		/* linked list (internal) */
 };
 
-extern struct exec_domain default_exec_domain;
+/*
+ * Return the base personality without flags.
+ */
+#define personality(pers)	(pers & PER_MASK)
+
+/*
+ * Personality of the currently running process.
+ */
+#define get_personality		(current->personality)
+
+/*
+ * Change personality of the currently running process.
+ */
+#define set_personality(pers) \
+	((current->personality == pers) ? 0 : __set_personality(pers))
+
+/*
+ * Load an execution domain.
+ */
+#define get_exec_domain(ep)				\
+do {							\
+	if (ep != NULL && ep->module != NULL)		\
+		__MOD_INC_USE_COUNT(ep->module);	\
+} while (0)
 
-extern int register_exec_domain(struct exec_domain *it);
-extern int unregister_exec_domain(struct exec_domain *it);
-#define put_exec_domain(it) \
-	if (it && it->module) __MOD_DEC_USE_COUNT(it->module);
-#define get_exec_domain(it) \
-	if (it && it->module) __MOD_INC_USE_COUNT(it->module);
-extern void __set_personality(unsigned long personality);
-#define set_personality(pers) do {	\
-	if (current->personality != pers) \
-		__set_personality(pers); \
+/*
+ * Unload an execution domain.
+ */
+#define put_exec_domain(ep)				\
+do {							\
+	if (ep != NULL && ep->module != NULL)		\
+		__MOD_DEC_USE_COUNT(ep->module);	\
 } while (0)
-asmlinkage long sys_personality(unsigned long personality);
 
-#endif /* _PERSONALITY_H */
+#endif /* _LINUX_PERSONALITY_H */
diff -urN linux-2.4.10-pre7/include/linux/sched.h linux/include/linux/sched.h
--- linux-2.4.10-pre7/include/linux/sched.h	Mon Dec  3 23:09:09 2001
+++ linux/include/linux/sched.h	Mon Dec  3 23:09:20 2001
@@ -7,7 +7,6 @@
 
 #include <linux/config.h>
 #include <linux/binfmts.h>
-#include <linux/personality.h>
 #include <linux/threads.h>
 #include <linux/kernel.h>
 #include <linux/types.h>
@@ -27,6 +26,8 @@
 #include <linux/securebits.h>
 #include <linux/fs_struct.h>
 
+struct exec_domain;
+
 /*
  * cloning flags:
  */
@@ -436,6 +437,12 @@
 #define DEF_COUNTER	(10*HZ/100)	/* 100 ms time slice */
 #define MAX_COUNTER	(20*HZ/100)
 #define DEF_NICE	(0)
+
+
+/*
+ * The default (Linux) execution domain.
+ */
+extern struct exec_domain	default_exec_domain;
 
 /*
  *  INIT_TASK is used to set up the first task table, touch at
diff -urN linux-2.4.10-pre7/include/linux/swap.h linux/include/linux/swap.h
--- linux-2.4.10-pre7/include/linux/swap.h	Wed Aug 15 14:21:11 2001
+++ linux/include/linux/swap.h	Mon Dec  3 23:09:20 2001
@@ -256,7 +256,7 @@
  * 64 (1 << INACTIVE_SHIFT) seconds.
  */
 #define INACTIVE_SHIFT 6
-#define inactive_target min(unsigned long, \
+#define inactive_target min_t(unsigned long, \
 			    (memory_pressure >> INACTIVE_SHIFT), \
 			    (num_physpages / 4))
 
diff -urN linux-2.4.10-pre7/include/linux/sysctl.h linux/include/linux/sysctl.h
--- linux-2.4.10-pre7/include/linux/sysctl.h	Mon Dec  3 23:09:09 2001
+++ linux/include/linux/sysctl.h	Mon Dec  3 23:09:20 2001
@@ -61,7 +61,8 @@
 	CTL_FS=5,		/* Filesystems */
 	CTL_DEBUG=6,		/* Debugging */
 	CTL_DEV=7,		/* Devices */
-	CTL_BUS=8		/* Buses */
+	CTL_BUS=8,		/* Buses */
+	CTL_ABI=9		/* Binary emulation */
 };
 
 /* CTL_BUS names: */
@@ -604,6 +605,17 @@
 	DEV_MAC_HID_MOUSE_BUTTON2_KEYCODE=4,
 	DEV_MAC_HID_MOUSE_BUTTON3_KEYCODE=5,
 	DEV_MAC_HID_ADB_MOUSE_SENDS_KEYCODES=6
+};
+
+/* /proc/sys/abi */
+enum
+{
+	ABI_DEFHANDLER_COFF=1,	/* default handler for coff binaries */
+	ABI_DEFHANDLER_ELF=2, 	/* default handler for ELF binaries */
+	ABI_DEFHANDLER_LCALL7=3,/* default handler for procs using lcall7 */
+	ABI_DEFHANDLER_LIBCSO=4,/* default handler for an libc.so ELF interp */
+	ABI_TRACE=5,		/* tracing flags */
+	ABI_FAKE_UTSNAME=6,	/* fake target utsname information */
 };
 
 #ifdef __KERNEL__
diff -urN linux-2.4.10-pre7/include/net/sock.h linux/include/net/sock.h
--- linux-2.4.10-pre7/include/net/sock.h	Wed Aug 15 14:21:32 2001
+++ linux/include/net/sock.h	Mon Dec  3 23:09:20 2001
@@ -1245,7 +1245,7 @@
 
 static inline int sock_rcvlowat(struct sock *sk, int waitall, int len)
 {
-	return (waitall ? len : min(int, sk->rcvlowat, len)) ? : 1;
+	return (waitall ? len : min_t(int, sk->rcvlowat, len)) ? : 1;
 }
 
 /* Alas, with timeout socket operations are not restartable.
diff -urN linux-2.4.10-pre7/include/net/tcp.h linux/include/net/tcp.h
--- linux-2.4.10-pre7/include/net/tcp.h	Wed Aug 15 14:26:33 2001
+++ linux/include/net/tcp.h	Mon Dec  3 23:09:20 2001
@@ -919,12 +919,12 @@
 static inline void tcp_initialize_rcv_mss(struct sock *sk)
 {
 	struct tcp_opt *tp = &sk->tp_pinfo.af_tcp;
-	unsigned int hint = min(unsigned int, tp->advmss, tp->mss_cache);
+	unsigned int hint = min_t(unsigned int, tp->advmss, tp->mss_cache);
 
-	hint = min(unsigned int, hint, tp->rcv_wnd/2);
+	hint = min_t(unsigned int, hint, tp->rcv_wnd/2);
 		
-	tp->ack.rcv_mss = max(unsigned int,
-			      min(unsigned int,
+	tp->ack.rcv_mss = max_t(unsigned int,
+			      min_t(unsigned int,
 				  hint, TCP_MIN_RCVMSS),
 			      TCP_MIN_MSS);
 }
@@ -1077,7 +1077,7 @@
  */
 static inline __u32 tcp_recalc_ssthresh(struct tcp_opt *tp)
 {
-	return max(u32, tp->snd_cwnd >> 1, 2);
+	return max_t(u32, tp->snd_cwnd >> 1, 2);
 }
 
 /* If cwnd > ssthresh, we may raise ssthresh to be half-way to cwnd.
@@ -1089,7 +1089,7 @@
 	if ((1<<tp->ca_state)&(TCPF_CA_CWR|TCPF_CA_Recovery))
 		return tp->snd_ssthresh;
 	else
-		return max(u32, tp->snd_ssthresh,
+		return max_t(u32, tp->snd_ssthresh,
 			   ((tp->snd_cwnd >> 1) +
 			    (tp->snd_cwnd >> 2)));
 }
@@ -1126,7 +1126,7 @@
 {
 	tp->undo_marker = 0;
 	tp->snd_ssthresh = tcp_recalc_ssthresh(tp);
-	tp->snd_cwnd = min(u32, tp->snd_cwnd,
+	tp->snd_cwnd = min_t(u32, tp->snd_cwnd,
 			   tcp_packets_in_flight(tp) + 1);
 	tp->snd_cwnd_cnt = 0;
 	tp->high_seq = tp->snd_nxt;
@@ -1493,7 +1493,7 @@
 	/* If no clamp set the clamp to the max possible scaled window */
 	if (*window_clamp == 0)
 		(*window_clamp) = (65535 << 14);
-	space = min(u32, *window_clamp, space);
+	space = min_t(u32, *window_clamp, space);
 
 	/* Quantize space offering to a multiple of mss if possible. */
 	if (space > mss)
@@ -1505,7 +1505,7 @@
 	 * our initial window offering to 32k. There should also
 	 * be a sysctl option to stop being nice.
 	 */
-	(*rcv_wnd) = min(int, space, MAX_TCP_WINDOW);
+	(*rcv_wnd) = min_t(int, space, MAX_TCP_WINDOW);
 	(*rcv_wscale) = 0;
 	if (wscale_ok) {
 		/* See RFC1323 for an explanation of the limit to 14 */
@@ -1514,7 +1514,7 @@
 			(*rcv_wscale)++;
 		}
 		if (*rcv_wscale && sysctl_tcp_app_win && space>=mss &&
-		    space - max(unsigned int, (space>>sysctl_tcp_app_win), mss>>*rcv_wscale) < 65536/2)
+		    space - max_t(unsigned int, (space>>sysctl_tcp_app_win), mss>>*rcv_wscale) < 65536/2)
 			(*rcv_wscale)--;
 	}
 
@@ -1532,7 +1532,7 @@
 			*rcv_wnd = init_cwnd*mss;
 	}
 	/* Set the clamp no higher than max representable value */
-	(*window_clamp) = min(u32, 65535 << (*rcv_wscale), *window_clamp);
+	(*window_clamp) = min_t(u32, 65535 << (*rcv_wscale), *window_clamp);
 }
 
 static inline int tcp_win_from_space(int space)
@@ -1698,8 +1698,8 @@
 static inline void tcp_moderate_sndbuf(struct sock *sk)
 {
 	if (!(sk->userlocks&SOCK_SNDBUF_LOCK)) {
-		sk->sndbuf = min(int, sk->sndbuf, sk->wmem_queued/2);
-		sk->sndbuf = max(int, sk->sndbuf, SOCK_MIN_SNDBUF);
+		sk->sndbuf = min_t(int, sk->sndbuf, sk->wmem_queued/2);
+		sk->sndbuf = max_t(int, sk->sndbuf, SOCK_MIN_SNDBUF);
 	}
 }
 
diff -urN linux-2.4.10-pre7/kernel/Makefile linux/kernel/Makefile
--- linux-2.4.10-pre7/kernel/Makefile	Fri Dec 29 14:07:24 2000
+++ linux/kernel/Makefile	Mon Dec  3 23:09:20 2001
@@ -9,7 +9,7 @@
 
 O_TARGET := kernel.o
 
-export-objs = signal.o sys.o kmod.o context.o ksyms.o pm.o
+export-objs = signal.o sys.o kmod.o context.o ksyms.o pm.o exec_domain.o
 
 obj-y     = sched.o dma.o fork.o exec_domain.o panic.o printk.o \
 	    module.o exit.o itimer.o info.o time.o softirq.o resource.o \
diff -urN linux-2.4.10-pre7/kernel/exec_domain.c linux/kernel/exec_domain.c
--- linux-2.4.10-pre7/kernel/exec_domain.c	Mon Jun 26 11:36:43 2000
+++ linux/kernel/exec_domain.c	Mon Dec  3 23:09:20 2001
@@ -1,11 +1,30 @@
-#include <linux/mm.h>
-#include <linux/smp_lock.h>
+/*
+ * Handling of different ABIs (personalities).
+ *
+ * We group personalities into execution domains which have their
+ * own handlers for kernel entry points, signal mapping, etc...
+ *
+ * 2001-05-06	Complete rewrite,  Christoph Hellwig (hch@caldera.de)
+ */
+
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/kmod.h>
 #include <linux/module.h>
+#include <linux/personality.h>
+#include <linux/sched.h>
+#include <linux/sysctl.h>
+#include <linux/types.h>
 
-static asmlinkage void no_lcall7(int segment, struct pt_regs * regs);
 
+static void default_handler(int, struct pt_regs *);
 
-static unsigned long ident_map[32] = {
+static struct exec_domain *exec_domains = &default_exec_domain;
+static rwlock_t exec_domains_lock = RW_LOCK_UNLOCKED;
+
+
+static u_long ident_map[32] = {
 	0,	1,	2,	3,	4,	5,	6,	7,
 	8,	9,	10,	11,	12,	13,	14,	15,
 	16,	17,	18,	19,	20,	21,	22,	23,
@@ -13,151 +32,260 @@
 };
 
 struct exec_domain default_exec_domain = {
-	"Linux",	/* name */
-	no_lcall7,	/* lcall7 causes a seg fault. */
-	0, 0xff,	/* All personalities. */
-	ident_map,	/* Identity map signals. */
-	ident_map,	/*  - both ways. */
-	NULL,		/* No usage counter. */
-	NULL		/* Nothing after this in the list. */
+	"Linux",		/* name */
+	default_handler,	/* lcall7 causes a seg fault. */
+	0, 0,			/* PER_LINUX personality. */
+	ident_map,		/* Identity map signals. */
+	ident_map,		/*  - both ways. */
 };
 
-static struct exec_domain *exec_domains = &default_exec_domain;
-static rwlock_t exec_domains_lock = RW_LOCK_UNLOCKED;
 
-static asmlinkage void no_lcall7(int segment, struct pt_regs * regs)
+static void
+default_handler(int segment, struct pt_regs *regp)
 {
-  /*
-   * This may have been a static linked SVr4 binary, so we would have the
-   * personality set incorrectly.  Check to see whether SVr4 is available,
-   * and use it, otherwise give the user a SEGV.
-   */
-	set_personality(PER_SVR4);
+	u_long			pers = 0;
 
-	if (current->exec_domain && current->exec_domain->handler
-	&& current->exec_domain->handler != no_lcall7) {
-		current->exec_domain->handler(segment, regs);
-		return;
+	/*
+	 * This may have been a static linked SVr4 binary, so we would
+	 * have the personality set incorrectly. Or it might have been
+	 * a Solaris/x86 binary. We can tell which because the former
+	 * uses lcall7, while the latter used lcall 0x27.
+	 * Try to find or load the appropriate personality, and fall back
+	 * to just forcing a SEGV.
+	 *
+	 * XXX: this is IA32-specific and should be moved to the MD-tree.
+	 */
+	switch (segment) {
+#ifdef __i386__
+	case 0x07:
+		pers = abi_defhandler_lcall7;
+		break;
+	case 0x27:
+		pers = PER_SOLARIS;
+		break;
+#endif
 	}
+	set_personality(pers);
 
-	send_sig(SIGSEGV, current, 1);
+	if (current->exec_domain->handler != default_handler)
+		current->exec_domain->handler(segment, regp);
+	else
+		send_sig(SIGSEGV, current, 1);
 }
 
-static struct exec_domain *lookup_exec_domain(unsigned long personality)
+static struct exec_domain *
+lookup_exec_domain(u_long personality)
 {
-	unsigned long pers = personality & PER_MASK;
-	struct exec_domain *it;
+	struct exec_domain *	ep;
+	char			buffer[30];
+	u_long			pers = personality(personality);
+		
+	read_lock(&exec_domains_lock);
+	for (ep = exec_domains; ep; ep = ep->next) {
+		if (pers >= ep->pers_low && pers <= ep->pers_high)
+			if (try_inc_mod_count(ep->module))
+				goto out;
+	}
+	read_unlock(&exec_domains_lock);
+
+#ifdef CONFIG_KMOD
+	sprintf(buffer, "personality-%ld", pers);
+	request_module(buffer);
 
 	read_lock(&exec_domains_lock);
-	for (it=exec_domains; it; it=it->next)
-		if (pers >= it->pers_low && pers <= it->pers_high) {
-			if (!try_inc_mod_count(it->module))
-				continue;
-			read_unlock(&exec_domains_lock);
-			return it;
-		}
+	for (ep = exec_domains; ep; ep = ep->next) {
+		if (pers >= ep->pers_low && pers <= ep->pers_high)
+			if (try_inc_mod_count(ep->module))
+				goto out;
+	}
 	read_unlock(&exec_domains_lock);
+#endif
 
-	/* Should never get this far. */
-	printk(KERN_ERR "No execution domain for personality 0x%02lx\n", pers);
-	return NULL;
+	ep = &default_exec_domain;
+out:
+	read_unlock(&exec_domains_lock);
+	return (ep);
 }
 
-int register_exec_domain(struct exec_domain *it)
+int
+register_exec_domain(struct exec_domain *ep)
 {
-	struct exec_domain *tmp;
+	struct exec_domain	*tmp;
+	int			err = -EBUSY;
 
-	if (!it)
+	if (ep == NULL)
 		return -EINVAL;
-	if (it->next)
+
+	if (ep->next != NULL)
 		return -EBUSY;
+
 	write_lock(&exec_domains_lock);
-	for (tmp=exec_domains; tmp; tmp=tmp->next)
-		if (tmp == it) {
-			write_unlock(&exec_domains_lock);
-			return -EBUSY;
-		}
-	it->next = exec_domains;
-	exec_domains = it;
+	for (tmp = exec_domains; tmp; tmp = tmp->next) {
+		if (tmp == ep)
+			goto out;
+	}
+
+	ep->next = exec_domains;
+	exec_domains = ep;
+	err = 0;
+
+out:
 	write_unlock(&exec_domains_lock);
-	return 0;
+	return (err);
 }
 
-int unregister_exec_domain(struct exec_domain *it)
+int
+unregister_exec_domain(struct exec_domain *ep)
 {
-	struct exec_domain ** tmp;
+	struct exec_domain	**epp;
 
-	tmp = &exec_domains;
+	epp = &exec_domains;
 	write_lock(&exec_domains_lock);
-	while (*tmp) {
-		if (it == *tmp) {
-			*tmp = it->next;
-			it->next = NULL;
-			write_unlock(&exec_domains_lock);
-			return 0;
-		}
-		tmp = &(*tmp)->next;
+	for (epp = &exec_domains; *epp; epp = &(*epp)->next) {
+		if (ep == *epp)
+			goto unregister;
 	}
 	write_unlock(&exec_domains_lock);
 	return -EINVAL;
+
+unregister:
+	*epp = ep->next;
+	ep->next = NULL;
+	write_unlock(&exec_domains_lock);
+	return 0;
 }
 
-void __set_personality(unsigned long personality)
+int
+__set_personality(u_long personality)
 {
-	struct exec_domain *it, *prev;
+	struct exec_domain	*ep, *oep;
 
-	it = lookup_exec_domain(personality);
-	if (it == current->exec_domain) {
+	ep = lookup_exec_domain(personality);
+	if (ep == NULL)
+		return -EINVAL;
+	if (ep == current->exec_domain) {
 		current->personality = personality;
-		return;
+		return 0;
 	}
-	if (!it)
-		return;
+
 	if (atomic_read(&current->fs->count) != 1) {
-		struct fs_struct *new = copy_fs_struct(current->fs);
-		struct fs_struct *old;
-		if (!new) {
-			put_exec_domain(it);
-			return;
+		struct fs_struct *fsp, *ofsp;
+
+		fsp = copy_fs_struct(current->fs);
+		if (fsp == NULL) {
+			put_exec_domain(ep);
+			return -ENOMEM;;
 		}
+
 		task_lock(current);
-		old = current->fs;
-		current->fs = new;
+		ofsp = current->fs;
+		current->fs = fsp;
 		task_unlock(current);
-		put_fs_struct(old);
+
+		put_fs_struct(ofsp);
 	}
+
 	/*
 	 * At that point we are guaranteed to be the sole owner of
 	 * current->fs.
 	 */
+
 	current->personality = personality;
-	prev = current->exec_domain;
-	current->exec_domain = it;
+	oep = current->exec_domain;
+	current->exec_domain = ep;
 	set_fs_altroot();
-	put_exec_domain(prev);
-}
 
-asmlinkage long sys_personality(unsigned long personality)
-{
-	int ret = current->personality;
-	if (personality != 0xffffffff) {
-		set_personality(personality);
-		if (current->personality != personality)
-			ret = -EINVAL;
-	}
-	return ret;
+	put_exec_domain(oep);
+
+	printk(KERN_DEBUG "[%s:%d]: set personality to %lx\n",
+			current->comm, current->pid, personality);
+	return 0;
 }
 
-int get_exec_domain_list(char * page)
+int
+get_exec_domain_list(char *page)
 {
-	int len = 0;
-	struct exec_domain * e;
+	struct exec_domain	*ep;
+	int			len = 0;
 
 	read_lock(&exec_domains_lock);
-	for (e=exec_domains; e && len < PAGE_SIZE - 80; e=e->next)
-		len += sprintf(page+len, "%d-%d\t%-16s\t[%s]\n",
-			e->pers_low, e->pers_high, e->name,
-			e->module ? e->module->name : "kernel");
+	for (ep = exec_domains; ep && len < PAGE_SIZE - 80; ep = ep->next)
+		len += sprintf(page + len, "%d-%d\t%-16s\t[%s]\n",
+			ep->pers_low, ep->pers_high, ep->name,
+			ep->module ? ep->module->name : "kernel");
 	read_unlock(&exec_domains_lock);
-	return len;
+	return (len);
 }
+
+asmlinkage long
+sys_personality(u_long personality)
+{
+	if (personality == 0xffffffff)
+		goto ret;
+	set_personality(personality);
+	if (current->personality != personality)
+		return -EINVAL;
+ret:
+	return (current->personality);
+}
+
+
+EXPORT_SYMBOL(register_exec_domain);
+EXPORT_SYMBOL(unregister_exec_domain);
+EXPORT_SYMBOL(__set_personality);
+
+/*
+ * We have to have all sysctl handling for the Linux-ABI
+ * in one place as the dynamic registration of sysctls is
+ * horribly crufty in Linux <= 2.4.
+ *
+ * I hope the new sysctl schemes discussed for future versions
+ * will obsolete this.
+ *
+ * 				--hch
+ */
+
+u_long abi_defhandler_coff = PER_SCOSVR3;
+u_long abi_defhandler_elf = PER_LINUX;
+u_long abi_defhandler_lcall7 = PER_SVR4;
+u_long abi_defhandler_libcso = PER_SVR4;
+u_int abi_traceflg;
+int abi_fake_utsname;
+
+static struct ctl_table abi_table[] = {
+	{ABI_DEFHANDLER_COFF, "defhandler_coff", &abi_defhandler_coff,
+		sizeof(int), 0644, NULL, &proc_doulongvec_minmax},
+	{ABI_DEFHANDLER_ELF, "defhandler_elf", &abi_defhandler_elf,
+		sizeof(int), 0644, NULL, &proc_doulongvec_minmax},
+	{ABI_DEFHANDLER_LCALL7, "defhandler_lcall7", &abi_defhandler_lcall7,
+		sizeof(int), 0644, NULL, &proc_doulongvec_minmax},
+	{ABI_DEFHANDLER_LIBCSO, "defhandler_libcso", &abi_defhandler_libcso,
+		sizeof(int), 0644, NULL, &proc_doulongvec_minmax},
+	{ABI_TRACE, "trace", &abi_traceflg,
+		sizeof(u_int), 0644, NULL, &proc_dointvec},
+	{ABI_FAKE_UTSNAME, "fake_utsname", &abi_fake_utsname,
+		sizeof(int), 0644, NULL, &proc_dointvec},
+	{0}
+};
+
+static struct ctl_table abi_root_table[] = {
+	{CTL_ABI, "abi", NULL, 0, 0555, abi_table},
+	{0}
+};
+
+static int __init
+abi_register_sysctl(void)
+{
+	register_sysctl_table(abi_root_table, 1);
+	return 0;
+}
+
+__initcall(abi_register_sysctl);
+
+
+EXPORT_SYMBOL(abi_defhandler_coff);
+EXPORT_SYMBOL(abi_defhandler_elf);
+EXPORT_SYMBOL(abi_defhandler_lcall7);
+EXPORT_SYMBOL(abi_defhandler_libcso);
+EXPORT_SYMBOL(abi_traceflg);
+EXPORT_SYMBOL(abi_fake_utsname);
diff -urN linux-2.4.10-pre7/kernel/exit.c linux/kernel/exit.c
--- linux-2.4.10-pre7/kernel/exit.c	Sun Aug 12 10:52:29 2001
+++ linux/kernel/exit.c	Mon Dec  3 23:09:20 2001
@@ -10,6 +10,7 @@
 #include <linux/smp_lock.h>
 #include <linux/module.h>
 #include <linux/completion.h>
+#include <linux/personality.h>
 #include <linux/tty.h>
 #ifdef CONFIG_BSD_PROCESS_ACCT
 #include <linux/acct.h>
diff -urN linux-2.4.10-pre7/kernel/fork.c linux/kernel/fork.c
--- linux-2.4.10-pre7/kernel/fork.c	Mon Dec  3 23:09:09 2001
+++ linux/kernel/fork.c	Mon Dec  3 23:09:20 2001
@@ -19,6 +19,7 @@
 #include <linux/module.h>
 #include <linux/vmalloc.h>
 #include <linux/completion.h>
+#include <linux/personality.h>
 
 #include <asm/pgtable.h>
 #include <asm/pgalloc.h>
diff -urN linux-2.4.10-pre7/kernel/ksyms.c linux/kernel/ksyms.c
--- linux-2.4.10-pre7/kernel/ksyms.c	Mon Dec  3 23:09:09 2001
+++ linux/kernel/ksyms.c	Mon Dec  3 23:09:20 2001
@@ -334,11 +334,6 @@
 EXPORT_SYMBOL(remove_arg_zero);
 EXPORT_SYMBOL(set_binfmt);
 
-/* execution environment registration */
-EXPORT_SYMBOL(register_exec_domain);
-EXPORT_SYMBOL(unregister_exec_domain);
-EXPORT_SYMBOL(__set_personality);
-
 /* sysctl table registration */
 EXPORT_SYMBOL(register_sysctl_table);
 EXPORT_SYMBOL(unregister_sysctl_table);
diff -urN linux-2.4.10-pre7/mm/memory.c linux/mm/memory.c
--- linux-2.4.10-pre7/mm/memory.c	Mon Dec  3 23:09:09 2001
+++ linux/mm/memory.c	Mon Dec  3 23:09:20 2001
@@ -1008,7 +1008,7 @@
  * between the file and the memory map for a potential last
  * incomplete page.  Ugly, but necessary.
  */
-void vmtruncate(struct inode * inode, loff_t offset)
+int vmtruncate(struct inode * inode, loff_t offset)
 {
 	unsigned long pgoff;
 	struct address_space *mapping = inode->i_mapping;
@@ -1053,7 +1053,7 @@
 		unlock_kernel();
 	}
 out:
-	return;
+	return 0;
 }
 
 /* 
diff -urN linux-2.4.10-pre7/mm/slab.c linux/mm/slab.c
--- linux-2.4.10-pre7/mm/slab.c	Mon Dec  3 23:09:09 2001
+++ linux/mm/slab.c	Mon Dec  3 23:09:20 2001
@@ -85,9 +85,15 @@
  * FORCED_DEBUG	- 1 enables SLAB_RED_ZONE and SLAB_POISON (if possible)
  */
 
+#ifdef CONFIG_DEBUG_SLAB
+#define	DEBUG		1
+#define	STATS		1
+#define	FORCED_DEBUG	1
+#else
 #define	DEBUG		0
 #define	STATS		0
 #define	FORCED_DEBUG	0
+#endif
 
 /*
  * Parameters for kmem_cache_reap
@@ -816,6 +822,33 @@
 	return cachep;
 }
 
+
+#if DEBUG
+/*
+ * This check if the kmem_cache_t pointer is chained in the cache_cache
+ * list. -arca
+ */
+static int is_chained_kmem_cache(kmem_cache_t * cachep)
+{
+	struct list_head *p;
+	int ret = 0;
+
+	/* Find the cache in the chain of caches. */
+	down(&cache_chain_sem);
+	list_for_each(p, &cache_chain) {
+		if (p == &cachep->next) {
+			ret = 1;
+			break;
+		}
+	}
+	up(&cache_chain_sem);
+
+	return ret;
+}
+#else
+#define is_chained_kmem_cache(x) 1
+#endif
+
 #ifdef CONFIG_SMP
 /*
  * Waits for all CPUs to execute func().
@@ -915,7 +948,7 @@
  */
 int kmem_cache_shrink(kmem_cache_t *cachep)
 {
-	if (!cachep || in_interrupt())
+	if (!cachep || in_interrupt() || !is_chained_kmem_cache(cachep))
 		BUG();
 
 	return __kmem_cache_shrink(cachep);
diff -urN linux-2.4.10-pre7/net/appletalk/ddp.c linux/net/appletalk/ddp.c
--- linux-2.4.10-pre7/net/appletalk/ddp.c	Mon Dec  3 23:09:09 2001
+++ linux/net/appletalk/ddp.c	Mon Dec  3 23:09:20 2001
@@ -1390,7 +1390,7 @@
 
 	/* Trim buffer in case of stray trailing data */
 	origlen = skb->len;
-	skb_trim(skb, min(unsigned int, skb->len, ddphv.deh_len));
+	skb_trim(skb, min_t(unsigned int, skb->len, ddphv.deh_len));
 
 	/*
 	 * Size check to see if ddp->deh_len was crap
@@ -1455,7 +1455,7 @@
 		}
 
                 /* Fix up skb->len field */
-                skb_trim(skb, min(unsigned int, origlen, rt->dev->hard_header_len +
+                skb_trim(skb, min_t(unsigned int, origlen, rt->dev->hard_header_len +
 			ddp_dl->header_length + ddphv.deh_len));
 
 		/* Mend the byte order */
diff -urN linux-2.4.10-pre7/net/ax25/af_ax25.c linux/net/ax25/af_ax25.c
--- linux-2.4.10-pre7/net/ax25/af_ax25.c	Wed Aug 15 01:22:17 2001
+++ linux/net/ax25/af_ax25.c	Mon Dec  3 23:09:20 2001
@@ -751,7 +751,7 @@
 		return -EFAULT;
 
 	valptr = (void *) &val;
-	length = min(unsigned int, maxlen, sizeof(int));
+	length = min_t(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(unsigned int, strlen(ax25_dev->dev->name)+1, maxlen);
+				length = min_t(unsigned int, strlen(ax25_dev->dev->name)+1, maxlen);
 				devname[length-1] = '\0';
 			} else {
 				*devname = '\0';
diff -urN linux-2.4.10-pre7/net/core/iovec.c linux/net/core/iovec.c
--- linux-2.4.10-pre7/net/core/iovec.c	Wed Aug 15 01:22:17 2001
+++ linux/net/core/iovec.c	Mon Dec  3 23:09:20 2001
@@ -87,7 +87,7 @@
 	{
 		if(iov->iov_len)
 		{
-			int copy = min(unsigned int, iov->iov_len, len);
+			int copy = min_t(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(unsigned int, iov->iov_len, len);
+			int copy = min_t(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(unsigned int, len, iov->iov_len);
+			int copy = min_t(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(unsigned int, len, iov->iov_len - offset);
+		int copy = min_t(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;
-		int copy = min(unsigned int, len, iov->iov_len - offset);
+		int copy = min_t(unsigned int, len, iov->iov_len - offset);
 
 		offset = 0;
 		/* There is a remnant from previous iov. */
diff -urN linux-2.4.10-pre7/net/ipv4/ip_sockglue.c linux/net/ipv4/ip_sockglue.c
--- linux-2.4.10-pre7/net/ipv4/ip_sockglue.c	Wed Aug 15 01:22:17 2001
+++ linux/net/ipv4/ip_sockglue.c	Mon Dec  3 23:09:20 2001
@@ -683,7 +683,7 @@
 
 				ip_options_undo(opt);
 
-				len = min(unsigned int, len, opt->optlen);
+				len = min_t(unsigned int, len, opt->optlen);
 				if(put_user(len, optlen))
 					return -EFAULT;
 				if(copy_to_user(optval, opt->__data, len))
@@ -744,7 +744,7 @@
 		case IP_MULTICAST_IF:
 		{
 			struct in_addr addr;
-			len = min(unsigned int, len, sizeof(struct in_addr));
+			len = min_t(unsigned int, len, sizeof(struct in_addr));
 			addr.s_addr = sk->protinfo.af_inet.mc_addr;
 			release_sock(sk);
 
@@ -808,7 +808,7 @@
 		if(copy_to_user(optval,&ucval,1))
 			return -EFAULT;
 	} else {
-		len = min(unsigned int, sizeof(int), len);
+		len = min_t(unsigned int, sizeof(int), len);
 		if(put_user(len, optlen))
 			return -EFAULT;
 		if(copy_to_user(optval,&val,len))
diff -urN linux-2.4.10-pre7/net/ipv4/ipmr.c linux/net/ipv4/ipmr.c
--- linux-2.4.10-pre7/net/ipv4/ipmr.c	Wed Aug 15 01:22:17 2001
+++ linux/net/ipv4/ipmr.c	Mon Dec  3 23:09:20 2001
@@ -979,7 +979,7 @@
 	if (get_user(olr, optlen))
 		return -EFAULT;
 
-	olr = min(unsigned int, olr, sizeof(int));
+	olr = min_t(unsigned int, olr, sizeof(int));
 	if (olr < 0)
 		return -EINVAL;
 		
diff -urN linux-2.4.10-pre7/net/ipv4/netfilter/ipchains_core.c linux/net/ipv4/netfilter/ipchains_core.c
--- linux-2.4.10-pre7/net/ipv4/netfilter/ipchains_core.c	Wed Aug 15 01:22:17 2001
+++ linux/net/ipv4/netfilter/ipchains_core.c	Mon Dec  3 23:09:20 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(unsigned int, f->ipfw.fw_outputsize, ntohs(ip->tot_len))
+		size_t len = min_t(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.10-pre7/net/ipv4/netfilter/ipfwadm_core.c linux/net/ipv4/netfilter/ipfwadm_core.c
--- linux-2.4.10-pre7/net/ipv4/netfilter/ipfwadm_core.c	Wed Aug 15 01:22:17 2001
+++ linux/net/ipv4/netfilter/ipfwadm_core.c	Mon Dec  3 23:09:20 2001
@@ -648,7 +648,7 @@
 			struct sk_buff *skb=alloc_skb(128, GFP_ATOMIC);
 			if(skb)
 			{
-				int len = min(unsigned int,
+				int len = min_t(unsigned int,
 					      128, ntohs(ip->tot_len));
 
 				skb_put(skb,len);
diff -urN linux-2.4.10-pre7/net/ipv4/route.c linux/net/ipv4/route.c
--- linux-2.4.10-pre7/net/ipv4/route.c	Wed Aug 15 01:22:17 2001
+++ linux/net/ipv4/route.c	Mon Dec  3 23:09:20 2001
@@ -515,14 +515,14 @@
 			equilibrium = ipv4_dst_ops.gc_thresh;
 		goal = atomic_read(&ipv4_dst_ops.entries) - equilibrium;
 		if (goal > 0) {
-			equilibrium += min(unsigned int, goal / 2, rt_hash_mask + 1);
+			equilibrium += min_t(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(unsigned int, goal / 2, rt_hash_mask + 1);
+		goal = max_t(unsigned int, goal / 2, rt_hash_mask + 1);
 		equilibrium = atomic_read(&ipv4_dst_ops.entries) - goal;
 	}
 
@@ -1207,7 +1207,7 @@
 	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(unsigned int, rt->u.dst.dev->mtu - 40,
+		rt->u.dst.advmss = max_t(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.10-pre7/net/ipv4/tcp.c linux/net/ipv4/tcp.c
--- linux-2.4.10-pre7/net/ipv4/tcp.c	Mon Dec  3 23:09:10 2001
+++ linux/net/ipv4/tcp.c	Mon Dec  3 23:09:20 2001
@@ -852,7 +852,7 @@
 
 		page = pages[poffset/PAGE_SIZE];
 		offset = poffset % PAGE_SIZE;
-		size = min(unsigned int, psize, PAGE_SIZE-offset);
+		size = min_t(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(unsigned int, len, sizeof(int));
+	len = min_t(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(unsigned int, len, sizeof(info));
+		len = min_t(unsigned int, len, sizeof(info));
 		if(put_user(len, optlen))
 			return -EFAULT;
 		if(copy_to_user(optval, &info,len))
diff -urN linux-2.4.10-pre7/net/ipv4/tcp_input.c linux/net/ipv4/tcp_input.c
--- linux-2.4.10-pre7/net/ipv4/tcp_input.c	Wed Aug 15 01:22:17 2001
+++ linux/net/ipv4/tcp_input.c	Mon Dec  3 23:09:20 2001
@@ -168,7 +168,7 @@
 	if (quickacks==0)
 		quickacks=2;
 	if (quickacks > tp->ack.quick)
-		tp->ack.quick = min(unsigned int, quickacks, TCP_MAX_QUICKACKS);
+		tp->ack.quick = min_t(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(int, 3*sndmem, sysctl_tcp_wmem[2]);
+		sk->sndbuf = min_t(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(u32, tp->rcv_ssthresh + incr, tp->window_clamp);
+			tp->rcv_ssthresh = min_t(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(int, 4*rcvmem, sysctl_tcp_rmem[2]);
+		sk->rcvbuf = min_t(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(u32, maxwin-(maxwin>>sysctl_tcp_app_win), 4*tp->advmss);
+			tp->window_clamp = max_t(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(u32, 2*tp->advmss, maxwin-tp->advmss);
+		tp->window_clamp = max_t(u32, 2*tp->advmss, maxwin-tp->advmss);
 
-	tp->rcv_ssthresh = min(u32, tp->rcv_ssthresh, tp->window_clamp);
+	tp->rcv_ssthresh = min_t(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(int, atomic_read(&sk->rmem_alloc), sysctl_tcp_rmem[2]);
+			sk->rcvbuf = min_t(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(unsigned int, app_win, 2*tp->advmss);
+		app_win = max_t(unsigned int, app_win, 2*tp->advmss);
 
 		if (!ofo_win)
-			tp->window_clamp = min(u32, tp->window_clamp, app_win);
-		tp->rcv_ssthresh = min(u32, tp->window_clamp, 2*tp->advmss);
+			tp->window_clamp = min_t(u32, tp->window_clamp, app_win);
+		tp->rcv_ssthresh = min_t(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(u32, tp->mdev, TCP_RTO_MIN);
+		tp->mdev_max = tp->rttvar = max_t(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(u32, tp->snd_cwnd>>1, tp->snd_ssthresh);
+				dst->ssthresh = max_t(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(u32, cwnd, tp->snd_cwnd_clamp);
+	return min_t(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(u32, tp->mdev, TCP_RTO_MIN);
+		tp->mdev_max = tp->rttvar = max_t(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(unsigned int, TCP_MAX_REORDERING, metric);
+		tp->reordering = min_t(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(int, fack_count, reord);
+						reord = min_t(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(int, fack_count, reord);
+						reord = min_t(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(int, fack_count, reord);
+						reord = min_t(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(int, fack_count, reord);
+					reord = min_t(int, fack_count, reord);
 			}
 
 			/* D-SACK. We can detect redundant retransmission
@@ -1019,7 +1019,7 @@
 	}
 	tcp_sync_left_out(tp);
 
-	tp->reordering = min(unsigned int, tp->reordering, sysctl_tcp_reordering);
+	tp->reordering = min_t(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(u32, tp->packets_out/2, sysctl_tcp_reordering) &&
+	    tp->sacked_out >= max_t(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,8 +1194,8 @@
  */
 static void tcp_check_reno_reordering(struct tcp_opt *tp, int addend)
 {
-	u32 holes = min(unsigned int,
-			max(unsigned int, tp->lost_out, 1),
+	u32 holes = min_t(unsigned int,
+			max_t(unsigned int, tp->lost_out, 1),
 			tp->packets_out);
 
 	if (tp->sacked_out + holes > tp->packets_out) {
@@ -1291,7 +1291,7 @@
  */
 static __inline__ void tcp_moderate_cwnd(struct tcp_opt *tp)
 {
-	tp->snd_cwnd = min(u32, tp->snd_cwnd,
+	tp->snd_cwnd = min_t(u32, tp->snd_cwnd,
 			   tcp_packets_in_flight(tp)+tcp_max_burst(tp));
 	tp->snd_cwnd_stamp = tcp_time_stamp;
 }
@@ -1308,7 +1308,7 @@
 	if (decr && tp->snd_cwnd > tp->snd_ssthresh/2)
 		tp->snd_cwnd -= decr;
 
-	tp->snd_cwnd = min(u32, tp->snd_cwnd, tcp_packets_in_flight(tp)+1);
+	tp->snd_cwnd = min_t(u32, tp->snd_cwnd, tcp_packets_in_flight(tp)+1);
 	tp->snd_cwnd_stamp = tcp_time_stamp;
 }
 
@@ -1340,7 +1340,7 @@
 static void tcp_undo_cwr(struct tcp_opt *tp, int undo)
 {
 	if (tp->prior_ssthresh) {
-		tp->snd_cwnd = max(unsigned int,
+		tp->snd_cwnd = max_t(unsigned int,
 				   tp->snd_cwnd, tp->snd_ssthresh<<1);
 
 		if (undo && tp->prior_ssthresh > tp->snd_ssthresh) {
@@ -1348,7 +1348,7 @@
 			TCP_ECN_withdraw_cwr(tp);
 		}
 	} else {
-		tp->snd_cwnd = max(unsigned int, tp->snd_cwnd, tp->snd_ssthresh);
+		tp->snd_cwnd = max_t(unsigned int, tp->snd_cwnd, tp->snd_ssthresh);
 	}
 	tcp_moderate_cwnd(tp);
 	tp->snd_cwnd_stamp = tcp_time_stamp;
@@ -1450,7 +1450,7 @@
 
 static __inline__ void tcp_complete_cwr(struct tcp_opt *tp)
 {
-	tp->snd_cwnd = min(u32, tp->snd_cwnd, tp->snd_ssthresh);
+	tp->snd_cwnd = min_t(u32, tp->snd_cwnd, tp->snd_ssthresh);
 	tp->snd_cwnd_stamp = tcp_time_stamp;
 }
 
@@ -1836,7 +1836,7 @@
 		 */
 	} else {
 		tcp_reset_xmit_timer(sk, TCP_TIME_PROBE0,
-				     min(u32, tp->rto << tp->backoff, TCP_RTO_MAX));
+				     min_t(u32, tp->rto << tp->backoff, TCP_RTO_MAX));
 	}
 }
 
@@ -2323,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(unsigned int, tp->num_sacks+1, 4-tp->tstamp_ok);
+		tp->eff_sacks = min_t(unsigned int, tp->num_sacks+1, 4-tp->tstamp_ok);
 	}
 }
 
@@ -2376,7 +2376,7 @@
 			 * Decrease num_sacks.
 			 */
 			tp->num_sacks--;
-			tp->eff_sacks = min(unsigned int, tp->num_sacks+tp->dsack, 4-tp->tstamp_ok);
+			tp->eff_sacks = min_t(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;
@@ -2438,7 +2438,7 @@
 	sp->start_seq = seq;
 	sp->end_seq = end_seq;
 	tp->num_sacks++;
-	tp->eff_sacks = min(unsigned int, tp->num_sacks+tp->dsack, 4-tp->tstamp_ok);
+	tp->eff_sacks = min_t(unsigned int, tp->num_sacks+tp->dsack, 4-tp->tstamp_ok);
 }
 
 /* RCV.NXT advances, some SACKs should be eaten. */
@@ -2475,7 +2475,7 @@
 	}
 	if (num_sacks != tp->num_sacks) {
 		tp->num_sacks = num_sacks;
-		tp->eff_sacks = min(unsigned int, tp->num_sacks+tp->dsack, 4-tp->tstamp_ok);
+		tp->eff_sacks = min_t(unsigned int, tp->num_sacks+tp->dsack, 4-tp->tstamp_ok);
 	}
 }
 
@@ -2541,7 +2541,7 @@
 
 	if (tp->dsack) {
 		tp->dsack = 0;
-		tp->eff_sacks = min(unsigned int, tp->num_sacks, 4-tp->tstamp_ok);
+		tp->eff_sacks = min_t(unsigned int, tp->num_sacks, 4-tp->tstamp_ok);
 	}
 
 	/*  Queue data for delivery to the user.
@@ -2558,7 +2558,7 @@
 		    tp->ucopy.len &&
 		    sk->lock.users &&
 		    !tp->urg_data) {
-			int chunk = min(unsigned int, skb->len, tp->ucopy.len);
+			int chunk = min_t(unsigned int, skb->len, tp->ucopy.len);
 
 			__set_current_state(TASK_RUNNING);
 
@@ -2807,7 +2807,7 @@
 
 			if (offset < 0) BUG();
 			if (size > 0) {
-				size = min(int, copy, size);
+				size = min_t(int, copy, size);
 				if (skb_copy_bits(skb, offset, skb_put(nskb, size), size))
 					BUG();
 				TCP_SKB_CB(nskb)->end_seq += size;
@@ -2886,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(u32, tp->rcv_ssthresh, 4*tp->advmss);
+		tp->rcv_ssthresh = min_t(u32, tp->rcv_ssthresh, 4*tp->advmss);
 
 	tcp_collapse_ofo_queue(sk);
 	tcp_collapse(sk, sk->receive_queue.next,
@@ -2941,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(u32, tp->snd_cwnd_used, 2);
+		u32 win_used = max_t(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;
@@ -2967,10 +2967,10 @@
 		int sndmem, demanded;
 
 		sndmem = tp->mss_clamp+MAX_TCP_HEADER+16+sizeof(struct sk_buff);
-		demanded = max(unsigned int, tp->snd_cwnd, tp->reordering+1);
+		demanded = max_t(unsigned int, tp->snd_cwnd, tp->reordering+1);
 		sndmem *= 2*demanded;
 		if (sndmem > sk->sndbuf)
-			sk->sndbuf = min(int, sndmem, sysctl_tcp_wmem[2]);
+			sk->sndbuf = min_t(int, sndmem, sysctl_tcp_wmem[2]);
 		tp->snd_cwnd_stamp = tcp_time_stamp;
 	}
 
@@ -3520,7 +3520,7 @@
 
 		if (tp->wscale_ok == 0) {
 			tp->snd_wscale = tp->rcv_wscale = 0;
-			tp->window_clamp = min(u32, tp->window_clamp, 65535);
+			tp->window_clamp = min_t(u32, tp->window_clamp, 65535);
 		}
 
 		if (tp->saw_tstamp) {
diff -urN linux-2.4.10-pre7/net/ipv4/tcp_minisocks.c linux/net/ipv4/tcp_minisocks.c
--- linux-2.4.10-pre7/net/ipv4/tcp_minisocks.c	Wed Aug 15 01:22:17 2001
+++ linux/net/ipv4/tcp_minisocks.c	Mon Dec  3 23:09:20 2001
@@ -766,7 +766,7 @@
 			newtp->rcv_wscale = req->rcv_wscale;
 		} else {
 			newtp->snd_wscale = newtp->rcv_wscale = 0;
-			newtp->window_clamp = min(u32, newtp->window_clamp, 65535);
+			newtp->window_clamp = min_t(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.10-pre7/net/ipv4/tcp_output.c linux/net/ipv4/tcp_output.c
--- linux-2.4.10-pre7/net/ipv4/tcp_output.c	Wed Aug 15 01:22:17 2001
+++ linux/net/ipv4/tcp_output.c	Mon Dec  3 23:09:20 2001
@@ -105,11 +105,11 @@
 	u32 cwnd = tp->snd_cwnd;
 
 	tp->snd_ssthresh = tcp_current_ssthresh(tp);
-	restart_cwnd = min(u32, restart_cwnd, cwnd);
+	restart_cwnd = min_t(u32, restart_cwnd, cwnd);
 
 	while ((delta -= tp->rto) > 0 && cwnd > restart_cwnd)
 		cwnd >>= 1;
-	tp->snd_cwnd = max(u32, cwnd, restart_cwnd);
+	tp->snd_cwnd = max_t(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(u32, (tp->max_window>>1), 68 - tp->tcp_header_len);
+		mss_now = max_t(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(unsigned int, tp->window_clamp, tcp_full_space(sk));
+	int full_space = min_t(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(u32, tp->rcv_ssthresh, 4*tp->advmss);
+			tp->rcv_ssthresh = min_t(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(int, sk->wmem_queued+(sk->wmem_queued>>2),sk->sndbuf))
+	if (atomic_read(&sk->wmem_alloc) > min_t(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(unsigned int, tp->srtt>>3, TCP_DELACK_MIN);
+			int rtt = max_t(unsigned int, tp->srtt>>3, TCP_DELACK_MIN);
 
 			if (rtt < max_ato)
 				max_ato = rtt;
 		}
 
-		ato = min(int, ato, max_ato);
+		ato = min_t(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(int, seg_size, mss);
+				seg_size = min_t(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(u32, tp->rto << tp->backoff, TCP_RTO_MAX));
+				      min_t(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(unsigned int, tp->rto << tp->backoff, TCP_RESOURCE_PROBE_INTERVAL));
+				      min_t(unsigned int, tp->rto << tp->backoff, TCP_RESOURCE_PROBE_INTERVAL));
 	}
 }
diff -urN linux-2.4.10-pre7/net/ipv4/tcp_timer.c linux/net/ipv4/tcp_timer.c
--- linux-2.4.10-pre7/net/ipv4/tcp_timer.c	Wed Aug 15 01:22:17 2001
+++ linux/net/ipv4/tcp_timer.c	Mon Dec  3 23:09:20 2001
@@ -248,7 +248,7 @@
 	if (tcp_ack_scheduled(tp)) {
 		if (!tp->ack.pingpong) {
 			/* Delayed ACK missed: inflate ATO. */
-			tp->ack.ato = min(u32, tp->ack.ato << 1, tp->rto);
+			tp->ack.ato = min_t(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(u32, tp->rto, TCP_RESOURCE_PROBE_INTERVAL));
+				     min_t(u32, tp->rto, TCP_RESOURCE_PROBE_INTERVAL));
 		goto out;
 	}
 
@@ -404,7 +404,7 @@
 	tp->retransmits++;
 
 out_reset_timer:
-	tp->rto = min(u32, tp->rto << 1, TCP_RTO_MAX);
+	tp->rto = min_t(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,7 @@
 
 					if (req->retrans++ == 0)
 						lopt->qlen_young--;
-					timeo = min(unsigned long,
+					timeo = min_t(unsigned long,
 						    (TCP_TIMEOUT_INIT << req->retrans),
 						    TCP_RTO_MAX);
 					req->expires = now + timeo;
diff -urN linux-2.4.10-pre7/net/ipv6/icmp.c linux/net/ipv6/icmp.c
--- linux-2.4.10-pre7/net/ipv6/icmp.c	Mon Dec  3 23:09:10 2001
+++ linux/net/ipv6/icmp.c	Mon Dec  3 23:09:20 2001
@@ -366,7 +366,7 @@
 	msg.daddr = &hdr->saddr;
 
 	len = skb->len - msg.offset + sizeof(struct icmp6hdr);
-	len = min(unsigned int, len, IPV6_MIN_MTU - sizeof(struct ipv6hdr));
+	len = min_t(unsigned int, len, IPV6_MIN_MTU - sizeof(struct ipv6hdr));
 
 	if (len < 0) {
 		if (net_ratelimit())
diff -urN linux-2.4.10-pre7/net/ipv6/ipv6_sockglue.c linux/net/ipv6/ipv6_sockglue.c
--- linux-2.4.10-pre7/net/ipv6/ipv6_sockglue.c	Wed Aug 15 01:22:17 2001
+++ linux/net/ipv6/ipv6_sockglue.c	Mon Dec  3 23:09:20 2001
@@ -535,7 +535,7 @@
 		return -EINVAL;
 #endif
 	}
-	len = min(unsigned int, sizeof(int), len);
+	len = min_t(unsigned int, sizeof(int), len);
 	if(put_user(len, optlen))
 		return -EFAULT;
 	if(copy_to_user(optval,&val,len))
diff -urN linux-2.4.10-pre7/net/ipv6/ndisc.c linux/net/ipv6/ndisc.c
--- linux-2.4.10-pre7/net/ipv6/ndisc.c	Wed Aug 15 01:22:18 2001
+++ linux/net/ipv6/ndisc.c	Mon Dec  3 23:09:20 2001
@@ -846,7 +846,7 @@
 		}
 	}
 
-	rd_len = min(unsigned int,
+	rd_len = min_t(unsigned int,
 		     IPV6_MIN_MTU-sizeof(struct ipv6hdr)-len, skb->len + 8);
 	rd_len &= ~0x7;
 	len += rd_len;
diff -urN linux-2.4.10-pre7/net/ipv6/raw.c linux/net/ipv6/raw.c
--- linux-2.4.10-pre7/net/ipv6/raw.c	Wed Aug 15 01:22:18 2001
+++ linux/net/ipv6/raw.c	Mon Dec  3 23:09:20 2001
@@ -699,7 +699,7 @@
 		return -ENOPROTOOPT;
 	}
 
-	len = min(unsigned int, sizeof(int), len);
+	len = min_t(unsigned int, sizeof(int), len);
 
 	if (put_user(len, optlen))
 		return -EFAULT;
diff -urN linux-2.4.10-pre7/net/ipv6/route.c linux/net/ipv6/route.c
--- linux-2.4.10-pre7/net/ipv6/route.c	Wed Aug 15 01:22:18 2001
+++ linux/net/ipv6/route.c	Mon Dec  3 23:09:20 2001
@@ -785,7 +785,7 @@
 
 install_route:
 	rt->u.dst.pmtu = ipv6_get_mtu(dev);
-	rt->u.dst.advmss = max(unsigned int, rt->u.dst.pmtu - 60, ip6_rt_min_advmss);
+	rt->u.dst.advmss = max_t(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(unsigned int, nrt->u.dst.pmtu - 60, ip6_rt_min_advmss);
+	nrt->u.dst.advmss = max_t(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(unsigned int, rt->u.dst.pmtu - 60, ip6_rt_min_advmss);
+	rt->u.dst.advmss = max_t(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(unsigned int, arg->mtu - 60, ip6_rt_min_advmss);
+	rt->u.dst.advmss = max_t(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.10-pre7/net/ipx/af_ipx.c linux/net/ipx/af_ipx.c
--- linux-2.4.10-pre7/net/ipx/af_ipx.c	Wed Aug 15 01:22:18 2001
+++ linux/net/ipx/af_ipx.c	Mon Dec  3 23:09:20 2001
@@ -1890,7 +1890,7 @@
 	if (get_user(len, optlen))
 		goto out;
 
-	len = min(unsigned int, len, sizeof(int));
+	len = min_t(unsigned int, len, sizeof(int));
 	ret = -EINVAL;
 	if(len < 0)
 		goto out;
diff -urN linux-2.4.10-pre7/net/irda/af_irda.c linux/net/irda/af_irda.c
--- linux-2.4.10-pre7/net/irda/af_irda.c	Mon Dec  3 23:09:10 2001
+++ linux/net/irda/af_irda.c	Mon Dec  3 23:09:20 2001
@@ -1400,7 +1400,7 @@
 			continue;
 		}
 
-		chunk = min(unsigned int, skb->len, size);
+		chunk = min_t(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.10-pre7/net/khttpd/datasending.c linux/net/khttpd/datasending.c
--- linux-2.4.10-pre7/net/khttpd/datasending.c	Wed Aug 15 01:22:18 2001
+++ linux/net/khttpd/datasending.c	Mon Dec  3 23:09:20 2001
@@ -105,8 +105,8 @@
 		
 		Space = sock_wspace(CurrentRequest->sock->sk);
 		
-		ReadSize = min(int, 4 * 4096, CurrentRequest->FileLength - CurrentRequest->BytesSent);
-		ReadSize = min(int, ReadSize, Space);
+		ReadSize = min_t(int, 4 * 4096, CurrentRequest->FileLength - CurrentRequest->BytesSent);
+		ReadSize = min_t(int, ReadSize, Space);
 
 		if (ReadSize>0)
 		{			
diff -urN linux-2.4.10-pre7/net/khttpd/rfc.c linux/net/khttpd/rfc.c
--- linux-2.4.10-pre7/net/khttpd/rfc.c	Wed Aug 15 01:22:18 2001
+++ linux/net/khttpd/rfc.c	Mon Dec  3 23:09:20 2001
@@ -326,9 +326,9 @@
 			
 			strncpy(Head->FileName,sysctl_khttpd_docroot,sizeof(Head->FileName));
 			PrefixLen = strlen(sysctl_khttpd_docroot);
-			Head->FileNameLength = min(unsigned int, 255, tmp - Buffer + PrefixLen);		
+			Head->FileNameLength = min_t(unsigned int, 255, tmp - Buffer + PrefixLen);		
 			
-			strncat(Head->FileName,Buffer,min(unsigned int, 255 - PrefixLen, tmp - Buffer));
+			strncat(Head->FileName,Buffer,min_t(unsigned int, 255 - PrefixLen, tmp - Buffer));
 					
 			Buffer=EOL+1;	
 #ifdef BENCHMARK
@@ -341,7 +341,7 @@
 		{
 			Buffer+=19;
 			
-			strncpy(Head->IMS,Buffer,min(unsigned int, 127,EOL-Buffer-1));
+			strncpy(Head->IMS,Buffer,min_t(unsigned int, 127,EOL-Buffer-1));
 					
 			Buffer=EOL+1;	
 			continue;
@@ -351,7 +351,7 @@
 		{
 			Buffer+=12;
 			
-			strncpy(Head->Agent,Buffer,min(unsigned int, 127,EOL-Buffer-1));
+			strncpy(Head->Agent,Buffer,min_t(unsigned int, 127,EOL-Buffer-1));
 					
 			Buffer=EOL+1;	
 			continue;
@@ -362,7 +362,7 @@
 		{
 			Buffer+=6;
 			
-			strncpy(Head->Host,Buffer,min(unsigned int, 127,EOL-Buffer-1));
+			strncpy(Head->Host,Buffer,min_t(unsigned int, 127,EOL-Buffer-1));
 					
 			Buffer=EOL+1;	
 			continue;
diff -urN linux-2.4.10-pre7/net/khttpd/waitheaders.c linux/net/khttpd/waitheaders.c
--- linux-2.4.10-pre7/net/khttpd/waitheaders.c	Wed Aug 15 01:22:18 2001
+++ linux/net/khttpd/waitheaders.c	Mon Dec  3 23:09:20 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(unsigned int, Request->Time,CurrentTime_i),Request->TimeS);
+		time_Unix2RFC(min_t(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.10-pre7/net/netrom/af_netrom.c linux/net/netrom/af_netrom.c
--- linux-2.4.10-pre7/net/netrom/af_netrom.c	Mon Dec  3 23:09:10 2001
+++ linux/net/netrom/af_netrom.c	Mon Dec  3 23:09:20 2001
@@ -435,7 +435,7 @@
 			return -ENOPROTOOPT;
 	}
 
-	len = min(unsigned int, len, sizeof(int));
+	len = min_t(unsigned int, len, sizeof(int));
 
 	if (put_user(len, optlen))
 		return -EFAULT;
diff -urN linux-2.4.10-pre7/net/rose/af_rose.c linux/net/rose/af_rose.c
--- linux-2.4.10-pre7/net/rose/af_rose.c	Wed Aug 15 01:22:18 2001
+++ linux/net/rose/af_rose.c	Mon Dec  3 23:09:20 2001
@@ -508,7 +508,7 @@
 			return -ENOPROTOOPT;
 	}
 
-	len = min(unsigned int, len, sizeof(int));
+	len = min_t(unsigned int, len, sizeof(int));
 
 	if (put_user(len, optlen))
 		return -EFAULT;
diff -urN linux-2.4.10-pre7/net/sched/sch_tbf.c linux/net/sched/sch_tbf.c
--- linux-2.4.10-pre7/net/sched/sch_tbf.c	Wed Aug 15 01:22:18 2001
+++ linux/net/sched/sch_tbf.c	Mon Dec  3 23:09:20 2001
@@ -227,7 +227,7 @@
 		}
 
 		if (!netif_queue_stopped(sch->dev)) {
-			long delay = PSCHED_US2JIFFIE(max(long, -toks, -ptoks));
+			long delay = PSCHED_US2JIFFIE(max_t(long, -toks, -ptoks));
 
 			if (delay == 0)
 				delay = 1;
diff -urN linux-2.4.10-pre7/net/sunrpc/xprt.c linux/net/sunrpc/xprt.c
--- linux-2.4.10-pre7/net/sunrpc/xprt.c	Wed Aug 15 01:22:18 2001
+++ linux/net/sunrpc/xprt.c	Mon Dec  3 23:09:20 2001
@@ -744,7 +744,7 @@
 
 	if (xprt->tcp_copied >= sizeof(xprt->tcp_xid) || !avail)
 		goto done;
-	want = min(unsigned int, sizeof(xprt->tcp_xid) - xprt->tcp_copied, avail);
+	want = min_t(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;
@@ -771,7 +771,7 @@
 
 	if (req->rq_rlen <= xprt->tcp_copied || !avail)
 		goto done;
-	want = min(unsigned int, req->rq_rlen - xprt->tcp_copied, avail);
+	want = min_t(unsigned int, req->rq_rlen - xprt->tcp_copied, avail);
 	do {
 		dprintk("RPC: %4d TCP receiving %d bytes\n",
 			req->rq_task->tk_pid, want);
@@ -805,7 +805,7 @@
 	int		want, result = 0;
 
 	while (avail) {
-		want = min(unsigned int, avail, sizeof(dummy));
+		want = min_t(unsigned int, avail, sizeof(dummy));
 		riov.iov_base = dummy;
 		riov.iov_len  = want;
 		dprintk("RPC:      TCP skipping %d bytes\n", want);
@@ -1067,7 +1067,7 @@
 
 
 	/* Wait until we have enough socket memory */
-	if (sock_wspace(sk) < min(int, sk->sndbuf,XPRT_MIN_WRITE_SPACE))
+	if (sock_wspace(sk) < min_t(int, sk->sndbuf,XPRT_MIN_WRITE_SPACE))
 		return;
 
 	if (!xprt_test_and_set_wspace(xprt)) {
diff -urN linux-2.4.10-pre7/net/unix/af_unix.c linux/net/unix/af_unix.c
--- linux-2.4.10-pre7/net/unix/af_unix.c	Wed Aug 15 01:22:18 2001
+++ linux/net/unix/af_unix.c	Mon Dec  3 23:09:20 2001
@@ -1336,7 +1336,7 @@
 		 *	fallback size buffer which is under a page and will
 		 *	succeed. [Alan]
 		 */
-		size = min(int, size, skb_tailroom(skb));
+		size = min_t(int, size, skb_tailroom(skb));
 
 		memcpy(UNIXCREDS(skb), &scm->creds, sizeof(struct ucred));
 		if (scm->fp)
@@ -1568,7 +1568,7 @@
 			sunaddr = NULL;
 		}
 
-		chunk = min(unsigned int, skb->len, size);
+		chunk = min_t(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.10-pre7/net/wanrouter/wanproc.c linux/net/wanrouter/wanproc.c
--- linux-2.4.10-pre7/net/wanrouter/wanproc.c	Wed Aug 15 01:22:18 2001
+++ linux/net/wanrouter/wanproc.c	Mon Dec  3 23:09:20 2001
@@ -259,7 +259,7 @@
 		pos = dent->get_info(page, dent->data, 0, 0);
 		offs = file->f_pos;
 		if (offs < pos) {
-			len = min(unsigned int, pos - offs, count);
+			len = min_t(unsigned int, pos - offs, count);
 			if (copy_to_user(buf, (page + offs), len)) {
 				kfree(page);
 				return -EFAULT;
@@ -805,7 +805,7 @@
 		pos = dent->get_info(page, dent->data, 0, 0, 0);
 		offs = file->f_pos;
 		if (offs < pos) {
-			len = min(unsigned int, pos - offs, count);
+			len = min_t(unsigned int, pos - offs, count);
 			if (copy_to_user(buf, (page + offs), len)) {
 				kfree(page);
 				return -EFAULT;
@@ -841,7 +841,7 @@
 		pos = dent->get_info(page, dent->data, 0, 0, 0);
 		offs = file->f_pos;
 		if (offs < pos) {
-			len = min(unsigned int, pos - offs, count);
+			len = min_t(unsigned int, pos - offs, count);
 			memcpy_tofs((void*)buf, (void*)(page + offs), len);
 			file->f_pos += len;
 		}
diff -urN linux-2.4.10-pre7/net/x25/af_x25.c linux/net/x25/af_x25.c
--- linux-2.4.10-pre7/net/x25/af_x25.c	Wed Aug 15 01:22:18 2001
+++ linux/net/x25/af_x25.c	Mon Dec  3 23:09:20 2001
@@ -407,7 +407,7 @@
 			return -ENOPROTOOPT;
 	}
 
-	len = min(unsigned int, len, sizeof(int));
+	len = min_t(unsigned int, len, sizeof(int));
 
 	if (len < 0)
 		return -EINVAL;
