]> git.hungrycats.org Git - linux/commitdiff
v2.4.9.7 -> v2.4.9.8
authorLinus Torvalds <torvalds@athlon.transmeta.com>
Tue, 5 Feb 2002 04:17:27 +0000 (20:17 -0800)
committerLinus Torvalds <torvalds@athlon.transmeta.com>
Tue, 5 Feb 2002 04:17:27 +0000 (20:17 -0800)
  - Christoph Hellwig: clean up personality handling a bit
  - Robert Love: update sysctl/vm documentation
  - make the three-argument (that everybody hates) "min()" be "min_t()",
  and introduce a type-anal "min()" that complains about arguments of
  different types.

168 files changed:
Documentation/sysctl/vm.txt
Makefile
arch/arm/kernel/arthur.c
arch/arm/kernel/traps.c
arch/cris/drivers/usb-host.c
arch/i386/kernel/i386_ksyms.c
arch/i386/kernel/signal.c
arch/i386/lib/Makefile
arch/sparc64/solaris/misc.c
arch/sparc64/solaris/timod.c
drivers/acorn/block/mfmhd.c
drivers/acorn/scsi/acornscsi.c
drivers/block/DAC960.c
drivers/block/acsi.c
drivers/block/amiflop.c
drivers/block/blkpg.c
drivers/block/cciss.c
drivers/block/cpqarray.c
drivers/block/floppy.c
drivers/block/loop.c
drivers/block/nbd.c
drivers/block/paride/pd.c
drivers/block/paride/pf.c
drivers/block/ps2esdi.c
drivers/block/rd.c
drivers/block/xd.c
drivers/char/agp/agpgart_be.c
drivers/char/cyclades.c
drivers/char/dsp56k.c
drivers/char/ppdev.c
drivers/char/rio/riointr.c
drivers/i2o/i2o_block.c
drivers/ide/hd.c
drivers/ide/ide.c
drivers/md/lvm-snap.c
drivers/md/lvm.c
drivers/md/md.c
drivers/mtd/devices/docecc.c
drivers/mtd/ftl.c
drivers/mtd/mtdblock.c
drivers/mtd/mtdblock_ro.c
drivers/mtd/nftlcore.c
drivers/net/acenic.c
drivers/net/de600.c
drivers/net/dgrs.c
drivers/net/hamradio/baycom_epp.c
drivers/net/sk98lin/skproc.c
drivers/net/wan/comx-hw-comx.c
drivers/net/wan/comx-hw-locomx.c
drivers/net/wan/comx-hw-mixcom.c
drivers/net/wan/comx-proto-fr.c
drivers/net/wan/comx-proto-lapb.c
drivers/net/wan/comx.c
drivers/net/wan/cycx_main.c
drivers/net/wan/cycx_x25.c
drivers/net/wan/sbni.c
drivers/net/wan/sdla_chdlc.c
drivers/net/wan/sdla_fr.c
drivers/net/wan/sdla_ppp.c
drivers/net/wan/sdla_x25.c
drivers/net/wan/wanpipe_multppp.c
drivers/net/wireless/airo.c
drivers/s390/block/dasd.c
drivers/s390/block/xpram.c
drivers/s390/net/iucv.c
drivers/s390/net/netiucv.c
drivers/sbus/char/jsflash.c
drivers/scsi/eata_pio.c
drivers/scsi/sd.c
drivers/scsi/sr_ioctl.c
drivers/scsi/sym53c8xx.h
drivers/sound/dmasound/dmasound_atari.c
drivers/sound/dmasound/dmasound_awacs.c
drivers/sound/dmasound/dmasound_paula.c
drivers/sound/dmasound/dmasound_q40.c
drivers/sound/emu10k1/audio.c
drivers/sound/emu10k1/cardwi.c
drivers/sound/emu10k1/cardwo.c
drivers/usb/bluetooth.c
drivers/usb/devio.c
drivers/usb/serial/digi_acceleport.c
drivers/usb/serial/empeg.c
drivers/usb/serial/io_edgeport.c
drivers/usb/serial/io_usbvend.h
drivers/usb/serial/usbserial.c
drivers/usb/serial/visor.c
drivers/usb/storage/datafab.c
drivers/usb/storage/jumpshot.c
drivers/usb/uhci.c
drivers/usb/usb-ohci.c
drivers/usb/usb-uhci.c
fs/adfs/inode.c
fs/attr.c
fs/buffer.c
fs/coda/upcall.c
fs/hfs/file_cap.c
fs/hfs/inode.c
fs/hpfs/inode.c
fs/isofs/rock.c
fs/jffs/inode-v23.c
fs/jffs/intrep.c
fs/namei.c
fs/ncpfs/file.c
fs/ncpfs/inode.c
fs/ncpfs/ioctl.c
fs/ncpfs/mmap.c
fs/ncpfs/ncplib_kernel.c
fs/ncpfs/ncpsign_kernel.c
fs/romfs/inode.c
fs/select.c
fs/smbfs/inode.c
fs/sysv/inode.c
fs/ufs/balloc.c
fs/ufs/truncate.c
fs/ufs/util.c
fs/ufs/util.h
fs/umsdos/inode.c
include/asm-i386/io.h
include/asm-i386/processor.h
include/asm-i386/spinlock.h
include/asm-i386/uaccess.h
include/linux/ac97_codec.h
include/linux/fs.h
include/linux/kernel.h
include/linux/mm.h
include/linux/personality.h
include/linux/sched.h
include/linux/swap.h
include/linux/sysctl.h
include/net/sock.h
include/net/tcp.h
kernel/Makefile
kernel/exec_domain.c
kernel/exit.c
kernel/fork.c
kernel/ksyms.c
mm/memory.c
mm/slab.c
net/appletalk/ddp.c
net/ax25/af_ax25.c
net/core/iovec.c
net/ipv4/ip_sockglue.c
net/ipv4/ipmr.c
net/ipv4/netfilter/ipchains_core.c
net/ipv4/netfilter/ipfwadm_core.c
net/ipv4/route.c
net/ipv4/tcp.c
net/ipv4/tcp_input.c
net/ipv4/tcp_minisocks.c
net/ipv4/tcp_output.c
net/ipv4/tcp_timer.c
net/ipv6/icmp.c
net/ipv6/ipv6_sockglue.c
net/ipv6/ndisc.c
net/ipv6/raw.c
net/ipv6/route.c
net/ipx/af_ipx.c
net/irda/af_irda.c
net/khttpd/datasending.c
net/khttpd/rfc.c
net/khttpd/waitheaders.c
net/netrom/af_netrom.c
net/rose/af_rose.c
net/sched/sch_tbf.c
net/sunrpc/xprt.c
net/unix/af_unix.c
net/wanrouter/wanproc.c
net/x25/af_x25.c

index 1ce29ba11f4304d4e11bb5ac30bd42aff43fa52e..bf9abe829e40d5561e7d51eabd1868e6da5c3599 100644 (file)
@@ -33,32 +33,29 @@ bdflush:
 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 @@ to a clean buffer, which can just be forgotten about).
 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:
 
index d54cbff49b455fcace5993e0493b6145cf6b5a44..2c5a78d3764d02c2df95463fd40ef2838cbcdf6b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 4
 SUBLEVEL = 10
-EXTRAVERSION =-pre7
+EXTRAVERSION =-pre8
 
 KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 
index 8e840106b0562e8ca8015e7b805cbd849290850f..a3c04d65e62c9f14ad36e78cb13cbe3091a9dfff 100644 (file)
@@ -65,7 +65,7 @@ static void arthur_lcall7(int nr, struct pt_regs *regs)
 
 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,
index 5aec58240bcfdd3532efa63f6c87e7f55e387235..a45b4542842bbf213c4435a40ee46bf69f967504 100644 (file)
@@ -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>
index 87bad1b280f209f406edf95309db697905c3c357..51d6f5e8ffd94a27ce6e90e9dc288380545436b1 100644 (file)
@@ -2258,11 +2258,11 @@ static int etrax_rh_submit_urb(urb_t *urb)
        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 @@ static int etrax_rh_submit_urb(urb_t *urb)
                                                   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 @@ static int etrax_rh_submit_urb(urb_t *urb)
                
        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);
                
index 3ebf74d18d3fafebba5216953589e1bffa470826..ef3fb15e7e7a796e761bb3f7e01dc91673a4698e 100644 (file)
@@ -72,7 +72,7 @@ EXPORT_SYMBOL(get_cmos_time);
 EXPORT_SYMBOL(apm_info);
 EXPORT_SYMBOL(gdt);
 
-#ifdef CONFIG_IO_DEBUG
+#ifdef CONFIG_DEBUG_IOVIRT
 EXPORT_SYMBOL(__io_virt_debug);
 #endif
 
index 3c69c51dc0306525874f1860079604170a68ec53..078a157dfe8e1f402c1c04acc8e6c0be9bf6dd10 100644 (file)
@@ -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>
index 74843f3e64791492720c6bc35295bd187df74964..44a12b70502a05ab55061b68095c330db1aba37b 100644 (file)
@@ -13,5 +13,6 @@ obj-y = checksum.o old-checksum.o delay.o \
 
 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
index 8d56b895a834e9aae528327288dcaed1e6f0d983..e30c8f5247ab5ae303ddd6a997b2e92e462697f8 100644 (file)
@@ -709,7 +709,7 @@ extern long solaris_to_linux_signals[], linux_to_solaris_signals[];
 
 struct exec_domain solaris_exec_domain = {
        "Solaris",
-       (lcall7_func)NULL,
+       NULL,
        1, 1,   /* PER_SVR4 personality */
        solaris_to_linux_signals,
        linux_to_solaris_signals,
index 283e0e37c241131c3ec8622343dd72864c7d16df..9b9ccba23f27b86079cbbbca1ec88efac5bec34a 100644 (file)
@@ -699,7 +699,7 @@ int timod_getmsg(unsigned int fd, char *ctl_buf, int ctl_maxlen, s32 *ctl_len,
        }
        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,
index 779a38ab5147e8ad87303646069941d27eaf2c2e..43239b602531ec95bf2f628e2a8fccb86787c76a 100644 (file)
@@ -1210,6 +1210,8 @@ static int mfm_ioctl(struct inode *inode, struct file *file, u_int cmd, u_long a
 
        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))
index 66525f3043746bccda6ef62652a0e0548dc8bb73..9d43392b6cba8d44c246961486aafe659555f358 100644 (file)
@@ -1059,7 +1059,7 @@ void acornscsi_dma_setup(AS_Host *host, dmadir_t direction)
     /*
      * 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 @@ void acornscsi_dma_intr(AS_Host *host)
     /*
      * 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 @@ void acornscsi_message(AS_Host *host)
                 * 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 =
index 1f4b9bce5c727b0acc356b0dc8b56405d3bcde1d..f77ca63e4be1fa78e2682b57ef564645cc78a254 100644 (file)
@@ -5074,10 +5074,12 @@ static int DAC960_IOCTL(Inode_T *Inode, File_T *File,
                           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:
index 6d44e211f1f867725666ebceb0676e02172a8872..7ea29ae90e593195f2c3cf281aecbc7648280e80 100644 (file)
@@ -1138,6 +1138,10 @@ static int acsi_ioctl( struct inode *inode, struct file *file,
                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:
index c322a942fe5e4aeda1527d6ea9b27e74f3110038..36239305ea374aa8ebf02bf0248a33391024a850 100644 (file)
@@ -1556,6 +1556,9 @@ static int fd_ioctl(struct inode *inode, struct file *filp,
        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;
index 166ae2505130694bd6dd2181c690dcacd940829c..63705f54f4da4afd6b0739ab2f18dc257ea1a1bb 100644 (file)
@@ -239,6 +239,7 @@ int blk_ioctl(kdev_t dev, unsigned int cmd, unsigned long arg)
                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;
index 0539f3aa59450c7160e99794545e18fbd4441e1e..341cd09c87e6201c1d58cd771975c60b67cbd674 100644 (file)
@@ -400,9 +400,11 @@ static int cciss_ioctl(struct inode *inode, struct file *filep,
                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);
        case BLKFLSBUF:
index b8ed321cae320432dc14c7e899e2007db9b9f3d1..def052deb126cfd81e7b62492057802b3cffc300 100644 (file)
@@ -1216,9 +1216,9 @@ static int ida_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
        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:
index 297d350b0544c527dcf79fd23c076bc2c3368d1a..941e63c2e59b6b3725ddc004887d585a19796801 100644 (file)
@@ -3497,6 +3497,10 @@ static int fd_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
                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 */
        }
index 8b4d168a5dec6b9acc9806073a5a4692d761eff1..d2b6c8f44752c2ed892d81db8dfc2d50835a7124 100644 (file)
@@ -849,11 +849,14 @@ static int lo_ioctl(struct inode * inode, struct file * file,
                        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:
index f37c95d299c79fdaa0de7320c9aa500e2c0cc19c..09ca5dcd89e1d2aa522001c4230683e7432b5e25 100644 (file)
@@ -446,6 +446,8 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
 #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;
 }
index 43c6510f41cc0fe902a58f98e39fdce8dffc8fc9..0ace2dee0d4e2629ce9fe908d63ceaae40788fc1 100644 (file)
@@ -287,6 +287,7 @@ static void pd_eject( int unit);
 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 @@ void pd_init_units( void )
        }
 }
 
-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 @@ int pd_init (void)
         }
        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 @@ int pd_init (void)
        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 @@ static int pd_ioctl(struct inode *inode,struct file *file,
                 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 @@ void    cleanup_module(void)
 
         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
index e935c00c459b9165e2ab0713d038c419b4b6b730..952631012021cd42288dc5d5702caffe4706561a 100644 (file)
@@ -482,11 +482,9 @@ static int pf_ioctl(struct inode *inode,struct file *file,
                 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:
index 5845927e04abc56613423dfd14b9d923112d10e5..537d2792265071805156f232bd537cc86b5c5142 100644 (file)
@@ -1114,6 +1114,9 @@ static int ps2esdi_ioctl(struct inode *inode,
                        }
                        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;
index 7ccda2a705673e17f8086dd92864c4e741d0a384..73d31e6b62ef835ffdb07914aa92eb80427c2813 100644 (file)
@@ -269,6 +269,9 @@ static int rd_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
                        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:
index 12e4877cedd34abf570548021e57f6ae97a3f60e..5e8b34b035a82e084c44229abbef7c547fbd2d29 100644 (file)
@@ -337,6 +337,8 @@ static int xd_ioctl (struct inode *inode,struct file *file,u_int cmd,u_long arg)
                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;
index 060c63691dda080e04a330313fb5381f2f54d5d0..8669b29e6d61132eb9bcdc65b89ba9998ea276f2 100644 (file)
@@ -437,8 +437,8 @@ static void agp_generic_agp_enable(u32 mode)
                        /* 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 @@ static void serverworks_agp_enable(u32 mode)
                        /* 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 */
index a9c385602cde3498cf79b99b1e4e0f7224b17695..a0a99fe49475e992293e84fea53362fd69a50b66 100644 (file)
@@ -1629,8 +1629,8 @@ cyz_handle_rx(struct cyclades_port *info, volatile struct CH_CTRL *ch_ctrl,
               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 @@ cyz_handle_tx(struct cyclades_port *info, volatile struct CH_CTRL *ch_ctrl,
        }
 #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],
index b438c9c63d8efd75edcc4d5fa52ba5e7a6883898..9eac58218bad00851dced57e6775f1ce3fa88da6 100644 (file)
@@ -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); \
index d4c94cc492f2293c680655a2ee1f5cbc54891b13..8152f7e6b8f71696c3757627fd33f47c3328d7fe 100644 (file)
@@ -118,7 +118,7 @@ static ssize_t pp_read (struct file * file, char * buf, size_t count,
                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 @@ static ssize_t pp_read (struct file * file, char * buf, size_t count,
        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 @@ static ssize_t pp_write (struct file * file, const char * buf, size_t count,
                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 @@ static ssize_t pp_write (struct file * file, const char * buf, size_t count,
        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;
index ad8a70df19f8f39d8c9b3ef482e95a1981c7625d..31297e3e88fafd5e70ac9ce87f856f16f19f7738 100644 (file)
@@ -819,7 +819,7 @@ struct Port *               PortP;
          ** 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);
index 0ec403f178d40977e5384c21ca8d9600bea7d12f..a933eaa57a3516f7921701404366556c27484a35 100644 (file)
@@ -1141,6 +1141,8 @@ static int i2ob_ioctl(struct inode *inode, struct file *file,
        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:
                {
index bdc854f46a3aa3d83933d87fdb9a607bc43dca19..385ac5752f55ae2ecdacacd8f6ee69dea0f1dec4 100644 (file)
@@ -639,9 +639,11 @@ static int hd_ioctl(struct inode * inode, struct file * file,
                }
 
                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))
index c64ba73fcf07baf9aab80a084a15f9539c353fc0..9723d0c5bcd445689f7c6f6eae944859bb8a0852 100644 (file)
@@ -2660,6 +2660,8 @@ static int ide_ioctl (struct inode *inode, struct file *file,
 
                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;
index ed19d45fc89536a1729e5c13c2a38413636fc60c..20e40c022e9056e4a57accab2d395756095410c6 100644 (file)
@@ -386,8 +386,8 @@ int lvm_snapshot_COW(kdev_t org_phys_dev,
 
        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 @@ int lvm_snapshot_COW(kdev_t org_phys_dev,
 
        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 @@ int lvm_snapshot_alloc_hash_table(lv_t * lv)
 
        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);
 
index cb830201c87dc3ee2383956f939d15d202fe08f5..3b758a70c40eb4217dbaf7066bcc1c02d03cb423 100644 (file)
@@ -877,6 +877,11 @@ static int lvm_blk_ioctl(struct inode *inode, struct file *file,
                        return -EFAULT;
                break;
 
+       case BLKGETSIZE64:
+               if (put_user((u64)lv_ptr->lv_size << 9, (u64 *)arg))
+                       return -EFAULT;
+               break;
+
 
        case BLKFLSBUF:
                /* flush buffer cache */
index 3ca62c0b18afcda32b8a3ab5fccc1a8177eaae58..02472fa1410f99766457ff5696fcbf1410021729 100644 (file)
@@ -2478,6 +2478,11 @@ static int md_ioctl (struct inode *inode, struct file *file,
                                                (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:
index f161a130a12fc62cdc728012f7c60558091ac696..3732075548e31534cb6f65444887aaaa592e4419 100644 (file)
@@ -402,7 +402,7 @@ eras_dec_rs(dtype Alpha_to[NN + 1], dtype Index_of[NN + 1],
     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])];
     }
index 02b217399c4a8fd5d03f66c66039cbb90ac51989..8248afd070f75207bdaacf5522749d96bab388fe 100644 (file)
@@ -1174,10 +1174,10 @@ static int ftl_ioctl(struct inode *inode, struct file *file,
        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);
index 132ce13eca040be7535afbac635857956decffc9..e025fb3e7c519bf26d834968c517f8a99b62e8bc 100644 (file)
@@ -529,10 +529,9 @@ static int mtdblock_ioctl(struct inode * inode, struct file * file,
 
        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)
index 1905bd29e79492613817edcd30d4c6502ee2643a..2d2873b6a3c1504461ac031268083fc0b528f6e9 100644 (file)
@@ -211,9 +211,9 @@ static int mtdblock_ioctl(struct inode * inode, struct file * file,
 
        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)
index 4bec8ae8812217cd9b46f19767a0b3f7e91fa39d..ac2c4bf229f693d2c20af4cde754e388184996f0 100644 (file)
@@ -791,9 +791,11 @@ static int nftl_ioctl(struct inode * inode, struct file * file, unsigned int cmd
                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;
index 3b5f6df4f1300d311cba1be4f368be1dae4d6a38..1fb3c1785c7a850e41b751428af83a107010f6b3 100644 (file)
@@ -2995,8 +2995,8 @@ static void __init ace_copy(struct ace_regs *regs, void *src,
                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 @@ static void __init ace_clear(struct ace_regs *regs, u32 dest, int size)
                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);
index d582b16db9369c124b24d034e1401cfec0207450..22314569e65c436cceb5efdc5835d5d1e9da5632 100644 (file)
@@ -814,7 +814,7 @@ de600_rspace(struct sock *sk)
  */
 
        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);
   }
index 7a6f1385cfe89e8fe53be03fd289c25e13f2a47d..a3422c810244633f0e91c66508c66e1a3a432578 100644 (file)
@@ -733,7 +733,7 @@ static int dgrs_start_xmit(struct sk_buff *skb, struct net_device *devN)
                        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;
index 403577fda957aa7fce59cb190b7cca4356f85ecd..e058dd89d3be5ce9a026874a3d7cbadef8503682 100644 (file)
@@ -610,7 +610,7 @@ static int transmit(struct baycom_state *bc, int cnt, unsigned char stat)
        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 @@ static int transmit(struct baycom_state *bc, int cnt, unsigned char stat)
                                        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 @@ static int transmit(struct baycom_state *bc, int cnt, unsigned char stat)
                                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 @@ static int transmit(struct baycom_state *bc, int cnt, unsigned char stat)
                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));
index 1abb4dd124bb84efeeab7be05d692b88b87cdd97..34f853ec857276c7eb94bfd03889cfcc2cc5bff5 100644 (file)
@@ -293,7 +293,7 @@ void *data)
        if (buffer_length >= len - offset) {
                *eof = 1;
        }
-       return (min(int, buffer_length, len - offset));
+       return (min_t(int, buffer_length, len - offset));
 }
 
 
index 86737b11e28a065f59220c8da0d1017963c67703..8bb67edb0fb24d836f562f9088e171417c96f91c 100644 (file)
@@ -1044,7 +1044,7 @@ static int comxhw_write_proc(struct file *file, const char *buffer,
                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 @@ static int comxhw_read_proc(char *page, char **start, off_t off, int count,
                        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 @@ static int comxhw_read_proc(char *page, char **start, off_t off, int count,
        if (count >= len - off) {
                *eof = 1;
        }
-       return min(int, count, len - off);
+       return min_t(int, count, len - off);
 }
 
 /* Called on echo comx >boardtype */
index 4b64939e864e87e2b477a7d10f2cb638a3aac59c..7a9521888a45925a2d821a03ce96b15583be30bf 100644 (file)
@@ -324,7 +324,7 @@ static int locomx_read_proc(char *page, char **start, off_t off, int count,
        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 @@ static int locomx_write_proc(struct file *file, const char *buffer,
                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;
        }
index adf829894ff2f12eafad69c3701078d3af5dc217..9bb74ba06cd4679fd913a6f1b898d3fe8237c058 100644 (file)
@@ -121,7 +121,7 @@ static inline void hscx_fill_fifo(struct net_device *dev)
 
 
        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 @@ static int mixcom_read_proc(char *page, char **start, off_t off, int count,
        }
        *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 @@ static int mixcom_write_proc(struct file *file, const char *buffer,
                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;
        }
index 75ef5c56c9a4b4c210edef83836ae45d954047fb..7929952b03def41c129d04b2f1de29eccd787270 100644 (file)
@@ -634,7 +634,7 @@ static int fr_read_proc(char *page, char **start, off_t off, int count,
 
        *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, 
index 520074f72f949d389d2e44262b8291f0cad69703..a6ed23818c74db6f7bba700fa90665c31ed96bb1 100644 (file)
@@ -212,7 +212,7 @@ static int comxlapb_read_proc(char *page, char **start, off_t off, int count,
        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, 
index 3d4986ea7ca1d86d03b7b1960ed87ffcce2715e7..5e2c5647ac334e103b7b662395c44b38b9a4aa32 100644 (file)
@@ -151,8 +151,8 @@ int comx_debug(struct net_device *dev, char *fmt, ...)
                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 @@ static int comx_read_proc(char *page, char **start, off_t off, int count,
        if (count >= len - off) {
                *eof = 1;
        }
-       return min(int, count, len - off);
+       return min_t(int, count, len - off);
 }
 
 
@@ -597,7 +597,7 @@ static int comx_root_read_proc(char *page, char **start, off_t off, int count,
        if (count >= len - off) {
                *eof = 1;
        }
-       return min(int, count, len - off);
+       return min_t(int, count, len - off);
 }
 
 
index 22ffa2e56a34b8fd97fcded1c192b9b8300e7ba6..c66f3c492eedd2f00b0ad349ebbbcc337791b841 100644 (file)
@@ -111,8 +111,8 @@ int __init cyclomx_init (void)
                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;
index 125a07b7eab2eaec7fb643dda0bd56e8a5c183f3..6699b3e6d40b3a86384b03296651df36576849d8 100644 (file)
@@ -260,13 +260,13 @@ int cyx_init (cycx_t *card, wandev_conf_t *conf)
                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 @@ int cyx_init (cycx_t *card, wandev_conf_t *conf)
        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))
index 157ec0df84bd6b8a01a8fd15b63e8d29d5a01ee7..84a9826147b12169080bc865de8880523c01b4bd 100644 (file)
@@ -659,7 +659,7 @@ download_data( struct net_device  *dev,  u32  *crc_p )
        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 @@ interpret_ack( struct net_device  *dev,  unsigned  ack )
                        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
index 3595ab117fab287e05971fe585d42af6400976ea..06023ffb5dcb05d6c30b0dca2e45224c277680c3 100644 (file)
@@ -506,13 +506,13 @@ int wpc_init (sdla_t* card, wandev_conf_t* conf)
                /* 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 @@ static int new_if (wan_device_t* wandev, netdevice_t* dev, wanif_conf_t* conf)
                        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 @@ static int new_if (wan_device_t* wandev, netdevice_t* dev, wanif_conf_t* conf)
                /* 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
index ac21b5d108d1d9ce544ca3fc7dc51ac2057684d6..3a0e84277d9fbb3f4688c01d8f498ae6a76ed8b5 100644 (file)
@@ -549,10 +549,10 @@ int wpf_init(sdla_t *card, wandev_conf_t *conf)
        /* 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 @@ int wpf_init(sdla_t *card, wandev_conf_t *conf)
                 * 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 @@ int wpf_init(sdla_t *card, wandev_conf_t *conf)
                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 @@ static int new_if (wan_device_t* wandev, netdevice_t* dev, wanif_conf_t* conf)
          */
        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 @@ static int new_if (wan_device_t* wandev, netdevice_t* dev, wanif_conf_t* conf)
                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;
                }
index 66402177f8cc97c487ae62cfd620503d86391d51..e3221f73ed8afed27a570e1303c110704d4498bc 100644 (file)
@@ -401,7 +401,7 @@ int wpp_init(sdla_t *card, wandev_conf_t *conf)
        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 @@ static int new_if(wan_device_t *wandev, netdevice_t *dev, wanif_conf_t *conf)
        
        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
index 1ce92859616a944f2491b7e14656a36c116c9a84..8be7d748ef93ab5f444e2616edf75e9dad43edf5 100644 (file)
@@ -654,13 +654,13 @@ int wpx_init (sdla_t* card, wandev_conf_t* conf)
        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 @@ int wpx_init (sdla_t* card, wandev_conf_t* conf)
        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)
index 17a0f1f3f409be463ff820979abcce4832c54019..59823688dff604ac936643690b87ef39c0cefa63 100644 (file)
@@ -376,13 +376,13 @@ int wsppp_init (sdla_t* card, wandev_conf_t* conf)
                /* 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;
        }
 
index 78b666462b01b2ebc19a052688b8a9548bb7c8bf..595aba251d2e160aed3ad7a8b4cf9faad1fbd185 100644 (file)
@@ -1753,7 +1753,7 @@ static int PC4500_readrid(struct airo_info *ai, u16 rid, void *pBuf, int len)
        // 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 @@ static int readrids(struct net_device *dev, aironet_ioctl *comp) {
         */
 
        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 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) {
                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;
 
index 0a8c1bae7dd59a781da5f5c94ff2558c63028c04..a27159bae3bd6dabe8bdd70d764f4ebec56e7416 100644 (file)
@@ -2175,11 +2175,13 @@ do_dasd_ioctl (struct inode *inp, /* unsigned */ int no, unsigned long data)
        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:{
index c56b72c4a7ba49b008f972496dec7b45701e6e3d..40da008cf41d2d66e9e13a47a682f896037b5474 100644 (file)
@@ -647,14 +647,14 @@ int xpram_ioctl (struct inode *inode, struct file *filp,
 
        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);
index 8b6b662f112425ffc7aa720305f9ea5b315a2cb8..26ea68ce650d0ea7ce99bbbf72bd0f5f800c2266 100644 (file)
@@ -1309,7 +1309,7 @@ iucv_receive (u16 pathid, u32 msgid, u32 trgcls,
                        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 @@ iucv_receive_array (u16 pathid,
 
                        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)),
index 09660e03ac7502546e324dafcd4dba56381ff9a6..7ea2bf79f69141311f4cfd51b9b17c884483528d 100644 (file)
@@ -828,7 +828,7 @@ register_iucv_dev (int devnumber, char *userid)
 
        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);
 
index 21e1a7552c3410a05c4a16b8315ca1b98cdedf24..f0107ea38285f547f1d7e5467bd2652227d12bd4 100644 (file)
@@ -454,6 +454,8 @@ static int jsfd_ioctl(struct inode *inode, struct file *file,
        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:
index 7a070be69aa4562d9a750172c80ea633305ff66b..13e918a23e8c23d007bfb12d910a771281fb1c95 100644 (file)
@@ -161,7 +161,7 @@ void eata_pio_int_handler(int irq, void *dev_id, struct pt_regs * regs)
                            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 @@ void eata_pio_int_handler(int irq, void *dev_id, struct pt_regs * regs)
                            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);
index bea96170a4df640c48136c19c7b25ac8e4fd727f..32d257fa1f926dfdc8248c5f35fe69a59be5a979 100644 (file)
@@ -90,6 +90,7 @@ static Scsi_Disk *rscsi_disks;
 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 @@ static int sd_ioctl(struct inode * inode, struct file * file, unsigned int cmd,
                        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 @@ static int sd_init()
        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_gendisks_de_arr:
 cleanup_sd_gendisks:
        kfree(sd);
 cleanup_sd:
+       kfree(sd_max_sectors);
+cleanup_max_sectors:
        kfree(sd_hardsizes);
 cleanup_blocksizes:
        kfree(sd_blocksizes);
index 6abdd0360e6c636c9042067505dc4677bdfa2e03..f79877af7ae02b873a25f735d83d52e73af1e4e8 100644 (file)
@@ -546,6 +546,8 @@ int sr_dev_ioctl(struct cdrom_device_info *cdi,
        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:
index 32b0fc288fee9452f7779d8f175b08054fc87ac4..63883cd24c2e4f5beeb354ff453ca7d312c72741 100644 (file)
@@ -96,6 +96,7 @@ int sym53c8xx_release(struct Scsi_Host *);
                        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
index 619a3e874c28c59cde774132741c5ecc7ce6306a..343219585a75a5bca9b8b4fbd926cb9ebe937061 100644 (file)
@@ -154,7 +154,7 @@ static ssize_t ata_ct_law(const u_char *userPtr, size_t userCount,
        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 @@ static ssize_t ata_ct_s8(const u_char *userPtr, size_t userCount,
        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 @@ static ssize_t ata_ct_u8(const u_char *userPtr, size_t userCount,
 
        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 @@ static ssize_t ata_ct_u8(const u_char *userPtr, size_t userCount,
                }
        } 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 @@ static ssize_t ata_ct_s16be(const u_char *userPtr, size_t userCount,
 
        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 @@ static ssize_t ata_ct_s16be(const u_char *userPtr, size_t userCount,
                *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 @@ static ssize_t ata_ct_u16be(const u_char *userPtr, size_t userCount,
 
        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 @@ static ssize_t ata_ct_u16be(const u_char *userPtr, size_t userCount,
                *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 @@ static ssize_t ata_ct_s16le(const u_char *userPtr, size_t userCount,
        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 @@ static ssize_t ata_ct_s16le(const u_char *userPtr, size_t userCount,
                *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 @@ static ssize_t ata_ct_u16le(const u_char *userPtr, size_t userCount,
        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 @@ static ssize_t ata_ct_u16le(const u_char *userPtr, size_t userCount,
                *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;
index 9143101a52ea077ef7ed5a8b84e93b79a92f5fc8..166ec6611d05d7963952647fcf491c48ea14e64f 100644 (file)
@@ -267,7 +267,7 @@ static ssize_t pmac_ct_law(const u_char *userPtr, size_t userCount,
        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 @@ static ssize_t pmac_ct_s8(const u_char *userPtr, size_t userCount,
        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 @@ static ssize_t pmac_ct_u8(const u_char *userPtr, size_t userCount,
        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 @@ static ssize_t pmac_ct_s16(const u_char *userPtr, size_t userCount,
 
        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 @@ static ssize_t pmac_ct_u16(const u_char *userPtr, size_t userCount,
 
        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 @@ static ssize_t pmac_ct_s8_read(const u_char *userPtr, size_t userCount,
        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 @@ static ssize_t pmac_ct_u8_read(const u_char *userPtr, size_t userCount,
        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 @@ static ssize_t pmac_ct_s16_read(const u_char *userPtr, size_t userCount,
 
        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 @@ static ssize_t pmac_ct_u16_read(const u_char *userPtr, size_t userCount,
 
        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;
 
index 1ec6382759e52100edc3efefd8cc119f7fd38584..9a9d69401ab70e7c16784292150bcc4739a8521c 100644 (file)
@@ -155,14 +155,14 @@ static ssize_t ami_ct_s8(const u_char *userPtr, size_t userCount,
 
        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 @@ static ssize_t funcname(const u_char *userPtr, size_t userCount,    \
                                                                        \
        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 @@ static ssize_t funcname(const u_char *userPtr, size_t userCount,    \
        } 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 @@ static ssize_t funcname(const u_char *userPtr, size_t userCount,    \
        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 @@ static ssize_t funcname(const u_char *userPtr, size_t userCount,    \
                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)++))     \
index 542935113ecf0341220c51031e90032bc339e434..cca93c04cc9b9c35503b2cad201dcb80429e2c57 100644 (file)
@@ -58,7 +58,7 @@ static ssize_t q40_ct_law(const u_char *userPtr, size_t userCount,
        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 @@ static ssize_t q40_ct_law(const u_char *userPtr, size_t userCount,
        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 @@ static ssize_t q40_ct_s8(const u_char *userPtr, size_t userCount,
        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 @@ static ssize_t q40_ct_s8(const u_char *userPtr, size_t userCount,
        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 @@ static ssize_t q40_ct_u8(const u_char *userPtr, size_t userCount,
        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 @@ static ssize_t q40_ct_u8(const u_char *userPtr, size_t userCount,
        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++))
index dd49c2f4a128fc6c8bd783941f1d4e524094f54e..899bb3cac3c75c80a06945816ae61aca955d12cb 100644 (file)
@@ -115,7 +115,7 @@ static ssize_t emu10k1_audio_read(struct file *file, char *buffer, size_t count,
 
                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 @@ static ssize_t emu10k1_audio_write(struct file *file, const char *buffer, size_t
                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);
 
index 184dcd5a8c8d39b0b34babac4ede02b00786c415..fde98545a1cbf08aaa8ed8bd312a40f75a0861ec 100644 (file)
@@ -325,7 +325,7 @@ void emu10k1_wavein_xferdata(struct wiinst *wiinst, u8 * data, u32 * size)
        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)
index c0191962766308c11726ed9fcbb649603fe7f3a2..9ec4adf565a37ad12d007e97b2a5327b2ff5ab61 100644 (file)
@@ -581,7 +581,7 @@ void emu10k1_waveout_xferdata(struct woinst *woinst, u8 *data, u32 *size)
        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)
index cf88770310856235ee94fb27317193081dd96648..05b00131a37465990f328aac189e2552c2837c05 100644 (file)
@@ -517,7 +517,7 @@ static int bluetooth_write (struct tty_struct * tty, int from_user, const unsign
                                }
                                
 
-                               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 */
index 0a89c09a6eff8ae652419b4e07db3478cfc5d20d..4e89bacb2e4c0218e0777d9fce7e3db7f7532616 100644 (file)
@@ -1082,7 +1082,7 @@ static int proc_ioctl (struct dev_state *ps, void *arg)
                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 */
index 882bbd49255eddb57fd2ebd8d0cc188ef29d3590..4e286f65c869978dabb2bc55308f0cbfa905aeca 100644 (file)
@@ -670,7 +670,7 @@ dbg( "digi_write_oob_command: TOP: port=%d, count=%d", oob_priv->dp_port_num, co
                }
 
                /* 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 @@ count );
                /* 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 @@ dbg( "digi_rx_unthrottle: TOP: port=%d", priv->dp_port_num );
        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 @@ dbg( "digi_write: TOP: port=%d, count=%d, from_user=%d, in_interrupt=%d",
 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 @@ priv->dp_port_num, count, from_user, in_interrupt() );
 
        /* 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 @@ static int digi_read_inb_callback( struct urb *urb )
 
                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 @@ static int digi_read_inb_callback( struct urb *urb )
 
                } 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 );
index d8fe9ce3497ac4e0040c5574f1227a34bc25bd82..c334710448fdfa4b3036833aa61c25ab28fa2232 100644 (file)
@@ -276,7 +276,7 @@ static int empeg_write (struct usb_serial_port *port, int from_user, const unsig
                        }
                }
 
-               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)) {
index 02a17ef2de1d38201b57dae32d0b49ce0c0288b7..7e0b853e3be3be61cecf8b674a914f6a0824cbd2 100644 (file)
@@ -1311,7 +1311,7 @@ static int edge_write (struct usb_serial_port *port, int from_user, const unsign
        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 @@ static int edge_write (struct usb_serial_port *port, int from_user, const unsign
        // 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 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, struct edge
 
        /* 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;
index 3cfac6cf68385ad46da7e7de84d358dc3399cfe6..e76cafd2a688aab908e519f37a7b12bfcc881225 100644 (file)
 
 // 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
index e8a88bcd1fa4ffb265fbce2770e231c024f5b312..8b781a87101892f2e3ffaa1b9024788386065a07 100644 (file)
@@ -1259,9 +1259,9 @@ static void * usb_serial_probe(struct usb_device *dev, unsigned int ifnum,
 
        /* 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];
index 13d2693b4cbaa5fbbb7578d96d6955698cea75f2..5c5b737c204d50223633ec939a714e6aaef8da28 100644 (file)
@@ -441,7 +441,7 @@ static int visor_write (struct usb_serial_port *port, int from_user, const unsig
                        }
                }
                
-               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;
index c98b8caac6800998767e1bb636c9f3eec4d99cc9..5bc78795dd5e4f63e160f4250e0e9350686aef8c 100644 (file)
@@ -204,7 +204,7 @@ static int datafab_read_data(struct us_data *us,
 
        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 @@ static int datafab_write_data(struct us_data *us,
 
        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;
index 9462a601572a96d18c38b80e0b964c5abb2b3dd0..ea05a32ff04c5e8e7be63ddc6f5c0fcdc3151c8d 100644 (file)
@@ -280,7 +280,7 @@ static int jumpshot_read_data(struct us_data *us,
 
        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 @@ static int jumpshot_write_data(struct us_data *us,
 
        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;
index dbba809ff82ee9e0857a5344e1d7a13140995371..ce0237107d00ff62fc0f6f13fe66aacfe08d8e8a 100644 (file)
@@ -2131,14 +2131,14 @@ static int rh_submit_urb(struct urb *urb)
        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 @@ static int rh_submit_urb(struct urb *urb)
                                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:
index dd1c2d0d2f31339ad95ac7686e9e1dc11d505a85..b8b5d07321660635acd1cb76f26bcb87dc843d1d 100644 (file)
@@ -1806,8 +1806,8 @@ static int rh_send_irq (ohci_t * ohci, void * rh_data, int rh_len)
   
        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 @@ static int rh_submit_urb (urb_t * urb)
                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 @@ static int rh_submit_urb (urb_t * urb)
                                                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 @@ static int rh_submit_urb (urb_t * urb)
                                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 @@ static int rh_submit_urb (urb_t * urb)
        // 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;
index 4657eba0bf8129cb7ca833ce3c5831f7439422f0..f5ccb10ea2ca7febe6663b7edf0a965504ee506a 100644 (file)
@@ -2111,14 +2111,14 @@ _static int rh_submit_urb (urb_t *urb)
        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 @@ _static int rh_submit_urb (urb_t *urb)
                                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 @@ _static int rh_submit_urb (urb_t *urb)
 
        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);
 
index 4f033cff6ebcdf5ecd8802b08a7841551021d787..c7b8560104454401ffca9f1d9a94cd5a2cd807a0 100644 (file)
@@ -319,7 +319,11 @@ adfs_notify_change(struct dentry *dentry, struct iattr *attr)
                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);
index cb88697e68b01a3a9d5bd55c31dfad093499d55a..d6a48893696e494ad404c2a11df90b515bf62ebf 100644 (file)
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -57,16 +57,21 @@ error:
        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 @@ void inode_setattr(struct inode * inode, struct iattr * attr)
                        inode->i_mode &= ~S_ISGID;
        }
        mark_inode_dirty(inode);
+out:
+       return error;
 }
 
 static int setattr_mask(unsigned int ia_valid)
index 299c568ab64c4c09a2f24dac4d7205b0d4a3c4e9..03c1907d45f2a99cf76d82bda6e9c41e66b07521 100644 (file)
@@ -103,7 +103,8 @@ static void __refile_buffer(struct buffer_head *);
 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
index dac80dc811cdd1391ba45de27aa59431150b6ebd..e21829beb27c4a2f89dcb997b81474a5c5c5e7e3 100644 (file)
@@ -71,7 +71,7 @@ do {\
 
 #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 venus_lookup(struct super_block *sb, struct ViceFid *fid,
        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 venus_mkdir(struct super_block *sb, struct ViceFid *dirfid,
         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 venus_rename(struct super_block *sb, struct ViceFid *old_fid,
        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 venus_create(struct super_block *sb, struct ViceFid *dirfid,
         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 venus_rmdir(struct super_block *sb, struct ViceFid *dirfid,
         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 venus_remove(struct super_block *sb, struct ViceFid *dirfid,
         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 venus_readlink(struct super_block *sb, struct ViceFid *fid,
         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 venus_link(struct super_block *sb, struct ViceFid *fid,
         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 venus_symlink(struct super_block *sb, struct ViceFid *fid,
         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 @@ int venus_statfs(struct super_block *sb, struct statfs *sfs)
         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);
index 97408841e2a05363ad38a18f1abb9390e0ac2ddf..9dac8cd398280c465ad15c314868b21fc308859e 100644 (file)
@@ -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 *,
index 705d31341a7ef682bdeb871257a395bb0a0d0687..5495cf773c83369603316f3b0adf7734e42b2e03 100644 (file)
@@ -169,7 +169,9 @@ static int __hfs_notify_change(struct dentry *dentry, struct iattr * attr, int k
                        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;
index 653c1f6604310c18f4a815fbf89314ce49897e9a..a4e03e28ef9f07f9ee24708fc88359b1799f8f0b 100644 (file)
@@ -300,10 +300,12 @@ int hpfs_notify_change(struct dentry *dentry, struct iattr *attr)
 {
        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;
 }
index 12142dfd75a43d89a838e6cf67ffa825458bfd3a..f3b9cc98fddf2085ecad028610320d27c71e6bcd 100644 (file)
@@ -454,7 +454,6 @@ int parse_rock_ridge_inode(struct iso_directory_record * de,
    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;
index a480ab70b8800daff3ca538084e14a1875699885..7210319f9756ad2791a53d8bdb180e15da3b3319 100644 (file)
@@ -718,7 +718,7 @@ jffs_readpage(struct file *file, struct page *page)
 
        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 @@ jffs_file_write(struct file *filp, const char *buf, size_t count,
                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 @@ jffs_file_write(struct file *filp, const char *buf, size_t count,
                
                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 @@ jffs_file_write(struct file *filp, const char *buf, size_t count,
 
                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);
        }
index d8d3c90077959210bd80fea98467ecd418396265..96cea613a2230f60374309d409adc6ff86855b7e 100644 (file)
@@ -1609,7 +1609,7 @@ jffs_get_node_data(struct jffs_file *f, struct jffs_node *node,
                  "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 @@ jffs_read_data(struct jffs_file *f, unsigned char *buf, __u32 read_offset,
                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 @@ jffs_delete_data(struct jffs_file *f, struct jffs_node *node)
                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 @@ jffs_rewrite_data(struct jffs_file *f, struct jffs_node *node, int size)
                }
 
                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 @@ jffs_try_to_erase(struct jffs_control *c)
                                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;
                        }
index 16be452df7ca98da4dba811b3a163d7eba9ace14..1e973bc983d14ea9c33f7689c1d359d34ebce6f5 100644 (file)
@@ -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>
index a72ed803d014afdd50023a0950314f8b0e34b9fd..1f70ec451ce709b91eebf3aa5550e9dbdb06684e 100644 (file)
@@ -152,7 +152,7 @@ ncp_file_read(struct file *file, char *buf, size_t count, loff_t *ppos)
        /* 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 @@ ncp_file_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
        }
        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);
 
index 6cb6e863f2e193df150137a83d5bc1ce5646ad0d..1ddf41daabf96a96da54436f7f373b9641b68eff 100644 (file)
@@ -692,7 +692,7 @@ int ncp_notify_change(struct dentry *dentry, struct iattr *attr)
                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;
index 37c87f8b203c96d249e66f5eb11bf368ffcd2887..f10cb81a9713fc025a8aae052acc520a746e2893 100644 (file)
@@ -378,7 +378,7 @@ outrel:
                }
                {
                        struct ncp_objectname_ioctl user;
-                       int outl;
+                       size_t outl;
 
                        if (copy_from_user(&user, 
                                           (struct ncp_objectname_ioctl*)arg,
@@ -448,7 +448,7 @@ outrel:
                }
                {
                        struct ncp_privatedata_ioctl user;
-                       int outl;
+                       size_t outl;
 
                        if (copy_from_user(&user, 
                                           (struct ncp_privatedata_ioctl*)arg,
index ad74d57b8d0b6a4087cb3a4fa7c734298aea726a..7d9bc345d4f0a5d983b25921c69bf23f9061fa93 100644 (file)
@@ -61,7 +61,7 @@ static struct page* ncp_file_mmap_nopage(struct vm_area_struct *area,
 
                        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,
index 3a0fd85d8f73465841bbef573bd6f4e9145ddcb6..58f543cd6939b35609d9e878d7a4070f21b13254 100644 (file)
@@ -127,7 +127,7 @@ ncp_negotiate_buffersize(struct ncp_server *server, int size, int *target)
                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_negotiate_size_and_options(struct ncp_server *server,
        /* 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);
 
index ea8482611fcda6f94d7debce7fb42d3077c75863..7183ba4bcb92a91a5ef56fa81277ffaa696b9021 100644 (file)
@@ -100,7 +100,7 @@ void sign_packet(struct ncp_server *server, int *size) {
  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);
 
index 41e1841d94ab8470af4cf400cf6d7cff5759347c..4d90804e60173514af8462c42ed3a428376202e6 100644 (file)
@@ -124,7 +124,7 @@ romfs_read_super(struct super_block *s, void *data, int silent)
                                "%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 @@ romfs_strnlen(struct inode *i, unsigned long offset, unsigned long count)
                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 @@ romfs_strnlen(struct inode *i, unsigned long offset, unsigned long count)
                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 @@ romfs_copyfrom(struct inode *i, void *dest, unsigned long offset, unsigned long
                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 @@ romfs_copyfrom(struct inode *i, void *dest, unsigned long offset, unsigned long
                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 @@ romfs_readpage(struct file *file, struct page * page)
        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);
index 7d4305cad8f7fcee81befd6d5af30deaa492c48c..b059b905f3f47a141ee4fe8ccd39e4f8694349de 100644 (file)
@@ -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>
index 9337f680dd78844eb96bd5951147ed96386522c7..9bb9b690478a9349a882558a7a2302103f664927 100644 (file)
@@ -544,7 +544,9 @@ smb_notify_change(struct dentry *dentry, struct iattr *attr)
                                         attr->ia_size);
                if (error)
                        goto out;
-               vmtruncate(inode, attr->ia_size);
+               error = vmtruncate(inode, attr->ia_size);
+               if (error)
+                       goto out;
                refresh = 1;
        }
 
index c24f41e2607ef1e0476aca39c4b5c73261b34ba8..afa05292f92e58ebf6fe2d94b7fae75f1eec1d7b 100644 (file)
@@ -198,8 +198,7 @@ int sysv_notify_change(struct dentry *dentry, struct iattr *attr)
                        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)
index 9aa7a9f31fcfea25f1c94a17d6b1855fc7d45ba0..45396e211d787b3259c7de061277e918a01f41ca 100644 (file)
@@ -312,7 +312,7 @@ unsigned ufs_new_fragments (struct inode * inode, u32 * p, unsigned fragment,
                        *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 @@ unsigned ufs_new_fragments (struct inode * inode, u32 * p, unsigned fragment,
        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 @@ unsigned ufs_new_fragments (struct inode * inode, u32 * p, unsigned fragment,
                *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)
index cae11a7cae697be7d5a536dcc5e03f002803fe37..61f608aa78c7fca238ed4b406794b736dc1f9ee1 100644 (file)
@@ -88,7 +88,7 @@ static int ufs_trunc_direct (struct inode * inode)
        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;
index 9380ccbc6b174ab55da7b8631699d06f7728d0d4..06f2cb8d56f56d04f5fde0f0592fe4e2cf33f4fa 100644 (file)
@@ -170,7 +170,7 @@ void _ubh_ubhcpymem_(struct ufs_sb_private_info * uspi,
                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 @@ void _ubh_memcpyubh_(struct ufs_sb_private_info * uspi,
                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;
index a1e5889d0bb51459de14e41524213c77578113c1..1fcefe4cd1110effbb1138598ba8a2c0373982f6 100644 (file)
@@ -331,7 +331,7 @@ static inline unsigned _ubh_find_next_zero_bit_(
        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 @@ static inline unsigned _ubh_find_last_zero_bit_(
        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;
index 9a47f8cd388e923dd1ee80b9a521573460c1965a..f3ccd379ba286c9a6ea013228c5cd5835a57cf78 100644 (file)
@@ -211,7 +211,7 @@ dentry->d_parent->d_name.name, dentry->d_name.name, info.fake.fname));
        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 */
index 55b2886e8181ff7c2635aba6162936cb09b4090c..0b68f5635d228393372ba5aff24f041badf7efd7 100644 (file)
@@ -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 @@ __OUTS(l)
  * 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__)
index 2373655be7384b348e4012055a59a3839b946f6a..a2f9b28d54defdf6338533f8ce26734c31fb2aa6 100644 (file)
@@ -477,4 +477,32 @@ static inline void rep_nop(void)
        __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 */
index 2d6eb04bf05c0eb641e2ed82f2ed2cb17abe57c6..c893aa09ea2dbb4870afa87f65aac6caaea312fe 100644 (file)
@@ -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 @@ extern int printk(const char * fmt, ...)
  * 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
index db7eedb37bea4b52fa9bd2ccd4167d26bef23b8d..7d4a2ab1cc6fd5451ece937b42cd4afef20f33e3 100644 (file)
@@ -126,6 +126,7 @@ extern void __get_user_4(void);
 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 @@ extern void __put_user_bad(void);
        __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 @@ do {                                                                        \
          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)
index e2afb261601a620cdd4d36a27d258890e0523698..96944938fc1814ea2ca6dd4c5417bbe2e75d6a5a 100644 (file)
 #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
 #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 */
 
 /* status */
index 953d87b4e165974add08777b81ddd19bdc89eab2..dfe64dc82c104c5048aa201f2d00297921ee557f 100644 (file)
@@ -167,7 +167,7 @@ extern int leases_enable, dir_notify_enable, lease_break_time;
 #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 @@ extern int leases_enable, dir_notify_enable, lease_break_time;
 /* 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_buffer_fdatasync(struct inode *inode, unsigned long start_idx
 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
index ea28234bd480652554b123af7eb94e584bcf1a15..cd9e83570b0b0e8f9159042b0f99002beaf8103f 100644 (file)
@@ -115,9 +115,32 @@ static inline void console_verbose(void)
        ((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__ */
index d4464136cbe77cc859149fca2fef40fe98702047..9bd982bb876b264b9e2596e1e32cce2b13996234 100644 (file)
@@ -434,7 +434,7 @@ extern int copy_page_range(struct mm_struct *dst, struct mm_struct *src, struct
 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);
index 58cab509e3d7883713da501fc60d235cb8cac431..230d39460364ee1ef5d87fe1b9d01fcfb618ae15 100644 (file)
-#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>
+/*
+ * 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. */
-#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.
+/*
+ * Flags for bug emulation.
+ *
+ * These occupy the top three bytes.
  */
-#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.
+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;
-
-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); \
+/*
+ * 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)
+
+/*
+ * 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 */
index 94957c39b4c3e00ae03e27e53558cea33d2fa30c..594acbc48a3415f6016c0e2cc284ee9677bcca77 100644 (file)
@@ -7,7 +7,6 @@ extern unsigned long event;
 
 #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 @@ extern unsigned long event;
 #include <linux/securebits.h>
 #include <linux/fs_struct.h>
 
+struct exec_domain;
+
 /*
  * cloning flags:
  */
@@ -437,6 +438,12 @@ struct task_struct {
 #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
  * your own risk!. Base=0, limit=0x1fffff (=2MB)
index 26619cf335af9c9086b3d07c190081d7931f4a28..42d464b87ef87ce418a494825deea74d0d9a9f7c 100644 (file)
@@ -256,7 +256,7 @@ extern spinlock_t pagemap_lru_lock;
  * 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))
 
index 413f196ad4d2260df662dcbab20b67a47f29d6bf..0849bd3f617f729a16834a0e46b423a4a885c22e 100644 (file)
@@ -61,7 +61,8 @@ enum
        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: */
@@ -606,6 +607,17 @@ enum {
        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__
 
 extern asmlinkage long sys_sysctl(struct __sysctl_args *);
index 403e842f6d78175e762464cc4931813375c4999c..480f74267d32efe016305b233685e28089dfe8cc 100644 (file)
@@ -1245,7 +1245,7 @@ static inline long sock_sndtimeo(struct sock *sk, int noblock)
 
 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.
index 8edcd920facd97f39bd62e02950e08d6382a14e8..4cb72ebec3f7d26b86e5795e9503d102412769ae 100644 (file)
@@ -919,12 +919,12 @@ static __inline__ unsigned int tcp_current_mss(struct sock *sk)
 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__ int tcp_packets_in_flight(struct tcp_opt *tp)
  */
 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 @@ static inline __u32 tcp_current_ssthresh(struct tcp_opt *tp)
        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 @@ static inline void __tcp_enter_cwr(struct tcp_opt *tp)
 {
        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 @@ static inline void tcp_select_initial_window(int space, __u32 mss,
        /* 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 @@ static inline void tcp_select_initial_window(int space, __u32 mss,
         * 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 @@ static inline void tcp_select_initial_window(int space, __u32 mss,
                        (*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 @@ static inline void tcp_select_initial_window(int space, __u32 mss,
                        *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_enter_memory_pressure(void)
 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);
        }
 }
 
index 9adeb6b2c392916ef3ff180508de1f8cb4895c38..81238b94e91ee2a2623d76c407a2d9b5203ff381 100644 (file)
@@ -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 \
index 1daf64cc19b65a70096ca06ffedfdec617fa33c9..729be6df82bed106fb2d58d540240dc5f09b5734 100644 (file)
@@ -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 struct exec_domain *exec_domains = &default_exec_domain;
+static rwlock_t exec_domains_lock = RW_LOCK_UNLOCKED;
 
 
-static unsigned long ident_map[32] = {
+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 @@ static unsigned long ident_map[32] = {
 };
 
 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);
-
-       if (current->exec_domain && current->exec_domain->handler
-       && current->exec_domain->handler != no_lcall7) {
-               current->exec_domain->handler(segment, regs);
-               return;
+       u_long                  pers = 0;
+
+       /*
+        * 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);
index cd5a8a8034c76ffd2ef7e1686e2a9f89dccd99ca..2832f6e13fbe0635ca660cf0e2012475ab202f91 100644 (file)
@@ -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>
index b692f28c2bf421804244ea0462665849df869a2f..6e94c524b5f216c7e80bd01517e630cbcbef120f 100644 (file)
@@ -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>
index adf90896a0b036f8b348ad3613afe2f0711eeda7..11efff39e261a6c0473297253acdb8a2ed800a95 100644 (file)
@@ -334,11 +334,6 @@ EXPORT_SYMBOL(compute_creds);
 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);
index 8dc197c05e4bce9c0dff58182f95ada09bee299a..0d7bc4538bf0668d2f389704815c8e1afd6c8755 100644 (file)
@@ -1008,7 +1008,7 @@ static void vmtruncate_list(struct vm_area_struct *mpnt, unsigned long pgoff)
  * 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 @@ out_truncate:
                unlock_kernel();
        }
 out:
-       return;
+       return 0;
 }
 
 /* 
index 27cf5e6ffbf89942056411849e77eb3ce559aba7..aa84825d6652a926ecca142fb24fd9cc2ede4ebe 100644 (file)
--- a/mm/slab.c
+++ b/mm/slab.c
  * 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 @@ opps:
        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 @@ static int __kmem_cache_shrink(kmem_cache_t *cachep)
  */
 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);
index 04655f32549458c4df334025db982e66bf6f1ee3..e011a9cc6842f351afe8120ddfc25c81c770e2ba 100644 (file)
@@ -1390,7 +1390,7 @@ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev,
 
        /* 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 @@ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev,
                }
 
                 /* 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 */
index da409ee2094600b28bc6de859cfdd7754b96dd7e..eebfd0c304b720a42e449d26d30bc64d16a7ae47 100644 (file)
@@ -751,7 +751,7 @@ static int ax25_getsockopt(struct socket *sock, int level, int optname, char *op
                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 @@ static int ax25_getsockopt(struct socket *sock, int level, int optname, char *op
 
                        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';
index 50f4395724df740b61a655518db6e1ad58592229..4c701b5ae68ef8423fe6ef2ac4cf222e984dd40a 100644 (file)
@@ -87,7 +87,7 @@ int memcpy_toiovec(struct iovec *iov, unsigned char *kdata, int len)
        {
                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 @@ void memcpy_tokerneliovec(struct iovec *iov, unsigned char *kdata, int len)
        {
                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 @@ int memcpy_fromiovec(unsigned char *kdata, struct iovec *iov, int len)
        {
                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 @@ int memcpy_fromiovecend(unsigned char *kdata, struct iovec *iov, int offset,
        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 @@ int csum_partial_copy_fromiovecend(unsigned char *kdata, struct iovec *iov,
        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. */
index 51b99b08826f0f9c24e7cd4f559c0d86faa146c0..e5e6e606b54b0c8afb14ea45961303ec8dd6b8e2 100644 (file)
@@ -683,7 +683,7 @@ int ip_getsockopt(struct sock *sk, int level, int optname, char *optval, int *op
 
                                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 @@ int ip_getsockopt(struct sock *sk, int level, int optname, char *optval, int *op
                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 @@ int ip_getsockopt(struct sock *sk, int level, int optname, char *optval, int *op
                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))
index bc736375167e177dbd047b08237db630d3b434f2..3fce6c89b9c550a7b381fdaf4f50699bebc63545 100644 (file)
@@ -979,7 +979,7 @@ int ip_mroute_getsockopt(struct sock *sk,int optname,char *optval,int *optlen)
        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;
                
index 186e63ee3cf0ccbcaabff9d59fb0f67797bb0a48..be46649aaca92ed66b89785f3cd673919a5c74a0 100644 (file)
@@ -534,7 +534,7 @@ ip_fw_domatch(struct ip_fwkernel *f,
        }
        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);
 
index d59d540533b277dfd3416d51e6242bff2aff82cf..d92464c4ab3b760a5d6fb9acd217b261f0a6ddde 100644 (file)
@@ -648,7 +648,7 @@ int ip_fw_chk(struct iphdr *ip, struct net_device *rif, __u16 *redirport,
                        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);
index e5432e639c09f7938ffdc37355935b0d2d8a3203..18e306363e3b6be42db367da5fef904491122142 100644 (file)
@@ -515,14 +515,14 @@ static int rt_garbage_collect(void)
                        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 @@ static void rt_set_nexthop(struct rtable *rt, struct fib_result *res, u32 itag)
        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;
index 7f5b961c8a3c27f9d388e3ce178d6dc012b97c6f..1fb788cea75a461219fbe5f7ecc5a2091d8d80e4 100644 (file)
@@ -852,7 +852,7 @@ ssize_t do_tcp_sendpages(struct sock *sk, struct page **pages, int poffset, size
 
                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 @@ int tcp_getsockopt(struct sock *sk, int level, int optname, char *optval,
        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 @@ int tcp_getsockopt(struct sock *sk, int level, int optname, char *optval,
                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))
index 74563cde650ac05cdfc2dc3dd1209e1ece9aa2c6..bdaf248cf950a81da14449160ee18dfbd0e3468c 100644 (file)
@@ -168,7 +168,7 @@ static void tcp_incr_quickack(struct tcp_opt *tp)
        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 @@ static void tcp_fixup_sndbuf(struct sock *sk)
        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 @@ tcp_grow_window(struct sock *sk, struct tcp_opt *tp, struct sk_buff *skb)
                        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 @@ static void tcp_fixup_rcvbuf(struct sock *sk)
        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 @@ static void tcp_init_buffer_space(struct sock *sk)
                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 @@ static void tcp_clamp_window(struct sock *sk, struct tcp_opt *tp)
                    !(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 @@ static void tcp_clamp_window(struct sock *sk, struct tcp_opt *tp)
                        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 @@ static __inline__ void tcp_rtt_estimator(struct tcp_opt *tp, __u32 mrtt)
                /* 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 @@ void tcp_update_metrics(struct sock *sk)
                           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 @@ __u32 tcp_init_cwnd(struct tcp_opt *tp)
        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 @@ static void tcp_init_metrics(struct sock *sk)
                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 @@ reset:
 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 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_
                                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 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_
                                         */
                                        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 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_
                                        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 @@ void tcp_enter_loss(struct sock *sk, int how)
        }
        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 @@ tcp_time_to_recover(struct sock *sk, struct tcp_opt *tp)
         * 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 @@ tcp_time_to_recover(struct sock *sk, struct tcp_opt *tp)
  */
 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 void tcp_update_scoreboard(struct sock *sk, struct tcp_opt *tp)
  */
 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 @@ static void tcp_cwnd_down(struct tcp_opt *tp)
        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 DBGUNDO(struct sock *sk, struct tcp_opt *tp, const char *msg)
 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 @@ static void tcp_undo_cwr(struct tcp_opt *tp, int undo)
                        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 int tcp_try_undo_loss(struct sock *sk, struct tcp_opt *tp)
 
 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 @@ static void tcp_ack_probe(struct sock *sk)
                 */
        } 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 @@ static __inline__ void tcp_dsack_set(struct tcp_opt *tp, u32 seq, u32 end_seq)
                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 @@ static void tcp_sack_maybe_coalesce(struct tcp_opt *tp)
                         * 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 @@ new_sack:
        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 @@ static void tcp_sack_remove(struct tcp_opt *tp)
        }
        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 @@ static void tcp_data_queue(struct sock *sk, struct sk_buff *skb)
 
        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 @@ static void tcp_data_queue(struct sock *sk, struct sk_buff *skb)
                    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 @@ tcp_collapse(struct sock *sk, struct sk_buff *head,
 
                        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 @@ static int tcp_prune_queue(struct sock *sk)
        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 @@ void tcp_cwnd_application_limited(struct sock *sk)
        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 @@ static void tcp_new_space(struct sock *sk)
                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 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb,
 
                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) {
index 701834143a98885903ff20f842af44aec4a34cf9..58246008aa9231df55c6bffe3662355e12b69418 100644 (file)
@@ -766,7 +766,7 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct open_request *req,
                        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;
index f4ec7c94a4005557d51607828720040af7b80a15..42595c91ea265f7978f1e4b2885980632c08b95b 100644 (file)
@@ -105,11 +105,11 @@ static void tcp_cwnd_restart(struct tcp_opt *tp)
        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 @@ int tcp_sync_mss(struct sock *sk, u32 pmtu)
 
        /* 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 @@ u32 __tcp_select_window(struct sock *sk)
         */
        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 @@ u32 __tcp_select_window(struct sock *sk)
                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 @@ int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb)
        /* 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 @@ void tcp_send_delayed_ack(struct sock *sk)
                 * 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 @@ int tcp_write_wakeup(struct sock *sk)
                         */
                        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 @@ void tcp_send_probe0(struct sock *sk)
                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 @@ void tcp_send_probe0(struct sock *sk)
                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));
        }
 }
index 421bfef2e4273d720a793313c805a4a94f881522..70e6d7a4574ac6997862a6bd0271a843d992b2c9 100644 (file)
@@ -248,7 +248,7 @@ static void tcp_delack_timer(unsigned long data)
        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 @@ static void tcp_retransmit_timer(struct sock *sk)
                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 @@ static void tcp_retransmit_timer(struct sock *sk)
        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 @@ static void tcp_synack_timer(struct sock *sk)
 
                                        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;
index 8986d989134de4a74d8357849d2ea87f1b6586b4..962b9d908ce8637425f794f035445b3c4dfcae6c 100644 (file)
@@ -366,7 +366,7 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
        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())
index 81b5341eeb81fdbf927656cef96148596f4a2068..81e61c050ca90d46196b41035de7a237dbf62b75 100644 (file)
@@ -535,7 +535,7 @@ int ipv6_getsockopt(struct sock *sk, int level, int optname, char *optval,
                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))
index 2812b12b206651c55cc88d6dc70ee574ceac66c6..002f3f45377253795546ed6118d4983b7ced8d08 100644 (file)
@@ -846,7 +846,7 @@ void ndisc_send_redirect(struct sk_buff *skb, struct neighbour *neigh,
                }
        }
 
-       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;
index cb144410d15edc1df55303545095b12ccf0cdad1..6e1ff164bc84459333a84d9274734588a0c36780 100644 (file)
@@ -699,7 +699,7 @@ static int rawv6_getsockopt(struct sock *sk, int level, int optname,
                return -ENOPROTOOPT;
        }
 
-       len = min(unsigned int, sizeof(int), len);
+       len = min_t(unsigned int, sizeof(int), len);
 
        if (put_user(len, optlen))
                return -EFAULT;
index 2448e18f909845eb159590ffbc480cf0d24c9251..435fcce69320c080a55fc42cb254f0f44eaba9c3 100644 (file)
@@ -785,7 +785,7 @@ int ip6_route_add(struct in6_rtmsg *rtmsg)
 
 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 @@ source_ok:
        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 @@ int ip6_rt_addr_add(struct in6_addr *addr, struct net_device *dev)
        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 @@ static int rt6_mtu_change_route(struct rt6_info *rt, void *p_arg)
            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;
index 36df373aa1bb41cfd6a5deff102e0de64fa8bfd8..59702dfdfa935fffa75c9ccaf1c46c5db45e1d85 100644 (file)
@@ -1890,7 +1890,7 @@ static int ipx_getsockopt(struct socket *sock, int level, int optname,
        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;
index eda8cc357d6162dcc5b117ae0b5632e5ab4438e6..752178b6098febc2444efd6f3803e77619d748d1 100644 (file)
@@ -1400,7 +1400,7 @@ static int irda_recvmsg_stream(struct socket *sock, struct msghdr *msg,
                        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)
index b0f58dca0006df837ea66337c6ed5287e7f03cf8..91d57f90734b48e519164da8f87b61cc9cce9e03 100644 (file)
@@ -105,8 +105,8 @@ int DataSending(const int CPUNR)
                
                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)
                {                       
index 6070ef56340607577fe246c811d998847b7bddb2..9c570b32bc34130a0e9a22e9ce47ef2d2625d44d 100644 (file)
@@ -326,9 +326,9 @@ void ParseHeader(char *Buffer,const int length, struct http_request *Head)
                        
                        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 @@ void ParseHeader(char *Buffer,const int length, struct http_request *Head)
                {
                        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 @@ void ParseHeader(char *Buffer,const int length, struct http_request *Head)
                {
                        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 @@ void ParseHeader(char *Buffer,const int length, struct http_request *Head)
                {
                        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;
index 1d49822b7400f2ce7e3329086b4b8ba205166ab6..a4d39da4a2c305ef7d2eba6140be677b4aa63279 100644 (file)
@@ -244,7 +244,7 @@ static int DecodeHeader(const int CPUNR, struct http_request *Request)
                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 */
 
index 42d07092f9342a44b625d3a5c85d8a41de320df8..f37bb2433e26e4dccae079d7bdc3bb920936873d 100644 (file)
@@ -435,7 +435,7 @@ static int nr_getsockopt(struct socket *sock, int level, int optname,
                        return -ENOPROTOOPT;
        }
 
-       len = min(unsigned int, len, sizeof(int));
+       len = min_t(unsigned int, len, sizeof(int));
 
        if (put_user(len, optlen))
                return -EFAULT;
index dd554124a876501cb1e633cdc83e8ae00e41452e..c3fea8fe74cf302b7dd22fe9aeb1759c5f32a1bb 100644 (file)
@@ -508,7 +508,7 @@ static int rose_getsockopt(struct socket *sock, int level, int optname,
                        return -ENOPROTOOPT;
        }
 
-       len = min(unsigned int, len, sizeof(int));
+       len = min_t(unsigned int, len, sizeof(int));
 
        if (put_user(len, optlen))
                return -EFAULT;
index 7c8aea21c5c943c42e4c638a616a95eceabe142e..dde3d0ddf28f0757e1f141b0d5708381aa1a0025 100644 (file)
@@ -227,7 +227,7 @@ tbf_dequeue(struct Qdisc* sch)
                }
 
                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;
index 39e9afa70a6099086ff694148fe9e5a4a2cc9cc7..0f189f8d6f891c0f0d35481a1e439742e388bdb7 100644 (file)
@@ -744,7 +744,7 @@ tcp_read_xid(struct rpc_xprt *xprt, int avail)
 
        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 @@ tcp_read_request(struct rpc_xprt *xprt, struct rpc_rqst *req, int avail)
 
        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 @@ tcp_read_discard(struct rpc_xprt *xprt, int avail)
        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 @@ udp_write_space(struct sock *sk)
 
 
        /* 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)) {
index 728548457cd1ea642faa6fc87a48b21201ae2cee..cc6cf6ad8dafe22c6fddb8c5cb0e75b06e0a57ea 100644 (file)
@@ -1336,7 +1336,7 @@ static int unix_stream_sendmsg(struct socket *sock, struct msghdr *msg, int len,
                 *      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 @@ static int unix_stream_recvmsg(struct socket *sock, struct msghdr *msg, int size
                        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)
index 92156ea3086a4c1916e96371c94f13667ef7959e..14cf0257f28c727cceb4ccc058dc81fd6004743d 100644 (file)
@@ -259,7 +259,7 @@ typedef struct wan_stat_entry
                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 @@ typedef struct wan_stat_entry
                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 @@ typedef struct wan_stat_entry
                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;
                }
index 95f1037061ec9a3bd3e9cbf0e299f3986937ed15..d2336b8bbe61dc3358d081fec68208a5a1533f94 100644 (file)
@@ -407,7 +407,7 @@ static int x25_getsockopt(struct socket *sock, int level, int optname,
                        return -ENOPROTOOPT;
        }
 
-       len = min(unsigned int, len, sizeof(int));
+       len = min_t(unsigned int, len, sizeof(int));
 
        if (len < 0)
                return -EINVAL;